diff options
author | Chris Michael <cpmichael@osg.samsung.com> | 2016-05-11 09:29:48 -0400 |
---|---|---|
committer | Chris Michael <cpmichael@osg.samsung.com> | 2016-05-27 11:57:53 -0400 |
commit | a6b018a2a8283e9244182152cc9187db818b7b63 (patch) | |
tree | afbd91e5711cb3f8d0b53f90e858201b62052154 | |
parent | 55f228a238ed93fa3e18af8531691371ce96eb36 (diff) | |
download | efl-a6b018a2a8283e9244182152cc9187db818b7b63.tar.gz |
ecore-drm2: Add API function to set the mode of an output
Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
-rw-r--r-- | src/lib/ecore_drm2/Ecore_Drm2.h | 15 | ||||
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2_outputs.c | 43 |
2 files changed, 58 insertions, 0 deletions
diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h index 508c0fd91f..df07a3316e 100644 --- a/src/lib/ecore_drm2/Ecore_Drm2.h +++ b/src/lib/ecore_drm2/Ecore_Drm2.h @@ -480,6 +480,21 @@ EAPI const Eina_List *ecore_drm2_output_modes_get(Ecore_Drm2_Output *output); EAPI void ecore_drm2_output_mode_info_get(Ecore_Drm2_Output_Mode *mode, int *w, int *h, unsigned int *refresh, unsigned int *flags); /** + * Set a given mode to be used on a given output + * + * @param output + * @param mode + * @param x + * @param y + * + * @return EINA_TRUE on success, EINA_FALSE otherwise + * + * @ingroup Ecore_Drm2_Output_Group + * @since 1.18 + */ +EAPI Eina_Bool ecore_drm2_output_mode_set(Ecore_Drm2_Output *output, Ecore_Drm2_Output_Mode *mode, int x, int y); + +/** * @defgroup Ecore_Drm2_Fb_Group Drm framebuffer functions * * Functions that deal with setup of framebuffers diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c b/src/lib/ecore_drm2/ecore_drm2_outputs.c index 0f89fe748a..4a4fe0bd99 100644 --- a/src/lib/ecore_drm2/ecore_drm2_outputs.c +++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c @@ -989,3 +989,46 @@ ecore_drm2_output_mode_info_get(Ecore_Drm2_Output_Mode *mode, int *w, int *h, un if (refresh) *refresh = mode->refresh; if (flags) *flags = mode->flags; } + +EAPI Eina_Bool +ecore_drm2_output_mode_set(Ecore_Drm2_Output *output, Ecore_Drm2_Output_Mode *mode, int x, int y) +{ + Eina_Bool ret = EINA_TRUE; + unsigned int buffer = 0; + + EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE); + EINA_SAFETY_ON_TRUE_RETURN_VAL((output->fd < 0), EINA_FALSE); + + output->x = x; + output->y = y; + output->current_mode = mode; + + if (mode) + { + if (output->current) + buffer = output->current->id; + else if (output->next) + buffer = output->next->id; + else + buffer = output->ocrtc->buffer_id; + + if (drmModeSetCrtc(output->fd, output->crtc_id, buffer, + x, 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(output->fd, output->crtc_id, 0, + 0, 0, 0, 0, NULL) < 0) + { + ERR("Failed to turn off Output %s: %m", output->name); + ret = EINA_FALSE; + } + } + + return ret; +} |