aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/video4linux/v4lgrab.c25
-rw-r--r--drivers/media/common/saa7146_video.c1
-rw-r--r--drivers/media/common/tuners/mxl5007t.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c24
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.h6
-rw-r--r--drivers/media/dvb/dvb-usb/af9005-fe.c2
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c30
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c18
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h2
-rw-r--r--drivers/media/dvb/frontends/drx397xD.c2
-rw-r--r--drivers/media/dvb/frontends/s5h1409.c7
-rw-r--r--drivers/media/dvb/frontends/stb0899_algo.c3
-rw-r--r--drivers/media/dvb/ttpci/budget.c1
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c2
-rw-r--r--drivers/media/radio/radio-mr800.c12
-rw-r--r--drivers/media/video/cs5345.c1
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c3
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c5
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c8
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c72
-rw-r--r--drivers/media/video/cx88/cx88.h2
-rw-r--r--drivers/media/video/em28xx/em28xx-audio.c14
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c32
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c20
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c20
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c45
-rw-r--r--drivers/media/video/em28xx/em28xx.h21
-rw-r--r--drivers/media/video/gspca/gspca.c4
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c4
-rw-r--r--drivers/media/video/pwc/pwc-if.c1
-rw-r--r--drivers/media/video/saa7127.c52
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c4
-rw-r--r--drivers/media/video/saa717x.c1
-rw-r--r--drivers/media/video/tda9875.c2
-rw-r--r--drivers/media/video/tveeprom.c3
-rw-r--r--drivers/media/video/tvp514x.c2
-rw-r--r--drivers/media/video/upd64031a.c1
-rw-r--r--drivers/media/video/upd64083.c1
-rw-r--r--drivers/media/video/usbvision/usbvision-i2c.c2
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c7
-rw-r--r--drivers/media/video/uvc/uvc_driver.c55
-rw-r--r--drivers/media/video/uvc/uvc_isight.c2
-rw-r--r--drivers/media/video/uvc/uvc_queue.c31
-rw-r--r--drivers/media/video/uvc/uvc_status.c3
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c10
-rw-r--r--drivers/media/video/uvc/uvc_video.c31
-rw-r--r--drivers/media/video/uvc/uvcvideo.h232
-rw-r--r--drivers/media/video/v4l2-subdev.c4
-rw-r--r--drivers/media/video/zoran/zoran.h12
-rw-r--r--drivers/media/video/zoran/zoran_card.c620
-rw-r--r--drivers/media/video/zoran/zoran_card.h2
-rw-r--r--drivers/media/video/zoran/zoran_driver.c105
-rw-r--r--include/media/v4l2-device.h8
54 files changed, 854 insertions, 731 deletions
diff --git a/Documentation/video4linux/v4lgrab.c b/Documentation/video4linux/v4lgrab.c
index 079b628481cf..d6e70bef8ad0 100644
--- a/Documentation/video4linux/v4lgrab.c
+++ b/Documentation/video4linux/v4lgrab.c
@@ -4,12 +4,21 @@
4 * 4 *
5 * Compile with: 5 * Compile with:
6 * gcc -s -Wall -Wstrict-prototypes v4lgrab.c -o v4lgrab 6 * gcc -s -Wall -Wstrict-prototypes v4lgrab.c -o v4lgrab
7 * Use as: 7 * Use as:
8 * v4lgrab >image.ppm 8 * v4lgrab >image.ppm
9 * 9 *
10 * Copyright (C) 1998-05-03, Phil Blundell <philb@gnu.org> 10 * Copyright (C) 1998-05-03, Phil Blundell <philb@gnu.org>
11 * Copied from http://www.tazenda.demon.co.uk/phil/vgrabber.c 11 * Copied from http://www.tazenda.demon.co.uk/phil/vgrabber.c
12 * with minor modifications (Dave Forrest, drf5n@virginia.edu). 12 * with minor modifications (Dave Forrest, drf5n@virginia.edu).
13 *
14 *
15 * For some cameras you may need to pre-load libv4l to perform
16 * the necessary decompression, e.g.:
17 *
18 * export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so
19 * ./v4lgrab >image.ppm
20 *
21 * see http://hansdegoede.livejournal.com/3636.html for details.
13 * 22 *
14 */ 23 */
15 24
@@ -24,7 +33,7 @@
24#include <linux/types.h> 33#include <linux/types.h>
25#include <linux/videodev.h> 34#include <linux/videodev.h>
26 35
27#define FILE "/dev/video0" 36#define VIDEO_DEV "/dev/video0"
28 37
29/* Stole this from tvset.c */ 38/* Stole this from tvset.c */
30 39
@@ -90,7 +99,7 @@ int get_brightness_adj(unsigned char *image, long size, int *brightness) {
90 99
91int main(int argc, char ** argv) 100int main(int argc, char ** argv)
92{ 101{
93 int fd = open(FILE, O_RDONLY), f; 102 int fd = open(VIDEO_DEV, O_RDONLY), f;
94 struct video_capability cap; 103 struct video_capability cap;
95 struct video_window win; 104 struct video_window win;
96 struct video_picture vpic; 105 struct video_picture vpic;
@@ -100,13 +109,13 @@ int main(int argc, char ** argv)
100 unsigned int i, src_depth; 109 unsigned int i, src_depth;
101 110
102 if (fd < 0) { 111 if (fd < 0) {
103 perror(FILE); 112 perror(VIDEO_DEV);
104 exit(1); 113 exit(1);
105 } 114 }
106 115
107 if (ioctl(fd, VIDIOCGCAP, &cap) < 0) { 116 if (ioctl(fd, VIDIOCGCAP, &cap) < 0) {
108 perror("VIDIOGCAP"); 117 perror("VIDIOGCAP");
109 fprintf(stderr, "(" FILE " not a video4linux device?)\n"); 118 fprintf(stderr, "(" VIDEO_DEV " not a video4linux device?)\n");
110 close(fd); 119 close(fd);
111 exit(1); 120 exit(1);
112 } 121 }
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 6098b626811f..47fee05eaefb 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -576,6 +576,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
576 vv->vflip = c->value; 576 vv->vflip = c->value;
577 break; 577 break;
578 default: { 578 default: {
579 mutex_unlock(&dev->lock);
579 return -EINVAL; 580 return -EINVAL;
580 } 581 }
581 } 582 }
diff --git a/drivers/media/common/tuners/mxl5007t.c b/drivers/media/common/tuners/mxl5007t.c
index 64379f2bf237..3ec28945c26f 100644
--- a/drivers/media/common/tuners/mxl5007t.c
+++ b/drivers/media/common/tuners/mxl5007t.c
@@ -657,7 +657,7 @@ static int mxl5007t_get_status(struct dvb_frontend *fe, u32 *status)
657{ 657{
658 struct mxl5007t_state *state = fe->tuner_priv; 658 struct mxl5007t_state *state = fe->tuner_priv;
659 int rf_locked, ref_locked; 659 int rf_locked, ref_locked;
660 s32 rf_input_level; 660 s32 rf_input_level = 0;
661 int ret; 661 int ret;
662 662
663 if (fe->ops.i2c_gate_ctrl) 663 if (fe->ops.i2c_gate_ctrl)
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 98ee16773ff2..7e3aeaa7370f 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -93,6 +93,9 @@ struct dvb_ca_slot {
93 /* current state of the CAM */ 93 /* current state of the CAM */
94 int slot_state; 94 int slot_state;
95 95
96 /* mutex used for serializing access to one CI slot */
97 struct mutex slot_lock;
98
96 /* Number of CAMCHANGES that have occurred since last processing */ 99 /* Number of CAMCHANGES that have occurred since last processing */
97 atomic_t camchange_count; 100 atomic_t camchange_count;
98 101
@@ -711,14 +714,20 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b
711 dprintk("%s\n", __func__); 714 dprintk("%s\n", __func__);
712 715
713 716
714 // sanity check 717 /* sanity check */
715 if (bytes_write > ca->slot_info[slot].link_buf_size) 718 if (bytes_write > ca->slot_info[slot].link_buf_size)
716 return -EINVAL; 719 return -EINVAL;
717 720
718 /* check if interface is actually waiting for us to read from it, or if a read is in progress */ 721 /* it is possible we are dealing with a single buffer implementation,
722 thus if there is data available for read or if there is even a read
723 already in progress, we do nothing but awake the kernel thread to
724 process the data if necessary. */
719 if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) 725 if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
720 goto exitnowrite; 726 goto exitnowrite;
721 if (status & (STATUSREG_DA | STATUSREG_RE)) { 727 if (status & (STATUSREG_DA | STATUSREG_RE)) {
728 if (status & STATUSREG_DA)
729 dvb_ca_en50221_thread_wakeup(ca);
730
722 status = -EAGAIN; 731 status = -EAGAIN;
723 goto exitnowrite; 732 goto exitnowrite;
724 } 733 }
@@ -987,6 +996,8 @@ static int dvb_ca_en50221_thread(void *data)
987 /* go through all the slots processing them */ 996 /* go through all the slots processing them */
988 for (slot = 0; slot < ca->slot_count; slot++) { 997 for (slot = 0; slot < ca->slot_count; slot++) {
989 998
999 mutex_lock(&ca->slot_info[slot].slot_lock);
1000
990 // check the cam status + deal with CAMCHANGEs 1001 // check the cam status + deal with CAMCHANGEs
991 while (dvb_ca_en50221_check_camstatus(ca, slot)) { 1002 while (dvb_ca_en50221_check_camstatus(ca, slot)) {
992 /* clear down an old CI slot if necessary */ 1003 /* clear down an old CI slot if necessary */
@@ -1122,7 +1133,7 @@ static int dvb_ca_en50221_thread(void *data)
1122 1133
1123 case DVB_CA_SLOTSTATE_RUNNING: 1134 case DVB_CA_SLOTSTATE_RUNNING:
1124 if (!ca->open) 1135 if (!ca->open)
1125 continue; 1136 break;
1126 1137
1127 // poll slots for data 1138 // poll slots for data
1128 pktcount = 0; 1139 pktcount = 0;
@@ -1146,6 +1157,8 @@ static int dvb_ca_en50221_thread(void *data)
1146 } 1157 }
1147 break; 1158 break;
1148 } 1159 }
1160
1161 mutex_unlock(&ca->slot_info[slot].slot_lock);
1149 } 1162 }
1150 } 1163 }
1151 1164
@@ -1181,6 +1194,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
1181 switch (cmd) { 1194 switch (cmd) {
1182 case CA_RESET: 1195 case CA_RESET:
1183 for (slot = 0; slot < ca->slot_count; slot++) { 1196 for (slot = 0; slot < ca->slot_count; slot++) {
1197 mutex_lock(&ca->slot_info[slot].slot_lock);
1184 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE) { 1198 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE) {
1185 dvb_ca_en50221_slot_shutdown(ca, slot); 1199 dvb_ca_en50221_slot_shutdown(ca, slot);
1186 if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) 1200 if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)
@@ -1188,6 +1202,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
1188 slot, 1202 slot,
1189 DVB_CA_EN50221_CAMCHANGE_INSERTED); 1203 DVB_CA_EN50221_CAMCHANGE_INSERTED);
1190 } 1204 }
1205 mutex_unlock(&ca->slot_info[slot].slot_lock);
1191 } 1206 }
1192 ca->next_read_slot = 0; 1207 ca->next_read_slot = 0;
1193 dvb_ca_en50221_thread_wakeup(ca); 1208 dvb_ca_en50221_thread_wakeup(ca);
@@ -1308,7 +1323,9 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
1308 goto exit; 1323 goto exit;
1309 } 1324 }
1310 1325
1326 mutex_lock(&ca->slot_info[slot].slot_lock);
1311 status = dvb_ca_en50221_write_data(ca, slot, fragbuf, fraglen + 2); 1327 status = dvb_ca_en50221_write_data(ca, slot, fragbuf, fraglen + 2);
1328 mutex_unlock(&ca->slot_info[slot].slot_lock);
1312 if (status == (fraglen + 2)) { 1329 if (status == (fraglen + 2)) {
1313 written = 1; 1330 written = 1;
1314 break; 1331 break;
@@ -1664,6 +1681,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1664 ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE; 1681 ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE;
1665 atomic_set(&ca->slot_info[i].camchange_count, 0); 1682 atomic_set(&ca->slot_info[i].camchange_count, 0);
1666 ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED; 1683 ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
1684 mutex_init(&ca->slot_info[i].slot_lock);
1667 } 1685 }
1668 1686
1669 if (signal_pending(current)) { 1687 if (signal_pending(current)) {
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.h b/drivers/media/dvb/dvb-core/dvb_ca_en50221.h
index 8467e63ddc0d..7df2e141187a 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.h
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.h
@@ -45,8 +45,10 @@ struct dvb_ca_en50221 {
45 /* the module owning this structure */ 45 /* the module owning this structure */
46 struct module* owner; 46 struct module* owner;
47 47
48 /* NOTE: the read_*, write_* and poll_slot_status functions must use locks as 48 /* NOTE: the read_*, write_* and poll_slot_status functions will be
49 * they may be called from several threads at once */ 49 * called for different slots concurrently and need to use locks where
50 * and if appropriate. There will be no concurrent access to one slot.
51 */
50 52
51 /* functions for accessing attribute memory on the CAM */ 53 /* functions for accessing attribute memory on the CAM */
52 int (*read_attribute_mem)(struct dvb_ca_en50221* ca, int slot, int address); 54 int (*read_attribute_mem)(struct dvb_ca_en50221* ca, int slot, int address);
diff --git a/drivers/media/dvb/dvb-usb/af9005-fe.c b/drivers/media/dvb/dvb-usb/af9005-fe.c
index b1a9c4cdec93..199ece0d4883 100644
--- a/drivers/media/dvb/dvb-usb/af9005-fe.c
+++ b/drivers/media/dvb/dvb-usb/af9005-fe.c
@@ -220,7 +220,7 @@ static int af9005_get_post_vit_ber(struct dvb_frontend *fe,
220 u16 * abort_count) 220 u16 * abort_count)
221{ 221{
222 u32 loc_cw_count = 0, loc_err_count; 222 u32 loc_cw_count = 0, loc_err_count;
223 u16 loc_abort_count; 223 u16 loc_abort_count = 0;
224 int ret; 224 int ret;
225 225
226 ret = 226 ret =
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index e1e9aa5c6b84..6a97a40d3dfb 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -694,7 +694,12 @@ static int af9015_read_config(struct usb_device *udev)
694 694
695 /* IR remote controller */ 695 /* IR remote controller */
696 req.addr = AF9015_EEPROM_IR_MODE; 696 req.addr = AF9015_EEPROM_IR_MODE;
697 ret = af9015_rw_udev(udev, &req); 697 /* first message will timeout often due to possible hw bug */
698 for (i = 0; i < 4; i++) {
699 ret = af9015_rw_udev(udev, &req);
700 if (!ret)
701 break;
702 }
698 if (ret) 703 if (ret)
699 goto error; 704 goto error;
700 deb_info("%s: IR mode:%d\n", __func__, val); 705 deb_info("%s: IR mode:%d\n", __func__, val);
@@ -835,18 +840,19 @@ static int af9015_read_config(struct usb_device *udev)
835 if (!dvb_usb_af9015_dual_mode) 840 if (!dvb_usb_af9015_dual_mode)
836 af9015_config.dual_mode = 0; 841 af9015_config.dual_mode = 0;
837 842
838 /* set buffer size according to USB port speed */ 843 /* Set adapter0 buffer size according to USB port speed, adapter1 buffer
844 size can be static because it is enabled only USB2.0 */
839 for (i = 0; i < af9015_properties_count; i++) { 845 for (i = 0; i < af9015_properties_count; i++) {
840 /* USB1.1 set smaller buffersize and disable 2nd adapter */ 846 /* USB1.1 set smaller buffersize and disable 2nd adapter */
841 if (udev->speed == USB_SPEED_FULL) { 847 if (udev->speed == USB_SPEED_FULL) {
842 af9015_properties[i].adapter->stream.u.bulk.buffersize = 848 af9015_properties[i].adapter[0].stream.u.bulk.buffersize
843 TS_USB11_MAX_PACKET_SIZE; 849 = TS_USB11_MAX_PACKET_SIZE;
844 /* disable 2nd adapter because we don't have 850 /* disable 2nd adapter because we don't have
845 PID-filters */ 851 PID-filters */
846 af9015_config.dual_mode = 0; 852 af9015_config.dual_mode = 0;
847 } else { 853 } else {
848 af9015_properties[i].adapter->stream.u.bulk.buffersize = 854 af9015_properties[i].adapter[0].stream.u.bulk.buffersize
849 TS_USB20_MAX_PACKET_SIZE; 855 = TS_USB20_MAX_PACKET_SIZE;
850 } 856 }
851 } 857 }
852 858
@@ -1254,6 +1260,12 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1254 .type = USB_BULK, 1260 .type = USB_BULK,
1255 .count = 6, 1261 .count = 6,
1256 .endpoint = 0x85, 1262 .endpoint = 0x85,
1263 .u = {
1264 .bulk = {
1265 .buffersize =
1266 TS_USB20_MAX_PACKET_SIZE,
1267 }
1268 }
1257 }, 1269 },
1258 } 1270 }
1259 }, 1271 },
@@ -1353,6 +1365,12 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1353 .type = USB_BULK, 1365 .type = USB_BULK,
1354 .count = 6, 1366 .count = 6,
1355 .endpoint = 0x85, 1367 .endpoint = 0x85,
1368 .u = {
1369 .bulk = {
1370 .buffersize =
1371 TS_USB20_MAX_PACKET_SIZE,
1372 }
1373 }
1356 }, 1374 },
1357 } 1375 }
1358 }, 1376 },
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 391732788911..635d30a55078 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -1393,6 +1393,9 @@ struct usb_device_id dib0700_usb_id_table[] = {
1393 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) }, 1393 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) },
1394/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) }, 1394/* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) },
1395 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) }, 1395 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) },
1396 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) },
1397 { USB_DEVICE(USB_VID_TERRATEC,
1398 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) },
1396 { 0 } /* Terminating entry */ 1399 { 0 } /* Terminating entry */
1397}; 1400};
1398MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); 1401MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -1537,7 +1540,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1537 { "DiBcom STK7700D reference design", 1540 { "DiBcom STK7700D reference design",
1538 { &dib0700_usb_id_table[14], NULL }, 1541 { &dib0700_usb_id_table[14], NULL },
1539 { NULL }, 1542 { NULL },
1540 } 1543 },
1544
1541 }, 1545 },
1542 1546
1543 .rc_interval = DEFAULT_RC_INTERVAL, 1547 .rc_interval = DEFAULT_RC_INTERVAL,
@@ -1557,7 +1561,7 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1557 }, 1561 },
1558 }, 1562 },
1559 1563
1560 .num_device_descs = 2, 1564 .num_device_descs = 3,
1561 .devices = { 1565 .devices = {
1562 { "ASUS My Cinema U3000 Mini DVBT Tuner", 1566 { "ASUS My Cinema U3000 Mini DVBT Tuner",
1563 { &dib0700_usb_id_table[23], NULL }, 1567 { &dib0700_usb_id_table[23], NULL },
@@ -1566,6 +1570,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1566 { "Yuan EC372S", 1570 { "Yuan EC372S",
1567 { &dib0700_usb_id_table[31], NULL }, 1571 { &dib0700_usb_id_table[31], NULL },
1568 { NULL }, 1572 { NULL },
1573 },
1574 { "Terratec Cinergy T Express",
1575 { &dib0700_usb_id_table[42], NULL },
1576 { NULL },
1569 } 1577 }
1570 }, 1578 },
1571 1579
@@ -1653,7 +1661,7 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1653 } 1661 }
1654 }, 1662 },
1655 1663
1656 .num_device_descs = 4, 1664 .num_device_descs = 5,
1657 .devices = { 1665 .devices = {
1658 { "DiBcom STK7070PD reference design", 1666 { "DiBcom STK7070PD reference design",
1659 { &dib0700_usb_id_table[17], NULL }, 1667 { &dib0700_usb_id_table[17], NULL },
@@ -1670,6 +1678,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1670 { "Hauppauge Nova-TD-500 (84xxx)", 1678 { "Hauppauge Nova-TD-500 (84xxx)",
1671 { &dib0700_usb_id_table[36], NULL }, 1679 { &dib0700_usb_id_table[36], NULL },
1672 { NULL }, 1680 { NULL },
1681 },
1682 { "Terratec Cinergy DT USB XS Diversity",
1683 { &dib0700_usb_id_table[43], NULL },
1684 { NULL },
1673 } 1685 }
1674 } 1686 }
1675 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 1687 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index a4fca3fca5ee..0db0c06ee6f2 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -162,8 +162,10 @@
162#define USB_PID_AVERMEDIA_A309 0xa309 162#define USB_PID_AVERMEDIA_A309 0xa309
163#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 163#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006
164#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a 164#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a
165#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
165#define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058 166#define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058
166#define USB_PID_TERRATEC_CINERGY_HT_EXPRESS 0x0060 167#define USB_PID_TERRATEC_CINERGY_HT_EXPRESS 0x0060
168#define USB_PID_TERRATEC_CINERGY_T_EXPRESS 0x0062
167#define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078 169#define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078
168#define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e 170#define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e
169#define USB_PID_PINNACLE_PCTV2000E 0x022c 171#define USB_PID_PINNACLE_PCTV2000E 0x022c
diff --git a/drivers/media/dvb/frontends/drx397xD.c b/drivers/media/dvb/frontends/drx397xD.c
index ec4e08dbc699..1e81e713df63 100644
--- a/drivers/media/dvb/frontends/drx397xD.c
+++ b/drivers/media/dvb/frontends/drx397xD.c
@@ -646,7 +646,7 @@ static int drx_tune(struct drx397xD_state *s,
646 u32 edi = 0, ebx = 0, ebp = 0, edx = 0; 646 u32 edi = 0, ebx = 0, ebp = 0, edx = 0;
647 u16 v20 = 0, v1E = 0, v16 = 0, v14 = 0, v12 = 0, v10 = 0, v0E = 0; 647 u16 v20 = 0, v1E = 0, v16 = 0, v14 = 0, v12 = 0, v10 = 0, v0E = 0;
648 648
649 int rc, df_tuner; 649 int rc, df_tuner = 0;
650 int a, b, c, d; 650 int a, b, c, d;
651 pr_debug("%s %d\n", __func__, s->config.d60); 651 pr_debug("%s %d\n", __func__, s->config.d60);
652 652
diff --git a/drivers/media/dvb/frontends/s5h1409.c b/drivers/media/dvb/frontends/s5h1409.c
index cf4d8936bb83..3e08d985d6e5 100644
--- a/drivers/media/dvb/frontends/s5h1409.c
+++ b/drivers/media/dvb/frontends/s5h1409.c
@@ -545,9 +545,6 @@ static int s5h1409_set_frontend(struct dvb_frontend *fe,
545 545
546 s5h1409_enable_modulation(fe, p->u.vsb.modulation); 546 s5h1409_enable_modulation(fe, p->u.vsb.modulation);
547 547
548 /* Allow the demod to settle */
549 msleep(100);
550
551 if (fe->ops.tuner_ops.set_params) { 548 if (fe->ops.tuner_ops.set_params) {
552 if (fe->ops.i2c_gate_ctrl) 549 if (fe->ops.i2c_gate_ctrl)
553 fe->ops.i2c_gate_ctrl(fe, 1); 550 fe->ops.i2c_gate_ctrl(fe, 1);
@@ -562,6 +559,10 @@ static int s5h1409_set_frontend(struct dvb_frontend *fe,
562 s5h1409_set_qam_interleave_mode(fe); 559 s5h1409_set_qam_interleave_mode(fe);
563 } 560 }
564 561
562 /* Issue a reset to the demod so it knows to resync against the
563 newly tuned frequency */
564 s5h1409_softreset(fe);
565
565 return 0; 566 return 0;
566} 567}
567 568
diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c
index 83dc7e12d5f0..a67d1775a43c 100644
--- a/drivers/media/dvb/frontends/stb0899_algo.c
+++ b/drivers/media/dvb/frontends/stb0899_algo.c
@@ -31,6 +31,8 @@ inline u32 stb0899_do_div(u64 n, u32 d)
31 return n; 31 return n;
32} 32}
33 33
34#if 0
35/* These functions are currently unused */
34/* 36/*
35 * stb0899_calc_srate 37 * stb0899_calc_srate
36 * Compute symbol rate 38 * Compute symbol rate
@@ -63,6 +65,7 @@ static u32 stb0899_get_srate(struct stb0899_state *state)
63 65
64 return stb0899_calc_srate(internal->master_clk, sfr); 66 return stb0899_calc_srate(internal->master_clk, sfr);
65} 67}
68#endif
66 69
67/* 70/*
68 * stb0899_set_srate 71 * stb0899_set_srate
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 1638e1d9f538..83e9e7750c8c 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -470,6 +470,7 @@ static void frontend_init(struct budget *budget)
470 budget->dvb_frontend = dvb_attach(l64781_attach, &grundig_29504_401_config, &budget->i2c_adap); 470 budget->dvb_frontend = dvb_attach(l64781_attach, &grundig_29504_401_config, &budget->i2c_adap);
471 if (budget->dvb_frontend) { 471 if (budget->dvb_frontend) {
472 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params; 472 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
473 budget->dvb_frontend->tuner_priv = NULL;
473 break; 474 break;
474 } 475 }
475 break; 476 break;
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 0aa96df80fc2..d91e0638448f 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1384,7 +1384,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1384static int ttusb_dec_init_stb(struct ttusb_dec *dec) 1384static int ttusb_dec_init_stb(struct ttusb_dec *dec)
1385{ 1385{
1386 int result; 1386 int result;
1387 unsigned int mode, model, version; 1387 unsigned int mode = 0, model = 0, version = 0;
1388 1388
1389 dprintk("%s\n", __func__); 1389 dprintk("%s\n", __func__);
1390 1390
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index 0747dc8862b0..fdfc7bf86b9e 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -194,10 +194,10 @@ static int amradio_start(struct amradio_device *radio)
194 return retval; 194 return retval;
195 } 195 }
196 196
197 mutex_unlock(&radio->lock);
198
199 radio->muted = 0; 197 radio->muted = 0;
200 198
199 mutex_unlock(&radio->lock);
200
201 return retval; 201 return retval;
202} 202}
203 203
@@ -230,10 +230,10 @@ static int amradio_stop(struct amradio_device *radio)
230 return retval; 230 return retval;
231 } 231 }
232 232
233 mutex_unlock(&radio->lock);
234
235 radio->muted = 1; 233 radio->muted = 1;
236 234
235 mutex_unlock(&radio->lock);
236
237 return retval; 237 return retval;
238} 238}
239 239
@@ -284,10 +284,10 @@ static int amradio_setfreq(struct amradio_device *radio, int freq)
284 return retval; 284 return retval;
285 } 285 }
286 286
287 mutex_unlock(&radio->lock);
288
289 radio->stereo = 0; 287 radio->stereo = 0;
290 288
289 mutex_unlock(&radio->lock);
290
291 return retval; 291 return retval;
292} 292}
293 293
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c
index 14bebf8a116f..87e91072627a 100644
--- a/drivers/media/video/cs5345.c
+++ b/drivers/media/video/cs5345.c
@@ -18,7 +18,6 @@
18 */ 18 */
19 19
20 20
21#include <linux/version.h>
22#include <linux/module.h> 21#include <linux/module.h>
23#include <linux/kernel.h> 22#include <linux/kernel.h>
24#include <linux/i2c.h> 23#include <linux/i2c.h>
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index 8f1db57bd1dd..bfe25841dbf4 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -1586,7 +1586,8 @@ static int mpeg_open(struct file *file)
1586 lock_kernel(); 1586 lock_kernel();
1587 list_for_each(list, &cx23885_devlist) { 1587 list_for_each(list, &cx23885_devlist) {
1588 h = list_entry(list, struct cx23885_dev, devlist); 1588 h = list_entry(list, struct cx23885_dev, devlist);
1589 if (h->v4l_device->minor == minor) { 1589 if (h->v4l_device &&
1590 h->v4l_device->minor == minor) {
1590 dev = h; 1591 dev = h;
1591 break; 1592 break;
1592 } 1593 }
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index 2d81c4d04340..eaa11893bfe9 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -730,12 +730,13 @@ static int video_open(struct file *file)
730 lock_kernel(); 730 lock_kernel();
731 list_for_each(list, &cx23885_devlist) { 731 list_for_each(list, &cx23885_devlist) {
732 h = list_entry(list, struct cx23885_dev, devlist); 732 h = list_entry(list, struct cx23885_dev, devlist);
733 if (h->video_dev->minor == minor) { 733 if (h->video_dev &&
734 h->video_dev->minor == minor) {
734 dev = h; 735 dev = h;
735 type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 736 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
736 } 737 }
737 if (h->vbi_dev && 738 if (h->vbi_dev &&
738 h->vbi_dev->minor == minor) { 739 h->vbi_dev->minor == minor) {
739 dev = h; 740 dev = h;
740 type = V4L2_BUF_TYPE_VBI_CAPTURE; 741 type = V4L2_BUF_TYPE_VBI_CAPTURE;
741 } 742 }
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 88f2fd32bfe3..25eb3bec9e5d 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -1382,6 +1382,14 @@ static int cx25840_log_status(struct v4l2_subdev *sd)
1382 1382
1383static int cx25840_command(struct i2c_client *client, unsigned cmd, void *arg) 1383static int cx25840_command(struct i2c_client *client, unsigned cmd, void *arg)
1384{ 1384{
1385 /* ignore this command */
1386 if (cmd == TUNER_SET_TYPE_ADDR || cmd == TUNER_SET_CONFIG)
1387 return 0;
1388
1389 /* Old-style drivers rely on initialization on first use, so
1390 call the init whenever a command is issued to this driver.
1391 New-style drivers using v4l2_subdev should call init explicitly. */
1392 cx25840_init(i2c_get_clientdata(client), 0);
1385 return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); 1393 return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg);
1386} 1394}
1387 1395
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 613dfea4ff3e..aef5297534af 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -614,34 +614,41 @@ static struct stv0288_config tevii_tuner_earda_config = {
614 .set_ts_params = cx24116_set_ts_param, 614 .set_ts_params = cx24116_set_ts_param,
615}; 615};
616 616
617static int dvb_register(struct cx8802_dev *dev) 617static int cx8802_alloc_frontends(struct cx8802_dev *dev)
618{ 618{
619 struct cx88_core *core = dev->core; 619 struct cx88_core *core = dev->core;
620 struct videobuf_dvb_frontend *fe0, *fe1 = NULL; 620 struct videobuf_dvb_frontend *fe = NULL;
621 int mfe_shared = 0; /* bus not shared by default */
622 int i; 621 int i;
623 622
624 if (0 != core->i2c_rc) {
625 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
626 goto frontend_detach;
627 }
628
629 if (!core->board.num_frontends)
630 return -EINVAL;
631
632 mutex_init(&dev->frontends.lock); 623 mutex_init(&dev->frontends.lock);
633 INIT_LIST_HEAD(&dev->frontends.felist); 624 INIT_LIST_HEAD(&dev->frontends.felist);
634 625
626 if (!core->board.num_frontends)
627 return -ENODEV;
628
635 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, 629 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
636 core->board.num_frontends); 630 core->board.num_frontends);
637 for (i = 1; i <= core->board.num_frontends; i++) { 631 for (i = 1; i <= core->board.num_frontends; i++) {
638 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, i); 632 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
639 if (!fe0) { 633 if (!fe) {
640 printk(KERN_ERR "%s() failed to alloc\n", __func__); 634 printk(KERN_ERR "%s() failed to alloc\n", __func__);
641 videobuf_dvb_dealloc_frontends(&dev->frontends); 635 videobuf_dvb_dealloc_frontends(&dev->frontends);
642 goto frontend_detach; 636 return -ENOMEM;
643 } 637 }
644 } 638 }
639 return 0;
640}
641
642static int dvb_register(struct cx8802_dev *dev)
643{
644 struct cx88_core *core = dev->core;
645 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
646 int mfe_shared = 0; /* bus not shared by default */
647
648 if (0 != core->i2c_rc) {
649 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
650 goto frontend_detach;
651 }
645 652
646 /* Get the first frontend */ 653 /* Get the first frontend */
647 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); 654 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
@@ -1243,6 +1250,8 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1243 struct cx88_core *core = drv->core; 1250 struct cx88_core *core = drv->core;
1244 struct cx8802_dev *dev = drv->core->dvbdev; 1251 struct cx8802_dev *dev = drv->core->dvbdev;
1245 int err; 1252 int err;
1253 struct videobuf_dvb_frontend *fe;
1254 int i;
1246 1255
1247 dprintk( 1, "%s\n", __func__); 1256 dprintk( 1, "%s\n", __func__);
1248 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", 1257 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
@@ -1258,39 +1267,34 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1258 /* If vp3054 isn't enabled, a stub will just return 0 */ 1267 /* If vp3054 isn't enabled, a stub will just return 0 */
1259 err = vp3054_i2c_probe(dev); 1268 err = vp3054_i2c_probe(dev);
1260 if (0 != err) 1269 if (0 != err)
1261 goto fail_probe; 1270 goto fail_core;
1262 1271
1263 /* dvb stuff */ 1272 /* dvb stuff */
1264 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); 1273 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
1265 dev->ts_gen_cntrl = 0x0c; 1274 dev->ts_gen_cntrl = 0x0c;
1266 1275
1276 err = cx8802_alloc_frontends(dev);
1277 if (err)
1278 goto fail_core;
1279
1267 err = -ENODEV; 1280 err = -ENODEV;
1268 if (core->board.num_frontends) { 1281 for (i = 1; i <= core->board.num_frontends; i++) {
1269 struct videobuf_dvb_frontend *fe; 1282 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1270 int i; 1283 if (fe == NULL) {
1271 1284 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
1272 for (i = 1; i <= core->board.num_frontends; i++) {
1273 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1274 if (fe == NULL) {
1275 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
1276 __func__, i); 1285 __func__, i);
1277 goto fail_probe; 1286 goto fail_probe;
1278 } 1287 }
1279 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops, 1288 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
1280 &dev->pci->dev, &dev->slock, 1289 &dev->pci->dev, &dev->slock,
1281 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1290 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1282 V4L2_FIELD_TOP, 1291 V4L2_FIELD_TOP,
1283 sizeof(struct cx88_buffer), 1292 sizeof(struct cx88_buffer),
1284 dev); 1293 dev);
1285 /* init struct videobuf_dvb */ 1294 /* init struct videobuf_dvb */
1286 fe->dvb.name = dev->core->name; 1295 fe->dvb.name = dev->core->name;
1287 }
1288 } else {
1289 /* no frontends allocated */
1290 printk(KERN_ERR "%s/2 .num_frontends should be non-zero\n",
1291 core->name);
1292 goto fail_core;
1293 } 1296 }
1297
1294 err = dvb_register(dev); 1298 err = dvb_register(dev);
1295 if (err) 1299 if (err)
1296 /* frontends/adapter de-allocated in dvb_register */ 1300 /* frontends/adapter de-allocated in dvb_register */
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 60a8b3187f14..6025fdd23344 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -336,8 +336,8 @@ struct cx88_core {
336 /* config info -- dvb */ 336 /* config info -- dvb */
337#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 337#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
338 int (*prev_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); 338 int (*prev_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
339 void (*gate_ctrl)(struct cx88_core *core, int open);
340#endif 339#endif
340 void (*gate_ctrl)(struct cx88_core *core, int open);
341 341
342 /* state info */ 342 /* state info */
343 struct task_struct *kthread; 343 struct task_struct *kthread;
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c
index 94378ccb7505..5d882a44e3ee 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -62,9 +62,15 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev)
62 62
63 dprintk("Stopping isoc\n"); 63 dprintk("Stopping isoc\n");
64 for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { 64 for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
65 usb_unlink_urb(dev->adev.urb[i]); 65 if (!irqs_disabled())
66 usb_kill_urb(dev->adev.urb[i]);
67 else
68 usb_unlink_urb(dev->adev.urb[i]);
66 usb_free_urb(dev->adev.urb[i]); 69 usb_free_urb(dev->adev.urb[i]);
67 dev->adev.urb[i] = NULL; 70 dev->adev.urb[i] = NULL;
71
72 kfree(dev->adev.transfer_buffer[i]);
73 dev->adev.transfer_buffer[i] = NULL;
68 } 74 }
69 75
70 return 0; 76 return 0;
@@ -389,11 +395,15 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream,
389static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream 395static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream
390 *substream) 396 *substream)
391{ 397{
392 struct em28xx *dev; 398 unsigned long flags;
393 399
400 struct em28xx *dev;
394 snd_pcm_uframes_t hwptr_done; 401 snd_pcm_uframes_t hwptr_done;
402
395 dev = snd_pcm_substream_chip(substream); 403 dev = snd_pcm_substream_chip(substream);
404 spin_lock_irqsave(&dev->adev.slock, flags);
396 hwptr_done = dev->adev.hwptr_done_capture; 405 hwptr_done = dev->adev.hwptr_done_capture;
406 spin_unlock_irqrestore(&dev->adev.slock, flags);
397 407
398 return hwptr_done; 408 return hwptr_done;
399} 409}
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index ef9bf008a924..3b3ca3f46d52 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -102,6 +102,18 @@ static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
102/* Board - EM2870 Kworld 355u 102/* Board - EM2870 Kworld 355u
103 Analog - No input analog */ 103 Analog - No input analog */
104 104
105static struct em28xx_reg_seq kworld_330u_analog[] = {
106 {EM28XX_R08_GPIO, 0x6d, ~EM_GPIO_4, 10},
107 {EM2880_R04_GPO, 0x00, 0xff, 10},
108 { -1, -1, -1, -1},
109};
110
111static struct em28xx_reg_seq kworld_330u_digital[] = {
112 {EM28XX_R08_GPIO, 0x6e, ~EM_GPIO_4, 10},
113 {EM2880_R04_GPO, 0x08, 0xff, 10},
114 { -1, -1, -1, -1},
115};
116
105/* Callback for the most boards */ 117/* Callback for the most boards */
106static struct em28xx_reg_seq default_tuner_gpio[] = { 118static struct em28xx_reg_seq default_tuner_gpio[] = {
107 {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, 119 {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10},
@@ -1177,29 +1189,33 @@ struct em28xx_board em28xx_boards[] = {
1177 .gpio = hauppauge_wintv_hvr_900_analog, 1189 .gpio = hauppauge_wintv_hvr_900_analog,
1178 } }, 1190 } },
1179 }, 1191 },
1180 [EM2883_BOARD_KWORLD_HYBRID_A316] = { 1192 [EM2883_BOARD_KWORLD_HYBRID_330U] = {
1181 .name = "Kworld PlusTV HD Hybrid 330", 1193 .name = "Kworld PlusTV HD Hybrid 330",
1182 .tuner_type = TUNER_XC2028, 1194 .tuner_type = TUNER_XC2028,
1183 .tuner_gpio = default_tuner_gpio, 1195 .tuner_gpio = default_tuner_gpio,
1184 .decoder = EM28XX_TVP5150, 1196 .decoder = EM28XX_TVP5150,
1185 .mts_firmware = 1, 1197 .mts_firmware = 1,
1186 .has_dvb = 1, 1198 .has_dvb = 1,
1187 .dvb_gpio = default_digital, 1199 .dvb_gpio = kworld_330u_digital,
1200 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ,
1201 .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_EEPROM_ON_BOARD | EM28XX_I2C_EEPROM_KEY_VALID,
1188 .input = { { 1202 .input = { {
1189 .type = EM28XX_VMUX_TELEVISION, 1203 .type = EM28XX_VMUX_TELEVISION,
1190 .vmux = TVP5150_COMPOSITE0, 1204 .vmux = TVP5150_COMPOSITE0,
1191 .amux = EM28XX_AMUX_VIDEO, 1205 .amux = EM28XX_AMUX_VIDEO,
1192 .gpio = default_analog, 1206 .gpio = kworld_330u_analog,
1207 .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1193 }, { 1208 }, {
1194 .type = EM28XX_VMUX_COMPOSITE1, 1209 .type = EM28XX_VMUX_COMPOSITE1,
1195 .vmux = TVP5150_COMPOSITE1, 1210 .vmux = TVP5150_COMPOSITE1,
1196 .amux = EM28XX_AMUX_LINE_IN, 1211 .amux = EM28XX_AMUX_LINE_IN,
1197 .gpio = hauppauge_wintv_hvr_900_analog, 1212 .gpio = kworld_330u_analog,
1213 .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1198 }, { 1214 }, {
1199 .type = EM28XX_VMUX_SVIDEO, 1215 .type = EM28XX_VMUX_SVIDEO,
1200 .vmux = TVP5150_SVIDEO, 1216 .vmux = TVP5150_SVIDEO,
1201 .amux = EM28XX_AMUX_LINE_IN, 1217 .amux = EM28XX_AMUX_LINE_IN,
1202 .gpio = hauppauge_wintv_hvr_900_analog, 1218 .gpio = kworld_330u_analog,
1203 } }, 1219 } },
1204 }, 1220 },
1205 [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = { 1221 [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = {
@@ -1249,7 +1265,7 @@ struct usb_device_id em28xx_id_table [] = {
1249 { USB_DEVICE(0xeb1a, 0xe310), 1265 { USB_DEVICE(0xeb1a, 0xe310),
1250 .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD }, 1266 .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD },
1251 { USB_DEVICE(0xeb1a, 0xa316), 1267 { USB_DEVICE(0xeb1a, 0xa316),
1252 .driver_info = EM2883_BOARD_KWORLD_HYBRID_A316 }, 1268 .driver_info = EM2883_BOARD_KWORLD_HYBRID_330U },
1253 { USB_DEVICE(0xeb1a, 0xe320), 1269 { USB_DEVICE(0xeb1a, 0xe320),
1254 .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II }, 1270 .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II },
1255 { USB_DEVICE(0xeb1a, 0xe323), 1271 { USB_DEVICE(0xeb1a, 0xe323),
@@ -1526,6 +1542,10 @@ static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
1526 /* FIXME: Better to specify the needed IF */ 1542 /* FIXME: Better to specify the needed IF */
1527 ctl->demod = XC3028_FE_DEFAULT; 1543 ctl->demod = XC3028_FE_DEFAULT;
1528 break; 1544 break;
1545 case EM2883_BOARD_KWORLD_HYBRID_330U:
1546 ctl->demod = XC3028_FE_CHINA;
1547 ctl->fname = XC2028_DEFAULT_FIRMWARE;
1548 break;
1529 default: 1549 default:
1530 ctl->demod = XC3028_FE_OREN538; 1550 ctl->demod = XC3028_FE_OREN538;
1531 } 1551 }
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index eb5fb05fab22..94fb1b639a2e 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -438,6 +438,10 @@ int em28xx_audio_analog_set(struct em28xx *dev)
438 if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { 438 if (dev->audio_mode.ac97 != EM28XX_NO_AC97) {
439 int vol; 439 int vol;
440 440
441 em28xx_write_ac97(dev, AC97_POWER_DOWN_CTRL, 0x4200);
442 em28xx_write_ac97(dev, AC97_EXT_AUD_CTRL, 0x0031);
443 em28xx_write_ac97(dev, AC97_PCM_IN_SRATE, 0xbb80);
444
441 /* LSB: left channel - both channels with the same level */ 445 /* LSB: left channel - both channels with the same level */
442 vol = (0x1f - dev->volume) | ((0x1f - dev->volume) << 8); 446 vol = (0x1f - dev->volume) | ((0x1f - dev->volume) << 8);
443 447
@@ -454,6 +458,15 @@ int em28xx_audio_analog_set(struct em28xx *dev)
454 em28xx_warn("couldn't setup AC97 register %d\n", 458 em28xx_warn("couldn't setup AC97 register %d\n",
455 outputs[i].reg); 459 outputs[i].reg);
456 } 460 }
461
462 if (dev->ctl_aoutput & EM28XX_AOUT_PCM_IN) {
463 int sel = ac97_return_record_select(dev->ctl_aoutput);
464
465 /* Use the same input for both left and right channels */
466 sel |= (sel << 8);
467
468 em28xx_write_ac97(dev, AC97_RECORD_SELECT, sel);
469 }
457 } 470 }
458 471
459 return ret; 472 return ret;
@@ -847,8 +860,11 @@ void em28xx_uninit_isoc(struct em28xx *dev)
847 for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { 860 for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
848 urb = dev->isoc_ctl.urb[i]; 861 urb = dev->isoc_ctl.urb[i];
849 if (urb) { 862 if (urb) {
850 usb_kill_urb(urb); 863 if (!irqs_disabled())
851 usb_unlink_urb(urb); 864 usb_kill_urb(urb);
865 else
866 usb_unlink_urb(urb);
867
852 if (dev->isoc_ctl.transfer_buffer[i]) { 868 if (dev->isoc_ctl.transfer_buffer[i]) {
853 usb_buffer_free(dev->udev, 869 usb_buffer_free(dev->udev,
854 urb->transfer_buffer_length, 870 urb->transfer_buffer_length,
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index d38cb21834d9..9ad8527b3fda 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -28,6 +28,7 @@
28 28
29#include "lgdt330x.h" 29#include "lgdt330x.h"
30#include "zl10353.h" 30#include "zl10353.h"
31#include "s5h1409.h"
31#ifdef EM28XX_DRX397XD_SUPPORT 32#ifdef EM28XX_DRX397XD_SUPPORT
32#include "drx397xD.h" 33#include "drx397xD.h"
33#endif 34#endif
@@ -232,6 +233,15 @@ static struct zl10353_config em28xx_zl10353_with_xc3028 = {
232 .if2 = 45600, 233 .if2 = 45600,
233}; 234};
234 235
236static struct s5h1409_config em28xx_s5h1409_with_xc3028 = {
237 .demod_address = 0x32 >> 1,
238 .output_mode = S5H1409_PARALLEL_OUTPUT,
239 .gpio = S5H1409_GPIO_OFF,
240 .inversion = S5H1409_INVERSION_OFF,
241 .status_mode = S5H1409_DEMODLOCKING,
242 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
243};
244
235#ifdef EM28XX_DRX397XD_SUPPORT 245#ifdef EM28XX_DRX397XD_SUPPORT
236/* [TODO] djh - not sure yet what the device config needs to contain */ 246/* [TODO] djh - not sure yet what the device config needs to contain */
237static struct drx397xD_config em28xx_drx397xD_with_xc3028 = { 247static struct drx397xD_config em28xx_drx397xD_with_xc3028 = {
@@ -412,7 +422,6 @@ static int dvb_init(struct em28xx *dev)
412 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850: 422 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
413 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: 423 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
414 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: 424 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
415 case EM2883_BOARD_KWORLD_HYBRID_A316:
416 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600: 425 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
417 dvb->frontend = dvb_attach(lgdt330x_attach, 426 dvb->frontend = dvb_attach(lgdt330x_attach,
418 &em2880_lgdt3303_dev, 427 &em2880_lgdt3303_dev,
@@ -433,6 +442,15 @@ static int dvb_init(struct em28xx *dev)
433 goto out_free; 442 goto out_free;
434 } 443 }
435 break; 444 break;
445 case EM2883_BOARD_KWORLD_HYBRID_330U:
446 dvb->frontend = dvb_attach(s5h1409_attach,
447 &em28xx_s5h1409_with_xc3028,
448 &dev->i2c_adap);
449 if (attach_xc3028(0x61, dev) < 0) {
450 result = -EINVAL;
451 goto out_free;
452 }
453 break;
436 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: 454 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
437#ifdef EM28XX_DRX397XD_SUPPORT 455#ifdef EM28XX_DRX397XD_SUPPORT
438 /* We don't have the config structure properly populated, so 456 /* We don't have the config structure properly populated, so
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 416b691c33c1..8e61b2ca9167 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -886,10 +886,10 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
886 if (0 == INPUT(i)->type) 886 if (0 == INPUT(i)->type)
887 return -EINVAL; 887 return -EINVAL;
888 888
889 mutex_lock(&dev->lock); 889 dev->ctl_input = i;
890
891 video_mux(dev, i);
892 890
891 mutex_lock(&dev->lock);
892 video_mux(dev, dev->ctl_input);
893 mutex_unlock(&dev->lock); 893 mutex_unlock(&dev->lock);
894 return 0; 894 return 0;
895} 895}
@@ -939,6 +939,12 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
939 struct em28xx_fh *fh = priv; 939 struct em28xx_fh *fh = priv;
940 struct em28xx *dev = fh->dev; 940 struct em28xx *dev = fh->dev;
941 941
942
943 if (a->index >= MAX_EM28XX_INPUT)
944 return -EINVAL;
945 if (0 == INPUT(a->index)->type)
946 return -EINVAL;
947
942 mutex_lock(&dev->lock); 948 mutex_lock(&dev->lock);
943 949
944 dev->ctl_ainput = INPUT(a->index)->amux; 950 dev->ctl_ainput = INPUT(a->index)->amux;
@@ -1950,6 +1956,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
1950 1956
1951int em28xx_register_analog_devices(struct em28xx *dev) 1957int em28xx_register_analog_devices(struct em28xx *dev)
1952{ 1958{
1959 u8 val;
1953 int ret; 1960 int ret;
1954 1961
1955 printk(KERN_INFO "%s: v4l2 driver version %d.%d.%d\n", 1962 printk(KERN_INFO "%s: v4l2 driver version %d.%d.%d\n",
@@ -1957,34 +1964,34 @@ int em28xx_register_analog_devices(struct em28xx *dev)
1957 (EM28XX_VERSION_CODE >> 16) & 0xff, 1964 (EM28XX_VERSION_CODE >> 16) & 0xff,
1958 (EM28XX_VERSION_CODE >> 8) & 0xff, EM28XX_VERSION_CODE & 0xff); 1965 (EM28XX_VERSION_CODE >> 8) & 0xff, EM28XX_VERSION_CODE & 0xff);
1959 1966
1967 /* set default norm */
1968 dev->norm = em28xx_video_template.current_norm;
1969 dev->width = norm_maxw(dev);
1970 dev->height = norm_maxh(dev);
1971 dev->interlaced = EM28XX_INTERLACED_DEFAULT;
1972 dev->hscale = 0;
1973 dev->vscale = 0;
1974 dev->ctl_input = 0;
1975
1960 /* Analog specific initialization */ 1976 /* Analog specific initialization */
1961 dev->format = &format[0]; 1977 dev->format = &format[0];
1962 video_mux(dev, 0); 1978 video_mux(dev, dev->ctl_input);
1979
1980 /* Audio defaults */
1981 dev->mute = 1;
1982 dev->volume = 0x1f;
1963 1983
1964 /* enable vbi capturing */ 1984 /* enable vbi capturing */
1965 1985
1966/* em28xx_write_reg(dev, EM28XX_R0E_AUDIOSRC, 0xc0); audio register */ 1986/* em28xx_write_reg(dev, EM28XX_R0E_AUDIOSRC, 0xc0); audio register */
1967/* em28xx_write_reg(dev, EM28XX_R0F_XCLK, 0x80); clk register */ 1987 val = (u8)em28xx_read_reg(dev, EM28XX_R0F_XCLK);
1988 em28xx_write_reg(dev, EM28XX_R0F_XCLK, (EM28XX_XCLK_AUDIO_UNMUTE | val));
1968 em28xx_write_reg(dev, EM28XX_R11_VINCTRL, 0x51); 1989 em28xx_write_reg(dev, EM28XX_R11_VINCTRL, 0x51);
1969 1990
1970 dev->mute = 1; /* maybe not the right place... */
1971 dev->volume = 0x1f;
1972
1973 em28xx_set_outfmt(dev); 1991 em28xx_set_outfmt(dev);
1974 em28xx_colorlevels_set_default(dev); 1992 em28xx_colorlevels_set_default(dev);
1975 em28xx_compression_disable(dev); 1993 em28xx_compression_disable(dev);
1976 1994
1977 /* set default norm */
1978 dev->norm = em28xx_video_template.current_norm;
1979 dev->width = norm_maxw(dev);
1980 dev->height = norm_maxh(dev);
1981 dev->interlaced = EM28XX_INTERLACED_DEFAULT;
1982 dev->hscale = 0;
1983 dev->vscale = 0;
1984
1985 /* FIXME: This is a very bad hack! Not all devices have TV on input 2 */
1986 dev->ctl_input = 2;
1987
1988 /* allocate and fill video video_device struct */ 1995 /* allocate and fill video video_device struct */
1989 dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video"); 1996 dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video");
1990 if (!dev->vdev) { 1997 if (!dev->vdev) {
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 6c6b94aa05b2..dd2cd36fb1bb 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -94,7 +94,7 @@
94#define EM2882_BOARD_KWORLD_VS_DVBT 54 94#define EM2882_BOARD_KWORLD_VS_DVBT 54
95#define EM2882_BOARD_TERRATEC_HYBRID_XS 55 95#define EM2882_BOARD_TERRATEC_HYBRID_XS 55
96#define EM2882_BOARD_PINNACLE_HYBRID_PRO 56 96#define EM2882_BOARD_PINNACLE_HYBRID_PRO 56
97#define EM2883_BOARD_KWORLD_HYBRID_A316 57 97#define EM2883_BOARD_KWORLD_HYBRID_330U 57
98#define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU 58 98#define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU 58
99#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 60 99#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 60
100#define EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2 61 100#define EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2 61
@@ -300,13 +300,32 @@ enum em28xx_amux {
300}; 300};
301 301
302enum em28xx_aout { 302enum em28xx_aout {
303 /* AC97 outputs */
303 EM28XX_AOUT_MASTER = 1 << 0, 304 EM28XX_AOUT_MASTER = 1 << 0,
304 EM28XX_AOUT_LINE = 1 << 1, 305 EM28XX_AOUT_LINE = 1 << 1,
305 EM28XX_AOUT_MONO = 1 << 2, 306 EM28XX_AOUT_MONO = 1 << 2,
306 EM28XX_AOUT_LFE = 1 << 3, 307 EM28XX_AOUT_LFE = 1 << 3,
307 EM28XX_AOUT_SURR = 1 << 4, 308 EM28XX_AOUT_SURR = 1 << 4,
309
310 /* PCM IN Mixer - used by AC97_RECORD_SELECT register */
311 EM28XX_AOUT_PCM_IN = 1 << 7,
312
313 /* Bits 10-8 are used to indicate the PCM IN record select */
314 EM28XX_AOUT_PCM_MIC_PCM = 0 << 8,
315 EM28XX_AOUT_PCM_CD = 1 << 8,
316 EM28XX_AOUT_PCM_VIDEO = 2 << 8,
317 EM28XX_AOUT_PCM_AUX = 3 << 8,
318 EM28XX_AOUT_PCM_LINE = 4 << 8,
319 EM28XX_AOUT_PCM_STEREO = 5 << 8,
320 EM28XX_AOUT_PCM_MONO = 6 << 8,
321 EM28XX_AOUT_PCM_PHONE = 7 << 8,
308}; 322};
309 323
324static inline int ac97_return_record_select(int a_out)
325{
326 return (a_out & 0x700) >> 8;
327}
328
310struct em28xx_reg_seq { 329struct em28xx_reg_seq {
311 int reg; 330 int reg;
312 unsigned char val, mask; 331 unsigned char val, mask;
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 5e36b9a4ae3e..2ed24527ecd6 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -423,7 +423,8 @@ static void destroy_urbs(struct gspca_dev *gspca_dev)
423 break; 423 break;
424 424
425 gspca_dev->urb[i] = NULL; 425 gspca_dev->urb[i] = NULL;
426 usb_kill_urb(urb); 426 if (!gspca_dev->present)
427 usb_kill_urb(urb);
427 if (urb->transfer_buffer != NULL) 428 if (urb->transfer_buffer != NULL)
428 usb_buffer_free(gspca_dev->dev, 429 usb_buffer_free(gspca_dev->dev,
429 urb->transfer_buffer_length, 430 urb->transfer_buffer_length,
@@ -1950,7 +1951,6 @@ void gspca_disconnect(struct usb_interface *intf)
1950 struct gspca_dev *gspca_dev = usb_get_intfdata(intf); 1951 struct gspca_dev *gspca_dev = usb_get_intfdata(intf);
1951 1952
1952 gspca_dev->present = 0; 1953 gspca_dev->present = 0;
1953 gspca_dev->streaming = 0;
1954 1954
1955 usb_set_intfdata(intf, NULL); 1955 usb_set_intfdata(intf, NULL);
1956 1956
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index e8e5921cdc34..c46c990987f9 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -949,8 +949,10 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
949 itv->instance = atomic_inc_return(&ivtv_instance) - 1; 949 itv->instance = atomic_inc_return(&ivtv_instance) - 1;
950 950
951 retval = v4l2_device_register(&dev->dev, &itv->device); 951 retval = v4l2_device_register(&dev->dev, &itv->device);
952 if (retval) 952 if (retval) {
953 kfree(itv);
953 return retval; 954 return retval;
955 }
954 /* "ivtv + PCI ID" is a bit of a mouthful, so use 956 /* "ivtv + PCI ID" is a bit of a mouthful, so use
955 "ivtv + instance" instead. */ 957 "ivtv + instance" instead. */
956 snprintf(itv->device.name, sizeof(itv->device.name), 958 snprintf(itv->device.name, sizeof(itv->device.name),
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 39fbc970f43d..0d810189dd87 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -62,7 +62,6 @@
62#include <linux/poll.h> 62#include <linux/poll.h>
63#include <linux/slab.h> 63#include <linux/slab.h>
64#include <linux/vmalloc.h> 64#include <linux/vmalloc.h>
65#include <linux/version.h>
66#include <asm/io.h> 65#include <asm/io.h>
67 66
68#include "pwc.h" 67#include "pwc.h"
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index d6848f7a503b..05221d47dd4c 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -149,7 +149,7 @@ static const struct i2c_reg_value saa7127_init_config_common[] = {
149 { SAA7127_REG_COPYGEN_0, 0x77 }, 149 { SAA7127_REG_COPYGEN_0, 0x77 },
150 { SAA7127_REG_COPYGEN_1, 0x41 }, 150 { SAA7127_REG_COPYGEN_1, 0x41 },
151 { SAA7127_REG_COPYGEN_2, 0x00 }, /* Macrovision enable/disable */ 151 { SAA7127_REG_COPYGEN_2, 0x00 }, /* Macrovision enable/disable */
152 { SAA7127_REG_OUTPUT_PORT_CONTROL, 0x9e }, 152 { SAA7127_REG_OUTPUT_PORT_CONTROL, 0xbf },
153 { SAA7127_REG_GAIN_LUMINANCE_RGB, 0x00 }, 153 { SAA7127_REG_GAIN_LUMINANCE_RGB, 0x00 },
154 { SAA7127_REG_GAIN_COLORDIFF_RGB, 0x00 }, 154 { SAA7127_REG_GAIN_COLORDIFF_RGB, 0x00 },
155 { SAA7127_REG_INPUT_PORT_CONTROL_1, 0x80 }, /* for color bars */ 155 { SAA7127_REG_INPUT_PORT_CONTROL_1, 0x80 }, /* for color bars */
@@ -488,12 +488,18 @@ static int saa7127_set_output_type(struct v4l2_subdev *sd, int output)
488 break; 488 break;
489 489
490 case SAA7127_OUTPUT_TYPE_COMPOSITE: 490 case SAA7127_OUTPUT_TYPE_COMPOSITE:
491 state->reg_2d = 0x08; /* 00001000 CVBS only, RGB DAC's off (high impedance mode) */ 491 if (state->ident == V4L2_IDENT_SAA7129)
492 state->reg_2d = 0x20; /* CVBS only */
493 else
494 state->reg_2d = 0x08; /* 00001000 CVBS only, RGB DAC's off (high impedance mode) */
492 state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */ 495 state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */
493 break; 496 break;
494 497
495 case SAA7127_OUTPUT_TYPE_SVIDEO: 498 case SAA7127_OUTPUT_TYPE_SVIDEO:
496 state->reg_2d = 0xff; /* 11111111 croma -> R, luma -> CVBS + G + B */ 499 if (state->ident == V4L2_IDENT_SAA7129)
500 state->reg_2d = 0x18; /* Y + C */
501 else
502 state->reg_2d = 0xff; /*11111111 croma -> R, luma -> CVBS + G + B */
497 state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */ 503 state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */
498 break; 504 break;
499 505
@@ -508,7 +514,10 @@ static int saa7127_set_output_type(struct v4l2_subdev *sd, int output)
508 break; 514 break;
509 515
510 case SAA7127_OUTPUT_TYPE_BOTH: 516 case SAA7127_OUTPUT_TYPE_BOTH:
511 state->reg_2d = 0xbf; 517 if (state->ident == V4L2_IDENT_SAA7129)
518 state->reg_2d = 0x38;
519 else
520 state->reg_2d = 0xbf;
512 state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */ 521 state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */
513 break; 522 break;
514 523
@@ -731,24 +740,6 @@ static int saa7127_probe(struct i2c_client *client,
731 return -ENODEV; 740 return -ENODEV;
732 } 741 }
733 742
734 /* Configure Encoder */
735
736 v4l2_dbg(1, debug, sd, "Configuring encoder\n");
737 saa7127_write_inittab(sd, saa7127_init_config_common);
738 saa7127_set_std(sd, V4L2_STD_NTSC);
739 saa7127_set_output_type(sd, SAA7127_OUTPUT_TYPE_BOTH);
740 saa7127_set_vps(sd, &vbi);
741 saa7127_set_wss(sd, &vbi);
742 saa7127_set_cc(sd, &vbi);
743 saa7127_set_xds(sd, &vbi);
744 if (test_image == 1)
745 /* The Encoder has an internal Colorbar generator */
746 /* This can be used for debugging */
747 saa7127_set_input_type(sd, SAA7127_INPUT_TYPE_TEST_IMAGE);
748 else
749 saa7127_set_input_type(sd, SAA7127_INPUT_TYPE_NORMAL);
750 saa7127_set_video_enable(sd, 1);
751
752 if (id->driver_data) { /* Chip type is already known */ 743 if (id->driver_data) { /* Chip type is already known */
753 state->ident = id->driver_data; 744 state->ident = id->driver_data;
754 } else { /* Needs detection */ 745 } else { /* Needs detection */
@@ -770,6 +761,23 @@ static int saa7127_probe(struct i2c_client *client,
770 761
771 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, 762 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
772 client->addr << 1, client->adapter->name); 763 client->addr << 1, client->adapter->name);
764
765 v4l2_dbg(1, debug, sd, "Configuring encoder\n");
766 saa7127_write_inittab(sd, saa7127_init_config_common);
767 saa7127_set_std(sd, V4L2_STD_NTSC);
768 saa7127_set_output_type(sd, SAA7127_OUTPUT_TYPE_BOTH);
769 saa7127_set_vps(sd, &vbi);
770 saa7127_set_wss(sd, &vbi);
771 saa7127_set_cc(sd, &vbi);
772 saa7127_set_xds(sd, &vbi);
773 if (test_image == 1)
774 /* The Encoder has an internal Colorbar generator */
775 /* This can be used for debugging */
776 saa7127_set_input_type(sd, SAA7127_INPUT_TYPE_TEST_IMAGE);
777 else
778 saa7127_set_input_type(sd, SAA7127_INPUT_TYPE_NORMAL);
779 saa7127_set_video_enable(sd, 1);
780
773 if (state->ident == V4L2_IDENT_SAA7129) 781 if (state->ident == V4L2_IDENT_SAA7129)
774 saa7127_write_inittab(sd, saa7129_init_config_extra); 782 saa7127_write_inittab(sd, saa7129_init_config_extra);
775 return 0; 783 return 0;
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index 26194a0ce927..c750d3dd57d2 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -1089,7 +1089,11 @@ static int saa7134_alsa_init(void)
1089 1089
1090 list_for_each(list,&saa7134_devlist) { 1090 list_for_each(list,&saa7134_devlist) {
1091 dev = list_entry(list, struct saa7134_dev, devlist); 1091 dev = list_entry(list, struct saa7134_dev, devlist);
1092 alsa_device_init(dev); 1092 if (dev->pci->device == PCI_DEVICE_ID_PHILIPS_SAA7130)
1093 printk(KERN_INFO "%s/alsa: %s doesn't support digital audio\n",
1094 dev->name, saa7134_boards[dev->board].name);
1095 else
1096 alsa_device_init(dev);
1093 } 1097 }
1094 1098
1095 if (dev == NULL) 1099 if (dev == NULL)
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index dfbe08a9ad9b..99221d726edb 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -660,6 +660,10 @@ static int saa7134_hwinit1(struct saa7134_dev *dev)
660 660
661 saa_writel(SAA7134_IRQ1, 0); 661 saa_writel(SAA7134_IRQ1, 0);
662 saa_writel(SAA7134_IRQ2, 0); 662 saa_writel(SAA7134_IRQ2, 0);
663
664 /* Clear any stale IRQ reports */
665 saa_writel(SAA7134_IRQ_REPORT, saa_readl(SAA7134_IRQ_REPORT));
666
663 mutex_init(&dev->lock); 667 mutex_init(&dev->lock);
664 spin_lock_init(&dev->slock); 668 spin_lock_init(&dev->slock);
665 669
diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c
index 454ad1dd7507..88c5e942f751 100644
--- a/drivers/media/video/saa717x.c
+++ b/drivers/media/video/saa717x.c
@@ -30,7 +30,6 @@
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 */ 31 */
32 32
33#include <linux/version.h>
34#include <linux/module.h> 33#include <linux/module.h>
35#include <linux/kernel.h> 34#include <linux/kernel.h>
36#include <linux/sched.h> 35#include <linux/sched.h>
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index 56f0c0eb500f..00c6cbe06ab0 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -242,7 +242,7 @@ static int tda9875_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
242static int tda9875_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) 242static int tda9875_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
243{ 243{
244 struct tda9875 *t = to_state(sd); 244 struct tda9875 *t = to_state(sd);
245 int chvol=0, volume, balance, left, right; 245 int chvol = 0, volume = 0, balance = 0, left, right;
246 246
247 switch (ctrl->id) { 247 switch (ctrl->id) {
248 case V4L2_CID_AUDIO_VOLUME: 248 case V4L2_CID_AUDIO_VOLUME:
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 3b0b84c2e451..78277abb733b 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -427,6 +427,9 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
427 const char *t_fmt_name2[8] = { " none", "", "", "", "", "", "", "" }; 427 const char *t_fmt_name2[8] = { " none", "", "", "", "", "", "", "" };
428 428
429 memset(tvee, 0, sizeof(*tvee)); 429 memset(tvee, 0, sizeof(*tvee));
430 tvee->tuner_type = TUNER_ABSENT;
431 tvee->tuner2_type = TUNER_ABSENT;
432
430 done = len = beenhere = 0; 433 done = len = beenhere = 0;
431 434
432 /* Different eeprom start offsets for em28xx, cx2388x and cx23418 */ 435 /* Different eeprom start offsets for em28xx, cx2388x and cx23418 */
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
index ac9aa40d09f6..8e23aa53c29a 100644
--- a/drivers/media/video/tvp514x.c
+++ b/drivers/media/video/tvp514x.c
@@ -1401,7 +1401,7 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id)
1401 1401
1402 decoder->pdata = client->dev.platform_data; 1402 decoder->pdata = client->dev.platform_data;
1403 if (!decoder->pdata) { 1403 if (!decoder->pdata) {
1404 v4l_err(client, "No platform data\n!!"); 1404 v4l_err(client, "No platform data!!\n");
1405 return -ENODEV; 1405 return -ENODEV;
1406 } 1406 }
1407 /* 1407 /*
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c
index 4f16effb530f..f4522bb08916 100644
--- a/drivers/media/video/upd64031a.c
+++ b/drivers/media/video/upd64031a.c
@@ -21,7 +21,6 @@
21 */ 21 */
22 22
23 23
24#include <linux/version.h>
25#include <linux/module.h> 24#include <linux/module.h>
26#include <linux/kernel.h> 25#include <linux/kernel.h>
27#include <linux/i2c.h> 26#include <linux/i2c.h>
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c
index 4b712f69d1b7..a5fb74bf2407 100644
--- a/drivers/media/video/upd64083.c
+++ b/drivers/media/video/upd64083.c
@@ -21,7 +21,6 @@
21 * 02110-1301, USA. 21 * 02110-1301, USA.
22 */ 22 */
23 23
24#include <linux/version.h>
25#include <linux/module.h> 24#include <linux/module.h>
26#include <linux/kernel.h> 25#include <linux/kernel.h>
27#include <linux/i2c.h> 26#include <linux/i2c.h>
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c
index 9907b9aff2b9..6b66ae4f430f 100644
--- a/drivers/media/video/usbvision/usbvision-i2c.c
+++ b/drivers/media/video/usbvision/usbvision-i2c.c
@@ -157,7 +157,7 @@ usbvision_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
157 struct i2c_msg *pmsg; 157 struct i2c_msg *pmsg;
158 struct usb_usbvision *usbvision; 158 struct usb_usbvision *usbvision;
159 int i, ret; 159 int i, ret;
160 unsigned char addr; 160 unsigned char addr = 0;
161 161
162 usbvision = (struct usb_usbvision *)i2c_get_adapdata(i2c_adap); 162 usbvision = (struct usb_usbvision *)i2c_get_adapdata(i2c_adap);
163 163
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index 2208165aa6f0..d2576f6391c0 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_ctrl.c -- USB Video Class driver - Controls 2 * uvc_ctrl.c -- USB Video Class driver - Controls
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/version.h>
16#include <linux/list.h> 15#include <linux/list.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/uaccess.h> 17#include <linux/uaccess.h>
@@ -29,7 +28,7 @@
29#define UVC_CTRL_DATA_BACKUP 1 28#define UVC_CTRL_DATA_BACKUP 1
30 29
31/* ------------------------------------------------------------------------ 30/* ------------------------------------------------------------------------
32 * Control, formats, ... 31 * Controls
33 */ 32 */
34 33
35static struct uvc_control_info uvc_ctrls[] = { 34static struct uvc_control_info uvc_ctrls[] = {
@@ -635,7 +634,7 @@ static __s32 uvc_get_le_value(struct uvc_control_mapping *mapping,
635 mask = (1 << bits) - 1; 634 mask = (1 << bits) - 1;
636 } 635 }
637 636
638 /* Sign-extend the value if needed */ 637 /* Sign-extend the value if needed. */
639 if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED) 638 if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED)
640 value |= -(value & (1 << (mapping->size - 1))); 639 value |= -(value & (1 << (mapping->size - 1)));
641 640
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index 89d8bd10a852..b12873265cc5 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_driver.c -- USB Video Class driver 2 * uvc_driver.c -- USB Video Class driver
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -24,7 +24,6 @@
24 */ 24 */
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/version.h>
28#include <linux/list.h> 27#include <linux/list.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/usb.h> 29#include <linux/usb.h>
@@ -49,7 +48,7 @@ static unsigned int uvc_quirks_param;
49unsigned int uvc_trace_param; 48unsigned int uvc_trace_param;
50 49
51/* ------------------------------------------------------------------------ 50/* ------------------------------------------------------------------------
52 * Control, formats, ... 51 * Video formats
53 */ 52 */
54 53
55static struct uvc_format_desc uvc_fmts[] = { 54static struct uvc_format_desc uvc_fmts[] = {
@@ -474,7 +473,7 @@ static int uvc_parse_format(struct uvc_device *dev,
474 473
475 /* Several UVC chipsets screw up dwMaxVideoFrameBufferSize 474 /* Several UVC chipsets screw up dwMaxVideoFrameBufferSize
476 * completely. Observed behaviours range from setting the 475 * completely. Observed behaviours range from setting the
477 * value to 1.1x the actual frame size of hardwiring the 476 * value to 1.1x the actual frame size to hardwiring the
478 * 16 low bits to 0. This results in a higher than necessary 477 * 16 low bits to 0. This results in a higher than necessary
479 * memory usage as well as a wrong image size information. For 478 * memory usage as well as a wrong image size information. For
480 * uncompressed formats this can be fixed by computing the 479 * uncompressed formats this can be fixed by computing the
@@ -487,7 +486,7 @@ static int uvc_parse_format(struct uvc_device *dev,
487 /* Some bogus devices report dwMinFrameInterval equal to 486 /* Some bogus devices report dwMinFrameInterval equal to
488 * dwMaxFrameInterval and have dwFrameIntervalStep set to 487 * dwMaxFrameInterval and have dwFrameIntervalStep set to
489 * zero. Setting all null intervals to 1 fixes the problem and 488 * zero. Setting all null intervals to 1 fixes the problem and
490 * some other divisions by zero which could happen. 489 * some other divisions by zero that could happen.
491 */ 490 */
492 for (i = 0; i < n; ++i) { 491 for (i = 0; i < n; ++i) {
493 interval = get_unaligned_le32(&buffer[26+4*i]); 492 interval = get_unaligned_le32(&buffer[26+4*i]);
@@ -1200,13 +1199,13 @@ static void uvc_unregister_video(struct uvc_device *dev)
1200 * Scan the UVC descriptors to locate a chain starting at an Output Terminal 1199 * Scan the UVC descriptors to locate a chain starting at an Output Terminal
1201 * and containing the following units: 1200 * and containing the following units:
1202 * 1201 *
1203 * - a USB Streaming Output Terminal 1202 * - one Output Terminal (USB Streaming or Display)
1204 * - zero or one Processing Unit 1203 * - zero or one Processing Unit
1205 * - zero, one or mode single-input Selector Units 1204 * - zero, one or mode single-input Selector Units
1206 * - zero or one multiple-input Selector Units, provided all inputs are 1205 * - zero or one multiple-input Selector Units, provided all inputs are
1207 * connected to input terminals 1206 * connected to input terminals
1208 * - zero, one or mode single-input Extension Units 1207 * - zero, one or mode single-input Extension Units
1209 * - one Camera Input Terminal, or one or more External terminals. 1208 * - one or more Input Terminals (Camera, External or USB Streaming)
1210 * 1209 *
1211 * A side forward scan is made on each detected entity to check for additional 1210 * A side forward scan is made on each detected entity to check for additional
1212 * extension units. 1211 * extension units.
@@ -1531,10 +1530,6 @@ static int uvc_register_video(struct uvc_device *dev)
1531 1530
1532 /* Set the driver data before calling video_register_device, otherwise 1531 /* Set the driver data before calling video_register_device, otherwise
1533 * uvc_v4l2_open might race us. 1532 * uvc_v4l2_open might race us.
1534 *
1535 * FIXME: usb_set_intfdata hasn't been called so far. Is that a
1536 * problem ? Does any function which could be called here get
1537 * a pointer to the usb_interface ?
1538 */ 1533 */
1539 dev->video.vdev = vdev; 1534 dev->video.vdev = vdev;
1540 video_set_drvdata(vdev, &dev->video); 1535 video_set_drvdata(vdev, &dev->video);
@@ -1569,7 +1564,7 @@ void uvc_delete(struct kref *kref)
1569 struct uvc_device *dev = container_of(kref, struct uvc_device, kref); 1564 struct uvc_device *dev = container_of(kref, struct uvc_device, kref);
1570 struct list_head *p, *n; 1565 struct list_head *p, *n;
1571 1566
1572 /* Unregister the video device */ 1567 /* Unregister the video device. */
1573 uvc_unregister_video(dev); 1568 uvc_unregister_video(dev);
1574 usb_put_intf(dev->intf); 1569 usb_put_intf(dev->intf);
1575 usb_put_dev(dev->udev); 1570 usb_put_dev(dev->udev);
@@ -1612,7 +1607,7 @@ static int uvc_probe(struct usb_interface *intf,
1612 uvc_trace(UVC_TRACE_PROBE, "Probing generic UVC device %s\n", 1607 uvc_trace(UVC_TRACE_PROBE, "Probing generic UVC device %s\n",
1613 udev->devpath); 1608 udev->devpath);
1614 1609
1615 /* Allocate memory for the device and initialize it */ 1610 /* Allocate memory for the device and initialize it. */
1616 if ((dev = kzalloc(sizeof *dev, GFP_KERNEL)) == NULL) 1611 if ((dev = kzalloc(sizeof *dev, GFP_KERNEL)) == NULL)
1617 return -ENOMEM; 1612 return -ENOMEM;
1618 1613
@@ -1633,14 +1628,14 @@ static int uvc_probe(struct usb_interface *intf,
1633 le16_to_cpu(udev->descriptor.idVendor), 1628 le16_to_cpu(udev->descriptor.idVendor),
1634 le16_to_cpu(udev->descriptor.idProduct)); 1629 le16_to_cpu(udev->descriptor.idProduct));
1635 1630
1636 /* Parse the Video Class control descriptor */ 1631 /* Parse the Video Class control descriptor. */
1637 if (uvc_parse_control(dev) < 0) { 1632 if (uvc_parse_control(dev) < 0) {
1638 uvc_trace(UVC_TRACE_PROBE, "Unable to parse UVC " 1633 uvc_trace(UVC_TRACE_PROBE, "Unable to parse UVC "
1639 "descriptors.\n"); 1634 "descriptors.\n");
1640 goto error; 1635 goto error;
1641 } 1636 }
1642 1637
1643 uvc_printk(KERN_INFO, "Found UVC %u.%02u device %s (%04x:%04x)\n", 1638 uvc_printk(KERN_INFO, "Found UVC %u.%02x device %s (%04x:%04x)\n",
1644 dev->uvc_version >> 8, dev->uvc_version & 0xff, 1639 dev->uvc_version >> 8, dev->uvc_version & 0xff,
1645 udev->product ? udev->product : "<unnamed>", 1640 udev->product ? udev->product : "<unnamed>",
1646 le16_to_cpu(udev->descriptor.idVendor), 1641 le16_to_cpu(udev->descriptor.idVendor),
@@ -1653,18 +1648,18 @@ static int uvc_probe(struct usb_interface *intf,
1653 "linux-uvc-devel mailing list.\n"); 1648 "linux-uvc-devel mailing list.\n");
1654 } 1649 }
1655 1650
1656 /* Initialize controls */ 1651 /* Initialize controls. */
1657 if (uvc_ctrl_init_device(dev) < 0) 1652 if (uvc_ctrl_init_device(dev) < 0)
1658 goto error; 1653 goto error;
1659 1654
1660 /* Register the video devices */ 1655 /* Register the video devices. */
1661 if (uvc_register_video(dev) < 0) 1656 if (uvc_register_video(dev) < 0)
1662 goto error; 1657 goto error;
1663 1658
1664 /* Save our data pointer in the interface data */ 1659 /* Save our data pointer in the interface data. */
1665 usb_set_intfdata(intf, dev); 1660 usb_set_intfdata(intf, dev);
1666 1661
1667 /* Initialize the interrupt URB */ 1662 /* Initialize the interrupt URB. */
1668 if ((ret = uvc_status_init(dev)) < 0) { 1663 if ((ret = uvc_status_init(dev)) < 0) {
1669 uvc_printk(KERN_INFO, "Unable to initialize the status " 1664 uvc_printk(KERN_INFO, "Unable to initialize the status "
1670 "endpoint (%d), status interrupt will not be " 1665 "endpoint (%d), status interrupt will not be "
@@ -1839,24 +1834,24 @@ static struct usb_device_id uvc_ids[] = {
1839 .bInterfaceSubClass = 1, 1834 .bInterfaceSubClass = 1,
1840 .bInterfaceProtocol = 0 }, 1835 .bInterfaceProtocol = 0 },
1841 /* Apple Built-In iSight */ 1836 /* Apple Built-In iSight */
1842 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 1837 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1843 | USB_DEVICE_ID_MATCH_INT_INFO, 1838 | USB_DEVICE_ID_MATCH_INT_INFO,
1844 .idVendor = 0x05ac, 1839 .idVendor = 0x05ac,
1845 .idProduct = 0x8501, 1840 .idProduct = 0x8501,
1846 .bInterfaceClass = USB_CLASS_VIDEO, 1841 .bInterfaceClass = USB_CLASS_VIDEO,
1847 .bInterfaceSubClass = 1, 1842 .bInterfaceSubClass = 1,
1848 .bInterfaceProtocol = 0, 1843 .bInterfaceProtocol = 0,
1849 .driver_info = UVC_QUIRK_PROBE_MINMAX 1844 .driver_info = UVC_QUIRK_PROBE_MINMAX
1850 | UVC_QUIRK_BUILTIN_ISIGHT }, 1845 | UVC_QUIRK_BUILTIN_ISIGHT },
1851 /* Genesys Logic USB 2.0 PC Camera */ 1846 /* Genesys Logic USB 2.0 PC Camera */
1852 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 1847 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1853 | USB_DEVICE_ID_MATCH_INT_INFO, 1848 | USB_DEVICE_ID_MATCH_INT_INFO,
1854 .idVendor = 0x05e3, 1849 .idVendor = 0x05e3,
1855 .idProduct = 0x0505, 1850 .idProduct = 0x0505,
1856 .bInterfaceClass = USB_CLASS_VIDEO, 1851 .bInterfaceClass = USB_CLASS_VIDEO,
1857 .bInterfaceSubClass = 1, 1852 .bInterfaceSubClass = 1,
1858 .bInterfaceProtocol = 0, 1853 .bInterfaceProtocol = 0,
1859 .driver_info = UVC_QUIRK_STREAM_NO_FID }, 1854 .driver_info = UVC_QUIRK_STREAM_NO_FID },
1860 /* MT6227 */ 1855 /* MT6227 */
1861 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 1856 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1862 | USB_DEVICE_ID_MATCH_INT_INFO, 1857 | USB_DEVICE_ID_MATCH_INT_INFO,
diff --git a/drivers/media/video/uvc/uvc_isight.c b/drivers/media/video/uvc/uvc_isight.c
index 37bdefdbead5..436f462685a0 100644
--- a/drivers/media/video/uvc/uvc_isight.c
+++ b/drivers/media/video/uvc/uvc_isight.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * Copyright (C) 2006-2007 4 * Copyright (C) 2006-2007
5 * Ivan N. Zlatev <contact@i-nz.net> 5 * Ivan N. Zlatev <contact@i-nz.net>
6 * Copyright (C) 2008-2009
7 * Laurent Pinchart <laurent.pinchart@skynet.be>
6 * 8 *
7 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c
index 42546342e97d..0155752e4a5a 100644
--- a/drivers/media/video/uvc/uvc_queue.c
+++ b/drivers/media/video/uvc/uvc_queue.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_queue.c -- USB Video Class driver - Buffers management 2 * uvc_queue.c -- USB Video Class driver - Buffers management
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/version.h>
16#include <linux/mm.h> 15#include <linux/mm.h>
17#include <linux/list.h> 16#include <linux/list.h>
18#include <linux/module.h> 17#include <linux/module.h>
@@ -37,22 +36,22 @@
37 * to user space will return -EBUSY. 36 * to user space will return -EBUSY.
38 * 37 *
39 * Video buffers are managed using two queues. However, unlike most USB video 38 * Video buffers are managed using two queues. However, unlike most USB video
40 * drivers which use an in queue and an out queue, we use a main queue which 39 * drivers that use an in queue and an out queue, we use a main queue to hold
41 * holds all queued buffers (both 'empty' and 'done' buffers), and an irq 40 * all queued buffers (both 'empty' and 'done' buffers), and an irq queue to
42 * queue which holds empty buffers. This design (copied from video-buf) 41 * hold empty buffers. This design (copied from video-buf) minimizes locking
43 * minimizes locking in interrupt, as only one queue is shared between 42 * in interrupt, as only one queue is shared between interrupt and user
44 * interrupt and user contexts. 43 * contexts.
45 * 44 *
46 * Use cases 45 * Use cases
47 * --------- 46 * ---------
48 * 47 *
49 * Unless stated otherwise, all operations which modify the irq buffers queue 48 * Unless stated otherwise, all operations that modify the irq buffers queue
50 * are protected by the irq spinlock. 49 * are protected by the irq spinlock.
51 * 50 *
52 * 1. The user queues the buffers, starts streaming and dequeues a buffer. 51 * 1. The user queues the buffers, starts streaming and dequeues a buffer.
53 * 52 *
54 * The buffers are added to the main and irq queues. Both operations are 53 * The buffers are added to the main and irq queues. Both operations are
55 * protected by the queue lock, and the latert is protected by the irq 54 * protected by the queue lock, and the later is protected by the irq
56 * spinlock as well. 55 * spinlock as well.
57 * 56 *
58 * The completion handler fetches a buffer from the irq queue and fills it 57 * The completion handler fetches a buffer from the irq queue and fills it
@@ -60,7 +59,7 @@
60 * returns immediately. 59 * returns immediately.
61 * 60 *
62 * When the buffer is full, the completion handler removes it from the irq 61 * When the buffer is full, the completion handler removes it from the irq
63 * queue, marks it as ready (UVC_BUF_STATE_DONE) and wake its wait queue. 62 * queue, marks it as ready (UVC_BUF_STATE_DONE) and wakes its wait queue.
64 * At that point, any process waiting on the buffer will be woken up. If a 63 * At that point, any process waiting on the buffer will be woken up. If a
65 * process tries to dequeue a buffer after it has been marked ready, the 64 * process tries to dequeue a buffer after it has been marked ready, the
66 * dequeing will succeed immediately. 65 * dequeing will succeed immediately.
@@ -91,8 +90,8 @@ void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
91/* 90/*
92 * Allocate the video buffers. 91 * Allocate the video buffers.
93 * 92 *
94 * Pages are reserved to make sure they will not be swaped, as they will be 93 * Pages are reserved to make sure they will not be swapped, as they will be
95 * filled in URB completion handler. 94 * filled in the URB completion handler.
96 * 95 *
97 * Buffers will be individually mapped, so they must all be page aligned. 96 * Buffers will be individually mapped, so they must all be page aligned.
98 */ 97 */
@@ -210,8 +209,8 @@ int uvc_query_buffer(struct uvc_video_queue *queue,
210 __uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf); 209 __uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf);
211 210
212done: 211done:
213 mutex_unlock(&queue->mutex); 212 mutex_unlock(&queue->mutex);
214 return ret; 213 return ret;
215} 214}
216 215
217/* 216/*
@@ -236,7 +235,7 @@ int uvc_queue_buffer(struct uvc_video_queue *queue,
236 } 235 }
237 236
238 mutex_lock(&queue->mutex); 237 mutex_lock(&queue->mutex);
239 if (v4l2_buf->index >= queue->count) { 238 if (v4l2_buf->index >= queue->count) {
240 uvc_trace(UVC_TRACE_CAPTURE, "[E] Out of range index.\n"); 239 uvc_trace(UVC_TRACE_CAPTURE, "[E] Out of range index.\n");
241 ret = -EINVAL; 240 ret = -EINVAL;
242 goto done; 241 goto done;
@@ -429,7 +428,7 @@ done:
429 * Cancel the video buffers queue. 428 * Cancel the video buffers queue.
430 * 429 *
431 * Cancelling the queue marks all buffers on the irq queue as erroneous, 430 * Cancelling the queue marks all buffers on the irq queue as erroneous,
432 * wakes them up and remove them from the queue. 431 * wakes them up and removes them from the queue.
433 * 432 *
434 * If the disconnect parameter is set, further calls to uvc_queue_buffer will 433 * If the disconnect parameter is set, further calls to uvc_queue_buffer will
435 * fail with -ENODEV. 434 * fail with -ENODEV.
diff --git a/drivers/media/video/uvc/uvc_status.c b/drivers/media/video/uvc/uvc_status.c
index 5d60b264d59a..c1e4ae27c613 100644
--- a/drivers/media/video/uvc/uvc_status.c
+++ b/drivers/media/video/uvc/uvc_status.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_status.c -- USB Video Class driver - Status endpoint 2 * uvc_status.c -- USB Video Class driver - Status endpoint
3 * 3 *
4 * Copyright (C) 2007-2008 4 * Copyright (C) 2007-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/version.h>
16#include <linux/input.h> 15#include <linux/input.h>
17#include <linux/usb.h> 16#include <linux/usb.h>
18#include <linux/usb/input.h> 17#include <linux/usb/input.h>
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index fa150fff2c10..d681519d0c8a 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_v4l2.c -- USB Video Class driver - V4L2 API 2 * uvc_v4l2.c -- USB Video Class driver - V4L2 API
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -37,7 +37,7 @@
37 * must be grouped (for instance the Red Balance, Blue Balance and Do White 37 * must be grouped (for instance the Red Balance, Blue Balance and Do White
38 * Balance V4L2 controls use the White Balance Component UVC control) or 38 * Balance V4L2 controls use the White Balance Component UVC control) or
39 * otherwise translated. The approach we take here is to use a translation 39 * otherwise translated. The approach we take here is to use a translation
40 * table for the controls which can be mapped directly, and handle the others 40 * table for the controls that can be mapped directly, and handle the others
41 * manually. 41 * manually.
42 */ 42 */
43static int uvc_v4l2_query_menu(struct uvc_video_device *video, 43static int uvc_v4l2_query_menu(struct uvc_video_device *video,
@@ -189,7 +189,7 @@ static int uvc_v4l2_try_format(struct uvc_video_device *video,
189 probe->dwMaxVideoFrameSize = 189 probe->dwMaxVideoFrameSize =
190 video->streaming->ctrl.dwMaxVideoFrameSize; 190 video->streaming->ctrl.dwMaxVideoFrameSize;
191 191
192 /* Probe the device */ 192 /* Probe the device. */
193 if ((ret = uvc_probe_video(video, probe)) < 0) 193 if ((ret = uvc_probe_video(video, probe)) < 0)
194 goto done; 194 goto done;
195 195
@@ -354,11 +354,11 @@ static int uvc_v4l2_set_streamparm(struct uvc_video_device *video,
354 * 354 *
355 * Each open instance of a UVC device can either be in a privileged or 355 * Each open instance of a UVC device can either be in a privileged or
356 * unprivileged state. Only a single instance can be in a privileged state at 356 * unprivileged state. Only a single instance can be in a privileged state at
357 * a given time. Trying to perform an operation which requires privileges will 357 * a given time. Trying to perform an operation that requires privileges will
358 * automatically acquire the required privileges if possible, or return -EBUSY 358 * automatically acquire the required privileges if possible, or return -EBUSY
359 * otherwise. Privileges are dismissed when closing the instance. 359 * otherwise. Privileges are dismissed when closing the instance.
360 * 360 *
361 * Operations which require privileges are: 361 * Operations that require privileges are:
362 * 362 *
363 * - VIDIOC_S_INPUT 363 * - VIDIOC_S_INPUT
364 * - VIDIOC_S_PARM 364 * - VIDIOC_S_PARM
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index e7c31995527f..9bc4705be78d 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_video.c -- USB Video Class driver - Video handling 2 * uvc_video.c -- USB Video Class driver - Video handling
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/version.h>
16#include <linux/list.h> 15#include <linux/list.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/usb.h> 17#include <linux/usb.h>
@@ -115,7 +114,7 @@ static int uvc_get_video_ctrl(struct uvc_video_device *video,
115 ctrl->wCompQuality = le16_to_cpup((__le16 *)data); 114 ctrl->wCompQuality = le16_to_cpup((__le16 *)data);
116 ret = 0; 115 ret = 0;
117 goto out; 116 goto out;
118 } else if (query == GET_DEF && probe == 1) { 117 } else if (query == GET_DEF && probe == 1 && ret != size) {
119 /* Many cameras don't support the GET_DEF request on their 118 /* Many cameras don't support the GET_DEF request on their
120 * video probe control. Warn once and return, the caller will 119 * video probe control. Warn once and return, the caller will
121 * fall back to GET_CUR. 120 * fall back to GET_CUR.
@@ -160,7 +159,7 @@ static int uvc_get_video_ctrl(struct uvc_video_device *video,
160 } 159 }
161 160
162 /* Some broken devices return a null or wrong dwMaxVideoFrameSize. 161 /* Some broken devices return a null or wrong dwMaxVideoFrameSize.
163 * Try to get the value from the format and frame descriptor. 162 * Try to get the value from the format and frame descriptors.
164 */ 163 */
165 uvc_fixup_buffer_size(video, ctrl); 164 uvc_fixup_buffer_size(video, ctrl);
166 ret = 0; 165 ret = 0;
@@ -191,9 +190,6 @@ static int uvc_set_video_ctrl(struct uvc_video_device *video,
191 *(__le16 *)&data[12] = cpu_to_le16(ctrl->wCompQuality); 190 *(__le16 *)&data[12] = cpu_to_le16(ctrl->wCompQuality);
192 *(__le16 *)&data[14] = cpu_to_le16(ctrl->wCompWindowSize); 191 *(__le16 *)&data[14] = cpu_to_le16(ctrl->wCompWindowSize);
193 *(__le16 *)&data[16] = cpu_to_le16(ctrl->wDelay); 192 *(__le16 *)&data[16] = cpu_to_le16(ctrl->wDelay);
194 /* Note: Some of the fields below are not required for IN devices (see
195 * UVC spec, 4.3.1.1), but we still copy them in case support for OUT
196 * devices is added in the future. */
197 put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]); 193 put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
198 put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]); 194 put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
199 195
@@ -400,7 +396,7 @@ static int uvc_video_decode_start(struct uvc_video_device *video,
400 * 396 *
401 * Empty buffers (bytesused == 0) don't trigger end of frame detection 397 * Empty buffers (bytesused == 0) don't trigger end of frame detection
402 * as it doesn't make sense to return an empty buffer. This also 398 * as it doesn't make sense to return an empty buffer. This also
403 * avoids detecting and of frame conditions at FID toggling if the 399 * avoids detecting end of frame conditions at FID toggling if the
404 * previous payload had the EOF bit set. 400 * previous payload had the EOF bit set.
405 */ 401 */
406 if (fid != video->last_fid && buf->buf.bytesused != 0) { 402 if (fid != video->last_fid && buf->buf.bytesused != 0) {
@@ -453,6 +449,17 @@ static void uvc_video_decode_end(struct uvc_video_device *video,
453 } 449 }
454} 450}
455 451
452/* Video payload encoding is handled by uvc_video_encode_header() and
453 * uvc_video_encode_data(). Only bulk transfers are currently supported.
454 *
455 * uvc_video_encode_header is called at the start of a payload. It adds header
456 * data to the transfer buffer and returns the header size. As the only known
457 * UVC output device transfers a whole frame in a single payload, the EOF bit
458 * is always set in the header.
459 *
460 * uvc_video_encode_data is called for every URB and copies the data from the
461 * video buffer to the transfer buffer.
462 */
456static int uvc_video_encode_header(struct uvc_video_device *video, 463static int uvc_video_encode_header(struct uvc_video_device *video,
457 struct uvc_buffer *buf, __u8 *data, int len) 464 struct uvc_buffer *buf, __u8 *data, int len)
458{ 465{
@@ -953,7 +960,7 @@ int uvc_video_suspend(struct uvc_video_device *video)
953} 960}
954 961
955/* 962/*
956 * Reconfigure the video interface and restart streaming if it was enable 963 * Reconfigure the video interface and restart streaming if it was enabled
957 * before suspend. 964 * before suspend.
958 * 965 *
959 * If an error occurs, disable the video queue. This will wake all pending 966 * If an error occurs, disable the video queue. This will wake all pending
@@ -985,8 +992,8 @@ int uvc_video_resume(struct uvc_video_device *video)
985 */ 992 */
986 993
987/* 994/*
988 * Initialize the UVC video device by retrieving the default format and 995 * Initialize the UVC video device by switching to alternate setting 0 and
989 * committing it. 996 * retrieve the default format.
990 * 997 *
991 * Some cameras (namely the Fuji Finepix) set the format and frame 998 * Some cameras (namely the Fuji Finepix) set the format and frame
992 * indexes to zero. The UVC standard doesn't clearly make this a spec 999 * indexes to zero. The UVC standard doesn't clearly make this a spec
@@ -1014,7 +1021,7 @@ int uvc_video_init(struct uvc_video_device *video)
1014 */ 1021 */
1015 usb_set_interface(video->dev->udev, video->streaming->intfnum, 0); 1022 usb_set_interface(video->dev->udev, video->streaming->intfnum, 0);
1016 1023
1017 /* Some webcams don't suport GET_DEF request on the probe control. We 1024 /* Some webcams don't suport GET_DEF requests on the probe control. We
1018 * fall back to GET_CUR if GET_DEF fails. 1025 * fall back to GET_CUR if GET_DEF fails.
1019 */ 1026 */
1020 if ((ret = uvc_get_video_ctrl(video, probe, 1, GET_DEF)) < 0 && 1027 if ((ret = uvc_get_video_ctrl(video, probe, 1, GET_DEF)) < 0 &&
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
index bcf4361dc1bc..027947ea9b6e 100644
--- a/drivers/media/video/uvc/uvcvideo.h
+++ b/drivers/media/video/uvc/uvcvideo.h
@@ -72,149 +72,149 @@ struct uvc_xu_control {
72 * UVC constants 72 * UVC constants
73 */ 73 */
74 74
75#define SC_UNDEFINED 0x00 75#define SC_UNDEFINED 0x00
76#define SC_VIDEOCONTROL 0x01 76#define SC_VIDEOCONTROL 0x01
77#define SC_VIDEOSTREAMING 0x02 77#define SC_VIDEOSTREAMING 0x02
78#define SC_VIDEO_INTERFACE_COLLECTION 0x03 78#define SC_VIDEO_INTERFACE_COLLECTION 0x03
79 79
80#define PC_PROTOCOL_UNDEFINED 0x00 80#define PC_PROTOCOL_UNDEFINED 0x00
81 81
82#define CS_UNDEFINED 0x20 82#define CS_UNDEFINED 0x20
83#define CS_DEVICE 0x21 83#define CS_DEVICE 0x21
84#define CS_CONFIGURATION 0x22 84#define CS_CONFIGURATION 0x22
85#define CS_STRING 0x23 85#define CS_STRING 0x23
86#define CS_INTERFACE 0x24 86#define CS_INTERFACE 0x24
87#define CS_ENDPOINT 0x25 87#define CS_ENDPOINT 0x25
88 88
89/* VideoControl class specific interface descriptor */ 89/* VideoControl class specific interface descriptor */
90#define VC_DESCRIPTOR_UNDEFINED 0x00 90#define VC_DESCRIPTOR_UNDEFINED 0x00
91#define VC_HEADER 0x01 91#define VC_HEADER 0x01
92#define VC_INPUT_TERMINAL 0x02 92#define VC_INPUT_TERMINAL 0x02
93#define VC_OUTPUT_TERMINAL 0x03 93#define VC_OUTPUT_TERMINAL 0x03
94#define VC_SELECTOR_UNIT 0x04 94#define VC_SELECTOR_UNIT 0x04
95#define VC_PROCESSING_UNIT 0x05 95#define VC_PROCESSING_UNIT 0x05
96#define VC_EXTENSION_UNIT 0x06 96#define VC_EXTENSION_UNIT 0x06
97 97
98/* VideoStreaming class specific interface descriptor */ 98/* VideoStreaming class specific interface descriptor */
99#define VS_UNDEFINED 0x00 99#define VS_UNDEFINED 0x00
100#define VS_INPUT_HEADER 0x01 100#define VS_INPUT_HEADER 0x01
101#define VS_OUTPUT_HEADER 0x02 101#define VS_OUTPUT_HEADER 0x02
102#define VS_STILL_IMAGE_FRAME 0x03 102#define VS_STILL_IMAGE_FRAME 0x03
103#define VS_FORMAT_UNCOMPRESSED 0x04 103#define VS_FORMAT_UNCOMPRESSED 0x04
104#define VS_FRAME_UNCOMPRESSED 0x05 104#define VS_FRAME_UNCOMPRESSED 0x05
105#define VS_FORMAT_MJPEG 0x06 105#define VS_FORMAT_MJPEG 0x06
106#define VS_FRAME_MJPEG 0x07 106#define VS_FRAME_MJPEG 0x07
107#define VS_FORMAT_MPEG2TS 0x0a 107#define VS_FORMAT_MPEG2TS 0x0a
108#define VS_FORMAT_DV 0x0c 108#define VS_FORMAT_DV 0x0c
109#define VS_COLORFORMAT 0x0d 109#define VS_COLORFORMAT 0x0d
110#define VS_FORMAT_FRAME_BASED 0x10 110#define VS_FORMAT_FRAME_BASED 0x10
111#define VS_FRAME_FRAME_BASED 0x11 111#define VS_FRAME_FRAME_BASED 0x11
112#define VS_FORMAT_STREAM_BASED 0x12 112#define VS_FORMAT_STREAM_BASED 0x12
113 113
114/* Endpoint type */ 114/* Endpoint type */
115#define EP_UNDEFINED 0x00 115#define EP_UNDEFINED 0x00
116#define EP_GENERAL 0x01 116#define EP_GENERAL 0x01
117#define EP_ENDPOINT 0x02 117#define EP_ENDPOINT 0x02
118#define EP_INTERRUPT 0x03 118#define EP_INTERRUPT 0x03
119 119
120/* Request codes */ 120/* Request codes */
121#define RC_UNDEFINED 0x00 121#define RC_UNDEFINED 0x00
122#define SET_CUR 0x01 122#define SET_CUR 0x01
123#define GET_CUR 0x81 123#define GET_CUR 0x81
124#define GET_MIN 0x82 124#define GET_MIN 0x82
125#define GET_MAX 0x83 125#define GET_MAX 0x83
126#define GET_RES 0x84 126#define GET_RES 0x84
127#define GET_LEN 0x85 127#define GET_LEN 0x85
128#define GET_INFO 0x86 128#define GET_INFO 0x86
129#define GET_DEF 0x87 129#define GET_DEF 0x87
130 130
131/* VideoControl interface controls */ 131/* VideoControl interface controls */
132#define VC_CONTROL_UNDEFINED 0x00 132#define VC_CONTROL_UNDEFINED 0x00
133#define VC_VIDEO_POWER_MODE_CONTROL 0x01 133#define VC_VIDEO_POWER_MODE_CONTROL 0x01
134#define VC_REQUEST_ERROR_CODE_CONTROL 0x02 134#define VC_REQUEST_ERROR_CODE_CONTROL 0x02
135 135
136/* Terminal controls */ 136/* Terminal controls */
137#define TE_CONTROL_UNDEFINED 0x00 137#define TE_CONTROL_UNDEFINED 0x00
138 138
139/* Selector Unit controls */ 139/* Selector Unit controls */
140#define SU_CONTROL_UNDEFINED 0x00 140#define SU_CONTROL_UNDEFINED 0x00
141#define SU_INPUT_SELECT_CONTROL 0x01 141#define SU_INPUT_SELECT_CONTROL 0x01
142 142
143/* Camera Terminal controls */ 143/* Camera Terminal controls */
144#define CT_CONTROL_UNDEFINED 0x00 144#define CT_CONTROL_UNDEFINED 0x00
145#define CT_SCANNING_MODE_CONTROL 0x01 145#define CT_SCANNING_MODE_CONTROL 0x01
146#define CT_AE_MODE_CONTROL 0x02 146#define CT_AE_MODE_CONTROL 0x02
147#define CT_AE_PRIORITY_CONTROL 0x03 147#define CT_AE_PRIORITY_CONTROL 0x03
148#define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04 148#define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
149#define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05 149#define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
150#define CT_FOCUS_ABSOLUTE_CONTROL 0x06 150#define CT_FOCUS_ABSOLUTE_CONTROL 0x06
151#define CT_FOCUS_RELATIVE_CONTROL 0x07 151#define CT_FOCUS_RELATIVE_CONTROL 0x07
152#define CT_FOCUS_AUTO_CONTROL 0x08 152#define CT_FOCUS_AUTO_CONTROL 0x08
153#define CT_IRIS_ABSOLUTE_CONTROL 0x09 153#define CT_IRIS_ABSOLUTE_CONTROL 0x09
154#define CT_IRIS_RELATIVE_CONTROL 0x0a 154#define CT_IRIS_RELATIVE_CONTROL 0x0a
155#define CT_ZOOM_ABSOLUTE_CONTROL 0x0b 155#define CT_ZOOM_ABSOLUTE_CONTROL 0x0b
156#define CT_ZOOM_RELATIVE_CONTROL 0x0c 156#define CT_ZOOM_RELATIVE_CONTROL 0x0c
157#define CT_PANTILT_ABSOLUTE_CONTROL 0x0d 157#define CT_PANTILT_ABSOLUTE_CONTROL 0x0d
158#define CT_PANTILT_RELATIVE_CONTROL 0x0e 158#define CT_PANTILT_RELATIVE_CONTROL 0x0e
159#define CT_ROLL_ABSOLUTE_CONTROL 0x0f 159#define CT_ROLL_ABSOLUTE_CONTROL 0x0f
160#define CT_ROLL_RELATIVE_CONTROL 0x10 160#define CT_ROLL_RELATIVE_CONTROL 0x10
161#define CT_PRIVACY_CONTROL 0x11 161#define CT_PRIVACY_CONTROL 0x11
162 162
163/* Processing Unit controls */ 163/* Processing Unit controls */
164#define PU_CONTROL_UNDEFINED 0x00 164#define PU_CONTROL_UNDEFINED 0x00
165#define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01 165#define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
166#define PU_BRIGHTNESS_CONTROL 0x02 166#define PU_BRIGHTNESS_CONTROL 0x02
167#define PU_CONTRAST_CONTROL 0x03 167#define PU_CONTRAST_CONTROL 0x03
168#define PU_GAIN_CONTROL 0x04 168#define PU_GAIN_CONTROL 0x04
169#define PU_POWER_LINE_FREQUENCY_CONTROL 0x05 169#define PU_POWER_LINE_FREQUENCY_CONTROL 0x05
170#define PU_HUE_CONTROL 0x06 170#define PU_HUE_CONTROL 0x06
171#define PU_SATURATION_CONTROL 0x07 171#define PU_SATURATION_CONTROL 0x07
172#define PU_SHARPNESS_CONTROL 0x08 172#define PU_SHARPNESS_CONTROL 0x08
173#define PU_GAMMA_CONTROL 0x09 173#define PU_GAMMA_CONTROL 0x09
174#define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a 174#define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
175#define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b 175#define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
176#define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c 176#define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
177#define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d 177#define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
178#define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e 178#define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
179#define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f 179#define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
180#define PU_HUE_AUTO_CONTROL 0x10 180#define PU_HUE_AUTO_CONTROL 0x10
181#define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11 181#define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
182#define PU_ANALOG_LOCK_STATUS_CONTROL 0x12 182#define PU_ANALOG_LOCK_STATUS_CONTROL 0x12
183 183
184#define LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01 184#define LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01
185#define LXU_MOTOR_PANTILT_RESET_CONTROL 0x02 185#define LXU_MOTOR_PANTILT_RESET_CONTROL 0x02
186#define LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03 186#define LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03
187 187
188/* VideoStreaming interface controls */ 188/* VideoStreaming interface controls */
189#define VS_CONTROL_UNDEFINED 0x00 189#define VS_CONTROL_UNDEFINED 0x00
190#define VS_PROBE_CONTROL 0x01 190#define VS_PROBE_CONTROL 0x01
191#define VS_COMMIT_CONTROL 0x02 191#define VS_COMMIT_CONTROL 0x02
192#define VS_STILL_PROBE_CONTROL 0x03 192#define VS_STILL_PROBE_CONTROL 0x03
193#define VS_STILL_COMMIT_CONTROL 0x04 193#define VS_STILL_COMMIT_CONTROL 0x04
194#define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05 194#define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
195#define VS_STREAM_ERROR_CODE_CONTROL 0x06 195#define VS_STREAM_ERROR_CODE_CONTROL 0x06
196#define VS_GENERATE_KEY_FRAME_CONTROL 0x07 196#define VS_GENERATE_KEY_FRAME_CONTROL 0x07
197#define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08 197#define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
198#define VS_SYNC_DELAY_CONTROL 0x09 198#define VS_SYNC_DELAY_CONTROL 0x09
199 199
200#define TT_VENDOR_SPECIFIC 0x0100 200#define TT_VENDOR_SPECIFIC 0x0100
201#define TT_STREAMING 0x0101 201#define TT_STREAMING 0x0101
202 202
203/* Input Terminal types */ 203/* Input Terminal types */
204#define ITT_VENDOR_SPECIFIC 0x0200 204#define ITT_VENDOR_SPECIFIC 0x0200
205#define ITT_CAMERA 0x0201 205#define ITT_CAMERA 0x0201
206#define ITT_MEDIA_TRANSPORT_INPUT 0x0202 206#define ITT_MEDIA_TRANSPORT_INPUT 0x0202
207 207
208/* Output Terminal types */ 208/* Output Terminal types */
209#define OTT_VENDOR_SPECIFIC 0x0300 209#define OTT_VENDOR_SPECIFIC 0x0300
210#define OTT_DISPLAY 0x0301 210#define OTT_DISPLAY 0x0301
211#define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302 211#define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
212 212
213/* External Terminal types */ 213/* External Terminal types */
214#define EXTERNAL_VENDOR_SPECIFIC 0x0400 214#define EXTERNAL_VENDOR_SPECIFIC 0x0400
215#define COMPOSITE_CONNECTOR 0x0401 215#define COMPOSITE_CONNECTOR 0x0401
216#define SVIDEO_CONNECTOR 0x0402 216#define SVIDEO_CONNECTOR 0x0402
217#define COMPONENT_CONNECTOR 0x0403 217#define COMPONENT_CONNECTOR 0x0403
218 218
219#define UVC_TERM_INPUT 0x0000 219#define UVC_TERM_INPUT 0x0000
220#define UVC_TERM_OUTPUT 0x8000 220#define UVC_TERM_OUTPUT 0x8000
@@ -541,11 +541,11 @@ struct uvc_streaming {
541}; 541};
542 542
543enum uvc_buffer_state { 543enum uvc_buffer_state {
544 UVC_BUF_STATE_IDLE = 0, 544 UVC_BUF_STATE_IDLE = 0,
545 UVC_BUF_STATE_QUEUED = 1, 545 UVC_BUF_STATE_QUEUED = 1,
546 UVC_BUF_STATE_ACTIVE = 2, 546 UVC_BUF_STATE_ACTIVE = 2,
547 UVC_BUF_STATE_DONE = 3, 547 UVC_BUF_STATE_DONE = 3,
548 UVC_BUF_STATE_ERROR = 4, 548 UVC_BUF_STATE_ERROR = 4,
549}; 549};
550 550
551struct uvc_buffer { 551struct uvc_buffer {
diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c
index fbe9cc0d433a..21208805ea9b 100644
--- a/drivers/media/video/v4l2-subdev.c
+++ b/drivers/media/video/v4l2-subdev.c
@@ -28,13 +28,13 @@ int v4l2_subdev_command(struct v4l2_subdev *sd, unsigned cmd, void *arg)
28{ 28{
29 switch (cmd) { 29 switch (cmd) {
30 case VIDIOC_QUERYCTRL: 30 case VIDIOC_QUERYCTRL:
31 return v4l2_subdev_call(sd, core, querymenu, arg); 31 return v4l2_subdev_call(sd, core, queryctrl, arg);
32 case VIDIOC_G_CTRL: 32 case VIDIOC_G_CTRL:
33 return v4l2_subdev_call(sd, core, g_ctrl, arg); 33 return v4l2_subdev_call(sd, core, g_ctrl, arg);
34 case VIDIOC_S_CTRL: 34 case VIDIOC_S_CTRL:
35 return v4l2_subdev_call(sd, core, s_ctrl, arg); 35 return v4l2_subdev_call(sd, core, s_ctrl, arg);
36 case VIDIOC_QUERYMENU: 36 case VIDIOC_QUERYMENU:
37 return v4l2_subdev_call(sd, core, queryctrl, arg); 37 return v4l2_subdev_call(sd, core, querymenu, arg);
38 case VIDIOC_LOG_STATUS: 38 case VIDIOC_LOG_STATUS:
39 return v4l2_subdev_call(sd, core, log_status); 39 return v4l2_subdev_call(sd, core, log_status);
40 case VIDIOC_DBG_G_CHIP_IDENT: 40 case VIDIOC_DBG_G_CHIP_IDENT:
diff --git a/drivers/media/video/zoran/zoran.h b/drivers/media/video/zoran/zoran.h
index 46b7ad477ceb..e873a916250f 100644
--- a/drivers/media/video/zoran/zoran.h
+++ b/drivers/media/video/zoran/zoran.h
@@ -349,7 +349,6 @@ struct card_info {
349 u16 i2c_decoder, i2c_encoder; /* I2C types */ 349 u16 i2c_decoder, i2c_encoder; /* I2C types */
350 u16 video_vfe, video_codec; /* videocodec types */ 350 u16 video_vfe, video_codec; /* videocodec types */
351 u16 audio_chip; /* audio type */ 351 u16 audio_chip; /* audio type */
352 u16 vendor_id, device_id; /* subsystem vendor/device ID */
353 352
354 int inputs; /* number of video inputs */ 353 int inputs; /* number of video inputs */
355 struct input { 354 struct input {
@@ -401,7 +400,6 @@ struct zoran {
401 char name[32]; /* name of this device */ 400 char name[32]; /* name of this device */
402 struct pci_dev *pci_dev; /* PCI device */ 401 struct pci_dev *pci_dev; /* PCI device */
403 unsigned char revision; /* revision of zr36057 */ 402 unsigned char revision; /* revision of zr36057 */
404 unsigned int zr36057_adr; /* bus address of IO mem returned by PCI BIOS */
405 unsigned char __iomem *zr36057_mem;/* pointer to mapped IO memory */ 403 unsigned char __iomem *zr36057_mem;/* pointer to mapped IO memory */
406 404
407 spinlock_t spinlock; /* Spinlock */ 405 spinlock_t spinlock; /* Spinlock */
@@ -490,16 +488,10 @@ struct zoran {
490 wait_queue_head_t test_q; 488 wait_queue_head_t test_q;
491}; 489};
492 490
493/*The following should be done in more portable way. It depends on define 491/* There was something called _ALPHA_BUZ that used the PCI address instead of
494 of _ALPHA_BUZ in the Makefile.*/ 492 * the kernel iomapped address for btread/btwrite. */
495
496#ifdef _ALPHA_BUZ
497#define btwrite(dat,adr) writel((dat), zr->zr36057_adr+(adr))
498#define btread(adr) readl(zr->zr36057_adr+(adr))
499#else
500#define btwrite(dat,adr) writel((dat), zr->zr36057_mem+(adr)) 493#define btwrite(dat,adr) writel((dat), zr->zr36057_mem+(adr))
501#define btread(adr) readl(zr->zr36057_mem+(adr)) 494#define btread(adr) readl(zr->zr36057_mem+(adr))
502#endif
503 495
504#define btand(dat,adr) btwrite((dat) & btread(adr), adr) 496#define btand(dat,adr) btwrite((dat) & btread(adr), adr)
505#define btor(dat,adr) btwrite((dat) | btread(adr), adr) 497#define btor(dat,adr) btwrite((dat) | btread(adr), adr)
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c
index 05f39195372e..5d2f090aa0f8 100644
--- a/drivers/media/video/zoran/zoran_card.c
+++ b/drivers/media/video/zoran/zoran_card.c
@@ -61,17 +61,17 @@
61 61
62extern const struct zoran_format zoran_formats[]; 62extern const struct zoran_format zoran_formats[];
63 63
64static int card[BUZ_MAX] = { -1, -1, -1, -1 }; 64static int card[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 };
65module_param_array(card, int, NULL, 0444); 65module_param_array(card, int, NULL, 0444);
66MODULE_PARM_DESC(card, "The type of card"); 66MODULE_PARM_DESC(card, "Card type");
67 67
68static int encoder[BUZ_MAX] = { -1, -1, -1, -1 }; 68static int encoder[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 };
69module_param_array(encoder, int, NULL, 0444); 69module_param_array(encoder, int, NULL, 0444);
70MODULE_PARM_DESC(encoder, "i2c TV encoder"); 70MODULE_PARM_DESC(encoder, "Video encoder chip");
71 71
72static int decoder[BUZ_MAX] = { -1, -1, -1, -1 }; 72static int decoder[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 };
73module_param_array(decoder, int, NULL, 0444); 73module_param_array(decoder, int, NULL, 0444);
74MODULE_PARM_DESC(decoder, "i2c TV decoder"); 74MODULE_PARM_DESC(decoder, "Video decoder chip");
75 75
76/* 76/*
77 The video mem address of the video card. 77 The video mem address of the video card.
@@ -104,9 +104,9 @@ module_param(default_norm, int, 0444);
104MODULE_PARM_DESC(default_norm, "Default norm (0=PAL, 1=NTSC, 2=SECAM)"); 104MODULE_PARM_DESC(default_norm, "Default norm (0=PAL, 1=NTSC, 2=SECAM)");
105 105
106/* /dev/videoN, -1 for autodetect */ 106/* /dev/videoN, -1 for autodetect */
107static int video_nr[BUZ_MAX] = {-1, -1, -1, -1}; 107static int video_nr[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 };
108module_param_array(video_nr, int, NULL, 0444); 108module_param_array(video_nr, int, NULL, 0444);
109MODULE_PARM_DESC(video_nr, "video device number (-1=Auto)"); 109MODULE_PARM_DESC(video_nr, "Video device number (-1=Auto)");
110 110
111/* 111/*
112 Number and size of grab buffers for Video 4 Linux 112 Number and size of grab buffers for Video 4 Linux
@@ -153,9 +153,21 @@ MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver");
153MODULE_AUTHOR("Serguei Miridonov"); 153MODULE_AUTHOR("Serguei Miridonov");
154MODULE_LICENSE("GPL"); 154MODULE_LICENSE("GPL");
155 155
156#define ZR_DEVICE(subven, subdev, data) { \
157 .vendor = PCI_VENDOR_ID_ZORAN, .device = PCI_DEVICE_ID_ZORAN_36057, \
158 .subvendor = (subven), .subdevice = (subdev), .driver_data = (data) }
159
160static struct pci_device_id zr36067_pci_tbl[] = {
161 ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC10PLUS, DC10plus),
162 ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC30PLUS, DC30plus),
163 ZR_DEVICE(PCI_VENDOR_ID_ELECTRONICDESIGNGMBH, PCI_DEVICE_ID_LML_33R10, LML33R10),
164 ZR_DEVICE(PCI_VENDOR_ID_IOMEGA, PCI_DEVICE_ID_IOMEGA_BUZ, BUZ),
165 ZR_DEVICE(PCI_ANY_ID, PCI_ANY_ID, NUM_CARDS),
166 {0}
167};
168MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl);
156 169
157int zoran_num; /* number of Buzs in use */ 170static unsigned int zoran_num; /* number of cards found */
158struct zoran *zoran[BUZ_MAX];
159 171
160/* videocodec bus functions ZR36060 */ 172/* videocodec bus functions ZR36060 */
161static u32 173static u32
@@ -472,8 +484,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
472 }, { 484 }, {
473 .type = DC10plus, 485 .type = DC10plus,
474 .name = "DC10plus", 486 .name = "DC10plus",
475 .vendor_id = PCI_VENDOR_ID_MIRO,
476 .device_id = PCI_DEVICE_ID_MIRO_DC10PLUS,
477 .i2c_decoder = I2C_DRIVERID_SAA7110, 487 .i2c_decoder = I2C_DRIVERID_SAA7110,
478 .i2c_encoder = I2C_DRIVERID_ADV7175, 488 .i2c_encoder = I2C_DRIVERID_ADV7175,
479 .video_codec = CODEC_TYPE_ZR36060, 489 .video_codec = CODEC_TYPE_ZR36060,
@@ -531,8 +541,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
531 }, { 541 }, {
532 .type = DC30plus, 542 .type = DC30plus,
533 .name = "DC30plus", 543 .name = "DC30plus",
534 .vendor_id = PCI_VENDOR_ID_MIRO,
535 .device_id = PCI_DEVICE_ID_MIRO_DC30PLUS,
536 .i2c_decoder = I2C_DRIVERID_VPX3220, 544 .i2c_decoder = I2C_DRIVERID_VPX3220,
537 .i2c_encoder = I2C_DRIVERID_ADV7175, 545 .i2c_encoder = I2C_DRIVERID_ADV7175,
538 .video_codec = CODEC_TYPE_ZR36050, 546 .video_codec = CODEC_TYPE_ZR36050,
@@ -589,8 +597,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
589 }, { 597 }, {
590 .type = LML33R10, 598 .type = LML33R10,
591 .name = "LML33R10", 599 .name = "LML33R10",
592 .vendor_id = PCI_VENDOR_ID_ELECTRONICDESIGNGMBH,
593 .device_id = PCI_DEVICE_ID_LML_33R10,
594 .i2c_decoder = I2C_DRIVERID_SAA7114, 600 .i2c_decoder = I2C_DRIVERID_SAA7114,
595 .i2c_encoder = I2C_DRIVERID_ADV7170, 601 .i2c_encoder = I2C_DRIVERID_ADV7170,
596 .video_codec = CODEC_TYPE_ZR36060, 602 .video_codec = CODEC_TYPE_ZR36060,
@@ -618,8 +624,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
618 }, { 624 }, {
619 .type = BUZ, 625 .type = BUZ,
620 .name = "Buz", 626 .name = "Buz",
621 .vendor_id = PCI_VENDOR_ID_IOMEGA,
622 .device_id = PCI_DEVICE_ID_IOMEGA_BUZ,
623 .i2c_decoder = I2C_DRIVERID_SAA7111A, 627 .i2c_decoder = I2C_DRIVERID_SAA7111A,
624 .i2c_encoder = I2C_DRIVERID_SAA7185B, 628 .i2c_encoder = I2C_DRIVERID_SAA7185B,
625 .video_codec = CODEC_TYPE_ZR36060, 629 .video_codec = CODEC_TYPE_ZR36060,
@@ -649,8 +653,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
649 .name = "6-Eyes", 653 .name = "6-Eyes",
650 /* AverMedia chose not to brand the 6-Eyes. Thus it 654 /* AverMedia chose not to brand the 6-Eyes. Thus it
651 can't be autodetected, and requires card=x. */ 655 can't be autodetected, and requires card=x. */
652 .vendor_id = -1,
653 .device_id = -1,
654 .i2c_decoder = I2C_DRIVERID_KS0127, 656 .i2c_decoder = I2C_DRIVERID_KS0127,
655 .i2c_encoder = I2C_DRIVERID_BT866, 657 .i2c_encoder = I2C_DRIVERID_BT866,
656 .video_codec = CODEC_TYPE_ZR36060, 658 .video_codec = CODEC_TYPE_ZR36060,
@@ -1138,7 +1140,8 @@ zr36057_init (struct zoran *zr)
1138 strcpy(zr->video_dev->name, ZR_DEVNAME(zr)); 1140 strcpy(zr->video_dev->name, ZR_DEVNAME(zr));
1139 err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr[zr->id]); 1141 err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr[zr->id]);
1140 if (err < 0) 1142 if (err < 0)
1141 goto exit_unregister; 1143 goto exit_free;
1144 video_set_drvdata(zr->video_dev, zr);
1142 1145
1143 zoran_init_hardware(zr); 1146 zoran_init_hardware(zr);
1144 if (zr36067_debug > 2) 1147 if (zr36067_debug > 2)
@@ -1153,19 +1156,19 @@ zr36057_init (struct zoran *zr)
1153 zr->initialized = 1; 1156 zr->initialized = 1;
1154 return 0; 1157 return 0;
1155 1158
1156exit_unregister:
1157 zoran_unregister_i2c(zr);
1158exit_free: 1159exit_free:
1159 kfree(zr->stat_com); 1160 kfree(zr->stat_com);
1160 kfree(zr->video_dev); 1161 kfree(zr->video_dev);
1161 return err; 1162 return err;
1162} 1163}
1163 1164
1164static void 1165static void __devexit zoran_remove(struct pci_dev *pdev)
1165zoran_release (struct zoran *zr)
1166{ 1166{
1167 struct zoran *zr = pci_get_drvdata(pdev);
1168
1167 if (!zr->initialized) 1169 if (!zr->initialized)
1168 goto exit_free; 1170 goto exit_free;
1171
1169 /* unregister videocodec bus */ 1172 /* unregister videocodec bus */
1170 if (zr->codec) { 1173 if (zr->codec) {
1171 struct videocodec_master *master = zr->codec->master_data; 1174 struct videocodec_master *master = zr->codec->master_data;
@@ -1194,6 +1197,7 @@ zoran_release (struct zoran *zr)
1194 pci_disable_device(zr->pci_dev); 1197 pci_disable_device(zr->pci_dev);
1195 video_unregister_device(zr->video_dev); 1198 video_unregister_device(zr->video_dev);
1196exit_free: 1199exit_free:
1200 pci_set_drvdata(pdev, NULL);
1197 kfree(zr); 1201 kfree(zr);
1198} 1202}
1199 1203
@@ -1256,338 +1260,329 @@ zoran_setup_videocodec (struct zoran *zr,
1256 * Scan for a Buz card (actually for the PCI controller ZR36057), 1260 * Scan for a Buz card (actually for the PCI controller ZR36057),
1257 * request the irq and map the io memory 1261 * request the irq and map the io memory
1258 */ 1262 */
1259static int __devinit 1263static int __devinit zoran_probe(struct pci_dev *pdev,
1260find_zr36057 (void) 1264 const struct pci_device_id *ent)
1261{ 1265{
1262 unsigned char latency, need_latency; 1266 unsigned char latency, need_latency;
1263 struct zoran *zr; 1267 struct zoran *zr;
1264 struct pci_dev *dev = NULL;
1265 int result; 1268 int result;
1266 struct videocodec_master *master_vfe = NULL; 1269 struct videocodec_master *master_vfe = NULL;
1267 struct videocodec_master *master_codec = NULL; 1270 struct videocodec_master *master_codec = NULL;
1268 int card_num; 1271 int card_num;
1269 char *i2c_enc_name, *i2c_dec_name, *codec_name, *vfe_name; 1272 char *i2c_enc_name, *i2c_dec_name, *codec_name, *vfe_name;
1273 unsigned int nr;
1270 1274
1271 zoran_num = 0;
1272 while (zoran_num < BUZ_MAX &&
1273 (dev = pci_get_device(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057, dev)) != NULL) {
1274 card_num = card[zoran_num];
1275 zr = kzalloc(sizeof(struct zoran), GFP_KERNEL);
1276 if (!zr) {
1277 dprintk(1,
1278 KERN_ERR
1279 "%s: find_zr36057() - kzalloc failed\n",
1280 ZORAN_NAME);
1281 continue;
1282 }
1283 zr->pci_dev = dev;
1284 //zr->zr36057_mem = NULL;
1285 zr->id = zoran_num;
1286 snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id);
1287 spin_lock_init(&zr->spinlock);
1288 mutex_init(&zr->resource_lock);
1289 if (pci_enable_device(dev))
1290 goto zr_free_mem;
1291 zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0);
1292 pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION,
1293 &zr->revision);
1294 if (zr->revision < 2) {
1295 dprintk(1,
1296 KERN_INFO
1297 "%s: Zoran ZR36057 (rev %d) irq: %d, memory: 0x%08x.\n",
1298 ZR_DEVNAME(zr), zr->revision, zr->pci_dev->irq,
1299 zr->zr36057_adr);
1300 1275
1301 if (card_num == -1) { 1276 nr = zoran_num++;
1302 dprintk(1, 1277 if (nr >= BUZ_MAX) {
1303 KERN_ERR 1278 dprintk(1,
1304 "%s: find_zr36057() - no card specified, please use the card=X insmod option\n", 1279 KERN_ERR
1305 ZR_DEVNAME(zr)); 1280 "%s: driver limited to %d card(s) maximum\n",
1306 goto zr_free_mem; 1281 ZORAN_NAME, BUZ_MAX);
1307 } 1282 return -ENOENT;
1308 } else { 1283 }
1309 int i;
1310 unsigned short ss_vendor, ss_device;
1311 1284
1312 ss_vendor = zr->pci_dev->subsystem_vendor; 1285 zr = kzalloc(sizeof(struct zoran), GFP_KERNEL);
1313 ss_device = zr->pci_dev->subsystem_device; 1286 if (!zr) {
1287 dprintk(1,
1288 KERN_ERR
1289 "%s: find_zr36057() - kzalloc failed\n",
1290 ZORAN_NAME);
1291 return -ENOMEM;
1292 }
1293 zr->pci_dev = pdev;
1294 zr->id = nr;
1295 snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id);
1296 spin_lock_init(&zr->spinlock);
1297 mutex_init(&zr->resource_lock);
1298 if (pci_enable_device(pdev))
1299 goto zr_free_mem;
1300 pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, &zr->revision);
1301
1302 dprintk(1,
1303 KERN_INFO
1304 "%s: Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08llx\n",
1305 ZR_DEVNAME(zr), zr->revision < 2 ? '5' : '6', zr->revision,
1306 zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 0));
1307 if (zr->revision >= 2) {
1308 dprintk(1,
1309 KERN_INFO
1310 "%s: Subsystem vendor=0x%04x id=0x%04x\n",
1311 ZR_DEVNAME(zr), zr->pci_dev->subsystem_vendor,
1312 zr->pci_dev->subsystem_device);
1313 }
1314
1315 /* Use auto-detected card type? */
1316 if (card[nr] == -1) {
1317 if (zr->revision < 2) {
1314 dprintk(1, 1318 dprintk(1,
1315 KERN_INFO 1319 KERN_ERR
1316 "%s: Zoran ZR36067 (rev %d) irq: %d, memory: 0x%08x\n", 1320 "%s: No card type specified, please use the card=X module parameter\n",
1317 ZR_DEVNAME(zr), zr->revision, zr->pci_dev->irq, 1321 ZR_DEVNAME(zr));
1318 zr->zr36057_adr);
1319 dprintk(1, 1322 dprintk(1,
1320 KERN_INFO
1321 "%s: subsystem vendor=0x%04x id=0x%04x\n",
1322 ZR_DEVNAME(zr), ss_vendor, ss_device);
1323 if (card_num == -1) {
1324 dprintk(3,
1325 KERN_DEBUG
1326 "%s: find_zr36057() - trying to autodetect card type\n",
1327 ZR_DEVNAME(zr));
1328 for (i=0;i<NUM_CARDS;i++) {
1329 if (ss_vendor == zoran_cards[i].vendor_id &&
1330 ss_device == zoran_cards[i].device_id) {
1331 dprintk(3,
1332 KERN_DEBUG
1333 "%s: find_zr36057() - card %s detected\n",
1334 ZR_DEVNAME(zr),
1335 zoran_cards[i].name);
1336 card_num = i;
1337 break;
1338 }
1339 }
1340 if (i == NUM_CARDS) {
1341 dprintk(1,
1342 KERN_ERR
1343 "%s: find_zr36057() - unknown card\n",
1344 ZR_DEVNAME(zr));
1345 goto zr_free_mem;
1346 }
1347 }
1348 }
1349
1350 if (card_num < 0 || card_num >= NUM_CARDS) {
1351 dprintk(2,
1352 KERN_ERR 1323 KERN_ERR
1353 "%s: find_zr36057() - invalid cardnum %d\n", 1324 "%s: It is not possible to auto-detect ZR36057 based cards\n",
1354 ZR_DEVNAME(zr), card_num); 1325 ZR_DEVNAME(zr));
1355 goto zr_free_mem; 1326 goto zr_free_mem;
1356 } 1327 }
1357 1328
1358 /* even though we make this a non pointer and thus 1329 card_num = ent->driver_data;
1359 * theoretically allow for making changes to this struct 1330 if (card_num >= NUM_CARDS) {
1360 * on a per-individual card basis at runtime, this is
1361 * strongly discouraged. This structure is intended to
1362 * keep general card information, no settings or anything */
1363 zr->card = zoran_cards[card_num];
1364 snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)),
1365 "%s[%u]", zr->card.name, zr->id);
1366
1367 zr->zr36057_mem = ioremap_nocache(zr->zr36057_adr, 0x1000);
1368 if (!zr->zr36057_mem) {
1369 dprintk(1, 1331 dprintk(1,
1370 KERN_ERR 1332 KERN_ERR
1371 "%s: find_zr36057() - ioremap failed\n", 1333 "%s: Unknown card, try specifying card=X module parameter\n",
1372 ZR_DEVNAME(zr)); 1334 ZR_DEVNAME(zr));
1373 goto zr_free_mem; 1335 goto zr_free_mem;
1374 } 1336 }
1375 1337 dprintk(3,
1376 result = request_irq(zr->pci_dev->irq, 1338 KERN_DEBUG
1377 zoran_irq, 1339 "%s: %s() - card %s detected\n",
1378 IRQF_SHARED | IRQF_DISABLED, 1340 ZR_DEVNAME(zr), __func__, zoran_cards[card_num].name);
1379 ZR_DEVNAME(zr), 1341 } else {
1380 (void *) zr); 1342 card_num = card[nr];
1381 if (result < 0) { 1343 if (card_num >= NUM_CARDS || card_num < 0) {
1382 if (result == -EINVAL) { 1344 dprintk(1,
1383 dprintk(1, 1345 KERN_ERR
1384 KERN_ERR 1346 "%s: User specified card type %d out of range (0 .. %d)\n",
1385 "%s: find_zr36057() - bad irq number or handler\n", 1347 ZR_DEVNAME(zr), card_num, NUM_CARDS - 1);
1386 ZR_DEVNAME(zr)); 1348 goto zr_free_mem;
1387 } else if (result == -EBUSY) {
1388 dprintk(1,
1389 KERN_ERR
1390 "%s: find_zr36057() - IRQ %d busy, change your PnP config in BIOS\n",
1391 ZR_DEVNAME(zr), zr->pci_dev->irq);
1392 } else {
1393 dprintk(1,
1394 KERN_ERR
1395 "%s: find_zr36057() - can't assign irq, error code %d\n",
1396 ZR_DEVNAME(zr), result);
1397 }
1398 goto zr_unmap;
1399 }
1400
1401 /* set PCI latency timer */
1402 pci_read_config_byte(zr->pci_dev, PCI_LATENCY_TIMER,
1403 &latency);
1404 need_latency = zr->revision > 1 ? 32 : 48;
1405 if (latency != need_latency) {
1406 dprintk(2,
1407 KERN_INFO
1408 "%s: Changing PCI latency from %d to %d.\n",
1409 ZR_DEVNAME(zr), latency, need_latency);
1410 pci_write_config_byte(zr->pci_dev,
1411 PCI_LATENCY_TIMER,
1412 need_latency);
1413 } 1349 }
1350 }
1414 1351
1415 zr36057_restart(zr); 1352 /* even though we make this a non pointer and thus
1416 /* i2c */ 1353 * theoretically allow for making changes to this struct
1417 dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n", 1354 * on a per-individual card basis at runtime, this is
1418 ZR_DEVNAME(zr)); 1355 * strongly discouraged. This structure is intended to
1356 * keep general card information, no settings or anything */
1357 zr->card = zoran_cards[card_num];
1358 snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)),
1359 "%s[%u]", zr->card.name, zr->id);
1360
1361 zr->zr36057_mem = pci_ioremap_bar(zr->pci_dev, 0);
1362 if (!zr->zr36057_mem) {
1363 dprintk(1,
1364 KERN_ERR
1365 "%s: %s() - ioremap failed\n",
1366 ZR_DEVNAME(zr), __func__);
1367 goto zr_free_mem;
1368 }
1419 1369
1420 /* i2c decoder */ 1370 result = request_irq(zr->pci_dev->irq, zoran_irq,
1421 if (decoder[zr->id] != -1) { 1371 IRQF_SHARED | IRQF_DISABLED, ZR_DEVNAME(zr), zr);
1422 i2c_dec_name = i2cid_to_modulename(decoder[zr->id]); 1372 if (result < 0) {
1423 zr->card.i2c_decoder = decoder[zr->id]; 1373 if (result == -EINVAL) {
1424 } else if (zr->card.i2c_decoder != 0) { 1374 dprintk(1,
1425 i2c_dec_name = 1375 KERN_ERR
1426 i2cid_to_modulename(zr->card.i2c_decoder); 1376 "%s: find_zr36057() - bad irq number or handler\n",
1377 ZR_DEVNAME(zr));
1378 } else if (result == -EBUSY) {
1379 dprintk(1,
1380 KERN_ERR
1381 "%s: find_zr36057() - IRQ %d busy, change your PnP config in BIOS\n",
1382 ZR_DEVNAME(zr), zr->pci_dev->irq);
1427 } else { 1383 } else {
1428 i2c_dec_name = NULL; 1384 dprintk(1,
1385 KERN_ERR
1386 "%s: find_zr36057() - can't assign irq, error code %d\n",
1387 ZR_DEVNAME(zr), result);
1429 } 1388 }
1389 goto zr_unmap;
1390 }
1430 1391
1431 if (i2c_dec_name) { 1392 /* set PCI latency timer */
1432 if ((result = request_module(i2c_dec_name)) < 0) { 1393 pci_read_config_byte(zr->pci_dev, PCI_LATENCY_TIMER,
1433 dprintk(1, 1394 &latency);
1434 KERN_ERR 1395 need_latency = zr->revision > 1 ? 32 : 48;
1435 "%s: failed to load module %s: %d\n", 1396 if (latency != need_latency) {
1436 ZR_DEVNAME(zr), i2c_dec_name, result); 1397 dprintk(2,
1437 } 1398 KERN_INFO
1438 } 1399 "%s: Changing PCI latency from %d to %d\n",
1400 ZR_DEVNAME(zr), latency, need_latency);
1401 pci_write_config_byte(zr->pci_dev, PCI_LATENCY_TIMER,
1402 need_latency);
1403 }
1439 1404
1440 /* i2c encoder */ 1405 zr36057_restart(zr);
1441 if (encoder[zr->id] != -1) { 1406 /* i2c */
1442 i2c_enc_name = i2cid_to_modulename(encoder[zr->id]); 1407 dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n",
1443 zr->card.i2c_encoder = encoder[zr->id]; 1408 ZR_DEVNAME(zr));
1444 } else if (zr->card.i2c_encoder != 0) { 1409
1445 i2c_enc_name = 1410 /* i2c decoder */
1446 i2cid_to_modulename(zr->card.i2c_encoder); 1411 if (decoder[zr->id] != -1) {
1447 } else { 1412 i2c_dec_name = i2cid_to_modulename(decoder[zr->id]);
1448 i2c_enc_name = NULL; 1413 zr->card.i2c_decoder = decoder[zr->id];
1449 } 1414 } else if (zr->card.i2c_decoder != 0) {
1415 i2c_dec_name = i2cid_to_modulename(zr->card.i2c_decoder);
1416 } else {
1417 i2c_dec_name = NULL;
1418 }
1450 1419
1451 if (i2c_enc_name) { 1420 if (i2c_dec_name) {
1452 if ((result = request_module(i2c_enc_name)) < 0) { 1421 result = request_module(i2c_dec_name);
1453 dprintk(1, 1422 if (result < 0) {
1454 KERN_ERR 1423 dprintk(1,
1455 "%s: failed to load module %s: %d\n", 1424 KERN_ERR
1456 ZR_DEVNAME(zr), i2c_enc_name, result); 1425 "%s: failed to load module %s: %d\n",
1457 } 1426 ZR_DEVNAME(zr), i2c_dec_name, result);
1458 } 1427 }
1428 }
1429
1430 /* i2c encoder */
1431 if (encoder[zr->id] != -1) {
1432 i2c_enc_name = i2cid_to_modulename(encoder[zr->id]);
1433 zr->card.i2c_encoder = encoder[zr->id];
1434 } else if (zr->card.i2c_encoder != 0) {
1435 i2c_enc_name = i2cid_to_modulename(zr->card.i2c_encoder);
1436 } else {
1437 i2c_enc_name = NULL;
1438 }
1459 1439
1460 if (zoran_register_i2c(zr) < 0) { 1440 if (i2c_enc_name) {
1441 result = request_module(i2c_enc_name);
1442 if (result < 0) {
1461 dprintk(1, 1443 dprintk(1,
1462 KERN_ERR 1444 KERN_ERR
1463 "%s: find_zr36057() - can't initialize i2c bus\n", 1445 "%s: failed to load module %s: %d\n",
1464 ZR_DEVNAME(zr)); 1446 ZR_DEVNAME(zr), i2c_enc_name, result);
1465 goto zr_free_irq;
1466 } 1447 }
1448 }
1467 1449
1468 dprintk(2, 1450 if (zoran_register_i2c(zr) < 0) {
1469 KERN_INFO "%s: Initializing videocodec bus...\n", 1451 dprintk(1,
1452 KERN_ERR
1453 "%s: find_zr36057() - can't initialize i2c bus\n",
1470 ZR_DEVNAME(zr)); 1454 ZR_DEVNAME(zr));
1455 goto zr_free_irq;
1456 }
1471 1457
1472 if (zr->card.video_codec != 0 && 1458 dprintk(2,
1473 (codec_name = 1459 KERN_INFO "%s: Initializing videocodec bus...\n",
1474 codecid_to_modulename(zr->card.video_codec)) != NULL) { 1460 ZR_DEVNAME(zr));
1475 if ((result = request_module(codec_name)) < 0) { 1461
1462 if (zr->card.video_codec) {
1463 codec_name = codecid_to_modulename(zr->card.video_codec);
1464 if (codec_name) {
1465 result = request_module(codec_name);
1466 if (result) {
1476 dprintk(1, 1467 dprintk(1,
1477 KERN_ERR 1468 KERN_ERR
1478 "%s: failed to load modules %s: %d\n", 1469 "%s: failed to load modules %s: %d\n",
1479 ZR_DEVNAME(zr), codec_name, result); 1470 ZR_DEVNAME(zr), codec_name, result);
1480 } 1471 }
1481 } 1472 }
1482 if (zr->card.video_vfe != 0 && 1473 }
1483 (vfe_name = 1474 if (zr->card.video_vfe) {
1484 codecid_to_modulename(zr->card.video_vfe)) != NULL) { 1475 vfe_name = codecid_to_modulename(zr->card.video_vfe);
1485 if ((result = request_module(vfe_name)) < 0) { 1476 if (vfe_name) {
1477 result = request_module(vfe_name);
1478 if (result < 0) {
1486 dprintk(1, 1479 dprintk(1,
1487 KERN_ERR 1480 KERN_ERR
1488 "%s: failed to load modules %s: %d\n", 1481 "%s: failed to load modules %s: %d\n",
1489 ZR_DEVNAME(zr), vfe_name, result); 1482 ZR_DEVNAME(zr), vfe_name, result);
1490 } 1483 }
1491 } 1484 }
1485 }
1492 1486
1493 /* reset JPEG codec */ 1487 /* reset JPEG codec */
1494 jpeg_codec_sleep(zr, 1); 1488 jpeg_codec_sleep(zr, 1);
1495 jpeg_codec_reset(zr); 1489 jpeg_codec_reset(zr);
1496 /* video bus enabled */ 1490 /* video bus enabled */
1497 /* display codec revision */ 1491 /* display codec revision */
1498 if (zr->card.video_codec != 0) { 1492 if (zr->card.video_codec != 0) {
1499 master_codec = zoran_setup_videocodec(zr, 1493 master_codec = zoran_setup_videocodec(zr, zr->card.video_codec);
1500 zr->card.video_codec); 1494 if (!master_codec)
1501 if (!master_codec) 1495 goto zr_unreg_i2c;
1502 goto zr_unreg_i2c; 1496 zr->codec = videocodec_attach(master_codec);
1503 zr->codec = videocodec_attach(master_codec); 1497 if (!zr->codec) {
1504 if (!zr->codec) { 1498 dprintk(1,
1505 dprintk(1, 1499 KERN_ERR
1506 KERN_ERR 1500 "%s: find_zr36057() - no codec found\n",
1507 "%s: find_zr36057() - no codec found\n", 1501 ZR_DEVNAME(zr));
1508 ZR_DEVNAME(zr)); 1502 goto zr_free_codec;
1509 goto zr_free_codec;
1510 }
1511 if (zr->codec->type != zr->card.video_codec) {
1512 dprintk(1,
1513 KERN_ERR
1514 "%s: find_zr36057() - wrong codec\n",
1515 ZR_DEVNAME(zr));
1516 goto zr_detach_codec;
1517 }
1518 } 1503 }
1519 if (zr->card.video_vfe != 0) { 1504 if (zr->codec->type != zr->card.video_codec) {
1520 master_vfe = zoran_setup_videocodec(zr, 1505 dprintk(1,
1521 zr->card.video_vfe); 1506 KERN_ERR
1522 if (!master_vfe) 1507 "%s: find_zr36057() - wrong codec\n",
1523 goto zr_detach_codec; 1508 ZR_DEVNAME(zr));
1524 zr->vfe = videocodec_attach(master_vfe); 1509 goto zr_detach_codec;
1525 if (!zr->vfe) { 1510 }
1526 dprintk(1, 1511 }
1527 KERN_ERR 1512 if (zr->card.video_vfe != 0) {
1528 "%s: find_zr36057() - no VFE found\n", 1513 master_vfe = zoran_setup_videocodec(zr, zr->card.video_vfe);
1529 ZR_DEVNAME(zr)); 1514 if (!master_vfe)
1530 goto zr_free_vfe; 1515 goto zr_detach_codec;
1531 } 1516 zr->vfe = videocodec_attach(master_vfe);
1532 if (zr->vfe->type != zr->card.video_vfe) { 1517 if (!zr->vfe) {
1533 dprintk(1, 1518 dprintk(1,
1534 KERN_ERR 1519 KERN_ERR
1535 "%s: find_zr36057() = wrong VFE\n", 1520 "%s: find_zr36057() - no VFE found\n",
1536 ZR_DEVNAME(zr)); 1521 ZR_DEVNAME(zr));
1537 goto zr_detach_vfe; 1522 goto zr_free_vfe;
1538 } 1523 }
1524 if (zr->vfe->type != zr->card.video_vfe) {
1525 dprintk(1,
1526 KERN_ERR
1527 "%s: find_zr36057() = wrong VFE\n",
1528 ZR_DEVNAME(zr));
1529 goto zr_detach_vfe;
1539 } 1530 }
1540 /* Success so keep the pci_dev referenced */
1541 pci_dev_get(zr->pci_dev);
1542 zoran[zoran_num++] = zr;
1543 continue;
1544
1545 // Init errors
1546 zr_detach_vfe:
1547 videocodec_detach(zr->vfe);
1548 zr_free_vfe:
1549 kfree(master_vfe);
1550 zr_detach_codec:
1551 videocodec_detach(zr->codec);
1552 zr_free_codec:
1553 kfree(master_codec);
1554 zr_unreg_i2c:
1555 zoran_unregister_i2c(zr);
1556 zr_free_irq:
1557 btwrite(0, ZR36057_SPGPPCR);
1558 free_irq(zr->pci_dev->irq, zr);
1559 zr_unmap:
1560 iounmap(zr->zr36057_mem);
1561 zr_free_mem:
1562 kfree(zr);
1563 continue;
1564 } 1531 }
1565 if (dev) /* Clean up ref count on early exit */
1566 pci_dev_put(dev);
1567 1532
1568 if (zoran_num == 0) { 1533 /* take care of Natoma chipset and a revision 1 zr36057 */
1569 dprintk(1, KERN_INFO "No known MJPEG cards found.\n"); 1534 if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) {
1535 zr->jpg_buffers.need_contiguous = 1;
1536 dprintk(1,
1537 KERN_INFO
1538 "%s: ZR36057/Natoma bug, max. buffer size is 128K\n",
1539 ZR_DEVNAME(zr));
1570 } 1540 }
1571 return zoran_num; 1541
1542 if (zr36057_init(zr) < 0)
1543 goto zr_detach_vfe;
1544
1545 zoran_proc_init(zr);
1546
1547 pci_set_drvdata(pdev, zr);
1548
1549 return 0;
1550
1551zr_detach_vfe:
1552 videocodec_detach(zr->vfe);
1553zr_free_vfe:
1554 kfree(master_vfe);
1555zr_detach_codec:
1556 videocodec_detach(zr->codec);
1557zr_free_codec:
1558 kfree(master_codec);
1559zr_unreg_i2c:
1560 zoran_unregister_i2c(zr);
1561zr_free_irq:
1562 btwrite(0, ZR36057_SPGPPCR);
1563 free_irq(zr->pci_dev->irq, zr);
1564zr_unmap:
1565 iounmap(zr->zr36057_mem);
1566zr_free_mem:
1567 kfree(zr);
1568
1569 return -ENODEV;
1572} 1570}
1573 1571
1574static int __init 1572static struct pci_driver zoran_driver = {
1575init_dc10_cards (void) 1573 .name = "zr36067",
1574 .id_table = zr36067_pci_tbl,
1575 .probe = zoran_probe,
1576 .remove = zoran_remove,
1577};
1578
1579static int __init zoran_init(void)
1576{ 1580{
1577 int i; 1581 int res;
1578 1582
1579 memset(zoran, 0, sizeof(zoran));
1580 printk(KERN_INFO "Zoran MJPEG board driver version %d.%d.%d\n", 1583 printk(KERN_INFO "Zoran MJPEG board driver version %d.%d.%d\n",
1581 MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION); 1584 MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION);
1582 1585
1583 /* Look for cards */
1584 if (find_zr36057() < 0) {
1585 return -EIO;
1586 }
1587 if (zoran_num == 0)
1588 return -ENODEV;
1589 dprintk(1, KERN_INFO "%s: %d card(s) found\n", ZORAN_NAME,
1590 zoran_num);
1591 /* check the parameters we have been given, adjust if necessary */ 1586 /* check the parameters we have been given, adjust if necessary */
1592 if (v4l_nbufs < 2) 1587 if (v4l_nbufs < 2)
1593 v4l_nbufs = 2; 1588 v4l_nbufs = 2;
@@ -1629,37 +1624,22 @@ init_dc10_cards (void)
1629 ZORAN_NAME); 1624 ZORAN_NAME);
1630 } 1625 }
1631 1626
1632 /* take care of Natoma chipset and a revision 1 zr36057 */ 1627 res = pci_register_driver(&zoran_driver);
1633 for (i = 0; i < zoran_num; i++) { 1628 if (res) {
1634 struct zoran *zr = zoran[i]; 1629 dprintk(1,
1635 1630 KERN_ERR
1636 if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) { 1631 "%s: Unable to register ZR36057 driver\n",
1637 zr->jpg_buffers.need_contiguous = 1; 1632 ZORAN_NAME);
1638 dprintk(1, 1633 return res;
1639 KERN_INFO
1640 "%s: ZR36057/Natoma bug, max. buffer size is 128K\n",
1641 ZR_DEVNAME(zr));
1642 }
1643
1644 if (zr36057_init(zr) < 0) {
1645 for (i = 0; i < zoran_num; i++)
1646 zoran_release(zoran[i]);
1647 return -EIO;
1648 }
1649 zoran_proc_init(zr);
1650 } 1634 }
1651 1635
1652 return 0; 1636 return 0;
1653} 1637}
1654 1638
1655static void __exit 1639static void __exit zoran_exit(void)
1656unload_dc10_cards (void)
1657{ 1640{
1658 int i; 1641 pci_unregister_driver(&zoran_driver);
1659
1660 for (i = 0; i < zoran_num; i++)
1661 zoran_release(zoran[i]);
1662} 1642}
1663 1643
1664module_init(init_dc10_cards); 1644module_init(zoran_init);
1665module_exit(unload_dc10_cards); 1645module_exit(zoran_exit);
diff --git a/drivers/media/video/zoran/zoran_card.h b/drivers/media/video/zoran/zoran_card.h
index e4dc9d29b404..4507bdc5e338 100644
--- a/drivers/media/video/zoran/zoran_card.h
+++ b/drivers/media/video/zoran/zoran_card.h
@@ -40,8 +40,6 @@ extern int zr36067_debug;
40 40
41/* Anybody who uses more than four? */ 41/* Anybody who uses more than four? */
42#define BUZ_MAX 4 42#define BUZ_MAX 4
43extern int zoran_num;
44extern struct zoran *zoran[BUZ_MAX];
45 43
46extern struct video_device zoran_template; 44extern struct video_device zoran_template;
47 45
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c
index b58b9dda715c..120ef235e63d 100644
--- a/drivers/media/video/zoran/zoran_driver.c
+++ b/drivers/media/video/zoran/zoran_driver.c
@@ -1196,83 +1196,54 @@ zoran_close_end_session (struct file *file)
1196 * Open a zoran card. Right now the flags stuff is just playing 1196 * Open a zoran card. Right now the flags stuff is just playing
1197 */ 1197 */
1198 1198
1199static int 1199static int zoran_open(struct file *file)
1200zoran_open(struct file *file)
1201{ 1200{
1202 unsigned int minor = video_devdata(file)->minor; 1201 struct zoran *zr = video_drvdata(file);
1203 struct zoran *zr = NULL;
1204 struct zoran_fh *fh; 1202 struct zoran_fh *fh;
1205 int i, res, first_open = 0, have_module_locks = 0; 1203 int res, first_open = 0;
1206 1204
1207 lock_kernel(); 1205 dprintk(2, KERN_INFO "%s: zoran_open(%s, pid=[%d]), users(-)=%d\n",
1208 /* find the device */ 1206 ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user + 1);
1209 for (i = 0; i < zoran_num; i++) {
1210 if (zoran[i]->video_dev->minor == minor) {
1211 zr = zoran[i];
1212 break;
1213 }
1214 }
1215 1207
1216 if (!zr) { 1208 lock_kernel();
1217 dprintk(1, KERN_ERR "%s: device not found!\n", ZORAN_NAME);
1218 res = -ENODEV;
1219 goto open_unlock_and_return;
1220 }
1221 1209
1222 /* see fs/device.c - the kernel already locks during open(), 1210 /* see fs/device.c - the kernel already locks during open(),
1223 * so locking ourselves only causes deadlocks */ 1211 * so locking ourselves only causes deadlocks */
1224 /*mutex_lock(&zr->resource_lock);*/ 1212 /*mutex_lock(&zr->resource_lock);*/
1225 1213
1214 if (zr->user >= 2048) {
1215 dprintk(1, KERN_ERR "%s: too many users (%d) on device\n",
1216 ZR_DEVNAME(zr), zr->user);
1217 res = -EBUSY;
1218 goto fail_unlock;
1219 }
1220
1226 if (!zr->decoder) { 1221 if (!zr->decoder) {
1227 dprintk(1, 1222 dprintk(1,
1228 KERN_ERR "%s: no TV decoder loaded for device!\n", 1223 KERN_ERR "%s: no TV decoder loaded for device!\n",
1229 ZR_DEVNAME(zr)); 1224 ZR_DEVNAME(zr));
1230 res = -EIO; 1225 res = -EIO;
1231 goto open_unlock_and_return; 1226 goto fail_unlock;
1232 } 1227 }
1233 1228
1234 /* try to grab a module lock */
1235 if (!try_module_get(THIS_MODULE)) {
1236 dprintk(1,
1237 KERN_ERR
1238 "%s: failed to acquire my own lock! PANIC!\n",
1239 ZR_DEVNAME(zr));
1240 res = -ENODEV;
1241 goto open_unlock_and_return;
1242 }
1243 if (!try_module_get(zr->decoder->driver->driver.owner)) { 1229 if (!try_module_get(zr->decoder->driver->driver.owner)) {
1244 dprintk(1, 1230 dprintk(1,
1245 KERN_ERR 1231 KERN_ERR
1246 "%s: failed to grab ownership of i2c decoder\n", 1232 "%s: failed to grab ownership of video decoder\n",
1247 ZR_DEVNAME(zr)); 1233 ZR_DEVNAME(zr));
1248 res = -EIO; 1234 res = -EIO;
1249 module_put(THIS_MODULE); 1235 goto fail_unlock;
1250 goto open_unlock_and_return;
1251 } 1236 }
1252 if (zr->encoder && 1237 if (zr->encoder &&
1253 !try_module_get(zr->encoder->driver->driver.owner)) { 1238 !try_module_get(zr->encoder->driver->driver.owner)) {
1254 dprintk(1, 1239 dprintk(1,
1255 KERN_ERR 1240 KERN_ERR
1256 "%s: failed to grab ownership of i2c encoder\n", 1241 "%s: failed to grab ownership of video encoder\n",
1257 ZR_DEVNAME(zr)); 1242 ZR_DEVNAME(zr));
1258 res = -EIO; 1243 res = -EIO;
1259 module_put(zr->decoder->driver->driver.owner); 1244 goto fail_decoder;
1260 module_put(THIS_MODULE);
1261 goto open_unlock_and_return;
1262 } 1245 }
1263 1246
1264 have_module_locks = 1;
1265
1266 if (zr->user >= 2048) {
1267 dprintk(1, KERN_ERR "%s: too many users (%d) on device\n",
1268 ZR_DEVNAME(zr), zr->user);
1269 res = -EBUSY;
1270 goto open_unlock_and_return;
1271 }
1272
1273 dprintk(1, KERN_INFO "%s: zoran_open(%s, pid=[%d]), users(-)=%d\n",
1274 ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user);
1275
1276 /* now, create the open()-specific file_ops struct */ 1247 /* now, create the open()-specific file_ops struct */
1277 fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL); 1248 fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL);
1278 if (!fh) { 1249 if (!fh) {
@@ -1281,7 +1252,7 @@ zoran_open(struct file *file)
1281 "%s: zoran_open() - allocation of zoran_fh failed\n", 1252 "%s: zoran_open() - allocation of zoran_fh failed\n",
1282 ZR_DEVNAME(zr)); 1253 ZR_DEVNAME(zr));
1283 res = -ENOMEM; 1254 res = -ENOMEM;
1284 goto open_unlock_and_return; 1255 goto fail_encoder;
1285 } 1256 }
1286 /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows 1257 /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows
1287 * on norm-change! */ 1258 * on norm-change! */
@@ -1292,9 +1263,8 @@ zoran_open(struct file *file)
1292 KERN_ERR 1263 KERN_ERR
1293 "%s: zoran_open() - allocation of overlay_mask failed\n", 1264 "%s: zoran_open() - allocation of overlay_mask failed\n",
1294 ZR_DEVNAME(zr)); 1265 ZR_DEVNAME(zr));
1295 kfree(fh);
1296 res = -ENOMEM; 1266 res = -ENOMEM;
1297 goto open_unlock_and_return; 1267 goto fail_fh;
1298 } 1268 }
1299 1269
1300 if (zr->user++ == 0) 1270 if (zr->user++ == 0)
@@ -1319,22 +1289,19 @@ zoran_open(struct file *file)
1319 1289
1320 return 0; 1290 return 0;
1321 1291
1322open_unlock_and_return: 1292fail_fh:
1323 /* if we grabbed locks, release them accordingly */ 1293 kfree(fh);
1324 if (have_module_locks) { 1294fail_encoder:
1325 module_put(zr->decoder->driver->driver.owner); 1295 if (zr->encoder)
1326 if (zr->encoder) { 1296 module_put(zr->encoder->driver->driver.owner);
1327 module_put(zr->encoder->driver->driver.owner); 1297fail_decoder:
1328 } 1298 module_put(zr->decoder->driver->driver.owner);
1329 module_put(THIS_MODULE); 1299fail_unlock:
1330 }
1331
1332 /* if there's no device found, we didn't obtain the lock either */
1333 if (zr) {
1334 /*mutex_unlock(&zr->resource_lock);*/
1335 }
1336 unlock_kernel(); 1300 unlock_kernel();
1337 1301
1302 dprintk(2, KERN_INFO "%s: open failed (%d), users(-)=%d\n",
1303 ZR_DEVNAME(zr), res, zr->user);
1304
1338 return res; 1305 return res;
1339} 1306}
1340 1307
@@ -1344,8 +1311,8 @@ zoran_close(struct file *file)
1344 struct zoran_fh *fh = file->private_data; 1311 struct zoran_fh *fh = file->private_data;
1345 struct zoran *zr = fh->zr; 1312 struct zoran *zr = fh->zr;
1346 1313
1347 dprintk(1, KERN_INFO "%s: zoran_close(%s, pid=[%d]), users(+)=%d\n", 1314 dprintk(2, KERN_INFO "%s: zoran_close(%s, pid=[%d]), users(+)=%d\n",
1348 ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user); 1315 ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user - 1);
1349 1316
1350 /* kernel locks (fs/device.c), so don't do that ourselves 1317 /* kernel locks (fs/device.c), so don't do that ourselves
1351 * (prevents deadlocks) */ 1318 * (prevents deadlocks) */
@@ -1391,10 +1358,8 @@ zoran_close(struct file *file)
1391 1358
1392 /* release locks on the i2c modules */ 1359 /* release locks on the i2c modules */
1393 module_put(zr->decoder->driver->driver.owner); 1360 module_put(zr->decoder->driver->driver.owner);
1394 if (zr->encoder) { 1361 if (zr->encoder)
1395 module_put(zr->encoder->driver->driver.owner); 1362 module_put(zr->encoder->driver->driver.owner);
1396 }
1397 module_put(THIS_MODULE);
1398 1363
1399 /*mutex_unlock(&zr->resource_lock);*/ 1364 /*mutex_unlock(&zr->resource_lock);*/
1400 1365
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 9bf4ccc93dbf..55e41afd95ef 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -94,16 +94,16 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
94/* Call the specified callback for all subdevs matching grp_id (if 0, then 94/* Call the specified callback for all subdevs matching grp_id (if 0, then
95 match them all). Ignore any errors. Note that you cannot add or delete 95 match them all). Ignore any errors. Note that you cannot add or delete
96 a subdev while walking the subdevs list. */ 96 a subdev while walking the subdevs list. */
97#define v4l2_device_call_all(dev, grp_id, o, f, args...) \ 97#define v4l2_device_call_all(dev, grpid, o, f, args...) \
98 __v4l2_device_call_subdevs(dev, \ 98 __v4l2_device_call_subdevs(dev, \
99 !(grp_id) || sd->grp_id == (grp_id), o, f , ##args) 99 !(grpid) || sd->grp_id == (grpid), o, f , ##args)
100 100
101/* Call the specified callback for all subdevs matching grp_id (if 0, then 101/* Call the specified callback for all subdevs matching grp_id (if 0, then
102 match them all). If the callback returns an error other than 0 or 102 match them all). If the callback returns an error other than 0 or
103 -ENOIOCTLCMD, then return with that error code. Note that you cannot 103 -ENOIOCTLCMD, then return with that error code. Note that you cannot
104 add or delete a subdev while walking the subdevs list. */ 104 add or delete a subdev while walking the subdevs list. */
105#define v4l2_device_call_until_err(dev, grp_id, o, f, args...) \ 105#define v4l2_device_call_until_err(dev, grpid, o, f, args...) \
106 __v4l2_device_call_subdevs_until_err(dev, \ 106 __v4l2_device_call_subdevs_until_err(dev, \
107 !(grp_id) || sd->grp_id == (grp_id), o, f , ##args) 107 !(grpid) || sd->grp_id == (grpid), o, f , ##args)
108 108
109#endif 109#endif