aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.osdl.org>2006-12-29 13:06:41 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-29 13:06:41 -0500
commit4945b8a553ec735f416596cbf5789c439d16fb38 (patch)
treec159093b9d7ae9395dcca30ebda0e8dc8284e4a6 /drivers
parent6c722e90d7ede7db2d2b28a3cc69a8545db67ea1 (diff)
parent69f7e75a9d45e5eaca16917a8d0dedf76149f13f (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
* 'master' of master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb: (28 commits) V4L/DVB (5010): Cx88: Fix leadtek_eeprom tagging V4L/DVB (5012): Usbvision fix: It was using "&&" instead "&" V4L/DVB (5001): Add two required headers on kernel 2.6.20-rc1 V4L/DVB (5014): Allyesconfig build fixes on some non x86 arch V4L/DVB (4997): Bttv: delete duplicated ioremap() V4L/DVB (4996): Msp3400: fix kthread_run error check V4L/DVB (4995): Vivi: fix kthread_run() error check V4L/DVB (4994): Vivi: fix use after free in list_for_each() V4L/DVB (4992): Fix typo in saa7134-dvb.c V4L/DVB (4991): Cafe_ccic.c: fix NULL dereference V4L/DVB (4990): Cpia2/cpia2_usb.c: fix error-path leak V4L/DVB (4988): Cx2341x audio_properties is an u16, not u8 V4L/DVB (4984): LOG_STATUS should show the real temporal filter value. V4L/DVB (4983): Force temporal filter to 0 when scaling to prevent ghosting. V4L/DVB (4982): Fix broken audio mode handling for line-in in msp3400. V4L/DVB (4980): Fixes bug 7267: PAL/60 is not working V4L/DVB (4979): Fixes compilation when CONFIG_V4L1_COMPAT is not selected V4L/DVB (4973): Dvb-core: fix printk type warning V4L/DVB (4972): Dvb-core: fix bug in CRC-32 checking on 64-bit systems V4L/DVB (4970): Usbvision memory fixes ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/common/ir-functions.c1
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c4
-rw-r--r--drivers/media/dvb/dvb-usb/nova-t-usb2.c4
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c2
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c4
-rw-r--r--drivers/media/video/cafe_ccic.c2
-rw-r--r--drivers/media/video/cpia2/cpia2_usb.c4
-rw-r--r--drivers/media/video/cx2341x.c21
-rw-r--r--drivers/media/video/cx25840/cx25840-vbi.c9
-rw-r--r--drivers/media/video/cx88/cx88-cards.c2
-rw-r--r--drivers/media/video/cx88/cx88-core.c35
-rw-r--r--drivers/media/video/cx88/cx88.h2
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c4
-rw-r--r--drivers/media/video/meye.c4
-rw-r--r--drivers/media/video/msp3400-driver.c8
-rw-r--r--drivers/media/video/msp3400-kthreads.c11
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c8
-rw-r--r--drivers/media/video/tuner-core.c4
-rw-r--r--drivers/media/video/usbvision/usbvision-cards.c11
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c83
-rw-r--r--drivers/media/video/usbvision/usbvision-i2c.c35
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c150
-rw-r--r--drivers/media/video/usbvision/usbvision.h27
-rw-r--r--drivers/media/video/vivi.c8
-rw-r--r--drivers/media/video/w9966.c2
-rw-r--r--drivers/media/video/w9968cf.c24
-rw-r--r--drivers/media/video/zoran_device.c3
28 files changed, 240 insertions, 234 deletions
diff --git a/drivers/media/common/ir-functions.c b/drivers/media/common/ir-functions.c
index 8eaa88fd8b9b..9a8dd8764c99 100644
--- a/drivers/media/common/ir-functions.c
+++ b/drivers/media/common/ir-functions.c
@@ -23,6 +23,7 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/jiffies.h>
26#include <media/ir-common.h> 27#include <media/ir-common.h>
27 28
28/* -------------------------------------------------------------------------- */ 29/* -------------------------------------------------------------------------- */
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index ebf4dc5190f6..76e9c36597eb 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -605,7 +605,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
605 { &utype, sizeof utype }, 605 { &utype, sizeof utype },
606 { priv->ule_skb->data, priv->ule_skb->len - 4 } 606 { priv->ule_skb->data, priv->ule_skb->len - 4 }
607 }; 607 };
608 unsigned long ule_crc = ~0L, expected_crc; 608 u32 ule_crc = ~0L, expected_crc;
609 if (priv->ule_dbit) { 609 if (priv->ule_dbit) {
610 /* Set D-bit for CRC32 verification, 610 /* Set D-bit for CRC32 verification,
611 * if it was set originally. */ 611 * if it was set originally. */
@@ -618,7 +618,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
618 *((u8 *)priv->ule_skb->tail - 2) << 8 | 618 *((u8 *)priv->ule_skb->tail - 2) << 8 |
619 *((u8 *)priv->ule_skb->tail - 1); 619 *((u8 *)priv->ule_skb->tail - 1);
620 if (ule_crc != expected_crc) { 620 if (ule_crc != expected_crc) {
621 printk(KERN_WARNING "%lu: CRC32 check FAILED: %#lx / %#lx, SNDU len %d type %#x, ts_remain %d, next 2: %x.\n", 621 printk(KERN_WARNING "%lu: CRC32 check FAILED: %08x / %08x, SNDU len %d type %#x, ts_remain %d, next 2: %x.\n",
622 priv->ts_count, ule_crc, expected_crc, priv->ule_sndu_len, priv->ule_sndu_type, ts_remain, ts_remain > 2 ? *(unsigned short *)from_where : 0); 622 priv->ts_count, ule_crc, expected_crc, priv->ule_sndu_len, priv->ule_sndu_type, ts_remain, ts_remain > 2 ? *(unsigned short *)from_where : 0);
623 623
624#ifdef ULE_DEBUG 624#ifdef ULE_DEBUG
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
index d48622e76b1b..badc468170ea 100644
--- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c
+++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
@@ -90,9 +90,11 @@ static int nova_t_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
90 deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x to c: %02x d: %02x toggle: %d\n",key[1],key[2],key[3],custom,data,toggle); 90 deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x to c: %02x d: %02x toggle: %d\n",key[1],key[2],key[3],custom,data,toggle);
91 91
92 for (i = 0; i < ARRAY_SIZE(haupp_rc_keys); i++) { 92 for (i = 0; i < ARRAY_SIZE(haupp_rc_keys); i++) {
93 deb_rc("c: %x, d: %x\n",haupp_rc_keys[i].data,haupp_rc_keys[i].custom);
94 if (haupp_rc_keys[i].data == data && 93 if (haupp_rc_keys[i].data == data &&
95 haupp_rc_keys[i].custom == custom) { 94 haupp_rc_keys[i].custom == custom) {
95
96 deb_rc("c: %x, d: %x\n",haupp_rc_keys[i].data,haupp_rc_keys[i].custom);
97
96 *event = haupp_rc_keys[i].event; 98 *event = haupp_rc_keys[i].event;
97 *state = REMOTE_KEY_PRESSED; 99 *state = REMOTE_KEY_PRESSED;
98 if (st->old_toggle == toggle) { 100 if (st->old_toggle == toggle) {
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
index 5da66178006c..23aa75a27c1f 100644
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ b/drivers/media/dvb/frontends/dib3000mc.c
@@ -515,7 +515,7 @@ static int dib3000mc_autosearch_start(struct dvb_frontend *demod, struct dibx000
515 fchan.vit_alpha = 1; fchan.vit_code_rate_hp = 2; fchan.vit_code_rate_lp = 2; 515 fchan.vit_alpha = 1; fchan.vit_code_rate_hp = 2; fchan.vit_code_rate_lp = 2;
516 fchan.vit_hrch = 0; fchan.vit_select_hp = 1; 516 fchan.vit_hrch = 0; fchan.vit_select_hp = 1;
517 517
518 dib3000mc_set_channel_cfg(state, &fchan, 7); 518 dib3000mc_set_channel_cfg(state, &fchan, 11);
519 519
520 reg = dib3000mc_read_word(state, 0); 520 reg = dib3000mc_read_word(state, 0);
521 dib3000mc_write_word(state, 0, reg | (1 << 8)); 521 dib3000mc_write_word(state, 0, reg | (1 << 8));
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 29a11c1db1b7..57357db31b8a 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -668,7 +668,7 @@ config VIDEO_M32R_AR_M64278
668 668
669config VIDEO_CAFE_CCIC 669config VIDEO_CAFE_CCIC
670 tristate "Marvell 88ALP01 (Cafe) CMOS Camera Controller support" 670 tristate "Marvell 88ALP01 (Cafe) CMOS Camera Controller support"
671 depends on I2C && VIDEO_V4L2 671 depends on PCI && I2C && VIDEO_V4L2
672 select VIDEO_OV7670 672 select VIDEO_OV7670
673 ---help--- 673 ---help---
674 This is a video4linux2 driver for the Marvell 88ALP01 integrated 674 This is a video4linux2 driver for the Marvell 88ALP01 integrated
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 3c8e4742dccc..ab8f970760f2 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -4050,8 +4050,8 @@ static int __devinit bttv_probe(struct pci_dev *dev,
4050 (unsigned long long)pci_resource_start(dev,0)); 4050 (unsigned long long)pci_resource_start(dev,0));
4051 schedule(); 4051 schedule();
4052 4052
4053 btv->bt848_mmio=ioremap(pci_resource_start(dev,0), 0x1000); 4053 btv->bt848_mmio = ioremap(pci_resource_start(dev, 0), 0x1000);
4054 if (NULL == ioremap(pci_resource_start(dev,0), 0x1000)) { 4054 if (NULL == btv->bt848_mmio) {
4055 printk("bttv%d: ioremap() failed\n", btv->c.nr); 4055 printk("bttv%d: ioremap() failed\n", btv->c.nr);
4056 result = -EIO; 4056 result = -EIO;
4057 goto fail1; 4057 goto fail1;
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index e347c7ebc984..3083c8075d13 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -2166,7 +2166,7 @@ static void cafe_pci_remove(struct pci_dev *pdev)
2166 struct cafe_camera *cam = cafe_find_by_pdev(pdev); 2166 struct cafe_camera *cam = cafe_find_by_pdev(pdev);
2167 2167
2168 if (cam == NULL) { 2168 if (cam == NULL) {
2169 cam_warn(cam, "pci_remove on unknown pdev %p\n", pdev); 2169 printk(KERN_WARNING "pci_remove on unknown pdev %p\n", pdev);
2170 return; 2170 return;
2171 } 2171 }
2172 mutex_lock(&cam->s_mutex); 2172 mutex_lock(&cam->s_mutex);
diff --git a/drivers/media/video/cpia2/cpia2_usb.c b/drivers/media/video/cpia2/cpia2_usb.c
index 28dc6a1a1e43..d8e929863a88 100644
--- a/drivers/media/video/cpia2/cpia2_usb.c
+++ b/drivers/media/video/cpia2/cpia2_usb.c
@@ -640,6 +640,10 @@ static int submit_urbs(struct camera_data *cam)
640 cam->sbuf[i].data = 640 cam->sbuf[i].data =
641 kmalloc(FRAMES_PER_DESC * FRAME_SIZE_PER_DESC, GFP_KERNEL); 641 kmalloc(FRAMES_PER_DESC * FRAME_SIZE_PER_DESC, GFP_KERNEL);
642 if (!cam->sbuf[i].data) { 642 if (!cam->sbuf[i].data) {
643 while (--i >= 0) {
644 kfree(cam->sbuf[i].data);
645 cam->sbuf[i].data = NULL;
646 }
643 return -ENOMEM; 647 return -ENOMEM;
644 } 648 }
645 } 649 }
diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c
index 657e0b969145..2f5ca71e0261 100644
--- a/drivers/media/video/cx2341x.c
+++ b/drivers/media/video/cx2341x.c
@@ -742,7 +742,6 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
742 742
743 if (old == NULL || old->width != new->width || old->height != new->height || 743 if (old == NULL || old->width != new->width || old->height != new->height ||
744 old->video_encoding != new->video_encoding) { 744 old->video_encoding != new->video_encoding) {
745 int is_scaling;
746 u16 w = new->width; 745 u16 w = new->width;
747 u16 h = new->height; 746 u16 h = new->height;
748 747
@@ -752,20 +751,18 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
752 } 751 }
753 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_SIZE, 2, h, w); 752 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_SIZE, 2, h, w);
754 if (err) return err; 753 if (err) return err;
754 }
755 755
756 if (new->width != 720 || new->height != (new->is_50hz ? 576 : 480)) {
756 /* Adjust temporal filter if necessary. The problem with the temporal 757 /* Adjust temporal filter if necessary. The problem with the temporal
757 filter is that it works well with full resolution capturing, but 758 filter is that it works well with full resolution capturing, but
758 not when the capture window is scaled (the filter introduces 759 not when the capture window is scaled (the filter introduces
759 a ghosting effect). So if the capture window changed, and there is 760 a ghosting effect). So if the capture window is scaled, then
760 no updated filter value, then the filter is set depending on whether 761 force the filter to 0.
761 the new window is full resolution or not.
762 762
763 For full resolution a setting of 8 really improves the video 763 For full resolution the filter really improves the video
764 quality, especially if the original video quality is suboptimal. */ 764 quality, especially if the original video quality is suboptimal. */
765 is_scaling = new->width != 720 || new->height != (new->is_50hz ? 576 : 480); 765 temporal = 0;
766 if (old && old->video_temporal_filter == temporal) {
767 temporal = is_scaling ? 0 : 8;
768 }
769 } 766 }
770 767
771 if (old == NULL || old->stream_type != new->stream_type) { 768 if (old == NULL || old->stream_type != new->stream_type) {
@@ -866,6 +863,7 @@ invalid:
866void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix) 863void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix)
867{ 864{
868 int is_mpeg1 = p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1; 865 int is_mpeg1 = p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
866 int temporal = p->video_temporal_filter;
869 867
870 /* Stream */ 868 /* Stream */
871 printk(KERN_INFO "%s: Stream: %s\n", 869 printk(KERN_INFO "%s: Stream: %s\n",
@@ -922,10 +920,13 @@ void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix)
922 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE), 920 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE),
923 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE), 921 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE),
924 p->video_spatial_filter); 922 p->video_spatial_filter);
923 if (p->width != 720 || p->height != (p->is_50hz ? 576 : 480)) {
924 temporal = 0;
925 }
925 printk(KERN_INFO "%s: Temporal Filter: %s, %d\n", 926 printk(KERN_INFO "%s: Temporal Filter: %s, %d\n",
926 prefix, 927 prefix,
927 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE), 928 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE),
928 p->video_temporal_filter); 929 temporal);
929 printk(KERN_INFO "%s: Median Filter: %s, Luma [%d, %d], Chroma [%d, %d]\n", 930 printk(KERN_INFO "%s: Median Filter: %s, Luma [%d, %d], Chroma [%d, %d]\n",
930 prefix, 931 prefix,
931 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE), 932 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE),
diff --git a/drivers/media/video/cx25840/cx25840-vbi.c b/drivers/media/video/cx25840/cx25840-vbi.c
index f85f2084324f..ced13febed89 100644
--- a/drivers/media/video/cx25840/cx25840-vbi.c
+++ b/drivers/media/video/cx25840/cx25840-vbi.c
@@ -128,7 +128,14 @@ void cx25840_vbi_setup(struct i2c_client *client)
128 uv_lpf=1; 128 uv_lpf=1;
129 129
130 src_decimation=0x21f; 130 src_decimation=0x21f;
131 if (std == V4L2_STD_PAL_M) { 131 if (std == V4L2_STD_PAL_60) {
132 vblank=26;
133 vblank656=26;
134 burst=0x5b;
135 luma_lpf=2;
136 comb=0x20;
137 sc=0x0a8263;
138 } else if (std == V4L2_STD_PAL_M) {
132 vblank=20; 139 vblank=20;
133 vblank656=24; 140 vblank656=24;
134 burst=0x61; 141 burst=0x61;
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index c791708b1336..434b78ab37d8 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1632,7 +1632,7 @@ const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
1632/* ----------------------------------------------------------------------- */ 1632/* ----------------------------------------------------------------------- */
1633/* some leadtek specific stuff */ 1633/* some leadtek specific stuff */
1634 1634
1635static void __devinit leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data) 1635static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
1636{ 1636{
1637 /* This is just for the "Winfast 2000XP Expert" board ATM; I don't have data on 1637 /* This is just for the "Winfast 2000XP Expert" board ATM; I don't have data on
1638 * any others. 1638 * any others.
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 453af5e943ff..18997361c75a 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -633,12 +633,12 @@ int cx88_reset(struct cx88_core *core)
633 633
634static unsigned int inline norm_swidth(struct cx88_tvnorm *norm) 634static unsigned int inline norm_swidth(struct cx88_tvnorm *norm)
635{ 635{
636 return (norm->id & V4L2_STD_625_50) ? 922 : 754; 636 return (norm->id & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922;
637} 637}
638 638
639static unsigned int inline norm_hdelay(struct cx88_tvnorm *norm) 639static unsigned int inline norm_hdelay(struct cx88_tvnorm *norm)
640{ 640{
641 return (norm->id & V4L2_STD_625_50) ? 186 : 135; 641 return (norm->id & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 135 : 186;
642} 642}
643 643
644static unsigned int inline norm_vdelay(struct cx88_tvnorm *norm) 644static unsigned int inline norm_vdelay(struct cx88_tvnorm *norm)
@@ -648,24 +648,33 @@ static unsigned int inline norm_vdelay(struct cx88_tvnorm *norm)
648 648
649static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm) 649static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm)
650{ 650{
651 static const unsigned int ntsc = 28636360;
652 static const unsigned int pal = 35468950;
653 static const unsigned int palm = 28604892;
654
655 if (norm->id & V4L2_STD_PAL_M) 651 if (norm->id & V4L2_STD_PAL_M)
656 return palm; 652 return 28604892; // 3.575611 MHz
653
654 if (norm->id & (V4L2_STD_PAL_Nc))
655 return 28656448; // 3.582056 MHz
656
657 if (norm->id & V4L2_STD_NTSC) // All NTSC/M and variants
658 return 28636360; // 3.57954545 MHz +/- 10 Hz
657 659
658 return (norm->id & V4L2_STD_625_50) ? pal : ntsc; 660 /* SECAM have also different sub carrier for chroma,
661 but step_db and step_dr, at cx88_set_tvnorm already handles that.
662
663 The same FSC applies to PAL/BGDKIH, PAL/60, NTSC/4.43 and PAL/N
664 */
665
666 return 35468950; // 4.43361875 MHz +/- 5 Hz
659} 667}
660 668
661static unsigned int inline norm_htotal(struct cx88_tvnorm *norm) 669static unsigned int inline norm_htotal(struct cx88_tvnorm *norm)
662{ 670{
663 /* Should always be Line Draw Time / (4*FSC) */
664 671
665 if (norm->id & V4L2_STD_PAL_M) 672 unsigned int fsc4=norm_fsc8(norm)/2;
666 return 909;
667 673
668 return (norm->id & V4L2_STD_625_50) ? 1135 : 910; 674 /* returns 4*FSC / vtotal / frames per seconds */
675 return (norm->id & V4L2_STD_625_50) ?
676 ((fsc4+312)/625+12)/25 :
677 ((fsc4+262)/525*1001+15000)/30000;
669} 678}
670 679
671static unsigned int inline norm_vbipack(struct cx88_tvnorm *norm) 680static unsigned int inline norm_vbipack(struct cx88_tvnorm *norm)
@@ -692,7 +701,7 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig
692 value &= 0x3fe; 701 value &= 0x3fe;
693 cx_write(MO_HDELAY_EVEN, value); 702 cx_write(MO_HDELAY_EVEN, value);
694 cx_write(MO_HDELAY_ODD, value); 703 cx_write(MO_HDELAY_ODD, value);
695 dprintk(1,"set_scale: hdelay 0x%04x\n", value); 704 dprintk(1,"set_scale: hdelay 0x%04x (width %d)\n", value,swidth);
696 705
697 value = (swidth * 4096 / width) - 4096; 706 value = (swidth * 4096 / width) - 4096;
698 cx_write(MO_HSCALE_EVEN, value); 707 cx_write(MO_HSCALE_EVEN, value);
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 7054e941f1d7..a9575ad8ca27 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -91,7 +91,7 @@ struct cx88_tvnorm {
91 91
92static unsigned int inline norm_maxw(struct cx88_tvnorm *norm) 92static unsigned int inline norm_maxw(struct cx88_tvnorm *norm)
93{ 93{
94 return (norm->id & V4L2_STD_625_50) ? 768 : 640; 94 return (norm->id & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768;
95} 95}
96 96
97 97
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 2a461dde480c..36e72c207a8f 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1674,9 +1674,9 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1674 if (dev->has_msp34xx) { 1674 if (dev->has_msp34xx) {
1675 /* Send a reset to other chips via gpio */ 1675 /* Send a reset to other chips via gpio */
1676 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1); 1676 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1);
1677 udelay(2500); 1677 msleep(3);
1678 em28xx_write_regs_req(dev, 0x00, 0x08, "\xff", 1); 1678 em28xx_write_regs_req(dev, 0x00, 0x08, "\xff", 1);
1679 udelay(2500); 1679 msleep(3);
1680 1680
1681 } 1681 }
1682 video_mux(dev, 0); 1682 video_mux(dev, 0);
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index b083338823df..616a35da191d 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -923,7 +923,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
923 struct video_picture *p = arg; 923 struct video_picture *p = arg;
924 if (p->depth != 16) 924 if (p->depth != 16)
925 return -EINVAL; 925 return -EINVAL;
926 if (p->palette != VIDEO_PALETTE_YUV422) 926 if (p->palette != VIDEO_PALETTE_YUV422 && p->palette != VIDEO_PALETTE_YUYV)
927 return -EINVAL; 927 return -EINVAL;
928 mutex_lock(&meye.lock); 928 mutex_lock(&meye.lock);
929 sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS, 929 sonypi_camera_command(SONYPI_COMMAND_SETCAMERABRIGHTNESS,
@@ -978,7 +978,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
978 978
979 if (vm->frame >= gbuffers || vm->frame < 0) 979 if (vm->frame >= gbuffers || vm->frame < 0)
980 return -EINVAL; 980 return -EINVAL;
981 if (vm->format != VIDEO_PALETTE_YUV422) 981 if (vm->format != VIDEO_PALETTE_YUV422 && vm->format != VIDEO_PALETTE_YUYV)
982 return -EINVAL; 982 return -EINVAL;
983 if (vm->height * vm->width * 2 > gbufsize) 983 if (vm->height * vm->width * 2 > gbufsize)
984 return -EINVAL; 984 return -EINVAL;
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index e1b56dc13c3f..2fb9fe6a1ae7 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -633,10 +633,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
633 if (((rt->input >> (4 + i * 4)) & 0xf) == 0) 633 if (((rt->input >> (4 + i * 4)) & 0xf) == 0)
634 extern_input = 0; 634 extern_input = 0;
635 } 635 }
636 if (extern_input) 636 state->mode = extern_input ? MSP_MODE_EXTERN : MSP_MODE_AM_DETECT;
637 state->mode = MSP_MODE_EXTERN; 637 state->rxsubchans = V4L2_TUNER_SUB_STEREO;
638 else
639 state->mode = MSP_MODE_AM_DETECT;
640 msp_set_scart(client, sc_in, 0); 638 msp_set_scart(client, sc_in, 0);
641 msp_set_scart(client, sc1_out, 1); 639 msp_set_scart(client, sc1_out, 1);
642 msp_set_scart(client, sc2_out, 2); 640 msp_set_scart(client, sc2_out, 2);
@@ -951,7 +949,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
951 if (thread_func) { 949 if (thread_func) {
952 state->kthread = kthread_run(thread_func, client, "msp34xx"); 950 state->kthread = kthread_run(thread_func, client, "msp34xx");
953 951
954 if (state->kthread == NULL) 952 if (IS_ERR(state->kthread))
955 v4l_warn(client, "kernel_thread() failed\n"); 953 v4l_warn(client, "kernel_thread() failed\n");
956 msp_wake_thread(client); 954 msp_wake_thread(client);
957 } 955 }
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index 4c7f85b566a0..e1821eb82fb5 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -483,7 +483,6 @@ int msp3400c_thread(void *data)
483 /* no carrier scan, just unmute */ 483 /* no carrier scan, just unmute */
484 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n"); 484 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
485 state->scan_in_progress = 0; 485 state->scan_in_progress = 0;
486 state->rxsubchans = V4L2_TUNER_SUB_STEREO;
487 msp_set_audio(client); 486 msp_set_audio(client);
488 continue; 487 continue;
489 } 488 }
@@ -851,12 +850,15 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
851 source = 1; /* stereo or A|B */ 850 source = 1; /* stereo or A|B */
852 matrix = 0x20; 851 matrix = 0x20;
853 break; 852 break;
854 case V4L2_TUNER_MODE_STEREO:
855 case V4L2_TUNER_MODE_LANG1: 853 case V4L2_TUNER_MODE_LANG1:
856 default:
857 source = 3; /* stereo or A */ 854 source = 3; /* stereo or A */
858 matrix = 0x00; 855 matrix = 0x00;
859 break; 856 break;
857 case V4L2_TUNER_MODE_STEREO:
858 default:
859 source = 3; /* stereo or A */
860 matrix = 0x20;
861 break;
860 } 862 }
861 863
862 if (in == MSP_DSP_IN_TUNER) 864 if (in == MSP_DSP_IN_TUNER)
@@ -1030,6 +1032,9 @@ static int msp34xxg_detect_stereo(struct i2c_client *client)
1030 int is_stereo = status & 0x40; 1032 int is_stereo = status & 0x40;
1031 int oldrx = state->rxsubchans; 1033 int oldrx = state->rxsubchans;
1032 1034
1035 if (state->mode == MSP_MODE_EXTERN)
1036 return 0;
1037
1033 state->rxsubchans = 0; 1038 state->rxsubchans = 0;
1034 if (is_stereo) 1039 if (is_stereo)
1035 state->rxsubchans = V4L2_TUNER_SUB_STEREO; 1040 state->rxsubchans = V4L2_TUNER_SUB_STEREO;
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index fa8339879095..c33f6a69a247 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -50,9 +50,9 @@ static unsigned int antenna_pwr = 0;
50module_param(antenna_pwr, int, 0444); 50module_param(antenna_pwr, int, 0444);
51MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)"); 51MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
52 52
53static int use_frontent = 0; 53static int use_frontend = 0;
54module_param(use_frontent, int, 0644); 54module_param(use_frontend, int, 0644);
55MODULE_PARM_DESC(use_frontent,"for cards with multiple frontends (0: terrestrial, 1: satellite)"); 55MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
56 56
57/* ------------------------------------------------------------------ */ 57/* ------------------------------------------------------------------ */
58static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on) 58static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
@@ -1303,7 +1303,7 @@ static int dvb_init(struct saa7134_dev *dev)
1303 } 1303 }
1304 break; 1304 break;
1305 case SAA7134_BOARD_FLYDVB_TRIO: 1305 case SAA7134_BOARD_FLYDVB_TRIO:
1306 if(! use_frontent) { //terrestrial 1306 if(! use_frontend) { //terrestrial
1307 dev->dvb.frontend = dvb_attach(tda10046_attach, 1307 dev->dvb.frontend = dvb_attach(tda10046_attach,
1308 &lifeview_trio_config, 1308 &lifeview_trio_config,
1309 &dev->i2c_adap); 1309 &dev->i2c_adap);
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 705daaa2a4ff..ee4a493032d6 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -267,6 +267,10 @@ static int tuner_fixup_std(struct tuner *t)
267{ 267{
268 if ((t->std & V4L2_STD_PAL) == V4L2_STD_PAL) { 268 if ((t->std & V4L2_STD_PAL) == V4L2_STD_PAL) {
269 switch (pal[0]) { 269 switch (pal[0]) {
270 case '6':
271 tuner_dbg ("insmod fixup: PAL => PAL-60\n");
272 t->std = V4L2_STD_PAL_60;
273 break;
270 case 'b': 274 case 'b':
271 case 'B': 275 case 'B':
272 case 'g': 276 case 'g':
diff --git a/drivers/media/video/usbvision/usbvision-cards.c b/drivers/media/video/usbvision/usbvision-cards.c
index 134eb9865df6..a40e5838515b 100644
--- a/drivers/media/video/usbvision/usbvision-cards.c
+++ b/drivers/media/video/usbvision/usbvision-cards.c
@@ -39,8 +39,8 @@ struct usbvision_device_data_st usbvision_device_data[] = {
39 {0x0573, 0x0400, -1, CODEC_SAA7113, 4, V4L2_STD_NTSC, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "D-Link V100"}, 39 {0x0573, 0x0400, -1, CODEC_SAA7113, 4, V4L2_STD_NTSC, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "D-Link V100"},
40 {0x0573, 0x2000, -1, CODEC_SAA7111, 2, V4L2_STD_NTSC, 1, 0, 1, 0, 0, -1, -1, -1, -1, -1, "X10 USB Camera"}, 40 {0x0573, 0x2000, -1, CODEC_SAA7111, 2, V4L2_STD_NTSC, 1, 0, 1, 0, 0, -1, -1, -1, -1, -1, "X10 USB Camera"},
41 {0x0573, 0x2d00, -1, CODEC_SAA7111, 2, V4L2_STD_PAL, 1, 0, 1, 0, 0, -1, -1, -1, 3, 7, "Osprey 50"}, 41 {0x0573, 0x2d00, -1, CODEC_SAA7111, 2, V4L2_STD_PAL, 1, 0, 1, 0, 0, -1, -1, -1, 3, 7, "Osprey 50"},
42 {0x0573, 0x2d01, -1, CODEC_SAA7113, 2, V4L2_STD_NTSC, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Hauppauge USB-Live Model 600"}, 42 {0x0573, 0x2d01, -1, CODEC_SAA7113, 2, V4L2_STD_NTSC, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Hauppauge USB-Live Model 600"},
43 {0x0573, 0x2101, -1, CODEC_SAA7113, 2, V4L2_STD_PAL, 2, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Zoran Co. PMD (Nogatech) AV-grabber Manhattan"}, 43 {0x0573, 0x2101, -1, CODEC_SAA7113, 2, V4L2_STD_PAL, 2, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Zoran Co. PMD (Nogatech) AV-grabber Manhattan"},
44 {0x0573, 0x4100, -1, CODEC_SAA7111, 3, V4L2_STD_NTSC, 1, 1, 1, 1, TUNER_PHILIPS_NTSC_M, -1, -1, -1, 20, -1, "Nogatech USB-TV (NTSC) FM"}, 44 {0x0573, 0x4100, -1, CODEC_SAA7111, 3, V4L2_STD_NTSC, 1, 1, 1, 1, TUNER_PHILIPS_NTSC_M, -1, -1, -1, 20, -1, "Nogatech USB-TV (NTSC) FM"},
45 {0x0573, 0x4110, -1, CODEC_SAA7111, 3, V4L2_STD_NTSC, 1, 1, 1, 1, TUNER_PHILIPS_NTSC_M, -1, -1, -1, 20, -1, "PNY USB-TV (NTSC) FM"}, 45 {0x0573, 0x4110, -1, CODEC_SAA7111, 3, V4L2_STD_NTSC, 1, 1, 1, 1, TUNER_PHILIPS_NTSC_M, -1, -1, -1, 20, -1, "PNY USB-TV (NTSC) FM"},
46 {0x0573, 0x4450, 0, CODEC_SAA7113, 3, V4L2_STD_PAL, 1, 1, 1, 1, TUNER_PHILIPS_PAL, -1, -1, 0, 3, 7, "PixelView PlayTv-USB PRO (PAL) FM"}, 46 {0x0573, 0x4450, 0, CODEC_SAA7113, 3, V4L2_STD_PAL, 1, 1, 1, 1, TUNER_PHILIPS_PAL, -1, -1, 0, 3, 7, "PixelView PlayTv-USB PRO (PAL) FM"},
@@ -71,10 +71,10 @@ struct usbvision_device_data_st usbvision_device_data[] = {
71 {0x0573, 0x4d37, 0, CODEC_SAA7113, 3, V4L2_STD_PAL, 1, 1, 1, 1, TUNER_PHILIPS_FM1216ME_MK3, -1, -1, 0, 3, 7, "Hauppauge WinTV USB device Model 40219 Rev E189"}, 71 {0x0573, 0x4d37, 0, CODEC_SAA7113, 3, V4L2_STD_PAL, 1, 1, 1, 1, TUNER_PHILIPS_FM1216ME_MK3, -1, -1, 0, 3, 7, "Hauppauge WinTV USB device Model 40219 Rev E189"},
72 {0x0768, 0x0006, -1, CODEC_SAA7113, 3, V4L2_STD_NTSC, 1, 1, 1, 1, TUNER_PHILIPS_NTSC_M, -1, -1, 5, 5, -1, "Camtel Technology USB TV Genie Pro FM Model TVB330"}, 72 {0x0768, 0x0006, -1, CODEC_SAA7113, 3, V4L2_STD_NTSC, 1, 1, 1, 1, TUNER_PHILIPS_NTSC_M, -1, -1, 5, 5, -1, "Camtel Technology USB TV Genie Pro FM Model TVB330"},
73 {0x07d0, 0x0001, -1, CODEC_SAA7113, 2, V4L2_STD_PAL, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Digital Video Creator I"}, 73 {0x07d0, 0x0001, -1, CODEC_SAA7113, 2, V4L2_STD_PAL, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Digital Video Creator I"},
74 {0x07d0, 0x0002, -1, CODEC_SAA7111, 2, V4L2_STD_NTSC, 0, 0, 1, 0, 0, -1, -1, 82, 20, 7, "Global Village GV-007 (NTSC)"}, 74 {0x07d0, 0x0002, -1, CODEC_SAA7111, 2, V4L2_STD_NTSC, 0, 0, 1, 0, 0, -1, -1, 82, 20, 7, "Global Village GV-007 (NTSC)"},
75 {0x07d0, 0x0003, 0, CODEC_SAA7113, 2, V4L2_STD_NTSC, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Dazzle Fusion Model DVC-50 Rev 1 (NTSC)"}, 75 {0x07d0, 0x0003, 0, CODEC_SAA7113, 2, V4L2_STD_NTSC, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Dazzle Fusion Model DVC-50 Rev 1 (NTSC)"},
76 {0x07d0, 0x0004, 0, CODEC_SAA7113, 2, V4L2_STD_PAL, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Dazzle Fusion Model DVC-80 Rev 1 (PAL)"}, 76 {0x07d0, 0x0004, 0, CODEC_SAA7113, 2, V4L2_STD_PAL, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Dazzle Fusion Model DVC-80 Rev 1 (PAL)"},
77 {0x07d0, 0x0005, 0, CODEC_SAA7113, 2, V4L2_STD_SECAM, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Dazzle Fusion Model DVC-90 Rev 1 (SECAM)"}, 77 {0x07d0, 0x0005, 0, CODEC_SAA7113, 2, V4L2_STD_SECAM, 0, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Dazzle Fusion Model DVC-90 Rev 1 (SECAM)"},
78 {0x2304, 0x010d, -1, CODEC_SAA7111, 3, V4L2_STD_PAL, 1, 0, 0, 1, TUNER_TEMIC_4066FY5_PAL_I, -1, -1, -1, -1, -1, "Pinnacle Studio PCTV USB (PAL)"}, 78 {0x2304, 0x010d, -1, CODEC_SAA7111, 3, V4L2_STD_PAL, 1, 0, 0, 1, TUNER_TEMIC_4066FY5_PAL_I, -1, -1, -1, -1, -1, "Pinnacle Studio PCTV USB (PAL)"},
79 {0x2304, 0x0109, -1, CODEC_SAA7111, 3, V4L2_STD_SECAM, 1, 0, 1, 1, TUNER_PHILIPS_SECAM, -1, -1, -1, -1, -1, "Pinnacle Studio PCTV USB (SECAM)"}, 79 {0x2304, 0x0109, -1, CODEC_SAA7111, 3, V4L2_STD_SECAM, 1, 0, 1, 1, TUNER_PHILIPS_SECAM, -1, -1, -1, -1, -1, "Pinnacle Studio PCTV USB (SECAM)"},
80 {0x2304, 0x0110, -1, CODEC_SAA7111, 3, V4L2_STD_PAL, 1, 1, 1, 1, TUNER_PHILIPS_PAL, -1, -1,128, 23, -1, "Pinnacle Studio PCTV USB (PAL) FM"}, 80 {0x2304, 0x0110, -1, CODEC_SAA7111, 3, V4L2_STD_PAL, 1, 1, 1, 1, TUNER_PHILIPS_PAL, -1, -1,128, 23, -1, "Pinnacle Studio PCTV USB (PAL) FM"},
@@ -86,7 +86,7 @@ struct usbvision_device_data_st usbvision_device_data[] = {
86 {0x2304, 0x0300, -1, CODEC_SAA7113, 2, V4L2_STD_NTSC, 1, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Pinnacle Studio Linx Video input cable (NTSC)"}, 86 {0x2304, 0x0300, -1, CODEC_SAA7113, 2, V4L2_STD_NTSC, 1, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Pinnacle Studio Linx Video input cable (NTSC)"},
87 {0x2304, 0x0301, -1, CODEC_SAA7113, 2, V4L2_STD_PAL, 1, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Pinnacle Studio Linx Video input cable (PAL)"}, 87 {0x2304, 0x0301, -1, CODEC_SAA7113, 2, V4L2_STD_PAL, 1, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Pinnacle Studio Linx Video input cable (PAL)"},
88 {0x2304, 0x0419, -1, CODEC_SAA7113, 3, V4L2_STD_PAL, 1, 1, 1, 1, TUNER_TEMIC_4009FR5_PAL, -1, -1, 0, 3, 7, "Pinnacle PCTV Bungee USB (PAL) FM"}, 88 {0x2304, 0x0419, -1, CODEC_SAA7113, 3, V4L2_STD_PAL, 1, 1, 1, 1, TUNER_TEMIC_4009FR5_PAL, -1, -1, 0, 3, 7, "Pinnacle PCTV Bungee USB (PAL) FM"},
89 {0x2400, 0x4200, -1, CODEC_SAA7111, 3, VIDEO_MODE_NTSC, 1, 0, 1, 1, TUNER_PHILIPS_NTSC_M, -1, -1, -1, -1, -1, "Hauppauge WinTv-USB"}, 89 {0x2400, 0x4200, -1, CODEC_SAA7111, 3, V4L2_STD_NTSC, 1, 0, 1, 1, TUNER_PHILIPS_NTSC_M, -1, -1, -1, -1, -1, "Hauppauge WinTv-USB"},
90 {} /* Terminating entry */ 90 {} /* Terminating entry */
91}; 91};
92 92
@@ -148,7 +148,6 @@ struct usb_device_id usbvision_table [] = {
148 { USB_DEVICE(0x2304, 0x0300) }, /* Pinnacle Studio Linx Video input cable (NTSC) */ 148 { USB_DEVICE(0x2304, 0x0300) }, /* Pinnacle Studio Linx Video input cable (NTSC) */
149 { USB_DEVICE(0x2304, 0x0301) }, /* Pinnacle Studio Linx Video input cable (PAL) */ 149 { USB_DEVICE(0x2304, 0x0301) }, /* Pinnacle Studio Linx Video input cable (PAL) */
150 { USB_DEVICE(0x2304, 0x0419) }, /* Pinnacle PCTV Bungee USB (PAL) FM */ 150 { USB_DEVICE(0x2304, 0x0419) }, /* Pinnacle PCTV Bungee USB (PAL) FM */
151
152 { USB_DEVICE(0x2400, 0x4200) }, /* Hauppauge WinTv-USB2 Model 42012 */ 151 { USB_DEVICE(0x2400, 0x4200) }, /* Hauppauge WinTv-USB2 Model 42012 */
153 152
154 { } /* Terminating entry */ 153 { } /* Terminating entry */
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index 797b97baf9ed..a807d971e273 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -118,7 +118,7 @@ static int usbvision_measure_bandwidth (struct usb_usbvision *usbvision);
118 * This is used when initializing the contents of the area. 118 * This is used when initializing the contents of the area.
119 */ 119 */
120 120
121void *usbvision_rvmalloc(unsigned long size) 121static void *usbvision_rvmalloc(unsigned long size)
122{ 122{
123 void *mem; 123 void *mem;
124 unsigned long adr; 124 unsigned long adr;
@@ -181,7 +181,7 @@ static void usbvision_hexdump(const unsigned char *data, int len)
181/******************************** 181/********************************
182 * scratch ring buffer handling 182 * scratch ring buffer handling
183 ********************************/ 183 ********************************/
184int scratch_len(struct usb_usbvision *usbvision) /*This returns the amount of data actually in the buffer */ 184static int scratch_len(struct usb_usbvision *usbvision) /*This returns the amount of data actually in the buffer */
185{ 185{
186 int len = usbvision->scratch_write_ptr - usbvision->scratch_read_ptr; 186 int len = usbvision->scratch_write_ptr - usbvision->scratch_read_ptr;
187 if (len < 0) { 187 if (len < 0) {
@@ -194,7 +194,7 @@ int scratch_len(struct usb_usbvision *usbvision) /*This returns the amount of
194 194
195 195
196/* This returns the free space left in the buffer */ 196/* This returns the free space left in the buffer */
197int scratch_free(struct usb_usbvision *usbvision) 197static int scratch_free(struct usb_usbvision *usbvision)
198{ 198{
199 int free = usbvision->scratch_read_ptr - usbvision->scratch_write_ptr; 199 int free = usbvision->scratch_read_ptr - usbvision->scratch_write_ptr;
200 if (free <= 0) { 200 if (free <= 0) {
@@ -211,7 +211,8 @@ int scratch_free(struct usb_usbvision *usbvision)
211 211
212 212
213/* This puts data into the buffer */ 213/* This puts data into the buffer */
214int scratch_put(struct usb_usbvision *usbvision, unsigned char *data, int len) 214static int scratch_put(struct usb_usbvision *usbvision, unsigned char *data,
215 int len)
215{ 216{
216 int len_part; 217 int len_part;
217 218
@@ -237,7 +238,7 @@ int scratch_put(struct usb_usbvision *usbvision, unsigned char *data, int len)
237} 238}
238 239
239/* This marks the write_ptr as position of new frame header */ 240/* This marks the write_ptr as position of new frame header */
240void scratch_mark_header(struct usb_usbvision *usbvision) 241static void scratch_mark_header(struct usb_usbvision *usbvision)
241{ 242{
242 PDEBUG(DBG_SCRATCH, "header at write_ptr=%d\n", usbvision->scratch_headermarker_write_ptr); 243 PDEBUG(DBG_SCRATCH, "header at write_ptr=%d\n", usbvision->scratch_headermarker_write_ptr);
243 244
@@ -248,7 +249,8 @@ void scratch_mark_header(struct usb_usbvision *usbvision)
248} 249}
249 250
250/* This gets data from the buffer at the given "ptr" position */ 251/* This gets data from the buffer at the given "ptr" position */
251int scratch_get_extra(struct usb_usbvision *usbvision, unsigned char *data, int *ptr, int len) 252static int scratch_get_extra(struct usb_usbvision *usbvision,
253 unsigned char *data, int *ptr, int len)
252{ 254{
253 int len_part; 255 int len_part;
254 if (*ptr + len < scratch_buf_size) { 256 if (*ptr + len < scratch_buf_size) {
@@ -274,7 +276,8 @@ int scratch_get_extra(struct usb_usbvision *usbvision, unsigned char *data, int
274 276
275 277
276/* This sets the scratch extra read pointer */ 278/* This sets the scratch extra read pointer */
277void scratch_set_extra_ptr(struct usb_usbvision *usbvision, int *ptr, int len) 279static void scratch_set_extra_ptr(struct usb_usbvision *usbvision, int *ptr,
280 int len)
278{ 281{
279 *ptr = (usbvision->scratch_read_ptr + len)%scratch_buf_size; 282 *ptr = (usbvision->scratch_read_ptr + len)%scratch_buf_size;
280 283
@@ -283,7 +286,7 @@ void scratch_set_extra_ptr(struct usb_usbvision *usbvision, int *ptr, int len)
283 286
284 287
285/*This increments the scratch extra read pointer */ 288/*This increments the scratch extra read pointer */
286void scratch_inc_extra_ptr(int *ptr, int len) 289static void scratch_inc_extra_ptr(int *ptr, int len)
287{ 290{
288 *ptr = (*ptr + len) % scratch_buf_size; 291 *ptr = (*ptr + len) % scratch_buf_size;
289 292
@@ -292,7 +295,8 @@ void scratch_inc_extra_ptr(int *ptr, int len)
292 295
293 296
294/* This gets data from the buffer */ 297/* This gets data from the buffer */
295int scratch_get(struct usb_usbvision *usbvision, unsigned char *data, int len) 298static int scratch_get(struct usb_usbvision *usbvision, unsigned char *data,
299 int len)
296{ 300{
297 int len_part; 301 int len_part;
298 if (usbvision->scratch_read_ptr + len < scratch_buf_size) { 302 if (usbvision->scratch_read_ptr + len < scratch_buf_size) {
@@ -318,7 +322,8 @@ int scratch_get(struct usb_usbvision *usbvision, unsigned char *data, int len)
318 322
319 323
320/* This sets read pointer to next header and returns it */ 324/* This sets read pointer to next header and returns it */
321int scratch_get_header(struct usb_usbvision *usbvision,struct usbvision_frame_header *header) 325static int scratch_get_header(struct usb_usbvision *usbvision,
326 struct usbvision_frame_header *header)
322{ 327{
323 int errCode = 0; 328 int errCode = 0;
324 329
@@ -346,7 +351,7 @@ int scratch_get_header(struct usb_usbvision *usbvision,struct usbvision_frame_he
346 351
347 352
348/*This removes len bytes of old data from the buffer */ 353/*This removes len bytes of old data from the buffer */
349void scratch_rm_old(struct usb_usbvision *usbvision, int len) 354static void scratch_rm_old(struct usb_usbvision *usbvision, int len)
350{ 355{
351 356
352 usbvision->scratch_read_ptr += len; 357 usbvision->scratch_read_ptr += len;
@@ -356,7 +361,7 @@ void scratch_rm_old(struct usb_usbvision *usbvision, int len)
356 361
357 362
358/*This resets the buffer - kills all data in it too */ 363/*This resets the buffer - kills all data in it too */
359void scratch_reset(struct usb_usbvision *usbvision) 364static void scratch_reset(struct usb_usbvision *usbvision)
360{ 365{
361 PDEBUG(DBG_SCRATCH, "\n"); 366 PDEBUG(DBG_SCRATCH, "\n");
362 367
@@ -369,7 +374,7 @@ void scratch_reset(struct usb_usbvision *usbvision)
369 374
370int usbvision_scratch_alloc(struct usb_usbvision *usbvision) 375int usbvision_scratch_alloc(struct usb_usbvision *usbvision)
371{ 376{
372 usbvision->scratch = vmalloc(scratch_buf_size); 377 usbvision->scratch = vmalloc_32(scratch_buf_size);
373 scratch_reset(usbvision); 378 scratch_reset(usbvision);
374 if(usbvision->scratch == NULL) { 379 if(usbvision->scratch == NULL) {
375 err("%s: unable to allocate %d bytes for scratch", 380 err("%s: unable to allocate %d bytes for scratch",
@@ -399,8 +404,8 @@ void usbvision_scratch_free(struct usb_usbvision *usbvision)
399 * 1: Draw a colored grid 404 * 1: Draw a colored grid
400 * 405 *
401 */ 406 */
402void usbvision_testpattern(struct usb_usbvision *usbvision, int fullframe, 407static void usbvision_testpattern(struct usb_usbvision *usbvision,
403 int pmode) 408 int fullframe, int pmode)
404{ 409{
405 static const char proc[] = "usbvision_testpattern"; 410 static const char proc[] = "usbvision_testpattern";
406 struct usbvision_frame *frame; 411 struct usbvision_frame *frame;
@@ -480,7 +485,7 @@ void usbvision_testpattern(struct usb_usbvision *usbvision, int fullframe,
480int usbvision_decompress_alloc(struct usb_usbvision *usbvision) 485int usbvision_decompress_alloc(struct usb_usbvision *usbvision)
481{ 486{
482 int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2; 487 int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2;
483 usbvision->IntraFrameBuffer = vmalloc(IFB_size); 488 usbvision->IntraFrameBuffer = vmalloc_32(IFB_size);
484 if (usbvision->IntraFrameBuffer == NULL) { 489 if (usbvision->IntraFrameBuffer == NULL) {
485 err("%s: unable to allocate %d for compr. frame buffer", __FUNCTION__, IFB_size); 490 err("%s: unable to allocate %d for compr. frame buffer", __FUNCTION__, IFB_size);
486 return -ENOMEM; 491 return -ENOMEM;
@@ -2199,6 +2204,7 @@ int usbvision_power_on(struct usb_usbvision *usbvision)
2199 usbvision_write_reg(usbvision, USBVISION_PWR_REG, USBVISION_SSPND_EN); 2204 usbvision_write_reg(usbvision, USBVISION_PWR_REG, USBVISION_SSPND_EN);
2200 usbvision_write_reg(usbvision, USBVISION_PWR_REG, 2205 usbvision_write_reg(usbvision, USBVISION_PWR_REG,
2201 USBVISION_SSPND_EN | USBVISION_RES2); 2206 USBVISION_SSPND_EN | USBVISION_RES2);
2207
2202 usbvision_write_reg(usbvision, USBVISION_PWR_REG, 2208 usbvision_write_reg(usbvision, USBVISION_PWR_REG,
2203 USBVISION_SSPND_EN | USBVISION_PWR_VID); 2209 USBVISION_SSPND_EN | USBVISION_PWR_VID);
2204 errCode = usbvision_write_reg(usbvision, USBVISION_PWR_REG, 2210 errCode = usbvision_write_reg(usbvision, USBVISION_PWR_REG,
@@ -2305,7 +2311,7 @@ int usbvision_restart_isoc(struct usb_usbvision *usbvision)
2305 usbvision->Vin_Reg2_Preset)) < 0) return ret; 2311 usbvision->Vin_Reg2_Preset)) < 0) return ret;
2306 2312
2307 /* TODO: schedule timeout */ 2313 /* TODO: schedule timeout */
2308 while ((usbvision_read_reg(usbvision, USBVISION_STATUS_REG) && 0x01) != 1); 2314 while ((usbvision_read_reg(usbvision, USBVISION_STATUS_REG) & 0x01) != 1);
2309 2315
2310 return 0; 2316 return 0;
2311} 2317}
@@ -2346,40 +2352,6 @@ int usbvision_setup(struct usb_usbvision *usbvision,int format)
2346 return USBVISION_IS_OPERATIONAL(usbvision); 2352 return USBVISION_IS_OPERATIONAL(usbvision);
2347} 2353}
2348 2354
2349
2350int usbvision_sbuf_alloc(struct usb_usbvision *usbvision)
2351{
2352 int i, errCode = 0;
2353 const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE;
2354
2355 /* Clean pointers so we know if we allocated something */
2356 for (i = 0; i < USBVISION_NUMSBUF; i++)
2357 usbvision->sbuf[i].data = NULL;
2358
2359 for (i = 0; i < USBVISION_NUMSBUF; i++) {
2360 usbvision->sbuf[i].data = kzalloc(sb_size, GFP_KERNEL);
2361 if (usbvision->sbuf[i].data == NULL) {
2362 err("%s: unable to allocate %d bytes for sbuf", __FUNCTION__, sb_size);
2363 errCode = -ENOMEM;
2364 break;
2365 }
2366 }
2367 return errCode;
2368}
2369
2370
2371void usbvision_sbuf_free(struct usb_usbvision *usbvision)
2372{
2373 int i;
2374
2375 for (i = 0; i < USBVISION_NUMSBUF; i++) {
2376 if (usbvision->sbuf[i].data != NULL) {
2377 kfree(usbvision->sbuf[i].data);
2378 usbvision->sbuf[i].data = NULL;
2379 }
2380 }
2381}
2382
2383/* 2355/*
2384 * usbvision_init_isoc() 2356 * usbvision_init_isoc()
2385 * 2357 *
@@ -2388,6 +2360,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2388{ 2360{
2389 struct usb_device *dev = usbvision->dev; 2361 struct usb_device *dev = usbvision->dev;
2390 int bufIdx, errCode, regValue; 2362 int bufIdx, errCode, regValue;
2363 const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE;
2391 2364
2392 if (!USBVISION_IS_OPERATIONAL(usbvision)) 2365 if (!USBVISION_IS_OPERATIONAL(usbvision))
2393 return -EFAULT; 2366 return -EFAULT;
@@ -2423,6 +2396,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2423 return -ENOMEM; 2396 return -ENOMEM;
2424 } 2397 }
2425 usbvision->sbuf[bufIdx].urb = urb; 2398 usbvision->sbuf[bufIdx].urb = urb;
2399 usbvision->sbuf[bufIdx].data = usb_buffer_alloc(usbvision->dev, sb_size, GFP_KERNEL,&urb->transfer_dma);
2426 urb->dev = dev; 2400 urb->dev = dev;
2427 urb->context = usbvision; 2401 urb->context = usbvision;
2428 urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp); 2402 urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp);
@@ -2464,6 +2438,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2464void usbvision_stop_isoc(struct usb_usbvision *usbvision) 2438void usbvision_stop_isoc(struct usb_usbvision *usbvision)
2465{ 2439{
2466 int bufIdx, errCode, regValue; 2440 int bufIdx, errCode, regValue;
2441 const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE;
2467 2442
2468 if ((usbvision->streaming == Stream_Off) || (usbvision->dev == NULL)) 2443 if ((usbvision->streaming == Stream_Off) || (usbvision->dev == NULL))
2469 return; 2444 return;
@@ -2471,6 +2446,12 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision)
2471 /* Unschedule all of the iso td's */ 2446 /* Unschedule all of the iso td's */
2472 for (bufIdx = 0; bufIdx < USBVISION_NUMSBUF; bufIdx++) { 2447 for (bufIdx = 0; bufIdx < USBVISION_NUMSBUF; bufIdx++) {
2473 usb_kill_urb(usbvision->sbuf[bufIdx].urb); 2448 usb_kill_urb(usbvision->sbuf[bufIdx].urb);
2449 if (usbvision->sbuf[bufIdx].data){
2450 usb_buffer_free(usbvision->dev,
2451 sb_size,
2452 usbvision->sbuf[bufIdx].data,
2453 usbvision->sbuf[bufIdx].urb->transfer_dma);
2454 }
2474 usb_free_urb(usbvision->sbuf[bufIdx].urb); 2455 usb_free_urb(usbvision->sbuf[bufIdx].urb);
2475 usbvision->sbuf[bufIdx].urb = NULL; 2456 usbvision->sbuf[bufIdx].urb = NULL;
2476 } 2457 }
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c
index 0f3fba7ea6fe..858252c15084 100644
--- a/drivers/media/video/usbvision/usbvision-i2c.c
+++ b/drivers/media/video/usbvision/usbvision-i2c.c
@@ -58,7 +58,6 @@ static int usbvision_i2c_read(void *data, unsigned char addr, char *buf,
58static inline int try_write_address(struct i2c_adapter *i2c_adap, 58static inline int try_write_address(struct i2c_adapter *i2c_adap,
59 unsigned char addr, int retries) 59 unsigned char addr, int retries)
60{ 60{
61 struct i2c_algo_usb_data *adap = i2c_adap->algo_data;
62 void *data; 61 void *data;
63 int i, ret = -1; 62 int i, ret = -1;
64 char buf[4]; 63 char buf[4];
@@ -69,10 +68,10 @@ static inline int try_write_address(struct i2c_adapter *i2c_adap,
69 ret = (usbvision_i2c_write(data, addr, buf, 1)); 68 ret = (usbvision_i2c_write(data, addr, buf, 1));
70 if (ret == 1) 69 if (ret == 1)
71 break; /* success! */ 70 break; /* success! */
72 udelay(5 /*adap->udelay */ ); 71 udelay(5);
73 if (i == retries) /* no success */ 72 if (i == retries) /* no success */
74 break; 73 break;
75 udelay(adap->udelay); 74 udelay(10);
76 } 75 }
77 if (i) { 76 if (i) {
78 PDEBUG(DBG_ALGO,"Needed %d retries for address %#2x", i, addr); 77 PDEBUG(DBG_ALGO,"Needed %d retries for address %#2x", i, addr);
@@ -84,7 +83,6 @@ static inline int try_write_address(struct i2c_adapter *i2c_adap,
84static inline int try_read_address(struct i2c_adapter *i2c_adap, 83static inline int try_read_address(struct i2c_adapter *i2c_adap,
85 unsigned char addr, int retries) 84 unsigned char addr, int retries)
86{ 85{
87 struct i2c_algo_usb_data *adap = i2c_adap->algo_data;
88 void *data; 86 void *data;
89 int i, ret = -1; 87 int i, ret = -1;
90 char buf[4]; 88 char buf[4];
@@ -94,10 +92,10 @@ static inline int try_read_address(struct i2c_adapter *i2c_adap,
94 ret = (usbvision_i2c_read(data, addr, buf, 1)); 92 ret = (usbvision_i2c_read(data, addr, buf, 1));
95 if (ret == 1) 93 if (ret == 1)
96 break; /* success! */ 94 break; /* success! */
97 udelay(5 /*adap->udelay */ ); 95 udelay(5);
98 if (i == retries) /* no success */ 96 if (i == retries) /* no success */
99 break; 97 break;
100 udelay(adap->udelay); 98 udelay(10);
101 } 99 }
102 if (i) { 100 if (i) {
103 PDEBUG(DBG_ALGO,"Needed %d retries for address %#2x", i, addr); 101 PDEBUG(DBG_ALGO,"Needed %d retries for address %#2x", i, addr);
@@ -213,7 +211,7 @@ static struct i2c_algorithm i2c_usb_algo = {
213/* 211/*
214 * registering functions to load algorithms at runtime 212 * registering functions to load algorithms at runtime
215 */ 213 */
216int usbvision_i2c_usb_add_bus(struct i2c_adapter *adap) 214static int usbvision_i2c_usb_add_bus(struct i2c_adapter *adap)
217{ 215{
218 PDEBUG(DBG_I2C, "I2C debugging is enabled [i2c]"); 216 PDEBUG(DBG_I2C, "I2C debugging is enabled [i2c]");
219 PDEBUG(DBG_ALGO, "ALGO debugging is enabled [i2c]"); 217 PDEBUG(DBG_ALGO, "ALGO debugging is enabled [i2c]");
@@ -248,15 +246,12 @@ int usbvision_i2c_usb_del_bus(struct i2c_adapter *adap)
248/* usbvision specific I2C functions */ 246/* usbvision specific I2C functions */
249/* ----------------------------------------------------------------------- */ 247/* ----------------------------------------------------------------------- */
250static struct i2c_adapter i2c_adap_template; 248static struct i2c_adapter i2c_adap_template;
251static struct i2c_algo_usb_data i2c_algo_template;
252static struct i2c_client i2c_client_template; 249static struct i2c_client i2c_client_template;
253 250
254int usbvision_init_i2c(struct usb_usbvision *usbvision) 251int usbvision_init_i2c(struct usb_usbvision *usbvision)
255{ 252{
256 memcpy(&usbvision->i2c_adap, &i2c_adap_template, 253 memcpy(&usbvision->i2c_adap, &i2c_adap_template,
257 sizeof(struct i2c_adapter)); 254 sizeof(struct i2c_adapter));
258 memcpy(&usbvision->i2c_algo, &i2c_algo_template,
259 sizeof(struct i2c_algo_usb_data));
260 memcpy(&usbvision->i2c_client, &i2c_client_template, 255 memcpy(&usbvision->i2c_client, &i2c_client_template,
261 sizeof(struct i2c_client)); 256 sizeof(struct i2c_client));
262 257
@@ -266,9 +261,7 @@ int usbvision_init_i2c(struct usb_usbvision *usbvision)
266 261
267 i2c_set_adapdata(&usbvision->i2c_adap, usbvision); 262 i2c_set_adapdata(&usbvision->i2c_adap, usbvision);
268 i2c_set_clientdata(&usbvision->i2c_client, usbvision); 263 i2c_set_clientdata(&usbvision->i2c_client, usbvision);
269 i2c_set_algo_usb_data(&usbvision->i2c_algo, usbvision);
270 264
271 usbvision->i2c_adap.algo_data = &usbvision->i2c_algo;
272 usbvision->i2c_client.adapter = &usbvision->i2c_adap; 265 usbvision->i2c_client.adapter = &usbvision->i2c_adap;
273 266
274 if (usbvision_write_reg(usbvision, USBVISION_SER_MODE, USBVISION_IIC_LRNACK) < 0) { 267 if (usbvision_write_reg(usbvision, USBVISION_SER_MODE, USBVISION_IIC_LRNACK) < 0) {
@@ -297,7 +290,6 @@ int usbvision_init_i2c(struct usb_usbvision *usbvision)
297void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd, 290void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd,
298 void *arg) 291 void *arg)
299{ 292{
300 BUG_ON(NULL == usbvision->i2c_adap.algo_data);
301 i2c_clients_command(&usbvision->i2c_adap, cmd, arg); 293 i2c_clients_command(&usbvision->i2c_adap, cmd, arg);
302} 294}
303 295
@@ -327,6 +319,9 @@ static int attach_inform(struct i2c_client *client)
327 case 0x4a: 319 case 0x4a:
328 PDEBUG(DBG_I2C,"attach_inform: saa7113 detected."); 320 PDEBUG(DBG_I2C,"attach_inform: saa7113 detected.");
329 break; 321 break;
322 case 0x48:
323 PDEBUG(DBG_I2C,"attach_inform: saa7111 detected.");
324 break;
330 case 0xa0: 325 case 0xa0:
331 PDEBUG(DBG_I2C,"attach_inform: eeprom detected."); 326 PDEBUG(DBG_I2C,"attach_inform: eeprom detected.");
332 break; 327 break;
@@ -531,21 +526,10 @@ static int usbvision_i2c_read(void *data, unsigned char addr, char *buf,
531 return rdcount; 526 return rdcount;
532} 527}
533 528
534static struct i2c_algo_usb_data i2c_algo_template = {
535 .data = NULL,
536 .inb = usbvision_i2c_read,
537 .outb = usbvision_i2c_write,
538 .udelay = 10,
539 .mdelay = 10,
540 .timeout = 100,
541};
542
543static struct i2c_adapter i2c_adap_template = { 529static struct i2c_adapter i2c_adap_template = {
544 .owner = THIS_MODULE, 530 .owner = THIS_MODULE,
545 .name = "usbvision", 531 .name = "usbvision",
546 .id = I2C_HW_B_BT848, /* FIXME */ 532 .id = I2C_HW_B_BT848, /* FIXME */
547 .algo = NULL,
548 .algo_data = NULL,
549 .client_register = attach_inform, 533 .client_register = attach_inform,
550 .client_unregister = detach_inform, 534 .client_unregister = detach_inform,
551#ifdef I2C_ADAP_CLASS_TV_ANALOG 535#ifdef I2C_ADAP_CLASS_TV_ANALOG
@@ -559,9 +543,6 @@ static struct i2c_client i2c_client_template = {
559 .name = "usbvision internal", 543 .name = "usbvision internal",
560}; 544};
561 545
562EXPORT_SYMBOL(usbvision_i2c_usb_add_bus);
563EXPORT_SYMBOL(usbvision_i2c_usb_del_bus);
564
565/* 546/*
566 * Overrides for Emacs so that we follow Linus's tabbing style. 547 * Overrides for Emacs so that we follow Linus's tabbing style.
567 * --------------------------------------------------------------------------- 548 * ---------------------------------------------------------------------------
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 864446c012eb..8c7eba2a728e 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -204,7 +204,7 @@ MODULE_ALIAS(DRIVER_ALIAS);
204 204
205static inline struct usb_usbvision *cd_to_usbvision(struct class_device *cd) 205static inline struct usb_usbvision *cd_to_usbvision(struct class_device *cd)
206{ 206{
207 struct video_device *vdev = to_video_device(cd); 207 struct video_device *vdev = container_of(cd, struct video_device, class_dev);
208 return video_get_drvdata(vdev); 208 return video_get_drvdata(vdev);
209} 209}
210 210
@@ -214,81 +214,85 @@ static ssize_t show_version(struct class_device *cd, char *buf)
214} 214}
215static CLASS_DEVICE_ATTR(version, S_IRUGO, show_version, NULL); 215static CLASS_DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
216 216
217static ssize_t show_model(struct class_device *class_dev, char *buf) 217static ssize_t show_model(struct class_device *cd, char *buf)
218{ 218{
219 struct video_device *vdev = to_video_device(class_dev); 219 struct video_device *vdev = container_of(cd, struct video_device, class_dev);
220 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 220 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
221 return sprintf(buf, "%s\n", usbvision_device_data[usbvision->DevModel].ModelString); 221 return sprintf(buf, "%s\n", usbvision_device_data[usbvision->DevModel].ModelString);
222} 222}
223static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); 223static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
224 224
225static ssize_t show_hue(struct class_device *class_dev, char *buf) 225static ssize_t show_hue(struct class_device *cd, char *buf)
226{ 226{
227 struct video_device *vdev = to_video_device(class_dev); 227 struct video_device *vdev = container_of(cd, struct video_device, class_dev);
228 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 228 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
229 struct v4l2_control ctrl; 229 struct v4l2_control ctrl;
230 ctrl.id = V4L2_CID_HUE; 230 ctrl.id = V4L2_CID_HUE;
231 ctrl.value = 0; 231 ctrl.value = 0;
232 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 232 if(usbvision->user)
233 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
233 return sprintf(buf, "%d\n", ctrl.value >> 8); 234 return sprintf(buf, "%d\n", ctrl.value >> 8);
234} 235}
235static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); 236static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
236 237
237static ssize_t show_contrast(struct class_device *class_dev, char *buf) 238static ssize_t show_contrast(struct class_device *cd, char *buf)
238{ 239{
239 struct video_device *vdev = to_video_device(class_dev); 240 struct video_device *vdev = container_of(cd, struct video_device, class_dev);
240 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 241 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
241 struct v4l2_control ctrl; 242 struct v4l2_control ctrl;
242 ctrl.id = V4L2_CID_CONTRAST; 243 ctrl.id = V4L2_CID_CONTRAST;
243 ctrl.value = 0; 244 ctrl.value = 0;
244 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 245 if(usbvision->user)
246 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
245 return sprintf(buf, "%d\n", ctrl.value >> 8); 247 return sprintf(buf, "%d\n", ctrl.value >> 8);
246} 248}
247static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); 249static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
248 250
249static ssize_t show_brightness(struct class_device *class_dev, char *buf) 251static ssize_t show_brightness(struct class_device *cd, char *buf)
250{ 252{
251 struct video_device *vdev = to_video_device(class_dev); 253 struct video_device *vdev = container_of(cd, struct video_device, class_dev);
252 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 254 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
253 struct v4l2_control ctrl; 255 struct v4l2_control ctrl;
254 ctrl.id = V4L2_CID_BRIGHTNESS; 256 ctrl.id = V4L2_CID_BRIGHTNESS;
255 ctrl.value = 0; 257 ctrl.value = 0;
256 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 258 if(usbvision->user)
259 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
257 return sprintf(buf, "%d\n", ctrl.value >> 8); 260 return sprintf(buf, "%d\n", ctrl.value >> 8);
258} 261}
259static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); 262static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
260 263
261static ssize_t show_saturation(struct class_device *class_dev, char *buf) 264static ssize_t show_saturation(struct class_device *cd, char *buf)
262{ 265{
263 struct video_device *vdev = to_video_device(class_dev); 266 struct video_device *vdev = container_of(cd, struct video_device, class_dev);
264 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 267 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
265 struct v4l2_control ctrl; 268 struct v4l2_control ctrl;
266 ctrl.id = V4L2_CID_SATURATION; 269 ctrl.id = V4L2_CID_SATURATION;
267 ctrl.value = 0; 270 ctrl.value = 0;
268 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 271 if(usbvision->user)
272 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
269 return sprintf(buf, "%d\n", ctrl.value >> 8); 273 return sprintf(buf, "%d\n", ctrl.value >> 8);
270} 274}
271static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); 275static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
272 276
273static ssize_t show_streaming(struct class_device *class_dev, char *buf) 277static ssize_t show_streaming(struct class_device *cd, char *buf)
274{ 278{
275 struct video_device *vdev = to_video_device(class_dev); 279 struct video_device *vdev = container_of(cd, struct video_device, class_dev);
276 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 280 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
277 return sprintf(buf, "%s\n", YES_NO(usbvision->streaming==Stream_On?1:0)); 281 return sprintf(buf, "%s\n", YES_NO(usbvision->streaming==Stream_On?1:0));
278} 282}
279static CLASS_DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); 283static CLASS_DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL);
280 284
281static ssize_t show_compression(struct class_device *class_dev, char *buf) 285static ssize_t show_compression(struct class_device *cd, char *buf)
282{ 286{
283 struct video_device *vdev = to_video_device(class_dev); 287 struct video_device *vdev = container_of(cd, struct video_device, class_dev);
284 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 288 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
285 return sprintf(buf, "%s\n", YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS)); 289 return sprintf(buf, "%s\n", YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS));
286} 290}
287static CLASS_DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); 291static CLASS_DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL);
288 292
289static ssize_t show_device_bridge(struct class_device *class_dev, char *buf) 293static ssize_t show_device_bridge(struct class_device *cd, char *buf)
290{ 294{
291 struct video_device *vdev = to_video_device(class_dev); 295 struct video_device *vdev = container_of(cd, struct video_device, class_dev);
292 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 296 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
293 return sprintf(buf, "%d\n", usbvision->bridgeType); 297 return sprintf(buf, "%d\n", usbvision->bridgeType);
294} 298}
@@ -297,31 +301,71 @@ static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL);
297static void usbvision_create_sysfs(struct video_device *vdev) 301static void usbvision_create_sysfs(struct video_device *vdev)
298{ 302{
299 int res; 303 int res;
300 if (vdev) { 304 if (!vdev)
301 res=video_device_create_file(vdev, &class_device_attr_version); 305 return;
302 res=video_device_create_file(vdev, &class_device_attr_model); 306 do {
303 res=video_device_create_file(vdev, &class_device_attr_hue); 307 res=class_device_create_file(&vdev->class_dev,
304 res=video_device_create_file(vdev, &class_device_attr_contrast); 308 &class_device_attr_version);
305 res=video_device_create_file(vdev, &class_device_attr_brightness); 309 if (res<0)
306 res=video_device_create_file(vdev, &class_device_attr_saturation); 310 break;
307 res=video_device_create_file(vdev, &class_device_attr_streaming); 311 res=class_device_create_file(&vdev->class_dev,
308 res=video_device_create_file(vdev, &class_device_attr_compression); 312 &class_device_attr_model);
309 res=video_device_create_file(vdev, &class_device_attr_bridge); 313 if (res<0)
310 } 314 break;
315 res=class_device_create_file(&vdev->class_dev,
316 &class_device_attr_hue);
317 if (res<0)
318 break;
319 res=class_device_create_file(&vdev->class_dev,
320 &class_device_attr_contrast);
321 if (res<0)
322 break;
323 res=class_device_create_file(&vdev->class_dev,
324 &class_device_attr_brightness);
325 if (res<0)
326 break;
327 res=class_device_create_file(&vdev->class_dev,
328 &class_device_attr_saturation);
329 if (res<0)
330 break;
331 res=class_device_create_file(&vdev->class_dev,
332 &class_device_attr_streaming);
333 if (res<0)
334 break;
335 res=class_device_create_file(&vdev->class_dev,
336 &class_device_attr_compression);
337 if (res<0)
338 break;
339 res=class_device_create_file(&vdev->class_dev,
340 &class_device_attr_bridge);
341 if (res>=0)
342 return;
343 } while (0);
344
345 err("%s error: %d\n", __FUNCTION__, res);
311} 346}
312 347
313static void usbvision_remove_sysfs(struct video_device *vdev) 348static void usbvision_remove_sysfs(struct video_device *vdev)
314{ 349{
315 if (vdev) { 350 if (vdev) {
316 video_device_remove_file(vdev, &class_device_attr_version); 351 class_device_remove_file(&vdev->class_dev,
317 video_device_remove_file(vdev, &class_device_attr_model); 352 &class_device_attr_version);
318 video_device_remove_file(vdev, &class_device_attr_hue); 353 class_device_remove_file(&vdev->class_dev,
319 video_device_remove_file(vdev, &class_device_attr_contrast); 354 &class_device_attr_model);
320 video_device_remove_file(vdev, &class_device_attr_brightness); 355 class_device_remove_file(&vdev->class_dev,
321 video_device_remove_file(vdev, &class_device_attr_saturation); 356 &class_device_attr_hue);
322 video_device_remove_file(vdev, &class_device_attr_streaming); 357 class_device_remove_file(&vdev->class_dev,
323 video_device_remove_file(vdev, &class_device_attr_compression); 358 &class_device_attr_contrast);
324 video_device_remove_file(vdev, &class_device_attr_bridge); 359 class_device_remove_file(&vdev->class_dev,
360 &class_device_attr_brightness);
361 class_device_remove_file(&vdev->class_dev,
362 &class_device_attr_saturation);
363 class_device_remove_file(&vdev->class_dev,
364 &class_device_attr_streaming);
365 class_device_remove_file(&vdev->class_dev,
366 &class_device_attr_compression);
367 class_device_remove_file(&vdev->class_dev,
368 &class_device_attr_bridge);
325 } 369 }
326} 370}
327 371
@@ -353,20 +397,15 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
353 if(!errCode) { 397 if(!errCode) {
354 /* Allocate memory for the scratch ring buffer */ 398 /* Allocate memory for the scratch ring buffer */
355 errCode = usbvision_scratch_alloc(usbvision); 399 errCode = usbvision_scratch_alloc(usbvision);
356 if(!errCode) { 400 if ((!errCode) && (isocMode==ISOC_MODE_COMPRESS)) {
357 /* Allocate memory for the USB S buffers */ 401 /* Allocate intermediate decompression buffers only if needed */
358 errCode = usbvision_sbuf_alloc(usbvision); 402 errCode = usbvision_decompress_alloc(usbvision);
359 if ((!errCode) && (usbvision->isocMode==ISOC_MODE_COMPRESS)) {
360 /* Allocate intermediate decompression buffers only if needed */
361 errCode = usbvision_decompress_alloc(usbvision);
362 }
363 } 403 }
364 } 404 }
365 if (errCode) { 405 if (errCode) {
366 /* Deallocate all buffers if trouble */ 406 /* Deallocate all buffers if trouble */
367 usbvision_frames_free(usbvision); 407 usbvision_frames_free(usbvision);
368 usbvision_scratch_free(usbvision); 408 usbvision_scratch_free(usbvision);
369 usbvision_sbuf_free(usbvision);
370 usbvision_decompress_free(usbvision); 409 usbvision_decompress_free(usbvision);
371 } 410 }
372 } 411 }
@@ -437,9 +476,8 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file)
437 usbvision_stop_isoc(usbvision); 476 usbvision_stop_isoc(usbvision);
438 477
439 usbvision_decompress_free(usbvision); 478 usbvision_decompress_free(usbvision);
440 usbvision_rvfree(usbvision->fbuf, usbvision->fbuf_size); 479 usbvision_frames_free(usbvision);
441 usbvision_scratch_free(usbvision); 480 usbvision_scratch_free(usbvision);
442 usbvision_sbuf_free(usbvision);
443 481
444 usbvision->user--; 482 usbvision->user--;
445 483
@@ -1884,7 +1922,7 @@ static struct usb_driver usbvision_driver = {
1884 * This procedure preprocesses CustomDevice parameter if any 1922 * This procedure preprocesses CustomDevice parameter if any
1885 * 1923 *
1886 */ 1924 */
1887void customdevice_process(void) 1925static void customdevice_process(void)
1888{ 1926{
1889 usbvision_device_data[0]=usbvision_device_data[1]; 1927 usbvision_device_data[0]=usbvision_device_data[1];
1890 usbvision_table[0]=usbvision_table[1]; 1928 usbvision_table[0]=usbvision_table[1];
@@ -1939,22 +1977,22 @@ void customdevice_process(void)
1939 { 1977 {
1940 case 'P': 1978 case 'P':
1941 PDEBUG(DBG_PROBE, "VideoNorm=PAL"); 1979 PDEBUG(DBG_PROBE, "VideoNorm=PAL");
1942 usbvision_device_data[0].VideoNorm=VIDEO_MODE_PAL; 1980 usbvision_device_data[0].VideoNorm=V4L2_STD_PAL;
1943 break; 1981 break;
1944 1982
1945 case 'S': 1983 case 'S':
1946 PDEBUG(DBG_PROBE, "VideoNorm=SECAM"); 1984 PDEBUG(DBG_PROBE, "VideoNorm=SECAM");
1947 usbvision_device_data[0].VideoNorm=VIDEO_MODE_SECAM; 1985 usbvision_device_data[0].VideoNorm=V4L2_STD_SECAM;
1948 break; 1986 break;
1949 1987
1950 case 'N': 1988 case 'N':
1951 PDEBUG(DBG_PROBE, "VideoNorm=NTSC"); 1989 PDEBUG(DBG_PROBE, "VideoNorm=NTSC");
1952 usbvision_device_data[0].VideoNorm=VIDEO_MODE_NTSC; 1990 usbvision_device_data[0].VideoNorm=V4L2_STD_NTSC;
1953 break; 1991 break;
1954 1992
1955 default: 1993 default:
1956 PDEBUG(DBG_PROBE, "VideoNorm=PAL (by default)"); 1994 PDEBUG(DBG_PROBE, "VideoNorm=PAL (by default)");
1957 usbvision_device_data[0].VideoNorm=VIDEO_MODE_PAL; 1995 usbvision_device_data[0].VideoNorm=V4L2_STD_PAL;
1958 break; 1996 break;
1959 } 1997 }
1960 goto2next(parse); 1998 goto2next(parse);
diff --git a/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h
index 0e7e3d653cac..e2bcaba93871 100644
--- a/drivers/media/video/usbvision/usbvision.h
+++ b/drivers/media/video/usbvision/usbvision.h
@@ -219,18 +219,6 @@ enum {
219 ((udevice)->last_error == 0) && \ 219 ((udevice)->last_error == 0) && \
220 (!(udevice)->remove_pending)) 220 (!(udevice)->remove_pending))
221 221
222/* I2C structures */
223struct i2c_algo_usb_data {
224 void *data; /* private data for lowlevel routines */
225 int (*inb) (void *data, unsigned char addr, char *buf, short len);
226 int (*outb) (void *data, unsigned char addr, char *buf, short len);
227
228 /* local settings */
229 int udelay;
230 int mdelay;
231 int timeout;
232};
233
234#define I2C_USB_ADAP_MAX 16 222#define I2C_USB_ADAP_MAX 16
235 223
236/* ----------------------------------------------------------------- */ 224/* ----------------------------------------------------------------- */
@@ -383,7 +371,6 @@ struct usb_usbvision {
383 371
384 /* i2c Declaration Section*/ 372 /* i2c Declaration Section*/
385 struct i2c_adapter i2c_adap; 373 struct i2c_adapter i2c_adap;
386 struct i2c_algo_usb_data i2c_algo;
387 struct i2c_client i2c_client; 374 struct i2c_client i2c_client;
388 375
389 struct urb *ctrlUrb; 376 struct urb *ctrlUrb;
@@ -489,19 +476,8 @@ struct usb_usbvision {
489/* i2c-algo-usb declaration */ 476/* i2c-algo-usb declaration */
490/* --------------------------------------------------------------- */ 477/* --------------------------------------------------------------- */
491 478
492int usbvision_i2c_usb_add_bus(struct i2c_adapter *);
493int usbvision_i2c_usb_del_bus(struct i2c_adapter *); 479int usbvision_i2c_usb_del_bus(struct i2c_adapter *);
494 480
495static inline void *i2c_get_algo_usb_data (struct i2c_algo_usb_data *dev)
496{
497 return dev->data;
498}
499
500static inline void i2c_set_algo_usb_data (struct i2c_algo_usb_data *dev, void *data)
501{
502 dev->data = data;
503}
504
505 481
506/* ----------------------------------------------------------------------- */ 482/* ----------------------------------------------------------------------- */
507/* usbvision specific I2C functions */ 483/* usbvision specific I2C functions */
@@ -510,7 +486,6 @@ int usbvision_init_i2c(struct usb_usbvision *usbvision);
510void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd,void *arg); 486void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd,void *arg);
511 487
512/* defined in usbvision-core.c */ 488/* defined in usbvision-core.c */
513void *usbvision_rvmalloc(unsigned long size);
514void usbvision_rvfree(void *mem, unsigned long size); 489void usbvision_rvfree(void *mem, unsigned long size);
515int usbvision_read_reg(struct usb_usbvision *usbvision, unsigned char reg); 490int usbvision_read_reg(struct usb_usbvision *usbvision, unsigned char reg);
516int usbvision_write_reg(struct usb_usbvision *usbvision, unsigned char reg, 491int usbvision_write_reg(struct usb_usbvision *usbvision, unsigned char reg,
@@ -520,8 +495,6 @@ int usbvision_frames_alloc(struct usb_usbvision *usbvision);
520void usbvision_frames_free(struct usb_usbvision *usbvision); 495void usbvision_frames_free(struct usb_usbvision *usbvision);
521int usbvision_scratch_alloc(struct usb_usbvision *usbvision); 496int usbvision_scratch_alloc(struct usb_usbvision *usbvision);
522void usbvision_scratch_free(struct usb_usbvision *usbvision); 497void usbvision_scratch_free(struct usb_usbvision *usbvision);
523int usbvision_sbuf_alloc(struct usb_usbvision *usbvision);
524void usbvision_sbuf_free(struct usb_usbvision *usbvision);
525int usbvision_decompress_alloc(struct usb_usbvision *usbvision); 498int usbvision_decompress_alloc(struct usb_usbvision *usbvision);
526void usbvision_decompress_free(struct usb_usbvision *usbvision); 499void usbvision_decompress_free(struct usb_usbvision *usbvision);
527 500
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 474ddb779643..bacb311b4f24 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -535,9 +535,9 @@ static int vivi_start_thread(struct vivi_dmaqueue *dma_q)
535 535
536 dma_q->kthread = kthread_run(vivi_thread, dma_q, "vivi"); 536 dma_q->kthread = kthread_run(vivi_thread, dma_q, "vivi");
537 537
538 if (dma_q->kthread == NULL) { 538 if (IS_ERR(dma_q->kthread)) {
539 printk(KERN_ERR "vivi: kernel_thread() failed\n"); 539 printk(KERN_ERR "vivi: kernel_thread() failed\n");
540 return -EINVAL; 540 return PTR_ERR(dma_q->kthread);
541 } 541 }
542 dprintk(1,"returning from %s\n",__FUNCTION__); 542 dprintk(1,"returning from %s\n",__FUNCTION__);
543 return 0; 543 return 0;
@@ -1363,7 +1363,9 @@ static void __exit vivi_exit(void)
1363 struct vivi_dev *h; 1363 struct vivi_dev *h;
1364 struct list_head *list; 1364 struct list_head *list;
1365 1365
1366 list_for_each(list,&vivi_devlist) { 1366 while (!list_empty(&vivi_devlist)) {
1367 list = vivi_devlist.next;
1368 list_del(list);
1367 h = list_entry(list, struct vivi_dev, vivi_devlist); 1369 h = list_entry(list, struct vivi_dev, vivi_devlist);
1368 kfree (h); 1370 kfree (h);
1369 } 1371 }
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index 4bdc886abc4c..8d14f308f171 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -789,7 +789,7 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
789 case VIDIOCSPICT: 789 case VIDIOCSPICT:
790 { 790 {
791 struct video_picture *vpic = arg; 791 struct video_picture *vpic = arg;
792 if (vpic->depth != 16 || vpic->palette != VIDEO_PALETTE_YUV422) 792 if (vpic->depth != 16 || (vpic->palette != VIDEO_PALETTE_YUV422 && vpic->palette != VIDEO_PALETTE_YUYV))
793 return -EINVAL; 793 return -EINVAL;
794 794
795 cam->brightness = vpic->brightness >> 8; 795 cam->brightness = vpic->brightness >> 8;
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index ddce2fb83424..9f403af7b040 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -1827,8 +1827,8 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1827 int err = 0; 1827 int err = 0;
1828 1828
1829 /* Work around to avoid FP arithmetics */ 1829 /* Work around to avoid FP arithmetics */
1830 #define __SC(x) ((x) << 10) 1830 #define SC(x) ((x) << 10)
1831 #define __UNSC(x) ((x) >> 10) 1831 #define UNSC(x) ((x) >> 10)
1832 1832
1833 /* Make sure we are using a supported resolution */ 1833 /* Make sure we are using a supported resolution */
1834 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width, 1834 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width,
@@ -1836,15 +1836,15 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1836 goto error; 1836 goto error;
1837 1837
1838 /* Scaling factors */ 1838 /* Scaling factors */
1839 fw = __SC(win.width) / cam->maxwidth; 1839 fw = SC(win.width) / cam->maxwidth;
1840 fh = __SC(win.height) / cam->maxheight; 1840 fh = SC(win.height) / cam->maxheight;
1841 1841
1842 /* Set up the width and height values used by the chip */ 1842 /* Set up the width and height values used by the chip */
1843 if ((win.width > cam->maxwidth) || (win.height > cam->maxheight)) { 1843 if ((win.width > cam->maxwidth) || (win.height > cam->maxheight)) {
1844 cam->vpp_flag |= VPP_UPSCALE; 1844 cam->vpp_flag |= VPP_UPSCALE;
1845 /* Calculate largest w,h mantaining the same w/h ratio */ 1845 /* Calculate largest w,h mantaining the same w/h ratio */
1846 w = (fw >= fh) ? cam->maxwidth : __SC(win.width)/fh; 1846 w = (fw >= fh) ? cam->maxwidth : SC(win.width)/fh;
1847 h = (fw >= fh) ? __SC(win.height)/fw : cam->maxheight; 1847 h = (fw >= fh) ? SC(win.height)/fw : cam->maxheight;
1848 if (w < cam->minwidth) /* just in case */ 1848 if (w < cam->minwidth) /* just in case */
1849 w = cam->minwidth; 1849 w = cam->minwidth;
1850 if (h < cam->minheight) /* just in case */ 1850 if (h < cam->minheight) /* just in case */
@@ -1861,8 +1861,8 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1861 1861
1862 /* Calculate cropped area manteining the right w/h ratio */ 1862 /* Calculate cropped area manteining the right w/h ratio */
1863 if (cam->largeview && !(cam->vpp_flag & VPP_UPSCALE)) { 1863 if (cam->largeview && !(cam->vpp_flag & VPP_UPSCALE)) {
1864 cw = (fw >= fh) ? cam->maxwidth : __SC(win.width)/fh; 1864 cw = (fw >= fh) ? cam->maxwidth : SC(win.width)/fh;
1865 ch = (fw >= fh) ? __SC(win.height)/fw : cam->maxheight; 1865 ch = (fw >= fh) ? SC(win.height)/fw : cam->maxheight;
1866 } else { 1866 } else {
1867 cw = w; 1867 cw = w;
1868 ch = h; 1868 ch = h;
@@ -1901,8 +1901,8 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1901 /* We have to scale win.x and win.y offsets */ 1901 /* We have to scale win.x and win.y offsets */
1902 if ( (cam->largeview && !(cam->vpp_flag & VPP_UPSCALE)) 1902 if ( (cam->largeview && !(cam->vpp_flag & VPP_UPSCALE))
1903 || (cam->vpp_flag & VPP_UPSCALE) ) { 1903 || (cam->vpp_flag & VPP_UPSCALE) ) {
1904 ax = __SC(win.x)/fw; 1904 ax = SC(win.x)/fw;
1905 ay = __SC(win.y)/fh; 1905 ay = SC(win.y)/fh;
1906 } else { 1906 } else {
1907 ax = win.x; 1907 ax = win.x;
1908 ay = win.y; 1908 ay = win.y;
@@ -1917,8 +1917,8 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1917 /* Adjust win.x, win.y */ 1917 /* Adjust win.x, win.y */
1918 if ( (cam->largeview && !(cam->vpp_flag & VPP_UPSCALE)) 1918 if ( (cam->largeview && !(cam->vpp_flag & VPP_UPSCALE))
1919 || (cam->vpp_flag & VPP_UPSCALE) ) { 1919 || (cam->vpp_flag & VPP_UPSCALE) ) {
1920 win.x = __UNSC(ax*fw); 1920 win.x = UNSC(ax*fw);
1921 win.y = __UNSC(ay*fh); 1921 win.y = UNSC(ay*fh);
1922 } else { 1922 } else {
1923 win.x = ax; 1923 win.x = ax;
1924 win.y = ay; 1924 win.y = ay;
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
index 168e431d7c71..b0752767ee4f 100644
--- a/drivers/media/video/zoran_device.c
+++ b/drivers/media/video/zoran_device.c
@@ -429,7 +429,7 @@ zr36057_set_vfe (struct zoran *zr,
429 reg |= (HorDcm << ZR36057_VFESPFR_HorDcm); 429 reg |= (HorDcm << ZR36057_VFESPFR_HorDcm);
430 reg |= (VerDcm << ZR36057_VFESPFR_VerDcm); 430 reg |= (VerDcm << ZR36057_VFESPFR_VerDcm);
431 reg |= (DispMode << ZR36057_VFESPFR_DispMode); 431 reg |= (DispMode << ZR36057_VFESPFR_DispMode);
432 if (format->palette != VIDEO_PALETTE_YUV422) 432 if (format->palette != VIDEO_PALETTE_YUV422 && format->palette != VIDEO_PALETTE_YUYV)
433 reg |= ZR36057_VFESPFR_LittleEndian; 433 reg |= ZR36057_VFESPFR_LittleEndian;
434 /* RJ: I don't know, why the following has to be the opposite 434 /* RJ: I don't know, why the following has to be the opposite
435 * of the corresponding ZR36060 setting, but only this way 435 * of the corresponding ZR36060 setting, but only this way
@@ -441,6 +441,7 @@ zr36057_set_vfe (struct zoran *zr,
441 reg |= ZR36057_VFESPFR_TopField; 441 reg |= ZR36057_VFESPFR_TopField;
442 switch (format->palette) { 442 switch (format->palette) {
443 443
444 case VIDEO_PALETTE_YUYV:
444 case VIDEO_PALETTE_YUV422: 445 case VIDEO_PALETTE_YUV422:
445 reg |= ZR36057_VFESPFR_YUV422; 446 reg |= ZR36057_VFESPFR_YUV422;
446 break; 447 break;