dt3155.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /***************************************************************************
  3. * Copyright (C) 2006-2010 by Marin Mitov *
  4. * [email protected] *
  5. * *
  6. * *
  7. ***************************************************************************/
  8. /* DT3155 header file */
  9. #ifndef _DT3155_H_
  10. #define _DT3155_H_
  11. #include <linux/pci.h>
  12. #include <linux/interrupt.h>
  13. #include <media/v4l2-device.h>
  14. #include <media/v4l2-dev.h>
  15. #include <media/videobuf2-v4l2.h>
  16. #define DT3155_NAME "dt3155"
  17. #define DT3155_VER_MAJ 2
  18. #define DT3155_VER_MIN 0
  19. #define DT3155_VER_EXT 0
  20. #define DT3155_VERSION __stringify(DT3155_VER_MAJ) "." \
  21. __stringify(DT3155_VER_MIN) "." \
  22. __stringify(DT3155_VER_EXT)
  23. /* DT3155 Base Register offsets (memory mapped) */
  24. #define EVEN_DMA_START 0x00
  25. #define ODD_DMA_START 0x0C
  26. #define EVEN_DMA_STRIDE 0x18
  27. #define ODD_DMA_STRIDE 0x24
  28. #define EVEN_PIXEL_FMT 0x30
  29. #define ODD_PIXEL_FMT 0x34
  30. #define FIFO_TRIGGER 0x38
  31. #define XFER_MODE 0x3C
  32. #define CSR1 0x40
  33. #define RETRY_WAIT_CNT 0x44
  34. #define INT_CSR 0x48
  35. #define EVEN_FLD_MASK 0x4C
  36. #define ODD_FLD_MASK 0x50
  37. #define MASK_LENGTH 0x54
  38. #define FIFO_FLAG_CNT 0x58
  39. #define IIC_CLK_DUR 0x5C
  40. #define IIC_CSR1 0x60
  41. #define IIC_CSR2 0x64
  42. /* DT3155 Internal Registers indexes (i2c/IIC mapped) */
  43. #define CSR2 0x10
  44. #define EVEN_CSR 0x11
  45. #define ODD_CSR 0x12
  46. #define CONFIG 0x13
  47. #define DT_ID 0x1F
  48. #define X_CLIP_START 0x20
  49. #define Y_CLIP_START 0x22
  50. #define X_CLIP_END 0x24
  51. #define Y_CLIP_END 0x26
  52. #define AD_ADDR 0x30
  53. #define AD_LUT 0x31
  54. #define AD_CMD 0x32
  55. #define DIG_OUT 0x40
  56. #define PM_LUT_ADDR 0x50
  57. #define PM_LUT_DATA 0x51
  58. /* AD command register values */
  59. #define AD_CMD_REG 0x00
  60. #define AD_POS_REF 0x01
  61. #define AD_NEG_REF 0x02
  62. /* CSR1 bit masks */
  63. #define RANGE_EN 0x00008000
  64. #define CRPT_DIS 0x00004000
  65. #define ADDR_ERR_ODD 0x00000800
  66. #define ADDR_ERR_EVEN 0x00000400
  67. #define FLD_CRPT_ODD 0x00000200
  68. #define FLD_CRPT_EVEN 0x00000100
  69. #define FIFO_EN 0x00000080
  70. #define SRST 0x00000040
  71. #define FLD_DN_ODD 0x00000020
  72. #define FLD_DN_EVEN 0x00000010
  73. /* These should not be used.
  74. * Use CAP_CONT_ODD/EVEN instead
  75. #define CAP_SNGL_ODD 0x00000008
  76. #define CAP_SNGL_EVEN 0x00000004
  77. */
  78. #define CAP_CONT_ODD 0x00000002
  79. #define CAP_CONT_EVEN 0x00000001
  80. /* INT_CSR bit masks */
  81. #define FLD_START_EN 0x00000400
  82. #define FLD_END_ODD_EN 0x00000200
  83. #define FLD_END_EVEN_EN 0x00000100
  84. #define FLD_START 0x00000004
  85. #define FLD_END_ODD 0x00000002
  86. #define FLD_END_EVEN 0x00000001
  87. /* IIC_CSR1 bit masks */
  88. #define DIRECT_ABORT 0x00000200
  89. /* IIC_CSR2 bit masks */
  90. #define NEW_CYCLE 0x01000000
  91. #define DIR_RD 0x00010000
  92. #define IIC_READ 0x01010000
  93. #define IIC_WRITE 0x01000000
  94. /* CSR2 bit masks */
  95. #define DISP_PASS 0x40
  96. #define BUSY_ODD 0x20
  97. #define BUSY_EVEN 0x10
  98. #define SYNC_PRESENT 0x08
  99. #define VT_50HZ 0x04
  100. #define SYNC_SNTL 0x02
  101. #define CHROM_FILT 0x01
  102. #define VT_60HZ 0x00
  103. /* CSR_EVEN/ODD bit masks */
  104. #define CSR_ERROR 0x04
  105. #define CSR_SNGL 0x02
  106. #define CSR_DONE 0x01
  107. /* CONFIG bit masks */
  108. #define PM_LUT_PGM 0x80
  109. #define PM_LUT_SEL 0x40
  110. #define CLIP_EN 0x20
  111. #define HSCALE_EN 0x10
  112. #define EXT_TRIG_UP 0x0C
  113. #define EXT_TRIG_DOWN 0x04
  114. #define ACQ_MODE_NEXT 0x02
  115. #define ACQ_MODE_ODD 0x01
  116. #define ACQ_MODE_EVEN 0x00
  117. /* AD_CMD bit masks */
  118. #define VIDEO_CNL_1 0x00
  119. #define VIDEO_CNL_2 0x40
  120. #define VIDEO_CNL_3 0x80
  121. #define VIDEO_CNL_4 0xC0
  122. #define SYNC_CNL_1 0x00
  123. #define SYNC_CNL_2 0x10
  124. #define SYNC_CNL_3 0x20
  125. #define SYNC_CNL_4 0x30
  126. #define SYNC_LVL_1 0x00
  127. #define SYNC_LVL_2 0x04
  128. #define SYNC_LVL_3 0x08
  129. #define SYNC_LVL_4 0x0C
  130. /* DT3155 identificator */
  131. #define DT3155_ID 0x20
  132. /* per board private data structure */
  133. /**
  134. * struct dt3155_priv - private data structure
  135. *
  136. * @v4l2_dev: v4l2_device structure
  137. * @vdev: video_device structure
  138. * @pdev: pointer to pci_dev structure
  139. * @vidq: vb2_queue structure
  140. * @curr_buf: pointer to curren buffer
  141. * @mux: mutex to protect the instance
  142. * @dmaq: queue for dma buffers
  143. * @lock: spinlock for dma queue
  144. * @std: input standard
  145. * @width: frame width
  146. * @height: frame height
  147. * @input: current input
  148. * @sequence: frame counter
  149. * @stats: statistics structure
  150. * @regs: local copy of mmio base register
  151. * @csr2: local copy of csr2 register
  152. * @config: local copy of config register
  153. */
  154. struct dt3155_priv {
  155. struct v4l2_device v4l2_dev;
  156. struct video_device vdev;
  157. struct pci_dev *pdev;
  158. struct vb2_queue vidq;
  159. struct vb2_v4l2_buffer *curr_buf;
  160. struct mutex mux;
  161. struct list_head dmaq;
  162. spinlock_t lock;
  163. v4l2_std_id std;
  164. unsigned width, height;
  165. unsigned input;
  166. unsigned int sequence;
  167. void __iomem *regs;
  168. u8 csr2, config;
  169. };
  170. #endif /* _DT3155_H_ */