Skip to contentSkip to conversation

viafb: Add missing break statement in switch

PATCH New Harald Welte 1 participant 14 messages May 23, 2009 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/14 viafb: Add missing break statement in switch

From: Harald Welte <[email protected]>

---
 drivers/video/via/hw.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/video/via/hw.c +1 -0
index fcd53ce..59ddf09 100644
@@ -2272,6 +2272,7 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp,
 
 	case UNICHROME_CX700:
 		viafb_write_regx(CX700_ModeXregs, NUM_TOTAL_CX700_ModeXregs);
+		break;
 
 	case UNICHROME_VX800:
 		viafb_write_regx(VX800_ModeXregs, NUM_TOTAL_VX800_ModeXregs);
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#1 lore raw

PATCH 2/14 viafb: Add support for the VX855 chipset

From: Harald Welte <[email protected]>

This patch adds support for a new VIA integrated graphics chipset, the VX855.

---
 drivers/video/via/chip.h     |    3 +
 drivers/video/via/hw.c       |  207 ++++++++++++++++++++++++++++--------------
 drivers/video/via/hw.h       |   14 +++
 drivers/video/via/share.h    |   98 ++++++++++++++++++++
 drivers/video/via/viafbdev.c |    7 +-
 drivers/video/via/viamode.c  |   55 +++++++++++
 drivers/video/via/viamode.h  |    2 +
 7 files changed, 316 insertions(+), 70 deletions(-)
drivers/video/via/chip.h +3 -0
index dde95ed..03e90cf 100644
@@ -68,6 +68,9 @@
 #define     UNICHROME_VX800         11
 #define     UNICHROME_VX800_DID     0x1122
 
+#define     UNICHROME_VX855         12
+#define     UNICHROME_VX855_DID     0x5122
+
 /**************************************************/
 /* Definition TMDS Trasmitter Information         */
 /**************************************************/
drivers/video/via/hw.c +139 -68

296 lines not on this page · raw message

drivers/video/via/hw.h +14 -0
index 6ff38fa..22786a5 100644
@@ -335,6 +335,17 @@ is reserved, so it may have problem to set 1600x1200 on IGA2. */
 /* location: {CR94,0,6} */
 #define VX800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM     128
 
+/* For VT3409 */
+#define VX855_IGA1_FIFO_MAX_DEPTH               400
+#define VX855_IGA1_FIFO_THRESHOLD               320
+#define VX855_IGA1_FIFO_HIGH_THRESHOLD          320
+#define VX855_IGA1_DISPLAY_QUEUE_EXPIRE_NUM     160
+
+#define VX855_IGA2_FIFO_MAX_DEPTH               200
+#define VX855_IGA2_FIFO_THRESHOLD               160
+#define VX855_IGA2_FIFO_HIGH_THRESHOLD          160
+#define VX855_IGA2_DISPLAY_QUEUE_EXPIRE_NUM     320
+
 #define IGA1_FIFO_DEPTH_SELECT_REG_NUM          1
 #define IGA1_FIFO_THRESHOLD_REG_NUM             2
 #define IGA1_FIFO_HIGH_THRESHOLD_REG_NUM        2
@@ -716,6 +727,7 @@ struct pll_map {
 	u32 cle266_pll;
 	u32 k800_pll;
 	u32 cx700_pll;
+	u32 vx855_pll;
 };
 
 struct rgbLUT {
@@ -860,6 +872,8 @@ struct iga2_crtc_timing {
 #define P4M900_FUNCTION3    0x3364
 /* VT3353 chipset*/
 #define VX800_FUNCTION3     0x3353
+/* VT3409 chipset*/
+#define VX855_FUNCTION3     0x3409
 
 #define NUM_TOTAL_PLL_TABLE ARRAY_SIZE(pll_value)
 
drivers/video/via/share.h +98 -0

110 lines not on this page · raw message

drivers/video/via/viafbdev.c +5 -2
index a0fec29..02e7a72 100644
@@ -218,7 +218,8 @@ static int viafb_check_var(struct fb_var_screeninfo *var,
 	if (!info->par)
 		return -1;
 	p_viafb_par = (struct viafb_par *)info->par;
-	if (p_viafb_par->chip_info->gfx_chip_name == UNICHROME_VX800)
+	if (p_viafb_par->chip_info->gfx_chip_name == UNICHROME_VX800 ||
+	    p_viafb_par->chip_info->gfx_chip_name == UNICHROME_VX855)
 		var->accel_flags = 0;
 
 	return 0;
@@ -1162,8 +1163,10 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
 
 		if ((p_viafb_par->chip_info->gfx_chip_name ==
 			UNICHROME_CX700) ||
+			(p_viafb_par->chip_info->gfx_chip_name ==
+			UNICHROME_VX800) ||
 			((p_viafb_par->chip_info->gfx_chip_name ==
-			UNICHROME_VX800))) {
+			UNICHROME_VX855))) {
 			bg_col =
 			    (((info->cmap.red)[viacursor.image.bg_color] &
 			    0xFFC0) << 14) |
drivers/video/via/viamode.c +55 -0

61 lines not on this page · raw message

drivers/video/via/viamode.h +2 -0
index 1a5de50..3636694 100644
@@ -57,6 +57,7 @@ struct res_map_refresh {
 #define NUM_TOTAL_KM400_ModeXregs ARRAY_SIZE(KM400_ModeXregs)
 #define NUM_TOTAL_CX700_ModeXregs ARRAY_SIZE(CX700_ModeXregs)
 #define NUM_TOTAL_VX800_ModeXregs ARRAY_SIZE(VX800_ModeXregs)
+#define NUM_TOTAL_VX855_ModeXregs ARRAY_SIZE(VX855_ModeXregs)
 #define NUM_TOTAL_CLE266_ModeXregs ARRAY_SIZE(CLE266_ModeXregs)
 #define NUM_TOTAL_PATCH_MODE ARRAY_SIZE(res_patch_table)
 #define NUM_TOTAL_MODETABLE ARRAY_SIZE(CLE266Modes)
@@ -170,6 +171,7 @@ extern struct io_reg CN700_ModeXregs[66];
 extern struct io_reg KM400_ModeXregs[55];
 extern struct io_reg CX700_ModeXregs[58];
 extern struct io_reg VX800_ModeXregs[58];
+extern struct io_reg VX855_ModeXregs[52];
 extern struct io_reg CLE266_ModeXregs[32];
 extern struct io_reg PM1024x768[2];
 extern struct patch_table res_patch_table[1];
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#2 lore raw

PATCH 3/14 viafb: Fix various resource leaks during module_init()

From: Harald Welte <[email protected]>

The current code executed from module_init() in viafb does not have proper error checking and [partial] resoure release paths in case an error happens half way through driver initialization.

This patch adresses the most obvious of those issues, such as a leftover i2c bus if module_init (and thus module load) fails.

---
 drivers/video/via/viafbdev.c |   52 ++++++++++++++++++++++++++++++-----------
 1 files changed, 38 insertions(+), 14 deletions(-)
drivers/video/via/viafbdev.c +38 -14
index 02e7a72..72387d4 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
  * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
 
  * This program is free software; you can redistribute it and/or
@@ -2109,7 +2109,7 @@ static int __devinit via_pci_probe(void)
 	unsigned long default_xres, default_yres;
 	char *tmpc, *tmpm;
 	char *tmpc_sec, *tmpm_sec;
-	int vmode_index;
+	int rc, vmode_index;
 	u32 tmds_length, lvds_length, crt_length, chip_length, viafb_par_length;
 
 	DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
@@ -2130,7 +2130,7 @@ static int __devinit via_pci_probe(void)
 	tmds_length + crt_length + chip_length, NULL);
 	if (!viafbinfo) {
 		printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
-		return -ENODEV;
+		return -ENOMEM;
 	}
 
 	viaparinfo = (struct viafb_par *)viafbinfo->par;
@@ -2157,7 +2157,9 @@ static int __devinit via_pci_probe(void)
 		viafb_dual_fb = 0;
 
 	/* Set up I2C bus stuff */
-	viafb_create_i2c_bus(viaparinfo);
+	rc = viafb_create_i2c_bus(viaparinfo);
+	if (rc)
+		goto out_fb_release;
 
 	viafb_init_chip_info();
 	viafb_get_fb_info(&viaparinfo->fbmem, &viaparinfo->memsize);
@@ -2169,7 +2171,8 @@ static int __devinit via_pci_probe(void)
 
 	if (!viaparinfo->fbmem_virt) {
 		printk(KERN_INFO "ioremap failed\n");
-		return -1;
+		rc = -EIO;
+		goto out_delete_i2c;
 	}
 
 	viafb_get_mmio_info(&viaparinfo->mmio_base, &viaparinfo->mmio_len);
@@ -2281,8 +2284,7 @@ static int __devinit via_pci_probe(void)
 		if (!viafbinfo1) {
 			printk(KERN_ERR
 			"allocate the second framebuffer struct error\n");
-			framebuffer_release(viafbinfo);
-			return -ENOMEM;
+			goto out_delete_i2c;
 		}
 		viaparinfo1 = viafbinfo1->par;
 		memcpy(viaparinfo1, viaparinfo, viafb_par_length);
@@ -2343,21 +2345,26 @@ static int __devinit via_pci_probe(void)
 	viafb_update_viafb_par(viafbinfo);
 	viafb_update_fix(&viafbinfo->fix, viafbinfo);
 	default_var.activate = FB_ACTIVATE_NOW;
-	fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
+	rc = fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
+	if (rc)
+		goto out_fb1_release;
 
 	if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
 	    && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) {
-		if (register_framebuffer(viafbinfo1) < 0)
-			return -EINVAL;
+		rc = register_framebuffer(viafbinfo1);
+		if (rc)
+			goto out_dealloc_cmap;
 	}
-	if (register_framebuffer(viafbinfo) < 0)
-		return -EINVAL;
+	rc = register_framebuffer(viafbinfo);
+	if (rc)
+		goto out_fb1_unreg_lcd_cle266;
 
 	if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device)
 			|| (viaparinfo->chip_info->gfx_chip_name !=
 			UNICHROME_CLE266))) {
-		if (register_framebuffer(viafbinfo1) < 0)
-			return -EINVAL;
+		rc = register_framebuffer(viafbinfo1);
+		if (rc)
+			goto out_fb_unreg;
 	}
 	DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n",
 		  viafbinfo->node, viafbinfo->fix.id, default_var.xres,
