summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-05-13 14:41:12 -0400
committerChris Michael <cp.michael@samsung.com>2015-05-13 14:42:15 -0400
commitbcf3b442dd3f4683dd6b634615ed6563e7a2c9d1 (patch)
treee2cb663e99a694f8d303a78c2176ad6302427f9f /src/lib/ecore_drm
parentd9b59f34d2bba43ba6b352789042199b9f746c47 (diff)
ecore-drm: Add API function to set a new mode on an output
Summary: This adds a new API function (ecore_drm_output_mode_set) that we can use from within RandR code to set the resolution of an output (or disable an output if NULL is passed in). @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.h17
-rw-r--r--src/lib/ecore_drm/ecore_drm_output.c48
2 files changed, 65 insertions, 0 deletions
diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h
index b26efa1ede..47c60048cf 100644
--- a/src/lib/ecore_drm/Ecore_Drm.h
+++ b/src/lib/ecore_drm/Ecore_Drm.h
@@ -923,6 +923,23 @@ EAPI Ecore_Drm_Output *ecore_drm_device_output_name_find(Ecore_Drm_Device *dev,
923 */ 923 */
924EAPI Eina_Bool ecore_drm_output_possible_crtc_get(Ecore_Drm_Output *output, unsigned int crtc); 924EAPI Eina_Bool ecore_drm_output_possible_crtc_get(Ecore_Drm_Output *output, unsigned int crtc);
925 925
926/**
927 * Set a given mode to be used on an Ecore_Drm_Output
928 *
929 * This function will set the given mode to be used on a given Ecore_Drm_Output
930 *
931 * @param output The Ecore_Drm_Output to set the mode on
932 * @param mode A valid Ecore_Drm_Output_Mode to set or NULL to disable the output
933 * @param X The X position to set this output to
934 * @param Y The Y position to set this output to
935 *
936 * @return EINA_TRUE on success, EINA_FALSE on failure
937 *
938 * @ingroup Ecore_Drm_Output_Group
939 * @since 1.15
940 */
941EAPI Eina_Bool ecore_drm_output_mode_set(Ecore_Drm_Output *output, Ecore_Drm_Output_Mode *mode, int x, int y);
942
926# ifdef __cplusplus 943# ifdef __cplusplus
927} 944}
928# endif 945# endif
diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c
index b2dbdfd932..276b74f100 100644
--- a/src/lib/ecore_drm/ecore_drm_output.c
+++ b/src/lib/ecore_drm/ecore_drm_output.c
@@ -1414,3 +1414,51 @@ next:
1414 1414
1415 return ret; 1415 return ret;
1416} 1416}
1417
1418EAPI Eina_Bool
1419ecore_drm_output_mode_set(Ecore_Drm_Output *output, Ecore_Drm_Output_Mode *mode, int x, int y)
1420{
1421 Ecore_Drm_Device *dev;
1422 Eina_Bool ret = EINA_TRUE;
1423 unsigned int buffer = 0;
1424
1425 EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE);
1426 EINA_SAFETY_ON_NULL_RETURN_VAL(output->dev, EINA_FALSE);
1427
1428 dev = output->dev;
1429
1430 output->x = x;
1431 output->y = y;
1432 output->current_mode = mode;
1433
1434 if ((mode) && (output->enabled))
1435 {
1436 if (dev->current)
1437 buffer = dev->current->id;
1438 else if (dev->next)
1439 buffer = dev->next->id;
1440 else
1441 buffer = output->crtc->buffer_id;
1442
1443 if (drmModeSetCrtc(dev->drm.fd, output->crtc_id, buffer,
1444 output->x, output->y,
1445 &output->conn_id, 1, &mode->info) < 0)
1446 {
1447 ERR("Failed to set Mode %dx%d for Output %s: %m",
1448 mode->width, mode->height, output->name);
1449 ret = EINA_FALSE;
1450 }
1451 }
1452 else
1453 {
1454 if (drmModeSetCrtc(dev->drm.fd, output->crtc_id,
1455 0, 0, 0, 0, 0, NULL) < 0)
1456 {
1457 ERR("Failed to set Mode %dx%d for Output %s: %m",
1458 mode->width, mode->height, output->name);
1459 ret = EINA_FALSE;
1460 }
1461 }
1462
1463 return ret;
1464}