ARM S3C2410 framebuffer driver
Subsystems (2)
PATCH 1/2 ARM S3C2410 framebuffer driver
Hi,
This set of two patches add support for the framebuffer of the Samsung S3C2410 ARM SoC. This driver was started about one year ago and is now used on iPAQ h1930/h1940, Acer n30 and probably other s3c2410-based machines I'm not aware of. I've also heard yesterday that it's working also on iPAQ rx3715/rx3115 (s3c2440-based machines).
Theses patches are against current linux-2.6 git tree.
The first one add the driver by itself along with Kconfig, Makefile and some headers. The second one add the plateform specific stuff needed to configure and use the driver.
Regards,
Arnaud Patard
---
drivers/video/Kconfig +24 -0
@@ -1484,6 +1484,30 @@ config FB_S1D13XXX working with S1D13806). Product specs at <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm> +config FB_S3C2410 + tristate "S3C2410 LCD framebuffer support" + depends on FB && ARCH_S3C2410 + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + select FB_SOFT_CURSOR + ---help--- + Frame buffer driver for the built-in LCD controller in the Samsung + S3C2410 processor. + + This driver is also available as a module ( = code which can be + inserted and removed from the running kernel whenever you want). The + module will be called s3c2410fb. If you want to compile it as a module, + say M here and read <file:Documentation/modules.txt>. + + If unsure, say N. +config FB_S3C2410_DEBUG + bool "S3C2410 lcd debug messages" + depends on FB_S3C2410 + help + Turn on debugging messages. Note that you can set/unset at run time + through sysfs + config FB_VIRTUAL tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" depends on FB
drivers/video/Makefile +1 -0
@@ -92,6 +92,7 @@ obj-$(CONFIG_FB_MAXINE) += maxinefb.o obj-$(CONFIG_FB_TX3912) += tx3912fb.o obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o obj-$(CONFIG_FB_IMX) += imxfb.o +obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o # Platform or fallback drivers go here obj-$(CONFIG_FB_VESA) += vesafb.o
drivers/video/s3c2410fb.c new file +902 -0
902 lines not on this page · raw message
drivers/video/s3c2410fb.h new file +56 -0
56 lines not on this page · raw message
include/asm-arm/arch-s3c2410/fb.h new file +69 -0
69 lines not on this page · raw message
include/asm-arm/arch-s3c2410/regs-lcd.h +17 -0
@@ -51,21 +51,32 @@#define S3C2410_LCDCON1_ENVID (1) +#define S3C2410_LCDCON1_MODEMASK 0x1E +#define S3C2410_LCDCON2_VBPD (x) ((x) << 24)#define S3C2410_LCDCON2_LINEVAL (x) ((x) << 14)#define S3C2410_LCDCON2_VFPD (x) ((x) << 6)#define S3C2410_LCDCON2_VSPW (x) ((x) << 0) +#define S3C2410_LCDCON2_GET_VBPD (x) ( ((x) >> 24) & 0xFF) +#define S3C2410_LCDCON2_GET_VFPD (x) ( ((x) >> 6) & 0xFF) +#define S3C2410_LCDCON2_GET_VSPW (x) ( ((x) >> 0) & 0x3F) +#define S3C2410_LCDCON3_HBPD (x) ((x) << 19)#define S3C2410_LCDCON3_WDLY (x) ((x) << 19)#define S3C2410_LCDCON3_HOZVAL (x) ((x) << 8)#define S3C2410_LCDCON3_HFPD (x) ((x) << 0)#define S3C2410_LCDCON3_LINEBLANK (x)((x) << 0) +#define S3C2410_LCDCON3_GET_HBPD (x) ( ((x) >> 19) & 0x7F) +#define S3C2410_LCDCON3_GET_HFPD (x) ( ((x) >> 0) & 0xFF) +#define S3C2410_LCDCON4_MVAL (x) ((x) << 8)#define S3C2410_LCDCON4_HSPW (x) ((x) << 0)#define S3C2410_LCDCON4_WLH (x) ((x) << 0) +#define S3C2410_LCDCON4_GET_HSPW (x) ( ((x) >> 0) & 0xFF) +#define S3C2410_LCDCON5_BPP24BL (1<<12)#define S3C2410_LCDCON5_FRM565 (1<<11)#define S3C2410_LCDCON5_INVVCLK (1<<10)
@@ -100,10 +111,16 @@#define S3C2410_DITHMODE S3C2410_LCDREG(0x4C)#define S3C2410_TPAL S3C2410_LCDREG(0x50) +#define S3C2410_TPAL_EN (1<<24) +/* interrupt info */ #define S3C2410_LCDINTPND S3C2410_LCDREG(0x54)#define S3C2410_LCDSRCPND S3C2410_LCDREG(0x58)#define S3C2410_LCDINTMSK S3C2410_LCDREG(0x5C) +#define S3C2410_LCDINT_FIWSEL (1<<2) +#define S3C2410_LCDINT_FRSYNC (1<<1) +#define S3C2410_LCDINT_FICNT (1<<0) +#define S3C2410_LPCSEL S3C2410_LCDREG(0x60)#define S3C2410_TFTPAL (x) S3C2410_LCDREG((0x400 + (x)*4))
Quoted 8 lines · Arnaud Patard (Rtp)
Hi,
This set of two patches add support for the framebuffer of the Samsung S3C2410 ARM SoC. This driver was started about one year ago and is now used on iPAQ h1930/h1940, Acer n30 and probably other s3c2410-based machines I'm not aware of. I've also heard yesterday that it's working also on iPAQ rx3715/rx3115 (s3c2440-based machines).
Quoted 5 lines
Theses patches are against current linux-2.6 git tree.
The first one add the driver by itself along withKconfig,Makefileand some headers. The second one add the plateform specific stuff needed to configure and use the driver.
Do the ARM people know about this driver?
Quoted 6 lines
Regards,
Arnaud PatardSigned-off-by Arnaud Patard <[email protected]>
<snip>
drivers/video/s3c2410fb.c line 125
Quoted 6 lines
drivers/video/s3c2410fb.c new file +6
-0+ +static inline struct s3c2410fb_info *fb_to_s3cfb (struct fb_info *info) +{ + return container_of(info, struct s3c2410fb_info, fb); +} +
Instead of the private structure containing struct fb_info, any reason why the private data can't be placed in fb_info->par?...
drivers/video/s3c2410fb.c line 186
Quoted 10 lines
+ *
s3c2410fb_check_var():
+ * Get the video params out of 'var'. If a value doesn't fit, round it up,
+ * if it's too big, return-EINVAL.
+ *
+ */drivers/video/s3c2410fb.c new file +5
-0+static int s3c2410fb_check_var (struct fb_var_screeninfo *var, +struct fb_info *info) +{ +struct s3c2410fb_info *fbi =fb_to_s3cfb (info); +
... and do it like this instead:
struct s3c2410fb_info *fbi = info->par;
Quoted 4 lines
drivers/video/s3c2410fb.c new file +4
-0+ +if (var->bits_per_pixel ==16 ) { + var->red.offset =11 ; + var->green.offset =5 ;
drivers/video/s3c2410fb.c line 222
Quoted 10 lines
drivers/video/s3c2410fb.c new file +10
-0+ var->blue.offset =0 ; + var->red.length =5 ; + var->green.length =6 ; + var->blue.length =5 ; + var->transp.length =0 ; + }else { + var->red.length =8 ; + var->red.offset =0 ; + var->green.length =0 ; + var->green.offset =8 ;
swapped green.length and green.offset?
Quoted 33 lines
drivers/video/s3c2410fb.c new file +33
-0+ var->blue.length =8 ; + var->blue.offset =0 ; + var->transp.length =0 ; + } + +return 0 ; +} + +/* s3c2410fb_activate_var +* +* activate (set) the controller from the given framebuffer +* information +*/ + +static int s3c2410fb_activate_var (struct s3c2410fb_info *fbi, +struct fb_var_screeninfo *var) +{ + fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK ; + +dprintk ("%s: var->xres = %d\n" , __FUNCTION__, var->xres); +dprintk ("%s: var->yres = %d\n" , __FUNCTION__, var->yres); +dprintk ("%s: var->bpp = %d\n" , __FUNCTION__, var->bits_per_pixel); + +switch (var->bits_per_pixel) { +case 1 : + fbi->regs.lcdcon1 |=S3C2410_LCDCON1_TFT1BPP ; +break ; +case 2 : + fbi->regs.lcdcon1 |=S3C2410_LCDCON1_TFT2BPP ; +break ; +case 4 : + fbi->regs.lcdcon1 |=S3C2410_LCDCON1_TFT4BPP ; +break ;
drivers/video/s3c2410fb.c line 265
Quoted 10 lines
drivers/video/s3c2410fb.c new file +10
-0+case 8 : + fbi->regs.lcdcon1 |=S3C2410_LCDCON1_TFT8BPP ; +break ; +case 16 : + fbi->regs.lcdcon1 |=S3C2410_LCDCON1_TFT16BPP ; +break ; + +default : +/* invalid pixel depth */ +dev_err (fbi->dev,"invalid bpp %d\n" , var->bits_per_pixel);
You won't need to have an error path here if you round up bits_per_pixel in the check_var(). info->var will always contain a valid var as it would always go through the driver's check_var().
Quoted 12 lines
drivers/video/s3c2410fb.c new file +12
-0+static int s3c2410fb_setcolreg (unsigned regno, +unsigned red,unsigned green,unsigned blue, +unsigned transp,struct fb_info *info) +{ +struct s3c2410fb_info *fbi = (struct s3c2410fb_info *)info; +unsigned int val; + +/* dprintk("setcol: regno=%d, rgb=%d,%d,%d\n", regno, red, green, blue); */ + +switch (fbi->fb.fix.visual) { +case FB_VISUAL_TRUECOLOR : +/* true-colour, use pseuo-palette */
drivers/video/s3c2410fb.c line 407
Quoted 10 lines
drivers/video/s3c2410fb.c new file +10
-0+ +if (regno <16 ) { +u32 *pal = fbi->fb.pseudo_palette; + + val =chan_to_field (red, &fbi->fb.var.red); + val |=chan_to_field (green, &fbi->fb.var.green); + val |=chan_to_field (blue, &fbi->fb.var.blue); + + pal[regno] = val; + }
Missing break statement?
drivers/video/s3c2410fb.c line 409
Quoted 2 lines
drivers/video/s3c2410fb.c new file +2
-0+ +case FB_VISUAL_STATIC_PSEUDOCOLOR :
static pseudocolor does not have a modifiable CLUT. And I don't see your driver supporting static pseudocolor.
Similarly, truecolor cannot have a modifiable clut, that's why you need the 'break' above. If you think your driver can modify the clut at 16 bpp, then advertise the visual as directcolor.
The above may seem nitpicking, but it can confuse user apps if the driver incorrectly advertises its capability.
Quoted 33 lines
drivers/video/s3c2410fb.c new file +33
-0+case FB_VISUAL_PSEUDOCOLOR : +if (regno <256 ) { +/* currently assume RGB 5-6-5 mode */ + + val = ((red >>0 ) &0xf800 ); + val |= ((green >>5 ) &0x07e0 ); + val |= ((blue >>11 ) &0x001f ); + +writel (val,S3C2410_TFTPAL (regno)); +schedule_palette_update (fbi, regno, val); + } + +break ; + +default : +return 1 ;/* unknown type */ + } + +return 0 ; +} + + +/** +* s3c2410fb_pan_display +* @var: frame buffer variable screen structure +* @info: frame buffer structure that represents a single frame buffer +* +* Pan (or wrap, depending on the `vmode' field) the display using the +* `xoffset' and `yoffset' fields of the `var' structure. +* If the values don't fit, return -EINVAL. +* +* Returns negative errno on error, or zero on success. +*/
drivers/video/s3c2410fb.c line 452
Quoted 10 lines
drivers/video/s3c2410fb.c new file +10
-0+static int s3c2410fb_pan_display (struct fb_var_screeninfo *var, +struct fb_info *info) +{ +dprintk ("pan_display(var=%p, info=%p)\n" , var, info); + +dprintk ("pan_display: xoffset=%d\n" , var->xoffset); +dprintk ("pan_display: yoffset=%d\n" , var->yoffset); + +return 0 ; +}
Just comment out pan_display if it's not doing anything. You'll just confuse apps that do multi-buffering.
drivers/video/s3c2410fb.c line 535
Quoted 4 lines
drivers/video/s3c2410fb.c new file +4
-0+ + +/* Fake monspecs to fill in fbinfo structure */ +/* Don't know if the values are important */
The values in monspecs are important if the driver uses it. Otherwise, you need not fake a monspecs.
Quoted 67 lines
drivers/video/s3c2410fb.c new file +67
-0+int __init s3c2410fb_probe (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct s3c2410fb_hw *mregs; +int ret; +int irq; +int i; + + mach_info = dev->platform_data; +if (mach_info ==NULL ) { +dev_err (dev,"no platform data for lcd, cannot attach\n" ); +return -EINVAL ; + } + + mregs = &mach_info->regs; + + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { +dev_err (dev,"no irq for device\n" ); +return -ENOENT ; + } + +s3c2410fb_init_registers (&info); + +dprintk ("devinit\n" ); + +strcpy (info.fb.fix.id, driver_name); + +memcpy (&info.regs, &mach_info->regs,sizeof (info.regs)); + + info.mach_info = dev->platform_data; + + info.fb.fix.type =FB_TYPE_PACKED_PIXELS ; + info.fb.fix.type_aux =0 ; + info.fb.fix.xpanstep =0 ; + info.fb.fix.ypanstep =0 ; + info.fb.fix.ywrapstep =0 ; + info.fb.fix.accel =FB_ACCEL_NONE ; + + info.fb.var.nonstd =0 ; + info.fb.var.activate =FB_ACTIVATE_NOW ; + info.fb.var.height = mach_info->height; + info.fb.var.width = mach_info->width; + info.fb.var.accel_flags =0 ; + info.fb.var.vmode =FB_VMODE_NONINTERLACED ; + + info.fb.fbops = &s3c2410fb_ops; + info.fb.flags =FBINFO_FLAG_DEFAULT ; + info.fb.monspecs = monspecs; + info.fb.pseudo_palette = &info.pseudo_pal; + + info.fb.var.xres = mach_info->xres.defval; + info.fb.var.xres_virtual = mach_info->xres.defval; + info.fb.var.yres = mach_info->yres.defval; + info.fb.var.yres_virtual = mach_info->yres.defval; + info.fb.var.bits_per_pixel = mach_info->bpp.defval; + + info.fb.var.upper_margin =S3C2410_LCDCON2_GET_VBPD (mregs->lcdcon2) +1 ; + info.fb.var.lower_margin =S3C2410_LCDCON2_GET_VFPD (mregs->lcdcon2) +1 ; + info.fb.var.vsync_len =S3C2410_LCDCON2_GET_VSPW (mregs->lcdcon2) +1 ; + + info.fb.var.left_margin =S3C2410_LCDCON3_GET_HFPD (mregs->lcdcon3) +1 ; + info.fb.var.right_margin =S3C2410_LCDCON3_GET_HBPD (mregs->lcdcon3) +1 ; + info.fb.var.hsync_len =S3C2410_LCDCON4_GET_HSPW (mregs->lcdcon4) +1 ; + + info.fb.var.red.offset =11 ; + info.fb.var.green.offset =5 ;
drivers/video/s3c2410fb.c line 750
Quoted 10 lines
drivers/video/s3c2410fb.c new file +10
-0+ info.fb.var.blue.offset =0 ; + info.fb.var.transp.offset =0 ; + info.fb.var.red.length =5 ; + info.fb.var.green.length =6 ; + info.fb.var.blue.length =5 ; + info.fb.var.transp.length =0 ; + info.fb.fix.smem_len = mach_info->xres.max * + mach_info->yres.max * + mach_info->bpp.max /8 ; +
You may need to allocate info.fb.cmap also (with fb_alloc_cmap(), and check its return).
And you can set info.fb.device = dev so your driver will become visible in sysfs.
(The standard method is to use framebuffer_alloc() to allocate struct fb_info and framebuffer_release() to free. You may have your own reasons not to use them, so it's okay).
Quoted 5 lines
drivers/video/s3c2410fb.c new file +5
-0+/* +* Cleanup +*/ +static void __exit s3c2410fb_cleanup(void) +{
drivers/video/s3c2410fb.c line 841
Quoted 10 lines
drivers/video/s3c2410fb.c new file +10
-0+s3c2410fb_stop_lcd (); +msleep (1 ); + +if (info.clk) { +clk_disable (info.clk); +clk_unuse (info.clk); +clk_put (info.clk); + info.clk =NULL ; + } +
and deallocate your info.fb.cmap here (with fb_dealloc_cmap())
drivers/video/s3c2410fb.c line 845
Quoted 4 lines
drivers/video/s3c2410fb.c new file +4
-0+unregister_framebuffer (&info.fb); +release_mem_region ((unsigned long )S3C24XX_VA_LCD ,S3C24XX_SZ_LCD ); +} +
Tony
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
Quoted 9 lines · Antonino A. Daplas
Quoted 8 lines · Arnaud Patard (Rtp)
Hi,
This set of two patches add support for the framebuffer of the Samsung S3C2410 ARM SoC. This driver was started about one year ago and is now used on iPAQ h1930/h1940, Acer n30 and probably other s3c2410-based machines I'm not aware of. I've also heard yesterday that it's working also on iPAQ rx3715/rx3115 (s3c2440-based machines).
Quoted 8 lines
Quoted 5 lines
Theses patches are against current linux-2.6 git tree.
The first one add the driver by itself along withKconfig,Makefileand some headers. The second one add the plateform specific stuff needed to configure and use the driver.Do the ARM people know about this driver?
ARM People that have s3c2410 plateforms know it. Moreover, Ben Dooks, the maintainer of this ARM architecture, helped me in writing this driver.
Quoted 32 lines
Quoted 6 lines
Regards,
Arnaud PatardSigned-off-by Arnaud Patard <[email protected]><snip>
Review
Quoted 6 lines
(quoted diff) +6
-0+ +static inline struct s3c2410fb_info *fb_to_s3cfb(struct fb_info *info) +{ + return container_of(info, struct s3c2410fb_info, fb); +} +Instead of the private structure containing struct
fb_info, any reason why the private data can't be placed infb_info->par?...Review
Quoted 10 lines
+ *
s3c2410fb_check_var():
+ * Get the video params out of 'var'. If a value doesn't fit, round it up,
+ * if it's too big, return-EINVAL.
+ *
+ */(quoted diff) +5
-0+static int s3c2410fb_check_var(struct fb_var_screeninfo *var, + struct fb_info *info) +{ + struct s3c2410fb_info *fbi = fb_to_s3cfb(info); +... and do it like this instead:
Quoted 2 lines
struct
s3c2410fb_info*fbi =info->par;
Corrected.
Quoted 8 lines
Quoted 8 lines
(quoted diff) +8
-0+ + if (var->bits_per_pixel == 16) { + var->red.offset = 11; + var->green.offset = 5; + var->blue.offset = 0; + var->red.length = 5; + var->green.length = 6; + var->blue.length = 5;
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ var->transp.length = 0; + } else { + var->red.length = 8; + var->red.offset = 0; + var->green.length = 0; + var->green.offset = 8;swapped green.length and green.offset?
hm.. I had corrected that some time ago.. It seems I forgot to merge the patch in my git tree. New version is with patch applied.
Quoted 39 lines
Quoted 39 lines
(quoted diff) +39
-0+ var->blue.length = 8; + var->blue.offset = 0; + var->transp.length = 0; + } + + return 0; +} + +/* s3c2410fb_activate_var + * + * activate (set) the controller from the given framebuffer + * information +*/ + +static int s3c2410fb_activate_var(struct s3c2410fb_info *fbi, + struct fb_var_screeninfo *var) +{ + fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK; + + dprintk("%s: var->xres = %d\n", __FUNCTION__, var->xres); + dprintk("%s: var->yres = %d\n", __FUNCTION__, var->yres); + dprintk("%s: var->bpp = %d\n", __FUNCTION__, var->bits_per_pixel); + + switch (var->bits_per_pixel) { + case 1: + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT1BPP; + break; + case 2: + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT2BPP; + break; + case 4: + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT4BPP; + break; + case 8: + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT8BPP; + break; + case 16: + fbi->regs.lcdcon1 |= S3C2410_LCDCON1_TFT16BPP; + break;
Quoted 9 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ + default: + /* invalid pixel depth */ + dev_err(fbi->dev, "invalid bpp %d\n", var->bits_per_pixel);You won't need to have an error path here if you round up
bits_per_pixelin thecheck_var().info->varwill always contain a valid var as it would always go through the driver'scheck_var().
This was for debugging purpose and no more really needed. Removed.
Quoted 16 lines
Quoted 16 lines
(quoted diff) +16
-0+static int s3c2410fb_setcolreg(unsigned regno, + unsigned red, unsigned green, unsigned blue, + unsigned transp, struct fb_info *info) +{ + struct s3c2410fb_info *fbi = (struct s3c2410fb_info *)info; + unsigned int val; + + /* dprintk("setcol: regno=%d, rgb=%d,%d,%d\n", regno, red, green, blue); */ + + switch (fbi->fb.fix.visual) { + case FB_VISUAL_TRUECOLOR: + /* true-colour, use pseuo-palette */ + + if (regno < 16) { + u32 *pal = fbi->fb.pseudo_palette; +
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ val = chan_to_field(red, &fbi->fb.var.red); + val |= chan_to_field(green, &fbi->fb.var.green); + val |= chan_to_field(blue, &fbi->fb.var.blue); + + pal[regno] = val; + }Missing break statement?
You're right...
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + case FB_VISUAL_STATIC_PSEUDOCOLOR:static pseudocolor does not have a modifiable CLUT. And I don't see your driver supporting static pseudocolor.
you're right. removed.
Quoted 45 lines
Similarly, truecolor cannot have a modifiable clut, that's why you need the 'break' above. If you think your driver can modify the clut at 16 bpp, then advertise the visual as directcolor.
The above may seem nitpicking, but it can confuse user apps if the driver incorrectly advertises its capability.
Quoted 38 lines
(quoted diff) +38
-0+ case FB_VISUAL_PSEUDOCOLOR: + if (regno < 256) { + /* currently assume RGB 5-6-5 mode */ + + val = ((red >> 0) & 0xf800); + val |= ((green >> 5) & 0x07e0); + val |= ((blue >> 11) & 0x001f); + + writel(val, S3C2410_TFTPAL(regno)); + schedule_palette_update(fbi, regno, val); + } + + break; + + default: + return 1; /* unknown type */ + } + + return 0; +} + + +/** + * s3c2410fb_pan_display + * @var: frame buffer variable screen structure + * @info: frame buffer structure that represents a single frame buffer + * + * Pan (or wrap, depending on the `vmode' field) the display using the + * `xoffset' and `yoffset' fields of the `var' structure. + * If the values don't fit, return -EINVAL. + * + * Returns negative errno on error, or zero on success. + */ +static int s3c2410fb_pan_display(struct fb_var_screeninfo *var, + struct fb_info *info) +{ + dprintk("pan_display(var=%p, info=%p)\n", var, info); +
Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ dprintk("pan_display: xoffset=%d\n", var->xoffset); + dprintk("pan_display: yoffset=%d\n", var->yoffset); + + return 0; +}Just comment out
pan_displayif it's not doing anything. You'll just confuse apps that do multi-buffering.
Okay. Corrected.
Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ + +/* Fake monspecs to fill in fbinfo structure */ +/* Don't know if the values are important */The values in monspecs are important if the driver uses it. Otherwise, you need not fake a monspecs.
Thanks. I didn't know that.
Quoted 81 lines
Quoted 67 lines
(quoted diff) +67
-0+int __init s3c2410fb_probe(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct s3c2410fb_hw *mregs; + int ret; + int irq; + int i; + + mach_info = dev->platform_data; + if (mach_info == NULL) { + dev_err(dev,"no platform data for lcd, cannot attach\n"); + return -EINVAL; + } + + mregs = &mach_info->regs; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(dev, "no irq for device\n"); + return -ENOENT; + } + + s3c2410fb_init_registers(&info); + + dprintk("devinit\n"); + + strcpy(info.fb.fix.id, driver_name); + + memcpy(&info.regs, &mach_info->regs, sizeof(info.regs)); + + info.mach_info = dev->platform_data; + + info.fb.fix.type = FB_TYPE_PACKED_PIXELS; + info.fb.fix.type_aux = 0; + info.fb.fix.xpanstep = 0; + info.fb.fix.ypanstep = 0; + info.fb.fix.ywrapstep = 0; + info.fb.fix.accel = FB_ACCEL_NONE; + + info.fb.var.nonstd = 0; + info.fb.var.activate = FB_ACTIVATE_NOW; + info.fb.var.height = mach_info->height; + info.fb.var.width = mach_info->width; + info.fb.var.accel_flags = 0; + info.fb.var.vmode = FB_VMODE_NONINTERLACED; + + info.fb.fbops = &s3c2410fb_ops; + info.fb.flags = FBINFO_FLAG_DEFAULT; + info.fb.monspecs = monspecs; + info.fb.pseudo_palette = &info.pseudo_pal; + + info.fb.var.xres = mach_info->xres.defval; + info.fb.var.xres_virtual = mach_info->xres.defval; + info.fb.var.yres = mach_info->yres.defval; + info.fb.var.yres_virtual = mach_info->yres.defval; + info.fb.var.bits_per_pixel = mach_info->bpp.defval; + + info.fb.var.upper_margin = S3C2410_LCDCON2_GET_VBPD(mregs->lcdcon2) +1; + info.fb.var.lower_margin = S3C2410_LCDCON2_GET_VFPD(mregs->lcdcon2) +1; + info.fb.var.vsync_len = S3C2410_LCDCON2_GET_VSPW(mregs->lcdcon2) + 1; + + info.fb.var.left_margin = S3C2410_LCDCON3_GET_HFPD(mregs->lcdcon3) + 1; + info.fb.var.right_margin = S3C2410_LCDCON3_GET_HBPD(mregs->lcdcon3) + 1; + info.fb.var.hsync_len = S3C2410_LCDCON4_GET_HSPW(mregs->lcdcon4) + 1; + + info.fb.var.red.offset = 11; + info.fb.var.green.offset = 5;Review
Quoted 10 lines
(quoted diff) +10
-0+ info.fb.var.blue.offset = 0; + info.fb.var.transp.offset = 0; + info.fb.var.red.length = 5; + info.fb.var.green.length = 6; + info.fb.var.blue.length = 5; + info.fb.var.transp.length = 0; + info.fb.fix.smem_len = mach_info->xres.max * + mach_info->yres.max * + mach_info->bpp.max / 8; +You may need to allocate info.fb.cmap also (with
fb_alloc_cmap(), and check its return).
Quoted 7 lines
And you can set info.fb.device = dev so your driver will become visible in sysfs.
(The standard method is to use
framebuffer_alloc()to allocate structfb_infoandframebuffer_release()to free. You may have your own reasons not to use them, so it's okay).
Okay. Rewritten to use framebuffer_alloc()
Quoted 19 lines
Quoted 6 lines
(quoted diff) +5
-0+/* + * Cleanup + */ +static void __exit s3c2410fb_cleanup(void) +{Review
Quoted 10 lines
(quoted diff) +10
-0+ s3c2410fb_stop_lcd(); + msleep(1); + + if (info.clk) { + clk_disable(info.clk); + clk_unuse(info.clk); + clk_put(info.clk); + info.clk = NULL; + } +and deallocate your info.fb.cmap here (with
fb_dealloc_cmap())
Quoted 6 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ unregister_framebuffer(&info.fb); + release_mem_region((unsigned long)S3C24XX_VA_LCD, S3C24XX_SZ_LCD); +} +Tony
New version attached.
Regards,
Arnaud
---
drivers/video/Kconfig +24 -0
@@ -1484,6 +1484,30 @@ config FB_S1D13XXX working with S1D13806). Product specs at <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm> +config FB_S3C2410 + tristate "S3C2410 LCD framebuffer support" + depends on FB && ARCH_S3C2410 + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + select FB_SOFT_CURSOR + ---help--- + Frame buffer driver for the built-in LCD controller in the Samsung + S3C2410 processor. + + This driver is also available as a module ( = code which can be + inserted and removed from the running kernel whenever you want). The + module will be called s3c2410fb. If you want to compile it as a module, + say M here and read <file:Documentation/modules.txt>. + + If unsure, say N. +config FB_S3C2410_DEBUG + bool "S3C2410 lcd debug messages" + depends on FB_S3C2410 + help + Turn on debugging messages. Note that you can set/unset at run time + through sysfs + config FB_VIRTUAL tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" depends on FB
drivers/video/Makefile +1 -0
@@ -92,6 +92,7 @@ obj-$(CONFIG_FB_MAXINE) += maxinefb.o obj-$(CONFIG_FB_TX3912) += tx3912fb.o obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o obj-$(CONFIG_FB_IMX) += imxfb.o +obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o # Platform or fallback drivers go here obj-$(CONFIG_FB_VESA) += vesafb.o
drivers/video/s3c2410fb.c new file +915 -0
915 lines not on this page · raw message
drivers/video/s3c2410fb.h new file +56 -0
56 lines not on this page · raw message
include/asm-arm/arch-s3c2410/fb.h new file +69 -0
69 lines not on this page · raw message
include/asm-arm/arch-s3c2410/regs-lcd.h +17 -0
@@ -51,21 +51,32 @@#define S3C2410_LCDCON1_ENVID (1) +#define S3C2410_LCDCON1_MODEMASK 0x1E +#define S3C2410_LCDCON2_VBPD (x) ((x) << 24)#define S3C2410_LCDCON2_LINEVAL (x) ((x) << 14)#define S3C2410_LCDCON2_VFPD (x) ((x) << 6)#define S3C2410_LCDCON2_VSPW (x) ((x) << 0) +#define S3C2410_LCDCON2_GET_VBPD (x) ( ((x) >> 24) & 0xFF) +#define S3C2410_LCDCON2_GET_VFPD (x) ( ((x) >> 6) & 0xFF) +#define S3C2410_LCDCON2_GET_VSPW (x) ( ((x) >> 0) & 0x3F) +#define S3C2410_LCDCON3_HBPD (x) ((x) << 19)#define S3C2410_LCDCON3_WDLY (x) ((x) << 19)#define S3C2410_LCDCON3_HOZVAL (x) ((x) << 8)#define S3C2410_LCDCON3_HFPD (x) ((x) << 0)#define S3C2410_LCDCON3_LINEBLANK (x)((x) << 0) +#define S3C2410_LCDCON3_GET_HBPD (x) ( ((x) >> 19) & 0x7F) +#define S3C2410_LCDCON3_GET_HFPD (x) ( ((x) >> 0) & 0xFF) +#define S3C2410_LCDCON4_MVAL (x) ((x) << 8)#define S3C2410_LCDCON4_HSPW (x) ((x) << 0)#define S3C2410_LCDCON4_WLH (x) ((x) << 0) +#define S3C2410_LCDCON4_GET_HSPW (x) ( ((x) >> 0) & 0xFF) +#define S3C2410_LCDCON5_BPP24BL (1<<12)#define S3C2410_LCDCON5_FRM565 (1<<11)#define S3C2410_LCDCON5_INVVCLK (1<<10)
@@ -100,10 +111,16 @@#define S3C2410_DITHMODE S3C2410_LCDREG(0x4C)#define S3C2410_TPAL S3C2410_LCDREG(0x50) +#define S3C2410_TPAL_EN (1<<24) +/* interrupt info */ #define S3C2410_LCDINTPND S3C2410_LCDREG(0x54)#define S3C2410_LCDSRCPND S3C2410_LCDREG(0x58)#define S3C2410_LCDINTMSK S3C2410_LCDREG(0x5C) +#define S3C2410_LCDINT_FIWSEL (1<<2) +#define S3C2410_LCDINT_FRSYNC (1<<1) +#define S3C2410_LCDINT_FICNT (1<<0) +#define S3C2410_LPCSEL S3C2410_LCDREG(0x60)#define S3C2410_TFTPAL (x) S3C2410_LCDREG((0x400 + (x)*4))
Antonino A. Daplas
AppliedQuoted 3 lines · Arnaud Patard (Rtp)
Quoted 1 line · Antonino A. Daplas
Arnaud Patard (Rtp) wrote:
Applied to my tree and will push to Andrew on my next drop.
Tony
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
Quoted 2 lines · Arnaud Patard (Rtp)
"Antonino A. Daplas" <[email protected]> writes:
I noticed one more thing:
Quoted 7 lines
drivers/video/s3c2410fb.c new file +7
-0+if (var->bits_per_pixel ==16 ) { + var->red.offset =11 ; + var->green.offset =5 ; + var->blue.offset =0 ; + var->red.length =5 ; + var->green.length =6 ; + var->blue.length =5 ;
drivers/video/s3c2410fb.c line 220
Quoted 10 lines
drivers/video/s3c2410fb.c new file +10
-0+ var->transp.length =0 ; + }else { + var->red.length =8 ; + var->red.offset =0 ; + var->green.length =8 ; + var->green.offset =0 ; + var->blue.length =8 ; + var->blue.offset =0 ; + var->transp.length =0 ; + }
Your driver supports bits_per_pixel of 1, 2, 4 and 8. It will be more correct if you do the above like this:
var->red.length = var->bits_per_pixel; var->red.offset = 0; var->green.length = var->bits_per_pixel; var->green.offset = 0; var->blue.length = var->bits_per_pixel; var->blue.offset = 0;
Otherwise, your driver will get wrong colors at bpp of 1 and 2 with fbcon.
If you believe the above is correct, I'll do the correction in my tree and you need not send a patch.
Tony
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
Quoted 34 lines · Antonino A. Daplas
Quoted 2 lines · Arnaud Patard (Rtp)
"Antonino A. Daplas" <[email protected]> writes:
I noticed one more thing:
Quoted 7 lines
drivers/video/s3c2410fb.c new file +7
-0+if (var->bits_per_pixel ==16 ) { + var->red.offset =11 ; + var->green.offset =5 ; + var->blue.offset =0 ; + var->red.length =5 ; + var->green.length =6 ; + var->blue.length =5 ;drivers/video/s3c2410fb.c line 220
Quoted 10 lines
drivers/video/s3c2410fb.c new file +10
-0+ var->transp.length =0 ; + }else { + var->red.length =8 ; + var->red.offset =0 ; + var->green.length =8 ; + var->green.offset =0 ; + var->blue.length =8 ; + var->blue.offset =0 ; + var->transp.length =0 ; + }Your driver supports
bits_per_pixelof 1, 2, 4 and 8. It will be more correct if you do the above like this:var->red.length = var->bits_per_pixel; var->red.offset = 0; var->green.length = var->bits_per_pixel; var->green.offset = 0; var->blue.length = var->bits_per_pixel; var->blue.offset = 0;
Quoted 5 lines
Otherwise, your driver will get wrong colors at bpp of 1 and 2 with fbcon.
If you believe the above is correct, I'll do the correction in my tree and you need not send a patch.
yeah, it's correct. This has been changed in a patch that adds STN support to the driver but this patch needs cleaning and tests before submission.
Regards,
Arnaud
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf