]> err.no Git - linux-2.6/commitdiff
V4L/DVB (6670): V4L: saa7134: tvaudio cleanups
authorMaxim Levitsky <maximlevitsky@gmail.com>
Tue, 23 Oct 2007 03:58:59 +0000 (00:58 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Fri, 25 Jan 2008 21:02:46 +0000 (19:02 -0200)
move some tv-audio initialization code out of tvaudio thread,
and call it on resume too.

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/saa7134/saa7134-core.c
drivers/media/video/saa7134/saa7134-tvaudio.c
drivers/media/video/saa7134/saa7134.h

index f5e43d375d2add40aa032a677d2c6c0d39879784..cbddd35f161864a5abaa2f1852cd6ec376536b55 100644 (file)
@@ -1235,6 +1235,7 @@ static int saa7134_resume(struct pci_dev *pci_dev)
        saa7134_set_tvnorm_hw(dev);
        saa7134_tvaudio_setmute(dev);
        saa7134_tvaudio_setvolume(dev, dev->ctl_volume);
+       saa7134_tvaudio_init(dev);
        saa7134_tvaudio_do_scan(dev);
        saa7134_enable_i2s(dev);
        saa7134_hw_enable2(dev);
index f8e304c7623277b0aa43354e01459aeace8f72a2..4e9810469ae309c0ac41917c2764a7977301658e 100644 (file)
@@ -163,32 +163,6 @@ static struct saa7134_tvaudio tvaudio[] = {
 
 /* ------------------------------------------------------------------ */
 
-static void tvaudio_init(struct saa7134_dev *dev)
-{
-       int clock = saa7134_boards[dev->board].audio_clock;
-
-       if (UNSET != audio_clock_override)
-               clock = audio_clock_override;
-
-       /* init all audio registers */
-       saa_writeb(SAA7134_AUDIO_PLL_CTRL,   0x00);
-       if (need_resched())
-               schedule();
-       else
-               udelay(10);
-
-       saa_writeb(SAA7134_AUDIO_CLOCK0,      clock        & 0xff);
-       saa_writeb(SAA7134_AUDIO_CLOCK1,     (clock >>  8) & 0xff);
-       saa_writeb(SAA7134_AUDIO_CLOCK2,     (clock >> 16) & 0xff);
-       /* frame locked audio is mandatory for NICAM */
-       saa_writeb(SAA7134_AUDIO_PLL_CTRL,   0x01);
-
-       saa_writeb(SAA7134_NICAM_ERROR_LOW,  0x14);
-       saa_writeb(SAA7134_NICAM_ERROR_HIGH, 0x50);
-       saa_writeb(SAA7134_MONITOR_SELECT,   0xa0);
-       saa_writeb(SAA7134_FM_DEMATRIX,      0x80);
-}
-
 static u32 tvaudio_carr2reg(u32 carrier)
 {
        u64 a = carrier;
@@ -517,9 +491,13 @@ static int tvaudio_thread(void *data)
                dev->thread.scan1 = dev->thread.scan2;
                dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1);
                dev->tvaudio  = NULL;
-               tvaudio_init(dev);
+
+               saa_writeb(SAA7134_MONITOR_SELECT,   0xa0);
+               saa_writeb(SAA7134_FM_DEMATRIX,      0x80);
+
                if (dev->ctl_automute)
                        dev->automute = 1;
+
                mute_input_7134(dev);
 
                /* give the tuner some time */
@@ -784,27 +762,15 @@ static int mute_input_7133(struct saa7134_dev *dev)
 static int tvaudio_thread_ddep(void *data)
 {
        struct saa7134_dev *dev = data;
-       u32 value, norms, clock;
+       u32 value, norms;
 
 
        set_freezable();
-
-       clock = saa7134_boards[dev->board].audio_clock;
-       if (UNSET != audio_clock_override)
-               clock = audio_clock_override;
-       saa_writel(0x598 >> 2, clock);
-
-       /* unmute */
-       saa_dsp_writel(dev, 0x474 >> 2, 0x00);
-       saa_dsp_writel(dev, 0x450 >> 2, 0x00);
-
        for (;;) {
                tvaudio_sleep(dev,-1);
                if (kthread_should_stop())
                        goto done;
-
        restart:
-
                try_to_freeze();
 
                dev->thread.scan1 = dev->thread.scan2;
@@ -978,6 +944,38 @@ int saa7134_tvaudio_getstereo(struct saa7134_dev *dev)
        return retval;
 }
 
+void saa7134_tvaudio_init(struct saa7134_dev *dev)
+{
+       int clock = saa7134_boards[dev->board].audio_clock;
+
+       if (UNSET != audio_clock_override)
+               clock = audio_clock_override;
+
+       switch (dev->pci->device) {
+       case PCI_DEVICE_ID_PHILIPS_SAA7134:
+               /* init all audio registers */
+               saa_writeb(SAA7134_AUDIO_PLL_CTRL,   0x00);
+               if (need_resched())
+                       schedule();
+               else
+                       udelay(10);
+
+               saa_writeb(SAA7134_AUDIO_CLOCK0,      clock        & 0xff);
+               saa_writeb(SAA7134_AUDIO_CLOCK1,     (clock >>  8) & 0xff);
+               saa_writeb(SAA7134_AUDIO_CLOCK2,     (clock >> 16) & 0xff);
+               /* frame locked audio is mandatory for NICAM */
+               saa_writeb(SAA7134_AUDIO_PLL_CTRL,   0x01);
+               saa_writeb(SAA7134_NICAM_ERROR_LOW,  0x14);
+               saa_writeb(SAA7134_NICAM_ERROR_HIGH, 0x50);
+               break;
+       case PCI_DEVICE_ID_PHILIPS_SAA7133:
+       case PCI_DEVICE_ID_PHILIPS_SAA7135:
+               saa_writel(0x598 >> 2, clock);
+               saa_dsp_writel(dev, 0x474 >> 2, 0x00);
+               saa_dsp_writel(dev, 0x450 >> 2, 0x00);
+       }
+}
+
 int saa7134_tvaudio_init2(struct saa7134_dev *dev)
 {
        int (*my_thread)(void *data) = NULL;
@@ -994,6 +992,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev)
 
        dev->thread.thread = NULL;
        if (my_thread) {
+               saa7134_tvaudio_init(dev);
                /* start tvaudio thread */
                dev->thread.thread = kthread_run(my_thread, dev, "%s", dev->name);
                if (IS_ERR(dev->thread.thread)) {
index a531e3c6c94196899c15fe5d84de06f0327f817e..5c5b074130769f7fc715c1b49b56476210304abb 100644 (file)
@@ -678,6 +678,7 @@ void saa7134_tvaudio_setinput(struct saa7134_dev *dev,
 void saa7134_tvaudio_setvolume(struct saa7134_dev *dev, int level);
 int saa7134_tvaudio_getstereo(struct saa7134_dev *dev);
 
+void saa7134_tvaudio_init(struct saa7134_dev *dev);
 int saa7134_tvaudio_init2(struct saa7134_dev *dev);
 int saa7134_tvaudio_fini(struct saa7134_dev *dev);
 int saa7134_tvaudio_do_scan(struct saa7134_dev *dev);