* [PATCH 2/7] viafb: unify modesetting functions
2010-04-17 19:44 [PATCH 1/7] viafb: package often used basic io functions Florian Tobias Schandinat
@ 2010-04-17 19:44 ` Florian Tobias Schandinat
2010-04-17 19:44 ` [PATCH 3/7] viafb: move some modesetting functions to a seperate file Florian Tobias Schandinat
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Florian Tobias Schandinat @ 2010-04-17 19:44 UTC (permalink / raw)
To: linux-kernel
Cc: linux-fbdev, JosephChan, ScottFang, corbet, Florian Tobias Schandinat
viafb: unify modesetting functions
This patch unifies some cleaned up modesetting functions to prepare for
moving them to an extra file. This includes make them use via_io and
changing there names to reflect that they do not depend on anything
framebuffer specific.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
---
drivers/video/via/hw.c | 66 +++++++++++++++++++++---------------------
drivers/video/via/hw.h | 8 ++--
drivers/video/via/viafbdev.c | 17 ++++++-----
3 files changed, 46 insertions(+), 45 deletions(-)
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index 32742dd..6c6c140 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -624,50 +624,50 @@ void viafb_set_iga_path(void)
}
}
-void viafb_set_primary_address(u32 addr)
+void via_set_primary_address(u32 addr)
{
- DEBUG_MSG(KERN_DEBUG "viafb_set_primary_address(0x%08X)\n", addr);
- viafb_write_reg(CR0D, VIACR, addr & 0xFF);
- viafb_write_reg(CR0C, VIACR, (addr >> 8) & 0xFF);
- viafb_write_reg(CR34, VIACR, (addr >> 16) & 0xFF);
- viafb_write_reg_mask(CR48, VIACR, (addr >> 24) & 0x1F, 0x1F);
+ DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr);
+ via_write_reg(VIACR, 0x0D, addr & 0xFF);
+ via_write_reg(VIACR, 0x0C, (addr >> 8) & 0xFF);
+ via_write_reg(VIACR, 0x34, (addr >> 16) & 0xFF);
+ via_write_reg_mask(VIACR, 0x48, (addr >> 24) & 0x1F, 0x1F);
}
-void viafb_set_secondary_address(u32 addr)
+void via_set_secondary_address(u32 addr)
{
- DEBUG_MSG(KERN_DEBUG "viafb_set_secondary_address(0x%08X)\n", addr);
+ DEBUG_MSG(KERN_DEBUG "via_set_secondary_address(0x%08X)\n", addr);
/* secondary display supports only quadword aligned memory */
- viafb_write_reg_mask(CR62, VIACR, (addr >> 2) & 0xFE, 0xFE);
- viafb_write_reg(CR63, VIACR, (addr >> 10) & 0xFF);
- viafb_write_reg(CR64, VIACR, (addr >> 18) & 0xFF);
- viafb_write_reg_mask(CRA3, VIACR, (addr >> 26) & 0x07, 0x07);
+ via_write_reg_mask(VIACR, 0x62, (addr >> 2) & 0xFE, 0xFE);
+ via_write_reg(VIACR, 0x63, (addr >> 10) & 0xFF);
+ via_write_reg(VIACR, 0x64, (addr >> 18) & 0xFF);
+ via_write_reg_mask(VIACR, 0xA3, (addr >> 26) & 0x07, 0x07);
}
-void viafb_set_primary_pitch(u32 pitch)
+void via_set_primary_pitch(u32 pitch)
{
- DEBUG_MSG(KERN_DEBUG "viafb_set_primary_pitch(0x%08X)\n", pitch);
+ DEBUG_MSG(KERN_DEBUG "via_set_primary_pitch(0x%08X)\n", pitch);
/* spec does not say that first adapter skips 3 bits but old
* code did it and seems to be reasonable in analogy to 2nd adapter
*/
pitch = pitch >> 3;
- viafb_write_reg(0x13, VIACR, pitch & 0xFF);
- viafb_write_reg_mask(0x35, VIACR, (pitch >> (8 - 5)) & 0xE0, 0xE0);
+ via_write_reg(VIACR, 0x13, pitch & 0xFF);
+ via_write_reg_mask(VIACR, 0x35, (pitch >> (8 - 5)) & 0xE0, 0xE0);
}
-void viafb_set_secondary_pitch(u32 pitch)
+void via_set_secondary_pitch(u32 pitch)
{
- DEBUG_MSG(KERN_DEBUG "viafb_set_secondary_pitch(0x%08X)\n", pitch);
+ DEBUG_MSG(KERN_DEBUG "via_set_secondary_pitch(0x%08X)\n", pitch);
pitch = pitch >> 3;
- viafb_write_reg(0x66, VIACR, pitch & 0xFF);
- viafb_write_reg_mask(0x67, VIACR, (pitch >> 8) & 0x03, 0x03);
- viafb_write_reg_mask(0x71, VIACR, (pitch >> (10 - 7)) & 0x80, 0x80);
+ via_write_reg(VIACR, 0x66, pitch & 0xFF);
+ via_write_reg_mask(VIACR, 0x67, (pitch >> 8) & 0x03, 0x03);
+ via_write_reg_mask(VIACR, 0x71, (pitch >> (10 - 7)) & 0x80, 0x80);
}
-void viafb_set_primary_color_depth(u8 depth)
+void via_set_primary_color_depth(u8 depth)
{
u8 value;
- DEBUG_MSG(KERN_DEBUG "viafb_set_primary_color_depth(%d)\n", depth);
+ DEBUG_MSG(KERN_DEBUG "via_set_primary_color_depth(%d)\n", depth);
switch (depth) {
case 8:
value = 0x00;
@@ -685,19 +685,19 @@ void viafb_set_primary_color_depth(u8 depth)
value = 0x08;
break;
default:
- printk(KERN_WARNING "viafb_set_primary_color_depth: "
+ printk(KERN_WARNING "via_set_primary_color_depth: "
"Unsupported depth: %d\n", depth);
return;
}
- viafb_write_reg_mask(0x15, VIASR, value, 0x1C);
+ via_write_reg_mask(VIASR, 0x15, value, 0x1C);
}
-void viafb_set_secondary_color_depth(u8 depth)
+void via_set_secondary_color_depth(u8 depth)
{
u8 value;
- DEBUG_MSG(KERN_DEBUG "viafb_set_secondary_color_depth(%d)\n", depth);
+ DEBUG_MSG(KERN_DEBUG "via_set_secondary_color_depth(%d)\n", depth);
switch (depth) {
case 8:
value = 0x00;
@@ -712,12 +712,12 @@ void viafb_set_secondary_color_depth(u8 depth)
value = 0x80;
break;
default:
- printk(KERN_WARNING "viafb_set_secondary_color_depth: "
+ printk(KERN_WARNING "via_set_secondary_color_depth: "
"Unsupported depth: %d\n", depth);
return;
}
- viafb_write_reg_mask(0x67, VIACR, value, 0xC0);
+ via_write_reg_mask(VIACR, 0x67, value, 0xC0);
}
static void set_color_register(u8 index, u8 red, u8 green, u8 blue)
@@ -2255,11 +2255,11 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
}
}
- viafb_set_primary_pitch(viafbinfo->fix.line_length);
- viafb_set_secondary_pitch(viafb_dual_fb ? viafbinfo1->fix.line_length
+ via_set_primary_pitch(viafbinfo->fix.line_length);
+ via_set_secondary_pitch(viafb_dual_fb ? viafbinfo1->fix.line_length
: viafbinfo->fix.line_length);
- viafb_set_primary_color_depth(viaparinfo->depth);
- viafb_set_secondary_color_depth(viafb_dual_fb ? viaparinfo1->depth
+ via_set_primary_color_depth(viaparinfo->depth);
+ via_set_secondary_color_depth(viafb_dual_fb ? viaparinfo1->depth
: viaparinfo->depth);
/* Update Refresh Rate Setting */
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h
index f0c202d..cb63f22 100644
--- a/drivers/video/via/hw.h
+++ b/drivers/video/via/hw.h
@@ -912,10 +912,10 @@ void viafb_update_device_setting(int hres, int vres, int bpp,
int viafb_get_fb_size_from_pci(void);
void viafb_set_iga_path(void);
-void viafb_set_primary_address(u32 addr);
-void viafb_set_secondary_address(u32 addr);
-void viafb_set_primary_pitch(u32 pitch);
-void viafb_set_secondary_pitch(u32 pitch);
+void via_set_primary_address(u32 addr);
+void via_set_secondary_address(u32 addr);
+void via_set_primary_pitch(u32 pitch);
+void via_set_secondary_pitch(u32 pitch);
void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue);
void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue);
void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len);
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 777b38a..c6c01ef 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -317,12 +317,12 @@ static int viafb_pan_display(struct fb_var_screeninfo *var,
DEBUG_MSG(KERN_DEBUG "viafb_pan_display, address = %d\n", vram_addr);
if (!viafb_dual_fb) {
- viafb_set_primary_address(vram_addr);
- viafb_set_secondary_address(vram_addr);
+ via_set_primary_address(vram_addr);
+ via_set_secondary_address(vram_addr);
} else if (viapar->iga_path == IGA1)
- viafb_set_primary_address(vram_addr);
+ via_set_primary_address(vram_addr);
else
- viafb_set_secondary_address(vram_addr);
+ via_set_secondary_address(vram_addr);
return 0;
}
@@ -1018,8 +1018,8 @@ static void viafb_set_device(struct device_t active_dev)
viafb_SAMM_ON = active_dev.samm;
viafb_primary_dev = active_dev.primary_dev;
- viafb_set_primary_address(0);
- viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
+ via_set_primary_address(0);
+ via_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
viafb_set_iga_path();
}
@@ -1165,8 +1165,9 @@ static int apply_device_setting(struct viafb_ioctl_setting setting_info,
if (viafb_SAMM_ON)
viafb_primary_dev = setting_info.primary_device;
- viafb_set_primary_address(0);
- viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
+ via_set_primary_address(0);
+ via_set_secondary_address(viafb_SAMM_ON ?
+ viafb_second_offset : 0);
viafb_set_iga_path();
}
need_set_mode = 1;
--
1.6.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/7] viafb: move some modesetting functions to a seperate file
2010-04-17 19:44 [PATCH 1/7] viafb: package often used basic io functions Florian Tobias Schandinat
2010-04-17 19:44 ` [PATCH 2/7] viafb: unify modesetting functions Florian Tobias Schandinat
@ 2010-04-17 19:44 ` Florian Tobias Schandinat
2010-04-17 19:44 ` [PATCH 4/7] viafb: replace inb/outb Florian Tobias Schandinat
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Florian Tobias Schandinat @ 2010-04-17 19:44 UTC (permalink / raw)
To: linux-kernel
Cc: linux-fbdev, JosephChan, ScottFang, corbet, Florian Tobias Schandinat
viafb: move some modesetting functions to a seperate file
This patch moves the modesetting functions which are already cleaned up
to a seperate file.
Just the beginning to bring some structure in this mess.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
---
drivers/video/via/Makefile | 2 +-
drivers/video/via/hw.c | 96 --------------------------
drivers/video/via/hw.h | 5 +-
drivers/video/via/via_modesetting.c | 126 +++++++++++++++++++++++++++++++++++
drivers/video/via/via_modesetting.h | 38 +++++++++++
5 files changed, 166 insertions(+), 101 deletions(-)
create mode 100644 drivers/video/via/via_modesetting.c
create mode 100644 drivers/video/via/via_modesetting.h
diff --git a/drivers/video/via/Makefile b/drivers/video/via/Makefile
index eeed238..6f5b010 100644
--- a/drivers/video/via/Makefile
+++ b/drivers/video/via/Makefile
@@ -4,4 +4,4 @@
obj-$(CONFIG_FB_VIA) += viafb.o
-viafb-y :=viafbdev.o hw.o via_i2c.o dvi.o lcd.o ioctl.o accel.o via_utility.o vt1636.o global.o tblDPASetting.o viamode.o tbl1636.o
+viafb-y :=viafbdev.o hw.o via_i2c.o dvi.o lcd.o ioctl.o accel.o via_utility.o vt1636.o global.o tblDPASetting.o viamode.o tbl1636.o via_modesetting.o
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index 6c6c140..1c3a8f3 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -624,102 +624,6 @@ void viafb_set_iga_path(void)
}
}
-void via_set_primary_address(u32 addr)
-{
- DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr);
- via_write_reg(VIACR, 0x0D, addr & 0xFF);
- via_write_reg(VIACR, 0x0C, (addr >> 8) & 0xFF);
- via_write_reg(VIACR, 0x34, (addr >> 16) & 0xFF);
- via_write_reg_mask(VIACR, 0x48, (addr >> 24) & 0x1F, 0x1F);
-}
-
-void via_set_secondary_address(u32 addr)
-{
- DEBUG_MSG(KERN_DEBUG "via_set_secondary_address(0x%08X)\n", addr);
- /* secondary display supports only quadword aligned memory */
- via_write_reg_mask(VIACR, 0x62, (addr >> 2) & 0xFE, 0xFE);
- via_write_reg(VIACR, 0x63, (addr >> 10) & 0xFF);
- via_write_reg(VIACR, 0x64, (addr >> 18) & 0xFF);
- via_write_reg_mask(VIACR, 0xA3, (addr >> 26) & 0x07, 0x07);
-}
-
-void via_set_primary_pitch(u32 pitch)
-{
- DEBUG_MSG(KERN_DEBUG "via_set_primary_pitch(0x%08X)\n", pitch);
- /* spec does not say that first adapter skips 3 bits but old
- * code did it and seems to be reasonable in analogy to 2nd adapter
- */
- pitch = pitch >> 3;
- via_write_reg(VIACR, 0x13, pitch & 0xFF);
- via_write_reg_mask(VIACR, 0x35, (pitch >> (8 - 5)) & 0xE0, 0xE0);
-}
-
-void via_set_secondary_pitch(u32 pitch)
-{
- DEBUG_MSG(KERN_DEBUG "via_set_secondary_pitch(0x%08X)\n", pitch);
- pitch = pitch >> 3;
- via_write_reg(VIACR, 0x66, pitch & 0xFF);
- via_write_reg_mask(VIACR, 0x67, (pitch >> 8) & 0x03, 0x03);
- via_write_reg_mask(VIACR, 0x71, (pitch >> (10 - 7)) & 0x80, 0x80);
-}
-
-void via_set_primary_color_depth(u8 depth)
-{
- u8 value;
-
- DEBUG_MSG(KERN_DEBUG "via_set_primary_color_depth(%d)\n", depth);
- switch (depth) {
- case 8:
- value = 0x00;
- break;
- case 15:
- value = 0x04;
- break;
- case 16:
- value = 0x14;
- break;
- case 24:
- value = 0x0C;
- break;
- case 30:
- value = 0x08;
- break;
- default:
- printk(KERN_WARNING "via_set_primary_color_depth: "
- "Unsupported depth: %d\n", depth);
- return;
- }
-
- via_write_reg_mask(VIASR, 0x15, value, 0x1C);
-}
-
-void via_set_secondary_color_depth(u8 depth)
-{
- u8 value;
-
- DEBUG_MSG(KERN_DEBUG "via_set_secondary_color_depth(%d)\n", depth);
- switch (depth) {
- case 8:
- value = 0x00;
- break;
- case 16:
- value = 0x40;
- break;
- case 24:
- value = 0xC0;
- break;
- case 30:
- value = 0x80;
- break;
- default:
- printk(KERN_WARNING "via_set_secondary_color_depth: "
- "Unsupported depth: %d\n", depth);
- return;
- }
-
- via_write_reg_mask(VIACR, 0x67, value, 0xC0);
-}
-
static void set_color_register(u8 index, u8 red, u8 green, u8 blue)
{
outb(0xFF, 0x3C6); /* bit mask of palette */
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h
index cb63f22..ddd15df 100644
--- a/drivers/video/via/hw.h
+++ b/drivers/video/via/hw.h
@@ -25,6 +25,7 @@
#include "viamode.h"
#include "global.h"
#include "via_io.h"
+#include "via_modesetting.h"
#define viafb_read_reg(p, i) via_read_reg(p, i)
#define viafb_write_reg(i, p, d) via_write_reg(p, i, d)
@@ -912,10 +913,6 @@ void viafb_update_device_setting(int hres, int vres, int bpp,
int viafb_get_fb_size_from_pci(void);
void viafb_set_iga_path(void);
-void via_set_primary_address(u32 addr);
-void via_set_secondary_address(u32 addr);
-void via_set_primary_pitch(u32 pitch);
-void via_set_secondary_pitch(u32 pitch);
void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue);
void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue);
void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len);
diff --git a/drivers/video/via/via_modesetting.c b/drivers/video/via/via_modesetting.c
new file mode 100644
index 0000000..69ff285
--- /dev/null
+++ b/drivers/video/via/via_modesetting.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
+ * Copyright 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE.See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+/*
+ * basic modesetting functions
+ */
+
+#include <linux/kernel.h>
+#include "via_modesetting.h"
+#include "via_io.h"
+#include "share.h"
+#include "debug.h"
+
+void via_set_primary_address(u32 addr)
+{
+ DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr);
+ via_write_reg(VIACR, 0x0D, addr & 0xFF);
+ via_write_reg(VIACR, 0x0C, (addr >> 8) & 0xFF);
+ via_write_reg(VIACR, 0x34, (addr >> 16) & 0xFF);
+ via_write_reg_mask(VIACR, 0x48, (addr >> 24) & 0x1F, 0x1F);
+}
+
+void via_set_secondary_address(u32 addr)
+{
+ DEBUG_MSG(KERN_DEBUG "via_set_secondary_address(0x%08X)\n", addr);
+ /* secondary display supports only quadword aligned memory */
+ via_write_reg_mask(VIACR, 0x62, (addr >> 2) & 0xFE, 0xFE);
+ via_write_reg(VIACR, 0x63, (addr >> 10) & 0xFF);
+ via_write_reg(VIACR, 0x64, (addr >> 18) & 0xFF);
+ via_write_reg_mask(VIACR, 0xA3, (addr >> 26) & 0x07, 0x07);
+}
+
+void via_set_primary_pitch(u32 pitch)
+{
+ DEBUG_MSG(KERN_DEBUG "via_set_primary_pitch(0x%08X)\n", pitch);
+ /* spec does not say that first adapter skips 3 bits but old
+ * code did it and seems to be reasonable in analogy to 2nd adapter
+ */
+ pitch = pitch >> 3;
+ via_write_reg(VIACR, 0x13, pitch & 0xFF);
+ via_write_reg_mask(VIACR, 0x35, (pitch >> (8 - 5)) & 0xE0, 0xE0);
+}
+
+void via_set_secondary_pitch(u32 pitch)
+{
+ DEBUG_MSG(KERN_DEBUG "via_set_secondary_pitch(0x%08X)\n", pitch);
+ pitch = pitch >> 3;
+ via_write_reg(VIACR, 0x66, pitch & 0xFF);
+ via_write_reg_mask(VIACR, 0x67, (pitch >> 8) & 0x03, 0x03);
+ via_write_reg_mask(VIACR, 0x71, (pitch >> (10 - 7)) & 0x80, 0x80);
+}
+
+void via_set_primary_color_depth(u8 depth)
+{
+ u8 value;
+
+ DEBUG_MSG(KERN_DEBUG "via_set_primary_color_depth(%d)\n", depth);
+ switch (depth) {
+ case 8:
+ value = 0x00;
+ break;
+ case 15:
+ value = 0x04;
+ break;
+ case 16:
+ value = 0x14;
+ break;
+ case 24:
+ value = 0x0C;
+ break;
+ case 30:
+ value = 0x08;
+ break;
+ default:
+ printk(KERN_WARNING "via_set_primary_color_depth: "
+ "Unsupported depth: %d\n", depth);
+ return;
+ }
+
+ via_write_reg_mask(VIASR, 0x15, value, 0x1C);
+}
+
+void via_set_secondary_color_depth(u8 depth)
+{
+ u8 value;
+
+ DEBUG_MSG(KERN_DEBUG "via_set_secondary_color_depth(%d)\n", depth);
+ switch (depth) {
+ case 8:
+ value = 0x00;
+ break;
+ case 16:
+ value = 0x40;
+ break;
+ case 24:
+ value = 0xC0;
+ break;
+ case 30:
+ value = 0x80;
+ break;
+ default:
+ printk(KERN_WARNING "via_set_secondary_color_depth: "
+ "Unsupported depth: %d\n", depth);
+ return;
+ }
+
+ via_write_reg_mask(VIACR, 0x67, value, 0xC0);
+}
diff --git a/drivers/video/via/via_modesetting.h b/drivers/video/via/via_modesetting.h
new file mode 100644
index 0000000..ae35cfd
--- /dev/null
+++ b/drivers/video/via/via_modesetting.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
+ * Copyright 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE.See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+/*
+ * basic modesetting functions
+ */
+
+#ifndef __VIA_MODESETTING_H__
+#define __VIA_MODESETTING_H__
+
+#include <linux/types.h>
+
+void via_set_primary_address(u32 addr);
+void via_set_secondary_address(u32 addr);
+void via_set_primary_pitch(u32 pitch);
+void via_set_secondary_pitch(u32 pitch);
+void via_set_primary_color_depth(u8 depth);
+void via_set_secondary_color_depth(u8 depth);
+
+#endif /* __VIA_MODESETTING_H__ */
--
1.6.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/7] viafb: replace inb/outb
2010-04-17 19:44 [PATCH 1/7] viafb: package often used basic io functions Florian Tobias Schandinat
2010-04-17 19:44 ` [PATCH 2/7] viafb: unify modesetting functions Florian Tobias Schandinat
2010-04-17 19:44 ` [PATCH 3/7] viafb: move some modesetting functions to a seperate file Florian Tobias Schandinat
@ 2010-04-17 19:44 ` Florian Tobias Schandinat
2010-04-17 19:44 ` [PATCH 5/7] viafb: improve misc register handling Florian Tobias Schandinat
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Florian Tobias Schandinat @ 2010-04-17 19:44 UTC (permalink / raw)
To: linux-kernel
Cc: linux-fbdev, JosephChan, ScottFang, corbet, Florian Tobias Schandinat
viafb: replace inb/outb
This patch replaces occurences of inb/outb with via_write_reg and
via_write_reg_mask where this is possible to improve code
readability.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
---
drivers/video/via/hw.c | 22 +++++++---------------
1 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index 1c3a8f3..41628c8 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -1008,16 +1008,12 @@ void viafb_load_reg(int timing_value, int viafb_load_reg_num,
void viafb_write_regx(struct io_reg RegTable[], int ItemNum)
{
int i;
- unsigned char RegTemp;
/*DEBUG_MSG(KERN_INFO "Table Size : %x!!\n",ItemNum ); */
- for (i = 0; i < ItemNum; i++) {
- outb(RegTable[i].index, RegTable[i].port);
- RegTemp = inb(RegTable[i].port + 1);
- RegTemp = (RegTemp & (~RegTable[i].mask)) | RegTable[i].value;
- outb(RegTemp, RegTable[i].port + 1);
- }
+ for (i = 0; i < ItemNum; i++)
+ via_write_reg_mask(RegTable[i].port, RegTable[i].index,
+ RegTable[i].value, RegTable[i].mask);
}
void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga)
@@ -2117,10 +2113,8 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
outb(VPIT.Misc, VIAWMisc);
/* Write Sequencer */
- for (i = 1; i <= StdSR; i++) {
- outb(i, VIASR);
- outb(VPIT.SR[i - 1], VIASR + 1);
- }
+ for (i = 1; i <= StdSR; i++)
+ via_write_reg(VIASR, i, VPIT.SR[i - 1]);
viafb_write_reg_mask(0x15, VIASR, 0xA2, 0xA2);
viafb_set_iga_path();
@@ -2129,10 +2123,8 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
viafb_fill_crtc_timing(crt_timing, vmode_tbl, video_bpp / 8, IGA1);
/* Write Graphic Controller */
- for (i = 0; i < StdGR; i++) {
- outb(i, VIAGR);
- outb(VPIT.GR[i], VIAGR + 1);
- }
+ for (i = 0; i < StdGR; i++)
+ via_write_reg(VIAGR, i, VPIT.GR[i]);
/* Write Attribute Controller */
for (i = 0; i < StdAR; i++) {
--
1.6.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/7] viafb: improve misc register handling
2010-04-17 19:44 [PATCH 1/7] viafb: package often used basic io functions Florian Tobias Schandinat
` (2 preceding siblings ...)
2010-04-17 19:44 ` [PATCH 4/7] viafb: replace inb/outb Florian Tobias Schandinat
@ 2010-04-17 19:44 ` Florian Tobias Schandinat
2010-04-17 19:44 ` [PATCH 6/7] viafb: fix proc entry removal Florian Tobias Schandinat
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Florian Tobias Schandinat @ 2010-04-17 19:44 UTC (permalink / raw)
To: linux-kernel
Cc: linux-fbdev, JosephChan, ScottFang, corbet, Florian Tobias Schandinat
viafb: improve misc register handling
This patch improves the misc register handling by adding a modify
function for this to via_io.h and moving expanded definitions of the
relevant ports there. The code was changed to use those to improve
readability.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
---
drivers/video/via/hw.c | 27 ++++++++-------------------
drivers/video/via/share.h | 2 --
drivers/video/via/via_io.h | 9 +++++++++
3 files changed, 17 insertions(+), 21 deletions(-)
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index 41628c8..a56d624 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -1394,8 +1394,6 @@ u32 viafb_get_clk_value(int clk)
/* Set VCLK*/
void viafb_set_vclock(u32 CLK, int set_iga)
{
- unsigned char RegTemp;
-
/* H.W. Reset : ON */
viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7);
@@ -1468,8 +1466,7 @@ void viafb_set_vclock(u32 CLK, int set_iga)
}
/* Fire! */
- RegTemp = inb(VIARMisc);
- outb(RegTemp | (BIT2 + BIT3), VIAWMisc);
+ via_write_misc_reg_mask(0x0C, 0x0C); /* select external clock */
}
void viafb_load_crtc_timing(struct display_timing device_timing,
@@ -1713,6 +1710,7 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
int index = 0;
int h_addr, v_addr;
u32 pll_D_N;
+ u8 polarity = 0;
for (i = 0; i < video_mode->mode_array; i++) {
index = i;
@@ -1741,20 +1739,11 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
v_addr = crt_reg.ver_addr;
/* update polarity for CRT timing */
- if (crt_table[index].h_sync_polarity == NEGATIVE) {
- if (crt_table[index].v_sync_polarity == NEGATIVE)
- outb((inb(VIARMisc) & (~(BIT6 + BIT7))) |
- (BIT6 + BIT7), VIAWMisc);
- else
- outb((inb(VIARMisc) & (~(BIT6 + BIT7))) | (BIT6),
- VIAWMisc);
- } else {
- if (crt_table[index].v_sync_polarity == NEGATIVE)
- outb((inb(VIARMisc) & (~(BIT6 + BIT7))) | (BIT7),
- VIAWMisc);
- else
- outb((inb(VIARMisc) & (~(BIT6 + BIT7))), VIAWMisc);
- }
+ if (crt_table[index].h_sync_polarity == NEGATIVE)
+ polarity |= BIT6;
+ if (crt_table[index].v_sync_polarity == NEGATIVE)
+ polarity |= BIT7;
+ via_write_misc_reg_mask(polarity, BIT6 | BIT7);
if (set_iga == IGA1) {
viafb_unlock_crt();
@@ -2110,7 +2099,7 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
/* Fill VPIT Parameters */
/* Write Misc Register */
- outb(VPIT.Misc, VIAWMisc);
+ outb(VPIT.Misc, VIA_MISC_REG_WRITE);
/* Write Sequencer */
for (i = 1; i <= StdSR; i++)
diff --git a/drivers/video/via/share.h b/drivers/video/via/share.h
index d55aaa7..16b92f9 100644
--- a/drivers/video/via/share.h
+++ b/drivers/video/via/share.h
@@ -45,8 +45,6 @@
/* standard VGA IO port
*/
-#define VIARMisc 0x3CC
-#define VIAWMisc 0x3C2
#define VIAStatus 0x3DA
#define VIACR 0x3D4
#define VIASR 0x3C4
diff --git a/drivers/video/via/via_io.h b/drivers/video/via/via_io.h
index 9dc112b..d76138c 100644
--- a/drivers/video/via/via_io.h
+++ b/drivers/video/via/via_io.h
@@ -29,6 +29,9 @@
#include <linux/types.h>
#include <linux/io.h>
+#define VIA_MISC_REG_READ 0x03CC
+#define VIA_MISC_REG_WRITE 0x03C2
+
static inline u8 via_read_reg(u16 port, u8 index)
{
outb(index, port);
@@ -50,4 +53,10 @@ static inline void via_write_reg_mask(u16 port, u8 index, u8 data, u8 mask)
outb((data & mask) | (old & ~mask), port + 1);
}
+static inline void via_write_misc_reg_mask(u8 data, u8 mask)
+{
+ u8 old = inb(VIA_MISC_REG_READ);
+ outb((data & mask) | (old & ~mask), VIA_MISC_REG_WRITE);
+}
+
#endif /* __VIA_IO_H__ */
--
1.6.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/7] viafb: fix proc entry removal
2010-04-17 19:44 [PATCH 1/7] viafb: package often used basic io functions Florian Tobias Schandinat
` (3 preceding siblings ...)
2010-04-17 19:44 ` [PATCH 5/7] viafb: improve misc register handling Florian Tobias Schandinat
@ 2010-04-17 19:44 ` Florian Tobias Schandinat
2010-04-17 19:44 ` [PATCH 7/7] viafb: make procfs entries optional Florian Tobias Schandinat
2010-04-17 20:40 ` [PATCH 1/7] viafb: package often used basic io functions Jonathan Corbet
6 siblings, 0 replies; 9+ messages in thread
From: Florian Tobias Schandinat @ 2010-04-17 19:44 UTC (permalink / raw)
To: linux-kernel
Cc: linux-fbdev, JosephChan, ScottFang, corbet, Florian Tobias Schandinat
viafb: fix proc entry removal
Trying to remove unregistered proc entries became painful and is
useless anyway. So remove the removal of an entry that was never
registered and duplicate the logic for one which is added
conditionally. Additionally move the removal above releasing fb_info
as we still need the information.
This prevents tainting the kernel by the procfs warn on and
avoiding access to already freed memory is probably also a good idea.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
---
drivers/video/via/viafbdev.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index c6c01ef..457a9b2 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1702,13 +1702,16 @@ static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
}
static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
{
- /* no problem if it was not registered */
+ struct chip_information *chip_info = &viaparinfo->shared->chip_info;
+
remove_proc_entry("dvp0", viafb_entry);/* parent dir */
remove_proc_entry("dvp1", viafb_entry);
remove_proc_entry("dfph", viafb_entry);
remove_proc_entry("dfpl", viafb_entry);
- remove_proc_entry("vt1636", viafb_entry);
- remove_proc_entry("vt1625", viafb_entry);
+ if (chip_info->lvds_chip_info.lvds_chip_name == VT1636_LVDS
+ || chip_info->lvds_chip_info2.lvds_chip_name == VT1636_LVDS)
+ remove_proc_entry("vt1636", viafb_entry);
+
remove_proc_entry("viafb", NULL);
}
@@ -1951,12 +1954,10 @@ static void __devexit via_pci_remove(struct pci_dev *pdev)
iounmap(viaparinfo->shared->engine_mmio);
viafb_delete_i2c_buss(viaparinfo);
-
+ viafb_remove_proc(viaparinfo->shared->proc_entry);
framebuffer_release(viafbinfo);
if (viafb_dual_fb)
framebuffer_release(viafbinfo1);
-
- viafb_remove_proc(viaparinfo->shared->proc_entry);
}
#ifndef MODULE
--
1.6.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 7/7] viafb: make procfs entries optional
2010-04-17 19:44 [PATCH 1/7] viafb: package often used basic io functions Florian Tobias Schandinat
` (4 preceding siblings ...)
2010-04-17 19:44 ` [PATCH 6/7] viafb: fix proc entry removal Florian Tobias Schandinat
@ 2010-04-17 19:44 ` Florian Tobias Schandinat
2010-04-17 20:40 ` [PATCH 1/7] viafb: package often used basic io functions Jonathan Corbet
6 siblings, 0 replies; 9+ messages in thread
From: Florian Tobias Schandinat @ 2010-04-17 19:44 UTC (permalink / raw)
To: linux-kernel
Cc: linux-fbdev, JosephChan, ScottFang, corbet, Florian Tobias Schandinat
viafb: make procfs entries optional
This patch adds a config option to enable procfs entries for direct
hardware access. This was the old behaviour but the option defaults
to no as this is really ugly and should not be needed if the driver
works correct (and if it doesn't, it needs to be fixed).
That stuff is really something that should
- not be needed at all (the driver should be capable of doing it)
- not be there (debugfs would be better for such things)
So add this option just for backwards compatiblity.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
---
drivers/video/Kconfig | 15 +++++++++++++++
drivers/video/via/viafbdev.c | 8 ++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 6e16244..de82639 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1520,6 +1520,21 @@ config FB_VIA
To compile this driver as a module, choose M here: the
module will be called viafb.
+
+if FB_VIA
+
+config FB_VIA_DIRECT_PROCFS
+ bool "direct hardware access via procfs (DEPRECATED)(DANGEROUS)"
+ depends on FB_VIA
+ default n
+ help
+ Allow direct hardware access to some output registers via procfs.
+ This is dangerous but may provide the only chance to get the
+ correct output device configuration.
+ Its use is strongly discouraged.
+
+endif
+
config FB_NEOMAGIC
tristate "NeoMagic display support"
depends on FB && PCI
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 457a9b2..b1323d9 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1326,6 +1326,8 @@ static void parse_dvi_port(void)
output_interface);
}
+#ifdef CONFIG_FB_VIA_DIRECT_PROCFS
+
/*
* The proc filesystem read/write function, a simple proc implement to
* get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
@@ -1715,6 +1717,8 @@ static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
remove_proc_entry("viafb", NULL);
}
+#endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
+
static int parse_mode(const char *str, u32 *xres, u32 *yres)
{
char *ptr;
@@ -1938,7 +1942,9 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
viafbinfo->node, viafbinfo->fix.id, default_var.xres,
default_var.yres, default_var.bits_per_pixel);
+#ifdef CONFIG_FB_VIA_DIRECT_PROCFS
viafb_init_proc(&viaparinfo->shared->proc_entry);
+#endif
viafb_init_dac(IGA2);
return 0;
}
@@ -1954,7 +1960,9 @@ static void __devexit via_pci_remove(struct pci_dev *pdev)
iounmap(viaparinfo->shared->engine_mmio);
viafb_delete_i2c_buss(viaparinfo);
+#ifdef CONFIG_FB_VIA_DIRECT_PROCFS
viafb_remove_proc(viaparinfo->shared->proc_entry);
+#endif
framebuffer_release(viafbinfo);
if (viafb_dual_fb)
framebuffer_release(viafbinfo1);
--
1.6.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] viafb: package often used basic io functions
2010-04-17 19:44 [PATCH 1/7] viafb: package often used basic io functions Florian Tobias Schandinat
` (5 preceding siblings ...)
2010-04-17 19:44 ` [PATCH 7/7] viafb: make procfs entries optional Florian Tobias Schandinat
@ 2010-04-17 20:40 ` Jonathan Corbet
2010-04-17 20:55 ` Florian Tobias Schandinat
6 siblings, 1 reply; 9+ messages in thread
From: Jonathan Corbet @ 2010-04-17 20:40 UTC (permalink / raw)
To: Florian Tobias Schandinat
Cc: linux-kernel, linux-fbdev, JosephChan, ScottFang
On Sat, 17 Apr 2010 19:44:51 +0000
Florian Tobias Schandinat <FlorianSchandinat@gmx.de> wrote:
> This patch puts redesigned versions of the basic io functions that
> are used overall the driver in an extra header.
I don't object to the basic idea of these patches, but...as I'm sure
you can imagine, this stuff will conflict hard with the work I'm trying
to prepare for submission. I, too, have had to go in to those
functions and do things like add locking. Is there any chance you
could hold off for just a *little* bit while I get things together?
As I said before, I was traveling this last week. Now I'm home and can
get back to this...
Thanks,
jon
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/7] viafb: package often used basic io functions
2010-04-17 20:40 ` [PATCH 1/7] viafb: package often used basic io functions Jonathan Corbet
@ 2010-04-17 20:55 ` Florian Tobias Schandinat
0 siblings, 0 replies; 9+ messages in thread
From: Florian Tobias Schandinat @ 2010-04-17 20:55 UTC (permalink / raw)
To: Jonathan Corbet; +Cc: linux-kernel, linux-fbdev, JosephChan, ScottFang
Hi Jon,
Jonathan Corbet schrieb:
> On Sat, 17 Apr 2010 19:44:51 +0000
> Florian Tobias Schandinat <FlorianSchandinat@gmx.de> wrote:
>
>> This patch puts redesigned versions of the basic io functions that
>> are used overall the driver in an extra header.
>
> I don't object to the basic idea of these patches, but...as I'm sure
> you can imagine, this stuff will conflict hard with the work I'm trying
> to prepare for submission. I, too, have had to go in to those
> functions and do things like add locking. Is there any chance you
> could hold off for just a *little* bit while I get things together?
Huh, I really didn't expect that to conflict with anything you were
doing as those are basic functions that are only changed a bit and I
didn't find anything that would cause any disturbance in some of your trees.
As for locking I'd rather suggest doing it in the caller of these
functions as they are often bundled together.
Feel free to ignore theses patches if they get in your way. As I said
the next merge window is mostly for you, I just try to get some stuff in
that has a near zero regression potential and that I don't expect to
conflict with yours.
> As I said before, I was traveling this last week. Now I'm home and can
> get back to this...
Thanks,
Florian Tobias Schandinat
^ permalink raw reply [flat|nested] 9+ messages in thread