Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * valkyriefb.c -- frame buffer device for the PowerMac 'valkyrie' display | |
3 | * | |
4 | * Created 8 August 1998 by | |
5 | * Martin Costabel <costabel@wanadoo.fr> and Kevin Schoedel | |
6 | * | |
7 | * Vmode-switching changes and vmode 15/17 modifications created 29 August | |
8 | * 1998 by Barry K. Nathan <barryn@pobox.com>. | |
9 | * | |
10 | * Ported to m68k Macintosh by David Huggins-Daines <dhd@debian.org> | |
11 | * | |
12 | * Derived directly from: | |
13 | * | |
14 | * controlfb.c -- frame buffer device for the PowerMac 'control' display | |
15 | * Copyright (C) 1998 Dan Jacobowitz <dan@debian.org> | |
16 | * | |
17 | * pmc-valkyrie.c -- Console support for PowerMac "valkyrie" display adaptor. | |
18 | * Copyright (C) 1997 Paul Mackerras. | |
19 | * | |
20 | * and indirectly: | |
21 | * | |
22 | * Frame buffer structure from: | |
23 | * drivers/video/chipsfb.c -- frame buffer device for | |
24 | * Chips & Technologies 65550 chip. | |
25 | * | |
26 | * Copyright (C) 1998 Paul Mackerras | |
27 | * | |
28 | * This file is derived from the Powermac "chips" driver: | |
29 | * Copyright (C) 1997 Fabio Riccardi. | |
30 | * And from the frame buffer device for Open Firmware-initialized devices: | |
31 | * Copyright (C) 1997 Geert Uytterhoeven. | |
32 | * | |
33 | * Hardware information from: | |
34 | * control.c: Console support for PowerMac "control" display adaptor. | |
35 | * Copyright (C) 1996 Paul Mackerras | |
36 | * | |
37 | * This file is subject to the terms and conditions of the GNU General Public | |
38 | * License. See the file COPYING in the main directory of this archive for | |
39 | * more details. | |
40 | */ | |
41 | ||
1da177e4 LT |
42 | #include <linux/module.h> |
43 | #include <linux/kernel.h> | |
44 | #include <linux/errno.h> | |
45 | #include <linux/string.h> | |
46 | #include <linux/mm.h> | |
47 | #include <linux/tty.h> | |
48 | #include <linux/slab.h> | |
49 | #include <linux/vmalloc.h> | |
50 | #include <linux/delay.h> | |
51 | #include <linux/interrupt.h> | |
52 | #include <linux/fb.h> | |
53 | #include <linux/selection.h> | |
54 | #include <linux/init.h> | |
55 | #include <linux/pci.h> | |
56 | #include <linux/nvram.h> | |
57 | #include <linux/adb.h> | |
58 | #include <linux/cuda.h> | |
59 | #include <asm/io.h> | |
60 | #ifdef CONFIG_MAC | |
61 | #include <asm/bootinfo.h> | |
62 | #include <asm/macintosh.h> | |
63 | #else | |
64 | #include <asm/prom.h> | |
65 | #endif | |
66 | #include <asm/pgtable.h> | |
67 | ||
68 | #include "macmodes.h" | |
69 | #include "valkyriefb.h" | |
70 | ||
71 | #ifdef CONFIG_MAC | |
72 | /* We don't yet have functions to read the PRAM... perhaps we can | |
73 | adapt them from the PPC code? */ | |
74 | static int default_vmode = VMODE_640_480_67; | |
75 | static int default_cmode = CMODE_8; | |
76 | #else | |
77 | static int default_vmode = VMODE_NVRAM; | |
78 | static int default_cmode = CMODE_NVRAM; | |
79 | #endif | |
80 | ||
81 | struct fb_par_valkyrie { | |
82 | int vmode, cmode; | |
83 | int xres, yres; | |
84 | int vxres, vyres; | |
85 | struct valkyrie_regvals *init; | |
86 | }; | |
87 | ||
88 | struct fb_info_valkyrie { | |
89 | struct fb_info info; | |
90 | struct fb_par_valkyrie par; | |
91 | struct cmap_regs __iomem *cmap_regs; | |
92 | unsigned long cmap_regs_phys; | |
93 | ||
94 | struct valkyrie_regs __iomem *valkyrie_regs; | |
95 | unsigned long valkyrie_regs_phys; | |
96 | ||
97 | __u8 __iomem *frame_buffer; | |
98 | unsigned long frame_buffer_phys; | |
99 | ||
100 | int sense; | |
101 | unsigned long total_vram; | |
102 | ||
103 | u32 pseudo_palette[16]; | |
104 | }; | |
105 | ||
106 | /* | |
107 | * Exported functions | |
108 | */ | |
109 | int valkyriefb_init(void); | |
110 | int valkyriefb_setup(char*); | |
111 | ||
112 | static int valkyriefb_check_var(struct fb_var_screeninfo *var, | |
113 | struct fb_info *info); | |
114 | static int valkyriefb_set_par(struct fb_info *info); | |
115 | static int valkyriefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |
116 | u_int transp, struct fb_info *info); | |
117 | static int valkyriefb_blank(int blank_mode, struct fb_info *info); | |
118 | ||
119 | static int read_valkyrie_sense(struct fb_info_valkyrie *p); | |
120 | static void set_valkyrie_clock(unsigned char *params); | |
121 | static int valkyrie_var_to_par(struct fb_var_screeninfo *var, | |
122 | struct fb_par_valkyrie *par, const struct fb_info *fb_info); | |
123 | ||
124 | static void valkyrie_init_info(struct fb_info *info, struct fb_info_valkyrie *p); | |
125 | static void valkyrie_par_to_fix(struct fb_par_valkyrie *par, struct fb_fix_screeninfo *fix); | |
126 | static void valkyrie_init_fix(struct fb_fix_screeninfo *fix, struct fb_info_valkyrie *p); | |
127 | ||
128 | static struct fb_ops valkyriefb_ops = { | |
129 | .owner = THIS_MODULE, | |
130 | .fb_check_var = valkyriefb_check_var, | |
131 | .fb_set_par = valkyriefb_set_par, | |
132 | .fb_setcolreg = valkyriefb_setcolreg, | |
133 | .fb_blank = valkyriefb_blank, | |
134 | .fb_fillrect = cfb_fillrect, | |
135 | .fb_copyarea = cfb_copyarea, | |
136 | .fb_imageblit = cfb_imageblit, | |
1da177e4 LT |
137 | }; |
138 | ||
139 | /* Sets the video mode according to info->var */ | |
140 | static int valkyriefb_set_par(struct fb_info *info) | |
141 | { | |
142 | struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) info; | |
143 | volatile struct valkyrie_regs __iomem *valkyrie_regs = p->valkyrie_regs; | |
144 | struct fb_par_valkyrie *par = info->par; | |
145 | struct valkyrie_regvals *init; | |
146 | int err; | |
147 | ||
148 | if ((err = valkyrie_var_to_par(&info->var, par, info))) | |
149 | return err; | |
150 | ||
151 | valkyrie_par_to_fix(par, &info->fix); | |
152 | ||
153 | /* Reset the valkyrie */ | |
154 | out_8(&valkyrie_regs->status.r, 0); | |
155 | udelay(100); | |
156 | ||
157 | /* Initialize display timing registers */ | |
158 | init = par->init; | |
159 | out_8(&valkyrie_regs->mode.r, init->mode | 0x80); | |
160 | out_8(&valkyrie_regs->depth.r, par->cmode + 3); | |
161 | set_valkyrie_clock(init->clock_params); | |
162 | udelay(100); | |
163 | ||
164 | /* Turn on display */ | |
165 | out_8(&valkyrie_regs->mode.r, init->mode); | |
166 | ||
167 | return 0; | |
168 | } | |
169 | ||
170 | static inline int valkyrie_par_to_var(struct fb_par_valkyrie *par, | |
171 | struct fb_var_screeninfo *var) | |
172 | { | |
173 | return mac_vmode_to_var(par->vmode, par->cmode, var); | |
174 | } | |
175 | ||
176 | static int | |
177 | valkyriefb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |
178 | { | |
179 | int err; | |
180 | struct fb_par_valkyrie par; | |
181 | ||
182 | if ((err = valkyrie_var_to_par(var, &par, info))) | |
183 | return err; | |
184 | valkyrie_par_to_var(&par, var); | |
185 | return 0; | |
186 | } | |
187 | ||
188 | /* | |
189 | * Blank the screen if blank_mode != 0, else unblank. If blank_mode == NULL | |
190 | * then the caller blanks by setting the CLUT (Color Look Up Table) to all | |
191 | * black. Return 0 if blanking succeeded, != 0 if un-/blanking failed due | |
192 | * to e.g. a video mode which doesn't support it. Implements VESA suspend | |
193 | * and powerdown modes on hardware that supports disabling hsync/vsync: | |
194 | * blank_mode == 2: suspend vsync | |
195 | * blank_mode == 3: suspend hsync | |
196 | * blank_mode == 4: powerdown | |
197 | */ | |
198 | static int valkyriefb_blank(int blank_mode, struct fb_info *info) | |
199 | { | |
200 | struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) info; | |
201 | struct fb_par_valkyrie *par = info->par; | |
202 | struct valkyrie_regvals *init = par->init; | |
203 | ||
204 | if (init == NULL) | |
205 | return 1; | |
206 | ||
207 | switch (blank_mode) { | |
208 | case FB_BLANK_UNBLANK: /* unblank */ | |
209 | out_8(&p->valkyrie_regs->mode.r, init->mode); | |
210 | break; | |
211 | case FB_BLANK_NORMAL: | |
212 | return 1; /* get caller to set CLUT to all black */ | |
213 | case FB_BLANK_VSYNC_SUSPEND: | |
214 | case FB_BLANK_HSYNC_SUSPEND: | |
215 | /* | |
216 | * [kps] Value extracted from MacOS. I don't know | |
217 | * whether this bit disables hsync or vsync, or | |
218 | * whether the hardware can do the other as well. | |
219 | */ | |
220 | out_8(&p->valkyrie_regs->mode.r, init->mode | 0x40); | |
221 | break; | |
222 | case FB_BLANK_POWERDOWN: | |
223 | out_8(&p->valkyrie_regs->mode.r, 0x66); | |
224 | break; | |
225 | } | |
226 | return 0; | |
227 | } | |
228 | ||
229 | static int valkyriefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | |
230 | u_int transp, struct fb_info *info) | |
231 | { | |
232 | struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) info; | |
233 | volatile struct cmap_regs __iomem *cmap_regs = p->cmap_regs; | |
234 | struct fb_par_valkyrie *par = info->par; | |
235 | ||
236 | if (regno > 255) | |
237 | return 1; | |
238 | red >>= 8; | |
239 | green >>= 8; | |
240 | blue >>= 8; | |
241 | ||
242 | /* tell clut which address to fill */ | |
243 | out_8(&p->cmap_regs->addr, regno); | |
244 | udelay(1); | |
245 | /* send one color channel at a time */ | |
246 | out_8(&cmap_regs->lut, red); | |
247 | out_8(&cmap_regs->lut, green); | |
248 | out_8(&cmap_regs->lut, blue); | |
249 | ||
250 | if (regno < 16 && par->cmode == CMODE_16) | |
251 | ((u32 *)info->pseudo_palette)[regno] = | |
252 | (regno << 10) | (regno << 5) | regno; | |
253 | ||
254 | return 0; | |
255 | } | |
256 | ||
257 | static inline int valkyrie_vram_reqd(int video_mode, int color_mode) | |
258 | { | |
259 | int pitch; | |
260 | struct valkyrie_regvals *init = valkyrie_reg_init[video_mode-1]; | |
261 | ||
262 | if ((pitch = init->pitch[color_mode]) == 0) | |
263 | pitch = 2 * init->pitch[0]; | |
264 | return init->vres * pitch; | |
265 | } | |
266 | ||
267 | static void set_valkyrie_clock(unsigned char *params) | |
268 | { | |
269 | struct adb_request req; | |
270 | int i; | |
271 | ||
272 | #ifdef CONFIG_ADB_CUDA | |
273 | for (i = 0; i < 3; ++i) { | |
274 | cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, | |
275 | 0x50, i + 1, params[i]); | |
276 | while (!req.complete) | |
277 | cuda_poll(); | |
278 | } | |
279 | #endif | |
280 | } | |
281 | ||
282 | static void __init valkyrie_choose_mode(struct fb_info_valkyrie *p) | |
283 | { | |
284 | p->sense = read_valkyrie_sense(p); | |
285 | printk(KERN_INFO "Monitor sense value = 0x%x\n", p->sense); | |
286 | ||
287 | /* Try to pick a video mode out of NVRAM if we have one. */ | |
288 | #ifndef CONFIG_MAC | |
289 | if (default_vmode == VMODE_NVRAM) { | |
290 | default_vmode = nvram_read_byte(NV_VMODE); | |
291 | if (default_vmode <= 0 | |
292 | || default_vmode > VMODE_MAX | |
293 | || !valkyrie_reg_init[default_vmode - 1]) | |
294 | default_vmode = VMODE_CHOOSE; | |
295 | } | |
296 | #endif | |
297 | if (default_vmode == VMODE_CHOOSE) | |
298 | default_vmode = mac_map_monitor_sense(p->sense); | |
299 | if (!valkyrie_reg_init[default_vmode - 1]) | |
300 | default_vmode = VMODE_640_480_67; | |
301 | #ifndef CONFIG_MAC | |
302 | if (default_cmode == CMODE_NVRAM) | |
303 | default_cmode = nvram_read_byte(NV_CMODE); | |
304 | #endif | |
305 | ||
306 | /* | |
307 | * Reduce the pixel size if we don't have enough VRAM or bandwidth. | |
308 | */ | |
309 | if (default_cmode < CMODE_8 || default_cmode > CMODE_16 | |
310 | || valkyrie_reg_init[default_vmode-1]->pitch[default_cmode] == 0 | |
311 | || valkyrie_vram_reqd(default_vmode, default_cmode) > p->total_vram) | |
312 | default_cmode = CMODE_8; | |
313 | ||
314 | printk(KERN_INFO "using video mode %d and color mode %d.\n", | |
315 | default_vmode, default_cmode); | |
316 | } | |
317 | ||
318 | int __init valkyriefb_init(void) | |
319 | { | |
320 | struct fb_info_valkyrie *p; | |
321 | unsigned long frame_buffer_phys, cmap_regs_phys, flags; | |
322 | int err; | |
323 | char *option = NULL; | |
324 | ||
325 | if (fb_get_options("valkyriefb", &option)) | |
326 | return -ENODEV; | |
327 | valkyriefb_setup(option); | |
328 | ||
329 | #ifdef CONFIG_MAC | |
330 | if (!MACH_IS_MAC) | |
331 | return 0; | |
332 | if (!(mac_bi_data.id == MAC_MODEL_Q630 | |
333 | /* I'm not sure about this one */ | |
334 | || mac_bi_data.id == MAC_MODEL_P588)) | |
335 | return 0; | |
336 | ||
337 | /* Hardcoded addresses... welcome to 68k Macintosh country :-) */ | |
338 | frame_buffer_phys = 0xf9000000; | |
339 | cmap_regs_phys = 0x50f24000; | |
340 | flags = IOMAP_NOCACHE_SER; /* IOMAP_WRITETHROUGH?? */ | |
341 | #else /* ppc (!CONFIG_MAC) */ | |
342 | { | |
343 | struct device_node *dp; | |
cc5d0189 | 344 | struct resource r; |
1da177e4 | 345 | |
cc5d0189 | 346 | dp = of_find_node_by_name(NULL, "valkyrie"); |
1da177e4 LT |
347 | if (dp == 0) |
348 | return 0; | |
349 | ||
cc5d0189 BH |
350 | if (of_address_to_resource(dp, 0, &r)) { |
351 | printk(KERN_ERR "can't find address for valkyrie\n"); | |
1da177e4 LT |
352 | return 0; |
353 | } | |
354 | ||
cc5d0189 BH |
355 | frame_buffer_phys = r.start; |
356 | cmap_regs_phys = r.start + 0x304000; | |
1da177e4 LT |
357 | flags = _PAGE_WRITETHRU; |
358 | } | |
359 | #endif /* ppc (!CONFIG_MAC) */ | |
360 | ||
361 | p = kmalloc(sizeof(*p), GFP_ATOMIC); | |
362 | if (p == 0) | |
363 | return -ENOMEM; | |
364 | memset(p, 0, sizeof(*p)); | |
365 | ||
366 | /* Map in frame buffer and registers */ | |
367 | if (!request_mem_region(frame_buffer_phys, 0x100000, "valkyriefb")) { | |
368 | kfree(p); | |
369 | return 0; | |
370 | } | |
371 | p->total_vram = 0x100000; | |
372 | p->frame_buffer_phys = frame_buffer_phys; | |
373 | p->frame_buffer = __ioremap(frame_buffer_phys, p->total_vram, flags); | |
374 | p->cmap_regs_phys = cmap_regs_phys; | |
375 | p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000); | |
376 | p->valkyrie_regs_phys = cmap_regs_phys+0x6000; | |
377 | p->valkyrie_regs = ioremap(p->valkyrie_regs_phys, 0x1000); | |
378 | err = -ENOMEM; | |
379 | if (p->frame_buffer == NULL || p->cmap_regs == NULL | |
380 | || p->valkyrie_regs == NULL) { | |
381 | printk(KERN_ERR "valkyriefb: couldn't map resources\n"); | |
382 | goto out_free; | |
383 | } | |
384 | ||
385 | valkyrie_choose_mode(p); | |
386 | mac_vmode_to_var(default_vmode, default_cmode, &p->info.var); | |
387 | valkyrie_init_info(&p->info, p); | |
388 | valkyrie_init_fix(&p->info.fix, p); | |
389 | if (valkyriefb_set_par(&p->info)) | |
390 | /* "can't happen" */ | |
391 | printk(KERN_ERR "valkyriefb: can't set default video mode\n"); | |
392 | ||
393 | if ((err = register_framebuffer(&p->info)) != 0) | |
394 | goto out_free; | |
395 | ||
396 | printk(KERN_INFO "fb%d: valkyrie frame buffer device\n", p->info.node); | |
397 | return 0; | |
398 | ||
399 | out_free: | |
400 | if (p->frame_buffer) | |
401 | iounmap(p->frame_buffer); | |
402 | if (p->cmap_regs) | |
403 | iounmap(p->cmap_regs); | |
404 | if (p->valkyrie_regs) | |
405 | iounmap(p->valkyrie_regs); | |
406 | kfree(p); | |
407 | return err; | |
408 | } | |
409 | ||
410 | /* | |
411 | * Get the monitor sense value. | |
412 | */ | |
413 | static int read_valkyrie_sense(struct fb_info_valkyrie *p) | |
414 | { | |
415 | int sense, in; | |
416 | ||
417 | out_8(&p->valkyrie_regs->msense.r, 0); /* release all lines */ | |
418 | __delay(20000); | |
419 | sense = ((in = in_8(&p->valkyrie_regs->msense.r)) & 0x70) << 4; | |
420 | /* drive each sense line low in turn and collect the other 2 */ | |
421 | out_8(&p->valkyrie_regs->msense.r, 4); /* drive A low */ | |
422 | __delay(20000); | |
423 | sense |= ((in = in_8(&p->valkyrie_regs->msense.r)) & 0x30); | |
424 | out_8(&p->valkyrie_regs->msense.r, 2); /* drive B low */ | |
425 | __delay(20000); | |
426 | sense |= ((in = in_8(&p->valkyrie_regs->msense.r)) & 0x40) >> 3; | |
427 | sense |= (in & 0x10) >> 2; | |
428 | out_8(&p->valkyrie_regs->msense.r, 1); /* drive C low */ | |
429 | __delay(20000); | |
430 | sense |= ((in = in_8(&p->valkyrie_regs->msense.r)) & 0x60) >> 5; | |
431 | ||
432 | out_8(&p->valkyrie_regs->msense.r, 7); | |
433 | ||
434 | return sense; | |
435 | } | |
436 | ||
437 | /* | |
438 | * This routine takes a user-supplied var, | |
439 | * and picks the best vmode/cmode from it. | |
440 | */ | |
441 | ||
442 | /* [bkn] I did a major overhaul of this function. | |
443 | * | |
444 | * Much of the old code was "swiped by jonh from atyfb.c". Because | |
445 | * macmodes has mac_var_to_vmode, I felt that it would be better to | |
446 | * rework this function to use that, instead of reinventing the wheel to | |
447 | * add support for vmode 17. This was reinforced by the fact that | |
448 | * the previously swiped atyfb.c code is no longer there. | |
449 | * | |
450 | * So, I swiped and adapted platinum_var_to_par (from platinumfb.c), replacing | |
451 | * most, but not all, of the old code in the process. One side benefit of | |
452 | * swiping the platinumfb code is that we now have more comprehensible error | |
453 | * messages when a vmode/cmode switch fails. (Most of the error messages are | |
454 | * platinumfb.c, but I added two of my own, and I also changed some commas | |
455 | * into colons to make the messages more consistent with other Linux error | |
456 | * messages.) In addition, I think the new code *might* fix some vmode- | |
457 | * switching oddities, but I'm not sure. | |
458 | * | |
459 | * There may be some more opportunities for cleanup in here, but this is a | |
460 | * good start... | |
461 | */ | |
462 | ||
463 | static int valkyrie_var_to_par(struct fb_var_screeninfo *var, | |
464 | struct fb_par_valkyrie *par, const struct fb_info *fb_info) | |
465 | { | |
466 | int vmode, cmode; | |
467 | struct valkyrie_regvals *init; | |
468 | struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) fb_info; | |
469 | ||
470 | if (mac_var_to_vmode(var, &vmode, &cmode) != 0) { | |
471 | printk(KERN_ERR "valkyriefb: can't do %dx%dx%d.\n", | |
472 | var->xres, var->yres, var->bits_per_pixel); | |
473 | return -EINVAL; | |
474 | } | |
475 | ||
476 | /* Check if we know about the wanted video mode */ | |
477 | if (vmode < 1 || vmode > VMODE_MAX || !valkyrie_reg_init[vmode-1]) { | |
478 | printk(KERN_ERR "valkyriefb: vmode %d not valid.\n", vmode); | |
479 | return -EINVAL; | |
480 | } | |
481 | ||
482 | if (cmode != CMODE_8 && cmode != CMODE_16) { | |
483 | printk(KERN_ERR "valkyriefb: cmode %d not valid.\n", cmode); | |
484 | return -EINVAL; | |
485 | } | |
486 | ||
487 | if (var->xres_virtual > var->xres || var->yres_virtual > var->yres | |
488 | || var->xoffset != 0 || var->yoffset != 0) { | |
489 | return -EINVAL; | |
490 | } | |
491 | ||
492 | init = valkyrie_reg_init[vmode-1]; | |
493 | if (init->pitch[cmode] == 0) { | |
494 | printk(KERN_ERR "valkyriefb: vmode %d does not support " | |
495 | "cmode %d.\n", vmode, cmode); | |
496 | return -EINVAL; | |
497 | } | |
498 | ||
499 | if (valkyrie_vram_reqd(vmode, cmode) > p->total_vram) { | |
500 | printk(KERN_ERR "valkyriefb: not enough ram for vmode %d, " | |
501 | "cmode %d.\n", vmode, cmode); | |
502 | return -EINVAL; | |
503 | } | |
504 | ||
505 | par->vmode = vmode; | |
506 | par->cmode = cmode; | |
507 | par->init = init; | |
508 | par->xres = var->xres; | |
509 | par->yres = var->yres; | |
510 | par->vxres = par->xres; | |
511 | par->vyres = par->yres; | |
512 | ||
513 | return 0; | |
514 | } | |
515 | ||
516 | static void valkyrie_init_fix(struct fb_fix_screeninfo *fix, struct fb_info_valkyrie *p) | |
517 | { | |
518 | memset(fix, 0, sizeof(*fix)); | |
519 | strcpy(fix->id, "valkyrie"); | |
520 | fix->mmio_start = p->valkyrie_regs_phys; | |
521 | fix->mmio_len = sizeof(struct valkyrie_regs); | |
522 | fix->type = FB_TYPE_PACKED_PIXELS; | |
523 | fix->smem_start = p->frame_buffer_phys + 0x1000; | |
524 | fix->smem_len = p->total_vram; | |
525 | ||
526 | fix->type_aux = 0; | |
527 | fix->ywrapstep = 0; | |
528 | fix->ypanstep = 0; | |
529 | fix->xpanstep = 0; | |
530 | ||
531 | } | |
532 | ||
533 | /* Fix must already be inited above */ | |
534 | static void valkyrie_par_to_fix(struct fb_par_valkyrie *par, | |
535 | struct fb_fix_screeninfo *fix) | |
536 | { | |
537 | fix->smem_len = valkyrie_vram_reqd(par->vmode, par->cmode); | |
538 | fix->visual = (par->cmode == CMODE_8) ? | |
539 | FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; | |
540 | fix->line_length = par->vxres << par->cmode; | |
541 | /* ywrapstep, xpanstep, ypanstep */ | |
542 | } | |
543 | ||
544 | static void __init valkyrie_init_info(struct fb_info *info, struct fb_info_valkyrie *p) | |
545 | { | |
546 | info->fbops = &valkyriefb_ops; | |
547 | info->screen_base = p->frame_buffer + 0x1000; | |
548 | info->flags = FBINFO_DEFAULT; | |
549 | info->pseudo_palette = p->pseudo_palette; | |
550 | fb_alloc_cmap(&info->cmap, 256, 0); | |
551 | info->par = &p->par; | |
552 | } | |
553 | ||
554 | ||
555 | /* | |
556 | * Parse user speficied options (`video=valkyriefb:') | |
557 | */ | |
558 | int __init valkyriefb_setup(char *options) | |
559 | { | |
560 | char *this_opt; | |
561 | ||
562 | if (!options || !*options) | |
563 | return 0; | |
564 | ||
565 | while ((this_opt = strsep(&options, ",")) != NULL) { | |
566 | if (!strncmp(this_opt, "vmode:", 6)) { | |
567 | int vmode = simple_strtoul(this_opt+6, NULL, 0); | |
568 | if (vmode > 0 && vmode <= VMODE_MAX) | |
569 | default_vmode = vmode; | |
570 | } | |
571 | else if (!strncmp(this_opt, "cmode:", 6)) { | |
572 | int depth = simple_strtoul(this_opt+6, NULL, 0); | |
573 | switch (depth) { | |
574 | case 8: | |
575 | default_cmode = CMODE_8; | |
576 | break; | |
577 | case 15: | |
578 | case 16: | |
579 | default_cmode = CMODE_16; | |
580 | break; | |
581 | } | |
582 | } | |
583 | } | |
584 | return 0; | |
585 | } | |
586 | ||
587 | module_init(valkyriefb_init); | |
588 | MODULE_LICENSE("GPL"); |