aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-18 18:08:02 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-18 18:08:02 -0500
commita310410f616c78f24490de1274487a7b7b137d97 (patch)
treedbc2fc187800e6e7014263bf83e10d0155620029 /drivers/media/usb
parentcdd278db0e3dd714e8076e58f723f3c59547591b (diff)
parent80f93c7b0f4599ffbdac8d964ecd1162b8b618b9 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: "This series include: - a new Remote Controller driver for ST SoC with the corresponding DT bindings - a new frontend (cx24117) - a new I2C camera flash driver (lm3560) - a new mem2mem driver for TI SoC (ti-vpe) - support for Raphael r828d added to r820t driver - some improvements on buffer allocation at VB2 core - usual driver fixes and improvements PS this time, we have a smaller number of patches. While it is hard to pinpoint to the reasons, I believe that it is mainly due to: 1) there are several patch series ready, but depending on DT review. I decided to grant some extra time for DT maintainers to look on it, as they're expecting to have more time with the changes agreed during ARM mini-summit and KS. If they can't review in time for 3.14, I'll review myself and apply for the next merge window. 2) I suspect that having both LinuxCon EU and LinuxCon NA happening during the same merge window affected the development productivity, as several core media developers participated on both events" * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (151 commits) [media] media: st-rc: Add ST remote control driver [media] gpio-ir-recv: Include linux/of.h header [media] tvp7002: Include linux/of.h header [media] tvp514x: Include linux/of.h header [media] ths8200: Include linux/of.h header [media] adv7343: Include linux/of.h header [media] v4l: Fix typo in v4l2_subdev_get_try_crop() [media] media: i2c: add driver for dual LED Flash, lm3560 [media] rtl28xxu: add 15f4:0131 Astrometa DVB-T2 [media] rtl28xxu: add RTL2832P + R828D support [media] rtl2832: add new tuner R828D [media] r820t: add support for R828D [media] media/i2c: ths8200: fix build failure with gcc 4.5.4 [media] Add support for KWorld UB435-Q V2 [media] staging/media: fix msi3101 build errors [media] ddbridge: Remove casting the return value which is a void pointer [media] ngene: Remove casting the return value which is a void pointer [media] dm1105: remove unneeded not-null test [media] sh_mobile_ceu_camera: remove deprecated IRQF_DISABLED [media] media: rcar_vin: Add preliminary r8a7790 support ...
Diffstat (limited to 'drivers/media/usb')
-rw-r--r--drivers/media/usb/b2c2/flexcop-usb.c6
-rw-r--r--drivers/media/usb/cpia2/cpia2_usb.c2
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-cards.c110
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c42
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.h1
-rw-r--r--drivers/media/usb/dvb-usb/az6027.c4
-rw-r--r--drivers/media/usb/dvb-usb/dw2102.c13
-rw-r--r--drivers/media/usb/em28xx/em28xx-camera.c42
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c121
-rw-r--r--drivers/media/usb/em28xx/em28xx-dvb.c63
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c7
-rw-r--r--drivers/media/usb/em28xx/em28xx.h2
-rw-r--r--drivers/media/usb/gspca/conex.c3
-rw-r--r--drivers/media/usb/gspca/cpia1.c4
-rw-r--r--drivers/media/usb/gspca/gspca.c48
-rw-r--r--drivers/media/usb/gspca/gspca.h10
-rw-r--r--drivers/media/usb/gspca/jeilinj.c5
-rw-r--r--drivers/media/usb/gspca/jl2005bcd.c2
-rw-r--r--drivers/media/usb/gspca/m5602/m5602_mt9m111.c2
-rw-r--r--drivers/media/usb/gspca/mars.c7
-rw-r--r--drivers/media/usb/gspca/mr97310a.c6
-rw-r--r--drivers/media/usb/gspca/nw80x.c11
-rw-r--r--drivers/media/usb/gspca/ov519.c52
-rw-r--r--drivers/media/usb/gspca/ov534.c5
-rw-r--r--drivers/media/usb/gspca/ov534_9.c334
-rw-r--r--drivers/media/usb/gspca/pac207.c4
-rw-r--r--drivers/media/usb/gspca/pac7311.c6
-rw-r--r--drivers/media/usb/gspca/se401.c6
-rw-r--r--drivers/media/usb/gspca/sn9c20x.c6
-rw-r--r--drivers/media/usb/gspca/sonixb.c7
-rw-r--r--drivers/media/usb/gspca/sonixj.c3
-rw-r--r--drivers/media/usb/gspca/spca1528.c3
-rw-r--r--drivers/media/usb/gspca/spca500.c3
-rw-r--r--drivers/media/usb/gspca/sq905c.c2
-rw-r--r--drivers/media/usb/gspca/sq930x.c3
-rw-r--r--drivers/media/usb/gspca/stk014.c5
-rw-r--r--drivers/media/usb/gspca/stk1135.c76
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx.c2
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c2
-rw-r--r--drivers/media/usb/gspca/sunplus.c3
-rw-r--r--drivers/media/usb/gspca/topro.c13
-rw-r--r--drivers/media/usb/gspca/tv8532.c7
-rw-r--r--drivers/media/usb/gspca/vicam.c8
-rw-r--r--drivers/media/usb/gspca/w996Xcf.c28
-rw-r--r--drivers/media/usb/gspca/xirlink_cit.c46
-rw-r--r--drivers/media/usb/gspca/zc3xx.c3
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-core.c11
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-hdw.c2
-rw-r--r--drivers/media/usb/siano/smsusb.c43
-rw-r--r--drivers/media/usb/tlg2300/pd-main.c2
-rw-r--r--drivers/media/usb/ttusb-dec/ttusb_dec.c152
-rw-r--r--drivers/media/usb/uvc/uvc_ctrl.c4
53 files changed, 932 insertions, 424 deletions
diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c
index 8b6275f85908..0bd969063392 100644
--- a/drivers/media/usb/b2c2/flexcop-usb.c
+++ b/drivers/media/usb/b2c2/flexcop-usb.c
@@ -390,7 +390,7 @@ static void flexcop_usb_transfer_exit(struct flexcop_usb *fc_usb)
390 } 390 }
391 391
392 if (fc_usb->iso_buffer != NULL) 392 if (fc_usb->iso_buffer != NULL)
393 pci_free_consistent(NULL, 393 usb_free_coherent(fc_usb->udev,
394 fc_usb->buffer_size, fc_usb->iso_buffer, 394 fc_usb->buffer_size, fc_usb->iso_buffer,
395 fc_usb->dma_addr); 395 fc_usb->dma_addr);
396} 396}
@@ -407,8 +407,8 @@ static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb)
407 "each of %d bytes size = %d.\n", B2C2_USB_NUM_ISO_URB, 407 "each of %d bytes size = %d.\n", B2C2_USB_NUM_ISO_URB,
408 B2C2_USB_FRAMES_PER_ISO, frame_size, bufsize); 408 B2C2_USB_FRAMES_PER_ISO, frame_size, bufsize);
409 409
410 fc_usb->iso_buffer = pci_alloc_consistent(NULL, 410 fc_usb->iso_buffer = usb_alloc_coherent(fc_usb->udev,
411 bufsize, &fc_usb->dma_addr); 411 bufsize, GFP_KERNEL, &fc_usb->dma_addr);
412 if (fc_usb->iso_buffer == NULL) 412 if (fc_usb->iso_buffer == NULL)
413 return -ENOMEM; 413 return -ENOMEM;
414 414
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
index be1719283609..351a78a84c3d 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -209,7 +209,7 @@ static void cpia2_usb_complete(struct urb *urb)
209{ 209{
210 int i; 210 int i;
211 unsigned char *cdata; 211 unsigned char *cdata;
212 static int frame_ready = false; 212 static bool frame_ready = false;
213 struct camera_data *cam = (struct camera_data *) urb->context; 213 struct camera_data *cam = (struct camera_data *) urb->context;
214 214
215 if (urb->status!=0) { 215 if (urb->status!=0) {
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index a384f80f595e..e9d017bea377 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -978,7 +978,6 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev,
978 int minor) 978 int minor)
979{ 979{
980 int retval = -ENOMEM; 980 int retval = -ENOMEM;
981 int errCode;
982 unsigned int maxh, maxw; 981 unsigned int maxh, maxw;
983 982
984 dev->udev = udev; 983 dev->udev = udev;
@@ -1014,8 +1013,8 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev,
1014 /* Cx231xx pre card setup */ 1013 /* Cx231xx pre card setup */
1015 cx231xx_pre_card_setup(dev); 1014 cx231xx_pre_card_setup(dev);
1016 1015
1017 errCode = cx231xx_config(dev); 1016 retval = cx231xx_config(dev);
1018 if (errCode) { 1017 if (retval) {
1019 cx231xx_errdev("error configuring device\n"); 1018 cx231xx_errdev("error configuring device\n");
1020 return -ENOMEM; 1019 return -ENOMEM;
1021 } 1020 }
@@ -1024,12 +1023,11 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev,
1024 dev->norm = dev->board.norm; 1023 dev->norm = dev->board.norm;
1025 1024
1026 /* register i2c bus */ 1025 /* register i2c bus */
1027 errCode = cx231xx_dev_init(dev); 1026 retval = cx231xx_dev_init(dev);
1028 if (errCode < 0) { 1027 if (retval) {
1029 cx231xx_dev_uninit(dev);
1030 cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n", 1028 cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n",
1031 __func__, errCode); 1029 __func__, retval);
1032 return errCode; 1030 goto err_dev_init;
1033 } 1031 }
1034 1032
1035 /* Do board specific init */ 1033 /* Do board specific init */
@@ -1047,11 +1045,11 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev,
1047 dev->interlaced = 0; 1045 dev->interlaced = 0;
1048 dev->video_input = 0; 1046 dev->video_input = 0;
1049 1047
1050 errCode = cx231xx_config(dev); 1048 retval = cx231xx_config(dev);
1051 if (errCode < 0) { 1049 if (retval) {
1052 cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n", 1050 cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n",
1053 __func__, errCode); 1051 __func__, retval);
1054 return errCode; 1052 goto err_dev_init;
1055 } 1053 }
1056 1054
1057 /* init video dma queues */ 1055 /* init video dma queues */
@@ -1075,9 +1073,9 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev,
1075 } 1073 }
1076 1074
1077 retval = cx231xx_register_analog_devices(dev); 1075 retval = cx231xx_register_analog_devices(dev);
1078 if (retval < 0) { 1076 if (retval) {
1079 cx231xx_release_resources(dev); 1077 cx231xx_release_analog_resources(dev);
1080 return retval; 1078 goto err_analog;
1081 } 1079 }
1082 1080
1083 cx231xx_ir_init(dev); 1081 cx231xx_ir_init(dev);
@@ -1085,6 +1083,11 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev,
1085 cx231xx_init_extension(dev); 1083 cx231xx_init_extension(dev);
1086 1084
1087 return 0; 1085 return 0;
1086err_analog:
1087 cx231xx_remove_from_devlist(dev);
1088err_dev_init:
1089 cx231xx_dev_uninit(dev);
1090 return retval;
1088} 1091}
1089 1092
1090#if defined(CONFIG_MODULES) && defined(MODULE) 1093#if defined(CONFIG_MODULES) && defined(MODULE)
@@ -1132,7 +1135,6 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1132 char *speed; 1135 char *speed;
1133 struct usb_interface_assoc_descriptor *assoc_desc; 1136 struct usb_interface_assoc_descriptor *assoc_desc;
1134 1137
1135 udev = usb_get_dev(interface_to_usbdev(interface));
1136 ifnum = interface->altsetting[0].desc.bInterfaceNumber; 1138 ifnum = interface->altsetting[0].desc.bInterfaceNumber;
1137 1139
1138 /* 1140 /*
@@ -1161,6 +1163,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1161 return -ENOMEM; 1163 return -ENOMEM;
1162 } 1164 }
1163 1165
1166 udev = usb_get_dev(interface_to_usbdev(interface));
1167
1164 snprintf(dev->name, 29, "cx231xx #%d", nr); 1168 snprintf(dev->name, 29, "cx231xx #%d", nr);
1165 dev->devno = nr; 1169 dev->devno = nr;
1166 dev->model = id->driver_info; 1170 dev->model = id->driver_info;
@@ -1223,10 +1227,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1223 if (assoc_desc->bFirstInterface != ifnum) { 1227 if (assoc_desc->bFirstInterface != ifnum) {
1224 cx231xx_err(DRIVER_NAME ": Not found " 1228 cx231xx_err(DRIVER_NAME ": Not found "
1225 "matching IAD interface\n"); 1229 "matching IAD interface\n");
1226 clear_bit(dev->devno, &cx231xx_devused); 1230 retval = -ENODEV;
1227 kfree(dev); 1231 goto err_if;
1228 dev = NULL;
1229 return -ENODEV;
1230 } 1232 }
1231 1233
1232 cx231xx_info("registering interface %d\n", ifnum); 1234 cx231xx_info("registering interface %d\n", ifnum);
@@ -1242,22 +1244,13 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1242 retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); 1244 retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
1243 if (retval) { 1245 if (retval) {
1244 cx231xx_errdev("v4l2_device_register failed\n"); 1246 cx231xx_errdev("v4l2_device_register failed\n");
1245 clear_bit(dev->devno, &cx231xx_devused); 1247 retval = -EIO;
1246 kfree(dev); 1248 goto err_v4l2;
1247 dev = NULL;
1248 return -EIO;
1249 } 1249 }
1250 /* allocate device struct */ 1250 /* allocate device struct */
1251 retval = cx231xx_init_dev(dev, udev, nr); 1251 retval = cx231xx_init_dev(dev, udev, nr);
1252 if (retval) { 1252 if (retval)
1253 clear_bit(dev->devno, &cx231xx_devused); 1253 goto err_init;
1254 v4l2_device_unregister(&dev->v4l2_dev);
1255 kfree(dev);
1256 dev = NULL;
1257 usb_set_intfdata(interface, NULL);
1258
1259 return retval;
1260 }
1261 1254
1262 /* compute alternate max packet sizes for video */ 1255 /* compute alternate max packet sizes for video */
1263 uif = udev->actconfig->interface[dev->current_pcb_config. 1256 uif = udev->actconfig->interface[dev->current_pcb_config.
@@ -1275,11 +1268,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1275 1268
1276 if (dev->video_mode.alt_max_pkt_size == NULL) { 1269 if (dev->video_mode.alt_max_pkt_size == NULL) {
1277 cx231xx_errdev("out of memory!\n"); 1270 cx231xx_errdev("out of memory!\n");
1278 clear_bit(dev->devno, &cx231xx_devused); 1271 retval = -ENOMEM;
1279 v4l2_device_unregister(&dev->v4l2_dev); 1272 goto err_video_alt;
1280 kfree(dev);
1281 dev = NULL;
1282 return -ENOMEM;
1283 } 1273 }
1284 1274
1285 for (i = 0; i < dev->video_mode.num_alt; i++) { 1275 for (i = 0; i < dev->video_mode.num_alt; i++) {
@@ -1309,11 +1299,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1309 1299
1310 if (dev->vbi_mode.alt_max_pkt_size == NULL) { 1300 if (dev->vbi_mode.alt_max_pkt_size == NULL) {
1311 cx231xx_errdev("out of memory!\n"); 1301 cx231xx_errdev("out of memory!\n");
1312 clear_bit(dev->devno, &cx231xx_devused); 1302 retval = -ENOMEM;
1313 v4l2_device_unregister(&dev->v4l2_dev); 1303 goto err_vbi_alt;
1314 kfree(dev);
1315 dev = NULL;
1316 return -ENOMEM;
1317 } 1304 }
1318 1305
1319 for (i = 0; i < dev->vbi_mode.num_alt; i++) { 1306 for (i = 0; i < dev->vbi_mode.num_alt; i++) {
@@ -1344,11 +1331,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1344 1331
1345 if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { 1332 if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) {
1346 cx231xx_errdev("out of memory!\n"); 1333 cx231xx_errdev("out of memory!\n");
1347 clear_bit(dev->devno, &cx231xx_devused); 1334 retval = -ENOMEM;
1348 v4l2_device_unregister(&dev->v4l2_dev); 1335 goto err_sliced_cc_alt;
1349 kfree(dev);
1350 dev = NULL;
1351 return -ENOMEM;
1352 } 1336 }
1353 1337
1354 for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) { 1338 for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) {
@@ -1380,11 +1364,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1380 1364
1381 if (dev->ts1_mode.alt_max_pkt_size == NULL) { 1365 if (dev->ts1_mode.alt_max_pkt_size == NULL) {
1382 cx231xx_errdev("out of memory!\n"); 1366 cx231xx_errdev("out of memory!\n");
1383 clear_bit(dev->devno, &cx231xx_devused); 1367 retval = -ENOMEM;
1384 v4l2_device_unregister(&dev->v4l2_dev); 1368 goto err_ts1_alt;
1385 kfree(dev);
1386 dev = NULL;
1387 return -ENOMEM;
1388 } 1369 }
1389 1370
1390 for (i = 0; i < dev->ts1_mode.num_alt; i++) { 1371 for (i = 0; i < dev->ts1_mode.num_alt; i++) {
@@ -1411,6 +1392,29 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
1411 request_modules(dev); 1392 request_modules(dev);
1412 1393
1413 return 0; 1394 return 0;
1395err_ts1_alt:
1396 kfree(dev->sliced_cc_mode.alt_max_pkt_size);
1397err_sliced_cc_alt:
1398 kfree(dev->vbi_mode.alt_max_pkt_size);
1399err_vbi_alt:
1400 kfree(dev->video_mode.alt_max_pkt_size);
1401err_video_alt:
1402 /* cx231xx_uninit_dev: */
1403 cx231xx_close_extension(dev);
1404 cx231xx_ir_exit(dev);
1405 cx231xx_release_analog_resources(dev);
1406 cx231xx_417_unregister(dev);
1407 cx231xx_remove_from_devlist(dev);
1408 cx231xx_dev_uninit(dev);
1409err_init:
1410 v4l2_device_unregister(&dev->v4l2_dev);
1411err_v4l2:
1412 usb_set_intfdata(interface, NULL);
1413err_if:
1414 usb_put_dev(udev);
1415 kfree(dev);
1416 clear_bit(dev->devno, &cx231xx_devused);
1417 return retval;
1414} 1418}
1415 1419
1416/* 1420/*
diff --git a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c
index d7308ab7a90f..2a34ceee4802 100644
--- a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c
+++ b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c
@@ -28,7 +28,7 @@ MODULE_PARM_DESC(pcb_debug, "enable pcb config debug messages [video]");
28 28
29/******************************************************************************/ 29/******************************************************************************/
30 30
31struct pcb_config cx231xx_Scenario[] = { 31static struct pcb_config cx231xx_Scenario[] = {
32 { 32 {
33 INDEX_SELFPOWER_DIGITAL_ONLY, /* index */ 33 INDEX_SELFPOWER_DIGITAL_ONLY, /* index */
34 USB_SELF_POWER, /* power_type */ 34 USB_SELF_POWER, /* power_type */
@@ -672,7 +672,7 @@ u32 initialize_cx231xx(struct cx231xx *dev)
672 pcb config it is related to */ 672 pcb config it is related to */
673 cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT, data, 4); 673 cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT, data, 4);
674 674
675 config_info = le32_to_cpu(*((u32 *) data)); 675 config_info = le32_to_cpu(*((__le32 *)data));
676 usb_speed = (u8) (config_info & 0x1); 676 usb_speed = (u8) (config_info & 0x1);
677 677
678 /* Verify this device belongs to Bus power or Self power device */ 678 /* Verify this device belongs to Bus power or Self power device */
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index c0cd0848631b..ecca03667f98 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -377,6 +377,7 @@ static int rtl2832u_read_config(struct dvb_usb_device *d)
377 struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf}; 377 struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf};
378 struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf}; 378 struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf};
379 struct rtl28xxu_req req_r820t = {0x0034, CMD_I2C_RD, 1, buf}; 379 struct rtl28xxu_req req_r820t = {0x0034, CMD_I2C_RD, 1, buf};
380 struct rtl28xxu_req req_r828d = {0x0074, CMD_I2C_RD, 1, buf};
380 381
381 dev_dbg(&d->udev->dev, "%s:\n", __func__); 382 dev_dbg(&d->udev->dev, "%s:\n", __func__);
382 383
@@ -489,6 +490,15 @@ static int rtl2832u_read_config(struct dvb_usb_device *d)
489 goto found; 490 goto found;
490 } 491 }
491 492
493 /* check R828D ID register; reg=00 val=69 */
494 ret = rtl28xxu_ctrl_msg(d, &req_r828d);
495 if (ret == 0 && buf[0] == 0x69) {
496 priv->tuner = TUNER_RTL2832_R828D;
497 priv->tuner_name = "R828D";
498 goto found;
499 }
500
501
492found: 502found:
493 dev_dbg(&d->udev->dev, "%s: tuner=%s\n", __func__, priv->tuner_name); 503 dev_dbg(&d->udev->dev, "%s: tuner=%s\n", __func__, priv->tuner_name);
494 504
@@ -745,6 +755,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
745 rtl2832_config = &rtl28xxu_rtl2832_e4000_config; 755 rtl2832_config = &rtl28xxu_rtl2832_e4000_config;
746 break; 756 break;
747 case TUNER_RTL2832_R820T: 757 case TUNER_RTL2832_R820T:
758 case TUNER_RTL2832_R828D:
748 rtl2832_config = &rtl28xxu_rtl2832_r820t_config; 759 rtl2832_config = &rtl28xxu_rtl2832_r820t_config;
749 break; 760 break;
750 default: 761 default:
@@ -866,6 +877,13 @@ static const struct r820t_config rtl2832u_r820t_config = {
866 .rafael_chip = CHIP_R820T, 877 .rafael_chip = CHIP_R820T,
867}; 878};
868 879
880static const struct r820t_config rtl2832u_r828d_config = {
881 .i2c_addr = 0x3a,
882 .xtal = 16000000,
883 .max_i2c_msg_len = 2,
884 .rafael_chip = CHIP_R828D,
885};
886
869static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) 887static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
870{ 888{
871 int ret; 889 int ret;
@@ -923,6 +941,27 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
923 adap->fe[0]->ops.read_signal_strength = 941 adap->fe[0]->ops.read_signal_strength =
924 adap->fe[0]->ops.tuner_ops.get_rf_strength; 942 adap->fe[0]->ops.tuner_ops.get_rf_strength;
925 break; 943 break;
944 case TUNER_RTL2832_R828D:
945 /* power off mn88472 demod on GPIO0 */
946 ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x00, 0x01);
947 if (ret)
948 goto err;
949
950 ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_DIR, 0x00, 0x01);
951 if (ret)
952 goto err;
953
954 ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_EN, 0x01, 0x01);
955 if (ret)
956 goto err;
957
958 fe = dvb_attach(r820t_attach, adap->fe[0], &d->i2c_adap,
959 &rtl2832u_r828d_config);
960
961 /* Use tuner to get the signal strength */
962 adap->fe[0]->ops.read_signal_strength =
963 adap->fe[0]->ops.tuner_ops.get_rf_strength;
964 break;
926 default: 965 default:
927 fe = NULL; 966 fe = NULL;
928 dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME, 967 dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME,
@@ -1388,6 +1427,9 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
1388 &rtl2832u_props, "Leadtek WinFast DTV Dongle mini", NULL) }, 1427 &rtl2832u_props, "Leadtek WinFast DTV Dongle mini", NULL) },
1389 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_CPYTO_REDI_PC50A, 1428 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_CPYTO_REDI_PC50A,
1390 &rtl2832u_props, "Crypto ReDi PC 50 A", NULL) }, 1429 &rtl2832u_props, "Crypto ReDi PC 50 A", NULL) },
1430
1431 { DVB_USB_DEVICE(USB_VID_HANFTEK, 0x0131,
1432 &rtl2832u_props, "Astrometa DVB-T2", NULL) },
1391 { } 1433 { }
1392}; 1434};
1393MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); 1435MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table);
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
index 729b3540c2f9..2142bcb41b41 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
@@ -83,6 +83,7 @@ enum rtl28xxu_tuner {
83 TUNER_RTL2832_TDA18272, 83 TUNER_RTL2832_TDA18272,
84 TUNER_RTL2832_FC0013, 84 TUNER_RTL2832_FC0013,
85 TUNER_RTL2832_R820T, 85 TUNER_RTL2832_R820T,
86 TUNER_RTL2832_R828D,
86}; 87};
87 88
88struct rtl28xxu_req { 89struct rtl28xxu_req {
diff --git a/drivers/media/usb/dvb-usb/az6027.c b/drivers/media/usb/dvb-usb/az6027.c
index ea2d5ee86576..c11138ebf6fb 100644
--- a/drivers/media/usb/dvb-usb/az6027.c
+++ b/drivers/media/usb/dvb-usb/az6027.c
@@ -254,7 +254,7 @@ static const struct stb0899_s1_reg az6027_stb0899_s1_init_3[] = {
254 254
255 255
256 256
257struct stb0899_config az6027_stb0899_config = { 257static struct stb0899_config az6027_stb0899_config = {
258 .init_dev = az6027_stb0899_s1_init_1, 258 .init_dev = az6027_stb0899_s1_init_1,
259 .init_s2_demod = stb0899_s2_init_2, 259 .init_s2_demod = stb0899_s2_init_2,
260 .init_s1_demod = az6027_stb0899_s1_init_3, 260 .init_s1_demod = az6027_stb0899_s1_init_3,
@@ -291,7 +291,7 @@ struct stb0899_config az6027_stb0899_config = {
291 .tuner_set_rfsiggain = NULL, 291 .tuner_set_rfsiggain = NULL,
292}; 292};
293 293
294struct stb6100_config az6027_stb6100_config = { 294static struct stb6100_config az6027_stb6100_config = {
295 .tuner_address = 0xc0, 295 .tuner_address = 0xc0,
296 .refclock = 27000000, 296 .refclock = 27000000,
297}; 297};
diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
index 6e237b6dd0a8..6136a2c7dbfd 100644
--- a/drivers/media/usb/dvb-usb/dw2102.c
+++ b/drivers/media/usb/dvb-usb/dw2102.c
@@ -955,9 +955,10 @@ static struct ds3000_config dw2104_ds3000_config = {
955 .demod_address = 0x68, 955 .demod_address = 0x68,
956}; 956};
957 957
958static struct ts2020_config dw2104_ts2020_config = { 958static struct ts2020_config dw2104_ts2020_config = {
959 .tuner_address = 0x60, 959 .tuner_address = 0x60,
960 .clk_out_div = 1, 960 .clk_out_div = 1,
961 .frequency_div = 1060000,
961}; 962};
962 963
963static struct ds3000_config s660_ds3000_config = { 964static struct ds3000_config s660_ds3000_config = {
@@ -966,6 +967,12 @@ static struct ds3000_config s660_ds3000_config = {
966 .set_lock_led = dw210x_led_ctrl, 967 .set_lock_led = dw210x_led_ctrl,
967}; 968};
968 969
970static struct ts2020_config s660_ts2020_config = {
971 .tuner_address = 0x60,
972 .clk_out_div = 1,
973 .frequency_div = 1146000,
974};
975
969static struct stv0900_config dw2104a_stv0900_config = { 976static struct stv0900_config dw2104a_stv0900_config = {
970 .demod_address = 0x6a, 977 .demod_address = 0x6a,
971 .demod_mode = 0, 978 .demod_mode = 0,
@@ -1205,7 +1212,7 @@ static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1205 if (d->fe_adap[0].fe == NULL) 1212 if (d->fe_adap[0].fe == NULL)
1206 return -EIO; 1213 return -EIO;
1207 1214
1208 dvb_attach(ts2020_attach, d->fe_adap[0].fe, &dw2104_ts2020_config, 1215 dvb_attach(ts2020_attach, d->fe_adap[0].fe, &s660_ts2020_config,
1209 &d->dev->i2c_adap); 1216 &d->dev->i2c_adap);
1210 1217
1211 st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage; 1218 st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage;
@@ -1213,7 +1220,7 @@ static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
1213 1220
1214 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1221 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
1215 1222
1216 info("Attached ds3000+ds2020!\n"); 1223 info("Attached ds3000+ts2020!\n");
1217 1224
1218 return 0; 1225 return 0;
1219} 1226}
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c
index 73cc50afa5e1..d666741797d4 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -22,6 +22,7 @@
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <media/soc_camera.h> 23#include <media/soc_camera.h>
24#include <media/mt9v011.h> 24#include <media/mt9v011.h>
25#include <media/v4l2-clk.h>
25#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
26 27
27#include "em28xx.h" 28#include "em28xx.h"
@@ -47,6 +48,7 @@ static struct soc_camera_link camlink = {
47 .bus_id = 0, 48 .bus_id = 0,
48 .flags = 0, 49 .flags = 0,
49 .module_name = "em28xx", 50 .module_name = "em28xx",
51 .unbalanced_power = true,
50}; 52};
51 53
52 54
@@ -325,13 +327,24 @@ int em28xx_detect_sensor(struct em28xx *dev)
325 327
326int em28xx_init_camera(struct em28xx *dev) 328int em28xx_init_camera(struct em28xx *dev)
327{ 329{
330 char clk_name[V4L2_SUBDEV_NAME_SIZE];
331 struct i2c_client *client = &dev->i2c_client[dev->def_i2c_bus];
332 struct i2c_adapter *adap = &dev->i2c_adap[dev->def_i2c_bus];
333 int ret = 0;
334
335 v4l2_clk_name_i2c(clk_name, sizeof(clk_name),
336 i2c_adapter_id(adap), client->addr);
337 dev->clk = v4l2_clk_register_fixed(clk_name, "mclk", -EINVAL);
338 if (IS_ERR(dev->clk))
339 return PTR_ERR(dev->clk);
340
328 switch (dev->em28xx_sensor) { 341 switch (dev->em28xx_sensor) {
329 case EM28XX_MT9V011: 342 case EM28XX_MT9V011:
330 { 343 {
331 struct mt9v011_platform_data pdata; 344 struct mt9v011_platform_data pdata;
332 struct i2c_board_info mt9v011_info = { 345 struct i2c_board_info mt9v011_info = {
333 .type = "mt9v011", 346 .type = "mt9v011",
334 .addr = dev->i2c_client[dev->def_i2c_bus].addr, 347 .addr = client->addr,
335 .platform_data = &pdata, 348 .platform_data = &pdata,
336 }; 349 };
337 350
@@ -352,10 +365,11 @@ int em28xx_init_camera(struct em28xx *dev)
352 dev->sensor_xtal = 4300000; 365 dev->sensor_xtal = 4300000;
353 pdata.xtal = dev->sensor_xtal; 366 pdata.xtal = dev->sensor_xtal;
354 if (NULL == 367 if (NULL ==
355 v4l2_i2c_new_subdev_board(&dev->v4l2_dev, 368 v4l2_i2c_new_subdev_board(&dev->v4l2_dev, adap,
356 &dev->i2c_adap[dev->def_i2c_bus], 369 &mt9v011_info, NULL)) {
357 &mt9v011_info, NULL)) 370 ret = -ENODEV;
358 return -ENODEV; 371 break;
372 }
359 /* probably means GRGB 16 bit bayer */ 373 /* probably means GRGB 16 bit bayer */
360 dev->vinmode = 0x0d; 374 dev->vinmode = 0x0d;
361 dev->vinctl = 0x00; 375 dev->vinctl = 0x00;
@@ -391,7 +405,7 @@ int em28xx_init_camera(struct em28xx *dev)
391 struct i2c_board_info ov2640_info = { 405 struct i2c_board_info ov2640_info = {
392 .type = "ov2640", 406 .type = "ov2640",
393 .flags = I2C_CLIENT_SCCB, 407 .flags = I2C_CLIENT_SCCB,
394 .addr = dev->i2c_client[dev->def_i2c_bus].addr, 408 .addr = client->addr,
395 .platform_data = &camlink, 409 .platform_data = &camlink,
396 }; 410 };
397 struct v4l2_mbus_framefmt fmt; 411 struct v4l2_mbus_framefmt fmt;
@@ -408,9 +422,12 @@ int em28xx_init_camera(struct em28xx *dev)
408 dev->sensor_yres = 480; 422 dev->sensor_yres = 480;
409 423
410 subdev = 424 subdev =
411 v4l2_i2c_new_subdev_board(&dev->v4l2_dev, 425 v4l2_i2c_new_subdev_board(&dev->v4l2_dev, adap,
412 &dev->i2c_adap[dev->def_i2c_bus],
413 &ov2640_info, NULL); 426 &ov2640_info, NULL);
427 if (NULL == subdev) {
428 ret = -ENODEV;
429 break;
430 }
414 431
415 fmt.code = V4L2_MBUS_FMT_YUYV8_2X8; 432 fmt.code = V4L2_MBUS_FMT_YUYV8_2X8;
416 fmt.width = 640; 433 fmt.width = 640;
@@ -427,8 +444,13 @@ int em28xx_init_camera(struct em28xx *dev)
427 } 444 }
428 case EM28XX_NOSENSOR: 445 case EM28XX_NOSENSOR:
429 default: 446 default:
430 return -EINVAL; 447 ret = -EINVAL;
431 } 448 }
432 449
433 return 0; 450 if (ret < 0) {
451 v4l2_clk_unregister_fixed(dev->clk);
452 dev->clk = NULL;
453 }
454
455 return ret;
434} 456}
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index dc65742c4bbc..a5196697627f 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -36,6 +36,7 @@
36#include <media/tvaudio.h> 36#include <media/tvaudio.h>
37#include <media/i2c-addr.h> 37#include <media/i2c-addr.h>
38#include <media/tveeprom.h> 38#include <media/tveeprom.h>
39#include <media/v4l2-clk.h>
39#include <media/v4l2-common.h> 40#include <media/v4l2-common.h>
40 41
41#include "em28xx.h" 42#include "em28xx.h"
@@ -95,8 +96,8 @@ static struct em28xx_reg_seq default_digital[] = {
95/* Board Hauppauge WinTV HVR 900 analog */ 96/* Board Hauppauge WinTV HVR 900 analog */
96static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = { 97static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
97 {EM2820_R08_GPIO_CTRL, 0x2d, ~EM_GPIO_4, 10}, 98 {EM2820_R08_GPIO_CTRL, 0x2d, ~EM_GPIO_4, 10},
98 {0x05, 0xff, 0x10, 10}, 99 { 0x05, 0xff, 0x10, 10},
99 { -1, -1, -1, -1}, 100 { -1, -1, -1, -1},
100}; 101};
101 102
102/* Board Hauppauge WinTV HVR 900 digital */ 103/* Board Hauppauge WinTV HVR 900 digital */
@@ -104,20 +105,20 @@ static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
104 {EM2820_R08_GPIO_CTRL, 0x2e, ~EM_GPIO_4, 10}, 105 {EM2820_R08_GPIO_CTRL, 0x2e, ~EM_GPIO_4, 10},
105 {EM2880_R04_GPO, 0x04, 0x0f, 10}, 106 {EM2880_R04_GPO, 0x04, 0x0f, 10},
106 {EM2880_R04_GPO, 0x0c, 0x0f, 10}, 107 {EM2880_R04_GPO, 0x0c, 0x0f, 10},
107 { -1, -1, -1, -1}, 108 { -1, -1, -1, -1},
108}; 109};
109 110
110/* Board Hauppauge WinTV HVR 900 (R2) digital */ 111/* Board Hauppauge WinTV HVR 900 (R2) digital */
111static struct em28xx_reg_seq hauppauge_wintv_hvr_900R2_digital[] = { 112static struct em28xx_reg_seq hauppauge_wintv_hvr_900R2_digital[] = {
112 {EM2820_R08_GPIO_CTRL, 0x2e, ~EM_GPIO_4, 10}, 113 {EM2820_R08_GPIO_CTRL, 0x2e, ~EM_GPIO_4, 10},
113 {EM2880_R04_GPO, 0x0c, 0x0f, 10}, 114 {EM2880_R04_GPO, 0x0c, 0x0f, 10},
114 { -1, -1, -1, -1}, 115 { -1, -1, -1, -1},
115}; 116};
116 117
117/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */ 118/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
118static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = { 119static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
119 {EM2820_R08_GPIO_CTRL, 0x69, ~EM_GPIO_4, 10}, 120 {EM2820_R08_GPIO_CTRL, 0x69, ~EM_GPIO_4, 10},
120 { -1, -1, -1, -1}, 121 { -1, -1, -1, -1},
121}; 122};
122 123
123/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */ 124/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
@@ -132,7 +133,7 @@ static struct em28xx_reg_seq em2882_kworld_315u_digital[] = {
132 {EM2880_R04_GPO, 0x04, 0xff, 10}, 133 {EM2880_R04_GPO, 0x04, 0xff, 10},
133 {EM2880_R04_GPO, 0x0c, 0xff, 10}, 134 {EM2880_R04_GPO, 0x0c, 0xff, 10},
134 {EM2820_R08_GPIO_CTRL, 0x7e, 0xff, 10}, 135 {EM2820_R08_GPIO_CTRL, 0x7e, 0xff, 10},
135 { -1, -1, -1, -1}, 136 { -1, -1, -1, -1},
136}; 137};
137 138
138static struct em28xx_reg_seq em2882_kworld_315u_tuner_gpio[] = { 139static struct em28xx_reg_seq em2882_kworld_315u_tuner_gpio[] = {
@@ -140,19 +141,19 @@ static struct em28xx_reg_seq em2882_kworld_315u_tuner_gpio[] = {
140 {EM2880_R04_GPO, 0x0c, 0xff, 10}, 141 {EM2880_R04_GPO, 0x0c, 0xff, 10},
141 {EM2880_R04_GPO, 0x08, 0xff, 10}, 142 {EM2880_R04_GPO, 0x08, 0xff, 10},
142 {EM2880_R04_GPO, 0x0c, 0xff, 10}, 143 {EM2880_R04_GPO, 0x0c, 0xff, 10},
143 { -1, -1, -1, -1}, 144 { -1, -1, -1, -1},
144}; 145};
145 146
146static struct em28xx_reg_seq kworld_330u_analog[] = { 147static struct em28xx_reg_seq kworld_330u_analog[] = {
147 {EM2820_R08_GPIO_CTRL, 0x6d, ~EM_GPIO_4, 10}, 148 {EM2820_R08_GPIO_CTRL, 0x6d, ~EM_GPIO_4, 10},
148 {EM2880_R04_GPO, 0x00, 0xff, 10}, 149 {EM2880_R04_GPO, 0x00, 0xff, 10},
149 { -1, -1, -1, -1}, 150 { -1, -1, -1, -1},
150}; 151};
151 152
152static struct em28xx_reg_seq kworld_330u_digital[] = { 153static struct em28xx_reg_seq kworld_330u_digital[] = {
153 {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10}, 154 {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10},
154 {EM2880_R04_GPO, 0x08, 0xff, 10}, 155 {EM2880_R04_GPO, 0x08, 0xff, 10},
155 { -1, -1, -1, -1}, 156 { -1, -1, -1, -1},
156}; 157};
157 158
158/* Evga inDtube 159/* Evga inDtube
@@ -170,11 +171,11 @@ static struct em28xx_reg_seq evga_indtube_digital[] = {
170 {EM2820_R08_GPIO_CTRL, 0x7a, 0xff, 1}, 171 {EM2820_R08_GPIO_CTRL, 0x7a, 0xff, 1},
171 {EM2880_R04_GPO, 0x04, 0xff, 10}, 172 {EM2880_R04_GPO, 0x04, 0xff, 10},
172 {EM2880_R04_GPO, 0x0c, 0xff, 1}, 173 {EM2880_R04_GPO, 0x0c, 0xff, 1},
173 { -1, -1, -1, -1}, 174 { -1, -1, -1, -1},
174}; 175};
175 176
176/* 177/*
177 * KWorld PlusTV 340U and UB435-Q (ATSC) GPIOs map: 178 * KWorld PlusTV 340U, UB435-Q and UB435-Q V2 (ATSC) GPIOs map:
178 * EM_GPIO_0 - currently unknown 179 * EM_GPIO_0 - currently unknown
179 * EM_GPIO_1 - LED disable/enable (1 = off, 0 = on) 180 * EM_GPIO_1 - LED disable/enable (1 = off, 0 = on)
180 * EM_GPIO_2 - currently unknown 181 * EM_GPIO_2 - currently unknown
@@ -185,8 +186,8 @@ static struct em28xx_reg_seq evga_indtube_digital[] = {
185 * EM_GPIO_7 - currently unknown 186 * EM_GPIO_7 - currently unknown
186 */ 187 */
187static struct em28xx_reg_seq kworld_a340_digital[] = { 188static struct em28xx_reg_seq kworld_a340_digital[] = {
188 {EM2820_R08_GPIO_CTRL, 0x6d, ~EM_GPIO_4, 10}, 189 {EM2820_R08_GPIO_CTRL, 0x6d, ~EM_GPIO_4, 10},
189 { -1, -1, -1, -1}, 190 { -1, -1, -1, -1},
190}; 191};
191 192
192/* Pinnacle Hybrid Pro eb1a:2881 */ 193/* Pinnacle Hybrid Pro eb1a:2881 */
@@ -205,13 +206,13 @@ static struct em28xx_reg_seq pinnacle_hybrid_pro_digital[] = {
205static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_analog[] = { 206static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_analog[] = {
206 {EM2820_R08_GPIO_CTRL, 0x6d, ~EM_GPIO_4, 10}, 207 {EM2820_R08_GPIO_CTRL, 0x6d, ~EM_GPIO_4, 10},
207 {EM2880_R04_GPO, 0x00, 0xff, 10}, 208 {EM2880_R04_GPO, 0x00, 0xff, 10},
208 { -1, -1, -1, -1}, 209 { -1, -1, -1, -1},
209}; 210};
210 211
211static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_digital[] = { 212static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_digital[] = {
212 {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10}, 213 {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10},
213 {EM2880_R04_GPO, 0x08, 0xff, 10}, 214 {EM2880_R04_GPO, 0x08, 0xff, 10},
214 { -1, -1, -1, -1}, 215 { -1, -1, -1, -1},
215}; 216};
216 217
217/* eb1a:2868 Reddo DVB-C USB TV Box 218/* eb1a:2868 Reddo DVB-C USB TV Box
@@ -225,7 +226,7 @@ static struct em28xx_reg_seq reddo_dvb_c_usb_box[] = {
225 {EM2820_R08_GPIO_CTRL, 0x7f, 0xff, 10}, 226 {EM2820_R08_GPIO_CTRL, 0x7f, 0xff, 10},
226 {EM2820_R08_GPIO_CTRL, 0x6f, 0xff, 10}, 227 {EM2820_R08_GPIO_CTRL, 0x6f, 0xff, 10},
227 {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, 228 {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10},
228 {-1, -1, -1, -1}, 229 { -1, -1, -1, -1},
229}; 230};
230 231
231/* Callback for the most boards */ 232/* Callback for the most boards */
@@ -233,23 +234,23 @@ static struct em28xx_reg_seq default_tuner_gpio[] = {
233 {EM2820_R08_GPIO_CTRL, EM_GPIO_4, EM_GPIO_4, 10}, 234 {EM2820_R08_GPIO_CTRL, EM_GPIO_4, EM_GPIO_4, 10},
234 {EM2820_R08_GPIO_CTRL, 0, EM_GPIO_4, 10}, 235 {EM2820_R08_GPIO_CTRL, 0, EM_GPIO_4, 10},
235 {EM2820_R08_GPIO_CTRL, EM_GPIO_4, EM_GPIO_4, 10}, 236 {EM2820_R08_GPIO_CTRL, EM_GPIO_4, EM_GPIO_4, 10},
236 { -1, -1, -1, -1}, 237 { -1, -1, -1, -1},
237}; 238};
238 239
239/* Mute/unmute */ 240/* Mute/unmute */
240static struct em28xx_reg_seq compro_unmute_tv_gpio[] = { 241static struct em28xx_reg_seq compro_unmute_tv_gpio[] = {
241 {EM2820_R08_GPIO_CTRL, 5, 7, 10}, 242 {EM2820_R08_GPIO_CTRL, 5, 7, 10},
242 { -1, -1, -1, -1}, 243 { -1, -1, -1, -1},
243}; 244};
244 245
245static struct em28xx_reg_seq compro_unmute_svid_gpio[] = { 246static struct em28xx_reg_seq compro_unmute_svid_gpio[] = {
246 {EM2820_R08_GPIO_CTRL, 4, 7, 10}, 247 {EM2820_R08_GPIO_CTRL, 4, 7, 10},
247 { -1, -1, -1, -1}, 248 { -1, -1, -1, -1},
248}; 249};
249 250
250static struct em28xx_reg_seq compro_mute_gpio[] = { 251static struct em28xx_reg_seq compro_mute_gpio[] = {
251 {EM2820_R08_GPIO_CTRL, 6, 7, 10}, 252 {EM2820_R08_GPIO_CTRL, 6, 7, 10},
252 { -1, -1, -1, -1}, 253 { -1, -1, -1, -1},
253}; 254};
254 255
255/* Terratec AV350 */ 256/* Terratec AV350 */
@@ -279,21 +280,21 @@ static struct em28xx_reg_seq vc211a_enable[] = {
279static struct em28xx_reg_seq dikom_dk300_digital[] = { 280static struct em28xx_reg_seq dikom_dk300_digital[] = {
280 {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10}, 281 {EM2820_R08_GPIO_CTRL, 0x6e, ~EM_GPIO_4, 10},
281 {EM2880_R04_GPO, 0x08, 0xff, 10}, 282 {EM2880_R04_GPO, 0x08, 0xff, 10},
282 { -1, -1, -1, -1}, 283 { -1, -1, -1, -1},
283}; 284};
284 285
285 286
286/* Reset for the most [digital] boards */ 287/* Reset for the most [digital] boards */
287static struct em28xx_reg_seq leadership_digital[] = { 288static struct em28xx_reg_seq leadership_digital[] = {
288 {EM2874_R80_GPIO_P0_CTRL, 0x70, 0xff, 10}, 289 {EM2874_R80_GPIO_P0_CTRL, 0x70, 0xff, 10},
289 { -1, -1, -1, -1}, 290 { -1, -1, -1, -1},
290}; 291};
291 292
292static struct em28xx_reg_seq leadership_reset[] = { 293static struct em28xx_reg_seq leadership_reset[] = {
293 {EM2874_R80_GPIO_P0_CTRL, 0xf0, 0xff, 10}, 294 {EM2874_R80_GPIO_P0_CTRL, 0xf0, 0xff, 10},
294 {EM2874_R80_GPIO_P0_CTRL, 0xb0, 0xff, 10}, 295 {EM2874_R80_GPIO_P0_CTRL, 0xb0, 0xff, 10},
295 {EM2874_R80_GPIO_P0_CTRL, 0xf0, 0xff, 10}, 296 {EM2874_R80_GPIO_P0_CTRL, 0xf0, 0xff, 10},
296 { -1, -1, -1, -1}, 297 { -1, -1, -1, -1},
297}; 298};
298 299
299/* 2013:024f PCTV nanoStick T2 290e 300/* 2013:024f PCTV nanoStick T2 290e
@@ -304,7 +305,7 @@ static struct em28xx_reg_seq pctv_290e[] = {
304 {EM2874_R80_GPIO_P0_CTRL, 0x00, 0xff, 80}, 305 {EM2874_R80_GPIO_P0_CTRL, 0x00, 0xff, 80},
305 {EM2874_R80_GPIO_P0_CTRL, 0x40, 0xff, 80}, /* GPIO_6 = 1 */ 306 {EM2874_R80_GPIO_P0_CTRL, 0x40, 0xff, 80}, /* GPIO_6 = 1 */
306 {EM2874_R80_GPIO_P0_CTRL, 0xc0, 0xff, 80}, /* GPIO_7 = 1 */ 307 {EM2874_R80_GPIO_P0_CTRL, 0xc0, 0xff, 80}, /* GPIO_7 = 1 */
307 {-1, -1, -1, -1}, 308 { -1, -1, -1, -1},
308}; 309};
309 310
310#if 0 311#if 0
@@ -313,14 +314,14 @@ static struct em28xx_reg_seq terratec_h5_gpio[] = {
313 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, 314 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100},
314 {EM2874_R80_GPIO_P0_CTRL, 0xf2, 0xff, 50}, 315 {EM2874_R80_GPIO_P0_CTRL, 0xf2, 0xff, 50},
315 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 50}, 316 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 50},
316 { -1, -1, -1, -1}, 317 { -1, -1, -1, -1},
317}; 318};
318 319
319static struct em28xx_reg_seq terratec_h5_digital[] = { 320static struct em28xx_reg_seq terratec_h5_digital[] = {
320 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 10}, 321 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 10},
321 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, 322 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100},
322 {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 10}, 323 {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 10},
323 { -1, -1, -1, -1}, 324 { -1, -1, -1, -1},
324}; 325};
325#endif 326#endif
326 327
@@ -335,12 +336,12 @@ static struct em28xx_reg_seq terratec_h5_digital[] = {
335 * GPIO_7 - LED (green LED) 336 * GPIO_7 - LED (green LED)
336 */ 337 */
337static struct em28xx_reg_seq pctv_460e[] = { 338static struct em28xx_reg_seq pctv_460e[] = {
338 {EM2874_R80_GPIO_P0_CTRL, 0x01, 0xff, 50}, 339 {EM2874_R80_GPIO_P0_CTRL, 0x01, 0xff, 50},
339 {0x0d, 0xff, 0xff, 50}, 340 { 0x0d, 0xff, 0xff, 50},
340 {EM2874_R80_GPIO_P0_CTRL, 0x41, 0xff, 50}, /* GPIO_6=1 */ 341 {EM2874_R80_GPIO_P0_CTRL, 0x41, 0xff, 50}, /* GPIO_6=1 */
341 {0x0d, 0x42, 0xff, 50}, 342 { 0x0d, 0x42, 0xff, 50},
342 {EM2874_R80_GPIO_P0_CTRL, 0x61, 0xff, 50}, /* GPIO_5=1 */ 343 {EM2874_R80_GPIO_P0_CTRL, 0x61, 0xff, 50}, /* GPIO_5=1 */
343 { -1, -1, -1, -1}, 344 { -1, -1, -1, -1},
344}; 345};
345 346
346static struct em28xx_reg_seq c3tech_digital_duo_digital[] = { 347static struct em28xx_reg_seq c3tech_digital_duo_digital[] = {
@@ -352,7 +353,7 @@ static struct em28xx_reg_seq c3tech_digital_duo_digital[] = {
352 {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 10}, 353 {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 10},
353 {EM2874_R80_GPIO_P0_CTRL, 0xbe, 0xff, 10}, 354 {EM2874_R80_GPIO_P0_CTRL, 0xbe, 0xff, 10},
354 {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 20}, 355 {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 20},
355 { -1, -1, -1, -1}, 356 { -1, -1, -1, -1},
356}; 357};
357 358
358#if 0 359#if 0
@@ -361,14 +362,14 @@ static struct em28xx_reg_seq hauppauge_930c_gpio[] = {
361 {EM2874_R80_GPIO_P0_CTRL, 0x4f, 0xff, 10}, /* xc5000 reset */ 362 {EM2874_R80_GPIO_P0_CTRL, 0x4f, 0xff, 10}, /* xc5000 reset */
362 {EM2874_R80_GPIO_P0_CTRL, 0x6f, 0xff, 10}, 363 {EM2874_R80_GPIO_P0_CTRL, 0x6f, 0xff, 10},
363 {EM2874_R80_GPIO_P0_CTRL, 0x4f, 0xff, 10}, 364 {EM2874_R80_GPIO_P0_CTRL, 0x4f, 0xff, 10},
364 { -1, -1, -1, -1}, 365 { -1, -1, -1, -1},
365}; 366};
366 367
367static struct em28xx_reg_seq hauppauge_930c_digital[] = { 368static struct em28xx_reg_seq hauppauge_930c_digital[] = {
368 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 10}, 369 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 10},
369 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, 370 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100},
370 {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 10}, 371 {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 10},
371 { -1, -1, -1, -1}, 372 { -1, -1, -1, -1},
372}; 373};
373#endif 374#endif
374 375
@@ -378,10 +379,10 @@ static struct em28xx_reg_seq hauppauge_930c_digital[] = {
378 * GPIO_7 - LED, 0=active 379 * GPIO_7 - LED, 0=active
379 */ 380 */
380static struct em28xx_reg_seq maxmedia_ub425_tc[] = { 381static struct em28xx_reg_seq maxmedia_ub425_tc[] = {
381 {EM2874_R80_GPIO_P0_CTRL, 0x83, 0xff, 100}, 382 {EM2874_R80_GPIO_P0_CTRL, 0x83, 0xff, 100},
382 {EM2874_R80_GPIO_P0_CTRL, 0xc3, 0xff, 100}, /* GPIO_6 = 1 */ 383 {EM2874_R80_GPIO_P0_CTRL, 0xc3, 0xff, 100}, /* GPIO_6 = 1 */
383 {EM2874_R80_GPIO_P0_CTRL, 0x43, 0xff, 000}, /* GPIO_7 = 0 */ 384 {EM2874_R80_GPIO_P0_CTRL, 0x43, 0xff, 000}, /* GPIO_7 = 0 */
384 {-1, -1, -1, -1}, 385 { -1, -1, -1, -1},
385}; 386};
386 387
387/* 2304:0242 PCTV QuatroStick (510e) 388/* 2304:0242 PCTV QuatroStick (510e)
@@ -391,10 +392,10 @@ static struct em28xx_reg_seq maxmedia_ub425_tc[] = {
391 * GPIO_7: LED, 1=active 392 * GPIO_7: LED, 1=active
392 */ 393 */
393static struct em28xx_reg_seq pctv_510e[] = { 394static struct em28xx_reg_seq pctv_510e[] = {
394 {EM2874_R80_GPIO_P0_CTRL, 0x10, 0xff, 100}, 395 {EM2874_R80_GPIO_P0_CTRL, 0x10, 0xff, 100},
395 {EM2874_R80_GPIO_P0_CTRL, 0x14, 0xff, 100}, /* GPIO_2 = 1 */ 396 {EM2874_R80_GPIO_P0_CTRL, 0x14, 0xff, 100}, /* GPIO_2 = 1 */
396 {EM2874_R80_GPIO_P0_CTRL, 0x54, 0xff, 050}, /* GPIO_6 = 1 */ 397 {EM2874_R80_GPIO_P0_CTRL, 0x54, 0xff, 050}, /* GPIO_6 = 1 */
397 { -1, -1, -1, -1}, 398 { -1, -1, -1, -1},
398}; 399};
399 400
400/* 2013:0251 PCTV QuatroStick nano (520e) 401/* 2013:0251 PCTV QuatroStick nano (520e)
@@ -404,11 +405,11 @@ static struct em28xx_reg_seq pctv_510e[] = {
404 * GPIO_7: LED, 1=active 405 * GPIO_7: LED, 1=active
405 */ 406 */
406static struct em28xx_reg_seq pctv_520e[] = { 407static struct em28xx_reg_seq pctv_520e[] = {
407 {EM2874_R80_GPIO_P0_CTRL, 0x10, 0xff, 100}, 408 {EM2874_R80_GPIO_P0_CTRL, 0x10, 0xff, 100},
408 {EM2874_R80_GPIO_P0_CTRL, 0x14, 0xff, 100}, /* GPIO_2 = 1 */ 409 {EM2874_R80_GPIO_P0_CTRL, 0x14, 0xff, 100}, /* GPIO_2 = 1 */
409 {EM2874_R80_GPIO_P0_CTRL, 0x54, 0xff, 050}, /* GPIO_6 = 1 */ 410 {EM2874_R80_GPIO_P0_CTRL, 0x54, 0xff, 050}, /* GPIO_6 = 1 */
410 {EM2874_R80_GPIO_P0_CTRL, 0xd4, 0xff, 000}, /* GPIO_7 = 1 */ 411 {EM2874_R80_GPIO_P0_CTRL, 0xd4, 0xff, 000}, /* GPIO_7 = 1 */
411 { -1, -1, -1, -1}, 412 { -1, -1, -1, -1},
412}; 413};
413 414
414/* 415/*
@@ -2030,6 +2031,18 @@ struct em28xx_board em28xx_boards[] = {
2030 .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | 2031 .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
2031 EM28XX_I2C_FREQ_400_KHZ, 2032 EM28XX_I2C_FREQ_400_KHZ,
2032 }, 2033 },
2034 /*
2035 * 1b80:e346 KWorld USB ATSC TV Stick UB435-Q V2
2036 * Empia EM2874B + LG DT3305 + NXP TDA18271HDC2
2037 */
2038 [EM2874_BOARD_KWORLD_UB435Q_V2] = {
2039 .name = "KWorld USB ATSC TV Stick UB435-Q V2",
2040 .tuner_type = TUNER_ABSENT,
2041 .has_dvb = 1,
2042 .dvb_gpio = kworld_a340_digital,
2043 .tuner_gpio = default_tuner_gpio,
2044 .def_i2c_bus = 1,
2045 },
2033}; 2046};
2034const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards); 2047const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
2035 2048
@@ -2173,6 +2186,8 @@ struct usb_device_id em28xx_id_table[] = {
2173 .driver_info = EM2860_BOARD_GADMEI_UTV330 }, 2186 .driver_info = EM2860_BOARD_GADMEI_UTV330 },
2174 { USB_DEVICE(0x1b80, 0xa340), 2187 { USB_DEVICE(0x1b80, 0xa340),
2175 .driver_info = EM2870_BOARD_KWORLD_A340 }, 2188 .driver_info = EM2870_BOARD_KWORLD_A340 },
2189 { USB_DEVICE(0x1b80, 0xe346),
2190 .driver_info = EM2874_BOARD_KWORLD_UB435Q_V2 },
2176 { USB_DEVICE(0x2013, 0x024f), 2191 { USB_DEVICE(0x2013, 0x024f),
2177 .driver_info = EM28174_BOARD_PCTV_290E }, 2192 .driver_info = EM28174_BOARD_PCTV_290E },
2178 { USB_DEVICE(0x2013, 0x024c), 2193 { USB_DEVICE(0x2013, 0x024c),
@@ -2857,6 +2872,8 @@ void em28xx_release_resources(struct em28xx *dev)
2857 if (dev->def_i2c_bus) 2872 if (dev->def_i2c_bus)
2858 em28xx_i2c_unregister(dev, 1); 2873 em28xx_i2c_unregister(dev, 1);
2859 em28xx_i2c_unregister(dev, 0); 2874 em28xx_i2c_unregister(dev, 0);
2875 if (dev->clk)
2876 v4l2_clk_unregister_fixed(dev->clk);
2860 2877
2861 v4l2_ctrl_handler_free(&dev->ctrl_handler); 2878 v4l2_ctrl_handler_free(&dev->ctrl_handler);
2862 2879
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index bb1e8dca80cd..344042bb845c 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -298,6 +298,18 @@ static struct lgdt3305_config em2870_lgdt3304_dev = {
298 .qam_if_khz = 4000, 298 .qam_if_khz = 4000,
299}; 299};
300 300
301static struct lgdt3305_config em2874_lgdt3305_dev = {
302 .i2c_addr = 0x0e,
303 .demod_chip = LGDT3305,
304 .spectral_inversion = 1,
305 .deny_i2c_rptr = 0,
306 .mpeg_mode = LGDT3305_MPEG_SERIAL,
307 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
308 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
309 .vsb_if_khz = 3250,
310 .qam_if_khz = 4000,
311};
312
301static struct s921_config sharp_isdbt = { 313static struct s921_config sharp_isdbt = {
302 .demod_address = 0x30 >> 1 314 .demod_address = 0x30 >> 1
303}; 315};
@@ -329,6 +341,11 @@ static struct tda18271_config kworld_a340_config = {
329 .std_map = &kworld_a340_std_map, 341 .std_map = &kworld_a340_std_map,
330}; 342};
331 343
344static struct tda18271_config kworld_ub435q_v2_config = {
345 .std_map = &kworld_a340_std_map,
346 .gate = TDA18271_GATE_DIGITAL,
347};
348
332static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate = { 349static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate = {
333 .demod_address = (0x1e >> 1), 350 .demod_address = (0x1e >> 1),
334 .no_tuner = 1, 351 .no_tuner = 1,
@@ -384,7 +401,10 @@ static struct drxk_config maxmedia_ub425_tc_drxk = {
384 .adr = 0x29, 401 .adr = 0x29,
385 .single_master = 1, 402 .single_master = 1,
386 .no_i2c_bridge = 1, 403 .no_i2c_bridge = 1,
404 .microcode_name = "dvb-demod-drxk-01.fw",
405 .chunk_size = 62,
387 .load_firmware_sync = true, 406 .load_firmware_sync = true,
407 .qam_demod_parameter_count = 2,
388}; 408};
389 409
390static struct drxk_config pctv_520e_drxk = { 410static struct drxk_config pctv_520e_drxk = {
@@ -424,7 +444,7 @@ static void hauppauge_hvr930c_init(struct em28xx *dev)
424 {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0x65}, 444 {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0x65},
425 {EM2874_R80_GPIO_P0_CTRL, 0xfb, 0xff, 0x32}, 445 {EM2874_R80_GPIO_P0_CTRL, 0xfb, 0xff, 0x32},
426 {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0xb8}, 446 {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0xb8},
427 { -1, -1, -1, -1}, 447 { -1, -1, -1, -1},
428 }; 448 };
429 struct em28xx_reg_seq hauppauge_hvr930c_end[] = { 449 struct em28xx_reg_seq hauppauge_hvr930c_end[] = {
430 {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x01}, 450 {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x01},
@@ -439,7 +459,7 @@ static void hauppauge_hvr930c_init(struct em28xx *dev)
439 {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x0b}, 459 {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x0b},
440 {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x65}, 460 {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x65},
441 461
442 { -1, -1, -1, -1}, 462 { -1, -1, -1, -1},
443 }; 463 };
444 464
445 struct { 465 struct {
@@ -491,13 +511,13 @@ static void terratec_h5_init(struct em28xx *dev)
491 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, 511 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100},
492 {EM2874_R80_GPIO_P0_CTRL, 0xf2, 0xff, 50}, 512 {EM2874_R80_GPIO_P0_CTRL, 0xf2, 0xff, 50},
493 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, 513 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100},
494 { -1, -1, -1, -1}, 514 { -1, -1, -1, -1},
495 }; 515 };
496 struct em28xx_reg_seq terratec_h5_end[] = { 516 struct em28xx_reg_seq terratec_h5_end[] = {
497 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, 517 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100},
498 {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 50}, 518 {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 50},
499 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, 519 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100},
500 { -1, -1, -1, -1}, 520 { -1, -1, -1, -1},
501 }; 521 };
502 struct { 522 struct {
503 unsigned char r[4]; 523 unsigned char r[4];
@@ -547,12 +567,12 @@ static void terratec_htc_stick_init(struct em28xx *dev)
547 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, 567 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100},
548 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 50}, 568 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 50},
549 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, 569 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100},
550 { -1, -1, -1, -1}, 570 { -1, -1, -1, -1},
551 }; 571 };
552 struct em28xx_reg_seq terratec_htc_stick_end[] = { 572 struct em28xx_reg_seq terratec_htc_stick_end[] = {
553 {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100}, 573 {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100},
554 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 50}, 574 {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 50},
555 { -1, -1, -1, -1}, 575 { -1, -1, -1, -1},
556 }; 576 };
557 577
558 /* 578 /*
@@ -594,13 +614,13 @@ static void terratec_htc_usb_xs_init(struct em28xx *dev)
594 {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 100}, 614 {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 100},
595 {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 50}, 615 {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 50},
596 {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100}, 616 {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100},
597 { -1, -1, -1, -1}, 617 { -1, -1, -1, -1},
598 }; 618 };
599 struct em28xx_reg_seq terratec_htc_usb_xs_end[] = { 619 struct em28xx_reg_seq terratec_htc_usb_xs_end[] = {
600 {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 100}, 620 {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 100},
601 {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 50}, 621 {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 50},
602 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, 622 {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100},
603 { -1, -1, -1, -1}, 623 { -1, -1, -1, -1},
604 }; 624 };
605 625
606 /* 626 /*
@@ -1227,18 +1247,14 @@ static int em28xx_dvb_init(struct em28xx *dev)
1227 dvb->fe[0]->ops.i2c_gate_ctrl = NULL; 1247 dvb->fe[0]->ops.i2c_gate_ctrl = NULL;
1228 1248
1229 /* attach tuner */ 1249 /* attach tuner */
1230 if (!dvb_attach(tda18271c2dd_attach, dvb->fe[0], 1250 if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
1231 &dev->i2c_adap[dev->def_i2c_bus], 0x60)) { 1251 &dev->i2c_adap[dev->def_i2c_bus],
1252 &em28xx_cxd2820r_tda18271_config)) {
1232 dvb_frontend_detach(dvb->fe[0]); 1253 dvb_frontend_detach(dvb->fe[0]);
1233 result = -EINVAL; 1254 result = -EINVAL;
1234 goto out_free; 1255 goto out_free;
1235 } 1256 }
1236 } 1257 }
1237
1238 /* TODO: we need drx-3913k firmware in order to support DVB-T */
1239 em28xx_info("MaxMedia UB425-TC/Delock 61959: only DVB-C " \
1240 "supported by that driver version\n");
1241
1242 break; 1258 break;
1243 case EM2884_BOARD_PCTV_510E: 1259 case EM2884_BOARD_PCTV_510E:
1244 case EM2884_BOARD_PCTV_520E: 1260 case EM2884_BOARD_PCTV_520E:
@@ -1297,6 +1313,23 @@ static int em28xx_dvb_init(struct em28xx *dev)
1297 goto out_free; 1313 goto out_free;
1298 } 1314 }
1299 break; 1315 break;
1316 case EM2874_BOARD_KWORLD_UB435Q_V2:
1317 dvb->fe[0] = dvb_attach(lgdt3305_attach,
1318 &em2874_lgdt3305_dev,
1319 &dev->i2c_adap[dev->def_i2c_bus]);
1320 if (!dvb->fe[0]) {
1321 result = -EINVAL;
1322 goto out_free;
1323 }
1324
1325 /* Attach the demodulator. */
1326 if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
1327 &dev->i2c_adap[dev->def_i2c_bus],
1328 &kworld_ub435q_v2_config)) {
1329 result = -EINVAL;
1330 goto out_free;
1331 }
1332 break;
1300 default: 1333 default:
1301 em28xx_errdev("/2: The frontend of your DVB/ATSC card" 1334 em28xx_errdev("/2: The frontend of your DVB/ATSC card"
1302 " isn't supported yet\n"); 1335 " isn't supported yet\n");
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 9d103344f34a..fc5d60efd4ab 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -638,7 +638,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
638 if (rc) 638 if (rc)
639 return rc; 639 return rc;
640 640
641 if (dev->streaming_users++ == 0) { 641 if (dev->streaming_users == 0) {
642 /* First active streaming user, so allocate all the URBs */ 642 /* First active streaming user, so allocate all the URBs */
643 643
644 /* Allocate the USB bandwidth */ 644 /* Allocate the USB bandwidth */
@@ -657,7 +657,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
657 dev->packet_multiplier, 657 dev->packet_multiplier,
658 em28xx_urb_data_copy); 658 em28xx_urb_data_copy);
659 if (rc < 0) 659 if (rc < 0)
660 goto fail; 660 return rc;
661 661
662 /* 662 /*
663 * djh: it's not clear whether this code is still needed. I'm 663 * djh: it's not clear whether this code is still needed. I'm
@@ -675,7 +675,8 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
675 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f); 675 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f);
676 } 676 }
677 677
678fail: 678 dev->streaming_users++;
679
679 return rc; 680 return rc;
680} 681}
681 682
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 205e9038b1c0..f8726ad5d0a8 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -131,6 +131,7 @@
131#define EM2884_BOARD_TERRATEC_HTC_USB_XS 87 131#define EM2884_BOARD_TERRATEC_HTC_USB_XS 87
132#define EM2884_BOARD_C3TECH_DIGITAL_DUO 88 132#define EM2884_BOARD_C3TECH_DIGITAL_DUO 88
133#define EM2874_BOARD_DELOCK_61959 89 133#define EM2874_BOARD_DELOCK_61959 89
134#define EM2874_BOARD_KWORLD_UB435Q_V2 90
134 135
135/* Limits minimum and default number of buffers */ 136/* Limits minimum and default number of buffers */
136#define EM28XX_MIN_BUF 4 137#define EM28XX_MIN_BUF 4
@@ -492,6 +493,7 @@ struct em28xx {
492 493
493 struct v4l2_device v4l2_dev; 494 struct v4l2_device v4l2_dev;
494 struct v4l2_ctrl_handler ctrl_handler; 495 struct v4l2_ctrl_handler ctrl_handler;
496 struct v4l2_clk *clk;
495 struct em28xx_board board; 497 struct em28xx_board board;
496 498
497 /* Webcam specific fields */ 499 /* Webcam specific fields */
diff --git a/drivers/media/usb/gspca/conex.c b/drivers/media/usb/gspca/conex.c
index 38714df31ac4..2e15c80d6e3d 100644
--- a/drivers/media/usb/gspca/conex.c
+++ b/drivers/media/usb/gspca/conex.c
@@ -783,7 +783,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
783 struct sd *sd = (struct sd *) gspca_dev; 783 struct sd *sd = (struct sd *) gspca_dev;
784 784
785 /* create the JPEG header */ 785 /* create the JPEG header */
786 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 786 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
787 gspca_dev->pixfmt.width,
787 0x22); /* JPEG 411 */ 788 0x22); /* JPEG 411 */
788 jpeg_set_qual(sd->jpeg_hdr, QUALITY); 789 jpeg_set_qual(sd->jpeg_hdr, QUALITY);
789 790
diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c
index 064b53043b15..f23df4a9d8c5 100644
--- a/drivers/media/usb/gspca/cpia1.c
+++ b/drivers/media/usb/gspca/cpia1.c
@@ -1553,9 +1553,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
1553 sd->params.format.videoSize = VIDEOSIZE_CIF; 1553 sd->params.format.videoSize = VIDEOSIZE_CIF;
1554 1554
1555 sd->params.roi.colEnd = sd->params.roi.colStart + 1555 sd->params.roi.colEnd = sd->params.roi.colStart +
1556 (gspca_dev->width >> 3); 1556 (gspca_dev->pixfmt.width >> 3);
1557 sd->params.roi.rowEnd = sd->params.roi.rowStart + 1557 sd->params.roi.rowEnd = sd->params.roi.rowStart +
1558 (gspca_dev->height >> 2); 1558 (gspca_dev->pixfmt.height >> 2);
1559 1559
1560 /* And now set the camera to a known state */ 1560 /* And now set the camera to a known state */
1561 ret = do_command(gspca_dev, CPIA_COMMAND_SetGrabMode, 1561 ret = do_command(gspca_dev, CPIA_COMMAND_SetGrabMode,
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 048507b27bb2..f3a7ace0fac9 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -504,8 +504,7 @@ static int frame_alloc(struct gspca_dev *gspca_dev, struct file *file,
504 unsigned int frsz; 504 unsigned int frsz;
505 int i; 505 int i;
506 506
507 i = gspca_dev->curr_mode; 507 frsz = gspca_dev->pixfmt.sizeimage;
508 frsz = gspca_dev->cam.cam_mode[i].sizeimage;
509 PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz); 508 PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz);
510 frsz = PAGE_ALIGN(frsz); 509 frsz = PAGE_ALIGN(frsz);
511 if (count >= GSPCA_MAX_FRAMES) 510 if (count >= GSPCA_MAX_FRAMES)
@@ -627,16 +626,14 @@ static struct usb_host_endpoint *alt_xfer(struct usb_host_interface *alt,
627static u32 which_bandwidth(struct gspca_dev *gspca_dev) 626static u32 which_bandwidth(struct gspca_dev *gspca_dev)
628{ 627{
629 u32 bandwidth; 628 u32 bandwidth;
630 int i;
631 629
632 /* get the (max) image size */ 630 /* get the (max) image size */
633 i = gspca_dev->curr_mode; 631 bandwidth = gspca_dev->pixfmt.sizeimage;
634 bandwidth = gspca_dev->cam.cam_mode[i].sizeimage;
635 632
636 /* if the image is compressed, estimate its mean size */ 633 /* if the image is compressed, estimate its mean size */
637 if (!gspca_dev->cam.needs_full_bandwidth && 634 if (!gspca_dev->cam.needs_full_bandwidth &&
638 bandwidth < gspca_dev->cam.cam_mode[i].width * 635 bandwidth < gspca_dev->pixfmt.width *
639 gspca_dev->cam.cam_mode[i].height) 636 gspca_dev->pixfmt.height)
640 bandwidth = bandwidth * 3 / 8; /* 0.375 */ 637 bandwidth = bandwidth * 3 / 8; /* 0.375 */
641 638
642 /* estimate the frame rate */ 639 /* estimate the frame rate */
@@ -650,7 +647,7 @@ static u32 which_bandwidth(struct gspca_dev *gspca_dev)
650 647
651 /* don't hope more than 15 fps with USB 1.1 and 648 /* don't hope more than 15 fps with USB 1.1 and
652 * image resolution >= 640x480 */ 649 * image resolution >= 640x480 */
653 if (gspca_dev->width >= 640 650 if (gspca_dev->pixfmt.width >= 640
654 && gspca_dev->dev->speed == USB_SPEED_FULL) 651 && gspca_dev->dev->speed == USB_SPEED_FULL)
655 bandwidth *= 15; /* 15 fps */ 652 bandwidth *= 15; /* 15 fps */
656 else 653 else
@@ -982,9 +979,7 @@ static void gspca_set_default_mode(struct gspca_dev *gspca_dev)
982 979
983 i = gspca_dev->cam.nmodes - 1; /* take the highest mode */ 980 i = gspca_dev->cam.nmodes - 1; /* take the highest mode */
984 gspca_dev->curr_mode = i; 981 gspca_dev->curr_mode = i;
985 gspca_dev->width = gspca_dev->cam.cam_mode[i].width; 982 gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i];
986 gspca_dev->height = gspca_dev->cam.cam_mode[i].height;
987 gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i].pixelformat;
988 983
989 /* does nothing if ctrl_handler == NULL */ 984 /* does nothing if ctrl_handler == NULL */
990 v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler); 985 v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler);
@@ -1105,10 +1100,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
1105 struct v4l2_format *fmt) 1100 struct v4l2_format *fmt)
1106{ 1101{
1107 struct gspca_dev *gspca_dev = video_drvdata(file); 1102 struct gspca_dev *gspca_dev = video_drvdata(file);
1108 int mode;
1109 1103
1110 mode = gspca_dev->curr_mode; 1104 fmt->fmt.pix = gspca_dev->pixfmt;
1111 fmt->fmt.pix = gspca_dev->cam.cam_mode[mode];
1112 /* some drivers use priv internally, zero it before giving it to 1105 /* some drivers use priv internally, zero it before giving it to
1113 userspace */ 1106 userspace */
1114 fmt->fmt.pix.priv = 0; 1107 fmt->fmt.pix.priv = 0;
@@ -1140,6 +1133,12 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
1140 mode = mode2; 1133 mode = mode2;
1141 } 1134 }
1142 fmt->fmt.pix = gspca_dev->cam.cam_mode[mode]; 1135 fmt->fmt.pix = gspca_dev->cam.cam_mode[mode];
1136 if (gspca_dev->sd_desc->try_fmt) {
1137 /* pass original resolution to subdriver try_fmt */
1138 fmt->fmt.pix.width = w;
1139 fmt->fmt.pix.height = h;
1140 gspca_dev->sd_desc->try_fmt(gspca_dev, fmt);
1141 }
1143 /* some drivers use priv internally, zero it before giving it to 1142 /* some drivers use priv internally, zero it before giving it to
1144 userspace */ 1143 userspace */
1145 fmt->fmt.pix.priv = 0; 1144 fmt->fmt.pix.priv = 0;
@@ -1178,19 +1177,16 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1178 goto out; 1177 goto out;
1179 } 1178 }
1180 1179
1181 if (ret == gspca_dev->curr_mode) {
1182 ret = 0;
1183 goto out; /* same mode */
1184 }
1185
1186 if (gspca_dev->streaming) { 1180 if (gspca_dev->streaming) {
1187 ret = -EBUSY; 1181 ret = -EBUSY;
1188 goto out; 1182 goto out;
1189 } 1183 }
1190 gspca_dev->width = fmt->fmt.pix.width;
1191 gspca_dev->height = fmt->fmt.pix.height;
1192 gspca_dev->pixfmt = fmt->fmt.pix.pixelformat;
1193 gspca_dev->curr_mode = ret; 1184 gspca_dev->curr_mode = ret;
1185 if (gspca_dev->sd_desc->try_fmt)
1186 /* subdriver try_fmt can modify format parameters */
1187 gspca_dev->pixfmt = fmt->fmt.pix;
1188 else
1189 gspca_dev->pixfmt = gspca_dev->cam.cam_mode[ret];
1194 1190
1195 ret = 0; 1191 ret = 0;
1196out: 1192out:
@@ -1205,6 +1201,9 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
1205 int i; 1201 int i;
1206 __u32 index = 0; 1202 __u32 index = 0;
1207 1203
1204 if (gspca_dev->sd_desc->enum_framesizes)
1205 return gspca_dev->sd_desc->enum_framesizes(gspca_dev, fsize);
1206
1208 for (i = 0; i < gspca_dev->cam.nmodes; i++) { 1207 for (i = 0; i < gspca_dev->cam.nmodes; i++) {
1209 if (fsize->pixel_format != 1208 if (fsize->pixel_format !=
1210 gspca_dev->cam.cam_mode[i].pixelformat) 1209 gspca_dev->cam.cam_mode[i].pixelformat)
@@ -1471,8 +1470,9 @@ static int vidioc_streamon(struct file *file, void *priv,
1471 if (ret < 0) 1470 if (ret < 0)
1472 goto out; 1471 goto out;
1473 } 1472 }
1474 PDEBUG_MODE(gspca_dev, D_STREAM, "stream on OK", gspca_dev->pixfmt, 1473 PDEBUG_MODE(gspca_dev, D_STREAM, "stream on OK",
1475 gspca_dev->width, gspca_dev->height); 1474 gspca_dev->pixfmt.pixelformat,
1475 gspca_dev->pixfmt.width, gspca_dev->pixfmt.height);
1476 ret = 0; 1476 ret = 0;
1477out: 1477out:
1478 mutex_unlock(&gspca_dev->queue_lock); 1478 mutex_unlock(&gspca_dev->queue_lock);
diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h
index ac0b11f46f50..300642dc1a17 100644
--- a/drivers/media/usb/gspca/gspca.h
+++ b/drivers/media/usb/gspca/gspca.h
@@ -88,6 +88,10 @@ typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev,
88typedef int (*cam_int_pkt_op) (struct gspca_dev *gspca_dev, 88typedef int (*cam_int_pkt_op) (struct gspca_dev *gspca_dev,
89 u8 *data, 89 u8 *data,
90 int len); 90 int len);
91typedef void (*cam_format_op) (struct gspca_dev *gspca_dev,
92 struct v4l2_format *fmt);
93typedef int (*cam_frmsize_op) (struct gspca_dev *gspca_dev,
94 struct v4l2_frmsizeenum *fsize);
91 95
92/* subdriver description */ 96/* subdriver description */
93struct sd_desc { 97struct sd_desc {
@@ -109,6 +113,8 @@ struct sd_desc {
109 cam_set_jpg_op set_jcomp; 113 cam_set_jpg_op set_jcomp;
110 cam_streamparm_op get_streamparm; 114 cam_streamparm_op get_streamparm;
111 cam_streamparm_op set_streamparm; 115 cam_streamparm_op set_streamparm;
116 cam_format_op try_fmt;
117 cam_frmsize_op enum_framesizes;
112#ifdef CONFIG_VIDEO_ADV_DEBUG 118#ifdef CONFIG_VIDEO_ADV_DEBUG
113 cam_set_reg_op set_register; 119 cam_set_reg_op set_register;
114 cam_get_reg_op get_register; 120 cam_get_reg_op get_register;
@@ -183,9 +189,7 @@ struct gspca_dev {
183 __u8 streaming; /* protected by both mutexes (*) */ 189 __u8 streaming; /* protected by both mutexes (*) */
184 190
185 __u8 curr_mode; /* current camera mode */ 191 __u8 curr_mode; /* current camera mode */
186 __u32 pixfmt; /* current mode parameters */ 192 struct v4l2_pix_format pixfmt; /* current mode parameters */
187 __u16 width;
188 __u16 height;
189 __u32 sequence; /* frame sequence number */ 193 __u32 sequence; /* frame sequence number */
190 194
191 wait_queue_head_t wq; /* wait queue */ 195 wait_queue_head_t wq; /* wait queue */
diff --git a/drivers/media/usb/gspca/jeilinj.c b/drivers/media/usb/gspca/jeilinj.c
index 8da3dde38385..19736e237b37 100644
--- a/drivers/media/usb/gspca/jeilinj.c
+++ b/drivers/media/usb/gspca/jeilinj.c
@@ -378,11 +378,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
378 struct sd *dev = (struct sd *) gspca_dev; 378 struct sd *dev = (struct sd *) gspca_dev;
379 379
380 /* create the JPEG header */ 380 /* create the JPEG header */
381 jpeg_define(dev->jpeg_hdr, gspca_dev->height, gspca_dev->width, 381 jpeg_define(dev->jpeg_hdr, gspca_dev->pixfmt.height,
382 gspca_dev->pixfmt.width,
382 0x21); /* JPEG 422 */ 383 0x21); /* JPEG 422 */
383 jpeg_set_qual(dev->jpeg_hdr, dev->quality); 384 jpeg_set_qual(dev->jpeg_hdr, dev->quality);
384 PDEBUG(D_STREAM, "Start streaming at %dx%d", 385 PDEBUG(D_STREAM, "Start streaming at %dx%d",
385 gspca_dev->height, gspca_dev->width); 386 gspca_dev->pixfmt.height, gspca_dev->pixfmt.width);
386 jlj_start(gspca_dev); 387 jlj_start(gspca_dev);
387 return gspca_dev->usb_err; 388 return gspca_dev->usb_err;
388} 389}
diff --git a/drivers/media/usb/gspca/jl2005bcd.c b/drivers/media/usb/gspca/jl2005bcd.c
index fdaeeb14453f..5b481fa43099 100644
--- a/drivers/media/usb/gspca/jl2005bcd.c
+++ b/drivers/media/usb/gspca/jl2005bcd.c
@@ -455,7 +455,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
455 struct sd *sd = (struct sd *) gspca_dev; 455 struct sd *sd = (struct sd *) gspca_dev;
456 sd->cap_mode = gspca_dev->cam.cam_mode; 456 sd->cap_mode = gspca_dev->cam.cam_mode;
457 457
458 switch (gspca_dev->width) { 458 switch (gspca_dev->pixfmt.width) {
459 case 640: 459 case 640:
460 PDEBUG(D_STREAM, "Start streaming at vga resolution"); 460 PDEBUG(D_STREAM, "Start streaming at vga resolution");
461 jl2005c_stream_start_vga_lg(gspca_dev); 461 jl2005c_stream_start_vga_lg(gspca_dev);
diff --git a/drivers/media/usb/gspca/m5602/m5602_mt9m111.c b/drivers/media/usb/gspca/m5602/m5602_mt9m111.c
index cfa4663f8934..27fcef11aef4 100644
--- a/drivers/media/usb/gspca/m5602/m5602_mt9m111.c
+++ b/drivers/media/usb/gspca/m5602/m5602_mt9m111.c
@@ -266,7 +266,7 @@ static int mt9m111_set_hvflip(struct gspca_dev *gspca_dev)
266 return err; 266 return err;
267 267
268 data[0] = MT9M111_RMB_OVER_SIZED; 268 data[0] = MT9M111_RMB_OVER_SIZED;
269 if (gspca_dev->width == 640) { 269 if (gspca_dev->pixfmt.width == 640) {
270 data[1] = MT9M111_RMB_ROW_SKIP_2X | 270 data[1] = MT9M111_RMB_ROW_SKIP_2X |
271 MT9M111_RMB_COLUMN_SKIP_2X | 271 MT9M111_RMB_COLUMN_SKIP_2X |
272 (hflip << 1) | vflip; 272 (hflip << 1) | vflip;
diff --git a/drivers/media/usb/gspca/mars.c b/drivers/media/usb/gspca/mars.c
index ff2c5abf115b..779a8785f421 100644
--- a/drivers/media/usb/gspca/mars.c
+++ b/drivers/media/usb/gspca/mars.c
@@ -254,7 +254,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
254 int i; 254 int i;
255 255
256 /* create the JPEG header */ 256 /* create the JPEG header */
257 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 257 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
258 gspca_dev->pixfmt.width,
258 0x21); /* JPEG 422 */ 259 0x21); /* JPEG 422 */
259 jpeg_set_qual(sd->jpeg_hdr, QUALITY); 260 jpeg_set_qual(sd->jpeg_hdr, QUALITY);
260 261
@@ -270,8 +271,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
270 data[0] = 0x00; /* address */ 271 data[0] = 0x00; /* address */
271 data[1] = 0x0c | 0x01; /* reg 0 */ 272 data[1] = 0x0c | 0x01; /* reg 0 */
272 data[2] = 0x01; /* reg 1 */ 273 data[2] = 0x01; /* reg 1 */
273 data[3] = gspca_dev->width / 8; /* h_size , reg 2 */ 274 data[3] = gspca_dev->pixfmt.width / 8; /* h_size , reg 2 */
274 data[4] = gspca_dev->height / 8; /* v_size , reg 3 */ 275 data[4] = gspca_dev->pixfmt.height / 8; /* v_size , reg 3 */
275 data[5] = 0x30; /* reg 4, MI, PAS5101 : 276 data[5] = 0x30; /* reg 4, MI, PAS5101 :
276 * 0x30 for 24mhz , 0x28 for 12mhz */ 277 * 0x30 for 24mhz , 0x28 for 12mhz */
277 data[6] = 0x02; /* reg 5, H start - was 0x04 */ 278 data[6] = 0x02; /* reg 5, H start - was 0x04 */
diff --git a/drivers/media/usb/gspca/mr97310a.c b/drivers/media/usb/gspca/mr97310a.c
index 68bb2f359666..f006e29ca019 100644
--- a/drivers/media/usb/gspca/mr97310a.c
+++ b/drivers/media/usb/gspca/mr97310a.c
@@ -521,7 +521,7 @@ static int start_cif_cam(struct gspca_dev *gspca_dev)
521 if (sd->sensor_type) 521 if (sd->sensor_type)
522 data[5] = 0xbb; 522 data[5] = 0xbb;
523 523
524 switch (gspca_dev->width) { 524 switch (gspca_dev->pixfmt.width) {
525 case 160: 525 case 160:
526 data[9] |= 0x04; /* reg 8, 2:1 scale down from 320 */ 526 data[9] |= 0x04; /* reg 8, 2:1 scale down from 320 */
527 /* fall thru */ 527 /* fall thru */
@@ -618,7 +618,7 @@ static int start_vga_cam(struct gspca_dev *gspca_dev)
618 data[10] = 0x18; 618 data[10] = 0x18;
619 } 619 }
620 620
621 switch (gspca_dev->width) { 621 switch (gspca_dev->pixfmt.width) {
622 case 160: 622 case 160:
623 data[9] |= 0x0c; /* reg 8, 4:1 scale down */ 623 data[9] |= 0x0c; /* reg 8, 4:1 scale down */
624 /* fall thru */ 624 /* fall thru */
@@ -847,7 +847,7 @@ static void setexposure(struct gspca_dev *gspca_dev, s32 expo, s32 min_clockdiv)
847 u8 clockdiv = (60 * expo + 7999) / 8000; 847 u8 clockdiv = (60 * expo + 7999) / 8000;
848 848
849 /* Limit framerate to not exceed usb bandwidth */ 849 /* Limit framerate to not exceed usb bandwidth */
850 if (clockdiv < min_clockdiv && gspca_dev->width >= 320) 850 if (clockdiv < min_clockdiv && gspca_dev->pixfmt.width >= 320)
851 clockdiv = min_clockdiv; 851 clockdiv = min_clockdiv;
852 else if (clockdiv < 2) 852 else if (clockdiv < 2)
853 clockdiv = 2; 853 clockdiv = 2;
diff --git a/drivers/media/usb/gspca/nw80x.c b/drivers/media/usb/gspca/nw80x.c
index 44c9964b1b3e..599f755e75b8 100644
--- a/drivers/media/usb/gspca/nw80x.c
+++ b/drivers/media/usb/gspca/nw80x.c
@@ -1708,7 +1708,7 @@ static void setautogain(struct gspca_dev *gspca_dev, s32 val)
1708 1708
1709 reg_r(gspca_dev, 0x1004, 1); 1709 reg_r(gspca_dev, 0x1004, 1);
1710 if (gspca_dev->usb_buf[0] & 0x04) { /* if AE_FULL_FRM */ 1710 if (gspca_dev->usb_buf[0] & 0x04) { /* if AE_FULL_FRM */
1711 sd->ae_res = gspca_dev->width * gspca_dev->height; 1711 sd->ae_res = gspca_dev->pixfmt.width * gspca_dev->pixfmt.height;
1712 } else { /* get the AE window size */ 1712 } else { /* get the AE window size */
1713 reg_r(gspca_dev, 0x1011, 8); 1713 reg_r(gspca_dev, 0x1011, 8);
1714 w = (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0] 1714 w = (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0]
@@ -1717,7 +1717,8 @@ static void setautogain(struct gspca_dev *gspca_dev, s32 val)
1717 - (gspca_dev->usb_buf[7] << 8) - gspca_dev->usb_buf[6]; 1717 - (gspca_dev->usb_buf[7] << 8) - gspca_dev->usb_buf[6];
1718 sd->ae_res = h * w; 1718 sd->ae_res = h * w;
1719 if (sd->ae_res == 0) 1719 if (sd->ae_res == 0)
1720 sd->ae_res = gspca_dev->width * gspca_dev->height; 1720 sd->ae_res = gspca_dev->pixfmt.width *
1721 gspca_dev->pixfmt.height;
1721 } 1722 }
1722} 1723}
1723 1724
@@ -1856,21 +1857,21 @@ static int sd_start(struct gspca_dev *gspca_dev)
1856 reg_w_buf(gspca_dev, cmd); 1857 reg_w_buf(gspca_dev, cmd);
1857 switch (sd->webcam) { 1858 switch (sd->webcam) {
1858 case P35u: 1859 case P35u:
1859 if (gspca_dev->width == 320) 1860 if (gspca_dev->pixfmt.width == 320)
1860 reg_w_buf(gspca_dev, nw801_start_qvga); 1861 reg_w_buf(gspca_dev, nw801_start_qvga);
1861 else 1862 else
1862 reg_w_buf(gspca_dev, nw801_start_vga); 1863 reg_w_buf(gspca_dev, nw801_start_vga);
1863 reg_w_buf(gspca_dev, nw801_start_2); 1864 reg_w_buf(gspca_dev, nw801_start_2);
1864 break; 1865 break;
1865 case Kr651us: 1866 case Kr651us:
1866 if (gspca_dev->width == 320) 1867 if (gspca_dev->pixfmt.width == 320)
1867 reg_w_buf(gspca_dev, kr651_start_qvga); 1868 reg_w_buf(gspca_dev, kr651_start_qvga);
1868 else 1869 else
1869 reg_w_buf(gspca_dev, kr651_start_vga); 1870 reg_w_buf(gspca_dev, kr651_start_vga);
1870 reg_w_buf(gspca_dev, kr651_start_2); 1871 reg_w_buf(gspca_dev, kr651_start_2);
1871 break; 1872 break;
1872 case Proscope: 1873 case Proscope:
1873 if (gspca_dev->width == 320) 1874 if (gspca_dev->pixfmt.width == 320)
1874 reg_w_buf(gspca_dev, proscope_start_qvga); 1875 reg_w_buf(gspca_dev, proscope_start_qvga);
1875 else 1876 else
1876 reg_w_buf(gspca_dev, proscope_start_vga); 1877 reg_w_buf(gspca_dev, proscope_start_vga);
diff --git a/drivers/media/usb/gspca/ov519.c b/drivers/media/usb/gspca/ov519.c
index 8937d79fd176..c95f32a0c02b 100644
--- a/drivers/media/usb/gspca/ov519.c
+++ b/drivers/media/usb/gspca/ov519.c
@@ -3468,7 +3468,7 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev)
3468 3468
3469 switch (sd->bridge) { 3469 switch (sd->bridge) {
3470 case BRIDGE_OVFX2: 3470 case BRIDGE_OVFX2:
3471 if (gspca_dev->width != 800) 3471 if (gspca_dev->pixfmt.width != 800)
3472 gspca_dev->cam.bulk_size = OVFX2_BULK_SIZE; 3472 gspca_dev->cam.bulk_size = OVFX2_BULK_SIZE;
3473 else 3473 else
3474 gspca_dev->cam.bulk_size = 7 * 4096; 3474 gspca_dev->cam.bulk_size = 7 * 4096;
@@ -3507,8 +3507,8 @@ static void ov511_mode_init_regs(struct sd *sd)
3507 /* Here I'm assuming that snapshot size == image size. 3507 /* Here I'm assuming that snapshot size == image size.
3508 * I hope that's always true. --claudio 3508 * I hope that's always true. --claudio
3509 */ 3509 */
3510 hsegs = (sd->gspca_dev.width >> 3) - 1; 3510 hsegs = (sd->gspca_dev.pixfmt.width >> 3) - 1;
3511 vsegs = (sd->gspca_dev.height >> 3) - 1; 3511 vsegs = (sd->gspca_dev.pixfmt.height >> 3) - 1;
3512 3512
3513 reg_w(sd, R511_CAM_PXCNT, hsegs); 3513 reg_w(sd, R511_CAM_PXCNT, hsegs);
3514 reg_w(sd, R511_CAM_LNCNT, vsegs); 3514 reg_w(sd, R511_CAM_LNCNT, vsegs);
@@ -3541,7 +3541,7 @@ static void ov511_mode_init_regs(struct sd *sd)
3541 case SEN_OV7640: 3541 case SEN_OV7640:
3542 case SEN_OV7648: 3542 case SEN_OV7648:
3543 case SEN_OV76BE: 3543 case SEN_OV76BE:
3544 if (sd->gspca_dev.width == 320) 3544 if (sd->gspca_dev.pixfmt.width == 320)
3545 interlaced = 1; 3545 interlaced = 1;
3546 /* Fall through */ 3546 /* Fall through */
3547 case SEN_OV6630: 3547 case SEN_OV6630:
@@ -3551,7 +3551,7 @@ static void ov511_mode_init_regs(struct sd *sd)
3551 case 30: 3551 case 30:
3552 case 25: 3552 case 25:
3553 /* Not enough bandwidth to do 640x480 @ 30 fps */ 3553 /* Not enough bandwidth to do 640x480 @ 30 fps */
3554 if (sd->gspca_dev.width != 640) { 3554 if (sd->gspca_dev.pixfmt.width != 640) {
3555 sd->clockdiv = 0; 3555 sd->clockdiv = 0;
3556 break; 3556 break;
3557 } 3557 }
@@ -3584,7 +3584,8 @@ static void ov511_mode_init_regs(struct sd *sd)
3584 3584
3585 /* Check if we have enough bandwidth to disable compression */ 3585 /* Check if we have enough bandwidth to disable compression */
3586 fps = (interlaced ? 60 : 30) / (sd->clockdiv + 1) + 1; 3586 fps = (interlaced ? 60 : 30) / (sd->clockdiv + 1) + 1;
3587 needed = fps * sd->gspca_dev.width * sd->gspca_dev.height * 3 / 2; 3587 needed = fps * sd->gspca_dev.pixfmt.width *
3588 sd->gspca_dev.pixfmt.height * 3 / 2;
3588 /* 1000 isoc packets/sec */ 3589 /* 1000 isoc packets/sec */
3589 if (needed > 1000 * packet_size) { 3590 if (needed > 1000 * packet_size) {
3590 /* Enable Y and UV quantization and compression */ 3591 /* Enable Y and UV quantization and compression */
@@ -3646,8 +3647,8 @@ static void ov518_mode_init_regs(struct sd *sd)
3646 reg_w(sd, 0x38, 0x80); 3647 reg_w(sd, 0x38, 0x80);
3647 } 3648 }
3648 3649
3649 hsegs = sd->gspca_dev.width / 16; 3650 hsegs = sd->gspca_dev.pixfmt.width / 16;
3650 vsegs = sd->gspca_dev.height / 4; 3651 vsegs = sd->gspca_dev.pixfmt.height / 4;
3651 3652
3652 reg_w(sd, 0x29, hsegs); 3653 reg_w(sd, 0x29, hsegs);
3653 reg_w(sd, 0x2a, vsegs); 3654 reg_w(sd, 0x2a, vsegs);
@@ -3686,7 +3687,8 @@ static void ov518_mode_init_regs(struct sd *sd)
3686 * happened to be with revision < 2 cams using an 3687 * happened to be with revision < 2 cams using an
3687 * OV7620 and revision 2 cams using an OV7620AE. 3688 * OV7620 and revision 2 cams using an OV7620AE.
3688 */ 3689 */
3689 if (sd->revision > 0 && sd->gspca_dev.width == 640) { 3690 if (sd->revision > 0 &&
3691 sd->gspca_dev.pixfmt.width == 640) {
3690 reg_w(sd, 0x20, 0x60); 3692 reg_w(sd, 0x20, 0x60);
3691 reg_w(sd, 0x21, 0x1f); 3693 reg_w(sd, 0x21, 0x1f);
3692 } else { 3694 } else {
@@ -3812,8 +3814,8 @@ static void ov519_mode_init_regs(struct sd *sd)
3812 break; 3814 break;
3813 } 3815 }
3814 3816
3815 reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.width >> 4); 3817 reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.pixfmt.width >> 4);
3816 reg_w(sd, OV519_R11_V_SIZE, sd->gspca_dev.height >> 3); 3818 reg_w(sd, OV519_R11_V_SIZE, sd->gspca_dev.pixfmt.height >> 3);
3817 if (sd->sensor == SEN_OV7670 && 3819 if (sd->sensor == SEN_OV7670 &&
3818 sd->gspca_dev.cam.cam_mode[sd->gspca_dev.curr_mode].priv) 3820 sd->gspca_dev.cam.cam_mode[sd->gspca_dev.curr_mode].priv)
3819 reg_w(sd, OV519_R12_X_OFFSETL, 0x04); 3821 reg_w(sd, OV519_R12_X_OFFSETL, 0x04);
@@ -3947,14 +3949,16 @@ static void mode_init_ov_sensor_regs(struct sd *sd)
3947 } 3949 }
3948 case SEN_OV3610: 3950 case SEN_OV3610:
3949 if (qvga) { 3951 if (qvga) {
3950 xstart = (1040 - gspca_dev->width) / 2 + (0x1f << 4); 3952 xstart = (1040 - gspca_dev->pixfmt.width) / 2 +
3951 ystart = (776 - gspca_dev->height) / 2; 3953 (0x1f << 4);
3954 ystart = (776 - gspca_dev->pixfmt.height) / 2;
3952 } else { 3955 } else {
3953 xstart = (2076 - gspca_dev->width) / 2 + (0x10 << 4); 3956 xstart = (2076 - gspca_dev->pixfmt.width) / 2 +
3954 ystart = (1544 - gspca_dev->height) / 2; 3957 (0x10 << 4);
3958 ystart = (1544 - gspca_dev->pixfmt.height) / 2;
3955 } 3959 }
3956 xend = xstart + gspca_dev->width; 3960 xend = xstart + gspca_dev->pixfmt.width;
3957 yend = ystart + gspca_dev->height; 3961 yend = ystart + gspca_dev->pixfmt.height;
3958 /* Writing to the COMH register resets the other windowing regs 3962 /* Writing to the COMH register resets the other windowing regs
3959 to their default values, so we must do this first. */ 3963 to their default values, so we must do this first. */
3960 i2c_w_mask(sd, 0x12, qvga ? 0x40 : 0x00, 0xf0); 3964 i2c_w_mask(sd, 0x12, qvga ? 0x40 : 0x00, 0xf0);
@@ -4229,8 +4233,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
4229 struct sd *sd = (struct sd *) gspca_dev; 4233 struct sd *sd = (struct sd *) gspca_dev;
4230 4234
4231 /* Default for most bridges, allow bridge_mode_init_regs to override */ 4235 /* Default for most bridges, allow bridge_mode_init_regs to override */
4232 sd->sensor_width = sd->gspca_dev.width; 4236 sd->sensor_width = sd->gspca_dev.pixfmt.width;
4233 sd->sensor_height = sd->gspca_dev.height; 4237 sd->sensor_height = sd->gspca_dev.pixfmt.height;
4234 4238
4235 switch (sd->bridge) { 4239 switch (sd->bridge) {
4236 case BRIDGE_OV511: 4240 case BRIDGE_OV511:
@@ -4345,12 +4349,13 @@ static void ov511_pkt_scan(struct gspca_dev *gspca_dev,
4345 ov51x_handle_button(gspca_dev, (in[8] >> 2) & 1); 4349 ov51x_handle_button(gspca_dev, (in[8] >> 2) & 1);
4346 if (in[8] & 0x80) { 4350 if (in[8] & 0x80) {
4347 /* Frame end */ 4351 /* Frame end */
4348 if ((in[9] + 1) * 8 != gspca_dev->width || 4352 if ((in[9] + 1) * 8 != gspca_dev->pixfmt.width ||
4349 (in[10] + 1) * 8 != gspca_dev->height) { 4353 (in[10] + 1) * 8 != gspca_dev->pixfmt.height) {
4350 PERR("Invalid frame size, got: %dx%d," 4354 PERR("Invalid frame size, got: %dx%d,"
4351 " requested: %dx%d\n", 4355 " requested: %dx%d\n",
4352 (in[9] + 1) * 8, (in[10] + 1) * 8, 4356 (in[9] + 1) * 8, (in[10] + 1) * 8,
4353 gspca_dev->width, gspca_dev->height); 4357 gspca_dev->pixfmt.width,
4358 gspca_dev->pixfmt.height);
4354 gspca_dev->last_packet_type = DISCARD_PACKET; 4359 gspca_dev->last_packet_type = DISCARD_PACKET;
4355 return; 4360 return;
4356 } 4361 }
@@ -4470,7 +4475,8 @@ static void ovfx2_pkt_scan(struct gspca_dev *gspca_dev,
4470 if (sd->first_frame) { 4475 if (sd->first_frame) {
4471 sd->first_frame--; 4476 sd->first_frame--;
4472 if (gspca_dev->image_len < 4477 if (gspca_dev->image_len <
4473 sd->gspca_dev.width * sd->gspca_dev.height) 4478 sd->gspca_dev.pixfmt.width *
4479 sd->gspca_dev.pixfmt.height)
4474 gspca_dev->last_packet_type = DISCARD_PACKET; 4480 gspca_dev->last_packet_type = DISCARD_PACKET;
4475 } 4481 }
4476 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); 4482 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
diff --git a/drivers/media/usb/gspca/ov534.c b/drivers/media/usb/gspca/ov534.c
index 03a33c46ca2c..90f0d637cd9d 100644
--- a/drivers/media/usb/gspca/ov534.c
+++ b/drivers/media/usb/gspca/ov534.c
@@ -1440,9 +1440,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1440 /* If this packet is marked as EOF, end the frame */ 1440 /* If this packet is marked as EOF, end the frame */
1441 } else if (data[1] & UVC_STREAM_EOF) { 1441 } else if (data[1] & UVC_STREAM_EOF) {
1442 sd->last_pts = 0; 1442 sd->last_pts = 0;
1443 if (gspca_dev->pixfmt == V4L2_PIX_FMT_YUYV 1443 if (gspca_dev->pixfmt.pixelformat == V4L2_PIX_FMT_YUYV
1444 && gspca_dev->image_len + len - 12 != 1444 && gspca_dev->image_len + len - 12 !=
1445 gspca_dev->width * gspca_dev->height * 2) { 1445 gspca_dev->pixfmt.width *
1446 gspca_dev->pixfmt.height * 2) {
1446 PDEBUG(D_PACK, "wrong sized frame"); 1447 PDEBUG(D_PACK, "wrong sized frame");
1447 goto discard; 1448 goto discard;
1448 } 1449 }
diff --git a/drivers/media/usb/gspca/ov534_9.c b/drivers/media/usb/gspca/ov534_9.c
index c4cd028fe0b4..47085cf2d723 100644
--- a/drivers/media/usb/gspca/ov534_9.c
+++ b/drivers/media/usb/gspca/ov534_9.c
@@ -59,6 +59,7 @@ enum sensors {
59 SENSOR_OV965x, /* ov9657 */ 59 SENSOR_OV965x, /* ov9657 */
60 SENSOR_OV971x, /* ov9712 */ 60 SENSOR_OV971x, /* ov9712 */
61 SENSOR_OV562x, /* ov5621 */ 61 SENSOR_OV562x, /* ov5621 */
62 SENSOR_OV361x, /* ov3610 */
62 NSENSORS 63 NSENSORS
63}; 64};
64 65
@@ -106,6 +107,274 @@ static const struct v4l2_pix_format ov562x_mode[] = {
106 } 107 }
107}; 108};
108 109
110enum ov361x {
111 ov361x_2048 = 0,
112 ov361x_1600,
113 ov361x_1024,
114 ov361x_640,
115 ov361x_320,
116 ov361x_160,
117 ov361x_last
118};
119
120static const struct v4l2_pix_format ov361x_mode[] = {
121 {0x800, 0x600, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
122 .bytesperline = 0x800,
123 .sizeimage = 0x800 * 0x600,
124 .colorspace = V4L2_COLORSPACE_SRGB},
125 {1600, 1200, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
126 .bytesperline = 1600,
127 .sizeimage = 1600 * 1200,
128 .colorspace = V4L2_COLORSPACE_SRGB},
129 {1024, 768, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
130 .bytesperline = 768,
131 .sizeimage = 1024 * 768,
132 .colorspace = V4L2_COLORSPACE_SRGB},
133 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
134 .bytesperline = 640,
135 .sizeimage = 640 * 480,
136 .colorspace = V4L2_COLORSPACE_SRGB},
137 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
138 .bytesperline = 320,
139 .sizeimage = 320 * 240,
140 .colorspace = V4L2_COLORSPACE_SRGB},
141 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
142 .bytesperline = 160,
143 .sizeimage = 160 * 120,
144 .colorspace = V4L2_COLORSPACE_SRGB}
145};
146
147static const u8 ov361x_start_2048[][2] = {
148 {0x12, 0x80},
149 {0x13, 0xcf},
150 {0x14, 0x40},
151 {0x15, 0x00},
152 {0x01, 0x80},
153 {0x02, 0x80},
154 {0x04, 0x70},
155 {0x0d, 0x40},
156 {0x0f, 0x47},
157 {0x11, 0x81},
158 {0x32, 0x36},
159 {0x33, 0x0c},
160 {0x34, 0x00},
161 {0x35, 0x90},
162 {0x12, 0x00},
163 {0x17, 0x10},
164 {0x18, 0x90},
165 {0x19, 0x00},
166 {0x1a, 0xc0},
167};
168static const u8 ov361x_bridge_start_2048[][2] = {
169 {0xf1, 0x60},
170 {0x88, 0x00},
171 {0x89, 0x08},
172 {0x8a, 0x00},
173 {0x8b, 0x06},
174 {0x8c, 0x01},
175 {0x8d, 0x10},
176 {0x1c, 0x00},
177 {0x1d, 0x48},
178 {0x1d, 0x00},
179 {0x1d, 0xff},
180 {0x1c, 0x0a},
181 {0x1d, 0x2e},
182 {0x1d, 0x1e},
183};
184
185static const u8 ov361x_start_1600[][2] = {
186 {0x12, 0x80},
187 {0x13, 0xcf},
188 {0x14, 0x40},
189 {0x15, 0x00},
190 {0x01, 0x80},
191 {0x02, 0x80},
192 {0x04, 0x70},
193 {0x0d, 0x40},
194 {0x0f, 0x47},
195 {0x11, 0x81},
196 {0x32, 0x36},
197 {0x33, 0x0C},
198 {0x34, 0x00},
199 {0x35, 0x90},
200 {0x12, 0x00},
201 {0x17, 0x10},
202 {0x18, 0x90},
203 {0x19, 0x00},
204 {0x1a, 0xc0},
205};
206static const u8 ov361x_bridge_start_1600[][2] = {
207 {0xf1, 0x60}, /* Hsize[7:0] */
208 {0x88, 0x00}, /* Hsize[15:8] Write Only, can't read */
209 {0x89, 0x08}, /* Vsize[7:0] */
210 {0x8a, 0x00}, /* Vsize[15:8] Write Only, can't read */
211 {0x8b, 0x06}, /* for Iso */
212 {0x8c, 0x01}, /* RAW input */
213 {0x8d, 0x10},
214 {0x1c, 0x00}, /* RAW output, Iso transfer */
215 {0x1d, 0x48},
216 {0x1d, 0x00},
217 {0x1d, 0xff},
218 {0x1c, 0x0a}, /* turn off JPEG, Iso mode */
219 {0x1d, 0x2e}, /* for Iso */
220 {0x1d, 0x1e},
221};
222
223static const u8 ov361x_start_1024[][2] = {
224 {0x12, 0x80},
225 {0x13, 0xcf},
226 {0x14, 0x40},
227 {0x15, 0x00},
228 {0x01, 0x80},
229 {0x02, 0x80},
230 {0x04, 0x70},
231 {0x0d, 0x40},
232 {0x0f, 0x47},
233 {0x11, 0x81},
234 {0x32, 0x36},
235 {0x33, 0x0C},
236 {0x34, 0x00},
237 {0x35, 0x90},
238 {0x12, 0x40},
239 {0x17, 0x1f},
240 {0x18, 0x5f},
241 {0x19, 0x00},
242 {0x1a, 0x68},
243};
244static const u8 ov361x_bridge_start_1024[][2] = {
245 {0xf1, 0x60}, /* Hsize[7:0] */
246 {0x88, 0x00}, /* Hsize[15:8] Write Only, can't read */
247 {0x89, 0x04}, /* Vsize[7:0] */
248 {0x8a, 0x00}, /* Vsize[15:8] Write Only, can't read */
249 {0x8b, 0x03}, /* for Iso */
250 {0x8c, 0x01}, /* RAW input */
251 {0x8d, 0x10},
252 {0x1c, 0x00}, /* RAW output, Iso transfer */
253 {0x1d, 0x48},
254 {0x1d, 0x00},
255 {0x1d, 0xff},
256 {0x1c, 0x0a}, /* turn off JPEG, Iso mode */
257 {0x1d, 0x2e}, /* for Iso */
258 {0x1d, 0x1e},
259};
260
261static const u8 ov361x_start_640[][2] = {
262 {0x12, 0x80},
263 {0x13, 0xcf},
264 {0x14, 0x40},
265 {0x15, 0x00},
266 {0x01, 0x80},
267 {0x02, 0x80},
268 {0x04, 0x70},
269 {0x0d, 0x40},
270 {0x0f, 0x47},
271 {0x11, 0x81},
272 {0x32, 0x36},
273 {0x33, 0x0C},
274 {0x34, 0x00},
275 {0x35, 0x90},
276 {0x12, 0x40},
277 {0x17, 0x1f},
278 {0x18, 0x5f},
279 {0x19, 0x00},
280 {0x1a, 0x68},
281};
282
283static const u8 ov361x_bridge_start_640[][2] = {
284 {0xf1, 0x60}, /* Hsize[7:0]*/
285 {0x88, 0x00}, /* Hsize[15:8] Write Only, can't read */
286 {0x89, 0x04}, /* Vsize[7:0] */
287 {0x8a, 0x00}, /* Vsize[15:8] Write Only, can't read */
288 {0x8b, 0x03}, /* for Iso */
289 {0x8c, 0x01}, /* RAW input */
290 {0x8d, 0x10},
291 {0x1c, 0x00}, /* RAW output, Iso transfer */
292 {0x1d, 0x48},
293 {0x1d, 0x00},
294 {0x1d, 0xff},
295 {0x1c, 0x0a}, /* turn off JPEG, Iso mode */
296 {0x1d, 0x2e}, /* for Iso */
297 {0x1d, 0x1e},
298};
299
300static const u8 ov361x_start_320[][2] = {
301 {0x12, 0x80},
302 {0x13, 0xcf},
303 {0x14, 0x40},
304 {0x15, 0x00},
305 {0x01, 0x80},
306 {0x02, 0x80},
307 {0x04, 0x70},
308 {0x0d, 0x40},
309 {0x0f, 0x47},
310 {0x11, 0x81},
311 {0x32, 0x36},
312 {0x33, 0x0C},
313 {0x34, 0x00},
314 {0x35, 0x90},
315 {0x12, 0x40},
316 {0x17, 0x1f},
317 {0x18, 0x5f},
318 {0x19, 0x00},
319 {0x1a, 0x68},
320};
321
322static const u8 ov361x_bridge_start_320[][2] = {
323 {0xf1, 0x60}, /* Hsize[7:0] */
324 {0x88, 0x00}, /* Hsize[15:8] Write Only, can't read */
325 {0x89, 0x04}, /* Vsize[7:0] */
326 {0x8a, 0x00}, /* Vsize[15:8] Write Only, can't read */
327 {0x8b, 0x03}, /* for Iso */
328 {0x8c, 0x01}, /* RAW input */
329 {0x8d, 0x10},
330 {0x1c, 0x00}, /* RAW output, Iso transfer; */
331 {0x1d, 0x48},
332 {0x1d, 0x00},
333 {0x1d, 0xff},
334 {0x1c, 0x0a}, /* turn off JPEG, Iso mode */
335 {0x1d, 0x2e}, /* for Iso */
336 {0x1d, 0x1e},
337};
338
339static const u8 ov361x_start_160[][2] = {
340 {0x12, 0x80},
341 {0x13, 0xcf},
342 {0x14, 0x40},
343 {0x15, 0x00},
344 {0x01, 0x80},
345 {0x02, 0x80},
346 {0x04, 0x70},
347 {0x0d, 0x40},
348 {0x0f, 0x47},
349 {0x11, 0x81},
350 {0x32, 0x36},
351 {0x33, 0x0C},
352 {0x34, 0x00},
353 {0x35, 0x90},
354 {0x12, 0x40},
355 {0x17, 0x1f},
356 {0x18, 0x5f},
357 {0x19, 0x00},
358 {0x1a, 0x68},
359};
360
361static const u8 ov361x_bridge_start_160[][2] = {
362 {0xf1, 0x60}, /* Hsize[7:0] */
363 {0x88, 0x00}, /* Hsize[15:8] Write Only, can't read */
364 {0x89, 0x04}, /* Vsize[7:0] */
365 {0x8a, 0x00}, /* Vsize[15:8] Write Only, can't read */
366 {0x8b, 0x03}, /* for Iso */
367 {0x8c, 0x01}, /* RAW input */
368 {0x8d, 0x10},
369 {0x1c, 0x00}, /* RAW output, Iso transfer */
370 {0x1d, 0x48},
371 {0x1d, 0x00},
372 {0x1d, 0xff},
373 {0x1c, 0x0a}, /* turn off JPEG, Iso mode */
374 {0x1d, 0x2e}, /* for Iso */
375 {0x1d, 0x1e},
376};
377
109static const u8 bridge_init[][2] = { 378static const u8 bridge_init[][2] = {
110 {0x88, 0xf8}, 379 {0x88, 0xf8},
111 {0x89, 0xff}, 380 {0x89, 0xff},
@@ -898,7 +1167,7 @@ static int sccb_check_status(struct gspca_dev *gspca_dev)
898 int i; 1167 int i;
899 1168
900 for (i = 0; i < 5; i++) { 1169 for (i = 0; i < 5; i++) {
901 msleep(10); 1170 msleep(20);
902 data = reg_r(gspca_dev, OV534_REG_STATUS); 1171 data = reg_r(gspca_dev, OV534_REG_STATUS);
903 1172
904 switch (data) { 1173 switch (data) {
@@ -1221,6 +1490,13 @@ static int sd_init(struct gspca_dev *gspca_dev)
1221 sccb_w_array(gspca_dev, ov562x_init_2, 1490 sccb_w_array(gspca_dev, ov562x_init_2,
1222 ARRAY_SIZE(ov562x_init_2)); 1491 ARRAY_SIZE(ov562x_init_2));
1223 reg_w(gspca_dev, 0xe0, 0x00); 1492 reg_w(gspca_dev, 0xe0, 0x00);
1493 } else if ((sensor_id & 0xfff0) == 0x3610) {
1494 sd->sensor = SENSOR_OV361x;
1495 gspca_dev->cam.cam_mode = ov361x_mode;
1496 gspca_dev->cam.nmodes = ARRAY_SIZE(ov361x_mode);
1497 reg_w(gspca_dev, 0xe7, 0x3a);
1498 reg_w(gspca_dev, 0xf1, 0x60);
1499 sccb_write(gspca_dev, 0x12, 0x80);
1224 } else { 1500 } else {
1225 pr_err("Unknown sensor %04x", sensor_id); 1501 pr_err("Unknown sensor %04x", sensor_id);
1226 return -EINVAL; 1502 return -EINVAL;
@@ -1229,6 +1505,53 @@ static int sd_init(struct gspca_dev *gspca_dev)
1229 return gspca_dev->usb_err; 1505 return gspca_dev->usb_err;
1230} 1506}
1231 1507
1508static int sd_start_ov361x(struct gspca_dev *gspca_dev)
1509{
1510 sccb_write(gspca_dev, 0x12, 0x80);
1511 msleep(20);
1512 switch (gspca_dev->curr_mode % (ov361x_last)) {
1513 case ov361x_2048:
1514 reg_w_array(gspca_dev, ov361x_bridge_start_2048,
1515 ARRAY_SIZE(ov361x_bridge_start_2048));
1516 sccb_w_array(gspca_dev, ov361x_start_2048,
1517 ARRAY_SIZE(ov361x_start_2048));
1518 break;
1519 case ov361x_1600:
1520 reg_w_array(gspca_dev, ov361x_bridge_start_1600,
1521 ARRAY_SIZE(ov361x_bridge_start_1600));
1522 sccb_w_array(gspca_dev, ov361x_start_1600,
1523 ARRAY_SIZE(ov361x_start_1600));
1524 break;
1525 case ov361x_1024:
1526 reg_w_array(gspca_dev, ov361x_bridge_start_1024,
1527 ARRAY_SIZE(ov361x_bridge_start_1024));
1528 sccb_w_array(gspca_dev, ov361x_start_1024,
1529 ARRAY_SIZE(ov361x_start_1024));
1530 break;
1531 case ov361x_640:
1532 reg_w_array(gspca_dev, ov361x_bridge_start_640,
1533 ARRAY_SIZE(ov361x_bridge_start_640));
1534 sccb_w_array(gspca_dev, ov361x_start_640,
1535 ARRAY_SIZE(ov361x_start_640));
1536 break;
1537 case ov361x_320:
1538 reg_w_array(gspca_dev, ov361x_bridge_start_320,
1539 ARRAY_SIZE(ov361x_bridge_start_320));
1540 sccb_w_array(gspca_dev, ov361x_start_320,
1541 ARRAY_SIZE(ov361x_start_320));
1542 break;
1543 case ov361x_160:
1544 reg_w_array(gspca_dev, ov361x_bridge_start_160,
1545 ARRAY_SIZE(ov361x_bridge_start_160));
1546 sccb_w_array(gspca_dev, ov361x_start_160,
1547 ARRAY_SIZE(ov361x_start_160));
1548 break;
1549 }
1550 reg_w(gspca_dev, 0xe0, 0x00); /* start transfer */
1551
1552 return gspca_dev->usb_err;
1553}
1554
1232static int sd_start(struct gspca_dev *gspca_dev) 1555static int sd_start(struct gspca_dev *gspca_dev)
1233{ 1556{
1234 struct sd *sd = (struct sd *) gspca_dev; 1557 struct sd *sd = (struct sd *) gspca_dev;
@@ -1237,6 +1560,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
1237 return gspca_dev->usb_err; 1560 return gspca_dev->usb_err;
1238 if (sd->sensor == SENSOR_OV562x) 1561 if (sd->sensor == SENSOR_OV562x)
1239 return gspca_dev->usb_err; 1562 return gspca_dev->usb_err;
1563 if (sd->sensor == SENSOR_OV361x)
1564 return sd_start_ov361x(gspca_dev);
1240 1565
1241 switch (gspca_dev->curr_mode) { 1566 switch (gspca_dev->curr_mode) {
1242 case QVGA_MODE: /* 320x240 */ 1567 case QVGA_MODE: /* 320x240 */
@@ -1290,6 +1615,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
1290 1615
1291static void sd_stopN(struct gspca_dev *gspca_dev) 1616static void sd_stopN(struct gspca_dev *gspca_dev)
1292{ 1617{
1618 if (((struct sd *)gspca_dev)->sensor == SENSOR_OV361x) {
1619 reg_w(gspca_dev, 0xe0, 0x01); /* stop transfer */
1620 /* reg_w(gspca_dev, 0x31, 0x09); */
1621 return;
1622 }
1293 reg_w(gspca_dev, 0xe0, 0x01); 1623 reg_w(gspca_dev, 0xe0, 0x01);
1294 set_led(gspca_dev, 0); 1624 set_led(gspca_dev, 0);
1295 reg_w(gspca_dev, 0xe0, 0x00); 1625 reg_w(gspca_dev, 0xe0, 0x00);
@@ -1425,6 +1755,8 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
1425 1755
1426 if (sd->sensor == SENSOR_OV971x) 1756 if (sd->sensor == SENSOR_OV971x)
1427 return 0; 1757 return 0;
1758 if (sd->sensor == SENSOR_OV361x)
1759 return 0;
1428 gspca_dev->vdev.ctrl_handler = hdl; 1760 gspca_dev->vdev.ctrl_handler = hdl;
1429 v4l2_ctrl_handler_init(hdl, 7); 1761 v4l2_ctrl_handler_init(hdl, 7);
1430 if (sd->sensor == SENSOR_OV562x) { 1762 if (sd->sensor == SENSOR_OV562x) {
diff --git a/drivers/media/usb/gspca/pac207.c b/drivers/media/usb/gspca/pac207.c
index 83519be94e58..cd79c180f67b 100644
--- a/drivers/media/usb/gspca/pac207.c
+++ b/drivers/media/usb/gspca/pac207.c
@@ -299,7 +299,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
299 pac207_write_regs(gspca_dev, 0x0042, pac207_sensor_init[3], 8); 299 pac207_write_regs(gspca_dev, 0x0042, pac207_sensor_init[3], 8);
300 300
301 /* Compression Balance */ 301 /* Compression Balance */
302 if (gspca_dev->width == 176) 302 if (gspca_dev->pixfmt.width == 176)
303 pac207_write_reg(gspca_dev, 0x4a, 0xff); 303 pac207_write_reg(gspca_dev, 0x4a, 0xff);
304 else 304 else
305 pac207_write_reg(gspca_dev, 0x4a, 0x30); 305 pac207_write_reg(gspca_dev, 0x4a, 0x30);
@@ -317,7 +317,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
317 mode = 0x00; 317 mode = 0x00;
318 else 318 else
319 mode = 0x02; 319 mode = 0x02;
320 if (gspca_dev->width == 176) { /* 176x144 */ 320 if (gspca_dev->pixfmt.width == 176) { /* 176x144 */
321 mode |= 0x01; 321 mode |= 0x01;
322 PDEBUG(D_STREAM, "pac207_start mode 176x144"); 322 PDEBUG(D_STREAM, "pac207_start mode 176x144");
323 } else { /* 352x288 */ 323 } else { /* 352x288 */
diff --git a/drivers/media/usb/gspca/pac7311.c b/drivers/media/usb/gspca/pac7311.c
index 1a5bdc853a80..25f86b1e74a8 100644
--- a/drivers/media/usb/gspca/pac7311.c
+++ b/drivers/media/usb/gspca/pac7311.c
@@ -326,7 +326,7 @@ static void setexposure(struct gspca_dev *gspca_dev, s32 val)
326 * 640x480 mode and page 4 reg 2 <= 3 then it must be 9 326 * 640x480 mode and page 4 reg 2 <= 3 then it must be 9
327 */ 327 */
328 reg_w(gspca_dev, 0xff, 0x01); 328 reg_w(gspca_dev, 0xff, 0x01);
329 if (gspca_dev->width != 640 && val <= 3) 329 if (gspca_dev->pixfmt.width != 640 && val <= 3)
330 reg_w(gspca_dev, 0x08, 0x09); 330 reg_w(gspca_dev, 0x08, 0x09);
331 else 331 else
332 reg_w(gspca_dev, 0x08, 0x08); 332 reg_w(gspca_dev, 0x08, 0x08);
@@ -337,7 +337,7 @@ static void setexposure(struct gspca_dev *gspca_dev, s32 val)
337 * camera to use higher compression or we may run out of 337 * camera to use higher compression or we may run out of
338 * bandwidth. 338 * bandwidth.
339 */ 339 */
340 if (gspca_dev->width == 640 && val == 2) 340 if (gspca_dev->pixfmt.width == 640 && val == 2)
341 reg_w(gspca_dev, 0x80, 0x01); 341 reg_w(gspca_dev, 0x80, 0x01);
342 else 342 else
343 reg_w(gspca_dev, 0x80, 0x1c); 343 reg_w(gspca_dev, 0x80, 0x1c);
@@ -615,7 +615,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
615 615
616 /* Start the new frame with the jpeg header */ 616 /* Start the new frame with the jpeg header */
617 pac_start_frame(gspca_dev, 617 pac_start_frame(gspca_dev,
618 gspca_dev->height, gspca_dev->width); 618 gspca_dev->pixfmt.height, gspca_dev->pixfmt.width);
619 } 619 }
620 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); 620 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
621} 621}
diff --git a/drivers/media/usb/gspca/se401.c b/drivers/media/usb/gspca/se401.c
index 5f729b8aa2bd..5102cea50471 100644
--- a/drivers/media/usb/gspca/se401.c
+++ b/drivers/media/usb/gspca/se401.c
@@ -354,9 +354,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
354 354
355 /* set size + mode */ 355 /* set size + mode */
356 se401_write_req(gspca_dev, SE401_REQ_SET_WIDTH, 356 se401_write_req(gspca_dev, SE401_REQ_SET_WIDTH,
357 gspca_dev->width * mult, 0); 357 gspca_dev->pixfmt.width * mult, 0);
358 se401_write_req(gspca_dev, SE401_REQ_SET_HEIGHT, 358 se401_write_req(gspca_dev, SE401_REQ_SET_HEIGHT,
359 gspca_dev->height * mult, 0); 359 gspca_dev->pixfmt.height * mult, 0);
360 /* 360 /*
361 * HDG: disabled this as it does not seem to do anything 361 * HDG: disabled this as it does not seem to do anything
362 * se401_write_req(gspca_dev, SE401_REQ_SET_OUTPUT_MODE, 362 * se401_write_req(gspca_dev, SE401_REQ_SET_OUTPUT_MODE,
@@ -480,7 +480,7 @@ static void sd_complete_frame(struct gspca_dev *gspca_dev, u8 *data, int len)
480static void sd_pkt_scan_janggu(struct gspca_dev *gspca_dev, u8 *data, int len) 480static void sd_pkt_scan_janggu(struct gspca_dev *gspca_dev, u8 *data, int len)
481{ 481{
482 struct sd *sd = (struct sd *)gspca_dev; 482 struct sd *sd = (struct sd *)gspca_dev;
483 int imagesize = gspca_dev->width * gspca_dev->height; 483 int imagesize = gspca_dev->pixfmt.width * gspca_dev->pixfmt.height;
484 int i, plen, bits, pixels, info, count; 484 int i, plen, bits, pixels, info, count;
485 485
486 if (sd->restart_stream) 486 if (sd->restart_stream)
diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c
index f4453d52801b..2a38621cf718 100644
--- a/drivers/media/usb/gspca/sn9c20x.c
+++ b/drivers/media/usb/gspca/sn9c20x.c
@@ -1955,7 +1955,7 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev)
1955 return 0; 1955 return 0;
1956 } 1956 }
1957 1957
1958 switch (gspca_dev->width) { 1958 switch (gspca_dev->pixfmt.width) {
1959 case 160: /* 160x120 */ 1959 case 160: /* 160x120 */
1960 gspca_dev->alt = 2; 1960 gspca_dev->alt = 2;
1961 break; 1961 break;
@@ -1985,8 +1985,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
1985{ 1985{
1986 struct sd *sd = (struct sd *) gspca_dev; 1986 struct sd *sd = (struct sd *) gspca_dev;
1987 int mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 1987 int mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
1988 int width = gspca_dev->width; 1988 int width = gspca_dev->pixfmt.width;
1989 int height = gspca_dev->height; 1989 int height = gspca_dev->pixfmt.height;
1990 u8 fmt, scale = 0; 1990 u8 fmt, scale = 0;
1991 1991
1992 jpeg_define(sd->jpeg_hdr, height, width, 1992 jpeg_define(sd->jpeg_hdr, height, width,
diff --git a/drivers/media/usb/gspca/sonixb.c b/drivers/media/usb/gspca/sonixb.c
index d7ff3b9687c5..7277dbd2afcd 100644
--- a/drivers/media/usb/gspca/sonixb.c
+++ b/drivers/media/usb/gspca/sonixb.c
@@ -513,10 +513,7 @@ static void i2c_w(struct gspca_dev *gspca_dev, const u8 *buf)
513 if (gspca_dev->usb_buf[0] & 0x04) { 513 if (gspca_dev->usb_buf[0] & 0x04) {
514 if (gspca_dev->usb_buf[0] & 0x08) { 514 if (gspca_dev->usb_buf[0] & 0x08) {
515 dev_err(gspca_dev->v4l2_dev.dev, 515 dev_err(gspca_dev->v4l2_dev.dev,
516 "i2c error writing %02x %02x %02x %02x" 516 "i2c error writing %8ph\n", buf);
517 " %02x %02x %02x %02x\n",
518 buf[0], buf[1], buf[2], buf[3],
519 buf[4], buf[5], buf[6], buf[7]);
520 gspca_dev->usb_err = -EIO; 517 gspca_dev->usb_err = -EIO;
521 } 518 }
522 return; 519 return;
@@ -753,7 +750,7 @@ static void setexposure(struct gspca_dev *gspca_dev)
753 /* In 640x480, if the reg11 has less than 4, the image is 750 /* In 640x480, if the reg11 has less than 4, the image is
754 unstable (the bridge goes into a higher compression mode 751 unstable (the bridge goes into a higher compression mode
755 which we have not reverse engineered yet). */ 752 which we have not reverse engineered yet). */
756 if (gspca_dev->width == 640 && reg11 < 4) 753 if (gspca_dev->pixfmt.width == 640 && reg11 < 4)
757 reg11 = 4; 754 reg11 = 4;
758 755
759 /* frame exposure time in ms = 1000 * reg11 / 30 -> 756 /* frame exposure time in ms = 1000 * reg11 / 30 ->
diff --git a/drivers/media/usb/gspca/sonixj.c b/drivers/media/usb/gspca/sonixj.c
index 3b5ccb1c4cdf..c69b45d7cfbf 100644
--- a/drivers/media/usb/gspca/sonixj.c
+++ b/drivers/media/usb/gspca/sonixj.c
@@ -2204,7 +2204,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
2204 { 0x14, 0xe7, 0x1e, 0xdd }; 2204 { 0x14, 0xe7, 0x1e, 0xdd };
2205 2205
2206 /* create the JPEG header */ 2206 /* create the JPEG header */
2207 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 2207 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
2208 gspca_dev->pixfmt.width,
2208 0x21); /* JPEG 422 */ 2209 0x21); /* JPEG 422 */
2209 2210
2210 /* initialize the bridge */ 2211 /* initialize the bridge */
diff --git a/drivers/media/usb/gspca/spca1528.c b/drivers/media/usb/gspca/spca1528.c
index 688592b289ea..f38fd8949609 100644
--- a/drivers/media/usb/gspca/spca1528.c
+++ b/drivers/media/usb/gspca/spca1528.c
@@ -255,7 +255,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
255 struct sd *sd = (struct sd *) gspca_dev; 255 struct sd *sd = (struct sd *) gspca_dev;
256 256
257 /* initialize the JPEG header */ 257 /* initialize the JPEG header */
258 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 258 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
259 gspca_dev->pixfmt.width,
259 0x22); /* JPEG 411 */ 260 0x22); /* JPEG 411 */
260 261
261 /* the JPEG quality shall be 85% */ 262 /* the JPEG quality shall be 85% */
diff --git a/drivers/media/usb/gspca/spca500.c b/drivers/media/usb/gspca/spca500.c
index 9f8bf51fd64b..f011a309dd65 100644
--- a/drivers/media/usb/gspca/spca500.c
+++ b/drivers/media/usb/gspca/spca500.c
@@ -608,7 +608,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
608 __u8 xmult, ymult; 608 __u8 xmult, ymult;
609 609
610 /* create the JPEG header */ 610 /* create the JPEG header */
611 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 611 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
612 gspca_dev->pixfmt.width,
612 0x22); /* JPEG 411 */ 613 0x22); /* JPEG 411 */
613 jpeg_set_qual(sd->jpeg_hdr, QUALITY); 614 jpeg_set_qual(sd->jpeg_hdr, QUALITY);
614 615
diff --git a/drivers/media/usb/gspca/sq905c.c b/drivers/media/usb/gspca/sq905c.c
index acb19fb9a3df..aa21edc9502d 100644
--- a/drivers/media/usb/gspca/sq905c.c
+++ b/drivers/media/usb/gspca/sq905c.c
@@ -272,7 +272,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
272 272
273 dev->cap_mode = gspca_dev->cam.cam_mode; 273 dev->cap_mode = gspca_dev->cam.cam_mode;
274 /* "Open the shutter" and set size, to start capture */ 274 /* "Open the shutter" and set size, to start capture */
275 switch (gspca_dev->width) { 275 switch (gspca_dev->pixfmt.width) {
276 case 640: 276 case 640:
277 PDEBUG(D_STREAM, "Start streaming at high resolution"); 277 PDEBUG(D_STREAM, "Start streaming at high resolution");
278 dev->cap_mode++; 278 dev->cap_mode++;
diff --git a/drivers/media/usb/gspca/sq930x.c b/drivers/media/usb/gspca/sq930x.c
index b10d0821111c..e274cf19a3ea 100644
--- a/drivers/media/usb/gspca/sq930x.c
+++ b/drivers/media/usb/gspca/sq930x.c
@@ -906,7 +906,8 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev)
906 906
907 gspca_dev->cam.bulk_nurbs = 1; /* there must be one URB only */ 907 gspca_dev->cam.bulk_nurbs = 1; /* there must be one URB only */
908 sd->do_ctrl = 0; 908 sd->do_ctrl = 0;
909 gspca_dev->cam.bulk_size = gspca_dev->width * gspca_dev->height + 8; 909 gspca_dev->cam.bulk_size = gspca_dev->pixfmt.width *
910 gspca_dev->pixfmt.height + 8;
910 return 0; 911 return 0;
911} 912}
912 913
diff --git a/drivers/media/usb/gspca/stk014.c b/drivers/media/usb/gspca/stk014.c
index 8c0982607f25..b0c70fea760b 100644
--- a/drivers/media/usb/gspca/stk014.c
+++ b/drivers/media/usb/gspca/stk014.c
@@ -250,7 +250,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
250 int ret, value; 250 int ret, value;
251 251
252 /* create the JPEG header */ 252 /* create the JPEG header */
253 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 253 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
254 gspca_dev->pixfmt.width,
254 0x22); /* JPEG 411 */ 255 0x22); /* JPEG 411 */
255 jpeg_set_qual(sd->jpeg_hdr, QUALITY); 256 jpeg_set_qual(sd->jpeg_hdr, QUALITY);
256 257
@@ -261,7 +262,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
261 set_par(gspca_dev, 0x00000000); 262 set_par(gspca_dev, 0x00000000);
262 set_par(gspca_dev, 0x8002e001); 263 set_par(gspca_dev, 0x8002e001);
263 set_par(gspca_dev, 0x14000000); 264 set_par(gspca_dev, 0x14000000);
264 if (gspca_dev->width > 320) 265 if (gspca_dev->pixfmt.width > 320)
265 value = 0x8002e001; /* 640x480 */ 266 value = 0x8002e001; /* 640x480 */
266 else 267 else
267 value = 0x4001f000; /* 320x240 */ 268 value = 0x4001f000; /* 320x240 */
diff --git a/drivers/media/usb/gspca/stk1135.c b/drivers/media/usb/gspca/stk1135.c
index 585868835ace..1fc80af2a189 100644
--- a/drivers/media/usb/gspca/stk1135.c
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -48,42 +48,11 @@ struct sd {
48}; 48};
49 49
50static const struct v4l2_pix_format stk1135_modes[] = { 50static const struct v4l2_pix_format stk1135_modes[] = {
51 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 51 /* default mode (this driver supports variable resolution) */
52 .bytesperline = 160,
53 .sizeimage = 160 * 120,
54 .colorspace = V4L2_COLORSPACE_SRGB},
55 {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
56 .bytesperline = 176,
57 .sizeimage = 176 * 144,
58 .colorspace = V4L2_COLORSPACE_SRGB},
59 {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
60 .bytesperline = 320,
61 .sizeimage = 320 * 240,
62 .colorspace = V4L2_COLORSPACE_SRGB},
63 {352, 288, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
64 .bytesperline = 352,
65 .sizeimage = 352 * 288,
66 .colorspace = V4L2_COLORSPACE_SRGB},
67 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 52 {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
68 .bytesperline = 640, 53 .bytesperline = 640,
69 .sizeimage = 640 * 480, 54 .sizeimage = 640 * 480,
70 .colorspace = V4L2_COLORSPACE_SRGB}, 55 .colorspace = V4L2_COLORSPACE_SRGB},
71 {720, 576, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
72 .bytesperline = 720,
73 .sizeimage = 720 * 576,
74 .colorspace = V4L2_COLORSPACE_SRGB},
75 {800, 600, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
76 .bytesperline = 800,
77 .sizeimage = 800 * 600,
78 .colorspace = V4L2_COLORSPACE_SRGB},
79 {1024, 768, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
80 .bytesperline = 1024,
81 .sizeimage = 1024 * 768,
82 .colorspace = V4L2_COLORSPACE_SRGB},
83 {1280, 1024, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
84 .bytesperline = 1280,
85 .sizeimage = 1280 * 1024,
86 .colorspace = V4L2_COLORSPACE_SRGB},
87}; 56};
88 57
89/* -- read a register -- */ 58/* -- read a register -- */
@@ -347,16 +316,16 @@ static void stk1135_configure_mt9m112(struct gspca_dev *gspca_dev)
347 sensor_write(gspca_dev, cfg[i].reg, cfg[i].val); 316 sensor_write(gspca_dev, cfg[i].reg, cfg[i].val);
348 317
349 /* set output size */ 318 /* set output size */
350 width = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].width; 319 width = gspca_dev->pixfmt.width;
351 height = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].height; 320 height = gspca_dev->pixfmt.height;
352 if (width <= 640) { /* use context A (half readout speed by default) */ 321 if (width <= 640 && height <= 512) { /* context A (half readout speed)*/
353 sensor_write(gspca_dev, 0x1a7, width); 322 sensor_write(gspca_dev, 0x1a7, width);
354 sensor_write(gspca_dev, 0x1aa, height); 323 sensor_write(gspca_dev, 0x1aa, height);
355 /* set read mode context A */ 324 /* set read mode context A */
356 sensor_write(gspca_dev, 0x0c8, 0x0000); 325 sensor_write(gspca_dev, 0x0c8, 0x0000);
357 /* set resize, read mode, vblank, hblank context A */ 326 /* set resize, read mode, vblank, hblank context A */
358 sensor_write(gspca_dev, 0x2c8, 0x0000); 327 sensor_write(gspca_dev, 0x2c8, 0x0000);
359 } else { /* use context B (full readout speed by default) */ 328 } else { /* context B (full readout speed) */
360 sensor_write(gspca_dev, 0x1a1, width); 329 sensor_write(gspca_dev, 0x1a1, width);
361 sensor_write(gspca_dev, 0x1a4, height); 330 sensor_write(gspca_dev, 0x1a4, height);
362 /* set read mode context B */ 331 /* set read mode context B */
@@ -484,8 +453,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
484 reg_w(gspca_dev, STK1135_REG_CISPO + 3, 0x00); 453 reg_w(gspca_dev, STK1135_REG_CISPO + 3, 0x00);
485 454
486 /* set capture end position */ 455 /* set capture end position */
487 width = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].width; 456 width = gspca_dev->pixfmt.width;
488 height = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].height; 457 height = gspca_dev->pixfmt.height;
489 reg_w(gspca_dev, STK1135_REG_CIEPO + 0, width & 0xff); 458 reg_w(gspca_dev, STK1135_REG_CIEPO + 0, width & 0xff);
490 reg_w(gspca_dev, STK1135_REG_CIEPO + 1, width >> 8); 459 reg_w(gspca_dev, STK1135_REG_CIEPO + 1, width >> 8);
491 reg_w(gspca_dev, STK1135_REG_CIEPO + 2, height & 0xff); 460 reg_w(gspca_dev, STK1135_REG_CIEPO + 2, height & 0xff);
@@ -643,6 +612,35 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
643 return 0; 612 return 0;
644} 613}
645 614
615static void stk1135_try_fmt(struct gspca_dev *gspca_dev, struct v4l2_format *fmt)
616{
617 fmt->fmt.pix.width = clamp(fmt->fmt.pix.width, 32U, 1280U);
618 fmt->fmt.pix.height = clamp(fmt->fmt.pix.height, 32U, 1024U);
619 /* round up to even numbers */
620 fmt->fmt.pix.width += (fmt->fmt.pix.width & 1);
621 fmt->fmt.pix.height += (fmt->fmt.pix.height & 1);
622
623 fmt->fmt.pix.bytesperline = fmt->fmt.pix.width;
624 fmt->fmt.pix.sizeimage = fmt->fmt.pix.width * fmt->fmt.pix.height;
625}
626
627static int stk1135_enum_framesizes(struct gspca_dev *gspca_dev,
628 struct v4l2_frmsizeenum *fsize)
629{
630 if (fsize->index != 0 || fsize->pixel_format != V4L2_PIX_FMT_SBGGR8)
631 return -EINVAL;
632
633 fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
634 fsize->stepwise.min_width = 32;
635 fsize->stepwise.min_height = 32;
636 fsize->stepwise.max_width = 1280;
637 fsize->stepwise.max_height = 1024;
638 fsize->stepwise.step_width = 2;
639 fsize->stepwise.step_height = 2;
640
641 return 0;
642}
643
646/* sub-driver description */ 644/* sub-driver description */
647static const struct sd_desc sd_desc = { 645static const struct sd_desc sd_desc = {
648 .name = MODULE_NAME, 646 .name = MODULE_NAME,
@@ -653,6 +651,8 @@ static const struct sd_desc sd_desc = {
653 .stopN = sd_stopN, 651 .stopN = sd_stopN,
654 .pkt_scan = sd_pkt_scan, 652 .pkt_scan = sd_pkt_scan,
655 .dq_callback = stk1135_dq_callback, 653 .dq_callback = stk1135_dq_callback,
654 .try_fmt = stk1135_try_fmt,
655 .enum_framesizes = stk1135_enum_framesizes,
656}; 656};
657 657
658/* -- module initialisation -- */ 658/* -- module initialisation -- */
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.c b/drivers/media/usb/gspca/stv06xx/stv06xx.c
index 55ee7a61c67f..49d209bbf9ee 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx.c
@@ -452,7 +452,7 @@ frame_data:
452 NULL, 0); 452 NULL, 0);
453 453
454 if (sd->bridge == BRIDGE_ST6422) 454 if (sd->bridge == BRIDGE_ST6422)
455 sd->to_skip = gspca_dev->width * 4; 455 sd->to_skip = gspca_dev->pixfmt.width * 4;
456 456
457 if (chunk_len) 457 if (chunk_len)
458 PERR("Chunk length is " 458 PERR("Chunk length is "
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
index 8206b7743300..8d785edcccf2 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
@@ -421,7 +421,7 @@ static int pb0100_set_autogain_target(struct gspca_dev *gspca_dev, __s32 val)
421 421
422 /* Number of pixels counted by the sensor when subsampling the pixels. 422 /* Number of pixels counted by the sensor when subsampling the pixels.
423 * Slightly larger than the real value to avoid oscillation */ 423 * Slightly larger than the real value to avoid oscillation */
424 totalpixels = gspca_dev->width * gspca_dev->height; 424 totalpixels = gspca_dev->pixfmt.width * gspca_dev->pixfmt.height;
425 totalpixels = totalpixels/(8*8) + totalpixels/(64*64); 425 totalpixels = totalpixels/(8*8) + totalpixels/(64*64);
426 426
427 brightpixels = (totalpixels * val) >> 8; 427 brightpixels = (totalpixels * val) >> 8;
diff --git a/drivers/media/usb/gspca/sunplus.c b/drivers/media/usb/gspca/sunplus.c
index af8767a9bd4c..a517d185febe 100644
--- a/drivers/media/usb/gspca/sunplus.c
+++ b/drivers/media/usb/gspca/sunplus.c
@@ -715,7 +715,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
715 int enable; 715 int enable;
716 716
717 /* create the JPEG header */ 717 /* create the JPEG header */
718 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 718 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
719 gspca_dev->pixfmt.width,
719 0x22); /* JPEG 411 */ 720 0x22); /* JPEG 411 */
720 jpeg_set_qual(sd->jpeg_hdr, QUALITY); 721 jpeg_set_qual(sd->jpeg_hdr, QUALITY);
721 722
diff --git a/drivers/media/usb/gspca/topro.c b/drivers/media/usb/gspca/topro.c
index 4cb511ccc5f6..640c2fe760b3 100644
--- a/drivers/media/usb/gspca/topro.c
+++ b/drivers/media/usb/gspca/topro.c
@@ -3856,7 +3856,7 @@ static void setsharpness(struct gspca_dev *gspca_dev, s32 val)
3856 3856
3857 if (sd->bridge == BRIDGE_TP6800) { 3857 if (sd->bridge == BRIDGE_TP6800) {
3858 val |= 0x08; /* grid compensation enable */ 3858 val |= 0x08; /* grid compensation enable */
3859 if (gspca_dev->width == 640) 3859 if (gspca_dev->pixfmt.width == 640)
3860 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x00); /* vga */ 3860 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x00); /* vga */
3861 else 3861 else
3862 val |= 0x04; /* scaling down enable */ 3862 val |= 0x04; /* scaling down enable */
@@ -3880,7 +3880,7 @@ static void set_resolution(struct gspca_dev *gspca_dev)
3880 struct sd *sd = (struct sd *) gspca_dev; 3880 struct sd *sd = (struct sd *) gspca_dev;
3881 3881
3882 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x00); 3882 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x00);
3883 if (gspca_dev->width == 320) { 3883 if (gspca_dev->pixfmt.width == 320) {
3884 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0x06); 3884 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0x06);
3885 msleep(100); 3885 msleep(100);
3886 i2c_w(gspca_dev, CX0342_AUTO_ADC_CALIB, 0x01); 3886 i2c_w(gspca_dev, CX0342_AUTO_ADC_CALIB, 0x01);
@@ -3924,7 +3924,7 @@ static int get_fr_idx(struct gspca_dev *gspca_dev)
3924 3924
3925 /* 640x480 * 30 fps does not work */ 3925 /* 640x480 * 30 fps does not work */
3926 if (i == 6 /* if 30 fps */ 3926 if (i == 6 /* if 30 fps */
3927 && gspca_dev->width == 640) 3927 && gspca_dev->pixfmt.width == 640)
3928 i = 0x05; /* 15 fps */ 3928 i = 0x05; /* 15 fps */
3929 } else { 3929 } else {
3930 for (i = 0; i < ARRAY_SIZE(rates_6810) - 1; i++) { 3930 for (i = 0; i < ARRAY_SIZE(rates_6810) - 1; i++) {
@@ -3935,7 +3935,7 @@ static int get_fr_idx(struct gspca_dev *gspca_dev)
3935 3935
3936 /* 640x480 * 30 fps does not work */ 3936 /* 640x480 * 30 fps does not work */
3937 if (i == 7 /* if 30 fps */ 3937 if (i == 7 /* if 30 fps */
3938 && gspca_dev->width == 640) 3938 && gspca_dev->pixfmt.width == 640)
3939 i = 6; /* 15 fps */ 3939 i = 6; /* 15 fps */
3940 i |= 0x80; /* clock * 1 */ 3940 i |= 0x80; /* clock * 1 */
3941 } 3941 }
@@ -4554,7 +4554,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
4554{ 4554{
4555 struct sd *sd = (struct sd *) gspca_dev; 4555 struct sd *sd = (struct sd *) gspca_dev;
4556 4556
4557 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width); 4557 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
4558 gspca_dev->pixfmt.width);
4558 set_dqt(gspca_dev, sd->quality); 4559 set_dqt(gspca_dev, sd->quality);
4559 if (sd->bridge == BRIDGE_TP6800) { 4560 if (sd->bridge == BRIDGE_TP6800) {
4560 if (sd->sensor == SENSOR_CX0342) 4561 if (sd->sensor == SENSOR_CX0342)
@@ -4737,7 +4738,7 @@ static void sd_dq_callback(struct gspca_dev *gspca_dev)
4737 (gspca_dev->usb_buf[26] << 8) + gspca_dev->usb_buf[25] + 4738 (gspca_dev->usb_buf[26] << 8) + gspca_dev->usb_buf[25] +
4738 (gspca_dev->usb_buf[29] << 8) + gspca_dev->usb_buf[28]) 4739 (gspca_dev->usb_buf[29] << 8) + gspca_dev->usb_buf[28])
4739 / 8; 4740 / 8;
4740 if (gspca_dev->width == 640) 4741 if (gspca_dev->pixfmt.width == 640)
4741 luma /= 4; 4742 luma /= 4;
4742 reg_w(gspca_dev, 0x7d, 0x00); 4743 reg_w(gspca_dev, 0x7d, 0x00);
4743 4744
diff --git a/drivers/media/usb/gspca/tv8532.c b/drivers/media/usb/gspca/tv8532.c
index 8591324a53e1..d497ba38af0d 100644
--- a/drivers/media/usb/gspca/tv8532.c
+++ b/drivers/media/usb/gspca/tv8532.c
@@ -268,7 +268,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
268 packet_type0 = packet_type1 = INTER_PACKET; 268 packet_type0 = packet_type1 = INTER_PACKET;
269 if (gspca_dev->empty_packet) { 269 if (gspca_dev->empty_packet) {
270 gspca_dev->empty_packet = 0; 270 gspca_dev->empty_packet = 0;
271 sd->packet = gspca_dev->height / 2; 271 sd->packet = gspca_dev->pixfmt.height / 2;
272 packet_type0 = FIRST_PACKET; 272 packet_type0 = FIRST_PACKET;
273 } else if (sd->packet == 0) 273 } else if (sd->packet == 0)
274 return; /* 2 more lines in 352x288 ! */ 274 return; /* 2 more lines in 352x288 ! */
@@ -284,9 +284,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
284 * - 4 bytes 284 * - 4 bytes
285 */ 285 */
286 gspca_frame_add(gspca_dev, packet_type0, 286 gspca_frame_add(gspca_dev, packet_type0,
287 data + 2, gspca_dev->width); 287 data + 2, gspca_dev->pixfmt.width);
288 gspca_frame_add(gspca_dev, packet_type1, 288 gspca_frame_add(gspca_dev, packet_type1,
289 data + gspca_dev->width + 5, gspca_dev->width); 289 data + gspca_dev->pixfmt.width + 5,
290 gspca_dev->pixfmt.width);
290} 291}
291 292
292static int sd_s_ctrl(struct v4l2_ctrl *ctrl) 293static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
diff --git a/drivers/media/usb/gspca/vicam.c b/drivers/media/usb/gspca/vicam.c
index a2275cfe0b81..103f6c4236b0 100644
--- a/drivers/media/usb/gspca/vicam.c
+++ b/drivers/media/usb/gspca/vicam.c
@@ -121,13 +121,13 @@ static int vicam_read_frame(struct gspca_dev *gspca_dev, u8 *data, int size)
121 121
122 memset(req_data, 0, 16); 122 memset(req_data, 0, 16);
123 req_data[0] = gain; 123 req_data[0] = gain;
124 if (gspca_dev->width == 256) 124 if (gspca_dev->pixfmt.width == 256)
125 req_data[1] |= 0x01; /* low nibble x-scale */ 125 req_data[1] |= 0x01; /* low nibble x-scale */
126 if (gspca_dev->height <= 122) { 126 if (gspca_dev->pixfmt.height <= 122) {
127 req_data[1] |= 0x10; /* high nibble y-scale */ 127 req_data[1] |= 0x10; /* high nibble y-scale */
128 unscaled_height = gspca_dev->height * 2; 128 unscaled_height = gspca_dev->pixfmt.height * 2;
129 } else 129 } else
130 unscaled_height = gspca_dev->height; 130 unscaled_height = gspca_dev->pixfmt.height;
131 req_data[2] = 0x90; /* unknown, does not seem to do anything */ 131 req_data[2] = 0x90; /* unknown, does not seem to do anything */
132 if (unscaled_height <= 200) 132 if (unscaled_height <= 200)
133 req_data[3] = 0x06; /* vend? */ 133 req_data[3] = 0x06; /* vend? */
diff --git a/drivers/media/usb/gspca/w996Xcf.c b/drivers/media/usb/gspca/w996Xcf.c
index 2165da0c7ce1..fb9fe2ef3a6f 100644
--- a/drivers/media/usb/gspca/w996Xcf.c
+++ b/drivers/media/usb/gspca/w996Xcf.c
@@ -430,11 +430,11 @@ static void w9968cf_set_crop_window(struct sd *sd)
430 #define SC(x) ((x) << 10) 430 #define SC(x) ((x) << 10)
431 431
432 /* Scaling factors */ 432 /* Scaling factors */
433 fw = SC(sd->gspca_dev.width) / max_width; 433 fw = SC(sd->gspca_dev.pixfmt.width) / max_width;
434 fh = SC(sd->gspca_dev.height) / max_height; 434 fh = SC(sd->gspca_dev.pixfmt.height) / max_height;
435 435
436 cw = (fw >= fh) ? max_width : SC(sd->gspca_dev.width) / fh; 436 cw = (fw >= fh) ? max_width : SC(sd->gspca_dev.pixfmt.width) / fh;
437 ch = (fw >= fh) ? SC(sd->gspca_dev.height) / fw : max_height; 437 ch = (fw >= fh) ? SC(sd->gspca_dev.pixfmt.height) / fw : max_height;
438 438
439 sd->sensor_width = max_width; 439 sd->sensor_width = max_width;
440 sd->sensor_height = max_height; 440 sd->sensor_height = max_height;
@@ -454,34 +454,34 @@ static void w9968cf_mode_init_regs(struct sd *sd)
454 454
455 w9968cf_set_crop_window(sd); 455 w9968cf_set_crop_window(sd);
456 456
457 reg_w(sd, 0x14, sd->gspca_dev.width); 457 reg_w(sd, 0x14, sd->gspca_dev.pixfmt.width);
458 reg_w(sd, 0x15, sd->gspca_dev.height); 458 reg_w(sd, 0x15, sd->gspca_dev.pixfmt.height);
459 459
460 /* JPEG width & height */ 460 /* JPEG width & height */
461 reg_w(sd, 0x30, sd->gspca_dev.width); 461 reg_w(sd, 0x30, sd->gspca_dev.pixfmt.width);
462 reg_w(sd, 0x31, sd->gspca_dev.height); 462 reg_w(sd, 0x31, sd->gspca_dev.pixfmt.height);
463 463
464 /* Y & UV frame buffer strides (in WORD) */ 464 /* Y & UV frame buffer strides (in WORD) */
465 if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == 465 if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat ==
466 V4L2_PIX_FMT_JPEG) { 466 V4L2_PIX_FMT_JPEG) {
467 reg_w(sd, 0x2c, sd->gspca_dev.width / 2); 467 reg_w(sd, 0x2c, sd->gspca_dev.pixfmt.width / 2);
468 reg_w(sd, 0x2d, sd->gspca_dev.width / 4); 468 reg_w(sd, 0x2d, sd->gspca_dev.pixfmt.width / 4);
469 } else 469 } else
470 reg_w(sd, 0x2c, sd->gspca_dev.width); 470 reg_w(sd, 0x2c, sd->gspca_dev.pixfmt.width);
471 471
472 reg_w(sd, 0x00, 0xbf17); /* reset everything */ 472 reg_w(sd, 0x00, 0xbf17); /* reset everything */
473 reg_w(sd, 0x00, 0xbf10); /* normal operation */ 473 reg_w(sd, 0x00, 0xbf10); /* normal operation */
474 474
475 /* Transfer size in WORDS (for UYVY format only) */ 475 /* Transfer size in WORDS (for UYVY format only) */
476 val = sd->gspca_dev.width * sd->gspca_dev.height; 476 val = sd->gspca_dev.pixfmt.width * sd->gspca_dev.pixfmt.height;
477 reg_w(sd, 0x3d, val & 0xffff); /* low bits */ 477 reg_w(sd, 0x3d, val & 0xffff); /* low bits */
478 reg_w(sd, 0x3e, val >> 16); /* high bits */ 478 reg_w(sd, 0x3e, val >> 16); /* high bits */
479 479
480 if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == 480 if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat ==
481 V4L2_PIX_FMT_JPEG) { 481 V4L2_PIX_FMT_JPEG) {
482 /* We may get called multiple times (usb isoc bw negotiat.) */ 482 /* We may get called multiple times (usb isoc bw negotiat.) */
483 jpeg_define(sd->jpeg_hdr, sd->gspca_dev.height, 483 jpeg_define(sd->jpeg_hdr, sd->gspca_dev.pixfmt.height,
484 sd->gspca_dev.width, 0x22); /* JPEG 420 */ 484 sd->gspca_dev.pixfmt.width, 0x22); /* JPEG 420 */
485 jpeg_set_qual(sd->jpeg_hdr, v4l2_ctrl_g_ctrl(sd->jpegqual)); 485 jpeg_set_qual(sd->jpeg_hdr, v4l2_ctrl_g_ctrl(sd->jpegqual));
486 w9968cf_upload_quantizationtables(sd); 486 w9968cf_upload_quantizationtables(sd);
487 v4l2_ctrl_grab(sd->jpegqual, true); 487 v4l2_ctrl_grab(sd->jpegqual, true);
diff --git a/drivers/media/usb/gspca/xirlink_cit.c b/drivers/media/usb/gspca/xirlink_cit.c
index 7eaf64eb867c..a41aa7817c54 100644
--- a/drivers/media/usb/gspca/xirlink_cit.c
+++ b/drivers/media/usb/gspca/xirlink_cit.c
@@ -1471,14 +1471,14 @@ static int cit_get_clock_div(struct gspca_dev *gspca_dev)
1471 1471
1472 while (clock_div > 3 && 1472 while (clock_div > 3 &&
1473 1000 * packet_size > 1473 1000 * packet_size >
1474 gspca_dev->width * gspca_dev->height * 1474 gspca_dev->pixfmt.width * gspca_dev->pixfmt.height *
1475 fps[clock_div - 1] * 3 / 2) 1475 fps[clock_div - 1] * 3 / 2)
1476 clock_div--; 1476 clock_div--;
1477 1477
1478 PDEBUG(D_PROBE, 1478 PDEBUG(D_PROBE,
1479 "PacketSize: %d, res: %dx%d -> using clockdiv: %d (%d fps)", 1479 "PacketSize: %d, res: %dx%d -> using clockdiv: %d (%d fps)",
1480 packet_size, gspca_dev->width, gspca_dev->height, clock_div, 1480 packet_size, gspca_dev->pixfmt.width, gspca_dev->pixfmt.height,
1481 fps[clock_div]); 1481 clock_div, fps[clock_div]);
1482 1482
1483 return clock_div; 1483 return clock_div;
1484} 1484}
@@ -1502,7 +1502,7 @@ static int cit_start_model0(struct gspca_dev *gspca_dev)
1502 cit_write_reg(gspca_dev, 0x0002, 0x0426); 1502 cit_write_reg(gspca_dev, 0x0002, 0x0426);
1503 cit_write_reg(gspca_dev, 0x0014, 0x0427); 1503 cit_write_reg(gspca_dev, 0x0014, 0x0427);
1504 1504
1505 switch (gspca_dev->width) { 1505 switch (gspca_dev->pixfmt.width) {
1506 case 160: /* 160x120 */ 1506 case 160: /* 160x120 */
1507 cit_write_reg(gspca_dev, 0x0004, 0x010b); 1507 cit_write_reg(gspca_dev, 0x0004, 0x010b);
1508 cit_write_reg(gspca_dev, 0x0001, 0x010a); 1508 cit_write_reg(gspca_dev, 0x0001, 0x010a);
@@ -1643,7 +1643,7 @@ static int cit_start_model1(struct gspca_dev *gspca_dev)
1643 cit_write_reg(gspca_dev, 0x00, 0x0101); 1643 cit_write_reg(gspca_dev, 0x00, 0x0101);
1644 cit_write_reg(gspca_dev, 0x00, 0x010a); 1644 cit_write_reg(gspca_dev, 0x00, 0x010a);
1645 1645
1646 switch (gspca_dev->width) { 1646 switch (gspca_dev->pixfmt.width) {
1647 case 128: /* 128x96 */ 1647 case 128: /* 128x96 */
1648 cit_write_reg(gspca_dev, 0x80, 0x0103); 1648 cit_write_reg(gspca_dev, 0x80, 0x0103);
1649 cit_write_reg(gspca_dev, 0x60, 0x0105); 1649 cit_write_reg(gspca_dev, 0x60, 0x0105);
@@ -1700,7 +1700,7 @@ static int cit_start_model1(struct gspca_dev *gspca_dev)
1700 } 1700 }
1701 1701
1702 /* Assorted init */ 1702 /* Assorted init */
1703 switch (gspca_dev->width) { 1703 switch (gspca_dev->pixfmt.width) {
1704 case 128: /* 128x96 */ 1704 case 128: /* 128x96 */
1705 cit_Packet_Format1(gspca_dev, 0x2b, 0x1e); 1705 cit_Packet_Format1(gspca_dev, 0x2b, 0x1e);
1706 cit_write_reg(gspca_dev, 0xc9, 0x0119); /* Same everywhere */ 1706 cit_write_reg(gspca_dev, 0xc9, 0x0119); /* Same everywhere */
@@ -1753,7 +1753,7 @@ static int cit_start_model2(struct gspca_dev *gspca_dev)
1753 cit_write_reg(gspca_dev, 0x0000, 0x0108); 1753 cit_write_reg(gspca_dev, 0x0000, 0x0108);
1754 cit_write_reg(gspca_dev, 0x0001, 0x0133); 1754 cit_write_reg(gspca_dev, 0x0001, 0x0133);
1755 cit_write_reg(gspca_dev, 0x0001, 0x0102); 1755 cit_write_reg(gspca_dev, 0x0001, 0x0102);
1756 switch (gspca_dev->width) { 1756 switch (gspca_dev->pixfmt.width) {
1757 case 176: /* 176x144 */ 1757 case 176: /* 176x144 */
1758 cit_write_reg(gspca_dev, 0x002c, 0x0103); /* All except 320x240 */ 1758 cit_write_reg(gspca_dev, 0x002c, 0x0103); /* All except 320x240 */
1759 cit_write_reg(gspca_dev, 0x0000, 0x0104); /* Same */ 1759 cit_write_reg(gspca_dev, 0x0000, 0x0104); /* Same */
@@ -1792,7 +1792,7 @@ static int cit_start_model2(struct gspca_dev *gspca_dev)
1792 1792
1793 cit_write_reg(gspca_dev, 0x0000, 0x0100); /* LED on */ 1793 cit_write_reg(gspca_dev, 0x0000, 0x0100); /* LED on */
1794 1794
1795 switch (gspca_dev->width) { 1795 switch (gspca_dev->pixfmt.width) {
1796 case 176: /* 176x144 */ 1796 case 176: /* 176x144 */
1797 cit_write_reg(gspca_dev, 0x0050, 0x0111); 1797 cit_write_reg(gspca_dev, 0x0050, 0x0111);
1798 cit_write_reg(gspca_dev, 0x00d0, 0x0111); 1798 cit_write_reg(gspca_dev, 0x00d0, 0x0111);
@@ -1840,7 +1840,7 @@ static int cit_start_model2(struct gspca_dev *gspca_dev)
1840 * Magic control of CMOS sensor. Only lower values like 1840 * Magic control of CMOS sensor. Only lower values like
1841 * 0-3 work, and picture shifts left or right. Don't change. 1841 * 0-3 work, and picture shifts left or right. Don't change.
1842 */ 1842 */
1843 switch (gspca_dev->width) { 1843 switch (gspca_dev->pixfmt.width) {
1844 case 176: /* 176x144 */ 1844 case 176: /* 176x144 */
1845 cit_model2_Packet1(gspca_dev, 0x0014, 0x0002); 1845 cit_model2_Packet1(gspca_dev, 0x0014, 0x0002);
1846 cit_model2_Packet1(gspca_dev, 0x0016, 0x0002); /* Horizontal shift */ 1846 cit_model2_Packet1(gspca_dev, 0x0016, 0x0002); /* Horizontal shift */
@@ -1899,7 +1899,7 @@ static int cit_start_model2(struct gspca_dev *gspca_dev)
1899 * does not allow arbitrary values and apparently is a bit mask, to 1899 * does not allow arbitrary values and apparently is a bit mask, to
1900 * be activated only at appropriate time. Don't change it randomly! 1900 * be activated only at appropriate time. Don't change it randomly!
1901 */ 1901 */
1902 switch (gspca_dev->width) { 1902 switch (gspca_dev->pixfmt.width) {
1903 case 176: /* 176x144 */ 1903 case 176: /* 176x144 */
1904 cit_model2_Packet1(gspca_dev, 0x0026, 0x00c2); 1904 cit_model2_Packet1(gspca_dev, 0x0026, 0x00c2);
1905 break; 1905 break;
@@ -2023,7 +2023,7 @@ static int cit_start_model3(struct gspca_dev *gspca_dev)
2023 cit_model3_Packet1(gspca_dev, 0x009e, 0x0096); 2023 cit_model3_Packet1(gspca_dev, 0x009e, 0x0096);
2024 cit_model3_Packet1(gspca_dev, 0x009f, 0x000a); 2024 cit_model3_Packet1(gspca_dev, 0x009f, 0x000a);
2025 2025
2026 switch (gspca_dev->width) { 2026 switch (gspca_dev->pixfmt.width) {
2027 case 160: 2027 case 160:
2028 cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */ 2028 cit_write_reg(gspca_dev, 0x0000, 0x0101); /* Same on 160x120, 320x240 */
2029 cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */ 2029 cit_write_reg(gspca_dev, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */
@@ -2134,7 +2134,7 @@ static int cit_start_model3(struct gspca_dev *gspca_dev)
2134 like with the IBM netcam pro). */ 2134 like with the IBM netcam pro). */
2135 cit_write_reg(gspca_dev, clock_div, 0x0111); /* Clock Divider */ 2135 cit_write_reg(gspca_dev, clock_div, 0x0111); /* Clock Divider */
2136 2136
2137 switch (gspca_dev->width) { 2137 switch (gspca_dev->pixfmt.width) {
2138 case 160: 2138 case 160:
2139 cit_model3_Packet1(gspca_dev, 0x001f, 0x0000); /* Same */ 2139 cit_model3_Packet1(gspca_dev, 0x001f, 0x0000); /* Same */
2140 cit_model3_Packet1(gspca_dev, 0x0039, 0x001f); /* Same */ 2140 cit_model3_Packet1(gspca_dev, 0x0039, 0x001f); /* Same */
@@ -2211,7 +2211,7 @@ static int cit_start_model4(struct gspca_dev *gspca_dev)
2211 cit_write_reg(gspca_dev, 0xfffa, 0x0124); 2211 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
2212 cit_model4_Packet1(gspca_dev, 0x0034, 0x0000); 2212 cit_model4_Packet1(gspca_dev, 0x0034, 0x0000);
2213 2213
2214 switch (gspca_dev->width) { 2214 switch (gspca_dev->pixfmt.width) {
2215 case 128: /* 128x96 */ 2215 case 128: /* 128x96 */
2216 cit_write_reg(gspca_dev, 0x0070, 0x0119); 2216 cit_write_reg(gspca_dev, 0x0070, 0x0119);
2217 cit_write_reg(gspca_dev, 0x00d0, 0x0111); 2217 cit_write_reg(gspca_dev, 0x00d0, 0x0111);
@@ -2531,7 +2531,7 @@ static int cit_start_ibm_netcam_pro(struct gspca_dev *gspca_dev)
2531 cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */ 2531 cit_write_reg(gspca_dev, 0x00fc, 0x012b); /* Same */
2532 cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */ 2532 cit_write_reg(gspca_dev, 0x0022, 0x012a); /* Same */
2533 2533
2534 switch (gspca_dev->width) { 2534 switch (gspca_dev->pixfmt.width) {
2535 case 160: /* 160x120 */ 2535 case 160: /* 160x120 */
2536 cit_write_reg(gspca_dev, 0x0024, 0x010b); 2536 cit_write_reg(gspca_dev, 0x0024, 0x010b);
2537 cit_write_reg(gspca_dev, 0x0089, 0x0119); 2537 cit_write_reg(gspca_dev, 0x0089, 0x0119);
@@ -2635,7 +2635,7 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev)
2635 struct usb_host_interface *alt; 2635 struct usb_host_interface *alt;
2636 int max_packet_size; 2636 int max_packet_size;
2637 2637
2638 switch (gspca_dev->width) { 2638 switch (gspca_dev->pixfmt.width) {
2639 case 160: 2639 case 160:
2640 max_packet_size = 450; 2640 max_packet_size = 450;
2641 break; 2641 break;
@@ -2659,7 +2659,7 @@ static int sd_isoc_nego(struct gspca_dev *gspca_dev)
2659 int ret, packet_size, min_packet_size; 2659 int ret, packet_size, min_packet_size;
2660 struct usb_host_interface *alt; 2660 struct usb_host_interface *alt;
2661 2661
2662 switch (gspca_dev->width) { 2662 switch (gspca_dev->pixfmt.width) {
2663 case 160: 2663 case 160:
2664 min_packet_size = 200; 2664 min_packet_size = 200;
2665 break; 2665 break;
@@ -2780,7 +2780,7 @@ static u8 *cit_find_sof(struct gspca_dev *gspca_dev, u8 *data, int len)
2780 case CIT_MODEL1: 2780 case CIT_MODEL1:
2781 case CIT_MODEL3: 2781 case CIT_MODEL3:
2782 case CIT_IBM_NETCAM_PRO: 2782 case CIT_IBM_NETCAM_PRO:
2783 switch (gspca_dev->width) { 2783 switch (gspca_dev->pixfmt.width) {
2784 case 160: /* 160x120 */ 2784 case 160: /* 160x120 */
2785 byte3 = 0x02; 2785 byte3 = 0x02;
2786 byte4 = 0x0a; 2786 byte4 = 0x0a;
@@ -2864,20 +2864,16 @@ static u8 *cit_find_sof(struct gspca_dev *gspca_dev, u8 *data, int len)
2864 if (data[i] == 0xff) { 2864 if (data[i] == 0xff) {
2865 if (i >= 4) 2865 if (i >= 4)
2866 PDEBUG(D_FRAM, 2866 PDEBUG(D_FRAM,
2867 "header found at offset: %d: %02x %02x 00 %02x %02x %02x\n", 2867 "header found at offset: %d: %02x %02x 00 %3ph\n",
2868 i - 1, 2868 i - 1,
2869 data[i - 4], 2869 data[i - 4],
2870 data[i - 3], 2870 data[i - 3],
2871 data[i], 2871 &data[i]);
2872 data[i + 1],
2873 data[i + 2]);
2874 else 2872 else
2875 PDEBUG(D_FRAM, 2873 PDEBUG(D_FRAM,
2876 "header found at offset: %d: 00 %02x %02x %02x\n", 2874 "header found at offset: %d: 00 %3ph\n",
2877 i - 1, 2875 i - 1,
2878 data[i], 2876 &data[i]);
2879 data[i + 1],
2880 data[i + 2]);
2881 return data + i + (sd->sof_len - 1); 2877 return data + i + (sd->sof_len - 1);
2882 } 2878 }
2883 break; 2879 break;
diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index cbfc2f921427..7b95d8e88a20 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -6700,7 +6700,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
6700 }; 6700 };
6701 6701
6702 /* create the JPEG header */ 6702 /* create the JPEG header */
6703 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 6703 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
6704 gspca_dev->pixfmt.width,
6704 0x21); /* JPEG 422 */ 6705 0x21); /* JPEG 422 */
6705 6706
6706 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; 6707 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
index 6e5070774dc2..2f0c89cbac76 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -78,7 +78,8 @@ void hdpvr_delete(struct hdpvr_device *dev)
78 78
79static void challenge(u8 *bytes) 79static void challenge(u8 *bytes)
80{ 80{
81 u64 *i64P, tmp64; 81 __le64 *i64P;
82 u64 tmp64;
82 uint i, idx; 83 uint i, idx;
83 84
84 for (idx = 0; idx < 32; ++idx) { 85 for (idx = 0; idx < 32; ++idx) {
@@ -106,10 +107,10 @@ static void challenge(u8 *bytes)
106 for (i = 0; i < 3; i++) 107 for (i = 0; i < 3; i++)
107 bytes[1] *= bytes[6] + 1; 108 bytes[1] *= bytes[6] + 1;
108 for (i = 0; i < 3; i++) { 109 for (i = 0; i < 3; i++) {
109 i64P = (u64 *)bytes; 110 i64P = (__le64 *)bytes;
110 tmp64 = le64_to_cpup(i64P); 111 tmp64 = le64_to_cpup(i64P);
111 tmp64 <<= bytes[7] & 0x0f; 112 tmp64 = tmp64 + (tmp64 << (bytes[7] & 0x0f));
112 *i64P += cpu_to_le64(tmp64); 113 *i64P = cpu_to_le64(tmp64);
113 } 114 }
114 break; 115 break;
115 } 116 }
@@ -301,8 +302,6 @@ static int hdpvr_probe(struct usb_interface *interface,
301 goto error; 302 goto error;
302 } 303 }
303 304
304 dev->workqueue = 0;
305
306 /* init video transfer queues first of all */ 305 /* init video transfer queues first of all */
307 /* to prevent oops in hdpvr_delete() on error paths */ 306 /* to prevent oops in hdpvr_delete() on error paths */
308 INIT_LIST_HEAD(&dev->free_buff_list); 307 INIT_LIST_HEAD(&dev->free_buff_list);
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index c4d51d78f837..ea05f678b559 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -2868,7 +2868,7 @@ static void pvr2_subdev_set_control(struct pvr2_hdw *hdw, int id,
2868 pvr2_subdev_set_control(hdw, id, #lab, (hdw)->lab##_val); \ 2868 pvr2_subdev_set_control(hdw, id, #lab, (hdw)->lab##_val); \
2869 } 2869 }
2870 2870
2871v4l2_std_id pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw) 2871static v4l2_std_id pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw)
2872{ 2872{
2873 v4l2_std_id std; 2873 v4l2_std_id std;
2874 std = (v4l2_std_id)hdw->std_mask_avail; 2874 std = (v4l2_std_id)hdw->std_mask_avail;
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index 03761c6f472f..05bd91a60c09 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -209,8 +209,10 @@ static int smsusb_sendrequest(void *context, void *buffer, size_t size)
209 struct sms_msg_hdr *phdr = (struct sms_msg_hdr *) buffer; 209 struct sms_msg_hdr *phdr = (struct sms_msg_hdr *) buffer;
210 int dummy; 210 int dummy;
211 211
212 if (dev->state != SMSUSB_ACTIVE) 212 if (dev->state != SMSUSB_ACTIVE) {
213 sms_debug("Device not active yet");
213 return -ENOENT; 214 return -ENOENT;
215 }
214 216
215 sms_debug("sending %s(%d) size: %d", 217 sms_debug("sending %s(%d) size: %d",
216 smscore_translate_msg(phdr->msg_type), phdr->msg_type, 218 smscore_translate_msg(phdr->msg_type), phdr->msg_type,
@@ -243,6 +245,9 @@ static int smsusb1_load_firmware(struct usb_device *udev, int id, int board_id)
243 int rc, dummy; 245 int rc, dummy;
244 char *fw_filename; 246 char *fw_filename;
245 247
248 if (id < 0)
249 id = sms_get_board(board_id)->default_mode;
250
246 if (id < DEVICE_MODE_DVBT || id > DEVICE_MODE_DVBT_BDA) { 251 if (id < DEVICE_MODE_DVBT || id > DEVICE_MODE_DVBT_BDA) {
247 sms_err("invalid firmware id specified %d", id); 252 sms_err("invalid firmware id specified %d", id);
248 return -EINVAL; 253 return -EINVAL;
@@ -445,14 +450,15 @@ static int smsusb_probe(struct usb_interface *intf,
445 char devpath[32]; 450 char devpath[32];
446 int i, rc; 451 int i, rc;
447 452
448 sms_info("interface number %d", 453 sms_info("board id=%lu, interface number %d",
454 id->driver_info,
449 intf->cur_altsetting->desc.bInterfaceNumber); 455 intf->cur_altsetting->desc.bInterfaceNumber);
450 456
451 if (sms_get_board(id->driver_info)->intf_num != 457 if (sms_get_board(id->driver_info)->intf_num !=
452 intf->cur_altsetting->desc.bInterfaceNumber) { 458 intf->cur_altsetting->desc.bInterfaceNumber) {
453 sms_err("interface number is %d expecting %d", 459 sms_debug("interface %d won't be used. Expecting interface %d to popup",
454 sms_get_board(id->driver_info)->intf_num, 460 intf->cur_altsetting->desc.bInterfaceNumber,
455 intf->cur_altsetting->desc.bInterfaceNumber); 461 sms_get_board(id->driver_info)->intf_num);
456 return -ENODEV; 462 return -ENODEV;
457 } 463 }
458 464
@@ -483,22 +489,32 @@ static int smsusb_probe(struct usb_interface *intf,
483 } 489 }
484 if ((udev->actconfig->desc.bNumInterfaces == 2) && 490 if ((udev->actconfig->desc.bNumInterfaces == 2) &&
485 (intf->cur_altsetting->desc.bInterfaceNumber == 0)) { 491 (intf->cur_altsetting->desc.bInterfaceNumber == 0)) {
486 sms_err("rom interface 0 is not used"); 492 sms_debug("rom interface 0 is not used");
487 return -ENODEV; 493 return -ENODEV;
488 } 494 }
489 495
490 if (id->driver_info == SMS1XXX_BOARD_SIANO_STELLAR_ROM) { 496 if (id->driver_info == SMS1XXX_BOARD_SIANO_STELLAR_ROM) {
491 sms_info("stellar device was found."); 497 /* Detected a Siano Stellar uninitialized */
498
492 snprintf(devpath, sizeof(devpath), "usb\\%d-%s", 499 snprintf(devpath, sizeof(devpath), "usb\\%d-%s",
493 udev->bus->busnum, udev->devpath); 500 udev->bus->busnum, udev->devpath);
494 sms_info("stellar device was found."); 501 sms_info("stellar device in cold state was found at %s.", devpath);
495 return smsusb1_load_firmware( 502 rc = smsusb1_load_firmware(
496 udev, smscore_registry_getmode(devpath), 503 udev, smscore_registry_getmode(devpath),
497 id->driver_info); 504 id->driver_info);
505
506 /* This device will reset and gain another USB ID */
507 if (!rc)
508 sms_info("stellar device now in warm state");
509 else
510 sms_err("Failed to put stellar in warm state. Error: %d", rc);
511
512 return rc;
513 } else {
514 rc = smsusb_init_device(intf, id->driver_info);
498 } 515 }
499 516
500 rc = smsusb_init_device(intf, id->driver_info); 517 sms_info("Device initialized with return code %d", rc);
501 sms_info("rc %d", rc);
502 sms_board_load_modules(id->driver_info); 518 sms_board_load_modules(id->driver_info);
503 return rc; 519 return rc;
504} 520}
@@ -550,10 +566,13 @@ static int smsusb_resume(struct usb_interface *intf)
550} 566}
551 567
552static const struct usb_device_id smsusb_id_table[] = { 568static const struct usb_device_id smsusb_id_table[] = {
569 /* This device is only present before firmware load */
553 { USB_DEVICE(0x187f, 0x0010), 570 { USB_DEVICE(0x187f, 0x0010),
554 .driver_info = SMS1XXX_BOARD_SIANO_STELLAR }, 571 .driver_info = SMS1XXX_BOARD_SIANO_STELLAR_ROM },
572 /* This device pops up after firmware load */
555 { USB_DEVICE(0x187f, 0x0100), 573 { USB_DEVICE(0x187f, 0x0100),
556 .driver_info = SMS1XXX_BOARD_SIANO_STELLAR }, 574 .driver_info = SMS1XXX_BOARD_SIANO_STELLAR },
575
557 { USB_DEVICE(0x187f, 0x0200), 576 { USB_DEVICE(0x187f, 0x0200),
558 .driver_info = SMS1XXX_BOARD_SIANO_NOVA_A }, 577 .driver_info = SMS1XXX_BOARD_SIANO_NOVA_A },
559 { USB_DEVICE(0x187f, 0x0201), 578 { USB_DEVICE(0x187f, 0x0201),
diff --git a/drivers/media/usb/tlg2300/pd-main.c b/drivers/media/usb/tlg2300/pd-main.c
index 95f94e5aa66d..3316caa4733b 100644
--- a/drivers/media/usb/tlg2300/pd-main.c
+++ b/drivers/media/usb/tlg2300/pd-main.c
@@ -232,7 +232,7 @@ static int firmware_download(struct usb_device *udev)
232 goto out; 232 goto out;
233 } 233 }
234 234
235 max_packet_size = udev->ep_out[0x1]->desc.wMaxPacketSize; 235 max_packet_size = le16_to_cpu(udev->ep_out[0x1]->desc.wMaxPacketSize);
236 log("\t\t download size : %d", (int)max_packet_size); 236 log("\t\t download size : %d", (int)max_packet_size);
237 237
238 for (offset = 0; offset < fwlength; offset += max_packet_size) { 238 for (offset = 0; offset < fwlength; offset += max_packet_size) {
diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c
index e52c3b97f304..29724af9b9ab 100644
--- a/drivers/media/usb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c
@@ -366,7 +366,7 @@ static int ttusb_dec_get_stb_state (struct ttusb_dec *dec, unsigned int *mode,
366 } 366 }
367 return 0; 367 return 0;
368 } else { 368 } else {
369 return -1; 369 return -ENOENT;
370 } 370 }
371} 371}
372 372
@@ -1241,6 +1241,8 @@ static void ttusb_dec_init_v_pes(struct ttusb_dec *dec)
1241 1241
1242static int ttusb_dec_init_usb(struct ttusb_dec *dec) 1242static int ttusb_dec_init_usb(struct ttusb_dec *dec)
1243{ 1243{
1244 int result;
1245
1244 dprintk("%s\n", __func__); 1246 dprintk("%s\n", __func__);
1245 1247
1246 mutex_init(&dec->usb_mutex); 1248 mutex_init(&dec->usb_mutex);
@@ -1258,7 +1260,7 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec)
1258 return -ENOMEM; 1260 return -ENOMEM;
1259 } 1261 }
1260 dec->irq_buffer = usb_alloc_coherent(dec->udev,IRQ_PACKET_SIZE, 1262 dec->irq_buffer = usb_alloc_coherent(dec->udev,IRQ_PACKET_SIZE,
1261 GFP_ATOMIC, &dec->irq_dma_handle); 1263 GFP_KERNEL, &dec->irq_dma_handle);
1262 if(!dec->irq_buffer) { 1264 if(!dec->irq_buffer) {
1263 usb_free_urb(dec->irq_urb); 1265 usb_free_urb(dec->irq_urb);
1264 return -ENOMEM; 1266 return -ENOMEM;
@@ -1270,7 +1272,13 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec)
1270 dec->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1272 dec->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1271 } 1273 }
1272 1274
1273 return ttusb_dec_alloc_iso_urbs(dec); 1275 result = ttusb_dec_alloc_iso_urbs(dec);
1276 if (result) {
1277 usb_free_urb(dec->irq_urb);
1278 usb_free_coherent(dec->udev, IRQ_PACKET_SIZE,
1279 dec->irq_buffer, dec->irq_dma_handle);
1280 }
1281 return result;
1274} 1282}
1275 1283
1276static int ttusb_dec_boot_dsp(struct ttusb_dec *dec) 1284static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
@@ -1293,10 +1301,11 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1293 1301
1294 dprintk("%s\n", __func__); 1302 dprintk("%s\n", __func__);
1295 1303
1296 if (request_firmware(&fw_entry, dec->firmware_name, &dec->udev->dev)) { 1304 result = request_firmware(&fw_entry, dec->firmware_name, &dec->udev->dev);
1305 if (result) {
1297 printk(KERN_ERR "%s: Firmware (%s) unavailable.\n", 1306 printk(KERN_ERR "%s: Firmware (%s) unavailable.\n",
1298 __func__, dec->firmware_name); 1307 __func__, dec->firmware_name);
1299 return 1; 1308 return result;
1300 } 1309 }
1301 1310
1302 firmware = fw_entry->data; 1311 firmware = fw_entry->data;
@@ -1306,7 +1315,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1306 printk("%s: firmware size too small for DSP code (%zu < 60).\n", 1315 printk("%s: firmware size too small for DSP code (%zu < 60).\n",
1307 __func__, firmware_size); 1316 __func__, firmware_size);
1308 release_firmware(fw_entry); 1317 release_firmware(fw_entry);
1309 return -1; 1318 return -ENOENT;
1310 } 1319 }
1311 1320
1312 /* a 32 bit checksum over the first 56 bytes of the DSP Code is stored 1321 /* a 32 bit checksum over the first 56 bytes of the DSP Code is stored
@@ -1320,7 +1329,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1320 "0x%08x != 0x%08x in file), file invalid.\n", 1329 "0x%08x != 0x%08x in file), file invalid.\n",
1321 __func__, crc32_csum, crc32_check); 1330 __func__, crc32_csum, crc32_check);
1322 release_firmware(fw_entry); 1331 release_firmware(fw_entry);
1323 return -1; 1332 return -ENOENT;
1324 } 1333 }
1325 memcpy(idstring, &firmware[36], 20); 1334 memcpy(idstring, &firmware[36], 20);
1326 idstring[20] = '\0'; 1335 idstring[20] = '\0';
@@ -1389,55 +1398,48 @@ static int ttusb_dec_init_stb(struct ttusb_dec *dec)
1389 dprintk("%s\n", __func__); 1398 dprintk("%s\n", __func__);
1390 1399
1391 result = ttusb_dec_get_stb_state(dec, &mode, &model, &version); 1400 result = ttusb_dec_get_stb_state(dec, &mode, &model, &version);
1401 if (result)
1402 return result;
1392 1403
1393 if (!result) { 1404 if (!mode) {
1394 if (!mode) { 1405 if (version == 0xABCDEFAB)
1395 if (version == 0xABCDEFAB) 1406 printk(KERN_INFO "ttusb_dec: no version "
1396 printk(KERN_INFO "ttusb_dec: no version " 1407 "info in Firmware\n");
1397 "info in Firmware\n"); 1408 else
1398 else 1409 printk(KERN_INFO "ttusb_dec: Firmware "
1399 printk(KERN_INFO "ttusb_dec: Firmware " 1410 "%x.%02x%c%c\n",
1400 "%x.%02x%c%c\n", 1411 version >> 24, (version >> 16) & 0xff,
1401 version >> 24, (version >> 16) & 0xff, 1412 (version >> 8) & 0xff, version & 0xff);
1402 (version >> 8) & 0xff, version & 0xff);
1403
1404 result = ttusb_dec_boot_dsp(dec);
1405 if (result)
1406 return result;
1407 else
1408 return 1;
1409 } else {
1410 /* We can't trust the USB IDs that some firmwares
1411 give the box */
1412 switch (model) {
1413 case 0x00070001:
1414 case 0x00070008:
1415 case 0x0007000c:
1416 ttusb_dec_set_model(dec, TTUSB_DEC3000S);
1417 break;
1418 case 0x00070009:
1419 case 0x00070013:
1420 ttusb_dec_set_model(dec, TTUSB_DEC2000T);
1421 break;
1422 case 0x00070011:
1423 ttusb_dec_set_model(dec, TTUSB_DEC2540T);
1424 break;
1425 default:
1426 printk(KERN_ERR "%s: unknown model returned "
1427 "by firmware (%08x) - please report\n",
1428 __func__, model);
1429 return -1;
1430 break;
1431 }
1432 1413
1414 result = ttusb_dec_boot_dsp(dec);
1415 if (result)
1416 return result;
1417 } else {
1418 /* We can't trust the USB IDs that some firmwares
1419 give the box */
1420 switch (model) {
1421 case 0x00070001:
1422 case 0x00070008:
1423 case 0x0007000c:
1424 ttusb_dec_set_model(dec, TTUSB_DEC3000S);
1425 break;
1426 case 0x00070009:
1427 case 0x00070013:
1428 ttusb_dec_set_model(dec, TTUSB_DEC2000T);
1429 break;
1430 case 0x00070011:
1431 ttusb_dec_set_model(dec, TTUSB_DEC2540T);
1432 break;
1433 default:
1434 printk(KERN_ERR "%s: unknown model returned "
1435 "by firmware (%08x) - please report\n",
1436 __func__, model);
1437 return -ENOENT;
1438 }
1433 if (version >= 0x01770000) 1439 if (version >= 0x01770000)
1434 dec->can_playback = 1; 1440 dec->can_playback = 1;
1435
1436 return 0;
1437 }
1438 } 1441 }
1439 else 1442 return 0;
1440 return result;
1441} 1443}
1442 1444
1443static int ttusb_dec_init_dvb(struct ttusb_dec *dec) 1445static int ttusb_dec_init_dvb(struct ttusb_dec *dec)
@@ -1539,19 +1541,7 @@ static void ttusb_dec_exit_dvb(struct ttusb_dec *dec)
1539 1541
1540static void ttusb_dec_exit_rc(struct ttusb_dec *dec) 1542static void ttusb_dec_exit_rc(struct ttusb_dec *dec)
1541{ 1543{
1542
1543 dprintk("%s\n", __func__); 1544 dprintk("%s\n", __func__);
1544 /* we have to check whether the irq URB is already submitted.
1545 * As the irq is submitted after the interface is changed,
1546 * this is the best method i figured out.
1547 * Any others?*/
1548 if (dec->interface == TTUSB_DEC_INTERFACE_IN)
1549 usb_kill_urb(dec->irq_urb);
1550
1551 usb_free_urb(dec->irq_urb);
1552
1553 usb_free_coherent(dec->udev,IRQ_PACKET_SIZE,
1554 dec->irq_buffer, dec->irq_dma_handle);
1555 1545
1556 if (dec->rc_input_dev) { 1546 if (dec->rc_input_dev) {
1557 input_unregister_device(dec->rc_input_dev); 1547 input_unregister_device(dec->rc_input_dev);
@@ -1566,6 +1556,20 @@ static void ttusb_dec_exit_usb(struct ttusb_dec *dec)
1566 1556
1567 dprintk("%s\n", __func__); 1557 dprintk("%s\n", __func__);
1568 1558
1559 if (enable_rc) {
1560 /* we have to check whether the irq URB is already submitted.
1561 * As the irq is submitted after the interface is changed,
1562 * this is the best method i figured out.
1563 * Any others?*/
1564 if (dec->interface == TTUSB_DEC_INTERFACE_IN)
1565 usb_kill_urb(dec->irq_urb);
1566
1567 usb_free_urb(dec->irq_urb);
1568
1569 usb_free_coherent(dec->udev, IRQ_PACKET_SIZE,
1570 dec->irq_buffer, dec->irq_dma_handle);
1571 }
1572
1569 dec->iso_stream_count = 0; 1573 dec->iso_stream_count = 0;
1570 1574
1571 for (i = 0; i < ISO_BUF_COUNT; i++) 1575 for (i = 0; i < ISO_BUF_COUNT; i++)
@@ -1623,6 +1627,7 @@ static int ttusb_dec_probe(struct usb_interface *intf,
1623{ 1627{
1624 struct usb_device *udev; 1628 struct usb_device *udev;
1625 struct ttusb_dec *dec; 1629 struct ttusb_dec *dec;
1630 int result;
1626 1631
1627 dprintk("%s\n", __func__); 1632 dprintk("%s\n", __func__);
1628 1633
@@ -1651,13 +1656,15 @@ static int ttusb_dec_probe(struct usb_interface *intf,
1651 1656
1652 dec->udev = udev; 1657 dec->udev = udev;
1653 1658
1654 if (ttusb_dec_init_usb(dec)) 1659 result = ttusb_dec_init_usb(dec);
1655 return 0; 1660 if (result)
1656 if (ttusb_dec_init_stb(dec)) { 1661 goto err_usb;
1657 ttusb_dec_exit_usb(dec); 1662 result = ttusb_dec_init_stb(dec);
1658 return 0; 1663 if (result)
1659 } 1664 goto err_stb;
1660 ttusb_dec_init_dvb(dec); 1665 result = ttusb_dec_init_dvb(dec);
1666 if (result)
1667 goto err_stb;
1661 1668
1662 dec->adapter.priv = dec; 1669 dec->adapter.priv = dec;
1663 switch (id->idProduct) { 1670 switch (id->idProduct) {
@@ -1696,6 +1703,11 @@ static int ttusb_dec_probe(struct usb_interface *intf,
1696 ttusb_init_rc(dec); 1703 ttusb_init_rc(dec);
1697 1704
1698 return 0; 1705 return 0;
1706err_stb:
1707 ttusb_dec_exit_usb(dec);
1708err_usb:
1709 kfree(dec);
1710 return result;
1699} 1711}
1700 1712
1701static void ttusb_dec_disconnect(struct usb_interface *intf) 1713static void ttusb_dec_disconnect(struct usb_interface *intf)
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index a2f4501c23ca..0eb82106d2ff 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -664,7 +664,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
664 .size = 32, 664 .size = 32,
665 .offset = 0, 665 .offset = 0,
666 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 666 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
667 .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, 667 .data_type = UVC_CTRL_DATA_TYPE_SIGNED,
668 }, 668 },
669 { 669 {
670 .id = V4L2_CID_TILT_ABSOLUTE, 670 .id = V4L2_CID_TILT_ABSOLUTE,
@@ -674,7 +674,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
674 .size = 32, 674 .size = 32,
675 .offset = 32, 675 .offset = 32,
676 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 676 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
677 .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, 677 .data_type = UVC_CTRL_DATA_TYPE_SIGNED,
678 }, 678 },
679 { 679 {
680 .id = V4L2_CID_PRIVACY, 680 .id = V4L2_CID_PRIVACY,