aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2013-12-18 16:42:06 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-18 16:42:06 -0500
commit143c9054949436cb05e468439dc5e46231f33d09 (patch)
treec2e972d8188fb1b36368e9acb5b6b59466c9d903 /drivers/media/usb
parent0b6807034791160d5e584138943d2daea765436d (diff)
parent35eecf052250f663f07a4cded7d3503fd1b50729 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Conflicts: drivers/net/ethernet/intel/i40e/i40e_main.c drivers/net/macvtap.c Both minor merge hassles, simple overlapping changes. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-cards.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c17
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf.c4
-rw-r--r--drivers/media/usb/dvb-usb/technisat-usb2.c2
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c2
-rw-r--r--drivers/media/usb/gspca/gl860/gl860.c2
-rw-r--r--drivers/media/usb/gspca/pac207.c2
-rw-r--r--drivers/media/usb/gspca/pac7302.c2
-rw-r--r--drivers/media/usb/gspca/stk1135.c3
-rw-r--r--drivers/media/usb/gspca/stv0680.c2
-rw-r--r--drivers/media/usb/gspca/sunplus.c1
-rw-r--r--drivers/media/usb/gspca/zc3xx.c2
-rw-r--r--drivers/media/usb/pwc/pwc-if.c2
-rw-r--r--drivers/media/usb/usbtv/usbtv.c174
-rw-r--r--drivers/media/usb/uvc/uvc_video.c2
15 files changed, 163 insertions, 56 deletions
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index e9d017bea377..528cce958a82 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1412,8 +1412,8 @@ err_v4l2:
1412 usb_set_intfdata(interface, NULL); 1412 usb_set_intfdata(interface, NULL);
1413err_if: 1413err_if:
1414 usb_put_dev(udev); 1414 usb_put_dev(udev);
1415 kfree(dev);
1416 clear_bit(dev->devno, &cx231xx_devused); 1415 clear_bit(dev->devno, &cx231xx_devused);
1416 kfree(dev);
1417 return retval; 1417 return retval;
1418} 1418}
1419 1419
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index c8fcd78425bd..8f9b2cea88f0 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -131,7 +131,7 @@ static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
131{ 131{
132 u8 wbuf[MAX_XFER_SIZE]; 132 u8 wbuf[MAX_XFER_SIZE];
133 u8 mbox = (reg >> 16) & 0xff; 133 u8 mbox = (reg >> 16) & 0xff;
134 struct usb_req req = { CMD_MEM_WR, mbox, sizeof(wbuf), wbuf, 0, NULL }; 134 struct usb_req req = { CMD_MEM_WR, mbox, 6 + len, wbuf, 0, NULL };
135 135
136 if (6 + len > sizeof(wbuf)) { 136 if (6 + len > sizeof(wbuf)) {
137 dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n", 137 dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n",
@@ -238,14 +238,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
238 } else { 238 } else {
239 /* I2C */ 239 /* I2C */
240 u8 buf[MAX_XFER_SIZE]; 240 u8 buf[MAX_XFER_SIZE];
241 struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf), 241 struct usb_req req = { CMD_I2C_RD, 0, 5 + msg[0].len,
242 buf, msg[1].len, msg[1].buf }; 242 buf, msg[1].len, msg[1].buf };
243 243
244 if (5 + msg[0].len > sizeof(buf)) { 244 if (5 + msg[0].len > sizeof(buf)) {
245 dev_warn(&d->udev->dev, 245 dev_warn(&d->udev->dev,
246 "%s: i2c xfer: len=%d is too big!\n", 246 "%s: i2c xfer: len=%d is too big!\n",
247 KBUILD_MODNAME, msg[0].len); 247 KBUILD_MODNAME, msg[0].len);
248 return -EOPNOTSUPP; 248 ret = -EOPNOTSUPP;
249 goto unlock;
249 } 250 }
250 req.mbox |= ((msg[0].addr & 0x80) >> 3); 251 req.mbox |= ((msg[0].addr & 0x80) >> 3);
251 buf[0] = msg[1].len; 252 buf[0] = msg[1].len;
@@ -274,14 +275,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
274 } else { 275 } else {
275 /* I2C */ 276 /* I2C */
276 u8 buf[MAX_XFER_SIZE]; 277 u8 buf[MAX_XFER_SIZE];
277 struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf, 278 struct usb_req req = { CMD_I2C_WR, 0, 5 + msg[0].len,
278 0, NULL }; 279 buf, 0, NULL };
279 280
280 if (5 + msg[0].len > sizeof(buf)) { 281 if (5 + msg[0].len > sizeof(buf)) {
281 dev_warn(&d->udev->dev, 282 dev_warn(&d->udev->dev,
282 "%s: i2c xfer: len=%d is too big!\n", 283 "%s: i2c xfer: len=%d is too big!\n",
283 KBUILD_MODNAME, msg[0].len); 284 KBUILD_MODNAME, msg[0].len);
284 return -EOPNOTSUPP; 285 ret = -EOPNOTSUPP;
286 goto unlock;
285 } 287 }
286 req.mbox |= ((msg[0].addr & 0x80) >> 3); 288 req.mbox |= ((msg[0].addr & 0x80) >> 3);
287 buf[0] = msg[0].len; 289 buf[0] = msg[0].len;
@@ -319,6 +321,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
319 ret = -EOPNOTSUPP; 321 ret = -EOPNOTSUPP;
320 } 322 }
321 323
324unlock:
322 mutex_unlock(&d->i2c_mutex); 325 mutex_unlock(&d->i2c_mutex);
323 326
324 if (ret < 0) 327 if (ret < 0)
@@ -1534,6 +1537,8 @@ static const struct usb_device_id af9035_id_table[] = {
1534 /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */ 1537 /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
1535 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099, 1538 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
1536 &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)", NULL) }, 1539 &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)", NULL) },
1540 { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a05,
1541 &af9035_props, "Leadtek WinFast DTV Dongle Dual", NULL) },
1537 { } 1542 { }
1538}; 1543};
1539MODULE_DEVICE_TABLE(usb, af9035_id_table); 1544MODULE_DEVICE_TABLE(usb, af9035_id_table);
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index 2627553f7de1..08240e498451 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -266,7 +266,7 @@ static int mxl111sf_adap_fe_init(struct dvb_frontend *fe)
266 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id]; 266 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id];
267 int err; 267 int err;
268 268
269 /* exit if we didnt initialize the driver yet */ 269 /* exit if we didn't initialize the driver yet */
270 if (!state->chip_id) { 270 if (!state->chip_id) {
271 mxl_debug("driver not yet initialized, exit."); 271 mxl_debug("driver not yet initialized, exit.");
272 goto fail; 272 goto fail;
@@ -322,7 +322,7 @@ static int mxl111sf_adap_fe_sleep(struct dvb_frontend *fe)
322 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id]; 322 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id];
323 int err; 323 int err;
324 324
325 /* exit if we didnt initialize the driver yet */ 325 /* exit if we didn't initialize the driver yet */
326 if (!state->chip_id) { 326 if (!state->chip_id) {
327 mxl_debug("driver not yet initialized, exit."); 327 mxl_debug("driver not yet initialized, exit.");
328 goto fail; 328 goto fail;
diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
index 40832a1aef6c..98d24aefb640 100644
--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
@@ -102,7 +102,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
102 if (rxlen > 62) { 102 if (rxlen > 62) {
103 err("i2c RX buffer can't exceed 62 bytes (dev 0x%02x)", 103 err("i2c RX buffer can't exceed 62 bytes (dev 0x%02x)",
104 device_addr); 104 device_addr);
105 txlen = 62; 105 rxlen = 62;
106 } 106 }
107 107
108 b[0] = I2C_SPEED_100KHZ_BIT; 108 b[0] = I2C_SPEED_100KHZ_BIT;
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index fc5d60efd4ab..dd19c9ff76e0 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1664,8 +1664,8 @@ static int em28xx_v4l2_close(struct file *filp)
1664 1664
1665 em28xx_videodbg("users=%d\n", dev->users); 1665 em28xx_videodbg("users=%d\n", dev->users);
1666 1666
1667 mutex_lock(&dev->lock);
1668 vb2_fop_release(filp); 1667 vb2_fop_release(filp);
1668 mutex_lock(&dev->lock);
1669 1669
1670 if (dev->users == 1) { 1670 if (dev->users == 1) {
1671 /* the device is already disconnect, 1671 /* the device is already disconnect,
diff --git a/drivers/media/usb/gspca/gl860/gl860.c b/drivers/media/usb/gspca/gl860/gl860.c
index cb1e64ca59c9..cea8d7f51c3c 100644
--- a/drivers/media/usb/gspca/gl860/gl860.c
+++ b/drivers/media/usb/gspca/gl860/gl860.c
@@ -438,7 +438,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
438 s32 nToSkip = 438 s32 nToSkip =
439 sd->swapRB * (gspca_dev->cam.cam_mode[mode].bytesperline + 1); 439 sd->swapRB * (gspca_dev->cam.cam_mode[mode].bytesperline + 1);
440 440
441 /* Test only against 0202h, so endianess does not matter */ 441 /* Test only against 0202h, so endianness does not matter */
442 switch (*(s16 *) data) { 442 switch (*(s16 *) data) {
443 case 0x0202: /* End of frame, start a new one */ 443 case 0x0202: /* End of frame, start a new one */
444 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); 444 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
diff --git a/drivers/media/usb/gspca/pac207.c b/drivers/media/usb/gspca/pac207.c
index cd79c180f67b..07529e5a0c56 100644
--- a/drivers/media/usb/gspca/pac207.c
+++ b/drivers/media/usb/gspca/pac207.c
@@ -416,7 +416,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
416#if IS_ENABLED(CONFIG_INPUT) 416#if IS_ENABLED(CONFIG_INPUT)
417static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 417static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
418 u8 *data, /* interrupt packet data */ 418 u8 *data, /* interrupt packet data */
419 int len) /* interrput packet length */ 419 int len) /* interrupt packet length */
420{ 420{
421 int ret = -EINVAL; 421 int ret = -EINVAL;
422 422
diff --git a/drivers/media/usb/gspca/pac7302.c b/drivers/media/usb/gspca/pac7302.c
index a91509643563..2fd1c5e31a0f 100644
--- a/drivers/media/usb/gspca/pac7302.c
+++ b/drivers/media/usb/gspca/pac7302.c
@@ -874,7 +874,7 @@ static int sd_dbg_s_register(struct gspca_dev *gspca_dev,
874#if IS_ENABLED(CONFIG_INPUT) 874#if IS_ENABLED(CONFIG_INPUT)
875static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 875static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
876 u8 *data, /* interrupt packet data */ 876 u8 *data, /* interrupt packet data */
877 int len) /* interrput packet length */ 877 int len) /* interrupt packet length */
878{ 878{
879 int ret = -EINVAL; 879 int ret = -EINVAL;
880 u8 data0, data1; 880 u8 data0, data1;
diff --git a/drivers/media/usb/gspca/stk1135.c b/drivers/media/usb/gspca/stk1135.c
index 1fc80af2a189..48234c9a8b6c 100644
--- a/drivers/media/usb/gspca/stk1135.c
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -361,6 +361,9 @@ static void stk1135_configure_clock(struct gspca_dev *gspca_dev)
361 361
362 /* set serial interface clock divider (30MHz/0x1f*16+2) = 60240 kHz) */ 362 /* set serial interface clock divider (30MHz/0x1f*16+2) = 60240 kHz) */
363 reg_w(gspca_dev, STK1135_REG_SICTL + 2, 0x1f); 363 reg_w(gspca_dev, STK1135_REG_SICTL + 2, 0x1f);
364
365 /* wait a while for sensor to catch up */
366 udelay(1000);
364} 367}
365 368
366static void stk1135_camera_disable(struct gspca_dev *gspca_dev) 369static void stk1135_camera_disable(struct gspca_dev *gspca_dev)
diff --git a/drivers/media/usb/gspca/stv0680.c b/drivers/media/usb/gspca/stv0680.c
index 9c0827631b9c..7f94ec74282e 100644
--- a/drivers/media/usb/gspca/stv0680.c
+++ b/drivers/media/usb/gspca/stv0680.c
@@ -139,7 +139,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
139 struct sd *sd = (struct sd *) gspca_dev; 139 struct sd *sd = (struct sd *) gspca_dev;
140 struct cam *cam = &gspca_dev->cam; 140 struct cam *cam = &gspca_dev->cam;
141 141
142 /* Give the camera some time to settle, otherwise initalization will 142 /* Give the camera some time to settle, otherwise initialization will
143 fail on hotplug, and yes it really needs a full second. */ 143 fail on hotplug, and yes it really needs a full second. */
144 msleep(1000); 144 msleep(1000);
145 145
diff --git a/drivers/media/usb/gspca/sunplus.c b/drivers/media/usb/gspca/sunplus.c
index a517d185febe..46c9f2229a18 100644
--- a/drivers/media/usb/gspca/sunplus.c
+++ b/drivers/media/usb/gspca/sunplus.c
@@ -1027,6 +1027,7 @@ static const struct usb_device_id device_table[] = {
1027 {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)}, 1027 {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)},
1028 {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)}, 1028 {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)},
1029 {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)}, 1029 {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)},
1030 {USB_DEVICE(0x06d6, 0x0041), BS(SPCA504B, 0)},
1030 {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)}, 1031 {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)},
1031 {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)}, 1032 {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)},
1032 {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)}, 1033 {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)},
diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index 7b95d8e88a20..d3e1b6d8bf49 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -6905,7 +6905,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev,
6905#if IS_ENABLED(CONFIG_INPUT) 6905#if IS_ENABLED(CONFIG_INPUT)
6906static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 6906static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
6907 u8 *data, /* interrupt packet data */ 6907 u8 *data, /* interrupt packet data */
6908 int len) /* interrput packet length */ 6908 int len) /* interrupt packet length */
6909{ 6909{
6910 if (len == 8 && data[4] == 1) { 6910 if (len == 8 && data[4] == 1) {
6911 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); 6911 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index 77bbf7889659..78c9bc8e7f56 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -1039,7 +1039,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1039 /* Set the leds off */ 1039 /* Set the leds off */
1040 pwc_set_leds(pdev, 0, 0); 1040 pwc_set_leds(pdev, 0, 0);
1041 1041
1042 /* Setup intial videomode */ 1042 /* Setup initial videomode */
1043 rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT, 1043 rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT,
1044 V4L2_PIX_FMT_YUV420, 30, &compression, 1); 1044 V4L2_PIX_FMT_YUV420, 30, &compression, 1);
1045 if (rc) 1045 if (rc)
diff --git a/drivers/media/usb/usbtv/usbtv.c b/drivers/media/usb/usbtv/usbtv.c
index 8a505a90d318..6222a4ab1e00 100644
--- a/drivers/media/usb/usbtv/usbtv.c
+++ b/drivers/media/usb/usbtv/usbtv.c
@@ -50,13 +50,8 @@
50#define USBTV_ISOC_TRANSFERS 16 50#define USBTV_ISOC_TRANSFERS 16
51#define USBTV_ISOC_PACKETS 8 51#define USBTV_ISOC_PACKETS 8
52 52
53#define USBTV_WIDTH 720
54#define USBTV_HEIGHT 480
55
56#define USBTV_CHUNK_SIZE 256 53#define USBTV_CHUNK_SIZE 256
57#define USBTV_CHUNK 240 54#define USBTV_CHUNK 240
58#define USBTV_CHUNKS (USBTV_WIDTH * USBTV_HEIGHT \
59 / 4 / USBTV_CHUNK)
60 55
61/* Chunk header. */ 56/* Chunk header. */
62#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \ 57#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
@@ -65,6 +60,27 @@
65#define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15) 60#define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15)
66#define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff) 61#define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff)
67 62
63#define USBTV_TV_STD (V4L2_STD_525_60 | V4L2_STD_PAL)
64
65/* parameters for supported TV norms */
66struct usbtv_norm_params {
67 v4l2_std_id norm;
68 int cap_width, cap_height;
69};
70
71static struct usbtv_norm_params norm_params[] = {
72 {
73 .norm = V4L2_STD_525_60,
74 .cap_width = 720,
75 .cap_height = 480,
76 },
77 {
78 .norm = V4L2_STD_PAL,
79 .cap_width = 720,
80 .cap_height = 576,
81 }
82};
83
68/* A single videobuf2 frame buffer. */ 84/* A single videobuf2 frame buffer. */
69struct usbtv_buf { 85struct usbtv_buf {
70 struct vb2_buffer vb; 86 struct vb2_buffer vb;
@@ -94,11 +110,38 @@ struct usbtv {
94 USBTV_COMPOSITE_INPUT, 110 USBTV_COMPOSITE_INPUT,
95 USBTV_SVIDEO_INPUT, 111 USBTV_SVIDEO_INPUT,
96 } input; 112 } input;
113 v4l2_std_id norm;
114 int width, height;
115 int n_chunks;
97 int iso_size; 116 int iso_size;
98 unsigned int sequence; 117 unsigned int sequence;
99 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS]; 118 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS];
100}; 119};
101 120
121static int usbtv_configure_for_norm(struct usbtv *usbtv, v4l2_std_id norm)
122{
123 int i, ret = 0;
124 struct usbtv_norm_params *params = NULL;
125
126 for (i = 0; i < ARRAY_SIZE(norm_params); i++) {
127 if (norm_params[i].norm & norm) {
128 params = &norm_params[i];
129 break;
130 }
131 }
132
133 if (params) {
134 usbtv->width = params->cap_width;
135 usbtv->height = params->cap_height;
136 usbtv->n_chunks = usbtv->width * usbtv->height
137 / 4 / USBTV_CHUNK;
138 usbtv->norm = params->norm;
139 } else
140 ret = -EINVAL;
141
142 return ret;
143}
144
102static int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size) 145static int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size)
103{ 146{
104 int ret; 147 int ret;
@@ -158,6 +201,57 @@ static int usbtv_select_input(struct usbtv *usbtv, int input)
158 return ret; 201 return ret;
159} 202}
160 203
204static int usbtv_select_norm(struct usbtv *usbtv, v4l2_std_id norm)
205{
206 int ret;
207 static const u16 pal[][2] = {
208 { USBTV_BASE + 0x001a, 0x0068 },
209 { USBTV_BASE + 0x010e, 0x0072 },
210 { USBTV_BASE + 0x010f, 0x00a2 },
211 { USBTV_BASE + 0x0112, 0x00b0 },
212 { USBTV_BASE + 0x0117, 0x0001 },
213 { USBTV_BASE + 0x0118, 0x002c },
214 { USBTV_BASE + 0x012d, 0x0010 },
215 { USBTV_BASE + 0x012f, 0x0020 },
216 { USBTV_BASE + 0x024f, 0x0002 },
217 { USBTV_BASE + 0x0254, 0x0059 },
218 { USBTV_BASE + 0x025a, 0x0016 },
219 { USBTV_BASE + 0x025b, 0x0035 },
220 { USBTV_BASE + 0x0263, 0x0017 },
221 { USBTV_BASE + 0x0266, 0x0016 },
222 { USBTV_BASE + 0x0267, 0x0036 }
223 };
224
225 static const u16 ntsc[][2] = {
226 { USBTV_BASE + 0x001a, 0x0079 },
227 { USBTV_BASE + 0x010e, 0x0068 },
228 { USBTV_BASE + 0x010f, 0x009c },
229 { USBTV_BASE + 0x0112, 0x00f0 },
230 { USBTV_BASE + 0x0117, 0x0000 },
231 { USBTV_BASE + 0x0118, 0x00fc },
232 { USBTV_BASE + 0x012d, 0x0004 },
233 { USBTV_BASE + 0x012f, 0x0008 },
234 { USBTV_BASE + 0x024f, 0x0001 },
235 { USBTV_BASE + 0x0254, 0x005f },
236 { USBTV_BASE + 0x025a, 0x0012 },
237 { USBTV_BASE + 0x025b, 0x0001 },
238 { USBTV_BASE + 0x0263, 0x001c },
239 { USBTV_BASE + 0x0266, 0x0011 },
240 { USBTV_BASE + 0x0267, 0x0005 }
241 };
242
243 ret = usbtv_configure_for_norm(usbtv, norm);
244
245 if (!ret) {
246 if (norm & V4L2_STD_525_60)
247 ret = usbtv_set_regs(usbtv, ntsc, ARRAY_SIZE(ntsc));
248 else if (norm & V4L2_STD_PAL)
249 ret = usbtv_set_regs(usbtv, pal, ARRAY_SIZE(pal));
250 }
251
252 return ret;
253}
254
161static int usbtv_setup_capture(struct usbtv *usbtv) 255static int usbtv_setup_capture(struct usbtv *usbtv)
162{ 256{
163 int ret; 257 int ret;
@@ -225,26 +319,11 @@ static int usbtv_setup_capture(struct usbtv *usbtv)
225 319
226 { USBTV_BASE + 0x0284, 0x0088 }, 320 { USBTV_BASE + 0x0284, 0x0088 },
227 { USBTV_BASE + 0x0003, 0x0004 }, 321 { USBTV_BASE + 0x0003, 0x0004 },
228 { USBTV_BASE + 0x001a, 0x0079 },
229 { USBTV_BASE + 0x0100, 0x00d3 }, 322 { USBTV_BASE + 0x0100, 0x00d3 },
230 { USBTV_BASE + 0x010e, 0x0068 },
231 { USBTV_BASE + 0x010f, 0x009c },
232 { USBTV_BASE + 0x0112, 0x00f0 },
233 { USBTV_BASE + 0x0115, 0x0015 }, 323 { USBTV_BASE + 0x0115, 0x0015 },
234 { USBTV_BASE + 0x0117, 0x0000 },
235 { USBTV_BASE + 0x0118, 0x00fc },
236 { USBTV_BASE + 0x012d, 0x0004 },
237 { USBTV_BASE + 0x012f, 0x0008 },
238 { USBTV_BASE + 0x0220, 0x002e }, 324 { USBTV_BASE + 0x0220, 0x002e },
239 { USBTV_BASE + 0x0225, 0x0008 }, 325 { USBTV_BASE + 0x0225, 0x0008 },
240 { USBTV_BASE + 0x024e, 0x0002 }, 326 { USBTV_BASE + 0x024e, 0x0002 },
241 { USBTV_BASE + 0x024f, 0x0001 },
242 { USBTV_BASE + 0x0254, 0x005f },
243 { USBTV_BASE + 0x025a, 0x0012 },
244 { USBTV_BASE + 0x025b, 0x0001 },
245 { USBTV_BASE + 0x0263, 0x001c },
246 { USBTV_BASE + 0x0266, 0x0011 },
247 { USBTV_BASE + 0x0267, 0x0005 },
248 { USBTV_BASE + 0x024e, 0x0002 }, 327 { USBTV_BASE + 0x024e, 0x0002 },
249 { USBTV_BASE + 0x024f, 0x0002 }, 328 { USBTV_BASE + 0x024f, 0x0002 },
250 }; 329 };
@@ -253,6 +332,10 @@ static int usbtv_setup_capture(struct usbtv *usbtv)
253 if (ret) 332 if (ret)
254 return ret; 333 return ret;
255 334
335 ret = usbtv_select_norm(usbtv, usbtv->norm);
336 if (ret)
337 return ret;
338
256 ret = usbtv_select_input(usbtv, usbtv->input); 339 ret = usbtv_select_input(usbtv, usbtv->input);
257 if (ret) 340 if (ret)
258 return ret; 341 return ret;
@@ -296,7 +379,7 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk)
296 frame_id = USBTV_FRAME_ID(chunk); 379 frame_id = USBTV_FRAME_ID(chunk);
297 odd = USBTV_ODD(chunk); 380 odd = USBTV_ODD(chunk);
298 chunk_no = USBTV_CHUNK_NO(chunk); 381 chunk_no = USBTV_CHUNK_NO(chunk);
299 if (chunk_no >= USBTV_CHUNKS) 382 if (chunk_no >= usbtv->n_chunks)
300 return; 383 return;
301 384
302 /* Beginning of a frame. */ 385 /* Beginning of a frame. */
@@ -324,10 +407,10 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk)
324 usbtv->chunks_done++; 407 usbtv->chunks_done++;
325 408
326 /* Last chunk in a frame, signalling an end */ 409 /* Last chunk in a frame, signalling an end */
327 if (odd && chunk_no == USBTV_CHUNKS-1) { 410 if (odd && chunk_no == usbtv->n_chunks-1) {
328 int size = vb2_plane_size(&buf->vb, 0); 411 int size = vb2_plane_size(&buf->vb, 0);
329 enum vb2_buffer_state state = usbtv->chunks_done == 412 enum vb2_buffer_state state = usbtv->chunks_done ==
330 USBTV_CHUNKS ? 413 usbtv->n_chunks ?
331 VB2_BUF_STATE_DONE : 414 VB2_BUF_STATE_DONE :
332 VB2_BUF_STATE_ERROR; 415 VB2_BUF_STATE_ERROR;
333 416
@@ -500,6 +583,8 @@ static int usbtv_querycap(struct file *file, void *priv,
500static int usbtv_enum_input(struct file *file, void *priv, 583static int usbtv_enum_input(struct file *file, void *priv,
501 struct v4l2_input *i) 584 struct v4l2_input *i)
502{ 585{
586 struct usbtv *dev = video_drvdata(file);
587
503 switch (i->index) { 588 switch (i->index) {
504 case USBTV_COMPOSITE_INPUT: 589 case USBTV_COMPOSITE_INPUT:
505 strlcpy(i->name, "Composite", sizeof(i->name)); 590 strlcpy(i->name, "Composite", sizeof(i->name));
@@ -512,7 +597,7 @@ static int usbtv_enum_input(struct file *file, void *priv,
512 } 597 }
513 598
514 i->type = V4L2_INPUT_TYPE_CAMERA; 599 i->type = V4L2_INPUT_TYPE_CAMERA;
515 i->std = V4L2_STD_525_60; 600 i->std = dev->vdev.tvnorms;
516 return 0; 601 return 0;
517} 602}
518 603
@@ -531,23 +616,37 @@ static int usbtv_enum_fmt_vid_cap(struct file *file, void *priv,
531static int usbtv_fmt_vid_cap(struct file *file, void *priv, 616static int usbtv_fmt_vid_cap(struct file *file, void *priv,
532 struct v4l2_format *f) 617 struct v4l2_format *f)
533{ 618{
534 f->fmt.pix.width = USBTV_WIDTH; 619 struct usbtv *usbtv = video_drvdata(file);
535 f->fmt.pix.height = USBTV_HEIGHT; 620
621 f->fmt.pix.width = usbtv->width;
622 f->fmt.pix.height = usbtv->height;
536 f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; 623 f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
537 f->fmt.pix.field = V4L2_FIELD_INTERLACED; 624 f->fmt.pix.field = V4L2_FIELD_INTERLACED;
538 f->fmt.pix.bytesperline = USBTV_WIDTH * 2; 625 f->fmt.pix.bytesperline = usbtv->width * 2;
539 f->fmt.pix.sizeimage = (f->fmt.pix.bytesperline * f->fmt.pix.height); 626 f->fmt.pix.sizeimage = (f->fmt.pix.bytesperline * f->fmt.pix.height);
540 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 627 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
541 f->fmt.pix.priv = 0; 628
542 return 0; 629 return 0;
543} 630}
544 631
545static int usbtv_g_std(struct file *file, void *priv, v4l2_std_id *norm) 632static int usbtv_g_std(struct file *file, void *priv, v4l2_std_id *norm)
546{ 633{
547 *norm = V4L2_STD_525_60; 634 struct usbtv *usbtv = video_drvdata(file);
635 *norm = usbtv->norm;
548 return 0; 636 return 0;
549} 637}
550 638
639static int usbtv_s_std(struct file *file, void *priv, v4l2_std_id norm)
640{
641 int ret = -EINVAL;
642 struct usbtv *usbtv = video_drvdata(file);
643
644 if ((norm & V4L2_STD_525_60) || (norm & V4L2_STD_PAL))
645 ret = usbtv_select_norm(usbtv, norm);
646
647 return ret;
648}
649
551static int usbtv_g_input(struct file *file, void *priv, unsigned int *i) 650static int usbtv_g_input(struct file *file, void *priv, unsigned int *i)
552{ 651{
553 struct usbtv *usbtv = video_drvdata(file); 652 struct usbtv *usbtv = video_drvdata(file);
@@ -561,13 +660,6 @@ static int usbtv_s_input(struct file *file, void *priv, unsigned int i)
561 return usbtv_select_input(usbtv, i); 660 return usbtv_select_input(usbtv, i);
562} 661}
563 662
564static int usbtv_s_std(struct file *file, void *priv, v4l2_std_id norm)
565{
566 if (norm & V4L2_STD_525_60)
567 return 0;
568 return -EINVAL;
569}
570
571struct v4l2_ioctl_ops usbtv_ioctl_ops = { 663struct v4l2_ioctl_ops usbtv_ioctl_ops = {
572 .vidioc_querycap = usbtv_querycap, 664 .vidioc_querycap = usbtv_querycap,
573 .vidioc_enum_input = usbtv_enum_input, 665 .vidioc_enum_input = usbtv_enum_input,
@@ -604,10 +696,12 @@ static int usbtv_queue_setup(struct vb2_queue *vq,
604 const struct v4l2_format *v4l_fmt, unsigned int *nbuffers, 696 const struct v4l2_format *v4l_fmt, unsigned int *nbuffers,
605 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) 697 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
606{ 698{
699 struct usbtv *usbtv = vb2_get_drv_priv(vq);
700
607 if (*nbuffers < 2) 701 if (*nbuffers < 2)
608 *nbuffers = 2; 702 *nbuffers = 2;
609 *nplanes = 1; 703 *nplanes = 1;
610 sizes[0] = USBTV_WIDTH * USBTV_HEIGHT / 2 * sizeof(u32); 704 sizes[0] = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32);
611 705
612 return 0; 706 return 0;
613} 707}
@@ -690,7 +784,11 @@ static int usbtv_probe(struct usb_interface *intf,
690 return -ENOMEM; 784 return -ENOMEM;
691 usbtv->dev = dev; 785 usbtv->dev = dev;
692 usbtv->udev = usb_get_dev(interface_to_usbdev(intf)); 786 usbtv->udev = usb_get_dev(interface_to_usbdev(intf));
787
693 usbtv->iso_size = size; 788 usbtv->iso_size = size;
789
790 (void)usbtv_configure_for_norm(usbtv, V4L2_STD_525_60);
791
694 spin_lock_init(&usbtv->buflock); 792 spin_lock_init(&usbtv->buflock);
695 mutex_init(&usbtv->v4l2_lock); 793 mutex_init(&usbtv->v4l2_lock);
696 mutex_init(&usbtv->vb2q_lock); 794 mutex_init(&usbtv->vb2q_lock);
@@ -727,7 +825,7 @@ static int usbtv_probe(struct usb_interface *intf,
727 usbtv->vdev.release = video_device_release_empty; 825 usbtv->vdev.release = video_device_release_empty;
728 usbtv->vdev.fops = &usbtv_fops; 826 usbtv->vdev.fops = &usbtv_fops;
729 usbtv->vdev.ioctl_ops = &usbtv_ioctl_ops; 827 usbtv->vdev.ioctl_ops = &usbtv_ioctl_ops;
730 usbtv->vdev.tvnorms = V4L2_STD_525_60; 828 usbtv->vdev.tvnorms = USBTV_TV_STD;
731 usbtv->vdev.queue = &usbtv->vb2q; 829 usbtv->vdev.queue = &usbtv->vb2q;
732 usbtv->vdev.lock = &usbtv->v4l2_lock; 830 usbtv->vdev.lock = &usbtv->v4l2_lock;
733 set_bit(V4L2_FL_USE_FH_PRIO, &usbtv->vdev.flags); 831 set_bit(V4L2_FL_USE_FH_PRIO, &usbtv->vdev.flags);
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 899cb6d1c4a4..898c208889cd 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -556,7 +556,7 @@ static u16 uvc_video_clock_host_sof(const struct uvc_clock_sample *sample)
556 * 556 *
557 * SOF = ((SOF2 - SOF1) * PTS + SOF1 * STC2 - SOF2 * STC1) / (STC2 - STC1) (1) 557 * SOF = ((SOF2 - SOF1) * PTS + SOF1 * STC2 - SOF2 * STC1) / (STC2 - STC1) (1)
558 * 558 *
559 * to avoid loosing precision in the division. Similarly, the host timestamp is 559 * to avoid losing precision in the division. Similarly, the host timestamp is
560 * computed with 560 * computed with
561 * 561 *
562 * TS = ((TS2 - TS1) * PTS + TS1 * SOF2 - TS2 * SOF1) / (SOF2 - SOF1) (2) 562 * TS = ((TS2 - TS1) * PTS + TS1 * SOF2 - TS2 * SOF1) / (SOF2 - SOF1) (2)