Add default mode for NexCom and Crossiville
[profile/ivi/weston.git] / packaging / weston-mode-nextcom.patch
1 commit 36d106aa5ad0254039557a6f69fbc5ba045a7971
2 Author: Wang Quanxian <quanxian.wang@intel.com>
3 Date:   Fri Jul 6 15:53:08 2012 +0800
4
5     Add default mode for NexCom and Crossiville
6        The platform has no EDID information. The mode could not be gotten
7        from drm interfaces.
8     
9     Signed-Off-By Wang Quanxian <quanxian.wang@intel.com>
10
11 diff --git a/src/compositor-drm.c b/src/compositor-drm.c
12 index 4dffa1d..b0a81be 100644
13 --- a/src/compositor-drm.c
14 +++ b/src/compositor-drm.c
15 @@ -143,6 +143,16 @@ struct drm_sprite {
16         uint32_t formats[];
17  };
18  
19 +static drmModeModeInfo builtin_800x480 = {
20 +       33750,                  /* clock */
21 +       800, 864, 976, 1088, 0, 
22 +       480, 486, 494, 517, 0,
23 +       59920,
24 +       DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC,
25 +       0,
26 +       "800x480"
27 +};
28 +
29  static int
30  surface_is_primary(struct weston_compositor *ec, struct weston_surface *es)
31  {
32 @@ -1294,7 +1304,7 @@ create_output_for_connector(struct drm_compositor *ec,
33         struct drm_mode *drm_mode, *next;
34         struct weston_mode *m, *preferred, *current;
35         drmModeEncoder *encoder;
36 -       drmModeModeInfo crtc_mode;
37 +       drmModeModeInfo crtc_mode = builtin_800x480;
38         drmModeCrtc *crtc;
39         int i, ret;
40  
41 @@ -1344,13 +1354,23 @@ create_output_for_connector(struct drm_compositor *ec,
42         drmModeFreeEncoder(encoder);
43         if (crtc == NULL)
44                 goto err_free;
45 -       crtc_mode = crtc->mode;
46 +
47 +       /* if don't get mode from drm driver, use default 800x480 */
48 +        if (crtc->mode.clock != 0)
49 +               crtc_mode = crtc->mode;
50 +
51         drmModeFreeCrtc(crtc);
52  
53 -       for (i = 0; i < connector->count_modes; i++) {
54 -               ret = drm_output_add_mode(output, &connector->modes[i]);
55 +       if (connector->count_modes == 0) {
56 +               ret = drm_output_add_mode(output, &builtin_800x480);
57                 if (ret)
58                         goto err_free;
59 +       }else{
60 +               for (i = 0; i < connector->count_modes; i++) {
61 +                       ret = drm_output_add_mode(output, &connector->modes[i]);
62 +                       if (ret)
63 +                               goto err_free;
64 +               }
65         }
66  
67         preferred = NULL;