[PATCH V2 4/8] Add new mode function in drm backend
Quanxian Wang
quanxian.wang at intel.com
Mon Mar 24 04:39:16 PDT 2014
Provide drm_output_new_mode interface to create new mode
from outsite instead of only from edid or configure.
Signed-off-by: Quanxian Wang <quanxian.wang at intel.com>
---
src/compositor-drm.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 154e15e..577d02f 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1389,6 +1389,72 @@ drm_output_add_mode(struct drm_output *output, drmModeModeInfo *info)
return mode;
}
+static struct weston_mode *
+drm_output_new_mode(struct weston_output *output,
+ int fclock,
+ int hdisplay,
+ int hsync_start,
+ int hsync_end,
+ int htotal,
+ int vdisplay,
+ int vsync_start,
+ int vsync_end,
+ int vtotal,
+ const char *hsync,
+ const char *vsync)
+{
+ drmModeModeInfo *modeinfo;
+ struct drm_mode *mode = NULL;
+
+ modeinfo = malloc(sizeof(*modeinfo));
+ if (modeinfo == NULL)
+ return NULL;
+ memset(modeinfo, 0x0, sizeof(*modeinfo));
+
+ modeinfo->type = DRM_MODE_TYPE_USERDEF;
+ modeinfo->hskew = 0;
+ modeinfo->vscan = 0;
+ modeinfo->vrefresh = 0;
+ modeinfo->flags = 0;
+
+ modeinfo->hdisplay = hdisplay;
+ modeinfo->hsync_start = hsync_start;
+ modeinfo->hsync_end = hsync_end;
+ modeinfo->htotal = htotal;
+ modeinfo->vdisplay = vdisplay;
+ modeinfo->vsync_start = vsync_start;
+ modeinfo->vsync_end = vsync_end;
+ modeinfo->vtotal = vtotal;
+
+ modeinfo->clock = fclock * 1000;
+
+ if (strcmp(hsync, "+hsync") == 0)
+ modeinfo->flags |= DRM_MODE_FLAG_PHSYNC;
+ else if (strcmp(hsync, "-hsync") == 0)
+ modeinfo->flags |= DRM_MODE_FLAG_NHSYNC;
+ else {
+ weston_log("Invalid hsync parameter %s.\n", hsync);
+ free(modeinfo);
+ return NULL;
+ }
+
+ if (strcmp(vsync, "+vsync") == 0)
+ modeinfo->flags |= DRM_MODE_FLAG_PVSYNC;
+ else if (strcmp(vsync, "-vsync") == 0)
+ modeinfo->flags |= DRM_MODE_FLAG_NVSYNC;
+ else {
+ weston_log("Invalid vsync parameter %s.\n", vsync);
+ free(modeinfo);
+ return NULL;
+ }
+
+ mode = drm_output_add_mode((struct drm_output *)output, modeinfo);
+ if (mode)
+ return &mode->base;
+ else
+ return NULL;
+}
+
static int
drm_subpixel_to_wayland(int drm_value)
{
@@ -2046,6 +2112,7 @@ create_output_for_connector(struct drm_compositor *ec,
output->base.assign_planes = drm_assign_planes;
output->base.set_dpms = drm_set_dpms;
output->base.switch_mode = drm_output_switch_mode;
+ output->base.new_mode = drm_output_new_mode;
output->base.gamma_size = output->original_crtc->gamma_size;
output->base.set_gamma = drm_output_set_gamma;
--
1.8.1.2
More information about the wayland-devel
mailing list