@@ -2366,6 +2373,23 @@ static int __devinit via_pci_probe(void)
 	viafb_init_proc(&viaparinfo->proc_entry);
 	viafb_init_dac(IGA2);
 	return 0;
+
+out_fb_unreg:
+	unregister_framebuffer(viafbinfo);
+out_fb1_unreg_lcd_cle266:
+	if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
+            && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266))
+		unregister_framebuffer(viafbinfo1);
+out_dealloc_cmap:
+	fb_dealloc_cmap(&viafbinfo->cmap);
+out_fb1_release:
+	if (viafbinfo1)
+		framebuffer_release(viafbinfo1);
+out_delete_i2c:
+	viafb_delete_i2c_buss(viaparinfo);
+out_fb_release:
+	framebuffer_release(viafbinfo);
+	return rc;
 }
 
 static void __devexit via_pci_remove(void)
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#3 lore raw

PATCH 4/14 viafb: make viafb a first-class citizen using pci_driver

From: Harald Welte <[email protected]>

---
 drivers/video/via/hw.c       |  116 +++--------------------------------------
 drivers/video/via/hw.h       |    7 +--
 drivers/video/via/viafbdev.c |   65 ++++++++++++++++++++---
 3 files changed, 68 insertions(+), 120 deletions(-)
drivers/video/via/hw.c +9 -107
index b111b6c..6306c88 100644
@@ -21,22 +21,6 @@
 
 #include "global.h"
 
-static const struct pci_device_id_info pciidlist[] = {
-	{PCI_VIA_VENDOR_ID, UNICHROME_CLE266_DID, UNICHROME_CLE266},
-	{PCI_VIA_VENDOR_ID, UNICHROME_PM800_DID, UNICHROME_PM800},
-	{PCI_VIA_VENDOR_ID, UNICHROME_K400_DID, UNICHROME_K400},
-	{PCI_VIA_VENDOR_ID, UNICHROME_K800_DID, UNICHROME_K800},
-	{PCI_VIA_VENDOR_ID, UNICHROME_CN700_DID, UNICHROME_CN700},
-	{PCI_VIA_VENDOR_ID, UNICHROME_P4M890_DID, UNICHROME_P4M890},
-	{PCI_VIA_VENDOR_ID, UNICHROME_K8M890_DID, UNICHROME_K8M890},
-	{PCI_VIA_VENDOR_ID, UNICHROME_CX700_DID, UNICHROME_CX700},
-	{PCI_VIA_VENDOR_ID, UNICHROME_P4M900_DID, UNICHROME_P4M900},
-	{PCI_VIA_VENDOR_ID, UNICHROME_CN750_DID, UNICHROME_CN750},
-	{PCI_VIA_VENDOR_ID, UNICHROME_VX800_DID, UNICHROME_VX800},
-	{PCI_VIA_VENDOR_ID, UNICHROME_VX855_DID, UNICHROME_VX855},
-	{0, 0, 0}
-};
-
 struct offset offset_reg = {
 	/* IGA1 Offset Register */
 	{IGA1_OFFSET_REG_NUM, {{CR13, 0, 7}, {CR35, 5, 7} } },
@@ -549,7 +533,8 @@ static void set_dvi_output_path(int set_iga, int output_interface);
 static void set_lcd_output_path(int set_iga, int output_interface);
 static int search_mode_setting(int ModeInfoIndex);
 static void load_fix_bit_crtc_reg(void);
-static void init_gfx_chip_info(void);
+static void init_gfx_chip_info(struct pci_dev *pdev,
+				const struct pci_device_id *pdi);
 static void init_tmds_chip_info(void);
 static void init_lvds_chip_info(void);
 static void device_screen_off(void);
@@ -559,7 +544,6 @@ static void device_off(void);
 static void device_on(void);
 static void enable_second_display_channel(void);
 static void disable_second_display_channel(void);
-static int get_fb_size_from_pci(void);
 
 void viafb_write_reg(u8 index, u16 io_port, u8 data)
 {
@@ -1996,9 +1980,10 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
 
 }
 
-void viafb_init_chip_info(void)
+void viafb_init_chip_info(struct pci_dev *pdev,
+			  const struct pci_device_id *pdi)
 {
-	init_gfx_chip_info();
+	init_gfx_chip_info(pdev, pdi);
 	init_tmds_chip_info();
 	init_lvds_chip_info();
 
@@ -2071,24 +2056,12 @@ void viafb_update_device_setting(int hres, int vres,
 	}
 }
 
-static void init_gfx_chip_info(void)
+static void init_gfx_chip_info(struct pci_dev *pdev,
+			       const struct pci_device_id *pdi)
 {
-	struct pci_dev *pdev = NULL;
-	u32 i;
 	u8 tmp;
 
-	/* Indentify GFX Chip Name */
-	for (i = 0; pciidlist[i].vendor != 0; i++) {
-		pdev = pci_get_device(pciidlist[i].vendor,
-			pciidlist[i].device, 0);
-		if (pdev)
-			break;
-	}
-
-	if (!pciidlist[i].vendor)
-		return ;
-
-	viaparinfo->chip_info->gfx_chip_name = pciidlist[i].chip_index;
+	viaparinfo->chip_info->gfx_chip_name = pdi->driver_data;
 
 	/* Check revision of CLE266 Chip */
 	if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
@@ -2119,8 +2092,6 @@ static void init_gfx_chip_info(void)
 				CX700_REVISION_700;
 		}
 	}
