bt455.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * linux/drivers/video/bt455.h
  3. *
  4. * Copyright 2003 Thiemo Seufer <[email protected]>
  5. * Copyright 2016 Maciej W. Rozycki <[email protected]>
  6. *
  7. * This file is subject to the terms and conditions of the GNU General
  8. * Public License. See the file COPYING in the main directory of this
  9. * archive for more details.
  10. */
  11. #include <linux/types.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. static inline void bt455_reset_reg(struct bt455_regs *regs)
  31. {
  32. mb();
  33. regs->addr_clr = 0;
  34. }
  35. /*
  36. * Read/write to a Bt455 color map register.
  37. */
  38. static inline void bt455_read_cmap_next(struct bt455_regs *regs, u8 *grey)
  39. {
  40. mb();
  41. regs->addr_cmap_data;
  42. rmb();
  43. *grey = regs->addr_cmap_data & 0xf;
  44. rmb();
  45. regs->addr_cmap_data;
  46. }
  47. static inline void bt455_write_cmap_next(struct bt455_regs *regs, u8 grey)
  48. {
  49. wmb();
  50. regs->addr_cmap_data = 0x0;
  51. wmb();
  52. regs->addr_cmap_data = grey & 0xf;
  53. wmb();
  54. regs->addr_cmap_data = 0x0;
  55. }
  56. static inline void bt455_write_ovly_next(struct bt455_regs *regs, u8 grey)
  57. {
  58. wmb();
  59. regs->addr_ovly = 0x0;
  60. wmb();
  61. regs->addr_ovly = grey & 0xf;
  62. wmb();
  63. regs->addr_ovly = 0x0;
  64. }
  65. static inline void bt455_read_cmap_entry(struct bt455_regs *regs,
  66. int cr, u8 *grey)
  67. {
  68. bt455_select_reg(regs, cr);
  69. bt455_read_cmap_next(regs, grey);
  70. }
  71. static inline void bt455_write_cmap_entry(struct bt455_regs *regs,
  72. int cr, u8 grey)
  73. {
  74. bt455_select_reg(regs, cr);
  75. bt455_write_cmap_next(regs, grey);
  76. }
  77. static inline void bt455_write_ovly_entry(struct bt455_regs *regs, u8 grey)
  78. {
  79. bt455_reset_reg(regs);
  80. bt455_write_ovly_next(regs, grey);
  81. }