aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/sn9c102
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-03-25 07:19:53 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-03-25 07:29:23 -0500
commitd56410e0a594150c5ca06319da7bc8901c4d455e (patch)
treef1462651ac1bcc5cec48219dbb422ac615231423 /drivers/media/video/sn9c102
parent9f6933be665ce3b049c274c99810ac754edabf19 (diff)
V4L/DVB (3599b): Whitespace cleanups under drivers/media
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/sn9c102')
-rw-r--r--drivers/media/video/sn9c102/Makefile6
-rw-r--r--drivers/media/video/sn9c102/sn9c102.h8
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c264
-rw-r--r--drivers/media/video/sn9c102/sn9c102_hv7131d.c16
-rw-r--r--drivers/media/video/sn9c102/sn9c102_mi0343.c106
-rw-r--r--drivers/media/video/sn9c102/sn9c102_ov7630.c14
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas106b.c16
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas202bca.c6
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas202bcb.c18
-rw-r--r--drivers/media/video/sn9c102/sn9c102_sensor.h70
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5110c1b.c12
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5130d1b.c12
12 files changed, 274 insertions, 274 deletions
diff --git a/drivers/media/video/sn9c102/Makefile b/drivers/media/video/sn9c102/Makefile
index 8bcb0f71d69f..536ad3098da4 100644
--- a/drivers/media/video/sn9c102/Makefile
+++ b/drivers/media/video/sn9c102/Makefile
@@ -1,7 +1,7 @@
1sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o \ 1sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o \
2 sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bca.o \ 2 sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bca.o \
3 sn9c102_pas202bcb.o sn9c102_tas5110c1b.o \ 3 sn9c102_pas202bcb.o sn9c102_tas5110c1b.o \
4 sn9c102_tas5130d1b.o 4 sn9c102_tas5130d1b.o
5 5
6obj-$(CONFIG_USB_SN9C102) += sn9c102.o 6obj-$(CONFIG_USB_SN9C102) += sn9c102.o
7 7
diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h
index 1d70a62b9f23..2c6ff396dafc 100644
--- a/drivers/media/video/sn9c102/sn9c102.h
+++ b/drivers/media/video/sn9c102/sn9c102.h
@@ -164,7 +164,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id)
164 164
165void 165void
166sn9c102_attach_sensor(struct sn9c102_device* cam, 166sn9c102_attach_sensor(struct sn9c102_device* cam,
167 struct sn9c102_sensor* sensor) 167 struct sn9c102_sensor* sensor)
168{ 168{
169 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor)); 169 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor));
170} 170}
@@ -183,7 +183,7 @@ do { \
183 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ 183 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
184 else if ((level) >= 3) \ 184 else if ((level) >= 3) \
185 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 185 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
186 __FUNCTION__, __LINE__ , ## args); \ 186 __FUNCTION__, __LINE__ , ## args); \
187 } \ 187 } \
188} while (0) 188} while (0)
189# define V4LDBG(level, name, cmd) \ 189# define V4LDBG(level, name, cmd) \
@@ -198,7 +198,7 @@ do { \
198 pr_info("sn9c102: " fmt "\n", ## args); \ 198 pr_info("sn9c102: " fmt "\n", ## args); \
199 else if ((level) == 3) \ 199 else if ((level) == 3) \
200 pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \ 200 pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \
201 __LINE__ , ## args); \ 201 __LINE__ , ## args); \
202 } \ 202 } \
203} while (0) 203} while (0)
204#else 204#else
@@ -210,7 +210,7 @@ do { \
210#undef PDBG 210#undef PDBG
211#define PDBG(fmt, args...) \ 211#define PDBG(fmt, args...) \
212dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ 212dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
213 __FUNCTION__, __LINE__ , ## args) 213 __FUNCTION__, __LINE__ , ## args)
214 214
215#undef PDBGG 215#undef PDBGG
216#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ 216#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 4c6cc6395723..ea4394dc9415 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -62,53 +62,53 @@ MODULE_LICENSE(SN9C102_MODULE_LICENSE);
62static short video_nr[] = {[0 ... SN9C102_MAX_DEVICES-1] = -1}; 62static short video_nr[] = {[0 ... SN9C102_MAX_DEVICES-1] = -1};
63module_param_array(video_nr, short, NULL, 0444); 63module_param_array(video_nr, short, NULL, 0444);
64MODULE_PARM_DESC(video_nr, 64MODULE_PARM_DESC(video_nr,
65 "\n<-1|n[,...]> Specify V4L2 minor mode number." 65 "\n<-1|n[,...]> Specify V4L2 minor mode number."
66 "\n -1 = use next available (default)" 66 "\n -1 = use next available (default)"
67 "\n n = use minor number n (integer >= 0)" 67 "\n n = use minor number n (integer >= 0)"
68 "\nYou can specify up to "__MODULE_STRING(SN9C102_MAX_DEVICES) 68 "\nYou can specify up to "__MODULE_STRING(SN9C102_MAX_DEVICES)
69 " cameras this way." 69 " cameras this way."
70 "\nFor example:" 70 "\nFor example:"
71 "\nvideo_nr=-1,2,-1 would assign minor number 2 to" 71 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
72 "\nthe second camera and use auto for the first" 72 "\nthe second camera and use auto for the first"
73 "\none and for every other camera." 73 "\none and for every other camera."
74 "\n"); 74 "\n");
75 75
76static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] = 76static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] =
77 SN9C102_FORCE_MUNMAP}; 77 SN9C102_FORCE_MUNMAP};
78module_param_array(force_munmap, bool, NULL, 0444); 78module_param_array(force_munmap, bool, NULL, 0444);
79MODULE_PARM_DESC(force_munmap, 79MODULE_PARM_DESC(force_munmap,
80 "\n<0|1[,...]> Force the application to unmap previously" 80 "\n<0|1[,...]> Force the application to unmap previously"
81 "\nmapped buffer memory before calling any VIDIOC_S_CROP or" 81 "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
82 "\nVIDIOC_S_FMT ioctl's. Not all the applications support" 82 "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
83 "\nthis feature. This parameter is specific for each" 83 "\nthis feature. This parameter is specific for each"
84 "\ndetected camera." 84 "\ndetected camera."
85 "\n 0 = do not force memory unmapping" 85 "\n 0 = do not force memory unmapping"
86 "\n 1 = force memory unmapping (save memory)" 86 "\n 1 = force memory unmapping (save memory)"
87 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." 87 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
88 "\n"); 88 "\n");
89 89
90static unsigned int frame_timeout[] = {[0 ... SN9C102_MAX_DEVICES-1] = 90static unsigned int frame_timeout[] = {[0 ... SN9C102_MAX_DEVICES-1] =
91 SN9C102_FRAME_TIMEOUT}; 91 SN9C102_FRAME_TIMEOUT};
92module_param_array(frame_timeout, uint, NULL, 0644); 92module_param_array(frame_timeout, uint, NULL, 0644);
93MODULE_PARM_DESC(frame_timeout, 93MODULE_PARM_DESC(frame_timeout,
94 "\n<n[,...]> Timeout for a video frame in seconds." 94 "\n<n[,...]> Timeout for a video frame in seconds."
95 "\nThis parameter is specific for each detected camera." 95 "\nThis parameter is specific for each detected camera."
96 "\nDefault value is "__MODULE_STRING(SN9C102_FRAME_TIMEOUT)"." 96 "\nDefault value is "__MODULE_STRING(SN9C102_FRAME_TIMEOUT)"."
97 "\n"); 97 "\n");
98 98
99#ifdef SN9C102_DEBUG 99#ifdef SN9C102_DEBUG
100static unsigned short debug = SN9C102_DEBUG_LEVEL; 100static unsigned short debug = SN9C102_DEBUG_LEVEL;
101module_param(debug, ushort, 0644); 101module_param(debug, ushort, 0644);
102MODULE_PARM_DESC(debug, 102MODULE_PARM_DESC(debug,
103 "\n<n> Debugging information level, from 0 to 3:" 103 "\n<n> Debugging information level, from 0 to 3:"
104 "\n0 = none (use carefully)" 104 "\n0 = none (use carefully)"
105 "\n1 = critical errors" 105 "\n1 = critical errors"
106 "\n2 = significant informations" 106 "\n2 = significant informations"
107 "\n3 = more verbose messages" 107 "\n3 = more verbose messages"
108 "\nLevel 3 is useful for testing only, when only " 108 "\nLevel 3 is useful for testing only, when only "
109 "one device is used." 109 "one device is used."
110 "\nDefault value is "__MODULE_STRING(SN9C102_DEBUG_LEVEL)"." 110 "\nDefault value is "__MODULE_STRING(SN9C102_DEBUG_LEVEL)"."
111 "\n"); 111 "\n");
112#endif 112#endif
113 113
114/*****************************************************************************/ 114/*****************************************************************************/
@@ -131,16 +131,16 @@ static sn9c102_eof_header_t sn9c102_eof_header[] = {
131 131
132/*****************************************************************************/ 132/*****************************************************************************/
133 133
134static u32 134static u32
135sn9c102_request_buffers(struct sn9c102_device* cam, u32 count, 135sn9c102_request_buffers(struct sn9c102_device* cam, u32 count,
136 enum sn9c102_io_method io) 136 enum sn9c102_io_method io)
137{ 137{
138 struct v4l2_pix_format* p = &(cam->sensor.pix_format); 138 struct v4l2_pix_format* p = &(cam->sensor.pix_format);
139 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds); 139 struct v4l2_rect* r = &(cam->sensor.cropcap.bounds);
140 const size_t imagesize = cam->module_param.force_munmap || 140 const size_t imagesize = cam->module_param.force_munmap ||
141 io == IO_READ ? 141 io == IO_READ ?
142 (p->width * p->height * p->priv) / 8 : 142 (p->width * p->height * p->priv) / 8 :
143 (r->width * r->height * p->priv) / 8; 143 (r->width * r->height * p->priv) / 8;
144 void* buff = NULL; 144 void* buff = NULL;
145 u32 i; 145 u32 i;
146 146
@@ -232,8 +232,8 @@ int sn9c102_write_regs(struct sn9c102_device* cam, u8* buff, u16 index)
232 return -1; 232 return -1;
233 233
234 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 234 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
235 index, 0, buff, sizeof(buff), 235 index, 0, buff, sizeof(buff),
236 SN9C102_CTRL_TIMEOUT*sizeof(buff)); 236 SN9C102_CTRL_TIMEOUT*sizeof(buff));
237 if (res < 0) { 237 if (res < 0) {
238 DBG(3, "Failed to write registers (index 0x%02X, error %d)", 238 DBG(3, "Failed to write registers (index 0x%02X, error %d)",
239 index, res); 239 index, res);
@@ -259,7 +259,7 @@ int sn9c102_write_reg(struct sn9c102_device* cam, u8 value, u16 index)
259 *buff = value; 259 *buff = value;
260 260
261 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 261 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
262 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT); 262 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
263 if (res < 0) { 263 if (res < 0) {
264 DBG(3, "Failed to write a register (value 0x%02X, index " 264 DBG(3, "Failed to write a register (value 0x%02X, index "
265 "0x%02X, error %d)", value, index, res); 265 "0x%02X, error %d)", value, index, res);
@@ -280,7 +280,7 @@ static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index)
280 int res; 280 int res;
281 281
282 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, 282 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
283 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT); 283 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
284 if (res < 0) 284 if (res < 0)
285 DBG(3, "Failed to read a register (index 0x%02X, error %d)", 285 DBG(3, "Failed to read a register (index 0x%02X, error %d)",
286 index, res); 286 index, res);
@@ -319,8 +319,8 @@ sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor)
319 319
320 320
321static int 321static int
322sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, 322sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
323 struct sn9c102_sensor* sensor) 323 struct sn9c102_sensor* sensor)
324{ 324{
325 int r; 325 int r;
326 r = sn9c102_read_reg(cam, 0x08); 326 r = sn9c102_read_reg(cam, 0x08);
@@ -329,8 +329,8 @@ sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
329 329
330 330
331static int 331static int
332sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, 332sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
333 struct sn9c102_sensor* sensor) 333 struct sn9c102_sensor* sensor)
334{ 334{
335 int r; 335 int r;
336 r = sn9c102_read_reg(cam, 0x08); 336 r = sn9c102_read_reg(cam, 0x08);
@@ -338,10 +338,10 @@ sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
338} 338}
339 339
340 340
341int 341int
342sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 342sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
343 struct sn9c102_sensor* sensor, u8 data0, u8 data1, 343 struct sn9c102_sensor* sensor, u8 data0, u8 data1,
344 u8 n, u8 buffer[]) 344 u8 n, u8 buffer[])
345{ 345{
346 struct usb_device* udev = cam->usbdev; 346 struct usb_device* udev = cam->usbdev;
347 u8* data = cam->control_buffer; 347 u8* data = cam->control_buffer;
@@ -349,12 +349,12 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
349 349
350 /* Write cycle */ 350 /* Write cycle */
351 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 351 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
352 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 0x10; 352 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 0x10;
353 data[1] = data0; /* I2C slave id */ 353 data[1] = data0; /* I2C slave id */
354 data[2] = data1; /* address */ 354 data[2] = data1; /* address */
355 data[7] = 0x10; 355 data[7] = 0x10;
356 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 356 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
357 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT); 357 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
358 if (res < 0) 358 if (res < 0)
359 err += res; 359 err += res;
360 360
@@ -362,12 +362,12 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
362 362
363 /* Read cycle - n bytes */ 363 /* Read cycle - n bytes */
364 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 364 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
365 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 365 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) |
366 (n << 4) | 0x02; 366 (n << 4) | 0x02;
367 data[1] = data0; 367 data[1] = data0;
368 data[7] = 0x10; 368 data[7] = 0x10;
369 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 369 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
370 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT); 370 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
371 if (res < 0) 371 if (res < 0)
372 err += res; 372 err += res;
373 373
@@ -375,7 +375,7 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
375 375
376 /* The first read byte will be placed in data[4] */ 376 /* The first read byte will be placed in data[4] */
377 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, 377 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
378 0x0a, 0, data, 5, SN9C102_CTRL_TIMEOUT); 378 0x0a, 0, data, 5, SN9C102_CTRL_TIMEOUT);
379 if (res < 0) 379 if (res < 0)
380 err += res; 380 err += res;
381 381
@@ -396,10 +396,10 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
396} 396}
397 397
398 398
399int 399int
400sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 400sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
401 struct sn9c102_sensor* sensor, u8 n, u8 data0, 401 struct sn9c102_sensor* sensor, u8 n, u8 data0,
402 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5) 402 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5)
403{ 403{
404 struct usb_device* udev = cam->usbdev; 404 struct usb_device* udev = cam->usbdev;
405 u8* data = cam->control_buffer; 405 u8* data = cam->control_buffer;
@@ -407,8 +407,8 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
407 407
408 /* Write cycle. It usually is address + value */ 408 /* Write cycle. It usually is address + value */
409 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 409 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
410 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) 410 ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0)
411 | ((n - 1) << 4); 411 | ((n - 1) << 4);
412 data[1] = data0; 412 data[1] = data0;
413 data[2] = data1; 413 data[2] = data1;
414 data[3] = data2; 414 data[3] = data2;
@@ -417,7 +417,7 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
417 data[6] = data5; 417 data[6] = data5;
418 data[7] = 0x14; 418 data[7] = 0x14;
419 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 419 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
420 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT); 420 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
421 if (res < 0) 421 if (res < 0)
422 err += res; 422 err += res;
423 423
@@ -437,20 +437,20 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
437 437
438int 438int
439sn9c102_i2c_try_read(struct sn9c102_device* cam, 439sn9c102_i2c_try_read(struct sn9c102_device* cam,
440 struct sn9c102_sensor* sensor, u8 address) 440 struct sn9c102_sensor* sensor, u8 address)
441{ 441{
442 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id, 442 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id,
443 address, 1, NULL); 443 address, 1, NULL);
444} 444}
445 445
446 446
447int 447int
448sn9c102_i2c_try_write(struct sn9c102_device* cam, 448sn9c102_i2c_try_write(struct sn9c102_device* cam,
449 struct sn9c102_sensor* sensor, u8 address, u8 value) 449 struct sn9c102_sensor* sensor, u8 address, u8 value)
450{ 450{
451 return sn9c102_i2c_try_raw_write(cam, sensor, 3, 451 return sn9c102_i2c_try_raw_write(cam, sensor, 3,
452 sensor->i2c_slave_id, address, 452 sensor->i2c_slave_id, address,
453 value, 0, 0, 0); 453 value, 0, 0, 0);
454} 454}
455 455
456 456
@@ -484,7 +484,7 @@ sn9c102_find_sof_header(struct sn9c102_device* cam, void* mem, size_t len)
484 n = sizeof(sn9c103_sof_header) / soflen; 484 n = sizeof(sn9c103_sof_header) / soflen;
485 } 485 }
486 486
487 for (i = 0; (len >= soflen) && (i <= len - soflen); i++) 487 for (i = 0; (len >= soflen) && (i <= len - soflen); i++)
488 for (j = 0; j < n; j++) 488 for (j = 0; j < n; j++)
489 /* The invariable part of the header is 6 bytes long */ 489 /* The invariable part of the header is 6 bytes long */
490 if ((cam->bridge != BRIDGE_SN9C103 && 490 if ((cam->bridge != BRIDGE_SN9C103 &&
@@ -552,15 +552,15 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs)
552 552
553 if (!(*f)) 553 if (!(*f))
554 (*f) = list_entry(cam->inqueue.next, struct sn9c102_frame_t, 554 (*f) = list_entry(cam->inqueue.next, struct sn9c102_frame_t,
555 frame); 555 frame);
556 556
557 imagesize = (cam->sensor.pix_format.width * 557 imagesize = (cam->sensor.pix_format.width *
558 cam->sensor.pix_format.height * 558 cam->sensor.pix_format.height *
559 cam->sensor.pix_format.priv) / 8; 559 cam->sensor.pix_format.priv) / 8;
560 560
561 soflen = (cam->bridge) == BRIDGE_SN9C103 ? 561 soflen = (cam->bridge) == BRIDGE_SN9C103 ?
562 sizeof(sn9c103_sof_header_t) : 562 sizeof(sn9c103_sof_header_t) :
563 sizeof(sn9c102_sof_header_t); 563 sizeof(sn9c102_sof_header_t);
564 564
565 for (i = 0; i < urb->number_of_packets; i++) { 565 for (i = 0; i < urb->number_of_packets; i++) {
566 unsigned int img, len, status; 566 unsigned int img, len, status;
@@ -611,19 +611,19 @@ end_of_frame:
611 611
612 if ((*f)->buf.bytesused == imagesize || 612 if ((*f)->buf.bytesused == imagesize ||
613 (cam->sensor.pix_format.pixelformat == 613 (cam->sensor.pix_format.pixelformat ==
614 V4L2_PIX_FMT_SN9C10X && eof)) { 614 V4L2_PIX_FMT_SN9C10X && eof)) {
615 u32 b; 615 u32 b;
616 b = (*f)->buf.bytesused; 616 b = (*f)->buf.bytesused;
617 (*f)->state = F_DONE; 617 (*f)->state = F_DONE;
618 (*f)->buf.sequence= ++cam->frame_count; 618 (*f)->buf.sequence= ++cam->frame_count;
619 spin_lock(&cam->queue_lock); 619 spin_lock(&cam->queue_lock);
620 list_move_tail(&(*f)->frame, 620 list_move_tail(&(*f)->frame,
621 &cam->outqueue); 621 &cam->outqueue);
622 if (!list_empty(&cam->inqueue)) 622 if (!list_empty(&cam->inqueue))
623 (*f) = list_entry( 623 (*f) = list_entry(
624 cam->inqueue.next, 624 cam->inqueue.next,
625 struct sn9c102_frame_t, 625 struct sn9c102_frame_t,
626 frame ); 626 frame );
627 else 627 else
628 (*f) = NULL; 628 (*f) = NULL;
629 spin_unlock(&cam->queue_lock); 629 spin_unlock(&cam->queue_lock);
@@ -638,7 +638,7 @@ end_of_frame:
638 } else if (eof) { 638 } else if (eof) {
639 (*f)->state = F_ERROR; 639 (*f)->state = F_ERROR;
640 DBG(3, "Not expected EOF after %lu " 640 DBG(3, "Not expected EOF after %lu "
641 "bytes of image data", 641 "bytes of image data",
642 (unsigned long) 642 (unsigned long)
643 ((*f)->buf.bytesused)); 643 ((*f)->buf.bytesused));
644 } 644 }
@@ -676,7 +676,7 @@ start_of_frame:
676 goto end_of_frame; 676 goto end_of_frame;
677 } else { 677 } else {
678 DBG(3, "SOF before expected EOF after " 678 DBG(3, "SOF before expected EOF after "
679 "%lu bytes of image data", 679 "%lu bytes of image data",
680 (unsigned long) 680 (unsigned long)
681 ((*f)->buf.bytesused)); 681 ((*f)->buf.bytesused));
682 goto start_of_frame; 682 goto start_of_frame;
@@ -702,18 +702,18 @@ static int sn9c102_start_transfer(struct sn9c102_device* cam)
702 struct usb_device *udev = cam->usbdev; 702 struct usb_device *udev = cam->usbdev;
703 struct urb* urb; 703 struct urb* urb;
704 const unsigned int sn9c102_wMaxPacketSize[] = {0, 128, 256, 384, 512, 704 const unsigned int sn9c102_wMaxPacketSize[] = {0, 128, 256, 384, 512,
705 680, 800, 900, 1023}; 705 680, 800, 900, 1023};
706 const unsigned int sn9c103_wMaxPacketSize[] = {0, 128, 256, 384, 512, 706 const unsigned int sn9c103_wMaxPacketSize[] = {0, 128, 256, 384, 512,
707 680, 800, 900, 1003}; 707 680, 800, 900, 1003};
708 const unsigned int psz = (cam->bridge == BRIDGE_SN9C103) ? 708 const unsigned int psz = (cam->bridge == BRIDGE_SN9C103) ?
709 sn9c103_wMaxPacketSize[SN9C102_ALTERNATE_SETTING] : 709 sn9c103_wMaxPacketSize[SN9C102_ALTERNATE_SETTING] :
710 sn9c102_wMaxPacketSize[SN9C102_ALTERNATE_SETTING]; 710 sn9c102_wMaxPacketSize[SN9C102_ALTERNATE_SETTING];
711 s8 i, j; 711 s8 i, j;
712 int err = 0; 712 int err = 0;
713 713
714 for (i = 0; i < SN9C102_URBS; i++) { 714 for (i = 0; i < SN9C102_URBS; i++) {
715 cam->transfer_buffer[i] = kzalloc(SN9C102_ISO_PACKETS * psz, 715 cam->transfer_buffer[i] = kzalloc(SN9C102_ISO_PACKETS * psz,
716 GFP_KERNEL); 716 GFP_KERNEL);
717 if (!cam->transfer_buffer[i]) { 717 if (!cam->transfer_buffer[i]) {
718 err = -ENOMEM; 718 err = -ENOMEM;
719 DBG(1, "Not enough memory"); 719 DBG(1, "Not enough memory");
@@ -815,9 +815,9 @@ static int sn9c102_stream_interrupt(struct sn9c102_device* cam)
815 815
816 cam->stream = STREAM_INTERRUPT; 816 cam->stream = STREAM_INTERRUPT;
817 timeout = wait_event_timeout(cam->wait_stream, 817 timeout = wait_event_timeout(cam->wait_stream,
818 (cam->stream == STREAM_OFF) || 818 (cam->stream == STREAM_OFF) ||
819 (cam->state & DEV_DISCONNECTED), 819 (cam->state & DEV_DISCONNECTED),
820 SN9C102_URB_TIMEOUT); 820 SN9C102_URB_TIMEOUT);
821 if (cam->state & DEV_DISCONNECTED) 821 if (cam->state & DEV_DISCONNECTED)
822 return -ENODEV; 822 return -ENODEV;
823 else if (cam->stream != STREAM_OFF) { 823 else if (cam->stream != STREAM_OFF) {
@@ -861,7 +861,7 @@ static u8 sn9c102_strtou8(const char* buff, size_t len, ssize_t* count)
861 861
862/* 862/*
863 NOTE 1: being inside one of the following methods implies that the v4l 863 NOTE 1: being inside one of the following methods implies that the v4l
864 device exists for sure (see kobjects and reference counters) 864 device exists for sure (see kobjects and reference counters)
865 NOTE 2: buffers are PAGE_SIZE long 865 NOTE 2: buffers are PAGE_SIZE long
866*/ 866*/
867 867
@@ -884,10 +884,10 @@ static ssize_t sn9c102_show_reg(struct class_device* cd, char* buf)
884 mutex_unlock(&sn9c102_sysfs_lock); 884 mutex_unlock(&sn9c102_sysfs_lock);
885 885
886 return count; 886 return count;
887} 887}
888 888
889 889
890static ssize_t 890static ssize_t
891sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len) 891sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len)
892{ 892{
893 struct sn9c102_device* cam; 893 struct sn9c102_device* cam;
@@ -947,7 +947,7 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf)
947 mutex_unlock(&sn9c102_sysfs_lock); 947 mutex_unlock(&sn9c102_sysfs_lock);
948 948
949 return count; 949 return count;
950} 950}
951 951
952 952
953static ssize_t 953static ssize_t
@@ -1013,7 +1013,7 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf)
1013} 1013}
1014 1014
1015 1015
1016static ssize_t 1016static ssize_t
1017sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) 1017sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len)
1018{ 1018{
1019 struct sn9c102_device* cam; 1019 struct sn9c102_device* cam;
@@ -1078,7 +1078,7 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf)
1078 mutex_unlock(&sn9c102_sysfs_lock); 1078 mutex_unlock(&sn9c102_sysfs_lock);
1079 1079
1080 return count; 1080 return count;
1081} 1081}
1082 1082
1083 1083
1084static ssize_t 1084static ssize_t
@@ -1222,22 +1222,22 @@ static ssize_t sn9c102_show_frame_header(struct class_device* cd, char* buf)
1222 DBG(3, "Frame header, read bytes: %zd", count); 1222 DBG(3, "Frame header, read bytes: %zd", count);
1223 1223
1224 return count; 1224 return count;
1225} 1225}
1226 1226
1227 1227
1228static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, 1228static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR,
1229 sn9c102_show_reg, sn9c102_store_reg); 1229 sn9c102_show_reg, sn9c102_store_reg);
1230static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR, 1230static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
1231 sn9c102_show_val, sn9c102_store_val); 1231 sn9c102_show_val, sn9c102_store_val);
1232static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR, 1232static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR,
1233 sn9c102_show_i2c_reg, sn9c102_store_i2c_reg); 1233 sn9c102_show_i2c_reg, sn9c102_store_i2c_reg);
1234static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, 1234static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
1235 sn9c102_show_i2c_val, sn9c102_store_i2c_val); 1235 sn9c102_show_i2c_val, sn9c102_store_i2c_val);
1236static CLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green); 1236static CLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green);
1237static CLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue); 1237static CLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue);
1238static CLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red); 1238static CLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red);
1239static CLASS_DEVICE_ATTR(frame_header, S_IRUGO, 1239static CLASS_DEVICE_ATTR(frame_header, S_IRUGO,
1240 sn9c102_show_frame_header, NULL); 1240 sn9c102_show_frame_header, NULL);
1241 1241
1242 1242
1243static void sn9c102_create_sysfs(struct sn9c102_device* cam) 1243static void sn9c102_create_sysfs(struct sn9c102_device* cam)
@@ -1278,7 +1278,7 @@ sn9c102_set_pix_format(struct sn9c102_device* cam, struct v4l2_pix_format* pix)
1278 1278
1279static int 1279static int
1280sn9c102_set_compression(struct sn9c102_device* cam, 1280sn9c102_set_compression(struct sn9c102_device* cam,
1281 struct v4l2_jpegcompression* compression) 1281 struct v4l2_jpegcompression* compression)
1282{ 1282{
1283 int err = 0; 1283 int err = 0;
1284 1284
@@ -1469,8 +1469,8 @@ static int sn9c102_open(struct inode* inode, struct file* filp)
1469 } 1469 }
1470 mutex_unlock(&cam->dev_mutex); 1470 mutex_unlock(&cam->dev_mutex);
1471 err = wait_event_interruptible_exclusive(cam->open, 1471 err = wait_event_interruptible_exclusive(cam->open,
1472 cam->state & DEV_DISCONNECTED 1472 cam->state & DEV_DISCONNECTED
1473 || !cam->users); 1473 || !cam->users);
1474 if (err) { 1474 if (err) {
1475 up_read(&sn9c102_disconnect); 1475 up_read(&sn9c102_disconnect);
1476 return err; 1476 return err;
@@ -1600,12 +1600,12 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
1600 return -EAGAIN; 1600 return -EAGAIN;
1601 } 1601 }
1602 timeout = wait_event_interruptible_timeout 1602 timeout = wait_event_interruptible_timeout
1603 ( cam->wait_frame, 1603 ( cam->wait_frame,
1604 (!list_empty(&cam->outqueue)) || 1604 (!list_empty(&cam->outqueue)) ||
1605 (cam->state & DEV_DISCONNECTED) || 1605 (cam->state & DEV_DISCONNECTED) ||
1606 (cam->state & DEV_MISCONFIGURED), 1606 (cam->state & DEV_MISCONFIGURED),
1607 cam->module_param.frame_timeout * 1607 cam->module_param.frame_timeout *
1608 1000 * msecs_to_jiffies(1) ); 1608 1000 * msecs_to_jiffies(1) );
1609 if (timeout < 0) { 1609 if (timeout < 0) {
1610 mutex_unlock(&cam->fileop_mutex); 1610 mutex_unlock(&cam->fileop_mutex);
1611 return timeout; 1611 return timeout;
@@ -1672,7 +1672,7 @@ static unsigned int sn9c102_poll(struct file *filp, poll_table *wait)
1672 1672
1673 if (cam->io == IO_NONE) { 1673 if (cam->io == IO_NONE) {
1674 if (!sn9c102_request_buffers(cam, cam->nreadbuffers, 1674 if (!sn9c102_request_buffers(cam, cam->nreadbuffers,
1675 IO_READ)) { 1675 IO_READ)) {
1676 DBG(1, "poll() failed, not enough memory"); 1676 DBG(1, "poll() failed, not enough memory");
1677 goto error; 1677 goto error;
1678 } 1678 }
@@ -1729,7 +1729,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma)
1729{ 1729{
1730 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 1730 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
1731 unsigned long size = vma->vm_end - vma->vm_start, 1731 unsigned long size = vma->vm_end - vma->vm_start,
1732 start = vma->vm_start; 1732 start = vma->vm_start;
1733 void *pos; 1733 void *pos;
1734 u32 i; 1734 u32 i;
1735 1735
@@ -1797,13 +1797,13 @@ sn9c102_vidioc_querycap(struct sn9c102_device* cam, void __user * arg)
1797 .driver = "sn9c102", 1797 .driver = "sn9c102",
1798 .version = SN9C102_MODULE_VERSION_CODE, 1798 .version = SN9C102_MODULE_VERSION_CODE,
1799 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | 1799 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1800 V4L2_CAP_STREAMING, 1800 V4L2_CAP_STREAMING,
1801 }; 1801 };
1802 1802
1803 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card)); 1803 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
1804 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0) 1804 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
1805 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id, 1805 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
1806 sizeof(cap.bus_info)); 1806 sizeof(cap.bus_info));
1807 1807
1808 if (copy_to_user(arg, &cap, sizeof(cap))) 1808 if (copy_to_user(arg, &cap, sizeof(cap)))
1809 return -EFAULT; 1809 return -EFAULT;
@@ -2138,7 +2138,7 @@ sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg)
2138 return -EINVAL; 2138 return -EINVAL;
2139 2139
2140 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_SN9C10X) 2140 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_SN9C10X)
2141 ? 0 : (pfmt->width * pfmt->priv) / 8; 2141 ? 0 : (pfmt->width * pfmt->priv) / 8;
2142 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8); 2142 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
2143 pfmt->field = V4L2_FIELD_NONE; 2143 pfmt->field = V4L2_FIELD_NONE;
2144 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt)); 2144 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
@@ -2152,7 +2152,7 @@ sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg)
2152 2152
2153static int 2153static int
2154sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd, 2154sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
2155 void __user * arg) 2155 void __user * arg)
2156{ 2156{
2157 struct sn9c102_sensor* s = &cam->sensor; 2157 struct sn9c102_sensor* s = &cam->sensor;
2158 struct v4l2_format format; 2158 struct v4l2_format format;
@@ -2214,7 +2214,7 @@ sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
2214 pix->priv = pfmt->priv; /* bpp */ 2214 pix->priv = pfmt->priv; /* bpp */
2215 pix->colorspace = pfmt->colorspace; 2215 pix->colorspace = pfmt->colorspace;
2216 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) 2216 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_SN9C10X)
2217 ? 0 : (pix->width * pix->priv) / 8; 2217 ? 0 : (pix->width * pix->priv) / 8;
2218 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8); 2218 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
2219 pix->field = V4L2_FIELD_NONE; 2219 pix->field = V4L2_FIELD_NONE;
2220 2220
@@ -2287,7 +2287,7 @@ static int
2287sn9c102_vidioc_g_jpegcomp(struct sn9c102_device* cam, void __user * arg) 2287sn9c102_vidioc_g_jpegcomp(struct sn9c102_device* cam, void __user * arg)
2288{ 2288{
2289 if (copy_to_user(arg, &cam->compression, 2289 if (copy_to_user(arg, &cam->compression,
2290 sizeof(cam->compression))) 2290 sizeof(cam->compression)))
2291 return -EFAULT; 2291 return -EFAULT;
2292 2292
2293 return 0; 2293 return 0;
@@ -2436,7 +2436,7 @@ sn9c102_vidioc_qbuf(struct sn9c102_device* cam, void __user * arg)
2436 2436
2437static int 2437static int
2438sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp, 2438sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp,
2439 void __user * arg) 2439 void __user * arg)
2440{ 2440{
2441 struct v4l2_buffer b; 2441 struct v4l2_buffer b;
2442 struct sn9c102_frame_t *f; 2442 struct sn9c102_frame_t *f;
@@ -2455,12 +2455,12 @@ sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp,
2455 if (filp->f_flags & O_NONBLOCK) 2455 if (filp->f_flags & O_NONBLOCK)
2456 return -EAGAIN; 2456 return -EAGAIN;
2457 timeout = wait_event_interruptible_timeout 2457 timeout = wait_event_interruptible_timeout
2458 ( cam->wait_frame, 2458 ( cam->wait_frame,
2459 (!list_empty(&cam->outqueue)) || 2459 (!list_empty(&cam->outqueue)) ||
2460 (cam->state & DEV_DISCONNECTED) || 2460 (cam->state & DEV_DISCONNECTED) ||
2461 (cam->state & DEV_MISCONFIGURED), 2461 (cam->state & DEV_MISCONFIGURED),
2462 cam->module_param.frame_timeout * 2462 cam->module_param.frame_timeout *
2463 1000 * msecs_to_jiffies(1) ); 2463 1000 * msecs_to_jiffies(1) );
2464 if (timeout < 0) 2464 if (timeout < 0)
2465 return timeout; 2465 return timeout;
2466 if (cam->state & DEV_DISCONNECTED) 2466 if (cam->state & DEV_DISCONNECTED)
@@ -2584,7 +2584,7 @@ sn9c102_vidioc_s_parm(struct sn9c102_device* cam, void __user * arg)
2584 2584
2585 2585
2586static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, 2586static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
2587 unsigned int cmd, void __user * arg) 2587 unsigned int cmd, void __user * arg)
2588{ 2588{
2589 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 2589 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
2590 2590
@@ -2678,7 +2678,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
2678 2678
2679 2679
2680static int sn9c102_ioctl(struct inode* inode, struct file* filp, 2680static int sn9c102_ioctl(struct inode* inode, struct file* filp,
2681 unsigned int cmd, unsigned long arg) 2681 unsigned int cmd, unsigned long arg)
2682{ 2682{
2683 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 2683 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
2684 int err = 0; 2684 int err = 0;
@@ -2761,7 +2761,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2761 } 2761 }
2762 2762
2763 cam->bridge = (id->idProduct & 0xffc0) == 0x6080 ? 2763 cam->bridge = (id->idProduct & 0xffc0) == 0x6080 ?
2764 BRIDGE_SN9C103 : BRIDGE_SN9C102; 2764 BRIDGE_SN9C103 : BRIDGE_SN9C102;
2765 switch (cam->bridge) { 2765 switch (cam->bridge) {
2766 case BRIDGE_SN9C101: 2766 case BRIDGE_SN9C101:
2767 case BRIDGE_SN9C102: 2767 case BRIDGE_SN9C102:
@@ -2807,7 +2807,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2807 mutex_lock(&cam->dev_mutex); 2807 mutex_lock(&cam->dev_mutex);
2808 2808
2809 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 2809 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
2810 video_nr[dev_nr]); 2810 video_nr[dev_nr]);
2811 if (err) { 2811 if (err) {
2812 DBG(1, "V4L2 device registration failed"); 2812 DBG(1, "V4L2 device registration failed");
2813 if (err == -ENFILE && video_nr[dev_nr] == -1) 2813 if (err == -ENFILE && video_nr[dev_nr] == -1)
diff --git a/drivers/media/video/sn9c102/sn9c102_hv7131d.c b/drivers/media/video/sn9c102/sn9c102_hv7131d.c
index 46c12ec3ca62..c4117bf64b69 100644
--- a/drivers/media/video/sn9c102/sn9c102_hv7131d.c
+++ b/drivers/media/video/sn9c102/sn9c102_hv7131d.c
@@ -44,8 +44,8 @@ static int hv7131d_init(struct sn9c102_device* cam)
44} 44}
45 45
46 46
47static int hv7131d_get_ctrl(struct sn9c102_device* cam, 47static int hv7131d_get_ctrl(struct sn9c102_device* cam,
48 struct v4l2_control* ctrl) 48 struct v4l2_control* ctrl)
49{ 49{
50 switch (ctrl->id) { 50 switch (ctrl->id) {
51 case V4L2_CID_EXPOSURE: 51 case V4L2_CID_EXPOSURE:
@@ -88,8 +88,8 @@ static int hv7131d_get_ctrl(struct sn9c102_device* cam,
88} 88}
89 89
90 90
91static int hv7131d_set_ctrl(struct sn9c102_device* cam, 91static int hv7131d_set_ctrl(struct sn9c102_device* cam,
92 const struct v4l2_control* ctrl) 92 const struct v4l2_control* ctrl)
93{ 93{
94 int err = 0; 94 int err = 0;
95 95
@@ -121,8 +121,8 @@ static int hv7131d_set_ctrl(struct sn9c102_device* cam,
121} 121}
122 122
123 123
124static int hv7131d_set_crop(struct sn9c102_device* cam, 124static int hv7131d_set_crop(struct sn9c102_device* cam,
125 const struct v4l2_rect* rect) 125 const struct v4l2_rect* rect)
126{ 126{
127 struct sn9c102_sensor* s = &hv7131d; 127 struct sn9c102_sensor* s = &hv7131d;
128 int err = 0; 128 int err = 0;
@@ -136,8 +136,8 @@ static int hv7131d_set_crop(struct sn9c102_device* cam,
136} 136}
137 137
138 138
139static int hv7131d_set_pix_format(struct sn9c102_device* cam, 139static int hv7131d_set_pix_format(struct sn9c102_device* cam,
140 const struct v4l2_pix_format* pix) 140 const struct v4l2_pix_format* pix)
141{ 141{
142 int err = 0; 142 int err = 0;
143 143
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0343.c b/drivers/media/video/sn9c102/sn9c102_mi0343.c
index d9aa7a61095d..4169ea4a2e20 100644
--- a/drivers/media/video/sn9c102/sn9c102_mi0343.c
+++ b/drivers/media/video/sn9c102/sn9c102_mi0343.c
@@ -39,64 +39,64 @@ static int mi0343_init(struct sn9c102_device* cam)
39 err += sn9c102_write_reg(cam, 0xa0, 0x19); 39 err += sn9c102_write_reg(cam, 0xa0, 0x19);
40 40
41 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 41 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
42 0x0d, 0x00, 0x01, 0, 0); 42 0x0d, 0x00, 0x01, 0, 0);
43 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 43 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
44 0x0d, 0x00, 0x00, 0, 0); 44 0x0d, 0x00, 0x00, 0, 0);
45 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 45 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
46 0x03, 0x01, 0xe1, 0, 0); 46 0x03, 0x01, 0xe1, 0, 0);
47 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 47 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
48 0x04, 0x02, 0x81, 0, 0); 48 0x04, 0x02, 0x81, 0, 0);
49 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 49 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
50 0x05, 0x00, 0x17, 0, 0); 50 0x05, 0x00, 0x17, 0, 0);
51 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 51 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
52 0x06, 0x00, 0x11, 0, 0); 52 0x06, 0x00, 0x11, 0, 0);
53 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id, 53 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
54 0x62, 0x04, 0x9a, 0, 0); 54 0x62, 0x04, 0x9a, 0, 0);
55 55
56 return err; 56 return err;
57} 57}
58 58
59 59
60static int mi0343_get_ctrl(struct sn9c102_device* cam, 60static int mi0343_get_ctrl(struct sn9c102_device* cam,
61 struct v4l2_control* ctrl) 61 struct v4l2_control* ctrl)
62{ 62{
63 switch (ctrl->id) { 63 switch (ctrl->id) {
64 case V4L2_CID_EXPOSURE: 64 case V4L2_CID_EXPOSURE:
65 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 65 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
66 0x09, 2+1, mi0343_i2c_data) < 0) 66 0x09, 2+1, mi0343_i2c_data) < 0)
67 return -EIO; 67 return -EIO;
68 ctrl->value = mi0343_i2c_data[2]; 68 ctrl->value = mi0343_i2c_data[2];
69 return 0; 69 return 0;
70 case V4L2_CID_GAIN: 70 case V4L2_CID_GAIN:
71 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 71 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
72 0x35, 2+1, mi0343_i2c_data) < 0) 72 0x35, 2+1, mi0343_i2c_data) < 0)
73 return -EIO; 73 return -EIO;
74 break; 74 break;
75 case V4L2_CID_HFLIP: 75 case V4L2_CID_HFLIP:
76 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 76 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
77 0x20, 2+1, mi0343_i2c_data) < 0) 77 0x20, 2+1, mi0343_i2c_data) < 0)
78 return -EIO; 78 return -EIO;
79 ctrl->value = mi0343_i2c_data[3] & 0x20 ? 1 : 0; 79 ctrl->value = mi0343_i2c_data[3] & 0x20 ? 1 : 0;
80 return 0; 80 return 0;
81 case V4L2_CID_VFLIP: 81 case V4L2_CID_VFLIP:
82 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 82 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
83 0x20, 2+1, mi0343_i2c_data) < 0) 83 0x20, 2+1, mi0343_i2c_data) < 0)
84 return -EIO; 84 return -EIO;
85 ctrl->value = mi0343_i2c_data[3] & 0x80 ? 1 : 0; 85 ctrl->value = mi0343_i2c_data[3] & 0x80 ? 1 : 0;
86 return 0; 86 return 0;
87 case V4L2_CID_RED_BALANCE: 87 case V4L2_CID_RED_BALANCE:
88 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 88 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
89 0x2d, 2+1, mi0343_i2c_data) < 0) 89 0x2d, 2+1, mi0343_i2c_data) < 0)
90 return -EIO; 90 return -EIO;
91 break; 91 break;
92 case V4L2_CID_BLUE_BALANCE: 92 case V4L2_CID_BLUE_BALANCE:
93 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 93 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
94 0x2c, 2+1, mi0343_i2c_data) < 0) 94 0x2c, 2+1, mi0343_i2c_data) < 0)
95 return -EIO; 95 return -EIO;
96 break; 96 break;
97 case SN9C102_V4L2_CID_GREEN_BALANCE: 97 case SN9C102_V4L2_CID_GREEN_BALANCE:
98 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 98 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
99 0x2e, 2+1, mi0343_i2c_data) < 0) 99 0x2e, 2+1, mi0343_i2c_data) < 0)
100 return -EIO; 100 return -EIO;
101 break; 101 break;
102 default: 102 default:
@@ -121,8 +121,8 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam,
121} 121}
122 122
123 123
124static int mi0343_set_ctrl(struct sn9c102_device* cam, 124static int mi0343_set_ctrl(struct sn9c102_device* cam,
125 const struct v4l2_control* ctrl) 125 const struct v4l2_control* ctrl)
126{ 126{
127 u16 reg = 0; 127 u16 reg = 0;
128 int err = 0; 128 int err = 0;
@@ -144,51 +144,51 @@ static int mi0343_set_ctrl(struct sn9c102_device* cam,
144 switch (ctrl->id) { 144 switch (ctrl->id) {
145 case V4L2_CID_EXPOSURE: 145 case V4L2_CID_EXPOSURE:
146 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 146 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
147 mi0343.i2c_slave_id, 147 mi0343.i2c_slave_id,
148 0x09, ctrl->value, 0x00, 148 0x09, ctrl->value, 0x00,
149 0, 0); 149 0, 0);
150 break; 150 break;
151 case V4L2_CID_GAIN: 151 case V4L2_CID_GAIN:
152 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 152 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
153 mi0343.i2c_slave_id, 153 mi0343.i2c_slave_id,
154 0x35, reg >> 8, reg & 0xff, 154 0x35, reg >> 8, reg & 0xff,
155 0, 0); 155 0, 0);
156 break; 156 break;
157 case V4L2_CID_HFLIP: 157 case V4L2_CID_HFLIP:
158 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 158 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
159 mi0343.i2c_slave_id, 159 mi0343.i2c_slave_id,
160 0x20, ctrl->value ? 0x40:0x00, 160 0x20, ctrl->value ? 0x40:0x00,
161 ctrl->value ? 0x20:0x00, 161 ctrl->value ? 0x20:0x00,
162 0, 0); 162 0, 0);
163 break; 163 break;
164 case V4L2_CID_VFLIP: 164 case V4L2_CID_VFLIP:
165 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 165 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
166 mi0343.i2c_slave_id, 166 mi0343.i2c_slave_id,
167 0x20, ctrl->value ? 0x80:0x00, 167 0x20, ctrl->value ? 0x80:0x00,
168 ctrl->value ? 0x80:0x00, 168 ctrl->value ? 0x80:0x00,
169 0, 0); 169 0, 0);
170 break; 170 break;
171 case V4L2_CID_RED_BALANCE: 171 case V4L2_CID_RED_BALANCE:
172 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 172 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
173 mi0343.i2c_slave_id, 173 mi0343.i2c_slave_id,
174 0x2d, reg >> 8, reg & 0xff, 174 0x2d, reg >> 8, reg & 0xff,
175 0, 0); 175 0, 0);
176 break; 176 break;
177 case V4L2_CID_BLUE_BALANCE: 177 case V4L2_CID_BLUE_BALANCE:
178 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 178 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
179 mi0343.i2c_slave_id, 179 mi0343.i2c_slave_id,
180 0x2c, reg >> 8, reg & 0xff, 180 0x2c, reg >> 8, reg & 0xff,
181 0, 0); 181 0, 0);
182 break; 182 break;
183 case SN9C102_V4L2_CID_GREEN_BALANCE: 183 case SN9C102_V4L2_CID_GREEN_BALANCE:
184 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 184 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
185 mi0343.i2c_slave_id, 185 mi0343.i2c_slave_id,
186 0x2b, reg >> 8, reg & 0xff, 186 0x2b, reg >> 8, reg & 0xff,
187 0, 0); 187 0, 0);
188 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 188 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
189 mi0343.i2c_slave_id, 189 mi0343.i2c_slave_id,
190 0x2e, reg >> 8, reg & 0xff, 190 0x2e, reg >> 8, reg & 0xff,
191 0, 0); 191 0, 0);
192 break; 192 break;
193 default: 193 default:
194 return -EINVAL; 194 return -EINVAL;
@@ -198,8 +198,8 @@ static int mi0343_set_ctrl(struct sn9c102_device* cam,
198} 198}
199 199
200 200
201static int mi0343_set_crop(struct sn9c102_device* cam, 201static int mi0343_set_crop(struct sn9c102_device* cam,
202 const struct v4l2_rect* rect) 202 const struct v4l2_rect* rect)
203{ 203{
204 struct sn9c102_sensor* s = &mi0343; 204 struct sn9c102_sensor* s = &mi0343;
205 int err = 0; 205 int err = 0;
@@ -213,20 +213,20 @@ static int mi0343_set_crop(struct sn9c102_device* cam,
213} 213}
214 214
215 215
216static int mi0343_set_pix_format(struct sn9c102_device* cam, 216static int mi0343_set_pix_format(struct sn9c102_device* cam,
217 const struct v4l2_pix_format* pix) 217 const struct v4l2_pix_format* pix)
218{ 218{
219 int err = 0; 219 int err = 0;
220 220
221 if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { 221 if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) {
222 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 222 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
223 mi0343.i2c_slave_id, 223 mi0343.i2c_slave_id,
224 0x0a, 0x00, 0x03, 0, 0); 224 0x0a, 0x00, 0x03, 0, 0);
225 err += sn9c102_write_reg(cam, 0x20, 0x19); 225 err += sn9c102_write_reg(cam, 0x20, 0x19);
226 } else { 226 } else {
227 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, 227 err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
228 mi0343.i2c_slave_id, 228 mi0343.i2c_slave_id,
229 0x0a, 0x00, 0x05, 0, 0); 229 0x0a, 0x00, 0x05, 0, 0);
230 err += sn9c102_write_reg(cam, 0xa0, 0x19); 230 err += sn9c102_write_reg(cam, 0xa0, 0x19);
231 } 231 }
232 232
@@ -351,7 +351,7 @@ int sn9c102_probe_mi0343(struct sn9c102_device* cam)
351 return -EIO; 351 return -EIO;
352 352
353 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, 353 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00,
354 2, mi0343_i2c_data) < 0) 354 2, mi0343_i2c_data) < 0)
355 return -EIO; 355 return -EIO;
356 356
357 if (mi0343_i2c_data[4] != 0x32 && mi0343_i2c_data[3] != 0xe3) 357 if (mi0343_i2c_data[4] != 0x32 && mi0343_i2c_data[3] != 0xe3)
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7630.c b/drivers/media/video/sn9c102/sn9c102_ov7630.c
index 42852b7cb042..3da042021787 100644
--- a/drivers/media/video/sn9c102/sn9c102_ov7630.c
+++ b/drivers/media/video/sn9c102/sn9c102_ov7630.c
@@ -69,7 +69,7 @@ static int ov7630_init(struct sn9c102_device* cam)
69 69
70 70
71static int ov7630_set_ctrl(struct sn9c102_device* cam, 71static int ov7630_set_ctrl(struct sn9c102_device* cam,
72 const struct v4l2_control* ctrl) 72 const struct v4l2_control* ctrl)
73{ 73{
74 int err = 0; 74 int err = 0;
75 75
@@ -89,8 +89,8 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
89 break; 89 break;
90 case V4L2_CID_CONTRAST: 90 case V4L2_CID_CONTRAST:
91 err += ctrl->value ? sn9c102_i2c_write(cam, 0x05, 91 err += ctrl->value ? sn9c102_i2c_write(cam, 0x05,
92 (ctrl->value-1) | 0x20) 92 (ctrl->value-1) | 0x20)
93 : sn9c102_i2c_write(cam, 0x05, 0x00); 93 : sn9c102_i2c_write(cam, 0x05, 0x00);
94 break; 94 break;
95 case V4L2_CID_BRIGHTNESS: 95 case V4L2_CID_BRIGHTNESS:
96 err += sn9c102_i2c_write(cam, 0x06, ctrl->value); 96 err += sn9c102_i2c_write(cam, 0x06, ctrl->value);
@@ -100,8 +100,8 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
100 break; 100 break;
101 case V4L2_CID_HUE: 101 case V4L2_CID_HUE:
102 err += ctrl->value ? sn9c102_i2c_write(cam, 0x04, 102 err += ctrl->value ? sn9c102_i2c_write(cam, 0x04,
103 (ctrl->value-1) | 0x20) 103 (ctrl->value-1) | 0x20)
104 : sn9c102_i2c_write(cam, 0x04, 0x00); 104 : sn9c102_i2c_write(cam, 0x04, 0x00);
105 break; 105 break;
106 case V4L2_CID_DO_WHITE_BALANCE: 106 case V4L2_CID_DO_WHITE_BALANCE:
107 err += sn9c102_i2c_write(cam, 0x0c, ctrl->value); 107 err += sn9c102_i2c_write(cam, 0x0c, ctrl->value);
@@ -139,7 +139,7 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
139 139
140 140
141static int ov7630_set_crop(struct sn9c102_device* cam, 141static int ov7630_set_crop(struct sn9c102_device* cam,
142 const struct v4l2_rect* rect) 142 const struct v4l2_rect* rect)
143{ 143{
144 struct sn9c102_sensor* s = &ov7630; 144 struct sn9c102_sensor* s = &ov7630;
145 int err = 0; 145 int err = 0;
@@ -152,7 +152,7 @@ static int ov7630_set_crop(struct sn9c102_device* cam,
152 152
153 153
154static int ov7630_set_pix_format(struct sn9c102_device* cam, 154static int ov7630_set_pix_format(struct sn9c102_device* cam,
155 const struct v4l2_pix_format* pix) 155 const struct v4l2_pix_format* pix)
156{ 156{
157 int err = 0; 157 int err = 0;
158 158
diff --git a/drivers/media/video/sn9c102/sn9c102_pas106b.c b/drivers/media/video/sn9c102/sn9c102_pas106b.c
index b1dee78abe04..9915944235e8 100644
--- a/drivers/media/video/sn9c102/sn9c102_pas106b.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas106b.c
@@ -53,8 +53,8 @@ static int pas106b_init(struct sn9c102_device* cam)
53} 53}
54 54
55 55
56static int pas106b_get_ctrl(struct sn9c102_device* cam, 56static int pas106b_get_ctrl(struct sn9c102_device* cam,
57 struct v4l2_control* ctrl) 57 struct v4l2_control* ctrl)
58{ 58{
59 switch (ctrl->id) { 59 switch (ctrl->id) {
60 case V4L2_CID_EXPOSURE: 60 case V4L2_CID_EXPOSURE:
@@ -102,8 +102,8 @@ static int pas106b_get_ctrl(struct sn9c102_device* cam,
102} 102}
103 103
104 104
105static int pas106b_set_ctrl(struct sn9c102_device* cam, 105static int pas106b_set_ctrl(struct sn9c102_device* cam,
106 const struct v4l2_control* ctrl) 106 const struct v4l2_control* ctrl)
107{ 107{
108 int err = 0; 108 int err = 0;
109 109
@@ -140,8 +140,8 @@ static int pas106b_set_ctrl(struct sn9c102_device* cam,
140} 140}
141 141
142 142
143static int pas106b_set_crop(struct sn9c102_device* cam, 143static int pas106b_set_crop(struct sn9c102_device* cam,
144 const struct v4l2_rect* rect) 144 const struct v4l2_rect* rect)
145{ 145{
146 struct sn9c102_sensor* s = &pas106b; 146 struct sn9c102_sensor* s = &pas106b;
147 int err = 0; 147 int err = 0;
@@ -155,8 +155,8 @@ static int pas106b_set_crop(struct sn9c102_device* cam,
155} 155}
156 156
157 157
158static int pas106b_set_pix_format(struct sn9c102_device* cam, 158static int pas106b_set_pix_format(struct sn9c102_device* cam,
159 const struct v4l2_pix_format* pix) 159 const struct v4l2_pix_format* pix)
160{ 160{
161 int err = 0; 161 int err = 0;
162 162
diff --git a/drivers/media/video/sn9c102/sn9c102_pas202bca.c b/drivers/media/video/sn9c102/sn9c102_pas202bca.c
index 3453237055bb..c8f1ae2152b8 100644
--- a/drivers/media/video/sn9c102/sn9c102_pas202bca.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas202bca.c
@@ -54,7 +54,7 @@ static int pas202bca_init(struct sn9c102_device* cam)
54 54
55 55
56static int pas202bca_set_pix_format(struct sn9c102_device* cam, 56static int pas202bca_set_pix_format(struct sn9c102_device* cam,
57 const struct v4l2_pix_format* pix) 57 const struct v4l2_pix_format* pix)
58{ 58{
59 int err = 0; 59 int err = 0;
60 60
@@ -68,7 +68,7 @@ static int pas202bca_set_pix_format(struct sn9c102_device* cam,
68 68
69 69
70static int pas202bca_set_ctrl(struct sn9c102_device* cam, 70static int pas202bca_set_ctrl(struct sn9c102_device* cam,
71 const struct v4l2_control* ctrl) 71 const struct v4l2_control* ctrl)
72{ 72{
73 int err = 0; 73 int err = 0;
74 74
@@ -102,7 +102,7 @@ static int pas202bca_set_ctrl(struct sn9c102_device* cam,
102 102
103 103
104static int pas202bca_set_crop(struct sn9c102_device* cam, 104static int pas202bca_set_crop(struct sn9c102_device* cam,
105 const struct v4l2_rect* rect) 105 const struct v4l2_rect* rect)
106{ 106{
107 struct sn9c102_sensor* s = &pas202bca; 107 struct sn9c102_sensor* s = &pas202bca;
108 int err = 0; 108 int err = 0;
diff --git a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
index d068616ab337..e3c1178e339c 100644
--- a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
@@ -58,8 +58,8 @@ static int pas202bcb_init(struct sn9c102_device* cam)
58} 58}
59 59
60 60
61static int pas202bcb_get_ctrl(struct sn9c102_device* cam, 61static int pas202bcb_get_ctrl(struct sn9c102_device* cam,
62 struct v4l2_control* ctrl) 62 struct v4l2_control* ctrl)
63{ 63{
64 switch (ctrl->id) { 64 switch (ctrl->id) {
65 case V4L2_CID_EXPOSURE: 65 case V4L2_CID_EXPOSURE:
@@ -101,8 +101,8 @@ static int pas202bcb_get_ctrl(struct sn9c102_device* cam,
101} 101}
102 102
103 103
104static int pas202bcb_set_pix_format(struct sn9c102_device* cam, 104static int pas202bcb_set_pix_format(struct sn9c102_device* cam,
105 const struct v4l2_pix_format* pix) 105 const struct v4l2_pix_format* pix)
106{ 106{
107 int err = 0; 107 int err = 0;
108 108
@@ -115,8 +115,8 @@ static int pas202bcb_set_pix_format(struct sn9c102_device* cam,
115} 115}
116 116
117 117
118static int pas202bcb_set_ctrl(struct sn9c102_device* cam, 118static int pas202bcb_set_ctrl(struct sn9c102_device* cam,
119 const struct v4l2_control* ctrl) 119 const struct v4l2_control* ctrl)
120{ 120{
121 int err = 0; 121 int err = 0;
122 122
@@ -149,8 +149,8 @@ static int pas202bcb_set_ctrl(struct sn9c102_device* cam,
149} 149}
150 150
151 151
152static int pas202bcb_set_crop(struct sn9c102_device* cam, 152static int pas202bcb_set_crop(struct sn9c102_device* cam,
153 const struct v4l2_rect* rect) 153 const struct v4l2_rect* rect)
154{ 154{
155 struct sn9c102_sensor* s = &pas202bcb; 155 struct sn9c102_sensor* s = &pas202bcb;
156 int err = 0; 156 int err = 0;
@@ -167,7 +167,7 @@ static int pas202bcb_set_crop(struct sn9c102_device* cam,
167static struct sn9c102_sensor pas202bcb = { 167static struct sn9c102_sensor pas202bcb = {
168 .name = "PAS202BCB", 168 .name = "PAS202BCB",
169 .maintainer = "Carlos Eduardo Medaglia Dyonisio " 169 .maintainer = "Carlos Eduardo Medaglia Dyonisio "
170 "<medaglia@undl.org.br>", 170 "<medaglia@undl.org.br>",
171 .sysfs_ops = SN9C102_I2C_READ | SN9C102_I2C_WRITE, 171 .sysfs_ops = SN9C102_I2C_READ | SN9C102_I2C_WRITE,
172 .frequency = SN9C102_I2C_400KHZ | SN9C102_I2C_100KHZ, 172 .frequency = SN9C102_I2C_400KHZ | SN9C102_I2C_100KHZ,
173 .interface = SN9C102_I2C_2WIRES, 173 .interface = SN9C102_I2C_2WIRES,
diff --git a/drivers/media/video/sn9c102/sn9c102_sensor.h b/drivers/media/video/sn9c102/sn9c102_sensor.h
index 2afd9e9d09bb..2a874ee6f9f5 100644
--- a/drivers/media/video/sn9c102/sn9c102_sensor.h
+++ b/drivers/media/video/sn9c102/sn9c102_sensor.h
@@ -58,7 +58,7 @@ struct sn9c102_sensor;
58 Probing functions: on success, you must attach the sensor to the camera 58 Probing functions: on success, you must attach the sensor to the camera
59 by calling sn9c102_attach_sensor() provided below. 59 by calling sn9c102_attach_sensor() provided below.
60 To enable the I2C communication, you might need to perform a really basic 60 To enable the I2C communication, you might need to perform a really basic
61 initialization of the SN9C10X chip by using the write function declared 61 initialization of the SN9C10X chip by using the write function declared
62 ahead. 62 ahead.
63 Functions must return 0 on success, the appropriate error otherwise. 63 Functions must return 0 on success, the appropriate error otherwise.
64*/ 64*/
@@ -73,7 +73,7 @@ extern int sn9c102_probe_tas5130d1b(struct sn9c102_device* cam);
73 73
74/* 74/*
75 Add the above entries to this table. Be sure to add the entry in the right 75 Add the above entries to this table. Be sure to add the entry in the right
76 place, since, on failure, the next probing routine is called according to 76 place, since, on failure, the next probing routine is called according to
77 the order of the list below, from top to bottom. 77 the order of the list below, from top to bottom.
78*/ 78*/
79#define SN9C102_SENSOR_TABLE \ 79#define SN9C102_SENSOR_TABLE \
@@ -94,9 +94,9 @@ extern struct sn9c102_device*
94sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id); 94sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id);
95 95
96/* Attach a probed sensor to the camera. */ 96/* Attach a probed sensor to the camera. */
97extern void 97extern void
98sn9c102_attach_sensor(struct sn9c102_device* cam, 98sn9c102_attach_sensor(struct sn9c102_device* cam,
99 struct sn9c102_sensor* sensor); 99 struct sn9c102_sensor* sensor);
100 100
101/* 101/*
102 Each SN9C10x camera has proper PID/VID identifiers. 102 Each SN9C10x camera has proper PID/VID identifiers.
@@ -105,7 +105,7 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
105*/ 105*/
106#define SN9C102_USB_DEVICE(vend, prod, intclass) \ 106#define SN9C102_USB_DEVICE(vend, prod, intclass) \
107 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ 107 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
108 USB_DEVICE_ID_MATCH_INT_CLASS, \ 108 USB_DEVICE_ID_MATCH_INT_CLASS, \
109 .idVendor = (vend), \ 109 .idVendor = (vend), \
110 .idProduct = (prod), \ 110 .idProduct = (prod), \
111 .bInterfaceClass = (intclass) 111 .bInterfaceClass = (intclass)
@@ -162,19 +162,19 @@ static const struct usb_device_id sn9c102_id_table[] = { \
162 Read/write routines: they always return -1 on error, 0 or the read value 162 Read/write routines: they always return -1 on error, 0 or the read value
163 otherwise. NOTE that a real read operation is not supported by the SN9C10X 163 otherwise. NOTE that a real read operation is not supported by the SN9C10X
164 chip for some of its registers. To work around this problem, a pseudo-read 164 chip for some of its registers. To work around this problem, a pseudo-read
165 call is provided instead: it returns the last successfully written value 165 call is provided instead: it returns the last successfully written value
166 on the register (0 if it has never been written), the usual -1 on error. 166 on the register (0 if it has never been written), the usual -1 on error.
167*/ 167*/
168 168
169/* The "try" I2C I/O versions are used when probing the sensor */ 169/* The "try" I2C I/O versions are used when probing the sensor */
170extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*, 170extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*,
171 u8 address, u8 value); 171 u8 address, u8 value);
172extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, 172extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
173 u8 address); 173 u8 address);
174 174
175/* 175/*
176 These must be used if and only if the sensor doesn't implement the standard 176 These must be used if and only if the sensor doesn't implement the standard
177 I2C protocol. There are a number of good reasons why you must use the 177 I2C protocol. There are a number of good reasons why you must use the
178 single-byte versions of these functions: do not abuse. The first function 178 single-byte versions of these functions: do not abuse. The first function
179 writes n bytes, from data0 to datan, to registers 0x09 - 0x09+n of SN9C10X 179 writes n bytes, from data0 to datan, to registers 0x09 - 0x09+n of SN9C10X
180 chip. The second one programs the registers 0x09 and 0x10 with data0 and 180 chip. The second one programs the registers 0x09 and 0x10 with data0 and
@@ -184,12 +184,12 @@ extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
184 byte. 184 byte.
185*/ 185*/
186extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 186extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
187 struct sn9c102_sensor* sensor, u8 n, 187 struct sn9c102_sensor* sensor, u8 n,
188 u8 data0, u8 data1, u8 data2, u8 data3, 188 u8 data0, u8 data1, u8 data2, u8 data3,
189 u8 data4, u8 data5); 189 u8 data4, u8 data5);
190extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 190extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
191 struct sn9c102_sensor* sensor, u8 data0, 191 struct sn9c102_sensor* sensor, u8 data0,
192 u8 data1, u8 n, u8 buffer[]); 192 u8 data1, u8 n, u8 buffer[]);
193 193
194/* To be used after the sensor struct has been attached to the camera struct */ 194/* To be used after the sensor struct has been attached to the camera struct */
195extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); 195extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value);
@@ -252,17 +252,17 @@ struct sn9c102_sensor {
252 252
253 /* 253 /*
254 NOTE: Where not noted,most of the functions below are not mandatory. 254 NOTE: Where not noted,most of the functions below are not mandatory.
255 Set to null if you do not implement them. If implemented, 255 Set to null if you do not implement them. If implemented,
256 they must return 0 on success, the proper error otherwise. 256 they must return 0 on success, the proper error otherwise.
257 */ 257 */
258 258
259 int (*init)(struct sn9c102_device* cam); 259 int (*init)(struct sn9c102_device* cam);
260 /* 260 /*
261 This function will be called after the sensor has been attached. 261 This function will be called after the sensor has been attached.
262 It should be used to initialize the sensor only, but may also 262 It should be used to initialize the sensor only, but may also
263 configure part of the SN9C10X chip if necessary. You don't need to 263 configure part of the SN9C10X chip if necessary. You don't need to
264 setup picture settings like brightness, contrast, etc.. here, if 264 setup picture settings like brightness, contrast, etc.. here, if
265 the corrisponding controls are implemented (see below), since 265 the corrisponding controls are implemented (see below), since
266 they are adjusted in the core driver by calling the set_ctrl() 266 they are adjusted in the core driver by calling the set_ctrl()
267 method after init(), where the arguments are the default values 267 method after init(), where the arguments are the default values
268 specified in the v4l2_queryctrl list of supported controls; 268 specified in the v4l2_queryctrl list of supported controls;
@@ -273,13 +273,13 @@ struct sn9c102_sensor {
273 273
274 struct v4l2_queryctrl qctrl[SN9C102_MAX_CTRLS]; 274 struct v4l2_queryctrl qctrl[SN9C102_MAX_CTRLS];
275 /* 275 /*
276 Optional list of default controls, defined as indicated in the 276 Optional list of default controls, defined as indicated in the
277 V4L2 API. Menu type controls are not handled by this interface. 277 V4L2 API. Menu type controls are not handled by this interface.
278 */ 278 */
279 279
280 int (*get_ctrl)(struct sn9c102_device* cam, struct v4l2_control* ctrl); 280 int (*get_ctrl)(struct sn9c102_device* cam, struct v4l2_control* ctrl);
281 int (*set_ctrl)(struct sn9c102_device* cam, 281 int (*set_ctrl)(struct sn9c102_device* cam,
282 const struct v4l2_control* ctrl); 282 const struct v4l2_control* ctrl);
283 /* 283 /*
284 You must implement at least the set_ctrl method if you have defined 284 You must implement at least the set_ctrl method if you have defined
285 the list above. The returned value must follow the V4L2 285 the list above. The returned value must follow the V4L2
@@ -306,7 +306,7 @@ struct sn9c102_sensor {
306 specified in the cropcap substructures 'bounds' and 'defrect'. 306 specified in the cropcap substructures 'bounds' and 'defrect'.
307 By default, the source rectangle should cover the largest possible 307 By default, the source rectangle should cover the largest possible
308 area. Again, it is not always true that the largest source rectangle 308 area. Again, it is not always true that the largest source rectangle
309 can cover the entire active window, although it is a rare case for 309 can cover the entire active window, although it is a rare case for
310 the hardware we have. The bounds of the source rectangle _must_ be 310 the hardware we have. The bounds of the source rectangle _must_ be
311 multiple of 16 and must use the same coordinate system as indicated 311 multiple of 16 and must use the same coordinate system as indicated
312 before; their centers shall align initially. 312 before; their centers shall align initially.
@@ -317,13 +317,13 @@ struct sn9c102_sensor {
317 defined the correct default bounds in the structures. 317 defined the correct default bounds in the structures.
318 See the V4L2 API for further details. 318 See the V4L2 API for further details.
319 NOTE: once you have defined the bounds of the active window 319 NOTE: once you have defined the bounds of the active window
320 (struct cropcap.bounds) you must not change them.anymore. 320 (struct cropcap.bounds) you must not change them.anymore.
321 Only 'bounds' and 'defrect' fields are mandatory, other fields 321 Only 'bounds' and 'defrect' fields are mandatory, other fields
322 will be ignored. 322 will be ignored.
323 */ 323 */
324 324
325 int (*set_crop)(struct sn9c102_device* cam, 325 int (*set_crop)(struct sn9c102_device* cam,
326 const struct v4l2_rect* rect); 326 const struct v4l2_rect* rect);
327 /* 327 /*
328 To be called on VIDIOC_C_SETCROP. The core module always calls a 328 To be called on VIDIOC_C_SETCROP. The core module always calls a
329 default routine which configures the appropriate SN9C10X regs (also 329 default routine which configures the appropriate SN9C10X regs (also
@@ -332,12 +332,12 @@ struct sn9c102_sensor {
332 case you override the default function, you always have to program 332 case you override the default function, you always have to program
333 the chip to match those values; on error return the corresponding 333 the chip to match those values; on error return the corresponding
334 error code without rolling back. 334 error code without rolling back.
335 NOTE: in case, you must program the SN9C10X chip to get rid of 335 NOTE: in case, you must program the SN9C10X chip to get rid of
336 blank pixels or blank lines at the _start_ of each line or 336 blank pixels or blank lines at the _start_ of each line or
337 frame after each HSYNC or VSYNC, so that the image starts with 337 frame after each HSYNC or VSYNC, so that the image starts with
338 real RGB data (see regs 0x12, 0x13) (having set H_SIZE and, 338 real RGB data (see regs 0x12, 0x13) (having set H_SIZE and,
339 V_SIZE you don't have to care about blank pixels or blank 339 V_SIZE you don't have to care about blank pixels or blank
340 lines at the end of each line or frame). 340 lines at the end of each line or frame).
341 */ 341 */
342 342
343 struct v4l2_pix_format pix_format; 343 struct v4l2_pix_format pix_format;
@@ -349,17 +349,17 @@ struct sn9c102_sensor {
349 number of bits per pixel for uncompressed video, 8 or 9 (despite the 349 number of bits per pixel for uncompressed video, 8 or 9 (despite the
350 current value of 'pixelformat'). 350 current value of 'pixelformat').
351 NOTE 1: both 'width' and 'height' _must_ be either 1/1 or 1/2 or 1/4 351 NOTE 1: both 'width' and 'height' _must_ be either 1/1 or 1/2 or 1/4
352 of cropcap.defrect.width and cropcap.defrect.height. I 352 of cropcap.defrect.width and cropcap.defrect.height. I
353 suggest 1/1. 353 suggest 1/1.
354 NOTE 2: The initial compression quality is defined by the first bit 354 NOTE 2: The initial compression quality is defined by the first bit
355 of reg 0x17 during the initialization of the image sensor. 355 of reg 0x17 during the initialization of the image sensor.
356 NOTE 3: as said above, you have to program the SN9C10X chip to get 356 NOTE 3: as said above, you have to program the SN9C10X chip to get
357 rid of any blank pixels, so that the output of the sensor 357 rid of any blank pixels, so that the output of the sensor
358 matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR). 358 matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR).
359 */ 359 */
360 360
361 int (*set_pix_format)(struct sn9c102_device* cam, 361 int (*set_pix_format)(struct sn9c102_device* cam,
362 const struct v4l2_pix_format* pix); 362 const struct v4l2_pix_format* pix);
363 /* 363 /*
364 To be called on VIDIOC_S_FMT, when switching from the SBGGR8 to 364 To be called on VIDIOC_S_FMT, when switching from the SBGGR8 to
365 SN9C10X pixel format or viceversa. On error return the corresponding 365 SN9C10X pixel format or viceversa. On error return the corresponding
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
index 2e08c552f40a..294eb02fbd88 100644
--- a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
@@ -44,8 +44,8 @@ static int tas5110c1b_init(struct sn9c102_device* cam)
44} 44}
45 45
46 46
47static int tas5110c1b_set_ctrl(struct sn9c102_device* cam, 47static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
48 const struct v4l2_control* ctrl) 48 const struct v4l2_control* ctrl)
49{ 49{
50 int err = 0; 50 int err = 0;
51 51
@@ -61,8 +61,8 @@ static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
61} 61}
62 62
63 63
64static int tas5110c1b_set_crop(struct sn9c102_device* cam, 64static int tas5110c1b_set_crop(struct sn9c102_device* cam,
65 const struct v4l2_rect* rect) 65 const struct v4l2_rect* rect)
66{ 66{
67 struct sn9c102_sensor* s = &tas5110c1b; 67 struct sn9c102_sensor* s = &tas5110c1b;
68 int err = 0; 68 int err = 0;
@@ -81,8 +81,8 @@ static int tas5110c1b_set_crop(struct sn9c102_device* cam,
81} 81}
82 82
83 83
84static int tas5110c1b_set_pix_format(struct sn9c102_device* cam, 84static int tas5110c1b_set_pix_format(struct sn9c102_device* cam,
85 const struct v4l2_pix_format* pix) 85 const struct v4l2_pix_format* pix)
86{ 86{
87 int err = 0; 87 int err = 0;
88 88
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
index c7b339740bbf..9ecb09032b68 100644
--- a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
@@ -42,8 +42,8 @@ static int tas5130d1b_init(struct sn9c102_device* cam)
42} 42}
43 43
44 44
45static int tas5130d1b_set_ctrl(struct sn9c102_device* cam, 45static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
46 const struct v4l2_control* ctrl) 46 const struct v4l2_control* ctrl)
47{ 47{
48 int err = 0; 48 int err = 0;
49 49
@@ -62,8 +62,8 @@ static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
62} 62}
63 63
64 64
65static int tas5130d1b_set_crop(struct sn9c102_device* cam, 65static int tas5130d1b_set_crop(struct sn9c102_device* cam,
66 const struct v4l2_rect* rect) 66 const struct v4l2_rect* rect)
67{ 67{
68 struct sn9c102_sensor* s = &tas5130d1b; 68 struct sn9c102_sensor* s = &tas5130d1b;
69 u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 104, 69 u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 104,
@@ -82,8 +82,8 @@ static int tas5130d1b_set_crop(struct sn9c102_device* cam,
82} 82}
83 83
84 84
85static int tas5130d1b_set_pix_format(struct sn9c102_device* cam, 85static int tas5130d1b_set_pix_format(struct sn9c102_device* cam,
86 const struct v4l2_pix_format* pix) 86 const struct v4l2_pix_format* pix)
87{ 87{
88 int err = 0; 88 int err = 0;
89 89