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 12 /* 13 * Bt455 byte-wide registers, 32-bit aligned. 14 */ 15 struct bt455_regs { 16 volatile u8 addr_cmap; 17 u8 pad0[3]; 18 volatile u8 addr_cmap_data; 19 u8 pad1[3]; 20 volatile u8 addr_clr; 21 u8 pad2[3]; 22 volatile u8 addr_ovly; 23 u8 pad3[3]; 24 }; 25 26 static inline void bt455_select_reg(struct bt455_regs *regs, int ir) 27 { 28 mb(); 29 regs->addr_cmap = ir & 0x0f; 30 } 31 32 /* 33 * Read/write to a Bt455 color map register. 34 */ 35 static inline void bt455_read_cmap_entry(struct bt455_regs *regs, int cr, 36 u8* red, u8* green, u8* blue) 37 { 38 bt455_select_reg(regs, cr); 39 mb(); 40 *red = regs->addr_cmap_data & 0x0f; 41 rmb(); 42 *green = regs->addr_cmap_data & 0x0f; 43 rmb(); 44 *blue = regs->addr_cmap_data & 0x0f; 45 } 46 47 static inline void bt455_write_cmap_entry(struct bt455_regs *regs, int cr, 48 u8 red, u8 green, u8 blue) 49 { 50 bt455_select_reg(regs, cr); 51 wmb(); 52 regs->addr_cmap_data = red & 0x0f; 53 wmb(); 54 regs->addr_cmap_data = green & 0x0f; 55 wmb(); 56 regs->addr_cmap_data = blue & 0x0f; 57 } 58 59 static inline void bt455_write_ovly_entry(struct bt455_regs *regs, int cr, 60 u8 red, u8 green, u8 blue) 61 { 62 bt455_select_reg(regs, cr); 63 wmb(); 64 regs->addr_ovly = red & 0x0f; 65 wmb(); 66 regs->addr_ovly = green & 0x0f; 67 wmb(); 68 regs->addr_ovly = blue & 0x0f; 69 } 70 71 static inline void bt455_set_cursor(struct bt455_regs *regs) 72 { 73 mb(); 74 regs->addr_ovly = 0x0f; 75 wmb(); 76 regs->addr_ovly = 0x0f; 77 wmb(); 78 regs->addr_ovly = 0x0f; 79 } 80 81 static inline void bt455_erase_cursor(struct bt455_regs *regs) 82 { 83 /* bt455_write_cmap_entry(regs, 8, 0x00, 0x00, 0x00); */ 84 /* bt455_write_cmap_entry(regs, 9, 0x00, 0x00, 0x00); */ 85 bt455_write_ovly_entry(regs, 8, 0x03, 0x03, 0x03); 86 bt455_write_ovly_entry(regs, 9, 0x07, 0x07, 0x07); 87 88 wmb(); 89 regs->addr_ovly = 0x09; 90 wmb(); 91 regs->addr_ovly = 0x09; 92 wmb(); 93 regs->addr_ovly = 0x09; 94 } 95