aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/via
diff options
context:
space:
mode:
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2010-04-17 15:44:51 -0400
committerJonathan Corbet <corbet@lwn.net>2010-05-07 19:16:03 -0400
commitc389874805a6849e3e347fc0e13fa170d80840c1 (patch)
tree11508f50085603a0a9f9f14b10046f9940775f55 /drivers/video/via
parent7e0de022680f7899d33141f3ab5724a704f5669a (diff)
viafb: package often used basic io functions
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>
Diffstat (limited to 'drivers/video/via')
-rw-r--r--drivers/video/via/hw.c22
-rw-r--r--drivers/video/via/hw.h8
-rw-r--r--drivers/video/via/via_io.h58
3 files changed, 63 insertions, 25 deletions
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index f2425ae228ae..805151f48ea9 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -537,18 +537,6 @@ static void device_on(void);
537static void enable_second_display_channel(void); 537static void enable_second_display_channel(void);
538static void disable_second_display_channel(void); 538static void disable_second_display_channel(void);
539 539
540void viafb_write_reg(u8 index, u16 io_port, u8 data)
541{
542 outb(index, io_port);
543 outb(data, io_port + 1);
544 /*DEBUG_MSG(KERN_INFO "\nIndex=%2d Value=%2d", index, data); */
545}
546u8 viafb_read_reg(int io_port, u8 index)
547{
548 outb(index, io_port);
549 return inb(io_port + 1);
550}
551
552void viafb_lock_crt(void) 540void viafb_lock_crt(void)
553{ 541{
554 viafb_write_reg_mask(CR11, VIACR, BIT7, BIT7); 542 viafb_write_reg_mask(CR11, VIACR, BIT7, BIT7);
@@ -560,16 +548,6 @@ void viafb_unlock_crt(void)
560 viafb_write_reg_mask(CR47, VIACR, 0, BIT0); 548 viafb_write_reg_mask(CR47, VIACR, 0, BIT0);
561} 549}
562 550
563void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask)
564{
565 u8 tmp;
566
567 outb(index, io_port);
568 tmp = inb(io_port + 1);
569 outb((data & mask) | (tmp & (~mask)), io_port + 1);
570 /*DEBUG_MSG(KERN_INFO "\nIndex=%2d Value=%2d", index, tmp); */
571}
572
573void write_dac_reg(u8 index, u8 r, u8 g, u8 b) 551void write_dac_reg(u8 index, u8 r, u8 g, u8 b)
574{ 552{
575 outb(index, LUT_INDEX_WRITE); 553 outb(index, LUT_INDEX_WRITE);
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h
index d248f4dc12ec..23c319010913 100644
--- a/drivers/video/via/hw.h
+++ b/drivers/video/via/hw.h
@@ -24,6 +24,11 @@
24 24
25#include "viamode.h" 25#include "viamode.h"
26#include "global.h" 26#include "global.h"
27#include "via_io.h"
28
29#define viafb_read_reg(p, i) via_read_reg(p, i)
30#define viafb_write_reg(i, p, d) via_write_reg(p, i, d)
31#define viafb_write_reg_mask(i, p, d, m) via_write_reg_mask(p, i, d, m)
27 32
28/*************************************************** 33/***************************************************
29* Definition IGA1 Design Method of CRTC Registers * 34* Definition IGA1 Design Method of CRTC Registers *
@@ -870,7 +875,6 @@ extern int viafb_LCD_ON;
870extern int viafb_DVI_ON; 875extern int viafb_DVI_ON;
871extern int viafb_hotplug; 876extern int viafb_hotplug;
872 877
873void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask);
874void viafb_set_output_path(int device, int set_iga, 878void viafb_set_output_path(int device, int set_iga,
875 int output_interface); 879 int output_interface);
876 880
@@ -885,8 +889,6 @@ void viafb_crt_disable(void);
885void viafb_crt_enable(void); 889void viafb_crt_enable(void);
886void init_ad9389(void); 890void init_ad9389(void);
887/* Access I/O Function */ 891/* Access I/O Function */
888void viafb_write_reg(u8 index, u16 io_port, u8 data);
889u8 viafb_read_reg(int io_port, u8 index);
890void viafb_lock_crt(void); 892void viafb_lock_crt(void);
891void viafb_unlock_crt(void); 893void viafb_unlock_crt(void);
892void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga); 894void 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 000000000000..e1c1093def00
--- /dev/null
+++ b/drivers/video/via/via_io.h
@@ -0,0 +1,58 @@
1/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4 * Copyright 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation;
9 * either version 2, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
13 * the implied warranty of MERCHANTABILITY or FITNESS FOR
14 * A PARTICULAR PURPOSE.See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22/*
23 * basic io functions
24 */
25
26#ifndef __VIA_IO_H__
27#define __VIA_IO_H__
28
29#include <linux/types.h>
30#include <linux/io.h>
31
32/*
33 * Indexed port operations. Note that these are all multi-op
34 * functions; every invocation will be racy if you're not holding
35 * reg_lock.
36 */
37static inline u8 via_read_reg(u16 port, u8 index)
38{
39 outb(index, port);
40 return inb(port + 1);
41}
42
43static inline void via_write_reg(u16 port, u8 index, u8 data)
44{
45 outb(index, port);
46 outb(data, port + 1);
47}
48
49static inline void via_write_reg_mask(u16 port, u8 index, u8 data, u8 mask)
50{
51 u8 old;
52
53 outb(index, port);
54 old = inb(port + 1);
55 outb((data & mask) | (old & ~mask), port + 1);
56}
57
58#endif /* __VIA_IO_H__ */