Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[linux-2.6] / drivers / video / bt455.h
1 /*
2  *      linux/drivers/video/bt455.h
3  *
4  *      Copyright 2003  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
5  *
6  *      This file is subject to the terms and conditions of the GNU General
7  *      Public License. See the file COPYING in the main directory of this
8  *      archive for more details.
9  */
10 #include <linux/types.h>
11 #include <asm/system.h>
12
13 /*
14  * Bt455 byte-wide registers, 32-bit aligned.
15  */
16 struct bt455_regs {
17         volatile u8 addr_cmap;
18         u8 pad0[3];
19         volatile u8 addr_cmap_data;
20         u8 pad1[3];
21         volatile u8 addr_clr;
22         u8 pad2[3];
23         volatile u8 addr_ovly;
24         u8 pad3[3];
25 };
26
27 static inline void bt455_select_reg(struct bt455_regs *regs, int ir)
28 {
29         mb();
30         regs->addr_cmap = ir & 0x0f;
31 }
32
33 /*
34  * Read/write to a Bt455 color map register.
35  */
36 static inline void bt455_read_cmap_entry(struct bt455_regs *regs, int cr,
37                                          u8* red, u8* green, u8* blue)
38 {
39         bt455_select_reg(regs, cr);
40         mb();
41         *red = regs->addr_cmap_data & 0x0f;
42         rmb();
43         *green = regs->addr_cmap_data & 0x0f;
44         rmb();
45         *blue = regs->addr_cmap_data & 0x0f;
46 }
47
48 static inline void bt455_write_cmap_entry(struct bt455_regs *regs, int cr,
49                                           u8 red, u8 green, u8 blue)
50 {
51         bt455_select_reg(regs, cr);
52         wmb();
53         regs->addr_cmap_data = red & 0x0f;
54         wmb();
55         regs->addr_cmap_data = green & 0x0f;
56         wmb();
57         regs->addr_cmap_data = blue & 0x0f;
58 }
59
60 static inline void bt455_write_ovly_entry(struct bt455_regs *regs, int cr,
61                                           u8 red, u8 green, u8 blue)
62 {
63         bt455_select_reg(regs, cr);
64         wmb();
65         regs->addr_ovly = red & 0x0f;
66         wmb();
67         regs->addr_ovly = green & 0x0f;
68         wmb();
69         regs->addr_ovly = blue & 0x0f;
70 }
71
72 static inline void bt455_set_cursor(struct bt455_regs *regs)
73 {
74         mb();
75         regs->addr_ovly = 0x0f;
76         wmb();
77         regs->addr_ovly = 0x0f;
78         wmb();
79         regs->addr_ovly = 0x0f;
80 }
81
82 static inline void bt455_erase_cursor(struct bt455_regs *regs)
83 {
84         /* bt455_write_cmap_entry(regs, 8, 0x00, 0x00, 0x00); */
85         /* bt455_write_cmap_entry(regs, 9, 0x00, 0x00, 0x00); */
86         bt455_write_ovly_entry(regs, 8, 0x03, 0x03, 0x03);
87         bt455_write_ovly_entry(regs, 9, 0x07, 0x07, 0x07);
88
89         wmb();
90         regs->addr_ovly = 0x09;
91         wmb();
92         regs->addr_ovly = 0x09;
93         wmb();
94         regs->addr_ovly = 0x09;
95 }