0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/types.h>
0012
0013
0014
0015
0016 struct bt455_regs {
0017 volatile u8 addr_cmap;
0018 u8 pad0[3];
0019 volatile u8 addr_cmap_data;
0020 u8 pad1[3];
0021 volatile u8 addr_clr;
0022 u8 pad2[3];
0023 volatile u8 addr_ovly;
0024 u8 pad3[3];
0025 };
0026
0027 static inline void bt455_select_reg(struct bt455_regs *regs, int ir)
0028 {
0029 mb();
0030 regs->addr_cmap = ir & 0x0f;
0031 }
0032
0033 static inline void bt455_reset_reg(struct bt455_regs *regs)
0034 {
0035 mb();
0036 regs->addr_clr = 0;
0037 }
0038
0039
0040
0041
0042 static inline void bt455_read_cmap_next(struct bt455_regs *regs, u8 *grey)
0043 {
0044 mb();
0045 regs->addr_cmap_data;
0046 rmb();
0047 *grey = regs->addr_cmap_data & 0xf;
0048 rmb();
0049 regs->addr_cmap_data;
0050 }
0051
0052 static inline void bt455_write_cmap_next(struct bt455_regs *regs, u8 grey)
0053 {
0054 wmb();
0055 regs->addr_cmap_data = 0x0;
0056 wmb();
0057 regs->addr_cmap_data = grey & 0xf;
0058 wmb();
0059 regs->addr_cmap_data = 0x0;
0060 }
0061
0062 static inline void bt455_write_ovly_next(struct bt455_regs *regs, u8 grey)
0063 {
0064 wmb();
0065 regs->addr_ovly = 0x0;
0066 wmb();
0067 regs->addr_ovly = grey & 0xf;
0068 wmb();
0069 regs->addr_ovly = 0x0;
0070 }
0071
0072 static inline void bt455_read_cmap_entry(struct bt455_regs *regs,
0073 int cr, u8 *grey)
0074 {
0075 bt455_select_reg(regs, cr);
0076 bt455_read_cmap_next(regs, grey);
0077 }
0078
0079 static inline void bt455_write_cmap_entry(struct bt455_regs *regs,
0080 int cr, u8 grey)
0081 {
0082 bt455_select_reg(regs, cr);
0083 bt455_write_cmap_next(regs, grey);
0084 }
0085
0086 static inline void bt455_write_ovly_entry(struct bt455_regs *regs, u8 grey)
0087 {
0088 bt455_reset_reg(regs);
0089 bt455_write_ovly_next(regs, grey);
0090 }