aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_crtc.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-07-29 07:47:11 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-08-08 11:46:03 -0400
commit10f637bf292ba501f9b9e9df6dfe21d8fa521fbd (patch)
treeda589badae4cc719b586c01b8ed5a305efa87045 /drivers/gpu/drm/drm_crtc.c
parente6ae8687a87b1fe5c25e824c8ad300f5587eb622 (diff)
drm: Add drm_plane/connector_index
In the atomic state we'll have an array of states for crtcs, planes and connectors and need to be able to at them by their index. We already have a drm_crtc_index function so add the missing ones for planes and connectors. If it later on turns out that the list walking is too expensive we can add the index to the relevant modeset objects. Rob Clark doesn't like the loops too much, but we can always add an obj->idx parameter later on. And for now reiterating is actually safer since nowadays we have hotpluggable connectors (thanks to DP MST). v2: Fix embarrassing copypasta fail in kerneldoc and header declarations, spotted by Matt Roper. Cc: Matt Roper <matthew.d.roper@intel.com> Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r--drivers/gpu/drm/drm_crtc.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 66d3bfb8d264..f3ef461deeb8 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1022,6 +1022,29 @@ void drm_connector_cleanup(struct drm_connector *connector)
1022EXPORT_SYMBOL(drm_connector_cleanup); 1022EXPORT_SYMBOL(drm_connector_cleanup);
1023 1023
1024/** 1024/**
1025 * drm_connector_index - find the index of a registered connector
1026 * @connector: connector to find index for
1027 *
1028 * Given a registered connector, return the index of that connector within a DRM
1029 * device's list of connectors.
1030 */
1031unsigned int drm_connector_index(struct drm_connector *connector)
1032{
1033 unsigned int index = 0;
1034 struct drm_connector *tmp;
1035
1036 list_for_each_entry(tmp, &connector->dev->mode_config.connector_list, head) {
1037 if (tmp == connector)
1038 return index;
1039
1040 index++;
1041 }
1042
1043 BUG();
1044}
1045EXPORT_SYMBOL(drm_connector_index);
1046
1047/**
1025 * drm_connector_register - register a connector 1048 * drm_connector_register - register a connector
1026 * @connector: the connector to register 1049 * @connector: the connector to register
1027 * 1050 *
@@ -1326,6 +1349,29 @@ void drm_plane_cleanup(struct drm_plane *plane)
1326EXPORT_SYMBOL(drm_plane_cleanup); 1349EXPORT_SYMBOL(drm_plane_cleanup);
1327 1350
1328/** 1351/**
1352 * drm_plane_index - find the index of a registered plane
1353 * @plane: plane to find index for
1354 *
1355 * Given a registered plane, return the index of that CRTC within a DRM
1356 * device's list of planes.
1357 */
1358unsigned int drm_plane_index(struct drm_plane *plane)
1359{
1360 unsigned int index = 0;
1361 struct drm_plane *tmp;
1362
1363 list_for_each_entry(tmp, &plane->dev->mode_config.plane_list, head) {
1364 if (tmp == plane)
1365 return index;
1366
1367 index++;
1368 }
1369
1370 BUG();
1371}
1372EXPORT_SYMBOL(drm_plane_index);
1373
1374/**
1329 * drm_plane_force_disable - Forcibly disable a plane 1375 * drm_plane_force_disable - Forcibly disable a plane
1330 * @plane: plane to disable 1376 * @plane: plane to disable
1331 * 1377 *