提交 c3898748 编写于 作者: F Florian Tobias Schandinat 提交者: Jonathan Corbet

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: NFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
上级 7e0de022
...@@ -537,18 +537,6 @@ static void device_on(void); ...@@ -537,18 +537,6 @@ static void device_on(void);
static void enable_second_display_channel(void); static void enable_second_display_channel(void);
static void disable_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) void viafb_lock_crt(void)
{ {
viafb_write_reg_mask(CR11, VIACR, BIT7, BIT7); viafb_write_reg_mask(CR11, VIACR, BIT7, BIT7);
...@@ -560,16 +548,6 @@ void viafb_unlock_crt(void) ...@@ -560,16 +548,6 @@ void viafb_unlock_crt(void)
viafb_write_reg_mask(CR47, VIACR, 0, BIT0); 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) void write_dac_reg(u8 index, u8 r, u8 g, u8 b)
{ {
outb(index, LUT_INDEX_WRITE); outb(index, LUT_INDEX_WRITE);
......
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
#include "viamode.h" #include "viamode.h"
#include "global.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 * * Definition IGA1 Design Method of CRTC Registers *
...@@ -870,7 +875,6 @@ extern int viafb_LCD_ON; ...@@ -870,7 +875,6 @@ extern int viafb_LCD_ON;
extern int viafb_DVI_ON; extern int viafb_DVI_ON;
extern int viafb_hotplug; 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, void viafb_set_output_path(int device, int set_iga,
int output_interface); int output_interface);
...@@ -885,8 +889,6 @@ void viafb_crt_disable(void); ...@@ -885,8 +889,6 @@ void viafb_crt_disable(void);
void viafb_crt_enable(void); void viafb_crt_enable(void);
void init_ad9389(void); void init_ad9389(void);
/* Access I/O Function */ /* 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_lock_crt(void);
void viafb_unlock_crt(void); void viafb_unlock_crt(void);
void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga); void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga);
......
/*
* 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__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册