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>
This commit is contained in:
Chris Michael 2015-05-13 14:41:12 -04:00
parent d9b59f34d2
commit bcf3b442dd
2 changed files with 65 additions and 0 deletions

View File

@ -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

View File

@ -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;
}