Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 10/16] suppress verbose debug messages: change printk() to DEBUG_MSG()

1 view
Skip to first unread message

Jonathan Corbet

unread,
Apr 8, 2010, 1:20:03 PM4/8/10
to
From: Paul Fox <p...@laptop.org>

---
drivers/video/via/via_i2c.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/via/via_i2c.c b/drivers/video/via/via_i2c.c
index 18bbbdd..86e6e8d 100644
--- a/drivers/video/via/via_i2c.c
+++ b/drivers/video/via/via_i2c.c
@@ -26,7 +26,7 @@ static void via_i2c_setscl(void *data, int state)
u8 val;
struct via_i2c_adap_cfg *adap_data = data;

- printk(KERN_DEBUG "reading index 0x%02x from IO 0x%x\n",
+ DEBUG_MSG(KERN_DEBUG "reading index 0x%02x from IO 0x%x\n",
adap_data->ioport_index, adap_data->io_port);
val = viafb_read_reg(adap_data->io_port,
adap_data->ioport_index) & 0xF0;
@@ -140,7 +140,7 @@ static int create_i2c_bus(struct i2c_adapter *adapter,
struct via_i2c_adap_cfg *adap_cfg,
struct pci_dev *pdev)
{
- printk(KERN_DEBUG "viafb: creating bus adap=0x%p, algo_bit_data=0x%p, adap_cfg=0x%p\n", adapter, algo, adap_cfg);
+ DEBUG_MSG(KERN_DEBUG "viafb: creating bus adap=0x%p, algo_bit_data=0x%p, adap_cfg=0x%p\n", adapter, algo, adap_cfg);

algo->setsda = via_i2c_setsda;
algo->setscl = via_i2c_setscl;
@@ -182,7 +182,7 @@ static struct via_i2c_adap_cfg adap_configs[] = {
int viafb_create_i2c_busses(struct viafb_par *viapar)
{
int i, ret;
- printk(KERN_DEBUG "%s: entering\n", __FUNCTION__);
+ DEBUG_MSG(KERN_DEBUG "%s: entering\n", __FUNCTION__);

for (i = 0; i < VIAFB_NUM_I2C; i++) {
struct via_i2c_adap_cfg *adap_cfg = &adap_configs[i];
--
1.7.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Jonathan Corbet

unread,
Apr 8, 2010, 1:20:02 PM4/8/10
to
This was part of Harald's "make viafb a first-class citizen using
pci_driver" patch, but somehow got dropped when that patch went into
mainline.

Signed-off-by: Jonathan Corbet <cor...@lwn.net>
---
drivers/video/via/viafbdev.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 91bfe6d..4a34d4f 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1991,7 +1991,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
if (!viafbinfo1) {
printk(KERN_ERR
"allocate the second framebuffer struct error\n");
- goto out_delete_i2c;
+ goto out_unmap_screen;
}
viaparinfo1 = viafbinfo1->par;
memcpy(viaparinfo1, viaparinfo, viafb_par_length);
@@ -2086,6 +2086,8 @@ out_dealloc_cmap:
out_fb1_release:
if (viafbinfo1)
framebuffer_release(viafbinfo1);
+out_unmap_screen:
+ iounmap(viafbinfo->screen_base);
out_delete_i2c:
viafb_delete_i2c_buss(viaparinfo);
out_fb_release:

Jonathan Corbet

unread,
Apr 8, 2010, 1:20:02 PM4/8/10
to
From: Harald Welte <laf...@gnumonks.org>

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

[jc: fixed merge conflicts]
Signed-off-by: Harald Welte <Haral...@viatech.com>
---
drivers/video/via/chip.h | 8 ++++++++
drivers/video/via/hw.c | 15 +++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/video/via/chip.h b/drivers/video/via/chip.h
index 474f428..f799e2c 100644
--- a/drivers/video/via/chip.h
+++ b/drivers/video/via/chip.h
@@ -122,9 +122,17 @@ 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;
+ 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;
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index f2e4bda..963704e 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -2034,6 +2034,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)

Jonathan Corbet

unread,
Apr 8, 2010, 1:20:02 PM4/8/10
to
Commit c3e25673843153ea75fda79a47cf12f10a25ca37 (viafb: 2D engine rewrite)
changed the setting of the GEMODE register so that the reserved bits are no
longer preserved. Fix that; at the same time, move this code to its own
function and restore the use of symbolic constants.

Signed-off-by: Jonathan Corbet <cor...@lwn.net>
---

drivers/video/via/accel.c | 48 ++++++++++++++++++++++++++++++---------------
1 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/drivers/video/via/accel.c b/drivers/video/via/accel.c
index d5077df..78c0a2b 100644
--- a/drivers/video/via/accel.c
+++ b/drivers/video/via/accel.c
@@ -165,12 +165,41 @@ static int hw_bitblt_1(void __iomem *engine, u8 op, u32 width, u32 height,
return 0;
}

+/*
+ * Figure out an appropriate bytes-per-pixel setting.
+ */
+static int viafb_set_bpp(void __iomem *engine, u8 bpp)
+{
+ u32 gemode;
+
+ /* Preserve the reserved bits */
+ gemode = readl(engine + VIA_REG_GEMODE) & 0xfffffcff;
+ switch (bpp) {
+ case 8:
+ gemode |= VIA_GEM_8bpp;
+ break;
+ case 16:
+ gemode |= VIA_GEM_16bpp;
+ break;
+ case 32:
+ gemode |= VIA_GEM_32bpp;
+ break;
+ default:
+ printk(KERN_WARNING "hw_bitblt_2: Unsupported bpp %d\n", bpp);
+ return -EINVAL;
+ }
+ writel(gemode, engine + VIA_REG_GEMODE);
+ return 0;
+}
+
+
static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height,
u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y,
u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y,
u32 fg_color, u32 bg_color, u8 fill_rop)
{
u32 ge_cmd = 0, tmp, i;
+ int ret;

if (!op || op > 3) {
printk(KERN_WARNING "hw_bitblt_2: Invalid operation: %d\n", op);
@@ -204,22 +233,9 @@ static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height,
}
}

- switch (dst_bpp) {
- case 8:
- tmp = 0x00000000;
- break;
- case 16:
- tmp = 0x00000100;
- break;
- case 32:
- tmp = 0x00000300;
- break;
- default:
- printk(KERN_WARNING "hw_bitblt_2: Unsupported bpp %d\n",
- dst_bpp);
- return -EINVAL;
- }
- writel(tmp, engine + 0x04);
+ ret = viafb_set_bpp(engine, dst_bpp);
+ if (ret)
+ return ret;

if (op == VIA_BITBLT_FILL)
tmp = 0;

Jonathan Corbet

unread,
Apr 8, 2010, 1:20:02 PM4/8/10
to
From: Harald Welte <laf...@gnumonks.org>

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.

Signed-off-by: Harald Welte <Haral...@viatech.com>
---

drivers/video/via/hw.c | 64 +++++++++++++++++++++++++++++------------------
drivers/video/via/hw.h | 4 +-
2 files changed, 41 insertions(+), 27 deletions(-)

diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index ea0f8ec..f2e4bda 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -2542,24 +2542,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:
@@ -2569,21 +2582,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);
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h
index b874d95..f67a56a 100644
--- a/drivers/video/via/hw.h
+++ b/drivers/video/via/hw.h
@@ -822,8 +822,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 */

Jonathan Corbet

unread,
Apr 8, 2010, 1:20:02 PM4/8/10
to
From: Deepak Saxena <dsa...@laptop.org>

The existing code in VIAFB, taken from the openchrome driver,
causes the system to lock up upon moving the mouse pointer. This
patch uses the selective register restore from the official
VIA driver to keep this from happening.

This fixes http://dev.laptop.org/ticket/9565

[jc: extensive reworking to merge with 2.6.34 and to deal with some
coding issues. This code still needs improvement, though; that will
come in a later patch.]

Signed-off-by: Deepak Saxena <dsa...@laptop.org>
---
drivers/video/via/viafbdev.c | 79 +++++++++++++++++++++++++++++++++++++++---
drivers/video/via/viafbdev.h | 76 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 148 insertions(+), 7 deletions(-)

diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 5a5964f..56d5416 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1850,9 +1850,9 @@ static int viafb_suspend(struct pci_dev *pdev, pm_message_t state)
if (state.event == PM_EVENT_SUSPEND) {
acquire_console_sem();

- memcpy_fromio(viaparinfo->shared->saved_regs,
+ memcpy_fromio(&viaparinfo->shared->saved_video_regs,
viaparinfo->shared->engine_mmio + 0x100,
- 0x100 * sizeof(u32));
+ sizeof(struct via_video_regs));

fb_set_suspend(viafbinfo, 1);

@@ -1869,6 +1869,10 @@ static int viafb_suspend(struct pci_dev *pdev, pm_message_t state)

static int viafb_resume(struct pci_dev *pdev)
{
+ volatile struct via_video_regs *viaVidEng =
+ (volatile struct via_video_regs *)(viaparinfo->shared->engine_mmio + 0x200);
+ struct via_video_regs *localVidEng = &viaparinfo->shared->saved_video_regs;
+
acquire_console_sem();
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
@@ -1876,9 +1880,74 @@ static int viafb_resume(struct pci_dev *pdev)
goto fail;
pci_set_master(pdev);

- memcpy_toio(viaparinfo->shared->engine_mmio + 0x100,
- viaparinfo->shared->saved_regs,
- 0x100 * sizeof(u32));
+ /*
+ * Following set of register restores is black magic takend
+ * from the VIA X driver. Most of it is from the LeaveVT() and
+ * EnterVT() path and some is gleaned by looking at other bits
+ * of code to figure out what registers to touch.
+ */
+ viaVidEng->alphawin_hvstart = localVidEng->alphawin_hvstart;
+ viaVidEng->alphawin_size = localVidEng->alphawin_size;
+ viaVidEng->alphawin_ctl = localVidEng->alphawin_ctl;
+ viaVidEng->alphafb_stride = localVidEng->alphafb_stride;
+ viaVidEng->color_key = localVidEng->color_key;
+ viaVidEng->alphafb_addr = localVidEng->alphafb_addr;
+ viaVidEng->chroma_low = localVidEng->chroma_low;
+ viaVidEng->chroma_up = localVidEng->chroma_up;
+
+ /*VT3314 only has V3*/
+ viaVidEng->video1_ctl = localVidEng->video1_ctl;
+ viaVidEng->video1_fetch = localVidEng->video1_fetch;
+ viaVidEng->video1y_addr1 = localVidEng->video1y_addr1;
+ viaVidEng->video1_stride = localVidEng->video1_stride;
+ viaVidEng->video1_hvstart = localVidEng->video1_hvstart;
+ viaVidEng->video1_size = localVidEng->video1_size;
+ viaVidEng->video1y_addr2 = localVidEng->video1y_addr2;
+ viaVidEng->video1_zoom = localVidEng->video1_zoom;
+ viaVidEng->video1_mictl = localVidEng->video1_mictl;
+ viaVidEng->video1y_addr0 = localVidEng->video1y_addr0;
+ viaVidEng->video1_fifo = localVidEng->video1_fifo;
+ viaVidEng->video1y_addr3 = localVidEng->video1y_addr3;
+ viaVidEng->v1_source_w_h = localVidEng->v1_source_w_h ;
+ viaVidEng->video1_CSC1 = localVidEng->video1_CSC1;
+ viaVidEng->video1_CSC2 = localVidEng->video1_CSC2;
+
+ viaVidEng->snd_color_key = localVidEng->snd_color_key;
+ viaVidEng->v3alpha_prefifo = localVidEng->v3alpha_prefifo;
+ viaVidEng->v3alpha_fifo = localVidEng->v3alpha_fifo;
+ viaVidEng->video3_CSC2 = localVidEng->video3_CSC2;
+ viaVidEng->video3_CSC2 = localVidEng->video3_CSC2;
+ viaVidEng->v3_source_width = localVidEng->v3_source_width;
+ viaVidEng->video3_ctl = localVidEng->video3_ctl;
+ viaVidEng->video3_addr0 = localVidEng->video3_addr0;
+ viaVidEng->video3_addr1 = localVidEng->video3_addr1;
+ viaVidEng->video3_stride = localVidEng->video3_stride;
+ viaVidEng->video3_hvstart = localVidEng->video3_hvstart;
+ viaVidEng->video3_size = localVidEng->video3_size;
+ viaVidEng->v3alpha_fetch = localVidEng->v3alpha_fetch;
+ viaVidEng->video3_zoom = localVidEng->video3_zoom;
+ viaVidEng->video3_mictl = localVidEng->video3_mictl;
+ viaVidEng->video3_CSC1 = localVidEng->video3_CSC1;
+ viaVidEng->video3_CSC2 = localVidEng->video3_CSC2;
+ viaVidEng->compose = localVidEng->compose;
+
+ /*
+ * This _might_ not be needed, likely text mode cursor
+ */
+ viaVidEng->cursor_mode = localVidEng->cursor_mode;
+ viaVidEng->cursor_pos = localVidEng->cursor_pos;
+ viaVidEng->cursor_org = localVidEng->cursor_org;
+ viaVidEng->cursor_bg = localVidEng->cursor_bg;
+ viaVidEng->cursor_fg = localVidEng->cursor_fg;
+
+ /*
+ * Magic register dance to make cursor reappear.
+ *
+ * Currently hardcoded settings need to clean this all
+ * up later...
+ */
+ viaVidEng->hi_control = 0xb6000005;
+ viaVidEng->compose |= 0xc0000000;

fb_set_suspend(viafbinfo, 0);

diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h
index 46d41af..23b4afd 100644
--- a/drivers/video/via/viafbdev.h
+++ b/drivers/video/via/viafbdev.h
@@ -39,6 +39,77 @@

#define VIAFB_NUM_I2C 5

+/*
+ * From VIA X Driver; these are the registers we save on suspend/resume
+ */
+struct via_video_regs {
+ u32 interruptflag; /* 200 */
+ u32 ramtab; /* 204 */
+ u32 alphawin_hvstart; /* 208 */
+ u32 alphawin_size; /* 20c */
+ u32 alphawin_ctl; /* 210 */
+ u32 crt_startaddr; /* 214 */
+ u32 crt_startaddr_2; /* 218 */
+ u32 alphafb_stride ; /* 21c */
+ u32 color_key; /* 220 */
+ u32 alphafb_addr; /* 224 */
+ u32 chroma_low; /* 228 */
+ u32 chroma_up; /* 22c */
+ u32 video1_ctl; /* 230 */
+ u32 video1_fetch; /* 234 */
+ u32 video1y_addr1; /* 238 */
+ u32 video1_stride; /* 23c */
+ u32 video1_hvstart; /* 240 */
+ u32 video1_size; /* 244 */
+ u32 video1y_addr2; /* 248 */
+ u32 video1_zoom; /* 24c */
+ u32 video1_mictl; /* 250 */
+ u32 video1y_addr0; /* 254 */
+ u32 video1_fifo; /* 258 */
+ u32 video1y_addr3; /* 25c */
+ u32 hi_control; /* 260 */
+ u32 snd_color_key; /* 264 */
+ u32 v3alpha_prefifo; /* 268 */
+ u32 v1_source_w_h; /* 26c */
+ u32 hi_transparent_color; /* 270 */
+ u32 v_display_temp; /* 274 :No use */
+ u32 v3alpha_fifo; /* 278 */
+ u32 v3_source_width; /* 27c */
+ u32 dummy1; /* 280 */
+ u32 video1_CSC1; /* 284 */
+ u32 video1_CSC2; /* 288 */
+ u32 video1u_addr0; /* 28c */
+ u32 video1_opqctl; /* 290 */
+ u32 video3_opqctl; /* 294 */
+ u32 compose; /* 298 */
+ u32 dummy2; /* 29c */
+ u32 video3_ctl; /* 2a0 */
+ u32 video3_addr0; /* 2a4 */
+ u32 video3_addr1; /* 2a8 */
+ u32 video3_stride; /* 2ac */
+ u32 video3_hvstart; /* 2b0 */
+ u32 video3_size; /* 2b4 */
+ u32 v3alpha_fetch; /* 2b8 */
+ u32 video3_zoom; /* 2bc */
+ u32 video3_mictl; /* 2c0 */
+ u32 video3_CSC1; /* 2c4 */
+ u32 video3_CSC2; /* 2c8 */
+ u32 v3_display_temp; /* 2cc */
+ u32 cursor_mode;
+ u32 cursor_pos;
+ u32 cursor_org;
+ u32 cursor_bg;
+ u32 cursor_fg;
+ u32 video1u_addr1; /* 2e4 */
+ u32 video1u_addr2; /* 2e8 */
+ u32 video1u_addr3; /* 2ec */
+ u32 video1v_addr0; /* 2f0 */
+ u32 video1v_addr1; /* 2f4 */
+ u32 video1v_addr2; /* 2f8 */
+ u32 video1v_addr3; /* 2fc */
+};
+
+
struct viafb_shared {
struct proc_dir_entry *proc_entry; /*viafb proc entry */

@@ -61,10 +132,11 @@ struct viafb_shared {


u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y,

u32 fg_color, u32 bg_color, u8 fill_rop);

- /* For suspend/resume */
- u32 saved_regs[0x100];
+ /* For suspend/resume */
+ struct via_video_regs saved_video_regs;
};

+
struct viafb_par {
u8 depth;
u32 vram_addr;

Jonathan Corbet

unread,
Apr 8, 2010, 1:20:02 PM4/8/10
to
The code is only known to work there, and is strongly suspected to not work
on other chipsets.

Signed-off-by: Jonathan Corbet <cor...@lwn.net>
---

drivers/video/via/viafbdev.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index f834440..2e70c79 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1916,6 +1916,12 @@ static int viafb_suspend(struct pci_dev *pdev, pm_message_t state)
int i;
void __iomem *iomem = viaparinfo->shared->engine_mmio;

+/*
+ * This code is currently only known to work on VX855
+ */
+ if (viaparinfo->shared->chip_info.gfx_chip_name != UNICHROME_VX855)
+ return -ENOTSUPP;
+


if (state.event == PM_EVENT_SUSPEND) {
acquire_console_sem();

@@ -1940,6 +1946,12 @@ static int viafb_resume(struct pci_dev *pdev)
int i;
void __iomem *iomem = viaparinfo->shared->engine_mmio;

+/*
+ * This code is currently only known to work on VX855
+ */
+ if (viaparinfo->shared->chip_info.gfx_chip_name != UNICHROME_VX855)
+ return -ENOTSUPP;


+
acquire_console_sem();
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);

Jonathan Corbet

unread,
Apr 8, 2010, 1:20:03 PM4/8/10
to
From: Harald Welte <laf...@gnumonks.org>

This patch changes the way how the various I2C busses are used internally
inside the viafb driver: Previosuly, only a single i2c_adapter was created,
even thougt two different hardware I2C busses are accessed: A structure member
in a global variable was modified to indicate the bus to be used.

Now, all existing hardware busses are registered with the i2c core, and the
viafb_i2c_{read,write}byte[s]() function take the adapter number as function
call parameter, rather than referring to the global structure member.

[jc: even more painful merge with mainline changes ->2.6.34]
[jc: painful merge with OLPC changes]

Signed-off-by: Harald Welte <Haral...@viatech.com>


Signed-off-by: Jonathan Corbet <cor...@lwn.net>
---

drivers/video/via/dvi.c | 35 ++++-----
drivers/video/via/lcd.c | 15 ++--
drivers/video/via/via_i2c.c | 172 ++++++++++++++++++++++++++----------------
drivers/video/via/via_i2c.h | 43 +++++++----
drivers/video/via/viafbdev.c | 6 +-
drivers/video/via/viafbdev.h | 4 +-
drivers/video/via/vt1636.c | 36 ++++-----
drivers/video/via/vt1636.h | 2 +-
8 files changed, 181 insertions(+), 132 deletions(-)

diff --git a/drivers/video/via/dvi.c b/drivers/video/via/dvi.c
index 67b3693..00d001e 100644
--- a/drivers/video/via/dvi.c
+++ b/drivers/video/via/dvi.c
@@ -96,7 +96,7 @@ int viafb_tmds_trasmitter_identify(void)
viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = VT1632_TMDS;
viaparinfo->chip_info->
tmds_chip_info.tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR;
- viaparinfo->chip_info->tmds_chip_info.i2c_port = I2CPORTINDEX;
+ viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_I2C_ADAP_31;
if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID) != FAIL) {
/*
* Currently only support 12bits,dual edge,add 24bits mode later
@@ -110,7 +110,7 @@ int viafb_tmds_trasmitter_identify(void)
viaparinfo->chip_info->tmds_chip_info.i2c_port);
return OK;
} else {
- viaparinfo->chip_info->tmds_chip_info.i2c_port = GPIOPORTINDEX;
+ viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_I2C_ADAP_2C;
if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID)
!= FAIL) {
tmds_register_write(0x08, 0x3b);
@@ -160,32 +160,26 @@ int viafb_tmds_trasmitter_identify(void)

static void tmds_register_write(int index, u8 data)
{
- viaparinfo->shared->i2c_stuff.i2c_port =
- viaparinfo->chip_info->tmds_chip_info.i2c_port;
-
- viafb_i2c_writebyte(viaparinfo->chip_info->tmds_chip_info.
- tmds_chip_slave_addr, index,
- data);
+ viafb_i2c_writebyte(viaparinfo->chip_info->tmds_chip_info.i2c_port,
+ viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr,
+ index, data);
}

static int tmds_register_read(int index)
{
u8 data;

- viaparinfo->shared->i2c_stuff.i2c_port =
- viaparinfo->chip_info->tmds_chip_info.i2c_port;
- viafb_i2c_readbyte((u8) viaparinfo->chip_info->
- tmds_chip_info.tmds_chip_slave_addr,
- (u8) index, &data);
+ viafb_i2c_readbyte(viaparinfo->chip_info->tmds_chip_info.i2c_port,
+ (u8) viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr,
+ (u8) index, &data);
return data;
}

static int tmds_register_read_bytes(int index, u8 *buff, int buff_len)
{
- viaparinfo->shared->i2c_stuff.i2c_port =
- viaparinfo->chip_info->tmds_chip_info.i2c_port;
- viafb_i2c_readbytes((u8) viaparinfo->chip_info->tmds_chip_info.
- tmds_chip_slave_addr, (u8) index, buff, buff_len);
+ viafb_i2c_readbytes(viaparinfo->chip_info->tmds_chip_info.i2c_port,
+ (u8) viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr,
+ (u8) index, buff, buff_len);
return 0;
}

@@ -648,9 +642,10 @@ void viafb_dvi_enable(void)
else
data = 0x37;
viafb_i2c_writebyte(viaparinfo->chip_info->
- tmds_chip_info.
- tmds_chip_slave_addr,
- 0x08, data);
+ tmds_chip_info.i2c_port,
+ viaparinfo->chip_info->
+ tmds_chip_info.tmds_chip_slave_addr,
+ 0x08, data);
}
}
}
diff --git a/drivers/video/via/lcd.c b/drivers/video/via/lcd.c
index 37a9746..fc27534 100644
--- a/drivers/video/via/lcd.c
+++ b/drivers/video/via/lcd.c
@@ -212,16 +212,14 @@ int viafb_lvds_trasmitter_identify(void)
if (machine_is_olpc())
return FAIL;
#endif
- viaparinfo->shared->i2c_stuff.i2c_port = I2CPORTINDEX;
- if (viafb_lvds_identify_vt1636()) {
- viaparinfo->chip_info->lvds_chip_info.i2c_port = I2CPORTINDEX;
+ if (viafb_lvds_identify_vt1636(VIA_I2C_ADAP_31)) {
+ viaparinfo->chip_info->lvds_chip_info.i2c_port = VIA_I2C_ADAP_31;
DEBUG_MSG(KERN_INFO
"Found VIA VT1636 LVDS on port i2c 0x31 \n");
} else {
- viaparinfo->shared->i2c_stuff.i2c_port = GPIOPORTINDEX;
- if (viafb_lvds_identify_vt1636()) {
+ if (viafb_lvds_identify_vt1636(VIA_I2C_ADAP_26)) {
viaparinfo->chip_info->lvds_chip_info.i2c_port =
- GPIOPORTINDEX;
+ VIA_I2C_ADAP_2C;
DEBUG_MSG(KERN_INFO
"Found VIA VT1636 LVDS on port gpio 0x2c \n");
}
@@ -485,9 +483,8 @@ static int lvds_register_read(int index)
{
u8 data;

- viaparinfo->shared->i2c_stuff.i2c_port = GPIOPORTINDEX;
- viafb_i2c_readbyte((u8) viaparinfo->chip_info->
- lvds_chip_info.lvds_chip_slave_addr,
+ viafb_i2c_readbyte(VIA_I2C_ADAP_2C,
+ (u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr,
(u8) index, &data);
return data;
}
diff --git a/drivers/video/via/via_i2c.c b/drivers/video/via/via_i2c.c
index 15543e9..18bbbdd 100644
--- a/drivers/video/via/via_i2c.c
+++ b/drivers/video/via/via_i2c.c
@@ -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
@@ -24,40 +24,44 @@


static void via_i2c_setscl(void *data, int state)
{
u8 val;

- struct via_i2c_stuff *via_i2c_chan = (struct via_i2c_stuff *)data;
+ struct via_i2c_adap_cfg *adap_data = data;

- val = viafb_read_reg(VIASR, via_i2c_chan->i2c_port) & 0xF0;
+ printk(KERN_DEBUG "reading index 0x%02x from IO 0x%x\n",
+ adap_data->ioport_index, adap_data->io_port);
+ val = viafb_read_reg(adap_data->io_port,
+ adap_data->ioport_index) & 0xF0;
if (state)
val |= 0x20;
else
val &= ~0x20;
- switch (via_i2c_chan->i2c_port) {
- case I2CPORTINDEX:
+ switch (adap_data->type) {
+ case VIA_I2C_I2C:
val |= 0x01;
break;
- case GPIOPORTINDEX:
+ case VIA_I2C_GPIO:
val |= 0x80;
break;
default:
- DEBUG_MSG("via_i2c: specify wrong i2c port.\n");
+ DEBUG_MSG("viafb_i2c: specify wrong i2c type.\n");
}
- viafb_write_reg(via_i2c_chan->i2c_port, VIASR, val);
+ viafb_write_reg(adap_data->ioport_index,
+ adap_data->io_port, val);
}

static int via_i2c_getscl(void *data)
{
- struct via_i2c_stuff *via_i2c_chan = (struct via_i2c_stuff *)data;
+ struct via_i2c_adap_cfg *adap_data = data;

- if (viafb_read_reg(VIASR, via_i2c_chan->i2c_port) & 0x08)
+ if (viafb_read_reg(adap_data->io_port, adap_data->ioport_index) & 0x08)
return 1;
return 0;
}

static int via_i2c_getsda(void *data)
{
- struct via_i2c_stuff *via_i2c_chan = (struct via_i2c_stuff *)data;
+ struct via_i2c_adap_cfg *adap_data = data;

- if (viafb_read_reg(VIASR, via_i2c_chan->i2c_port) & 0x04)
+ if (viafb_read_reg(adap_data->io_port, adap_data->ioport_index) & 0x04)
return 1;
return 0;
}
@@ -65,27 +69,29 @@ static int via_i2c_getsda(void *data)
static void via_i2c_setsda(void *data, int state)
{
u8 val;
- struct via_i2c_stuff *via_i2c_chan = (struct via_i2c_stuff *)data;
+ struct via_i2c_adap_cfg *adap_data = data;

- val = viafb_read_reg(VIASR, via_i2c_chan->i2c_port) & 0xF0;
+ val = viafb_read_reg(adap_data->io_port,
+ adap_data->ioport_index) & 0xF0;
if (state)
val |= 0x10;
else
val &= ~0x10;
- switch (via_i2c_chan->i2c_port) {
- case I2CPORTINDEX:
+ switch (adap_data->type) {
+ case VIA_I2C_I2C:
val |= 0x01;
break;
- case GPIOPORTINDEX:
+ case VIA_I2C_GPIO:
val |= 0x40;
break;
default:
- DEBUG_MSG("via_i2c: specify wrong i2c port.\n");
+ DEBUG_MSG("viafb_i2c: specify wrong i2c type.\n");
}
- viafb_write_reg(via_i2c_chan->i2c_port, VIASR, val);
+ viafb_write_reg(adap_data->ioport_index,
+ adap_data->io_port, val);
}

-int viafb_i2c_readbyte(u8 slave_addr, u8 index, u8 *pdata)
+int viafb_i2c_readbyte(u8 adap, u8 slave_addr, u8 index, u8 *pdata)
{
u8 mm1[] = {0x00};
struct i2c_msg msgs[2];
@@ -97,12 +103,11 @@ int viafb_i2c_readbyte(u8 slave_addr, u8 index, u8 *pdata)
mm1[0] = index;
msgs[0].len = 1; msgs[1].len = 1;
msgs[0].buf = mm1; msgs[1].buf = pdata;
- i2c_transfer(&viaparinfo->shared->i2c_stuff.adapter, msgs, 2);
-
- return 0;
+ return i2c_transfer(&viaparinfo->shared->i2c_stuff[adap].adapter,
+ msgs, 2);
}

-int viafb_i2c_writebyte(u8 slave_addr, u8 index, u8 data)
+int viafb_i2c_writebyte(u8 adap, u8 slave_addr, u8 index, u8 data)
{
u8 msg[2] = { index, data };
struct i2c_msg msgs;
@@ -111,10 +116,11 @@ int viafb_i2c_writebyte(u8 slave_addr, u8 index, u8 data)
msgs.addr = slave_addr / 2;
msgs.len = 2;
msgs.buf = msg;
- return i2c_transfer(&viaparinfo->shared->i2c_stuff.adapter, &msgs, 1);
+ return i2c_transfer(&viaparinfo->shared->i2c_stuff[adap].adapter,
+ &msgs, 1);
}

-int viafb_i2c_readbytes(u8 slave_addr, u8 index, u8 *buff, int buff_len)
+int viafb_i2c_readbytes(u8 adap, u8 slave_addr, u8 index, u8 *buff, int buff_len)
{
u8 mm1[] = {0x00};
struct i2c_msg msgs[2];
@@ -125,53 +131,89 @@ int viafb_i2c_readbytes(u8 slave_addr, u8 index, u8 *buff, int buff_len)
mm1[0] = index;
msgs[0].len = 1; msgs[1].len = buff_len;
msgs[0].buf = mm1; msgs[1].buf = buff;
- i2c_transfer(&viaparinfo->shared->i2c_stuff.adapter, msgs, 2);
- return 0;
+ return i2c_transfer(&viaparinfo->shared->i2c_stuff[adap].adapter,
+ msgs, 2);
}

-int viafb_create_i2c_bus(void *viapar)
+static int create_i2c_bus(struct i2c_adapter *adapter,
+ struct i2c_algo_bit_data *algo,
+ struct via_i2c_adap_cfg *adap_cfg,
+ struct pci_dev *pdev)
{
- int ret;
- struct via_i2c_stuff *i2c_stuff =
- &((struct viafb_par *)viapar)->shared->i2c_stuff;
-
- strcpy(i2c_stuff->adapter.name, "via_i2c");
- i2c_stuff->i2c_port = 0x0;
- i2c_stuff->adapter.owner = THIS_MODULE;
- i2c_stuff->adapter.id = 0x01FFFF;
- i2c_stuff->adapter.class = 0;
- i2c_stuff->adapter.algo_data = &i2c_stuff->algo;
- i2c_stuff->adapter.dev.parent = NULL;
- i2c_stuff->algo.setsda = via_i2c_setsda;
- i2c_stuff->algo.setscl = via_i2c_setscl;
- i2c_stuff->algo.getsda = via_i2c_getsda;
- i2c_stuff->algo.getscl = via_i2c_getscl;
- i2c_stuff->algo.udelay = 40;
- i2c_stuff->algo.timeout = 20;
- i2c_stuff->algo.data = i2c_stuff;
-
- i2c_set_adapdata(&i2c_stuff->adapter, i2c_stuff);
+ printk(KERN_DEBUG "viafb: creating bus adap=0x%p, algo_bit_data=0x%p, adap_cfg=0x%p\n", adapter, algo, adap_cfg);
+
+ algo->setsda = via_i2c_setsda;
+ algo->setscl = via_i2c_setscl;
+ algo->getsda = via_i2c_getsda;
+ algo->getscl = via_i2c_getscl;
+ algo->udelay = 40;
+ algo->timeout = 20;
+ algo->data = adap_cfg;
+
+ sprintf(adapter->name, "viafb i2c io_port idx 0x%02x",
+ adap_cfg->ioport_index);
+ adapter->owner = THIS_MODULE;
+ adapter->id = 0x01FFFF;
+ adapter->class = I2C_CLASS_DDC;
+ adapter->algo_data = algo;
+ if (pdev)
+ adapter->dev.parent = &pdev->dev;
+ else
+ adapter->dev.parent = NULL;
+ //i2c_set_adapdata(adapter, adap_cfg);

/* Raise SCL and SDA */
- i2c_stuff->i2c_port = I2CPORTINDEX;
- via_i2c_setsda(i2c_stuff, 1);
- via_i2c_setscl(i2c_stuff, 1);
-
- i2c_stuff->i2c_port = GPIOPORTINDEX;
- via_i2c_setsda(i2c_stuff, 1);
- via_i2c_setscl(i2c_stuff, 1);
+ via_i2c_setsda(adap_cfg, 1);
+ via_i2c_setscl(adap_cfg, 1);
udelay(20);

- ret = i2c_bit_add_bus(&i2c_stuff->adapter);
- if (ret == 0)
- DEBUG_MSG("I2C bus %s registered.\n", i2c_stuff->adapter.name);
- else
- DEBUG_MSG("Failed to register I2C bus %s.\n",
- i2c_stuff->adapter.name);
- return ret;
+ return i2c_bit_add_bus(adapter);
+}
+
+static struct via_i2c_adap_cfg adap_configs[] = {
+ [VIA_I2C_ADAP_26] = { VIA_I2C_I2C, VIASR, 0x26 },
+ [VIA_I2C_ADAP_31] = { VIA_I2C_I2C, VIASR, 0x31 },
+ [VIA_I2C_ADAP_25] = { VIA_I2C_GPIO, VIASR, 0x25 },
+ [VIA_I2C_ADAP_2C] = { VIA_I2C_GPIO, VIASR, 0x2c },
+ [VIA_I2C_ADAP_3D] = { VIA_I2C_GPIO, VIASR, 0x3d },
+ { 0, 0, 0 }
+};
+
+int viafb_create_i2c_busses(struct viafb_par *viapar)
+{
+ int i, ret;
+ printk(KERN_DEBUG "%s: entering\n", __FUNCTION__);
+
+ for (i = 0; i < VIAFB_NUM_I2C; i++) {
+ struct via_i2c_adap_cfg *adap_cfg = &adap_configs[i];
+ struct via_i2c_stuff *i2c_stuff = &viapar->shared->i2c_stuff[i];
+
+ if (adap_cfg->type == 0)
+ break;
+
+ ret = create_i2c_bus(&i2c_stuff->adapter,
+ &i2c_stuff->algo, adap_cfg,
+ NULL); //FIXME: PCIDEV
+ if (ret < 0) {
+ printk(KERN_ERR "viafb: cannot create i2c bus %u:%d\n",
+ i, ret);
+ //FIXME: properly release previous busses
+ return ret;
+ }
+ }
+
+ return 0;
}

-void viafb_delete_i2c_buss(void *par)
+void viafb_delete_i2c_busses(struct viafb_par *par)
{
- i2c_del_adapter(&((struct viafb_par *)par)->shared->i2c_stuff.adapter);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(par->shared->i2c_stuff); i++) {
+ struct via_i2c_stuff *i2c_stuff = &par->shared->i2c_stuff[i];
+ /* only remove those entries in the array that we've
+ * actually used (and thus initialized algo_data) */
+ if (i2c_stuff->adapter.algo_data == &i2c_stuff->algo)
+ i2c_del_adapter(&i2c_stuff->adapter);
+ }
}
diff --git a/drivers/video/via/via_i2c.h b/drivers/video/via/via_i2c.h
index 3a13242..00ed978 100644
--- a/drivers/video/via/via_i2c.h
+++ b/drivers/video/via/via_i2c.h
@@ -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
@@ -24,23 +24,38 @@
#include <linux/i2c.h>
#include <linux/i2c-algo-bit.h>

+enum via_i2c_type {
+ VIA_I2C_NONE,
+ VIA_I2C_I2C,
+ VIA_I2C_GPIO,
+};
+
+/* private data for each adapter */
+struct via_i2c_adap_cfg {
+ enum via_i2c_type type;
+ u_int16_t io_port;
+ u_int8_t ioport_index;
+};
+
struct via_i2c_stuff {
u16 i2c_port; /* GPIO or I2C port */
struct i2c_adapter adapter;
struct i2c_algo_bit_data algo;
};

-#define I2CPORT 0x3c4
-#define I2CPORTINDEX 0x31
-#define GPIOPORT 0x3C4
-#define GPIOPORTINDEX 0x2C
-#define I2C_BUS 1
-#define GPIO_BUS 2
-#define DELAYPORT 0x3C3
-
-int viafb_i2c_readbyte(u8 slave_addr, u8 index, u8 *pdata);
-int viafb_i2c_writebyte(u8 slave_addr, u8 index, u8 data);
-int viafb_i2c_readbytes(u8 slave_addr, u8 index, u8 *buff, int buff_len);
-int viafb_create_i2c_bus(void *par);
-void viafb_delete_i2c_buss(void *par);
+enum viafb_i2c_adap {
+ VIA_I2C_ADAP_26,
+ VIA_I2C_ADAP_31,
+ VIA_I2C_ADAP_25,
+ VIA_I2C_ADAP_2C,
+ VIA_I2C_ADAP_3D,
+};
+
+int viafb_i2c_readbyte(u8 adap, u8 slave_addr, u8 index, u8 *pdata);
+int viafb_i2c_writebyte(u8 adap, u8 slave_addr, u8 index, u8 data);
+int viafb_i2c_readbytes(u8 adap, u8 slave_addr, u8 index, u8 *buff, int buff_len);
+
+struct viafb_par;
+int viafb_create_i2c_busses(struct viafb_par *par);
+void viafb_delete_i2c_busses(struct viafb_par *par);
#endif /* __VIA_I2C_H__ */
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 4a34d4f..ea3018e 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1886,7 +1886,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
viafb_dual_fb = 0;

/* Set up I2C bus stuff */
- rc = viafb_create_i2c_bus(viaparinfo);
+ rc = viafb_create_i2c_busses(viaparinfo);
if (rc)
goto out_fb_release;

@@ -2089,7 +2089,7 @@ out_fb1_release:
out_unmap_screen:
iounmap(viafbinfo->screen_base);
out_delete_i2c:
- viafb_delete_i2c_buss(viaparinfo);
+ viafb_delete_i2c_busses(viaparinfo);
out_fb_release:
framebuffer_release(viafbinfo);
return rc;
@@ -2105,7 +2105,7 @@ static void __devexit via_pci_remove(struct pci_dev *pdev)
iounmap((void *)viafbinfo->screen_base);
iounmap(viaparinfo->shared->engine_mmio);

- viafb_delete_i2c_buss(viaparinfo);
+ viafb_delete_i2c_busses(viaparinfo);

framebuffer_release(viafbinfo);
if (viafb_dual_fb)
diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h
index 0c94d24..1dab97b 100644
--- a/drivers/video/via/viafbdev.h
+++ b/drivers/video/via/viafbdev.h
@@ -37,11 +37,13 @@
#define VERSION_OS 0 /* 0: for 32 bits OS, 1: for 64 bits OS */
#define VERSION_MINOR 4

+#define VIAFB_NUM_I2C 5


+
struct viafb_shared {
struct proc_dir_entry *proc_entry; /*viafb proc entry */

/* I2C stuff */
- struct via_i2c_stuff i2c_stuff;
+ struct via_i2c_stuff i2c_stuff[VIAFB_NUM_I2C];

/* All the information will be needed to set engine */
struct tmds_setting_information tmds_setting_info;
diff --git a/drivers/video/via/vt1636.c b/drivers/video/via/vt1636.c
index a6b3749..d75b5f0 100644
--- a/drivers/video/via/vt1636.c
+++ b/drivers/video/via/vt1636.c
@@ -27,9 +27,8 @@ u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information
{
u8 data;

- viaparinfo->shared->i2c_stuff.i2c_port = plvds_chip_info->i2c_port;
- viafb_i2c_readbyte(plvds_chip_info->lvds_chip_slave_addr, index, &data);
-
+ viafb_i2c_readbyte(plvds_chip_info->i2c_port,
+ plvds_chip_info->lvds_chip_slave_addr, index, &data);
return data;
}

@@ -39,14 +38,13 @@ void viafb_gpio_i2c_write_mask_lvds(struct lvds_setting_information
{
int index, data;

- viaparinfo->shared->i2c_stuff.i2c_port = plvds_chip_info->i2c_port;
-
index = io_data.Index;
data = viafb_gpio_i2c_read_lvds(plvds_setting_info, plvds_chip_info,
index);
data = (data & (~io_data.Mask)) | io_data.Data;

- viafb_i2c_writebyte(plvds_chip_info->lvds_chip_slave_addr, index, data);
+ viafb_i2c_writebyte(plvds_chip_info->i2c_port,
+ plvds_chip_info->lvds_chip_slave_addr, index, data);
}

void viafb_init_lvds_vt1636(struct lvds_setting_information
@@ -159,7 +157,7 @@ void viafb_disable_lvds_vt1636(struct lvds_setting_information
}
}

-bool viafb_lvds_identify_vt1636(void)
+bool viafb_lvds_identify_vt1636(u8 i2c_adapter)
{
u8 Buffer[2];

@@ -170,23 +168,23 @@ bool viafb_lvds_identify_vt1636(void)
VT1636_LVDS_I2C_ADDR;

/* Check vendor ID first: */
- viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info.
- lvds_chip_slave_addr,
- 0x00, &Buffer[0]);
- viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info.
- lvds_chip_slave_addr,
- 0x01, &Buffer[1]);
+ viafb_i2c_readbyte(i2c_adapter,
+ (u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr,
+ 0x00, &Buffer[0]);
+ viafb_i2c_readbyte(i2c_adapter,
+ (u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr,
+ 0x01, &Buffer[1]);

if (!((Buffer[0] == 0x06) && (Buffer[1] == 0x11)))
return false;

/* Check Chip ID: */
- viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info.
- lvds_chip_slave_addr,
- 0x02, &Buffer[0]);
- viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info.
- lvds_chip_slave_addr,
- 0x03, &Buffer[1]);
+ viafb_i2c_readbyte(i2c_adapter,
+ (u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr,
+ 0x02, &Buffer[0]);
+ viafb_i2c_readbyte(i2c_adapter,
+ (u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr,
+ 0x03, &Buffer[1]);
if ((Buffer[0] == 0x45) && (Buffer[1] == 0x33)) {
viaparinfo->chip_info->lvds_chip_info.lvds_chip_name =
VT1636_LVDS;
diff --git a/drivers/video/via/vt1636.h b/drivers/video/via/vt1636.h
index 2a150c5..4c1314e 100644
--- a/drivers/video/via/vt1636.h
+++ b/drivers/video/via/vt1636.h
@@ -22,7 +22,7 @@
#ifndef _VT1636_H_
#define _VT1636_H_
#include "chip.h"
-bool viafb_lvds_identify_vt1636(void);
+bool viafb_lvds_identify_vt1636(u8 i2c_adapter);
void viafb_init_lvds_vt1636(struct lvds_setting_information
*plvds_setting_info, struct lvds_chip_information *plvds_chip_info);
void viafb_enable_lvds_vt1636(struct lvds_setting_information

Jonathan Corbet

unread,
Apr 8, 2010, 1:20:03 PM4/8/10
to
From: Harald Welte <laf...@gnumonks.org>

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.

[jc: fixed merge conflicts]


Signed-off-by: Harald Welte <Haral...@viatech.com>
---

drivers/video/via/viafbdev.c | 52 ++++++++++++++++++++++++++++++-----------
1 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 3028e7d..91bfe6d 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c


@@ -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

@@ -1847,7 +1847,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
u32 default_xres, default_yres;
- int vmode_index;
+ int rc, vmode_index;
u32 viafb_par_length;

DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
@@ -1862,7 +1862,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
&pdev->dev);
if (!viafbinfo) {
printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
- return -ENODEV;
+ return -ENOMEM;
}

viaparinfo = (struct viafb_par *)viafbinfo->par;
@@ -1886,7 +1886,9 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,


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(pdev, ent);
viaparinfo->fbmem = pci_resource_start(pdev, 0);
@@ -1897,7 +1899,8 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
viaparinfo->memsize);
if (!viafbinfo->screen_base) {
printk(KERN_INFO "ioremap failed\n");
- return -ENOMEM;
+ rc = -EIO;
+ goto out_delete_i2c;
}

viafbinfo->fix.mmio_start = pci_resource_start(pdev, 1);
@@ -1988,8 +1991,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,


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);

@@ -2044,21 +2046,26 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
viaparinfo->depth = fb_get_color_depth(&viafbinfo->var,
&viafbinfo->fix);
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,
@@ -2067,6 +2074,23 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
viafb_init_proc(&viaparinfo->shared->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(struct pci_dev *pdev)

Florian Tobias Schandinat

unread,
Apr 8, 2010, 2:30:02 PM4/8/10
to
Jonathan Corbet schrieb:

I don't know whether this is right (changing the return code) as Andrew
recommend a while ago:
"It should return -ENOMEM rather than -1, but that's minor."
So I did and now I wonder which one is correct?

> + goto out_delete_i2c;
> }
>
> viafbinfo->fix.mmio_start = pci_resource_start(pdev, 1);
> @@ -1988,8 +1991,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
> if (!viafbinfo1) {
> printk(KERN_ERR
> "allocate the second framebuffer struct error\n");
> - framebuffer_release(viafbinfo);
> - return -ENOMEM;

rc = -ENOMEM;
is missing?

Otherwise it looks okay.


Thanks,

Florian Tobias Schandinat

Florian Tobias Schandinat

unread,
Apr 8, 2010, 2:50:02 PM4/8/10
to
Hi,

something I am wondering about is whether we can't simply do:
viaparinfo->memsize = pci_resource_len(pdev, 0);
I suppose that this is not possible meaning that the pci len can be
longer than the actual memory but I just wanted to use the moment to
make sure.

Jonathan Corbet schrieb:

Would it be possible to replace this loop with a lookup table that uses
the fact that we already know which IGP we have?
Yeah, that's not a bug it only feels a bit awkward to do it this way.

This function was not designed to return an error (memsize is not
checked). Either return a default value (let's say 8MB) or add a check
for memsize.

> + }
>
> FBSize = FBSize & 0x00007000;
> DEBUG_MSG(KERN_INFO "FB Size = %x\n", FBSize);
> diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h
> index b874d95..f67a56a 100644
> --- a/drivers/video/via/hw.h
> +++ b/drivers/video/via/hw.h
> @@ -822,8 +822,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 */

Thanks,

Florian Tobias Schandinat

Florian Tobias Schandinat

unread,
Apr 8, 2010, 3:00:02 PM4/8/10
to
Jonathan Corbet schrieb:

> This was part of Harald's "make viafb a first-class citizen using
> pci_driver" patch, but somehow got dropped when that patch went into
> mainline.

Well it was dropped because the patch introducing the goto_error_out
logic wasn't backported that time because I planned to rewrite the
framebuffer initialization to use a common function for multiple
framebuffers.
As we now (due to your previous patches) have this logic it looks good
to me.


Thanks,

Florian Tobias Schandinat

--

Florian Tobias Schandinat

unread,
Apr 8, 2010, 11:10:02 PM4/8/10
to
Hi Jon,

Jonathan Corbet schrieb:


> Commit c3e25673843153ea75fda79a47cf12f10a25ca37 (viafb: 2D engine rewrite)
> changed the setting of the GEMODE register so that the reserved bits are no
> longer preserved. Fix that; at the same time, move this code to its own
> function and restore the use of symbolic constants.

in your later patch "[PATCH 06/16] viafb: complete support for
VX800/VX855 accelerated framebuffer" you reintroduce initializing those
bits to 0. That's fine but I can't see a reason for preserving this bits
here as it adds useless overhead unless the hardware itself changed some
of those bits and behaves differently according to those bits.
Additionally the first 2 bits are not reserved but provide a rotation
where 00 is what we want (no rotation).
And if you rip code off hw_bitblt_2 it would be better to do the same
with hw_bitblt_1. A quick look reveals that the same function can be
used there (the error message would need to be adjusted but that's minor).
So nack@preserving (unless it would cause problems otherwise) but
ack@ripping code off and sharing between hw_bitblt_1 & hw_bitblt_2.


Thanks,

Florian Tobias Schandinat

--

Florian Tobias Schandinat

unread,
Apr 8, 2010, 11:30:03 PM4/8/10
to
Jonathan Corbet schrieb:

> From: Harald Welte <laf...@gnumonks.org>
>
> This will help us for the upcoming support for 2D acceleration using
> the M1 engine.
>
> [jc: fixed merge conflicts]
> Signed-off-by: Harald Welte <Haral...@viatech.com>

That's probably a good idea (although most things are already done in
the separate blitting functions).
Just a minor nit:
Could we change the default so that if someone adds support for a new
IGP (and misses this function) we default to either the newest or
preferably to none? I've just seen too much poorly maintained code in
this driver and defaulting to the oldest is hence a bad idea.
Otherwise it's fine.


Thanks,

Florian Tobias Schandinat

--

Jonathan Corbet

unread,
Apr 9, 2010, 3:40:02 PM4/9/10
to
On Thu, 08 Apr 2010 20:22:57 +0200
Florian Tobias Schandinat <FlorianS...@gmx.de> wrote:

> > if (!viafbinfo->screen_base) {
> > printk(KERN_INFO "ioremap failed\n");
> > - return -ENOMEM;
> > + rc = -EIO;
>
> I don't know whether this is right (changing the return code) as Andrew
> recommend a while ago:
> "It should return -ENOMEM rather than -1, but that's minor."
> So I did and now I wonder which one is correct?

To me it seems like -ENOMEM could be a bit confusing here; there's a lot of
things that could go wrong with that same error return.

That said, I did some digging around, and -ENOMEM does seem to be the
standard response to an ioremap() failure. So I've changed it back.

> > if (!viafbinfo1) {
> > printk(KERN_ERR
> > "allocate the second framebuffer struct error\n");
> > - framebuffer_release(viafbinfo);
> > - return -ENOMEM;
>
> rc = -ENOMEM;
> is missing?

Indeed. Fixed.

Thanks,

jon

Jonathan Corbet

unread,
Apr 9, 2010, 3:50:01 PM4/9/10
to
On Thu, 08 Apr 2010 20:42:17 +0200

Florian Tobias Schandinat <FlorianS...@gmx.de> wrote:

> something I am wondering about is whether we can't simply do:
> viaparinfo->memsize = pci_resource_len(pdev, 0);
> I suppose that this is not possible meaning that the pci len can be
> longer than the actual memory but I just wanted to use the moment to
> make sure.

That would make sense. But if somebody who is closer to the hardware than
I am doesn't take that approach, I'm nervous about changing it. Harald?

> This function was not designed to return an error (memsize is not
> checked). Either return a default value (let's say 8MB) or add a check
> for memsize.

That's a good point. I put in a check.

Thanks,

jon

Jonathan Corbet

unread,
Apr 9, 2010, 4:10:02 PM4/9/10
to
On Fri, 09 Apr 2010 05:07:34 +0200

Florian Tobias Schandinat <FlorianS...@gmx.de> wrote:

> in your later patch "[PATCH 06/16] viafb: complete support for
> VX800/VX855 accelerated framebuffer" you reintroduce initializing those
> bits to 0. That's fine but I can't see a reason for preserving this bits
> here as it adds useless overhead unless the hardware itself changed some
> of those bits and behaves differently according to those bits.

Somehow the cost of an additional MMIO read at mode setting time is
just not going to keep me up at night.

I will admit that I've learned to be rather superstitious when it comes
to messing with reserved bits. Hardware designers like to hide
functionality like "bring down the wrath of the gods" behind such
bits. The old code preserved them and worked, so I did the same. I
don't see any real reason not to keep it.

> Additionally the first 2 bits are not reserved but provide a rotation
> where 00 is what we want (no rotation).

That much is true, yes. My mistake, will fix.

> And if you rip code off hw_bitblt_2 it would be better to do the same
> with hw_bitblt_1. A quick look reveals that the same function can be
> used there (the error message would need to be adjusted but that's minor).

That had crossed my mind; there is quite a bit of duplicated code
between those two very long functions. At the time I was focused on
making things work, and I didn't want to mess with code that I couldn't
actually test. So further cleanup is on my list, but I would prefer to
defer it for a little bit.

Thanks,

jon

Jonathan Corbet

unread,
Apr 9, 2010, 4:20:02 PM4/9/10
to
On Fri, 09 Apr 2010 05:20:28 +0200

Florian Tobias Schandinat <FlorianS...@gmx.de> wrote:

> Just a minor nit:
> Could we change the default so that if someone adds support for a new
> IGP (and misses this function) we default to either the newest or
> preferably to none? I've just seen too much poorly maintained code in
> this driver and defaulting to the oldest is hence a bad idea.
> Otherwise it's fine.

That would require making an exhaustive list of older chipset types.
It could probably be inferred through inspection of the code, but I
worry about making assumptions in this area...

Thanks,

jon

Florian Tobias Schandinat

unread,
Apr 9, 2010, 4:30:02 PM4/9/10
to
Hi Jon,

Jonathan Corbet schrieb:


> On Fri, 09 Apr 2010 05:07:34 +0200
> Florian Tobias Schandinat <FlorianS...@gmx.de> wrote:
>
>> in your later patch "[PATCH 06/16] viafb: complete support for
>> VX800/VX855 accelerated framebuffer" you reintroduce initializing those
>> bits to 0. That's fine but I can't see a reason for preserving this bits
>> here as it adds useless overhead unless the hardware itself changed some
>> of those bits and behaves differently according to those bits.
>
> Somehow the cost of an additional MMIO read at mode setting time is
> just not going to keep me up at night.

Well it's not only mode setting its for each hardware accelerated
operation, but...

> I will admit that I've learned to be rather superstitious when it comes
> to messing with reserved bits. Hardware designers like to hide
> functionality like "bring down the wrath of the gods" behind such
> bits. The old code preserved them and worked, so I did the same. I
> don't see any real reason not to keep it.

...if you insist on it its okay with me. I still disagree but its
nothing I can't live with.

>> Additionally the first 2 bits are not reserved but provide a rotation
>> where 00 is what we want (no rotation).
>
> That much is true, yes. My mistake, will fix.
>
>> And if you rip code off hw_bitblt_2 it would be better to do the same
>> with hw_bitblt_1. A quick look reveals that the same function can be
>> used there (the error message would need to be adjusted but that's minor).
>
> That had crossed my mind; there is quite a bit of duplicated code
> between those two very long functions. At the time I was focused on
> making things work, and I didn't want to mess with code that I couldn't
> actually test. So further cleanup is on my list, but I would prefer to
> defer it for a little bit.

The code (and the spec regarding the reserved bits also) is obviously
identical so please don't ignore it. If you decide to put it in a
separate function please do so for both blit engines especially if they
really do the same as in this case. As you say they are mostly identical
and that's by design. Please keep them in sync if possible. They exist
that way to be a stateless and to avoid cluttering if's around.
(no need to say that I'll test those patches on my CLE266 and VX800 as
soon as they apply cleanly to mainline)


Thanks,

Florian Tobias Schandinat

Florian Tobias Schandinat

unread,
Apr 9, 2010, 4:40:01 PM4/9/10
to
Jonathan Corbet schrieb:

> On Fri, 09 Apr 2010 05:20:28 +0200
> Florian Tobias Schandinat <FlorianS...@gmx.de> wrote:
>
>> Just a minor nit:
>> Could we change the default so that if someone adds support for a new
>> IGP (and misses this function) we default to either the newest or
>> preferably to none? I've just seen too much poorly maintained code in
>> this driver and defaulting to the oldest is hence a bad idea.
>> Otherwise it's fine.
>
> That would require making an exhaustive list of older chipset types.
> It could probably be inferred through inspection of the code, but I
> worry about making assumptions in this area...

Such list already exists. gfx_chip_name = pdi->driver_data in hw.c (and
only there) so what is needed is the list viafb_pci_table in viafbdev.c
(relatively at the end) of all chips:
UNICHROME_CLE266
UNICHROME_PM800
UNICHROME_K400
UNICHROME_K800
UNICHROME_CN700
UNICHROME_K8M890
UNICHROME_CX700
UNICHROME_P4M900
UNICHROME_CN750
UNICHROME_VX800
UNICHROME_VX855

Would appreciate it if you could use this info.


Thanks,

Florian Tobias Schandinat

Jonathan Corbet

unread,
Apr 9, 2010, 4:40:01 PM4/9/10
to
On Fri, 09 Apr 2010 22:23:06 +0200
Florian Tobias Schandinat <FlorianS...@gmx.de> wrote:

> > That had crossed my mind; there is quite a bit of duplicated code
> > between those two very long functions. At the time I was focused on
> > making things work, and I didn't want to mess with code that I couldn't
> > actually test. So further cleanup is on my list, but I would prefer to
> > defer it for a little bit.
>
> The code (and the spec regarding the reserved bits also) is obviously
> identical so please don't ignore it.

In fact, I already came to this conclusion and have added a patch to
have both functions use the same code.

Thanks,

jon

Florian Tobias Schandinat

unread,
Apr 9, 2010, 6:10:02 PM4/9/10
to
This patch is fine.


Thanks,

Florian Tobias Schandinat

Jonathan Corbet schrieb:

--

Florian Tobias Schandinat

unread,
Apr 9, 2010, 6:10:01 PM4/9/10
to
Jonathan Corbet schrieb:

> From: Harald Welte <laf...@gnumonks.org>
>
> This patch changes the way how the various I2C busses are used internally
> inside the viafb driver: Previosuly, only a single i2c_adapter was created,
> even thougt two different hardware I2C busses are accessed: A structure member
> in a global variable was modified to indicate the bus to be used.
>
> Now, all existing hardware busses are registered with the i2c core, and the
> viafb_i2c_{read,write}byte[s]() function take the adapter number as function
> call parameter, rather than referring to the global structure member.
>
> [jc: even more painful merge with mainline changes ->2.6.34]
> [jc: painful merge with OLPC changes]

I don't know I2C too well and this patch has certainly its issues (the
FIXMEs, the hardcoded VIAFB_NUM_I2C, probably others) but in general it
looks okay. Therefore I think it should be merged and the issues should
be fixed afterwards.


Thanks,

Florian Tobias Schandinat

--

Harald Welte

unread,
Apr 10, 2010, 3:10:01 AM4/10/10
to
Hi Jon + Florian,

On Fri, Apr 09, 2010 at 01:46:10PM -0600, Jonathan Corbet wrote:
> On Thu, 08 Apr 2010 20:42:17 +0200
> Florian Tobias Schandinat <FlorianS...@gmx.de> wrote:
>
> > something I am wondering about is whether we can't simply do:
> > viaparinfo->memsize = pci_resource_len(pdev, 0);
> > I suppose that this is not possible meaning that the pci len can be
> > longer than the actual memory but I just wanted to use the moment to
> > make sure.
>
> That would make sense. But if somebody who is closer to the hardware than
> I am doesn't take that approach, I'm nervous about changing it. Harald?

I believe it is not safe to simply use the pci_resource_len(pdev, 0).

At least in some of the hardware I've been working with in the past, the
PCI resource length was always fixed, independent of how large the BIOS
configured the shared video memory.

So please don't use that method.

Regards,
Harald
--
- Harald Welte <laf...@gnumonks.org> http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)

Jonathan Corbet

unread,
Apr 18, 2010, 1:40:01 PM4/18/10
to
[Getting back to the older stuff...]

On Fri, 09 Apr 2010 22:34:16 +0200


Florian Tobias Schandinat <FlorianS...@gmx.de> wrote:

> >> Just a minor nit:
> >> Could we change the default so that if someone adds support for a new
> >> IGP (and misses this function) we default to either the newest or
> >> preferably to none? I've just seen too much poorly maintained code in
> >> this driver and defaulting to the oldest is hence a bad idea.
> >> Otherwise it's fine.
> >
> > That would require making an exhaustive list of older chipset types.
> > It could probably be inferred through inspection of the code, but I
> > worry about making assumptions in this area...
>
> Such list already exists. gfx_chip_name = pdi->driver_data in hw.c (and
> only there) so what is needed is the list viafb_pci_table in viafbdev.c
> (relatively at the end) of all chips:

I've spent a bit of time looking at this. What's really needed is a
better way of abstracting the chip types so that we can maybe get rid
of all those switch statements throughout the driver. For the purposes
of getting this work in, I'm not quite prepared to make that change,
though I could certainly consider doing it in the future.

In the absence of that, the only course of action which makes sense is
to simply fail the initialization if an unknown chip type shows up
there. That's easy, and I can do it. But, given that this was a
"minor nit," can we leave it as-is for now? There's a *lot* of things
to clean up in this driver, I'd like to make it better a step at a time
rather than trying to do the whole thing at once.

Thanks,

jon

Florian Tobias Schandinat

unread,
Apr 18, 2010, 2:10:01 PM4/18/10
to
Jonathan Corbet schrieb:

> [Getting back to the older stuff...]
>
> On Fri, 09 Apr 2010 22:34:16 +0200
> Florian Tobias Schandinat <FlorianS...@gmx.de> wrote:
>
>>>> Just a minor nit:
>>>> Could we change the default so that if someone adds support for a new
>>>> IGP (and misses this function) we default to either the newest or
>>>> preferably to none? I've just seen too much poorly maintained code in
>>>> this driver and defaulting to the oldest is hence a bad idea.
>>>> Otherwise it's fine.
>
> In the absence of that, the only course of action which makes sense is
> to simply fail the initialization if an unknown chip type shows up
> there. That's easy, and I can do it. But, given that this was a
> "minor nit," can we leave it as-is for now?

Yes, if you feel too uncomfortable with changing it and agree that the
whole stuff should be made more maintainable later on I am okay with
letting this in as is.

> There's a *lot* of things to clean up in this driver, I'd like to make it
> better a step at a time rather than trying to do the whole thing at once.

This is indeed very true.


Thanks,

Florian Tobias Schandinat

Harald Welte

unread,
Apr 18, 2010, 4:10:02 PM4/18/10
to
Hi!

On Sun, Apr 18, 2010 at 11:34:30AM -0600, Jonathan Corbet wrote:

> In the absence of that, the only course of action which makes sense is
> to simply fail the initialization if an unknown chip type shows up
> there. That's easy, and I can do it. But, given that this was a
> "minor nit," can we leave it as-is for now? There's a *lot* of things
> to clean up in this driver, I'd like to make it better a step at a time
> rather than trying to do the whole thing at once.

i agree with that step by step strategy.

I always felt conservative about making too big changes. After all, it is hard
to find people who actually own and use all those various models of graphics
chips, and even more so: who want to try + test recent mainline and check for
regressions :(

VIA's resources are extremely limited, and they can barely complete the work
required for new products... I know it's unfortunate, but VIA is a very small
company.

Regards,
Harald
--
- Harald Welte <laf...@gnumonks.org> http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)

0 new messages