-
-	pci_dev_put(pdev);
 }
 
 static void init_tmds_chip_info(void)
@@ -2612,38 +2583,6 @@ void viafb_crt_enable(void)
 	viafb_write_reg_mask(CR36, VIACR, 0x0, BIT5 + BIT4);
 }
 
-void viafb_get_mmio_info(unsigned long *mmio_base,
-	unsigned long *mmio_len)
-{
-	struct pci_dev *pdev = NULL;
-	u32 vendor, device;
-	u32 i;
-
-	for (i = 0; pciidlist[i].vendor != 0; i++)
-		if (viaparinfo->chip_info->gfx_chip_name ==
-			pciidlist[i].chip_index)
-			break;
-
-	if (!pciidlist[i].vendor)
-		return ;
-
-	vendor = pciidlist[i].vendor;
-	device = pciidlist[i].device;
-
-	pdev = pci_get_device(vendor, device, NULL);
-
-	if (!pdev) {
-		*mmio_base = 0;
-		*mmio_len = 0;
-		return ;
-	}
-
-	*mmio_base = pci_resource_start(pdev, 1);
-	*mmio_len = pci_resource_len(pdev, 1);
-
-	pci_dev_put(pdev);
-}
-
 static void enable_second_display_channel(void)
 {
 	/* to enable second display channel. */
@@ -2660,44 +2599,7 @@ static void disable_second_display_channel(void)
 	viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6);
 }
 
-void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len)
-{
-	struct pci_dev *pdev = NULL;
-	u32 vendor, device;
-	u32 i;
-
-	for (i = 0; pciidlist[i].vendor != 0; i++)
-		if (viaparinfo->chip_info->gfx_chip_name ==
-			pciidlist[i].chip_index)
-			break;
-
-	if (!pciidlist[i].vendor)
-		return ;
-
-	vendor = pciidlist[i].vendor;
-	device = pciidlist[i].device;
-
-	pdev = pci_get_device(vendor, device, NULL);
-
-	if (!pdev) {
-		*fb_base = viafb_read_reg(VIASR, SR30) << 24;
-		*fb_len = viafb_get_memsize();
-		DEBUG_MSG(KERN_INFO "Get FB info from SR30!\n");
-		DEBUG_MSG(KERN_INFO "fb_base = %08x\n", *fb_base);
-		DEBUG_MSG(KERN_INFO "fb_len = %08x\n", *fb_len);
-		return ;
-	}
-
-	*fb_base = (unsigned int)pci_resource_start(pdev, 0);
-	*fb_len = get_fb_size_from_pci();
-	DEBUG_MSG(KERN_INFO "Get FB info from PCI system!\n");
-	DEBUG_MSG(KERN_INFO "fb_base = %08x\n", *fb_base);
-	DEBUG_MSG(KERN_INFO "fb_len = %08x\n", *fb_len);
-
-	pci_dev_put(pdev);
-}
-
-static int get_fb_size_from_pci(void)
+int viafb_get_fb_size_from_pci(void)
 {
 	unsigned long configid, deviceid, FBSize = 0;
 	int VideoMemSize;
drivers/video/via/hw.h +3 -4
index 22786a5..1cd0648 100644
@@ -931,17 +931,16 @@ void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
 int viafb_setmode(int vmode_index, int hor_res, int ver_res,
 	    int video_bpp, int vmode_index1, int hor_res1,
 	    int ver_res1, int video_bpp1);
-void viafb_init_chip_info(void);
+void viafb_init_chip_info(struct pci_dev *pdev,
+			  const struct pci_device_id *pdi);
 void viafb_init_dac(int set_iga);
 int viafb_get_pixclock(int hres, int vres, int vmode_refresh);
 int viafb_get_refresh(int hres, int vres, u32 float_refresh);
 void viafb_update_device_setting(int hres, int vres, int bpp,
 			   int vmode_refresh, int flag);
-void viafb_get_mmio_info(unsigned long *mmio_base,
-	unsigned long *mmio_len);
 
+int viafb_get_fb_size_from_pci(void);
 void viafb_set_iga_path(void);
 void viafb_set_start_addr(void);
-void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len);
 
 #endif /* __HW_H__ */
drivers/video/via/viafbdev.c +56 -9

124 lines not on this page · raw message

Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#4 lore raw

PATCH 5/14 viafb: pass reference to pci device when calling framebuffer_alloc()

From: Harald Welte <[email protected]>

---
 drivers/video/via/viafbdev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/video/via/viafbdev.c +2 -1
index 3040dd9..7e8f2f6 100644
@@ -2128,7 +2128,8 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
 	 * variables
 	*/
 	viafbinfo = framebuffer_alloc(viafb_par_length + 2 * lvds_length +
-	tmds_length + crt_length + chip_length, NULL);
+				      tmds_length + crt_length + chip_length,
+				      &pdev->dev);
 	if (!viafbinfo) {
 		printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
 		return -ENOMEM;
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#5 lore raw

PATCH 6/14 viafb: use proper pci config API

From: Harald Welte <[email protected]>

This patch alters viafb to use the proper Linux in-kernel API to access PCI configuration space, rather than poking at I/O ports by itself.

---
 drivers/video/via/hw.c |   64 +++++++++++++++++++++++++++++------------------
 drivers/video/via/hw.h |    4 +-
 2 files changed, 41 insertions(+), 27 deletions(-)
drivers/video/via/hw.c +39 -25
index 6306c88..40b7c0c 100644
@@ -2599,24 +2599,37 @@ static void disable_second_display_channel(void)
 	viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6);
 }
 
