dt3155.h 5.7 KB

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