omap3-pandora-kernel: add a few more USB TV card modules
[openpandora.oe.git] / recipes / linux / omap3-pandora-kernel / mru-make-video-timings-selectable.diff
1 From: Mans Rullgard <mans@mansr.com>
2 Date: Fri, 29 Aug 2008 01:42:12 +0000 (+0100)
3 Subject: OMAP: Make video mode selectable from pre-defined list
4 X-Git-Url: http://git.mansr.com/?p=linux-omap;a=commitdiff_plain;h=7a9e55d7156dae6bc930c77620a88a669d2ed1c9
5
6 OMAP: Make video mode selectable from pre-defined list
7
8 This adds a list of common video modes and allows one to be
9 selected with video=omapfb:mode:name on the command line,
10 overriding the defaults from lcd_*.c. A default named mode
11 can also be specified in the kernel configuration.
12
13 Signed-off-by: Mans Rullgard <mans@mansr.com>
14 ---
15
16 diff --git a/drivers/video/omap/Kconfig b/drivers/video/omap/Kconfig
17 index 5ebd591..9977e80 100644
18 --- a/drivers/video/omap/Kconfig
19 +++ b/drivers/video/omap/Kconfig
20 @@ -7,26 +7,13 @@ config FB_OMAP
21         help
22            Frame buffer driver for OMAP based boards.
23  
24 -choice
25 -       depends on FB_OMAP && MACH_OVERO
26 -       prompt "Screen resolution"
27 -       default FB_OMAP_079M3R
28 +config FB_OMAP_VIDEO_MODE
29 +       string "Default video mode"
30 +       depends on FB_OMAP
31         help
32 -         Selected desired screen resolution
33 -
34 -config FB_OMAP_031M3R
35 -       boolean "640 x 480 @ 60 Hz Reduced blanking"
36 -
37 -config FB_OMAP_048M3R
38 -       boolean "800 x 600 @ 60 Hz Reduced blanking"
39 -
40 -config FB_OMAP_079M3R
41 -       boolean "1024 x 768 @ 60 Hz Reduced blanking"
42 -
43 -config FB_OMAP_092M9R
44 -       boolean "1280 x 720 @ 60 Hz Reduced blanking"
45 -
46 -endchoice
47 +         Enter video mode name to use if none is specified on the kernel
48 +         command line. If left blank, board-specific default timings
49 +         will be used. See omapfb_main.c for a list of valid mode names.
50  
51  config FB_OMAP_LCDC_EXTERNAL
52         bool "External LCD controller support"
53 diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c
54 index e9ffb92..c4c4049 100644
55 --- a/drivers/video/omap/omapfb_main.c
56 +++ b/drivers/video/omap/omapfb_main.c
57 @@ -36,6 +36,20 @@
58  
59  #define MODULE_NAME    "omapfb"
60  
61 +struct video_mode {
62 +       const char      *name;
63 +       int             x_res, y_res;
64 +       int             pixel_clock;    /* In kHz */
65 +       int             hsw;            /* Horizontal synchronization
66 +                                          pulse width */
67 +       int             hfp;            /* Horizontal front porch */
68 +       int             hbp;            /* Horizontal back porch */
69 +       int             vsw;            /* Vertical synchronization
70 +                                          pulse width */
71 +       int             vfp;            /* Vertical front porch */
72 +       int             vbp;            /* Vertical back porch */
73 +};
74 +
75  static unsigned int    def_accel;
76  static unsigned long   def_vram[OMAPFB_PLANE_NUM];
77  static unsigned int    def_vram_cnt;
78 @@ -43,6 +57,7 @@ static unsigned long  def_vxres;
79  static unsigned long   def_vyres;
80  static unsigned int    def_rotate;
81  static unsigned int    def_mirror;
82 +static char            def_mode[16] = CONFIG_FB_OMAP_VIDEO_MODE;
83  
84  #ifdef CONFIG_FB_OMAP_MANUAL_UPDATE
85  static int             manual_update = 1;
86 @@ -53,6 +68,7 @@ static int            manual_update;
87  static struct platform_device  *fbdev_pdev;
88  static struct lcd_panel                *fbdev_panel;
89  static struct omapfb_device    *omapfb_dev;
90 +static struct video_mode       video_mode;
91  
92  struct caps_table_struct {
93         unsigned long flag;
94 @@ -83,6 +99,152 @@ static struct caps_table_struct color_caps[] = {
95         { 1 << OMAPFB_COLOR_YUY422,     "YUY422", },
96  };
97  
98 +static struct video_mode video_modes[] __initdata = {
99 +       {
100 +               /* 640 x 480 @ 60 Hz  Reduced blanking VESA CVT 0.31M3-R */
101 +               .name           = "640x480@60",
102 +               .x_res          = 640,
103 +               .y_res          = 480,
104 +               .hfp            = 48,
105 +               .hsw            = 32,
106 +               .hbp            = 80,
107 +               .vfp            = 3,
108 +               .vsw            = 4,
109 +               .vbp            = 7,
110 +               .pixel_clock    = 23500,
111 +       },
112 +       {
113 +               /* 800 x 600 @ 60 Hz  Reduced blanking VESA CVT 0.48M3-R */
114 +               .name           = "800x600@60",
115 +               .x_res          = 800,
116 +               .y_res          = 600,
117 +               .hfp            = 48,
118 +               .hsw            = 32,
119 +               .hbp            = 80,
120 +               .vfp            = 3,
121 +               .vsw            = 4,
122 +               .vbp            = 11,
123 +               .pixel_clock    = 35500,
124 +       },
125 +       {
126 +               /* 1024 x 768 @ 60 Hz  Reduced blanking VESA CVT 0.79M3-R */
127 +               .name           = "1024x768@60",
128 +               .x_res          = 1024,
129 +               .y_res          = 768,
130 +               .hfp            = 48,
131 +               .hsw            = 32,
132 +               .hbp            = 80,
133 +               .vfp            = 3,
134 +               .vsw            = 4,
135 +               .vbp            = 15,
136 +               .pixel_clock    = 56000,
137 +       },
138 +       {
139 +               /* 1280 x 720 @ 60 Hz  Reduced blanking VESA CVT 0.92M9-R */
140 +               .name           = "1280x720@60",
141 +               .x_res          = 1280,
142 +               .y_res          = 720,
143 +               .hfp            = 48,
144 +               .hsw            = 32,
145 +               .hbp            = 80,
146 +               .vfp            = 3,
147 +               .vsw            = 5,
148 +               .vbp            = 13,
149 +               .pixel_clock    = 64000,
150 +       },
151 +       {
152 +               /* 720 x 480 @ 60 Hz  CEA-861 Format 3 */
153 +               .name           = "480p60",
154 +               .x_res          = 720,
155 +               .y_res          = 480,
156 +               .hfp            = 16,
157 +               .hsw            = 62,
158 +               .hbp            = 60,
159 +               .vfp            = 9,
160 +               .vsw            = 6,
161 +               .vbp            = 30,
162 +               .pixel_clock    = 27027,
163 +       },
164 +       {
165 +               /* 720 x 576 @ 60 Hz  CEA-861 Format 18 */
166 +               .name           = "576p50",
167 +               .x_res          = 720,
168 +               .y_res          = 576,
169 +               .hfp            = 12,
170 +               .hsw            = 64,
171 +               .hbp            = 68,
172 +               .vfp            = 5,
173 +               .vsw            = 5,
174 +               .vbp            = 39,
175 +               .pixel_clock    = 27000,
176 +       },
177 +       {
178 +               /* 1280 x 720 @ 50 Hz  CEA-861B Format 19 */
179 +               .name           = "720p50",
180 +               .x_res          = 1280,
181 +               .y_res          = 720,
182 +               .hfp            = 440,
183 +               .hsw            = 40,
184 +               .hbp            = 220,
185 +               .vfp            = 20,
186 +               .vsw            = 5,
187 +               .vbp            = 5,
188 +               .pixel_clock    = 74250,
189 +       },
190 +       {
191 +               /* 1280 x 720 @ 60 Hz  CEA-861B Format 4 */
192 +               .name           = "720p60",
193 +               .x_res          = 1280,
194 +               .y_res          = 720,
195 +               .hfp            = 110,
196 +               .hsw            = 40,
197 +               .hbp            = 220,
198 +               .vfp            = 20,
199 +               .vsw            = 5,
200 +               .vbp            = 5,
201 +               .pixel_clock    = 74250,
202 +       },
203 +       {
204 +               /* 1920 x 1080 @ 24 Hz  CEA-861B Format 32 */
205 +               .name           = "1080p24",
206 +               .x_res          = 1920,
207 +               .y_res          = 1080,
208 +               .hfp            = 148,
209 +               .hsw            = 44,
210 +               .hbp            = 638,
211 +               .vfp            = 36,
212 +               .vsw            = 5,
213 +               .vbp            = 4,
214 +               .pixel_clock    = 74250,
215 +       },
216 +       {
217 +               /* 1920 x 1080 @ 25 Hz  CEA-861B Format 33 */
218 +               .name           = "1080p25",
219 +               .x_res          = 1920,
220 +               .y_res          = 1080,
221 +               .hfp            = 148,
222 +               .hsw            = 44,
223 +               .hbp            = 528,
224 +               .vfp            = 36,
225 +               .vsw            = 5,
226 +               .vbp            = 4,
227 +               .pixel_clock    = 74250,
228 +       },
229 +       {
230 +               /* 1920 x 1080 @ 30 Hz  CEA-861B Format 34 */
231 +               .name           = "1080p30",
232 +               .x_res          = 1920,
233 +               .y_res          = 1080,
234 +               .hfp            = 148,
235 +               .hsw            = 44,
236 +               .hbp            = 88,
237 +               .vfp            = 36,
238 +               .vsw            = 5,
239 +               .vbp            = 4,
240 +               .pixel_clock    = 74250,
241 +       },
242 +};
243 +
244  /*
245   * ---------------------------------------------------------------------------
246   * LCD panel
247 @@ -1714,6 +1876,20 @@ static int omapfb_do_probe(struct platform_device *pdev,
248                 goto cleanup;
249         }
250  
251 +       if (video_mode.name) {
252 +               pr_info("omapfb: using mode %s\n", video_mode.name);
253 +
254 +               fbdev->panel->x_res     = video_mode.x_res;
255 +               fbdev->panel->y_res     = video_mode.y_res;
256 +               fbdev->panel->pixel_clock = video_mode.pixel_clock;
257 +               fbdev->panel->hsw       = video_mode.hsw;
258 +               fbdev->panel->hfp       = video_mode.hfp;
259 +               fbdev->panel->hbp       = video_mode.hbp;
260 +               fbdev->panel->vsw       = video_mode.vsw;
261 +               fbdev->panel->vfp       = video_mode.vfp;
262 +               fbdev->panel->vbp       = video_mode.vbp;
263 +       }
264 +
265         r = fbdev->panel->init(fbdev->panel, fbdev);
266         if (r)
267                 goto cleanup;
268 @@ -1870,6 +2046,17 @@ static struct platform_driver omapfb_driver = {
269         },
270  };
271  
272 +static void __init omapfb_find_mode(char *name, struct video_mode *vmode)
273 +{
274 +       int i;
275 +
276 +       for (i = 0; i < sizeof(video_modes)/sizeof(video_modes[0]); i++)
277 +               if (!strcmp(name, video_modes[i].name)) {
278 +                       *vmode = video_modes[i];
279 +                       break;
280 +               }
281 +}
282 +
283  #ifndef MODULE
284  
285  /* Process kernel command line parameters */
286 @@ -1918,6 +2105,8 @@ static int __init omapfb_setup(char *options)
287                         def_mirror = (simple_strtoul(this_opt + 7, NULL, 0));
288                 else if (!strncmp(this_opt, "manual_update", 13))
289                         manual_update = 1;
290 +               else if (!strncmp(this_opt, "mode:", 5))
291 +                       strncpy(def_mode, this_opt + 5, sizeof(def_mode));
292                 else {
293                         pr_debug("omapfb: invalid option\n");
294                         r = -1;
295 @@ -1939,6 +2128,9 @@ static int __init omapfb_init(void)
296                 return -ENODEV;
297         omapfb_setup(option);
298  #endif
299 +
300 +       omapfb_find_mode(def_mode, &video_mode);
301 +
302         /* Register the driver with LDM */
303         if (platform_driver_register(&omapfb_driver)) {
304                 pr_debug("failed to register omapfb driver\n");
305 @@ -1960,6 +2152,7 @@ module_param_named(vyres, def_vyres, long, 0664);
306  module_param_named(rotate, def_rotate, uint, 0664);
307  module_param_named(mirror, def_mirror, uint, 0664);
308  module_param_named(manual_update, manual_update, bool, 0664);
309 +module_param_string(video_mode, def_mode, sizeof(def_mode), 0664);
310  
311  module_init(omapfb_init);
312  module_exit(omapfb_cleanup);