From d876c11a0fd40993136f5cc1e81371ccc6c21a63 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:43:16 +1100 Subject: fbdev: mac_var_to_mode() fix The valkyriefb driver assumes that this logic holds: mac_vmode_to_var(X, cmode, &var); mac_var_to_vmode(&var, &vmode, &cmode); assert(vmode == X); But it doesn't hold because mac_var_to_vmode() can return a mode with a slower pixel clock, even when a match is available. So we end up with this failure: using video mode 11 and color mode 0. valkyriefb: vmode 12 not valid. valkyriefb: can't set default video mode valkyriefb: vmode 12 not valid. Rather than have mac_var_to_mode() return the first reasonable mode it finds, have it return the mode that is closest to the requested one (or the mode with the closest longer pixel clock period if there is no exact match). Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- drivers/video/macmodes.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'drivers/video/macmodes.c') diff --git a/drivers/video/macmodes.c b/drivers/video/macmodes.c index 083f60321ed8..3e11f7425aef 100644 --- a/drivers/video/macmodes.c +++ b/drivers/video/macmodes.c @@ -134,7 +134,7 @@ static const struct fb_videomode mac_modedb[] = { * * These MUST be ordered in * - increasing resolution - * - decreasing refresh rate + * - decreasing pixel clock period */ static const struct mode_map { @@ -142,20 +142,20 @@ static const struct mode_map { const struct fb_videomode *mode; } mac_modes[] = { /* 640x480 */ - { VMODE_640_480_67, &mac_modedb[1] }, { VMODE_640_480_60, &mac_modedb[0] }, + { VMODE_640_480_67, &mac_modedb[1] }, /* 800x600 */ + { VMODE_800_600_56, &mac_modedb[2] }, + { VMODE_800_600_60, &mac_modedb[3] }, { VMODE_800_600_75, &mac_modedb[5] }, { VMODE_800_600_72, &mac_modedb[4] }, - { VMODE_800_600_60, &mac_modedb[3] }, - { VMODE_800_600_56, &mac_modedb[2] }, /* 832x624 */ { VMODE_832_624_75, &mac_modedb[6] }, /* 1024x768 */ - { VMODE_1024_768_75, &mac_modedb[10] }, - { VMODE_1024_768_75V, &mac_modedb[9] }, - { VMODE_1024_768_70, &mac_modedb[8] }, { VMODE_1024_768_60, &mac_modedb[7] }, + { VMODE_1024_768_70, &mac_modedb[8] }, + { VMODE_1024_768_75V, &mac_modedb[9] }, + { VMODE_1024_768_75, &mac_modedb[10] }, /* 1152x768 */ { VMODE_1152_768_60, &mac_modedb[14] }, /* 1152x870 */ @@ -299,7 +299,6 @@ EXPORT_SYMBOL(mac_vmode_to_var); int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, int *cmode) { - const struct fb_videomode *mode = NULL; const struct mode_map *map; if (var->bits_per_pixel <= 8) @@ -311,8 +310,13 @@ int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, else return -EINVAL; + /* + * Find the mac_mode with a matching resolution or failing that, the + * closest larger resolution. Skip modes with a shorter pixel clock period. + */ for (map = mac_modes; map->vmode != -1; map++) { - mode = map->mode; + const struct fb_videomode *mode = map->mode; + if (var->xres > mode->xres || var->yres > mode->yres) continue; if (var->xres_virtual > mode->xres || var->yres_virtual > mode->yres) @@ -322,6 +326,24 @@ int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, if ((var->vmode & FB_VMODE_MASK) != mode->vmode) continue; *vmode = map->vmode; + + /* + * Having found a good resolution, find the matching pixel clock + * or failing that, the closest longer pixel clock period. + */ + map++; + while (map->vmode != -1) { + const struct fb_videomode *clk_mode = map->mode; + + if (mode->xres != clk_mode->xres || mode->yres != clk_mode->yres) + break; + if (var->pixclock > mode->pixclock) + break; + if (mode->vmode != clk_mode->vmode) + continue; + *vmode = map->vmode; + map++; + } return 0; } return -EINVAL; -- cgit v1.2.3 From 1bb63845d122750124807e5aeb733d2276e5fb7d Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:47:02 +1100 Subject: fbdev: add some missing mac modes Add the missing mac video modes for the Portrait and 12" RGB displays. The specs come from the Mac LC III developer note. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- drivers/video/macmodes.c | 52 ++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'drivers/video/macmodes.c') diff --git a/drivers/video/macmodes.c b/drivers/video/macmodes.c index 3e11f7425aef..af86c081d2be 100644 --- a/drivers/video/macmodes.c +++ b/drivers/video/macmodes.c @@ -33,6 +33,10 @@ static const struct fb_videomode mac_modedb[] = { { + /* 512x384, 60Hz, Non-Interlaced (15.67 MHz dot clock) */ + "mac2", 60, 512, 384, 63828, 80, 16, 19, 1, 32, 3, + 0, FB_VMODE_NONINTERLACED + }, { /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */ "mac5", 60, 640, 480, 39722, 32, 32, 33, 10, 96, 2, 0, FB_VMODE_NONINTERLACED @@ -40,6 +44,10 @@ static const struct fb_videomode mac_modedb[] = { /* 640x480, 67Hz, Non-Interlaced (30.0 MHz dotclock) */ "mac6", 67, 640, 480, 33334, 80, 80, 39, 3, 64, 3, 0, FB_VMODE_NONINTERLACED + }, { + /* 640x870, 75Hz (portrait), Non-Interlaced (57.28 MHz dot clock) */ + "mac7", 75, 640, 870, 17457, 80, 32, 42, 3, 80, 3, + 0, FB_VMODE_NONINTERLACED }, { /* 800x600, 56 Hz, Non-Interlaced (36.00 MHz dotclock) */ "mac9", 56, 800, 600, 27778, 112, 40, 22, 1, 72, 2, @@ -104,10 +112,6 @@ static const struct fb_videomode mac_modedb[] = { /* VMODE_512_384_60I: 512x384, 60Hz, Interlaced (NTSC) */ "mac1", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen, sync, FB_VMODE_INTERLACED - }, { - /* VMODE_512_384_60: 512x384, 60Hz, Non-Interlaced */ - "mac2", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen, - sync, FB_VMODE_NONINTERLACED }, { /* VMODE_640_480_50I: 640x480, 50Hz, Interlaced (PAL) */ "mac3", 50, 640, 480, pixclock, left, right, upper, lower, hslen, vslen, @@ -116,10 +120,6 @@ static const struct fb_videomode mac_modedb[] = { /* VMODE_640_480_60I: 640x480, 60Hz, Interlaced (NTSC) */ "mac4", 60, 640, 480, pixclock, left, right, upper, lower, hslen, vslen, sync, FB_VMODE_INTERLACED - }, { - /* VMODE_640_870_75P: 640x870, 75Hz (portrait), Non-Interlaced */ - "mac7", 75, 640, 870, pixclock, left, right, upper, lower, hslen, vslen, - sync, FB_VMODE_NONINTERLACED }, { /* VMODE_768_576_50I: 768x576, 50Hz (PAL full frame), Interlaced */ "mac8", 50, 768, 576, pixclock, left, right, upper, lower, hslen, vslen, @@ -141,31 +141,35 @@ static const struct mode_map { int vmode; const struct fb_videomode *mode; } mac_modes[] = { + /* 512x384 */ + { VMODE_512_384_60, &mac_modedb[0] }, /* 640x480 */ - { VMODE_640_480_60, &mac_modedb[0] }, - { VMODE_640_480_67, &mac_modedb[1] }, + { VMODE_640_480_60, &mac_modedb[1] }, + { VMODE_640_480_67, &mac_modedb[2] }, + /* 640x870 */ + { VMODE_640_870_75P, &mac_modedb[3] }, /* 800x600 */ - { VMODE_800_600_56, &mac_modedb[2] }, - { VMODE_800_600_60, &mac_modedb[3] }, - { VMODE_800_600_75, &mac_modedb[5] }, - { VMODE_800_600_72, &mac_modedb[4] }, + { VMODE_800_600_56, &mac_modedb[4] }, + { VMODE_800_600_60, &mac_modedb[5] }, + { VMODE_800_600_75, &mac_modedb[7] }, + { VMODE_800_600_72, &mac_modedb[6] }, /* 832x624 */ - { VMODE_832_624_75, &mac_modedb[6] }, + { VMODE_832_624_75, &mac_modedb[8] }, /* 1024x768 */ - { VMODE_1024_768_60, &mac_modedb[7] }, - { VMODE_1024_768_70, &mac_modedb[8] }, - { VMODE_1024_768_75V, &mac_modedb[9] }, - { VMODE_1024_768_75, &mac_modedb[10] }, + { VMODE_1024_768_60, &mac_modedb[9] }, + { VMODE_1024_768_70, &mac_modedb[10] }, + { VMODE_1024_768_75V, &mac_modedb[11] }, + { VMODE_1024_768_75, &mac_modedb[12] }, /* 1152x768 */ - { VMODE_1152_768_60, &mac_modedb[14] }, + { VMODE_1152_768_60, &mac_modedb[16] }, /* 1152x870 */ - { VMODE_1152_870_75, &mac_modedb[11] }, + { VMODE_1152_870_75, &mac_modedb[13] }, /* 1280x960 */ - { VMODE_1280_960_75, &mac_modedb[12] }, + { VMODE_1280_960_75, &mac_modedb[14] }, /* 1280x1024 */ - { VMODE_1280_1024_75, &mac_modedb[13] }, + { VMODE_1280_1024_75, &mac_modedb[15] }, /* 1600x1024 */ - { VMODE_1600_1024_60, &mac_modedb[15] }, + { VMODE_1600_1024_60, &mac_modedb[17] }, { -1, NULL } }; -- cgit v1.2.3