aboutsummaryrefslogtreecommitdiffstats
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
parentecore-drm: Fix issue with output_current_resolution_get function (diff)
downloadefl-bcf3b442dd3f4683dd6b634615ed6563e7a2c9d1.tar.gz
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,
*/
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 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:
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;
+}