SOURCES (LINUX_2_6_14): linux-2.6.14.7-TGA-fbdev-lkml.patch (NEW) ...
mguevara
mguevara at pld-linux.org
Tue Feb 21 17:37:53 CET 2006
Author: mguevara Date: Tue Feb 21 16:37:53 2006 GMT
Module: SOURCES Tag: LINUX_2_6_14
---- Log message:
- 2.6.14.7 replacement for 2.6.x-TGA-fbdev-lkml.patch
- IMHO needs review - it looks like the code changed little bit,
so the patch could be obsolete now.
---- Files affected:
SOURCES:
linux-2.6.14.7-TGA-fbdev-lkml.patch (NONE -> 1.1.2.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/linux-2.6.14.7-TGA-fbdev-lkml.patch
diff -u /dev/null SOURCES/linux-2.6.14.7-TGA-fbdev-lkml.patch:1.1.2.1
--- /dev/null Tue Feb 21 17:37:53 2006
+++ SOURCES/linux-2.6.14.7-TGA-fbdev-lkml.patch Tue Feb 21 17:37:48 2006
@@ -0,0 +1,478 @@
+diff -uNr a/drivers/video/tgafb.c b/drivers/video/tgafb.c
+--- a/drivers/video/tgafb.c 2004-12-24 22:35:23.000000000 +0100
++++ b/drivers/video/tgafb.c 2005-01-25 12:41:07.565680400 +0100
+@@ -43,6 +43,7 @@
+ static void tgafb_imageblit(struct fb_info *, const struct fb_image *);
+ static void tgafb_fillrect(struct fb_info *, const struct fb_fillrect *);
+ static void tgafb_copyarea(struct fb_info *, const struct fb_copyarea *);
++static int tgafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info);
+
+ static int tgafb_pci_register(struct pci_dev *, const struct pci_device_id *);
+ #ifdef MODULE
+@@ -62,6 +63,7 @@
+ .fb_set_par = tgafb_set_par,
+ .fb_setcolreg = tgafb_setcolreg,
+ .fb_blank = tgafb_blank,
++ .fb_pan_display = tgafb_pan_display,
+ .fb_fillrect = tgafb_fillrect,
+ .fb_copyarea = tgafb_copyarea,
+ .fb_imageblit = tgafb_imageblit,
+@@ -78,6 +80,7 @@
+ 0, 0, 0 }
+ };
+
++
+ static struct pci_driver tgafb_driver = {
+ .name = "tgafb",
+ .id_table = tgafb_pci_table,
+@@ -85,7 +88,6 @@
+ .remove = __devexit_p(tgafb_pci_unregister),
+ };
+
+-
+ /**
+ * tgafb_check_var - Optional function. Validates a var passed in.
+ * @var: frame buffer variable screen structure
+@@ -129,10 +131,10 @@
+ tgafb_set_par(struct fb_info *info)
+ {
+ static unsigned int const deep_presets[4] = {
+- 0x00014000,
+- 0x0001440d,
++ 0x00004000,
++ 0x0000440d,
+ 0xffffffff,
+- 0x0001441d
++ 0x0000441d
+ };
+ static unsigned int const rasterop_presets[4] = {
+ 0x00000003,
+@@ -156,7 +158,7 @@
+ struct tga_par *par = (struct tga_par *) info->par;
+ u32 htimings, vtimings, pll_freq;
+ u8 tga_type;
+- int i, j;
++ int i;
+
+ /* Encode video timings. */
+ htimings = (((info->var.xres/4) & TGA_HORIZ_ACT_LSB)
+@@ -194,7 +196,8 @@
+ while (TGA_READ_REG(par, TGA_CMD_STAT_REG) & 1) /* wait for not busy */
+ continue;
+ mb();
+- TGA_WRITE_REG(par, deep_presets[tga_type], TGA_DEEP_REG);
++ TGA_WRITE_REG(par, deep_presets[tga_type] |
++ (par->sync_on_green ? 0x0 : 0x00010000), TGA_DEEP_REG);
+ while (TGA_READ_REG(par, TGA_CMD_STAT_REG) & 1) /* wait for not busy */
+ continue;
+ mb();
+@@ -227,37 +230,13 @@
+ BT485_WRITE(par, 0x20, BT485_CMD_2); /* cursor off, for now */
+ BT485_WRITE(par, 0xff, BT485_PIXEL_MASK);
+
+- /* Fill palette registers. */
+- BT485_WRITE(par, 0x00, BT485_ADDR_PAL_WRITE);
+- TGA_WRITE_REG(par, BT485_DATA_PAL, TGA_RAMDAC_SETUP_REG);
+-
+- for (i = 0; i < 16; i++) {
+- j = color_table[i];
+- TGA_WRITE_REG(par, default_red[j]|(BT485_DATA_PAL<<8),
+- TGA_RAMDAC_REG);
+- TGA_WRITE_REG(par, default_grn[j]|(BT485_DATA_PAL<<8),
+- TGA_RAMDAC_REG);
+- TGA_WRITE_REG(par, default_blu[j]|(BT485_DATA_PAL<<8),
+- TGA_RAMDAC_REG);
+- }
+- for (i = 0; i < 240*3; i += 4) {
+- TGA_WRITE_REG(par, 0x55|(BT485_DATA_PAL<<8),
+- TGA_RAMDAC_REG);
+- TGA_WRITE_REG(par, 0x00|(BT485_DATA_PAL<<8),
+- TGA_RAMDAC_REG);
+- TGA_WRITE_REG(par, 0x00|(BT485_DATA_PAL<<8),
+- TGA_RAMDAC_REG);
+- TGA_WRITE_REG(par, 0x00|(BT485_DATA_PAL<<8),
+- TGA_RAMDAC_REG);
+- }
+-
+ } else { /* 24-plane or 24plusZ */
+
+ /* Init BT463 registers. */
+ BT463_WRITE(par, BT463_REG_ACC, BT463_CMD_REG_0, 0x40);
+ BT463_WRITE(par, BT463_REG_ACC, BT463_CMD_REG_1, 0x08);
+ BT463_WRITE(par, BT463_REG_ACC, BT463_CMD_REG_2,
+- (par->sync_on_green ? 0x80 : 0x40));
++ (par->sync_on_green ? 0xc0 : 0x40));
+
+ BT463_WRITE(par, BT463_REG_ACC, BT463_READ_MASK_0, 0xff);
+ BT463_WRITE(par, BT463_REG_ACC, BT463_READ_MASK_1, 0xff);
+@@ -269,30 +248,6 @@
+ BT463_WRITE(par, BT463_REG_ACC, BT463_BLINK_MASK_2, 0x00);
+ BT463_WRITE(par, BT463_REG_ACC, BT463_BLINK_MASK_3, 0x00);
+
+- /* Fill the palette. */
+- BT463_LOAD_ADDR(par, 0x0000);
+- TGA_WRITE_REG(par, BT463_PALETTE<<2, TGA_RAMDAC_REG);
+-
+- for (i = 0; i < 16; i++) {
+- j = color_table[i];
+- TGA_WRITE_REG(par, default_red[j]|(BT463_PALETTE<<10),
+- TGA_RAMDAC_REG);
+- TGA_WRITE_REG(par, default_grn[j]|(BT463_PALETTE<<10),
+- TGA_RAMDAC_REG);
+- TGA_WRITE_REG(par, default_blu[j]|(BT463_PALETTE<<10),
+- TGA_RAMDAC_REG);
+- }
+- for (i = 0; i < 512*3; i += 4) {
+- TGA_WRITE_REG(par, 0x55|(BT463_PALETTE<<10),
+- TGA_RAMDAC_REG);
+- TGA_WRITE_REG(par, 0x00|(BT463_PALETTE<<10),
+- TGA_RAMDAC_REG);
+- TGA_WRITE_REG(par, 0x00|(BT463_PALETTE<<10),
+- TGA_RAMDAC_REG);
+- TGA_WRITE_REG(par, 0x00|(BT463_PALETTE<<10),
+- TGA_RAMDAC_REG);
+- }
+-
+ /* Fill window type table after start of vertical retrace. */
+ while (!(TGA_READ_REG(par, TGA_INTR_STAT_REG) & 0x01))
+ continue;
+@@ -316,6 +271,9 @@
+
+ }
+
++ /* Init the palette. */
++ fb_set_cmap(fb_default_cmap(16), info);
++
+ /* Finally, enable video scan (and pray for the monitor... :-) */
+ TGA_WRITE_REG(par, TGA_VALID_VIDEO, TGA_VALID_REG);
+
+@@ -511,16 +469,8 @@
+ * Acceleration.
+ */
+
+-/**
+- * tgafb_imageblit - REQUIRED function. Can use generic routines if
+- * non acclerated hardware and packed pixel based.
+- * Copies a image from system memory to the screen.
+- *
+- * @info: frame buffer structure that represents a single frame buffer
+- * @image: structure defining the image.
+- */
+ static void
+-tgafb_imageblit(struct fb_info *info, const struct fb_image *image)
++tgafb_mono_imageblit(struct fb_info *info, const struct fb_image *image)
+ {
+ static unsigned char const bitrev[256] = {
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+@@ -565,6 +515,17 @@
+ void __iomem *regs_base;
+ void __iomem *fb_base;
+
++ is8bpp = info->var.bits_per_pixel == 8;
++
++ /* For copies that aren't pixel expansion, there's little we
++ can do better than the generic code. */
++ /* ??? There is a DMA write mode; I wonder if that could be
++ made to pull the data from the image buffer... */
++ if (image->depth > 1) {
++ cfb_imageblit(info, image);
++ return;
++ }
++
+ dx = image->dx;
+ dy = image->dy;
+ width = image->width;
+@@ -582,18 +543,8 @@
+ if (dy + height > vyres)
+ height = vyres - dy;
+
+- /* For copies that aren't pixel expansion, there's little we
+- can do better than the generic code. */
+- /* ??? There is a DMA write mode; I wonder if that could be
+- made to pull the data from the image buffer... */
+- if (image->depth > 1) {
+- cfb_imageblit(info, image);
+- return;
+- }
+-
+ regs_base = par->tga_regs_base;
+ fb_base = par->tga_fb_base;
+- is8bpp = info->var.bits_per_pixel == 8;
+
+ /* Expand the color values to fill 32-bits. */
+ /* ??? Would be nice to notice colour changes elsewhere, so
+@@ -771,6 +722,86 @@
+ regs_base + TGA_MODE_REG);
+ }
+
++static void
++tgafb_clut_imageblit(struct fb_info *info, const struct fb_image *image)
++{
++ struct tga_par *par = (struct tga_par *) info->par;
++ u32 color, dx, dy, width, height, vxres, vyres;
++ u32 *palette = ((u32 *)info->pseudo_palette);
++ unsigned long pos, line_length;
++ unsigned long i, j;
++ const unsigned char *data;
++ void *regs_base, *fb_base;
++
++ dx = image->dx;
++ dy = image->dy;
++ width = image->width;
++ height = image->height;
++ vxres = info->var.xres_virtual;
++ vyres = info->var.yres_virtual;
++ line_length = info->fix.line_length;
++
++ /* Crop the image to the screen. */
++ if (dx > vxres || dy > vyres)
++ return;
++ if (dx + width > vxres)
++ width = vxres - dx;
++ if (dy + height > vyres)
++ height = vyres - dy;
++
++ regs_base = par->tga_regs_base;
++ fb_base = par->tga_fb_base;
++
++ pos = dy * line_length + (dx * 4);
++ data = image->data;
++
++ /* Now copy the image, color_expanding via the palette. */
++ for (i = 0; i < height; i++) {
++ for (j = 0; j < width; j++) {
++ color = palette[*data++];
++ __raw_writel(color, fb_base + pos + j*4);
++ }
++ pos += line_length;
++ }
++}
++
++/**
++ * tgafb_imageblit - REQUIRED function. Can use generic routines if
++ * non acclerated hardware and packed pixel based.
++ * Copies a image from system memory to the screen.
++ *
++ * @info: frame buffer structure that represents a single frame buffer
++ * @image: structure defining the image.
++ */
++static void
++tgafb_imageblit(struct fb_info *info, const struct fb_image *image)
++{
++ unsigned int is8bpp = info->var.bits_per_pixel == 8;
++
++ /* If a mono image, regardless of FB depth, go do it. */
++ if (image->depth == 1) {
++ tgafb_mono_imageblit(info, image);
++ return;
++ }
++
++ /* For copies that aren't pixel expansion, there's little we
++ can do better than the generic code. */
++ /* ??? There is a DMA write mode; I wonder if that could be
++ made to pull the data from the image buffer... */
++ if (image->depth == info->var.bits_per_pixel) {
++ cfb_imageblit(info, image);
++ return;
++ }
++
++ /* If 24-plane FB and the image is 8-plane with CLUT, we can do it. */
++ if (!is8bpp && image->depth == 8) {
++ tgafb_clut_imageblit(info, image);
++ return;
++ }
++
++ /* Silently return... */
++}
++
+ /**
+ * tgafb_fillrect - REQUIRED function. Can use generic routines if
+ * non acclerated hardware and packed pixel based.
+@@ -1369,6 +1400,31 @@
+ info->fix.ywrapstep = 0;
+
+ info->fix.accel = FB_ACCEL_DEC_TGA;
++
++ /*
++ * These are needed by fb_set_logo_truepalette(), so we
++ * set them here for 24-plane cards.
++ */
++ if (tga_type != TGA_TYPE_8PLANE) {
++ info->var.red.length = 8;
++ info->var.green.length = 8;
++ info->var.blue.length = 8;
++ info->var.red.offset = 16;
++ info->var.green.offset = 8;
++ info->var.blue.offset = 0;
++ }
++}
++
++static int tgafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
++{
++ /* We just use this to catch switches out of
++ * graphics mode.
++ */
++ tgafb_set_par(info); /* A bit of overkill for BASE_ADDR reset. */
++
++ if (var->xoffset || var->yoffset || var->vmode)
++ return -EINVAL;
++ return 0;
+ }
+
+ static __devinit int
+@@ -1381,17 +1437,13 @@
+ TGA_24PLUSZ_FB_OFFSET
+ };
+
+- struct all_info {
+- struct fb_info info;
+- struct tga_par par;
+- u32 pseudo_palette[16];
+- } *all;
+-
++ unsigned long bar0_start, bar0_len;
++ struct fb_info *info;
++ struct tga_par *par;
+ void __iomem *mem_base;
+- unsigned long bar0_start, bar0_len;
+- u8 tga_type;
+- int ret;
+-
++ u8 tga_type;
++ int ret;
++
+ /* Enable device in PCI config. */
+ if (pci_enable_device(pdev)) {
+ printk(KERN_ERR "tgafb: Cannot enable PCI device\n");
+@@ -1399,13 +1451,12 @@
+ }
+
+ /* Allocate the fb and par structures. */
+- all = kmalloc(sizeof(*all), GFP_KERNEL);
+- if (!all) {
++ info = framebuffer_alloc(sizeof(struct tga_par), &pdev->dev);
++ if (!info) {
+ printk(KERN_ERR "tgafb: Cannot allocate memory\n");
+ return -ENOMEM;
+ }
+- memset(all, 0, sizeof(*all));
+- pci_set_drvdata(pdev, all);
++ pci_set_drvdata(pdev, info);
+
+ /* Request the mem regions. */
+ bar0_start = pci_resource_start(pdev, 0);
+@@ -1425,24 +1476,22 @@
+
+ /* Grab info about the card. */
+ tga_type = (readl(mem_base) >> 12) & 0x0f;
+- all->par.pdev = pdev;
+- all->par.tga_mem_base = mem_base;
+- all->par.tga_fb_base = mem_base + fb_offset_presets[tga_type];
+- all->par.tga_regs_base = mem_base + TGA_REGS_OFFSET;
+- all->par.tga_type = tga_type;
+- pci_read_config_byte(pdev, PCI_REVISION_ID, &all->par.tga_chip_rev);
++ par = info->par;
++ par->tga_mem_base = mem_base;
++ par->tga_fb_base = mem_base + fb_offset_presets[tga_type];
++ par->tga_regs_base = mem_base + TGA_REGS_OFFSET;
++ par->tga_type = tga_type;
++ pci_read_config_byte(pdev, PCI_REVISION_ID, &par->tga_chip_rev);
+
+ /* Setup framebuffer. */
+- all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
+- FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_FILLRECT;
+- all->info.fbops = &tgafb_ops;
+- all->info.screen_base = all->par.tga_fb_base;
+- all->info.par = &all->par;
+- all->info.pseudo_palette = all->pseudo_palette;
++ info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
++ FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_FILLRECT;
++ info->fbops = &tgafb_ops;
++ info->screen_base = (char *) par->tga_fb_base;
+
+ /* This should give a reasonable default video mode. */
+
+- ret = fb_find_mode(&all->info.var, &all->info, mode_option,
++ ret = fb_find_mode(&info->var, info, mode_option,
+ NULL, 0, NULL,
+ tga_type == TGA_TYPE_8PLANE ? 8 : 32);
+ if (ret == 0 || ret == 4) {
+@@ -1497,7 +1545,7 @@
+ iounmap(par->tga_mem_base);
+ release_mem_region(pci_resource_start(pdev, 0),
+ pci_resource_len(pdev, 0));
+- kfree(info);
++ framebuffer_release(info);
+ }
+
+ static void __exit
+diff -uNr a/include/video/tgafb.h b/include/video/tgafb.h
+--- a/include/video/tgafb.h 2004-12-24 22:35:24.000000000 +0100
++++ b/include/video/tgafb.h 2005-01-25 12:41:44.717032536 +0100
+@@ -167,6 +167,8 @@
+
+ #define BT463_WINDOW_TYPE_BASE 0x0300
+
++#ifdef __KERNEL__
++
+ /*
+ * The framebuffer driver private data.
+ */
+@@ -234,5 +236,6 @@
+ TGA_WRITE_REG(par, m << 2, TGA_RAMDAC_SETUP_REG);
+ TGA_WRITE_REG(par, m << 10 | v, TGA_RAMDAC_REG);
+ }
++#endif /* __KERNEL__ */
+
+ #endif /* TGAFB_H */
+--- a/drivers/video/tgafb.c 2006-02-21 17:08:13.000000000 +0100
++++ b/drivers/video/tgafb.c 2006-02-21 17:28:46.000000000 +0100
+@@ -1498,40 +1498,39 @@
+ goto err1;
+ }
+
+- if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
++ if (fb_alloc_cmap(&info->cmap, 256, 0)) {
+ printk(KERN_ERR "tgafb: Could not allocate color map\n");
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+- tgafb_set_par(&all->info);
+- tgafb_init_fix(&all->info);
++ tgafb_init_fix(info);
+
+- all->info.device = &pdev->dev;
+- if (register_framebuffer(&all->info) < 0) {
++ info->device = &pdev->dev;
++ if (register_framebuffer(info) < 0) {
+ printk(KERN_ERR "tgafb: Could not register framebuffer\n");
+ ret = -EINVAL;
+ goto err1;
+ }
+
+ printk(KERN_INFO "tgafb: DC21030 [TGA] detected, rev=0x%02x\n",
+- all->par.tga_chip_rev);
++ par->tga_chip_rev);
+ printk(KERN_INFO "tgafb: at PCI bus %d, device %d, function %d\n",
+ pdev->bus->number, PCI_SLOT(pdev->devfn),
+ PCI_FUNC(pdev->devfn));
+ printk(KERN_INFO "fb%d: %s frame buffer device at 0x%lx\n",
+- all->info.node, all->info.fix.id, bar0_start);
++ info->node, info->fix.id, bar0_start);
+
+ return 0;
+
+ err1:
+ release_mem_region(bar0_start, bar0_len);
+ err0:
+- kfree(all);
++ framebuffer_release(info);
+ return ret;
+ }
+
+-static void __exit
++static void __devexit
+ tgafb_pci_unregister(struct pci_dev *pdev)
+ {
+ struct fb_info *info = pci_get_drvdata(pdev);
================================================================
More information about the pld-cvs-commit
mailing list