dt3155v4l.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19. ***************************************************************************/
  20. /* DT3155 header file */
  21. #ifndef _DT3155_H_
  22. #define _DT3155_H_
  23. #ifdef __KERNEL__
  24. #include <linux/pci.h>
  25. #include <linux/interrupt.h>
  26. #define DT3155_NAME "dt3155"
  27. #define DT3155_VER_MAJ 1
  28. #define DT3155_VER_MIN 1
  29. #define DT3155_VER_EXT 0
  30. #define DT3155_VERSION __stringify(DT3155_VER_MAJ) "." \
  31. __stringify(DT3155_VER_MIN) "." \
  32. __stringify(DT3155_VER_EXT)
  33. /* DT3155 Base Register offsets (memory mapped) */
  34. #define EVEN_DMA_START 0x00
  35. #define ODD_DMA_START 0x0C
  36. #define EVEN_DMA_STRIDE 0x18
  37. #define ODD_DMA_STRIDE 0x24
  38. #define EVEN_PIXEL_FMT 0x30
  39. #define ODD_PIXEL_FMT 0x34
  40. #define FIFO_TRIGER 0x38
  41. #define XFER_MODE 0x3C
  42. #define CSR1 0x40
  43. #define RETRY_WAIT_CNT 0x44
  44. #define INT_CSR 0x48
  45. #define EVEN_FLD_MASK 0x4C
  46. #define ODD_FLD_MASK 0x50
  47. #define MASK_LENGTH 0x54
  48. #define FIFO_FLAG_CNT 0x58
  49. #define IIC_CLK_DUR 0x5C
  50. #define IIC_CSR1 0x60
  51. #define IIC_CSR2 0x64
  52. /* DT3155 Internal Registers indexes (i2c/IIC mapped) */
  53. #define CSR2 0x10
  54. #define EVEN_CSR 0x11
  55. #define ODD_CSR 0x12
  56. #define CONFIG 0x13
  57. #define DT_ID 0x1F
  58. #define X_CLIP_START 0x20
  59. #define Y_CLIP_START 0x22
  60. #define X_CLIP_END 0x24
  61. #define Y_CLIP_END 0x26
  62. #define AD_ADDR 0x30
  63. #define AD_LUT 0x31
  64. #define AD_CMD 0x32
  65. #define DIG_OUT 0x40
  66. #define PM_LUT_ADDR 0x50
  67. #define PM_LUT_DATA 0x51
  68. /* AD command register values */
  69. #define AD_CMD_REG 0x00
  70. #define AD_POS_REF 0x01
  71. #define AD_NEG_REF 0x02
  72. /* CSR1 bit masks */
  73. #define CRPT_DIS 0x00004000
  74. #define FLD_CRPT_ODD 0x00000200
  75. #define FLD_CRPT_EVEN 0x00000100
  76. #define FIFO_EN 0x00000080
  77. #define SRST 0x00000040
  78. #define FLD_DN_ODD 0x00000020
  79. #define FLD_DN_EVEN 0x00000010
  80. /* These should not be used.
  81. * Use CAP_CONT_ODD/EVEN instead
  82. #define CAP_SNGL_ODD 0x00000008
  83. #define CAP_SNGL_EVEN 0x00000004
  84. */
  85. #define CAP_CONT_ODD 0x00000002
  86. #define CAP_CONT_EVEN 0x00000001
  87. /* INT_CSR bit masks */
  88. #define FLD_START_EN 0x00000400
  89. #define FLD_END_ODD_EN 0x00000200
  90. #define FLD_END_EVEN_EN 0x00000100
  91. #define FLD_START 0x00000004
  92. #define FLD_END_ODD 0x00000002
  93. #define FLD_END_EVEN 0x00000001
  94. /* IIC_CSR1 bit masks */
  95. #define DIRECT_ABORT 0x00000200
  96. /* IIC_CSR2 bit masks */
  97. #define NEW_CYCLE 0x01000000
  98. #define DIR_RD 0x00010000
  99. #define IIC_READ 0x01010000
  100. #define IIC_WRITE 0x01000000
  101. /* CSR2 bit masks */
  102. #define DISP_PASS 0x40
  103. #define BUSY_ODD 0x20
  104. #define BUSY_EVEN 0x10
  105. #define SYNC_PRESENT 0x08
  106. #define VT_50HZ 0x04
  107. #define SYNC_SNTL 0x02
  108. #define CHROM_FILT 0x01
  109. #define VT_60HZ 0x00
  110. /* CSR_EVEN/ODD bit masks */
  111. #define CSR_ERROR 0x04
  112. #define CSR_SNGL 0x02
  113. #define CSR_DONE 0x01
  114. /* CONFIG bit masks */
  115. #define PM_LUT_PGM 0x80
  116. #define PM_LUT_SEL 0x40
  117. #define CLIP_EN 0x20
  118. #define HSCALE_EN 0x10
  119. #define EXT_TRIG_UP 0x0C
  120. #define EXT_TRIG_DOWN 0x04
  121. #define ACQ_MODE_NEXT 0x02
  122. #define ACQ_MODE_ODD 0x01
  123. #define ACQ_MODE_EVEN 0x00
  124. /* AD_CMD bit masks */
  125. #define VIDEO_CNL_1 0x00
  126. #define VIDEO_CNL_2 0x40
  127. #define VIDEO_CNL_3 0x80
  128. #define VIDEO_CNL_4 0xC0
  129. #define SYNC_CNL_1 0x00
  130. #define SYNC_CNL_2 0x10
  131. #define SYNC_CNL_3 0x20
  132. #define SYNC_CNL_4 0x30
  133. #define SYNC_LVL_1 0x00
  134. #define SYNC_LVL_2 0x04
  135. #define SYNC_LVL_3 0x08
  136. #define SYNC_LVL_4 0x0C
  137. /* DT3155 identificator */
  138. #define DT3155_ID 0x20
  139. #ifdef CONFIG_DT3155_CCIR
  140. #define DMA_STRIDE 768
  141. #else
  142. #define DMA_STRIDE 640
  143. #endif
  144. /**
  145. * struct dt3155_stats - statistics structure
  146. *
  147. * @free_bufs_empty: no free image buffers
  148. * @corrupted_fields: corrupted fields
  149. * @dma_map_failed: dma mapping failed
  150. * @start_before_end: new started before old ended
  151. */
  152. struct dt3155_stats {
  153. int free_bufs_empty;
  154. int corrupted_fields;
  155. int dma_map_failed;
  156. int start_before_end;
  157. };
  158. /* per board private data structure */
  159. /**
  160. * struct dt3155_priv - private data structure
  161. *
  162. * @vdev: pointer to video_device structure
  163. * @acq_fp pointer to filp that starts acquisition
  164. * @streaming streaming is negotiated
  165. * @pdev: pointer to pci_dev structure
  166. * @vidq pointer to videobuf_queue structure
  167. * @curr_buf: pointer to curren buffer
  168. * @thread pointer to worker thraed
  169. * @irq_handler: irq handler for the driver
  170. * @qt_ops local copy of dma-contig qtype_ops
  171. * @dmaq queue for dma buffers
  172. * @do_dma wait queue of the kernel thread
  173. * @mux: mutex to protect the instance
  174. * @lock spinlock for videobuf queues
  175. * @field_count fields counter
  176. * @stats: statistics structure
  177. * @users open count
  178. * @regs: local copy of mmio base register
  179. * @csr2: local copy of csr2 register
  180. * @config: local copy of config register
  181. */
  182. struct dt3155_priv {
  183. struct video_device *vdev;
  184. struct file *acq_fp;
  185. int streaming;
  186. struct pci_dev *pdev;
  187. struct videobuf_queue *vidq;
  188. struct videobuf_buffer *curr_buf;
  189. struct task_struct *thread;
  190. irq_handler_t irq_handler;
  191. struct videobuf_qtype_ops qt_ops;
  192. struct list_head dmaq;
  193. wait_queue_head_t do_dma;
  194. struct mutex mux;
  195. spinlock_t lock;
  196. unsigned int field_count;
  197. struct dt3155_stats stats;
  198. void *regs;
  199. int users;
  200. u8 csr2, config;
  201. };
  202. #endif /* __KERNEL__ */
  203. #endif /* _DT3155_H_ */