+static u_int16_t via_function3[] = {
+	CLE266_FUNCTION3, KM400_FUNCTION3, CN400_FUNCTION3, CN700_FUNCTION3,
+	CX700_FUNCTION3, KM800_FUNCTION3, KM890_FUNCTION3, P4M890_FUNCTION3,
+	P4M900_FUNCTION3, VX800_FUNCTION3, VX855_FUNCTION3,
+};
+
+/* Get the BIOS-configured framebuffer size from PCI configuration space
+ * of function 3 in the respective chipset */
 int viafb_get_fb_size_from_pci(void)
 {
-	unsigned long configid, deviceid, FBSize = 0;
-	int VideoMemSize;
-	int DeviceFound = false;
-
-	for (configid = 0x80000000; configid < 0x80010800; configid += 0x100) {
-		outl(configid, (unsigned long)0xCF8);
-		deviceid = (inl((unsigned long)0xCFC) >> 16) & 0xffff;
-
-		switch (deviceid) {
-		case CLE266:
-		case KM400:
-			outl(configid + 0xE0, (unsigned long)0xCF8);
-			FBSize = inl((unsigned long)0xCFC);
-			DeviceFound = true;	/* Found device id */
-			break;
+	int i;
+	u_int8_t offset = 0;
+	u_int32_t FBSize;
+	u_int32_t VideoMemSize;
+
+	/* search for the "FUNCTION3" device in this chipset */
+	for (i = 0; i < ARRAY_SIZE(via_function3); i++) {
+		struct pci_dev *pdev;
+
+		pdev = pci_get_device(PCI_VENDOR_ID_VIA, via_function3[i],
+				      NULL);
+		if (!pdev)
+			continue;
+
+		DEBUG_MSG(KERN_INFO "Device ID = %x\n", pdev->device);
 
+		switch (pdev->device) {
+		case CLE266_FUNCTION3:
+		case KM400_FUNCTION3:
+			offset = 0xE0;
+			break;
 		case CN400_FUNCTION3:
 		case CN700_FUNCTION3:
 		case CX700_FUNCTION3:
@@ -2626,21 +2639,22 @@ int viafb_get_fb_size_from_pci(void)
 		case P4M900_FUNCTION3:
 		case VX800_FUNCTION3:
 		case VX855_FUNCTION3:
-			/*case CN750_FUNCTION3: */
-			outl(configid + 0xA0, (unsigned long)0xCF8);
-			FBSize = inl((unsigned long)0xCFC);
-			DeviceFound = true;	/* Found device id */
-			break;
-
-		default:
+		/*case CN750_FUNCTION3: */
+			offset = 0xA0;
 			break;
 		}
-
-		if (DeviceFound)
+		
+		if (!offset)
 			break;
+
+		pci_read_config_dword(pdev, offset, &FBSize);
+		pci_dev_put(pdev);
 	}
 
-	DEBUG_MSG(KERN_INFO "Device ID = %lx\n", deviceid);
+	if (!offset) {
+		printk(KERN_ERR "cannot determine framebuffer size\n");
+		return -EIO;
+	}
 
 	FBSize = FBSize & 0x00007000;
 	DEBUG_MSG(KERN_INFO "FB Size = %x\n", FBSize);
drivers/video/via/hw.h +2 -2
index 1cd0648..a69e907 100644
@@ -850,8 +850,8 @@ struct iga2_crtc_timing {
 };
 
 /* device ID */
-#define CLE266              0x3123
-#define KM400               0x3205
+#define CLE266_FUNCTION3    0x3123
+#define KM400_FUNCTION3     0x3205
 #define CN400_FUNCTION2     0x2259
 #define CN400_FUNCTION3     0x3259
 /* support VT3314 chipset */
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#6 lore raw

PATCH 7/14 viafb: get rid of some duplicated fields in private structure

From: Harald Welte <[email protected]>

Instead of using private structure members, we use the standard ones:
* viapar->fbmem converted to fb_info->fix.smem_start
* viapar->memsize is converted to fb_info->fix.smem_len
* viapar->fbmem_virt is convereted to fb_info->screen_base

---
 drivers/video/via/global.c   |    1 -
 drivers/video/via/hw.c       |    2 +-
 drivers/video/via/viafbdev.c |   47 +++++++++++++++++++----------------------
 drivers/video/via/viafbdev.h |    3 --
 4 files changed, 23 insertions(+), 30 deletions(-)
drivers/video/via/global.c +0 -1
index 468be24..2b7d0d3 100644
@@ -57,4 +57,3 @@ struct fb_info *viafbinfo;
 struct fb_info *viafbinfo1;
 struct viafb_par *viaparinfo;
 struct viafb_par *viaparinfo1;
-
drivers/video/via/hw.c +1 -1
index 40b7c0c..e06d6b7 100644
@@ -680,7 +680,7 @@ void viafb_set_start_addr(void)
 				size = 8 * 1024 * 1024;
 		} else {
 
-			size = viaparinfo1->memsize;
+			size = viafbinfo1->fix.smem_len;
 		}
 		offset = viafb_second_offset;
 		DEBUG_MSG(KERN_INFO
drivers/video/via/viafbdev.c +22 -25

119 lines not on this page · raw message

drivers/video/via/viafbdev.h +0 -3
index a4158e8..ed4129e 100644
@@ -45,10 +45,7 @@ struct viafb_par {
 	u32 xoffset;
 	u32 yoffset;
 
-	void __iomem *fbmem_virt;	/*framebuffer virtual memory address */
 	void __iomem *io_virt;	/*iospace virtual memory address */
-	unsigned int fbmem;	/*framebuffer physical memory address */
-	unsigned int memsize;	/*size of fbmem */
 	unsigned int io;	/*io space address */
 	unsigned long mmio_base;	/*mmio base address */
 	unsigned long mmio_len;	/*mmio base length */
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#7 lore raw

PATCH 8/14 viafb: Remove MMIO from private structure

From: Harald Welte <[email protected]>

Rather than using our own private structure members for MMIO base and length, we use the fb_info->fix ones.

---
 drivers/video/via/viafbdev.c |   11 ++++-------
 drivers/video/via/viafbdev.h |    2 --
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/video/via/viafbdev.c +4 -7
index 3c4651c..a8bfc0a 100644
@@ -122,9 +122,6 @@ static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
 	strcpy(fix->id, viafb_name);
 
 	fix->smem_len = viaparinfo->fbmem_free;
-	fix->mmio_start = viaparinfo->mmio_base;
-	fix->mmio_len = viaparinfo->mmio_len;
-
 	fix->type = FB_TYPE_PACKED_PIXELS;
 	fix->type_aux = 0;
 
@@ -2175,10 +2172,10 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
 		goto out_delete_i2c;
 	}
 
-	viaparinfo->mmio_base = pci_resource_start(pdev, 1);
-	viaparinfo->mmio_len = pci_resource_len(pdev, 1);
-	viaparinfo->io_virt = ioremap_nocache(viaparinfo->mmio_base,
-		viaparinfo->mmio_len);
+	viafbinfo->fix.mmio_start = pci_resource_start(pdev, 1);
+	viafbinfo->fix.mmio_len = pci_resource_len(pdev, 1);
+	viaparinfo->io_virt = ioremap_nocache(viafbinfo->fix.mmio_start,
+					      viafbinfo->fix.mmio_len);
 	if (!viaparinfo->io_virt) {
 		printk(KERN_ERR "ioremap of MMIO failed\n");
 		rc = -EIO;
drivers/video/via/viafbdev.h +0 -2
index ed4129e..0c1d734 100644
@@ -47,8 +47,6 @@ struct viafb_par {
 
 	void __iomem *io_virt;	/*iospace virtual memory address */
 	unsigned int io;	/*io space address */
-	unsigned long mmio_base;	/*mmio base address */
-	unsigned long mmio_len;	/*mmio base length */
 	u32 fbmem_free;		/* Free FB memory */
 	u32 fbmem_used;		/* Use FB memory size */
 	u32 cursor_start;	/* Cursor Start Address */
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#8 lore raw

PATCH 9/14 viafb: make module parameters visible in sysfs

From: Harald Welte <[email protected]>

---
 drivers/video/via/viafbdev.c |   45 +++++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 22 deletions(-)
drivers/video/via/viafbdev.c +23 -22
index a8bfc0a..2e93f71 100644
@@ -20,6 +20,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/stat.h>
 #define _MASTER_FILE
 
 #include "global.h"
@@ -2570,82 +2571,82 @@ module_init(viafb_init);
 module_exit(viafb_exit);
 
 #ifdef MODULE
-module_param(viafb_memsize, int, 0);
+module_param(viafb_memsize, int, S_IRUSR);
 
-module_param(viafb_mode, charp, 0);
+module_param(viafb_mode, charp, S_IRUSR);
 MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)");
 
-module_param(viafb_mode1, charp, 0);
+module_param(viafb_mode1, charp, S_IRUSR);
 MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)");
 
-module_param(viafb_bpp, int, 0);
+module_param(viafb_bpp, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)");
 
-module_param(viafb_bpp1, int, 0);
+module_param(viafb_bpp1, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)");
 
-module_param(viafb_refresh, int, 0);
+module_param(viafb_refresh, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_refresh,
 	"Set CRT viafb_refresh rate (default = 60)");
 
-module_param(viafb_refresh1, int, 0);
+module_param(viafb_refresh1, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_refresh1,
 	"Set CRT refresh rate (default = 60)");
 
-module_param(viafb_lcd_panel_id, int, 0);
+module_param(viafb_lcd_panel_id, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_lcd_panel_id,
 	"Set Flat Panel type(Default=1024x768)");
 
-module_param(viafb_lcd_dsp_method, int, 0);
+module_param(viafb_lcd_dsp_method, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_lcd_dsp_method,
 	"Set Flat Panel display scaling method.(Default=Expandsion)");
 
-module_param(viafb_SAMM_ON, int, 0);
+module_param(viafb_SAMM_ON, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_SAMM_ON,
 	"Turn on/off flag of SAMM(Default=OFF)");
 
-module_param(viafb_accel, int, 0);
+module_param(viafb_accel, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_accel,
 	"Set 2D Hardware Acceleration.(Default = OFF)");
 
-module_param(viafb_active_dev, charp, 0);
+module_param(viafb_active_dev, charp, S_IRUSR);
 MODULE_PARM_DESC(viafb_active_dev, "Specify active devices.");
 
-module_param(viafb_display_hardware_layout, int, 0);
+module_param(viafb_display_hardware_layout, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_display_hardware_layout,
 	"Display Hardware Layout (LCD Only, DVI Only...,etc)");
 
-module_param(viafb_second_size, int, 0);
+module_param(viafb_second_size, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_second_size,
 	"Set secondary device memory size");
 
-module_param(viafb_dual_fb, int, 0);
+module_param(viafb_dual_fb, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_dual_fb,
 	"Turn on/off flag of dual framebuffer devices.(Default = OFF)");
 
-module_param(viafb_platform_epia_dvi, int, 0);
+module_param(viafb_platform_epia_dvi, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_platform_epia_dvi,
 	"Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
 
-module_param(viafb_device_lcd_dualedge, int, 0);
+module_param(viafb_device_lcd_dualedge, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_device_lcd_dualedge,
 	"Turn on/off flag of dual edge panel.(Default = OFF)");
 
-module_param(viafb_bus_width, int, 0);
+module_param(viafb_bus_width, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_bus_width,
 	"Set bus width of panel.(Default = 12)");
 
-module_param(viafb_lcd_mode, int, 0);
+module_param(viafb_lcd_mode, int, S_IRUSR);
 MODULE_PARM_DESC(viafb_lcd_mode,
 	"Set Flat Panel mode(Default=OPENLDI)");
 
-module_param(viafb_video_dev, charp, 0);
+module_param(viafb_video_dev, charp, S_IRUSR);
 MODULE_PARM_DESC(viafb_video_dev, "Specify video devices.");
 
-module_param(viafb_lcd_port, charp, 0);
+module_param(viafb_lcd_port, charp, S_IRUSR);
 MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port.");
 
-module_param(viafb_dvi_port, charp, 0);
+module_param(viafb_dvi_port, charp, S_IRUSR);
 MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port.");
 
 MODULE_LICENSE("GPL");
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#9 lore raw

PATCH 10/14 viafb: clean up duplicated code from 2D acceleration

From: Harald Welte <[email protected]>

There are four parts of the viafb code who initialize the bitblit screen base and pitch, some of them actually broken. This patch unifies them in one function called viafb_set_2d_mode() which replaces and enhances the old function to just set the bpp.

---
 drivers/video/via/accel.c    |   35 ++++++++++++-----------
 drivers/video/via/accel.h    |    2 +-
 drivers/video/via/viafbdev.c |   62 +++++-------------------------------------
 3 files changed, 26 insertions(+), 73 deletions(-)
drivers/video/via/accel.c +18 -17
index 45c54bf..4a1183f 100644
@@ -191,26 +191,18 @@ void viafb_init_2d_engine(void)
 		}
 	}
 
-	viafb_set_2d_color_depth(viaparinfo->bpp);
-
-	writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_DSTBASE);
-
-	writel(VIA_PITCH_ENABLE |
-		   (((viaparinfo->hres *
-		      viaparinfo->bpp >> 3) >> 3) | (((viaparinfo->hres *
-						   viaparinfo->
-						   bpp >> 3) >> 3) << 16)),
-					viaparinfo->io_virt + VIA_REG_PITCH);
+	viafb_set_2d_mode(viafbinfo);
 }
 
