]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
[media] [saa7134] do not change mute state for capturing audio
authorStas Sergeev <stsp@list.ru>
Sat, 3 Dec 2011 19:40:45 +0000 (16:40 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 30 Dec 2011 19:07:38 +0000 (17:07 -0200)
The attached patch fixes the automute logic of saa7134.
It avoids the white noise on the pulseaudio startup.
(pulseaudio reads the saa7134 alsa device on startup)

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/saa7134/saa7134-core.c
drivers/media/video/saa7134/saa7134-tvaudio.c
drivers/media/video/saa7134/saa7134-video.c
drivers/media/video/saa7134/saa7134.h

index ca65cda3e101880d63b1c002412af0f80a6561a2..5fbb4e49495c8278f25da91b4dca454c405e5dc0 100644 (file)
@@ -1263,7 +1263,6 @@ static int saa7134_resume(struct pci_dev *pci_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 57e646bb48b394008e42b686922dc3233554fb9f..ec1df6f6f43066969c58e6bb044adb2fb7e134bd 100644 (file)
@@ -332,6 +332,13 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan)
 {
        __s32 left,right,value;
 
+       if (!(dev->tvnorm->id & scan->std)) {
+               value = 0;
+               dprintk("skipping %d.%03d MHz [%4s]\n",
+                       scan->carr / 1000, scan->carr % 1000, scan->name);
+               return 0;
+       }
+
        if (audio_debug > 1) {
                int i;
                dprintk("debug %d:",scan->carr);
@@ -348,30 +355,25 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan)
                }
                printk("\n");
        }
-       if (dev->tvnorm->id & scan->std) {
-               tvaudio_setcarrier(dev,scan->carr-90,scan->carr-90);
-               saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
-               if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
-                       return -1;
-               left = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
-
-               tvaudio_setcarrier(dev,scan->carr+90,scan->carr+90);
-               saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
-               if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
-                       return -1;
-               right = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
-
-               left >>= 16;
-               right >>= 16;
-               value = left > right ? left - right : right - left;
-               dprintk("scanning %d.%03d MHz [%4s] =>  dc is %5d [%d/%d]\n",
-                       scan->carr / 1000, scan->carr % 1000,
-                       scan->name, value, left, right);
-       } else {
-               value = 0;
-               dprintk("skipping %d.%03d MHz [%4s]\n",
-                       scan->carr / 1000, scan->carr % 1000, scan->name);
-       }
+
+       tvaudio_setcarrier(dev,scan->carr-90,scan->carr-90);
+       saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
+       if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
+               return -1;
+       left = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
+
+       tvaudio_setcarrier(dev,scan->carr+90,scan->carr+90);
+       saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
+       if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
+               return -1;
+       right = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
+
+       left >>= 16;
+       right >>= 16;
+       value = left > right ? left - right : right - left;
+       dprintk("scanning %d.%03d MHz [%4s] =>  dc is %5d [%d/%d]\n",
+               scan->carr / 1000, scan->carr % 1000,
+               scan->name, value, left, right);
        return value;
 }
 
@@ -546,6 +548,7 @@ static int tvaudio_thread(void *data)
                                dev->tvnorm->name, carrier/1000, carrier%1000,
                                max1, max2);
                        dev->last_carrier = carrier;
+                       dev->automute = 0;
 
                } else if (0 != dev->last_carrier) {
                        /* no carrier -- try last detected one as fallback */
@@ -553,6 +556,7 @@ static int tvaudio_thread(void *data)
                        dprintk("audio carrier scan failed, "
                                "using %d.%03d MHz [last detected]\n",
                                carrier/1000, carrier%1000);
+                       dev->automute = 1;
 
                } else {
                        /* no carrier + no fallback -- use default */
@@ -560,9 +564,9 @@ static int tvaudio_thread(void *data)
                        dprintk("audio carrier scan failed, "
                                "using %d.%03d MHz [default]\n",
                                carrier/1000, carrier%1000);
+                       dev->automute = 1;
                }
                tvaudio_setcarrier(dev,carrier,carrier);
-               dev->automute = 0;
                saa_andorb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0x30, 0x00);
                saa7134_tvaudio_setmute(dev);
                /* find the exact tv audio norm */
@@ -1020,6 +1024,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev)
        }
 
        dev->thread.thread = NULL;
+       dev->thread.scan1 = dev->thread.scan2 = 0;
        if (my_thread) {
                saa7134_tvaudio_init(dev);
                /* start tvaudio thread */
@@ -1029,13 +1034,19 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev)
                               dev->name);
                        /* XXX: missing error handling here */
                }
-               saa7134_tvaudio_do_scan(dev);
        }
 
        saa7134_enable_i2s(dev);
        return 0;
 }
 
+int saa7134_tvaudio_close(struct saa7134_dev *dev)
+{
+       dev->automute = 1;
+       /* anything else to undo? */
+       return 0;
+}
+
 int saa7134_tvaudio_fini(struct saa7134_dev *dev)
 {
        /* shutdown tvaudio thread */
index 9cf7914f6f90eb87c03205650a39396a50b84f38..417034eb6ad258d55cfe10dc0d160e00b9a6130f 100644 (file)
@@ -1462,6 +1462,8 @@ static int video_release(struct file *file)
        struct saa6588_command cmd;
        unsigned long flags;
 
+       saa7134_tvaudio_close(dev);
+
        /* turn off overlay */
        if (res_check(fh, RESOURCE_OVERLAY)) {
                spin_lock_irqsave(&dev->slock,flags);
index 4ad9de4410d4c31b1c2c781a62341606a6fc52f7..42fba4f93c72b95cf1429f2e846b0b608ac2c77b 100644 (file)
@@ -818,6 +818,7 @@ 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);
+int saa7134_tvaudio_close(struct saa7134_dev *dev);
 
 int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value);