vfc.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #ifndef _LINUX_VFC_H_
  2. #define _LINUX_VFC_H_
  3. /*
  4. * The control register for the vfc is at offset 0x4000
  5. * The first field ram bank is located at offset 0x5000
  6. * The second field ram bank is at offset 0x7000
  7. * i2c_reg address the Phillips PCF8584(see notes in vfc_i2c.c)
  8. * data and transmit register.
  9. * i2c_s1 controls register s1 of the PCF8584
  10. * i2c_write seems to be similar to i2c_write but I am not
  11. * quite sure why sun uses it
  12. *
  13. * I am also not sure whether or not you can read the fram bank as a
  14. * whole or whether you must read each word individually from offset
  15. * 0x5000 as soon as I figure it out I will update this file */
  16. struct vfc_regs {
  17. char pad1[0x4000];
  18. unsigned int control; /* Offset 0x4000 */
  19. char pad2[0xffb]; /* from offset 0x4004 to 0x5000 */
  20. unsigned int fram_bank1; /* Offset 0x5000 */
  21. char pad3[0xffb]; /* from offset 0x5004 to 0x6000 */
  22. unsigned int i2c_reg; /* Offset 0x6000 */
  23. unsigned int i2c_magic2; /* Offset 0x6004 */
  24. unsigned int i2c_s1; /* Offset 0x6008 */
  25. unsigned int i2c_write; /* Offset 0x600c */
  26. char pad4[0xff0]; /* from offset 0x6010 to 0x7000 */
  27. unsigned int fram_bank2; /* Offset 0x7000 */
  28. char pad5[0x1000];
  29. };
  30. #define VFC_SAA9051_NR (13)
  31. #define VFC_SAA9051_ADDR (0x8a)
  32. /* The saa9051 returns the following for its status
  33. * bit 0 - 0
  34. * bit 1 - SECAM color detected (1=found,0=not found)
  35. * bit 2 - COLOR detected (1=found,0=not found)
  36. * bit 3 - 0
  37. * bit 4 - Field frequency bit (1=60Hz (NTSC), 0=50Hz (PAL))
  38. * bit 5 - 1
  39. * bit 6 - horizontal frequency lock (1=transmitter found,
  40. * 0=no transmitter)
  41. * bit 7 - Power on reset bit (1=reset,0=at least one successful
  42. * read of the status byte)
  43. */
  44. #define VFC_SAA9051_PONRES (0x80)
  45. #define VFC_SAA9051_HLOCK (0x40)
  46. #define VFC_SAA9051_FD (0x10)
  47. #define VFC_SAA9051_CD (0x04)
  48. #define VFC_SAA9051_CS (0x02)
  49. /* The various saa9051 sub addresses */
  50. #define VFC_SAA9051_IDEL (0)
  51. #define VFC_SAA9051_HSY_START (1)
  52. #define VFC_SAA9051_HSY_STOP (2)
  53. #define VFC_SAA9051_HC_START (3)
  54. #define VFC_SAA9051_HC_STOP (4)
  55. #define VFC_SAA9051_HS_START (5)
  56. #define VFC_SAA9051_HORIZ_PEAK (6)
  57. #define VFC_SAA9051_HUE (7)
  58. #define VFC_SAA9051_C1 (8)
  59. #define VFC_SAA9051_C2 (9)
  60. #define VFC_SAA9051_C3 (0xa)
  61. #define VFC_SAA9051_SECAM_DELAY (0xb)
  62. /* Bit settings for saa9051 sub address 0x06 */
  63. #define VFC_SAA9051_AP1 (0x01)
  64. #define VFC_SAA9051_AP2 (0x02)
  65. #define VFC_SAA9051_COR1 (0x04)
  66. #define VFC_SAA9051_COR2 (0x08)
  67. #define VFC_SAA9051_BP1 (0x10)
  68. #define VFC_SAA9051_BP2 (0x20)
  69. #define VFC_SAA9051_PF (0x40)
  70. #define VFC_SAA9051_BY (0x80)
  71. /* Bit settings for saa9051 sub address 0x08 */
  72. #define VFC_SAA9051_CCFR0 (0x01)
  73. #define VFC_SAA9051_CCFR1 (0x02)
  74. #define VFC_SAA9051_YPN (0x04)
  75. #define VFC_SAA9051_ALT (0x08)
  76. #define VFC_SAA9051_CO (0x10)
  77. #define VFC_SAA9051_VTR (0x20)
  78. #define VFC_SAA9051_FS (0x40)
  79. #define VFC_SAA9051_HPLL (0x80)
  80. /* Bit settings for saa9051 sub address 9 */
  81. #define VFC_SAA9051_SS0 (0x01)
  82. #define VFC_SAA9051_SS1 (0x02)
  83. #define VFC_SAA9051_AFCC (0x04)
  84. #define VFC_SAA9051_CI (0x08)
  85. #define VFC_SAA9051_SA9D4 (0x10) /* Don't care bit */
  86. #define VFC_SAA9051_OEC (0x20)
  87. #define VFC_SAA9051_OEY (0x40)
  88. #define VFC_SAA9051_VNL (0x80)
  89. /* Bit settings for saa9051 sub address 0x0A */
  90. #define VFC_SAA9051_YDL0 (0x01)
  91. #define VFC_SAA9051_YDL1 (0x02)
  92. #define VFC_SAA9051_YDL2 (0x04)
  93. #define VFC_SAA9051_SS2 (0x08)
  94. #define VFC_SAA9051_SS3 (0x10)
  95. #define VFC_SAA9051_YC (0x20)
  96. #define VFC_SAA9051_CT (0x40)
  97. #define VFC_SAA9051_SYC (0x80)
  98. #define VFC_SAA9051_SA(a,b) ((a)->saa9051_state_array[(b)+1])
  99. #define vfc_update_saa9051(a) (vfc_i2c_sendbuf((a),VFC_SAA9051_ADDR,\
  100. (a)->saa9051_state_array,\
  101. VFC_SAA9051_NR))
  102. struct vfc_dev {
  103. volatile struct vfc_regs __iomem *regs;
  104. struct vfc_regs *phys_regs;
  105. unsigned int control_reg;
  106. struct mutex device_lock_mtx;
  107. int instance;
  108. int busy;
  109. unsigned long which_io;
  110. unsigned char saa9051_state_array[VFC_SAA9051_NR];
  111. };
  112. void captstat_reset(struct vfc_dev *);
  113. void memptr_reset(struct vfc_dev *);
  114. int vfc_pcf8584_init(struct vfc_dev *);
  115. void vfc_i2c_delay_no_busy(struct vfc_dev *, unsigned long);
  116. void vfc_i2c_delay(struct vfc_dev *);
  117. int vfc_i2c_sendbuf(struct vfc_dev *, unsigned char, char *, int) ;
  118. int vfc_i2c_recvbuf(struct vfc_dev *, unsigned char, char *, int) ;
  119. int vfc_i2c_reset_bus(struct vfc_dev *);
  120. int vfc_init_i2c_bus(struct vfc_dev *);
  121. #define VFC_CONTROL_DIAGMODE 0x10000000
  122. #define VFC_CONTROL_MEMPTR 0x20000000
  123. #define VFC_CONTROL_CAPTURE 0x02000000
  124. #define VFC_CONTROL_CAPTRESET 0x04000000
  125. #define VFC_STATUS_CAPTURE 0x08000000
  126. #ifdef VFC_IOCTL_DEBUG
  127. #define VFC_IOCTL_DEBUG_PRINTK(a) printk a
  128. #else
  129. #define VFC_IOCTL_DEBUG_PRINTK(a)
  130. #endif
  131. #ifdef VFC_I2C_DEBUG
  132. #define VFC_I2C_DEBUG_PRINTK(a) printk a
  133. #else
  134. #define VFC_I2C_DEBUG_PRINTK(a)
  135. #endif
  136. #endif /* _LINUX_VFC_H_ */