Linux-libre 4.19.20-gnu
[librecmc/linux-libre.git] / drivers / staging / xgifb / vb_util.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _VBUTIL_
3 #define _VBUTIL_
4 static inline void xgifb_reg_set(unsigned long port, u8 index, u8 data)
5 {
6         outb(index, port);
7         outb(data, port + 1);
8 }
9
10 static inline u8 xgifb_reg_get(unsigned long port, u8 index)
11 {
12         outb(index, port);
13         return inb(port + 1);
14 }
15
16 static inline void xgifb_reg_and_or(unsigned long port, u8 index,
17                                     unsigned int data_and, unsigned int data_or)
18 {
19         u8 temp;
20
21         temp = xgifb_reg_get(port, index);
22         temp = (u8)((temp & data_and) | data_or);
23         xgifb_reg_set(port, index, temp);
24 }
25
26 static inline void xgifb_reg_and(unsigned long port, u8 index,
27                                  unsigned int data_and)
28 {
29         u8 temp;
30
31         temp = xgifb_reg_get(port, index);
32         temp = (u8)(temp & data_and);
33         xgifb_reg_set(port, index, temp);
34 }
35
36 static inline void xgifb_reg_or(unsigned long port, u8 index,
37                                 unsigned int data_or)
38 {
39         u8 temp;
40
41         temp = xgifb_reg_get(port, index);
42         temp |= data_or;
43         xgifb_reg_set(port, index, temp);
44 }
45 #endif
46