devilhorns pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=bcf3b442dd3f4683dd6b634615ed6563e7a2c9d1
commit bcf3b442dd3f4683dd6b634615ed6563e7a2c9d1 Author: Chris Michael <cp.mich...@samsung.com> Date: Wed May 13 14:41:12 2015 -0400 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.mich...@samsung.com> --- src/lib/ecore_drm/Ecore_Drm.h | 17 +++++++++++++ src/lib/ecore_drm/ecore_drm_output.c | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index b26efa1..47c6004 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, */ EAPI Eina_Bool ecore_drm_output_possible_crtc_get(Ecore_Drm_Output *output, unsigned int crtc); +/** + * Set a given mode to be used on an Ecore_Drm_Output + * + * This function will set the given mode to be used on a given Ecore_Drm_Output + * + * @param output The Ecore_Drm_Output to set the mode on + * @param mode A valid Ecore_Drm_Output_Mode to set or NULL to disable the output + * @param X The X position to set this output to + * @param Y The Y position to set this output to + * + * @return EINA_TRUE on success, EINA_FALSE on failure + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI Eina_Bool ecore_drm_output_mode_set(Ecore_Drm_Output *output, Ecore_Drm_Output_Mode *mode, int x, int y); + # ifdef __cplusplus } # endif diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index b2dbdfd..276b74f 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -1414,3 +1414,51 @@ next: return ret; } + +EAPI Eina_Bool +ecore_drm_output_mode_set(Ecore_Drm_Output *output, Ecore_Drm_Output_Mode *mode, int x, int y) +{ + Ecore_Drm_Device *dev; + Eina_Bool ret = EINA_TRUE; + unsigned int buffer = 0; + + EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(output->dev, EINA_FALSE); + + dev = output->dev; + + output->x = x; + output->y = y; + output->current_mode = mode; + + if ((mode) && (output->enabled)) + { + if (dev->current) + buffer = dev->current->id; + else if (dev->next) + buffer = dev->next->id; + else + buffer = output->crtc->buffer_id; + + if (drmModeSetCrtc(dev->drm.fd, output->crtc_id, buffer, + output->x, output->y, + &output->conn_id, 1, &mode->info) < 0) + { + ERR("Failed to set Mode %dx%d for Output %s: %m", + mode->width, mode->height, output->name); + ret = EINA_FALSE; + } + } + else + { + if (drmModeSetCrtc(dev->drm.fd, output->crtc_id, + 0, 0, 0, 0, 0, NULL) < 0) + { + ERR("Failed to set Mode %dx%d for Output %s: %m", + mode->width, mode->height, output->name); + ret = EINA_FALSE; + } + } + + return ret; +} --