Skip to content

Commit f81338a

Browse files
chandra4codedanvet
authored andcommitted
drm: Adding drm helper function drm_plane_from_index().
Adding drm helper function to return plane pointer from index where index is a returned by drm_plane_index. v2: -avoided nested loop by adding loop count (Daniel) v3: -updated patch header prefix to 'drm' (Matt) v4: -fixed a kerneldoc issue (kbuild-internal) Cc: [email protected] Signed-off-by: Chandra Konduru <[email protected]> Reviewed-by: Matt Roper <[email protected]> Acked-by: Dave Airlie <[email protected]> Signed-off-by: Daniel Vetter <[email protected]>
1 parent 595e1ee commit f81338a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,29 @@ unsigned int drm_plane_index(struct drm_plane *plane)
12851285
}
12861286
EXPORT_SYMBOL(drm_plane_index);
12871287

1288+
/**
1289+
* drm_plane_from_index - find the registered plane at an index
1290+
* @dev: DRM device
1291+
* @idx: index of registered plane to find for
1292+
*
1293+
* Given a plane index, return the registered plane from DRM device's
1294+
* list of planes with matching index.
1295+
*/
1296+
struct drm_plane *
1297+
drm_plane_from_index(struct drm_device *dev, int idx)
1298+
{
1299+
struct drm_plane *plane;
1300+
unsigned int i = 0;
1301+
1302+
list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
1303+
if (i == idx)
1304+
return plane;
1305+
i++;
1306+
}
1307+
return NULL;
1308+
}
1309+
EXPORT_SYMBOL(drm_plane_from_index);
1310+
12881311
/**
12891312
* drm_plane_force_disable - Forcibly disable a plane
12901313
* @plane: plane to disable

include/drm/drm_crtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,7 @@ extern int drm_plane_init(struct drm_device *dev,
12641264
bool is_primary);
12651265
extern void drm_plane_cleanup(struct drm_plane *plane);
12661266
extern unsigned int drm_plane_index(struct drm_plane *plane);
1267+
extern struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx);
12671268
extern void drm_plane_force_disable(struct drm_plane *plane);
12681269
extern int drm_plane_check_pixel_format(const struct drm_plane *plane,
12691270
u32 format);

0 commit comments

Comments
 (0)