-void viafb_set_2d_color_depth(int bpp)
+/* Set the mode-specific parameters for the 2D acceleration, such as
+ * BPP, source and destination base, as well as pitch */
+void viafb_set_2d_mode(struct fb_info *info)
 {
-	u32 dwGEMode;
+	u32 dwGEMode, pitch, pitch_reg, base;
 
+	/* Set BPP */
 	dwGEMode = readl(viaparinfo->io_virt + 0x04) & 0xFFFFFCFF;
-
-	switch (bpp) {
+	switch (viaparinfo->bpp) {
 	case 16:
 		dwGEMode |= VIA_GEM_16bpp;
 		break;
@@ -221,9 +213,18 @@ void viafb_set_2d_color_depth(int bpp)
 		dwGEMode |= VIA_GEM_8bpp;
 		break;
 	}
-
-	/* Set BPP and Pitch */
 	writel(dwGEMode, viaparinfo->io_virt + VIA_REG_GEMODE);
+
+	/* Set source and destination base */
+	base = ((void *)info->screen_base - viafb_FB_MM);
+	writel(base >> 3, viaparinfo->io_virt + VIA_REG_SRCBASE);
+	writel(base >> 3, viaparinfo->io_virt + VIA_REG_DSTBASE);
+
+	/* Set source and destination pitch (128bit aligned) */
+	pitch = (viaparinfo->hres * viaparinfo->bpp >> 3) >> 3;
+	pitch_reg = pitch | (pitch << 16);
+	pitch_reg |= VIA_PITCH_ENABLE;
+	writel(pitch_reg, viaparinfo->io_virt + VIA_REG_PITCH);
 }
 
 void viafb_hw_cursor_init(void)
drivers/video/via/accel.h +1 -1
index 29bf854..bef3134 100644
@@ -161,7 +161,7 @@
 
 void viafb_init_accel(void);
 void viafb_init_2d_engine(void);
-void set_2d_color_depth(int);
+void viafb_set_2d_mode(struct fb_info *info);
 void viafb_hw_cursor_init(void);
 void viafb_show_hw_cursor(struct fb_info *info, int Status); int
 viafb_wait_engine_idle(void); void viafb_set_2d_color_depth(int bpp);
drivers/video/via/viafbdev.c +7 -55

104 lines not on this page · raw message

Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#10 lore raw

PATCH 11/14 viafb: introduce wrapper for 2D engine registers

From: Harald Welte <[email protected]>

This is required as preparation for supporting the new M1 engine of the VX800/VX855 which has registers at permutated addresses.

---
 drivers/video/via/accel.c    |   13 +++++++++----
 drivers/video/via/accel.h    |    1 +
 drivers/video/via/viafbdev.c |   38 +++++++++++++++++---------------------
 3 files changed, 27 insertions(+), 25 deletions(-)
drivers/video/via/accel.c +9 -4
index 4a1183f..c3af95f 100644
@@ -20,6 +20,11 @@
  */
 #include "global.h"
 
+void viafb_2d_writel(u_int32_t val, u_int32_t reg)
+{
+	writel(val, viaparinfo->io_virt + reg);
+}
+
 void viafb_init_accel(void)
 {
 	viaparinfo->fbmem_free -= CURSOR_SIZE;
@@ -213,18 +218,18 @@ void viafb_set_2d_mode(struct fb_info *info)
 		dwGEMode |= VIA_GEM_8bpp;
 		break;
 	}
-	writel(dwGEMode, viaparinfo->io_virt + VIA_REG_GEMODE);
+	viafb_2d_writel(dwGEMode, VIA_REG_GEMODE);
 
 	/* Set source and destination base */
 	base = ((void *)info->screen_base - viafb_FB_MM);
-	writel(base >> 3, viaparinfo->io_virt + VIA_REG_SRCBASE);
-	writel(base >> 3, viaparinfo->io_virt + VIA_REG_DSTBASE);
+	viafb_2d_writel(base >> 3, VIA_REG_SRCBASE);
+	viafb_2d_writel(base >> 3, VIA_REG_DSTBASE);
 
 	/* Set source and destination pitch (128bit aligned) */
 	pitch = (viaparinfo->hres * viaparinfo->bpp >> 3) >> 3;
 	pitch_reg = pitch | (pitch << 16);
 	pitch_reg |= VIA_PITCH_ENABLE;
-	writel(pitch_reg, viaparinfo->io_virt + VIA_REG_PITCH);
+	viafb_2d_writel(pitch_reg, VIA_REG_PITCH);
 }
 
 void viafb_hw_cursor_init(void)
