From 29362040b2a01e731d0dd7e3f52300a1d5ad8836 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 4 May 2015 13:25:15 -0400 Subject: [PATCH 01/18] ecore-drm: Add API function to return screen size range Summary: This adds new API function to return the min & max width & height of valid screen range for an Ecore_Drm_Device @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 14 ++++++++++++++ src/lib/ecore_drm/ecore_drm_device.c | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index feb48f8414..157d0b8f18 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -761,6 +761,20 @@ EAPI void ecore_drm_device_pointer_xy_get(Ecore_Drm_Device *dev, int *x, int *y) */ EAPI const Eina_List *ecore_drm_devices_get(void); +/** + * Get the minimum and maximum screen size range + * + * @param dev The Ecore_Drm_Device to get screen size range from + * @param *minw The parameter in which smallest width is stored + * @param *minh The parameter in which smallest height is stored + * @param *maxw The parameter in which largest width is stored + * @param *maxh The parameter in which largest height is stored + * + * @ingroup Ecore_Drm_Device_Group + * @since 1.15 + */ +EAPI void ecore_drm_screen_size_range_get(Ecore_Drm_Device *dev, int *minw, int *minh, int *maxw, int *maxh); + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index 2646483436..bc28205c99 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c @@ -530,3 +530,14 @@ ecore_drm_device_output_find(Ecore_Drm_Device *dev, int x, int y) return NULL; } + +EAPI void +ecore_drm_screen_size_range_get(Ecore_Drm_Device *dev, int *minw, int *minh, int *maxw, int *maxh) +{ + EINA_SAFETY_ON_NULL_RETURN(dev); + + if (minw) *minw = dev->min_width; + if (minh) *minh = dev->min_height; + if (maxw) *maxw = dev->max_width; + if (maxh) *maxh = dev->max_height; +} From 2606735b394b9cfbf14f46edfe413c76aa872d7b Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 4 May 2015 14:06:31 -0400 Subject: [PATCH 02/18] ecore-drm: Add API function to return the name of an output Summary: This adds a new API function to turn the name of a given Ecore_Drm_Output. @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 13 +++++++++++++ src/lib/ecore_drm/ecore_drm_output.c | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index 157d0b8f18..54e252e4e0 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -708,6 +708,19 @@ EAPI Eina_Stringshare *ecore_drm_output_model_get(Ecore_Drm_Output *output); */ EAPI Eina_Stringshare *ecore_drm_output_make_get(Ecore_Drm_Output *output); +/** + * Get the name of Ecore_Drm_Output + * + * This function will give the name of Ecore_Drm_Output + * + * @param output The Ecore_Drm_Output to get name for + * @return The name. Caller should free this return. + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI char *ecore_drm_output_name_get(Ecore_Drm_Output *output); + /** * Set the dpms level of an Ecore_Drm_Output * diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index b564f10626..614abea519 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -1091,3 +1091,11 @@ ecore_drm_output_connector_id_get(Ecore_Drm_Output *output) return output->conn_id; } + +EAPI char * +ecore_drm_output_name_get(Ecore_Drm_Output *output) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL); + + return strdup(output->name); +} From c4461ac5d80508da2e542026d7578df2e7390b7b Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 4 May 2015 14:13:21 -0400 Subject: [PATCH 03/18] ecore-drm: Add API function to return output connected state Summary: This adds a new API function to check if a given output is connected or not. @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 12 ++++++++++++ src/lib/ecore_drm/ecore_drm_output.c | 12 +++++++++++- src/lib/ecore_drm/ecore_drm_private.h | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index 54e252e4e0..e5c2972a0d 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -788,6 +788,18 @@ EAPI const Eina_List *ecore_drm_devices_get(void); */ EAPI void ecore_drm_screen_size_range_get(Ecore_Drm_Device *dev, int *minw, int *minh, int *maxw, int *maxh); +/** + * Get if a given output is connected + * + * @param output The Ecore_Drm_Output to get the connected status of + * + * @return EINA_TRUE if output is connected, EINA_FALSE otherwise + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI Eina_Bool ecore_drm_output_connected_get(Ecore_Drm_Output *output); + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index 614abea519..f04a8903ef 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -754,13 +754,15 @@ ecore_drm_outputs_create(Ecore_Drm_Device *dev) if (!(conn = drmModeGetConnector(dev->drm.fd, res->connectors[i]))) continue; - if (conn->connection != DRM_MODE_CONNECTED) goto next; + /* if (conn->connection != DRM_MODE_CONNECTED) goto next; */ /* create output for this connector */ if (!(output = _ecore_drm_output_create(dev, res, conn, x, y, EINA_FALSE))) goto next; + output->connected = (conn->connection == DRM_MODE_CONNECTED); + x += output->current_mode->width; next: @@ -1099,3 +1101,11 @@ ecore_drm_output_name_get(Ecore_Drm_Output *output) return strdup(output->name); } + +EAPI Eina_Bool +ecore_drm_output_connected_get(Ecore_Drm_Output *output) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE); + + return output->connected; +} diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h index 75e103a62b..c7b9c2f78a 100644 --- a/src/lib/ecore_drm/ecore_drm_private.h +++ b/src/lib/ecore_drm/ecore_drm_private.h @@ -140,6 +140,7 @@ struct _Ecore_Drm_Output Ecore_Drm_Backlight *backlight; + Eina_Bool connected : 1; Eina_Bool enabled : 1; Eina_Bool cloned : 1; Eina_Bool need_repaint : 1; From 3aee7d1b6faa1641bb045e0618920aaf8f286359 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 4 May 2015 14:22:10 -0400 Subject: [PATCH 04/18] ecore-drm: Add connector type to output structure Summary: This adds a connector type field to the Output structure. This will be used in the Enlightenment Drm rendering code for RandR config Signed-off-by: Chris Michael --- src/lib/ecore_drm/ecore_drm_output.c | 1 + src/lib/ecore_drm/ecore_drm_private.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index f04a8903ef..a767b31481 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -419,6 +419,7 @@ _ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes *res, drmModeConnecto output->model = eina_stringshare_add("UNKNOWN"); output->name = eina_stringshare_add("UNKNOWN"); + output->conn_type = conn->connector_type; if (conn->connector_type < ALEN(conn_types)) type = conn_types[conn->connector_type]; else diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h index c7b9c2f78a..9339a2ac5b 100644 --- a/src/lib/ecore_drm/ecore_drm_private.h +++ b/src/lib/ecore_drm/ecore_drm_private.h @@ -117,6 +117,7 @@ struct _Ecore_Drm_Output Ecore_Drm_Device *dev; unsigned int crtc_id; unsigned int conn_id; + unsigned int conn_type; drmModeCrtcPtr crtc; drmModePropertyPtr dpms; From 4d2290847fa921e3cb42a9fe45c1978c7c2d9eef Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 4 May 2015 14:26:47 -0400 Subject: [PATCH 05/18] ecore-drm: Add API function to return the connector type of a given output Summary: This adds a new API function to return the connector type of an Ecore_Drm_Output @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 12 ++++++++++++ src/lib/ecore_drm/ecore_drm_output.c | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index e5c2972a0d..319d007047 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -800,6 +800,18 @@ EAPI void ecore_drm_screen_size_range_get(Ecore_Drm_Device *dev, int *minw, int */ EAPI Eina_Bool ecore_drm_output_connected_get(Ecore_Drm_Output *output); +/** + * Get the connector type of a given Ecore_Drm_Output + * + * @param output The Ecore_Drm_Output to get the connector type of + * + * @return An unsigned integer representing the type of connector for this output + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI unsigned int ecore_drm_output_connector_type_get(Ecore_Drm_Output *output); + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index a767b31481..78882d69e2 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -1110,3 +1110,11 @@ ecore_drm_output_connected_get(Ecore_Drm_Output *output) return output->connected; } + +EAPI unsigned int +ecore_drm_output_connector_type_get(Ecore_Drm_Output *output) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(output, 0); + + return output->conn_type; +} From 130ad6d60fa7e67c50db7aeffa3fab37b92de404 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 4 May 2015 14:41:18 -0400 Subject: [PATCH 06/18] ecore-drm: Add API function to return if a given output has a backlight Summary: This adds a new API function to call so we can check if a given Ecore_Drm_Output has a backlight @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 12 ++++++++++++ src/lib/ecore_drm/ecore_drm_output.c | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index 319d007047..d0a2c3673a 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -812,6 +812,18 @@ EAPI Eina_Bool ecore_drm_output_connected_get(Ecore_Drm_Output *output); */ EAPI unsigned int ecore_drm_output_connector_type_get(Ecore_Drm_Output *output); +/** + * Get if a given output has a backlight + * + * @param output The Ecore_Drm_Output to get the backlight of + * + * @return EINA_TRUE if this output has a backlight, EINA_FALSE otherwise + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI Eina_Bool ecore_drm_output_backlight_get(Ecore_Drm_Output *output); + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index 78882d69e2..3ffc131530 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -1118,3 +1118,10 @@ ecore_drm_output_connector_type_get(Ecore_Drm_Output *output) return output->conn_type; } + +EAPI Eina_Bool +ecore_drm_output_backlight_get(Ecore_Drm_Output *output) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE); + return (output->backlight != NULL); +} From 34664306a99100cdcebcba9b163d2d28ee3d1350 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 4 May 2015 15:03:47 -0400 Subject: [PATCH 07/18] ecore-drm: Add API function to return the edid of a given output Summary: This adds a new API function to return the EDID string of a given output. @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 12 ++++++++++++ src/lib/ecore_drm/ecore_drm_output.c | 12 ++++++++++++ src/lib/ecore_drm/ecore_drm_private.h | 2 ++ 3 files changed, 26 insertions(+) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index d0a2c3673a..e2b79a0567 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -824,6 +824,18 @@ EAPI unsigned int ecore_drm_output_connector_type_get(Ecore_Drm_Output *output); */ EAPI Eina_Bool ecore_drm_output_backlight_get(Ecore_Drm_Output *output); +/** + * Get the edid of a given output + * + * @param output The Ecore_Drm_Output to get the backlight of + * + * @return A string representing the edid + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI char *ecore_drm_output_edid_get(Ecore_Drm_Output *output); + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index 3ffc131530..b6c44cc3a1 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -160,10 +160,13 @@ _ecore_drm_output_edid_find(Ecore_Drm_Output *output, drmModeConnector *conn) conn->prop_values[i]); } drmModeFreeProperty(prop); + if (blob) break; } if (!blob) return; + output->edid_blob = (char *)eina_memdup(blob->data, blob->length, 1); + ret = _ecore_drm_output_edid_parse(output, blob->data, blob->length); if (!ret) { @@ -1125,3 +1128,12 @@ ecore_drm_output_backlight_get(Ecore_Drm_Output *output) EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE); return (output->backlight != NULL); } + +EAPI char * +ecore_drm_output_edid_get(Ecore_Drm_Output *output) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(output->edid_blob, NULL); + + return strdup(output->edid_blob); +} diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h index 9339a2ac5b..3bacef2334 100644 --- a/src/lib/ecore_drm/ecore_drm_private.h +++ b/src/lib/ecore_drm/ecore_drm_private.h @@ -131,6 +131,8 @@ struct _Ecore_Drm_Output Ecore_Drm_Output_Mode *current_mode; Eina_List *modes; + char *edid_blob; + struct { char eisa[13]; From 1ab4975491f184f11b4c6407218669805a29894e Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Tue, 5 May 2015 09:12:25 -0400 Subject: [PATCH 08/18] ecore-drm: Add API function to return output modes Summary: This adds a new API function to return a list of modes supported on a given output @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 24 ++++++++++++++++++++++-- src/lib/ecore_drm/ecore_drm_output.c | 9 +++++++++ src/lib/ecore_drm/ecore_drm_private.h | 8 -------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index e2b79a0567..2177b3f49f 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -153,8 +153,14 @@ struct _Ecore_Drm_Event_Output /* opaque structure to represent a drm device */ typedef struct _Ecore_Drm_Device Ecore_Drm_Device; -/* opaque structure to represent a drm output mode */ -typedef struct _Ecore_Drm_Output_Mode Ecore_Drm_Output_Mode; +/* structure to represent a drm output mode */ +typedef struct _Ecore_Drm_Output_Mode +{ + unsigned int flags; + int width, height; + unsigned int refresh; + drmModeModeInfo info; +} Ecore_Drm_Output_Mode; /* opaque structure to represent a drm output */ typedef struct _Ecore_Drm_Output Ecore_Drm_Output; @@ -836,6 +842,20 @@ EAPI Eina_Bool ecore_drm_output_backlight_get(Ecore_Drm_Output *output); */ EAPI char *ecore_drm_output_edid_get(Ecore_Drm_Output *output); +/** + * Get a list of the modes supported on a given output + * + * @param output The Ecore_Drm_Output to get the modes for + * + * @return An Eina_List of the modes supported for this output + * + * @note The returned list should not be freed + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI Eina_List *ecore_drm_output_modes_get(Ecore_Drm_Output *output); + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index b6c44cc3a1..fbd2a2a53e 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -1137,3 +1137,12 @@ ecore_drm_output_edid_get(Ecore_Drm_Output *output) return strdup(output->edid_blob); } + +EAPI Eina_List * +ecore_drm_output_modes_get(Ecore_Drm_Output *output) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(output->modes, NULL); + + return output->modes; +} diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h index 3bacef2334..8a2ca3c91b 100644 --- a/src/lib/ecore_drm/ecore_drm_private.h +++ b/src/lib/ecore_drm/ecore_drm_private.h @@ -87,14 +87,6 @@ typedef struct _Ecore_Drm_Pageflip_Callback int count; } Ecore_Drm_Pageflip_Callback; -struct _Ecore_Drm_Output_Mode -{ - unsigned int flags; - int width, height; - unsigned int refresh; - drmModeModeInfo info; -}; - typedef enum _Ecore_Drm_Backlight_Type { ECORE_DRM_BACKLIGHT_RAW, From 0341d08831436faa6d280ec8b040654c417491a2 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 6 May 2015 09:33:17 -0400 Subject: [PATCH 09/18] ecore-drm: Add some debug code to spit out planes and plane properties Summary: This adds a debug function to spit out planes and their properties while debugging rotation support Signed-off-by: Chris Michael --- src/lib/ecore_drm/ecore_drm_output.c | 124 +++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index fbd2a2a53e..5a1f5312cd 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -706,6 +706,123 @@ next: } } +static void +_ecore_drm_output_planes_get(Ecore_Drm_Device *dev) +{ + drmModePlaneRes *pres; + unsigned int i = 0, j = 0; + int k = 0; + + pres = drmModeGetPlaneResources(dev->drm.fd); + if (!pres) return; + + for (; i < pres->count_planes; i++) + { + drmModePlane *plane; + drmModeObjectPropertiesPtr props; + int type = -1; + + plane = drmModeGetPlane(dev->drm.fd, pres->planes[i]); + if (!plane) continue; + + props = drmModeObjectGetProperties(dev->drm.fd, plane->plane_id, + DRM_MODE_OBJECT_PLANE); + if (!props) goto free_plane; + + DBG("Plane %u Properties:", plane->plane_id); + + for (j = 0; type == -1 && j < props->count_props; j++) + { + drmModePropertyPtr prop; + + prop = drmModeGetProperty(dev->drm.fd, props->props[j]); + if (!prop) continue; + + if (!strcmp(prop->name, "type")) + { + type = props->prop_values[j]; + DBG("\tType: %d", type); + for (k = 0; k < prop->count_enums; k++) + { + DBG("\t\t%s=%llu", prop->enums[k].name, + prop->enums[k].value); + } + } + + drmModeFreeProperty(prop); + } + + DBG("\tFormats:"); + for (j = 0; j < plane->count_formats; j++) + DBG("\t\t%4.4s", (char *)&plane->formats[j]); + + for (j = 0; j < props->count_props; j++ ) + { + drmModePropertyPtr prop; + + prop = drmModeGetProperty(dev->drm.fd, props->props[j]); + if (!prop) continue; + + DBG("\tProperty Name: %s", prop->name); + + if (prop->flags & DRM_MODE_PROP_RANGE) + { + DBG("\t\tRange Property"); + for (k = 0; k < prop->count_values; k++) + DBG("\t\t\t%"PRIu64, prop->values[k]); + } + if (prop->flags & DRM_MODE_PROP_ENUM) + { + DBG("\t\tEnum Property"); + for (k = 0; k < prop->count_enums; k++) + DBG("\t\t\t%s=%llu", prop->enums[k].name, + prop->enums[k].value); + } + if (prop->flags & DRM_MODE_PROP_BITMASK) + { + DBG("\t\tBitmask Property"); + for (k = 0; k < prop->count_enums; k++) + DBG("\t\t\t%s=0x%llx", prop->enums[k].name, + (1LL << prop->enums[k].value)); + } + + if (!strcmp(prop->name, "rotation")) + { + DBG("\t\tSupported Rotations:"); + for (k = 0; k < prop->count_enums; k++) + { + if (!strcmp(prop->enums[k].name, "rotate-0")) + DBG("\t\t\tRotate 0"); + else if (!strcmp(prop->enums[k].name, "rotate-90")) + DBG("\t\t\tRotate 90"); + else if (!strcmp(prop->enums[k].name, "rotate-180")) + DBG("\t\t\tRotate 180"); + else if (!strcmp(prop->enums[k].name, "rotate-270")) + DBG("\t\t\tRotate 270"); + else if (!strcmp(prop->enums[k].name, "reflect-x")) + DBG("\t\t\tReflect X"); + else if (!strcmp(prop->enums[k].name, "reflect-y")) + DBG("\t\t\tReflect Y"); + else + DBG("\t\t\t%s", prop->enums[k].name); + } + } + + drmModeFreeProperty(prop); + } + + DBG("\tCurrent Crtc: %d", plane->crtc_id); + DBG("\tPossible Crtcs: 0x%08x", plane->possible_crtcs); + + drmModeFreeObjectProperties(props); + +free_plane: + drmModeFreePlane(plane); + } + + drmModeFreePlaneResources(pres); +} + /* public functions */ /** @@ -752,6 +869,12 @@ ecore_drm_outputs_create(Ecore_Drm_Device *dev) dev->max_width = res->max_width; dev->max_height = res->max_height; + /* DBG("Dev Size"); */ + /* DBG("\tMin Width: %u", res->min_width); */ + /* DBG("\tMin Height: %u", res->min_height); */ + /* DBG("\tMax Width: %u", res->max_width); */ + /* DBG("\tMax Height: %u", res->max_height); */ + for (i = 0; i < res->count_connectors; i++) { /* get the connector */ @@ -775,6 +898,7 @@ next: } /* TODO: Planes */ + _ecore_drm_output_planes_get(dev); ret = EINA_TRUE; if (eina_list_count(dev->outputs) < 1) From e8754ee9d2c68f616eb7e5e9e9a79488c6e70336 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 6 May 2015 09:41:03 -0400 Subject: [PATCH 10/18] ecore-drm: Set output connected property in the creation function Summary: Makes more sense to set the output's connected property inside the function which creates outputs. @fix Signed-off-by: Chris Michael --- src/lib/ecore_drm/ecore_drm_output.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index 5a1f5312cd..2e91909893 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -422,6 +422,7 @@ _ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes *res, drmModeConnecto output->model = eina_stringshare_add("UNKNOWN"); output->name = eina_stringshare_add("UNKNOWN"); + output->connected = (conn->connection == DRM_MODE_CONNECTED); output->conn_type = conn->connector_type; if (conn->connector_type < ALEN(conn_types)) type = conn_types[conn->connector_type]; @@ -888,8 +889,6 @@ ecore_drm_outputs_create(Ecore_Drm_Device *dev) _ecore_drm_output_create(dev, res, conn, x, y, EINA_FALSE))) goto next; - output->connected = (conn->connection == DRM_MODE_CONNECTED); - x += output->current_mode->width; next: From 7df68b484b2cdfc8bcfa3c6d11c692867dc08cbc Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 6 May 2015 11:31:25 -0400 Subject: [PATCH 11/18] ecore-drm: Cleanup plane debug output Signed-off-by: Chris Michael --- src/lib/ecore_drm/ecore_drm_output.c | 32 ++-------------------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index 2e91909893..32249cbb14 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -740,15 +740,7 @@ _ecore_drm_output_planes_get(Ecore_Drm_Device *dev) if (!prop) continue; if (!strcmp(prop->name, "type")) - { - type = props->prop_values[j]; - DBG("\tType: %d", type); - for (k = 0; k < prop->count_enums; k++) - { - DBG("\t\t%s=%llu", prop->enums[k].name, - prop->enums[k].value); - } - } + type = props->prop_values[j]; drmModeFreeProperty(prop); } @@ -787,27 +779,7 @@ _ecore_drm_output_planes_get(Ecore_Drm_Device *dev) (1LL << prop->enums[k].value)); } - if (!strcmp(prop->name, "rotation")) - { - DBG("\t\tSupported Rotations:"); - for (k = 0; k < prop->count_enums; k++) - { - if (!strcmp(prop->enums[k].name, "rotate-0")) - DBG("\t\t\tRotate 0"); - else if (!strcmp(prop->enums[k].name, "rotate-90")) - DBG("\t\t\tRotate 90"); - else if (!strcmp(prop->enums[k].name, "rotate-180")) - DBG("\t\t\tRotate 180"); - else if (!strcmp(prop->enums[k].name, "rotate-270")) - DBG("\t\t\tRotate 270"); - else if (!strcmp(prop->enums[k].name, "reflect-x")) - DBG("\t\t\tReflect X"); - else if (!strcmp(prop->enums[k].name, "reflect-y")) - DBG("\t\t\tReflect Y"); - else - DBG("\t\t\t%s", prop->enums[k].name); - } - } + DBG("\t\tValue: %"PRIu64, props->prop_values[j]); drmModeFreeProperty(prop); } From c79922f392d01102cd6a9eb9db58565d149b3134 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 6 May 2015 11:31:57 -0400 Subject: [PATCH 12/18] ecore-drm: Set drm client capabilities to support universal planes Summary: If we do not set client capabilities to support universal planes, then libdrm does not expose the primary or cursor planes so this adds a quick call to set DRM_CLIENT_CAP_UNIVERSAL_PLANES @fix Signed-off-by: Chris Michael --- src/lib/ecore_drm/ecore_drm_device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index bc28205c99..81636c65e7 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c @@ -281,6 +281,10 @@ ecore_drm_device_open(Ecore_Drm_Device *dev) DBG("Opened Device %s : %d", dev->drm.name, dev->drm.fd); + /* set client capabilities to 'universal planes' so drm core will expose + * the full universal plane list (including primary & cursor planes) */ + drmSetClientCap(dev->drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); + if (!drmGetCap(dev->drm.fd, DRM_CAP_TIMESTAMP_MONOTONIC, &caps)) { if (caps == 1) From 94adf30b93e7a1bc2f7d77ea98beddc81bffdd06 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 6 May 2015 12:15:56 -0400 Subject: [PATCH 13/18] ecore-drm: Add support for a Primary Output Summary: As 'primary' output support is not implemented in hardware, we need to support this feature via software. For now, the first output returned via libdrm will be marked as 'primary' until user changes it via config @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/ecore_drm_output.c | 8 ++++++++ src/lib/ecore_drm/ecore_drm_private.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index 32249cbb14..9ce8641363 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -507,6 +507,13 @@ _ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes *res, drmModeConnecto dev->outputs = eina_list_append(dev->outputs, output); + /* NB: 'primary' output property is not supported in HW, so we need to + * implement it via software. As such, the First output which gets + * listed via libdrm will be assigned 'primary' until user changes + * it via config */ + if (eina_list_count(dev->outputs) == 1) + output->primary = EINA_TRUE; + DBG("Created New Output At %d,%d", output->x, output->y); DBG("\tCrtc Pos: %d %d", output->crtc->x, output->crtc->y); DBG("\tCrtc: %d", output->crtc_id); @@ -515,6 +522,7 @@ _ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes *res, drmModeConnecto DBG("\tModel: %s", output->model); DBG("\tName: %s", output->name); DBG("\tCloned: %d", output->cloned); + DBG("\tPrimary: %d", output->primary); EINA_LIST_FOREACH(output->modes, l, mode) { diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h index 8a2ca3c91b..063ac06632 100644 --- a/src/lib/ecore_drm/ecore_drm_private.h +++ b/src/lib/ecore_drm/ecore_drm_private.h @@ -135,6 +135,7 @@ struct _Ecore_Drm_Output Ecore_Drm_Backlight *backlight; + Eina_Bool primary : 1; Eina_Bool connected : 1; Eina_Bool enabled : 1; Eina_Bool cloned : 1; From 8120cdcc1369acb0b1f69d8995e9843a4656511c Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 6 May 2015 12:22:15 -0400 Subject: [PATCH 14/18] ecore-drm: Add API function to return primary output Summary: This adds a new API function to return the output which is marked as the primary output. @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 12 ++++++++++++ src/lib/ecore_drm/ecore_drm_output.c | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index 2177b3f49f..fcf784b2c2 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -856,6 +856,18 @@ EAPI char *ecore_drm_output_edid_get(Ecore_Drm_Output *output); */ EAPI Eina_List *ecore_drm_output_modes_get(Ecore_Drm_Output *output); +/** + * Get the output which is marked as primary + * + * @param dev The Ecore_Drm_Device to get the primary output from + * + * @return The primary Ecore_Drm_Output or NULL if no primary output is set + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI Ecore_Drm_Output *ecore_drm_output_primary_get(Ecore_Drm_Device *dev); + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index 9ce8641363..d9283f1b06 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -1249,3 +1249,17 @@ ecore_drm_output_modes_get(Ecore_Drm_Output *output) return output->modes; } + +EAPI Ecore_Drm_Output * +ecore_drm_output_primary_get(Ecore_Drm_Device *dev) +{ + Ecore_Drm_Output *ret; + const Eina_List *l; + + EINA_SAFETY_ON_NULL_RETURN_VAL(dev, NULL); + + EINA_LIST_FOREACH(dev->outputs, l, ret) + if (ret->primary) return ret; + + return NULL; +} From 49de7d0ee8180de6d8d0692cbf718f11f874e5ef Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 6 May 2015 13:19:08 -0400 Subject: [PATCH 15/18] ecore-drm: Add API function to get an output's crtc size Summary: This adds a new API function to return an output's crtc size. This is mainly used for drm RandR config in E @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 12 ++++++++++++ src/lib/ecore_drm/ecore_drm_output.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index fcf784b2c2..0003ef50eb 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -868,6 +868,18 @@ EAPI Eina_List *ecore_drm_output_modes_get(Ecore_Drm_Output *output); */ EAPI Ecore_Drm_Output *ecore_drm_output_primary_get(Ecore_Drm_Device *dev); +/** + * Get the size of the crtc for a given output + * + * @param output The Ecore_Drm_Output to get the crtc size of + * @param *width The parameter in which width is stored + * @param *height The parameter in which height is stored + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI void ecore_drm_output_crtc_size_get(Ecore_Drm_Output *output, int *width, int *height); + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index d9283f1b06..8b4369ec4c 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -1263,3 +1263,15 @@ ecore_drm_output_primary_get(Ecore_Drm_Device *dev) return NULL; } + +EAPI void +ecore_drm_output_crtc_size_get(Ecore_Drm_Output *output, int *width, int *height) +{ + if (width) *width = 0; + if (height) *height = 0; + + EINA_SAFETY_ON_NULL_RETURN(output); + + if (width) *width = output->crtc->width; + if (height) *height = output->crtc->height; +} From 03a242f263fecc7178928aa7bdb989335495b6a3 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Thu, 7 May 2015 09:24:15 -0400 Subject: [PATCH 16/18] ecore-drm: Fix formatting Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index 0003ef50eb..d0e97b5246 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -29,9 +29,9 @@ # endif // ifdef __GNUC__ # endif // ifdef _MSC_VER -#ifdef __cplusplus +# ifdef __cplusplus extern "C" { -#endif +# endif typedef enum _Ecore_Drm_Evdev_Capabilities { @@ -880,11 +880,11 @@ EAPI Ecore_Drm_Output *ecore_drm_output_primary_get(Ecore_Drm_Device *dev); */ EAPI void ecore_drm_output_crtc_size_get(Ecore_Drm_Output *output, int *width, int *height); -#ifdef __cplusplus +# ifdef __cplusplus } -#endif +# endif -#undef EAPI -#define EAPI +# undef EAPI +# define EAPI #endif From 2145cb18c296b4269d52b57c000a9495ce8b71e1 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Thu, 7 May 2015 11:31:46 -0400 Subject: [PATCH 17/18] ecore-drm: Add API function to find an output given a name Summary: This adds a new API function to find an Ecore_Drm_Output which matches a given name. @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 16 ++++++++++++++++ src/lib/ecore_drm/ecore_drm_device.c | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index d0e97b5246..ad2ae4a9dd 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -880,6 +880,22 @@ EAPI Ecore_Drm_Output *ecore_drm_output_primary_get(Ecore_Drm_Device *dev); */ EAPI void ecore_drm_output_crtc_size_get(Ecore_Drm_Output *output, int *width, int *height); +/** + * Find an Ecore_Drm_Output which has the given name + * + * This function will loop all the existing outputs in Ecore_Drm_Device and + * return an output if one exists that matches the given name. + * + * @param dev The Ecore_Drm_Device to search + * @param name The Ecore_Drm_Output matching this name + * + * @return An Ecore_Drm_Output if one exists at these coordinates or NULL + * + * @ingroup Ecore_Drm_Device_Group + * @since 1.15 + */ +EAPI Ecore_Drm_Output *ecore_drm_device_output_name_find(Ecore_Drm_Device *dev, const char *name); + # ifdef __cplusplus } # endif diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index 81636c65e7..2a29b0e758 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c @@ -545,3 +545,19 @@ ecore_drm_screen_size_range_get(Ecore_Drm_Device *dev, int *minw, int *minh, int if (maxw) *maxw = dev->max_width; if (maxh) *maxh = dev->max_height; } + +EAPI Ecore_Drm_Output * +ecore_drm_device_output_name_find(Ecore_Drm_Device *dev, const char *name) +{ + Ecore_Drm_Output *output; + Eina_List *l; + + EINA_SAFETY_ON_NULL_RETURN_VAL(dev, NULL); + EINA_SAFETY_ON_TRUE_RETURN_VAL(name, NULL); + + EINA_LIST_FOREACH(dev->outputs, l, output) + if ((output->name) && (!strcmp(name, output->name))) + return output; + + return NULL; +} From 958b15c2077214b3349e9102dd486bc5bef929d7 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Thu, 7 May 2015 11:37:54 -0400 Subject: [PATCH 18/18] ecore-drm: Add new API function to mark an output as primary Summary: This adds a new API function which we can use to mark a given Ecore_Drm_Output as being the primary output. @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 10 ++++++++++ src/lib/ecore_drm/ecore_drm_device.c | 2 +- src/lib/ecore_drm/ecore_drm_output.c | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index ad2ae4a9dd..481da42f15 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -868,6 +868,16 @@ EAPI Eina_List *ecore_drm_output_modes_get(Ecore_Drm_Output *output); */ EAPI Ecore_Drm_Output *ecore_drm_output_primary_get(Ecore_Drm_Device *dev); +/** + * Set a given output as primary + * + * @param output The Ecore_Drm_Output to set as primary + * + * @ingroup Ecore_Drm_Output_Group + * @since 1.15 + */ +EAPI void ecore_drm_output_primary_set(Ecore_Drm_Output *output); + /** * Get the size of the crtc for a given output * diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index 2a29b0e758..b902c19d34 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c @@ -553,7 +553,7 @@ ecore_drm_device_output_name_find(Ecore_Drm_Device *dev, const char *name) Eina_List *l; EINA_SAFETY_ON_NULL_RETURN_VAL(dev, NULL); - EINA_SAFETY_ON_TRUE_RETURN_VAL(name, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); EINA_LIST_FOREACH(dev->outputs, l, output) if ((output->name) && (!strcmp(name, output->name))) diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c index 8b4369ec4c..25965383c5 100644 --- a/src/lib/ecore_drm/ecore_drm_output.c +++ b/src/lib/ecore_drm/ecore_drm_output.c @@ -1264,6 +1264,22 @@ ecore_drm_output_primary_get(Ecore_Drm_Device *dev) return NULL; } +EAPI void +ecore_drm_output_primary_set(Ecore_Drm_Output *output) +{ + const Eina_List *l; + Ecore_Drm_Output *out; + + EINA_SAFETY_ON_NULL_RETURN(output); + + /* unmark all outputs as primary */ + EINA_LIST_FOREACH(output->dev->outputs, l, out) + out->primary = EINA_FALSE; + + /* mark this output as primary */ + output->primary = EINA_TRUE; +} + EAPI void ecore_drm_output_crtc_size_get(Ecore_Drm_Output *output, int *width, int *height) {