]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
V4L: bttv: fix v4l1 api usage breaking the driver
authorTrent Piepho <xyzzy@speakeasy.org>
Tue, 10 Jul 2007 04:03:01 +0000 (00:03 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 4 Aug 2007 16:10:26 +0000 (09:10 -0700)
If one uses a V4L *one* application, such as vlc or mplayer's v4l driver, as
the first user after the driver is loaded, the driver wedges itself and will
never capture properly.  Even if one uses a V4L2 application later, it still
won't work.

If one uses a V4L *two* application first, such as tvtime or mplayer's v4l2
driver, then the driver will be ok.  One can then run a V4L1 application, and
it will work.

It turns out the problem is with norm changing and the crop support that was
added in 2.6.21.  The driver defaults to PAL, and keeps the last norm it was
set too across opens.  If one changes the norm via V4L1, the cropping
parameters are not reset like they should be, and they'll remain broken across
device opens.

This patch removes the direct setting of btv->tvnorm in the V4L1 ioctl
VIDIOCSCHAN handler.  The norm is set via the existing call to set_input(),
which calls set_tvnorm(), which will reset the cropping values now that it is
able to detect the norm change.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/media/video/bt8xx/bttv-driver.c

index 5720b77ac9a78deed24e01a422b8b649cfa26187..d4bef35c40bba8ec7ca89ad646a176063cd60eac 100644 (file)
@@ -1313,7 +1313,7 @@ set_tvnorm(struct bttv *btv, unsigned int norm)
 
 /* Call with btv->lock down. */
 static void
-set_input(struct bttv *btv, unsigned int input)
+set_input(struct bttv *btv, unsigned int input, unsigned int norm)
 {
        unsigned long flags;
 
@@ -1332,7 +1332,7 @@ set_input(struct bttv *btv, unsigned int input)
        }
        audio_input(btv,(input == bttv_tvcards[btv->c.type].tuner ?
                       TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN));
-       set_tvnorm(btv,btv->tvnorm);
+       set_tvnorm(btv, norm);
        i2c_vidiocschan(btv);
 }
 
@@ -1423,7 +1423,7 @@ static void bttv_reinit_bt848(struct bttv *btv)
 
        init_bt848(btv);
        btv->pll.pll_current = -1;
-       set_input(btv,btv->input);
+       set_input(btv, btv->input, btv->tvnorm);
 }
 
 static int get_control(struct bttv *btv, struct v4l2_control *c)
@@ -1993,8 +1993,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
                        return 0;
                }
 
-               btv->tvnorm = v->norm;
-               set_input(btv,v->channel);
+               set_input(btv, v->channel, v->norm);
                mutex_unlock(&btv->lock);
                return 0;
        }
@@ -2130,7 +2129,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
                if (*i > bttv_tvcards[btv->c.type].video_inputs)
                        return -EINVAL;
                mutex_lock(&btv->lock);
-               set_input(btv,*i);
+               set_input(btv, *i, btv->tvnorm);
                mutex_unlock(&btv->lock);
                return 0;
        }
@@ -4762,7 +4761,7 @@ static int __devinit bttv_probe(struct pci_dev *dev,
                bt848_hue(btv,32768);
                bt848_sat(btv,32768);
                audio_mute(btv, 1);
-               set_input(btv,0);
+               set_input(btv, 0, btv->tvnorm);
                bttv_crop_reset(&btv->crop[0], btv->tvnorm);
                btv->crop[1] = btv->crop[0]; /* current = default */
                disclaim_vbi_lines(btv);