ecore-drm2: Add API function to set the mode of an output

Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
This commit is contained in:
Chris Michael 2016-05-11 09:29:48 -04:00
parent 55f228a238
commit a6b018a2a8
2 changed files with 58 additions and 0 deletions

View File

@ -479,6 +479,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
*

View File

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