Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 28 Oct 2004 17:31:09 +0100 (BST) Received: from 67-121-164-6.ded.pacbell.net ([IPv6:::ffff:67.121.164.6]:60921 "EHLO mailserver.sunrisetelecom.com") by linux-mips.org with ESMTP id ; Thu, 28 Oct 2004 17:30:55 +0100 Received: from there ([192.168.50.222]) by mailserver.sunrisetelecom.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 28 Oct 2004 09:30:39 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Karl Lessard To: linux-mips@linux-mips.org Subject: [PATCH] New AU1100 FB driver Date: Thu, 28 Oct 2004 12:27:55 -0400 X-Mailer: KMail [version 1.3.2] Cc: ppopov@embeddedalley.com, ralf@linux-mips.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: X-OriginalArrivalTime: 28 Oct 2004 16:30:39.0987 (UTC) FILETIME=[7646FC30:01C4BD0B] Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 6227 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: klessard@sunrisetelecom.com Precedence: bulk X-list: linux-mips Hi all, This is a new framebuffer driver for the AU1100 LCD controller that runs with kernels 2.6. It has been largly modified, as you can see by the size of the patch. The FB-driver interface has changed a lot since kernels 2.4. Also, this new driver is now more flexible on its way, and handles more display settings (...and I've to admit I've done a bit a cleanup). Here's a brief explanation. First, in the old drivers, all mode-dependent settings were hardcoded in the "panel" structure, so only one mode was possible for a panel. Now, the panel only describe mode-independent data, has its ranges for frequency, pixel clock and resolution. Then when a application try to set a mode, we validate it into those ranges (check_var) and set the controller properly (set_par). So now, you can add to the kernel args the video mode you want to use for your fbconsole. The old "panel:" option still remains to specify which panel your exactly using. Here's a example of argumets to boot the Pb1100 board in 8bpp mode: video=au1100fb:panel:Sharp_LQ038Q5DR01,320x240-8 or set the s10 switch to 1, and remove the panel option: video=au1100fb:320x240-8 Also, in 16bpp, all RGB formats supported by the controller can be used (before it was hardcoded to 565), swivel modes and screen panning (only in Y). Support for STN dual-panels has also be added, but never tested. To allow the use of different resolutions (for panels that supports it), the LCD clock has been set to a static 48MHz (tell me if I shouldn't do so). The pixel clock is taken from the mode data (see fb_var), and adjust to a divider of LCD clock, only lcd_clkcontrol is updated on a mode switch. So we don't need to set a fixed pixel clock for a panel anymore. For now, the driver has only been tested on a Pb1100 board with a LQ038Q5DR01 Sharp LCD panel, in 1bpp, 2bpp, 4bpp, 8bpp, 12bpp and 16bpp modes. Other panels should be registered later on in the same way as the Sharp panel (see known_panels in au1100fb.h). Things left to do: - suspend and resume the controller device - add other known panels Known bugs: - 12bpp display mode gives bad colors Please e-mail directly for any questions, I have no access to the mailing list from my inbox. Thanks, Karl Lessard Index: arch/mips/au1000/common/platform.c =================================================================== RCS file: /home/cvs/linux/arch/mips/au1000/common/platform.c,v retrieving revision 1.1 diff -u -r1.1 platform.c --- arch/mips/au1000/common/platform.c 10 Oct 2004 17:56:25 -0000 1.1 +++ arch/mips/au1000/common/platform.c 28 Oct 2004 15:11:27 -0000 @@ -15,6 +15,9 @@ #include +/*** USB OHCI host controller ***/ + +#ifdef CONFIG_USB_OHCI_HCD static struct resource au1xxx_usb_ohci_resources[] = { [0] = { .start = USB_OHCI_BASE, @@ -41,14 +44,72 @@ .num_resources = ARRAY_SIZE(au1xxx_usb_ohci_resources), .resource = au1xxx_usb_ohci_resources, }; +#endif + +/*** AU1100 LCD controller ***/ + +#ifdef CONFIG_FB_AU1100 +static struct resource au1100_lcd_resources[] = { + [0] = { + .start = AU1100_LCD_BASE, + .end = AU1100_LCD_BASE + AU1100_LCD_LEN, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = AU1100_LCD_INT, + .end = AU1100_LCD_INT, + .flags = IORESOURCE_IRQ, + } +}; + +/* The dmamask must be set for AU1100 LCD to work */ +static u64 au1100_lcd_dmamask = ~(u32)0; + +static struct platform_device au1100_lcd_device = { + .name = "au1100-lcd", + .id = 0, + .dev = { + .dma_mask = &au1100_lcd_dmamask, + .coherent_dma_mask = 0xffffffff, + }, + .num_resources = ARRAY_SIZE(au1100_lcd_resources), + .resource = au1100_lcd_resources, +}; +#endif + +/***/ static struct platform_device *au1xxx_platform_devices[] __initdata = { +#ifdef CONFIG_USB_OHCI_HCD &au1xxx_usb_ohci_device, +#endif +#ifdef CONFIG_FB_AU1100 + &au1100_lcd_device, +#endif }; int au1xxx_platform_init(void) { - return platform_add_devices(au1xxx_platform_devices, ARRAY_SIZE(au1xxx_platform_devices)); + int ret = platform_add_devices(au1xxx_platform_devices, + ARRAY_SIZE(au1xxx_platform_devices)); + if (ret < 0) { + printk(KERN_ERR __FILE__ + ": fail to register au1xxx platform devices (err: %d)\n", + ret); + return ret; + } + + return 0; +} + +void au1xxx_platform_exit(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(au1xxx_platform_devices); i++) { + platform_device_unregister(au1xxx_platform_devices[i]); + } } arch_initcall(au1xxx_platform_init); +__exitcall(au1xxx_platform_exit); Index: arch/mips/au1000/common/setup.c =================================================================== RCS file: /home/cvs/linux/arch/mips/au1000/common/setup.c,v retrieving revision 1.20 diff -u -r1.20 setup.c --- arch/mips/au1000/common/setup.c 11 Oct 2004 20:01:14 -0000 1.20 +++ arch/mips/au1000/common/setup.c 28 Oct 2004 15:11:28 -0000 @@ -108,11 +108,10 @@ if ((argptr = strstr(argptr, "video=")) == NULL) { argptr = prom_getcmdline(); /* default panel */ - /*strcat(argptr, " video=au1100fb:panel:Sharp_320x240_16");*/ #ifdef CONFIG_MIPS_HYDROGEN3 strcat(argptr, " video=au1100fb:panel:Hydrogen_3_NEC_panel_320x240,nohwcursor"); #else - strcat(argptr, " video=au1100fb:panel:s10,nohwcursor"); + /*strcat(argptr, " video=au1100fb:panel:Sharp_LQ038Q5DR01");*/ #endif } #endif Index: drivers/video/Kconfig =================================================================== RCS file: /home/cvs/linux/drivers/video/Kconfig,v retrieving revision 1.29 diff -u -r1.29 Kconfig --- drivers/video/Kconfig 25 Oct 2004 20:44:39 -0000 1.29 +++ drivers/video/Kconfig 28 Oct 2004 15:11:33 -0000 @@ -909,7 +909,7 @@ config FB_AU1100 bool "Au1100 LCD Driver" - depends on FB && EXPERIMENTAL && PCI && MIPS && MIPS_PB1100=y + depends on FB && MIPS && MIPS_PB1100=y config FB_SBUS bool "SBUS and UPA framebuffers" Index: drivers/video/Makefile =================================================================== RCS file: /home/cvs/linux/drivers/video/Makefile,v retrieving revision 1.84 diff -u -r1.84 Makefile --- drivers/video/Makefile 12 Oct 2004 01:45:47 -0000 1.84 +++ drivers/video/Makefile 28 Oct 2004 15:11:33 -0000 @@ -89,7 +89,7 @@ obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_MAXINE) += maxinefb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_TX3912) += tx3912fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o -obj-$(CONFIG_FB_AU1100) += au1100fb.o fbgen.o +obj-$(CONFIG_FB_AU1100) += au1100fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o # Platform or fallback drivers go here Index: drivers/video/au1100fb.c =================================================================== RCS file: /home/cvs/linux/drivers/video/au1100fb.c,v retrieving revision 1.3 diff -u -r1.3 au1100fb.c --- drivers/video/au1100fb.c 26 Oct 2004 02:23:08 -0000 1.3 +++ drivers/video/au1100fb.c 28 Oct 2004 15:11:34 -0000 @@ -9,6 +9,9 @@ * Copyright 2002 Alchemy Semiconductor * Author: Alchemy Semiconductor * + * Rewritten during Linux 2.6 port + * by Karl Lessard + * * Based on: * linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device * Created 28 Dec 1997 by Geert Uytterhoeven @@ -39,358 +42,671 @@ #include #include #include -#include -#include -#include #include #include -#include +#include +#include +#include -#include -#include -#include "au1100fb.h" +#include -#include