au1100fb.c ported from 2.4 to 2.6
PATCH 1/1 au1100fb.c ported from 2.4 to 2.6
Hi,
works in 16bpp, anyone with a system that works in 8bbp can give me a hand to test this mode?
Signature · 1 line
Christian <[email protected]>
Index: drivers/video/Kconfig
===================================================================
RCS file: /home/cvs/linux/drivers/video/Kconfig,v
retrieving revision 1.31
video/Kconfig +1 -1
@@ -973,7 +973,7 @@ config FB_AU1100 bool "Au1100 LCD Driver" - depends on FB && EXPERIMENTAL && PCI && MIPS && MIPS_PB1100=y + depends on FB && EXPERIMENTAL && MIPS && SOC_AU1X00 config FB_SBUS bool "SBUS and UPA framebuffers"
Index: drivers/video/Makefile
===================================================================
RCS file: /home/cvs/linux/drivers/video/Makefile,v retrieving revision 1.85
video/Makefile +1 -1
@@ -94,7 +94,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
video/au1100fb.c +350 -411
897 lines not on this page · raw message
Index: drivers/video/au1100fb.h
===================================================================
RCS file: /home/cvs/linux/drivers/video/au1100fb.h,v retrieving revision 1.1
video/au1100fb.h +34 -0
@@ -191,6 +191,39 @@*/ struct known_lcd_panels panels[] = { +#ifdef CONFIG_WWPC + { /* just the standard LCD */ + 240, /* xres */ + 320, /* yres */ + 16, /* bpp */ + + "WWPC LCD", + + /* mode_control */ + 0x0006806A, + + /* mode_horztiming */ + 0x0A1010EF, + + /* mode_verttiming */ + 0x0301013F, + + /* mode_clkcontrol */ + 0x00018001, + + /* mode_pwmdiv */ + 0, + + /* mode_pwmhi */ + 0, + + /* mode_toyclksrc */ + 0, /* not used */ + + /* mode_backlight */ + 0 /* not used */ + } +#else { /* 0: Pb1100 LCDA: Sharp 320x240 TFT panel */ 320, /* xres */ 240, /* yres */
@@ -377,5 +410,6 @@/* mode_backlight */ 7 }, +#endif };#endif /* _AU1100LCD_H */
Quoted 2 lines · Christian
works in 16bpp, anyone with a system that works in 8bbp can give me a hand to test this mode?
I have a system that has a 4bpp monochrome display and the driver doesn't work. After initializing, it turns on the display[1] but I fail to get any content onto it. I extended the array with the display characteristics according to an existing driver, but to no avail.
I'm pretty lost there, since I have zero prior experience with framebuffers or video drivers, so I'd appreciate any hint that might get me towards debugging this.
Uli
[1] p_lcd_reg->lcd_control |= LCD_CONTROL_GO;
Quoted 8 lines · Ulrich Eckhardt
I have a system that has a 4bpp monochrome display and the driver doesn't work. After initializing, it turns on the display[1] but I fail to get any content onto it. I extended the array with the display characteristics according to an existing driver, but to no avail.
I'm pretty lost there, since I have zero prior experience with framebuffers or video drivers, so I'd appreciate any hint that might get me towards debugging this.
Hi,
you actually have to do the following modification modifications.
First you have to modify the function au1100fb_setcolreg, add the switch case for 4bpp. Look in the Alchemy manual for the format of the palette in the 4 bpp case. Then look for my comment "TODO: 8bbp", put a switch and for pseudocolor like visual ... I think this is not even necessary. More important is that you change the monitor type. If you want I can send you privately a patch this weekend, but I just cannot assure it works, you have to test it and eventually contribute.
Signature · 1 line
Christian <[email protected]>
Quoted 4 lines · Christian
First you have to modify the function
au1100fb_setcolreg, add the switch case for 4bpp. Look in the Alchemy manual for the format of the palette in the 4 bpp case. Then look for my comment "TODO: 8bbp", put a switch and for pseudocolor like visual ... I think this is not even necessary.
Thanks, will look.
Quoted 1 line
More important is that you change the monitor type.
Yep, finding working parameters without real knowledge of what the registers mean was the hardest part, but I have it working now.
Quoted 3 lines
If you want I can
send you privately a patch this weekend, but I just cannot assure it works, you have to test it and eventually contribute.
I'd appreciate that, thank you.
Currently I'm facing a different problem though, look at this code and the bitmap it generates (4bpp):
unsigned long* fb = my_fb_info->fb_virt_start;
fb[0] = 0x0000000f; // *....... fb[40] = 0x000000f0; // .*...... fb[80] = 0x000000ff; // **......
fb[120] = 0xf0000f00; // ..*....*
fb[160] = 0xff000f0f; // *.*...**
fb[200] = 0xfff00ff0; // .**..***
fb[240] = 0xffff0fff; // ***.****
To me, expecting the LSB to be part of the leftmost pixel is not really surprising, but functions like cfb_fillrect() (or rather bitfill32() etc) expect the order to be the other way around. I'm afraid that other framebuffer functions also expect that, but I haven't gotten far enough to test those. I only tested cfb_fillrect() and, seeing it fail, started looking for answers... any idea?
I stumbled across another .. err .. 'feature': take a look at the appended patch, in particular the handling of the mask for the first long, am I dreaming or is this in fact handled wrongly in the current FB code? I'm a bit confused, because the same mistake is made in pretty much every FB driver I looked at.
Thanks
Uli
---
Index: cfbcopyarea.c
===================================================================
RCS file: /home/cvs/linux/drivers/video/cfbcopyarea.c,v retrieving revision 1.10
cfbcopyarea.c 4 Feb 2005 13:11:16 -0000 renamed from cfbcopyarea.c 12 Oct 2004 01:45:47 -0000 1.10 +2 -2
@@ -70,7 +70,7 @@ } else { // Multiple destination words // Leading bits - if (first) { + if (first != ~0UL) { FB_WRITEL((FB_READL(src) & first) | (FB_READL(dst) & ~first), dst);
@@ -223,7 +223,7 @@ } else { // Multiple destination words // Leading bits - if (first) { + if (first != ~0UL) { FB_WRITEL((FB_READL(src) & first) | (FB_READL(dst) & ~first), dst); dst--; src--;
Index: cfbfillrect.c
===================================================================
RCS file: /home/cvs/linux/drivers/video/cfbfillrect.c,v retrieving revision 1.8
cfbfillrect.c 4 Feb 2005 13:11:16 -0000 renamed from cfbfillrect.c 12 Oct 2004 01:45:47 -0000 1.8 +8 -8
@@ -142,7 +142,7 @@ } else { // Multiple destination words // Leading bits - if (first) { + if (first != ~0UL) { FB_WRITEL(comp(val, FB_READL(dst), first), dst); dst++; n -= BITS_PER_LONG-dst_idx;
@@ -166,7 +166,7 @@ // Trailing bits if (last) - FB_WRITEL(comp(val, FB_READL(dst), first), dst); + FB_WRITEL(comp(val, FB_READL(dst), last), dst); } }
@@ -197,7 +197,7 @@ } else { // Multiple destination words // Leading bits - if (first) { + if (first != ~0UL) { FB_WRITEL(comp(pat, FB_READL(dst), first), dst); dst++; pat = pat << left | pat >> right;
@@ -224,7 +224,7 @@ // Trailing bits if (last) - FB_WRITEL(comp(pat, FB_READL(dst), first), dst); + FB_WRITEL(comp(pat, FB_READL(dst), last), dst); } }
@@ -252,7 +252,7 @@ } else { // Multiple destination words // Leading bits - if (first) { + if (first != ~0UL) { dat = FB_READL(dst); FB_WRITEL(comp(dat ^ val, dat, first), dst); dst++;
@@ -287,7 +287,7 @@ // Trailing bits if (last) { dat = FB_READL(dst); - FB_WRITEL(comp(dat ^ val, dat, first), dst); + FB_WRITEL(comp(dat ^ val, dat, last), dst); } } }
@@ -320,7 +320,7 @@ } else { // Multiple destination words // Leading bits - if (first) { + if (first != ~0UL) { dat = FB_READL(dst); FB_WRITEL(comp(dat ^ pat, dat, first), dst); dst++;
@@ -354,7 +354,7 @@ // Trailing bits if (last) { dat = FB_READL(dst); - FB_WRITEL(comp(dat ^ pat, dat, first), dst); + FB_WRITEL(comp(dat ^ pat, dat, last), dst); } } }
Another two suggestions:
- you hard-coded the used display in au1100fb.{h,c} with #ifdef CONFIG_WWPC. There is another option already used in arch/mips/au1000/common/setup.c, and that is to append the necessary lines to the kernel commandline if no conflicting arguments are present.
- I have removed the comments that say to which field a constant belongs and instead converted au1100fb.h to use new-style initialisers which is just easier to not get wrong. I also added parameters for my display and replaced the #define for uint32. The new file is attached as whole, I didn't know against what to diff it...
Could you merge the file and resend the patch? I hope it will get committed then.
Uli
/*
* BRIEF MODULE DESCRIPTION
* Hardware definitions for the Au1100 LCD controller
*
* Copyright 2002 MontaVista Software
* Copyright 2002 Alchemy Semiconductor
* Author: Alchemy Semiconductor, MontaVista Software
*
* This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _AU1100LCD_H
#define _AU1100LCD_H
/********************************************************************/
typedef volatile struct
{
u32 lcd_control;
u32 lcd_intstatus;
u32 lcd_intenable;
u32 lcd_horztiming;
u32 lcd_verttiming;
u32 lcd_clkcontrol;
u32 lcd_dmaaddr0;
u32 lcd_dmaaddr1;
u32 lcd_words;
u32 lcd_pwmdiv;
u32 lcd_pwmhi;
u32 reserved[(0x0400-0x002C)/4];
u32 lcd_pallettebase[256];} AU1100_LCD;
/********************************************************************/
#define AU1100_LCD_ADDR 0xB5000000
/*
* Register bit definitions
*/
/* lcd_control */
#define LCD_CONTROL_SBB_1 (0<<21) #define LCD_CONTROL_SBB_2 (1<<21) #define LCD_CONTROL_SBB_3 (2<<21) #define LCD_CONTROL_SBB_4 (3<<21)
#define LCD_CONTROL_SBPPF (7<<18)
#define LCD_CONTROL_SBPPF_655 (0<<18)
#define LCD_CONTROL_SBPPF_565 (1<<18)
#define LCD_CONTROL_SBPPF_556 (2<<18)
#define LCD_CONTROL_SBPPF_1555 (3<<18)
#define LCD_CONTROL_SBPPF_5551 (4<<18)
#define LCD_CONTROL_WP (1<<17)
#define LCD_CONTROL_WD (1<<16)
#define LCD_CONTROL_C (1<<15)
#define LCD_CONTROL_SM (3<<13)
#define LCD_CONTROL_SM_0 (0<<13)
#define LCD_CONTROL_SM_90 (1<<13)
#define LCD_CONTROL_SM_180 (2<<13)
#define LCD_CONTROL_SM_270 (3<<13)
#define LCD_CONTROL_DB (1<<12)
#define LCD_CONTROL_CCO (1<<11)
#define LCD_CONTROL_DP (1<<10)
#define LCD_CONTROL_PO (3<<8)
#define LCD_CONTROL_PO_00 (0<<8)
#define LCD_CONTROL_PO_01 (1<<8)
#define LCD_CONTROL_PO_10 (2<<8)
#define LCD_CONTROL_PO_11 (3<<8)
#define LCD_CONTROL_MPI (1<<7)
#define LCD_CONTROL_PT (1<<6)
#define LCD_CONTROL_PC (1<<5)
#define LCD_CONTROL_BPP (7<<1)
#define LCD_CONTROL_BPP_1 (0<<1)
#define LCD_CONTROL_BPP_2 (1<<1)
#define LCD_CONTROL_BPP_4 (2<<1)
#define LCD_CONTROL_BPP_8 (3<<1)
#define LCD_CONTROL_BPP_12 (4<<1)
#define LCD_CONTROL_BPP_16 (5<<1)
#define LCD_CONTROL_GO (1<<0)
/* lcd_intstatus, lcd_intenable */
#define LCD_INT_SD (1<<7)
#define LCD_INT_OF (1<<6)
#define LCD_INT_UF (1<<5)
#define LCD_INT_SA (1<<3)
#define LCD_INT_SS (1<<2)
#define LCD_INT_S1 (1<<1)
#define LCD_INT_S0 (1<<0)
/* lcd_horztiming */
#define LCD_HORZTIMING_HN2 (255<<24)
#define LCD_HORZTIMING_HN2_N(N) (((N)-1)<<24)
#define LCD_HORZTIMING_HN1 (255<<16)
#define LCD_HORZTIMING_HN1_N(N) (((N)-1)<<16)
#define LCD_HORZTIMING_HPW (63<<10)
#define LCD_HORZTIMING_HPW_N(N) (((N)-1)<<10)
#define LCD_HORZTIMING_PPL (1023<<0)
#define LCD_HORZTIMING_PPL_N(N) (((N)-1)<<0)
/* lcd_verttiming */
#define LCD_VERTTIMING_VN2 (255<<24)
#define LCD_VERTTIMING_VN2_N(N) (((N)-1)<<24)
#define LCD_VERTTIMING_VN1 (255<<16)
#define LCD_VERTTIMING_VN1_N(N) (((N)-1)<<16)
#define LCD_VERTTIMING_VPW (63<<10)
#define LCD_VERTTIMING_VPW_N(N) (((N)-1)<<10)
#define LCD_VERTTIMING_LPP (1023<<0)
#define LCD_VERTTIMING_LPP_N(N) (((N)-1)<<0)
/* lcd_clkcontrol */
#define LCD_CLKCONTROL_IB (1<<18)
#define LCD_CLKCONTROL_IC (1<<17)
#define LCD_CLKCONTROL_IH (1<<16)
#define LCD_CLKCONTROL_IV (1<<15)
#define LCD_CLKCONTROL_BF (31<<10)
#define LCD_CLKCONTROL_BF_N(N) (((N)-1)<<10)
#define LCD_CLKCONTROL_PCD (1023<<0)
#define LCD_CLKCONTROL_PCD_N(N) ((N)<<0)
/* lcd_pwmdiv */
#define LCD_PWMDIV_EN (1<<12)
#define LCD_PWMDIV_PWMDIV (2047<<0)
#define LCD_PWMDIV_PWMDIV_N(N) (((N)-1)<<0)
/* lcd_pwmhi */
#define LCD_PWMHI_PWMHI1 (2047<<12)
#define LCD_PWMHI_PWMHI1_N(N) ((N)<<12)
#define LCD_PWMHI_PWMHI0 (2047<<0)
#define LCD_PWMHI_PWMHI0_N(N) ((N)<<0)
/* lcd_pallettebase - MONOCHROME */
#define LCD_PALLETTE_MONO_MI (15<<0)
#define LCD_PALLETTE_MONO_MI_N(N) ((N)<<0)
/* lcd_pallettebase - COLOR */
#define LCD_PALLETTE_COLOR_BI (15<<8)
#define LCD_PALLETTE_COLOR_BI_N(N) ((N)<<8)
#define LCD_PALLETTE_COLOR_GI (15<<4)
#define LCD_PALLETTE_COLOR_GI_N(N) ((N)<<4)
#define LCD_PALLETTE_COLOR_RI (15<<0)
#define LCD_PALLETTE_COLOR_RI_N(N) ((N)<<0)
/* lcd_palletebase - COLOR TFT PALLETIZED */
#define LCD_PALLETTE_TFT_DC (65535<<0)
#define LCD_PALLETTE_TFT_DC_N(N) ((N)<<0)
/********************************************************************/
struct known_lcd_panels
{
uint32 xres;
uint32 yres;
uint32 bpp;
unsigned char panel_name[256];
uint32 mode_control;
uint32 mode_horztiming;
uint32 mode_verttiming;
uint32 mode_clkcontrol;
uint32 mode_pwmdiv;
uint32 mode_pwmhi;
uint32 mode_toyclksrc;
uint32 mode_backlight;
};#if defined(__BIG_ENDIAN)
# define LCD_DEFAULT_PIX_FORMAT LCD_CONTROL_PO_11 #else
# define LCD_DEFAULT_PIX_FORMAT LCD_CONTROL_PO_00 #endif
/*
* The fb driver assumes that AUX PLL is at 48MHz. That can
* cover up to 800x600 resolution; if you need higher resolution,
* you should modify the driver as needed, not just this structure. */
struct known_lcd_panels panels[] =
{
#ifdef CONFIG_WWPC
{ /* just the standard LCD */
.xres = 240,
.yres = 320,
.bpp = 16,
.panel_name = "WWPC LCD",
.mode_control = 0x0006806A,
.mode_horztiming = 0x0A1010EF,
.mode_verttiming = 0x0301013F,
.mode_clkcontrol = 0x00018001,
.mode_pwmdiv = 0,
.mode_pwmhi = 0,
.mode_toyclksrc = 0, /* not used */
.mode_backlight = 0 /* not used */
}
#else
{ /* Pb1100 LCDA: Sharp 320x240 TFT panel */
.xres = 320,
.yres = 240,
.bpp = 16,
.panel_name = "Sharp_320x240_16",
.mode_control =
( LCD_CONTROL_SBPPF_565
| LCD_CONTROL_C
| LCD_CONTROL_SM_0
| LCD_DEFAULT_PIX_FORMAT
| LCD_CONTROL_PT
| LCD_CONTROL_PC
| LCD_CONTROL_BPP_16 ),
.mode_horztiming =
( LCD_HORZTIMING_HN2_N(8)
| LCD_HORZTIMING_HN1_N(60)
| LCD_HORZTIMING_HPW_N(12)
| LCD_HORZTIMING_PPL_N(320) ),
.mode_verttiming =
( LCD_VERTTIMING_VN2_N(5)
| LCD_VERTTIMING_VN1_N(17)
| LCD_VERTTIMING_VPW_N(1)
| LCD_VERTTIMING_LPP_N(240) ),
.mode_clkcontrol = LCD_CLKCONTROL_PCD_N(1),
.mode_pwmdiv = 0,
.mode_pwmhi = 0,
.mode_toyclksrc =
((1<<7) | (1<<6) | (1<<5)),
.mode_backlight = 6
},
{ /* Hitachi SP14Q005 and possibly others */
.xres = 320,
.yres = 240,
.bpp = 4,
.panel_name = "Hitachi_SP14Qxxx",
.mode_control =
( LCD_CONTROL_C
| LCD_CONTROL_BPP_4 ),
.mode_horztiming =
( LCD_HORZTIMING_HN2_N(1)
| LCD_HORZTIMING_HN1_N(1)
| LCD_HORZTIMING_HPW_N(1)
| LCD_HORZTIMING_PPL_N(320) ),
.mode_verttiming =
( LCD_VERTTIMING_VN2_N(1)
| LCD_VERTTIMING_VN1_N(1)
| LCD_VERTTIMING_VPW_N(1)
| LCD_VERTTIMING_LPP_N(240) ),
.mode_clkcontrol = LCD_CLKCONTROL_PCD_N(4),
.mode_pwmdiv = 0,
.mode_pwmhi = 0,
.mode_toyclksrc =
((1<<27) | (1<<26) | (1<<25) | (1<<7) | (1<<6) | (1<<5)),
.mode_backlight = 6
},
{ /* Pb1100 LCDC 640x480 TFT panel */
.xres = 640,
.yres = 480,
.bpp = 16,
.panel_name = "Generic_640x480_16",
.mode_control = 0x004806a | LCD_DEFAULT_PIX_FORMAT,
.mode_horztiming = 0x3434d67f,
.mode_verttiming = 0x0e0e39df,
.mode_clkcontrol = LCD_CLKCONTROL_PCD_N(1),
.mode_pwmdiv = 0,
.mode_pwmhi = 0,
.mode_toyclksrc =
((1<<7) | (1<<6) | (0<<5)),
.mode_backlight = 7
},
{ /* Pb1100 LCDB 640x480 PrimeView TFT panel */
.xres = 640,
.yres = 480,
.bpp = 16,
.panel_name = "PrimeView_640x480_16",
.mode_control = 0x0004886a | LCD_DEFAULT_PIX_FORMAT,
.mode_horztiming = 0x0e4bfe7f,
.mode_verttiming = 0x210805df,
.mode_clkcontrol = 0x00038001,
.mode_pwmdiv = 0,
.mode_pwmhi = 0,
.mode_toyclksrc =
((1<<7) | (1<<6) | (0<<5)),
.mode_backlight = 7
},
{ /* Pb1100 800x600x16bpp NEON CRT */
.xres = 800,
.yres = 600,
.bpp = 16,
.panel_name = "NEON_800x600_16",
.mode_control = 0x0004886A | LCD_DEFAULT_PIX_FORMAT,
.mode_horztiming = 0x005AFF1F,
.mode_verttiming = 0x16000E57,
.mode_clkcontrol = 0x00020000,
.mode_pwmdiv = 0,
.mode_pwmhi = 0,
.mode_toyclksrc =
((1<<7) | (1<<6) | (0<<5)),
.mode_backlight = 7
},
{ /* Pb1100 640x480x16bpp NEON CRT */
.xres = 640,
.yres = 480,
.bpp = 16,
.panel_name = "NEON_640x480_16",
.mode_control = 0x0004886A | LCD_DEFAULT_PIX_FORMAT,
.mode_horztiming = 0x0052E27F,
.mode_verttiming = 0x18000DDF,
.mode_clkcontrol = 0x00020000,
.mode_pwmdiv = 0,
.mode_pwmhi = 0,
.mode_toyclksrc =
((1<<7) | (1<<6) | (0<<5)),
.mode_backlight = 7
},#endif
};
#endif /* _AU1100LCD_H */