Go to the documentation of this file.
31 #ifndef __LINUX_USBVISION_H
32 #define __LINUX_USBVISION_H
34 #include <linux/list.h>
36 #include <linux/i2c.h>
40 #include <linux/videodev2.h>
42 #define USBVISION_DEBUG
44 #define USBVISION_PWR_REG 0x00
45 #define USBVISION_SSPND_EN (1 << 1)
46 #define USBVISION_RES2 (1 << 2)
47 #define USBVISION_PWR_VID (1 << 5)
48 #define USBVISION_E2_EN (1 << 7)
49 #define USBVISION_CONFIG_REG 0x01
50 #define USBVISION_ADRS_REG 0x02
51 #define USBVISION_ALTER_REG 0x03
52 #define USBVISION_FORCE_ALTER_REG 0x04
53 #define USBVISION_STATUS_REG 0x05
54 #define USBVISION_IOPIN_REG 0x06
55 #define USBVISION_IO_1 (1 << 0)
56 #define USBVISION_IO_2 (1 << 1)
57 #define USBVISION_AUDIO_IN 0
58 #define USBVISION_AUDIO_TV 1
59 #define USBVISION_AUDIO_RADIO 2
60 #define USBVISION_AUDIO_MUTE 3
61 #define USBVISION_SER_MODE 0x07
62 #define USBVISION_CLK_OUT (1 << 0)
63 #define USBVISION_DAT_IO (1 << 1)
64 #define USBVISION_SENS_OUT (1 << 2)
65 #define USBVISION_SER_MODE_SOFT (0 << 4)
66 #define USBVISION_SER_MODE_SIO (1 << 4)
67 #define USBVISION_SER_ADRS 0x08
68 #define USBVISION_SER_CONT 0x09
69 #define USBVISION_SER_DAT1 0x0A
70 #define USBVISION_SER_DAT2 0x0B
71 #define USBVISION_SER_DAT3 0x0C
72 #define USBVISION_SER_DAT4 0x0D
73 #define USBVISION_EE_DATA 0x0E
74 #define USBVISION_EE_LSBAD 0x0F
75 #define USBVISION_EE_CONT 0x10
76 #define USBVISION_DRM_CONT 0x12
77 #define USBVISION_REF (1 << 0)
78 #define USBVISION_RES_UR (1 << 2)
79 #define USBVISION_RES_FDL (1 << 3)
80 #define USBVISION_RES_VDW (1 << 4)
81 #define USBVISION_DRM_PRM1 0x13
82 #define USBVISION_DRM_PRM2 0x14
83 #define USBVISION_DRM_PRM3 0x15
84 #define USBVISION_DRM_PRM4 0x16
85 #define USBVISION_DRM_PRM5 0x17
86 #define USBVISION_DRM_PRM6 0x18
87 #define USBVISION_DRM_PRM7 0x19
88 #define USBVISION_DRM_PRM8 0x1A
89 #define USBVISION_VIN_REG1 0x1B
90 #define USBVISION_8_422_SYNC 0x01
91 #define USBVISION_16_422_SYNC 0x02
92 #define USBVISION_VSNC_POL (1 << 3)
93 #define USBVISION_HSNC_POL (1 << 4)
94 #define USBVISION_FID_POL (1 << 5)
95 #define USBVISION_HVALID_PO (1 << 6)
96 #define USBVISION_VCLK_POL (1 << 7)
97 #define USBVISION_VIN_REG2 0x1C
98 #define USBVISION_AUTO_FID (1 << 0)
99 #define USBVISION_NONE_INTER (1 << 1)
100 #define USBVISION_NOHVALID (1 << 2)
101 #define USBVISION_UV_ID (1 << 3)
102 #define USBVISION_FIX_2C (1 << 4)
103 #define USBVISION_SEND_FID (1 << 5)
104 #define USBVISION_KEEP_BLANK (1 << 7)
105 #define USBVISION_LXSIZE_I 0x1D
106 #define USBVISION_MXSIZE_I 0x1E
107 #define USBVISION_LYSIZE_I 0x1F
108 #define USBVISION_MYSIZE_I 0x20
109 #define USBVISION_LX_OFFST 0x21
110 #define USBVISION_MX_OFFST 0x22
111 #define USBVISION_LY_OFFST 0x23
112 #define USBVISION_MY_OFFST 0x24
113 #define USBVISION_FRM_RATE 0x25
114 #define USBVISION_LXSIZE_O 0x26
115 #define USBVISION_MXSIZE_O 0x27
116 #define USBVISION_LYSIZE_O 0x28
117 #define USBVISION_MYSIZE_O 0x29
118 #define USBVISION_FILT_CONT 0x2A
119 #define USBVISION_VO_MODE 0x2B
120 #define USBVISION_INTRA_CYC 0x2C
121 #define USBVISION_STRIP_SZ 0x2D
122 #define USBVISION_FORCE_INTRA 0x2E
123 #define USBVISION_FORCE_UP 0x2F
124 #define USBVISION_BUF_THR 0x30
125 #define USBVISION_DVI_YUV 0x31
126 #define USBVISION_AUDIO_CONT 0x32
127 #define USBVISION_AUD_PK_LEN 0x33
128 #define USBVISION_BLK_PK_LEN 0x34
129 #define USBVISION_PCM_THR1 0x38
130 #define USBVISION_PCM_THR2 0x39
131 #define USBVISION_DIST_THR_L 0x3A
132 #define USBVISION_DIST_THR_H 0x3B
133 #define USBVISION_MAX_DIST_L 0x3C
134 #define USBVISION_MAX_DIST_H 0x3D
135 #define USBVISION_OP_CODE 0x33
137 #define MAX_BYTES_PER_PIXEL 4
139 #define MIN_FRAME_WIDTH 64
140 #define MAX_USB_WIDTH 320
141 #define MAX_FRAME_WIDTH 320
143 #define MIN_FRAME_HEIGHT 48
144 #define MAX_USB_HEIGHT 240
145 #define MAX_FRAME_HEIGHT 240
147 #define MAX_FRAME_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * MAX_BYTES_PER_PIXEL)
148 #define USBVISION_CLIPMASK_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT / 8)
150 #define USBVISION_URB_FRAMES 32
152 #define USBVISION_NUM_HEADERMARKER 20
153 #define USBVISION_NUMFRAMES 3
154 #define USBVISION_NUMSBUF 2
156 #define USBVISION_POWEROFF_TIME (3 * HZ)
159 #define FRAMERATE_MIN 0
160 #define FRAMERATE_MAX 31
169 #define RESTRICT_TO_RANGE(v, mi, ma) \
170 { if ((v) < (mi)) (v) = (mi); else if ((v) > (ma)) (v) = (ma); }
191 #define LIMIT_RGB(x) (((x) < 0) ? 0 : (((x) > 255) ? 255 : (x)))
192 #define YUV_TO_RGB_BY_THE_BOOK(my, mu, mv, mr, mg, mb) { \
193 int mm_y, mm_yc, mm_u, mm_v, mm_r, mm_g, mm_b; \
197 mm_yc = mm_y * 76284; \
198 mm_b = (mm_yc + 132252 * mm_v) >> 16; \
199 mm_g = (mm_yc - 53281 * mm_u - 25625 * mm_v) >> 16; \
200 mm_r = (mm_yc + 104595 * mm_u) >> 16; \
201 mb = LIMIT_RGB(mm_b); \
202 mg = LIMIT_RGB(mm_g); \
203 mr = LIMIT_RGB(mm_r); \
207 #define USBVISION_SAY_AND_WAIT(what) { \
208 wait_queue_head_t wq; \
209 init_waitqueue_head(&wq); \
210 printk(KERN_INFO "Say: %s\n", what); \
211 interruptible_sleep_on_timeout(&wq, HZ * 3); \
219 #define USBVISION_IS_OPERATIONAL(udevice) (\
220 (udevice != NULL) && \
221 ((udevice)->dev != NULL) && \
222 ((udevice)->last_error == 0) && \
223 (!(udevice)->remove_pending))
225 #define I2C_USB_ADAP_MAX 16
227 #define USBVISION_NORMS (V4L2_STD_PAL | V4L2_STD_NTSC | V4L2_STD_SECAM | V4L2_STD_PAL_M)
274 #define USBVISION_MAGIC_1 0x55
275 #define USBVISION_MAGIC_2 0xAA
276 #define USBVISION_HEADER_LENGTH 0x0c
277 #define USBVISION_SAA7111_ADDR 0x48
278 #define USBVISION_SAA7113_ADDR 0x4a
279 #define USBVISION_IIC_LRACK 0x20
280 #define USBVISION_IIC_LRNACK 0x30
281 #define USBVISION_FRAME_FORMAT_PARAM_INTRA (1<<7)
290 #define USBVISION_SUPPORTED_PALETTES ARRAY_SIZE(usbvision_v4l2_format)
334 #define CODEC_SAA7113 7113
335 #define CODEC_SAA7111 7111
336 #define CODEC_WEBCAM 3000
337 #define BRIDGE_NT1003 1003
338 #define BRIDGE_NT1004 1004
339 #define BRIDGE_NT1005 1005
478 #define call_all(usbvision, o, f, args...) \
479 v4l2_device_call_all(&usbvision->v4l2_dev, 0, o, f, ##args)
495 unsigned char value);