Import 2.3.25pre1
[davej-history.git] / drivers / usb / cpia.h
blobf1d9ed7cd24f68208bc23eb4ff1118c6469bffc6
1 #ifndef __LINUX_CPIA_H
2 #define __LINUX_CPIA_H
4 #include <linux/list.h>
6 #define USB_REQ_CPIA_GET_VERSION 0x01
7 #define USB_REQ_CPIA_GET_PNP_ID 0x02
8 #define USB_REQ_CPIA_GET_CAMERA_STATUS 0x03
9 #define USB_REQ_CPIA_GOTO_HI_POWER 0x04
10 #define USB_REQ_CPIA_GOTO_LO_POWER 0x05
11 /* No 0x06 */
12 #define USB_REQ_CPIA_GOTO_SUSPEND 0x07
13 #define USB_REQ_CPIA_GOTO_PASS_THROUGH 0x08
14 /* No 0x09 */
15 #define USB_REQ_CPIA_MODIFY_CAMERA_STATUS 0x0A
17 #define USB_REQ_CPIA_READ_VC_REGS 0x21
18 #define USB_REQ_CPIA_WRITE_BC_REG 0x22
19 #define USB_REQ_CPIA_READ_MC_PORTS 0x23
20 #define USB_REQ_CPIA_WRITE_MC_PORT 0x24
21 #define USB_REQ_CPIA_SET_BAUD_RATE 0x25
22 #define USB_REQ_CPIA_SET_ECP_TIMING 0x26
23 #define USB_REQ_CPIA_READ_IDATA 0x27
24 #define USB_REQ_CPIA_WRITE_IDATA 0x28
25 #define USB_REQ_CPIA_GENERIC_CALL 0x29
26 #define USB_REQ_CPIA_I2CSTART 0x2A
27 #define USB_REQ_CPIA_I2CSTOP 0x2B
28 #define USB_REQ_CPIA_I2CWRITE 0x2C
29 #define USB_REQ_CPIA_I2CREAD 0x2D
31 #define USB_REQ_CPIA_GET_VP_VERSION 0xA1
32 #define USB_REQ_CPIA_SET_COLOUR_PARAMS 0xA3
33 #define USB_REQ_CPIA_SET_EXPOSURE 0xA4
34 /* No 0xA5 */
35 #define USB_REQ_CPIA_SET_COLOUR_BALANCE 0xA6
36 #define USB_REQ_CPIA_SET_SENSOR_FPS 0xA7
37 #define USB_REQ_CPIA_SET_VP_DEFAULTS 0xA8
38 #define USB_REQ_CPIA_SET_APCOR 0xA9
39 #define USB_REQ_CPIA_SET_FLICKER_CTRL 0xAA
40 #define USB_REQ_CPIA_SET_VL_OFFSET 0xAB
42 #define USB_REQ_CPIA_GET_COLOUR_PARAMETERS 0xB0
43 #define USB_REQ_CPIA_GET_COLOUR_BALANCE 0xB1
44 #define USB_REQ_CPIA_GET_EXPOSURE 0xB2
45 #define USB_REQ_CPIA_SET_SENSOR_MATRIX 0xB3
47 #define USB_REQ_CPIA_COLOUR_BARS 0xBD
48 #define USB_REQ_CPIA_READ_VP_REGS 0xBE
49 #define USB_REQ_CPIA_WRITE_VP_REGS 0xBF
51 #define USB_REQ_CPIA_GRAB_FRAME 0xC1
52 #define USB_REQ_CPIA_UPLOAD_FRAME 0xC2
53 #define USB_REQ_CPIA_SET_GRAB_MODE 0xC3
54 #define USB_REQ_CPIA_INIT_STREAM_CAP 0xC4
55 #define USB_REQ_CPIA_FINI_STREAM_CAP 0xC5
56 #define USB_REQ_CPIA_START_STREAM_CAP 0xC6
57 #define USB_REQ_CPIA_END_STREAM_CAP 0xC7
58 #define USB_REQ_CPIA_SET_FORMAT 0xC8
59 #define USB_REQ_CPIA_SET_ROI 0xC9
60 #define USB_REQ_CPIA_SET_COMPRESSION 0xCA
61 #define USB_REQ_CPIA_SET_COMPRESSION_TARGET 0xCB
62 #define USB_REQ_CPIA_SET_YUV_THRESH 0xCC
63 #define USB_REQ_CPIA_SET_COMPRESSION_PARAMS 0xCD
64 #define USB_REQ_CPIA_DISCARD_FRAME 0xCE
66 #define USB_REQ_CPIA_OUTPUT_RS232 0xE1
67 #define USB_REQ_CPIA_ABORT_PROCESS 0xE4
68 #define USB_REQ_CPIA_SET_DRAM_PAGE 0xE5
69 #define USB_REQ_CPIA_START_DRAM_UPLOAD 0xE6
70 #define USB_REQ_CPIA_START_DUMMY_STREAM 0xE8
71 #define USB_REQ_CPIA_ABORT_STREAM 0xE9
72 #define USB_REQ_CPIA_DOWNLOAD_DRAM 0xEA
73 /* #define USB_REQ_CPIA_NULL_CMD 0x?? */
75 #define CPIA_QCIF 0
76 #define CPIA_CIF 1
78 #define CPIA_YUYV 0
79 #define CPIA_UYVY 1
81 #define STREAM_BUF_SIZE (PAGE_SIZE * 4)
82 /* #define STREAM_BUF_SIZE (FRAMES_PER_DESC * FRAME_SIZE_PER_DESC) */
84 #define SCRATCH_BUF_SIZE (STREAM_BUF_SIZE * 2)
86 #define FRAMES_PER_DESC 10
87 #define FRAME_SIZE_PER_DESC 960 /* Shouldn't be hardcoded */
89 enum {
90 STATE_SCANNING, /* Scanning for start */
91 STATE_HEADER, /* Parsing header */
92 STATE_LINES, /* Parsing lines */
95 #define CPIA_MAGIC 0x1968
96 struct cpia_frame_header {
97 __u16 magic; /* 0 - 1 */
98 __u16 timestamp; /* 2 - 3 */
99 __u16 unused; /* 4 - 5 */
100 __u16 timestamp1; /* 6 - 7 */
101 __u8 unused1[8]; /* 8 - 15 */
102 __u8 video_size; /* 16 0 = QCIF, 1 = CIF */
103 __u8 sub_sample; /* 17 0 = 4:2:0, 1 = 4:2:2 */
104 __u8 yuv_order; /* 18 0 = YUYV, 1 = UYVY */
105 __u8 unused2[5]; /* 19 - 23 */
106 __u8 col_start; /* 24 */
107 __u8 col_end; /* 25 */
108 __u8 row_start; /* 26 */
109 __u8 row_end; /* 27 */
110 __u8 comp_enable; /* 28 0 = non compressed, 1 = compressed */
111 __u8 decimation; /* 29 0 = no decimation, 1 = decimation */
112 __u8 y_thresh; /* 30 */
113 __u8 uv_thresh; /* 31 */
114 __u8 system_state; /* 32 */
115 __u8 grab_state; /* 33 */
116 __u8 stream_state; /* 34 */
117 __u8 fatal_error; /* 35 */
118 __u8 cmd_error; /* 36 */
119 __u8 debug_flags; /* 37 */
120 __u8 camera_state_7; /* 38 */
121 __u8 camera_state_8; /* 39 */
122 __u8 cr_achieved; /* 40 */
123 __u8 fr_achieved; /* 41 */
124 __u8 unused3[22]; /* 42 - 63 */
127 struct usb_device;
129 struct cpia_sbuf {
130 char *data;
131 struct usb_isoc_desc *isodesc;
134 enum {
135 FRAME_UNUSED, /* Unused (no MCAPTURE) */
136 FRAME_READY, /* Ready to start grabbing */
137 FRAME_GRABBING, /* In the process of being grabbed into */
138 FRAME_DONE, /* Finished grabbing, but not been synced yet */
139 FRAME_ERROR, /* Something bad happened while processing */
142 struct cpia_frame {
143 char *data; /* Frame buffer */
145 struct cpia_frame_header header; /* Header from stream */
147 int width; /* Width application is expecting */
148 int height; /* Height */
150 int hdrwidth; /* Width the frame actually is */
151 int hdrheight; /* Height */
153 int grabstate; /* State of grabbing */
154 int scanstate; /* State of scanning */
156 int curline; /* Line of frame we're working on */
158 wait_queue_head_t wq; /* Processes waiting */
161 #define CPIA_NUMFRAMES 2
162 #define CPIA_NUMSBUF 2
164 struct usb_cpia {
165 struct video_device vdev;
167 /* Device structure */
168 struct usb_device *dev;
170 int streaming; /* Are we streaming Isochronous? */
171 int grabbing; /* Are we grabbing? */
173 int compress; /* Should the next frame be compressed? */
175 char *fbuf; /* Videodev buffer area */
177 int curframe;
178 struct cpia_frame frame[CPIA_NUMFRAMES]; /* Double buffering */
180 int cursbuf; /* Current receiving sbuf */
181 struct cpia_sbuf sbuf[CPIA_NUMSBUF]; /* Double buffering */
183 /* Scratch space from the Isochronous pipe */
184 unsigned char scratch[SCRATCH_BUF_SIZE];
185 int scratchlen;
188 #endif