summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-05-11 12:37:24 -0400
committerChris Michael <cp.michael@samsung.com>2015-05-12 08:57:47 -0400
commit8a3441dfe9f2c59586498b41cc87fc26288b7d06 (patch)
tree26b9e3fac1f5cb012f3e529758ac7759db9eb65b /src/lib/ecore_drm
parent22ef03cd5332cb5687b6398fb696292e3d0f7ae7 (diff)
ecore-drm: Add API function to test if an output can go on a given crtc
Summary: This adds a new API function to test if a given Ecore_Drm_Output can be used on a given crtc. This is needed for DRM RandR support @feature Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_drm')
-rw-r--r--src/lib/ecore_drm/Ecore_Drm.h16
-rw-r--r--src/lib/ecore_drm/ecore_drm_output.c64
2 files changed, 80 insertions, 0 deletions
diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h
index 481da42f15..f468b56c3f 100644
--- a/src/lib/ecore_drm/Ecore_Drm.h
+++ b/src/lib/ecore_drm/Ecore_Drm.h
@@ -906,6 +906,22 @@ EAPI void ecore_drm_output_crtc_size_get(Ecore_Drm_Output *output, int *width, i
906 */ 906 */
907EAPI Ecore_Drm_Output *ecore_drm_device_output_name_find(Ecore_Drm_Device *dev, const char *name); 907EAPI Ecore_Drm_Output *ecore_drm_device_output_name_find(Ecore_Drm_Device *dev, const char *name);
908 908
909/**
910 * Get if an Ecore_Drm_Output can be used on a given crtc
911 *
912 * This function will loop the possible crtcs of an encoder to determine if
913 * a given output can be assigned to a given crtc
914 *
915 * @param output The Ecore_Drm_Output to test if can be used on crtc
916 * @param crtc The crtc to test an Ecore_Drm_Output against
917 *
918 * @return EINA_TRUE if the output can be assigned to given crtc, EINA_FALSE otherwise
919 *
920 * @ingroup Ecore_Drm_Output_Group
921 * @since 1.15
922 */
923EAPI Eina_Bool ecore_drm_output_possible_crtc_get(Ecore_Drm_Output *output, unsigned int crtc);
924
909# ifdef __cplusplus 925# ifdef __cplusplus
910} 926}
911# endif 927# endif
diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c
index 25965383c5..a76a8ece72 100644
--- a/src/lib/ecore_drm/ecore_drm_output.c
+++ b/src/lib/ecore_drm/ecore_drm_output.c
@@ -1291,3 +1291,67 @@ ecore_drm_output_crtc_size_get(Ecore_Drm_Output *output, int *width, int *height
1291 if (width) *width = output->crtc->width; 1291 if (width) *width = output->crtc->width;
1292 if (height) *height = output->crtc->height; 1292 if (height) *height = output->crtc->height;
1293} 1293}
1294
1295EAPI Eina_Bool
1296ecore_drm_output_possible_crtc_get(Ecore_Drm_Output *output, unsigned int crtc)
1297{
1298 Ecore_Drm_Device *dev;
1299 drmModeRes *res;
1300 drmModeConnector *conn;
1301 drmModeEncoder *enc;
1302 int i, j;
1303 unsigned int p;
1304 Eina_Bool ret = EINA_FALSE;
1305
1306 EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE);
1307 EINA_SAFETY_ON_NULL_RETURN_VAL(output->dev, EINA_FALSE);
1308
1309 dev = output->dev;
1310 EINA_SAFETY_ON_TRUE_RETURN_VAL(dev->drm.fd < 0, EINA_FALSE);
1311
1312 /* get the resources */
1313 if (!(res = drmModeGetResources(dev->drm.fd)))
1314 {
1315 ERR("Could not get resources for drm card: %m");
1316 return EINA_FALSE;
1317 }
1318
1319 for (i = 0; i < res->count_connectors; i++)
1320 {
1321 /* get the connector */
1322 if (!(conn = drmModeGetConnector(dev->drm.fd, res->connectors[i])))
1323 continue;
1324
1325 for (j = 0; j < conn->count_encoders; j++)
1326 {
1327 /* get the encoder on this connector */
1328 if (!(enc = drmModeGetEncoder(dev->drm.fd, conn->encoders[j])))
1329 {
1330 WRN("Failed to get encoder: %m");
1331 continue;
1332 }
1333
1334 /* get the encoder for given crtc */
1335 if (enc->crtc_id != crtc) goto next;
1336
1337 p = enc->possible_crtcs;
1338
1339 /* Does the CRTC match the list of possible CRTCs from the encoder? */
1340 if (p & (1 << output->crtc_id))
1341 ret = EINA_TRUE;
1342
1343next:
1344 drmModeFreeEncoder(enc);
1345 if (ret) break;
1346 }
1347
1348 /* free the connector */
1349 drmModeFreeConnector(conn);
1350 if (ret) break;
1351 }
1352
1353 /* free resources */
1354 drmModeFreeResources(res);
1355
1356 return ret;
1357}