drivers/video/via/accel.h +1 -0
index bef3134..5081ac2 100644
@@ -159,6 +159,7 @@
 
 #define MAXLOOP                 0xFFFFFF
 
+void viafb_2d_writel(u_int32_t val, u_int32_t reg);
 void viafb_init_accel(void);
 void viafb_init_2d_engine(void);
 void viafb_set_2d_mode(struct fb_info *info);
drivers/video/via/viafbdev.c +17 -21
index fbc0da4..7d0c8ee 100644
@@ -899,16 +899,14 @@ static void viafb_fillrect(struct fb_info *info,
 	viafb_set_2d_mode(info);
 
 	/* BitBlt Destination Address */
-	writel(((rect->dy << 16) | rect->dx),
-		viaparinfo->io_virt + VIA_REG_DSTPOS);
+	viafb_2d_writel(((rect->dy << 16) | rect->dx), VIA_REG_DSTPOS);
 	/* Dimension: width & height */
-	writel((((rect->height - 1) << 16) | (rect->width - 1)),
-		viaparinfo->io_virt + VIA_REG_DIMENSION);
+	viafb_2d_writel((((rect->height - 1) << 16) | (rect->width - 1)),
+			VIA_REG_DIMENSION);
 	/* Forground color or Destination color */
-	writel(col, viaparinfo->io_virt + VIA_REG_FGCOLOR);
+	viafb_2d_writel(col, VIA_REG_FGCOLOR);
 	/* GE Command */
-	writel((0x01 | 0x2000 | (rop << 24)),
-		viaparinfo->io_virt + VIA_REG_GECMD);
+	viafb_2d_writel((0x01 | 0x2000 | (rop << 24)), VIA_REG_GECMD);
 
 }
 
@@ -943,15 +941,14 @@ static void viafb_copyarea(struct fb_info *info,
 	viafb_set_2d_mode(info);
 
 	/* BitBlt Source Address */
-	writel(((sy << 16) | sx), viaparinfo->io_virt + VIA_REG_SRCPOS);
+	viafb_2d_writel(((sy << 16) | sx), VIA_REG_SRCPOS);
 	/* BitBlt Destination Address */
-	writel(((dy << 16) | dx), viaparinfo->io_virt + VIA_REG_DSTPOS);
+	viafb_2d_writel(((dy << 16) | dx), VIA_REG_DSTPOS);
 	/* Dimension: width & height */
-	writel((((area->height - 1) << 16) | (area->width - 1)),
-		   viaparinfo->io_virt + VIA_REG_DIMENSION);
+	viafb_2d_writel((((area->height - 1) << 16) | (area->width - 1)),
+			VIA_REG_DIMENSION);
 	/* GE Command */
-	writel((0x01 | direction | (0xCC << 24)),
-		viaparinfo->io_virt + VIA_REG_GECMD);
+	viafb_2d_writel((0x01 | direction | (0xCC << 24)), VIA_REG_GECMD);
 
 }
 
@@ -987,19 +984,18 @@ static void viafb_imageblit(struct fb_info *info,
 	viafb_set_2d_mode(info);
 
 	/* BitBlt Source Address */
-	writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
+	viafb_2d_writel(0x0, VIA_REG_SRCPOS);
 	/* BitBlt Destination Address */
-	writel(((image->dy << 16) | image->dx),
-		viaparinfo->io_virt + VIA_REG_DSTPOS);
+	viafb_2d_writel(((image->dy << 16) | image->dx), VIA_REG_DSTPOS);
 	/* Dimension: width & height */
-	writel((((image->height - 1) << 16) | (image->width - 1)),
-		   viaparinfo->io_virt + VIA_REG_DIMENSION);
+	viafb_2d_writel((((image->height - 1) << 16) | (image->width - 1)),
+			VIA_REG_DIMENSION);
 	/* fb color */
-	writel(fg_col, viaparinfo->io_virt + VIA_REG_FGCOLOR);
+	viafb_2d_writel(fg_col, VIA_REG_FGCOLOR);
 	/* bg color */
-	writel(bg_col, viaparinfo->io_virt + VIA_REG_BGCOLOR);
+	viafb_2d_writel(bg_col, VIA_REG_BGCOLOR);
 	/* GE Command */
-	writel(0xCC020142, viaparinfo->io_virt + VIA_REG_GECMD);
+	viafb_2d_writel(0xCC020142, VIA_REG_GECMD);
 
 	for (i = 0; i < size / 4; i++) {
 		writel(*udata, viaparinfo->io_virt + VIA_MMIO_BLTBASE);
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#11 lore raw

PATCH 12/14 viafb: initialize 2D engine registers from loop

From: Harald Welte <[email protected]>

We don't need to unroll the register initialization routine when initializing the 2D engine registers

---
 drivers/video/via/accel.c |   18 +++---------------
 1 files changed, 3 insertions(+), 15 deletions(-)
drivers/video/via/accel.c +3 -15
index c3af95f..b3a414e 100644
@@ -41,23 +41,11 @@ void viafb_init_2d_engine(void)
 {
 	u32 dwVQStartAddr, dwVQEndAddr;
 	u32 dwVQLen, dwVQStartL, dwVQEndL, dwVQStartEndH;
+	int i;
 
 	/* init 2D engine regs to reset 2D engine */
-	writel(0x0, viaparinfo->io_virt + VIA_REG_GEMODE);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_DSTPOS);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_DIMENSION);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_PATADDR);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_FGCOLOR);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_BGCOLOR);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_CLIPTL);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_CLIPBR);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_OFFSET);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_KEYCONTROL);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_DSTBASE);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_PITCH);
-	writel(0x0, viaparinfo->io_virt + VIA_REG_MONOPAT1);
+	for (i = 0; i <= 0x40; i+= 4)
+		writel(0x0, viaparinfo->io_virt + i);
 
 	/* Init AGP and VQ regs */
 	switch (viaparinfo->chip_info->gfx_chip_name) {
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#12 lore raw

PATCH 13/14 viafb: Determine type of 2D engine and store it in chip_info

From: Harald Welte <[email protected]>

This will help us for the upcoming support for 2D acceleration using the M1 engine.

---
 drivers/video/via/chip.h     |    8 ++++++++
 drivers/video/via/hw.c       |   15 +++++++++++++++
 drivers/video/via/viafbdev.c |    3 +--
 3 files changed, 24 insertions(+), 2 deletions(-)
drivers/video/via/chip.h +8 -0
index 03e90cf..7f4bf73 100644
@@ -122,10 +122,18 @@ struct lvds_chip_information {
 	int i2c_port;
 };
 
+/* The type of 2D engine */
+enum via_2d_engine {
+	VIA_2D_ENG_H2,
+	VIA_2D_ENG_H5,
+	VIA_2D_ENG_M1,
+};
+
 struct chip_information {
 	int gfx_chip_name;
 	int gfx_chip_revision;
 	int chip_on_slot;
+	enum via_2d_engine twod_engine;
 	struct tmds_chip_information tmds_chip_info;
 	struct lvds_chip_information lvds_chip_info;
 	struct lvds_chip_information lvds_chip_info2;
drivers/video/via/hw.c +15 -0
index e06d6b7..e14b852 100644
@@ -2092,6 +2092,21 @@ static void init_gfx_chip_info(struct pci_dev *pdev,
 				CX700_REVISION_700;
 		}
 	}
+
+	/* Determine which 2D engine we have */
+	switch (viaparinfo->chip_info->gfx_chip_name) {
+	case UNICHROME_VX800:
+	case UNICHROME_VX855:
+		viaparinfo->chip_info->twod_engine = VIA_2D_ENG_M1;
+		break;
+	case UNICHROME_K8M890:
+	case UNICHROME_P4M900:
+		viaparinfo->chip_info->twod_engine = VIA_2D_ENG_H5;
+		break;
+	default:
+		viaparinfo->chip_info->twod_engine = VIA_2D_ENG_H2;
+		break;
+	}
 }
 
 static void init_tmds_chip_info(void)
