aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/macmodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/macmodes.c')
-rw-r--r--drivers/video/macmodes.c80
1 files changed, 53 insertions, 27 deletions
diff --git a/drivers/video/macmodes.c b/drivers/video/macmodes.c
index 083f60321ed8..af86c081d2be 100644
--- a/drivers/video/macmodes.c
+++ b/drivers/video/macmodes.c
@@ -33,6 +33,10 @@
33 33
34static const struct fb_videomode mac_modedb[] = { 34static const struct fb_videomode mac_modedb[] = {
35 { 35 {
36 /* 512x384, 60Hz, Non-Interlaced (15.67 MHz dot clock) */
37 "mac2", 60, 512, 384, 63828, 80, 16, 19, 1, 32, 3,
38 0, FB_VMODE_NONINTERLACED
39 }, {
36 /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */ 40 /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */
37 "mac5", 60, 640, 480, 39722, 32, 32, 33, 10, 96, 2, 41 "mac5", 60, 640, 480, 39722, 32, 32, 33, 10, 96, 2,
38 0, FB_VMODE_NONINTERLACED 42 0, FB_VMODE_NONINTERLACED
@@ -41,6 +45,10 @@ static const struct fb_videomode mac_modedb[] = {
41 "mac6", 67, 640, 480, 33334, 80, 80, 39, 3, 64, 3, 45 "mac6", 67, 640, 480, 33334, 80, 80, 39, 3, 64, 3,
42 0, FB_VMODE_NONINTERLACED 46 0, FB_VMODE_NONINTERLACED
43 }, { 47 }, {
48 /* 640x870, 75Hz (portrait), Non-Interlaced (57.28 MHz dot clock) */
49 "mac7", 75, 640, 870, 17457, 80, 32, 42, 3, 80, 3,
50 0, FB_VMODE_NONINTERLACED
51 }, {
44 /* 800x600, 56 Hz, Non-Interlaced (36.00 MHz dotclock) */ 52 /* 800x600, 56 Hz, Non-Interlaced (36.00 MHz dotclock) */
45 "mac9", 56, 800, 600, 27778, 112, 40, 22, 1, 72, 2, 53 "mac9", 56, 800, 600, 27778, 112, 40, 22, 1, 72, 2,
46 FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED 54 FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
@@ -105,10 +113,6 @@ static const struct fb_videomode mac_modedb[] = {
105 "mac1", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen, 113 "mac1", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen,
106 sync, FB_VMODE_INTERLACED 114 sync, FB_VMODE_INTERLACED
107 }, { 115 }, {
108 /* VMODE_512_384_60: 512x384, 60Hz, Non-Interlaced */
109 "mac2", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen,
110 sync, FB_VMODE_NONINTERLACED
111 }, {
112 /* VMODE_640_480_50I: 640x480, 50Hz, Interlaced (PAL) */ 116 /* VMODE_640_480_50I: 640x480, 50Hz, Interlaced (PAL) */
113 "mac3", 50, 640, 480, pixclock, left, right, upper, lower, hslen, vslen, 117 "mac3", 50, 640, 480, pixclock, left, right, upper, lower, hslen, vslen,
114 sync, FB_VMODE_INTERLACED 118 sync, FB_VMODE_INTERLACED
@@ -117,10 +121,6 @@ static const struct fb_videomode mac_modedb[] = {
117 "mac4", 60, 640, 480, pixclock, left, right, upper, lower, hslen, vslen, 121 "mac4", 60, 640, 480, pixclock, left, right, upper, lower, hslen, vslen,
118 sync, FB_VMODE_INTERLACED 122 sync, FB_VMODE_INTERLACED
119 }, { 123 }, {
120 /* VMODE_640_870_75P: 640x870, 75Hz (portrait), Non-Interlaced */
121 "mac7", 75, 640, 870, pixclock, left, right, upper, lower, hslen, vslen,
122 sync, FB_VMODE_NONINTERLACED
123 }, {
124 /* VMODE_768_576_50I: 768x576, 50Hz (PAL full frame), Interlaced */ 124 /* VMODE_768_576_50I: 768x576, 50Hz (PAL full frame), Interlaced */
125 "mac8", 50, 768, 576, pixclock, left, right, upper, lower, hslen, vslen, 125 "mac8", 50, 768, 576, pixclock, left, right, upper, lower, hslen, vslen,
126 sync, FB_VMODE_INTERLACED 126 sync, FB_VMODE_INTERLACED
@@ -134,38 +134,42 @@ static const struct fb_videomode mac_modedb[] = {
134 * 134 *
135 * These MUST be ordered in 135 * These MUST be ordered in
136 * - increasing resolution 136 * - increasing resolution
137 * - decreasing refresh rate 137 * - decreasing pixel clock period
138 */ 138 */
139 139
140static const struct mode_map { 140static const struct mode_map {
141 int vmode; 141 int vmode;
142 const struct fb_videomode *mode; 142 const struct fb_videomode *mode;
143} mac_modes[] = { 143} mac_modes[] = {
144 /* 512x384 */
145 { VMODE_512_384_60, &mac_modedb[0] },
144 /* 640x480 */ 146 /* 640x480 */
145 { VMODE_640_480_67, &mac_modedb[1] }, 147 { VMODE_640_480_60, &mac_modedb[1] },
146 { VMODE_640_480_60, &mac_modedb[0] }, 148 { VMODE_640_480_67, &mac_modedb[2] },
149 /* 640x870 */
150 { VMODE_640_870_75P, &mac_modedb[3] },
147 /* 800x600 */ 151 /* 800x600 */
148 { VMODE_800_600_75, &mac_modedb[5] }, 152 { VMODE_800_600_56, &mac_modedb[4] },
149 { VMODE_800_600_72, &mac_modedb[4] }, 153 { VMODE_800_600_60, &mac_modedb[5] },
150 { VMODE_800_600_60, &mac_modedb[3] }, 154 { VMODE_800_600_75, &mac_modedb[7] },
151 { VMODE_800_600_56, &mac_modedb[2] }, 155 { VMODE_800_600_72, &mac_modedb[6] },
152 /* 832x624 */ 156 /* 832x624 */
153 { VMODE_832_624_75, &mac_modedb[6] }, 157 { VMODE_832_624_75, &mac_modedb[8] },
154 /* 1024x768 */ 158 /* 1024x768 */
155 { VMODE_1024_768_75, &mac_modedb[10] }, 159 { VMODE_1024_768_60, &mac_modedb[9] },
156 { VMODE_1024_768_75V, &mac_modedb[9] }, 160 { VMODE_1024_768_70, &mac_modedb[10] },
157 { VMODE_1024_768_70, &mac_modedb[8] }, 161 { VMODE_1024_768_75V, &mac_modedb[11] },
158 { VMODE_1024_768_60, &mac_modedb[7] }, 162 { VMODE_1024_768_75, &mac_modedb[12] },
159 /* 1152x768 */ 163 /* 1152x768 */
160 { VMODE_1152_768_60, &mac_modedb[14] }, 164 { VMODE_1152_768_60, &mac_modedb[16] },
161 /* 1152x870 */ 165 /* 1152x870 */
162 { VMODE_1152_870_75, &mac_modedb[11] }, 166 { VMODE_1152_870_75, &mac_modedb[13] },
163 /* 1280x960 */ 167 /* 1280x960 */
164 { VMODE_1280_960_75, &mac_modedb[12] }, 168 { VMODE_1280_960_75, &mac_modedb[14] },
165 /* 1280x1024 */ 169 /* 1280x1024 */
166 { VMODE_1280_1024_75, &mac_modedb[13] }, 170 { VMODE_1280_1024_75, &mac_modedb[15] },
167 /* 1600x1024 */ 171 /* 1600x1024 */
168 { VMODE_1600_1024_60, &mac_modedb[15] }, 172 { VMODE_1600_1024_60, &mac_modedb[17] },
169 { -1, NULL } 173 { -1, NULL }
170}; 174};
171 175
@@ -299,7 +303,6 @@ EXPORT_SYMBOL(mac_vmode_to_var);
299int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, 303int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode,
300 int *cmode) 304 int *cmode)
301{ 305{
302 const struct fb_videomode *mode = NULL;
303 const struct mode_map *map; 306 const struct mode_map *map;
304 307
305 if (var->bits_per_pixel <= 8) 308 if (var->bits_per_pixel <= 8)
@@ -311,8 +314,13 @@ int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode,
311 else 314 else
312 return -EINVAL; 315 return -EINVAL;
313 316
317 /*
318 * Find the mac_mode with a matching resolution or failing that, the
319 * closest larger resolution. Skip modes with a shorter pixel clock period.
320 */
314 for (map = mac_modes; map->vmode != -1; map++) { 321 for (map = mac_modes; map->vmode != -1; map++) {
315 mode = map->mode; 322 const struct fb_videomode *mode = map->mode;
323
316 if (var->xres > mode->xres || var->yres > mode->yres) 324 if (var->xres > mode->xres || var->yres > mode->yres)
317 continue; 325 continue;
318 if (var->xres_virtual > mode->xres || var->yres_virtual > mode->yres) 326 if (var->xres_virtual > mode->xres || var->yres_virtual > mode->yres)
@@ -322,6 +330,24 @@ int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode,
322 if ((var->vmode & FB_VMODE_MASK) != mode->vmode) 330 if ((var->vmode & FB_VMODE_MASK) != mode->vmode)
323 continue; 331 continue;
324 *vmode = map->vmode; 332 *vmode = map->vmode;
333
334 /*
335 * Having found a good resolution, find the matching pixel clock
336 * or failing that, the closest longer pixel clock period.
337 */
338 map++;
339 while (map->vmode != -1) {
340 const struct fb_videomode *clk_mode = map->mode;
341
342 if (mode->xres != clk_mode->xres || mode->yres != clk_mode->yres)
343 break;
344 if (var->pixclock > mode->pixclock)
345 break;
346 if (mode->vmode != clk_mode->vmode)
347 continue;
348 *vmode = map->vmode;
349 map++;
350 }
325 return 0; 351 return 0;
326 } 352 }
327 return -EINVAL; 353 return -EINVAL;