diff options
author | Chris Michael <cp.michael@samsung.com> | 2015-04-07 11:41:21 -0400 |
---|---|---|
committer | Boram Park <boram1288.park@samsung.com> | 2015-04-29 07:44:21 +0900 |
commit | e9f22c28a0fb06ae4335c15b8a1cef058ba6d165 (patch) | |
tree | b9d69e4a34137429b0a865b7235d7ad32e5004dc | |
parent | dbed58f9a5144397e8031aa378e202f861fcba26 (diff) | |
download | efl-e9f22c28a0fb06ae4335c15b8a1cef058ba6d165.tar.gz |
ecore-drm: Add support for DPMS on an output
Summary: This commit adds support for setting DPMS level of an output.
This adds a new API function 'ecore_drm_output_dpms_set' to set the
level.
@feature
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Conflicts:
src/lib/ecore_drm/Ecore_Drm.h
src/lib/ecore_drm/ecore_drm_output.c
src/lib/ecore_drm/ecore_drm_private.h
Change-Id: Id544f862b2f76ff10a9a1142852b505d9c4d0fbb
-rw-r--r-- | src/lib/ecore_drm/Ecore_Drm.h | 14 | ||||
-rw-r--r-- | src/lib/ecore_drm/ecore_drm_output.c | 34 | ||||
-rw-r--r-- | src/lib/ecore_drm/ecore_drm_private.h | 1 |
3 files changed, 49 insertions, 0 deletions
diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index da9aa5db1e..2ce3bf7571 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -256,4 +256,18 @@ EAPI void ecore_drm_fb_destroy(Ecore_Drm_Fb *fb); EAPI Eina_Bool ecore_drm_launcher_connect(Ecore_Drm_Device *dev); EAPI void ecore_drm_launcher_disconnect(Ecore_Drm_Device *dev); + +/** + * Set the dpms level of an Ecore_Drm_Output + * + * This function will set the DPMS level of an Ecore_Drm_Output + * + * @param output The Ecore_Drm_Output to set the dpms level on + * @param level The level to set + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI void ecore_drm_output_dpms_set(Ecore_Drm_Output *output, int level); + #endif diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index 1b2f0aa51d..dfa9c031ea 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -17,6 +17,25 @@ EAPI int ECORE_DRM_EVENT_OUTPUT = 0; /* local functions */ +static drmModePropertyPtr +_ecore_drm_output_property_get(int fd, drmModeConnectorPtr conn, const char *name) +{ + drmModePropertyPtr prop; + int i = 0; + + for (; i < conn->count_props; i++) + { + if (!(prop = drmModeGetProperty(fd, conn->props[i]))) + continue; + + if (!strcmp(prop->name, name)) return prop; + + drmModeFreeProperty(prop); + } + + return NULL; +} + static Eina_Bool _ecore_drm_output_software_setup(Ecore_Drm_Device *dev, Ecore_Drm_Output *output) { @@ -319,6 +338,7 @@ _ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes *res, drmModeConnecto output->conn_id = conn->connector_id; dev->conn_allocator |= (1 << output->conn_id); output->crtc = drmModeGetCrtc(dev->drm.fd, output->crtc_id); + output->dpms = _ecore_drm_output_property_get(dev->drm.fd, conn, "DPMS"); memset(&mode, 0, sizeof(mode)); if ((enc = drmModeGetEncoder(dev->drm.fd, conn->encoder_id))) @@ -374,6 +394,7 @@ mode_err: eina_stringshare_del(output->name); EINA_LIST_FREE(output->modes, mode) free(mode); + drmModeFreeProperty(output->dpms); drmModeFreeCrtc(output->crtc); dev->crtc_allocator &= ~(1 << output->crtc_id); dev->conn_allocator &= ~(1 << output->conn_id); @@ -414,6 +435,7 @@ _ecore_drm_output_free(Ecore_Drm_Output *output) if (output->model) eina_stringshare_del(output->model); if (output->make) eina_stringshare_del(output->make); + if (output->dpms) drmModeFreeProperty(output->dpms); if (output->crtc) drmModeFreeCrtc(output->crtc); free(output); @@ -793,6 +815,8 @@ ecore_drm_output_enable(Ecore_Drm_Output *output) if ((!output) || (!output->current)) return EINA_FALSE; + ecore_drm_output_dpms_set(output, DRM_MODE_DPMS_ON); + mode = output->current_mode; if (drmModeSetCrtc(output->drm_fd, output->crtc_id, output->current->id, 0, 0, &output->conn_id, 1, &mode->info) < 0) @@ -945,3 +969,13 @@ ecore_drm_outputs_geometry_get(Ecore_Drm_Device *dev, int *x, int *y, int *w, in if (w) *w = ow; if (h) *h = oh; } + +EAPI void +ecore_drm_output_dpms_set(Ecore_Drm_Output *output, int level) +{ + EINA_SAFETY_ON_NULL_RETURN(output); + EINA_SAFETY_ON_NULL_RETURN(output->dpms); + + drmModeConnectorSetProperty(output->dev->drm.fd, output->conn_id, + output->dpms->prop_id, level); +} diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h index 5f3c1bc0b4..f5e3dadbfc 100644 --- a/src/lib/ecore_drm/ecore_drm_private.h +++ b/src/lib/ecore_drm/ecore_drm_private.h @@ -115,6 +115,7 @@ struct _Ecore_Drm_Output unsigned int conn_id; drmModeCrtcPtr crtc; Eeze_Udev_Watch *watch; + drmModePropertyPtr dpms; int x, y; int drm_fd; |