drivers/video/via/viafbdev.c +1 -2
index 7d0c8ee..1357034 100644
@@ -214,8 +214,7 @@ static int viafb_check_var(struct fb_var_screeninfo *var,
 	if (!info->par)
 		return -1;
 	p_viafb_par = (struct viafb_par *)info->par;
-	if (p_viafb_par->chip_info->gfx_chip_name == UNICHROME_VX800 ||
-	    p_viafb_par->chip_info->gfx_chip_name == UNICHROME_VX855)
+	if (p_viafb_par->chip_info->twod_engine == VIA_2D_ENG_M1)
 		var->accel_flags = 0;
 
 	return 0;
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
#13 lore raw

PATCH 14/14 viafb: Add support for 2D accelerated framebuffer on VX800/VX855

From: Harald Welte <[email protected]>

The VX800/VX820 and the VX855/VX875 chipsets have a different 2D acceleration engine called "M1". The M1 engine has some subtle (and some not-so-subtle) differences to the previous engines, so support for accelerated framebuffer on those chipsets was disabled so far.

This patch adds full support for the M1 engine to viafb.

---
 drivers/video/via/accel.c    |   72 ++++++++++++++++++++++++++++++++++++-----
 drivers/video/via/accel.h    |   40 +++++++++++++++++++++++
 drivers/video/via/viafbdev.c |    2 -
 3 files changed, 103 insertions(+), 11 deletions(-)
drivers/video/via/accel.c +63 -9
index b3a414e..a4b66be 100644
@@ -20,8 +20,34 @@
  */
 #include "global.h"
 
+/* Somehow, the M1 engine has the registers in slightly different
+ * locations than previous 2D acceleration engines */
+static u_int8_t via_m1_eng_reg[] = {
+	[VIA_REG_GECMD]		= VIA_REG_GECMD_M1,
+	[VIA_REG_GEMODE]	= VIA_REG_GEMODE_M1,
+	[VIA_REG_SRCPOS]	= VIA_REG_SRCPOS_M1,
+	[VIA_REG_DSTPOS]	= VIA_REG_DSTPOS_M1,
+	[VIA_REG_DIMENSION]	= VIA_REG_DIMENSION_M1,
+	[VIA_REG_PATADDR]	= VIA_REG_PATADDR_M1,
+	[VIA_REG_FGCOLOR]	= VIA_REG_FGCOLOR_M1,
+	[VIA_REG_BGCOLOR]	= VIA_REG_BGCOLOR_M1,
+	[VIA_REG_CLIPTL]	= VIA_REG_CLIPTL_M1,
+	[VIA_REG_CLIPBR]	= VIA_REG_CLIPBR_M1,
+	[VIA_REG_OFFSET]	= VIA_REG_OFFSET_M1,
+	[VIA_REG_KEYCONTROL]	= VIA_REG_KEYCONTROL_M1,
+	[VIA_REG_SRCBASE]	= VIA_REG_SRCBASE_M1,
+	[VIA_REG_DSTBASE]	= VIA_REG_DSTBASE_M1,
+	[VIA_REG_PITCH]		= VIA_REG_PITCH_M1,
+	[VIA_REG_MONOPAT0]	= VIA_REG_MONOPAT0_M1,
+	[VIA_REG_MONOPAT1]	= VIA_REG_MONOPAT1_M1,
+};
+
 void viafb_2d_writel(u_int32_t val, u_int32_t reg)
 {
+	if (viaparinfo->chip_info->twod_engine == VIA_2D_ENG_M1 &&
+	    reg < ARRAY_SIZE(via_m1_eng_reg))
+		reg = via_m1_eng_reg[reg];
+
 	writel(val, viaparinfo->io_virt + reg);
 }
 
@@ -41,16 +67,26 @@ void viafb_init_2d_engine(void)
 {
 	u32 dwVQStartAddr, dwVQEndAddr;
 	u32 dwVQLen, dwVQStartL, dwVQEndL, dwVQStartEndH;
-	int i;
+	int i, highest_reg;
 
 	/* init 2D engine regs to reset 2D engine */
-	for (i = 0; i <= 0x40; i+= 4)
+	switch (viaparinfo->chip_info->twod_engine) {
+	case VIA_2D_ENG_M1:
+		highest_reg = 0x5c;
+		break;
+	default:
+		highest_reg = 0x40;
+		break;
+	}
+	for (i = 0; i <= highest_reg; i+= 4)
 		writel(0x0, viaparinfo->io_virt + i);
 
 	/* Init AGP and VQ regs */
 	switch (viaparinfo->chip_info->gfx_chip_name) {
 	case UNICHROME_K8M890:
 	case UNICHROME_P4M900:
+	case UNICHROME_VX800:
+	case UNICHROME_VX855:
 		writel(0x00100000, viaparinfo->io_virt + VIA_REG_CR_TRANSET);
 		writel(0x680A0000, viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
 		writel(0x02000000, viaparinfo->io_virt + VIA_REG_CR_TRANSPACE);
@@ -85,6 +121,8 @@ void viafb_init_2d_engine(void)
 		switch (viaparinfo->chip_info->gfx_chip_name) {
 		case UNICHROME_K8M890:
 		case UNICHROME_P4M900:
+		case UNICHROME_VX800:
+		case UNICHROME_VX855:
 			dwVQStartL |= 0x20000000;
 			dwVQEndL |= 0x20000000;
 			dwVQStartEndH |= 0x20000000;
@@ -97,6 +135,8 @@ void viafb_init_2d_engine(void)
 		switch (viaparinfo->chip_info->gfx_chip_name) {
 		case UNICHROME_K8M890:
 		case UNICHROME_P4M900:
+		case UNICHROME_VX800:
+		case UNICHROME_VX855:
 			writel(0x00100000,
 				viaparinfo->io_virt + VIA_REG_CR_TRANSET);
 			writel(dwVQStartEndH,
@@ -162,6 +202,8 @@ void viafb_init_2d_engine(void)
 		switch (viaparinfo->chip_info->gfx_chip_name) {
 		case UNICHROME_K8M890:
 		case UNICHROME_P4M900:
+		case UNICHROME_VX800:
+		case UNICHROME_VX855:
 			writel(0x00100000,
 				viaparinfo->io_virt + VIA_REG_CR_TRANSET);
 			writel(0x74301000,
@@ -216,7 +258,8 @@ void viafb_set_2d_mode(struct fb_info *info)
 	/* Set source and destination pitch (128bit aligned) */
 	pitch = (viaparinfo->hres * viaparinfo->bpp >> 3) >> 3;
 	pitch_reg = pitch | (pitch << 16);
-	pitch_reg |= VIA_PITCH_ENABLE;
+	if (viaparinfo->chip_info->twod_engine != VIA_2D_ENG_M1)
+		pitch_reg |= VIA_PITCH_ENABLE;
 	viafb_2d_writel(pitch_reg, VIA_REG_PITCH);
 }
 
@@ -259,15 +302,26 @@ void viafb_show_hw_cursor(struct fb_info *info, int Status)
 int viafb_wait_engine_idle(void)
 {
 	int loop = 0;
+	u_int32_t status_mask;
 
-	while (!(readl(viaparinfo->io_virt + VIA_REG_STATUS) &
-			VIA_VR_QUEUE_BUSY) && (loop < MAXLOOP)) {
-		loop++;
-		cpu_relax();
+	switch (viaparinfo->chip_info->twod_engine) {
+	case VIA_2D_ENG_H5:
+	case VIA_2D_ENG_M1:
+		status_mask = VIA_CMD_RGTR_BUSY_M1 | VIA_2D_ENG_BUSY_M1 |
+			      VIA_3D_ENG_BUSY_M1;
+		break;
+	default:
+		while (!(readl(viaparinfo->io_virt + VIA_REG_STATUS) &
+				VIA_VR_QUEUE_BUSY) && (loop < MAXLOOP)) {
+			loop++;
+			cpu_relax();
+		}
+		status_mask = VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY |
+			      VIA_3D_ENG_BUSY;
+		break;
 	}
 
-	while ((readl(viaparinfo->io_virt + VIA_REG_STATUS) &
-		    (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)) &&
+	while ((readl(viaparinfo->io_virt + VIA_REG_STATUS) & status_mask) &&
 		    (loop < MAXLOOP)) {
 		loop++;
 		cpu_relax();
drivers/video/via/accel.h +40 -0
index 5081ac2..9a39ed1 100644
@@ -67,6 +67,34 @@
 /* from 0x100 to 0x1ff */
 #define VIA_REG_COLORPAT        0x100
 
+/* defines for VIA 2D registers for vt3353/3409 (M1 engine)*/
+#define VIA_REG_GECMD_M1        0x000
+#define VIA_REG_GEMODE_M1       0x004
+#define VIA_REG_GESTATUS_M1     0x004       /* as same as VIA_REG_GEMODE */
+#define VIA_REG_PITCH_M1        0x008       /* pitch of src and dst */
+#define VIA_REG_DIMENSION_M1    0x00C       /* width and height */
+#define VIA_REG_DSTPOS_M1       0x010
+#define VIA_REG_LINE_XY_M1      0x010
+#define VIA_REG_DSTBASE_M1      0x014
+#define VIA_REG_SRCPOS_M1       0x018
+#define VIA_REG_LINE_K1K2_M1    0x018
+#define VIA_REG_SRCBASE_M1      0x01C
+#define VIA_REG_PATADDR_M1      0x020
+#define VIA_REG_MONOPAT0_M1     0x024
+#define VIA_REG_MONOPAT1_M1     0x028
+#define VIA_REG_OFFSET_M1       0x02C
+#define VIA_REG_LINE_ERROR_M1   0x02C
+#define VIA_REG_CLIPTL_M1       0x040       /* top and left of clipping */
+#define VIA_REG_CLIPBR_M1       0x044       /* bottom and right of clipping */
+#define VIA_REG_KEYCONTROL_M1   0x048       /* color key control */
+#define VIA_REG_FGCOLOR_M1      0x04C
+#define VIA_REG_DSTCOLORKEY_M1  0x04C       /* as same as VIA_REG_FG */
+#define VIA_REG_BGCOLOR_M1      0x050
+#define VIA_REG_SRCCOLORKEY_M1  0x050       /* as same as VIA_REG_BG */
+#define VIA_REG_MONOPATFGC_M1   0x058       /* Add BG color of Pattern. */
+#define VIA_REG_MONOPATBGC_M1   0x05C       /* Add FG color of Pattern. */
+#define VIA_REG_COLORPAT_M1     0x100       /* from 0x100 to 0x1ff */
+
 /* VIA_REG_PITCH(0x38): Pitch Setting */
 #define VIA_PITCH_ENABLE        0x80000000
 
@@ -157,6 +185,18 @@
 /* Virtual Queue is busy */
 #define VIA_VR_QUEUE_BUSY       0x00020000
 
+/* VIA_REG_STATUS(0x400): Engine Status for H5 */
+#define VIA_CMD_RGTR_BUSY_H5   0x00000010  /* Command Regulator is busy */
+#define VIA_2D_ENG_BUSY_H5     0x00000002  /* 2D Engine is busy */
+#define VIA_3D_ENG_BUSY_H5     0x00001FE1  /* 3D Engine is busy */
+#define VIA_VR_QUEUE_BUSY_H5   0x00000004  /* Virtual Queue is busy */
+
+/* VIA_REG_STATUS(0x400): Engine Status for VT3353/3409 */
+#define VIA_CMD_RGTR_BUSY_M1   0x00000010  /* Command Regulator is busy */
+#define VIA_2D_ENG_BUSY_M1     0x00000002  /* 2D Engine is busy */
+#define VIA_3D_ENG_BUSY_M1     0x00001FE1  /* 3D Engine is busy */
+#define VIA_VR_QUEUE_BUSY_M1   0x00000004  /* Virtual Queue is busy */
+
 #define MAXLOOP                 0xFFFFFF
 
 void viafb_2d_writel(u_int32_t val, u_int32_t reg);
drivers/video/via/viafbdev.c +0 -2
index 1357034..c7cf22b 100644
@@ -214,8 +214,6 @@ static int viafb_check_var(struct fb_var_screeninfo *var,
 	if (!info->par)
 		return -1;
 	p_viafb_par = (struct viafb_par *)info->par;
-	if (p_viafb_par->chip_info->twod_engine == VIA_2D_ENG_M1)
-		var->accel_flags = 0;
 
 	return 0;
 }
Signature · 9 lines
1.6.2.4


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com