bt455.h 2.0 KB

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