summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-11-04 14:18:02 -0200
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-11-04 14:18:02 -0200
commit1dbbdee4213114f49f8fe0d92a6daeba5c6f639f (patch)
tree9dd17b2bd0bc0913493cc7764d7a4d1d4a411bd9 /linux
parent0d047cc5c24e86c3087e7c2300d048f48a11988a (diff)
parent971898bb2fef994eccedc53e385ec8fec1b01244 (diff)
downloadmediapointer-dvb-s2-1dbbdee4213114f49f8fe0d92a6daeba5c6f639f.tar.gz
mediapointer-dvb-s2-1dbbdee4213114f49f8fe0d92a6daeba5c6f639f.tar.bz2
merge: http://linuxtv.org/hg/~mcisely/pvrusb2
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux')
-rw-r--r--linux/Documentation/video4linux/CARDLIST.em28xx6
-rw-r--r--linux/drivers/media/video/Kconfig2
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-cards.c316
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-i2c.c93
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-video.c275
-rw-r--r--linux/drivers/media/video/em28xx/em28xx.h19
-rw-r--r--linux/drivers/media/video/tda8290.c64
-rw-r--r--linux/drivers/media/video/tda8290.h4
-rw-r--r--linux/drivers/media/video/tuner-core.c4
-rw-r--r--linux/drivers/media/video/tvp5150.c11
10 files changed, 509 insertions, 285 deletions
diff --git a/linux/Documentation/video4linux/CARDLIST.em28xx b/linux/Documentation/video4linux/CARDLIST.em28xx
index abdcc68d4..f809834af 100644
--- a/linux/Documentation/video4linux/CARDLIST.em28xx
+++ b/linux/Documentation/video4linux/CARDLIST.em28xx
@@ -1,9 +1,9 @@
0 -> Unknown EM2800 video grabber (em2800) [eb1a:2800]
- 1 -> Unknown EM2820/2840 video grabber (em2820/em2840)
+ 1 -> Unknown EM2750/28xx video grabber (em2820/em2840) [eb1a:2750,eb1a:2820,eb1a:2821,eb1a:2860,eb1a:2861,eb1a:2870,eb1a:2881,eb1a:2883]
2 -> Terratec Cinergy 250 USB (em2820/em2840) [0ccd:0036]
3 -> Pinnacle PCTV USB 2 (em2820/em2840) [2304:0208]
4 -> Hauppauge WinTV USB 2 (em2820/em2840) [2040:4200]
- 5 -> MSI VOX USB 2.0 (em2820/em2840) [eb1a:2820]
+ 5 -> MSI VOX USB 2.0 (em2820/em2840)
6 -> Terratec Cinergy 200 USB (em2800)
7 -> Leadtek Winfast USB II (em2800)
8 -> Kworld USB2800 (em2800)
@@ -12,3 +12,5 @@
11 -> Terratec Hybrid XS (em2880)
12 -> Kworld PVR TV 2800 RF (em2820/em2840)
13 -> Terratec Prodigy XS (em2880)
+ 14 -> Pixelview Prolink PlayTV USB 2.0 (em2820/em2840)
+ 15 -> V-Gear PocketTV (em2800)
diff --git a/linux/drivers/media/video/Kconfig b/linux/drivers/media/video/Kconfig
index 8a164bd1c..6c7835629 100644
--- a/linux/drivers/media/video/Kconfig
+++ b/linux/drivers/media/video/Kconfig
@@ -372,7 +372,7 @@ endmenu # encoder / decoder chips
config VIDEO_VIVI
tristate "Virtual Video Driver"
- depends on VIDEO_V4L2 && !SPARC32 && !SPARC64 && PCI
+ depends on VIDEO_V4L2 && !SPARC32 && !SPARC64
select VIDEOBUF_VMALLOC
default n
---help---
diff --git a/linux/drivers/media/video/em28xx/em28xx-cards.c b/linux/drivers/media/video/em28xx/em28xx-cards.c
index 29407d8d7..624d3c37f 100644
--- a/linux/drivers/media/video/em28xx/em28xx-cards.c
+++ b/linux/drivers/media/video/em28xx/em28xx-cards.c
@@ -38,6 +38,16 @@
#include "em28xx.h"
#include "tuner-xc2028.h"
+static int tuner = -1;
+module_param(tuner, int, 0444);
+MODULE_PARM_DESC(tuner, "tuner type");
+
+struct em28xx_hash_table {
+ unsigned long hash;
+ unsigned int model;
+ unsigned int tuner;
+};
+
struct em28xx_board em28xx_boards[] = {
[EM2800_BOARD_UNKNOWN] = {
.name = "Unknown EM2800 video grabber",
@@ -58,22 +68,8 @@ struct em28xx_board em28xx_boards[] = {
}},
},
[EM2820_BOARD_UNKNOWN] = {
- .name = "Unknown EM2820/2840 video grabber",
+ .name = "Unknown EM2750/28xx video grabber",
.is_em2800 = 0,
- .vchannels = 2,
- .norm = VIDEO_MODE_PAL,
- .tda9887_conf = TDA9887_PRESENT,
- .has_tuner = 1,
- .decoder = EM28XX_SAA7113,
- .input = {{
- .type = EM28XX_VMUX_COMPOSITE1,
- .vmux = SAA7115_COMPOSITE0,
- .amux = 1,
- },{
- .type = EM28XX_VMUX_SVIDEO,
- .vmux = SAA7115_SVIDEO3,
- .amux = 1,
- }},
},
[EM2820_BOARD_KWORLD_PVRTV2800RF] = {
.name = "Kworld PVR TV 2800 RF",
@@ -333,13 +329,63 @@ struct em28xx_board em28xx_boards[] = {
.amux = 1,
}},
},
+ [EM2800_BOARD_VGEAR_POCKETTV] = {
+ .name = "V-Gear PocketTV",
+ .is_em2800 = 1,
+ .vchannels = 3,
+ .norm = VIDEO_MODE_PAL,
+ .tuner_type = TUNER_LG_PAL_NEW_TAPC,
+ .tda9887_conf = TDA9887_PRESENT,
+ .has_tuner = 1,
+ .decoder = EM28XX_SAA7113,
+ .input = {{
+ .type = EM28XX_VMUX_TELEVISION,
+ .vmux = SAA7115_COMPOSITE2,
+ .amux = 0,
+ },{
+ .type = EM28XX_VMUX_COMPOSITE1,
+ .vmux = SAA7115_COMPOSITE0,
+ .amux = 1,
+ },{
+ .type = EM28XX_VMUX_SVIDEO,
+ .vmux = SAA7115_SVIDEO3,
+ .amux = 1,
+ }},
+ },
+ [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
+ .name = "Pixelview Prolink PlayTV USB 2.0",
+ .vchannels = 3,
+ .tda9887_conf = TDA9887_PRESENT,
+ .has_tuner = 1,
+ .decoder = EM28XX_SAA7113,
+ .input = {{
+ .type = EM28XX_VMUX_TELEVISION,
+ .vmux = SAA7115_COMPOSITE2,
+ .amux = 1,
+ },{
+ .type = EM28XX_VMUX_COMPOSITE1,
+ .vmux = SAA7115_COMPOSITE0,
+ .amux = 1,
+ },{
+ .type = EM28XX_VMUX_SVIDEO,
+ .vmux = SAA7115_SVIDEO3,
+ .amux = 1,
+ }},
+ },
};
const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
/* table of devices that work with this driver */
struct usb_device_id em28xx_id_table [] = {
+ { USB_DEVICE(0xeb1a, 0x2750), .driver_info = EM2820_BOARD_UNKNOWN },
{ USB_DEVICE(0xeb1a, 0x2800), .driver_info = EM2800_BOARD_UNKNOWN },
- { USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_MSI_VOX_USB_2 },
+ { USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_UNKNOWN },
+ { USB_DEVICE(0xeb1a, 0x2821), .driver_info = EM2820_BOARD_UNKNOWN },
+ { USB_DEVICE(0xeb1a, 0x2860), .driver_info = EM2820_BOARD_UNKNOWN },
+ { USB_DEVICE(0xeb1a, 0x2861), .driver_info = EM2820_BOARD_UNKNOWN },
+ { USB_DEVICE(0xeb1a, 0x2870), .driver_info = EM2820_BOARD_UNKNOWN },
+ { USB_DEVICE(0xeb1a, 0x2881), .driver_info = EM2820_BOARD_UNKNOWN },
+ { USB_DEVICE(0xeb1a, 0x2883), .driver_info = EM2820_BOARD_UNKNOWN },
{ USB_DEVICE(0x0ccd, 0x0036), .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
{ USB_DEVICE(0x2304, 0x0208), .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
{ USB_DEVICE(0x2040, 0x4200), .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
@@ -350,70 +396,228 @@ struct usb_device_id em28xx_id_table [] = {
{ USB_DEVICE(0x0ccd, 0x0047), .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
{ },
};
+MODULE_DEVICE_TABLE (usb, em28xx_id_table);
+/* EEPROM hash table for devices with generic USB IDs */
+static struct em28xx_hash_table em28xx_eeprom_hash [] = {
+ /* P/N: SA 60002070465 Tuner: TVF7533-MF */
+ { 0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF },
+};
+
+/* I2C devicelist hash table for devices with generic USB IDs */
+static struct em28xx_hash_table em28xx_i2c_hash[] = {
+ { 0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC },
+ { 0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC },
+};
+
+/* Since em28xx_pre_card_setup() requires a proper dev->model,
+ * this won't work for boards with generic PCI IDs
+ */
void em28xx_pre_card_setup(struct em28xx *dev)
{
/* request some modules */
switch(dev->model){
- case EM2880_BOARD_TERRATEC_PRODIGY_XS:
- case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
- case EM2880_BOARD_TERRATEC_HYBRID_XS:
- {
- em28xx_write_regs_req(dev, 0x00, 0x08, "\x7d", 1); // reset through GPIO?
- break;
- }
+ case EM2880_BOARD_TERRATEC_PRODIGY_XS:
+ case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
+ case EM2880_BOARD_TERRATEC_HYBRID_XS:
+ /* reset through GPIO? */
+ em28xx_write_regs_req(dev, 0x00, 0x08, "\x7d", 1);
+ break;
}
}
+static int em28xx_tuner_callback(void *ptr, int command, int arg)
+{
+ int rc = 0;
+ struct em28xx *dev = ptr;
+
+ if (dev->tuner_type != TUNER_XC2028)
+ return 0;
+
+ switch (command) {
+ case XC2028_TUNER_RESET:
+ /* FIXME: This is device-dependent */
+ dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
+ dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1);
+
+ msleep(140);
+ break;
+ }
+ return rc;
+}
+
static void em28xx_config_tuner (struct em28xx *dev)
{
struct v4l2_priv_tun_config xc2028_cfg;
struct xc2028_ctrl ctl;
+ struct tuner_setup tun_setup;
+ struct v4l2_frequency f;
+
+ if (!dev->has_tuner)
+ return;
+
+ tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
+ tun_setup.type = dev->tuner_type;
+ tun_setup.addr = dev->tuner_addr;
+ tun_setup.tuner_callback = em28xx_tuner_callback;
+
+ em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
+
+ if (dev->tuner_type == TUNER_XC2028) {
+ memset (&ctl, 0, sizeof(ctl));
+
+ ctl.fname = XC2028_DEFAULT_FIRMWARE;
+ ctl.max_len = 64;
+
+ xc2028_cfg.tuner = TUNER_XC2028;
+ xc2028_cfg.priv = &ctl;
+
+ em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
+ }
+
+ /* configure tuner */
+ f.tuner = 0;
+ f.type = V4L2_TUNER_ANALOG_TV;
+ f.frequency = 9076; /* just a magic number */
+ dev->ctl_freq = f.frequency;
+ em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
+}
- memset (&ctl,0,sizeof(ctl));
+static int em28xx_hint_board(struct em28xx *dev)
+{
+ int i;
- ctl.fname = XC2028_DEFAULT_FIRMWARE;
- ctl.max_len = 64;
+ /* HINT method: EEPROM
+ *
+ * This method works only for boards with eeprom.
+ * Uses a hash of all eeprom bytes. The hash should be
+ * unique for a vendor/tuner pair.
+ * There are a high chance that tuners for different
+ * video standards produce different hashes.
+ */
+ for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
+ if (dev->hash == em28xx_eeprom_hash[i].hash) {
+ dev->model = em28xx_eeprom_hash[i].model;
+ dev->tuner_type = em28xx_eeprom_hash[i].tuner;
+
+ em28xx_errdev("Your board has no unique USB ID.\n");
+ em28xx_errdev("A hint were successfully done, "
+ "based on eeprom hash.\n");
+ em28xx_errdev("This method is not 100%% failproof.\n");
+ em28xx_errdev("If the board were missdetected, "
+ "please email this log to:\n");
+ em28xx_errdev("\tV4L Mailing List "
+ " <video4linux-list@redhat.com>\n");
+ em28xx_errdev("Board detected as %s\n",
+ em28xx_boards[dev->model].name);
+
+ return 0;
+ }
+ }
- xc2028_cfg.tuner = TUNER_XC2028;
- xc2028_cfg.priv = &ctl;
+ /* HINT method: I2C attached devices
+ *
+ * This method works for all boards.
+ * Uses a hash of i2c scanned devices.
+ * Devices with the same i2c attached chips will
+ * be considered equal.
+ * This method is less precise than the eeprom one.
+ */
- em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
+ /* user did not request i2c scanning => do it now */
+ if (!dev->i2c_hash)
+ em28xx_do_i2c_scan(dev);
+
+ for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
+ if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
+ dev->model = em28xx_i2c_hash[i].model;
+ dev->tuner_type = em28xx_i2c_hash[i].tuner;
+ em28xx_errdev("Your board has no unique USB ID.\n");
+ em28xx_errdev("A hint were successfully done, "
+ "based on i2c devicelist hash.\n");
+ em28xx_errdev("This method is not 100%% failproof.\n");
+ em28xx_errdev("If the board were missdetected, "
+ "please email this log to:\n");
+ em28xx_errdev("\tV4L Mailing List "
+ " <video4linux-list@redhat.com>\n");
+ em28xx_errdev("Board detected as %s\n",
+ em28xx_boards[dev->model].name);
+
+ return 0;
+ }
+ }
+
+ em28xx_errdev("Your board has no unique USB ID and thus need a "
+ "hint to be detected.\n");
+ em28xx_errdev("You may try to use card=<n> insmod option to "
+ "workaround that.\n");
+ em28xx_errdev("Please send an email with this log to:\n");
+ em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
+ em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
+ em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
+
+ em28xx_errdev("Here is a list of valid choices for the card=<n>"
+ " insmod option:\n");
+ for (i = 0; i < em28xx_bcount; i++) {
+ em28xx_errdev(" card=%d -> %s\n",
+ i, em28xx_boards[i].name);
+ }
+ return -1;
}
void em28xx_card_setup(struct em28xx *dev)
{
/* request some modules */
- switch(dev->model){
- case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
- {
- struct tveeprom tv;
+ switch (dev->model) {
+ case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
+ {
+ struct tveeprom tv;
#ifdef CONFIG_MODULES
- request_module("tveeprom");
- request_module("ir-kbd-i2c");
- request_module("msp3400");
+ request_module("tveeprom");
+ request_module("ir-kbd-i2c");
#endif
- /* Call first TVeeprom */
-
- dev->i2c_client.addr = 0xa0 >> 1;
- tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
-
- dev->tuner_type= tv.tuner_type;
- if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
- dev->i2s_speed=2048000;
- dev->has_msp34xx=1;
- } else
- dev->has_msp34xx=0;
- break;
- }
- case EM2820_BOARD_KWORLD_PVRTV2800RF:
- {
- em28xx_write_regs_req(dev,0x00,0x08, "\xf9", 1); // GPIO enables sound on KWORLD PVR TV 2800RF
- break;
- }
+ /* Call first TVeeprom */
+
+ dev->i2c_client.addr = 0xa0 >> 1;
+ tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
+ dev->tuner_type = tv.tuner_type;
+ if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
+ dev->i2s_speed = 2048000;
+ dev->has_msp34xx = 1;
+ }
+ break;
+ }
+ case EM2820_BOARD_KWORLD_PVRTV2800RF:
+ /* GPIO enables sound on KWORLD PVR TV 2800RF */
+ em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
+ break;
+ case EM2820_BOARD_UNKNOWN:
+ case EM2800_BOARD_UNKNOWN:
+ em28xx_hint_board(dev);
}
+
+ dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
+ dev->has_tuner = em28xx_boards[dev->model].has_tuner;
+ dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
+ dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
+ dev->decoder = em28xx_boards[dev->model].decoder;
+ dev->video_inputs = em28xx_boards[dev->model].vchannels;
+
+ if (tuner >= 0)
+ dev->tuner_type = tuner;
+
+#ifdef CONFIG_MODULES
+ /* request some modules */
+ if (dev->has_msp34xx)
+ request_module("msp3400");
+ if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
+ request_module("saa7115");
+ if (dev->decoder == EM28XX_TVP5150)
+ request_module("tvp5150");
+ if (dev->has_tuner)
+ request_module("tuner");
+#endif
+
em28xx_config_tuner (dev);
}
-
-MODULE_DEVICE_TABLE (usb, em28xx_id_table);
diff --git a/linux/drivers/media/video/em28xx/em28xx-i2c.c b/linux/drivers/media/video/em28xx/em28xx-i2c.c
index 833c439bc..52374fb71 100644
--- a/linux/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/linux/drivers/media/video/em28xx/em28xx-i2c.c
@@ -292,6 +292,31 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
return rc;
}
+/* based on linux/sunrpc/svcauth.h and linux/hash.h
+ * The original hash function returns a different value, if arch is x86_64
+ * or i386.
+ */
+static inline unsigned long em28xx_hash_mem(char *buf, int length, int bits)
+{
+ unsigned long hash = 0;
+ unsigned long l = 0;
+ int len = 0;
+ unsigned char c;
+ do {
+ if (len == length) {
+ c = (char)len;
+ len = -1;
+ } else
+ c = *buf++;
+ l = (l << 8) | c;
+ len++;
+ if ((len & (32 / 8 - 1)) == 0)
+ hash = ((hash^l) * 0x9e370001UL);
+ } while (len);
+
+ return (hash >> (32 - bits)) & 0xffffffffUL;
+}
+
static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len)
{
unsigned char buf, *p = eedata;
@@ -335,7 +360,11 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len)
printk("\n");
}
- printk(KERN_INFO "EEPROM ID= 0x%08x\n", em_eeprom->id);
+ if (em_eeprom->id == 0x9567eb1a)
+ dev->hash = em28xx_hash_mem(eedata, len, 32);
+
+ printk(KERN_INFO "EEPROM ID= 0x%08x, hash = 0x%08lx\n",
+ em_eeprom->id, dev->hash);
printk(KERN_INFO "Vendor/Product ID= %04x:%04x\n", em_eeprom->vendor_ID,
em_eeprom->product_ID);
@@ -403,43 +432,6 @@ static void dec_use(struct i2c_adapter *adap)
}
#endif
-static int em28xx_tuner_callback(void *ptr, int command, int arg)
-{
- int rc = 0;
- struct em28xx *dev = ptr;
-
- if (dev->tuner_type != TUNER_XC2028)
- return 0;
-
- switch (command) {
- case XC2028_TUNER_RESET:
- /* FIXME: This is device-dependent */
- dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
- dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1);
-
- msleep(140);
- break;
- }
- return rc;
-}
-
-static int em28xx_set_tuner(int check_eeprom, struct i2c_client *client)
-{
- struct em28xx *dev = client->adapter->algo_data;
- struct tuner_setup tun_setup;
-
- if (dev->has_tuner) {
- tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
- tun_setup.type = dev->tuner_type;
- tun_setup.addr = dev->tuner_addr;
- tun_setup.tuner_callback = em28xx_tuner_callback;
-
- em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
- }
-
- return (0);
-}
-
/*
* attach_inform()
* gets called when a device attaches to the i2c bus
@@ -498,9 +490,11 @@ static int attach_inform(struct i2c_client *client)
break;
default:
+ if (!dev->tuner_addr)
+ dev->tuner_addr = client->addr;
+
dprintk1(1,"attach inform: detected I2C address %x\n", client->addr << 1);
- dev->tuner_addr = client->addr;
- em28xx_set_tuner(-1, client);
+
}
return 0;
@@ -560,19 +554,26 @@ static char *i2c_devs[128] = {
* do_i2c_scan()
* check i2c address range for devices
*/
-static void do_i2c_scan(char *name, struct i2c_client *c)
+void em28xx_do_i2c_scan(struct em28xx *dev)
{
+ u8 i2c_devicelist[128];
unsigned char buf;
int i, rc;
+ memset(i2c_devicelist, 0, ARRAY_SIZE(i2c_devicelist));
+
for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) {
- c->addr = i;
- rc = i2c_master_recv(c, &buf, 0);
+ dev->i2c_client.addr = i;
+ rc = i2c_master_recv(&dev->i2c_client, &buf, 0);
if (rc < 0)
continue;
- printk(KERN_INFO "%s: found i2c device @ 0x%x [%s]\n", name,
- i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
+ i2c_devicelist[i] = i;
+ printk(KERN_INFO "%s: found i2c device @ 0x%x [%s]\n",
+ dev->name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
}
+
+ dev->i2c_hash = em28xx_hash_mem(i2c_devicelist,
+ ARRAY_SIZE(i2c_devicelist), 32);
}
/*
@@ -605,7 +606,7 @@ int em28xx_i2c_register(struct em28xx *dev)
em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata));
if (i2c_scan)
- do_i2c_scan(dev->name, &dev->i2c_client);
+ em28xx_do_i2c_scan(dev);
return 0;
}
diff --git a/linux/drivers/media/video/em28xx/em28xx-video.c b/linux/drivers/media/video/em28xx/em28xx-video.c
index d3bb65306..c75111219 100644
--- a/linux/drivers/media/video/em28xx/em28xx-video.c
+++ b/linux/drivers/media/video/em28xx/em28xx-video.c
@@ -39,7 +39,6 @@
#endif
#include "em28xx.h"
-#include <media/tuner.h>
#include <media/v4l2-common.h>
#include <media/msp3400.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
@@ -89,10 +88,6 @@ MODULE_PARM_DESC(card,"card type");
MODULE_PARM_DESC(video_nr,"video device numbers");
MODULE_PARM_DESC(vbi_nr,"vbi device numbers");
-static int tuner = -1;
-module_param(tuner, int, 0444);
-MODULE_PARM_DESC(tuner, "tuner type");
-
static unsigned int video_debug = 0;
module_param(video_debug,int,0644);
MODULE_PARM_DESC(video_debug,"enable debug messages [video]");
@@ -149,8 +144,6 @@ static struct v4l2_queryctrl em28xx_qctrl[] = {
static struct usb_driver em28xx_usb_driver;
-static DEFINE_MUTEX(em28xx_sysfs_lock);
-static DECLARE_RWSEM(em28xx_disconnect);
/********************* v4l2 interface ******************************************/
@@ -162,7 +155,8 @@ static int em28xx_config(struct em28xx *dev)
{
/* Sets I2C speed to 100 KHz */
- em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1);
+ if (!dev->is_em2800)
+ em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1);
#if 1
/* enable vbi capturing */
@@ -190,7 +184,6 @@ static int em28xx_config(struct em28xx *dev)
*/
static void em28xx_config_i2c(struct em28xx *dev)
{
- struct v4l2_frequency f;
struct v4l2_routing route;
route.input = INPUT(dev->ctl_input)->vmux;
@@ -198,13 +191,6 @@ static void em28xx_config_i2c(struct em28xx *dev)
em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, NULL);
em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route);
em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL);
-
- /* configure tuner */
- f.tuner = 0;
- f.type = V4L2_TUNER_ANALOG_TV;
- f.frequency = 9076; /* FIXME:remove magic number */
- dev->ctl_freq = f.frequency;
- em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
}
/*
@@ -285,22 +271,18 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
em28xx_videodbg("open minor=%d type=%s users=%d\n",
minor,v4l2_type_names[dev->type],dev->users);
- if (!down_read_trylock(&em28xx_disconnect))
- return -ERESTARTSYS;
+ mutex_lock(&dev->lock);
if (dev->users) {
em28xx_warn("this driver can be opened only once\n");
- up_read(&em28xx_disconnect);
+ mutex_unlock(&dev->lock);
return -EBUSY;
}
- mutex_init(&dev->fileop_lock); /* to 1 == available */
spin_lock_init(&dev->queue_lock);
init_waitqueue_head(&dev->wait_frame);
init_waitqueue_head(&dev->wait_stream);
- mutex_lock(&dev->lock);
-
if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
em28xx_set_alternate(dev);
@@ -338,7 +320,6 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
err:
mutex_unlock(&dev->lock);
- up_read(&em28xx_disconnect);
return errCode;
}
@@ -349,7 +330,6 @@ err:
*/
static void em28xx_release_resources(struct em28xx *dev)
{
- mutex_lock(&em28xx_sysfs_lock);
/*FIXME: I2C IR should be disconnected */
@@ -361,7 +341,6 @@ static void em28xx_release_resources(struct em28xx *dev)
video_unregister_device(dev->vbi_dev);
em28xx_i2c_unregister(dev);
usb_put_dev(dev->udev);
- mutex_unlock(&em28xx_sysfs_lock);
#if 0 /* Fixme: disallocating these generates kernel hang */
kfree (dev->vdev);
@@ -425,6 +404,8 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
int ret = 0;
struct em28xx *dev = filp->private_data;
+ mutex_lock(&dev->lock);
+
if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
em28xx_videodbg("V4l2_Buf_type_videocapture is set\n");
}
@@ -432,47 +413,46 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
em28xx_videodbg("V4L2_BUF_TYPE_VBI_CAPTURE is set\n");
em28xx_videodbg("not supported yet! ...\n");
if (copy_to_user(buf, "", 1)) {
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -EFAULT;
}
+ mutex_unlock(&dev->lock);
return (1);
}
if (dev->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) {
em28xx_videodbg("V4L2_BUF_TYPE_SLICED_VBI_CAPTURE is set\n");
em28xx_videodbg("not supported yet! ...\n");
if (copy_to_user(buf, "", 1)) {
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -EFAULT;
}
+ mutex_unlock(&dev->lock);
return (1);
}
- if (mutex_lock_interruptible(&dev->fileop_lock))
- return -ERESTARTSYS;
-
if (dev->state & DEV_DISCONNECTED) {
em28xx_videodbg("device not present\n");
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -ENODEV;
}
if (dev->state & DEV_MISCONFIGURED) {
em28xx_videodbg("device misconfigured; close and open it again\n");
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -EIO;
}
if (dev->io == IO_MMAP) {
em28xx_videodbg ("IO method is set to mmap; close and open"
" the device again to choose the read method\n");
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -EINVAL;
}
if (dev->io == IO_NONE) {
if (!em28xx_request_buffers(dev, EM28XX_NUM_READ_FRAMES)) {
em28xx_errdev("read failed, not enough memory\n");
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -ENOMEM;
}
dev->io = IO_READ;
@@ -481,13 +461,13 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
}
if (!count) {
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return 0;
}
if (list_empty(&dev->outqueue)) {
if (filp->f_flags & O_NONBLOCK) {
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -EAGAIN;
}
ret = wait_event_interruptible
@@ -495,11 +475,11 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
(!list_empty(&dev->outqueue)) ||
(dev->state & DEV_DISCONNECTED));
if (ret) {
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return ret;
}
if (dev->state & DEV_DISCONNECTED) {
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -ENODEV;
}
}
@@ -518,12 +498,12 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
count = f->buf.length;
if (copy_to_user(buf, f->bufmem, count)) {
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -EFAULT;
}
*f_pos += count;
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return count;
}
@@ -537,8 +517,7 @@ static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait)
unsigned int mask = 0;
struct em28xx *dev = filp->private_data;
- if (mutex_lock_interruptible(&dev->fileop_lock))
- return POLLERR;
+ mutex_lock(&dev->lock);
if (dev->state & DEV_DISCONNECTED) {
em28xx_videodbg("device not present\n");
@@ -563,13 +542,13 @@ static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait)
if (!list_empty(&dev->outqueue))
mask |= POLLIN | POLLRDNORM;
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return mask;
}
}
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return POLLERR;
}
@@ -609,25 +588,24 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
struct em28xx *dev = filp->private_data;
- if (mutex_lock_interruptible(&dev->fileop_lock))
- return -ERESTARTSYS;
+ mutex_lock(&dev->lock);
if (dev->state & DEV_DISCONNECTED) {
em28xx_videodbg("mmap: device not present\n");
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -ENODEV;
}
if (dev->state & DEV_MISCONFIGURED) {
em28xx_videodbg ("mmap: Device is misconfigured; close and "
"open it again\n");
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -EIO;
}
if (dev->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) ||
size != PAGE_ALIGN(dev->frame[0].buf.length)) {
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -EINVAL;
}
@@ -637,7 +615,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
}
if (i == dev->num_frames) {
em28xx_videodbg("mmap: user supplied mapping address is out of range\n");
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -EINVAL;
}
@@ -649,7 +627,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
while (size > 0) { /* size is page-aligned */
if (vm_insert_page(vma, start, vmalloc_to_page(pos))) {
em28xx_videodbg("mmap: vm_insert_page failed\n");
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return -EAGAIN;
}
start += PAGE_SIZE;
@@ -661,7 +639,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
vma->vm_private_data = &dev->frame[i];
em28xx_vm_open(vma);
- mutex_unlock(&dev->fileop_lock);
+ mutex_unlock(&dev->lock);
return 0;
}
@@ -1148,7 +1126,9 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
}
}
}
+ mutex_lock(&dev->lock);
em28xx_i2c_call_clients(dev,cmd,qc);
+ mutex_unlock(&dev->lock);
if (qc->type)
return 0;
else
@@ -1162,7 +1142,9 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
if (!dev->has_msp34xx)
retval=em28xx_get_ctrl(dev, ctrl);
if (retval==-EINVAL) {
+ mutex_lock(&dev->lock);
em28xx_i2c_call_clients(dev,cmd,arg);
+ mutex_unlock(&dev->lock);
return 0;
} else return retval;
}
@@ -1170,21 +1152,26 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
{
struct v4l2_control *ctrl = arg;
u8 i;
+ mutex_lock(&dev->lock);
if (!dev->has_msp34xx){
for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) {
if (ctrl->id == em28xx_qctrl[i].id) {
+ int retval=-EINVAL;
if (ctrl->value <
em28xx_qctrl[i].minimum
|| ctrl->value >
em28xx_qctrl[i].maximum)
return -ERANGE;
- return em28xx_set_ctrl(dev, ctrl);
+ retval = em28xx_set_ctrl(dev, ctrl);
+ mutex_unlock(&dev->lock);
+ return retval;
}
}
}
em28xx_i2c_call_clients(dev,cmd,arg);
+ mutex_unlock(&dev->lock);
return 0;
}
/* --- tuner ioctls ------------------------------------------ */
@@ -1292,12 +1279,16 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
|| dev->io != IO_MMAP)
return -EINVAL;
+ mutex_lock(&dev->lock);
if (dev->stream == STREAM_ON) {
em28xx_videodbg ("VIDIOC_STREAMOFF: interrupting stream\n");
- if ((ret = em28xx_stream_interrupt(dev)))
+ if ((ret = em28xx_stream_interrupt(dev))){
+ mutex_unlock(&dev->lock);
return ret;
+ }
}
em28xx_empty_framequeues(dev);
+ mutex_unlock(&dev->lock);
return 0;
}
@@ -1366,11 +1357,23 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
return 0;
}
case VIDIOC_G_FMT:
- return em28xx_get_fmt(dev, (struct v4l2_format *) arg);
+ {
+ int retval;
+ mutex_lock(&dev->lock);
+ retval = em28xx_get_fmt(dev, (struct v4l2_format *) arg);
+ mutex_unlock(&dev->lock);
+ return retval;
+ }
case VIDIOC_TRY_FMT:
case VIDIOC_S_FMT:
- return em28xx_set_fmt(dev, cmd, (struct v4l2_format *)arg);
+ {
+ int retval;
+ mutex_lock(&dev->lock);
+ retval = em28xx_set_fmt(dev, cmd, (struct v4l2_format *)arg);
+ mutex_unlock(&dev->lock);
+ return retval;
+ }
#if 0
case VIDIOCGMBUF:
@@ -1421,10 +1424,13 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
return -EINVAL;
}
+ mutex_lock(&dev->lock);
if (dev->stream == STREAM_ON) {
em28xx_videodbg("VIDIOC_REQBUFS: interrupting stream\n");
- if ((ret = em28xx_stream_interrupt(dev)))
+ if ((ret = em28xx_stream_interrupt(dev))){
+ mutex_unlock(&dev->lock);
return ret;
+ }
}
em28xx_empty_framequeues(dev);
@@ -1439,6 +1445,7 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
em28xx_videodbg ("VIDIOC_REQBUFS: setting io method to mmap: num bufs %i\n",
rb->count);
dev->io = rb->count ? IO_MMAP : IO_NONE;
+ mutex_unlock(&dev->lock);
return 0;
}
case VIDIOC_QUERYBUF:
@@ -1540,26 +1547,19 @@ static int em28xx_v4l2_ioctl(struct inode *inode, struct file *filp,
int ret = 0;
struct em28xx *dev = filp->private_data;
- if (mutex_lock_interruptible(&dev->fileop_lock))
- return -ERESTARTSYS;
-
if (dev->state & DEV_DISCONNECTED) {
em28xx_errdev("v4l2 ioctl: device not present\n");
- mutex_unlock(&dev->fileop_lock);
return -ENODEV;
}
if (dev->state & DEV_MISCONFIGURED) {
em28xx_errdev
("v4l2 ioctl: device is misconfigured; close and open it again\n");
- mutex_unlock(&dev->fileop_lock);
return -EIO;
}
ret = video_usercopy(inode, filp, cmd, arg, em28xx_video_do_ioctl);
- mutex_unlock(&dev->fileop_lock);
-
return ret;
}
@@ -1585,7 +1585,7 @@ static const struct file_operations em28xx_v4l_fops = {
* allocates and inits the device structs, registers i2c bus and v4l device
*/
static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
- int minor, int model)
+ int minor)
{
struct em28xx *dev = *devhandle;
int retval = -ENOMEM;
@@ -1593,7 +1593,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
unsigned int maxh, maxw;
dev->udev = udev;
- dev->model = model;
mutex_init(&dev->lock);
init_waitqueue_head(&dev->open);
@@ -1602,43 +1601,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
dev->em28xx_write_regs_req = em28xx_write_regs_req;
dev->em28xx_read_reg_req = em28xx_read_reg_req;
- dev->is_em2800 = em28xx_boards[model].is_em2800;
- dev->has_tuner = em28xx_boards[model].has_tuner;
- dev->has_msp34xx = em28xx_boards[model].has_msp34xx;
- dev->tda9887_conf = em28xx_boards[model].tda9887_conf;
- dev->decoder = em28xx_boards[model].decoder;
-
- if (tuner >= 0)
- dev->tuner_type = tuner;
- else
- dev->tuner_type = em28xx_boards[model].tuner_type;
-
- dev->video_inputs = em28xx_boards[model].vchannels;
-
- for (i = 0; i < TVNORMS; i++)
- if (em28xx_boards[model].norm == tvnorms[i].mode)
- break;
- if (i == TVNORMS)
- i = 0;
-
- dev->tvnorm = &tvnorms[i]; /* set default norm */
-
- em28xx_videodbg("tvnorm=%s\n", dev->tvnorm->name);
-
- maxw = norm_maxw(dev);
- maxh = norm_maxh(dev);
-
- /* set default image size */
- dev->width = maxw;
- dev->height = maxh;
- dev->interlaced = EM28XX_INTERLACED_DEFAULT;
- dev->field_size = dev->width * dev->height;
- dev->frame_size =
- dev->interlaced ? dev->field_size << 1 : dev->field_size;
- dev->bytesperline = dev->width * 2;
- dev->hscale = 0;
- dev->vscale = 0;
- dev->ctl_input = 2;
+ dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
/* setup video picture settings for saa7113h */
memset(&dev->vpic, 0, sizeof(dev->vpic));
@@ -1651,24 +1614,15 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
dev->vpic.palette = VIDEO_PALETTE_YUV422;
em28xx_pre_card_setup(dev);
-#ifdef CONFIG_MODULES
- /* request some modules */
- if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
- request_module("saa7115");
- if (dev->decoder == EM28XX_TVP5150)
- request_module("tvp5150");
- if (dev->has_tuner)
- request_module("tuner");
-#endif
+
errCode = em28xx_config(dev);
if (errCode) {
em28xx_errdev("error configuring device\n");
- em28xx_devused&=~(1<<dev->devno);
+ em28xx_devused &= ~(1<<dev->devno);
kfree(dev);
return -ENOMEM;
}
- mutex_lock(&dev->lock);
/* register i2c bus */
em28xx_i2c_register(dev);
@@ -1678,14 +1632,33 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
/* configure the device */
em28xx_config_i2c(dev);
- mutex_unlock(&dev->lock);
+ for (i = 0; i < TVNORMS; i++)
+ if (em28xx_boards[dev->model].norm == tvnorms[i].mode)
+ break;
+ if (i == TVNORMS)
+ i = 0;
+
+ dev->tvnorm = &tvnorms[i]; /* set default norm */
+
+ em28xx_videodbg("tvnorm=%s\n", dev->tvnorm->name);
+
+ maxw = norm_maxw(dev);
+ maxh = norm_maxh(dev);
+
+ /* set default image size */
+ dev->width = maxw;
+ dev->height = maxh;
+ dev->interlaced = EM28XX_INTERLACED_DEFAULT;
+ dev->field_size = dev->width * dev->height;
+ dev->frame_size =
+ dev->interlaced ? dev->field_size << 1 : dev->field_size;
+ dev->bytesperline = dev->width * 2;
+ dev->hscale = 0;
+ dev->vscale = 0;
+ dev->ctl_input = 2;
errCode = em28xx_config(dev);
-#ifdef CONFIG_MODULES
- if (dev->has_msp34xx)
- request_module("msp3400");
-#endif
/* allocate and fill v4l2 device struct */
dev->vdev = video_device_alloc();
if (NULL == dev->vdev) {
@@ -1732,8 +1705,18 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
video_set_drvdata(dev->vbi_dev, dev);
#endif
+
+ if (dev->has_msp34xx) {
+ /* Send a reset to other chips via gpio */
+ em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1);
+ msleep(3);
+ em28xx_write_regs_req(dev, 0x00, 0x08, "\xff", 1);
+ msleep(3);
+
+ }
+ video_mux(dev, 0);
+
/* register v4l2 device */
- mutex_lock(&dev->lock);
if ((retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
video_nr[dev->devno]))) {
em28xx_errdev("unable to register video device (error=%i).\n",
@@ -1760,18 +1743,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
printk("registered VBI\n");
}
- if (dev->has_msp34xx) {
- /* Send a reset to other chips via gpio */
- em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1);
- msleep(3);
- em28xx_write_regs_req(dev, 0x00, 0x08, "\xff", 1);
- msleep(3);
-
- }
- video_mux(dev, 0);
-
- mutex_unlock(&dev->lock);
-
em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n",
dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN,
dev->vbi_dev->minor-MINOR_VFL_TYPE_VBI_MIN);
@@ -1791,7 +1762,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
struct usb_interface *uif;
struct em28xx *dev = NULL;
int retval = -ENODEV;
- int model,i,nr,ifnum;
+ int i, nr, ifnum;
udev = usb_get_dev(interface_to_usbdev(interface));
ifnum = interface->altsetting[0].desc.bInterfaceNumber;
@@ -1831,8 +1802,6 @@ static int em28xx_usb_probe(struct usb_interface *interface,
return -ENODEV;
}
- model=id->driver_info;
-
if (nr >= EM28XX_MAXBOARDS) {
printk (DRIVER_NAME ": Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS);
em28xx_devused&=~(1<<nr);
@@ -1848,7 +1817,8 @@ static int em28xx_usb_probe(struct usb_interface *interface,
}
snprintf(dev->name, 29, "em28xx #%d", nr);
- dev->devno=nr;
+ dev->devno = nr;
+ dev->model = id->driver_info;
/* compute alternate max packet sizes */
uif = udev->actconfig->interface[0];
@@ -1875,30 +1845,14 @@ static int em28xx_usb_probe(struct usb_interface *interface,
}
if ((card[nr]>=0)&&(card[nr]<em28xx_bcount))
- model=card[nr];
-
- if ((model==EM2800_BOARD_UNKNOWN)||(model==EM2820_BOARD_UNKNOWN)) {
- em28xx_errdev( "Your board has no eeprom inside it and thus can't\n"
- "%s: be autodetected. Please pass card=<n> insmod option to\n"
- "%s: workaround that. Redirect complaints to the vendor of\n"
- "%s: the TV card. Generic type will be used."
- "%s: Best regards,\n"
- "%s: -- tux\n",
- dev->name,dev->name,dev->name,dev->name,dev->name);
- em28xx_errdev("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
- dev->name);
- for (i = 0; i < em28xx_bcount; i++) {
- em28xx_errdev(" card=%d -> %s\n", i,
- em28xx_boards[i].name);
- }
- }
+ dev->model = card[nr];
/* allocate device struct */
- retval = em28xx_init_dev(&dev, udev, nr, model);
+ retval = em28xx_init_dev(&dev, udev, nr);
if (retval)
return retval;
- em28xx_info("Found %s\n", em28xx_boards[model].name);
+ em28xx_info("Found %s\n", em28xx_boards[dev->model].name);
/* save our data pointer in this interface device */
usb_set_intfdata(interface, dev);
@@ -1912,18 +1866,19 @@ static int em28xx_usb_probe(struct usb_interface *interface,
*/
static void em28xx_usb_disconnect(struct usb_interface *interface)
{
- struct em28xx *dev = usb_get_intfdata(interface);
+ struct em28xx *dev;
+
+ dev = usb_get_intfdata(interface);
usb_set_intfdata(interface, NULL);
if (!dev)
return;
- down_write(&em28xx_disconnect);
+ em28xx_info("disconnecting %s\n", dev->vdev->name);
+ /* wait until all current v4l2 io is finished then deallocate resources */
mutex_lock(&dev->lock);
- em28xx_info("disconnecting %s\n", dev->vdev->name);
-
wake_up_interruptible_all(&dev->open);
if (dev->users) {
@@ -1942,6 +1897,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
em28xx_release_resources(dev);
}
+
mutex_unlock(&dev->lock);
if (!dev->users) {
@@ -1949,7 +1905,6 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
kfree(dev);
}
- up_write(&em28xx_disconnect);
}
static struct usb_driver em28xx_usb_driver = {
diff --git a/linux/drivers/media/video/em28xx/em28xx.h b/linux/drivers/media/video/em28xx/em28xx.h
index 8b4c54f9f..ae86a5ca7 100644
--- a/linux/drivers/media/video/em28xx/em28xx.h
+++ b/linux/drivers/media/video/em28xx/em28xx.h
@@ -49,6 +49,8 @@
#define EM2880_BOARD_TERRATEC_HYBRID_XS 11
#define EM2820_BOARD_KWORLD_PVRTV2800RF 12
#define EM2880_BOARD_TERRATEC_PRODIGY_XS 13
+#define EM2820_BOARD_PROLINK_PLAYTV_USB2 14
+#define EM2800_BOARD_VGEAR_POCKETTV 15
#define UNSET -1
@@ -260,13 +262,16 @@ struct em28xx {
int interlaced; /* 1=interlace fileds, 0=just top fileds */
int type;
+ unsigned long hash; /* eeprom hash - for boards with generic ID */
+ unsigned long i2c_hash; /* i2c devicelist hash - for boards with generic ID */
+
/* states */
enum em28xx_dev_state state;
enum em28xx_stream_state stream;
enum em28xx_io_method io;
/* locks */
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
- struct mutex lock, fileop_lock;
+ struct mutex lock;
#else
struct semaphore lock, fileop_lock;
#endif
@@ -299,6 +304,7 @@ struct em28xx {
/* Provided by em28xx-i2c.c */
void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg);
+void em28xx_do_i2c_scan(struct em28xx *dev);
int em28xx_i2c_register(struct em28xx *dev);
int em28xx_i2c_unregister(struct em28xx *dev);
@@ -339,6 +345,9 @@ extern struct em28xx_board em28xx_boards[];
extern struct usb_device_id em28xx_id_table[];
extern const unsigned int em28xx_bcount;
+/* em2800 registers */
+#define EM2800_AUDIOSRC_REG 0x08
+
/* em28xx registers */
#define CHIPID_REG 0x0a
#define USBSUSP_REG 0x0c /* */
@@ -394,6 +403,8 @@ extern const unsigned int em28xx_bcount;
#define VIDEO_AC97 0x14
/* register settings */
+#define EM2800_AUDIO_SRC_TUNER 0x0d
+#define EM2800_AUDIO_SRC_LINE 0x0c
#define EM28XX_AUDIO_SRC_TUNER 0xc0
#define EM28XX_AUDIO_SRC_LINE 0x80
@@ -415,6 +426,12 @@ extern const unsigned int em28xx_bcount;
inline static int em28xx_audio_source(struct em28xx *dev, int input)
{
+ if(dev->is_em2800){
+ u8 tmp = EM2800_AUDIO_SRC_TUNER;
+ if(input == EM28XX_AUDIO_SRC_LINE)
+ tmp = EM2800_AUDIO_SRC_LINE;
+ em28xx_write_regs(dev, EM2800_AUDIOSRC_REG, &tmp, 1);
+ }
return em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0);
}
diff --git a/linux/drivers/media/video/tda8290.c b/linux/drivers/media/video/tda8290.c
index 8026e65a8..7470f736b 100644
--- a/linux/drivers/media/video/tda8290.c
+++ b/linux/drivers/media/video/tda8290.c
@@ -663,6 +663,46 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
return 0;
}
+static int tda8290_probe(struct tuner_i2c_props *i2c_props)
+{
+#define TDA8290_ID 0x89
+ unsigned char tda8290_id[] = { 0x1f, 0x00 };
+
+ /* detect tda8290 */
+ tuner_i2c_xfer_send(i2c_props, &tda8290_id[0], 1);
+ tuner_i2c_xfer_recv(i2c_props, &tda8290_id[1], 1);
+
+ if (tda8290_id[1] == TDA8290_ID) {
+ if (tuner_debug)
+ printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n",
+ __FUNCTION__, i2c_adapter_id(i2c_props->adap),
+ i2c_props->addr);
+ return 0;
+ }
+
+ return -1;
+}
+
+static int tda8295_probe(struct tuner_i2c_props *i2c_props)
+{
+#define TDA8295_ID 0x8a
+ unsigned char tda8295_id[] = { 0x2f, 0x00 };
+
+ /* detect tda8295 */
+ tuner_i2c_xfer_send(i2c_props, &tda8295_id[0], 1);
+ tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1);
+
+ if (tda8295_id[1] == TDA8295_ID) {
+ if (tuner_debug)
+ printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n",
+ __FUNCTION__, i2c_adapter_id(i2c_props->adap),
+ i2c_props->addr);
+ return 0;
+ }
+
+ return -1;
+}
+
static struct analog_tuner_ops tda8290_tuner_ops = {
.set_tv_freq = tda8290_set_freq,
.set_radio_freq = tda8290_set_freq,
@@ -686,11 +726,6 @@ int tda829x_attach(struct tuner *t)
struct dvb_frontend *fe = &t->fe;
struct tda8290_priv *priv = NULL;
- unsigned char tda8290_id[] = { 0x1f, 0x00 };
-#define TDA8290_ID 0x89
- unsigned char tda8295_id[] = { 0x2f, 0x00 };
-#define TDA8295_ID 0x8a
-
priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL);
if (priv == NULL)
return -ENOMEM;
@@ -702,18 +737,12 @@ int tda829x_attach(struct tuner *t)
priv->cfg.tuner_callback = t->tuner_callback;
priv->t = t;
- /* detect tda8290 */
- tuner_i2c_xfer_send(&priv->i2c_props, &tda8290_id[0], 1);
- tuner_i2c_xfer_recv(&priv->i2c_props, &tda8290_id[1], 1);
- if (tda8290_id[1] == TDA8290_ID) {
+ if (tda8290_probe(&priv->i2c_props) == 0) {
priv->ver = TDA8290;
fe->ops.analog_demod_ops = &tda8290_tuner_ops;
}
- /* detect tda8295 */
- tuner_i2c_xfer_send(&priv->i2c_props, &tda8295_id[0], 1);
- tuner_i2c_xfer_recv(&priv->i2c_props, &tda8295_id[1], 1);
- if (tda8295_id[1] == TDA8295_ID) {
+ if (tda8295_probe(&priv->i2c_props) == 0) {
priv->ver = TDA8295;
fe->ops.analog_demod_ops = &tda8295_tuner_ops;
}
@@ -735,7 +764,7 @@ int tda829x_attach(struct tuner *t)
}
EXPORT_SYMBOL_GPL(tda829x_attach);
-int tda8290_probe(struct tuner *t)
+int tda829x_probe(struct tuner *t)
{
struct tuner_i2c_props i2c_props = {
.adap = t->i2c->adapter,
@@ -749,6 +778,11 @@ int tda8290_probe(struct tuner *t)
unsigned char addr_dto_lsb = 0x07;
unsigned char data;
+ if ((tda8290_probe(&i2c_props) == 0) ||
+ (tda8295_probe(&i2c_props) == 0))
+ return 0;
+
+ /* fall back to old probing method */
tuner_i2c_xfer_send(&i2c_props, easy_mode_b, 2);
tuner_i2c_xfer_send(&i2c_props, soft_reset, 2);
tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1);
@@ -765,7 +799,7 @@ int tda8290_probe(struct tuner *t)
tuner_i2c_xfer_send(&i2c_props, restore_9886, 3);
return -1;
}
-EXPORT_SYMBOL_GPL(tda8290_probe);
+EXPORT_SYMBOL_GPL(tda829x_probe);
MODULE_DESCRIPTION("Philips/NXP TDA8290/TDA8295 analog IF demodulator driver");
MODULE_AUTHOR("Gerd Knorr, Hartmut Hackmann, Michael Krufky");
diff --git a/linux/drivers/media/video/tda8290.h b/linux/drivers/media/video/tda8290.h
index 81517370b..3a1f04520 100644
--- a/linux/drivers/media/video/tda8290.h
+++ b/linux/drivers/media/video/tda8290.h
@@ -21,11 +21,11 @@
#include "tuner-driver.h"
#if defined(CONFIG_TUNER_TDA8290) || (defined(CONFIG_TUNER_TDA8290_MODULE) && defined(MODULE))
-extern int tda8290_probe(struct tuner *t);
+extern int tda829x_probe(struct tuner *t);
extern int tda829x_attach(struct tuner *t);
#else
-static inline int tda8290_probe(struct tuner *t)
+static inline int tda829x_probe(struct tuner *t)
{
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
return -EINVAL;
diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c
index 1f116878d..1285c44ab 100644
--- a/linux/drivers/media/video/tuner-core.c
+++ b/linux/drivers/media/video/tuner-core.c
@@ -688,8 +688,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr,
case 0x4b:
/* If chip is not tda8290, don't register.
since it can be tda9887*/
- if (tda8290_probe(t) == 0) {
- tuner_dbg("chip at addr %x is a tda8290\n", addr);
+ if (tda829x_probe(t) == 0) {
+ tuner_dbg("tda829x detected\n");
} else {
/* Default is being tda9887 */
t->type = TUNER_TDA9887;
diff --git a/linux/drivers/media/video/tvp5150.c b/linux/drivers/media/video/tvp5150.c
index 6be434987..1619c5ff3 100644
--- a/linux/drivers/media/video/tvp5150.c
+++ b/linux/drivers/media/video/tvp5150.c
@@ -320,6 +320,7 @@ static inline void tvp5150_selmux(struct i2c_client *c)
int opmode=0;
struct tvp5150 *decoder = i2c_get_clientdata(c);
int input = 0;
+ unsigned char val;
if ((decoder->route.output & TVP5150_BLACK_SCREEN) || !decoder->enable)
input = 8;
@@ -345,6 +346,16 @@ static inline void tvp5150_selmux(struct i2c_client *c)
tvp5150_write(c, TVP5150_OP_MODE_CTL, opmode);
tvp5150_write(c, TVP5150_VD_IN_SRC_SEL_1, input);
+
+ /* Svideo should enable YCrCb output and disable GPCL output
+ * For Composite and TV, it should be the reverse
+ */
+ val = tvp5150_read(c, TVP5150_MISC_CTL);
+ if (decoder->route.input == TVP5150_SVIDEO)
+ val = (val & ~0x40) | 0x10;
+ else
+ val = (val & ~0x10) | 0x40;
+ tvp5150_write(c, TVP5150_MISC_CTL, val);
};
struct i2c_reg_value {