bt455.h 2.0 KB

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