aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/via/viafbdev.c
diff options
context:
space:
mode:
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2010-03-10 18:21:38 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-12 18:52:33 -0500
commitbd140691bda491b417a6d1e81b03416b54cb8d8d (patch)
treef19f8fcd1acd4b6ae60ed4ba261e9106f3452793 /drivers/video/via/viafbdev.c
parentdba77f8409eb861b28d295211776d953a8255ec7 (diff)
viafb: rework color checking
Make color checking a bit more tolerant in what values it allows and more fine grained to later support 15 and 30 bits formats. It splits the filling of the color information in var to a seperate function and sets some color related values in var that where previously untouched. This could be a bug fix but at least I don't know any applications that was fooled by not correctly setting the fields in var. At least no regressions are expected. Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Cc: Joseph Chan <JosephChan@via.com.tw> Cc: Scott Fang <ScottFang@viatech.com.cn> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/via/viafbdev.c')
-rw-r--r--drivers/video/via/viafbdev.c61
1 files changed, 56 insertions, 5 deletions
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index bb0f616b7d44..bd8db75236ab 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -60,6 +60,47 @@ static int viafb_pan_display(struct fb_var_screeninfo *var,
60static struct fb_ops viafb_ops; 60static struct fb_ops viafb_ops;
61 61
62 62
63static void viafb_fill_var_color_info(struct fb_var_screeninfo *var, u8 depth)
64{
65 var->grayscale = 0;
66 var->red.msb_right = 0;
67 var->green.msb_right = 0;
68 var->blue.msb_right = 0;
69 var->transp.offset = 0;
70 var->transp.length = 0;
71 var->transp.msb_right = 0;
72 var->nonstd = 0;
73 switch (depth) {
74 case 8:
75 var->bits_per_pixel = 8;
76 var->red.offset = 0;
77 var->green.offset = 0;
78 var->blue.offset = 0;
79 var->red.length = 6;
80 var->green.length = 6;
81 var->blue.length = 6;
82 break;
83 case 16:
84 var->bits_per_pixel = 16;
85 var->red.offset = 11;
86 var->green.offset = 5;
87 var->blue.offset = 0;
88 var->red.length = 5;
89 var->green.length = 6;
90 var->blue.length = 5;
91 break;
92 case 24:
93 var->bits_per_pixel = 32;
94 var->red.offset = 16;
95 var->green.offset = 8;
96 var->blue.offset = 0;
97 var->red.length = 8;
98 var->green.length = 8;
99 var->blue.length = 8;
100 break;
101 }
102}
103
63static void viafb_update_fix(struct fb_info *info) 104static void viafb_update_fix(struct fb_info *info)
64{ 105{
65 u32 bpp = info->var.bits_per_pixel; 106 u32 bpp = info->var.bits_per_pixel;
@@ -81,6 +122,7 @@ static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
81 122
82 fix->type = FB_TYPE_PACKED_PIXELS; 123 fix->type = FB_TYPE_PACKED_PIXELS;
83 fix->type_aux = 0; 124 fix->type_aux = 0;
125 fix->visual = FB_VISUAL_TRUECOLOR;
84 126
85 fix->xpanstep = fix->ywrapstep = 0; 127 fix->xpanstep = fix->ywrapstep = 0;
86 fix->ypanstep = 1; 128 fix->ypanstep = 1;
@@ -103,7 +145,7 @@ static int viafb_release(struct fb_info *info, int user)
103static int viafb_check_var(struct fb_var_screeninfo *var, 145static int viafb_check_var(struct fb_var_screeninfo *var,
104 struct fb_info *info) 146 struct fb_info *info)
105{ 147{
106 int htotal, vtotal; 148 int htotal, vtotal, depth;
107 struct VideoModeTable *vmode_entry; 149 struct VideoModeTable *vmode_entry;
108 struct viafb_par *ppar = info->par; 150 struct viafb_par *ppar = info->par;
109 u32 long_refresh; 151 u32 long_refresh;
@@ -122,13 +164,22 @@ static int viafb_check_var(struct fb_var_screeninfo *var,
122 return -EINVAL; 164 return -EINVAL;
123 } 165 }
124 166
125 if (24 == var->bits_per_pixel) 167 depth = fb_get_color_depth(var, &info->fix);
126 var->bits_per_pixel = 32; 168 if (!depth)
169 depth = var->bits_per_pixel;
127 170
128 if (var->bits_per_pixel != 8 && var->bits_per_pixel != 16 && 171 if (depth < 0 || depth > 32)
129 var->bits_per_pixel != 32)
130 return -EINVAL; 172 return -EINVAL;
173 else if (!depth)
174 depth = 24;
175 else if (depth <= 8)
176 depth = 8;
177 else if (depth <= 16)
178 depth = 16;
179 else
180 depth = 24;
131 181
182 viafb_fill_var_color_info(var, depth);
132 if ((var->xres_virtual * (var->bits_per_pixel >> 3)) & 0x1F) 183 if ((var->xres_virtual * (var->bits_per_pixel >> 3)) & 0x1F)
133 /*32 pixel alignment */ 184 /*32 pixel alignment */
134 var->xres_virtual = (var->xres_virtual + 31) & ~31; 185 var->xres_virtual = (var->xres_virtual + 31) & ~31;