aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/media/stv680.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/usb/media/stv680.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/usb/media/stv680.h')
-rw-r--r--drivers/usb/media/stv680.h222
1 files changed, 222 insertions, 0 deletions
diff --git a/drivers/usb/media/stv680.h b/drivers/usb/media/stv680.h
new file mode 100644
index 000000000000..7e0e314dcf12
--- /dev/null
+++ b/drivers/usb/media/stv680.h
@@ -0,0 +1,222 @@
1/****************************************************************************
2 *
3 * Filename: stv680.h
4 *
5 * Description:
6 * This is a USB driver for STV0680 based usb video cameras.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 ****************************************************************************/
23
24/* size of usb transfers */
25#define STV680_PACKETSIZE 4096
26
27/* number of queued bulk transfers to use, may have problems if > 1 */
28#define STV680_NUMSBUF 1
29
30/* number of frames supported by the v4l part */
31#define STV680_NUMFRAMES 2
32
33/* scratch buffers for passing data to the decoders: 2 or 4 are good */
34#define STV680_NUMSCRATCH 2
35
36/* number of nul sized packets to receive before kicking the camera */
37#define STV680_MAX_NULLPACKETS 200
38
39/* number of decoding errors before kicking the camera */
40#define STV680_MAX_ERRORS 100
41
42#define USB_PENCAM_VENDOR_ID 0x0553
43#define USB_PENCAM_PRODUCT_ID 0x0202
44#define PENCAM_TIMEOUT 1000
45/* fmt 4 */
46#define STV_VIDEO_PALETTE VIDEO_PALETTE_RGB24
47
48static struct usb_device_id device_table[] = {
49 {USB_DEVICE (USB_PENCAM_VENDOR_ID, USB_PENCAM_PRODUCT_ID)},
50 {}
51};
52MODULE_DEVICE_TABLE (usb, device_table);
53
54struct stv680_sbuf {
55 unsigned char *data;
56};
57
58enum {
59 FRAME_UNUSED, /* Unused (no MCAPTURE) */
60 FRAME_READY, /* Ready to start grabbing */
61 FRAME_GRABBING, /* In the process of being grabbed into */
62 FRAME_DONE, /* Finished grabbing, but not been synced yet */
63 FRAME_ERROR, /* Something bad happened while processing */
64};
65
66enum {
67 BUFFER_UNUSED,
68 BUFFER_READY,
69 BUFFER_BUSY,
70 BUFFER_DONE,
71};
72
73/* raw camera data <- sbuf (urb transfer buf) */
74struct stv680_scratch {
75 unsigned char *data;
76 volatile int state;
77 int offset;
78 int length;
79};
80
81/* processed data for display ends up here, after bayer */
82struct stv680_frame {
83 unsigned char *data; /* Frame buffer */
84 volatile int grabstate; /* State of grabbing */
85 unsigned char *curline;
86 int curlinepix;
87 int curpix;
88};
89
90/* this is almost the video structure uvd_t, with extra parameters for stv */
91struct usb_stv {
92 struct video_device *vdev;
93
94 struct usb_device *udev;
95
96 unsigned char bulk_in_endpointAddr; /* __u8 the address of the bulk in endpoint */
97 char *camera_name;
98
99 unsigned int VideoMode; /* 0x0100 = VGA, 0x0000 = CIF, 0x0300 = QVGA */
100 int SupportedModes;
101 int CIF;
102 int VGA;
103 int QVGA;
104 int cwidth; /* camera width */
105 int cheight; /* camera height */
106 int maxwidth; /* max video width */
107 int maxheight; /* max video height */
108 int vwidth; /* current width for video window */
109 int vheight; /* current height for video window */
110 unsigned long int rawbufsize;
111 unsigned long int maxframesize; /* rawbufsize * 3 for RGB */
112
113 int origGain;
114 int origMode; /* original camera mode */
115
116 struct semaphore lock; /* to lock the structure */
117 int user; /* user count for exclusive use */
118 int removed; /* device disconnected */
119 int streaming; /* Are we streaming video? */
120 char *fbuf; /* Videodev buffer area */
121 struct urb *urb[STV680_NUMSBUF]; /* # of queued bulk transfers */
122 int curframe; /* Current receiving frame */
123 struct stv680_frame frame[STV680_NUMFRAMES]; /* # frames supported by v4l part */
124 int readcount;
125 int framecount;
126 int error;
127 int dropped;
128 int scratch_next;
129 int scratch_use;
130 int scratch_overflow;
131 struct stv680_scratch scratch[STV680_NUMSCRATCH]; /* for decoders */
132 struct stv680_sbuf sbuf[STV680_NUMSBUF];
133
134 unsigned int brightness;
135 unsigned int chgbright;
136 unsigned int whiteness;
137 unsigned int colour;
138 unsigned int contrast;
139 unsigned int hue;
140 unsigned int palette;
141 unsigned int depth; /* rgb24 in bits */
142
143 wait_queue_head_t wq; /* Processes waiting */
144
145 int nullpackets;
146};
147
148
149static unsigned char red[256] = {
150 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
151 18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42,
152 44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69,
153 71, 71, 73, 75, 77, 78, 80, 81, 82, 84, 85, 87,
154 88, 89, 90, 91, 93, 94, 95, 97, 98, 98, 99, 101,
155 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
156 114, 115, 116, 116, 117, 118, 119, 120, 121, 122, 123, 124,
157 125, 125, 126, 127, 128, 129, 129, 130, 131, 132, 133, 134,
158 134, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143,
159 143, 143, 144, 145, 146, 147, 147, 148, 149, 150, 150, 151,
160 152, 152, 152, 153, 154, 154, 155, 156, 157, 157, 158, 159,
161 159, 160, 161, 161, 161, 162, 163, 163, 164, 165, 165, 166,
162 167, 167, 168, 168, 169, 170, 170, 170, 171, 171, 172, 173,
163 173, 174, 174, 175, 176, 176, 177, 178, 178, 179, 179, 179,
164 180, 180, 181, 181, 182, 183, 183, 184, 184, 185, 185, 186,
165 187, 187, 188, 188, 188, 188, 189, 190, 190, 191, 191, 192,
166 192, 193, 193, 194, 195, 195, 196, 196, 197, 197, 197, 197,
167 198, 198, 199, 199, 200, 201, 201, 202, 202, 203, 203, 204,
168 204, 205, 205, 206, 206, 206, 206, 207, 207, 208, 208, 209,
169 209, 210, 210, 211, 211, 212, 212, 213, 213, 214, 214, 215,
170 215, 215, 215, 216, 216, 217, 217, 218, 218, 218, 219, 219,
171 220, 220, 221, 221
172};
173
174static unsigned char green[256] = {
175 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
176 21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47,
177 50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77,
178 79, 80, 82, 84, 86, 87, 89, 91, 92, 94, 95, 97,
179 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 111, 113,
180 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126,
181 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
182 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149,
183 150, 151, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159,
184 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168,
185 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177,
186 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185,
187 186, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193,
188 193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200,
189 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206, 207,
190 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214,
191 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220,
192 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,
193 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233,
194 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239,
195 239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244,
196 245, 245, 246, 246
197};
198
199static unsigned char blue[256] = {
200 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
201 23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51,
202 55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84,
203 86, 88, 90, 92, 94, 95, 97, 100, 101, 103, 104, 106,
204 107, 110, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124,
205 125, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138,
206 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151,
207 152, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163,
208 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174,
209 176, 176, 177, 178, 179, 180, 180, 181, 182, 183, 183, 184,
210 185, 187, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194,
211 194, 195, 196, 196, 198, 199, 200, 200, 201, 202, 202, 203,
212 204, 204, 205, 205, 206, 207, 207, 209, 210, 210, 211, 212,
213 212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 218, 220,
214 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,
215 228, 228, 229, 229, 231, 231, 232, 233, 233, 234, 234, 235,
216 235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 242, 242,
217 243, 243, 244, 244, 245, 246, 246, 247, 247, 248, 248, 249,
218 249, 250, 250, 251, 251, 253, 253, 254, 254, 255, 255, 255,
219 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
220 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
221 255, 255, 255, 255
222};