Commit 9f5610e20b322347ce3e55e75a78965717a62412

Authored by Peter Huewe
Committed by Florian Tobias Schandinat
1 parent c1f58f1e1e

video/via: Convert to kstrtou8_from_user

This patch replaces the code for getting an number from a
userspace buffer by a simple call to kstrou8_from_user.
This makes it easier to read and less error prone.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Acked-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>

Showing 1 changed file with 12 additions and 22 deletions Inline Diff

drivers/video/via/viafbdev.c
1 /* 1 /*
2 * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved. 2 * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. 3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4 4
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public 6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation; 7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version. 8 * either version 2, or (at your option) any later version.
9 9
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even 11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR 12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE.See the GNU General Public License 13 * A PARTICULAR PURPOSE.See the GNU General Public License
14 * for more details. 14 * for more details.
15 15
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */ 20 */
21 21
22 #include <linux/module.h> 22 #include <linux/module.h>
23 #include <linux/seq_file.h> 23 #include <linux/seq_file.h>
24 #include <linux/slab.h> 24 #include <linux/slab.h>
25 #include <linux/stat.h> 25 #include <linux/stat.h>
26 #include <linux/via-core.h> 26 #include <linux/via-core.h>
27 #include <linux/via_i2c.h> 27 #include <linux/via_i2c.h>
28 #include <asm/olpc.h> 28 #include <asm/olpc.h>
29 29
30 #define _MASTER_FILE 30 #define _MASTER_FILE
31 #include "global.h" 31 #include "global.h"
32 32
33 static char *viafb_name = "Via"; 33 static char *viafb_name = "Via";
34 static u32 pseudo_pal[17]; 34 static u32 pseudo_pal[17];
35 35
36 /* video mode */ 36 /* video mode */
37 static char *viafb_mode; 37 static char *viafb_mode;
38 static char *viafb_mode1; 38 static char *viafb_mode1;
39 static int viafb_bpp = 32; 39 static int viafb_bpp = 32;
40 static int viafb_bpp1 = 32; 40 static int viafb_bpp1 = 32;
41 41
42 static unsigned int viafb_second_offset; 42 static unsigned int viafb_second_offset;
43 static int viafb_second_size; 43 static int viafb_second_size;
44 44
45 static int viafb_accel = 1; 45 static int viafb_accel = 1;
46 46
47 /* Added for specifying active devices.*/ 47 /* Added for specifying active devices.*/
48 static char *viafb_active_dev; 48 static char *viafb_active_dev;
49 49
50 /*Added for specify lcd output port*/ 50 /*Added for specify lcd output port*/
51 static char *viafb_lcd_port = ""; 51 static char *viafb_lcd_port = "";
52 static char *viafb_dvi_port = ""; 52 static char *viafb_dvi_port = "";
53 53
54 static void retrieve_device_setting(struct viafb_ioctl_setting 54 static void retrieve_device_setting(struct viafb_ioctl_setting
55 *setting_info); 55 *setting_info);
56 static int viafb_pan_display(struct fb_var_screeninfo *var, 56 static int viafb_pan_display(struct fb_var_screeninfo *var,
57 struct fb_info *info); 57 struct fb_info *info);
58 58
59 static struct fb_ops viafb_ops; 59 static struct fb_ops viafb_ops;
60 60
61 /* supported output devices on each IGP 61 /* supported output devices on each IGP
62 * only CX700, VX800, VX855, VX900 were documented 62 * only CX700, VX800, VX855, VX900 were documented
63 * VIA_CRT should be everywhere 63 * VIA_CRT should be everywhere
64 * VIA_6C can be onle pre-CX700 (probably only on CLE266) as 6C is used for PLL 64 * VIA_6C can be onle pre-CX700 (probably only on CLE266) as 6C is used for PLL
65 * source selection on CX700 and later 65 * source selection on CX700 and later
66 * K400 seems to support VIA_96, VIA_DVP1, VIA_LVDS{1,2} as in viamode.c 66 * K400 seems to support VIA_96, VIA_DVP1, VIA_LVDS{1,2} as in viamode.c
67 */ 67 */
68 static const u32 supported_odev_map[] = { 68 static const u32 supported_odev_map[] = {
69 [UNICHROME_CLE266] = VIA_CRT | VIA_LDVP0 | VIA_LDVP1, 69 [UNICHROME_CLE266] = VIA_CRT | VIA_LDVP0 | VIA_LDVP1,
70 [UNICHROME_K400] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 70 [UNICHROME_K400] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1
71 | VIA_LVDS2, 71 | VIA_LVDS2,
72 [UNICHROME_K800] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 72 [UNICHROME_K800] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1
73 | VIA_LVDS2, 73 | VIA_LVDS2,
74 [UNICHROME_PM800] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 74 [UNICHROME_PM800] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1
75 | VIA_LVDS2, 75 | VIA_LVDS2,
76 [UNICHROME_CN700] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 76 [UNICHROME_CN700] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1
77 | VIA_LVDS2, 77 | VIA_LVDS2,
78 [UNICHROME_CX700] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, 78 [UNICHROME_CX700] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
79 [UNICHROME_CN750] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, 79 [UNICHROME_CN750] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
80 [UNICHROME_K8M890] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, 80 [UNICHROME_K8M890] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
81 [UNICHROME_P4M890] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, 81 [UNICHROME_P4M890] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
82 [UNICHROME_P4M900] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, 82 [UNICHROME_P4M900] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
83 [UNICHROME_VX800] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, 83 [UNICHROME_VX800] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
84 [UNICHROME_VX855] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, 84 [UNICHROME_VX855] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
85 [UNICHROME_VX900] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, 85 [UNICHROME_VX900] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
86 }; 86 };
87 87
88 static void viafb_fill_var_color_info(struct fb_var_screeninfo *var, u8 depth) 88 static void viafb_fill_var_color_info(struct fb_var_screeninfo *var, u8 depth)
89 { 89 {
90 var->grayscale = 0; 90 var->grayscale = 0;
91 var->red.msb_right = 0; 91 var->red.msb_right = 0;
92 var->green.msb_right = 0; 92 var->green.msb_right = 0;
93 var->blue.msb_right = 0; 93 var->blue.msb_right = 0;
94 var->transp.offset = 0; 94 var->transp.offset = 0;
95 var->transp.length = 0; 95 var->transp.length = 0;
96 var->transp.msb_right = 0; 96 var->transp.msb_right = 0;
97 var->nonstd = 0; 97 var->nonstd = 0;
98 switch (depth) { 98 switch (depth) {
99 case 8: 99 case 8:
100 var->bits_per_pixel = 8; 100 var->bits_per_pixel = 8;
101 var->red.offset = 0; 101 var->red.offset = 0;
102 var->green.offset = 0; 102 var->green.offset = 0;
103 var->blue.offset = 0; 103 var->blue.offset = 0;
104 var->red.length = 8; 104 var->red.length = 8;
105 var->green.length = 8; 105 var->green.length = 8;
106 var->blue.length = 8; 106 var->blue.length = 8;
107 break; 107 break;
108 case 15: 108 case 15:
109 var->bits_per_pixel = 16; 109 var->bits_per_pixel = 16;
110 var->red.offset = 10; 110 var->red.offset = 10;
111 var->green.offset = 5; 111 var->green.offset = 5;
112 var->blue.offset = 0; 112 var->blue.offset = 0;
113 var->red.length = 5; 113 var->red.length = 5;
114 var->green.length = 5; 114 var->green.length = 5;
115 var->blue.length = 5; 115 var->blue.length = 5;
116 break; 116 break;
117 case 16: 117 case 16:
118 var->bits_per_pixel = 16; 118 var->bits_per_pixel = 16;
119 var->red.offset = 11; 119 var->red.offset = 11;
120 var->green.offset = 5; 120 var->green.offset = 5;
121 var->blue.offset = 0; 121 var->blue.offset = 0;
122 var->red.length = 5; 122 var->red.length = 5;
123 var->green.length = 6; 123 var->green.length = 6;
124 var->blue.length = 5; 124 var->blue.length = 5;
125 break; 125 break;
126 case 24: 126 case 24:
127 var->bits_per_pixel = 32; 127 var->bits_per_pixel = 32;
128 var->red.offset = 16; 128 var->red.offset = 16;
129 var->green.offset = 8; 129 var->green.offset = 8;
130 var->blue.offset = 0; 130 var->blue.offset = 0;
131 var->red.length = 8; 131 var->red.length = 8;
132 var->green.length = 8; 132 var->green.length = 8;
133 var->blue.length = 8; 133 var->blue.length = 8;
134 break; 134 break;
135 case 30: 135 case 30:
136 var->bits_per_pixel = 32; 136 var->bits_per_pixel = 32;
137 var->red.offset = 20; 137 var->red.offset = 20;
138 var->green.offset = 10; 138 var->green.offset = 10;
139 var->blue.offset = 0; 139 var->blue.offset = 0;
140 var->red.length = 10; 140 var->red.length = 10;
141 var->green.length = 10; 141 var->green.length = 10;
142 var->blue.length = 10; 142 var->blue.length = 10;
143 break; 143 break;
144 } 144 }
145 } 145 }
146 146
147 static void viafb_update_fix(struct fb_info *info) 147 static void viafb_update_fix(struct fb_info *info)
148 { 148 {
149 u32 bpp = info->var.bits_per_pixel; 149 u32 bpp = info->var.bits_per_pixel;
150 150
151 info->fix.visual = 151 info->fix.visual =
152 bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; 152 bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
153 info->fix.line_length = ALIGN(info->var.xres_virtual * bpp / 8, 153 info->fix.line_length = ALIGN(info->var.xres_virtual * bpp / 8,
154 VIA_PITCH_SIZE); 154 VIA_PITCH_SIZE);
155 } 155 }
156 156
157 static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix, 157 static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
158 struct viafb_par *viaparinfo) 158 struct viafb_par *viaparinfo)
159 { 159 {
160 memset(fix, 0, sizeof(struct fb_fix_screeninfo)); 160 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
161 strcpy(fix->id, viafb_name); 161 strcpy(fix->id, viafb_name);
162 162
163 fix->smem_start = viaparinfo->fbmem; 163 fix->smem_start = viaparinfo->fbmem;
164 fix->smem_len = viaparinfo->fbmem_free; 164 fix->smem_len = viaparinfo->fbmem_free;
165 165
166 fix->type = FB_TYPE_PACKED_PIXELS; 166 fix->type = FB_TYPE_PACKED_PIXELS;
167 fix->type_aux = 0; 167 fix->type_aux = 0;
168 fix->visual = FB_VISUAL_TRUECOLOR; 168 fix->visual = FB_VISUAL_TRUECOLOR;
169 169
170 fix->xpanstep = fix->ywrapstep = 0; 170 fix->xpanstep = fix->ywrapstep = 0;
171 fix->ypanstep = 1; 171 fix->ypanstep = 1;
172 172
173 /* Just tell the accel name */ 173 /* Just tell the accel name */
174 viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME; 174 viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME;
175 } 175 }
176 static int viafb_open(struct fb_info *info, int user) 176 static int viafb_open(struct fb_info *info, int user)
177 { 177 {
178 DEBUG_MSG(KERN_INFO "viafb_open!\n"); 178 DEBUG_MSG(KERN_INFO "viafb_open!\n");
179 return 0; 179 return 0;
180 } 180 }
181 181
182 static int viafb_release(struct fb_info *info, int user) 182 static int viafb_release(struct fb_info *info, int user)
183 { 183 {
184 DEBUG_MSG(KERN_INFO "viafb_release!\n"); 184 DEBUG_MSG(KERN_INFO "viafb_release!\n");
185 return 0; 185 return 0;
186 } 186 }
187 187
188 static inline int get_var_refresh(struct fb_var_screeninfo *var) 188 static inline int get_var_refresh(struct fb_var_screeninfo *var)
189 { 189 {
190 u32 htotal, vtotal; 190 u32 htotal, vtotal;
191 191
192 htotal = var->left_margin + var->xres + var->right_margin 192 htotal = var->left_margin + var->xres + var->right_margin
193 + var->hsync_len; 193 + var->hsync_len;
194 vtotal = var->upper_margin + var->yres + var->lower_margin 194 vtotal = var->upper_margin + var->yres + var->lower_margin
195 + var->vsync_len; 195 + var->vsync_len;
196 return PICOS2KHZ(var->pixclock) * 1000 / (htotal * vtotal); 196 return PICOS2KHZ(var->pixclock) * 1000 / (htotal * vtotal);
197 } 197 }
198 198
199 static int viafb_check_var(struct fb_var_screeninfo *var, 199 static int viafb_check_var(struct fb_var_screeninfo *var,
200 struct fb_info *info) 200 struct fb_info *info)
201 { 201 {
202 int depth, refresh; 202 int depth, refresh;
203 struct viafb_par *ppar = info->par; 203 struct viafb_par *ppar = info->par;
204 u32 line; 204 u32 line;
205 205
206 DEBUG_MSG(KERN_INFO "viafb_check_var!\n"); 206 DEBUG_MSG(KERN_INFO "viafb_check_var!\n");
207 /* Sanity check */ 207 /* Sanity check */
208 /* HW neither support interlacte nor double-scaned mode */ 208 /* HW neither support interlacte nor double-scaned mode */
209 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE) 209 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE)
210 return -EINVAL; 210 return -EINVAL;
211 211
212 /* the refresh rate is not important here, as we only want to know 212 /* the refresh rate is not important here, as we only want to know
213 * whether the resolution exists 213 * whether the resolution exists
214 */ 214 */
215 if (!viafb_get_best_mode(var->xres, var->yres, 60)) { 215 if (!viafb_get_best_mode(var->xres, var->yres, 60)) {
216 DEBUG_MSG(KERN_INFO 216 DEBUG_MSG(KERN_INFO
217 "viafb: Mode %dx%dx%d not supported!!\n", 217 "viafb: Mode %dx%dx%d not supported!!\n",
218 var->xres, var->yres, var->bits_per_pixel); 218 var->xres, var->yres, var->bits_per_pixel);
219 return -EINVAL; 219 return -EINVAL;
220 } 220 }
221 221
222 depth = fb_get_color_depth(var, &info->fix); 222 depth = fb_get_color_depth(var, &info->fix);
223 if (!depth) 223 if (!depth)
224 depth = var->bits_per_pixel; 224 depth = var->bits_per_pixel;
225 225
226 if (depth < 0 || depth > 32) 226 if (depth < 0 || depth > 32)
227 return -EINVAL; 227 return -EINVAL;
228 else if (!depth) 228 else if (!depth)
229 depth = 24; 229 depth = 24;
230 else if (depth == 15 && viafb_dual_fb && ppar->iga_path == IGA1) 230 else if (depth == 15 && viafb_dual_fb && ppar->iga_path == IGA1)
231 depth = 15; 231 depth = 15;
232 else if (depth == 30) 232 else if (depth == 30)
233 depth = 30; 233 depth = 30;
234 else if (depth <= 8) 234 else if (depth <= 8)
235 depth = 8; 235 depth = 8;
236 else if (depth <= 16) 236 else if (depth <= 16)
237 depth = 16; 237 depth = 16;
238 else 238 else
239 depth = 24; 239 depth = 24;
240 240
241 viafb_fill_var_color_info(var, depth); 241 viafb_fill_var_color_info(var, depth);
242 if (var->xres_virtual < var->xres) 242 if (var->xres_virtual < var->xres)
243 var->xres_virtual = var->xres; 243 var->xres_virtual = var->xres;
244 244
245 line = ALIGN(var->xres_virtual * var->bits_per_pixel / 8, 245 line = ALIGN(var->xres_virtual * var->bits_per_pixel / 8,
246 VIA_PITCH_SIZE); 246 VIA_PITCH_SIZE);
247 if (line > VIA_PITCH_MAX || line * var->yres_virtual > ppar->memsize) 247 if (line > VIA_PITCH_MAX || line * var->yres_virtual > ppar->memsize)
248 return -EINVAL; 248 return -EINVAL;
249 249
250 /* Based on var passed in to calculate the refresh, 250 /* Based on var passed in to calculate the refresh,
251 * because our driver use some modes special. 251 * because our driver use some modes special.
252 */ 252 */
253 refresh = viafb_get_refresh(var->xres, var->yres, 253 refresh = viafb_get_refresh(var->xres, var->yres,
254 get_var_refresh(var)); 254 get_var_refresh(var));
255 255
256 /* Adjust var according to our driver's own table */ 256 /* Adjust var according to our driver's own table */
257 viafb_fill_var_timing_info(var, 257 viafb_fill_var_timing_info(var,
258 viafb_get_best_mode(var->xres, var->yres, refresh)); 258 viafb_get_best_mode(var->xres, var->yres, refresh));
259 if (var->accel_flags & FB_ACCELF_TEXT && 259 if (var->accel_flags & FB_ACCELF_TEXT &&
260 !ppar->shared->vdev->engine_mmio) 260 !ppar->shared->vdev->engine_mmio)
261 var->accel_flags = 0; 261 var->accel_flags = 0;
262 262
263 return 0; 263 return 0;
264 } 264 }
265 265
266 static int viafb_set_par(struct fb_info *info) 266 static int viafb_set_par(struct fb_info *info)
267 { 267 {
268 struct viafb_par *viapar = info->par; 268 struct viafb_par *viapar = info->par;
269 int refresh; 269 int refresh;
270 DEBUG_MSG(KERN_INFO "viafb_set_par!\n"); 270 DEBUG_MSG(KERN_INFO "viafb_set_par!\n");
271 271
272 viafb_update_fix(info); 272 viafb_update_fix(info);
273 viapar->depth = fb_get_color_depth(&info->var, &info->fix); 273 viapar->depth = fb_get_color_depth(&info->var, &info->fix);
274 viafb_update_device_setting(viafbinfo->var.xres, viafbinfo->var.yres, 274 viafb_update_device_setting(viafbinfo->var.xres, viafbinfo->var.yres,
275 viafbinfo->var.bits_per_pixel, 0); 275 viafbinfo->var.bits_per_pixel, 0);
276 276
277 if (viafb_dual_fb) { 277 if (viafb_dual_fb) {
278 viafb_update_device_setting(viafbinfo1->var.xres, 278 viafb_update_device_setting(viafbinfo1->var.xres,
279 viafbinfo1->var.yres, viafbinfo1->var.bits_per_pixel, 279 viafbinfo1->var.yres, viafbinfo1->var.bits_per_pixel,
280 1); 280 1);
281 } else if (viafb_SAMM_ON == 1) { 281 } else if (viafb_SAMM_ON == 1) {
282 DEBUG_MSG(KERN_INFO 282 DEBUG_MSG(KERN_INFO
283 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n", 283 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
284 viafb_second_xres, viafb_second_yres, viafb_bpp1); 284 viafb_second_xres, viafb_second_yres, viafb_bpp1);
285 285
286 viafb_update_device_setting(viafb_second_xres, 286 viafb_update_device_setting(viafb_second_xres,
287 viafb_second_yres, viafb_bpp1, 1); 287 viafb_second_yres, viafb_bpp1, 1);
288 } 288 }
289 289
290 refresh = get_var_refresh(&info->var); 290 refresh = get_var_refresh(&info->var);
291 if (viafb_dual_fb && viapar->iga_path == IGA2) { 291 if (viafb_dual_fb && viapar->iga_path == IGA2) {
292 viafb_bpp1 = info->var.bits_per_pixel; 292 viafb_bpp1 = info->var.bits_per_pixel;
293 viafb_refresh1 = refresh; 293 viafb_refresh1 = refresh;
294 } else { 294 } else {
295 viafb_bpp = info->var.bits_per_pixel; 295 viafb_bpp = info->var.bits_per_pixel;
296 viafb_refresh = refresh; 296 viafb_refresh = refresh;
297 } 297 }
298 298
299 if (info->var.accel_flags & FB_ACCELF_TEXT) 299 if (info->var.accel_flags & FB_ACCELF_TEXT)
300 info->flags &= ~FBINFO_HWACCEL_DISABLED; 300 info->flags &= ~FBINFO_HWACCEL_DISABLED;
301 else 301 else
302 info->flags |= FBINFO_HWACCEL_DISABLED; 302 info->flags |= FBINFO_HWACCEL_DISABLED;
303 viafb_setmode(); 303 viafb_setmode();
304 viafb_pan_display(&info->var, info); 304 viafb_pan_display(&info->var, info);
305 305
306 return 0; 306 return 0;
307 } 307 }
308 308
309 /* Set one color register */ 309 /* Set one color register */
310 static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green, 310 static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green,
311 unsigned blue, unsigned transp, struct fb_info *info) 311 unsigned blue, unsigned transp, struct fb_info *info)
312 { 312 {
313 struct viafb_par *viapar = info->par; 313 struct viafb_par *viapar = info->par;
314 u32 r, g, b; 314 u32 r, g, b;
315 315
316 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) { 316 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) {
317 if (regno > 255) 317 if (regno > 255)
318 return -EINVAL; 318 return -EINVAL;
319 319
320 if (!viafb_dual_fb || viapar->iga_path == IGA1) 320 if (!viafb_dual_fb || viapar->iga_path == IGA1)
321 viafb_set_primary_color_register(regno, red >> 8, 321 viafb_set_primary_color_register(regno, red >> 8,
322 green >> 8, blue >> 8); 322 green >> 8, blue >> 8);
323 323
324 if (!viafb_dual_fb || viapar->iga_path == IGA2) 324 if (!viafb_dual_fb || viapar->iga_path == IGA2)
325 viafb_set_secondary_color_register(regno, red >> 8, 325 viafb_set_secondary_color_register(regno, red >> 8,
326 green >> 8, blue >> 8); 326 green >> 8, blue >> 8);
327 } else { 327 } else {
328 if (regno > 15) 328 if (regno > 15)
329 return -EINVAL; 329 return -EINVAL;
330 330
331 r = (red >> (16 - info->var.red.length)) 331 r = (red >> (16 - info->var.red.length))
332 << info->var.red.offset; 332 << info->var.red.offset;
333 b = (blue >> (16 - info->var.blue.length)) 333 b = (blue >> (16 - info->var.blue.length))
334 << info->var.blue.offset; 334 << info->var.blue.offset;
335 g = (green >> (16 - info->var.green.length)) 335 g = (green >> (16 - info->var.green.length))
336 << info->var.green.offset; 336 << info->var.green.offset;
337 ((u32 *) info->pseudo_palette)[regno] = r | g | b; 337 ((u32 *) info->pseudo_palette)[regno] = r | g | b;
338 } 338 }
339 339
340 return 0; 340 return 0;
341 } 341 }
342 342
343 static int viafb_pan_display(struct fb_var_screeninfo *var, 343 static int viafb_pan_display(struct fb_var_screeninfo *var,
344 struct fb_info *info) 344 struct fb_info *info)
345 { 345 {
346 struct viafb_par *viapar = info->par; 346 struct viafb_par *viapar = info->par;
347 u32 vram_addr = viapar->vram_addr 347 u32 vram_addr = viapar->vram_addr
348 + var->yoffset * info->fix.line_length 348 + var->yoffset * info->fix.line_length
349 + var->xoffset * info->var.bits_per_pixel / 8; 349 + var->xoffset * info->var.bits_per_pixel / 8;
350 350
351 DEBUG_MSG(KERN_DEBUG "viafb_pan_display, address = %d\n", vram_addr); 351 DEBUG_MSG(KERN_DEBUG "viafb_pan_display, address = %d\n", vram_addr);
352 if (!viafb_dual_fb) { 352 if (!viafb_dual_fb) {
353 via_set_primary_address(vram_addr); 353 via_set_primary_address(vram_addr);
354 via_set_secondary_address(vram_addr); 354 via_set_secondary_address(vram_addr);
355 } else if (viapar->iga_path == IGA1) 355 } else if (viapar->iga_path == IGA1)
356 via_set_primary_address(vram_addr); 356 via_set_primary_address(vram_addr);
357 else 357 else
358 via_set_secondary_address(vram_addr); 358 via_set_secondary_address(vram_addr);
359 359
360 return 0; 360 return 0;
361 } 361 }
362 362
363 static int viafb_blank(int blank_mode, struct fb_info *info) 363 static int viafb_blank(int blank_mode, struct fb_info *info)
364 { 364 {
365 DEBUG_MSG(KERN_INFO "viafb_blank!\n"); 365 DEBUG_MSG(KERN_INFO "viafb_blank!\n");
366 /* clear DPMS setting */ 366 /* clear DPMS setting */
367 367
368 switch (blank_mode) { 368 switch (blank_mode) {
369 case FB_BLANK_UNBLANK: 369 case FB_BLANK_UNBLANK:
370 /* Screen: On, HSync: On, VSync: On */ 370 /* Screen: On, HSync: On, VSync: On */
371 /* control CRT monitor power management */ 371 /* control CRT monitor power management */
372 via_set_state(VIA_CRT, VIA_STATE_ON); 372 via_set_state(VIA_CRT, VIA_STATE_ON);
373 break; 373 break;
374 case FB_BLANK_HSYNC_SUSPEND: 374 case FB_BLANK_HSYNC_SUSPEND:
375 /* Screen: Off, HSync: Off, VSync: On */ 375 /* Screen: Off, HSync: Off, VSync: On */
376 /* control CRT monitor power management */ 376 /* control CRT monitor power management */
377 via_set_state(VIA_CRT, VIA_STATE_STANDBY); 377 via_set_state(VIA_CRT, VIA_STATE_STANDBY);
378 break; 378 break;
379 case FB_BLANK_VSYNC_SUSPEND: 379 case FB_BLANK_VSYNC_SUSPEND:
380 /* Screen: Off, HSync: On, VSync: Off */ 380 /* Screen: Off, HSync: On, VSync: Off */
381 /* control CRT monitor power management */ 381 /* control CRT monitor power management */
382 via_set_state(VIA_CRT, VIA_STATE_SUSPEND); 382 via_set_state(VIA_CRT, VIA_STATE_SUSPEND);
383 break; 383 break;
384 case FB_BLANK_POWERDOWN: 384 case FB_BLANK_POWERDOWN:
385 /* Screen: Off, HSync: Off, VSync: Off */ 385 /* Screen: Off, HSync: Off, VSync: Off */
386 /* control CRT monitor power management */ 386 /* control CRT monitor power management */
387 via_set_state(VIA_CRT, VIA_STATE_OFF); 387 via_set_state(VIA_CRT, VIA_STATE_OFF);
388 break; 388 break;
389 } 389 }
390 390
391 return 0; 391 return 0;
392 } 392 }
393 393
394 static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) 394 static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
395 { 395 {
396 union { 396 union {
397 struct viafb_ioctl_mode viamode; 397 struct viafb_ioctl_mode viamode;
398 struct viafb_ioctl_samm viasamm; 398 struct viafb_ioctl_samm viasamm;
399 struct viafb_driver_version driver_version; 399 struct viafb_driver_version driver_version;
400 struct fb_var_screeninfo sec_var; 400 struct fb_var_screeninfo sec_var;
401 struct _panel_size_pos_info panel_pos_size_para; 401 struct _panel_size_pos_info panel_pos_size_para;
402 struct viafb_ioctl_setting viafb_setting; 402 struct viafb_ioctl_setting viafb_setting;
403 struct device_t active_dev; 403 struct device_t active_dev;
404 } u; 404 } u;
405 u32 state_info = 0; 405 u32 state_info = 0;
406 u32 *viafb_gamma_table; 406 u32 *viafb_gamma_table;
407 char driver_name[] = "viafb"; 407 char driver_name[] = "viafb";
408 408
409 u32 __user *argp = (u32 __user *) arg; 409 u32 __user *argp = (u32 __user *) arg;
410 u32 gpu32; 410 u32 gpu32;
411 411
412 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd); 412 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
413 printk(KERN_WARNING "viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n"); 413 printk(KERN_WARNING "viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n");
414 memset(&u, 0, sizeof(u)); 414 memset(&u, 0, sizeof(u));
415 415
416 switch (cmd) { 416 switch (cmd) {
417 case VIAFB_GET_CHIP_INFO: 417 case VIAFB_GET_CHIP_INFO:
418 if (copy_to_user(argp, viaparinfo->chip_info, 418 if (copy_to_user(argp, viaparinfo->chip_info,
419 sizeof(struct chip_information))) 419 sizeof(struct chip_information)))
420 return -EFAULT; 420 return -EFAULT;
421 break; 421 break;
422 case VIAFB_GET_INFO_SIZE: 422 case VIAFB_GET_INFO_SIZE:
423 return put_user((u32)sizeof(struct viafb_ioctl_info), argp); 423 return put_user((u32)sizeof(struct viafb_ioctl_info), argp);
424 case VIAFB_GET_INFO: 424 case VIAFB_GET_INFO:
425 return viafb_ioctl_get_viafb_info(arg); 425 return viafb_ioctl_get_viafb_info(arg);
426 case VIAFB_HOTPLUG: 426 case VIAFB_HOTPLUG:
427 return put_user(viafb_ioctl_hotplug(info->var.xres, 427 return put_user(viafb_ioctl_hotplug(info->var.xres,
428 info->var.yres, 428 info->var.yres,
429 info->var.bits_per_pixel), argp); 429 info->var.bits_per_pixel), argp);
430 case VIAFB_SET_HOTPLUG_FLAG: 430 case VIAFB_SET_HOTPLUG_FLAG:
431 if (copy_from_user(&gpu32, argp, sizeof(gpu32))) 431 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
432 return -EFAULT; 432 return -EFAULT;
433 viafb_hotplug = (gpu32) ? 1 : 0; 433 viafb_hotplug = (gpu32) ? 1 : 0;
434 break; 434 break;
435 case VIAFB_GET_RESOLUTION: 435 case VIAFB_GET_RESOLUTION:
436 u.viamode.xres = (u32) viafb_hotplug_Xres; 436 u.viamode.xres = (u32) viafb_hotplug_Xres;
437 u.viamode.yres = (u32) viafb_hotplug_Yres; 437 u.viamode.yres = (u32) viafb_hotplug_Yres;
438 u.viamode.refresh = (u32) viafb_hotplug_refresh; 438 u.viamode.refresh = (u32) viafb_hotplug_refresh;
439 u.viamode.bpp = (u32) viafb_hotplug_bpp; 439 u.viamode.bpp = (u32) viafb_hotplug_bpp;
440 if (viafb_SAMM_ON == 1) { 440 if (viafb_SAMM_ON == 1) {
441 u.viamode.xres_sec = viafb_second_xres; 441 u.viamode.xres_sec = viafb_second_xres;
442 u.viamode.yres_sec = viafb_second_yres; 442 u.viamode.yres_sec = viafb_second_yres;
443 u.viamode.virtual_xres_sec = viafb_dual_fb ? viafbinfo1->var.xres_virtual : viafbinfo->var.xres_virtual; 443 u.viamode.virtual_xres_sec = viafb_dual_fb ? viafbinfo1->var.xres_virtual : viafbinfo->var.xres_virtual;
444 u.viamode.virtual_yres_sec = viafb_dual_fb ? viafbinfo1->var.yres_virtual : viafbinfo->var.yres_virtual; 444 u.viamode.virtual_yres_sec = viafb_dual_fb ? viafbinfo1->var.yres_virtual : viafbinfo->var.yres_virtual;
445 u.viamode.refresh_sec = viafb_refresh1; 445 u.viamode.refresh_sec = viafb_refresh1;
446 u.viamode.bpp_sec = viafb_bpp1; 446 u.viamode.bpp_sec = viafb_bpp1;
447 } else { 447 } else {
448 u.viamode.xres_sec = 0; 448 u.viamode.xres_sec = 0;
449 u.viamode.yres_sec = 0; 449 u.viamode.yres_sec = 0;
450 u.viamode.virtual_xres_sec = 0; 450 u.viamode.virtual_xres_sec = 0;
451 u.viamode.virtual_yres_sec = 0; 451 u.viamode.virtual_yres_sec = 0;
452 u.viamode.refresh_sec = 0; 452 u.viamode.refresh_sec = 0;
453 u.viamode.bpp_sec = 0; 453 u.viamode.bpp_sec = 0;
454 } 454 }
455 if (copy_to_user(argp, &u.viamode, sizeof(u.viamode))) 455 if (copy_to_user(argp, &u.viamode, sizeof(u.viamode)))
456 return -EFAULT; 456 return -EFAULT;
457 break; 457 break;
458 case VIAFB_GET_SAMM_INFO: 458 case VIAFB_GET_SAMM_INFO:
459 u.viasamm.samm_status = viafb_SAMM_ON; 459 u.viasamm.samm_status = viafb_SAMM_ON;
460 460
461 if (viafb_SAMM_ON == 1) { 461 if (viafb_SAMM_ON == 1) {
462 if (viafb_dual_fb) { 462 if (viafb_dual_fb) {
463 u.viasamm.size_prim = viaparinfo->fbmem_free; 463 u.viasamm.size_prim = viaparinfo->fbmem_free;
464 u.viasamm.size_sec = viaparinfo1->fbmem_free; 464 u.viasamm.size_sec = viaparinfo1->fbmem_free;
465 } else { 465 } else {
466 if (viafb_second_size) { 466 if (viafb_second_size) {
467 u.viasamm.size_prim = 467 u.viasamm.size_prim =
468 viaparinfo->fbmem_free - 468 viaparinfo->fbmem_free -
469 viafb_second_size * 1024 * 1024; 469 viafb_second_size * 1024 * 1024;
470 u.viasamm.size_sec = 470 u.viasamm.size_sec =
471 viafb_second_size * 1024 * 1024; 471 viafb_second_size * 1024 * 1024;
472 } else { 472 } else {
473 u.viasamm.size_prim = 473 u.viasamm.size_prim =
474 viaparinfo->fbmem_free >> 1; 474 viaparinfo->fbmem_free >> 1;
475 u.viasamm.size_sec = 475 u.viasamm.size_sec =
476 (viaparinfo->fbmem_free >> 1); 476 (viaparinfo->fbmem_free >> 1);
477 } 477 }
478 } 478 }
479 u.viasamm.mem_base = viaparinfo->fbmem; 479 u.viasamm.mem_base = viaparinfo->fbmem;
480 u.viasamm.offset_sec = viafb_second_offset; 480 u.viasamm.offset_sec = viafb_second_offset;
481 } else { 481 } else {
482 u.viasamm.size_prim = 482 u.viasamm.size_prim =
483 viaparinfo->memsize - viaparinfo->fbmem_used; 483 viaparinfo->memsize - viaparinfo->fbmem_used;
484 u.viasamm.size_sec = 0; 484 u.viasamm.size_sec = 0;
485 u.viasamm.mem_base = viaparinfo->fbmem; 485 u.viasamm.mem_base = viaparinfo->fbmem;
486 u.viasamm.offset_sec = 0; 486 u.viasamm.offset_sec = 0;
487 } 487 }
488 488
489 if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm))) 489 if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm)))
490 return -EFAULT; 490 return -EFAULT;
491 491
492 break; 492 break;
493 case VIAFB_TURN_ON_OUTPUT_DEVICE: 493 case VIAFB_TURN_ON_OUTPUT_DEVICE:
494 if (copy_from_user(&gpu32, argp, sizeof(gpu32))) 494 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
495 return -EFAULT; 495 return -EFAULT;
496 if (gpu32 & CRT_Device) 496 if (gpu32 & CRT_Device)
497 via_set_state(VIA_CRT, VIA_STATE_ON); 497 via_set_state(VIA_CRT, VIA_STATE_ON);
498 if (gpu32 & DVI_Device) 498 if (gpu32 & DVI_Device)
499 viafb_dvi_enable(); 499 viafb_dvi_enable();
500 if (gpu32 & LCD_Device) 500 if (gpu32 & LCD_Device)
501 viafb_lcd_enable(); 501 viafb_lcd_enable();
502 break; 502 break;
503 case VIAFB_TURN_OFF_OUTPUT_DEVICE: 503 case VIAFB_TURN_OFF_OUTPUT_DEVICE:
504 if (copy_from_user(&gpu32, argp, sizeof(gpu32))) 504 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
505 return -EFAULT; 505 return -EFAULT;
506 if (gpu32 & CRT_Device) 506 if (gpu32 & CRT_Device)
507 via_set_state(VIA_CRT, VIA_STATE_OFF); 507 via_set_state(VIA_CRT, VIA_STATE_OFF);
508 if (gpu32 & DVI_Device) 508 if (gpu32 & DVI_Device)
509 viafb_dvi_disable(); 509 viafb_dvi_disable();
510 if (gpu32 & LCD_Device) 510 if (gpu32 & LCD_Device)
511 viafb_lcd_disable(); 511 viafb_lcd_disable();
512 break; 512 break;
513 case VIAFB_GET_DEVICE: 513 case VIAFB_GET_DEVICE:
514 u.active_dev.crt = viafb_CRT_ON; 514 u.active_dev.crt = viafb_CRT_ON;
515 u.active_dev.dvi = viafb_DVI_ON; 515 u.active_dev.dvi = viafb_DVI_ON;
516 u.active_dev.lcd = viafb_LCD_ON; 516 u.active_dev.lcd = viafb_LCD_ON;
517 u.active_dev.samm = viafb_SAMM_ON; 517 u.active_dev.samm = viafb_SAMM_ON;
518 u.active_dev.primary_dev = viafb_primary_dev; 518 u.active_dev.primary_dev = viafb_primary_dev;
519 519
520 u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method; 520 u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
521 u.active_dev.lcd_panel_id = viafb_lcd_panel_id; 521 u.active_dev.lcd_panel_id = viafb_lcd_panel_id;
522 u.active_dev.lcd_mode = viafb_lcd_mode; 522 u.active_dev.lcd_mode = viafb_lcd_mode;
523 523
524 u.active_dev.xres = viafb_hotplug_Xres; 524 u.active_dev.xres = viafb_hotplug_Xres;
525 u.active_dev.yres = viafb_hotplug_Yres; 525 u.active_dev.yres = viafb_hotplug_Yres;
526 526
527 u.active_dev.xres1 = viafb_second_xres; 527 u.active_dev.xres1 = viafb_second_xres;
528 u.active_dev.yres1 = viafb_second_yres; 528 u.active_dev.yres1 = viafb_second_yres;
529 529
530 u.active_dev.bpp = viafb_bpp; 530 u.active_dev.bpp = viafb_bpp;
531 u.active_dev.bpp1 = viafb_bpp1; 531 u.active_dev.bpp1 = viafb_bpp1;
532 u.active_dev.refresh = viafb_refresh; 532 u.active_dev.refresh = viafb_refresh;
533 u.active_dev.refresh1 = viafb_refresh1; 533 u.active_dev.refresh1 = viafb_refresh1;
534 534
535 u.active_dev.epia_dvi = viafb_platform_epia_dvi; 535 u.active_dev.epia_dvi = viafb_platform_epia_dvi;
536 u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge; 536 u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
537 u.active_dev.bus_width = viafb_bus_width; 537 u.active_dev.bus_width = viafb_bus_width;
538 538
539 if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev))) 539 if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev)))
540 return -EFAULT; 540 return -EFAULT;
541 break; 541 break;
542 542
543 case VIAFB_GET_DRIVER_VERSION: 543 case VIAFB_GET_DRIVER_VERSION:
544 u.driver_version.iMajorNum = VERSION_MAJOR; 544 u.driver_version.iMajorNum = VERSION_MAJOR;
545 u.driver_version.iKernelNum = VERSION_KERNEL; 545 u.driver_version.iKernelNum = VERSION_KERNEL;
546 u.driver_version.iOSNum = VERSION_OS; 546 u.driver_version.iOSNum = VERSION_OS;
547 u.driver_version.iMinorNum = VERSION_MINOR; 547 u.driver_version.iMinorNum = VERSION_MINOR;
548 548
549 if (copy_to_user(argp, &u.driver_version, 549 if (copy_to_user(argp, &u.driver_version,
550 sizeof(u.driver_version))) 550 sizeof(u.driver_version)))
551 return -EFAULT; 551 return -EFAULT;
552 552
553 break; 553 break;
554 554
555 case VIAFB_GET_DEVICE_INFO: 555 case VIAFB_GET_DEVICE_INFO:
556 556
557 retrieve_device_setting(&u.viafb_setting); 557 retrieve_device_setting(&u.viafb_setting);
558 558
559 if (copy_to_user(argp, &u.viafb_setting, 559 if (copy_to_user(argp, &u.viafb_setting,
560 sizeof(u.viafb_setting))) 560 sizeof(u.viafb_setting)))
561 return -EFAULT; 561 return -EFAULT;
562 562
563 break; 563 break;
564 564
565 case VIAFB_GET_DEVICE_SUPPORT: 565 case VIAFB_GET_DEVICE_SUPPORT:
566 viafb_get_device_support_state(&state_info); 566 viafb_get_device_support_state(&state_info);
567 if (put_user(state_info, argp)) 567 if (put_user(state_info, argp))
568 return -EFAULT; 568 return -EFAULT;
569 break; 569 break;
570 570
571 case VIAFB_GET_DEVICE_CONNECT: 571 case VIAFB_GET_DEVICE_CONNECT:
572 viafb_get_device_connect_state(&state_info); 572 viafb_get_device_connect_state(&state_info);
573 if (put_user(state_info, argp)) 573 if (put_user(state_info, argp))
574 return -EFAULT; 574 return -EFAULT;
575 break; 575 break;
576 576
577 case VIAFB_GET_PANEL_SUPPORT_EXPAND: 577 case VIAFB_GET_PANEL_SUPPORT_EXPAND:
578 state_info = 578 state_info =
579 viafb_lcd_get_support_expand_state(info->var.xres, 579 viafb_lcd_get_support_expand_state(info->var.xres,
580 info->var.yres); 580 info->var.yres);
581 if (put_user(state_info, argp)) 581 if (put_user(state_info, argp))
582 return -EFAULT; 582 return -EFAULT;
583 break; 583 break;
584 584
585 case VIAFB_GET_DRIVER_NAME: 585 case VIAFB_GET_DRIVER_NAME:
586 if (copy_to_user(argp, driver_name, sizeof(driver_name))) 586 if (copy_to_user(argp, driver_name, sizeof(driver_name)))
587 return -EFAULT; 587 return -EFAULT;
588 break; 588 break;
589 589
590 case VIAFB_SET_GAMMA_LUT: 590 case VIAFB_SET_GAMMA_LUT:
591 viafb_gamma_table = memdup_user(argp, 256 * sizeof(u32)); 591 viafb_gamma_table = memdup_user(argp, 256 * sizeof(u32));
592 if (IS_ERR(viafb_gamma_table)) 592 if (IS_ERR(viafb_gamma_table))
593 return PTR_ERR(viafb_gamma_table); 593 return PTR_ERR(viafb_gamma_table);
594 viafb_set_gamma_table(viafb_bpp, viafb_gamma_table); 594 viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);
595 kfree(viafb_gamma_table); 595 kfree(viafb_gamma_table);
596 break; 596 break;
597 597
598 case VIAFB_GET_GAMMA_LUT: 598 case VIAFB_GET_GAMMA_LUT:
599 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL); 599 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
600 if (!viafb_gamma_table) 600 if (!viafb_gamma_table)
601 return -ENOMEM; 601 return -ENOMEM;
602 viafb_get_gamma_table(viafb_gamma_table); 602 viafb_get_gamma_table(viafb_gamma_table);
603 if (copy_to_user(argp, viafb_gamma_table, 603 if (copy_to_user(argp, viafb_gamma_table,
604 256 * sizeof(u32))) { 604 256 * sizeof(u32))) {
605 kfree(viafb_gamma_table); 605 kfree(viafb_gamma_table);
606 return -EFAULT; 606 return -EFAULT;
607 } 607 }
608 kfree(viafb_gamma_table); 608 kfree(viafb_gamma_table);
609 break; 609 break;
610 610
611 case VIAFB_GET_GAMMA_SUPPORT_STATE: 611 case VIAFB_GET_GAMMA_SUPPORT_STATE:
612 viafb_get_gamma_support_state(viafb_bpp, &state_info); 612 viafb_get_gamma_support_state(viafb_bpp, &state_info);
613 if (put_user(state_info, argp)) 613 if (put_user(state_info, argp))
614 return -EFAULT; 614 return -EFAULT;
615 break; 615 break;
616 case VIAFB_SYNC_SURFACE: 616 case VIAFB_SYNC_SURFACE:
617 DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n"); 617 DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n");
618 break; 618 break;
619 case VIAFB_GET_DRIVER_CAPS: 619 case VIAFB_GET_DRIVER_CAPS:
620 break; 620 break;
621 621
622 case VIAFB_GET_PANEL_MAX_SIZE: 622 case VIAFB_GET_PANEL_MAX_SIZE:
623 if (copy_from_user(&u.panel_pos_size_para, argp, 623 if (copy_from_user(&u.panel_pos_size_para, argp,
624 sizeof(u.panel_pos_size_para))) 624 sizeof(u.panel_pos_size_para)))
625 return -EFAULT; 625 return -EFAULT;
626 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; 626 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
627 if (copy_to_user(argp, &u.panel_pos_size_para, 627 if (copy_to_user(argp, &u.panel_pos_size_para,
628 sizeof(u.panel_pos_size_para))) 628 sizeof(u.panel_pos_size_para)))
629 return -EFAULT; 629 return -EFAULT;
630 break; 630 break;
631 case VIAFB_GET_PANEL_MAX_POSITION: 631 case VIAFB_GET_PANEL_MAX_POSITION:
632 if (copy_from_user(&u.panel_pos_size_para, argp, 632 if (copy_from_user(&u.panel_pos_size_para, argp,
633 sizeof(u.panel_pos_size_para))) 633 sizeof(u.panel_pos_size_para)))
634 return -EFAULT; 634 return -EFAULT;
635 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; 635 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
636 if (copy_to_user(argp, &u.panel_pos_size_para, 636 if (copy_to_user(argp, &u.panel_pos_size_para,
637 sizeof(u.panel_pos_size_para))) 637 sizeof(u.panel_pos_size_para)))
638 return -EFAULT; 638 return -EFAULT;
639 break; 639 break;
640 640
641 case VIAFB_GET_PANEL_POSITION: 641 case VIAFB_GET_PANEL_POSITION:
642 if (copy_from_user(&u.panel_pos_size_para, argp, 642 if (copy_from_user(&u.panel_pos_size_para, argp,
643 sizeof(u.panel_pos_size_para))) 643 sizeof(u.panel_pos_size_para)))
644 return -EFAULT; 644 return -EFAULT;
645 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; 645 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
646 if (copy_to_user(argp, &u.panel_pos_size_para, 646 if (copy_to_user(argp, &u.panel_pos_size_para,
647 sizeof(u.panel_pos_size_para))) 647 sizeof(u.panel_pos_size_para)))
648 return -EFAULT; 648 return -EFAULT;
649 break; 649 break;
650 case VIAFB_GET_PANEL_SIZE: 650 case VIAFB_GET_PANEL_SIZE:
651 if (copy_from_user(&u.panel_pos_size_para, argp, 651 if (copy_from_user(&u.panel_pos_size_para, argp,
652 sizeof(u.panel_pos_size_para))) 652 sizeof(u.panel_pos_size_para)))
653 return -EFAULT; 653 return -EFAULT;
654 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; 654 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
655 if (copy_to_user(argp, &u.panel_pos_size_para, 655 if (copy_to_user(argp, &u.panel_pos_size_para,
656 sizeof(u.panel_pos_size_para))) 656 sizeof(u.panel_pos_size_para)))
657 return -EFAULT; 657 return -EFAULT;
658 break; 658 break;
659 659
660 case VIAFB_SET_PANEL_POSITION: 660 case VIAFB_SET_PANEL_POSITION:
661 if (copy_from_user(&u.panel_pos_size_para, argp, 661 if (copy_from_user(&u.panel_pos_size_para, argp,
662 sizeof(u.panel_pos_size_para))) 662 sizeof(u.panel_pos_size_para)))
663 return -EFAULT; 663 return -EFAULT;
664 break; 664 break;
665 case VIAFB_SET_PANEL_SIZE: 665 case VIAFB_SET_PANEL_SIZE:
666 if (copy_from_user(&u.panel_pos_size_para, argp, 666 if (copy_from_user(&u.panel_pos_size_para, argp,
667 sizeof(u.panel_pos_size_para))) 667 sizeof(u.panel_pos_size_para)))
668 return -EFAULT; 668 return -EFAULT;
669 break; 669 break;
670 670
671 default: 671 default:
672 return -EINVAL; 672 return -EINVAL;
673 } 673 }
674 674
675 return 0; 675 return 0;
676 } 676 }
677 677
678 static void viafb_fillrect(struct fb_info *info, 678 static void viafb_fillrect(struct fb_info *info,
679 const struct fb_fillrect *rect) 679 const struct fb_fillrect *rect)
680 { 680 {
681 struct viafb_par *viapar = info->par; 681 struct viafb_par *viapar = info->par;
682 struct viafb_shared *shared = viapar->shared; 682 struct viafb_shared *shared = viapar->shared;
683 u32 fg_color; 683 u32 fg_color;
684 u8 rop; 684 u8 rop;
685 685
686 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) { 686 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) {
687 cfb_fillrect(info, rect); 687 cfb_fillrect(info, rect);
688 return; 688 return;
689 } 689 }
690 690
691 if (!rect->width || !rect->height) 691 if (!rect->width || !rect->height)
692 return; 692 return;
693 693
694 if (info->fix.visual == FB_VISUAL_TRUECOLOR) 694 if (info->fix.visual == FB_VISUAL_TRUECOLOR)
695 fg_color = ((u32 *)info->pseudo_palette)[rect->color]; 695 fg_color = ((u32 *)info->pseudo_palette)[rect->color];
696 else 696 else
697 fg_color = rect->color; 697 fg_color = rect->color;
698 698
699 if (rect->rop == ROP_XOR) 699 if (rect->rop == ROP_XOR)
700 rop = 0x5A; 700 rop = 0x5A;
701 else 701 else
702 rop = 0xF0; 702 rop = 0xF0;
703 703
704 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: fillrect\n"); 704 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: fillrect\n");
705 if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_FILL, 705 if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_FILL,
706 rect->width, rect->height, info->var.bits_per_pixel, 706 rect->width, rect->height, info->var.bits_per_pixel,
707 viapar->vram_addr, info->fix.line_length, rect->dx, rect->dy, 707 viapar->vram_addr, info->fix.line_length, rect->dx, rect->dy,
708 NULL, 0, 0, 0, 0, fg_color, 0, rop)) 708 NULL, 0, 0, 0, 0, fg_color, 0, rop))
709 cfb_fillrect(info, rect); 709 cfb_fillrect(info, rect);
710 } 710 }
711 711
712 static void viafb_copyarea(struct fb_info *info, 712 static void viafb_copyarea(struct fb_info *info,
713 const struct fb_copyarea *area) 713 const struct fb_copyarea *area)
714 { 714 {
715 struct viafb_par *viapar = info->par; 715 struct viafb_par *viapar = info->par;
716 struct viafb_shared *shared = viapar->shared; 716 struct viafb_shared *shared = viapar->shared;
717 717
718 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) { 718 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) {
719 cfb_copyarea(info, area); 719 cfb_copyarea(info, area);
720 return; 720 return;
721 } 721 }
722 722
723 if (!area->width || !area->height) 723 if (!area->width || !area->height)
724 return; 724 return;
725 725
726 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: copyarea\n"); 726 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: copyarea\n");
727 if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_COLOR, 727 if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_COLOR,
728 area->width, area->height, info->var.bits_per_pixel, 728 area->width, area->height, info->var.bits_per_pixel,
729 viapar->vram_addr, info->fix.line_length, area->dx, area->dy, 729 viapar->vram_addr, info->fix.line_length, area->dx, area->dy,
730 NULL, viapar->vram_addr, info->fix.line_length, 730 NULL, viapar->vram_addr, info->fix.line_length,
731 area->sx, area->sy, 0, 0, 0)) 731 area->sx, area->sy, 0, 0, 0))
732 cfb_copyarea(info, area); 732 cfb_copyarea(info, area);
733 } 733 }
734 734
735 static void viafb_imageblit(struct fb_info *info, 735 static void viafb_imageblit(struct fb_info *info,
736 const struct fb_image *image) 736 const struct fb_image *image)
737 { 737 {
738 struct viafb_par *viapar = info->par; 738 struct viafb_par *viapar = info->par;
739 struct viafb_shared *shared = viapar->shared; 739 struct viafb_shared *shared = viapar->shared;
740 u32 fg_color = 0, bg_color = 0; 740 u32 fg_color = 0, bg_color = 0;
741 u8 op; 741 u8 op;
742 742
743 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt || 743 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt ||
744 (image->depth != 1 && image->depth != viapar->depth)) { 744 (image->depth != 1 && image->depth != viapar->depth)) {
745 cfb_imageblit(info, image); 745 cfb_imageblit(info, image);
746 return; 746 return;
747 } 747 }
748 748
749 if (image->depth == 1) { 749 if (image->depth == 1) {
750 op = VIA_BITBLT_MONO; 750 op = VIA_BITBLT_MONO;
751 if (info->fix.visual == FB_VISUAL_TRUECOLOR) { 751 if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
752 fg_color = 752 fg_color =
753 ((u32 *)info->pseudo_palette)[image->fg_color]; 753 ((u32 *)info->pseudo_palette)[image->fg_color];
754 bg_color = 754 bg_color =
755 ((u32 *)info->pseudo_palette)[image->bg_color]; 755 ((u32 *)info->pseudo_palette)[image->bg_color];
756 } else { 756 } else {
757 fg_color = image->fg_color; 757 fg_color = image->fg_color;
758 bg_color = image->bg_color; 758 bg_color = image->bg_color;
759 } 759 }
760 } else 760 } else
761 op = VIA_BITBLT_COLOR; 761 op = VIA_BITBLT_COLOR;
762 762
763 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: imageblit\n"); 763 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: imageblit\n");
764 if (shared->hw_bitblt(shared->vdev->engine_mmio, op, 764 if (shared->hw_bitblt(shared->vdev->engine_mmio, op,
765 image->width, image->height, info->var.bits_per_pixel, 765 image->width, image->height, info->var.bits_per_pixel,
766 viapar->vram_addr, info->fix.line_length, image->dx, image->dy, 766 viapar->vram_addr, info->fix.line_length, image->dx, image->dy,
767 (u32 *)image->data, 0, 0, 0, 0, fg_color, bg_color, 0)) 767 (u32 *)image->data, 0, 0, 0, 0, fg_color, bg_color, 0))
768 cfb_imageblit(info, image); 768 cfb_imageblit(info, image);
769 } 769 }
770 770
771 static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor) 771 static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
772 { 772 {
773 struct viafb_par *viapar = info->par; 773 struct viafb_par *viapar = info->par;
774 void __iomem *engine = viapar->shared->vdev->engine_mmio; 774 void __iomem *engine = viapar->shared->vdev->engine_mmio;
775 u32 temp, xx, yy, bg_color = 0, fg_color = 0, 775 u32 temp, xx, yy, bg_color = 0, fg_color = 0,
776 chip_name = viapar->shared->chip_info.gfx_chip_name; 776 chip_name = viapar->shared->chip_info.gfx_chip_name;
777 int i, j = 0, cur_size = 64; 777 int i, j = 0, cur_size = 64;
778 778
779 if (info->flags & FBINFO_HWACCEL_DISABLED || info != viafbinfo) 779 if (info->flags & FBINFO_HWACCEL_DISABLED || info != viafbinfo)
780 return -ENODEV; 780 return -ENODEV;
781 781
782 /* LCD ouput does not support hw cursors (at least on VN896) */ 782 /* LCD ouput does not support hw cursors (at least on VN896) */
783 if ((chip_name == UNICHROME_CLE266 && viapar->iga_path == IGA2) || 783 if ((chip_name == UNICHROME_CLE266 && viapar->iga_path == IGA2) ||
784 viafb_LCD_ON) 784 viafb_LCD_ON)
785 return -ENODEV; 785 return -ENODEV;
786 786
787 viafb_show_hw_cursor(info, HW_Cursor_OFF); 787 viafb_show_hw_cursor(info, HW_Cursor_OFF);
788 788
789 if (cursor->set & FB_CUR_SETHOT) { 789 if (cursor->set & FB_CUR_SETHOT) {
790 temp = (cursor->hot.x << 16) + cursor->hot.y; 790 temp = (cursor->hot.x << 16) + cursor->hot.y;
791 writel(temp, engine + VIA_REG_CURSOR_ORG); 791 writel(temp, engine + VIA_REG_CURSOR_ORG);
792 } 792 }
793 793
794 if (cursor->set & FB_CUR_SETPOS) { 794 if (cursor->set & FB_CUR_SETPOS) {
795 yy = cursor->image.dy - info->var.yoffset; 795 yy = cursor->image.dy - info->var.yoffset;
796 xx = cursor->image.dx - info->var.xoffset; 796 xx = cursor->image.dx - info->var.xoffset;
797 temp = yy & 0xFFFF; 797 temp = yy & 0xFFFF;
798 temp |= (xx << 16); 798 temp |= (xx << 16);
799 writel(temp, engine + VIA_REG_CURSOR_POS); 799 writel(temp, engine + VIA_REG_CURSOR_POS);
800 } 800 }
801 801
802 if (cursor->image.width <= 32 && cursor->image.height <= 32) 802 if (cursor->image.width <= 32 && cursor->image.height <= 32)
803 cur_size = 32; 803 cur_size = 32;
804 else if (cursor->image.width <= 64 && cursor->image.height <= 64) 804 else if (cursor->image.width <= 64 && cursor->image.height <= 64)
805 cur_size = 64; 805 cur_size = 64;
806 else { 806 else {
807 printk(KERN_WARNING "viafb_cursor: The cursor is too large " 807 printk(KERN_WARNING "viafb_cursor: The cursor is too large "
808 "%dx%d", cursor->image.width, cursor->image.height); 808 "%dx%d", cursor->image.width, cursor->image.height);
809 return -ENXIO; 809 return -ENXIO;
810 } 810 }
811 811
812 if (cursor->set & FB_CUR_SETSIZE) { 812 if (cursor->set & FB_CUR_SETSIZE) {
813 temp = readl(engine + VIA_REG_CURSOR_MODE); 813 temp = readl(engine + VIA_REG_CURSOR_MODE);
814 if (cur_size == 32) 814 if (cur_size == 32)
815 temp |= 0x2; 815 temp |= 0x2;
816 else 816 else
817 temp &= ~0x2; 817 temp &= ~0x2;
818 818
819 writel(temp, engine + VIA_REG_CURSOR_MODE); 819 writel(temp, engine + VIA_REG_CURSOR_MODE);
820 } 820 }
821 821
822 if (cursor->set & FB_CUR_SETCMAP) { 822 if (cursor->set & FB_CUR_SETCMAP) {
823 fg_color = cursor->image.fg_color; 823 fg_color = cursor->image.fg_color;
824 bg_color = cursor->image.bg_color; 824 bg_color = cursor->image.bg_color;
825 if (chip_name == UNICHROME_CX700 || 825 if (chip_name == UNICHROME_CX700 ||
826 chip_name == UNICHROME_VX800 || 826 chip_name == UNICHROME_VX800 ||
827 chip_name == UNICHROME_VX855 || 827 chip_name == UNICHROME_VX855 ||
828 chip_name == UNICHROME_VX900) { 828 chip_name == UNICHROME_VX900) {
829 fg_color = 829 fg_color =
830 ((info->cmap.red[fg_color] & 0xFFC0) << 14) | 830 ((info->cmap.red[fg_color] & 0xFFC0) << 14) |
831 ((info->cmap.green[fg_color] & 0xFFC0) << 4) | 831 ((info->cmap.green[fg_color] & 0xFFC0) << 4) |
832 ((info->cmap.blue[fg_color] & 0xFFC0) >> 6); 832 ((info->cmap.blue[fg_color] & 0xFFC0) >> 6);
833 bg_color = 833 bg_color =
834 ((info->cmap.red[bg_color] & 0xFFC0) << 14) | 834 ((info->cmap.red[bg_color] & 0xFFC0) << 14) |
835 ((info->cmap.green[bg_color] & 0xFFC0) << 4) | 835 ((info->cmap.green[bg_color] & 0xFFC0) << 4) |
836 ((info->cmap.blue[bg_color] & 0xFFC0) >> 6); 836 ((info->cmap.blue[bg_color] & 0xFFC0) >> 6);
837 } else { 837 } else {
838 fg_color = 838 fg_color =
839 ((info->cmap.red[fg_color] & 0xFF00) << 8) | 839 ((info->cmap.red[fg_color] & 0xFF00) << 8) |
840 (info->cmap.green[fg_color] & 0xFF00) | 840 (info->cmap.green[fg_color] & 0xFF00) |
841 ((info->cmap.blue[fg_color] & 0xFF00) >> 8); 841 ((info->cmap.blue[fg_color] & 0xFF00) >> 8);
842 bg_color = 842 bg_color =
843 ((info->cmap.red[bg_color] & 0xFF00) << 8) | 843 ((info->cmap.red[bg_color] & 0xFF00) << 8) |
844 (info->cmap.green[bg_color] & 0xFF00) | 844 (info->cmap.green[bg_color] & 0xFF00) |
845 ((info->cmap.blue[bg_color] & 0xFF00) >> 8); 845 ((info->cmap.blue[bg_color] & 0xFF00) >> 8);
846 } 846 }
847 847
848 writel(bg_color, engine + VIA_REG_CURSOR_BG); 848 writel(bg_color, engine + VIA_REG_CURSOR_BG);
849 writel(fg_color, engine + VIA_REG_CURSOR_FG); 849 writel(fg_color, engine + VIA_REG_CURSOR_FG);
850 } 850 }
851 851
852 if (cursor->set & FB_CUR_SETSHAPE) { 852 if (cursor->set & FB_CUR_SETSHAPE) {
853 struct { 853 struct {
854 u8 data[CURSOR_SIZE]; 854 u8 data[CURSOR_SIZE];
855 u32 bak[CURSOR_SIZE / 4]; 855 u32 bak[CURSOR_SIZE / 4];
856 } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC); 856 } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC);
857 int size = ((cursor->image.width + 7) >> 3) * 857 int size = ((cursor->image.width + 7) >> 3) *
858 cursor->image.height; 858 cursor->image.height;
859 859
860 if (!cr_data) 860 if (!cr_data)
861 return -ENOMEM; 861 return -ENOMEM;
862 862
863 if (cur_size == 32) { 863 if (cur_size == 32) {
864 for (i = 0; i < (CURSOR_SIZE / 4); i++) { 864 for (i = 0; i < (CURSOR_SIZE / 4); i++) {
865 cr_data->bak[i] = 0x0; 865 cr_data->bak[i] = 0x0;
866 cr_data->bak[i + 1] = 0xFFFFFFFF; 866 cr_data->bak[i + 1] = 0xFFFFFFFF;
867 i += 1; 867 i += 1;
868 } 868 }
869 } else { 869 } else {
870 for (i = 0; i < (CURSOR_SIZE / 4); i++) { 870 for (i = 0; i < (CURSOR_SIZE / 4); i++) {
871 cr_data->bak[i] = 0x0; 871 cr_data->bak[i] = 0x0;
872 cr_data->bak[i + 1] = 0x0; 872 cr_data->bak[i + 1] = 0x0;
873 cr_data->bak[i + 2] = 0xFFFFFFFF; 873 cr_data->bak[i + 2] = 0xFFFFFFFF;
874 cr_data->bak[i + 3] = 0xFFFFFFFF; 874 cr_data->bak[i + 3] = 0xFFFFFFFF;
875 i += 3; 875 i += 3;
876 } 876 }
877 } 877 }
878 878
879 switch (cursor->rop) { 879 switch (cursor->rop) {
880 case ROP_XOR: 880 case ROP_XOR:
881 for (i = 0; i < size; i++) 881 for (i = 0; i < size; i++)
882 cr_data->data[i] = cursor->mask[i]; 882 cr_data->data[i] = cursor->mask[i];
883 break; 883 break;
884 case ROP_COPY: 884 case ROP_COPY:
885 885
886 for (i = 0; i < size; i++) 886 for (i = 0; i < size; i++)
887 cr_data->data[i] = cursor->mask[i]; 887 cr_data->data[i] = cursor->mask[i];
888 break; 888 break;
889 default: 889 default:
890 break; 890 break;
891 } 891 }
892 892
893 if (cur_size == 32) { 893 if (cur_size == 32) {
894 for (i = 0; i < size; i++) { 894 for (i = 0; i < size; i++) {
895 cr_data->bak[j] = (u32) cr_data->data[i]; 895 cr_data->bak[j] = (u32) cr_data->data[i];
896 cr_data->bak[j + 1] = ~cr_data->bak[j]; 896 cr_data->bak[j + 1] = ~cr_data->bak[j];
897 j += 2; 897 j += 2;
898 } 898 }
899 } else { 899 } else {
900 for (i = 0; i < size; i++) { 900 for (i = 0; i < size; i++) {
901 cr_data->bak[j] = (u32) cr_data->data[i]; 901 cr_data->bak[j] = (u32) cr_data->data[i];
902 cr_data->bak[j + 1] = 0x0; 902 cr_data->bak[j + 1] = 0x0;
903 cr_data->bak[j + 2] = ~cr_data->bak[j]; 903 cr_data->bak[j + 2] = ~cr_data->bak[j];
904 cr_data->bak[j + 3] = ~cr_data->bak[j + 1]; 904 cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
905 j += 4; 905 j += 4;
906 } 906 }
907 } 907 }
908 908
909 memcpy_toio(viafbinfo->screen_base + viapar->shared-> 909 memcpy_toio(viafbinfo->screen_base + viapar->shared->
910 cursor_vram_addr, cr_data->bak, CURSOR_SIZE); 910 cursor_vram_addr, cr_data->bak, CURSOR_SIZE);
911 kfree(cr_data); 911 kfree(cr_data);
912 } 912 }
913 913
914 if (cursor->enable) 914 if (cursor->enable)
915 viafb_show_hw_cursor(info, HW_Cursor_ON); 915 viafb_show_hw_cursor(info, HW_Cursor_ON);
916 916
917 return 0; 917 return 0;
918 } 918 }
919 919
920 static int viafb_sync(struct fb_info *info) 920 static int viafb_sync(struct fb_info *info)
921 { 921 {
922 if (!(info->flags & FBINFO_HWACCEL_DISABLED)) 922 if (!(info->flags & FBINFO_HWACCEL_DISABLED))
923 viafb_wait_engine_idle(info); 923 viafb_wait_engine_idle(info);
924 return 0; 924 return 0;
925 } 925 }
926 926
927 static int get_primary_device(void) 927 static int get_primary_device(void)
928 { 928 {
929 int primary_device = 0; 929 int primary_device = 0;
930 /* Rule: device on iga1 path are the primary device. */ 930 /* Rule: device on iga1 path are the primary device. */
931 if (viafb_SAMM_ON) { 931 if (viafb_SAMM_ON) {
932 if (viafb_CRT_ON) { 932 if (viafb_CRT_ON) {
933 if (viaparinfo->shared->iga1_devices & VIA_CRT) { 933 if (viaparinfo->shared->iga1_devices & VIA_CRT) {
934 DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n", IGA1); 934 DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n", IGA1);
935 primary_device = CRT_Device; 935 primary_device = CRT_Device;
936 } 936 }
937 } 937 }
938 if (viafb_DVI_ON) { 938 if (viafb_DVI_ON) {
939 if (viaparinfo->tmds_setting_info->iga_path == IGA1) { 939 if (viaparinfo->tmds_setting_info->iga_path == IGA1) {
940 DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n", 940 DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n",
941 viaparinfo-> 941 viaparinfo->
942 tmds_setting_info->iga_path); 942 tmds_setting_info->iga_path);
943 primary_device = DVI_Device; 943 primary_device = DVI_Device;
944 } 944 }
945 } 945 }
946 if (viafb_LCD_ON) { 946 if (viafb_LCD_ON) {
947 if (viaparinfo->lvds_setting_info->iga_path == IGA1) { 947 if (viaparinfo->lvds_setting_info->iga_path == IGA1) {
948 DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n", 948 DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n",
949 viaparinfo-> 949 viaparinfo->
950 lvds_setting_info->iga_path); 950 lvds_setting_info->iga_path);
951 primary_device = LCD_Device; 951 primary_device = LCD_Device;
952 } 952 }
953 } 953 }
954 if (viafb_LCD2_ON) { 954 if (viafb_LCD2_ON) {
955 if (viaparinfo->lvds_setting_info2->iga_path == IGA1) { 955 if (viaparinfo->lvds_setting_info2->iga_path == IGA1) {
956 DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n", 956 DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n",
957 viaparinfo-> 957 viaparinfo->
958 lvds_setting_info2->iga_path); 958 lvds_setting_info2->iga_path);
959 primary_device = LCD2_Device; 959 primary_device = LCD2_Device;
960 } 960 }
961 } 961 }
962 } 962 }
963 return primary_device; 963 return primary_device;
964 } 964 }
965 965
966 static void retrieve_device_setting(struct viafb_ioctl_setting 966 static void retrieve_device_setting(struct viafb_ioctl_setting
967 *setting_info) 967 *setting_info)
968 { 968 {
969 969
970 /* get device status */ 970 /* get device status */
971 if (viafb_CRT_ON == 1) 971 if (viafb_CRT_ON == 1)
972 setting_info->device_status = CRT_Device; 972 setting_info->device_status = CRT_Device;
973 if (viafb_DVI_ON == 1) 973 if (viafb_DVI_ON == 1)
974 setting_info->device_status |= DVI_Device; 974 setting_info->device_status |= DVI_Device;
975 if (viafb_LCD_ON == 1) 975 if (viafb_LCD_ON == 1)
976 setting_info->device_status |= LCD_Device; 976 setting_info->device_status |= LCD_Device;
977 if (viafb_LCD2_ON == 1) 977 if (viafb_LCD2_ON == 1)
978 setting_info->device_status |= LCD2_Device; 978 setting_info->device_status |= LCD2_Device;
979 979
980 setting_info->samm_status = viafb_SAMM_ON; 980 setting_info->samm_status = viafb_SAMM_ON;
981 setting_info->primary_device = get_primary_device(); 981 setting_info->primary_device = get_primary_device();
982 982
983 setting_info->first_dev_bpp = viafb_bpp; 983 setting_info->first_dev_bpp = viafb_bpp;
984 setting_info->second_dev_bpp = viafb_bpp1; 984 setting_info->second_dev_bpp = viafb_bpp1;
985 985
986 setting_info->first_dev_refresh = viafb_refresh; 986 setting_info->first_dev_refresh = viafb_refresh;
987 setting_info->second_dev_refresh = viafb_refresh1; 987 setting_info->second_dev_refresh = viafb_refresh1;
988 988
989 setting_info->first_dev_hor_res = viafb_hotplug_Xres; 989 setting_info->first_dev_hor_res = viafb_hotplug_Xres;
990 setting_info->first_dev_ver_res = viafb_hotplug_Yres; 990 setting_info->first_dev_ver_res = viafb_hotplug_Yres;
991 setting_info->second_dev_hor_res = viafb_second_xres; 991 setting_info->second_dev_hor_res = viafb_second_xres;
992 setting_info->second_dev_ver_res = viafb_second_yres; 992 setting_info->second_dev_ver_res = viafb_second_yres;
993 993
994 /* Get lcd attributes */ 994 /* Get lcd attributes */
995 setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method; 995 setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method;
996 setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id; 996 setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id;
997 setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode; 997 setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode;
998 } 998 }
999 999
1000 static int __init parse_active_dev(void) 1000 static int __init parse_active_dev(void)
1001 { 1001 {
1002 viafb_CRT_ON = STATE_OFF; 1002 viafb_CRT_ON = STATE_OFF;
1003 viafb_DVI_ON = STATE_OFF; 1003 viafb_DVI_ON = STATE_OFF;
1004 viafb_LCD_ON = STATE_OFF; 1004 viafb_LCD_ON = STATE_OFF;
1005 viafb_LCD2_ON = STATE_OFF; 1005 viafb_LCD2_ON = STATE_OFF;
1006 /* 1. Modify the active status of devices. */ 1006 /* 1. Modify the active status of devices. */
1007 /* 2. Keep the order of devices, so we can set corresponding 1007 /* 2. Keep the order of devices, so we can set corresponding
1008 IGA path to devices in SAMM case. */ 1008 IGA path to devices in SAMM case. */
1009 /* Note: The previous of active_dev is primary device, 1009 /* Note: The previous of active_dev is primary device,
1010 and the following is secondary device. */ 1010 and the following is secondary device. */
1011 if (!viafb_active_dev) { 1011 if (!viafb_active_dev) {
1012 if (machine_is_olpc()) { /* LCD only */ 1012 if (machine_is_olpc()) { /* LCD only */
1013 viafb_LCD_ON = STATE_ON; 1013 viafb_LCD_ON = STATE_ON;
1014 viafb_SAMM_ON = STATE_OFF; 1014 viafb_SAMM_ON = STATE_OFF;
1015 } else { 1015 } else {
1016 viafb_CRT_ON = STATE_ON; 1016 viafb_CRT_ON = STATE_ON;
1017 viafb_SAMM_ON = STATE_OFF; 1017 viafb_SAMM_ON = STATE_OFF;
1018 } 1018 }
1019 } else if (!strcmp(viafb_active_dev, "CRT+DVI")) { 1019 } else if (!strcmp(viafb_active_dev, "CRT+DVI")) {
1020 /* CRT+DVI */ 1020 /* CRT+DVI */
1021 viafb_CRT_ON = STATE_ON; 1021 viafb_CRT_ON = STATE_ON;
1022 viafb_DVI_ON = STATE_ON; 1022 viafb_DVI_ON = STATE_ON;
1023 viafb_primary_dev = CRT_Device; 1023 viafb_primary_dev = CRT_Device;
1024 } else if (!strcmp(viafb_active_dev, "DVI+CRT")) { 1024 } else if (!strcmp(viafb_active_dev, "DVI+CRT")) {
1025 /* DVI+CRT */ 1025 /* DVI+CRT */
1026 viafb_CRT_ON = STATE_ON; 1026 viafb_CRT_ON = STATE_ON;
1027 viafb_DVI_ON = STATE_ON; 1027 viafb_DVI_ON = STATE_ON;
1028 viafb_primary_dev = DVI_Device; 1028 viafb_primary_dev = DVI_Device;
1029 } else if (!strcmp(viafb_active_dev, "CRT+LCD")) { 1029 } else if (!strcmp(viafb_active_dev, "CRT+LCD")) {
1030 /* CRT+LCD */ 1030 /* CRT+LCD */
1031 viafb_CRT_ON = STATE_ON; 1031 viafb_CRT_ON = STATE_ON;
1032 viafb_LCD_ON = STATE_ON; 1032 viafb_LCD_ON = STATE_ON;
1033 viafb_primary_dev = CRT_Device; 1033 viafb_primary_dev = CRT_Device;
1034 } else if (!strcmp(viafb_active_dev, "LCD+CRT")) { 1034 } else if (!strcmp(viafb_active_dev, "LCD+CRT")) {
1035 /* LCD+CRT */ 1035 /* LCD+CRT */
1036 viafb_CRT_ON = STATE_ON; 1036 viafb_CRT_ON = STATE_ON;
1037 viafb_LCD_ON = STATE_ON; 1037 viafb_LCD_ON = STATE_ON;
1038 viafb_primary_dev = LCD_Device; 1038 viafb_primary_dev = LCD_Device;
1039 } else if (!strcmp(viafb_active_dev, "DVI+LCD")) { 1039 } else if (!strcmp(viafb_active_dev, "DVI+LCD")) {
1040 /* DVI+LCD */ 1040 /* DVI+LCD */
1041 viafb_DVI_ON = STATE_ON; 1041 viafb_DVI_ON = STATE_ON;
1042 viafb_LCD_ON = STATE_ON; 1042 viafb_LCD_ON = STATE_ON;
1043 viafb_primary_dev = DVI_Device; 1043 viafb_primary_dev = DVI_Device;
1044 } else if (!strcmp(viafb_active_dev, "LCD+DVI")) { 1044 } else if (!strcmp(viafb_active_dev, "LCD+DVI")) {
1045 /* LCD+DVI */ 1045 /* LCD+DVI */
1046 viafb_DVI_ON = STATE_ON; 1046 viafb_DVI_ON = STATE_ON;
1047 viafb_LCD_ON = STATE_ON; 1047 viafb_LCD_ON = STATE_ON;
1048 viafb_primary_dev = LCD_Device; 1048 viafb_primary_dev = LCD_Device;
1049 } else if (!strcmp(viafb_active_dev, "LCD+LCD2")) { 1049 } else if (!strcmp(viafb_active_dev, "LCD+LCD2")) {
1050 viafb_LCD_ON = STATE_ON; 1050 viafb_LCD_ON = STATE_ON;
1051 viafb_LCD2_ON = STATE_ON; 1051 viafb_LCD2_ON = STATE_ON;
1052 viafb_primary_dev = LCD_Device; 1052 viafb_primary_dev = LCD_Device;
1053 } else if (!strcmp(viafb_active_dev, "LCD2+LCD")) { 1053 } else if (!strcmp(viafb_active_dev, "LCD2+LCD")) {
1054 viafb_LCD_ON = STATE_ON; 1054 viafb_LCD_ON = STATE_ON;
1055 viafb_LCD2_ON = STATE_ON; 1055 viafb_LCD2_ON = STATE_ON;
1056 viafb_primary_dev = LCD2_Device; 1056 viafb_primary_dev = LCD2_Device;
1057 } else if (!strcmp(viafb_active_dev, "CRT")) { 1057 } else if (!strcmp(viafb_active_dev, "CRT")) {
1058 /* CRT only */ 1058 /* CRT only */
1059 viafb_CRT_ON = STATE_ON; 1059 viafb_CRT_ON = STATE_ON;
1060 viafb_SAMM_ON = STATE_OFF; 1060 viafb_SAMM_ON = STATE_OFF;
1061 } else if (!strcmp(viafb_active_dev, "DVI")) { 1061 } else if (!strcmp(viafb_active_dev, "DVI")) {
1062 /* DVI only */ 1062 /* DVI only */
1063 viafb_DVI_ON = STATE_ON; 1063 viafb_DVI_ON = STATE_ON;
1064 viafb_SAMM_ON = STATE_OFF; 1064 viafb_SAMM_ON = STATE_OFF;
1065 } else if (!strcmp(viafb_active_dev, "LCD")) { 1065 } else if (!strcmp(viafb_active_dev, "LCD")) {
1066 /* LCD only */ 1066 /* LCD only */
1067 viafb_LCD_ON = STATE_ON; 1067 viafb_LCD_ON = STATE_ON;
1068 viafb_SAMM_ON = STATE_OFF; 1068 viafb_SAMM_ON = STATE_OFF;
1069 } else 1069 } else
1070 return -EINVAL; 1070 return -EINVAL;
1071 1071
1072 return 0; 1072 return 0;
1073 } 1073 }
1074 1074
1075 static int __devinit parse_port(char *opt_str, int *output_interface) 1075 static int __devinit parse_port(char *opt_str, int *output_interface)
1076 { 1076 {
1077 if (!strncmp(opt_str, "DVP0", 4)) 1077 if (!strncmp(opt_str, "DVP0", 4))
1078 *output_interface = INTERFACE_DVP0; 1078 *output_interface = INTERFACE_DVP0;
1079 else if (!strncmp(opt_str, "DVP1", 4)) 1079 else if (!strncmp(opt_str, "DVP1", 4))
1080 *output_interface = INTERFACE_DVP1; 1080 *output_interface = INTERFACE_DVP1;
1081 else if (!strncmp(opt_str, "DFP_HIGHLOW", 11)) 1081 else if (!strncmp(opt_str, "DFP_HIGHLOW", 11))
1082 *output_interface = INTERFACE_DFP; 1082 *output_interface = INTERFACE_DFP;
1083 else if (!strncmp(opt_str, "DFP_HIGH", 8)) 1083 else if (!strncmp(opt_str, "DFP_HIGH", 8))
1084 *output_interface = INTERFACE_DFP_HIGH; 1084 *output_interface = INTERFACE_DFP_HIGH;
1085 else if (!strncmp(opt_str, "DFP_LOW", 7)) 1085 else if (!strncmp(opt_str, "DFP_LOW", 7))
1086 *output_interface = INTERFACE_DFP_LOW; 1086 *output_interface = INTERFACE_DFP_LOW;
1087 else 1087 else
1088 *output_interface = INTERFACE_NONE; 1088 *output_interface = INTERFACE_NONE;
1089 return 0; 1089 return 0;
1090 } 1090 }
1091 1091
1092 static void __devinit parse_lcd_port(void) 1092 static void __devinit parse_lcd_port(void)
1093 { 1093 {
1094 parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info. 1094 parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info.
1095 output_interface); 1095 output_interface);
1096 /*Initialize to avoid unexpected behavior */ 1096 /*Initialize to avoid unexpected behavior */
1097 viaparinfo->chip_info->lvds_chip_info2.output_interface = 1097 viaparinfo->chip_info->lvds_chip_info2.output_interface =
1098 INTERFACE_NONE; 1098 INTERFACE_NONE;
1099 1099
1100 DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n", 1100 DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1101 viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info. 1101 viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info.
1102 output_interface); 1102 output_interface);
1103 } 1103 }
1104 1104
1105 static void __devinit parse_dvi_port(void) 1105 static void __devinit parse_dvi_port(void)
1106 { 1106 {
1107 parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info. 1107 parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info.
1108 output_interface); 1108 output_interface);
1109 1109
1110 DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n", 1110 DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1111 viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info. 1111 viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info.
1112 output_interface); 1112 output_interface);
1113 } 1113 }
1114 1114
1115 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS 1115 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1116 1116
1117 /* 1117 /*
1118 * The proc filesystem read/write function, a simple proc implement to 1118 * The proc filesystem read/write function, a simple proc implement to
1119 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1, 1119 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1120 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2], 1120 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1121 * CR9B, SR65, CR97, CR99 1121 * CR9B, SR65, CR97, CR99
1122 */ 1122 */
1123 static int viafb_dvp0_proc_show(struct seq_file *m, void *v) 1123 static int viafb_dvp0_proc_show(struct seq_file *m, void *v)
1124 { 1124 {
1125 u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0; 1125 u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0;
1126 dvp0_data_dri = 1126 dvp0_data_dri =
1127 (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 | 1127 (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 |
1128 (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1; 1128 (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1;
1129 dvp0_clk_dri = 1129 dvp0_clk_dri =
1130 (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 | 1130 (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 |
1131 (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2; 1131 (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2;
1132 dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f; 1132 dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f;
1133 seq_printf(m, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri); 1133 seq_printf(m, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri);
1134 return 0; 1134 return 0;
1135 } 1135 }
1136 1136
1137 static int viafb_dvp0_proc_open(struct inode *inode, struct file *file) 1137 static int viafb_dvp0_proc_open(struct inode *inode, struct file *file)
1138 { 1138 {
1139 return single_open(file, viafb_dvp0_proc_show, NULL); 1139 return single_open(file, viafb_dvp0_proc_show, NULL);
1140 } 1140 }
1141 1141
1142 static ssize_t viafb_dvp0_proc_write(struct file *file, 1142 static ssize_t viafb_dvp0_proc_write(struct file *file,
1143 const char __user *buffer, size_t count, loff_t *pos) 1143 const char __user *buffer, size_t count, loff_t *pos)
1144 { 1144 {
1145 char buf[20], *value, *pbuf; 1145 char buf[20], *value, *pbuf;
1146 u8 reg_val = 0; 1146 u8 reg_val = 0;
1147 unsigned long length, i; 1147 unsigned long length, i;
1148 if (count < 1) 1148 if (count < 1)
1149 return -EINVAL; 1149 return -EINVAL;
1150 length = count > 20 ? 20 : count; 1150 length = count > 20 ? 20 : count;
1151 if (copy_from_user(&buf[0], buffer, length)) 1151 if (copy_from_user(&buf[0], buffer, length))
1152 return -EFAULT; 1152 return -EFAULT;
1153 buf[length - 1] = '\0'; /*Ensure end string */ 1153 buf[length - 1] = '\0'; /*Ensure end string */
1154 pbuf = &buf[0]; 1154 pbuf = &buf[0];
1155 for (i = 0; i < 3; i++) { 1155 for (i = 0; i < 3; i++) {
1156 value = strsep(&pbuf, " "); 1156 value = strsep(&pbuf, " ");
1157 if (value != NULL) { 1157 if (value != NULL) {
1158 if (kstrtou8(value, 0, &reg_val) < 0) 1158 if (kstrtou8(value, 0, &reg_val) < 0)
1159 return -EINVAL; 1159 return -EINVAL;
1160 DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i, 1160 DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i,
1161 reg_val); 1161 reg_val);
1162 switch (i) { 1162 switch (i) {
1163 case 0: 1163 case 0:
1164 viafb_write_reg_mask(CR96, VIACR, 1164 viafb_write_reg_mask(CR96, VIACR,
1165 reg_val, 0x0f); 1165 reg_val, 0x0f);
1166 break; 1166 break;
1167 case 1: 1167 case 1:
1168 viafb_write_reg_mask(SR2A, VIASR, 1168 viafb_write_reg_mask(SR2A, VIASR,
1169 reg_val << 4, BIT5); 1169 reg_val << 4, BIT5);
1170 viafb_write_reg_mask(SR1B, VIASR, 1170 viafb_write_reg_mask(SR1B, VIASR,
1171 reg_val << 1, BIT1); 1171 reg_val << 1, BIT1);
1172 break; 1172 break;
1173 case 2: 1173 case 2:
1174 viafb_write_reg_mask(SR2A, VIASR, 1174 viafb_write_reg_mask(SR2A, VIASR,
1175 reg_val << 3, BIT4); 1175 reg_val << 3, BIT4);
1176 viafb_write_reg_mask(SR1E, VIASR, 1176 viafb_write_reg_mask(SR1E, VIASR,
1177 reg_val << 2, BIT2); 1177 reg_val << 2, BIT2);
1178 break; 1178 break;
1179 default: 1179 default:
1180 break; 1180 break;
1181 } 1181 }
1182 } else { 1182 } else {
1183 break; 1183 break;
1184 } 1184 }
1185 } 1185 }
1186 return count; 1186 return count;
1187 } 1187 }
1188 1188
1189 static const struct file_operations viafb_dvp0_proc_fops = { 1189 static const struct file_operations viafb_dvp0_proc_fops = {
1190 .owner = THIS_MODULE, 1190 .owner = THIS_MODULE,
1191 .open = viafb_dvp0_proc_open, 1191 .open = viafb_dvp0_proc_open,
1192 .read = seq_read, 1192 .read = seq_read,
1193 .llseek = seq_lseek, 1193 .llseek = seq_lseek,
1194 .release = single_release, 1194 .release = single_release,
1195 .write = viafb_dvp0_proc_write, 1195 .write = viafb_dvp0_proc_write,
1196 }; 1196 };
1197 1197
1198 static int viafb_dvp1_proc_show(struct seq_file *m, void *v) 1198 static int viafb_dvp1_proc_show(struct seq_file *m, void *v)
1199 { 1199 {
1200 u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0; 1200 u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0;
1201 dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f; 1201 dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f;
1202 dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2; 1202 dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2;
1203 dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03; 1203 dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03;
1204 seq_printf(m, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri); 1204 seq_printf(m, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri);
1205 return 0; 1205 return 0;
1206 } 1206 }
1207 1207
1208 static int viafb_dvp1_proc_open(struct inode *inode, struct file *file) 1208 static int viafb_dvp1_proc_open(struct inode *inode, struct file *file)
1209 { 1209 {
1210 return single_open(file, viafb_dvp1_proc_show, NULL); 1210 return single_open(file, viafb_dvp1_proc_show, NULL);
1211 } 1211 }
1212 1212
1213 static ssize_t viafb_dvp1_proc_write(struct file *file, 1213 static ssize_t viafb_dvp1_proc_write(struct file *file,
1214 const char __user *buffer, size_t count, loff_t *pos) 1214 const char __user *buffer, size_t count, loff_t *pos)
1215 { 1215 {
1216 char buf[20], *value, *pbuf; 1216 char buf[20], *value, *pbuf;
1217 u8 reg_val = 0; 1217 u8 reg_val = 0;
1218 unsigned long length, i; 1218 unsigned long length, i;
1219 if (count < 1) 1219 if (count < 1)
1220 return -EINVAL; 1220 return -EINVAL;
1221 length = count > 20 ? 20 : count; 1221 length = count > 20 ? 20 : count;
1222 if (copy_from_user(&buf[0], buffer, length)) 1222 if (copy_from_user(&buf[0], buffer, length))
1223 return -EFAULT; 1223 return -EFAULT;
1224 buf[length - 1] = '\0'; /*Ensure end string */ 1224 buf[length - 1] = '\0'; /*Ensure end string */
1225 pbuf = &buf[0]; 1225 pbuf = &buf[0];
1226 for (i = 0; i < 3; i++) { 1226 for (i = 0; i < 3; i++) {
1227 value = strsep(&pbuf, " "); 1227 value = strsep(&pbuf, " ");
1228 if (value != NULL) { 1228 if (value != NULL) {
1229 if (kstrtou8(value, 0, &reg_val) < 0) 1229 if (kstrtou8(value, 0, &reg_val) < 0)
1230 return -EINVAL; 1230 return -EINVAL;
1231 switch (i) { 1231 switch (i) {
1232 case 0: 1232 case 0:
1233 viafb_write_reg_mask(CR9B, VIACR, 1233 viafb_write_reg_mask(CR9B, VIACR,
1234 reg_val, 0x0f); 1234 reg_val, 0x0f);
1235 break; 1235 break;
1236 case 1: 1236 case 1:
1237 viafb_write_reg_mask(SR65, VIASR, 1237 viafb_write_reg_mask(SR65, VIASR,
1238 reg_val << 2, 0x0c); 1238 reg_val << 2, 0x0c);
1239 break; 1239 break;
1240 case 2: 1240 case 2:
1241 viafb_write_reg_mask(SR65, VIASR, 1241 viafb_write_reg_mask(SR65, VIASR,
1242 reg_val, 0x03); 1242 reg_val, 0x03);
1243 break; 1243 break;
1244 default: 1244 default:
1245 break; 1245 break;
1246 } 1246 }
1247 } else { 1247 } else {
1248 break; 1248 break;
1249 } 1249 }
1250 } 1250 }
1251 return count; 1251 return count;
1252 } 1252 }
1253 1253
1254 static const struct file_operations viafb_dvp1_proc_fops = { 1254 static const struct file_operations viafb_dvp1_proc_fops = {
1255 .owner = THIS_MODULE, 1255 .owner = THIS_MODULE,
1256 .open = viafb_dvp1_proc_open, 1256 .open = viafb_dvp1_proc_open,
1257 .read = seq_read, 1257 .read = seq_read,
1258 .llseek = seq_lseek, 1258 .llseek = seq_lseek,
1259 .release = single_release, 1259 .release = single_release,
1260 .write = viafb_dvp1_proc_write, 1260 .write = viafb_dvp1_proc_write,
1261 }; 1261 };
1262 1262
1263 static int viafb_dfph_proc_show(struct seq_file *m, void *v) 1263 static int viafb_dfph_proc_show(struct seq_file *m, void *v)
1264 { 1264 {
1265 u8 dfp_high = 0; 1265 u8 dfp_high = 0;
1266 dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f; 1266 dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f;
1267 seq_printf(m, "%x\n", dfp_high); 1267 seq_printf(m, "%x\n", dfp_high);
1268 return 0; 1268 return 0;
1269 } 1269 }
1270 1270
1271 static int viafb_dfph_proc_open(struct inode *inode, struct file *file) 1271 static int viafb_dfph_proc_open(struct inode *inode, struct file *file)
1272 { 1272 {
1273 return single_open(file, viafb_dfph_proc_show, NULL); 1273 return single_open(file, viafb_dfph_proc_show, NULL);
1274 } 1274 }
1275 1275
1276 static ssize_t viafb_dfph_proc_write(struct file *file, 1276 static ssize_t viafb_dfph_proc_write(struct file *file,
1277 const char __user *buffer, size_t count, loff_t *pos) 1277 const char __user *buffer, size_t count, loff_t *pos)
1278 { 1278 {
1279 char buf[20]; 1279 int err;
1280 u8 reg_val = 0; 1280 u8 reg_val;
1281 unsigned long length; 1281 err = kstrtou8_from_user(buffer, count, 0, &reg_val);
1282 if (count < 1) 1282 if (err)
1283 return -EINVAL; 1283 return err;
1284 length = count > 20 ? 20 : count; 1284
1285 if (copy_from_user(&buf[0], buffer, length))
1286 return -EFAULT;
1287 buf[length - 1] = '\0'; /*Ensure end string */
1288 if (kstrtou8(buf, 0, &reg_val) < 0)
1289 return -EINVAL;
1290 viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f); 1285 viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f);
1291 return count; 1286 return count;
1292 } 1287 }
1293 1288
1294 static const struct file_operations viafb_dfph_proc_fops = { 1289 static const struct file_operations viafb_dfph_proc_fops = {
1295 .owner = THIS_MODULE, 1290 .owner = THIS_MODULE,
1296 .open = viafb_dfph_proc_open, 1291 .open = viafb_dfph_proc_open,
1297 .read = seq_read, 1292 .read = seq_read,
1298 .llseek = seq_lseek, 1293 .llseek = seq_lseek,
1299 .release = single_release, 1294 .release = single_release,
1300 .write = viafb_dfph_proc_write, 1295 .write = viafb_dfph_proc_write,
1301 }; 1296 };
1302 1297
1303 static int viafb_dfpl_proc_show(struct seq_file *m, void *v) 1298 static int viafb_dfpl_proc_show(struct seq_file *m, void *v)
1304 { 1299 {
1305 u8 dfp_low = 0; 1300 u8 dfp_low = 0;
1306 dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f; 1301 dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f;
1307 seq_printf(m, "%x\n", dfp_low); 1302 seq_printf(m, "%x\n", dfp_low);
1308 return 0; 1303 return 0;
1309 } 1304 }
1310 1305
1311 static int viafb_dfpl_proc_open(struct inode *inode, struct file *file) 1306 static int viafb_dfpl_proc_open(struct inode *inode, struct file *file)
1312 { 1307 {
1313 return single_open(file, viafb_dfpl_proc_show, NULL); 1308 return single_open(file, viafb_dfpl_proc_show, NULL);
1314 } 1309 }
1315 1310
1316 static ssize_t viafb_dfpl_proc_write(struct file *file, 1311 static ssize_t viafb_dfpl_proc_write(struct file *file,
1317 const char __user *buffer, size_t count, loff_t *pos) 1312 const char __user *buffer, size_t count, loff_t *pos)
1318 { 1313 {
1319 char buf[20]; 1314 int err;
1320 u8 reg_val = 0; 1315 u8 reg_val;
1321 unsigned long length; 1316 err = kstrtou8_from_user(buffer, count, 0, &reg_val);
1322 if (count < 1) 1317 if (err)
1323 return -EINVAL; 1318 return err;
1324 length = count > 20 ? 20 : count; 1319
1325 if (copy_from_user(&buf[0], buffer, length))
1326 return -EFAULT;
1327 buf[length - 1] = '\0'; /*Ensure end string */
1328 if (kstrtou8(buf, 0, &reg_val) < 0)
1329 return -EINVAL;
1330 viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f); 1320 viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f);
1331 return count; 1321 return count;
1332 } 1322 }
1333 1323
1334 static const struct file_operations viafb_dfpl_proc_fops = { 1324 static const struct file_operations viafb_dfpl_proc_fops = {
1335 .owner = THIS_MODULE, 1325 .owner = THIS_MODULE,
1336 .open = viafb_dfpl_proc_open, 1326 .open = viafb_dfpl_proc_open,
1337 .read = seq_read, 1327 .read = seq_read,
1338 .llseek = seq_lseek, 1328 .llseek = seq_lseek,
1339 .release = single_release, 1329 .release = single_release,
1340 .write = viafb_dfpl_proc_write, 1330 .write = viafb_dfpl_proc_write,
1341 }; 1331 };
1342 1332
1343 static int viafb_vt1636_proc_show(struct seq_file *m, void *v) 1333 static int viafb_vt1636_proc_show(struct seq_file *m, void *v)
1344 { 1334 {
1345 u8 vt1636_08 = 0, vt1636_09 = 0; 1335 u8 vt1636_08 = 0, vt1636_09 = 0;
1346 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { 1336 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1347 case VT1636_LVDS: 1337 case VT1636_LVDS:
1348 vt1636_08 = 1338 vt1636_08 =
1349 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info, 1339 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1350 &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f; 1340 &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f;
1351 vt1636_09 = 1341 vt1636_09 =
1352 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info, 1342 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1353 &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f; 1343 &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f;
1354 seq_printf(m, "%x %x\n", vt1636_08, vt1636_09); 1344 seq_printf(m, "%x %x\n", vt1636_08, vt1636_09);
1355 break; 1345 break;
1356 default: 1346 default:
1357 break; 1347 break;
1358 } 1348 }
1359 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { 1349 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1360 case VT1636_LVDS: 1350 case VT1636_LVDS:
1361 vt1636_08 = 1351 vt1636_08 =
1362 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2, 1352 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1363 &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f; 1353 &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f;
1364 vt1636_09 = 1354 vt1636_09 =
1365 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2, 1355 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1366 &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f; 1356 &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f;
1367 seq_printf(m, " %x %x\n", vt1636_08, vt1636_09); 1357 seq_printf(m, " %x %x\n", vt1636_08, vt1636_09);
1368 break; 1358 break;
1369 default: 1359 default:
1370 break; 1360 break;
1371 } 1361 }
1372 return 0; 1362 return 0;
1373 } 1363 }
1374 1364
1375 static int viafb_vt1636_proc_open(struct inode *inode, struct file *file) 1365 static int viafb_vt1636_proc_open(struct inode *inode, struct file *file)
1376 { 1366 {
1377 return single_open(file, viafb_vt1636_proc_show, NULL); 1367 return single_open(file, viafb_vt1636_proc_show, NULL);
1378 } 1368 }
1379 1369
1380 static ssize_t viafb_vt1636_proc_write(struct file *file, 1370 static ssize_t viafb_vt1636_proc_write(struct file *file,
1381 const char __user *buffer, size_t count, loff_t *pos) 1371 const char __user *buffer, size_t count, loff_t *pos)
1382 { 1372 {
1383 char buf[30], *value, *pbuf; 1373 char buf[30], *value, *pbuf;
1384 struct IODATA reg_val; 1374 struct IODATA reg_val;
1385 unsigned long length, i; 1375 unsigned long length, i;
1386 if (count < 1) 1376 if (count < 1)
1387 return -EINVAL; 1377 return -EINVAL;
1388 length = count > 30 ? 30 : count; 1378 length = count > 30 ? 30 : count;
1389 if (copy_from_user(&buf[0], buffer, length)) 1379 if (copy_from_user(&buf[0], buffer, length))
1390 return -EFAULT; 1380 return -EFAULT;
1391 buf[length - 1] = '\0'; /*Ensure end string */ 1381 buf[length - 1] = '\0'; /*Ensure end string */
1392 pbuf = &buf[0]; 1382 pbuf = &buf[0];
1393 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { 1383 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1394 case VT1636_LVDS: 1384 case VT1636_LVDS:
1395 for (i = 0; i < 2; i++) { 1385 for (i = 0; i < 2; i++) {
1396 value = strsep(&pbuf, " "); 1386 value = strsep(&pbuf, " ");
1397 if (value != NULL) { 1387 if (value != NULL) {
1398 if (kstrtou8(value, 0, &reg_val.Data) < 0) 1388 if (kstrtou8(value, 0, &reg_val.Data) < 0)
1399 return -EINVAL; 1389 return -EINVAL;
1400 switch (i) { 1390 switch (i) {
1401 case 0: 1391 case 0:
1402 reg_val.Index = 0x08; 1392 reg_val.Index = 0x08;
1403 reg_val.Mask = 0x0f; 1393 reg_val.Mask = 0x0f;
1404 viafb_gpio_i2c_write_mask_lvds 1394 viafb_gpio_i2c_write_mask_lvds
1405 (viaparinfo->lvds_setting_info, 1395 (viaparinfo->lvds_setting_info,
1406 &viaparinfo-> 1396 &viaparinfo->
1407 chip_info->lvds_chip_info, 1397 chip_info->lvds_chip_info,
1408 reg_val); 1398 reg_val);
1409 break; 1399 break;
1410 case 1: 1400 case 1:
1411 reg_val.Index = 0x09; 1401 reg_val.Index = 0x09;
1412 reg_val.Mask = 0x1f; 1402 reg_val.Mask = 0x1f;
1413 viafb_gpio_i2c_write_mask_lvds 1403 viafb_gpio_i2c_write_mask_lvds
1414 (viaparinfo->lvds_setting_info, 1404 (viaparinfo->lvds_setting_info,
1415 &viaparinfo-> 1405 &viaparinfo->
1416 chip_info->lvds_chip_info, 1406 chip_info->lvds_chip_info,
1417 reg_val); 1407 reg_val);
1418 break; 1408 break;
1419 default: 1409 default:
1420 break; 1410 break;
1421 } 1411 }
1422 } else { 1412 } else {
1423 break; 1413 break;
1424 } 1414 }
1425 } 1415 }
1426 break; 1416 break;
1427 default: 1417 default:
1428 break; 1418 break;
1429 } 1419 }
1430 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { 1420 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1431 case VT1636_LVDS: 1421 case VT1636_LVDS:
1432 for (i = 0; i < 2; i++) { 1422 for (i = 0; i < 2; i++) {
1433 value = strsep(&pbuf, " "); 1423 value = strsep(&pbuf, " ");
1434 if (value != NULL) { 1424 if (value != NULL) {
1435 if (kstrtou8(value, 0, &reg_val.Data) < 0) 1425 if (kstrtou8(value, 0, &reg_val.Data) < 0)
1436 return -EINVAL; 1426 return -EINVAL;
1437 switch (i) { 1427 switch (i) {
1438 case 0: 1428 case 0:
1439 reg_val.Index = 0x08; 1429 reg_val.Index = 0x08;
1440 reg_val.Mask = 0x0f; 1430 reg_val.Mask = 0x0f;
1441 viafb_gpio_i2c_write_mask_lvds 1431 viafb_gpio_i2c_write_mask_lvds
1442 (viaparinfo->lvds_setting_info2, 1432 (viaparinfo->lvds_setting_info2,
1443 &viaparinfo-> 1433 &viaparinfo->
1444 chip_info->lvds_chip_info2, 1434 chip_info->lvds_chip_info2,
1445 reg_val); 1435 reg_val);
1446 break; 1436 break;
1447 case 1: 1437 case 1:
1448 reg_val.Index = 0x09; 1438 reg_val.Index = 0x09;
1449 reg_val.Mask = 0x1f; 1439 reg_val.Mask = 0x1f;
1450 viafb_gpio_i2c_write_mask_lvds 1440 viafb_gpio_i2c_write_mask_lvds
1451 (viaparinfo->lvds_setting_info2, 1441 (viaparinfo->lvds_setting_info2,
1452 &viaparinfo-> 1442 &viaparinfo->
1453 chip_info->lvds_chip_info2, 1443 chip_info->lvds_chip_info2,
1454 reg_val); 1444 reg_val);
1455 break; 1445 break;
1456 default: 1446 default:
1457 break; 1447 break;
1458 } 1448 }
1459 } else { 1449 } else {
1460 break; 1450 break;
1461 } 1451 }
1462 } 1452 }
1463 break; 1453 break;
1464 default: 1454 default:
1465 break; 1455 break;
1466 } 1456 }
1467 return count; 1457 return count;
1468 } 1458 }
1469 1459
1470 static const struct file_operations viafb_vt1636_proc_fops = { 1460 static const struct file_operations viafb_vt1636_proc_fops = {
1471 .owner = THIS_MODULE, 1461 .owner = THIS_MODULE,
1472 .open = viafb_vt1636_proc_open, 1462 .open = viafb_vt1636_proc_open,
1473 .read = seq_read, 1463 .read = seq_read,
1474 .llseek = seq_lseek, 1464 .llseek = seq_lseek,
1475 .release = single_release, 1465 .release = single_release,
1476 .write = viafb_vt1636_proc_write, 1466 .write = viafb_vt1636_proc_write,
1477 }; 1467 };
1478 1468
1479 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */ 1469 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1480 1470
1481 static int viafb_sup_odev_proc_show(struct seq_file *m, void *v) 1471 static int viafb_sup_odev_proc_show(struct seq_file *m, void *v)
1482 { 1472 {
1483 via_odev_to_seq(m, supported_odev_map[ 1473 via_odev_to_seq(m, supported_odev_map[
1484 viaparinfo->shared->chip_info.gfx_chip_name]); 1474 viaparinfo->shared->chip_info.gfx_chip_name]);
1485 return 0; 1475 return 0;
1486 } 1476 }
1487 1477
1488 static int viafb_sup_odev_proc_open(struct inode *inode, struct file *file) 1478 static int viafb_sup_odev_proc_open(struct inode *inode, struct file *file)
1489 { 1479 {
1490 return single_open(file, viafb_sup_odev_proc_show, NULL); 1480 return single_open(file, viafb_sup_odev_proc_show, NULL);
1491 } 1481 }
1492 1482
1493 static const struct file_operations viafb_sup_odev_proc_fops = { 1483 static const struct file_operations viafb_sup_odev_proc_fops = {
1494 .owner = THIS_MODULE, 1484 .owner = THIS_MODULE,
1495 .open = viafb_sup_odev_proc_open, 1485 .open = viafb_sup_odev_proc_open,
1496 .read = seq_read, 1486 .read = seq_read,
1497 .llseek = seq_lseek, 1487 .llseek = seq_lseek,
1498 .release = single_release, 1488 .release = single_release,
1499 }; 1489 };
1500 1490
1501 static ssize_t odev_update(const char __user *buffer, size_t count, u32 *odev) 1491 static ssize_t odev_update(const char __user *buffer, size_t count, u32 *odev)
1502 { 1492 {
1503 char buf[64], *ptr = buf; 1493 char buf[64], *ptr = buf;
1504 u32 devices; 1494 u32 devices;
1505 bool add, sub; 1495 bool add, sub;
1506 1496
1507 if (count < 1 || count > 63) 1497 if (count < 1 || count > 63)
1508 return -EINVAL; 1498 return -EINVAL;
1509 if (copy_from_user(&buf[0], buffer, count)) 1499 if (copy_from_user(&buf[0], buffer, count))
1510 return -EFAULT; 1500 return -EFAULT;
1511 buf[count] = '\0'; 1501 buf[count] = '\0';
1512 add = buf[0] == '+'; 1502 add = buf[0] == '+';
1513 sub = buf[0] == '-'; 1503 sub = buf[0] == '-';
1514 if (add || sub) 1504 if (add || sub)
1515 ptr++; 1505 ptr++;
1516 devices = via_parse_odev(ptr, &ptr); 1506 devices = via_parse_odev(ptr, &ptr);
1517 if (*ptr == '\n') 1507 if (*ptr == '\n')
1518 ptr++; 1508 ptr++;
1519 if (*ptr != 0) 1509 if (*ptr != 0)
1520 return -EINVAL; 1510 return -EINVAL;
1521 if (add) 1511 if (add)
1522 *odev |= devices; 1512 *odev |= devices;
1523 else if (sub) 1513 else if (sub)
1524 *odev &= ~devices; 1514 *odev &= ~devices;
1525 else 1515 else
1526 *odev = devices; 1516 *odev = devices;
1527 return count; 1517 return count;
1528 } 1518 }
1529 1519
1530 static int viafb_iga1_odev_proc_show(struct seq_file *m, void *v) 1520 static int viafb_iga1_odev_proc_show(struct seq_file *m, void *v)
1531 { 1521 {
1532 via_odev_to_seq(m, viaparinfo->shared->iga1_devices); 1522 via_odev_to_seq(m, viaparinfo->shared->iga1_devices);
1533 return 0; 1523 return 0;
1534 } 1524 }
1535 1525
1536 static int viafb_iga1_odev_proc_open(struct inode *inode, struct file *file) 1526 static int viafb_iga1_odev_proc_open(struct inode *inode, struct file *file)
1537 { 1527 {
1538 return single_open(file, viafb_iga1_odev_proc_show, NULL); 1528 return single_open(file, viafb_iga1_odev_proc_show, NULL);
1539 } 1529 }
1540 1530
1541 static ssize_t viafb_iga1_odev_proc_write(struct file *file, 1531 static ssize_t viafb_iga1_odev_proc_write(struct file *file,
1542 const char __user *buffer, size_t count, loff_t *pos) 1532 const char __user *buffer, size_t count, loff_t *pos)
1543 { 1533 {
1544 u32 dev_on, dev_off, dev_old, dev_new; 1534 u32 dev_on, dev_off, dev_old, dev_new;
1545 ssize_t res; 1535 ssize_t res;
1546 1536
1547 dev_old = dev_new = viaparinfo->shared->iga1_devices; 1537 dev_old = dev_new = viaparinfo->shared->iga1_devices;
1548 res = odev_update(buffer, count, &dev_new); 1538 res = odev_update(buffer, count, &dev_new);
1549 if (res != count) 1539 if (res != count)
1550 return res; 1540 return res;
1551 dev_off = dev_old & ~dev_new; 1541 dev_off = dev_old & ~dev_new;
1552 dev_on = dev_new & ~dev_old; 1542 dev_on = dev_new & ~dev_old;
1553 viaparinfo->shared->iga1_devices = dev_new; 1543 viaparinfo->shared->iga1_devices = dev_new;
1554 viaparinfo->shared->iga2_devices &= ~dev_new; 1544 viaparinfo->shared->iga2_devices &= ~dev_new;
1555 via_set_state(dev_off, VIA_STATE_OFF); 1545 via_set_state(dev_off, VIA_STATE_OFF);
1556 via_set_source(dev_new, IGA1); 1546 via_set_source(dev_new, IGA1);
1557 via_set_state(dev_on, VIA_STATE_ON); 1547 via_set_state(dev_on, VIA_STATE_ON);
1558 return res; 1548 return res;
1559 } 1549 }
1560 1550
1561 static const struct file_operations viafb_iga1_odev_proc_fops = { 1551 static const struct file_operations viafb_iga1_odev_proc_fops = {
1562 .owner = THIS_MODULE, 1552 .owner = THIS_MODULE,
1563 .open = viafb_iga1_odev_proc_open, 1553 .open = viafb_iga1_odev_proc_open,
1564 .read = seq_read, 1554 .read = seq_read,
1565 .llseek = seq_lseek, 1555 .llseek = seq_lseek,
1566 .release = single_release, 1556 .release = single_release,
1567 .write = viafb_iga1_odev_proc_write, 1557 .write = viafb_iga1_odev_proc_write,
1568 }; 1558 };
1569 1559
1570 static int viafb_iga2_odev_proc_show(struct seq_file *m, void *v) 1560 static int viafb_iga2_odev_proc_show(struct seq_file *m, void *v)
1571 { 1561 {
1572 via_odev_to_seq(m, viaparinfo->shared->iga2_devices); 1562 via_odev_to_seq(m, viaparinfo->shared->iga2_devices);
1573 return 0; 1563 return 0;
1574 } 1564 }
1575 1565
1576 static int viafb_iga2_odev_proc_open(struct inode *inode, struct file *file) 1566 static int viafb_iga2_odev_proc_open(struct inode *inode, struct file *file)
1577 { 1567 {
1578 return single_open(file, viafb_iga2_odev_proc_show, NULL); 1568 return single_open(file, viafb_iga2_odev_proc_show, NULL);
1579 } 1569 }
1580 1570
1581 static ssize_t viafb_iga2_odev_proc_write(struct file *file, 1571 static ssize_t viafb_iga2_odev_proc_write(struct file *file,
1582 const char __user *buffer, size_t count, loff_t *pos) 1572 const char __user *buffer, size_t count, loff_t *pos)
1583 { 1573 {
1584 u32 dev_on, dev_off, dev_old, dev_new; 1574 u32 dev_on, dev_off, dev_old, dev_new;
1585 ssize_t res; 1575 ssize_t res;
1586 1576
1587 dev_old = dev_new = viaparinfo->shared->iga2_devices; 1577 dev_old = dev_new = viaparinfo->shared->iga2_devices;
1588 res = odev_update(buffer, count, &dev_new); 1578 res = odev_update(buffer, count, &dev_new);
1589 if (res != count) 1579 if (res != count)
1590 return res; 1580 return res;
1591 dev_off = dev_old & ~dev_new; 1581 dev_off = dev_old & ~dev_new;
1592 dev_on = dev_new & ~dev_old; 1582 dev_on = dev_new & ~dev_old;
1593 viaparinfo->shared->iga2_devices = dev_new; 1583 viaparinfo->shared->iga2_devices = dev_new;
1594 viaparinfo->shared->iga1_devices &= ~dev_new; 1584 viaparinfo->shared->iga1_devices &= ~dev_new;
1595 via_set_state(dev_off, VIA_STATE_OFF); 1585 via_set_state(dev_off, VIA_STATE_OFF);
1596 via_set_source(dev_new, IGA2); 1586 via_set_source(dev_new, IGA2);
1597 via_set_state(dev_on, VIA_STATE_ON); 1587 via_set_state(dev_on, VIA_STATE_ON);
1598 return res; 1588 return res;
1599 } 1589 }
1600 1590
1601 static const struct file_operations viafb_iga2_odev_proc_fops = { 1591 static const struct file_operations viafb_iga2_odev_proc_fops = {
1602 .owner = THIS_MODULE, 1592 .owner = THIS_MODULE,
1603 .open = viafb_iga2_odev_proc_open, 1593 .open = viafb_iga2_odev_proc_open,
1604 .read = seq_read, 1594 .read = seq_read,
1605 .llseek = seq_lseek, 1595 .llseek = seq_lseek,
1606 .release = single_release, 1596 .release = single_release,
1607 .write = viafb_iga2_odev_proc_write, 1597 .write = viafb_iga2_odev_proc_write,
1608 }; 1598 };
1609 1599
1610 #define IS_VT1636(lvds_chip) ((lvds_chip).lvds_chip_name == VT1636_LVDS) 1600 #define IS_VT1636(lvds_chip) ((lvds_chip).lvds_chip_name == VT1636_LVDS)
1611 static void viafb_init_proc(struct viafb_shared *shared) 1601 static void viafb_init_proc(struct viafb_shared *shared)
1612 { 1602 {
1613 struct proc_dir_entry *iga1_entry, *iga2_entry, 1603 struct proc_dir_entry *iga1_entry, *iga2_entry,
1614 *viafb_entry = proc_mkdir("viafb", NULL); 1604 *viafb_entry = proc_mkdir("viafb", NULL);
1615 1605
1616 shared->proc_entry = viafb_entry; 1606 shared->proc_entry = viafb_entry;
1617 if (viafb_entry) { 1607 if (viafb_entry) {
1618 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS 1608 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1619 proc_create("dvp0", 0, viafb_entry, &viafb_dvp0_proc_fops); 1609 proc_create("dvp0", 0, viafb_entry, &viafb_dvp0_proc_fops);
1620 proc_create("dvp1", 0, viafb_entry, &viafb_dvp1_proc_fops); 1610 proc_create("dvp1", 0, viafb_entry, &viafb_dvp1_proc_fops);
1621 proc_create("dfph", 0, viafb_entry, &viafb_dfph_proc_fops); 1611 proc_create("dfph", 0, viafb_entry, &viafb_dfph_proc_fops);
1622 proc_create("dfpl", 0, viafb_entry, &viafb_dfpl_proc_fops); 1612 proc_create("dfpl", 0, viafb_entry, &viafb_dfpl_proc_fops);
1623 if (IS_VT1636(shared->chip_info.lvds_chip_info) 1613 if (IS_VT1636(shared->chip_info.lvds_chip_info)
1624 || IS_VT1636(shared->chip_info.lvds_chip_info2)) 1614 || IS_VT1636(shared->chip_info.lvds_chip_info2))
1625 proc_create("vt1636", 0, viafb_entry, 1615 proc_create("vt1636", 0, viafb_entry,
1626 &viafb_vt1636_proc_fops); 1616 &viafb_vt1636_proc_fops);
1627 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */ 1617 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1628 1618
1629 proc_create("supported_output_devices", 0, viafb_entry, 1619 proc_create("supported_output_devices", 0, viafb_entry,
1630 &viafb_sup_odev_proc_fops); 1620 &viafb_sup_odev_proc_fops);
1631 iga1_entry = proc_mkdir("iga1", viafb_entry); 1621 iga1_entry = proc_mkdir("iga1", viafb_entry);
1632 shared->iga1_proc_entry = iga1_entry; 1622 shared->iga1_proc_entry = iga1_entry;
1633 proc_create("output_devices", 0, iga1_entry, 1623 proc_create("output_devices", 0, iga1_entry,
1634 &viafb_iga1_odev_proc_fops); 1624 &viafb_iga1_odev_proc_fops);
1635 iga2_entry = proc_mkdir("iga2", viafb_entry); 1625 iga2_entry = proc_mkdir("iga2", viafb_entry);
1636 shared->iga2_proc_entry = iga2_entry; 1626 shared->iga2_proc_entry = iga2_entry;
1637 proc_create("output_devices", 0, iga2_entry, 1627 proc_create("output_devices", 0, iga2_entry,
1638 &viafb_iga2_odev_proc_fops); 1628 &viafb_iga2_odev_proc_fops);
1639 } 1629 }
1640 } 1630 }
1641 static void viafb_remove_proc(struct viafb_shared *shared) 1631 static void viafb_remove_proc(struct viafb_shared *shared)
1642 { 1632 {
1643 struct proc_dir_entry *viafb_entry = shared->proc_entry, 1633 struct proc_dir_entry *viafb_entry = shared->proc_entry,
1644 *iga1_entry = shared->iga1_proc_entry, 1634 *iga1_entry = shared->iga1_proc_entry,
1645 *iga2_entry = shared->iga2_proc_entry; 1635 *iga2_entry = shared->iga2_proc_entry;
1646 1636
1647 if (!viafb_entry) 1637 if (!viafb_entry)
1648 return; 1638 return;
1649 1639
1650 remove_proc_entry("output_devices", iga2_entry); 1640 remove_proc_entry("output_devices", iga2_entry);
1651 remove_proc_entry("iga2", viafb_entry); 1641 remove_proc_entry("iga2", viafb_entry);
1652 remove_proc_entry("output_devices", iga1_entry); 1642 remove_proc_entry("output_devices", iga1_entry);
1653 remove_proc_entry("iga1", viafb_entry); 1643 remove_proc_entry("iga1", viafb_entry);
1654 remove_proc_entry("supported_output_devices", viafb_entry); 1644 remove_proc_entry("supported_output_devices", viafb_entry);
1655 1645
1656 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS 1646 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1657 remove_proc_entry("dvp0", viafb_entry);/* parent dir */ 1647 remove_proc_entry("dvp0", viafb_entry);/* parent dir */
1658 remove_proc_entry("dvp1", viafb_entry); 1648 remove_proc_entry("dvp1", viafb_entry);
1659 remove_proc_entry("dfph", viafb_entry); 1649 remove_proc_entry("dfph", viafb_entry);
1660 remove_proc_entry("dfpl", viafb_entry); 1650 remove_proc_entry("dfpl", viafb_entry);
1661 if (IS_VT1636(shared->chip_info.lvds_chip_info) 1651 if (IS_VT1636(shared->chip_info.lvds_chip_info)
1662 || IS_VT1636(shared->chip_info.lvds_chip_info2)) 1652 || IS_VT1636(shared->chip_info.lvds_chip_info2))
1663 remove_proc_entry("vt1636", viafb_entry); 1653 remove_proc_entry("vt1636", viafb_entry);
1664 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */ 1654 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1665 1655
1666 remove_proc_entry("viafb", NULL); 1656 remove_proc_entry("viafb", NULL);
1667 } 1657 }
1668 #undef IS_VT1636 1658 #undef IS_VT1636
1669 1659
1670 static int parse_mode(const char *str, u32 devices, u32 *xres, u32 *yres) 1660 static int parse_mode(const char *str, u32 devices, u32 *xres, u32 *yres)
1671 { 1661 {
1672 const struct fb_videomode *mode = NULL; 1662 const struct fb_videomode *mode = NULL;
1673 char *ptr; 1663 char *ptr;
1674 1664
1675 if (!str) { 1665 if (!str) {
1676 if (devices == VIA_CRT) 1666 if (devices == VIA_CRT)
1677 mode = via_aux_get_preferred_mode( 1667 mode = via_aux_get_preferred_mode(
1678 viaparinfo->shared->i2c_26); 1668 viaparinfo->shared->i2c_26);
1679 else if (devices == VIA_DVP1) 1669 else if (devices == VIA_DVP1)
1680 mode = via_aux_get_preferred_mode( 1670 mode = via_aux_get_preferred_mode(
1681 viaparinfo->shared->i2c_31); 1671 viaparinfo->shared->i2c_31);
1682 1672
1683 if (mode) { 1673 if (mode) {
1684 *xres = mode->xres; 1674 *xres = mode->xres;
1685 *yres = mode->yres; 1675 *yres = mode->yres;
1686 } else if (machine_is_olpc()) { 1676 } else if (machine_is_olpc()) {
1687 *xres = 1200; 1677 *xres = 1200;
1688 *yres = 900; 1678 *yres = 900;
1689 } else { 1679 } else {
1690 *xres = 640; 1680 *xres = 640;
1691 *yres = 480; 1681 *yres = 480;
1692 } 1682 }
1693 return 0; 1683 return 0;
1694 } 1684 }
1695 1685
1696 *xres = simple_strtoul(str, &ptr, 10); 1686 *xres = simple_strtoul(str, &ptr, 10);
1697 if (ptr[0] != 'x') 1687 if (ptr[0] != 'x')
1698 return -EINVAL; 1688 return -EINVAL;
1699 1689
1700 *yres = simple_strtoul(&ptr[1], &ptr, 10); 1690 *yres = simple_strtoul(&ptr[1], &ptr, 10);
1701 if (ptr[0]) 1691 if (ptr[0])
1702 return -EINVAL; 1692 return -EINVAL;
1703 1693
1704 return 0; 1694 return 0;
1705 } 1695 }
1706 1696
1707 1697
1708 #ifdef CONFIG_PM 1698 #ifdef CONFIG_PM
1709 static int viafb_suspend(void *unused) 1699 static int viafb_suspend(void *unused)
1710 { 1700 {
1711 console_lock(); 1701 console_lock();
1712 fb_set_suspend(viafbinfo, 1); 1702 fb_set_suspend(viafbinfo, 1);
1713 viafb_sync(viafbinfo); 1703 viafb_sync(viafbinfo);
1714 console_unlock(); 1704 console_unlock();
1715 1705
1716 return 0; 1706 return 0;
1717 } 1707 }
1718 1708
1719 static int viafb_resume(void *unused) 1709 static int viafb_resume(void *unused)
1720 { 1710 {
1721 console_lock(); 1711 console_lock();
1722 if (viaparinfo->shared->vdev->engine_mmio) 1712 if (viaparinfo->shared->vdev->engine_mmio)
1723 viafb_reset_engine(viaparinfo); 1713 viafb_reset_engine(viaparinfo);
1724 viafb_set_par(viafbinfo); 1714 viafb_set_par(viafbinfo);
1725 if (viafb_dual_fb) 1715 if (viafb_dual_fb)
1726 viafb_set_par(viafbinfo1); 1716 viafb_set_par(viafbinfo1);
1727 fb_set_suspend(viafbinfo, 0); 1717 fb_set_suspend(viafbinfo, 0);
1728 1718
1729 console_unlock(); 1719 console_unlock();
1730 return 0; 1720 return 0;
1731 } 1721 }
1732 1722
1733 static struct viafb_pm_hooks viafb_fb_pm_hooks = { 1723 static struct viafb_pm_hooks viafb_fb_pm_hooks = {
1734 .suspend = viafb_suspend, 1724 .suspend = viafb_suspend,
1735 .resume = viafb_resume 1725 .resume = viafb_resume
1736 }; 1726 };
1737 1727
1738 #endif 1728 #endif
1739 1729
1740 static void __devinit i2c_bus_probe(struct viafb_shared *shared) 1730 static void __devinit i2c_bus_probe(struct viafb_shared *shared)
1741 { 1731 {
1742 /* should be always CRT */ 1732 /* should be always CRT */
1743 printk(KERN_INFO "viafb: Probing I2C bus 0x26\n"); 1733 printk(KERN_INFO "viafb: Probing I2C bus 0x26\n");
1744 shared->i2c_26 = via_aux_probe(viafb_find_i2c_adapter(VIA_PORT_26)); 1734 shared->i2c_26 = via_aux_probe(viafb_find_i2c_adapter(VIA_PORT_26));
1745 1735
1746 /* seems to be usually DVP1 */ 1736 /* seems to be usually DVP1 */
1747 printk(KERN_INFO "viafb: Probing I2C bus 0x31\n"); 1737 printk(KERN_INFO "viafb: Probing I2C bus 0x31\n");
1748 shared->i2c_31 = via_aux_probe(viafb_find_i2c_adapter(VIA_PORT_31)); 1738 shared->i2c_31 = via_aux_probe(viafb_find_i2c_adapter(VIA_PORT_31));
1749 1739
1750 /* FIXME: what is this? */ 1740 /* FIXME: what is this? */
1751 if (!machine_is_olpc()) { 1741 if (!machine_is_olpc()) {
1752 printk(KERN_INFO "viafb: Probing I2C bus 0x2C\n"); 1742 printk(KERN_INFO "viafb: Probing I2C bus 0x2C\n");
1753 shared->i2c_2C = via_aux_probe(viafb_find_i2c_adapter(VIA_PORT_2C)); 1743 shared->i2c_2C = via_aux_probe(viafb_find_i2c_adapter(VIA_PORT_2C));
1754 } 1744 }
1755 1745
1756 printk(KERN_INFO "viafb: Finished I2C bus probing"); 1746 printk(KERN_INFO "viafb: Finished I2C bus probing");
1757 } 1747 }
1758 1748
1759 static void i2c_bus_free(struct viafb_shared *shared) 1749 static void i2c_bus_free(struct viafb_shared *shared)
1760 { 1750 {
1761 via_aux_free(shared->i2c_26); 1751 via_aux_free(shared->i2c_26);
1762 via_aux_free(shared->i2c_31); 1752 via_aux_free(shared->i2c_31);
1763 via_aux_free(shared->i2c_2C); 1753 via_aux_free(shared->i2c_2C);
1764 } 1754 }
1765 1755
1766 int __devinit via_fb_pci_probe(struct viafb_dev *vdev) 1756 int __devinit via_fb_pci_probe(struct viafb_dev *vdev)
1767 { 1757 {
1768 u32 default_xres, default_yres; 1758 u32 default_xres, default_yres;
1769 struct fb_var_screeninfo default_var; 1759 struct fb_var_screeninfo default_var;
1770 int rc; 1760 int rc;
1771 u32 viafb_par_length; 1761 u32 viafb_par_length;
1772 1762
1773 DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n"); 1763 DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
1774 memset(&default_var, 0, sizeof(default_var)); 1764 memset(&default_var, 0, sizeof(default_var));
1775 viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8); 1765 viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8);
1776 1766
1777 /* Allocate fb_info and ***_par here, also including some other needed 1767 /* Allocate fb_info and ***_par here, also including some other needed
1778 * variables 1768 * variables
1779 */ 1769 */
1780 viafbinfo = framebuffer_alloc(viafb_par_length + 1770 viafbinfo = framebuffer_alloc(viafb_par_length +
1781 ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8), 1771 ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8),
1782 &vdev->pdev->dev); 1772 &vdev->pdev->dev);
1783 if (!viafbinfo) { 1773 if (!viafbinfo) {
1784 printk(KERN_ERR"Could not allocate memory for viafb_info.\n"); 1774 printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
1785 return -ENOMEM; 1775 return -ENOMEM;
1786 } 1776 }
1787 1777
1788 viaparinfo = (struct viafb_par *)viafbinfo->par; 1778 viaparinfo = (struct viafb_par *)viafbinfo->par;
1789 viaparinfo->shared = viafbinfo->par + viafb_par_length; 1779 viaparinfo->shared = viafbinfo->par + viafb_par_length;
1790 viaparinfo->shared->vdev = vdev; 1780 viaparinfo->shared->vdev = vdev;
1791 viaparinfo->vram_addr = 0; 1781 viaparinfo->vram_addr = 0;
1792 viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info; 1782 viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info;
1793 viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info; 1783 viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info;
1794 viaparinfo->lvds_setting_info2 = 1784 viaparinfo->lvds_setting_info2 =
1795 &viaparinfo->shared->lvds_setting_info2; 1785 &viaparinfo->shared->lvds_setting_info2;
1796 viaparinfo->chip_info = &viaparinfo->shared->chip_info; 1786 viaparinfo->chip_info = &viaparinfo->shared->chip_info;
1797 1787
1798 i2c_bus_probe(viaparinfo->shared); 1788 i2c_bus_probe(viaparinfo->shared);
1799 if (viafb_dual_fb) 1789 if (viafb_dual_fb)
1800 viafb_SAMM_ON = 1; 1790 viafb_SAMM_ON = 1;
1801 parse_lcd_port(); 1791 parse_lcd_port();
1802 parse_dvi_port(); 1792 parse_dvi_port();
1803 1793
1804 viafb_init_chip_info(vdev->chip_type); 1794 viafb_init_chip_info(vdev->chip_type);
1805 /* 1795 /*
1806 * The framebuffer will have been successfully mapped by 1796 * The framebuffer will have been successfully mapped by
1807 * the core (or we'd not be here), but we still need to 1797 * the core (or we'd not be here), but we still need to
1808 * set up our own accounting. 1798 * set up our own accounting.
1809 */ 1799 */
1810 viaparinfo->fbmem = vdev->fbmem_start; 1800 viaparinfo->fbmem = vdev->fbmem_start;
1811 viaparinfo->memsize = vdev->fbmem_len; 1801 viaparinfo->memsize = vdev->fbmem_len;
1812 viaparinfo->fbmem_free = viaparinfo->memsize; 1802 viaparinfo->fbmem_free = viaparinfo->memsize;
1813 viaparinfo->fbmem_used = 0; 1803 viaparinfo->fbmem_used = 0;
1814 viafbinfo->screen_base = vdev->fbmem; 1804 viafbinfo->screen_base = vdev->fbmem;
1815 1805
1816 viafbinfo->fix.mmio_start = vdev->engine_start; 1806 viafbinfo->fix.mmio_start = vdev->engine_start;
1817 viafbinfo->fix.mmio_len = vdev->engine_len; 1807 viafbinfo->fix.mmio_len = vdev->engine_len;
1818 viafbinfo->node = 0; 1808 viafbinfo->node = 0;
1819 viafbinfo->fbops = &viafb_ops; 1809 viafbinfo->fbops = &viafb_ops;
1820 viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; 1810 viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1821 1811
1822 viafbinfo->pseudo_palette = pseudo_pal; 1812 viafbinfo->pseudo_palette = pseudo_pal;
1823 if (viafb_accel && !viafb_setup_engine(viafbinfo)) { 1813 if (viafb_accel && !viafb_setup_engine(viafbinfo)) {
1824 viafbinfo->flags |= FBINFO_HWACCEL_COPYAREA | 1814 viafbinfo->flags |= FBINFO_HWACCEL_COPYAREA |
1825 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT; 1815 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT;
1826 default_var.accel_flags = FB_ACCELF_TEXT; 1816 default_var.accel_flags = FB_ACCELF_TEXT;
1827 } else { 1817 } else {
1828 viafbinfo->flags |= FBINFO_HWACCEL_DISABLED; 1818 viafbinfo->flags |= FBINFO_HWACCEL_DISABLED;
1829 default_var.accel_flags = 0; 1819 default_var.accel_flags = 0;
1830 } 1820 }
1831 1821
1832 if (viafb_second_size && (viafb_second_size < 8)) { 1822 if (viafb_second_size && (viafb_second_size < 8)) {
1833 viafb_second_offset = viaparinfo->fbmem_free - 1823 viafb_second_offset = viaparinfo->fbmem_free -
1834 viafb_second_size * 1024 * 1024; 1824 viafb_second_size * 1024 * 1024;
1835 } else { 1825 } else {
1836 viafb_second_size = 8; 1826 viafb_second_size = 8;
1837 viafb_second_offset = viaparinfo->fbmem_free - 1827 viafb_second_offset = viaparinfo->fbmem_free -
1838 viafb_second_size * 1024 * 1024; 1828 viafb_second_size * 1024 * 1024;
1839 } 1829 }
1840 1830
1841 parse_mode(viafb_mode, viaparinfo->shared->iga1_devices, 1831 parse_mode(viafb_mode, viaparinfo->shared->iga1_devices,
1842 &default_xres, &default_yres); 1832 &default_xres, &default_yres);
1843 if (viafb_SAMM_ON == 1) 1833 if (viafb_SAMM_ON == 1)
1844 parse_mode(viafb_mode1, viaparinfo->shared->iga2_devices, 1834 parse_mode(viafb_mode1, viaparinfo->shared->iga2_devices,
1845 &viafb_second_xres, &viafb_second_yres); 1835 &viafb_second_xres, &viafb_second_yres);
1846 1836
1847 default_var.xres = default_xres; 1837 default_var.xres = default_xres;
1848 default_var.yres = default_yres; 1838 default_var.yres = default_yres;
1849 default_var.xres_virtual = default_xres; 1839 default_var.xres_virtual = default_xres;
1850 default_var.yres_virtual = default_yres; 1840 default_var.yres_virtual = default_yres;
1851 default_var.bits_per_pixel = viafb_bpp; 1841 default_var.bits_per_pixel = viafb_bpp;
1852 viafb_fill_var_timing_info(&default_var, viafb_get_best_mode( 1842 viafb_fill_var_timing_info(&default_var, viafb_get_best_mode(
1853 default_var.xres, default_var.yres, viafb_refresh)); 1843 default_var.xres, default_var.yres, viafb_refresh));
1854 viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo); 1844 viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo);
1855 viafbinfo->var = default_var; 1845 viafbinfo->var = default_var;
1856 1846
1857 if (viafb_dual_fb) { 1847 if (viafb_dual_fb) {
1858 viafbinfo1 = framebuffer_alloc(viafb_par_length, 1848 viafbinfo1 = framebuffer_alloc(viafb_par_length,
1859 &vdev->pdev->dev); 1849 &vdev->pdev->dev);
1860 if (!viafbinfo1) { 1850 if (!viafbinfo1) {
1861 printk(KERN_ERR 1851 printk(KERN_ERR
1862 "allocate the second framebuffer struct error\n"); 1852 "allocate the second framebuffer struct error\n");
1863 rc = -ENOMEM; 1853 rc = -ENOMEM;
1864 goto out_fb_release; 1854 goto out_fb_release;
1865 } 1855 }
1866 viaparinfo1 = viafbinfo1->par; 1856 viaparinfo1 = viafbinfo1->par;
1867 memcpy(viaparinfo1, viaparinfo, viafb_par_length); 1857 memcpy(viaparinfo1, viaparinfo, viafb_par_length);
1868 viaparinfo1->vram_addr = viafb_second_offset; 1858 viaparinfo1->vram_addr = viafb_second_offset;
1869 viaparinfo1->memsize = viaparinfo->memsize - 1859 viaparinfo1->memsize = viaparinfo->memsize -
1870 viafb_second_offset; 1860 viafb_second_offset;
1871 viaparinfo->memsize = viafb_second_offset; 1861 viaparinfo->memsize = viafb_second_offset;
1872 viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset; 1862 viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset;
1873 1863
1874 viaparinfo1->fbmem_used = viaparinfo->fbmem_used; 1864 viaparinfo1->fbmem_used = viaparinfo->fbmem_used;
1875 viaparinfo1->fbmem_free = viaparinfo1->memsize - 1865 viaparinfo1->fbmem_free = viaparinfo1->memsize -
1876 viaparinfo1->fbmem_used; 1866 viaparinfo1->fbmem_used;
1877 viaparinfo->fbmem_free = viaparinfo->memsize; 1867 viaparinfo->fbmem_free = viaparinfo->memsize;
1878 viaparinfo->fbmem_used = 0; 1868 viaparinfo->fbmem_used = 0;
1879 1869
1880 viaparinfo->iga_path = IGA1; 1870 viaparinfo->iga_path = IGA1;
1881 viaparinfo1->iga_path = IGA2; 1871 viaparinfo1->iga_path = IGA2;
1882 memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info)); 1872 memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info));
1883 viafbinfo1->par = viaparinfo1; 1873 viafbinfo1->par = viaparinfo1;
1884 viafbinfo1->screen_base = viafbinfo->screen_base + 1874 viafbinfo1->screen_base = viafbinfo->screen_base +
1885 viafb_second_offset; 1875 viafb_second_offset;
1886 1876
1887 default_var.xres = viafb_second_xres; 1877 default_var.xres = viafb_second_xres;
1888 default_var.yres = viafb_second_yres; 1878 default_var.yres = viafb_second_yres;
1889 default_var.xres_virtual = viafb_second_xres; 1879 default_var.xres_virtual = viafb_second_xres;
1890 default_var.yres_virtual = viafb_second_yres; 1880 default_var.yres_virtual = viafb_second_yres;
1891 default_var.bits_per_pixel = viafb_bpp1; 1881 default_var.bits_per_pixel = viafb_bpp1;
1892 viafb_fill_var_timing_info(&default_var, viafb_get_best_mode( 1882 viafb_fill_var_timing_info(&default_var, viafb_get_best_mode(
1893 default_var.xres, default_var.yres, viafb_refresh1)); 1883 default_var.xres, default_var.yres, viafb_refresh1));
1894 1884
1895 viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1); 1885 viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1);
1896 viafb_check_var(&default_var, viafbinfo1); 1886 viafb_check_var(&default_var, viafbinfo1);
1897 viafbinfo1->var = default_var; 1887 viafbinfo1->var = default_var;
1898 viafb_update_fix(viafbinfo1); 1888 viafb_update_fix(viafbinfo1);
1899 viaparinfo1->depth = fb_get_color_depth(&viafbinfo1->var, 1889 viaparinfo1->depth = fb_get_color_depth(&viafbinfo1->var,
1900 &viafbinfo1->fix); 1890 &viafbinfo1->fix);
1901 } 1891 }
1902 1892
1903 viafb_check_var(&viafbinfo->var, viafbinfo); 1893 viafb_check_var(&viafbinfo->var, viafbinfo);
1904 viafb_update_fix(viafbinfo); 1894 viafb_update_fix(viafbinfo);
1905 viaparinfo->depth = fb_get_color_depth(&viafbinfo->var, 1895 viaparinfo->depth = fb_get_color_depth(&viafbinfo->var,
1906 &viafbinfo->fix); 1896 &viafbinfo->fix);
1907 default_var.activate = FB_ACTIVATE_NOW; 1897 default_var.activate = FB_ACTIVATE_NOW;
1908 rc = fb_alloc_cmap(&viafbinfo->cmap, 256, 0); 1898 rc = fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
1909 if (rc) 1899 if (rc)
1910 goto out_fb1_release; 1900 goto out_fb1_release;
1911 1901
1912 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device) 1902 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
1913 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) { 1903 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) {
1914 rc = register_framebuffer(viafbinfo1); 1904 rc = register_framebuffer(viafbinfo1);
1915 if (rc) 1905 if (rc)
1916 goto out_dealloc_cmap; 1906 goto out_dealloc_cmap;
1917 } 1907 }
1918 rc = register_framebuffer(viafbinfo); 1908 rc = register_framebuffer(viafbinfo);
1919 if (rc) 1909 if (rc)
1920 goto out_fb1_unreg_lcd_cle266; 1910 goto out_fb1_unreg_lcd_cle266;
1921 1911
1922 if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device) 1912 if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device)
1923 || (viaparinfo->chip_info->gfx_chip_name != 1913 || (viaparinfo->chip_info->gfx_chip_name !=
1924 UNICHROME_CLE266))) { 1914 UNICHROME_CLE266))) {
1925 rc = register_framebuffer(viafbinfo1); 1915 rc = register_framebuffer(viafbinfo1);
1926 if (rc) 1916 if (rc)
1927 goto out_fb_unreg; 1917 goto out_fb_unreg;
1928 } 1918 }
1929 DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n", 1919 DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n",
1930 viafbinfo->node, viafbinfo->fix.id, default_var.xres, 1920 viafbinfo->node, viafbinfo->fix.id, default_var.xres,
1931 default_var.yres, default_var.bits_per_pixel); 1921 default_var.yres, default_var.bits_per_pixel);
1932 1922
1933 viafb_init_proc(viaparinfo->shared); 1923 viafb_init_proc(viaparinfo->shared);
1934 viafb_init_dac(IGA2); 1924 viafb_init_dac(IGA2);
1935 1925
1936 #ifdef CONFIG_PM 1926 #ifdef CONFIG_PM
1937 viafb_pm_register(&viafb_fb_pm_hooks); 1927 viafb_pm_register(&viafb_fb_pm_hooks);
1938 #endif 1928 #endif
1939 return 0; 1929 return 0;
1940 1930
1941 out_fb_unreg: 1931 out_fb_unreg:
1942 unregister_framebuffer(viafbinfo); 1932 unregister_framebuffer(viafbinfo);
1943 out_fb1_unreg_lcd_cle266: 1933 out_fb1_unreg_lcd_cle266:
1944 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device) 1934 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
1945 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) 1935 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266))
1946 unregister_framebuffer(viafbinfo1); 1936 unregister_framebuffer(viafbinfo1);
1947 out_dealloc_cmap: 1937 out_dealloc_cmap:
1948 fb_dealloc_cmap(&viafbinfo->cmap); 1938 fb_dealloc_cmap(&viafbinfo->cmap);
1949 out_fb1_release: 1939 out_fb1_release:
1950 if (viafbinfo1) 1940 if (viafbinfo1)
1951 framebuffer_release(viafbinfo1); 1941 framebuffer_release(viafbinfo1);
1952 out_fb_release: 1942 out_fb_release:
1953 i2c_bus_free(viaparinfo->shared); 1943 i2c_bus_free(viaparinfo->shared);
1954 framebuffer_release(viafbinfo); 1944 framebuffer_release(viafbinfo);
1955 return rc; 1945 return rc;
1956 } 1946 }
1957 1947
1958 void __devexit via_fb_pci_remove(struct pci_dev *pdev) 1948 void __devexit via_fb_pci_remove(struct pci_dev *pdev)
1959 { 1949 {
1960 DEBUG_MSG(KERN_INFO "via_pci_remove!\n"); 1950 DEBUG_MSG(KERN_INFO "via_pci_remove!\n");
1961 fb_dealloc_cmap(&viafbinfo->cmap); 1951 fb_dealloc_cmap(&viafbinfo->cmap);
1962 unregister_framebuffer(viafbinfo); 1952 unregister_framebuffer(viafbinfo);
1963 if (viafb_dual_fb) 1953 if (viafb_dual_fb)
1964 unregister_framebuffer(viafbinfo1); 1954 unregister_framebuffer(viafbinfo1);
1965 viafb_remove_proc(viaparinfo->shared); 1955 viafb_remove_proc(viaparinfo->shared);
1966 i2c_bus_free(viaparinfo->shared); 1956 i2c_bus_free(viaparinfo->shared);
1967 framebuffer_release(viafbinfo); 1957 framebuffer_release(viafbinfo);
1968 if (viafb_dual_fb) 1958 if (viafb_dual_fb)
1969 framebuffer_release(viafbinfo1); 1959 framebuffer_release(viafbinfo1);
1970 } 1960 }
1971 1961
1972 #ifndef MODULE 1962 #ifndef MODULE
1973 static int __init viafb_setup(void) 1963 static int __init viafb_setup(void)
1974 { 1964 {
1975 char *this_opt; 1965 char *this_opt;
1976 char *options; 1966 char *options;
1977 1967
1978 DEBUG_MSG(KERN_INFO "viafb_setup!\n"); 1968 DEBUG_MSG(KERN_INFO "viafb_setup!\n");
1979 1969
1980 if (fb_get_options("viafb", &options)) 1970 if (fb_get_options("viafb", &options))
1981 return -ENODEV; 1971 return -ENODEV;
1982 1972
1983 if (!options || !*options) 1973 if (!options || !*options)
1984 return 0; 1974 return 0;
1985 1975
1986 while ((this_opt = strsep(&options, ",")) != NULL) { 1976 while ((this_opt = strsep(&options, ",")) != NULL) {
1987 if (!*this_opt) 1977 if (!*this_opt)
1988 continue; 1978 continue;
1989 1979
1990 if (!strncmp(this_opt, "viafb_mode1=", 12)) { 1980 if (!strncmp(this_opt, "viafb_mode1=", 12)) {
1991 viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL); 1981 viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
1992 } else if (!strncmp(this_opt, "viafb_mode=", 11)) { 1982 } else if (!strncmp(this_opt, "viafb_mode=", 11)) {
1993 viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL); 1983 viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL);
1994 } else if (!strncmp(this_opt, "viafb_bpp1=", 11)) { 1984 } else if (!strncmp(this_opt, "viafb_bpp1=", 11)) {
1995 if (kstrtouint(this_opt + 11, 0, &viafb_bpp1) < 0) 1985 if (kstrtouint(this_opt + 11, 0, &viafb_bpp1) < 0)
1996 return -EINVAL; 1986 return -EINVAL;
1997 } else if (!strncmp(this_opt, "viafb_bpp=", 10)) { 1987 } else if (!strncmp(this_opt, "viafb_bpp=", 10)) {
1998 if (kstrtouint(this_opt + 10, 0, &viafb_bpp) < 0) 1988 if (kstrtouint(this_opt + 10, 0, &viafb_bpp) < 0)
1999 return -EINVAL; 1989 return -EINVAL;
2000 } else if (!strncmp(this_opt, "viafb_refresh1=", 15)) { 1990 } else if (!strncmp(this_opt, "viafb_refresh1=", 15)) {
2001 if (kstrtoint(this_opt + 15, 0, &viafb_refresh1) < 0) 1991 if (kstrtoint(this_opt + 15, 0, &viafb_refresh1) < 0)
2002 return -EINVAL; 1992 return -EINVAL;
2003 } else if (!strncmp(this_opt, "viafb_refresh=", 14)) { 1993 } else if (!strncmp(this_opt, "viafb_refresh=", 14)) {
2004 if (kstrtoint(this_opt + 14, 0, &viafb_refresh) < 0) 1994 if (kstrtoint(this_opt + 14, 0, &viafb_refresh) < 0)
2005 return -EINVAL; 1995 return -EINVAL;
2006 } else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21)) { 1996 } else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21)) {
2007 if (kstrtoint(this_opt + 21, 0, 1997 if (kstrtoint(this_opt + 21, 0,
2008 &viafb_lcd_dsp_method) < 0) 1998 &viafb_lcd_dsp_method) < 0)
2009 return -EINVAL; 1999 return -EINVAL;
2010 } else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19)) { 2000 } else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19)) {
2011 if (kstrtoint(this_opt + 19, 0, 2001 if (kstrtoint(this_opt + 19, 0,
2012 &viafb_lcd_panel_id) < 0) 2002 &viafb_lcd_panel_id) < 0)
2013 return -EINVAL; 2003 return -EINVAL;
2014 } else if (!strncmp(this_opt, "viafb_accel=", 12)) { 2004 } else if (!strncmp(this_opt, "viafb_accel=", 12)) {
2015 if (kstrtoint(this_opt + 12, 0, &viafb_accel) < 0) 2005 if (kstrtoint(this_opt + 12, 0, &viafb_accel) < 0)
2016 return -EINVAL; 2006 return -EINVAL;
2017 } else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14)) { 2007 } else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14)) {
2018 if (kstrtoint(this_opt + 14, 0, &viafb_SAMM_ON) < 0) 2008 if (kstrtoint(this_opt + 14, 0, &viafb_SAMM_ON) < 0)
2019 return -EINVAL; 2009 return -EINVAL;
2020 } else if (!strncmp(this_opt, "viafb_active_dev=", 17)) { 2010 } else if (!strncmp(this_opt, "viafb_active_dev=", 17)) {
2021 viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL); 2011 viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL);
2022 } else if (!strncmp(this_opt, 2012 } else if (!strncmp(this_opt,
2023 "viafb_display_hardware_layout=", 30)) { 2013 "viafb_display_hardware_layout=", 30)) {
2024 if (kstrtoint(this_opt + 30, 0, 2014 if (kstrtoint(this_opt + 30, 0,
2025 &viafb_display_hardware_layout) < 0) 2015 &viafb_display_hardware_layout) < 0)
2026 return -EINVAL; 2016 return -EINVAL;
2027 } else if (!strncmp(this_opt, "viafb_second_size=", 18)) { 2017 } else if (!strncmp(this_opt, "viafb_second_size=", 18)) {
2028 if (kstrtoint(this_opt + 18, 0, &viafb_second_size) < 0) 2018 if (kstrtoint(this_opt + 18, 0, &viafb_second_size) < 0)
2029 return -EINVAL; 2019 return -EINVAL;
2030 } else if (!strncmp(this_opt, 2020 } else if (!strncmp(this_opt,
2031 "viafb_platform_epia_dvi=", 24)) { 2021 "viafb_platform_epia_dvi=", 24)) {
2032 if (kstrtoint(this_opt + 24, 0, 2022 if (kstrtoint(this_opt + 24, 0,
2033 &viafb_platform_epia_dvi) < 0) 2023 &viafb_platform_epia_dvi) < 0)
2034 return -EINVAL; 2024 return -EINVAL;
2035 } else if (!strncmp(this_opt, 2025 } else if (!strncmp(this_opt,
2036 "viafb_device_lcd_dualedge=", 26)) { 2026 "viafb_device_lcd_dualedge=", 26)) {
2037 if (kstrtoint(this_opt + 26, 0, 2027 if (kstrtoint(this_opt + 26, 0,
2038 &viafb_device_lcd_dualedge) < 0) 2028 &viafb_device_lcd_dualedge) < 0)
2039 return -EINVAL; 2029 return -EINVAL;
2040 } else if (!strncmp(this_opt, "viafb_bus_width=", 16)) { 2030 } else if (!strncmp(this_opt, "viafb_bus_width=", 16)) {
2041 if (kstrtoint(this_opt + 16, 0, &viafb_bus_width) < 0) 2031 if (kstrtoint(this_opt + 16, 0, &viafb_bus_width) < 0)
2042 return -EINVAL; 2032 return -EINVAL;
2043 } else if (!strncmp(this_opt, "viafb_lcd_mode=", 15)) { 2033 } else if (!strncmp(this_opt, "viafb_lcd_mode=", 15)) {
2044 if (kstrtoint(this_opt + 15, 0, &viafb_lcd_mode) < 0) 2034 if (kstrtoint(this_opt + 15, 0, &viafb_lcd_mode) < 0)
2045 return -EINVAL; 2035 return -EINVAL;
2046 } else if (!strncmp(this_opt, "viafb_lcd_port=", 15)) { 2036 } else if (!strncmp(this_opt, "viafb_lcd_port=", 15)) {
2047 viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL); 2037 viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL);
2048 } else if (!strncmp(this_opt, "viafb_dvi_port=", 15)) { 2038 } else if (!strncmp(this_opt, "viafb_dvi_port=", 15)) {
2049 viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL); 2039 viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL);
2050 } 2040 }
2051 } 2041 }
2052 return 0; 2042 return 0;
2053 } 2043 }
2054 #endif 2044 #endif
2055 2045
2056 /* 2046 /*
2057 * These are called out of via-core for now. 2047 * These are called out of via-core for now.
2058 */ 2048 */
2059 int __init viafb_init(void) 2049 int __init viafb_init(void)
2060 { 2050 {
2061 u32 dummy_x, dummy_y; 2051 u32 dummy_x, dummy_y;
2062 int r = 0; 2052 int r = 0;
2063 2053
2064 if (machine_is_olpc()) 2054 if (machine_is_olpc())
2065 /* Apply XO-1.5-specific configuration. */ 2055 /* Apply XO-1.5-specific configuration. */
2066 viafb_lcd_panel_id = 23; 2056 viafb_lcd_panel_id = 23;
2067 2057
2068 #ifndef MODULE 2058 #ifndef MODULE
2069 r = viafb_setup(); 2059 r = viafb_setup();
2070 if (r < 0) 2060 if (r < 0)
2071 return r; 2061 return r;
2072 #endif 2062 #endif
2073 if (parse_mode(viafb_mode, 0, &dummy_x, &dummy_y) 2063 if (parse_mode(viafb_mode, 0, &dummy_x, &dummy_y)
2074 || !viafb_get_best_mode(dummy_x, dummy_y, viafb_refresh) 2064 || !viafb_get_best_mode(dummy_x, dummy_y, viafb_refresh)
2075 || parse_mode(viafb_mode1, 0, &dummy_x, &dummy_y) 2065 || parse_mode(viafb_mode1, 0, &dummy_x, &dummy_y)
2076 || !viafb_get_best_mode(dummy_x, dummy_y, viafb_refresh1) 2066 || !viafb_get_best_mode(dummy_x, dummy_y, viafb_refresh1)
2077 || viafb_bpp < 0 || viafb_bpp > 32 2067 || viafb_bpp < 0 || viafb_bpp > 32
2078 || viafb_bpp1 < 0 || viafb_bpp1 > 32 2068 || viafb_bpp1 < 0 || viafb_bpp1 > 32
2079 || parse_active_dev()) 2069 || parse_active_dev())
2080 return -EINVAL; 2070 return -EINVAL;
2081 2071
2082 printk(KERN_INFO 2072 printk(KERN_INFO
2083 "VIA Graphics Integration Chipset framebuffer %d.%d initializing\n", 2073 "VIA Graphics Integration Chipset framebuffer %d.%d initializing\n",
2084 VERSION_MAJOR, VERSION_MINOR); 2074 VERSION_MAJOR, VERSION_MINOR);
2085 return r; 2075 return r;
2086 } 2076 }
2087 2077
2088 void __exit viafb_exit(void) 2078 void __exit viafb_exit(void)
2089 { 2079 {
2090 DEBUG_MSG(KERN_INFO "viafb_exit!\n"); 2080 DEBUG_MSG(KERN_INFO "viafb_exit!\n");
2091 } 2081 }
2092 2082
2093 static struct fb_ops viafb_ops = { 2083 static struct fb_ops viafb_ops = {
2094 .owner = THIS_MODULE, 2084 .owner = THIS_MODULE,
2095 .fb_open = viafb_open, 2085 .fb_open = viafb_open,
2096 .fb_release = viafb_release, 2086 .fb_release = viafb_release,
2097 .fb_check_var = viafb_check_var, 2087 .fb_check_var = viafb_check_var,
2098 .fb_set_par = viafb_set_par, 2088 .fb_set_par = viafb_set_par,
2099 .fb_setcolreg = viafb_setcolreg, 2089 .fb_setcolreg = viafb_setcolreg,
2100 .fb_pan_display = viafb_pan_display, 2090 .fb_pan_display = viafb_pan_display,
2101 .fb_blank = viafb_blank, 2091 .fb_blank = viafb_blank,
2102 .fb_fillrect = viafb_fillrect, 2092 .fb_fillrect = viafb_fillrect,
2103 .fb_copyarea = viafb_copyarea, 2093 .fb_copyarea = viafb_copyarea,
2104 .fb_imageblit = viafb_imageblit, 2094 .fb_imageblit = viafb_imageblit,
2105 .fb_cursor = viafb_cursor, 2095 .fb_cursor = viafb_cursor,
2106 .fb_ioctl = viafb_ioctl, 2096 .fb_ioctl = viafb_ioctl,
2107 .fb_sync = viafb_sync, 2097 .fb_sync = viafb_sync,
2108 }; 2098 };
2109 2099
2110 2100
2111 #ifdef MODULE 2101 #ifdef MODULE
2112 module_param(viafb_mode, charp, S_IRUSR); 2102 module_param(viafb_mode, charp, S_IRUSR);
2113 MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)"); 2103 MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)");
2114 2104
2115 module_param(viafb_mode1, charp, S_IRUSR); 2105 module_param(viafb_mode1, charp, S_IRUSR);
2116 MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)"); 2106 MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)");
2117 2107
2118 module_param(viafb_bpp, int, S_IRUSR); 2108 module_param(viafb_bpp, int, S_IRUSR);
2119 MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)"); 2109 MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)");
2120 2110
2121 module_param(viafb_bpp1, int, S_IRUSR); 2111 module_param(viafb_bpp1, int, S_IRUSR);
2122 MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)"); 2112 MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)");
2123 2113
2124 module_param(viafb_refresh, int, S_IRUSR); 2114 module_param(viafb_refresh, int, S_IRUSR);
2125 MODULE_PARM_DESC(viafb_refresh, 2115 MODULE_PARM_DESC(viafb_refresh,
2126 "Set CRT viafb_refresh rate (default = 60)"); 2116 "Set CRT viafb_refresh rate (default = 60)");
2127 2117
2128 module_param(viafb_refresh1, int, S_IRUSR); 2118 module_param(viafb_refresh1, int, S_IRUSR);
2129 MODULE_PARM_DESC(viafb_refresh1, 2119 MODULE_PARM_DESC(viafb_refresh1,
2130 "Set CRT refresh rate (default = 60)"); 2120 "Set CRT refresh rate (default = 60)");
2131 2121
2132 module_param(viafb_lcd_panel_id, int, S_IRUSR); 2122 module_param(viafb_lcd_panel_id, int, S_IRUSR);
2133 MODULE_PARM_DESC(viafb_lcd_panel_id, 2123 MODULE_PARM_DESC(viafb_lcd_panel_id,
2134 "Set Flat Panel type(Default=1024x768)"); 2124 "Set Flat Panel type(Default=1024x768)");
2135 2125
2136 module_param(viafb_lcd_dsp_method, int, S_IRUSR); 2126 module_param(viafb_lcd_dsp_method, int, S_IRUSR);
2137 MODULE_PARM_DESC(viafb_lcd_dsp_method, 2127 MODULE_PARM_DESC(viafb_lcd_dsp_method,
2138 "Set Flat Panel display scaling method.(Default=Expandsion)"); 2128 "Set Flat Panel display scaling method.(Default=Expandsion)");
2139 2129
2140 module_param(viafb_SAMM_ON, int, S_IRUSR); 2130 module_param(viafb_SAMM_ON, int, S_IRUSR);
2141 MODULE_PARM_DESC(viafb_SAMM_ON, 2131 MODULE_PARM_DESC(viafb_SAMM_ON,
2142 "Turn on/off flag of SAMM(Default=OFF)"); 2132 "Turn on/off flag of SAMM(Default=OFF)");
2143 2133
2144 module_param(viafb_accel, int, S_IRUSR); 2134 module_param(viafb_accel, int, S_IRUSR);
2145 MODULE_PARM_DESC(viafb_accel, 2135 MODULE_PARM_DESC(viafb_accel,
2146 "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)"); 2136 "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
2147 2137
2148 module_param(viafb_active_dev, charp, S_IRUSR); 2138 module_param(viafb_active_dev, charp, S_IRUSR);
2149 MODULE_PARM_DESC(viafb_active_dev, "Specify active devices."); 2139 MODULE_PARM_DESC(viafb_active_dev, "Specify active devices.");
2150 2140
2151 module_param(viafb_display_hardware_layout, int, S_IRUSR); 2141 module_param(viafb_display_hardware_layout, int, S_IRUSR);
2152 MODULE_PARM_DESC(viafb_display_hardware_layout, 2142 MODULE_PARM_DESC(viafb_display_hardware_layout,
2153 "Display Hardware Layout (LCD Only, DVI Only...,etc)"); 2143 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2154 2144
2155 module_param(viafb_second_size, int, S_IRUSR); 2145 module_param(viafb_second_size, int, S_IRUSR);
2156 MODULE_PARM_DESC(viafb_second_size, 2146 MODULE_PARM_DESC(viafb_second_size,
2157 "Set secondary device memory size"); 2147 "Set secondary device memory size");
2158 2148
2159 module_param(viafb_dual_fb, int, S_IRUSR); 2149 module_param(viafb_dual_fb, int, S_IRUSR);
2160 MODULE_PARM_DESC(viafb_dual_fb, 2150 MODULE_PARM_DESC(viafb_dual_fb,
2161 "Turn on/off flag of dual framebuffer devices.(Default = OFF)"); 2151 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2162 2152
2163 module_param(viafb_platform_epia_dvi, int, S_IRUSR); 2153 module_param(viafb_platform_epia_dvi, int, S_IRUSR);
2164 MODULE_PARM_DESC(viafb_platform_epia_dvi, 2154 MODULE_PARM_DESC(viafb_platform_epia_dvi,
2165 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)"); 2155 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2166 2156
2167 module_param(viafb_device_lcd_dualedge, int, S_IRUSR); 2157 module_param(viafb_device_lcd_dualedge, int, S_IRUSR);
2168 MODULE_PARM_DESC(viafb_device_lcd_dualedge, 2158 MODULE_PARM_DESC(viafb_device_lcd_dualedge,
2169 "Turn on/off flag of dual edge panel.(Default = OFF)"); 2159 "Turn on/off flag of dual edge panel.(Default = OFF)");
2170 2160
2171 module_param(viafb_bus_width, int, S_IRUSR); 2161 module_param(viafb_bus_width, int, S_IRUSR);
2172 MODULE_PARM_DESC(viafb_bus_width, 2162 MODULE_PARM_DESC(viafb_bus_width,
2173 "Set bus width of panel.(Default = 12)"); 2163 "Set bus width of panel.(Default = 12)");
2174 2164
2175 module_param(viafb_lcd_mode, int, S_IRUSR); 2165 module_param(viafb_lcd_mode, int, S_IRUSR);
2176 MODULE_PARM_DESC(viafb_lcd_mode, 2166 MODULE_PARM_DESC(viafb_lcd_mode,
2177 "Set Flat Panel mode(Default=OPENLDI)"); 2167 "Set Flat Panel mode(Default=OPENLDI)");
2178 2168
2179 module_param(viafb_lcd_port, charp, S_IRUSR); 2169 module_param(viafb_lcd_port, charp, S_IRUSR);
2180 MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port."); 2170 MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port.");
2181 2171
2182 module_param(viafb_dvi_port, charp, S_IRUSR); 2172 module_param(viafb_dvi_port, charp, S_IRUSR);
2183 MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port."); 2173 MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port.");
2184 2174
2185 MODULE_LICENSE("GPL"); 2175 MODULE_LICENSE("GPL");
2186 #endif 2176 #endif
2187 2177