From: Jonathan Corbet <corbet@lwn.net>
To: linux-kernel@vger.kernel.org
Cc: Harald Welte <laforge@gnumonks.org>,
Deepak Saxena <dsaxena@laptop.org>,
linux-fbdev@vger.kernel.org, JosephChan@via.com.tw,
ScottFang@viatech.com.cn,
Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Subject: [PATCH 04/13] viafb: package often used basic io functions
Date: Fri, 23 Apr 2010 21:28:04 +0000 [thread overview]
Message-ID: <1272058093-20914-5-git-send-email-corbet@lwn.net> (raw)
In-Reply-To: <1272058093-20914-1-git-send-email-corbet@lwn.net>
From: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
This patch puts redesigned versions of the basic io functions that
are used overall the driver in an extra header. It is prefixed with
via_ as no framebuffer dependend stuff is in there. They were inlined
as they are really simple which reduced the module size about 2.5%.
The parameter order of read and write was fixed as it really doesn't
make sense to change the order as they are parts of the same address
and not source and destination.
Wrapper which use the new functions were added to hw.h to replicate
the old interface and avoid changing all old code.
[jc: added one comment]
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
---
drivers/video/via/hw.c | 22 ----------------
drivers/video/via/hw.h | 8 ++++--
drivers/video/via/via_io.h | 58 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+), 25 deletions(-)
create mode 100644 drivers/video/via/via_io.h
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index ecbc4f4..8a8c4dc 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -538,18 +538,6 @@ static void device_on(void);
static void enable_second_display_channel(void);
static void disable_second_display_channel(void);
-void viafb_write_reg(u8 index, u16 io_port, u8 data)
-{
- outb(index, io_port);
- outb(data, io_port + 1);
- /*DEBUG_MSG(KERN_INFO "\nIndex=%2d Value=%2d", index, data); */
-}
-u8 viafb_read_reg(int io_port, u8 index)
-{
- outb(index, io_port);
- return inb(io_port + 1);
-}
-
void viafb_lock_crt(void)
{
viafb_write_reg_mask(CR11, VIACR, BIT7, BIT7);
@@ -561,16 +549,6 @@ void viafb_unlock_crt(void)
viafb_write_reg_mask(CR47, VIACR, 0, BIT0);
}
-void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask)
-{
- u8 tmp;
-
- outb(index, io_port);
- tmp = inb(io_port + 1);
- outb((data & mask) | (tmp & (~mask)), io_port + 1);
- /*DEBUG_MSG(KERN_INFO "\nIndex=%2d Value=%2d", index, tmp); */
-}
-
void write_dac_reg(u8 index, u8 r, u8 g, u8 b)
{
outb(index, LUT_INDEX_WRITE);
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h
index d248f4d..23c3190 100644
--- a/drivers/video/via/hw.h
+++ b/drivers/video/via/hw.h
@@ -24,6 +24,11 @@
#include "viamode.h"
#include "global.h"
+#include "via_io.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)
+#define viafb_write_reg_mask(i, p, d, m) via_write_reg_mask(p, i, d, m)
/***************************************************
* Definition IGA1 Design Method of CRTC Registers *
@@ -870,7 +875,6 @@ extern int viafb_LCD_ON;
extern int viafb_DVI_ON;
extern int viafb_hotplug;
-void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask);
void viafb_set_output_path(int device, int set_iga,
int output_interface);
@@ -885,8 +889,6 @@ void viafb_crt_disable(void);
void viafb_crt_enable(void);
void init_ad9389(void);
/* Access I/O Function */
-void viafb_write_reg(u8 index, u16 io_port, u8 data);
-u8 viafb_read_reg(int io_port, u8 index);
void viafb_lock_crt(void);
void viafb_unlock_crt(void);
void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga);
diff --git a/drivers/video/via/via_io.h b/drivers/video/via/via_io.h
new file mode 100644
index 0000000..e1c1093
--- /dev/null
+++ b/drivers/video/via/via_io.h
@@ -0,0 +1,58 @@
+/*
+ * 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 io functions
+ */
+
+#ifndef __VIA_IO_H__
+#define __VIA_IO_H__
+
+#include <linux/types.h>
+#include <linux/io.h>
+
+/*
+ * Indexed port operations. Note that these are all multi-op
+ * functions; every invocation will be racy if you're not holding
+ * reg_lock.
+ */
+static inline u8 via_read_reg(u16 port, u8 index)
+{
+ outb(index, port);
+ return inb(port + 1);
+}
+
+static inline void via_write_reg(u16 port, u8 index, u8 data)
+{
+ outb(index, port);
+ outb(data, port + 1);
+}
+
+static inline void via_write_reg_mask(u16 port, u8 index, u8 data, u8 mask)
+{
+ u8 old;
+
+ outb(index, port);
+ old = inb(port + 1);
+ outb((data & mask) | (old & ~mask), port + 1);
+}
+
+#endif /* __VIA_IO_H__ */
--
1.7.0.1
next prev parent reply other threads:[~2010-04-23 21:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-23 21:28 [RFC] Second OLPC Viafb series Jonathan Corbet
2010-04-23 21:28 ` [PATCH 01/13] viafb: Move core stuff into via-core.c Jonathan Corbet
2010-04-23 21:28 ` [PATCH 02/13] viafb: Separate global and fb-specific data Jonathan Corbet
2010-04-23 21:28 ` [PATCH 03/13] viafb: add a driver for GPIO lines Jonathan Corbet
2010-04-23 21:28 ` Jonathan Corbet [this message]
2010-04-23 21:28 ` [PATCH 05/13] viafb: Convert GPIO and i2c to the new indexed port ops Jonathan Corbet
2010-04-23 21:28 ` [PATCH 06/13] viafb: Turn GPIO and i2c into proper platform devices Jonathan Corbet
2010-04-23 21:28 ` [PATCH 07/13] via: Do not attempt I/O on inactive I2C adapters Jonathan Corbet
2010-04-23 21:28 ` [PATCH 08/13] viafb: Introduce viafb_find_i2c_adapter() Jonathan Corbet
2010-04-23 21:28 ` [PATCH 09/13] via: Rationalize vt1636 detection Jonathan Corbet
2010-04-23 21:28 ` [PATCH 10/13] viafb: Add a simple interrupt management infrastructure Jonathan Corbet
2010-04-23 21:28 ` [PATCH 11/13] viafb: Add a simple VX855 DMA engine driver Jonathan Corbet
2010-04-23 21:28 ` [PATCH 12/13] viafb: Reserve framebuffer memory for the upcoming camera driver Jonathan Corbet
2010-04-23 21:28 ` [PATCH 13/13] viafb: Add a driver for the video capture engine Jonathan Corbet
2010-04-24 15:07 ` [RFC] Second OLPC Viafb series Florian Tobias Schandinat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1272058093-20914-5-git-send-email-corbet@lwn.net \
--to=corbet@lwn.net \
--cc=FlorianSchandinat@gmx.de \
--cc=JosephChan@via.com.tw \
--cc=ScottFang@viatech.com.cn \
--cc=dsaxena@laptop.org \
--cc=laforge@gnumonks.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).