s/retreiv/retriev/g
[linux-2.6/kvm.git] / drivers / video / au1100fb.c
bloba5129806172fb0684980eb685cf9a84f20fe58e7
1 /*
2 * BRIEF MODULE DESCRIPTION
3 * Au1100 LCD Driver.
5 * Rewritten for 2.6 by Embedded Alley Solutions
6 * <source@embeddedalley.com>, based on submissions by
7 * Karl Lessard <klessard@sunrisetelecom.com>
8 * <c.pellegrin@exadron.com>
10 * Copyright 2002 MontaVista Software
11 * Author: MontaVista Software, Inc.
12 * ppopov@mvista.com or source@mvista.com
14 * Copyright 2002 Alchemy Semiconductor
15 * Author: Alchemy Semiconductor
17 * Based on:
18 * linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device
19 * Created 28 Dec 1997 by Geert Uytterhoeven
21 * This program is free software; you can redistribute it and/or modify it
22 * under the terms of the GNU General Public License as published by the
23 * Free Software Foundation; either version 2 of the License, or (at your
24 * option) any later version.
26 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
29 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
32 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * You should have received a copy of the GNU General Public License along
38 * with this program; if not, write to the Free Software Foundation, Inc.,
39 * 675 Mass Ave, Cambridge, MA 02139, USA.
41 #include <linux/config.h>
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/fb.h>
48 #include <linux/init.h>
49 #include <linux/interrupt.h>
50 #include <linux/ctype.h>
51 #include <linux/dma-mapping.h>
53 #include <asm/mach-au1x00/au1000.h>
55 #define DEBUG 0
57 #include "au1100fb.h"
60 * Sanity check. If this is a new Au1100 based board, search for
61 * the PB1100 ifdefs to make sure you modify the code accordingly.
63 #if defined(CONFIG_MIPS_PB1100)
64 #include <asm/mach-pb1x00/pb1100.h>
65 #elif defined(CONFIG_MIPS_DB1100)
66 #include <asm/mach-db1x00/db1x00.h>
67 #else
68 #error "Unknown Au1100 board, Au1100 FB driver not supported"
69 #endif
71 #define DRIVER_NAME "au1100fb"
72 #define DRIVER_DESC "LCD controller driver for AU1100 processors"
74 #define to_au1100fb_device(_info) \
75 (_info ? container_of(_info, struct au1100fb_device, info) : NULL);
77 /* Bitfields format supported by the controller. Note that the order of formats
78 * SHOULD be the same as in the LCD_CONTROL_SBPPF field, so we can retrieve the
79 * right pixel format by doing rgb_bitfields[LCD_CONTROL_SBPPF_XXX >> LCD_CONTROL_SBPPF]
81 struct fb_bitfield rgb_bitfields[][4] =
83 /* Red, Green, Blue, Transp */
84 { { 10, 6, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 0, 0, 0 } },
85 { { 11, 5, 0 }, { 5, 6, 0 }, { 0, 5, 0 }, { 0, 0, 0 } },
86 { { 11, 5, 0 }, { 6, 5, 0 }, { 0, 6, 0 }, { 0, 0, 0 } },
87 { { 10, 5, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 15, 1, 0 } },
88 { { 11, 5, 0 }, { 6, 5, 0 }, { 1, 5, 0 }, { 0, 1, 0 } },
90 /* The last is used to describe 12bpp format */
91 { { 8, 4, 0 }, { 4, 4, 0 }, { 0, 4, 0 }, { 0, 0, 0 } },
94 static struct fb_fix_screeninfo au1100fb_fix __initdata = {
95 .id = "AU1100 FB",
96 .xpanstep = 1,
97 .ypanstep = 1,
98 .type = FB_TYPE_PACKED_PIXELS,
99 .accel = FB_ACCEL_NONE,
102 static struct fb_var_screeninfo au1100fb_var __initdata = {
103 .activate = FB_ACTIVATE_NOW,
104 .height = -1,
105 .width = -1,
106 .vmode = FB_VMODE_NONINTERLACED,
109 static struct au1100fb_drv_info drv_info;
112 * Set hardware with var settings. This will enable the controller with a specific
113 * mode, normally validated with the fb_check_var method
115 int au1100fb_setmode(struct au1100fb_device *fbdev)
117 struct fb_info *info = &fbdev->info;
118 u32 words;
119 int index;
121 if (!fbdev)
122 return -EINVAL;
124 /* Update var-dependent FB info */
125 if (panel_is_active(fbdev->panel) || panel_is_color(fbdev->panel)) {
126 if (info->var.bits_per_pixel <= 8) {
127 /* palettized */
128 info->var.red.offset = 0;
129 info->var.red.length = info->var.bits_per_pixel;
130 info->var.red.msb_right = 0;
132 info->var.green.offset = 0;
133 info->var.green.length = info->var.bits_per_pixel;
134 info->var.green.msb_right = 0;
136 info->var.blue.offset = 0;
137 info->var.blue.length = info->var.bits_per_pixel;
138 info->var.blue.msb_right = 0;
140 info->var.transp.offset = 0;
141 info->var.transp.length = 0;
142 info->var.transp.msb_right = 0;
144 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
145 info->fix.line_length = info->var.xres_virtual /
146 (8/info->var.bits_per_pixel);
147 } else {
148 /* non-palettized */
149 index = (fbdev->panel->control_base & LCD_CONTROL_SBPPF_MASK) >> LCD_CONTROL_SBPPF_BIT;
150 info->var.red = rgb_bitfields[index][0];
151 info->var.green = rgb_bitfields[index][1];
152 info->var.blue = rgb_bitfields[index][2];
153 info->var.transp = rgb_bitfields[index][3];
155 info->fix.visual = FB_VISUAL_TRUECOLOR;
156 info->fix.line_length = info->var.xres_virtual << 1; /* depth=16 */
158 } else {
159 /* mono */
160 info->fix.visual = FB_VISUAL_MONO10;
161 info->fix.line_length = info->var.xres_virtual / 8;
164 info->screen_size = info->fix.line_length * info->var.yres_virtual;
166 /* Determine BPP mode and format */
167 fbdev->regs->lcd_control = fbdev->panel->control_base |
168 ((info->var.rotate/90) << LCD_CONTROL_SM_BIT);
170 fbdev->regs->lcd_intenable = 0;
171 fbdev->regs->lcd_intstatus = 0;
173 fbdev->regs->lcd_horztiming = fbdev->panel->horztiming;
175 fbdev->regs->lcd_verttiming = fbdev->panel->verttiming;
177 fbdev->regs->lcd_clkcontrol = fbdev->panel->clkcontrol_base;
179 fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(fbdev->fb_phys);
181 if (panel_is_dual(fbdev->panel)) {
182 /* Second panel display seconf half of screen if possible,
183 * otherwise display the same as the first panel */
184 if (info->var.yres_virtual >= (info->var.yres << 1)) {
185 fbdev->regs->lcd_dmaaddr1 = LCD_DMA_SA_N(fbdev->fb_phys +
186 (info->fix.line_length *
187 (info->var.yres_virtual >> 1)));
188 } else {
189 fbdev->regs->lcd_dmaaddr1 = LCD_DMA_SA_N(fbdev->fb_phys);
193 words = info->fix.line_length / sizeof(u32);
194 if (!info->var.rotate || (info->var.rotate == 180)) {
195 words *= info->var.yres_virtual;
196 if (info->var.rotate /* 180 */) {
197 words -= (words % 8); /* should be divisable by 8 */
200 fbdev->regs->lcd_words = LCD_WRD_WRDS_N(words);
202 fbdev->regs->lcd_pwmdiv = 0;
203 fbdev->regs->lcd_pwmhi = 0;
205 /* Resume controller */
206 fbdev->regs->lcd_control |= LCD_CONTROL_GO;
208 return 0;
211 /* fb_setcolreg
212 * Set color in LCD palette.
214 int au1100fb_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *fbi)
216 struct au1100fb_device *fbdev = to_au1100fb_device(fbi);
217 u32 *palette = fbdev->regs->lcd_pallettebase;
218 u32 value;
220 if (regno > (AU1100_LCD_NBR_PALETTE_ENTRIES - 1))
221 return -EINVAL;
223 if (fbi->var.grayscale) {
224 /* Convert color to grayscale */
225 red = green = blue =
226 (19595 * red + 38470 * green + 7471 * blue) >> 16;
229 if (fbi->fix.visual == FB_VISUAL_TRUECOLOR) {
230 /* Place color in the pseudopalette */
231 if (regno > 16)
232 return -EINVAL;
234 palette = (u32*)fbi->pseudo_palette;
236 red >>= (16 - fbi->var.red.length);
237 green >>= (16 - fbi->var.green.length);
238 blue >>= (16 - fbi->var.blue.length);
240 value = (red << fbi->var.red.offset) |
241 (green << fbi->var.green.offset)|
242 (blue << fbi->var.blue.offset);
243 value &= 0xFFFF;
245 } else if (panel_is_active(fbdev->panel)) {
246 /* COLOR TFT PALLETTIZED (use RGB 565) */
247 value = (red & 0xF800)|((green >> 5) & 0x07E0)|((blue >> 11) & 0x001F);
248 value &= 0xFFFF;
250 } else if (panel_is_color(fbdev->panel)) {
251 /* COLOR STN MODE */
252 value = (((panel_swap_rgb(fbdev->panel) ? blue : red) >> 12) & 0x000F) |
253 ((green >> 8) & 0x00F0) |
254 (((panel_swap_rgb(fbdev->panel) ? red : blue) >> 4) & 0x0F00);
255 value &= 0xFFF;
256 } else {
257 /* MONOCHROME MODE */
258 value = (green >> 12) & 0x000F;
259 value &= 0xF;
262 palette[regno] = value;
264 return 0;
267 /* fb_blank
268 * Blank the screen. Depending on the mode, the screen will be
269 * activated with the backlight color, or desactivated
271 int au1100fb_fb_blank(int blank_mode, struct fb_info *fbi)
273 struct au1100fb_device *fbdev = to_au1100fb_device(fbi);
275 print_dbg("fb_blank %d %p", blank_mode, fbi);
277 switch (blank_mode) {
279 case VESA_NO_BLANKING:
280 /* Turn on panel */
281 fbdev->regs->lcd_control |= LCD_CONTROL_GO;
282 #ifdef CONFIG_MIPS_PB1100
283 if (drv_info.panel_idx == 1) {
284 au_writew(au_readw(PB1100_G_CONTROL)
285 | (PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD),
286 PB1100_G_CONTROL);
288 #endif
289 au_sync();
290 break;
292 case VESA_VSYNC_SUSPEND:
293 case VESA_HSYNC_SUSPEND:
294 case VESA_POWERDOWN:
295 /* Turn off panel */
296 fbdev->regs->lcd_control &= ~LCD_CONTROL_GO;
297 #ifdef CONFIG_MIPS_PB1100
298 if (drv_info.panel_idx == 1) {
299 au_writew(au_readw(PB1100_G_CONTROL)
300 & ~(PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD),
301 PB1100_G_CONTROL);
303 #endif
304 au_sync();
305 break;
306 default:
307 break;
310 return 0;
313 /* fb_pan_display
314 * Pan display in x and/or y as specified
316 int au1100fb_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fbi)
318 struct au1100fb_device *fbdev = to_au1100fb_device(fbi);
319 int dy;
321 print_dbg("fb_pan_display %p %p", var, fbi);
323 if (!var || !fbdev) {
324 return -EINVAL;
327 if (var->xoffset - fbi->var.xoffset) {
328 /* No support for X panning for now! */
329 return -EINVAL;
332 print_dbg("fb_pan_display 2 %p %p", var, fbi);
333 dy = var->yoffset - fbi->var.yoffset;
334 if (dy) {
336 u32 dmaaddr;
338 print_dbg("Panning screen of %d lines", dy);
340 dmaaddr = fbdev->regs->lcd_dmaaddr0;
341 dmaaddr += (fbi->fix.line_length * dy);
343 /* TODO: Wait for current frame to finished */
344 fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(dmaaddr);
346 if (panel_is_dual(fbdev->panel)) {
347 dmaaddr = fbdev->regs->lcd_dmaaddr1;
348 dmaaddr += (fbi->fix.line_length * dy);
349 fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(dmaaddr);
352 print_dbg("fb_pan_display 3 %p %p", var, fbi);
354 return 0;
357 /* fb_rotate
358 * Rotate the display of this angle. This doesn't seems to be used by the core,
359 * but as our hardware supports it, so why not implementing it...
361 void au1100fb_fb_rotate(struct fb_info *fbi, int angle)
363 struct au1100fb_device *fbdev = to_au1100fb_device(fbi);
365 print_dbg("fb_rotate %p %d", fbi, angle);
367 if (fbdev && (angle > 0) && !(angle % 90)) {
369 fbdev->regs->lcd_control &= ~LCD_CONTROL_GO;
371 fbdev->regs->lcd_control &= ~(LCD_CONTROL_SM_MASK);
372 fbdev->regs->lcd_control |= ((angle/90) << LCD_CONTROL_SM_BIT);
374 fbdev->regs->lcd_control |= LCD_CONTROL_GO;
378 /* fb_mmap
379 * Map video memory in user space. We don't use the generic fb_mmap method mainly
380 * to allow the use of the TLB streaming flag (CCA=6)
382 int au1100fb_fb_mmap(struct fb_info *fbi, struct file *file, struct vm_area_struct *vma)
384 struct au1100fb_device *fbdev = to_au1100fb_device(fbi);
385 unsigned int len;
386 unsigned long start=0, off;
388 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
389 return -EINVAL;
392 start = fbdev->fb_phys & PAGE_MASK;
393 len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);
395 off = vma->vm_pgoff << PAGE_SHIFT;
397 if ((vma->vm_end - vma->vm_start + off) > len) {
398 return -EINVAL;
401 off += start;
402 vma->vm_pgoff = off >> PAGE_SHIFT;
404 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
405 pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6
407 vma->vm_flags |= VM_IO;
409 if (io_remap_page_range(vma, vma->vm_start, off,
410 vma->vm_end - vma->vm_start,
411 vma->vm_page_prot)) {
412 return -EAGAIN;
415 return 0;
418 static struct fb_ops au1100fb_ops =
420 .owner = THIS_MODULE,
421 .fb_setcolreg = au1100fb_fb_setcolreg,
422 .fb_blank = au1100fb_fb_blank,
423 .fb_pan_display = au1100fb_fb_pan_display,
424 .fb_fillrect = cfb_fillrect,
425 .fb_copyarea = cfb_copyarea,
426 .fb_imageblit = cfb_imageblit,
427 .fb_rotate = au1100fb_fb_rotate,
428 .fb_mmap = au1100fb_fb_mmap,
432 /*-------------------------------------------------------------------------*/
434 /* AU1100 LCD controller device driver */
436 int au1100fb_drv_probe(struct device *dev)
438 struct au1100fb_device *fbdev = NULL;
439 struct resource *regs_res;
440 unsigned long page;
441 u32 sys_clksrc;
443 if (!dev)
444 return -EINVAL;
446 /* Allocate new device private */
447 if (!(fbdev = kmalloc(sizeof(struct au1100fb_device), GFP_KERNEL))) {
448 print_err("fail to allocate device private record");
449 return -ENOMEM;
451 memset((void*)fbdev, 0, sizeof(struct au1100fb_device));
453 fbdev->panel = &known_lcd_panels[drv_info.panel_idx];
455 dev_set_drvdata(dev, (void*)fbdev);
457 /* Allocate region for our registers and map them */
458 if (!(regs_res = platform_get_resource(to_platform_device(dev),
459 IORESOURCE_MEM, 0))) {
460 print_err("fail to retrieve registers resource");
461 return -EFAULT;
464 au1100fb_fix.mmio_start = regs_res->start;
465 au1100fb_fix.mmio_len = regs_res->end - regs_res->start + 1;
467 if (!request_mem_region(au1100fb_fix.mmio_start, au1100fb_fix.mmio_len,
468 DRIVER_NAME)) {
469 print_err("fail to lock memory region at 0x%08x",
470 au1100fb_fix.mmio_start);
471 return -EBUSY;
474 fbdev->regs = (struct au1100fb_regs*)KSEG1ADDR(au1100fb_fix.mmio_start);
476 print_dbg("Register memory map at %p", fbdev->regs);
477 print_dbg("phys=0x%08x, size=%d", fbdev->regs_phys, fbdev->regs_len);
481 /* Allocate the framebuffer to the maximum screen size * nbr of video buffers */
482 fbdev->fb_len = fbdev->panel->xres * fbdev->panel->yres *
483 (fbdev->panel->bpp >> 3) * AU1100FB_NBR_VIDEO_BUFFERS;
485 fbdev->fb_mem = dma_alloc_coherent(dev, PAGE_ALIGN(fbdev->fb_len),
486 &fbdev->fb_phys, GFP_KERNEL);
487 if (!fbdev->fb_mem) {
488 print_err("fail to allocate frambuffer (size: %dK))",
489 fbdev->fb_len / 1024);
490 return -ENOMEM;
493 au1100fb_fix.smem_start = fbdev->fb_phys;
494 au1100fb_fix.smem_len = fbdev->fb_len;
497 * Set page reserved so that mmap will work. This is necessary
498 * since we'll be remapping normal memory.
500 for (page = (unsigned long)fbdev->fb_mem;
501 page < PAGE_ALIGN((unsigned long)fbdev->fb_mem + fbdev->fb_len);
502 page += PAGE_SIZE) {
503 #if CONFIG_DMA_NONCOHERENT
504 SetPageReserved(virt_to_page(CAC_ADDR(page)));
505 #else
506 SetPageReserved(virt_to_page(page));
507 #endif
510 print_dbg("Framebuffer memory map at %p", fbdev->fb_mem);
511 print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024);
513 /* Setup LCD clock to AUX (48 MHz) */
514 sys_clksrc = au_readl(SYS_CLKSRC) & ~(SYS_CS_ML_MASK | SYS_CS_DL | SYS_CS_CL);
515 au_writel((sys_clksrc | (1 << SYS_CS_ML_BIT)), SYS_CLKSRC);
517 /* load the panel info into the var struct */
518 au1100fb_var.bits_per_pixel = fbdev->panel->bpp;
519 au1100fb_var.xres = fbdev->panel->xres;
520 au1100fb_var.xres_virtual = au1100fb_var.xres;
521 au1100fb_var.yres = fbdev->panel->yres;
522 au1100fb_var.yres_virtual = au1100fb_var.yres;
524 fbdev->info.screen_base = fbdev->fb_mem;
525 fbdev->info.fbops = &au1100fb_ops;
526 fbdev->info.fix = au1100fb_fix;
528 if (!(fbdev->info.pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL))) {
529 return -ENOMEM;
531 memset(fbdev->info.pseudo_palette, 0, sizeof(u32) * 16);
533 if (fb_alloc_cmap(&fbdev->info.cmap, AU1100_LCD_NBR_PALETTE_ENTRIES, 0) < 0) {
534 print_err("Fail to allocate colormap (%d entries)",
535 AU1100_LCD_NBR_PALETTE_ENTRIES);
536 kfree(fbdev->info.pseudo_palette);
537 return -EFAULT;
540 fbdev->info.var = au1100fb_var;
542 /* Set h/w registers */
543 au1100fb_setmode(fbdev);
545 /* Register new framebuffer */
546 if (register_framebuffer(&fbdev->info) < 0) {
547 print_err("cannot register new framebuffer");
548 goto failed;
551 return 0;
553 failed:
554 if (fbdev->regs) {
555 release_mem_region(fbdev->regs_phys, fbdev->regs_len);
557 if (fbdev->fb_mem) {
558 dma_free_noncoherent(dev, fbdev->fb_len, fbdev->fb_mem, fbdev->fb_phys);
560 if (fbdev->info.cmap.len != 0) {
561 fb_dealloc_cmap(&fbdev->info.cmap);
563 kfree(fbdev);
564 dev_set_drvdata(dev, NULL);
566 return 0;
569 int au1100fb_drv_remove(struct device *dev)
571 struct au1100fb_device *fbdev = NULL;
573 if (!dev)
574 return -ENODEV;
576 fbdev = (struct au1100fb_device*) dev_get_drvdata(dev);
578 #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO)
579 au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info);
580 #endif
581 fbdev->regs->lcd_control &= ~LCD_CONTROL_GO;
583 /* Clean up all probe data */
584 unregister_framebuffer(&fbdev->info);
586 release_mem_region(fbdev->regs_phys, fbdev->regs_len);
588 dma_free_coherent(dev, PAGE_ALIGN(fbdev->fb_len), fbdev->fb_mem, fbdev->fb_phys);
590 fb_dealloc_cmap(&fbdev->info.cmap);
591 kfree(fbdev->info.pseudo_palette);
592 kfree((void*)fbdev);
594 return 0;
597 int au1100fb_drv_suspend(struct device *dev, u32 state, u32 level)
599 /* TODO */
600 return 0;
603 int au1100fb_drv_resume(struct device *dev, u32 level)
605 /* TODO */
606 return 0;
609 static struct device_driver au1100fb_driver = {
610 .name = "au1100-lcd",
611 .bus = &platform_bus_type,
613 .probe = au1100fb_drv_probe,
614 .remove = au1100fb_drv_remove,
615 .suspend = au1100fb_drv_suspend,
616 .resume = au1100fb_drv_resume,
619 /*-------------------------------------------------------------------------*/
621 /* Kernel driver */
623 int au1100fb_setup(char *options)
625 char* this_opt;
626 int num_panels = ARRAY_SIZE(known_lcd_panels);
627 char* mode = NULL;
628 int panel_idx = 0;
630 if (num_panels <= 0) {
631 print_err("No LCD panels supported by driver!");
632 return -EFAULT;
635 if (options) {
636 while ((this_opt = strsep(&options,",")) != NULL) {
637 /* Panel option */
638 if (!strncmp(this_opt, "panel:", 6)) {
639 int i;
640 this_opt += 6;
641 for (i = 0; i < num_panels; i++) {
642 if (!strncmp(this_opt,
643 known_lcd_panels[i].name,
644 strlen(this_opt))) {
645 panel_idx = i;
646 break;
649 if (i >= num_panels) {
650 print_warn("Panel %s not supported!", this_opt);
653 /* Mode option (only option that start with digit) */
654 else if (isdigit(this_opt[0])) {
655 mode = kmalloc(strlen(this_opt) + 1, GFP_KERNEL);
656 strncpy(mode, this_opt, strlen(this_opt) + 1);
658 /* Unsupported option */
659 else {
660 print_warn("Unsupported option \"%s\"", this_opt);
665 drv_info.panel_idx = panel_idx;
666 drv_info.opt_mode = mode;
668 print_info("Panel=%s Mode=%s",
669 known_lcd_panels[drv_info.panel_idx].name,
670 drv_info.opt_mode ? drv_info.opt_mode : "default");
672 return 0;
675 int __init au1100fb_init(void)
677 char* options;
678 int ret;
680 print_info("" DRIVER_DESC "");
682 memset(&drv_info, 0, sizeof(drv_info));
684 if (fb_get_options(DRIVER_NAME, &options))
685 return -ENODEV;
687 /* Setup driver with options */
688 ret = au1100fb_setup(options);
689 if (ret < 0) {
690 print_err("Fail to setup driver");
691 return ret;
694 return driver_register(&au1100fb_driver);
697 void __exit au1100fb_cleanup(void)
699 driver_unregister(&au1100fb_driver);
701 if (drv_info.opt_mode)
702 kfree(drv_info.opt_mode);
705 module_init(au1100fb_init);
706 module_exit(au1100fb_cleanup);
708 MODULE_DESCRIPTION(DRIVER_DESC);
709 MODULE_LICENSE("GPL");