aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/pwc
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2012-08-13 23:13:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-15 15:25:07 -0400
commit0c0d06cac63ee327ceaab4b5ffe2206574ab86bd (patch)
treee759f0dc3185d97f2a0c6b5cd5e32ea6faa74d40 /drivers/media/usb/pwc
parent84cfe9e79bd5ac11c963f4841158454fefa872f6 (diff)
[media] rename most media/video usb drivers to media/usb
Rename all USB drivers with their own directory under drivers/media/video into drivers/media/usb and update the building system. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/usb/pwc')
-rw-r--r--drivers/media/usb/pwc/Kconfig48
-rw-r--r--drivers/media/usb/pwc/Makefile4
-rw-r--r--drivers/media/usb/pwc/philips.txt236
-rw-r--r--drivers/media/usb/pwc/pwc-ctrl.c553
-rw-r--r--drivers/media/usb/pwc/pwc-dec1.c32
-rw-r--r--drivers/media/usb/pwc/pwc-dec1.h39
-rw-r--r--drivers/media/usb/pwc/pwc-dec23.c691
-rw-r--r--drivers/media/usb/pwc/pwc-dec23.h61
-rw-r--r--drivers/media/usb/pwc/pwc-if.c1165
-rw-r--r--drivers/media/usb/pwc/pwc-kiara.c892
-rw-r--r--drivers/media/usb/pwc/pwc-kiara.h48
-rw-r--r--drivers/media/usb/pwc/pwc-misc.c93
-rw-r--r--drivers/media/usb/pwc/pwc-nala.h66
-rw-r--r--drivers/media/usb/pwc/pwc-timon.c1448
-rw-r--r--drivers/media/usb/pwc/pwc-timon.h63
-rw-r--r--drivers/media/usb/pwc/pwc-uncompress.c107
-rw-r--r--drivers/media/usb/pwc/pwc-v4l.c1053
-rw-r--r--drivers/media/usb/pwc/pwc.h393
18 files changed, 6992 insertions, 0 deletions
diff --git a/drivers/media/usb/pwc/Kconfig b/drivers/media/usb/pwc/Kconfig
new file mode 100644
index 000000000000..d63d0a850035
--- /dev/null
+++ b/drivers/media/usb/pwc/Kconfig
@@ -0,0 +1,48 @@
1config USB_PWC
2 tristate "USB Philips Cameras"
3 depends on VIDEO_V4L2
4 select VIDEOBUF2_VMALLOC
5 ---help---
6 Say Y or M here if you want to use one of these Philips & OEM
7 webcams:
8 * Philips PCA645, PCA646
9 * Philips PCVC675, PCVC680, PCVC690
10 * Philips PCVC720/40, PCVC730, PCVC740, PCVC750
11 * Philips SPC900NC
12 * Askey VC010
13 * Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro'
14 and 'Orbit'/'Sphere'
15 * Samsung MPC-C10, MPC-C30
16 * Creative Webcam 5, Pro Ex
17 * SOTEC Afina Eye
18 * Visionite VCS-UC300, VCS-UM100
19
20 The PCA635, PCVC665 and PCVC720/20 are not supported by this driver
21 and never will be, but the 665 and 720/20 are supported by other
22 drivers.
23
24 Some newer logitech webcams are not handled by this driver but by the
25 Usb Video Class driver (linux-uvc).
26
27 The built-in microphone is enabled by selecting USB Audio support.
28
29 To compile this driver as a module, choose M here: the
30 module will be called pwc.
31
32config USB_PWC_DEBUG
33 bool "USB Philips Cameras verbose debug"
34 depends on USB_PWC
35 help
36 Say Y here in order to have the pwc driver generate verbose debugging
37 messages.
38 A special module options 'trace' is used to control the verbosity.
39
40config USB_PWC_INPUT_EVDEV
41 bool "USB Philips Cameras input events device support"
42 default y
43 depends on USB_PWC && (USB_PWC=INPUT || INPUT=y)
44 ---help---
45 This option makes USB Philips cameras register the snapshot button as
46 an input device to report button events.
47
48 If you are in doubt, say Y.
diff --git a/drivers/media/usb/pwc/Makefile b/drivers/media/usb/pwc/Makefile
new file mode 100644
index 000000000000..f5c8ec261e87
--- /dev/null
+++ b/drivers/media/usb/pwc/Makefile
@@ -0,0 +1,4 @@
1pwc-objs := pwc-if.o pwc-misc.o pwc-ctrl.o pwc-v4l.o pwc-uncompress.o
2pwc-objs += pwc-dec1.o pwc-dec23.o pwc-kiara.o pwc-timon.o
3
4obj-$(CONFIG_USB_PWC) += pwc.o
diff --git a/drivers/media/usb/pwc/philips.txt b/drivers/media/usb/pwc/philips.txt
new file mode 100644
index 000000000000..d38dd791511e
--- /dev/null
+++ b/drivers/media/usb/pwc/philips.txt
@@ -0,0 +1,236 @@
1This file contains some additional information for the Philips and OEM webcams.
2E-mail: webcam@smcc.demon.nl Last updated: 2004-01-19
3Site: http://www.smcc.demon.nl/webcam/
4
5As of this moment, the following cameras are supported:
6 * Philips PCA645
7 * Philips PCA646
8 * Philips PCVC675
9 * Philips PCVC680
10 * Philips PCVC690
11 * Philips PCVC720/40
12 * Philips PCVC730
13 * Philips PCVC740
14 * Philips PCVC750
15 * Askey VC010
16 * Creative Labs Webcam 5
17 * Creative Labs Webcam Pro Ex
18 * Logitech QuickCam 3000 Pro
19 * Logitech QuickCam 4000 Pro
20 * Logitech QuickCam Notebook Pro
21 * Logitech QuickCam Zoom
22 * Logitech QuickCam Orbit
23 * Logitech QuickCam Sphere
24 * Samsung MPC-C10
25 * Samsung MPC-C30
26 * Sotec Afina Eye
27 * AME CU-001
28 * Visionite VCS-UM100
29 * Visionite VCS-UC300
30
31The main webpage for the Philips driver is at the address above. It contains
32a lot of extra information, a FAQ, and the binary plugin 'PWCX'. This plugin
33contains decompression routines that allow you to use higher image sizes and
34framerates; in addition the webcam uses less bandwidth on the USB bus (handy
35if you want to run more than 1 camera simultaneously). These routines fall
36under a NDA, and may therefore not be distributed as source; however, its use
37is completely optional.
38
39You can build this code either into your kernel, or as a module. I recommend
40the latter, since it makes troubleshooting a lot easier. The built-in
41microphone is supported through the USB Audio class.
42
43When you load the module you can set some default settings for the
44camera; some programs depend on a particular image-size or -format and
45don't know how to set it properly in the driver. The options are:
46
47size
48 Can be one of 'sqcif', 'qsif', 'qcif', 'sif', 'cif' or
49 'vga', for an image size of resp. 128x96, 160x120, 176x144,
50 320x240, 352x288 and 640x480 (of course, only for those cameras that
51 support these resolutions).
52
53fps
54 Specifies the desired framerate. Is an integer in the range of 4-30.
55
56fbufs
57 This parameter specifies the number of internal buffers to use for storing
58 frames from the cam. This will help if the process that reads images from
59 the cam is a bit slow or momentarily busy. However, on slow machines it
60 only introduces lag, so choose carefully. The default is 3, which is
61 reasonable. You can set it between 2 and 5.
62
63mbufs
64 This is an integer between 1 and 10. It will tell the module the number of
65 buffers to reserve for mmap(), VIDIOCCGMBUF, VIDIOCMCAPTURE and friends.
66 The default is 2, which is adequate for most applications (double
67 buffering).
68
69 Should you experience a lot of 'Dumping frame...' messages during
70 grabbing with a tool that uses mmap(), you might want to increase if.
71 However, it doesn't really buffer images, it just gives you a bit more
72 slack when your program is behind. But you need a multi-threaded or
73 forked program to really take advantage of these buffers.
74
75 The absolute maximum is 10, but don't set it too high! Every buffer takes
76 up 460 KB of RAM, so unless you have a lot of memory setting this to
77 something more than 4 is an absolute waste. This memory is only
78 allocated during open(), so nothing is wasted when the camera is not in
79 use.
80
81power_save
82 When power_save is enabled (set to 1), the module will try to shut down
83 the cam on close() and re-activate on open(). This will save power and
84 turn off the LED. Not all cameras support this though (the 645 and 646
85 don't have power saving at all), and some models don't work either (they
86 will shut down, but never wake up). Consider this experimental. By
87 default this option is disabled.
88
89compression (only useful with the plugin)
90 With this option you can control the compression factor that the camera
91 uses to squeeze the image through the USB bus. You can set the
92 parameter between 0 and 3:
93 0 = prefer uncompressed images; if the requested mode is not available
94 in an uncompressed format, the driver will silently switch to low
95 compression.
96 1 = low compression.
97 2 = medium compression.
98 3 = high compression.
99
100 High compression takes less bandwidth of course, but it could also
101 introduce some unwanted artefacts. The default is 2, medium compression.
102 See the FAQ on the website for an overview of which modes require
103 compression.
104
105 The compression parameter does not apply to the 645 and 646 cameras
106 and OEM models derived from those (only a few). Most cams honour this
107 parameter.
108
109leds
110 This settings takes 2 integers, that define the on/off time for the LED
111 (in milliseconds). One of the interesting things that you can do with
112 this is let the LED blink while the camera is in use. This:
113
114 leds=500,500
115
116 will blink the LED once every second. But with:
117
118 leds=0,0
119
120 the LED never goes on, making it suitable for silent surveillance.
121
122 By default the camera's LED is on solid while in use, and turned off
123 when the camera is not used anymore.
124
125 This parameter works only with the ToUCam range of cameras (720, 730, 740,
126 750) and OEMs. For other cameras this command is silently ignored, and
127 the LED cannot be controlled.
128
129 Finally: this parameters does not take effect UNTIL the first time you
130 open the camera device. Until then, the LED remains on.
131
132dev_hint
133 A long standing problem with USB devices is their dynamic nature: you
134 never know what device a camera gets assigned; it depends on module load
135 order, the hub configuration, the order in which devices are plugged in,
136 and the phase of the moon (i.e. it can be random). With this option you
137 can give the driver a hint as to what video device node (/dev/videoX) it
138 should use with a specific camera. This is also handy if you have two
139 cameras of the same model.
140
141 A camera is specified by its type (the number from the camera model,
142 like PCA645, PCVC750VC, etc) and optionally the serial number (visible
143 in /proc/bus/usb/devices). A hint consists of a string with the following
144 format:
145
146 [type[.serialnumber]:]node
147
148 The square brackets mean that both the type and the serialnumber are
149 optional, but a serialnumber cannot be specified without a type (which
150 would be rather pointless). The serialnumber is separated from the type
151 by a '.'; the node number by a ':'.
152
153 This somewhat cryptic syntax is best explained by a few examples:
154
155 dev_hint=3,5 The first detected cam gets assigned
156 /dev/video3, the second /dev/video5. Any
157 other cameras will get the first free
158 available slot (see below).
159
160 dev_hint=645:1,680:2 The PCA645 camera will get /dev/video1,
161 and a PCVC680 /dev/video2.
162
163 dev_hint=645.0123:3,645.4567:0 The PCA645 camera with serialnumber
164 0123 goes to /dev/video3, the same
165 camera model with the 4567 serial
166 gets /dev/video0.
167
168 dev_hint=750:1,4,5,6 The PCVC750 camera will get /dev/video1, the
169 next 3 Philips cams will use /dev/video4
170 through /dev/video6.
171
172 Some points worth knowing:
173 - Serialnumbers are case sensitive and must be written full, including
174 leading zeroes (it's treated as a string).
175 - If a device node is already occupied, registration will fail and
176 the webcam is not available.
177 - You can have up to 64 video devices; be sure to make enough device
178 nodes in /dev if you want to spread the numbers.
179 After /dev/video9 comes /dev/video10 (not /dev/videoA).
180 - If a camera does not match any dev_hint, it will simply get assigned
181 the first available device node, just as it used to be.
182
183trace
184 In order to better detect problems, it is now possible to turn on a
185 'trace' of some of the calls the module makes; it logs all items in your
186 kernel log at debug level.
187
188 The trace variable is a bitmask; each bit represents a certain feature.
189 If you want to trace something, look up the bit value(s) in the table
190 below, add the values together and supply that to the trace variable.
191
192 Value Value Description Default
193 (dec) (hex)
194 1 0x1 Module initialization; this will log messages On
195 while loading and unloading the module
196
197 2 0x2 probe() and disconnect() traces On
198
199 4 0x4 Trace open() and close() calls Off
200
201 8 0x8 read(), mmap() and associated ioctl() calls Off
202
203 16 0x10 Memory allocation of buffers, etc. Off
204
205 32 0x20 Showing underflow, overflow and Dumping frame On
206 messages
207
208 64 0x40 Show viewport and image sizes Off
209
210 128 0x80 PWCX debugging Off
211
212 For example, to trace the open() & read() functions, sum 8 + 4 = 12,
213 so you would supply trace=12 during insmod or modprobe. If
214 you want to turn the initialization and probing tracing off, set trace=0.
215 The default value for trace is 35 (0x23).
216
217
218
219Example:
220
221 # modprobe pwc size=cif fps=15 power_save=1
222
223The fbufs, mbufs and trace parameters are global and apply to all connected
224cameras. Each camera has its own set of buffers.
225
226size and fps only specify defaults when you open() the device; this is to
227accommodate some tools that don't set the size. You can change these
228settings after open() with the Video4Linux ioctl() calls. The default of
229defaults is QCIF size at 10 fps.
230
231The compression parameter is semiglobal; it sets the initial compression
232preference for all camera's, but this parameter can be set per camera with
233the VIDIOCPWCSCQUAL ioctl() call.
234
235All parameters are optional.
236
diff --git a/drivers/media/usb/pwc/pwc-ctrl.c b/drivers/media/usb/pwc/pwc-ctrl.c
new file mode 100644
index 000000000000..1f506fde97d0
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-ctrl.c
@@ -0,0 +1,553 @@
1/* Driver for Philips webcam
2 Functions that send various control messages to the webcam, including
3 video modes.
4 (C) 1999-2003 Nemosoft Unv.
5 (C) 2004-2006 Luc Saillard (luc@saillard.org)
6 (C) 2011 Hans de Goede <hdegoede@redhat.com>
7
8 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
9 driver and thus may have bugs that are not present in the original version.
10 Please send bug reports and support requests to <luc@saillard.org>.
11
12 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
13 driver and thus may have bugs that are not present in the original version.
14 Please send bug reports and support requests to <luc@saillard.org>.
15 The decompression routines have been implemented by reverse-engineering the
16 Nemosoft binary pwcx module. Caveat emptor.
17
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation; either version 2 of the License, or
21 (at your option) any later version.
22
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
27
28 You should have received a copy of the GNU General Public License
29 along with this program; if not, write to the Free Software
30 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31*/
32
33/*
34 Changes
35 2001/08/03 Alvarado Added methods for changing white balance and
36 red/green gains
37 */
38
39/* Control functions for the cam; brightness, contrast, video mode, etc. */
40
41#ifdef __KERNEL__
42#include <asm/uaccess.h>
43#endif
44#include <asm/errno.h>
45
46#include "pwc.h"
47#include "pwc-kiara.h"
48#include "pwc-timon.h"
49#include "pwc-dec1.h"
50#include "pwc-dec23.h"
51
52/* Selectors for status controls used only in this file */
53#define GET_STATUS_B00 0x0B00
54#define SENSOR_TYPE_FORMATTER1 0x0C00
55#define GET_STATUS_3000 0x3000
56#define READ_RAW_Y_MEAN_FORMATTER 0x3100
57#define SET_POWER_SAVE_MODE_FORMATTER 0x3200
58#define MIRROR_IMAGE_FORMATTER 0x3300
59#define LED_FORMATTER 0x3400
60#define LOWLIGHT 0x3500
61#define GET_STATUS_3600 0x3600
62#define SENSOR_TYPE_FORMATTER2 0x3700
63#define GET_STATUS_3800 0x3800
64#define GET_STATUS_4000 0x4000
65#define GET_STATUS_4100 0x4100 /* Get */
66#define CTL_STATUS_4200 0x4200 /* [GS] 1 */
67
68/* Formatters for the Video Endpoint controls [GS]ET_EP_STREAM_CTL */
69#define VIDEO_OUTPUT_CONTROL_FORMATTER 0x0100
70
71static const char *size2name[PSZ_MAX] =
72{
73 "subQCIF",
74 "QSIF",
75 "QCIF",
76 "SIF",
77 "CIF",
78 "VGA",
79};
80
81/********/
82
83/* Entries for the Nala (645/646) camera; the Nala doesn't have compression
84 preferences, so you either get compressed or non-compressed streams.
85
86 An alternate value of 0 means this mode is not available at all.
87 */
88
89#define PWC_FPS_MAX_NALA 8
90
91struct Nala_table_entry {
92 char alternate; /* USB alternate setting */
93 int compressed; /* Compressed yes/no */
94
95 unsigned char mode[3]; /* precomputed mode table */
96};
97
98static unsigned int Nala_fps_vector[PWC_FPS_MAX_NALA] = { 4, 5, 7, 10, 12, 15, 20, 24 };
99
100static struct Nala_table_entry Nala_table[PSZ_MAX][PWC_FPS_MAX_NALA] =
101{
102#include "pwc-nala.h"
103};
104
105/****************************************************************************/
106
107static int recv_control_msg(struct pwc_device *pdev,
108 u8 request, u16 value, int recv_count)
109{
110 int rc;
111
112 rc = usb_control_msg(pdev->udev, usb_rcvctrlpipe(pdev->udev, 0),
113 request,
114 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
115 value, pdev->vcinterface,
116 pdev->ctrl_buf, recv_count, USB_CTRL_GET_TIMEOUT);
117 if (rc < 0)
118 PWC_ERROR("recv_control_msg error %d req %02x val %04x\n",
119 rc, request, value);
120 return rc;
121}
122
123static inline int send_video_command(struct pwc_device *pdev,
124 int index, const unsigned char *buf, int buflen)
125{
126 int rc;
127
128 memcpy(pdev->ctrl_buf, buf, buflen);
129
130 rc = usb_control_msg(pdev->udev, usb_sndctrlpipe(pdev->udev, 0),
131 SET_EP_STREAM_CTL,
132 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
133 VIDEO_OUTPUT_CONTROL_FORMATTER, index,
134 pdev->ctrl_buf, buflen, USB_CTRL_SET_TIMEOUT);
135 if (rc >= 0)
136 memcpy(pdev->cmd_buf, buf, buflen);
137 else
138 PWC_ERROR("send_video_command error %d\n", rc);
139
140 return rc;
141}
142
143int send_control_msg(struct pwc_device *pdev,
144 u8 request, u16 value, void *buf, int buflen)
145{
146 return usb_control_msg(pdev->udev, usb_sndctrlpipe(pdev->udev, 0),
147 request,
148 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
149 value, pdev->vcinterface,
150 buf, buflen, USB_CTRL_SET_TIMEOUT);
151}
152
153static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt,
154 int frames, int *compression, int send_to_cam)
155{
156 int fps, ret = 0;
157 struct Nala_table_entry *pEntry;
158 int frames2frames[31] =
159 { /* closest match of framerate */
160 0, 0, 0, 0, 4, /* 0-4 */
161 5, 5, 7, 7, 10, /* 5-9 */
162 10, 10, 12, 12, 15, /* 10-14 */
163 15, 15, 15, 20, 20, /* 15-19 */
164 20, 20, 20, 24, 24, /* 20-24 */
165 24, 24, 24, 24, 24, /* 25-29 */
166 24 /* 30 */
167 };
168 int frames2table[31] =
169 { 0, 0, 0, 0, 0, /* 0-4 */
170 1, 1, 1, 2, 2, /* 5-9 */
171 3, 3, 4, 4, 4, /* 10-14 */
172 5, 5, 5, 5, 5, /* 15-19 */
173 6, 6, 6, 6, 7, /* 20-24 */
174 7, 7, 7, 7, 7, /* 25-29 */
175 7 /* 30 */
176 };
177
178 if (size < 0 || size > PSZ_CIF)
179 return -EINVAL;
180 if (frames < 4)
181 frames = 4;
182 else if (frames > 25)
183 frames = 25;
184 frames = frames2frames[frames];
185 fps = frames2table[frames];
186 pEntry = &Nala_table[size][fps];
187 if (pEntry->alternate == 0)
188 return -EINVAL;
189
190 if (send_to_cam)
191 ret = send_video_command(pdev, pdev->vendpoint,
192 pEntry->mode, 3);
193 if (ret < 0)
194 return ret;
195
196 if (pEntry->compressed && pixfmt == V4L2_PIX_FMT_YUV420)
197 pwc_dec1_init(pdev, pEntry->mode);
198
199 /* Set various parameters */
200 pdev->pixfmt = pixfmt;
201 pdev->vframes = frames;
202 pdev->valternate = pEntry->alternate;
203 pdev->width = pwc_image_sizes[size][0];
204 pdev->height = pwc_image_sizes[size][1];
205 pdev->frame_size = (pdev->width * pdev->height * 3) / 2;
206 if (pEntry->compressed) {
207 if (pdev->release < 5) { /* 4 fold compression */
208 pdev->vbandlength = 528;
209 pdev->frame_size /= 4;
210 }
211 else {
212 pdev->vbandlength = 704;
213 pdev->frame_size /= 3;
214 }
215 }
216 else
217 pdev->vbandlength = 0;
218
219 /* Let pwc-if.c:isoc_init know we don't support higher compression */
220 *compression = 3;
221
222 return 0;
223}
224
225
226static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt,
227 int frames, int *compression, int send_to_cam)
228{
229 const struct Timon_table_entry *pChoose;
230 int fps, ret = 0;
231
232 if (size >= PSZ_MAX || *compression < 0 || *compression > 3)
233 return -EINVAL;
234 if (frames < 5)
235 frames = 5;
236 else if (size == PSZ_VGA && frames > 15)
237 frames = 15;
238 else if (frames > 30)
239 frames = 30;
240 fps = (frames / 5) - 1;
241
242 /* Find a supported framerate with progressively higher compression */
243 pChoose = NULL;
244 while (*compression <= 3) {
245 pChoose = &Timon_table[size][fps][*compression];
246 if (pChoose->alternate != 0)
247 break;
248 (*compression)++;
249 }
250 if (pChoose == NULL || pChoose->alternate == 0)
251 return -ENOENT; /* Not supported. */
252
253 if (send_to_cam)
254 ret = send_video_command(pdev, pdev->vendpoint,
255 pChoose->mode, 13);
256 if (ret < 0)
257 return ret;
258
259 if (pChoose->bandlength > 0 && pixfmt == V4L2_PIX_FMT_YUV420)
260 pwc_dec23_init(pdev, pChoose->mode);
261
262 /* Set various parameters */
263 pdev->pixfmt = pixfmt;
264 pdev->vframes = (fps + 1) * 5;
265 pdev->valternate = pChoose->alternate;
266 pdev->width = pwc_image_sizes[size][0];
267 pdev->height = pwc_image_sizes[size][1];
268 pdev->vbandlength = pChoose->bandlength;
269 if (pChoose->bandlength > 0)
270 pdev->frame_size = (pChoose->bandlength * pdev->height) / 4;
271 else
272 pdev->frame_size = (pdev->width * pdev->height * 12) / 8;
273 return 0;
274}
275
276
277static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt,
278 int frames, int *compression, int send_to_cam)
279{
280 const struct Kiara_table_entry *pChoose = NULL;
281 int fps, ret = 0;
282
283 if (size >= PSZ_MAX || *compression < 0 || *compression > 3)
284 return -EINVAL;
285 if (frames < 5)
286 frames = 5;
287 else if (size == PSZ_VGA && frames > 15)
288 frames = 15;
289 else if (frames > 30)
290 frames = 30;
291 fps = (frames / 5) - 1;
292
293 /* Find a supported framerate with progressively higher compression */
294 while (*compression <= 3) {
295 pChoose = &Kiara_table[size][fps][*compression];
296 if (pChoose->alternate != 0)
297 break;
298 (*compression)++;
299 }
300 if (pChoose == NULL || pChoose->alternate == 0)
301 return -ENOENT; /* Not supported. */
302
303 /* Firmware bug: video endpoint is 5, but commands are sent to endpoint 4 */
304 if (send_to_cam)
305 ret = send_video_command(pdev, 4, pChoose->mode, 12);
306 if (ret < 0)
307 return ret;
308
309 if (pChoose->bandlength > 0 && pixfmt == V4L2_PIX_FMT_YUV420)
310 pwc_dec23_init(pdev, pChoose->mode);
311
312 /* All set and go */
313 pdev->pixfmt = pixfmt;
314 pdev->vframes = (fps + 1) * 5;
315 pdev->valternate = pChoose->alternate;
316 pdev->width = pwc_image_sizes[size][0];
317 pdev->height = pwc_image_sizes[size][1];
318 pdev->vbandlength = pChoose->bandlength;
319 if (pdev->vbandlength > 0)
320 pdev->frame_size = (pdev->vbandlength * pdev->height) / 4;
321 else
322 pdev->frame_size = (pdev->width * pdev->height * 12) / 8;
323 PWC_TRACE("frame_size=%d, vframes=%d, vsize=%d, vbandlength=%d\n",
324 pdev->frame_size, pdev->vframes, size, pdev->vbandlength);
325 return 0;
326}
327
328int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
329 int pixfmt, int frames, int *compression, int send_to_cam)
330{
331 int ret, size;
332
333 PWC_DEBUG_FLOW("set_video_mode(%dx%d @ %d, pixfmt %08x).\n",
334 width, height, frames, pixfmt);
335 size = pwc_get_size(pdev, width, height);
336 PWC_TRACE("decode_size = %d.\n", size);
337
338 if (DEVICE_USE_CODEC1(pdev->type)) {
339 ret = set_video_mode_Nala(pdev, size, pixfmt, frames,
340 compression, send_to_cam);
341 } else if (DEVICE_USE_CODEC3(pdev->type)) {
342 ret = set_video_mode_Kiara(pdev, size, pixfmt, frames,
343 compression, send_to_cam);
344 } else {
345 ret = set_video_mode_Timon(pdev, size, pixfmt, frames,
346 compression, send_to_cam);
347 }
348 if (ret < 0) {
349 PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret);
350 return ret;
351 }
352 pdev->frame_total_size = pdev->frame_size + pdev->frame_header_size + pdev->frame_trailer_size;
353 PWC_DEBUG_SIZE("Set resolution to %dx%d\n", pdev->width, pdev->height);
354 return 0;
355}
356
357static unsigned int pwc_get_fps_Nala(struct pwc_device *pdev, unsigned int index, unsigned int size)
358{
359 unsigned int i;
360
361 for (i = 0; i < PWC_FPS_MAX_NALA; i++) {
362 if (Nala_table[size][i].alternate) {
363 if (index--==0) return Nala_fps_vector[i];
364 }
365 }
366 return 0;
367}
368
369static unsigned int pwc_get_fps_Kiara(struct pwc_device *pdev, unsigned int index, unsigned int size)
370{
371 unsigned int i;
372
373 for (i = 0; i < PWC_FPS_MAX_KIARA; i++) {
374 if (Kiara_table[size][i][3].alternate) {
375 if (index--==0) return Kiara_fps_vector[i];
376 }
377 }
378 return 0;
379}
380
381static unsigned int pwc_get_fps_Timon(struct pwc_device *pdev, unsigned int index, unsigned int size)
382{
383 unsigned int i;
384
385 for (i=0; i < PWC_FPS_MAX_TIMON; i++) {
386 if (Timon_table[size][i][3].alternate) {
387 if (index--==0) return Timon_fps_vector[i];
388 }
389 }
390 return 0;
391}
392
393unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size)
394{
395 unsigned int ret;
396
397 if (DEVICE_USE_CODEC1(pdev->type)) {
398 ret = pwc_get_fps_Nala(pdev, index, size);
399
400 } else if (DEVICE_USE_CODEC3(pdev->type)) {
401 ret = pwc_get_fps_Kiara(pdev, index, size);
402
403 } else {
404 ret = pwc_get_fps_Timon(pdev, index, size);
405 }
406
407 return ret;
408}
409
410int pwc_get_u8_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *data)
411{
412 int ret;
413
414 ret = recv_control_msg(pdev, request, value, 1);
415 if (ret < 0)
416 return ret;
417
418 *data = pdev->ctrl_buf[0];
419 return 0;
420}
421
422int pwc_set_u8_ctrl(struct pwc_device *pdev, u8 request, u16 value, u8 data)
423{
424 int ret;
425
426 pdev->ctrl_buf[0] = data;
427 ret = send_control_msg(pdev, request, value, pdev->ctrl_buf, 1);
428 if (ret < 0)
429 return ret;
430
431 return 0;
432}
433
434int pwc_get_s8_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *data)
435{
436 int ret;
437
438 ret = recv_control_msg(pdev, request, value, 1);
439 if (ret < 0)
440 return ret;
441
442 *data = ((s8 *)pdev->ctrl_buf)[0];
443 return 0;
444}
445
446int pwc_get_u16_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *data)
447{
448 int ret;
449
450 ret = recv_control_msg(pdev, request, value, 2);
451 if (ret < 0)
452 return ret;
453
454 *data = (pdev->ctrl_buf[1] << 8) | pdev->ctrl_buf[0];
455 return 0;
456}
457
458int pwc_set_u16_ctrl(struct pwc_device *pdev, u8 request, u16 value, u16 data)
459{
460 int ret;
461
462 pdev->ctrl_buf[0] = data & 0xff;
463 pdev->ctrl_buf[1] = data >> 8;
464 ret = send_control_msg(pdev, request, value, pdev->ctrl_buf, 2);
465 if (ret < 0)
466 return ret;
467
468 return 0;
469}
470
471int pwc_button_ctrl(struct pwc_device *pdev, u16 value)
472{
473 int ret;
474
475 ret = send_control_msg(pdev, SET_STATUS_CTL, value, NULL, 0);
476 if (ret < 0)
477 return ret;
478
479 return 0;
480}
481
482/* POWER */
483void pwc_camera_power(struct pwc_device *pdev, int power)
484{
485 int r;
486
487 if (!pdev->power_save)
488 return;
489
490 if (pdev->type < 675 || (pdev->type < 730 && pdev->release < 6))
491 return; /* Not supported by Nala or Timon < release 6 */
492
493 if (power)
494 pdev->ctrl_buf[0] = 0x00; /* active */
495 else
496 pdev->ctrl_buf[0] = 0xFF; /* power save */
497 r = send_control_msg(pdev, SET_STATUS_CTL,
498 SET_POWER_SAVE_MODE_FORMATTER, pdev->ctrl_buf, 1);
499 if (r < 0)
500 PWC_ERROR("Failed to power %s camera (%d)\n",
501 power ? "on" : "off", r);
502}
503
504int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value)
505{
506 int r;
507
508 if (pdev->type < 730)
509 return 0;
510 on_value /= 100;
511 off_value /= 100;
512 if (on_value < 0)
513 on_value = 0;
514 if (on_value > 0xff)
515 on_value = 0xff;
516 if (off_value < 0)
517 off_value = 0;
518 if (off_value > 0xff)
519 off_value = 0xff;
520
521 pdev->ctrl_buf[0] = on_value;
522 pdev->ctrl_buf[1] = off_value;
523
524 r = send_control_msg(pdev,
525 SET_STATUS_CTL, LED_FORMATTER, pdev->ctrl_buf, 2);
526 if (r < 0)
527 PWC_ERROR("Failed to set LED on/off time (%d)\n", r);
528
529 return r;
530}
531
532#ifdef CONFIG_USB_PWC_DEBUG
533int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
534{
535 int ret = -1, request;
536
537 if (pdev->type < 675)
538 request = SENSOR_TYPE_FORMATTER1;
539 else if (pdev->type < 730)
540 return -1; /* The Vesta series doesn't have this call */
541 else
542 request = SENSOR_TYPE_FORMATTER2;
543
544 ret = recv_control_msg(pdev, GET_STATUS_CTL, request, 1);
545 if (ret < 0)
546 return ret;
547 if (pdev->type < 675)
548 *sensor = pdev->ctrl_buf[0] | 0x100;
549 else
550 *sensor = pdev->ctrl_buf[0];
551 return 0;
552}
553#endif
diff --git a/drivers/media/usb/pwc/pwc-dec1.c b/drivers/media/usb/pwc/pwc-dec1.c
new file mode 100644
index 000000000000..e899036aadf4
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-dec1.c
@@ -0,0 +1,32 @@
1/* Linux driver for Philips webcam
2 Decompression for chipset version 1
3 (C) 2004-2006 Luc Saillard (luc@saillard.org)
4
5 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
6 driver and thus may have bugs that are not present in the original version.
7 Please send bug reports and support requests to <luc@saillard.org>.
8 The decompression routines have been implemented by reverse-engineering the
9 Nemosoft binary pwcx module. Caveat emptor.
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24*/
25#include "pwc.h"
26
27void pwc_dec1_init(struct pwc_device *pdev, const unsigned char *cmd)
28{
29 struct pwc_dec1_private *pdec = &pdev->dec1;
30
31 pdec->version = pdev->release;
32}
diff --git a/drivers/media/usb/pwc/pwc-dec1.h b/drivers/media/usb/pwc/pwc-dec1.h
new file mode 100644
index 000000000000..c565ef8f52fb
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-dec1.h
@@ -0,0 +1,39 @@
1/* Linux driver for Philips webcam
2 (C) 2004-2006 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25#ifndef PWC_DEC1_H
26#define PWC_DEC1_H
27
28#include <linux/mutex.h>
29
30struct pwc_device;
31
32struct pwc_dec1_private
33{
34 int version;
35};
36
37void pwc_dec1_init(struct pwc_device *pdev, const unsigned char *cmd);
38
39#endif
diff --git a/drivers/media/usb/pwc/pwc-dec23.c b/drivers/media/usb/pwc/pwc-dec23.c
new file mode 100644
index 000000000000..3792fedff951
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-dec23.c
@@ -0,0 +1,691 @@
1/* Linux driver for Philips webcam
2 Decompression for chipset version 2 et 3
3 (C) 2004-2006 Luc Saillard (luc@saillard.org)
4
5 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
6 driver and thus may have bugs that are not present in the original version.
7 Please send bug reports and support requests to <luc@saillard.org>.
8 The decompression routines have been implemented by reverse-engineering the
9 Nemosoft binary pwcx module. Caveat emptor.
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
25*/
26
27#include "pwc-timon.h"
28#include "pwc-kiara.h"
29#include "pwc-dec23.h"
30
31#include <linux/string.h>
32#include <linux/slab.h>
33
34/*
35 * USE_LOOKUP_TABLE_TO_CLAMP
36 * 0: use a C version of this tests: { a<0?0:(a>255?255:a) }
37 * 1: use a faster lookup table for cpu with a big cache (intel)
38 */
39#define USE_LOOKUP_TABLE_TO_CLAMP 1
40/*
41 * UNROLL_LOOP_FOR_COPYING_BLOCK
42 * 0: use a loop for a smaller code (but little slower)
43 * 1: when unrolling the loop, gcc produces some faster code (perhaps only
44 * valid for intel processor class). Activating this option, automaticaly
45 * activate USE_LOOKUP_TABLE_TO_CLAMP
46 */
47#define UNROLL_LOOP_FOR_COPY 1
48#if UNROLL_LOOP_FOR_COPY
49# undef USE_LOOKUP_TABLE_TO_CLAMP
50# define USE_LOOKUP_TABLE_TO_CLAMP 1
51#endif
52
53static void build_subblock_pattern(struct pwc_dec23_private *pdec)
54{
55 static const unsigned int initial_values[12] = {
56 -0x526500, -0x221200, 0x221200, 0x526500,
57 -0x3de200, 0x3de200,
58 -0x6db480, -0x2d5d00, 0x2d5d00, 0x6db480,
59 -0x12c200, 0x12c200
60
61 };
62 static const unsigned int values_derivated[12] = {
63 0xa4ca, 0x4424, -0x4424, -0xa4ca,
64 0x7bc4, -0x7bc4,
65 0xdb69, 0x5aba, -0x5aba, -0xdb69,
66 0x2584, -0x2584
67 };
68 unsigned int temp_values[12];
69 int i, j;
70
71 memcpy(temp_values, initial_values, sizeof(initial_values));
72 for (i = 0; i < 256; i++) {
73 for (j = 0; j < 12; j++) {
74 pdec->table_subblock[i][j] = temp_values[j];
75 temp_values[j] += values_derivated[j];
76 }
77 }
78}
79
80static void build_bit_powermask_table(struct pwc_dec23_private *pdec)
81{
82 unsigned char *p;
83 unsigned int bit, byte, mask, val;
84 unsigned int bitpower = 1;
85
86 for (bit = 0; bit < 8; bit++) {
87 mask = bitpower - 1;
88 p = pdec->table_bitpowermask[bit];
89 for (byte = 0; byte < 256; byte++) {
90 val = (byte & mask);
91 if (byte & bitpower)
92 val = -val;
93 *p++ = val;
94 }
95 bitpower<<=1;
96 }
97}
98
99
100static void build_table_color(const unsigned int romtable[16][8],
101 unsigned char p0004[16][1024],
102 unsigned char p8004[16][256])
103{
104 int compression_mode, j, k, bit, pw;
105 unsigned char *p0, *p8;
106 const unsigned int *r;
107
108 /* We have 16 compressions tables */
109 for (compression_mode = 0; compression_mode < 16; compression_mode++) {
110 p0 = p0004[compression_mode];
111 p8 = p8004[compression_mode];
112 r = romtable[compression_mode];
113
114 for (j = 0; j < 8; j++, r++, p0 += 128) {
115
116 for (k = 0; k < 16; k++) {
117 if (k == 0)
118 bit = 1;
119 else if (k >= 1 && k < 3)
120 bit = (r[0] >> 15) & 7;
121 else if (k >= 3 && k < 6)
122 bit = (r[0] >> 12) & 7;
123 else if (k >= 6 && k < 10)
124 bit = (r[0] >> 9) & 7;
125 else if (k >= 10 && k < 13)
126 bit = (r[0] >> 6) & 7;
127 else if (k >= 13 && k < 15)
128 bit = (r[0] >> 3) & 7;
129 else
130 bit = (r[0]) & 7;
131 if (k == 0)
132 *p8++ = 8;
133 else
134 *p8++ = j - bit;
135 *p8++ = bit;
136
137 pw = 1 << bit;
138 p0[k + 0x00] = (1 * pw) + 0x80;
139 p0[k + 0x10] = (2 * pw) + 0x80;
140 p0[k + 0x20] = (3 * pw) + 0x80;
141 p0[k + 0x30] = (4 * pw) + 0x80;
142 p0[k + 0x40] = (-1 * pw) + 0x80;
143 p0[k + 0x50] = (-2 * pw) + 0x80;
144 p0[k + 0x60] = (-3 * pw) + 0x80;
145 p0[k + 0x70] = (-4 * pw) + 0x80;
146 } /* end of for (k=0; k<16; k++, p8++) */
147 } /* end of for (j=0; j<8; j++ , table++) */
148 } /* end of foreach compression_mode */
149}
150
151/*
152 *
153 */
154static void fill_table_dc00_d800(struct pwc_dec23_private *pdec)
155{
156#define SCALEBITS 15
157#define ONE_HALF (1UL << (SCALEBITS - 1))
158 int i;
159 unsigned int offset1 = ONE_HALF;
160 unsigned int offset2 = 0x0000;
161
162 for (i=0; i<256; i++) {
163 pdec->table_dc00[i] = offset1 & ~(ONE_HALF);
164 pdec->table_d800[i] = offset2;
165
166 offset1 += 0x7bc4;
167 offset2 += 0x7bc4;
168 }
169}
170
171/*
172 * To decode the stream:
173 * if look_bits(2) == 0: # op == 2 in the lookup table
174 * skip_bits(2)
175 * end of the stream
176 * elif look_bits(3) == 7: # op == 1 in the lookup table
177 * skip_bits(3)
178 * yyyy = get_bits(4)
179 * xxxx = get_bits(8)
180 * else: # op == 0 in the lookup table
181 * skip_bits(x)
182 *
183 * For speedup processing, we build a lookup table and we takes the first 6 bits.
184 *
185 * struct {
186 * unsigned char op; // operation to execute
187 * unsigned char bits; // bits use to perform operation
188 * unsigned char offset1; // offset to add to access in the table_0004 % 16
189 * unsigned char offset2; // offset to add to access in the table_0004
190 * }
191 *
192 * How to build this table ?
193 * op == 2 when (i%4)==0
194 * op == 1 when (i%8)==7
195 * op == 0 otherwise
196 *
197 */
198static const unsigned char hash_table_ops[64*4] = {
199 0x02, 0x00, 0x00, 0x00,
200 0x00, 0x03, 0x01, 0x00,
201 0x00, 0x04, 0x01, 0x10,
202 0x00, 0x06, 0x01, 0x30,
203 0x02, 0x00, 0x00, 0x00,
204 0x00, 0x03, 0x01, 0x40,
205 0x00, 0x05, 0x01, 0x20,
206 0x01, 0x00, 0x00, 0x00,
207 0x02, 0x00, 0x00, 0x00,
208 0x00, 0x03, 0x01, 0x00,
209 0x00, 0x04, 0x01, 0x50,
210 0x00, 0x05, 0x02, 0x00,
211 0x02, 0x00, 0x00, 0x00,
212 0x00, 0x03, 0x01, 0x40,
213 0x00, 0x05, 0x03, 0x00,
214 0x01, 0x00, 0x00, 0x00,
215 0x02, 0x00, 0x00, 0x00,
216 0x00, 0x03, 0x01, 0x00,
217 0x00, 0x04, 0x01, 0x10,
218 0x00, 0x06, 0x02, 0x10,
219 0x02, 0x00, 0x00, 0x00,
220 0x00, 0x03, 0x01, 0x40,
221 0x00, 0x05, 0x01, 0x60,
222 0x01, 0x00, 0x00, 0x00,
223 0x02, 0x00, 0x00, 0x00,
224 0x00, 0x03, 0x01, 0x00,
225 0x00, 0x04, 0x01, 0x50,
226 0x00, 0x05, 0x02, 0x40,
227 0x02, 0x00, 0x00, 0x00,
228 0x00, 0x03, 0x01, 0x40,
229 0x00, 0x05, 0x03, 0x40,
230 0x01, 0x00, 0x00, 0x00,
231 0x02, 0x00, 0x00, 0x00,
232 0x00, 0x03, 0x01, 0x00,
233 0x00, 0x04, 0x01, 0x10,
234 0x00, 0x06, 0x01, 0x70,
235 0x02, 0x00, 0x00, 0x00,
236 0x00, 0x03, 0x01, 0x40,
237 0x00, 0x05, 0x01, 0x20,
238 0x01, 0x00, 0x00, 0x00,
239 0x02, 0x00, 0x00, 0x00,
240 0x00, 0x03, 0x01, 0x00,
241 0x00, 0x04, 0x01, 0x50,
242 0x00, 0x05, 0x02, 0x00,
243 0x02, 0x00, 0x00, 0x00,
244 0x00, 0x03, 0x01, 0x40,
245 0x00, 0x05, 0x03, 0x00,
246 0x01, 0x00, 0x00, 0x00,
247 0x02, 0x00, 0x00, 0x00,
248 0x00, 0x03, 0x01, 0x00,
249 0x00, 0x04, 0x01, 0x10,
250 0x00, 0x06, 0x02, 0x50,
251 0x02, 0x00, 0x00, 0x00,
252 0x00, 0x03, 0x01, 0x40,
253 0x00, 0x05, 0x01, 0x60,
254 0x01, 0x00, 0x00, 0x00,
255 0x02, 0x00, 0x00, 0x00,
256 0x00, 0x03, 0x01, 0x00,
257 0x00, 0x04, 0x01, 0x50,
258 0x00, 0x05, 0x02, 0x40,
259 0x02, 0x00, 0x00, 0x00,
260 0x00, 0x03, 0x01, 0x40,
261 0x00, 0x05, 0x03, 0x40,
262 0x01, 0x00, 0x00, 0x00
263};
264
265/*
266 *
267 */
268static const unsigned int MulIdx[16][16] = {
269 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
270 {0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,},
271 {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,},
272 {4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4,},
273 {6, 7, 8, 9, 7, 10, 11, 8, 8, 11, 10, 7, 9, 8, 7, 6,},
274 {4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5, 4, 4, 5, 5, 4,},
275 {1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2,},
276 {0, 3, 3, 0, 1, 2, 2, 1, 2, 1, 1, 2, 3, 0, 0, 3,},
277 {0, 1, 2, 3, 3, 2, 1, 0, 3, 2, 1, 0, 0, 1, 2, 3,},
278 {1, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 0, 2, 2, 2, 2,},
279 {7, 10, 11, 8, 9, 8, 7, 6, 6, 7, 8, 9, 8, 11, 10, 7,},
280 {4, 5, 5, 4, 5, 4, 4, 5, 5, 4, 4, 5, 4, 5, 5, 4,},
281 {7, 9, 6, 8, 10, 8, 7, 11, 11, 7, 8, 10, 8, 6, 9, 7,},
282 {1, 3, 0, 2, 2, 0, 3, 1, 2, 0, 3, 1, 1, 3, 0, 2,},
283 {1, 2, 2, 1, 3, 0, 0, 3, 0, 3, 3, 0, 2, 1, 1, 2,},
284 {10, 8, 7, 11, 8, 6, 9, 7, 7, 9, 6, 8, 11, 7, 8, 10}
285};
286
287#if USE_LOOKUP_TABLE_TO_CLAMP
288#define MAX_OUTER_CROP_VALUE (512)
289static unsigned char pwc_crop_table[256 + 2*MAX_OUTER_CROP_VALUE];
290#define CLAMP(x) (pwc_crop_table[MAX_OUTER_CROP_VALUE+(x)])
291#else
292#define CLAMP(x) ((x)>255?255:((x)<0?0:x))
293#endif
294
295
296/* If the type or the command change, we rebuild the lookup table */
297void pwc_dec23_init(struct pwc_device *pdev, const unsigned char *cmd)
298{
299 int flags, version, shift, i;
300 struct pwc_dec23_private *pdec = &pdev->dec23;
301
302 mutex_init(&pdec->lock);
303
304 if (pdec->last_cmd_valid && pdec->last_cmd == cmd[2])
305 return;
306
307 if (DEVICE_USE_CODEC3(pdev->type)) {
308 flags = cmd[2] & 0x18;
309 if (flags == 8)
310 pdec->nbits = 7; /* More bits, mean more bits to encode the stream, but better quality */
311 else if (flags == 0x10)
312 pdec->nbits = 8;
313 else
314 pdec->nbits = 6;
315
316 version = cmd[2] >> 5;
317 build_table_color(KiaraRomTable[version][0], pdec->table_0004_pass1, pdec->table_8004_pass1);
318 build_table_color(KiaraRomTable[version][1], pdec->table_0004_pass2, pdec->table_8004_pass2);
319
320 } else {
321
322 flags = cmd[2] & 6;
323 if (flags == 2)
324 pdec->nbits = 7;
325 else if (flags == 4)
326 pdec->nbits = 8;
327 else
328 pdec->nbits = 6;
329
330 version = cmd[2] >> 3;
331 build_table_color(TimonRomTable[version][0], pdec->table_0004_pass1, pdec->table_8004_pass1);
332 build_table_color(TimonRomTable[version][1], pdec->table_0004_pass2, pdec->table_8004_pass2);
333 }
334
335 /* Informations can be coded on a variable number of bits but never less than 8 */
336 shift = 8 - pdec->nbits;
337 pdec->scalebits = SCALEBITS - shift;
338 pdec->nbitsmask = 0xFF >> shift;
339
340 fill_table_dc00_d800(pdec);
341 build_subblock_pattern(pdec);
342 build_bit_powermask_table(pdec);
343
344#if USE_LOOKUP_TABLE_TO_CLAMP
345 /* Build the static table to clamp value [0-255] */
346 for (i=0;i<MAX_OUTER_CROP_VALUE;i++)
347 pwc_crop_table[i] = 0;
348 for (i=0; i<256; i++)
349 pwc_crop_table[MAX_OUTER_CROP_VALUE+i] = i;
350 for (i=0; i<MAX_OUTER_CROP_VALUE; i++)
351 pwc_crop_table[MAX_OUTER_CROP_VALUE+256+i] = 255;
352#endif
353
354 pdec->last_cmd = cmd[2];
355 pdec->last_cmd_valid = 1;
356}
357
358/*
359 * Copy the 4x4 image block to Y plane buffer
360 */
361static void copy_image_block_Y(const int *src, unsigned char *dst, unsigned int bytes_per_line, unsigned int scalebits)
362{
363#if UNROLL_LOOP_FOR_COPY
364 const unsigned char *cm = pwc_crop_table+MAX_OUTER_CROP_VALUE;
365 const int *c = src;
366 unsigned char *d = dst;
367
368 *d++ = cm[c[0] >> scalebits];
369 *d++ = cm[c[1] >> scalebits];
370 *d++ = cm[c[2] >> scalebits];
371 *d++ = cm[c[3] >> scalebits];
372
373 d = dst + bytes_per_line;
374 *d++ = cm[c[4] >> scalebits];
375 *d++ = cm[c[5] >> scalebits];
376 *d++ = cm[c[6] >> scalebits];
377 *d++ = cm[c[7] >> scalebits];
378
379 d = dst + bytes_per_line*2;
380 *d++ = cm[c[8] >> scalebits];
381 *d++ = cm[c[9] >> scalebits];
382 *d++ = cm[c[10] >> scalebits];
383 *d++ = cm[c[11] >> scalebits];
384
385 d = dst + bytes_per_line*3;
386 *d++ = cm[c[12] >> scalebits];
387 *d++ = cm[c[13] >> scalebits];
388 *d++ = cm[c[14] >> scalebits];
389 *d++ = cm[c[15] >> scalebits];
390#else
391 int i;
392 const int *c = src;
393 unsigned char *d = dst;
394 for (i = 0; i < 4; i++, c++)
395 *d++ = CLAMP((*c) >> scalebits);
396
397 d = dst + bytes_per_line;
398 for (i = 0; i < 4; i++, c++)
399 *d++ = CLAMP((*c) >> scalebits);
400
401 d = dst + bytes_per_line*2;
402 for (i = 0; i < 4; i++, c++)
403 *d++ = CLAMP((*c) >> scalebits);
404
405 d = dst + bytes_per_line*3;
406 for (i = 0; i < 4; i++, c++)
407 *d++ = CLAMP((*c) >> scalebits);
408#endif
409}
410
411/*
412 * Copy the 4x4 image block to a CrCb plane buffer
413 *
414 */
415static void copy_image_block_CrCb(const int *src, unsigned char *dst, unsigned int bytes_per_line, unsigned int scalebits)
416{
417#if UNROLL_LOOP_FOR_COPY
418 /* Unroll all loops */
419 const unsigned char *cm = pwc_crop_table+MAX_OUTER_CROP_VALUE;
420 const int *c = src;
421 unsigned char *d = dst;
422
423 *d++ = cm[c[0] >> scalebits];
424 *d++ = cm[c[4] >> scalebits];
425 *d++ = cm[c[1] >> scalebits];
426 *d++ = cm[c[5] >> scalebits];
427 *d++ = cm[c[2] >> scalebits];
428 *d++ = cm[c[6] >> scalebits];
429 *d++ = cm[c[3] >> scalebits];
430 *d++ = cm[c[7] >> scalebits];
431
432 d = dst + bytes_per_line;
433 *d++ = cm[c[12] >> scalebits];
434 *d++ = cm[c[8] >> scalebits];
435 *d++ = cm[c[13] >> scalebits];
436 *d++ = cm[c[9] >> scalebits];
437 *d++ = cm[c[14] >> scalebits];
438 *d++ = cm[c[10] >> scalebits];
439 *d++ = cm[c[15] >> scalebits];
440 *d++ = cm[c[11] >> scalebits];
441#else
442 int i;
443 const int *c1 = src;
444 const int *c2 = src + 4;
445 unsigned char *d = dst;
446
447 for (i = 0; i < 4; i++, c1++, c2++) {
448 *d++ = CLAMP((*c1) >> scalebits);
449 *d++ = CLAMP((*c2) >> scalebits);
450 }
451 c1 = src + 12;
452 d = dst + bytes_per_line;
453 for (i = 0; i < 4; i++, c1++, c2++) {
454 *d++ = CLAMP((*c1) >> scalebits);
455 *d++ = CLAMP((*c2) >> scalebits);
456 }
457#endif
458}
459
460/*
461 * To manage the stream, we keep bits in a 32 bits register.
462 * fill_nbits(n): fill the reservoir with at least n bits
463 * skip_bits(n): discard n bits from the reservoir
464 * get_bits(n): fill the reservoir, returns the first n bits and discard the
465 * bits from the reservoir.
466 * __get_nbits(n): faster version of get_bits(n), but asumes that the reservoir
467 * contains at least n bits. bits returned is discarded.
468 */
469#define fill_nbits(pdec, nbits_wanted) do { \
470 while (pdec->nbits_in_reservoir<(nbits_wanted)) \
471 { \
472 pdec->reservoir |= (*(pdec->stream)++) << (pdec->nbits_in_reservoir); \
473 pdec->nbits_in_reservoir += 8; \
474 } \
475} while(0);
476
477#define skip_nbits(pdec, nbits_to_skip) do { \
478 pdec->reservoir >>= (nbits_to_skip); \
479 pdec->nbits_in_reservoir -= (nbits_to_skip); \
480} while(0);
481
482#define get_nbits(pdec, nbits_wanted, result) do { \
483 fill_nbits(pdec, nbits_wanted); \
484 result = (pdec->reservoir) & ((1U<<(nbits_wanted))-1); \
485 skip_nbits(pdec, nbits_wanted); \
486} while(0);
487
488#define __get_nbits(pdec, nbits_wanted, result) do { \
489 result = (pdec->reservoir) & ((1U<<(nbits_wanted))-1); \
490 skip_nbits(pdec, nbits_wanted); \
491} while(0);
492
493#define look_nbits(pdec, nbits_wanted) \
494 ((pdec->reservoir) & ((1U<<(nbits_wanted))-1))
495
496/*
497 * Decode a 4x4 pixel block
498 */
499static void decode_block(struct pwc_dec23_private *pdec,
500 const unsigned char *ptable0004,
501 const unsigned char *ptable8004)
502{
503 unsigned int primary_color;
504 unsigned int channel_v, offset1, op;
505 int i;
506
507 fill_nbits(pdec, 16);
508 __get_nbits(pdec, pdec->nbits, primary_color);
509
510 if (look_nbits(pdec,2) == 0) {
511 skip_nbits(pdec, 2);
512 /* Very simple, the color is the same for all pixels of the square */
513 for (i = 0; i < 16; i++)
514 pdec->temp_colors[i] = pdec->table_dc00[primary_color];
515
516 return;
517 }
518
519 /* This block is encoded with small pattern */
520 for (i = 0; i < 16; i++)
521 pdec->temp_colors[i] = pdec->table_d800[primary_color];
522
523 __get_nbits(pdec, 3, channel_v);
524 channel_v = ((channel_v & 1) << 2) | (channel_v & 2) | ((channel_v & 4) >> 2);
525
526 ptable0004 += (channel_v * 128);
527 ptable8004 += (channel_v * 32);
528
529 offset1 = 0;
530 do
531 {
532 unsigned int htable_idx, rows = 0;
533 const unsigned int *block;
534
535 /* [ zzzz y x x ]
536 * xx == 00 :=> end of the block def, remove the two bits from the stream
537 * yxx == 111
538 * yxx == any other value
539 *
540 */
541 fill_nbits(pdec, 16);
542 htable_idx = look_nbits(pdec, 6);
543 op = hash_table_ops[htable_idx * 4];
544
545 if (op == 2) {
546 skip_nbits(pdec, 2);
547
548 } else if (op == 1) {
549 /* 15bits [ xxxx xxxx yyyy 111 ]
550 * yyy => offset in the table8004
551 * xxx => offset in the tabled004 (tree)
552 */
553 unsigned int mask, shift;
554 unsigned int nbits, col1;
555 unsigned int yyyy;
556
557 skip_nbits(pdec, 3);
558 /* offset1 += yyyy */
559 __get_nbits(pdec, 4, yyyy);
560 offset1 += 1 + yyyy;
561 offset1 &= 0x0F;
562 nbits = ptable8004[offset1 * 2];
563
564 /* col1 = xxxx xxxx */
565 __get_nbits(pdec, nbits+1, col1);
566
567 /* Bit mask table */
568 mask = pdec->table_bitpowermask[nbits][col1];
569 shift = ptable8004[offset1 * 2 + 1];
570 rows = ((mask << shift) + 0x80) & 0xFF;
571
572 block = pdec->table_subblock[rows];
573 for (i = 0; i < 16; i++)
574 pdec->temp_colors[i] += block[MulIdx[offset1][i]];
575
576 } else {
577 /* op == 0
578 * offset1 is coded on 3 bits
579 */
580 unsigned int shift;
581
582 offset1 += hash_table_ops [htable_idx * 4 + 2];
583 offset1 &= 0x0F;
584
585 rows = ptable0004[offset1 + hash_table_ops [htable_idx * 4 + 3]];
586 block = pdec->table_subblock[rows];
587 for (i = 0; i < 16; i++)
588 pdec->temp_colors[i] += block[MulIdx[offset1][i]];
589
590 shift = hash_table_ops[htable_idx * 4 + 1];
591 skip_nbits(pdec, shift);
592 }
593
594 } while (op != 2);
595
596}
597
598static void DecompressBand23(struct pwc_dec23_private *pdec,
599 const unsigned char *rawyuv,
600 unsigned char *planar_y,
601 unsigned char *planar_u,
602 unsigned char *planar_v,
603 unsigned int compressed_image_width,
604 unsigned int real_image_width)
605{
606 int compression_index, nblocks;
607 const unsigned char *ptable0004;
608 const unsigned char *ptable8004;
609
610 pdec->reservoir = 0;
611 pdec->nbits_in_reservoir = 0;
612 pdec->stream = rawyuv + 1; /* The first byte of the stream is skipped */
613
614 get_nbits(pdec, 4, compression_index);
615
616 /* pass 1: uncompress Y component */
617 nblocks = compressed_image_width / 4;
618
619 ptable0004 = pdec->table_0004_pass1[compression_index];
620 ptable8004 = pdec->table_8004_pass1[compression_index];
621
622 /* Each block decode a square of 4x4 */
623 while (nblocks) {
624 decode_block(pdec, ptable0004, ptable8004);
625 copy_image_block_Y(pdec->temp_colors, planar_y, real_image_width, pdec->scalebits);
626 planar_y += 4;
627 nblocks--;
628 }
629
630 /* pass 2: uncompress UV component */
631 nblocks = compressed_image_width / 8;
632
633 ptable0004 = pdec->table_0004_pass2[compression_index];
634 ptable8004 = pdec->table_8004_pass2[compression_index];
635
636 /* Each block decode a square of 4x4 */
637 while (nblocks) {
638 decode_block(pdec, ptable0004, ptable8004);
639 copy_image_block_CrCb(pdec->temp_colors, planar_u, real_image_width/2, pdec->scalebits);
640
641 decode_block(pdec, ptable0004, ptable8004);
642 copy_image_block_CrCb(pdec->temp_colors, planar_v, real_image_width/2, pdec->scalebits);
643
644 planar_v += 8;
645 planar_u += 8;
646 nblocks -= 2;
647 }
648
649}
650
651/**
652 *
653 * Uncompress a pwc23 buffer.
654 *
655 * src: raw data
656 * dst: image output
657 */
658void pwc_dec23_decompress(struct pwc_device *pdev,
659 const void *src,
660 void *dst)
661{
662 int bandlines_left, bytes_per_block;
663 struct pwc_dec23_private *pdec = &pdev->dec23;
664
665 /* YUV420P image format */
666 unsigned char *pout_planar_y;
667 unsigned char *pout_planar_u;
668 unsigned char *pout_planar_v;
669 unsigned int plane_size;
670
671 mutex_lock(&pdec->lock);
672
673 bandlines_left = pdev->height / 4;
674 bytes_per_block = pdev->width * 4;
675 plane_size = pdev->height * pdev->width;
676
677 pout_planar_y = dst;
678 pout_planar_u = dst + plane_size;
679 pout_planar_v = dst + plane_size + plane_size / 4;
680
681 while (bandlines_left--) {
682 DecompressBand23(pdec, src,
683 pout_planar_y, pout_planar_u, pout_planar_v,
684 pdev->width, pdev->width);
685 src += pdev->vbandlength;
686 pout_planar_y += bytes_per_block;
687 pout_planar_u += pdev->width;
688 pout_planar_v += pdev->width;
689 }
690 mutex_unlock(&pdec->lock);
691}
diff --git a/drivers/media/usb/pwc/pwc-dec23.h b/drivers/media/usb/pwc/pwc-dec23.h
new file mode 100644
index 000000000000..c655b1c1e6a9
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-dec23.h
@@ -0,0 +1,61 @@
1/* Linux driver for Philips webcam
2 (C) 2004-2006 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25#ifndef PWC_DEC23_H
26#define PWC_DEC23_H
27
28struct pwc_device;
29
30struct pwc_dec23_private
31{
32 struct mutex lock;
33
34 unsigned char last_cmd, last_cmd_valid;
35
36 unsigned int scalebits;
37 unsigned int nbitsmask, nbits; /* Number of bits of a color in the compressed stream */
38
39 unsigned int reservoir;
40 unsigned int nbits_in_reservoir;
41
42 const unsigned char *stream;
43 int temp_colors[16];
44
45 unsigned char table_0004_pass1[16][1024];
46 unsigned char table_0004_pass2[16][1024];
47 unsigned char table_8004_pass1[16][256];
48 unsigned char table_8004_pass2[16][256];
49 unsigned int table_subblock[256][12];
50
51 unsigned char table_bitpowermask[8][256];
52 unsigned int table_d800[256];
53 unsigned int table_dc00[256];
54
55};
56
57void pwc_dec23_init(struct pwc_device *pdev, const unsigned char *cmd);
58void pwc_dec23_decompress(struct pwc_device *pdev,
59 const void *src,
60 void *dst);
61#endif
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
new file mode 100644
index 000000000000..de7c7ba99ef4
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -0,0 +1,1165 @@
1/* Linux driver for Philips webcam
2 USB and Video4Linux interface part.
3 (C) 1999-2004 Nemosoft Unv.
4 (C) 2004-2006 Luc Saillard (luc@saillard.org)
5 (C) 2011 Hans de Goede <hdegoede@redhat.com>
6
7 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
8 driver and thus may have bugs that are not present in the original version.
9 Please send bug reports and support requests to <luc@saillard.org>.
10 The decompression routines have been implemented by reverse-engineering the
11 Nemosoft binary pwcx module. Caveat emptor.
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27*/
28
29/*
30 This code forms the interface between the USB layers and the Philips
31 specific stuff. Some adanved stuff of the driver falls under an
32 NDA, signed between me and Philips B.V., Eindhoven, the Netherlands, and
33 is thus not distributed in source form. The binary pwcx.o module
34 contains the code that falls under the NDA.
35
36 In case you're wondering: 'pwc' stands for "Philips WebCam", but
37 I really didn't want to type 'philips_web_cam' every time (I'm lazy as
38 any Linux kernel hacker, but I don't like uncomprehensible abbreviations
39 without explanation).
40
41 Oh yes, convention: to disctinguish between all the various pointers to
42 device-structures, I use these names for the pointer variables:
43 udev: struct usb_device *
44 vdev: struct video_device (member of pwc_dev)
45 pdev: struct pwc_devive *
46*/
47
48/* Contributors:
49 - Alvarado: adding whitebalance code
50 - Alistar Moire: QuickCam 3000 Pro device/product ID
51 - Tony Hoyle: Creative Labs Webcam 5 device/product ID
52 - Mark Burazin: solving hang in VIDIOCSYNC when camera gets unplugged
53 - Jk Fang: Sotec Afina Eye ID
54 - Xavier Roche: QuickCam Pro 4000 ID
55 - Jens Knudsen: QuickCam Zoom ID
56 - J. Debert: QuickCam for Notebooks ID
57 - Pham Thanh Nam: webcam snapshot button as an event input device
58*/
59
60#include <linux/errno.h>
61#include <linux/init.h>
62#include <linux/mm.h>
63#include <linux/module.h>
64#include <linux/poll.h>
65#include <linux/slab.h>
66#ifdef CONFIG_USB_PWC_INPUT_EVDEV
67#include <linux/usb/input.h>
68#endif
69#include <linux/vmalloc.h>
70#include <asm/io.h>
71#include <linux/kernel.h> /* simple_strtol() */
72
73#include "pwc.h"
74#include "pwc-kiara.h"
75#include "pwc-timon.h"
76#include "pwc-dec23.h"
77#include "pwc-dec1.h"
78
79/* Function prototypes and driver templates */
80
81/* hotplug device table support */
82static const struct usb_device_id pwc_device_table [] = {
83 { USB_DEVICE(0x0471, 0x0302) }, /* Philips models */
84 { USB_DEVICE(0x0471, 0x0303) },
85 { USB_DEVICE(0x0471, 0x0304) },
86 { USB_DEVICE(0x0471, 0x0307) },
87 { USB_DEVICE(0x0471, 0x0308) },
88 { USB_DEVICE(0x0471, 0x030C) },
89 { USB_DEVICE(0x0471, 0x0310) },
90 { USB_DEVICE(0x0471, 0x0311) }, /* Philips ToUcam PRO II */
91 { USB_DEVICE(0x0471, 0x0312) },
92 { USB_DEVICE(0x0471, 0x0313) }, /* the 'new' 720K */
93 { USB_DEVICE(0x0471, 0x0329) }, /* Philips SPC 900NC PC Camera */
94 { USB_DEVICE(0x069A, 0x0001) }, /* Askey */
95 { USB_DEVICE(0x046D, 0x08B0) }, /* Logitech QuickCam Pro 3000 */
96 { USB_DEVICE(0x046D, 0x08B1) }, /* Logitech QuickCam Notebook Pro */
97 { USB_DEVICE(0x046D, 0x08B2) }, /* Logitech QuickCam Pro 4000 */
98 { USB_DEVICE(0x046D, 0x08B3) }, /* Logitech QuickCam Zoom (old model) */
99 { USB_DEVICE(0x046D, 0x08B4) }, /* Logitech QuickCam Zoom (new model) */
100 { USB_DEVICE(0x046D, 0x08B5) }, /* Logitech QuickCam Orbit/Sphere */
101 { USB_DEVICE(0x046D, 0x08B6) }, /* Cisco VT Camera */
102 { USB_DEVICE(0x046D, 0x08B7) }, /* Logitech ViewPort AV 100 */
103 { USB_DEVICE(0x046D, 0x08B8) }, /* Logitech (reserved) */
104 { USB_DEVICE(0x055D, 0x9000) }, /* Samsung MPC-C10 */
105 { USB_DEVICE(0x055D, 0x9001) }, /* Samsung MPC-C30 */
106 { USB_DEVICE(0x055D, 0x9002) }, /* Samsung SNC-35E (Ver3.0) */
107 { USB_DEVICE(0x041E, 0x400C) }, /* Creative Webcam 5 */
108 { USB_DEVICE(0x041E, 0x4011) }, /* Creative Webcam Pro Ex */
109 { USB_DEVICE(0x04CC, 0x8116) }, /* Afina Eye */
110 { USB_DEVICE(0x06BE, 0x8116) }, /* new Afina Eye */
111 { USB_DEVICE(0x0d81, 0x1910) }, /* Visionite */
112 { USB_DEVICE(0x0d81, 0x1900) },
113 { }
114};
115MODULE_DEVICE_TABLE(usb, pwc_device_table);
116
117static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id *id);
118static void usb_pwc_disconnect(struct usb_interface *intf);
119static void pwc_isoc_cleanup(struct pwc_device *pdev);
120
121static struct usb_driver pwc_driver = {
122 .name = "Philips webcam", /* name */
123 .id_table = pwc_device_table,
124 .probe = usb_pwc_probe, /* probe() */
125 .disconnect = usb_pwc_disconnect, /* disconnect() */
126};
127
128#define MAX_DEV_HINTS 20
129#define MAX_ISOC_ERRORS 20
130
131#ifdef CONFIG_USB_PWC_DEBUG
132 int pwc_trace = PWC_DEBUG_LEVEL;
133#endif
134static int power_save = -1;
135static int leds[2] = { 100, 0 };
136
137/***/
138
139static const struct v4l2_file_operations pwc_fops = {
140 .owner = THIS_MODULE,
141 .open = v4l2_fh_open,
142 .release = vb2_fop_release,
143 .read = vb2_fop_read,
144 .poll = vb2_fop_poll,
145 .mmap = vb2_fop_mmap,
146 .unlocked_ioctl = video_ioctl2,
147};
148static struct video_device pwc_template = {
149 .name = "Philips Webcam", /* Filled in later */
150 .release = video_device_release_empty,
151 .fops = &pwc_fops,
152 .ioctl_ops = &pwc_ioctl_ops,
153};
154
155/***************************************************************************/
156/* Private functions */
157
158struct pwc_frame_buf *pwc_get_next_fill_buf(struct pwc_device *pdev)
159{
160 unsigned long flags = 0;
161 struct pwc_frame_buf *buf = NULL;
162
163 spin_lock_irqsave(&pdev->queued_bufs_lock, flags);
164 if (list_empty(&pdev->queued_bufs))
165 goto leave;
166
167 buf = list_entry(pdev->queued_bufs.next, struct pwc_frame_buf, list);
168 list_del(&buf->list);
169leave:
170 spin_unlock_irqrestore(&pdev->queued_bufs_lock, flags);
171 return buf;
172}
173
174static void pwc_snapshot_button(struct pwc_device *pdev, int down)
175{
176 if (down) {
177 PWC_TRACE("Snapshot button pressed.\n");
178 } else {
179 PWC_TRACE("Snapshot button released.\n");
180 }
181
182#ifdef CONFIG_USB_PWC_INPUT_EVDEV
183 if (pdev->button_dev) {
184 input_report_key(pdev->button_dev, KEY_CAMERA, down);
185 input_sync(pdev->button_dev);
186 }
187#endif
188}
189
190static void pwc_frame_complete(struct pwc_device *pdev)
191{
192 struct pwc_frame_buf *fbuf = pdev->fill_buf;
193
194 /* The ToUCam Fun CMOS sensor causes the firmware to send 2 or 3 bogus
195 frames on the USB wire after an exposure change. This conditition is
196 however detected in the cam and a bit is set in the header.
197 */
198 if (pdev->type == 730) {
199 unsigned char *ptr = (unsigned char *)fbuf->data;
200
201 if (ptr[1] == 1 && ptr[0] & 0x10) {
202 PWC_TRACE("Hyundai CMOS sensor bug. Dropping frame.\n");
203 pdev->drop_frames += 2;
204 }
205 if ((ptr[0] ^ pdev->vmirror) & 0x01) {
206 pwc_snapshot_button(pdev, ptr[0] & 0x01);
207 }
208 if ((ptr[0] ^ pdev->vmirror) & 0x02) {
209 if (ptr[0] & 0x02)
210 PWC_TRACE("Image is mirrored.\n");
211 else
212 PWC_TRACE("Image is normal.\n");
213 }
214 pdev->vmirror = ptr[0] & 0x03;
215 /* Sometimes the trailer of the 730 is still sent as a 4 byte packet
216 after a short frame; this condition is filtered out specifically. A 4 byte
217 frame doesn't make sense anyway.
218 So we get either this sequence:
219 drop_bit set -> 4 byte frame -> short frame -> good frame
220 Or this one:
221 drop_bit set -> short frame -> good frame
222 So we drop either 3 or 2 frames in all!
223 */
224 if (fbuf->filled == 4)
225 pdev->drop_frames++;
226 } else if (pdev->type == 740 || pdev->type == 720) {
227 unsigned char *ptr = (unsigned char *)fbuf->data;
228 if ((ptr[0] ^ pdev->vmirror) & 0x01) {
229 pwc_snapshot_button(pdev, ptr[0] & 0x01);
230 }
231 pdev->vmirror = ptr[0] & 0x03;
232 }
233
234 /* In case we were instructed to drop the frame, do so silently. */
235 if (pdev->drop_frames > 0) {
236 pdev->drop_frames--;
237 } else {
238 /* Check for underflow first */
239 if (fbuf->filled < pdev->frame_total_size) {
240 PWC_DEBUG_FLOW("Frame buffer underflow (%d bytes);"
241 " discarded.\n", fbuf->filled);
242 } else {
243 fbuf->vb.v4l2_buf.field = V4L2_FIELD_NONE;
244 fbuf->vb.v4l2_buf.sequence = pdev->vframe_count;
245 vb2_buffer_done(&fbuf->vb, VB2_BUF_STATE_DONE);
246 pdev->fill_buf = NULL;
247 pdev->vsync = 0;
248 }
249 } /* !drop_frames */
250 pdev->vframe_count++;
251}
252
253/* This gets called for the Isochronous pipe (video). This is done in
254 * interrupt time, so it has to be fast, not crash, and not stall. Neat.
255 */
256static void pwc_isoc_handler(struct urb *urb)
257{
258 struct pwc_device *pdev = (struct pwc_device *)urb->context;
259 int i, fst, flen;
260 unsigned char *iso_buf = NULL;
261
262 if (urb->status == -ENOENT || urb->status == -ECONNRESET ||
263 urb->status == -ESHUTDOWN) {
264 PWC_DEBUG_OPEN("URB (%p) unlinked %ssynchronuously.\n", urb, urb->status == -ENOENT ? "" : "a");
265 return;
266 }
267
268 if (pdev->fill_buf == NULL)
269 pdev->fill_buf = pwc_get_next_fill_buf(pdev);
270
271 if (urb->status != 0) {
272 const char *errmsg;
273
274 errmsg = "Unknown";
275 switch(urb->status) {
276 case -ENOSR: errmsg = "Buffer error (overrun)"; break;
277 case -EPIPE: errmsg = "Stalled (device not responding)"; break;
278 case -EOVERFLOW: errmsg = "Babble (bad cable?)"; break;
279 case -EPROTO: errmsg = "Bit-stuff error (bad cable?)"; break;
280 case -EILSEQ: errmsg = "CRC/Timeout (could be anything)"; break;
281 case -ETIME: errmsg = "Device does not respond"; break;
282 }
283 PWC_ERROR("pwc_isoc_handler() called with status %d [%s].\n",
284 urb->status, errmsg);
285 /* Give up after a number of contiguous errors */
286 if (++pdev->visoc_errors > MAX_ISOC_ERRORS)
287 {
288 PWC_ERROR("Too many ISOC errors, bailing out.\n");
289 if (pdev->fill_buf) {
290 vb2_buffer_done(&pdev->fill_buf->vb,
291 VB2_BUF_STATE_ERROR);
292 pdev->fill_buf = NULL;
293 }
294 }
295 pdev->vsync = 0; /* Drop the current frame */
296 goto handler_end;
297 }
298
299 /* Reset ISOC error counter. We did get here, after all. */
300 pdev->visoc_errors = 0;
301
302 /* vsync: 0 = don't copy data
303 1 = sync-hunt
304 2 = synched
305 */
306 /* Compact data */
307 for (i = 0; i < urb->number_of_packets; i++) {
308 fst = urb->iso_frame_desc[i].status;
309 flen = urb->iso_frame_desc[i].actual_length;
310 iso_buf = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
311 if (fst != 0) {
312 PWC_ERROR("Iso frame %d has error %d\n", i, fst);
313 continue;
314 }
315 if (flen > 0 && pdev->vsync) {
316 struct pwc_frame_buf *fbuf = pdev->fill_buf;
317
318 if (pdev->vsync == 1) {
319 do_gettimeofday(&fbuf->vb.v4l2_buf.timestamp);
320 pdev->vsync = 2;
321 }
322
323 if (flen + fbuf->filled > pdev->frame_total_size) {
324 PWC_ERROR("Frame overflow (%d > %d)\n",
325 flen + fbuf->filled,
326 pdev->frame_total_size);
327 pdev->vsync = 0; /* Let's wait for an EOF */
328 } else {
329 memcpy(fbuf->data + fbuf->filled, iso_buf,
330 flen);
331 fbuf->filled += flen;
332 }
333 }
334 if (flen < pdev->vlast_packet_size) {
335 /* Shorter packet... end of frame */
336 if (pdev->vsync == 2)
337 pwc_frame_complete(pdev);
338 if (pdev->fill_buf == NULL)
339 pdev->fill_buf = pwc_get_next_fill_buf(pdev);
340 if (pdev->fill_buf) {
341 pdev->fill_buf->filled = 0;
342 pdev->vsync = 1;
343 }
344 }
345 pdev->vlast_packet_size = flen;
346 }
347
348handler_end:
349 i = usb_submit_urb(urb, GFP_ATOMIC);
350 if (i != 0)
351 PWC_ERROR("Error (%d) re-submitting urb in pwc_isoc_handler.\n", i);
352}
353
354/* Both v4l2_lock and vb_queue_lock should be locked when calling this */
355static int pwc_isoc_init(struct pwc_device *pdev)
356{
357 struct usb_device *udev;
358 struct urb *urb;
359 int i, j, ret;
360 struct usb_interface *intf;
361 struct usb_host_interface *idesc = NULL;
362 int compression = 0; /* 0..3 = uncompressed..high */
363
364 pdev->vsync = 0;
365 pdev->vlast_packet_size = 0;
366 pdev->fill_buf = NULL;
367 pdev->vframe_count = 0;
368 pdev->visoc_errors = 0;
369 udev = pdev->udev;
370
371retry:
372 /* We first try with low compression and then retry with a higher
373 compression setting if there is not enough bandwidth. */
374 ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt,
375 pdev->vframes, &compression, 1);
376
377 /* Get the current alternate interface, adjust packet size */
378 intf = usb_ifnum_to_if(udev, 0);
379 if (intf)
380 idesc = usb_altnum_to_altsetting(intf, pdev->valternate);
381 if (!idesc)
382 return -EIO;
383
384 /* Search video endpoint */
385 pdev->vmax_packet_size = -1;
386 for (i = 0; i < idesc->desc.bNumEndpoints; i++) {
387 if ((idesc->endpoint[i].desc.bEndpointAddress & 0xF) == pdev->vendpoint) {
388 pdev->vmax_packet_size = le16_to_cpu(idesc->endpoint[i].desc.wMaxPacketSize);
389 break;
390 }
391 }
392
393 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) {
394 PWC_ERROR("Failed to find packet size for video endpoint in current alternate setting.\n");
395 return -ENFILE; /* Odd error, that should be noticeable */
396 }
397
398 /* Set alternate interface */
399 PWC_DEBUG_OPEN("Setting alternate interface %d\n", pdev->valternate);
400 ret = usb_set_interface(pdev->udev, 0, pdev->valternate);
401 if (ret == -ENOSPC && compression < 3) {
402 compression++;
403 goto retry;
404 }
405 if (ret < 0)
406 return ret;
407
408 /* Allocate and init Isochronuous urbs */
409 for (i = 0; i < MAX_ISO_BUFS; i++) {
410 urb = usb_alloc_urb(ISO_FRAMES_PER_DESC, GFP_KERNEL);
411 if (urb == NULL) {
412 PWC_ERROR("Failed to allocate urb %d\n", i);
413 pwc_isoc_cleanup(pdev);
414 return -ENOMEM;
415 }
416 pdev->urbs[i] = urb;
417 PWC_DEBUG_MEMORY("Allocated URB at 0x%p\n", urb);
418
419 urb->interval = 1; // devik
420 urb->dev = udev;
421 urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint);
422 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
423 urb->transfer_buffer = usb_alloc_coherent(udev,
424 ISO_BUFFER_SIZE,
425 GFP_KERNEL,
426 &urb->transfer_dma);
427 if (urb->transfer_buffer == NULL) {
428 PWC_ERROR("Failed to allocate urb buffer %d\n", i);
429 pwc_isoc_cleanup(pdev);
430 return -ENOMEM;
431 }
432 urb->transfer_buffer_length = ISO_BUFFER_SIZE;
433 urb->complete = pwc_isoc_handler;
434 urb->context = pdev;
435 urb->start_frame = 0;
436 urb->number_of_packets = ISO_FRAMES_PER_DESC;
437 for (j = 0; j < ISO_FRAMES_PER_DESC; j++) {
438 urb->iso_frame_desc[j].offset = j * ISO_MAX_FRAME_SIZE;
439 urb->iso_frame_desc[j].length = pdev->vmax_packet_size;
440 }
441 }
442
443 /* link */
444 for (i = 0; i < MAX_ISO_BUFS; i++) {
445 ret = usb_submit_urb(pdev->urbs[i], GFP_KERNEL);
446 if (ret == -ENOSPC && compression < 3) {
447 compression++;
448 pwc_isoc_cleanup(pdev);
449 goto retry;
450 }
451 if (ret) {
452 PWC_ERROR("isoc_init() submit_urb %d failed with error %d\n", i, ret);
453 pwc_isoc_cleanup(pdev);
454 return ret;
455 }
456 PWC_DEBUG_MEMORY("URB 0x%p submitted.\n", pdev->urbs[i]);
457 }
458
459 /* All is done... */
460 PWC_DEBUG_OPEN("<< pwc_isoc_init()\n");
461 return 0;
462}
463
464static void pwc_iso_stop(struct pwc_device *pdev)
465{
466 int i;
467
468 /* Unlinking ISOC buffers one by one */
469 for (i = 0; i < MAX_ISO_BUFS; i++) {
470 if (pdev->urbs[i]) {
471 PWC_DEBUG_MEMORY("Unlinking URB %p\n", pdev->urbs[i]);
472 usb_kill_urb(pdev->urbs[i]);
473 }
474 }
475}
476
477static void pwc_iso_free(struct pwc_device *pdev)
478{
479 int i;
480
481 /* Freeing ISOC buffers one by one */
482 for (i = 0; i < MAX_ISO_BUFS; i++) {
483 if (pdev->urbs[i]) {
484 PWC_DEBUG_MEMORY("Freeing URB\n");
485 if (pdev->urbs[i]->transfer_buffer) {
486 usb_free_coherent(pdev->udev,
487 pdev->urbs[i]->transfer_buffer_length,
488 pdev->urbs[i]->transfer_buffer,
489 pdev->urbs[i]->transfer_dma);
490 }
491 usb_free_urb(pdev->urbs[i]);
492 pdev->urbs[i] = NULL;
493 }
494 }
495}
496
497/* Both v4l2_lock and vb_queue_lock should be locked when calling this */
498static void pwc_isoc_cleanup(struct pwc_device *pdev)
499{
500 PWC_DEBUG_OPEN(">> pwc_isoc_cleanup()\n");
501
502 pwc_iso_stop(pdev);
503 pwc_iso_free(pdev);
504 usb_set_interface(pdev->udev, 0, 0);
505
506 PWC_DEBUG_OPEN("<< pwc_isoc_cleanup()\n");
507}
508
509/* Must be called with vb_queue_lock hold */
510static void pwc_cleanup_queued_bufs(struct pwc_device *pdev)
511{
512 unsigned long flags = 0;
513
514 spin_lock_irqsave(&pdev->queued_bufs_lock, flags);
515 while (!list_empty(&pdev->queued_bufs)) {
516 struct pwc_frame_buf *buf;
517
518 buf = list_entry(pdev->queued_bufs.next, struct pwc_frame_buf,
519 list);
520 list_del(&buf->list);
521 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
522 }
523 spin_unlock_irqrestore(&pdev->queued_bufs_lock, flags);
524}
525
526#ifdef CONFIG_USB_PWC_DEBUG
527static const char *pwc_sensor_type_to_string(unsigned int sensor_type)
528{
529 switch(sensor_type) {
530 case 0x00:
531 return "Hyundai CMOS sensor";
532 case 0x20:
533 return "Sony CCD sensor + TDA8787";
534 case 0x2E:
535 return "Sony CCD sensor + Exas 98L59";
536 case 0x2F:
537 return "Sony CCD sensor + ADI 9804";
538 case 0x30:
539 return "Sharp CCD sensor + TDA8787";
540 case 0x3E:
541 return "Sharp CCD sensor + Exas 98L59";
542 case 0x3F:
543 return "Sharp CCD sensor + ADI 9804";
544 case 0x40:
545 return "UPA 1021 sensor";
546 case 0x100:
547 return "VGA sensor";
548 case 0x101:
549 return "PAL MR sensor";
550 default:
551 return "unknown type of sensor";
552 }
553}
554#endif
555
556/***************************************************************************/
557/* Video4Linux functions */
558
559static void pwc_video_release(struct v4l2_device *v)
560{
561 struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev);
562
563 v4l2_ctrl_handler_free(&pdev->ctrl_handler);
564 v4l2_device_unregister(&pdev->v4l2_dev);
565 kfree(pdev->ctrl_buf);
566 kfree(pdev);
567}
568
569/***************************************************************************/
570/* Videobuf2 operations */
571
572static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
573 unsigned int *nbuffers, unsigned int *nplanes,
574 unsigned int sizes[], void *alloc_ctxs[])
575{
576 struct pwc_device *pdev = vb2_get_drv_priv(vq);
577 int size;
578
579 if (*nbuffers < MIN_FRAMES)
580 *nbuffers = MIN_FRAMES;
581 else if (*nbuffers > MAX_FRAMES)
582 *nbuffers = MAX_FRAMES;
583
584 *nplanes = 1;
585
586 size = pwc_get_size(pdev, MAX_WIDTH, MAX_HEIGHT);
587 sizes[0] = PAGE_ALIGN(pwc_image_sizes[size][0] *
588 pwc_image_sizes[size][1] * 3 / 2);
589
590 return 0;
591}
592
593static int buffer_init(struct vb2_buffer *vb)
594{
595 struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb);
596
597 /* need vmalloc since frame buffer > 128K */
598 buf->data = vzalloc(PWC_FRAME_SIZE);
599 if (buf->data == NULL)
600 return -ENOMEM;
601
602 return 0;
603}
604
605static int buffer_prepare(struct vb2_buffer *vb)
606{
607 struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue);
608
609 /* Don't allow queing new buffers after device disconnection */
610 if (!pdev->udev)
611 return -ENODEV;
612
613 return 0;
614}
615
616static int buffer_finish(struct vb2_buffer *vb)
617{
618 struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue);
619 struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb);
620
621 /*
622 * Application has called dqbuf and is getting back a buffer we've
623 * filled, take the pwc data we've stored in buf->data and decompress
624 * it into a usable format, storing the result in the vb2_buffer
625 */
626 return pwc_decompress(pdev, buf);
627}
628
629static void buffer_cleanup(struct vb2_buffer *vb)
630{
631 struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb);
632
633 vfree(buf->data);
634}
635
636static void buffer_queue(struct vb2_buffer *vb)
637{
638 struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue);
639 struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb);
640 unsigned long flags = 0;
641
642 /* Check the device has not disconnected between prep and queuing */
643 if (!pdev->udev) {
644 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
645 return;
646 }
647
648 spin_lock_irqsave(&pdev->queued_bufs_lock, flags);
649 list_add_tail(&buf->list, &pdev->queued_bufs);
650 spin_unlock_irqrestore(&pdev->queued_bufs_lock, flags);
651}
652
653static int start_streaming(struct vb2_queue *vq, unsigned int count)
654{
655 struct pwc_device *pdev = vb2_get_drv_priv(vq);
656 int r;
657
658 if (!pdev->udev)
659 return -ENODEV;
660
661 if (mutex_lock_interruptible(&pdev->v4l2_lock))
662 return -ERESTARTSYS;
663 /* Turn on camera and set LEDS on */
664 pwc_camera_power(pdev, 1);
665 pwc_set_leds(pdev, leds[0], leds[1]);
666
667 r = pwc_isoc_init(pdev);
668 if (r) {
669 /* If we failed turn camera and LEDS back off */
670 pwc_set_leds(pdev, 0, 0);
671 pwc_camera_power(pdev, 0);
672 /* And cleanup any queued bufs!! */
673 pwc_cleanup_queued_bufs(pdev);
674 }
675 mutex_unlock(&pdev->v4l2_lock);
676
677 return r;
678}
679
680static int stop_streaming(struct vb2_queue *vq)
681{
682 struct pwc_device *pdev = vb2_get_drv_priv(vq);
683
684 if (mutex_lock_interruptible(&pdev->v4l2_lock))
685 return -ERESTARTSYS;
686 if (pdev->udev) {
687 pwc_set_leds(pdev, 0, 0);
688 pwc_camera_power(pdev, 0);
689 pwc_isoc_cleanup(pdev);
690 }
691
692 pwc_cleanup_queued_bufs(pdev);
693 mutex_unlock(&pdev->v4l2_lock);
694
695 return 0;
696}
697
698static struct vb2_ops pwc_vb_queue_ops = {
699 .queue_setup = queue_setup,
700 .buf_init = buffer_init,
701 .buf_prepare = buffer_prepare,
702 .buf_finish = buffer_finish,
703 .buf_cleanup = buffer_cleanup,
704 .buf_queue = buffer_queue,
705 .start_streaming = start_streaming,
706 .stop_streaming = stop_streaming,
707 .wait_prepare = vb2_ops_wait_prepare,
708 .wait_finish = vb2_ops_wait_finish,
709};
710
711/***************************************************************************/
712/* USB functions */
713
714/* This function gets called when a new device is plugged in or the usb core
715 * is loaded.
716 */
717
718static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id *id)
719{
720 struct usb_device *udev = interface_to_usbdev(intf);
721 struct pwc_device *pdev = NULL;
722 int vendor_id, product_id, type_id;
723 int rc;
724 int features = 0;
725 int compression = 0;
726 int my_power_save = power_save;
727 char serial_number[30], *name;
728
729 vendor_id = le16_to_cpu(udev->descriptor.idVendor);
730 product_id = le16_to_cpu(udev->descriptor.idProduct);
731
732 /* Check if we can handle this device */
733 PWC_DEBUG_PROBE("probe() called [%04X %04X], if %d\n",
734 vendor_id, product_id,
735 intf->altsetting->desc.bInterfaceNumber);
736
737 /* the interfaces are probed one by one. We are only interested in the
738 video interface (0) now.
739 Interface 1 is the Audio Control, and interface 2 Audio itself.
740 */
741 if (intf->altsetting->desc.bInterfaceNumber > 0)
742 return -ENODEV;
743
744 if (vendor_id == 0x0471) {
745 switch (product_id) {
746 case 0x0302:
747 PWC_INFO("Philips PCA645VC USB webcam detected.\n");
748 name = "Philips 645 webcam";
749 type_id = 645;
750 break;
751 case 0x0303:
752 PWC_INFO("Philips PCA646VC USB webcam detected.\n");
753 name = "Philips 646 webcam";
754 type_id = 646;
755 break;
756 case 0x0304:
757 PWC_INFO("Askey VC010 type 2 USB webcam detected.\n");
758 name = "Askey VC010 webcam";
759 type_id = 646;
760 break;
761 case 0x0307:
762 PWC_INFO("Philips PCVC675K (Vesta) USB webcam detected.\n");
763 name = "Philips 675 webcam";
764 type_id = 675;
765 break;
766 case 0x0308:
767 PWC_INFO("Philips PCVC680K (Vesta Pro) USB webcam detected.\n");
768 name = "Philips 680 webcam";
769 type_id = 680;
770 break;
771 case 0x030C:
772 PWC_INFO("Philips PCVC690K (Vesta Pro Scan) USB webcam detected.\n");
773 name = "Philips 690 webcam";
774 type_id = 690;
775 break;
776 case 0x0310:
777 PWC_INFO("Philips PCVC730K (ToUCam Fun)/PCVC830 (ToUCam II) USB webcam detected.\n");
778 name = "Philips 730 webcam";
779 type_id = 730;
780 break;
781 case 0x0311:
782 PWC_INFO("Philips PCVC740K (ToUCam Pro)/PCVC840 (ToUCam II) USB webcam detected.\n");
783 name = "Philips 740 webcam";
784 type_id = 740;
785 break;
786 case 0x0312:
787 PWC_INFO("Philips PCVC750K (ToUCam Pro Scan) USB webcam detected.\n");
788 name = "Philips 750 webcam";
789 type_id = 750;
790 break;
791 case 0x0313:
792 PWC_INFO("Philips PCVC720K/40 (ToUCam XS) USB webcam detected.\n");
793 name = "Philips 720K/40 webcam";
794 type_id = 720;
795 break;
796 case 0x0329:
797 PWC_INFO("Philips SPC 900NC USB webcam detected.\n");
798 name = "Philips SPC 900NC webcam";
799 type_id = 740;
800 break;
801 default:
802 return -ENODEV;
803 break;
804 }
805 }
806 else if (vendor_id == 0x069A) {
807 switch(product_id) {
808 case 0x0001:
809 PWC_INFO("Askey VC010 type 1 USB webcam detected.\n");
810 name = "Askey VC010 webcam";
811 type_id = 645;
812 break;
813 default:
814 return -ENODEV;
815 break;
816 }
817 }
818 else if (vendor_id == 0x046d) {
819 switch(product_id) {
820 case 0x08b0:
821 PWC_INFO("Logitech QuickCam Pro 3000 USB webcam detected.\n");
822 name = "Logitech QuickCam Pro 3000";
823 type_id = 740; /* CCD sensor */
824 break;
825 case 0x08b1:
826 PWC_INFO("Logitech QuickCam Notebook Pro USB webcam detected.\n");
827 name = "Logitech QuickCam Notebook Pro";
828 type_id = 740; /* CCD sensor */
829 break;
830 case 0x08b2:
831 PWC_INFO("Logitech QuickCam 4000 Pro USB webcam detected.\n");
832 name = "Logitech QuickCam Pro 4000";
833 type_id = 740; /* CCD sensor */
834 if (my_power_save == -1)
835 my_power_save = 1;
836 break;
837 case 0x08b3:
838 PWC_INFO("Logitech QuickCam Zoom USB webcam detected.\n");
839 name = "Logitech QuickCam Zoom";
840 type_id = 740; /* CCD sensor */
841 break;
842 case 0x08B4:
843 PWC_INFO("Logitech QuickCam Zoom (new model) USB webcam detected.\n");
844 name = "Logitech QuickCam Zoom";
845 type_id = 740; /* CCD sensor */
846 if (my_power_save == -1)
847 my_power_save = 1;
848 break;
849 case 0x08b5:
850 PWC_INFO("Logitech QuickCam Orbit/Sphere USB webcam detected.\n");
851 name = "Logitech QuickCam Orbit";
852 type_id = 740; /* CCD sensor */
853 if (my_power_save == -1)
854 my_power_save = 1;
855 features |= FEATURE_MOTOR_PANTILT;
856 break;
857 case 0x08b6:
858 PWC_INFO("Logitech/Cisco VT Camera webcam detected.\n");
859 name = "Cisco VT Camera";
860 type_id = 740; /* CCD sensor */
861 break;
862 case 0x08b7:
863 PWC_INFO("Logitech ViewPort AV 100 webcam detected.\n");
864 name = "Logitech ViewPort AV 100";
865 type_id = 740; /* CCD sensor */
866 break;
867 case 0x08b8: /* Where this released? */
868 PWC_INFO("Logitech QuickCam detected (reserved ID).\n");
869 name = "Logitech QuickCam (res.)";
870 type_id = 730; /* Assuming CMOS */
871 break;
872 default:
873 return -ENODEV;
874 break;
875 }
876 }
877 else if (vendor_id == 0x055d) {
878 /* I don't know the difference between the C10 and the C30;
879 I suppose the difference is the sensor, but both cameras
880 work equally well with a type_id of 675
881 */
882 switch(product_id) {
883 case 0x9000:
884 PWC_INFO("Samsung MPC-C10 USB webcam detected.\n");
885 name = "Samsung MPC-C10";
886 type_id = 675;
887 break;
888 case 0x9001:
889 PWC_INFO("Samsung MPC-C30 USB webcam detected.\n");
890 name = "Samsung MPC-C30";
891 type_id = 675;
892 break;
893 case 0x9002:
894 PWC_INFO("Samsung SNC-35E (v3.0) USB webcam detected.\n");
895 name = "Samsung MPC-C30";
896 type_id = 740;
897 break;
898 default:
899 return -ENODEV;
900 break;
901 }
902 }
903 else if (vendor_id == 0x041e) {
904 switch(product_id) {
905 case 0x400c:
906 PWC_INFO("Creative Labs Webcam 5 detected.\n");
907 name = "Creative Labs Webcam 5";
908 type_id = 730;
909 if (my_power_save == -1)
910 my_power_save = 1;
911 break;
912 case 0x4011:
913 PWC_INFO("Creative Labs Webcam Pro Ex detected.\n");
914 name = "Creative Labs Webcam Pro Ex";
915 type_id = 740;
916 break;
917 default:
918 return -ENODEV;
919 break;
920 }
921 }
922 else if (vendor_id == 0x04cc) {
923 switch(product_id) {
924 case 0x8116:
925 PWC_INFO("Sotec Afina Eye USB webcam detected.\n");
926 name = "Sotec Afina Eye";
927 type_id = 730;
928 break;
929 default:
930 return -ENODEV;
931 break;
932 }
933 }
934 else if (vendor_id == 0x06be) {
935 switch(product_id) {
936 case 0x8116:
937 /* This is essentially the same cam as the Sotec Afina Eye */
938 PWC_INFO("AME Co. Afina Eye USB webcam detected.\n");
939 name = "AME Co. Afina Eye";
940 type_id = 750;
941 break;
942 default:
943 return -ENODEV;
944 break;
945 }
946
947 }
948 else if (vendor_id == 0x0d81) {
949 switch(product_id) {
950 case 0x1900:
951 PWC_INFO("Visionite VCS-UC300 USB webcam detected.\n");
952 name = "Visionite VCS-UC300";
953 type_id = 740; /* CCD sensor */
954 break;
955 case 0x1910:
956 PWC_INFO("Visionite VCS-UM100 USB webcam detected.\n");
957 name = "Visionite VCS-UM100";
958 type_id = 730; /* CMOS sensor */
959 break;
960 default:
961 return -ENODEV;
962 break;
963 }
964 }
965 else
966 return -ENODEV; /* Not any of the know types; but the list keeps growing. */
967
968 if (my_power_save == -1)
969 my_power_save = 0;
970
971 memset(serial_number, 0, 30);
972 usb_string(udev, udev->descriptor.iSerialNumber, serial_number, 29);
973 PWC_DEBUG_PROBE("Device serial number is %s\n", serial_number);
974
975 if (udev->descriptor.bNumConfigurations > 1)
976 PWC_WARNING("Warning: more than 1 configuration available.\n");
977
978 /* Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device */
979 pdev = kzalloc(sizeof(struct pwc_device), GFP_KERNEL);
980 if (pdev == NULL) {
981 PWC_ERROR("Oops, could not allocate memory for pwc_device.\n");
982 return -ENOMEM;
983 }
984 pdev->type = type_id;
985 pdev->features = features;
986 pwc_construct(pdev); /* set min/max sizes correct */
987
988 mutex_init(&pdev->v4l2_lock);
989 mutex_init(&pdev->vb_queue_lock);
990 spin_lock_init(&pdev->queued_bufs_lock);
991 INIT_LIST_HEAD(&pdev->queued_bufs);
992
993 pdev->udev = udev;
994 pdev->power_save = my_power_save;
995
996 /* Init videobuf2 queue structure */
997 memset(&pdev->vb_queue, 0, sizeof(pdev->vb_queue));
998 pdev->vb_queue.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
999 pdev->vb_queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
1000 pdev->vb_queue.drv_priv = pdev;
1001 pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf);
1002 pdev->vb_queue.ops = &pwc_vb_queue_ops;
1003 pdev->vb_queue.mem_ops = &vb2_vmalloc_memops;
1004 vb2_queue_init(&pdev->vb_queue);
1005
1006 /* Init video_device structure */
1007 memcpy(&pdev->vdev, &pwc_template, sizeof(pwc_template));
1008 strcpy(pdev->vdev.name, name);
1009 pdev->vdev.queue = &pdev->vb_queue;
1010 pdev->vdev.queue->lock = &pdev->vb_queue_lock;
1011 set_bit(V4L2_FL_USE_FH_PRIO, &pdev->vdev.flags);
1012 video_set_drvdata(&pdev->vdev, pdev);
1013
1014 pdev->release = le16_to_cpu(udev->descriptor.bcdDevice);
1015 PWC_DEBUG_PROBE("Release: %04x\n", pdev->release);
1016
1017 /* Allocate USB command buffers */
1018 pdev->ctrl_buf = kmalloc(sizeof(pdev->cmd_buf), GFP_KERNEL);
1019 if (!pdev->ctrl_buf) {
1020 PWC_ERROR("Oops, could not allocate memory for pwc_device.\n");
1021 rc = -ENOMEM;
1022 goto err_free_mem;
1023 }
1024
1025#ifdef CONFIG_USB_PWC_DEBUG
1026 /* Query sensor type */
1027 if (pwc_get_cmos_sensor(pdev, &rc) >= 0) {
1028 PWC_DEBUG_OPEN("This %s camera is equipped with a %s (%d).\n",
1029 pdev->vdev.name,
1030 pwc_sensor_type_to_string(rc), rc);
1031 }
1032#endif
1033
1034 /* Set the leds off */
1035 pwc_set_leds(pdev, 0, 0);
1036
1037 /* Setup intial videomode */
1038 rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT,
1039 V4L2_PIX_FMT_YUV420, 30, &compression, 1);
1040 if (rc)
1041 goto err_free_mem;
1042
1043 /* Register controls (and read default values from camera */
1044 rc = pwc_init_controls(pdev);
1045 if (rc) {
1046 PWC_ERROR("Failed to register v4l2 controls (%d).\n", rc);
1047 goto err_free_mem;
1048 }
1049
1050 /* And powerdown the camera until streaming starts */
1051 pwc_camera_power(pdev, 0);
1052
1053 /* Register the v4l2_device structure */
1054 pdev->v4l2_dev.release = pwc_video_release;
1055 rc = v4l2_device_register(&intf->dev, &pdev->v4l2_dev);
1056 if (rc) {
1057 PWC_ERROR("Failed to register v4l2-device (%d).\n", rc);
1058 goto err_free_controls;
1059 }
1060
1061 pdev->v4l2_dev.ctrl_handler = &pdev->ctrl_handler;
1062 pdev->vdev.v4l2_dev = &pdev->v4l2_dev;
1063 pdev->vdev.lock = &pdev->v4l2_lock;
1064
1065 rc = video_register_device(&pdev->vdev, VFL_TYPE_GRABBER, -1);
1066 if (rc < 0) {
1067 PWC_ERROR("Failed to register as video device (%d).\n", rc);
1068 goto err_unregister_v4l2_dev;
1069 }
1070 PWC_INFO("Registered as %s.\n", video_device_node_name(&pdev->vdev));
1071
1072#ifdef CONFIG_USB_PWC_INPUT_EVDEV
1073 /* register webcam snapshot button input device */
1074 pdev->button_dev = input_allocate_device();
1075 if (!pdev->button_dev) {
1076 PWC_ERROR("Err, insufficient memory for webcam snapshot button device.");
1077 rc = -ENOMEM;
1078 goto err_video_unreg;
1079 }
1080
1081 usb_make_path(udev, pdev->button_phys, sizeof(pdev->button_phys));
1082 strlcat(pdev->button_phys, "/input0", sizeof(pdev->button_phys));
1083
1084 pdev->button_dev->name = "PWC snapshot button";
1085 pdev->button_dev->phys = pdev->button_phys;
1086 usb_to_input_id(pdev->udev, &pdev->button_dev->id);
1087 pdev->button_dev->dev.parent = &pdev->udev->dev;
1088 pdev->button_dev->evbit[0] = BIT_MASK(EV_KEY);
1089 pdev->button_dev->keybit[BIT_WORD(KEY_CAMERA)] = BIT_MASK(KEY_CAMERA);
1090
1091 rc = input_register_device(pdev->button_dev);
1092 if (rc) {
1093 input_free_device(pdev->button_dev);
1094 pdev->button_dev = NULL;
1095 goto err_video_unreg;
1096 }
1097#endif
1098
1099 return 0;
1100
1101err_video_unreg:
1102 video_unregister_device(&pdev->vdev);
1103err_unregister_v4l2_dev:
1104 v4l2_device_unregister(&pdev->v4l2_dev);
1105err_free_controls:
1106 v4l2_ctrl_handler_free(&pdev->ctrl_handler);
1107err_free_mem:
1108 kfree(pdev->ctrl_buf);
1109 kfree(pdev);
1110 return rc;
1111}
1112
1113/* The user yanked out the cable... */
1114static void usb_pwc_disconnect(struct usb_interface *intf)
1115{
1116 struct v4l2_device *v = usb_get_intfdata(intf);
1117 struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev);
1118
1119 mutex_lock(&pdev->vb_queue_lock);
1120 mutex_lock(&pdev->v4l2_lock);
1121 /* No need to keep the urbs around after disconnection */
1122 if (pdev->vb_queue.streaming)
1123 pwc_isoc_cleanup(pdev);
1124 pdev->udev = NULL;
1125 pwc_cleanup_queued_bufs(pdev);
1126
1127 v4l2_device_disconnect(&pdev->v4l2_dev);
1128 video_unregister_device(&pdev->vdev);
1129 mutex_unlock(&pdev->v4l2_lock);
1130 mutex_unlock(pdev->vb_queue.lock);
1131
1132#ifdef CONFIG_USB_PWC_INPUT_EVDEV
1133 if (pdev->button_dev)
1134 input_unregister_device(pdev->button_dev);
1135#endif
1136
1137 v4l2_device_put(&pdev->v4l2_dev);
1138}
1139
1140
1141/*
1142 * Initialization code & module stuff
1143 */
1144
1145static unsigned int leds_nargs;
1146
1147#ifdef CONFIG_USB_PWC_DEBUG
1148module_param_named(trace, pwc_trace, int, 0644);
1149#endif
1150module_param(power_save, int, 0644);
1151module_param_array(leds, int, &leds_nargs, 0444);
1152
1153#ifdef CONFIG_USB_PWC_DEBUG
1154MODULE_PARM_DESC(trace, "For debugging purposes");
1155#endif
1156MODULE_PARM_DESC(power_save, "Turn power saving for new cameras on or off");
1157MODULE_PARM_DESC(leds, "LED on,off time in milliseconds");
1158
1159MODULE_DESCRIPTION("Philips & OEM USB webcam driver");
1160MODULE_AUTHOR("Luc Saillard <luc@saillard.org>");
1161MODULE_LICENSE("GPL");
1162MODULE_ALIAS("pwcx");
1163MODULE_VERSION( PWC_VERSION );
1164
1165module_usb_driver(pwc_driver);
diff --git a/drivers/media/usb/pwc/pwc-kiara.c b/drivers/media/usb/pwc/pwc-kiara.c
new file mode 100644
index 000000000000..e5f4fd817125
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-kiara.c
@@ -0,0 +1,892 @@
1/* Linux driver for Philips webcam
2 (C) 2004-2006 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25
26/* This tables contains entries for the 730/740/750 (Kiara) camera, with
27 4 different qualities (no compression, low, medium, high).
28 It lists the bandwidth requirements for said mode by its alternate interface
29 number. An alternate of 0 means that the mode is unavailable.
30
31 There are 6 * 4 * 4 entries:
32 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
33 6 framerates: 5, 10, 15, 20, 25, 30
34 4 compression modi: none, low, medium, high
35
36 When an uncompressed mode is not available, the next available compressed mode
37 will be chosen (unless the decompressor is absent). Sometimes there are only
38 1 or 2 compressed modes available; in that case entries are duplicated.
39*/
40
41
42#include "pwc-kiara.h"
43
44const unsigned int Kiara_fps_vector[PWC_FPS_MAX_KIARA] = { 5, 10, 15, 20, 25, 30 };
45
46const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] =
47{
48 /* SQCIF */
49 {
50 /* 5 fps */
51 {
52 {0, },
53 {0, },
54 {0, },
55 {0, },
56 },
57 /* 10 fps */
58 {
59 {0, },
60 {0, },
61 {0, },
62 {0, },
63 },
64 /* 15 fps */
65 {
66 {0, },
67 {0, },
68 {0, },
69 {0, },
70 },
71 /* 20 fps */
72 {
73 {0, },
74 {0, },
75 {0, },
76 {0, },
77 },
78 /* 25 fps */
79 {
80 {0, },
81 {0, },
82 {0, },
83 {0, },
84 },
85 /* 30 fps */
86 {
87 {0, },
88 {0, },
89 {0, },
90 {0, },
91 },
92 },
93 /* QSIF */
94 {
95 /* 5 fps */
96 {
97 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
98 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
99 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
100 {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
101 },
102 /* 10 fps */
103 {
104 {2, 291, 0, {0x1C, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0x01, 0x80}},
105 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
106 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
107 {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
108 },
109 /* 15 fps */
110 {
111 {3, 437, 0, {0x1B, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x01, 0x80}},
112 {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
113 {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
114 {1, 192, 420, {0x13, 0xF4, 0x30, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
115 },
116 /* 20 fps */
117 {
118 {4, 589, 0, {0x1A, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4D, 0x02, 0x80}},
119 {3, 448, 730, {0x12, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xC0, 0x01, 0x80}},
120 {2, 292, 476, {0x12, 0xF4, 0x30, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0x01, 0x80}},
121 {1, 192, 312, {0x12, 0xF4, 0x50, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
122 },
123 /* 25 fps */
124 {
125 {5, 703, 0, {0x19, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x02, 0x80}},
126 {3, 447, 610, {0x11, 0xF4, 0x30, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x28, 0xBF, 0x01, 0x80}},
127 {2, 292, 398, {0x11, 0xF4, 0x50, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x28, 0x24, 0x01, 0x80}},
128 {1, 193, 262, {0x11, 0xF4, 0x50, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x28, 0xC1, 0x00, 0x80}},
129 },
130 /* 30 fps */
131 {
132 {8, 874, 0, {0x18, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6A, 0x03, 0x80}},
133 {5, 704, 730, {0x10, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x28, 0xC0, 0x02, 0x80}},
134 {3, 448, 492, {0x10, 0xF4, 0x30, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x28, 0xC0, 0x01, 0x80}},
135 {2, 292, 320, {0x10, 0xF4, 0x50, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x28, 0x24, 0x01, 0x80}},
136 },
137 },
138 /* QCIF */
139 {
140 /* 5 fps */
141 {
142 {0, },
143 {0, },
144 {0, },
145 {0, },
146 },
147 /* 10 fps */
148 {
149 {0, },
150 {0, },
151 {0, },
152 {0, },
153 },
154 /* 15 fps */
155 {
156 {0, },
157 {0, },
158 {0, },
159 {0, },
160 },
161 /* 20 fps */
162 {
163 {0, },
164 {0, },
165 {0, },
166 {0, },
167 },
168 /* 25 fps */
169 {
170 {0, },
171 {0, },
172 {0, },
173 {0, },
174 },
175 /* 30 fps */
176 {
177 {0, },
178 {0, },
179 {0, },
180 {0, },
181 },
182 },
183 /* SIF */
184 {
185 /* 5 fps */
186 {
187 {4, 582, 0, {0x0D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x02, 0x80}},
188 {3, 387, 1276, {0x05, 0xF4, 0x30, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x01, 0x80}},
189 {2, 291, 960, {0x05, 0xF4, 0x30, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0x01, 0x80}},
190 {1, 191, 630, {0x05, 0xF4, 0x50, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x18, 0xBF, 0x00, 0x80}},
191 },
192 /* 10 fps */
193 {
194 {0, },
195 {6, 775, 1278, {0x04, 0xF4, 0x30, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x03, 0x80}},
196 {3, 447, 736, {0x04, 0xF4, 0x30, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x28, 0xBF, 0x01, 0x80}},
197 {2, 292, 480, {0x04, 0xF4, 0x70, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x28, 0x24, 0x01, 0x80}},
198 },
199 /* 15 fps */
200 {
201 {0, },
202 {9, 955, 1050, {0x03, 0xF4, 0x30, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x03, 0x80}},
203 {4, 592, 650, {0x03, 0xF4, 0x30, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x50, 0x02, 0x80}},
204 {3, 448, 492, {0x03, 0xF4, 0x50, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x38, 0xC0, 0x01, 0x80}},
205 },
206 /* 20 fps */
207 {
208 {0, },
209 {9, 958, 782, {0x02, 0xF4, 0x30, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x03, 0x80}},
210 {5, 703, 574, {0x02, 0xF4, 0x50, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x02, 0x80}},
211 {3, 446, 364, {0x02, 0xF4, 0x90, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x38, 0xBE, 0x01, 0x80}},
212 },
213 /* 25 fps */
214 {
215 {0, },
216 {9, 958, 654, {0x01, 0xF4, 0x30, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x03, 0x80}},
217 {6, 776, 530, {0x01, 0xF4, 0x50, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x03, 0x80}},
218 {4, 592, 404, {0x01, 0xF4, 0x70, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x48, 0x50, 0x02, 0x80}},
219 },
220 /* 30 fps */
221 {
222 {0, },
223 {9, 957, 526, {0x00, 0xF4, 0x50, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x03, 0x80}},
224 {6, 775, 426, {0x00, 0xF4, 0x70, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x03, 0x80}},
225 {4, 590, 324, {0x00, 0x7A, 0x88, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x50, 0x4E, 0x02, 0x80}},
226 },
227 },
228 /* CIF */
229 {
230 /* 5 fps */
231 {
232 {0, },
233 {0, },
234 {0, },
235 {0, },
236 },
237 /* 10 fps */
238 {
239 {0, },
240 {0, },
241 {0, },
242 {0, },
243 },
244 /* 15 fps */
245 {
246 {0, },
247 {0, },
248 {0, },
249 {0, },
250 },
251 /* 20 fps */
252 {
253 {0, },
254 {0, },
255 {0, },
256 {0, },
257 },
258 /* 25 fps */
259 {
260 {0, },
261 {0, },
262 {0, },
263 {0, },
264 },
265 /* 30 fps */
266 {
267 {0, },
268 {0, },
269 {0, },
270 {0, },
271 },
272 },
273 /* VGA */
274 {
275 /* 5 fps */
276 {
277 {0, },
278 {6, 773, 1272, {0x25, 0xF4, 0x30, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}},
279 {4, 592, 976, {0x25, 0xF4, 0x50, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x02, 0x80}},
280 {3, 448, 738, {0x25, 0xF4, 0x90, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x01, 0x80}},
281 },
282 /* 10 fps */
283 {
284 {0, },
285 {9, 956, 788, {0x24, 0xF4, 0x70, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x03, 0x80}},
286 {6, 776, 640, {0x24, 0xF4, 0xB0, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x03, 0x80}},
287 {4, 592, 488, {0x24, 0x7A, 0xE8, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x02, 0x80}},
288 },
289 /* 15 fps */
290 {
291 {0, },
292 {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
293 {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
294 {8, 895, 492, {0x23, 0x7A, 0xE8, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x03, 0x80}},
295 },
296 /* 20 fps */
297 {
298 {0, },
299 {0, },
300 {0, },
301 {0, },
302 },
303 /* 25 fps */
304 {
305 {0, },
306 {0, },
307 {0, },
308 {0, },
309 },
310 /* 30 fps */
311 {
312 {0, },
313 {0, },
314 {0, },
315 {0, },
316 },
317 },
318};
319
320
321/*
322 * Rom table for kiara chips
323 *
324 * 32 roms tables (one for each resolution ?)
325 * 2 tables per roms (one for each passes) (Y, and U&V)
326 * 128 bytes per passes
327 */
328
329const unsigned int KiaraRomTable [8][2][16][8] =
330{
331 { /* version 0 */
332 { /* version 0, passes 0 */
333 {0x00000000,0x00000000,0x00000000,0x00000000,
334 0x00000000,0x00000000,0x00000001,0x00000001},
335 {0x00000000,0x00000000,0x00000009,0x00000009,
336 0x00000009,0x00000009,0x00000009,0x00000009},
337 {0x00000000,0x00000000,0x00000009,0x00000049,
338 0x00000049,0x00000049,0x00000049,0x00000049},
339 {0x00000000,0x00000000,0x00000049,0x00000049,
340 0x00000049,0x00000249,0x0000024a,0x00000049},
341 {0x00000000,0x00000000,0x00000049,0x00000049,
342 0x00000249,0x00000249,0x0000024a,0x0000024a},
343 {0x00000000,0x00000000,0x00000049,0x00000249,
344 0x00000249,0x0000124a,0x0000024a,0x0000024a},
345 {0x00000000,0x00000000,0x00000049,0x00000249,
346 0x0000124a,0x00009252,0x00001252,0x00001252},
347 {0x00000000,0x00000000,0x00000249,0x00000249,
348 0x00009252,0x00009292,0x00009292,0x00009292},
349 {0x00000000,0x00000000,0x00000249,0x00001249,
350 0x00009292,0x00009292,0x00009493,0x000124db},
351 {0x00000000,0x00000000,0x00000249,0x0000924a,
352 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
353 {0x00000000,0x00000000,0x00001249,0x00009252,
354 0x0000a493,0x000124db,0x000124db,0x000126dc},
355 {0x00000000,0x00000000,0x00001249,0x00009493,
356 0x000124db,0x000126dc,0x000136e4,0x000126dc},
357 {0x00000000,0x00000000,0x00009292,0x0000a49b,
358 0x000124db,0x000136e4,0x000136e4,0x000136e4},
359 {0x00000000,0x00000000,0x00009292,0x0000a49b,
360 0x000126dc,0x0001b724,0x0001b92d,0x0001b925},
361 {0x00000000,0x00000000,0x00009492,0x000124db,
362 0x000136e4,0x0001b925,0x0001c96e,0x0001c92d},
363 {0x00000000,0x00000000,0x00000000,0x00000000,
364 0x00000000,0x00000000,0x00000000,0x00000000}
365 },
366 { /* version 0, passes 1 */
367 {0x00000000,0x00000000,0x00000000,0x00000000,
368 0x00000000,0x00000000,0x00000000,0x00000000},
369 {0x00000000,0x00000000,0x00000000,0x00000000,
370 0x00000000,0x00000000,0x00000000,0x00000000},
371 {0x00000000,0x00000000,0x00000001,0x00000009,
372 0x00000009,0x00000009,0x00000009,0x00000001},
373 {0x00000000,0x00000000,0x00000009,0x00000009,
374 0x00000049,0x00000049,0x00000049,0x00000049},
375 {0x00000000,0x00000000,0x00000049,0x00000049,
376 0x00000049,0x00000049,0x0000024a,0x0000024a},
377 {0x00000000,0x00000000,0x00000049,0x00000049,
378 0x00000249,0x00000249,0x0000024a,0x0000024a},
379 {0x00000000,0x00000000,0x00000049,0x00000249,
380 0x00000249,0x00000249,0x0000024a,0x00001252},
381 {0x00000000,0x00000000,0x00000049,0x00001249,
382 0x0000124a,0x0000124a,0x00001252,0x00009292},
383 {0x00000000,0x00000000,0x00000249,0x00001249,
384 0x00009252,0x00009252,0x00009292,0x00009493},
385 {0x00000000,0x00000000,0x00000249,0x0000924a,
386 0x00009292,0x00009292,0x00009292,0x00009493},
387 {0x00000000,0x00000000,0x00000249,0x00009292,
388 0x00009492,0x00009493,0x0000a49b,0x00009493},
389 {0x00000000,0x00000000,0x00001249,0x00009292,
390 0x0000a493,0x000124db,0x000126dc,0x000126dc},
391 {0x00000000,0x00000000,0x0000924a,0x00009493,
392 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
393 {0x00000000,0x00000000,0x00009252,0x00009493,
394 0x000126dc,0x000126dc,0x000136e4,0x000136e4},
395 {0x00000000,0x00000000,0x00009292,0x0000a49b,
396 0x000136e4,0x000136e4,0x0001b725,0x0001b724},
397 {0x00000000,0x00000000,0x00000000,0x00000000,
398 0x00000000,0x00000000,0x00000000,0x00000000}
399 }
400 },
401 { /* version 1 */
402 { /* version 1, passes 0 */
403 {0x00000000,0x00000000,0x00000000,0x00000000,
404 0x00000000,0x00000000,0x00000000,0x00000001},
405 {0x00000000,0x00000000,0x00000009,0x00000009,
406 0x00000009,0x00000009,0x00000009,0x00000009},
407 {0x00000000,0x00000000,0x00000049,0x00000049,
408 0x00000049,0x00000049,0x00000049,0x00000049},
409 {0x00000000,0x00000000,0x00000049,0x00000049,
410 0x00000049,0x00000249,0x0000024a,0x0000024a},
411 {0x00000000,0x00000000,0x00000049,0x00000249,
412 0x00000249,0x00000249,0x0000024a,0x00001252},
413 {0x00000000,0x00000000,0x00000249,0x00000249,
414 0x00000249,0x0000124a,0x00001252,0x00001252},
415 {0x00000000,0x00000000,0x00000249,0x00000249,
416 0x0000124a,0x0000124a,0x00009292,0x00009292},
417 {0x00000000,0x00000000,0x00000249,0x00001249,
418 0x0000124a,0x00009252,0x00009292,0x00009292},
419 {0x00000000,0x00000000,0x00000249,0x00001249,
420 0x00009252,0x00009292,0x00009292,0x00009292},
421 {0x00000000,0x00000000,0x00000249,0x00001249,
422 0x00009252,0x00009292,0x00009493,0x00009493},
423 {0x00000000,0x00000000,0x00000249,0x0000924a,
424 0x00009252,0x00009493,0x00009493,0x00009493},
425 {0x00000000,0x00000000,0x00000249,0x0000924a,
426 0x00009292,0x00009493,0x00009493,0x00009493},
427 {0x00000000,0x00000000,0x00000249,0x00009252,
428 0x00009492,0x00009493,0x0000a49b,0x0000a49b},
429 {0x00000000,0x00000000,0x00001249,0x00009292,
430 0x00009492,0x000124db,0x000124db,0x000124db},
431 {0x00000000,0x00000000,0x0000924a,0x00009493,
432 0x0000a493,0x000126dc,0x000126dc,0x000126dc},
433 {0x00000000,0x00000000,0x00000000,0x00000000,
434 0x00000000,0x00000000,0x00000000,0x00000000}
435 },
436 { /* version 1, passes 1 */
437 {0x00000000,0x00000000,0x00000000,0x00000000,
438 0x00000000,0x00000000,0x00000000,0x00000000},
439 {0x00000000,0x00000000,0x00000049,0x00000009,
440 0x00000049,0x00000009,0x00000001,0x00000000},
441 {0x00000000,0x00000000,0x00000049,0x00000049,
442 0x00000049,0x00000049,0x00000049,0x00000000},
443 {0x00000000,0x00000000,0x00000249,0x00000049,
444 0x00000249,0x00000049,0x0000024a,0x00000001},
445 {0x00000000,0x00000000,0x00000249,0x00000249,
446 0x00000249,0x00000249,0x0000024a,0x00000001},
447 {0x00000000,0x00000000,0x00000249,0x00000249,
448 0x00000249,0x00000249,0x0000024a,0x00000001},
449 {0x00000000,0x00000000,0x00000249,0x00000249,
450 0x00000249,0x00000249,0x0000024a,0x00000009},
451 {0x00000000,0x00000000,0x00000249,0x00000249,
452 0x0000124a,0x0000124a,0x0000024a,0x00000009},
453 {0x00000000,0x00000000,0x00000249,0x00000249,
454 0x0000124a,0x0000124a,0x0000024a,0x00000009},
455 {0x00000000,0x00000000,0x00001249,0x00001249,
456 0x0000124a,0x00009252,0x00001252,0x00000049},
457 {0x00000000,0x00000000,0x00001249,0x00001249,
458 0x0000124a,0x00009292,0x00001252,0x00000049},
459 {0x00000000,0x00000000,0x00001249,0x00001249,
460 0x0000124a,0x00009292,0x00001252,0x00000049},
461 {0x00000000,0x00000000,0x00001249,0x00001249,
462 0x00009252,0x00009292,0x00001252,0x0000024a},
463 {0x00000000,0x00000000,0x00001249,0x00001249,
464 0x00009292,0x00009292,0x00001252,0x0000024a},
465 {0x00000000,0x00000000,0x0000924a,0x0000924a,
466 0x00009492,0x00009493,0x00009292,0x00001252},
467 {0x00000000,0x00000000,0x00000000,0x00000000,
468 0x00000000,0x00000000,0x00000000,0x00000000}
469 }
470 },
471 { /* version 2 */
472 { /* version 2, passes 0 */
473 {0x00000000,0x00000000,0x00000049,0x00000049,
474 0x00000049,0x00000049,0x0000024a,0x0000024a},
475 {0x00000000,0x00000000,0x00000249,0x00000249,
476 0x00000249,0x0000124a,0x00001252,0x00009292},
477 {0x00000000,0x00000000,0x00000249,0x00000249,
478 0x0000124a,0x00009252,0x00009292,0x00009292},
479 {0x00000000,0x00000000,0x00000249,0x00001249,
480 0x0000124a,0x00009292,0x00009493,0x00009493},
481 {0x00000000,0x00000000,0x00000249,0x00001249,
482 0x00009252,0x00009493,0x00009493,0x0000a49b},
483 {0x00000000,0x00000000,0x00000249,0x0000924a,
484 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
485 {0x00000000,0x00000000,0x00001249,0x0000924a,
486 0x00009292,0x00009493,0x0000a49b,0x000124db},
487 {0x00000000,0x00000000,0x00001249,0x00009252,
488 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
489 {0x00000000,0x00000000,0x00001249,0x00009292,
490 0x00009492,0x000124db,0x000124db,0x000126dc},
491 {0x00000000,0x00000000,0x00001249,0x00009292,
492 0x0000a493,0x000124db,0x000126dc,0x000126dc},
493 {0x00000000,0x00000000,0x00001249,0x00009493,
494 0x0000a493,0x000124db,0x000126dc,0x000136e4},
495 {0x00000000,0x00000000,0x00001249,0x00009493,
496 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
497 {0x00000000,0x00000000,0x0000924a,0x00009493,
498 0x0001249b,0x000126dc,0x000136e4,0x000136e4},
499 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
500 0x000124db,0x000136e4,0x000136e4,0x0001b724},
501 {0x00000000,0x00000000,0x00009252,0x000124db,
502 0x000126dc,0x0001b724,0x0001b725,0x0001b925},
503 {0x00000000,0x00000000,0x00000000,0x00000000,
504 0x00000000,0x00000000,0x00000000,0x00000000}
505 },
506 { /* version 2, passes 1 */
507 {0x00000000,0x00000000,0x00000049,0x00000049,
508 0x00000049,0x00000049,0x00000049,0x00000049},
509 {0x00000000,0x00000000,0x00000249,0x00000249,
510 0x00000249,0x00000249,0x0000024a,0x00000049},
511 {0x00000000,0x00000000,0x00001249,0x00000249,
512 0x0000124a,0x0000124a,0x00001252,0x00000049},
513 {0x00000000,0x00000000,0x00001249,0x00001249,
514 0x0000124a,0x0000124a,0x00009292,0x0000024a},
515 {0x00000000,0x00000000,0x00001249,0x00001249,
516 0x00009252,0x00009292,0x00009292,0x0000024a},
517 {0x00000000,0x00000000,0x00001249,0x00001249,
518 0x00009252,0x00009292,0x0000a49b,0x0000024a},
519 {0x00000000,0x00000000,0x00001249,0x00001249,
520 0x00009292,0x00009493,0x0000a49b,0x00001252},
521 {0x00000000,0x00000000,0x00001249,0x00001249,
522 0x00009292,0x00009493,0x0000a49b,0x00001252},
523 {0x00000000,0x00000000,0x00001249,0x0000924a,
524 0x00009492,0x0000a49b,0x0000a49b,0x00001252},
525 {0x00000000,0x00000000,0x00001249,0x00009252,
526 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
527 {0x00000000,0x00000000,0x00001249,0x00009292,
528 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
529 {0x00000000,0x00000000,0x00001249,0x00009493,
530 0x0000a493,0x0000a49b,0x0000a49b,0x00009292},
531 {0x00000000,0x00000000,0x00001249,0x00009493,
532 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
533 {0x00000000,0x00000000,0x0000924a,0x00009493,
534 0x0000a493,0x000124db,0x0000a49b,0x00009493},
535 {0x00000000,0x00000000,0x00009252,0x0000a49b,
536 0x0001249b,0x000126dc,0x000124db,0x0000a49b},
537 {0x00000000,0x00000000,0x00000000,0x00000000,
538 0x00000000,0x00000000,0x00000000,0x00000000}
539 }
540 },
541 { /* version 3 */
542 { /* version 3, passes 0 */
543 {0x00000000,0x00000000,0x00000249,0x00000249,
544 0x0000124a,0x0000124a,0x00009292,0x00009292},
545 {0x00000000,0x00000000,0x00001249,0x00001249,
546 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
547 {0x00000000,0x00000000,0x00001249,0x0000924a,
548 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
549 {0x00000000,0x00000000,0x00001249,0x00009292,
550 0x00009492,0x000124db,0x000126dc,0x000126dc},
551 {0x00000000,0x00000000,0x00001249,0x00009493,
552 0x0000a493,0x000124db,0x000126dc,0x000126dc},
553 {0x00000000,0x00000000,0x00001249,0x00009493,
554 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
555 {0x00000000,0x00000000,0x00001249,0x00009493,
556 0x0000a493,0x000126dc,0x000136e4,0x0001b724},
557 {0x00000000,0x00000000,0x00001249,0x00009493,
558 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
559 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
560 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
561 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
562 0x0001249b,0x000136e4,0x0001b725,0x0001b724},
563 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
564 0x000124db,0x000136e4,0x0001b725,0x0001b925},
565 {0x00000000,0x00000000,0x00009292,0x0000a49b,
566 0x000126dc,0x000136e4,0x0001b92d,0x0001b925},
567 {0x00000000,0x00000000,0x00009292,0x0000a49b,
568 0x000126dc,0x0001b724,0x0001b92d,0x0001c92d},
569 {0x00000000,0x00000000,0x00009492,0x000124db,
570 0x000126dc,0x0001b724,0x0001c96e,0x0001c92d},
571 {0x00000000,0x00000000,0x0000a492,0x000126db,
572 0x000136e4,0x0001b925,0x00025bb6,0x00024b77},
573 {0x00000000,0x00000000,0x00000000,0x00000000,
574 0x00000000,0x00000000,0x00000000,0x00000000}
575 },
576 { /* version 3, passes 1 */
577 {0x00000000,0x00000000,0x00001249,0x00000249,
578 0x0000124a,0x0000124a,0x00001252,0x00001252},
579 {0x00000000,0x00000000,0x00001249,0x00001249,
580 0x00009252,0x00009292,0x00009292,0x00001252},
581 {0x00000000,0x00000000,0x00001249,0x0000924a,
582 0x00009492,0x00009493,0x0000a49b,0x00001252},
583 {0x00000000,0x00000000,0x00001249,0x00009252,
584 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
585 {0x00000000,0x00000000,0x00001249,0x00009292,
586 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
587 {0x00000000,0x00000000,0x00001249,0x00009493,
588 0x0000a493,0x0000a49b,0x000126dc,0x00009292},
589 {0x00000000,0x00000000,0x0000924a,0x00009493,
590 0x0000a493,0x0000a49b,0x000126dc,0x00009493},
591 {0x00000000,0x00000000,0x0000924a,0x00009493,
592 0x0000a493,0x0000a49b,0x000126dc,0x00009493},
593 {0x00000000,0x00000000,0x0000924a,0x00009493,
594 0x0000a493,0x000124db,0x000126dc,0x00009493},
595 {0x00000000,0x00000000,0x0000924a,0x00009493,
596 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
597 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
598 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
599 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
600 0x0001249b,0x000126dc,0x000126dc,0x0000a49b},
601 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
602 0x000124db,0x000136e4,0x000126dc,0x000124db},
603 {0x00000000,0x00000000,0x00009492,0x0000a49b,
604 0x000136e4,0x000136e4,0x000126dc,0x000124db},
605 {0x00000000,0x00000000,0x0000a492,0x000124db,
606 0x0001b724,0x0001b724,0x000136e4,0x000126dc},
607 {0x00000000,0x00000000,0x00000000,0x00000000,
608 0x00000000,0x00000000,0x00000000,0x00000000}
609 }
610 },
611 { /* version 4 */
612 { /* version 4, passes 0 */
613 {0x00000000,0x00000000,0x00000049,0x00000049,
614 0x00000049,0x00000049,0x00000049,0x00000049},
615 {0x00000000,0x00000000,0x00000249,0x00000049,
616 0x00000249,0x00000249,0x0000024a,0x00000049},
617 {0x00000000,0x00000000,0x00000249,0x00000249,
618 0x0000124a,0x00009252,0x00001252,0x0000024a},
619 {0x00000000,0x00000000,0x00001249,0x00001249,
620 0x00009252,0x00009292,0x00009493,0x00001252},
621 {0x00000000,0x00000000,0x00001249,0x0000924a,
622 0x00009292,0x00009493,0x00009493,0x00001252},
623 {0x00000000,0x00000000,0x00001249,0x00009292,
624 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
625 {0x00000000,0x00000000,0x00001249,0x00009493,
626 0x0000a493,0x000124db,0x000124db,0x00009493},
627 {0x00000000,0x00000000,0x0000924a,0x00009493,
628 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
629 {0x00000000,0x00000000,0x0000924a,0x00009493,
630 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
631 {0x00000000,0x00000000,0x0000924a,0x00009493,
632 0x0001249b,0x000126dc,0x000126dc,0x000124db},
633 {0x00000000,0x00000000,0x00009252,0x00009493,
634 0x000124db,0x000136e4,0x000136e4,0x000126dc},
635 {0x00000000,0x00000000,0x00009252,0x0000a49b,
636 0x000124db,0x000136e4,0x000136e4,0x000126dc},
637 {0x00000000,0x00000000,0x00009292,0x0000a49b,
638 0x000126dc,0x000136e4,0x000136e4,0x000136e4},
639 {0x00000000,0x00000000,0x00009492,0x0000a49b,
640 0x000126dc,0x0001b724,0x0001b725,0x0001b724},
641 {0x00000000,0x00000000,0x0000a492,0x000124db,
642 0x000136e4,0x0001b925,0x0001b92d,0x0001b925},
643 {0x00000000,0x00000000,0x00000000,0x00000000,
644 0x00000000,0x00000000,0x00000000,0x00000000}
645 },
646 { /* version 4, passes 1 */
647 {0x00000000,0x00000000,0x00000249,0x00000049,
648 0x00000009,0x00000009,0x00000009,0x00000009},
649 {0x00000000,0x00000000,0x00000249,0x00000249,
650 0x00000049,0x00000049,0x00000009,0x00000009},
651 {0x00000000,0x00000000,0x00001249,0x00001249,
652 0x0000124a,0x00000249,0x00000049,0x00000049},
653 {0x00000000,0x00000000,0x00001249,0x00001249,
654 0x0000124a,0x0000124a,0x00000049,0x00000049},
655 {0x00000000,0x00000000,0x00001249,0x00001249,
656 0x00009252,0x0000124a,0x0000024a,0x0000024a},
657 {0x00000000,0x00000000,0x00001249,0x0000924a,
658 0x00009252,0x0000124a,0x0000024a,0x0000024a},
659 {0x00000000,0x00000000,0x00001249,0x00009292,
660 0x00009492,0x00009252,0x00001252,0x00001252},
661 {0x00000000,0x00000000,0x00001249,0x00009493,
662 0x0000a493,0x00009292,0x00009292,0x00001252},
663 {0x00000000,0x00000000,0x0000924a,0x00009493,
664 0x0000a493,0x00009292,0x00009292,0x00009292},
665 {0x00000000,0x00000000,0x0000924a,0x00009493,
666 0x0000a493,0x00009493,0x00009493,0x00009292},
667 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
668 0x0000a493,0x0000a49b,0x00009493,0x00009493},
669 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
670 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
671 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
672 0x0001249b,0x000124db,0x0000a49b,0x0000a49b},
673 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
674 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
675 {0x00000000,0x00000000,0x00009252,0x000124db,
676 0x0001b724,0x000136e4,0x000126dc,0x000124db},
677 {0x00000000,0x00000000,0x00000000,0x00000000,
678 0x00000000,0x00000000,0x00000000,0x00000000}
679 }
680 },
681 { /* version 5 */
682 { /* version 5, passes 0 */
683 {0x00000000,0x00000000,0x00000249,0x00000249,
684 0x00000249,0x00000249,0x00001252,0x00001252},
685 {0x00000000,0x00000000,0x00001249,0x00001249,
686 0x00009252,0x00009292,0x00009292,0x00001252},
687 {0x00000000,0x00000000,0x00001249,0x0000924a,
688 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
689 {0x00000000,0x00000000,0x00001249,0x00009493,
690 0x0000a493,0x0000a49b,0x000124db,0x00009493},
691 {0x00000000,0x00000000,0x00001249,0x00009493,
692 0x0000a493,0x000124db,0x000126dc,0x00009493},
693 {0x00000000,0x00000000,0x0000924a,0x00009493,
694 0x0000a493,0x000126dc,0x000126dc,0x0000a49b},
695 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
696 0x0001249b,0x000126dc,0x000136e4,0x000124db},
697 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
698 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
699 {0x00000000,0x00000000,0x00009292,0x0000a49b,
700 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
701 {0x00000000,0x00000000,0x00009292,0x0000a49b,
702 0x000126dc,0x0001b724,0x0001b725,0x000136e4},
703 {0x00000000,0x00000000,0x00009292,0x0000a49b,
704 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
705 {0x00000000,0x00000000,0x00009492,0x0000a49b,
706 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
707 {0x00000000,0x00000000,0x00009492,0x000124db,
708 0x000136e4,0x0001b925,0x0001c96e,0x0001b925},
709 {0x00000000,0x00000000,0x00009492,0x000124db,
710 0x0001b724,0x0001b925,0x0001c96e,0x0001c92d},
711 {0x00000000,0x00000000,0x0000a492,0x000126db,
712 0x0001c924,0x0002496d,0x00025bb6,0x00024b77},
713 {0x00000000,0x00000000,0x00000000,0x00000000,
714 0x00000000,0x00000000,0x00000000,0x00000000}
715 },
716 { /* version 5, passes 1 */
717 {0x00000000,0x00000000,0x00001249,0x00000249,
718 0x00000249,0x00000249,0x0000024a,0x0000024a},
719 {0x00000000,0x00000000,0x00001249,0x00001249,
720 0x0000124a,0x0000124a,0x0000024a,0x0000024a},
721 {0x00000000,0x00000000,0x00001249,0x0000924a,
722 0x00009252,0x00009252,0x0000024a,0x0000024a},
723 {0x00000000,0x00000000,0x00001249,0x00009292,
724 0x00009492,0x0000a49b,0x00001252,0x00001252},
725 {0x00000000,0x00000000,0x0000924a,0x00009493,
726 0x0000a493,0x0000a49b,0x00001252,0x00001252},
727 {0x00000000,0x00000000,0x0000924a,0x00009493,
728 0x0000a493,0x0000a49b,0x00009292,0x00001252},
729 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
730 0x0000a493,0x0000a49b,0x00009292,0x00009292},
731 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
732 0x0000a493,0x0000a49b,0x00009493,0x00009292},
733 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
734 0x0001249b,0x000124db,0x00009493,0x00009292},
735 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
736 0x0001249b,0x000124db,0x00009493,0x00009493},
737 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
738 0x000124db,0x000124db,0x0000a49b,0x00009493},
739 {0x00000000,0x00000000,0x0000924a,0x000124db,
740 0x000126dc,0x000126dc,0x0000a49b,0x00009493},
741 {0x00000000,0x00000000,0x0000924a,0x000124db,
742 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
743 {0x00000000,0x00000000,0x00009292,0x000124db,
744 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
745 {0x00000000,0x00000000,0x00009492,0x000126db,
746 0x0001b724,0x000136e4,0x000126dc,0x000124db},
747 {0x00000000,0x00000000,0x00000000,0x00000000,
748 0x00000000,0x00000000,0x00000000,0x00000000}
749 }
750 },
751 { /* version 6 */
752 { /* version 6, passes 0 */
753 {0x00000000,0x00000000,0x00001249,0x00001249,
754 0x00009252,0x00009292,0x00009493,0x00009493},
755 {0x00000000,0x00000000,0x00001249,0x00009292,
756 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
757 {0x00000000,0x00000000,0x00001249,0x00009493,
758 0x0000a493,0x000124db,0x000124db,0x0000a49b},
759 {0x00000000,0x00000000,0x0000924a,0x00009493,
760 0x0000a493,0x000126dc,0x000126dc,0x0000a49b},
761 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
762 0x0001249b,0x000126dc,0x000136e4,0x000124db},
763 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
764 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
765 {0x00000000,0x00000000,0x00009292,0x0000a49b,
766 0x000126dc,0x0001b724,0x0001b725,0x000126dc},
767 {0x00000000,0x00000000,0x00009292,0x0000a49b,
768 0x000136e4,0x0001b724,0x0001b92d,0x000136e4},
769 {0x00000000,0x00000000,0x00009492,0x0000a49b,
770 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
771 {0x00000000,0x00000000,0x00009492,0x000124db,
772 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
773 {0x00000000,0x00000000,0x00009492,0x000124db,
774 0x000136e4,0x0001b925,0x0001b92d,0x0001b925},
775 {0x00000000,0x00000000,0x00009492,0x000124db,
776 0x0001b724,0x0001b925,0x0001c96e,0x0001c92d},
777 {0x00000000,0x00000000,0x0000a492,0x000124db,
778 0x0001b724,0x0001c92d,0x0001c96e,0x0001c92d},
779 {0x00000000,0x00000000,0x0000a492,0x000124db,
780 0x0001b724,0x0001c92d,0x00024b76,0x0002496e},
781 {0x00000000,0x00000000,0x00012492,0x000126db,
782 0x0001c924,0x00024b6d,0x0002ddb6,0x00025bbf},
783 {0x00000000,0x00000000,0x00000000,0x00000000,
784 0x00000000,0x00000000,0x00000000,0x00000000}
785 },
786 { /* version 6, passes 1 */
787 {0x00000000,0x00000000,0x00001249,0x00001249,
788 0x0000124a,0x0000124a,0x00001252,0x00001252},
789 {0x00000000,0x00000000,0x00001249,0x00009292,
790 0x00009492,0x00009252,0x00001252,0x00001252},
791 {0x00000000,0x00000000,0x0000924a,0x00009493,
792 0x0000a493,0x00009292,0x00001252,0x00001252},
793 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
794 0x0000a493,0x0000a49b,0x00009292,0x00009292},
795 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
796 0x0000a493,0x0000a49b,0x00009292,0x00009292},
797 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
798 0x0001249b,0x0000a49b,0x00009493,0x00009292},
799 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
800 0x000124db,0x000124db,0x00009493,0x00009493},
801 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
802 0x000124db,0x000124db,0x0000a49b,0x00009493},
803 {0x00000000,0x00000000,0x0000924a,0x000124db,
804 0x000126dc,0x000124db,0x0000a49b,0x00009493},
805 {0x00000000,0x00000000,0x0000924a,0x000124db,
806 0x000126dc,0x000126dc,0x0000a49b,0x0000a49b},
807 {0x00000000,0x00000000,0x0000924a,0x000124db,
808 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
809 {0x00000000,0x00000000,0x00009492,0x000126db,
810 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
811 {0x00000000,0x00000000,0x00009492,0x000126db,
812 0x0001b724,0x000136e4,0x000126dc,0x000124db},
813 {0x00000000,0x00000000,0x00009492,0x000126db,
814 0x0001b724,0x000136e4,0x000126dc,0x000124db},
815 {0x00000000,0x00000000,0x0000a492,0x000136db,
816 0x0001c924,0x0001b724,0x000136e4,0x000126dc},
817 {0x00000000,0x00000000,0x00000000,0x00000000,
818 0x00000000,0x00000000,0x00000000,0x00000000}
819 }
820 },
821 { /* version 7 */
822 { /* version 7, passes 0 */
823 {0x00000000,0x00000000,0x00001249,0x00001249,
824 0x00009252,0x00009292,0x00009493,0x00009493},
825 {0x00000000,0x00000000,0x00001249,0x00009493,
826 0x0000a493,0x000124db,0x000126dc,0x00009493},
827 {0x00000000,0x00000000,0x00001249,0x0000a49b,
828 0x0001249b,0x000126dc,0x000126dc,0x0000a49b},
829 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
830 0x0001249b,0x000126dc,0x000136e4,0x0000a49b},
831 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
832 0x000126dc,0x000136e4,0x0001b725,0x000124db},
833 {0x00000000,0x00000000,0x00009292,0x0000a49b,
834 0x000136e4,0x0001b724,0x0001b725,0x000126dc},
835 {0x00000000,0x00000000,0x00009292,0x000124db,
836 0x000136e4,0x0001b724,0x0001b725,0x000126dc},
837 {0x00000000,0x00000000,0x00009492,0x000124db,
838 0x000136e4,0x0001b724,0x0001c96e,0x000136e4},
839 {0x00000000,0x00000000,0x00009492,0x000124db,
840 0x000136e4,0x0001c92d,0x0001c96e,0x0001b724},
841 {0x00000000,0x00000000,0x0000a492,0x000124db,
842 0x000136e4,0x0001c92d,0x0001c96e,0x0001b724},
843 {0x00000000,0x00000000,0x0000a492,0x000124db,
844 0x0001b724,0x0001c92d,0x0001c96e,0x0001b925},
845 {0x00000000,0x00000000,0x0000a492,0x000126db,
846 0x0001b724,0x0001c92d,0x00024b76,0x0001c92d},
847 {0x00000000,0x00000000,0x0000a492,0x000126db,
848 0x0001b924,0x0001c92d,0x00024b76,0x0001c92d},
849 {0x00000000,0x00000000,0x0000a492,0x000126db,
850 0x0001b924,0x0001c92d,0x00024b76,0x0002496e},
851 {0x00000000,0x00000000,0x00012492,0x000136db,
852 0x00024924,0x00024b6d,0x0002ddb6,0x00025bbf},
853 {0x00000000,0x00000000,0x00000000,0x00000000,
854 0x00000000,0x00000000,0x00000000,0x00000000}
855 },
856 { /* version 7, passes 1 */
857 {0x00000000,0x00000000,0x00001249,0x00001249,
858 0x0000124a,0x0000124a,0x00001252,0x00001252},
859 {0x00000000,0x00000000,0x0000924a,0x00009493,
860 0x00009492,0x00009292,0x00001252,0x00001252},
861 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
862 0x0000a493,0x0000a49b,0x00001252,0x00001252},
863 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
864 0x0000a493,0x0000a49b,0x00009292,0x00009292},
865 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
866 0x0000a493,0x0000a49b,0x00009292,0x00009292},
867 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
868 0x000126dc,0x0000a49b,0x00009493,0x00009292},
869 {0x00000000,0x00000000,0x0000924a,0x000124db,
870 0x000126dc,0x000124db,0x00009493,0x00009493},
871 {0x00000000,0x00000000,0x0000924a,0x000124db,
872 0x000136e4,0x000124db,0x0000a49b,0x00009493},
873 {0x00000000,0x00000000,0x0000924a,0x000136db,
874 0x0001b724,0x000124db,0x0000a49b,0x00009493},
875 {0x00000000,0x00000000,0x0000924a,0x000136db,
876 0x0001b724,0x000126dc,0x0000a49b,0x0000a49b},
877 {0x00000000,0x00000000,0x00009292,0x000136db,
878 0x0001b724,0x000126dc,0x000124db,0x0000a49b},
879 {0x00000000,0x00000000,0x00009492,0x000136db,
880 0x0001b724,0x000126dc,0x000124db,0x0000a49b},
881 {0x00000000,0x00000000,0x0000a492,0x000136db,
882 0x0001b724,0x000136e4,0x000126dc,0x000124db},
883 {0x00000000,0x00000000,0x0000a492,0x000136db,
884 0x0001b724,0x000136e4,0x000126dc,0x000124db},
885 {0x00000000,0x00000000,0x00012492,0x0001b6db,
886 0x0001c924,0x0001b724,0x000136e4,0x000126dc},
887 {0x00000000,0x00000000,0x00000000,0x00000000,
888 0x00000000,0x00000000,0x00000000,0x00000000}
889 }
890 }
891};
892
diff --git a/drivers/media/usb/pwc/pwc-kiara.h b/drivers/media/usb/pwc/pwc-kiara.h
new file mode 100644
index 000000000000..8e02b7ac2139
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-kiara.h
@@ -0,0 +1,48 @@
1/* Linux driver for Philips webcam
2 (C) 2004-2006 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25/* Entries for the Kiara (730/740/750) camera */
26
27#ifndef PWC_KIARA_H
28#define PWC_KIARA_H
29
30#include "pwc.h"
31
32#define PWC_FPS_MAX_KIARA 6
33
34struct Kiara_table_entry
35{
36 char alternate; /* USB alternate interface */
37 unsigned short packetsize; /* Normal packet size */
38 unsigned short bandlength; /* Bandlength when decompressing */
39 unsigned char mode[12]; /* precomputed mode settings for cam */
40};
41
42extern const struct Kiara_table_entry Kiara_table[PSZ_MAX][PWC_FPS_MAX_KIARA][4];
43extern const unsigned int KiaraRomTable[8][2][16][8];
44extern const unsigned int Kiara_fps_vector[PWC_FPS_MAX_KIARA];
45
46#endif
47
48
diff --git a/drivers/media/usb/pwc/pwc-misc.c b/drivers/media/usb/pwc/pwc-misc.c
new file mode 100644
index 000000000000..9be5adffa874
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-misc.c
@@ -0,0 +1,93 @@
1/* Linux driver for Philips webcam
2 Various miscellaneous functions and tables.
3 (C) 1999-2003 Nemosoft Unv.
4 (C) 2004-2006 Luc Saillard (luc@saillard.org)
5
6 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
7 driver and thus may have bugs that are not present in the original version.
8 Please send bug reports and support requests to <luc@saillard.org>.
9 The decompression routines have been implemented by reverse-engineering the
10 Nemosoft binary pwcx module. Caveat emptor.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25*/
26
27
28#include "pwc.h"
29
30const int pwc_image_sizes[PSZ_MAX][2] =
31{
32 { 128, 96 }, /* sqcif */
33 { 160, 120 }, /* qsif */
34 { 176, 144 }, /* qcif */
35 { 320, 240 }, /* sif */
36 { 352, 288 }, /* cif */
37 { 640, 480 }, /* vga */
38};
39
40/* x,y -> PSZ_ */
41int pwc_get_size(struct pwc_device *pdev, int width, int height)
42{
43 int i;
44
45 /* Find the largest size supported by the camera that fits into the
46 requested size. */
47 for (i = PSZ_MAX - 1; i >= 0; i--) {
48 if (!(pdev->image_mask & (1 << i)))
49 continue;
50
51 if (pwc_image_sizes[i][0] <= width &&
52 pwc_image_sizes[i][1] <= height)
53 return i;
54 }
55
56 /* No mode found, return the smallest mode we have */
57 for (i = 0; i < PSZ_MAX; i++) {
58 if (pdev->image_mask & (1 << i))
59 return i;
60 }
61
62 /* Never reached there always is atleast one supported mode */
63 return 0;
64}
65
66/* initialize variables depending on type and decompressor */
67void pwc_construct(struct pwc_device *pdev)
68{
69 if (DEVICE_USE_CODEC1(pdev->type)) {
70
71 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF;
72 pdev->vcinterface = 2;
73 pdev->vendpoint = 4;
74 pdev->frame_header_size = 0;
75 pdev->frame_trailer_size = 0;
76
77 } else if (DEVICE_USE_CODEC3(pdev->type)) {
78
79 pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
80 pdev->vcinterface = 3;
81 pdev->vendpoint = 5;
82 pdev->frame_header_size = TOUCAM_HEADER_SIZE;
83 pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE;
84
85 } else /* if (DEVICE_USE_CODEC2(pdev->type)) */ {
86
87 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
88 pdev->vcinterface = 3;
89 pdev->vendpoint = 4;
90 pdev->frame_header_size = 0;
91 pdev->frame_trailer_size = 0;
92 }
93}
diff --git a/drivers/media/usb/pwc/pwc-nala.h b/drivers/media/usb/pwc/pwc-nala.h
new file mode 100644
index 000000000000..168c73ef75d8
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-nala.h
@@ -0,0 +1,66 @@
1 /* SQCIF */
2 {
3 {0, 0, {0x04, 0x01, 0x03}},
4 {8, 0, {0x05, 0x01, 0x03}},
5 {7, 0, {0x08, 0x01, 0x03}},
6 {7, 0, {0x0A, 0x01, 0x03}},
7 {6, 0, {0x0C, 0x01, 0x03}},
8 {5, 0, {0x0F, 0x01, 0x03}},
9 {4, 0, {0x14, 0x01, 0x03}},
10 {3, 0, {0x18, 0x01, 0x03}},
11 },
12 /* QSIF */
13 {
14 {0},
15 {0},
16 {0},
17 {0},
18 {0},
19 {0},
20 {0},
21 {0},
22 },
23 /* QCIF */
24 {
25 {0, 0, {0x04, 0x01, 0x02}},
26 {8, 0, {0x05, 0x01, 0x02}},
27 {7, 0, {0x08, 0x01, 0x02}},
28 {6, 0, {0x0A, 0x01, 0x02}},
29 {5, 0, {0x0C, 0x01, 0x02}},
30 {4, 0, {0x0F, 0x01, 0x02}},
31 {1, 0, {0x14, 0x01, 0x02}},
32 {1, 0, {0x18, 0x01, 0x02}},
33 },
34 /* SIF */
35 {
36 {0},
37 {0},
38 {0},
39 {0},
40 {0},
41 {0},
42 {0},
43 {0},
44 },
45 /* CIF */
46 {
47 {4, 0, {0x04, 0x01, 0x01}},
48 {7, 1, {0x05, 0x03, 0x01}},
49 {6, 1, {0x08, 0x03, 0x01}},
50 {4, 1, {0x0A, 0x03, 0x01}},
51 {3, 1, {0x0C, 0x03, 0x01}},
52 {2, 1, {0x0F, 0x03, 0x01}},
53 {0},
54 {0},
55 },
56 /* VGA */
57 {
58 {0},
59 {0},
60 {0},
61 {0},
62 {0},
63 {0},
64 {0},
65 {0},
66 },
diff --git a/drivers/media/usb/pwc/pwc-timon.c b/drivers/media/usb/pwc/pwc-timon.c
new file mode 100644
index 000000000000..c56c174b161c
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-timon.c
@@ -0,0 +1,1448 @@
1/* Linux driver for Philips webcam
2 (C) 2004-2006 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25
26/* This tables contains entries for the 675/680/690 (Timon) camera, with
27 4 different qualities (no compression, low, medium, high).
28 It lists the bandwidth requirements for said mode by its alternate interface
29 number. An alternate of 0 means that the mode is unavailable.
30
31 There are 6 * 4 * 4 entries:
32 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
33 6 framerates: 5, 10, 15, 20, 25, 30
34 4 compression modi: none, low, medium, high
35
36 When an uncompressed mode is not available, the next available compressed mode
37 will be chosen (unless the decompressor is absent). Sometimes there are only
38 1 or 2 compressed modes available; in that case entries are duplicated.
39*/
40
41#include "pwc-timon.h"
42
43const unsigned int Timon_fps_vector[PWC_FPS_MAX_TIMON] = { 5, 10, 15, 20, 25, 30 };
44
45const struct Timon_table_entry Timon_table[PSZ_MAX][PWC_FPS_MAX_TIMON][4] =
46{
47 /* SQCIF */
48 {
49 /* 5 fps */
50 {
51 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
52 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
53 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
54 {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
55 },
56 /* 10 fps */
57 {
58 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
59 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
60 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
61 {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
62 },
63 /* 15 fps */
64 {
65 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
66 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
67 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
68 {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
69 },
70 /* 20 fps */
71 {
72 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
73 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
74 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
75 {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
76 },
77 /* 25 fps */
78 {
79 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
80 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
81 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
82 {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
83 },
84 /* 30 fps */
85 {
86 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
87 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
88 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
89 {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
90 },
91 },
92 /* QSIF */
93 {
94 /* 5 fps */
95 {
96 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
97 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
98 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
99 {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
100 },
101 /* 10 fps */
102 {
103 {2, 291, 0, {0x2C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0xA1, 0xC0, 0x02}},
104 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
105 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
106 {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
107 },
108 /* 15 fps */
109 {
110 {3, 437, 0, {0x2B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x6D, 0xC0, 0x02}},
111 {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
112 {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
113 {1, 191, 420, {0x2B, 0xF4, 0x0D, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
114 },
115 /* 20 fps */
116 {
117 {4, 588, 0, {0x2A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4C, 0x52, 0xC0, 0x02}},
118 {3, 447, 730, {0x2A, 0xF4, 0x05, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
119 {2, 292, 476, {0x2A, 0xF4, 0x0D, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
120 {1, 192, 312, {0x2A, 0xF4, 0x1D, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
121 },
122 /* 25 fps */
123 {
124 {5, 703, 0, {0x29, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x42, 0xC0, 0x02}},
125 {3, 447, 610, {0x29, 0xF4, 0x05, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
126 {2, 292, 398, {0x29, 0xF4, 0x0D, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
127 {1, 192, 262, {0x29, 0xF4, 0x25, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
128 },
129 /* 30 fps */
130 {
131 {8, 873, 0, {0x28, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x69, 0x37, 0xC0, 0x02}},
132 {5, 704, 774, {0x28, 0xF4, 0x05, 0x18, 0x21, 0x17, 0x59, 0x0F, 0x18, 0xC0, 0x42, 0xC0, 0x02}},
133 {3, 448, 492, {0x28, 0xF4, 0x05, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x18, 0xC0, 0x69, 0xC0, 0x02}},
134 {2, 291, 320, {0x28, 0xF4, 0x1D, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
135 },
136 },
137 /* QCIF */
138 {
139 /* 5 fps */
140 {
141 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
142 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
143 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
144 {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
145 },
146 /* 10 fps */
147 {
148 {3, 385, 0, {0x0C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x81, 0x79, 0xC0, 0x02}},
149 {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
150 {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
151 {1, 194, 532, {0x0C, 0xF4, 0x05, 0x10, 0x9A, 0x0F, 0xBE, 0x1B, 0x08, 0xC2, 0xF0, 0xC0, 0x02}},
152 },
153 /* 15 fps */
154 {
155 {4, 577, 0, {0x0B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x41, 0x52, 0xC0, 0x02}},
156 {3, 447, 818, {0x0B, 0xF4, 0x05, 0x19, 0x89, 0x18, 0xAD, 0x0F, 0x10, 0xBF, 0x69, 0xC0, 0x02}},
157 {2, 292, 534, {0x0B, 0xF4, 0x05, 0x10, 0xA3, 0x0F, 0xC7, 0x19, 0x10, 0x24, 0xA1, 0xC0, 0x02}},
158 {1, 195, 356, {0x0B, 0xF4, 0x15, 0x0B, 0x11, 0x0A, 0x35, 0x1E, 0x10, 0xC3, 0xF0, 0xC0, 0x02}},
159 },
160 /* 20 fps */
161 {
162 {6, 776, 0, {0x0A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x08, 0x3F, 0xC0, 0x02}},
163 {4, 591, 804, {0x0A, 0xF4, 0x05, 0x19, 0x1E, 0x18, 0x42, 0x0F, 0x18, 0x4F, 0x4E, 0xC0, 0x02}},
164 {3, 447, 608, {0x0A, 0xF4, 0x05, 0x12, 0xFD, 0x12, 0x21, 0x15, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
165 {2, 291, 396, {0x0A, 0xF4, 0x15, 0x0C, 0x5E, 0x0B, 0x82, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
166 },
167 /* 25 fps */
168 {
169 {9, 928, 0, {0x09, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xA0, 0x33, 0xC0, 0x02}},
170 {5, 703, 800, {0x09, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x10, 0x18, 0xBF, 0x42, 0xC0, 0x02}},
171 {3, 447, 508, {0x09, 0xF4, 0x0D, 0x0F, 0xD2, 0x0E, 0xF6, 0x1B, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
172 {2, 292, 332, {0x09, 0xF4, 0x1D, 0x0A, 0x5A, 0x09, 0x7E, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
173 },
174 /* 30 fps */
175 {
176 {0, },
177 {9, 956, 876, {0x08, 0xF4, 0x05, 0x1B, 0x58, 0x1A, 0x7C, 0x0E, 0x20, 0xBC, 0x33, 0x10, 0x02}},
178 {4, 592, 542, {0x08, 0xF4, 0x05, 0x10, 0xE4, 0x10, 0x08, 0x17, 0x20, 0x50, 0x4E, 0x10, 0x02}},
179 {2, 291, 266, {0x08, 0xF4, 0x25, 0x08, 0x48, 0x07, 0x6C, 0x1E, 0x20, 0x23, 0xA1, 0x10, 0x02}},
180 },
181 },
182 /* SIF */
183 {
184 /* 5 fps */
185 {
186 {4, 582, 0, {0x35, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x52, 0x60, 0x02}},
187 {3, 387, 1276, {0x35, 0xF4, 0x05, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x79, 0x60, 0x02}},
188 {2, 291, 960, {0x35, 0xF4, 0x0D, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0xA1, 0x60, 0x02}},
189 {1, 191, 630, {0x35, 0xF4, 0x1D, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x08, 0xBF, 0xF4, 0x60, 0x02}},
190 },
191 /* 10 fps */
192 {
193 {0, },
194 {6, 775, 1278, {0x34, 0xF4, 0x05, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x3F, 0x10, 0x02}},
195 {3, 447, 736, {0x34, 0xF4, 0x15, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x18, 0xBF, 0x69, 0x10, 0x02}},
196 {2, 291, 480, {0x34, 0xF4, 0x2D, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x18, 0x23, 0xA1, 0x10, 0x02}},
197 },
198 /* 15 fps */
199 {
200 {0, },
201 {9, 955, 1050, {0x33, 0xF4, 0x05, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x33, 0x10, 0x02}},
202 {4, 591, 650, {0x33, 0xF4, 0x15, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x4F, 0x4E, 0x10, 0x02}},
203 {3, 448, 492, {0x33, 0xF4, 0x25, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x28, 0xC0, 0x69, 0x10, 0x02}},
204 },
205 /* 20 fps */
206 {
207 {0, },
208 {9, 958, 782, {0x32, 0xF4, 0x0D, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x33, 0xD0, 0x02}},
209 {5, 703, 574, {0x32, 0xF4, 0x1D, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x42, 0xD0, 0x02}},
210 {3, 446, 364, {0x32, 0xF4, 0x3D, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x30, 0xBE, 0x69, 0xD0, 0x02}},
211 },
212 /* 25 fps */
213 {
214 {0, },
215 {9, 958, 654, {0x31, 0xF4, 0x15, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x33, 0x90, 0x02}},
216 {6, 776, 530, {0x31, 0xF4, 0x25, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x3F, 0x90, 0x02}},
217 {4, 592, 404, {0x31, 0xF4, 0x35, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x38, 0x50, 0x4E, 0x90, 0x02}},
218 },
219 /* 30 fps */
220 {
221 {0, },
222 {9, 957, 526, {0x30, 0xF4, 0x25, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x33, 0x60, 0x02}},
223 {6, 775, 426, {0x30, 0xF4, 0x35, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x3F, 0x60, 0x02}},
224 {4, 590, 324, {0x30, 0x7A, 0x4B, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x40, 0x4E, 0x52, 0x60, 0x02}},
225 },
226 },
227 /* CIF */
228 {
229 /* 5 fps */
230 {
231 {6, 771, 0, {0x15, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x3F, 0x80, 0x02}},
232 {4, 465, 1278, {0x15, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x03, 0x18, 0xD1, 0x65, 0x80, 0x02}},
233 {2, 291, 800, {0x15, 0xF4, 0x15, 0x18, 0xF4, 0x17, 0x3C, 0x05, 0x18, 0x23, 0xA1, 0x80, 0x02}},
234 {1, 193, 528, {0x15, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x18, 0xC1, 0xF4, 0x80, 0x02}},
235 },
236 /* 10 fps */
237 {
238 {0, },
239 {9, 932, 1278, {0x14, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x04, 0x30, 0xA4, 0x33, 0x10, 0x02}},
240 {4, 591, 812, {0x14, 0xF4, 0x15, 0x19, 0x56, 0x17, 0x9E, 0x06, 0x28, 0x4F, 0x4E, 0x10, 0x02}},
241 {2, 291, 400, {0x14, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x28, 0x23, 0xA1, 0x10, 0x02}},
242 },
243 /* 15 fps */
244 {
245 {0, },
246 {9, 956, 876, {0x13, 0xF4, 0x0D, 0x1B, 0x58, 0x19, 0xA0, 0x05, 0x38, 0xBC, 0x33, 0x60, 0x02}},
247 {5, 703, 644, {0x13, 0xF4, 0x1D, 0x14, 0x1C, 0x12, 0x64, 0x08, 0x38, 0xBF, 0x42, 0x60, 0x02}},
248 {3, 448, 410, {0x13, 0xF4, 0x3D, 0x0C, 0xC4, 0x0B, 0x0C, 0x0E, 0x38, 0xC0, 0x69, 0x60, 0x02}},
249 },
250 /* 20 fps */
251 {
252 {0, },
253 {9, 956, 650, {0x12, 0xF4, 0x1D, 0x14, 0x4A, 0x12, 0x92, 0x09, 0x48, 0xBC, 0x33, 0x10, 0x03}},
254 {6, 776, 528, {0x12, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x40, 0x08, 0x3F, 0x10, 0x03}},
255 {4, 591, 402, {0x12, 0xF4, 0x3D, 0x0C, 0x8F, 0x0A, 0xD7, 0x0E, 0x40, 0x4F, 0x4E, 0x10, 0x03}},
256 },
257 /* 25 fps */
258 {
259 {0, },
260 {9, 956, 544, {0x11, 0xF4, 0x25, 0x10, 0xF4, 0x0F, 0x3C, 0x0A, 0x48, 0xBC, 0x33, 0xC0, 0x02}},
261 {7, 840, 478, {0x11, 0xF4, 0x2D, 0x0E, 0xEB, 0x0D, 0x33, 0x0B, 0x48, 0x48, 0x3B, 0xC0, 0x02}},
262 {5, 703, 400, {0x11, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x48, 0xBF, 0x42, 0xC0, 0x02}},
263 },
264 /* 30 fps */
265 {
266 {0, },
267 {9, 956, 438, {0x10, 0xF4, 0x35, 0x0D, 0xAC, 0x0B, 0xF4, 0x0D, 0x50, 0xBC, 0x33, 0x10, 0x02}},
268 {7, 838, 384, {0x10, 0xF4, 0x45, 0x0B, 0xFD, 0x0A, 0x45, 0x0F, 0x50, 0x46, 0x3B, 0x10, 0x02}},
269 {6, 773, 354, {0x10, 0x7A, 0x4B, 0x0B, 0x0C, 0x09, 0x80, 0x10, 0x50, 0x05, 0x3F, 0x10, 0x02}},
270 },
271 },
272 /* VGA */
273 {
274 /* 5 fps */
275 {
276 {0, },
277 {6, 773, 1272, {0x1D, 0xF4, 0x15, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x3F, 0x10, 0x02}},
278 {4, 592, 976, {0x1D, 0xF4, 0x25, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x4E, 0x10, 0x02}},
279 {3, 448, 738, {0x1D, 0xF4, 0x3D, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x69, 0x10, 0x02}},
280 },
281 /* 10 fps */
282 {
283 {0, },
284 {9, 956, 788, {0x1C, 0xF4, 0x35, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x33, 0x10, 0x02}},
285 {6, 776, 640, {0x1C, 0x7A, 0x53, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x3F, 0x10, 0x02}},
286 {4, 592, 488, {0x1C, 0x7A, 0x6B, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x4E, 0x10, 0x02}},
287 },
288 /* 15 fps */
289 {
290 {0, },
291 {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
292 {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
293 {8, 895, 492, {0x1B, 0x7A, 0x6B, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x37, 0x80, 0x02}},
294 },
295 /* 20 fps */
296 {
297 {0, },
298 {0, },
299 {0, },
300 {0, },
301 },
302 /* 25 fps */
303 {
304 {0, },
305 {0, },
306 {0, },
307 {0, },
308 },
309 /* 30 fps */
310 {
311 {0, },
312 {0, },
313 {0, },
314 {0, },
315 },
316 },
317};
318
319/*
320 * 16 versions:
321 * 2 tables (one for Y, and one for U&V)
322 * 16 levels of details per tables
323 * 8 blocs
324 */
325
326const unsigned int TimonRomTable [16][2][16][8] =
327{
328 { /* version 0 */
329 { /* version 0, passes 0 */
330 {0x00000000,0x00000000,0x00000000,0x00000000,
331 0x00000000,0x00000000,0x00000000,0x00000001},
332 {0x00000000,0x00000000,0x00000001,0x00000001,
333 0x00000001,0x00000001,0x00000001,0x00000001},
334 {0x00000000,0x00000000,0x00000001,0x00000001,
335 0x00000001,0x00000009,0x00000009,0x00000009},
336 {0x00000000,0x00000000,0x00000009,0x00000001,
337 0x00000009,0x00000009,0x00000009,0x00000009},
338 {0x00000000,0x00000000,0x00000009,0x00000009,
339 0x00000009,0x00000009,0x00000049,0x00000009},
340 {0x00000000,0x00000000,0x00000009,0x00000009,
341 0x00000009,0x00000049,0x00000049,0x00000049},
342 {0x00000000,0x00000000,0x00000009,0x00000009,
343 0x00000049,0x00000049,0x00000049,0x00000049},
344 {0x00000000,0x00000000,0x00000009,0x00000049,
345 0x00000049,0x00000049,0x00000049,0x00000049},
346 {0x00000000,0x00000000,0x00000049,0x00000049,
347 0x00000049,0x00000049,0x0000024a,0x0000024a},
348 {0x00000000,0x00000000,0x00000049,0x00000049,
349 0x00000049,0x00000249,0x0000024a,0x0000024a},
350 {0x00000000,0x00000000,0x00000049,0x00000049,
351 0x00000249,0x00000249,0x0000024a,0x0000024a},
352 {0x00000000,0x00000000,0x00000049,0x00000049,
353 0x00000249,0x00000249,0x00001252,0x0000024a},
354 {0x00000000,0x00000000,0x00000049,0x00000049,
355 0x00000249,0x0000124a,0x00001252,0x0000024a},
356 {0x00000000,0x00000000,0x00000049,0x00000249,
357 0x00000249,0x0000124a,0x00001252,0x0000024a},
358 {0x00000000,0x00000000,0x00000249,0x00001249,
359 0x0000124a,0x00009252,0x00009292,0x00001252},
360 {0x00000000,0x00000000,0x00000000,0x00000000,
361 0x00000000,0x00000000,0x00000000,0x00000000}
362 },
363 { /* version 0, passes 1 */
364 {0x00000000,0x00000000,0x00000000,0x00000000,
365 0x00000000,0x00000000,0x00000000,0x00000000},
366 {0x00000000,0x00000000,0x00000001,0x00000001,
367 0x00000001,0x00000001,0x00000000,0x00000000},
368 {0x00000000,0x00000000,0x00000009,0x00000001,
369 0x00000001,0x00000009,0x00000000,0x00000000},
370 {0x00000000,0x00000000,0x00000009,0x00000009,
371 0x00000009,0x00000009,0x00000000,0x00000000},
372 {0x00000000,0x00000000,0x00000009,0x00000009,
373 0x00000009,0x00000009,0x00000001,0x00000000},
374 {0x00000000,0x00000000,0x00000049,0x00000009,
375 0x00000009,0x00000049,0x00000001,0x00000001},
376 {0x00000000,0x00000000,0x00000049,0x00000009,
377 0x00000009,0x00000049,0x00000001,0x00000001},
378 {0x00000000,0x00000000,0x00000049,0x00000049,
379 0x00000049,0x00000049,0x00000009,0x00000001},
380 {0x00000000,0x00000000,0x00000049,0x00000049,
381 0x00000049,0x00000049,0x00000009,0x00000001},
382 {0x00000000,0x00000000,0x00000049,0x00000049,
383 0x00000049,0x00000049,0x00000009,0x00000001},
384 {0x00000000,0x00000000,0x00000049,0x00000049,
385 0x00000049,0x00000049,0x00000009,0x00000009},
386 {0x00000000,0x00000000,0x00000049,0x00000049,
387 0x00000049,0x00000249,0x00000049,0x00000009},
388 {0x00000000,0x00000000,0x00000049,0x00000049,
389 0x00000049,0x00000249,0x00000049,0x00000009},
390 {0x00000000,0x00000000,0x00000249,0x00000049,
391 0x00000249,0x00000249,0x00000049,0x00000009},
392 {0x00000000,0x00000000,0x00001249,0x00000249,
393 0x0000124a,0x0000124a,0x0000024a,0x00000049},
394 {0x00000000,0x00000000,0x00000000,0x00000000,
395 0x00000000,0x00000000,0x00000000,0x00000000}
396 }
397 },
398 { /* version 1 */
399 { /* version 1, passes 0 */
400 {0x00000000,0x00000000,0x00000000,0x00000000,
401 0x00000000,0x00000000,0x00000000,0x00000001},
402 {0x00000000,0x00000000,0x00000001,0x00000001,
403 0x00000001,0x00000009,0x00000009,0x00000009},
404 {0x00000000,0x00000000,0x00000009,0x00000009,
405 0x00000009,0x00000009,0x00000009,0x00000009},
406 {0x00000000,0x00000000,0x00000009,0x00000009,
407 0x00000009,0x00000049,0x00000049,0x00000049},
408 {0x00000000,0x00000000,0x00000009,0x00000049,
409 0x00000049,0x00000049,0x00000049,0x00000049},
410 {0x00000000,0x00000000,0x00000049,0x00000049,
411 0x00000049,0x00000249,0x0000024a,0x0000024a},
412 {0x00000000,0x00000000,0x00000049,0x00000049,
413 0x00000249,0x00000249,0x0000024a,0x0000024a},
414 {0x00000000,0x00000000,0x00000049,0x00000249,
415 0x00000249,0x00000249,0x0000024a,0x00001252},
416 {0x00000000,0x00000000,0x00000049,0x00000249,
417 0x00000249,0x0000124a,0x00001252,0x00001252},
418 {0x00000000,0x00000000,0x00000049,0x00000249,
419 0x0000124a,0x0000124a,0x00001252,0x00001252},
420 {0x00000000,0x00000000,0x00000249,0x00000249,
421 0x0000124a,0x0000124a,0x00009292,0x00009292},
422 {0x00000000,0x00000000,0x00000249,0x00001249,
423 0x0000124a,0x00009252,0x00009292,0x00009292},
424 {0x00000000,0x00000000,0x00000249,0x00001249,
425 0x00009252,0x00009252,0x00009292,0x00009292},
426 {0x00000000,0x00000000,0x00000249,0x0000924a,
427 0x00009292,0x00009493,0x00009493,0x00009493},
428 {0x00000000,0x00000000,0x00001249,0x00009252,
429 0x00009492,0x0000a49b,0x0000a49b,0x0000a49b},
430 {0x00000000,0x00000000,0x00000000,0x00000000,
431 0x00000000,0x00000000,0x00000000,0x00000000}
432 },
433 { /* version 1, passes 1 */
434 {0x00000000,0x00000000,0x00000000,0x00000000,
435 0x00000000,0x00000000,0x00000000,0x00000000},
436 {0x00000000,0x00000000,0x00000009,0x00000009,
437 0x00000009,0x00000001,0x00000001,0x00000000},
438 {0x00000000,0x00000000,0x00000009,0x00000009,
439 0x00000009,0x00000009,0x00000001,0x00000000},
440 {0x00000000,0x00000000,0x00000049,0x00000049,
441 0x00000049,0x00000009,0x00000001,0x00000000},
442 {0x00000000,0x00000000,0x00000049,0x00000049,
443 0x00000049,0x00000049,0x00000001,0x00000001},
444 {0x00000000,0x00000000,0x00000049,0x00000049,
445 0x00000049,0x00000049,0x00000009,0x00000001},
446 {0x00000000,0x00000000,0x00000249,0x00000049,
447 0x00000049,0x00000249,0x00000009,0x00000001},
448 {0x00000000,0x00000000,0x00000249,0x00000049,
449 0x00000249,0x00000249,0x00000009,0x00000009},
450 {0x00000000,0x00000000,0x00000249,0x00000249,
451 0x00000249,0x00000249,0x00000049,0x00000009},
452 {0x00000000,0x00000000,0x00000249,0x00000249,
453 0x00000249,0x0000124a,0x00000049,0x00000009},
454 {0x00000000,0x00000000,0x00000249,0x00000249,
455 0x00000249,0x0000124a,0x00000049,0x00000009},
456 {0x00000000,0x00000000,0x00000249,0x00000249,
457 0x00000249,0x0000124a,0x0000024a,0x00000049},
458 {0x00000000,0x00000000,0x00000249,0x00000249,
459 0x0000124a,0x0000124a,0x0000024a,0x00000049},
460 {0x00000000,0x00000000,0x00000249,0x00000249,
461 0x0000124a,0x0000124a,0x0000024a,0x00000049},
462 {0x00000000,0x00000000,0x00001249,0x00001249,
463 0x00009252,0x00009252,0x00001252,0x0000024a},
464 {0x00000000,0x00000000,0x00000000,0x00000000,
465 0x00000000,0x00000000,0x00000000,0x00000000}
466 }
467 },
468 { /* version 2 */
469 { /* version 2, passes 0 */
470 {0x00000000,0x00000000,0x00000000,0x00000000,
471 0x00000000,0x00000000,0x00000000,0x00000001},
472 {0x00000000,0x00000000,0x00000009,0x00000009,
473 0x00000009,0x00000009,0x00000009,0x00000009},
474 {0x00000000,0x00000000,0x00000049,0x00000049,
475 0x00000049,0x00000049,0x00000049,0x00000049},
476 {0x00000000,0x00000000,0x00000049,0x00000049,
477 0x00000049,0x00000249,0x0000024a,0x0000024a},
478 {0x00000000,0x00000000,0x00000049,0x00000249,
479 0x00000249,0x00000249,0x0000024a,0x00001252},
480 {0x00000000,0x00000000,0x00000249,0x00000249,
481 0x00000249,0x0000124a,0x00001252,0x00001252},
482 {0x00000000,0x00000000,0x00000249,0x00000249,
483 0x0000124a,0x0000124a,0x00009292,0x00009292},
484 {0x00000000,0x00000000,0x00000249,0x00001249,
485 0x0000124a,0x00009252,0x00009292,0x00009292},
486 {0x00000000,0x00000000,0x00000249,0x00001249,
487 0x00009252,0x00009292,0x00009292,0x00009292},
488 {0x00000000,0x00000000,0x00000249,0x00001249,
489 0x00009252,0x00009292,0x00009493,0x00009493},
490 {0x00000000,0x00000000,0x00000249,0x0000924a,
491 0x00009252,0x00009493,0x00009493,0x00009493},
492 {0x00000000,0x00000000,0x00000249,0x0000924a,
493 0x00009292,0x00009493,0x00009493,0x00009493},
494 {0x00000000,0x00000000,0x00000249,0x00009252,
495 0x00009492,0x00009493,0x0000a49b,0x0000a49b},
496 {0x00000000,0x00000000,0x00001249,0x00009292,
497 0x00009492,0x000124db,0x000124db,0x000124db},
498 {0x00000000,0x00000000,0x0000924a,0x00009493,
499 0x0000a493,0x000126dc,0x000126dc,0x000126dc},
500 {0x00000000,0x00000000,0x00000000,0x00000000,
501 0x00000000,0x00000000,0x00000000,0x00000000}
502 },
503 { /* version 2, passes 1 */
504 {0x00000000,0x00000000,0x00000000,0x00000000,
505 0x00000000,0x00000000,0x00000000,0x00000000},
506 {0x00000000,0x00000000,0x00000049,0x00000009,
507 0x00000049,0x00000009,0x00000001,0x00000000},
508 {0x00000000,0x00000000,0x00000049,0x00000049,
509 0x00000049,0x00000049,0x00000049,0x00000000},
510 {0x00000000,0x00000000,0x00000249,0x00000049,
511 0x00000249,0x00000049,0x0000024a,0x00000001},
512 {0x00000000,0x00000000,0x00000249,0x00000249,
513 0x00000249,0x00000249,0x0000024a,0x00000001},
514 {0x00000000,0x00000000,0x00000249,0x00000249,
515 0x00000249,0x00000249,0x0000024a,0x00000001},
516 {0x00000000,0x00000000,0x00000249,0x00000249,
517 0x00000249,0x00000249,0x0000024a,0x00000009},
518 {0x00000000,0x00000000,0x00000249,0x00000249,
519 0x0000124a,0x0000124a,0x0000024a,0x00000009},
520 {0x00000000,0x00000000,0x00000249,0x00000249,
521 0x0000124a,0x0000124a,0x0000024a,0x00000009},
522 {0x00000000,0x00000000,0x00001249,0x00001249,
523 0x0000124a,0x00009252,0x00001252,0x00000049},
524 {0x00000000,0x00000000,0x00001249,0x00001249,
525 0x0000124a,0x00009292,0x00001252,0x00000049},
526 {0x00000000,0x00000000,0x00001249,0x00001249,
527 0x0000124a,0x00009292,0x00001252,0x00000049},
528 {0x00000000,0x00000000,0x00001249,0x00001249,
529 0x00009252,0x00009292,0x00001252,0x0000024a},
530 {0x00000000,0x00000000,0x00001249,0x00001249,
531 0x00009292,0x00009292,0x00001252,0x0000024a},
532 {0x00000000,0x00000000,0x0000924a,0x0000924a,
533 0x00009492,0x00009493,0x00009292,0x00001252},
534 {0x00000000,0x00000000,0x00000000,0x00000000,
535 0x00000000,0x00000000,0x00000000,0x00000000}
536 }
537 },
538 { /* version 3 */
539 { /* version 3, passes 0 */
540 {0x00000000,0x00000000,0x00000000,0x00000000,
541 0x00000000,0x00000000,0x00000000,0x00000001},
542 {0x00000000,0x00000000,0x00000049,0x00000049,
543 0x00000049,0x00000049,0x00000049,0x00000049},
544 {0x00000000,0x00000000,0x00000049,0x00000249,
545 0x00000249,0x00000249,0x00001252,0x0000024a},
546 {0x00000000,0x00000000,0x00000249,0x00000249,
547 0x00000249,0x0000124a,0x00001252,0x00001252},
548 {0x00000000,0x00000000,0x00000249,0x00000249,
549 0x0000124a,0x00009252,0x00009292,0x00009292},
550 {0x00000000,0x00000000,0x00000249,0x00001249,
551 0x0000124a,0x00009292,0x00009292,0x00009493},
552 {0x00000000,0x00000000,0x00000249,0x00001249,
553 0x00009252,0x00009292,0x00009493,0x00009493},
554 {0x00000000,0x00000000,0x00000249,0x00001249,
555 0x00009292,0x00009493,0x00009493,0x00009493},
556 {0x00000000,0x00000000,0x00000249,0x00009252,
557 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
558 {0x00000000,0x00000000,0x00001249,0x00009252,
559 0x00009292,0x0000a49b,0x0000a49b,0x0000a49b},
560 {0x00000000,0x00000000,0x00001249,0x00009252,
561 0x00009492,0x0000a49b,0x0000a49b,0x0000a49b},
562 {0x00000000,0x00000000,0x00001249,0x00009292,
563 0x00009492,0x0000a49b,0x000124db,0x000124db},
564 {0x00000000,0x00000000,0x00001249,0x00009292,
565 0x0000a493,0x0000a49b,0x000124db,0x000124db},
566 {0x00000000,0x00000000,0x00001249,0x00009493,
567 0x0001249b,0x000126dc,0x000136e4,0x000126dc},
568 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
569 0x000124db,0x000136e4,0x0001b725,0x000136e4},
570 {0x00000000,0x00000000,0x00000000,0x00000000,
571 0x00000000,0x00000000,0x00000000,0x00000000}
572 },
573 { /* version 3, passes 1 */
574 {0x00000000,0x00000000,0x00000000,0x00000000,
575 0x00000000,0x00000000,0x00000000,0x00000000},
576 {0x00000000,0x00000000,0x00000049,0x00000049,
577 0x00000049,0x00000049,0x00000001,0x00000000},
578 {0x00000000,0x00000000,0x00000249,0x00000249,
579 0x00000249,0x00000249,0x00000049,0x00000001},
580 {0x00000000,0x00000000,0x00000249,0x00000249,
581 0x00000249,0x0000124a,0x00001252,0x00000001},
582 {0x00000000,0x00000000,0x00000249,0x00000249,
583 0x0000124a,0x0000124a,0x00001252,0x00000009},
584 {0x00000000,0x00000000,0x00000249,0x00001249,
585 0x0000124a,0x00009252,0x00009292,0x00000009},
586 {0x00000000,0x00000000,0x00001249,0x00001249,
587 0x0000124a,0x00009252,0x00009292,0x00000049},
588 {0x00000000,0x00000000,0x00001249,0x00001249,
589 0x00009252,0x00009252,0x00009292,0x00000049},
590 {0x00000000,0x00000000,0x00001249,0x00001249,
591 0x00009252,0x00009493,0x00009292,0x0000024a},
592 {0x00000000,0x00000000,0x00001249,0x00001249,
593 0x00009252,0x00009493,0x00009292,0x0000024a},
594 {0x00000000,0x00000000,0x00001249,0x00001249,
595 0x00009252,0x00009493,0x00009493,0x00001252},
596 {0x00000000,0x00000000,0x00001249,0x0000924a,
597 0x00009292,0x00009493,0x00009493,0x00001252},
598 {0x00000000,0x00000000,0x00001249,0x0000924a,
599 0x00009492,0x00009493,0x00009493,0x00009292},
600 {0x00000000,0x00000000,0x00001249,0x00009252,
601 0x00009492,0x0000a49b,0x00009493,0x00009292},
602 {0x00000000,0x00000000,0x0000924a,0x00009292,
603 0x0000a493,0x000124db,0x0000a49b,0x00009493},
604 {0x00000000,0x00000000,0x00000000,0x00000000,
605 0x00000000,0x00000000,0x00000000,0x00000000}
606 }
607 },
608 { /* version 4 */
609 { /* version 4, passes 0 */
610 {0x00000000,0x00000000,0x00000049,0x00000049,
611 0x00000049,0x00000049,0x0000024a,0x0000024a},
612 {0x00000000,0x00000000,0x00000249,0x00000249,
613 0x00000249,0x0000124a,0x00001252,0x00009292},
614 {0x00000000,0x00000000,0x00000249,0x00000249,
615 0x0000124a,0x00009252,0x00009292,0x00009292},
616 {0x00000000,0x00000000,0x00000249,0x00001249,
617 0x0000124a,0x00009292,0x00009493,0x00009493},
618 {0x00000000,0x00000000,0x00000249,0x00001249,
619 0x00009252,0x00009493,0x00009493,0x0000a49b},
620 {0x00000000,0x00000000,0x00000249,0x0000924a,
621 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
622 {0x00000000,0x00000000,0x00001249,0x0000924a,
623 0x00009292,0x00009493,0x0000a49b,0x000124db},
624 {0x00000000,0x00000000,0x00001249,0x00009252,
625 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
626 {0x00000000,0x00000000,0x00001249,0x00009292,
627 0x00009492,0x000124db,0x000124db,0x000126dc},
628 {0x00000000,0x00000000,0x00001249,0x00009292,
629 0x0000a493,0x000124db,0x000126dc,0x000126dc},
630 {0x00000000,0x00000000,0x00001249,0x00009493,
631 0x0000a493,0x000124db,0x000126dc,0x000136e4},
632 {0x00000000,0x00000000,0x00001249,0x00009493,
633 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
634 {0x00000000,0x00000000,0x0000924a,0x00009493,
635 0x0001249b,0x000126dc,0x000136e4,0x000136e4},
636 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
637 0x000124db,0x000136e4,0x000136e4,0x0001b724},
638 {0x00000000,0x00000000,0x00009252,0x000124db,
639 0x000126dc,0x0001b724,0x0001b725,0x0001b925},
640 {0x00000000,0x00000000,0x00000000,0x00000000,
641 0x00000000,0x00000000,0x00000000,0x00000000}
642 },
643 { /* version 4, passes 1 */
644 {0x00000000,0x00000000,0x00000049,0x00000049,
645 0x00000049,0x00000049,0x00000049,0x00000049},
646 {0x00000000,0x00000000,0x00000249,0x00000249,
647 0x00000249,0x00000249,0x0000024a,0x00000049},
648 {0x00000000,0x00000000,0x00001249,0x00000249,
649 0x0000124a,0x0000124a,0x00001252,0x00000049},
650 {0x00000000,0x00000000,0x00001249,0x00001249,
651 0x0000124a,0x0000124a,0x00009292,0x0000024a},
652 {0x00000000,0x00000000,0x00001249,0x00001249,
653 0x00009252,0x00009292,0x00009292,0x0000024a},
654 {0x00000000,0x00000000,0x00001249,0x00001249,
655 0x00009252,0x00009292,0x0000a49b,0x0000024a},
656 {0x00000000,0x00000000,0x00001249,0x00001249,
657 0x00009292,0x00009493,0x0000a49b,0x00001252},
658 {0x00000000,0x00000000,0x00001249,0x00001249,
659 0x00009292,0x00009493,0x0000a49b,0x00001252},
660 {0x00000000,0x00000000,0x00001249,0x0000924a,
661 0x00009492,0x0000a49b,0x0000a49b,0x00001252},
662 {0x00000000,0x00000000,0x00001249,0x00009252,
663 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
664 {0x00000000,0x00000000,0x00001249,0x00009292,
665 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
666 {0x00000000,0x00000000,0x00001249,0x00009493,
667 0x0000a493,0x0000a49b,0x0000a49b,0x00009292},
668 {0x00000000,0x00000000,0x00001249,0x00009493,
669 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
670 {0x00000000,0x00000000,0x0000924a,0x00009493,
671 0x0000a493,0x000124db,0x0000a49b,0x00009493},
672 {0x00000000,0x00000000,0x00009252,0x0000a49b,
673 0x0001249b,0x000126dc,0x000124db,0x0000a49b},
674 {0x00000000,0x00000000,0x00000000,0x00000000,
675 0x00000000,0x00000000,0x00000000,0x00000000}
676 }
677 },
678 { /* version 5 */
679 { /* version 5, passes 0 */
680 {0x00000000,0x00000000,0x00000249,0x00000249,
681 0x00000249,0x0000124a,0x00001252,0x00009292},
682 {0x00000000,0x00000000,0x00000249,0x00001249,
683 0x0000124a,0x00009292,0x00009292,0x00009493},
684 {0x00000000,0x00000000,0x00000249,0x0000924a,
685 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
686 {0x00000000,0x00000000,0x00001249,0x0000924a,
687 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
688 {0x00000000,0x00000000,0x00001249,0x0000924a,
689 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
690 {0x00000000,0x00000000,0x00001249,0x00009292,
691 0x00009492,0x0000a49b,0x000124db,0x000124db},
692 {0x00000000,0x00000000,0x00001249,0x00009292,
693 0x0000a493,0x000124db,0x000124db,0x000126dc},
694 {0x00000000,0x00000000,0x00001249,0x00009493,
695 0x0000a493,0x000124db,0x000126dc,0x000126dc},
696 {0x00000000,0x00000000,0x00001249,0x00009493,
697 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
698 {0x00000000,0x00000000,0x00001249,0x00009493,
699 0x0001249b,0x000126dc,0x000136e4,0x000136e4},
700 {0x00000000,0x00000000,0x00001249,0x00009493,
701 0x0001249b,0x000126dc,0x000136e4,0x000136e4},
702 {0x00000000,0x00000000,0x0000924a,0x00009493,
703 0x0001249b,0x000126dc,0x0001b725,0x0001b724},
704 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
705 0x000124db,0x000126dc,0x0001b725,0x0001b724},
706 {0x00000000,0x00000000,0x00009292,0x0000a49b,
707 0x000126dc,0x000136e4,0x0001b92d,0x0001b925},
708 {0x00000000,0x00000000,0x00009492,0x000124db,
709 0x000136e4,0x0001b724,0x0001c96e,0x0001c92d},
710 {0x00000000,0x00000000,0x00000000,0x00000000,
711 0x00000000,0x00000000,0x00000000,0x00000000}
712 },
713 { /* version 5, passes 1 */
714 {0x00000000,0x00000000,0x00000249,0x00000249,
715 0x0000124a,0x00000249,0x0000024a,0x0000024a},
716 {0x00000000,0x00000000,0x00001249,0x00001249,
717 0x0000124a,0x0000124a,0x00001252,0x0000024a},
718 {0x00000000,0x00000000,0x00001249,0x00001249,
719 0x00009292,0x00009493,0x00009493,0x0000024a},
720 {0x00000000,0x00000000,0x00001249,0x00001249,
721 0x00009292,0x00009493,0x00009493,0x00001252},
722 {0x00000000,0x00000000,0x00001249,0x00001249,
723 0x00009292,0x00009493,0x0000a49b,0x00001252},
724 {0x00000000,0x00000000,0x00001249,0x0000924a,
725 0x00009492,0x00009493,0x000124db,0x00001252},
726 {0x00000000,0x00000000,0x00001249,0x00009292,
727 0x00009492,0x00009493,0x000124db,0x00009292},
728 {0x00000000,0x00000000,0x00001249,0x00009292,
729 0x00009492,0x0000a49b,0x000124db,0x00009292},
730 {0x00000000,0x00000000,0x00001249,0x00009493,
731 0x0000a493,0x0000a49b,0x000124db,0x00009292},
732 {0x00000000,0x00000000,0x00001249,0x00009493,
733 0x0000a493,0x000124db,0x000124db,0x00009493},
734 {0x00000000,0x00000000,0x0000924a,0x00009493,
735 0x0000a493,0x000124db,0x000124db,0x00009493},
736 {0x00000000,0x00000000,0x0000924a,0x00009493,
737 0x0000a493,0x000124db,0x000124db,0x00009493},
738 {0x00000000,0x00000000,0x0000924a,0x00009493,
739 0x0000a493,0x000124db,0x000124db,0x0000a49b},
740 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
741 0x000124db,0x000126dc,0x000124db,0x0000a49b},
742 {0x00000000,0x00000000,0x00009252,0x000124db,
743 0x000126dc,0x000136e4,0x000126dc,0x000124db},
744 {0x00000000,0x00000000,0x00000000,0x00000000,
745 0x00000000,0x00000000,0x00000000,0x00000000}
746 }
747 },
748 { /* version 6 */
749 { /* version 6, passes 0 */
750 {0x00000000,0x00000000,0x00000249,0x00000249,
751 0x0000124a,0x0000124a,0x00009292,0x00009292},
752 {0x00000000,0x00000000,0x00001249,0x00001249,
753 0x00009292,0x00009493,0x0000a49b,0x0000a49b},
754 {0x00000000,0x00000000,0x00001249,0x0000924a,
755 0x00009492,0x0000a49b,0x0000a49b,0x000124db},
756 {0x00000000,0x00000000,0x00001249,0x00009292,
757 0x00009492,0x000124db,0x000126dc,0x000126dc},
758 {0x00000000,0x00000000,0x00001249,0x00009493,
759 0x0000a493,0x000124db,0x000126dc,0x000126dc},
760 {0x00000000,0x00000000,0x00001249,0x00009493,
761 0x0000a493,0x000126dc,0x000136e4,0x000136e4},
762 {0x00000000,0x00000000,0x00001249,0x00009493,
763 0x0000a493,0x000126dc,0x000136e4,0x0001b724},
764 {0x00000000,0x00000000,0x00001249,0x00009493,
765 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
766 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
767 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
768 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
769 0x0001249b,0x000136e4,0x0001b725,0x0001b724},
770 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
771 0x000124db,0x000136e4,0x0001b725,0x0001b925},
772 {0x00000000,0x00000000,0x00009292,0x0000a49b,
773 0x000126dc,0x000136e4,0x0001b92d,0x0001b925},
774 {0x00000000,0x00000000,0x00009292,0x0000a49b,
775 0x000126dc,0x0001b724,0x0001b92d,0x0001c92d},
776 {0x00000000,0x00000000,0x00009492,0x000124db,
777 0x000126dc,0x0001b724,0x0001c96e,0x0001c92d},
778 {0x00000000,0x00000000,0x0000a492,0x000126db,
779 0x000136e4,0x0001b925,0x00025bb6,0x00024b77},
780 {0x00000000,0x00000000,0x00000000,0x00000000,
781 0x00000000,0x00000000,0x00000000,0x00000000}
782 },
783 { /* version 6, passes 1 */
784 {0x00000000,0x00000000,0x00001249,0x00000249,
785 0x0000124a,0x0000124a,0x00001252,0x00001252},
786 {0x00000000,0x00000000,0x00001249,0x00001249,
787 0x00009252,0x00009292,0x00009292,0x00001252},
788 {0x00000000,0x00000000,0x00001249,0x0000924a,
789 0x00009492,0x00009493,0x0000a49b,0x00001252},
790 {0x00000000,0x00000000,0x00001249,0x00009252,
791 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
792 {0x00000000,0x00000000,0x00001249,0x00009292,
793 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
794 {0x00000000,0x00000000,0x00001249,0x00009493,
795 0x0000a493,0x0000a49b,0x000126dc,0x00009292},
796 {0x00000000,0x00000000,0x0000924a,0x00009493,
797 0x0000a493,0x0000a49b,0x000126dc,0x00009493},
798 {0x00000000,0x00000000,0x0000924a,0x00009493,
799 0x0000a493,0x0000a49b,0x000126dc,0x00009493},
800 {0x00000000,0x00000000,0x0000924a,0x00009493,
801 0x0000a493,0x000124db,0x000126dc,0x00009493},
802 {0x00000000,0x00000000,0x0000924a,0x00009493,
803 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
804 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
805 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
806 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
807 0x0001249b,0x000126dc,0x000126dc,0x0000a49b},
808 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
809 0x000124db,0x000136e4,0x000126dc,0x000124db},
810 {0x00000000,0x00000000,0x00009492,0x0000a49b,
811 0x000136e4,0x000136e4,0x000126dc,0x000124db},
812 {0x00000000,0x00000000,0x0000a492,0x000124db,
813 0x0001b724,0x0001b724,0x000136e4,0x000126dc},
814 {0x00000000,0x00000000,0x00000000,0x00000000,
815 0x00000000,0x00000000,0x00000000,0x00000000}
816 }
817 },
818 { /* version 7 */
819 { /* version 7, passes 0 */
820 {0x00000000,0x00000000,0x00001249,0x00001249,
821 0x00009292,0x00009493,0x0000a49b,0x000124db},
822 {0x00000000,0x00000000,0x00001249,0x00009292,
823 0x0000a493,0x0000a49b,0x000124db,0x000126dc},
824 {0x00000000,0x00000000,0x00001249,0x00009493,
825 0x0000a493,0x000124db,0x000126dc,0x000136e4},
826 {0x00000000,0x00000000,0x00001249,0x00009493,
827 0x0000a493,0x000124db,0x000136e4,0x000136e4},
828 {0x00000000,0x00000000,0x00001249,0x00009493,
829 0x0001249b,0x000126dc,0x000136e4,0x000136e4},
830 {0x00000000,0x00000000,0x00001249,0x0000a49b,
831 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
832 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
833 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
834 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
835 0x000124db,0x000136e4,0x0001b725,0x0001b724},
836 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
837 0x000126dc,0x000136e4,0x0001b725,0x0001b925},
838 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
839 0x000126dc,0x0001b724,0x0001b92d,0x0001b925},
840 {0x00000000,0x00000000,0x00009292,0x0000a49b,
841 0x000126dc,0x0001b724,0x0001c96e,0x0001c92d},
842 {0x00000000,0x00000000,0x00009292,0x000124db,
843 0x000126dc,0x0001b724,0x0001c96e,0x0001c92d},
844 {0x00000000,0x00000000,0x00009492,0x000124db,
845 0x000136e4,0x0001b724,0x0001c96e,0x0002496e},
846 {0x00000000,0x00000000,0x00009492,0x000126db,
847 0x000136e4,0x0001b925,0x0001c96e,0x0002496e},
848 {0x00000000,0x00000000,0x0000a492,0x000136db,
849 0x0001b724,0x0002496d,0x00025bb6,0x00025bbf},
850 {0x00000000,0x00000000,0x00000000,0x00000000,
851 0x00000000,0x00000000,0x00000000,0x00000000}
852 },
853 { /* version 7, passes 1 */
854 {0x00000000,0x00000000,0x00001249,0x00001249,
855 0x00009252,0x00009292,0x00009292,0x00009292},
856 {0x00000000,0x00000000,0x00001249,0x0000924a,
857 0x00009492,0x00009493,0x00009493,0x00009292},
858 {0x00000000,0x00000000,0x00001249,0x00009493,
859 0x0000a493,0x0000a49b,0x0000a49b,0x00009292},
860 {0x00000000,0x00000000,0x0000924a,0x00009493,
861 0x0000a493,0x0000a49b,0x000124db,0x00009493},
862 {0x00000000,0x00000000,0x0000924a,0x00009493,
863 0x0000a493,0x000124db,0x000124db,0x00009493},
864 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
865 0x0000a493,0x000124db,0x000136e4,0x00009493},
866 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
867 0x0000a493,0x000124db,0x000136e4,0x0000a49b},
868 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
869 0x0001249b,0x000124db,0x000136e4,0x0000a49b},
870 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
871 0x0001249b,0x000126dc,0x000136e4,0x0000a49b},
872 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
873 0x0001249b,0x000126dc,0x000136e4,0x000124db},
874 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
875 0x000126dc,0x000136e4,0x000136e4,0x000124db},
876 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
877 0x000126dc,0x000136e4,0x000136e4,0x000124db},
878 {0x00000000,0x00000000,0x0000924a,0x000124db,
879 0x000136e4,0x000136e4,0x000136e4,0x000126dc},
880 {0x00000000,0x00000000,0x0000a492,0x000124db,
881 0x000136e4,0x0001b724,0x000136e4,0x000126dc},
882 {0x00000000,0x00000000,0x00012492,0x000126db,
883 0x0001b724,0x0001b925,0x0001b725,0x000136e4},
884 {0x00000000,0x00000000,0x00000000,0x00000000,
885 0x00000000,0x00000000,0x00000000,0x00000000}
886 }
887 },
888 { /* version 8 */
889 { /* version 8, passes 0 */
890 {0x00000000,0x00000000,0x00001249,0x00001249,
891 0x00009292,0x00009493,0x0000a49b,0x000124db},
892 {0x00000000,0x00000000,0x00001249,0x00009292,
893 0x0000a493,0x000124db,0x000126dc,0x000126dc},
894 {0x00000000,0x00000000,0x00001249,0x00009493,
895 0x0000a493,0x000124db,0x000126dc,0x000136e4},
896 {0x00000000,0x00000000,0x00001249,0x0000a49b,
897 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
898 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
899 0x0001249b,0x000126dc,0x000136e4,0x0001b724},
900 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
901 0x000124db,0x000136e4,0x0001b725,0x0001b724},
902 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
903 0x000126dc,0x000136e4,0x0001b725,0x0001b925},
904 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
905 0x000126dc,0x0001b724,0x0001b92d,0x0001c92d},
906 {0x00000000,0x00000000,0x00009252,0x000124db,
907 0x000126dc,0x0001b724,0x0001b92d,0x0001c92d},
908 {0x00000000,0x00000000,0x00009292,0x000124db,
909 0x000126dc,0x0001b925,0x0001c96e,0x0001c92d},
910 {0x00000000,0x00000000,0x00009492,0x000124db,
911 0x000136e4,0x0001b925,0x0001c96e,0x0001c92d},
912 {0x00000000,0x00000000,0x00009492,0x000124db,
913 0x000136e4,0x0001b925,0x00024b76,0x00024b77},
914 {0x00000000,0x00000000,0x00009492,0x000126db,
915 0x000136e4,0x0001b925,0x00024b76,0x00025bbf},
916 {0x00000000,0x00000000,0x0000a492,0x000126db,
917 0x000136e4,0x0001c92d,0x00024b76,0x00025bbf},
918 {0x00000000,0x00000000,0x00012492,0x000136db,
919 0x0001b724,0x00024b6d,0x0002ddb6,0x0002efff},
920 {0x00000000,0x00000000,0x00000000,0x00000000,
921 0x00000000,0x00000000,0x00000000,0x00000000}
922 },
923 { /* version 8, passes 1 */
924 {0x00000000,0x00000000,0x00001249,0x00001249,
925 0x00009252,0x00009493,0x00009493,0x00009493},
926 {0x00000000,0x00000000,0x00001249,0x00009292,
927 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
928 {0x00000000,0x00000000,0x0000924a,0x00009493,
929 0x0000a493,0x0000a49b,0x000124db,0x00009493},
930 {0x00000000,0x00000000,0x0000924a,0x00009493,
931 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
932 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
933 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
934 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
935 0x0000a493,0x000124db,0x000136e4,0x000124db},
936 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
937 0x0001249b,0x000126dc,0x000136e4,0x000124db},
938 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
939 0x000126dc,0x000126dc,0x000136e4,0x000126dc},
940 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
941 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
942 {0x00000000,0x00000000,0x0000924a,0x000124db,
943 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
944 {0x00000000,0x00000000,0x0000924a,0x000124db,
945 0x000126dc,0x000136e4,0x000136e4,0x000136e4},
946 {0x00000000,0x00000000,0x00009292,0x000124db,
947 0x000136e4,0x0001b724,0x0001b725,0x000136e4},
948 {0x00000000,0x00000000,0x00009492,0x000126db,
949 0x000136e4,0x0001b925,0x0001b725,0x0001b724},
950 {0x00000000,0x00000000,0x00009492,0x000126db,
951 0x000136e4,0x0001b925,0x0001b725,0x0001b724},
952 {0x00000000,0x00000000,0x0000a492,0x000136db,
953 0x0001b724,0x0002496d,0x0001b92d,0x0001b925},
954 {0x00000000,0x00000000,0x00000000,0x00000000,
955 0x00000000,0x00000000,0x00000000,0x00000000}
956 }
957 },
958 { /* version 9 */
959 { /* version 9, passes 0 */
960 {0x00000000,0x00000000,0x00000049,0x00000049,
961 0x00000049,0x00000049,0x00000049,0x00000049},
962 {0x00000000,0x00000000,0x00000249,0x00000049,
963 0x00000249,0x00000249,0x0000024a,0x00000049},
964 {0x00000000,0x00000000,0x00000249,0x00000249,
965 0x0000124a,0x00009252,0x00001252,0x0000024a},
966 {0x00000000,0x00000000,0x00001249,0x00001249,
967 0x00009252,0x00009292,0x00009493,0x00001252},
968 {0x00000000,0x00000000,0x00001249,0x0000924a,
969 0x00009292,0x00009493,0x00009493,0x00001252},
970 {0x00000000,0x00000000,0x00001249,0x00009292,
971 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
972 {0x00000000,0x00000000,0x00001249,0x00009493,
973 0x0000a493,0x000124db,0x000124db,0x00009493},
974 {0x00000000,0x00000000,0x0000924a,0x00009493,
975 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
976 {0x00000000,0x00000000,0x0000924a,0x00009493,
977 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
978 {0x00000000,0x00000000,0x0000924a,0x00009493,
979 0x0001249b,0x000126dc,0x000126dc,0x000124db},
980 {0x00000000,0x00000000,0x00009252,0x00009493,
981 0x000124db,0x000136e4,0x000136e4,0x000126dc},
982 {0x00000000,0x00000000,0x00009252,0x0000a49b,
983 0x000124db,0x000136e4,0x000136e4,0x000126dc},
984 {0x00000000,0x00000000,0x00009292,0x0000a49b,
985 0x000126dc,0x000136e4,0x000136e4,0x000136e4},
986 {0x00000000,0x00000000,0x00009492,0x0000a49b,
987 0x000126dc,0x0001b724,0x0001b725,0x0001b724},
988 {0x00000000,0x00000000,0x0000a492,0x000124db,
989 0x000136e4,0x0001b925,0x0001b92d,0x0001b925},
990 {0x00000000,0x00000000,0x00000000,0x00000000,
991 0x00000000,0x00000000,0x00000000,0x00000000}
992 },
993 { /* version 9, passes 1 */
994 {0x00000000,0x00000000,0x00000249,0x00000049,
995 0x00000009,0x00000009,0x00000009,0x00000009},
996 {0x00000000,0x00000000,0x00000249,0x00000249,
997 0x00000049,0x00000049,0x00000009,0x00000009},
998 {0x00000000,0x00000000,0x00001249,0x00001249,
999 0x0000124a,0x00000249,0x00000049,0x00000049},
1000 {0x00000000,0x00000000,0x00001249,0x00001249,
1001 0x0000124a,0x0000124a,0x00000049,0x00000049},
1002 {0x00000000,0x00000000,0x00001249,0x00001249,
1003 0x00009252,0x0000124a,0x0000024a,0x0000024a},
1004 {0x00000000,0x00000000,0x00001249,0x0000924a,
1005 0x00009252,0x0000124a,0x0000024a,0x0000024a},
1006 {0x00000000,0x00000000,0x00001249,0x00009292,
1007 0x00009492,0x00009252,0x00001252,0x00001252},
1008 {0x00000000,0x00000000,0x00001249,0x00009493,
1009 0x0000a493,0x00009292,0x00009292,0x00001252},
1010 {0x00000000,0x00000000,0x0000924a,0x00009493,
1011 0x0000a493,0x00009292,0x00009292,0x00009292},
1012 {0x00000000,0x00000000,0x0000924a,0x00009493,
1013 0x0000a493,0x00009493,0x00009493,0x00009292},
1014 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1015 0x0000a493,0x0000a49b,0x00009493,0x00009493},
1016 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1017 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
1018 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1019 0x0001249b,0x000124db,0x0000a49b,0x0000a49b},
1020 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1021 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1022 {0x00000000,0x00000000,0x00009252,0x000124db,
1023 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1024 {0x00000000,0x00000000,0x00000000,0x00000000,
1025 0x00000000,0x00000000,0x00000000,0x00000000}
1026 }
1027 },
1028 { /* version 10 */
1029 { /* version 10, passes 0 */
1030 {0x00000000,0x00000000,0x00000249,0x00000249,
1031 0x00000249,0x00000249,0x0000024a,0x0000024a},
1032 {0x00000000,0x00000000,0x00000249,0x00001249,
1033 0x00009252,0x00009292,0x00009292,0x0000024a},
1034 {0x00000000,0x00000000,0x00001249,0x00001249,
1035 0x00009252,0x00009292,0x00009292,0x00001252},
1036 {0x00000000,0x00000000,0x00001249,0x0000924a,
1037 0x00009492,0x00009493,0x0000a49b,0x00009292},
1038 {0x00000000,0x00000000,0x00001249,0x00009292,
1039 0x00009492,0x000124db,0x000124db,0x00009292},
1040 {0x00000000,0x00000000,0x00001249,0x00009493,
1041 0x0000a493,0x000124db,0x000124db,0x00009493},
1042 {0x00000000,0x00000000,0x00001249,0x00009493,
1043 0x0000a493,0x000124db,0x000126dc,0x0000a49b},
1044 {0x00000000,0x00000000,0x0000924a,0x00009493,
1045 0x0000a493,0x000124db,0x000126dc,0x000124db},
1046 {0x00000000,0x00000000,0x0000924a,0x00009493,
1047 0x0001249b,0x000126dc,0x000126dc,0x000124db},
1048 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1049 0x000124db,0x000126dc,0x000136e4,0x000126dc},
1050 {0x00000000,0x00000000,0x00009252,0x0000a49b,
1051 0x000124db,0x000136e4,0x000136e4,0x000136e4},
1052 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1053 0x000126dc,0x000136e4,0x000136e4,0x000136e4},
1054 {0x00000000,0x00000000,0x00009492,0x0000a49b,
1055 0x000126dc,0x0001b724,0x0001b92d,0x0001b724},
1056 {0x00000000,0x00000000,0x00009492,0x000124db,
1057 0x000126dc,0x0001b925,0x0001b92d,0x0001b925},
1058 {0x00000000,0x00000000,0x0000a492,0x000126db,
1059 0x000136e4,0x0002496d,0x0001c96e,0x0001c92d},
1060 {0x00000000,0x00000000,0x00000000,0x00000000,
1061 0x00000000,0x00000000,0x00000000,0x00000000}
1062 },
1063 { /* version 10, passes 1 */
1064 {0x00000000,0x00000000,0x00000249,0x00000249,
1065 0x00000049,0x00000049,0x00000049,0x00000049},
1066 {0x00000000,0x00000000,0x00001249,0x00001249,
1067 0x0000124a,0x00000249,0x00000049,0x00000049},
1068 {0x00000000,0x00000000,0x00001249,0x00001249,
1069 0x0000124a,0x00009252,0x0000024a,0x00000049},
1070 {0x00000000,0x00000000,0x00001249,0x00001249,
1071 0x00009252,0x00009493,0x0000024a,0x0000024a},
1072 {0x00000000,0x00000000,0x00001249,0x00009252,
1073 0x00009492,0x00009493,0x00001252,0x0000024a},
1074 {0x00000000,0x00000000,0x00001249,0x00009292,
1075 0x00009492,0x00009493,0x00001252,0x00001252},
1076 {0x00000000,0x00000000,0x0000924a,0x00009493,
1077 0x00009492,0x00009493,0x00009292,0x00001252},
1078 {0x00000000,0x00000000,0x0000924a,0x00009493,
1079 0x0000a493,0x00009493,0x00009292,0x00009292},
1080 {0x00000000,0x00000000,0x0000924a,0x00009493,
1081 0x0000a493,0x0000a49b,0x00009493,0x00009292},
1082 {0x00000000,0x00000000,0x0000924a,0x00009493,
1083 0x0000a493,0x0000a49b,0x00009493,0x00009292},
1084 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1085 0x0000a493,0x000124db,0x0000a49b,0x00009493},
1086 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1087 0x0000a493,0x000124db,0x0000a49b,0x00009493},
1088 {0x00000000,0x00000000,0x0000924a,0x000124db,
1089 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1090 {0x00000000,0x00000000,0x0000924a,0x000124db,
1091 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1092 {0x00000000,0x00000000,0x00009252,0x000126db,
1093 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1094 {0x00000000,0x00000000,0x00000000,0x00000000,
1095 0x00000000,0x00000000,0x00000000,0x00000000}
1096 }
1097 },
1098 { /* version 11 */
1099 { /* version 11, passes 0 */
1100 {0x00000000,0x00000000,0x00000249,0x00000249,
1101 0x00000249,0x00000249,0x00001252,0x00001252},
1102 {0x00000000,0x00000000,0x00001249,0x00001249,
1103 0x00009252,0x00009292,0x00009292,0x00001252},
1104 {0x00000000,0x00000000,0x00001249,0x0000924a,
1105 0x00009492,0x0000a49b,0x0000a49b,0x00009292},
1106 {0x00000000,0x00000000,0x00001249,0x00009493,
1107 0x0000a493,0x0000a49b,0x000124db,0x00009493},
1108 {0x00000000,0x00000000,0x00001249,0x00009493,
1109 0x0000a493,0x000124db,0x000126dc,0x00009493},
1110 {0x00000000,0x00000000,0x0000924a,0x00009493,
1111 0x0000a493,0x000126dc,0x000126dc,0x0000a49b},
1112 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1113 0x0001249b,0x000126dc,0x000136e4,0x000124db},
1114 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1115 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
1116 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1117 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
1118 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1119 0x000126dc,0x0001b724,0x0001b725,0x000136e4},
1120 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1121 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
1122 {0x00000000,0x00000000,0x00009492,0x0000a49b,
1123 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
1124 {0x00000000,0x00000000,0x00009492,0x000124db,
1125 0x000136e4,0x0001b925,0x0001c96e,0x0001b925},
1126 {0x00000000,0x00000000,0x00009492,0x000124db,
1127 0x0001b724,0x0001b925,0x0001c96e,0x0001c92d},
1128 {0x00000000,0x00000000,0x0000a492,0x000126db,
1129 0x0001c924,0x0002496d,0x00025bb6,0x00024b77},
1130 {0x00000000,0x00000000,0x00000000,0x00000000,
1131 0x00000000,0x00000000,0x00000000,0x00000000}
1132 },
1133 { /* version 11, passes 1 */
1134 {0x00000000,0x00000000,0x00001249,0x00000249,
1135 0x00000249,0x00000249,0x0000024a,0x0000024a},
1136 {0x00000000,0x00000000,0x00001249,0x00001249,
1137 0x0000124a,0x0000124a,0x0000024a,0x0000024a},
1138 {0x00000000,0x00000000,0x00001249,0x0000924a,
1139 0x00009252,0x00009252,0x0000024a,0x0000024a},
1140 {0x00000000,0x00000000,0x00001249,0x00009292,
1141 0x00009492,0x0000a49b,0x00001252,0x00001252},
1142 {0x00000000,0x00000000,0x0000924a,0x00009493,
1143 0x0000a493,0x0000a49b,0x00001252,0x00001252},
1144 {0x00000000,0x00000000,0x0000924a,0x00009493,
1145 0x0000a493,0x0000a49b,0x00009292,0x00001252},
1146 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1147 0x0000a493,0x0000a49b,0x00009292,0x00009292},
1148 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1149 0x0000a493,0x0000a49b,0x00009493,0x00009292},
1150 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1151 0x0001249b,0x000124db,0x00009493,0x00009292},
1152 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1153 0x0001249b,0x000124db,0x00009493,0x00009493},
1154 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1155 0x000124db,0x000124db,0x0000a49b,0x00009493},
1156 {0x00000000,0x00000000,0x0000924a,0x000124db,
1157 0x000126dc,0x000126dc,0x0000a49b,0x00009493},
1158 {0x00000000,0x00000000,0x0000924a,0x000124db,
1159 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1160 {0x00000000,0x00000000,0x00009292,0x000124db,
1161 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1162 {0x00000000,0x00000000,0x00009492,0x000126db,
1163 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1164 {0x00000000,0x00000000,0x00000000,0x00000000,
1165 0x00000000,0x00000000,0x00000000,0x00000000}
1166 }
1167 },
1168 { /* version 12 */
1169 { /* version 12, passes 0 */
1170 {0x00000000,0x00000000,0x00001249,0x00001249,
1171 0x00009252,0x00009292,0x00009493,0x00009493},
1172 {0x00000000,0x00000000,0x00001249,0x00009292,
1173 0x0000a493,0x0000a49b,0x0000a49b,0x00009493},
1174 {0x00000000,0x00000000,0x00001249,0x00009493,
1175 0x0000a493,0x000124db,0x000124db,0x0000a49b},
1176 {0x00000000,0x00000000,0x0000924a,0x00009493,
1177 0x0000a493,0x000126dc,0x000126dc,0x0000a49b},
1178 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1179 0x0001249b,0x000126dc,0x000136e4,0x000124db},
1180 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1181 0x000126dc,0x000136e4,0x000136e4,0x000126dc},
1182 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1183 0x000126dc,0x0001b724,0x0001b725,0x000126dc},
1184 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1185 0x000136e4,0x0001b724,0x0001b92d,0x000136e4},
1186 {0x00000000,0x00000000,0x00009492,0x0000a49b,
1187 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
1188 {0x00000000,0x00000000,0x00009492,0x000124db,
1189 0x000136e4,0x0001b724,0x0001b92d,0x0001b724},
1190 {0x00000000,0x00000000,0x00009492,0x000124db,
1191 0x000136e4,0x0001b925,0x0001b92d,0x0001b925},
1192 {0x00000000,0x00000000,0x00009492,0x000124db,
1193 0x0001b724,0x0001b925,0x0001c96e,0x0001c92d},
1194 {0x00000000,0x00000000,0x0000a492,0x000124db,
1195 0x0001b724,0x0001c92d,0x0001c96e,0x0001c92d},
1196 {0x00000000,0x00000000,0x0000a492,0x000124db,
1197 0x0001b724,0x0001c92d,0x00024b76,0x0002496e},
1198 {0x00000000,0x00000000,0x00012492,0x000126db,
1199 0x0001c924,0x00024b6d,0x0002ddb6,0x00025bbf},
1200 {0x00000000,0x00000000,0x00000000,0x00000000,
1201 0x00000000,0x00000000,0x00000000,0x00000000}
1202 },
1203 { /* version 12, passes 1 */
1204 {0x00000000,0x00000000,0x00001249,0x00001249,
1205 0x0000124a,0x0000124a,0x00001252,0x00001252},
1206 {0x00000000,0x00000000,0x00001249,0x00009292,
1207 0x00009492,0x00009252,0x00001252,0x00001252},
1208 {0x00000000,0x00000000,0x0000924a,0x00009493,
1209 0x0000a493,0x00009292,0x00001252,0x00001252},
1210 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1211 0x0000a493,0x0000a49b,0x00009292,0x00009292},
1212 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1213 0x0000a493,0x0000a49b,0x00009292,0x00009292},
1214 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1215 0x0001249b,0x0000a49b,0x00009493,0x00009292},
1216 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1217 0x000124db,0x000124db,0x00009493,0x00009493},
1218 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1219 0x000124db,0x000124db,0x0000a49b,0x00009493},
1220 {0x00000000,0x00000000,0x0000924a,0x000124db,
1221 0x000126dc,0x000124db,0x0000a49b,0x00009493},
1222 {0x00000000,0x00000000,0x0000924a,0x000124db,
1223 0x000126dc,0x000126dc,0x0000a49b,0x0000a49b},
1224 {0x00000000,0x00000000,0x0000924a,0x000124db,
1225 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1226 {0x00000000,0x00000000,0x00009492,0x000126db,
1227 0x000136e4,0x000126dc,0x000124db,0x0000a49b},
1228 {0x00000000,0x00000000,0x00009492,0x000126db,
1229 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1230 {0x00000000,0x00000000,0x00009492,0x000126db,
1231 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1232 {0x00000000,0x00000000,0x0000a492,0x000136db,
1233 0x0001c924,0x0001b724,0x000136e4,0x000126dc},
1234 {0x00000000,0x00000000,0x00000000,0x00000000,
1235 0x00000000,0x00000000,0x00000000,0x00000000}
1236 }
1237 },
1238 { /* version 13 */
1239 { /* version 13, passes 0 */
1240 {0x00000000,0x00000000,0x00001249,0x00001249,
1241 0x00009252,0x00009292,0x00009493,0x00009493},
1242 {0x00000000,0x00000000,0x00001249,0x00009493,
1243 0x0000a493,0x000124db,0x000126dc,0x00009493},
1244 {0x00000000,0x00000000,0x00001249,0x0000a49b,
1245 0x0001249b,0x000126dc,0x000126dc,0x0000a49b},
1246 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1247 0x0001249b,0x000126dc,0x000136e4,0x0000a49b},
1248 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1249 0x000126dc,0x000136e4,0x0001b725,0x000124db},
1250 {0x00000000,0x00000000,0x00009292,0x0000a49b,
1251 0x000136e4,0x0001b724,0x0001b725,0x000126dc},
1252 {0x00000000,0x00000000,0x00009292,0x000124db,
1253 0x000136e4,0x0001b724,0x0001b725,0x000126dc},
1254 {0x00000000,0x00000000,0x00009492,0x000124db,
1255 0x000136e4,0x0001b724,0x0001c96e,0x000136e4},
1256 {0x00000000,0x00000000,0x00009492,0x000124db,
1257 0x000136e4,0x0001c92d,0x0001c96e,0x0001b724},
1258 {0x00000000,0x00000000,0x0000a492,0x000124db,
1259 0x000136e4,0x0001c92d,0x0001c96e,0x0001b724},
1260 {0x00000000,0x00000000,0x0000a492,0x000124db,
1261 0x0001b724,0x0001c92d,0x0001c96e,0x0001b925},
1262 {0x00000000,0x00000000,0x0000a492,0x000126db,
1263 0x0001b724,0x0001c92d,0x00024b76,0x0001c92d},
1264 {0x00000000,0x00000000,0x0000a492,0x000126db,
1265 0x0001b924,0x0001c92d,0x00024b76,0x0001c92d},
1266 {0x00000000,0x00000000,0x0000a492,0x000126db,
1267 0x0001b924,0x0001c92d,0x00024b76,0x0002496e},
1268 {0x00000000,0x00000000,0x00012492,0x000136db,
1269 0x00024924,0x00024b6d,0x0002ddb6,0x00025bbf},
1270 {0x00000000,0x00000000,0x00000000,0x00000000,
1271 0x00000000,0x00000000,0x00000000,0x00000000}
1272 },
1273 { /* version 13, passes 1 */
1274 {0x00000000,0x00000000,0x00001249,0x00001249,
1275 0x0000124a,0x0000124a,0x00001252,0x00001252},
1276 {0x00000000,0x00000000,0x0000924a,0x00009493,
1277 0x00009492,0x00009292,0x00001252,0x00001252},
1278 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1279 0x0000a493,0x0000a49b,0x00001252,0x00001252},
1280 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1281 0x0000a493,0x0000a49b,0x00009292,0x00009292},
1282 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1283 0x0000a493,0x0000a49b,0x00009292,0x00009292},
1284 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1285 0x000126dc,0x0000a49b,0x00009493,0x00009292},
1286 {0x00000000,0x00000000,0x0000924a,0x000124db,
1287 0x000126dc,0x000124db,0x00009493,0x00009493},
1288 {0x00000000,0x00000000,0x0000924a,0x000124db,
1289 0x000136e4,0x000124db,0x0000a49b,0x00009493},
1290 {0x00000000,0x00000000,0x0000924a,0x000136db,
1291 0x0001b724,0x000124db,0x0000a49b,0x00009493},
1292 {0x00000000,0x00000000,0x0000924a,0x000136db,
1293 0x0001b724,0x000126dc,0x0000a49b,0x0000a49b},
1294 {0x00000000,0x00000000,0x00009292,0x000136db,
1295 0x0001b724,0x000126dc,0x000124db,0x0000a49b},
1296 {0x00000000,0x00000000,0x00009492,0x000136db,
1297 0x0001b724,0x000126dc,0x000124db,0x0000a49b},
1298 {0x00000000,0x00000000,0x0000a492,0x000136db,
1299 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1300 {0x00000000,0x00000000,0x0000a492,0x000136db,
1301 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1302 {0x00000000,0x00000000,0x00012492,0x0001b6db,
1303 0x0001c924,0x0001b724,0x000136e4,0x000126dc},
1304 {0x00000000,0x00000000,0x00000000,0x00000000,
1305 0x00000000,0x00000000,0x00000000,0x00000000}
1306 }
1307 },
1308 { /* version 14 */
1309 { /* version 14, passes 0 */
1310 {0x00000000,0x00000000,0x00001249,0x0000924a,
1311 0x00009292,0x00009493,0x00009493,0x00009493},
1312 {0x00000000,0x00000000,0x00001249,0x0000a49b,
1313 0x0000a493,0x000124db,0x000126dc,0x00009493},
1314 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1315 0x0001249b,0x000126dc,0x000136e4,0x0000a49b},
1316 {0x00000000,0x00000000,0x0000924a,0x000124db,
1317 0x000126dc,0x000136e4,0x0001b725,0x000124db},
1318 {0x00000000,0x00000000,0x00009292,0x000124db,
1319 0x000126dc,0x0001b724,0x0001b92d,0x000126dc},
1320 {0x00000000,0x00000000,0x00009492,0x000124db,
1321 0x000136e4,0x0001b724,0x0001b92d,0x000126dc},
1322 {0x00000000,0x00000000,0x00009492,0x000124db,
1323 0x000136e4,0x0001c92d,0x0001c96e,0x000136e4},
1324 {0x00000000,0x00000000,0x00009492,0x000124db,
1325 0x0001b724,0x0001c92d,0x0001c96e,0x0001b724},
1326 {0x00000000,0x00000000,0x0000a492,0x000124db,
1327 0x0001b724,0x0001c92d,0x00024b76,0x0001b925},
1328 {0x00000000,0x00000000,0x0000a492,0x000126db,
1329 0x0001b724,0x0001c92d,0x00024b76,0x0001c92d},
1330 {0x00000000,0x00000000,0x0000a492,0x000126db,
1331 0x0001b724,0x0001c92d,0x00024b76,0x0001c92d},
1332 {0x00000000,0x00000000,0x0000a492,0x000136db,
1333 0x0001b724,0x0001c92d,0x00024b76,0x0002496e},
1334 {0x00000000,0x00000000,0x0000a492,0x000136db,
1335 0x0001b924,0x0002496d,0x00024b76,0x00024b77},
1336 {0x00000000,0x00000000,0x0000a492,0x000136db,
1337 0x0001b924,0x00024b6d,0x0002ddb6,0x00025bbf},
1338 {0x00000000,0x00000000,0x00012492,0x0001b6db,
1339 0x00024924,0x0002db6d,0x00036db6,0x0002efff},
1340 {0x00000000,0x00000000,0x00000000,0x00000000,
1341 0x00000000,0x00000000,0x00000000,0x00000000}
1342 },
1343 { /* version 14, passes 1 */
1344 {0x00000000,0x00000000,0x00001249,0x00001249,
1345 0x0000124a,0x0000124a,0x00001252,0x00001252},
1346 {0x00000000,0x00000000,0x0000924a,0x00009493,
1347 0x0000a493,0x00009292,0x00001252,0x00001252},
1348 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1349 0x0000a493,0x0000a49b,0x00001252,0x00001252},
1350 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1351 0x0001249b,0x000136e4,0x00009292,0x00009292},
1352 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1353 0x0001249b,0x000136e4,0x00009292,0x00009292},
1354 {0x00000000,0x00000000,0x0000924a,0x000124db,
1355 0x000136e4,0x000136e4,0x00009493,0x00009292},
1356 {0x00000000,0x00000000,0x00009492,0x000136db,
1357 0x0001b724,0x000136e4,0x00009493,0x00009493},
1358 {0x00000000,0x00000000,0x00009492,0x000136db,
1359 0x0001b724,0x000136e4,0x0000a49b,0x00009493},
1360 {0x00000000,0x00000000,0x00009492,0x000136db,
1361 0x0001b724,0x000136e4,0x0000a49b,0x00009493},
1362 {0x00000000,0x00000000,0x00009492,0x000136db,
1363 0x0001b724,0x000136e4,0x0000a49b,0x0000a49b},
1364 {0x00000000,0x00000000,0x0000a492,0x000136db,
1365 0x0001b724,0x000136e4,0x000124db,0x0000a49b},
1366 {0x00000000,0x00000000,0x0000a492,0x000136db,
1367 0x0001b724,0x000136e4,0x000124db,0x0000a49b},
1368 {0x00000000,0x00000000,0x0000a492,0x000136db,
1369 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1370 {0x00000000,0x00000000,0x0000a492,0x000136db,
1371 0x0001b724,0x000136e4,0x000126dc,0x000124db},
1372 {0x00000000,0x00000000,0x00012492,0x0001b6db,
1373 0x0001c924,0x0001b724,0x000136e4,0x000126dc},
1374 {0x00000000,0x00000000,0x00000000,0x00000000,
1375 0x00000000,0x00000000,0x00000000,0x00000000}
1376 }
1377 },
1378 { /* version 15 */
1379 { /* version 15, passes 0 */
1380 {0x00000000,0x00000000,0x00001249,0x00009493,
1381 0x0000a493,0x0000a49b,0x000124db,0x000124db},
1382 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1383 0x0001249b,0x000126dc,0x000136e4,0x000124db},
1384 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1385 0x000126dc,0x0001b724,0x0001b725,0x000126dc},
1386 {0x00000000,0x00000000,0x0000924a,0x000124db,
1387 0x000136e4,0x0001b724,0x0001b92d,0x000126dc},
1388 {0x00000000,0x00000000,0x00009492,0x000124db,
1389 0x000136e4,0x0001b925,0x0001c96e,0x000136e4},
1390 {0x00000000,0x00000000,0x00009492,0x000124db,
1391 0x0001b724,0x0001c92d,0x0001c96e,0x0001b724},
1392 {0x00000000,0x00000000,0x0000a492,0x000124db,
1393 0x0001b724,0x0001c92d,0x0001c96e,0x0001b724},
1394 {0x00000000,0x00000000,0x0000a492,0x000126db,
1395 0x0001b724,0x0001c92d,0x0001c96e,0x0001b925},
1396 {0x00000000,0x00000000,0x0000a492,0x000126db,
1397 0x0001b924,0x0001c92d,0x00024b76,0x0001c92d},
1398 {0x00000000,0x00000000,0x0000a492,0x000136db,
1399 0x0001b924,0x0001c92d,0x00024b76,0x0001c92d},
1400 {0x00000000,0x00000000,0x0000a492,0x000136db,
1401 0x0001b924,0x0002496d,0x00024b76,0x0002496e},
1402 {0x00000000,0x00000000,0x0000a492,0x000136db,
1403 0x0001c924,0x0002496d,0x00025bb6,0x00024b77},
1404 {0x00000000,0x00000000,0x0000a492,0x000136db,
1405 0x0001c924,0x00024b6d,0x00025bb6,0x00024b77},
1406 {0x00000000,0x00000000,0x00012492,0x000136db,
1407 0x0001c924,0x00024b6d,0x0002ddb6,0x00025bbf},
1408 {0x00000000,0x00000000,0x00012492,0x0001b6db,
1409 0x00024924,0x0002db6d,0x00036db6,0x0002efff},
1410 {0x00000000,0x00000000,0x00000000,0x00000000,
1411 0x00000000,0x00000000,0x00000000,0x00000000}
1412 },
1413 { /* version 15, passes 1 */
1414 {0x00000000,0x00000000,0x0000924a,0x0000924a,
1415 0x00009292,0x00009292,0x00009292,0x00009292},
1416 {0x00000000,0x00000000,0x0000924a,0x0000a49b,
1417 0x0000a493,0x000124db,0x00009292,0x00009292},
1418 {0x00000000,0x00000000,0x0000924a,0x000124db,
1419 0x000124db,0x0001b724,0x00009493,0x00009493},
1420 {0x00000000,0x00000000,0x0000924a,0x000124db,
1421 0x000126dc,0x0001b724,0x00009493,0x00009493},
1422 {0x00000000,0x00000000,0x0000924a,0x000124db,
1423 0x000136e4,0x0001b724,0x0000a49b,0x0000a49b},
1424 {0x00000000,0x00000000,0x00009292,0x000136db,
1425 0x0001b724,0x0001b724,0x0000a49b,0x0000a49b},
1426 {0x00000000,0x00000000,0x00009492,0x000136db,
1427 0x0001c924,0x0001b724,0x000124db,0x000124db},
1428 {0x00000000,0x00000000,0x00009492,0x000136db,
1429 0x0001c924,0x0001b724,0x000124db,0x000124db},
1430 {0x00000000,0x00000000,0x0000a492,0x000136db,
1431 0x0001c924,0x0001b724,0x000126dc,0x000126dc},
1432 {0x00000000,0x00000000,0x0000a492,0x000136db,
1433 0x0001c924,0x0001b925,0x000126dc,0x000126dc},
1434 {0x00000000,0x00000000,0x0000a492,0x000136db,
1435 0x0001c924,0x0001b925,0x000136e4,0x000136e4},
1436 {0x00000000,0x00000000,0x0000a492,0x000136db,
1437 0x0001c924,0x0001b925,0x000136e4,0x000136e4},
1438 {0x00000000,0x00000000,0x0000a492,0x000136db,
1439 0x0001c924,0x0001b925,0x0001b725,0x0001b724},
1440 {0x00000000,0x00000000,0x00012492,0x000136db,
1441 0x0001c924,0x0001b925,0x0001b725,0x0001b724},
1442 {0x00000000,0x00000000,0x00012492,0x0001b6db,
1443 0x00024924,0x0002496d,0x0001b92d,0x0001b925},
1444 {0x00000000,0x00000000,0x00000000,0x00000000,
1445 0x00000000,0x00000000,0x00000000,0x00000000}
1446 }
1447 }
1448};
diff --git a/drivers/media/usb/pwc/pwc-timon.h b/drivers/media/usb/pwc/pwc-timon.h
new file mode 100644
index 000000000000..270c5b9010f6
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-timon.h
@@ -0,0 +1,63 @@
1/* Linux driver for Philips webcam
2 (C) 2004-2006 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25
26
27/* This tables contains entries for the 675/680/690 (Timon) camera, with
28 4 different qualities (no compression, low, medium, high).
29 It lists the bandwidth requirements for said mode by its alternate interface
30 number. An alternate of 0 means that the mode is unavailable.
31
32 There are 6 * 4 * 4 entries:
33 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
34 6 framerates: 5, 10, 15, 20, 25, 30
35 4 compression modi: none, low, medium, high
36
37 When an uncompressed mode is not available, the next available compressed mode
38 will be chosen (unless the decompressor is absent). Sometimes there are only
39 1 or 2 compressed modes available; in that case entries are duplicated.
40*/
41
42#ifndef PWC_TIMON_H
43#define PWC_TIMON_H
44
45#include "pwc.h"
46
47#define PWC_FPS_MAX_TIMON 6
48
49struct Timon_table_entry
50{
51 char alternate; /* USB alternate interface */
52 unsigned short packetsize; /* Normal packet size */
53 unsigned short bandlength; /* Bandlength when decompressing */
54 unsigned char mode[13]; /* precomputed mode settings for cam */
55};
56
57extern const struct Timon_table_entry Timon_table[PSZ_MAX][PWC_FPS_MAX_TIMON][4];
58extern const unsigned int TimonRomTable [16][2][16][8];
59extern const unsigned int Timon_fps_vector[PWC_FPS_MAX_TIMON];
60
61#endif
62
63
diff --git a/drivers/media/usb/pwc/pwc-uncompress.c b/drivers/media/usb/pwc/pwc-uncompress.c
new file mode 100644
index 000000000000..b65903fbcf0d
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-uncompress.c
@@ -0,0 +1,107 @@
1/* Linux driver for Philips webcam
2 Decompression frontend.
3 (C) 1999-2003 Nemosoft Unv.
4 (C) 2004-2006 Luc Saillard (luc@saillard.org)
5
6 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
7 driver and thus may have bugs that are not present in the original version.
8 Please send bug reports and support requests to <luc@saillard.org>.
9 The decompression routines have been implemented by reverse-engineering the
10 Nemosoft binary pwcx module. Caveat emptor.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
26 vim: set ts=8:
27*/
28
29#include <asm/current.h>
30#include <asm/types.h>
31
32#include "pwc.h"
33#include "pwc-dec1.h"
34#include "pwc-dec23.h"
35
36int pwc_decompress(struct pwc_device *pdev, struct pwc_frame_buf *fbuf)
37{
38 int n, line, col;
39 void *yuv, *image;
40 u16 *src;
41 u16 *dsty, *dstu, *dstv;
42
43 image = vb2_plane_vaddr(&fbuf->vb, 0);
44
45 yuv = fbuf->data + pdev->frame_header_size; /* Skip header */
46
47 /* Raw format; that's easy... */
48 if (pdev->pixfmt != V4L2_PIX_FMT_YUV420)
49 {
50 struct pwc_raw_frame *raw_frame = image;
51 raw_frame->type = cpu_to_le16(pdev->type);
52 raw_frame->vbandlength = cpu_to_le16(pdev->vbandlength);
53 /* cmd_buf is always 4 bytes, but sometimes, only the
54 * first 3 bytes is filled (Nala case). We can
55 * determine this using the type of the webcam */
56 memcpy(raw_frame->cmd, pdev->cmd_buf, 4);
57 memcpy(raw_frame+1, yuv, pdev->frame_size);
58 vb2_set_plane_payload(&fbuf->vb, 0,
59 pdev->frame_size + sizeof(struct pwc_raw_frame));
60 return 0;
61 }
62
63 vb2_set_plane_payload(&fbuf->vb, 0,
64 pdev->width * pdev->height * 3 / 2);
65
66 if (pdev->vbandlength == 0) {
67 /* Uncompressed mode.
68 *
69 * We do some byte shuffling here to go from the
70 * native format to YUV420P.
71 */
72 src = (u16 *)yuv;
73 n = pdev->width * pdev->height;
74 dsty = (u16 *)(image);
75 dstu = (u16 *)(image + n);
76 dstv = (u16 *)(image + n + n / 4);
77
78 for (line = 0; line < pdev->height; line++) {
79 for (col = 0; col < pdev->width; col += 4) {
80 *dsty++ = *src++;
81 *dsty++ = *src++;
82 if (line & 1)
83 *dstv++ = *src++;
84 else
85 *dstu++ = *src++;
86 }
87 }
88
89 return 0;
90 }
91
92 /*
93 * Compressed;
94 * the decompressor routines will write the data in planar format
95 * immediately.
96 */
97 if (DEVICE_USE_CODEC1(pdev->type)) {
98
99 /* TODO & FIXME */
100 PWC_ERROR("This chipset is not supported for now\n");
101 return -ENXIO; /* No such device or address: missing decompressor */
102
103 } else {
104 pwc_dec23_decompress(pdev, yuv, image);
105 }
106 return 0;
107}
diff --git a/drivers/media/usb/pwc/pwc-v4l.c b/drivers/media/usb/pwc/pwc-v4l.c
new file mode 100644
index 000000000000..545e9bbdeede
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc-v4l.c
@@ -0,0 +1,1053 @@
1/* Linux driver for Philips webcam
2 USB and Video4Linux interface part.
3 (C) 1999-2004 Nemosoft Unv.
4 (C) 2004-2006 Luc Saillard (luc@saillard.org)
5 (C) 2011 Hans de Goede <hdegoede@redhat.com>
6
7 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
8 driver and thus may have bugs that are not present in the original version.
9 Please send bug reports and support requests to <luc@saillard.org>.
10 The decompression routines have been implemented by reverse-engineering the
11 Nemosoft binary pwcx module. Caveat emptor.
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27*/
28
29#include <linux/errno.h>
30#include <linux/init.h>
31#include <linux/mm.h>
32#include <linux/module.h>
33#include <linux/poll.h>
34#include <linux/vmalloc.h>
35#include <linux/jiffies.h>
36#include <asm/io.h>
37
38#include "pwc.h"
39
40#define PWC_CID_CUSTOM(ctrl) ((V4L2_CID_USER_BASE | 0xf000) + custom_ ## ctrl)
41
42static int pwc_g_volatile_ctrl(struct v4l2_ctrl *ctrl);
43static int pwc_s_ctrl(struct v4l2_ctrl *ctrl);
44
45static const struct v4l2_ctrl_ops pwc_ctrl_ops = {
46 .g_volatile_ctrl = pwc_g_volatile_ctrl,
47 .s_ctrl = pwc_s_ctrl,
48};
49
50enum { awb_indoor, awb_outdoor, awb_fl, awb_manual, awb_auto };
51enum { custom_autocontour, custom_contour, custom_noise_reduction,
52 custom_awb_speed, custom_awb_delay,
53 custom_save_user, custom_restore_user, custom_restore_factory };
54
55const char * const pwc_auto_whitebal_qmenu[] = {
56 "Indoor (Incandescant Lighting) Mode",
57 "Outdoor (Sunlight) Mode",
58 "Indoor (Fluorescent Lighting) Mode",
59 "Manual Mode",
60 "Auto Mode",
61 NULL
62};
63
64static const struct v4l2_ctrl_config pwc_auto_white_balance_cfg = {
65 .ops = &pwc_ctrl_ops,
66 .id = V4L2_CID_AUTO_WHITE_BALANCE,
67 .type = V4L2_CTRL_TYPE_MENU,
68 .max = awb_auto,
69 .qmenu = pwc_auto_whitebal_qmenu,
70};
71
72static const struct v4l2_ctrl_config pwc_autocontour_cfg = {
73 .ops = &pwc_ctrl_ops,
74 .id = PWC_CID_CUSTOM(autocontour),
75 .type = V4L2_CTRL_TYPE_BOOLEAN,
76 .name = "Auto contour",
77 .min = 0,
78 .max = 1,
79 .step = 1,
80};
81
82static const struct v4l2_ctrl_config pwc_contour_cfg = {
83 .ops = &pwc_ctrl_ops,
84 .id = PWC_CID_CUSTOM(contour),
85 .type = V4L2_CTRL_TYPE_INTEGER,
86 .name = "Contour",
87 .flags = V4L2_CTRL_FLAG_SLIDER,
88 .min = 0,
89 .max = 63,
90 .step = 1,
91};
92
93static const struct v4l2_ctrl_config pwc_backlight_cfg = {
94 .ops = &pwc_ctrl_ops,
95 .id = V4L2_CID_BACKLIGHT_COMPENSATION,
96 .type = V4L2_CTRL_TYPE_BOOLEAN,
97 .min = 0,
98 .max = 1,
99 .step = 1,
100};
101
102static const struct v4l2_ctrl_config pwc_flicker_cfg = {
103 .ops = &pwc_ctrl_ops,
104 .id = V4L2_CID_BAND_STOP_FILTER,
105 .type = V4L2_CTRL_TYPE_BOOLEAN,
106 .min = 0,
107 .max = 1,
108 .step = 1,
109};
110
111static const struct v4l2_ctrl_config pwc_noise_reduction_cfg = {
112 .ops = &pwc_ctrl_ops,
113 .id = PWC_CID_CUSTOM(noise_reduction),
114 .type = V4L2_CTRL_TYPE_INTEGER,
115 .name = "Dynamic Noise Reduction",
116 .min = 0,
117 .max = 3,
118 .step = 1,
119};
120
121static const struct v4l2_ctrl_config pwc_save_user_cfg = {
122 .ops = &pwc_ctrl_ops,
123 .id = PWC_CID_CUSTOM(save_user),
124 .type = V4L2_CTRL_TYPE_BUTTON,
125 .name = "Save User Settings",
126};
127
128static const struct v4l2_ctrl_config pwc_restore_user_cfg = {
129 .ops = &pwc_ctrl_ops,
130 .id = PWC_CID_CUSTOM(restore_user),
131 .type = V4L2_CTRL_TYPE_BUTTON,
132 .name = "Restore User Settings",
133};
134
135static const struct v4l2_ctrl_config pwc_restore_factory_cfg = {
136 .ops = &pwc_ctrl_ops,
137 .id = PWC_CID_CUSTOM(restore_factory),
138 .type = V4L2_CTRL_TYPE_BUTTON,
139 .name = "Restore Factory Settings",
140};
141
142static const struct v4l2_ctrl_config pwc_awb_speed_cfg = {
143 .ops = &pwc_ctrl_ops,
144 .id = PWC_CID_CUSTOM(awb_speed),
145 .type = V4L2_CTRL_TYPE_INTEGER,
146 .name = "Auto White Balance Speed",
147 .min = 1,
148 .max = 32,
149 .step = 1,
150};
151
152static const struct v4l2_ctrl_config pwc_awb_delay_cfg = {
153 .ops = &pwc_ctrl_ops,
154 .id = PWC_CID_CUSTOM(awb_delay),
155 .type = V4L2_CTRL_TYPE_INTEGER,
156 .name = "Auto White Balance Delay",
157 .min = 0,
158 .max = 63,
159 .step = 1,
160};
161
162int pwc_init_controls(struct pwc_device *pdev)
163{
164 struct v4l2_ctrl_handler *hdl;
165 struct v4l2_ctrl_config cfg;
166 int r, def;
167
168 hdl = &pdev->ctrl_handler;
169 r = v4l2_ctrl_handler_init(hdl, 20);
170 if (r)
171 return r;
172
173 /* Brightness, contrast, saturation, gamma */
174 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, BRIGHTNESS_FORMATTER, &def);
175 if (r || def > 127)
176 def = 63;
177 pdev->brightness = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
178 V4L2_CID_BRIGHTNESS, 0, 127, 1, def);
179
180 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, CONTRAST_FORMATTER, &def);
181 if (r || def > 63)
182 def = 31;
183 pdev->contrast = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
184 V4L2_CID_CONTRAST, 0, 63, 1, def);
185
186 if (pdev->type >= 675) {
187 if (pdev->type < 730)
188 pdev->saturation_fmt = SATURATION_MODE_FORMATTER2;
189 else
190 pdev->saturation_fmt = SATURATION_MODE_FORMATTER1;
191 r = pwc_get_s8_ctrl(pdev, GET_CHROM_CTL, pdev->saturation_fmt,
192 &def);
193 if (r || def < -100 || def > 100)
194 def = 0;
195 pdev->saturation = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
196 V4L2_CID_SATURATION, -100, 100, 1, def);
197 }
198
199 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, GAMMA_FORMATTER, &def);
200 if (r || def > 31)
201 def = 15;
202 pdev->gamma = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
203 V4L2_CID_GAMMA, 0, 31, 1, def);
204
205 /* auto white balance, red gain, blue gain */
206 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL, WB_MODE_FORMATTER, &def);
207 if (r || def > awb_auto)
208 def = awb_auto;
209 cfg = pwc_auto_white_balance_cfg;
210 cfg.name = v4l2_ctrl_get_name(cfg.id);
211 cfg.def = def;
212 pdev->auto_white_balance = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
213 /* check auto controls to avoid NULL deref in v4l2_ctrl_auto_cluster */
214 if (!pdev->auto_white_balance)
215 return hdl->error;
216
217 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL,
218 PRESET_MANUAL_RED_GAIN_FORMATTER, &def);
219 if (r)
220 def = 127;
221 pdev->red_balance = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
222 V4L2_CID_RED_BALANCE, 0, 255, 1, def);
223
224 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL,
225 PRESET_MANUAL_BLUE_GAIN_FORMATTER, &def);
226 if (r)
227 def = 127;
228 pdev->blue_balance = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
229 V4L2_CID_BLUE_BALANCE, 0, 255, 1, def);
230
231 v4l2_ctrl_auto_cluster(3, &pdev->auto_white_balance, awb_manual, true);
232
233 /* autogain, gain */
234 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, AGC_MODE_FORMATTER, &def);
235 if (r || (def != 0 && def != 0xff))
236 def = 0;
237 /* Note a register value if 0 means auto gain is on */
238 pdev->autogain = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
239 V4L2_CID_AUTOGAIN, 0, 1, 1, def == 0);
240 if (!pdev->autogain)
241 return hdl->error;
242
243 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, PRESET_AGC_FORMATTER, &def);
244 if (r || def > 63)
245 def = 31;
246 pdev->gain = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
247 V4L2_CID_GAIN, 0, 63, 1, def);
248
249 /* auto exposure, exposure */
250 if (DEVICE_USE_CODEC2(pdev->type)) {
251 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, SHUTTER_MODE_FORMATTER,
252 &def);
253 if (r || (def != 0 && def != 0xff))
254 def = 0;
255 /*
256 * def = 0 auto, def = ff manual
257 * menu idx 0 = auto, idx 1 = manual
258 */
259 pdev->exposure_auto = v4l2_ctrl_new_std_menu(hdl,
260 &pwc_ctrl_ops,
261 V4L2_CID_EXPOSURE_AUTO,
262 1, 0, def != 0);
263 if (!pdev->exposure_auto)
264 return hdl->error;
265
266 /* GET_LUM_CTL, PRESET_SHUTTER_FORMATTER is unreliable */
267 r = pwc_get_u16_ctrl(pdev, GET_STATUS_CTL,
268 READ_SHUTTER_FORMATTER, &def);
269 if (r || def > 655)
270 def = 655;
271 pdev->exposure = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
272 V4L2_CID_EXPOSURE, 0, 655, 1, def);
273 /* CODEC2: separate auto gain & auto exposure */
274 v4l2_ctrl_auto_cluster(2, &pdev->autogain, 0, true);
275 v4l2_ctrl_auto_cluster(2, &pdev->exposure_auto,
276 V4L2_EXPOSURE_MANUAL, true);
277 } else if (DEVICE_USE_CODEC3(pdev->type)) {
278 /* GET_LUM_CTL, PRESET_SHUTTER_FORMATTER is unreliable */
279 r = pwc_get_u16_ctrl(pdev, GET_STATUS_CTL,
280 READ_SHUTTER_FORMATTER, &def);
281 if (r || def > 255)
282 def = 255;
283 pdev->exposure = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
284 V4L2_CID_EXPOSURE, 0, 255, 1, def);
285 /* CODEC3: both gain and exposure controlled by autogain */
286 pdev->autogain_expo_cluster[0] = pdev->autogain;
287 pdev->autogain_expo_cluster[1] = pdev->gain;
288 pdev->autogain_expo_cluster[2] = pdev->exposure;
289 v4l2_ctrl_auto_cluster(3, pdev->autogain_expo_cluster,
290 0, true);
291 }
292
293 /* color / bw setting */
294 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL, COLOUR_MODE_FORMATTER,
295 &def);
296 if (r || (def != 0 && def != 0xff))
297 def = 0xff;
298 /* def = 0 bw, def = ff color, menu idx 0 = color, idx 1 = bw */
299 pdev->colorfx = v4l2_ctrl_new_std_menu(hdl, &pwc_ctrl_ops,
300 V4L2_CID_COLORFX, 1, 0, def == 0);
301
302 /* autocontour, contour */
303 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, AUTO_CONTOUR_FORMATTER, &def);
304 if (r || (def != 0 && def != 0xff))
305 def = 0;
306 cfg = pwc_autocontour_cfg;
307 cfg.def = def == 0;
308 pdev->autocontour = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
309 if (!pdev->autocontour)
310 return hdl->error;
311
312 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, PRESET_CONTOUR_FORMATTER, &def);
313 if (r || def > 63)
314 def = 31;
315 cfg = pwc_contour_cfg;
316 cfg.def = def;
317 pdev->contour = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
318
319 v4l2_ctrl_auto_cluster(2, &pdev->autocontour, 0, false);
320
321 /* backlight */
322 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL,
323 BACK_LIGHT_COMPENSATION_FORMATTER, &def);
324 if (r || (def != 0 && def != 0xff))
325 def = 0;
326 cfg = pwc_backlight_cfg;
327 cfg.name = v4l2_ctrl_get_name(cfg.id);
328 cfg.def = def == 0;
329 pdev->backlight = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
330
331 /* flikker rediction */
332 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL,
333 FLICKERLESS_MODE_FORMATTER, &def);
334 if (r || (def != 0 && def != 0xff))
335 def = 0;
336 cfg = pwc_flicker_cfg;
337 cfg.name = v4l2_ctrl_get_name(cfg.id);
338 cfg.def = def == 0;
339 pdev->flicker = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
340
341 /* Dynamic noise reduction */
342 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL,
343 DYNAMIC_NOISE_CONTROL_FORMATTER, &def);
344 if (r || def > 3)
345 def = 2;
346 cfg = pwc_noise_reduction_cfg;
347 cfg.def = def;
348 pdev->noise_reduction = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
349
350 /* Save / Restore User / Factory Settings */
351 pdev->save_user = v4l2_ctrl_new_custom(hdl, &pwc_save_user_cfg, NULL);
352 pdev->restore_user = v4l2_ctrl_new_custom(hdl, &pwc_restore_user_cfg,
353 NULL);
354 if (pdev->restore_user)
355 pdev->restore_user->flags |= V4L2_CTRL_FLAG_UPDATE;
356 pdev->restore_factory = v4l2_ctrl_new_custom(hdl,
357 &pwc_restore_factory_cfg,
358 NULL);
359 if (pdev->restore_factory)
360 pdev->restore_factory->flags |= V4L2_CTRL_FLAG_UPDATE;
361
362 /* Auto White Balance speed & delay */
363 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL,
364 AWB_CONTROL_SPEED_FORMATTER, &def);
365 if (r || def < 1 || def > 32)
366 def = 1;
367 cfg = pwc_awb_speed_cfg;
368 cfg.def = def;
369 pdev->awb_speed = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
370
371 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL,
372 AWB_CONTROL_DELAY_FORMATTER, &def);
373 if (r || def > 63)
374 def = 0;
375 cfg = pwc_awb_delay_cfg;
376 cfg.def = def;
377 pdev->awb_delay = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
378
379 if (!(pdev->features & FEATURE_MOTOR_PANTILT))
380 return hdl->error;
381
382 /* Motor pan / tilt / reset */
383 pdev->motor_pan = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
384 V4L2_CID_PAN_RELATIVE, -4480, 4480, 64, 0);
385 if (!pdev->motor_pan)
386 return hdl->error;
387 pdev->motor_tilt = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
388 V4L2_CID_TILT_RELATIVE, -1920, 1920, 64, 0);
389 pdev->motor_pan_reset = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
390 V4L2_CID_PAN_RESET, 0, 0, 0, 0);
391 pdev->motor_tilt_reset = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
392 V4L2_CID_TILT_RESET, 0, 0, 0, 0);
393 v4l2_ctrl_cluster(4, &pdev->motor_pan);
394
395 return hdl->error;
396}
397
398static void pwc_vidioc_fill_fmt(struct v4l2_format *f,
399 int width, int height, u32 pixfmt)
400{
401 memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format));
402 f->fmt.pix.width = width;
403 f->fmt.pix.height = height;
404 f->fmt.pix.field = V4L2_FIELD_NONE;
405 f->fmt.pix.pixelformat = pixfmt;
406 f->fmt.pix.bytesperline = f->fmt.pix.width;
407 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.width * 3 / 2;
408 f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
409 PWC_DEBUG_IOCTL("pwc_vidioc_fill_fmt() "
410 "width=%d, height=%d, bytesperline=%d, sizeimage=%d, pixelformat=%c%c%c%c\n",
411 f->fmt.pix.width,
412 f->fmt.pix.height,
413 f->fmt.pix.bytesperline,
414 f->fmt.pix.sizeimage,
415 (f->fmt.pix.pixelformat)&255,
416 (f->fmt.pix.pixelformat>>8)&255,
417 (f->fmt.pix.pixelformat>>16)&255,
418 (f->fmt.pix.pixelformat>>24)&255);
419}
420
421/* ioctl(VIDIOC_TRY_FMT) */
422static int pwc_vidioc_try_fmt(struct pwc_device *pdev, struct v4l2_format *f)
423{
424 int size;
425
426 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
427 PWC_DEBUG_IOCTL("Bad video type must be V4L2_BUF_TYPE_VIDEO_CAPTURE\n");
428 return -EINVAL;
429 }
430
431 switch (f->fmt.pix.pixelformat) {
432 case V4L2_PIX_FMT_YUV420:
433 break;
434 case V4L2_PIX_FMT_PWC1:
435 if (DEVICE_USE_CODEC23(pdev->type)) {
436 PWC_DEBUG_IOCTL("codec1 is only supported for old pwc webcam\n");
437 return -EINVAL;
438 }
439 break;
440 case V4L2_PIX_FMT_PWC2:
441 if (DEVICE_USE_CODEC1(pdev->type)) {
442 PWC_DEBUG_IOCTL("codec23 is only supported for new pwc webcam\n");
443 return -EINVAL;
444 }
445 break;
446 default:
447 PWC_DEBUG_IOCTL("Unsupported pixel format\n");
448 return -EINVAL;
449
450 }
451
452 size = pwc_get_size(pdev, f->fmt.pix.width, f->fmt.pix.height);
453 pwc_vidioc_fill_fmt(f,
454 pwc_image_sizes[size][0],
455 pwc_image_sizes[size][1],
456 f->fmt.pix.pixelformat);
457
458 return 0;
459}
460
461/* ioctl(VIDIOC_SET_FMT) */
462
463static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
464{
465 struct pwc_device *pdev = video_drvdata(file);
466 int ret, pixelformat, compression = 0;
467
468 ret = pwc_vidioc_try_fmt(pdev, f);
469 if (ret < 0)
470 return ret;
471
472 if (vb2_is_busy(&pdev->vb_queue))
473 return -EBUSY;
474
475 pixelformat = f->fmt.pix.pixelformat;
476
477 PWC_DEBUG_IOCTL("Trying to set format to: width=%d height=%d fps=%d "
478 "format=%c%c%c%c\n",
479 f->fmt.pix.width, f->fmt.pix.height, pdev->vframes,
480 (pixelformat)&255,
481 (pixelformat>>8)&255,
482 (pixelformat>>16)&255,
483 (pixelformat>>24)&255);
484
485 ret = pwc_set_video_mode(pdev, f->fmt.pix.width, f->fmt.pix.height,
486 pixelformat, 30, &compression, 0);
487
488 PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret);
489
490 pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, pdev->pixfmt);
491 return ret;
492}
493
494static int pwc_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
495{
496 struct pwc_device *pdev = video_drvdata(file);
497
498 strcpy(cap->driver, PWC_NAME);
499 strlcpy(cap->card, pdev->vdev.name, sizeof(cap->card));
500 usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info));
501 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
502 V4L2_CAP_READWRITE;
503 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
504 return 0;
505}
506
507static int pwc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
508{
509 if (i->index) /* Only one INPUT is supported */
510 return -EINVAL;
511
512 strlcpy(i->name, "Camera", sizeof(i->name));
513 i->type = V4L2_INPUT_TYPE_CAMERA;
514 return 0;
515}
516
517static int pwc_g_input(struct file *file, void *fh, unsigned int *i)
518{
519 *i = 0;
520 return 0;
521}
522
523static int pwc_s_input(struct file *file, void *fh, unsigned int i)
524{
525 return i ? -EINVAL : 0;
526}
527
528static int pwc_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
529{
530 struct pwc_device *pdev =
531 container_of(ctrl->handler, struct pwc_device, ctrl_handler);
532 int ret = 0;
533
534 switch (ctrl->id) {
535 case V4L2_CID_AUTO_WHITE_BALANCE:
536 if (pdev->color_bal_valid &&
537 (pdev->auto_white_balance->val != awb_auto ||
538 time_before(jiffies,
539 pdev->last_color_bal_update + HZ / 4))) {
540 pdev->red_balance->val = pdev->last_red_balance;
541 pdev->blue_balance->val = pdev->last_blue_balance;
542 break;
543 }
544 ret = pwc_get_u8_ctrl(pdev, GET_STATUS_CTL,
545 READ_RED_GAIN_FORMATTER,
546 &pdev->red_balance->val);
547 if (ret)
548 break;
549 ret = pwc_get_u8_ctrl(pdev, GET_STATUS_CTL,
550 READ_BLUE_GAIN_FORMATTER,
551 &pdev->blue_balance->val);
552 if (ret)
553 break;
554 pdev->last_red_balance = pdev->red_balance->val;
555 pdev->last_blue_balance = pdev->blue_balance->val;
556 pdev->last_color_bal_update = jiffies;
557 pdev->color_bal_valid = true;
558 break;
559 case V4L2_CID_AUTOGAIN:
560 if (pdev->gain_valid && time_before(jiffies,
561 pdev->last_gain_update + HZ / 4)) {
562 pdev->gain->val = pdev->last_gain;
563 break;
564 }
565 ret = pwc_get_u8_ctrl(pdev, GET_STATUS_CTL,
566 READ_AGC_FORMATTER, &pdev->gain->val);
567 if (ret)
568 break;
569 pdev->last_gain = pdev->gain->val;
570 pdev->last_gain_update = jiffies;
571 pdev->gain_valid = true;
572 if (!DEVICE_USE_CODEC3(pdev->type))
573 break;
574 /* Fall through for CODEC3 where autogain also controls expo */
575 case V4L2_CID_EXPOSURE_AUTO:
576 if (pdev->exposure_valid && time_before(jiffies,
577 pdev->last_exposure_update + HZ / 4)) {
578 pdev->exposure->val = pdev->last_exposure;
579 break;
580 }
581 ret = pwc_get_u16_ctrl(pdev, GET_STATUS_CTL,
582 READ_SHUTTER_FORMATTER,
583 &pdev->exposure->val);
584 if (ret)
585 break;
586 pdev->last_exposure = pdev->exposure->val;
587 pdev->last_exposure_update = jiffies;
588 pdev->exposure_valid = true;
589 break;
590 default:
591 ret = -EINVAL;
592 }
593
594 if (ret)
595 PWC_ERROR("g_ctrl %s error %d\n", ctrl->name, ret);
596
597 return ret;
598}
599
600static int pwc_set_awb(struct pwc_device *pdev)
601{
602 int ret;
603
604 if (pdev->auto_white_balance->is_new) {
605 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL,
606 WB_MODE_FORMATTER,
607 pdev->auto_white_balance->val);
608 if (ret)
609 return ret;
610
611 if (pdev->auto_white_balance->val != awb_manual)
612 pdev->color_bal_valid = false; /* Force cache update */
613
614 /*
615 * If this is a preset, update our red / blue balance values
616 * so that events get generated for the new preset values
617 */
618 if (pdev->auto_white_balance->val == awb_indoor ||
619 pdev->auto_white_balance->val == awb_outdoor ||
620 pdev->auto_white_balance->val == awb_fl)
621 pwc_g_volatile_ctrl(pdev->auto_white_balance);
622 }
623 if (pdev->auto_white_balance->val != awb_manual)
624 return 0;
625
626 if (pdev->red_balance->is_new) {
627 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL,
628 PRESET_MANUAL_RED_GAIN_FORMATTER,
629 pdev->red_balance->val);
630 if (ret)
631 return ret;
632 }
633
634 if (pdev->blue_balance->is_new) {
635 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL,
636 PRESET_MANUAL_BLUE_GAIN_FORMATTER,
637 pdev->blue_balance->val);
638 if (ret)
639 return ret;
640 }
641 return 0;
642}
643
644/* For CODEC2 models which have separate autogain and auto exposure */
645static int pwc_set_autogain(struct pwc_device *pdev)
646{
647 int ret;
648
649 if (pdev->autogain->is_new) {
650 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
651 AGC_MODE_FORMATTER,
652 pdev->autogain->val ? 0 : 0xff);
653 if (ret)
654 return ret;
655
656 if (pdev->autogain->val)
657 pdev->gain_valid = false; /* Force cache update */
658 }
659
660 if (pdev->autogain->val)
661 return 0;
662
663 if (pdev->gain->is_new) {
664 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
665 PRESET_AGC_FORMATTER,
666 pdev->gain->val);
667 if (ret)
668 return ret;
669 }
670 return 0;
671}
672
673/* For CODEC2 models which have separate autogain and auto exposure */
674static int pwc_set_exposure_auto(struct pwc_device *pdev)
675{
676 int ret;
677 int is_auto = pdev->exposure_auto->val == V4L2_EXPOSURE_AUTO;
678
679 if (pdev->exposure_auto->is_new) {
680 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
681 SHUTTER_MODE_FORMATTER,
682 is_auto ? 0 : 0xff);
683 if (ret)
684 return ret;
685
686 if (is_auto)
687 pdev->exposure_valid = false; /* Force cache update */
688 }
689
690 if (is_auto)
691 return 0;
692
693 if (pdev->exposure->is_new) {
694 ret = pwc_set_u16_ctrl(pdev, SET_LUM_CTL,
695 PRESET_SHUTTER_FORMATTER,
696 pdev->exposure->val);
697 if (ret)
698 return ret;
699 }
700 return 0;
701}
702
703/* For CODEC3 models which have autogain controlling both gain and exposure */
704static int pwc_set_autogain_expo(struct pwc_device *pdev)
705{
706 int ret;
707
708 if (pdev->autogain->is_new) {
709 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
710 AGC_MODE_FORMATTER,
711 pdev->autogain->val ? 0 : 0xff);
712 if (ret)
713 return ret;
714
715 if (pdev->autogain->val) {
716 pdev->gain_valid = false; /* Force cache update */
717 pdev->exposure_valid = false; /* Force cache update */
718 }
719 }
720
721 if (pdev->autogain->val)
722 return 0;
723
724 if (pdev->gain->is_new) {
725 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
726 PRESET_AGC_FORMATTER,
727 pdev->gain->val);
728 if (ret)
729 return ret;
730 }
731
732 if (pdev->exposure->is_new) {
733 ret = pwc_set_u16_ctrl(pdev, SET_LUM_CTL,
734 PRESET_SHUTTER_FORMATTER,
735 pdev->exposure->val);
736 if (ret)
737 return ret;
738 }
739 return 0;
740}
741
742static int pwc_set_motor(struct pwc_device *pdev)
743{
744 int ret;
745
746 pdev->ctrl_buf[0] = 0;
747 if (pdev->motor_pan_reset->is_new)
748 pdev->ctrl_buf[0] |= 0x01;
749 if (pdev->motor_tilt_reset->is_new)
750 pdev->ctrl_buf[0] |= 0x02;
751 if (pdev->motor_pan_reset->is_new || pdev->motor_tilt_reset->is_new) {
752 ret = send_control_msg(pdev, SET_MPT_CTL,
753 PT_RESET_CONTROL_FORMATTER,
754 pdev->ctrl_buf, 1);
755 if (ret < 0)
756 return ret;
757 }
758
759 memset(pdev->ctrl_buf, 0, 4);
760 if (pdev->motor_pan->is_new) {
761 pdev->ctrl_buf[0] = pdev->motor_pan->val & 0xFF;
762 pdev->ctrl_buf[1] = (pdev->motor_pan->val >> 8);
763 }
764 if (pdev->motor_tilt->is_new) {
765 pdev->ctrl_buf[2] = pdev->motor_tilt->val & 0xFF;
766 pdev->ctrl_buf[3] = (pdev->motor_tilt->val >> 8);
767 }
768 if (pdev->motor_pan->is_new || pdev->motor_tilt->is_new) {
769 ret = send_control_msg(pdev, SET_MPT_CTL,
770 PT_RELATIVE_CONTROL_FORMATTER,
771 pdev->ctrl_buf, 4);
772 if (ret < 0)
773 return ret;
774 }
775
776 return 0;
777}
778
779static int pwc_s_ctrl(struct v4l2_ctrl *ctrl)
780{
781 struct pwc_device *pdev =
782 container_of(ctrl->handler, struct pwc_device, ctrl_handler);
783 int ret = 0;
784
785 switch (ctrl->id) {
786 case V4L2_CID_BRIGHTNESS:
787 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
788 BRIGHTNESS_FORMATTER, ctrl->val);
789 break;
790 case V4L2_CID_CONTRAST:
791 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
792 CONTRAST_FORMATTER, ctrl->val);
793 break;
794 case V4L2_CID_SATURATION:
795 ret = pwc_set_s8_ctrl(pdev, SET_CHROM_CTL,
796 pdev->saturation_fmt, ctrl->val);
797 break;
798 case V4L2_CID_GAMMA:
799 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
800 GAMMA_FORMATTER, ctrl->val);
801 break;
802 case V4L2_CID_AUTO_WHITE_BALANCE:
803 ret = pwc_set_awb(pdev);
804 break;
805 case V4L2_CID_AUTOGAIN:
806 if (DEVICE_USE_CODEC2(pdev->type))
807 ret = pwc_set_autogain(pdev);
808 else if (DEVICE_USE_CODEC3(pdev->type))
809 ret = pwc_set_autogain_expo(pdev);
810 else
811 ret = -EINVAL;
812 break;
813 case V4L2_CID_EXPOSURE_AUTO:
814 if (DEVICE_USE_CODEC2(pdev->type))
815 ret = pwc_set_exposure_auto(pdev);
816 else
817 ret = -EINVAL;
818 break;
819 case V4L2_CID_COLORFX:
820 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL,
821 COLOUR_MODE_FORMATTER,
822 ctrl->val ? 0 : 0xff);
823 break;
824 case PWC_CID_CUSTOM(autocontour):
825 if (pdev->autocontour->is_new) {
826 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
827 AUTO_CONTOUR_FORMATTER,
828 pdev->autocontour->val ? 0 : 0xff);
829 }
830 if (ret == 0 && pdev->contour->is_new) {
831 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
832 PRESET_CONTOUR_FORMATTER,
833 pdev->contour->val);
834 }
835 break;
836 case V4L2_CID_BACKLIGHT_COMPENSATION:
837 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
838 BACK_LIGHT_COMPENSATION_FORMATTER,
839 ctrl->val ? 0 : 0xff);
840 break;
841 case V4L2_CID_BAND_STOP_FILTER:
842 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
843 FLICKERLESS_MODE_FORMATTER,
844 ctrl->val ? 0 : 0xff);
845 break;
846 case PWC_CID_CUSTOM(noise_reduction):
847 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
848 DYNAMIC_NOISE_CONTROL_FORMATTER,
849 ctrl->val);
850 break;
851 case PWC_CID_CUSTOM(save_user):
852 ret = pwc_button_ctrl(pdev, SAVE_USER_DEFAULTS_FORMATTER);
853 break;
854 case PWC_CID_CUSTOM(restore_user):
855 ret = pwc_button_ctrl(pdev, RESTORE_USER_DEFAULTS_FORMATTER);
856 break;
857 case PWC_CID_CUSTOM(restore_factory):
858 ret = pwc_button_ctrl(pdev,
859 RESTORE_FACTORY_DEFAULTS_FORMATTER);
860 break;
861 case PWC_CID_CUSTOM(awb_speed):
862 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL,
863 AWB_CONTROL_SPEED_FORMATTER,
864 ctrl->val);
865 break;
866 case PWC_CID_CUSTOM(awb_delay):
867 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL,
868 AWB_CONTROL_DELAY_FORMATTER,
869 ctrl->val);
870 break;
871 case V4L2_CID_PAN_RELATIVE:
872 ret = pwc_set_motor(pdev);
873 break;
874 default:
875 ret = -EINVAL;
876 }
877
878 if (ret)
879 PWC_ERROR("s_ctrl %s error %d\n", ctrl->name, ret);
880
881 return ret;
882}
883
884static int pwc_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f)
885{
886 struct pwc_device *pdev = video_drvdata(file);
887
888 /* We only support two format: the raw format, and YUV */
889 switch (f->index) {
890 case 0:
891 /* RAW format */
892 f->pixelformat = pdev->type <= 646 ? V4L2_PIX_FMT_PWC1 : V4L2_PIX_FMT_PWC2;
893 f->flags = V4L2_FMT_FLAG_COMPRESSED;
894 strlcpy(f->description, "Raw Philips Webcam", sizeof(f->description));
895 break;
896 case 1:
897 f->pixelformat = V4L2_PIX_FMT_YUV420;
898 strlcpy(f->description, "4:2:0, planar, Y-Cb-Cr", sizeof(f->description));
899 break;
900 default:
901 return -EINVAL;
902 }
903 return 0;
904}
905
906static int pwc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
907{
908 struct pwc_device *pdev = video_drvdata(file);
909
910 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
911 return -EINVAL;
912
913 PWC_DEBUG_IOCTL("ioctl(VIDIOC_G_FMT) return size %dx%d\n",
914 pdev->width, pdev->height);
915 pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, pdev->pixfmt);
916 return 0;
917}
918
919static int pwc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
920{
921 struct pwc_device *pdev = video_drvdata(file);
922
923 return pwc_vidioc_try_fmt(pdev, f);
924}
925
926static int pwc_enum_framesizes(struct file *file, void *fh,
927 struct v4l2_frmsizeenum *fsize)
928{
929 struct pwc_device *pdev = video_drvdata(file);
930 unsigned int i = 0, index = fsize->index;
931
932 if (fsize->pixel_format == V4L2_PIX_FMT_YUV420 ||
933 (fsize->pixel_format == V4L2_PIX_FMT_PWC1 &&
934 DEVICE_USE_CODEC1(pdev->type)) ||
935 (fsize->pixel_format == V4L2_PIX_FMT_PWC2 &&
936 DEVICE_USE_CODEC23(pdev->type))) {
937 for (i = 0; i < PSZ_MAX; i++) {
938 if (!(pdev->image_mask & (1UL << i)))
939 continue;
940 if (!index--) {
941 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
942 fsize->discrete.width = pwc_image_sizes[i][0];
943 fsize->discrete.height = pwc_image_sizes[i][1];
944 return 0;
945 }
946 }
947 }
948 return -EINVAL;
949}
950
951static int pwc_enum_frameintervals(struct file *file, void *fh,
952 struct v4l2_frmivalenum *fival)
953{
954 struct pwc_device *pdev = video_drvdata(file);
955 int size = -1;
956 unsigned int i;
957
958 for (i = 0; i < PSZ_MAX; i++) {
959 if (pwc_image_sizes[i][0] == fival->width &&
960 pwc_image_sizes[i][1] == fival->height) {
961 size = i;
962 break;
963 }
964 }
965
966 /* TODO: Support raw format */
967 if (size < 0 || fival->pixel_format != V4L2_PIX_FMT_YUV420)
968 return -EINVAL;
969
970 i = pwc_get_fps(pdev, fival->index, size);
971 if (!i)
972 return -EINVAL;
973
974 fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
975 fival->discrete.numerator = 1;
976 fival->discrete.denominator = i;
977
978 return 0;
979}
980
981static int pwc_g_parm(struct file *file, void *fh,
982 struct v4l2_streamparm *parm)
983{
984 struct pwc_device *pdev = video_drvdata(file);
985
986 if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
987 return -EINVAL;
988
989 memset(parm, 0, sizeof(*parm));
990
991 parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
992 parm->parm.capture.readbuffers = MIN_FRAMES;
993 parm->parm.capture.capability |= V4L2_CAP_TIMEPERFRAME;
994 parm->parm.capture.timeperframe.denominator = pdev->vframes;
995 parm->parm.capture.timeperframe.numerator = 1;
996
997 return 0;
998}
999
1000static int pwc_s_parm(struct file *file, void *fh,
1001 struct v4l2_streamparm *parm)
1002{
1003 struct pwc_device *pdev = video_drvdata(file);
1004 int compression = 0;
1005 int ret, fps;
1006
1007 if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1008 return -EINVAL;
1009
1010 /* If timeperframe == 0, then reset the framerate to the nominal value.
1011 We pick a high framerate here, and let pwc_set_video_mode() figure
1012 out the best match. */
1013 if (parm->parm.capture.timeperframe.numerator == 0 ||
1014 parm->parm.capture.timeperframe.denominator == 0)
1015 fps = 30;
1016 else
1017 fps = parm->parm.capture.timeperframe.denominator /
1018 parm->parm.capture.timeperframe.numerator;
1019
1020 if (vb2_is_busy(&pdev->vb_queue))
1021 return -EBUSY;
1022
1023 ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt,
1024 fps, &compression, 0);
1025
1026 pwc_g_parm(file, fh, parm);
1027
1028 return ret;
1029}
1030
1031const struct v4l2_ioctl_ops pwc_ioctl_ops = {
1032 .vidioc_querycap = pwc_querycap,
1033 .vidioc_enum_input = pwc_enum_input,
1034 .vidioc_g_input = pwc_g_input,
1035 .vidioc_s_input = pwc_s_input,
1036 .vidioc_enum_fmt_vid_cap = pwc_enum_fmt_vid_cap,
1037 .vidioc_g_fmt_vid_cap = pwc_g_fmt_vid_cap,
1038 .vidioc_s_fmt_vid_cap = pwc_s_fmt_vid_cap,
1039 .vidioc_try_fmt_vid_cap = pwc_try_fmt_vid_cap,
1040 .vidioc_reqbufs = vb2_ioctl_reqbufs,
1041 .vidioc_querybuf = vb2_ioctl_querybuf,
1042 .vidioc_qbuf = vb2_ioctl_qbuf,
1043 .vidioc_dqbuf = vb2_ioctl_dqbuf,
1044 .vidioc_streamon = vb2_ioctl_streamon,
1045 .vidioc_streamoff = vb2_ioctl_streamoff,
1046 .vidioc_log_status = v4l2_ctrl_log_status,
1047 .vidioc_enum_framesizes = pwc_enum_framesizes,
1048 .vidioc_enum_frameintervals = pwc_enum_frameintervals,
1049 .vidioc_g_parm = pwc_g_parm,
1050 .vidioc_s_parm = pwc_s_parm,
1051 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
1052 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1053};
diff --git a/drivers/media/usb/pwc/pwc.h b/drivers/media/usb/pwc/pwc.h
new file mode 100644
index 000000000000..7a6a0d39c2c6
--- /dev/null
+++ b/drivers/media/usb/pwc/pwc.h
@@ -0,0 +1,393 @@
1/* (C) 1999-2003 Nemosoft Unv.
2 (C) 2004-2006 Luc Saillard (luc@saillard.org)
3
4 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
5 driver and thus may have bugs that are not present in the original version.
6 Please send bug reports and support requests to <luc@saillard.org>.
7 The decompression routines have been implemented by reverse-engineering the
8 Nemosoft binary pwcx module. Caveat emptor.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23*/
24
25#ifndef PWC_H
26#define PWC_H
27
28#include <linux/module.h>
29#include <linux/usb.h>
30#include <linux/spinlock.h>
31#include <linux/wait.h>
32#include <linux/mutex.h>
33#include <linux/mm.h>
34#include <linux/slab.h>
35#include <asm/errno.h>
36#include <linux/videodev2.h>
37#include <media/v4l2-common.h>
38#include <media/v4l2-device.h>
39#include <media/v4l2-ioctl.h>
40#include <media/v4l2-ctrls.h>
41#include <media/v4l2-fh.h>
42#include <media/v4l2-event.h>
43#include <media/videobuf2-vmalloc.h>
44#ifdef CONFIG_USB_PWC_INPUT_EVDEV
45#include <linux/input.h>
46#endif
47#include "pwc-dec1.h"
48#include "pwc-dec23.h"
49
50/* Version block */
51#define PWC_VERSION "10.0.15"
52#define PWC_NAME "pwc"
53#define PFX PWC_NAME ": "
54
55
56/* Trace certain actions in the driver */
57#define PWC_DEBUG_LEVEL_MODULE (1<<0)
58#define PWC_DEBUG_LEVEL_PROBE (1<<1)
59#define PWC_DEBUG_LEVEL_OPEN (1<<2)
60#define PWC_DEBUG_LEVEL_READ (1<<3)
61#define PWC_DEBUG_LEVEL_MEMORY (1<<4)
62#define PWC_DEBUG_LEVEL_FLOW (1<<5)
63#define PWC_DEBUG_LEVEL_SIZE (1<<6)
64#define PWC_DEBUG_LEVEL_IOCTL (1<<7)
65#define PWC_DEBUG_LEVEL_TRACE (1<<8)
66
67#define PWC_DEBUG_MODULE(fmt, args...) PWC_DEBUG(MODULE, fmt, ##args)
68#define PWC_DEBUG_PROBE(fmt, args...) PWC_DEBUG(PROBE, fmt, ##args)
69#define PWC_DEBUG_OPEN(fmt, args...) PWC_DEBUG(OPEN, fmt, ##args)
70#define PWC_DEBUG_READ(fmt, args...) PWC_DEBUG(READ, fmt, ##args)
71#define PWC_DEBUG_MEMORY(fmt, args...) PWC_DEBUG(MEMORY, fmt, ##args)
72#define PWC_DEBUG_FLOW(fmt, args...) PWC_DEBUG(FLOW, fmt, ##args)
73#define PWC_DEBUG_SIZE(fmt, args...) PWC_DEBUG(SIZE, fmt, ##args)
74#define PWC_DEBUG_IOCTL(fmt, args...) PWC_DEBUG(IOCTL, fmt, ##args)
75#define PWC_DEBUG_TRACE(fmt, args...) PWC_DEBUG(TRACE, fmt, ##args)
76
77
78#ifdef CONFIG_USB_PWC_DEBUG
79
80#define PWC_DEBUG_LEVEL (PWC_DEBUG_LEVEL_MODULE)
81
82#define PWC_DEBUG(level, fmt, args...) do {\
83 if ((PWC_DEBUG_LEVEL_ ##level) & pwc_trace) \
84 printk(KERN_DEBUG PFX fmt, ##args); \
85 } while (0)
86
87#define PWC_ERROR(fmt, args...) printk(KERN_ERR PFX fmt, ##args)
88#define PWC_WARNING(fmt, args...) printk(KERN_WARNING PFX fmt, ##args)
89#define PWC_INFO(fmt, args...) printk(KERN_INFO PFX fmt, ##args)
90#define PWC_TRACE(fmt, args...) PWC_DEBUG(TRACE, fmt, ##args)
91
92#else /* if ! CONFIG_USB_PWC_DEBUG */
93
94#define PWC_ERROR(fmt, args...) printk(KERN_ERR PFX fmt, ##args)
95#define PWC_WARNING(fmt, args...) printk(KERN_WARNING PFX fmt, ##args)
96#define PWC_INFO(fmt, args...) printk(KERN_INFO PFX fmt, ##args)
97#define PWC_TRACE(fmt, args...) do { } while(0)
98#define PWC_DEBUG(level, fmt, args...) do { } while(0)
99
100#define pwc_trace 0
101
102#endif
103
104/* Defines for ToUCam cameras */
105#define TOUCAM_HEADER_SIZE 8
106#define TOUCAM_TRAILER_SIZE 4
107
108#define FEATURE_MOTOR_PANTILT 0x0001
109#define FEATURE_CODEC1 0x0002
110#define FEATURE_CODEC2 0x0004
111
112#define MAX_WIDTH 640
113#define MAX_HEIGHT 480
114
115/* Ignore errors in the first N frames, to allow for startup delays */
116#define FRAME_LOWMARK 5
117
118/* Size and number of buffers for the ISO pipe. */
119#define MAX_ISO_BUFS 3
120#define ISO_FRAMES_PER_DESC 10
121#define ISO_MAX_FRAME_SIZE 960
122#define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
123
124/* Maximum size after decompression is 640x480 YUV data, 1.5 * 640 * 480 */
125#define PWC_FRAME_SIZE (460800 + TOUCAM_HEADER_SIZE + TOUCAM_TRAILER_SIZE)
126
127/* Absolute minimum and maximum number of buffers available for mmap() */
128#define MIN_FRAMES 2
129#define MAX_FRAMES 16
130
131/* Some macros to quickly find the type of a webcam */
132#define DEVICE_USE_CODEC1(x) ((x)<675)
133#define DEVICE_USE_CODEC2(x) ((x)>=675 && (x)<700)
134#define DEVICE_USE_CODEC3(x) ((x)>=700)
135#define DEVICE_USE_CODEC23(x) ((x)>=675)
136
137/* Request types: video */
138#define SET_LUM_CTL 0x01
139#define GET_LUM_CTL 0x02
140#define SET_CHROM_CTL 0x03
141#define GET_CHROM_CTL 0x04
142#define SET_STATUS_CTL 0x05
143#define GET_STATUS_CTL 0x06
144#define SET_EP_STREAM_CTL 0x07
145#define GET_EP_STREAM_CTL 0x08
146#define GET_XX_CTL 0x09
147#define SET_XX_CTL 0x0A
148#define GET_XY_CTL 0x0B
149#define SET_XY_CTL 0x0C
150#define SET_MPT_CTL 0x0D
151#define GET_MPT_CTL 0x0E
152
153/* Selectors for the Luminance controls [GS]ET_LUM_CTL */
154#define AGC_MODE_FORMATTER 0x2000
155#define PRESET_AGC_FORMATTER 0x2100
156#define SHUTTER_MODE_FORMATTER 0x2200
157#define PRESET_SHUTTER_FORMATTER 0x2300
158#define PRESET_CONTOUR_FORMATTER 0x2400
159#define AUTO_CONTOUR_FORMATTER 0x2500
160#define BACK_LIGHT_COMPENSATION_FORMATTER 0x2600
161#define CONTRAST_FORMATTER 0x2700
162#define DYNAMIC_NOISE_CONTROL_FORMATTER 0x2800
163#define FLICKERLESS_MODE_FORMATTER 0x2900
164#define AE_CONTROL_SPEED 0x2A00
165#define BRIGHTNESS_FORMATTER 0x2B00
166#define GAMMA_FORMATTER 0x2C00
167
168/* Selectors for the Chrominance controls [GS]ET_CHROM_CTL */
169#define WB_MODE_FORMATTER 0x1000
170#define AWB_CONTROL_SPEED_FORMATTER 0x1100
171#define AWB_CONTROL_DELAY_FORMATTER 0x1200
172#define PRESET_MANUAL_RED_GAIN_FORMATTER 0x1300
173#define PRESET_MANUAL_BLUE_GAIN_FORMATTER 0x1400
174#define COLOUR_MODE_FORMATTER 0x1500
175#define SATURATION_MODE_FORMATTER1 0x1600
176#define SATURATION_MODE_FORMATTER2 0x1700
177
178/* Selectors for the Status controls [GS]ET_STATUS_CTL */
179#define SAVE_USER_DEFAULTS_FORMATTER 0x0200
180#define RESTORE_USER_DEFAULTS_FORMATTER 0x0300
181#define RESTORE_FACTORY_DEFAULTS_FORMATTER 0x0400
182#define READ_AGC_FORMATTER 0x0500
183#define READ_SHUTTER_FORMATTER 0x0600
184#define READ_RED_GAIN_FORMATTER 0x0700
185#define READ_BLUE_GAIN_FORMATTER 0x0800
186
187/* Formatters for the motorized pan & tilt [GS]ET_MPT_CTL */
188#define PT_RELATIVE_CONTROL_FORMATTER 0x01
189#define PT_RESET_CONTROL_FORMATTER 0x02
190#define PT_STATUS_FORMATTER 0x03
191
192/* Enumeration of image sizes */
193#define PSZ_SQCIF 0x00
194#define PSZ_QSIF 0x01
195#define PSZ_QCIF 0x02
196#define PSZ_SIF 0x03
197#define PSZ_CIF 0x04
198#define PSZ_VGA 0x05
199#define PSZ_MAX 6
200
201struct pwc_raw_frame {
202 __le16 type; /* type of the webcam */
203 __le16 vbandlength; /* Size of 4 lines compressed (used by the
204 decompressor) */
205 __u8 cmd[4]; /* the four byte of the command (in case of
206 nala, only the first 3 bytes is filled) */
207 __u8 rawframe[0]; /* frame_size = H / 4 * vbandlength */
208} __packed;
209
210/* intermediate buffers with raw data from the USB cam */
211struct pwc_frame_buf
212{
213 struct vb2_buffer vb; /* common v4l buffer stuff -- must be first */
214 struct list_head list;
215 void *data;
216 int filled; /* number of bytes filled */
217};
218
219struct pwc_device
220{
221 struct video_device vdev;
222 struct v4l2_device v4l2_dev;
223
224 /* videobuf2 queue and queued buffers list */
225 struct vb2_queue vb_queue;
226 struct list_head queued_bufs;
227 spinlock_t queued_bufs_lock; /* Protects queued_bufs */
228
229 /* Note if taking both locks v4l2_lock must always be locked first! */
230 struct mutex v4l2_lock; /* Protects everything else */
231 struct mutex vb_queue_lock; /* Protects vb_queue and capt_file */
232
233 /* Pointer to our usb_device, will be NULL after unplug */
234 struct usb_device *udev; /* Both mutexes most be hold when setting! */
235
236 /* type of cam (645, 646, 675, 680, 690, 720, 730, 740, 750) */
237 int type;
238 int release; /* release number */
239 int features; /* feature bits */
240
241 /*** Video data ***/
242 int vendpoint; /* video isoc endpoint */
243 int vcinterface; /* video control interface */
244 int valternate; /* alternate interface needed */
245 int vframes; /* frames-per-second */
246 int pixfmt; /* pixelformat: V4L2_PIX_FMT_YUV420 or _PWCX */
247 int vframe_count; /* received frames */
248 int vmax_packet_size; /* USB maxpacket size */
249 int vlast_packet_size; /* for frame synchronisation */
250 int visoc_errors; /* number of contiguous ISOC errors */
251 int vbandlength; /* compressed band length; 0 is uncompressed */
252 char vsync; /* used by isoc handler */
253 char vmirror; /* for ToUCaM series */
254 char power_save; /* Do powersaving for this cam */
255
256 unsigned char cmd_buf[13];
257 unsigned char *ctrl_buf;
258
259 struct urb *urbs[MAX_ISO_BUFS];
260
261 /*
262 * Frame currently being filled, this only gets touched by the
263 * isoc urb complete handler, and by stream start / stop since
264 * start / stop touch it before / after starting / killing the urbs
265 * no locking is needed around this
266 */
267 struct pwc_frame_buf *fill_buf;
268
269 int frame_header_size, frame_trailer_size;
270 int frame_size;
271 int frame_total_size; /* including header & trailer */
272 int drop_frames;
273
274 union { /* private data for decompression engine */
275 struct pwc_dec1_private dec1;
276 struct pwc_dec23_private dec23;
277 };
278
279 /*
280 * We have an 'image' and a 'view', where 'image' is the fixed-size img
281 * as delivered by the camera, and 'view' is the size requested by the
282 * program. The camera image is centered in this viewport, laced with
283 * a gray or black border. view_min <= image <= view <= view_max;
284 */
285 int image_mask; /* supported sizes */
286 int width, height; /* current resolution */
287
288#ifdef CONFIG_USB_PWC_INPUT_EVDEV
289 struct input_dev *button_dev; /* webcam snapshot button input */
290 char button_phys[64];
291#endif
292
293 /* controls */
294 struct v4l2_ctrl_handler ctrl_handler;
295 u16 saturation_fmt;
296 struct v4l2_ctrl *brightness;
297 struct v4l2_ctrl *contrast;
298 struct v4l2_ctrl *saturation;
299 struct v4l2_ctrl *gamma;
300 struct {
301 /* awb / red-blue balance cluster */
302 struct v4l2_ctrl *auto_white_balance;
303 struct v4l2_ctrl *red_balance;
304 struct v4l2_ctrl *blue_balance;
305 /* usb ctrl transfers are slow, so we cache things */
306 int color_bal_valid;
307 unsigned long last_color_bal_update; /* In jiffies */
308 s32 last_red_balance;
309 s32 last_blue_balance;
310 };
311 struct {
312 /* autogain / gain cluster */
313 struct v4l2_ctrl *autogain;
314 struct v4l2_ctrl *gain;
315 int gain_valid;
316 unsigned long last_gain_update; /* In jiffies */
317 s32 last_gain;
318 };
319 struct {
320 /* exposure_auto / exposure cluster */
321 struct v4l2_ctrl *exposure_auto;
322 struct v4l2_ctrl *exposure;
323 int exposure_valid;
324 unsigned long last_exposure_update; /* In jiffies */
325 s32 last_exposure;
326 };
327 struct v4l2_ctrl *colorfx;
328 struct {
329 /* autocontour/contour cluster */
330 struct v4l2_ctrl *autocontour;
331 struct v4l2_ctrl *contour;
332 };
333 struct v4l2_ctrl *backlight;
334 struct v4l2_ctrl *flicker;
335 struct v4l2_ctrl *noise_reduction;
336 struct v4l2_ctrl *save_user;
337 struct v4l2_ctrl *restore_user;
338 struct v4l2_ctrl *restore_factory;
339 struct v4l2_ctrl *awb_speed;
340 struct v4l2_ctrl *awb_delay;
341 struct {
342 /* motor control cluster */
343 struct v4l2_ctrl *motor_pan;
344 struct v4l2_ctrl *motor_tilt;
345 struct v4l2_ctrl *motor_pan_reset;
346 struct v4l2_ctrl *motor_tilt_reset;
347 };
348 /* CODEC3 models have both gain and exposure controlled by autogain */
349 struct v4l2_ctrl *autogain_expo_cluster[3];
350};
351
352/* Global variables */
353#ifdef CONFIG_USB_PWC_DEBUG
354extern int pwc_trace;
355#endif
356
357/** Functions in pwc-misc.c */
358/* sizes in pixels */
359extern const int pwc_image_sizes[PSZ_MAX][2];
360
361int pwc_get_size(struct pwc_device *pdev, int width, int height);
362void pwc_construct(struct pwc_device *pdev);
363
364/** Functions in pwc-ctrl.c */
365/* Request a certain video mode. Returns < 0 if not possible */
366extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
367 int pixfmt, int frames, int *compression, int send_to_cam);
368extern unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size);
369extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value);
370extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor);
371extern int send_control_msg(struct pwc_device *pdev,
372 u8 request, u16 value, void *buf, int buflen);
373
374/* Control get / set helpers */
375int pwc_get_u8_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *data);
376int pwc_set_u8_ctrl(struct pwc_device *pdev, u8 request, u16 value, u8 data);
377int pwc_get_s8_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *data);
378#define pwc_set_s8_ctrl pwc_set_u8_ctrl
379int pwc_get_u16_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *dat);
380int pwc_set_u16_ctrl(struct pwc_device *pdev, u8 request, u16 value, u16 data);
381int pwc_button_ctrl(struct pwc_device *pdev, u16 value);
382int pwc_init_controls(struct pwc_device *pdev);
383
384/* Power down or up the camera; not supported by all models */
385extern void pwc_camera_power(struct pwc_device *pdev, int power);
386
387extern const struct v4l2_ioctl_ops pwc_ioctl_ops;
388
389/** pwc-uncompress.c */
390/* Expand frame to image, possibly including decompression. Uses read_frame and fill_image */
391int pwc_decompress(struct pwc_device *pdev, struct pwc_frame_buf *fbuf);
392
393#endif