提交 a1dca1e3 编写于 作者: S Stas Sergeev 提交者: Mauro Carvalho Chehab

[media] [saa7134] do not change mute state for capturing audio

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: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 8cc20dd8
...@@ -1263,7 +1263,6 @@ static int saa7134_resume(struct pci_dev *pci_dev) ...@@ -1263,7 +1263,6 @@ static int saa7134_resume(struct pci_dev *pci_dev)
saa7134_tvaudio_setmute(dev); saa7134_tvaudio_setmute(dev);
saa7134_tvaudio_setvolume(dev, dev->ctl_volume); saa7134_tvaudio_setvolume(dev, dev->ctl_volume);
saa7134_tvaudio_init(dev); saa7134_tvaudio_init(dev);
saa7134_tvaudio_do_scan(dev);
saa7134_enable_i2s(dev); saa7134_enable_i2s(dev);
saa7134_hw_enable2(dev); saa7134_hw_enable2(dev);
......
...@@ -332,6 +332,13 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan) ...@@ -332,6 +332,13 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan)
{ {
__s32 left,right,value; __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) { if (audio_debug > 1) {
int i; int i;
dprintk("debug %d:",scan->carr); dprintk("debug %d:",scan->carr);
...@@ -348,30 +355,25 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan) ...@@ -348,30 +355,25 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan)
} }
printk("\n"); printk("\n");
} }
if (dev->tvnorm->id & scan->std) {
tvaudio_setcarrier(dev,scan->carr-90,scan->carr-90); tvaudio_setcarrier(dev,scan->carr-90,scan->carr-90);
saa_readl(SAA7134_LEVEL_READOUT1 >> 2); saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY)) if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
return -1; return -1;
left = saa_readl(SAA7134_LEVEL_READOUT1 >> 2); left = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
tvaudio_setcarrier(dev,scan->carr+90,scan->carr+90); tvaudio_setcarrier(dev,scan->carr+90,scan->carr+90);
saa_readl(SAA7134_LEVEL_READOUT1 >> 2); saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY)) if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
return -1; return -1;
right = saa_readl(SAA7134_LEVEL_READOUT1 >> 2); right = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
left >>= 16; left >>= 16;
right >>= 16; right >>= 16;
value = left > right ? left - right : right - left; value = left > right ? left - right : right - left;
dprintk("scanning %d.%03d MHz [%4s] => dc is %5d [%d/%d]\n", dprintk("scanning %d.%03d MHz [%4s] => dc is %5d [%d/%d]\n",
scan->carr / 1000, scan->carr % 1000, scan->carr / 1000, scan->carr % 1000,
scan->name, value, left, right); scan->name, value, left, right);
} else {
value = 0;
dprintk("skipping %d.%03d MHz [%4s]\n",
scan->carr / 1000, scan->carr % 1000, scan->name);
}
return value; return value;
} }
...@@ -546,6 +548,7 @@ static int tvaudio_thread(void *data) ...@@ -546,6 +548,7 @@ static int tvaudio_thread(void *data)
dev->tvnorm->name, carrier/1000, carrier%1000, dev->tvnorm->name, carrier/1000, carrier%1000,
max1, max2); max1, max2);
dev->last_carrier = carrier; dev->last_carrier = carrier;
dev->automute = 0;
} else if (0 != dev->last_carrier) { } else if (0 != dev->last_carrier) {
/* no carrier -- try last detected one as fallback */ /* no carrier -- try last detected one as fallback */
...@@ -553,6 +556,7 @@ static int tvaudio_thread(void *data) ...@@ -553,6 +556,7 @@ static int tvaudio_thread(void *data)
dprintk("audio carrier scan failed, " dprintk("audio carrier scan failed, "
"using %d.%03d MHz [last detected]\n", "using %d.%03d MHz [last detected]\n",
carrier/1000, carrier%1000); carrier/1000, carrier%1000);
dev->automute = 1;
} else { } else {
/* no carrier + no fallback -- use default */ /* no carrier + no fallback -- use default */
...@@ -560,9 +564,9 @@ static int tvaudio_thread(void *data) ...@@ -560,9 +564,9 @@ static int tvaudio_thread(void *data)
dprintk("audio carrier scan failed, " dprintk("audio carrier scan failed, "
"using %d.%03d MHz [default]\n", "using %d.%03d MHz [default]\n",
carrier/1000, carrier%1000); carrier/1000, carrier%1000);
dev->automute = 1;
} }
tvaudio_setcarrier(dev,carrier,carrier); tvaudio_setcarrier(dev,carrier,carrier);
dev->automute = 0;
saa_andorb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0x30, 0x00); saa_andorb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0x30, 0x00);
saa7134_tvaudio_setmute(dev); saa7134_tvaudio_setmute(dev);
/* find the exact tv audio norm */ /* find the exact tv audio norm */
...@@ -1020,6 +1024,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) ...@@ -1020,6 +1024,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev)
} }
dev->thread.thread = NULL; dev->thread.thread = NULL;
dev->thread.scan1 = dev->thread.scan2 = 0;
if (my_thread) { if (my_thread) {
saa7134_tvaudio_init(dev); saa7134_tvaudio_init(dev);
/* start tvaudio thread */ /* start tvaudio thread */
...@@ -1029,13 +1034,19 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) ...@@ -1029,13 +1034,19 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev)
dev->name); dev->name);
/* XXX: missing error handling here */ /* XXX: missing error handling here */
} }
saa7134_tvaudio_do_scan(dev);
} }
saa7134_enable_i2s(dev); saa7134_enable_i2s(dev);
return 0; 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) int saa7134_tvaudio_fini(struct saa7134_dev *dev)
{ {
/* shutdown tvaudio thread */ /* shutdown tvaudio thread */
......
...@@ -1462,6 +1462,8 @@ static int video_release(struct file *file) ...@@ -1462,6 +1462,8 @@ static int video_release(struct file *file)
struct saa6588_command cmd; struct saa6588_command cmd;
unsigned long flags; unsigned long flags;
saa7134_tvaudio_close(dev);
/* turn off overlay */ /* turn off overlay */
if (res_check(fh, RESOURCE_OVERLAY)) { if (res_check(fh, RESOURCE_OVERLAY)) {
spin_lock_irqsave(&dev->slock,flags); spin_lock_irqsave(&dev->slock,flags);
......
...@@ -818,6 +818,7 @@ void saa7134_tvaudio_init(struct saa7134_dev *dev); ...@@ -818,6 +818,7 @@ void saa7134_tvaudio_init(struct saa7134_dev *dev);
int saa7134_tvaudio_init2(struct saa7134_dev *dev); int saa7134_tvaudio_init2(struct saa7134_dev *dev);
int saa7134_tvaudio_fini(struct saa7134_dev *dev); int saa7134_tvaudio_fini(struct saa7134_dev *dev);
int saa7134_tvaudio_do_scan(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); int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册