diff options
author | Stas Sergeev <stsp@list.ru> | 2011-12-03 14:40:45 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-12-30 14:07:38 -0500 |
commit | a1dca1e30ac7991d8a90a3377008c850eb466edf (patch) | |
tree | aa9fae7075b74997e1c2e1ad457a423373c04a2c | |
parent | 8cc20dd89c9ec807b169c8db42192377da470acc (diff) |
[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: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/saa7134/saa7134-core.c | 1 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-tvaudio.c | 63 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-video.c | 2 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 1 |
4 files changed, 40 insertions, 27 deletions
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index ca65cda3e101..5fbb4e49495c 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -1263,7 +1263,6 @@ static int saa7134_resume(struct pci_dev *pci_dev) | |||
1263 | saa7134_tvaudio_setmute(dev); | 1263 | saa7134_tvaudio_setmute(dev); |
1264 | saa7134_tvaudio_setvolume(dev, dev->ctl_volume); | 1264 | saa7134_tvaudio_setvolume(dev, dev->ctl_volume); |
1265 | saa7134_tvaudio_init(dev); | 1265 | saa7134_tvaudio_init(dev); |
1266 | saa7134_tvaudio_do_scan(dev); | ||
1267 | saa7134_enable_i2s(dev); | 1266 | saa7134_enable_i2s(dev); |
1268 | saa7134_hw_enable2(dev); | 1267 | saa7134_hw_enable2(dev); |
1269 | 1268 | ||
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index 57e646bb48b3..ec1df6f6f430 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c | |||
@@ -332,6 +332,13 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan) | |||
332 | { | 332 | { |
333 | __s32 left,right,value; | 333 | __s32 left,right,value; |
334 | 334 | ||
335 | if (!(dev->tvnorm->id & scan->std)) { | ||
336 | value = 0; | ||
337 | dprintk("skipping %d.%03d MHz [%4s]\n", | ||
338 | scan->carr / 1000, scan->carr % 1000, scan->name); | ||
339 | return 0; | ||
340 | } | ||
341 | |||
335 | if (audio_debug > 1) { | 342 | if (audio_debug > 1) { |
336 | int i; | 343 | int i; |
337 | dprintk("debug %d:",scan->carr); | 344 | dprintk("debug %d:",scan->carr); |
@@ -348,30 +355,25 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan) | |||
348 | } | 355 | } |
349 | printk("\n"); | 356 | printk("\n"); |
350 | } | 357 | } |
351 | if (dev->tvnorm->id & scan->std) { | 358 | |
352 | tvaudio_setcarrier(dev,scan->carr-90,scan->carr-90); | 359 | tvaudio_setcarrier(dev,scan->carr-90,scan->carr-90); |
353 | saa_readl(SAA7134_LEVEL_READOUT1 >> 2); | 360 | saa_readl(SAA7134_LEVEL_READOUT1 >> 2); |
354 | if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY)) | 361 | if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY)) |
355 | return -1; | 362 | return -1; |
356 | left = saa_readl(SAA7134_LEVEL_READOUT1 >> 2); | 363 | left = saa_readl(SAA7134_LEVEL_READOUT1 >> 2); |
357 | 364 | ||
358 | tvaudio_setcarrier(dev,scan->carr+90,scan->carr+90); | 365 | tvaudio_setcarrier(dev,scan->carr+90,scan->carr+90); |
359 | saa_readl(SAA7134_LEVEL_READOUT1 >> 2); | 366 | saa_readl(SAA7134_LEVEL_READOUT1 >> 2); |
360 | if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY)) | 367 | if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY)) |
361 | return -1; | 368 | return -1; |
362 | right = saa_readl(SAA7134_LEVEL_READOUT1 >> 2); | 369 | right = saa_readl(SAA7134_LEVEL_READOUT1 >> 2); |
363 | 370 | ||
364 | left >>= 16; | 371 | left >>= 16; |
365 | right >>= 16; | 372 | right >>= 16; |
366 | value = left > right ? left - right : right - left; | 373 | value = left > right ? left - right : right - left; |
367 | dprintk("scanning %d.%03d MHz [%4s] => dc is %5d [%d/%d]\n", | 374 | dprintk("scanning %d.%03d MHz [%4s] => dc is %5d [%d/%d]\n", |
368 | scan->carr / 1000, scan->carr % 1000, | 375 | scan->carr / 1000, scan->carr % 1000, |
369 | scan->name, value, left, right); | 376 | scan->name, value, left, right); |
370 | } else { | ||
371 | value = 0; | ||
372 | dprintk("skipping %d.%03d MHz [%4s]\n", | ||
373 | scan->carr / 1000, scan->carr % 1000, scan->name); | ||
374 | } | ||
375 | return value; | 377 | return value; |
376 | } | 378 | } |
377 | 379 | ||
@@ -546,6 +548,7 @@ static int tvaudio_thread(void *data) | |||
546 | dev->tvnorm->name, carrier/1000, carrier%1000, | 548 | dev->tvnorm->name, carrier/1000, carrier%1000, |
547 | max1, max2); | 549 | max1, max2); |
548 | dev->last_carrier = carrier; | 550 | dev->last_carrier = carrier; |
551 | dev->automute = 0; | ||
549 | 552 | ||
550 | } else if (0 != dev->last_carrier) { | 553 | } else if (0 != dev->last_carrier) { |
551 | /* no carrier -- try last detected one as fallback */ | 554 | /* no carrier -- try last detected one as fallback */ |
@@ -553,6 +556,7 @@ static int tvaudio_thread(void *data) | |||
553 | dprintk("audio carrier scan failed, " | 556 | dprintk("audio carrier scan failed, " |
554 | "using %d.%03d MHz [last detected]\n", | 557 | "using %d.%03d MHz [last detected]\n", |
555 | carrier/1000, carrier%1000); | 558 | carrier/1000, carrier%1000); |
559 | dev->automute = 1; | ||
556 | 560 | ||
557 | } else { | 561 | } else { |
558 | /* no carrier + no fallback -- use default */ | 562 | /* no carrier + no fallback -- use default */ |
@@ -560,9 +564,9 @@ static int tvaudio_thread(void *data) | |||
560 | dprintk("audio carrier scan failed, " | 564 | dprintk("audio carrier scan failed, " |
561 | "using %d.%03d MHz [default]\n", | 565 | "using %d.%03d MHz [default]\n", |
562 | carrier/1000, carrier%1000); | 566 | carrier/1000, carrier%1000); |
567 | dev->automute = 1; | ||
563 | } | 568 | } |
564 | tvaudio_setcarrier(dev,carrier,carrier); | 569 | tvaudio_setcarrier(dev,carrier,carrier); |
565 | dev->automute = 0; | ||
566 | saa_andorb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0x30, 0x00); | 570 | saa_andorb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0x30, 0x00); |
567 | saa7134_tvaudio_setmute(dev); | 571 | saa7134_tvaudio_setmute(dev); |
568 | /* find the exact tv audio norm */ | 572 | /* find the exact tv audio norm */ |
@@ -1020,6 +1024,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) | |||
1020 | } | 1024 | } |
1021 | 1025 | ||
1022 | dev->thread.thread = NULL; | 1026 | dev->thread.thread = NULL; |
1027 | dev->thread.scan1 = dev->thread.scan2 = 0; | ||
1023 | if (my_thread) { | 1028 | if (my_thread) { |
1024 | saa7134_tvaudio_init(dev); | 1029 | saa7134_tvaudio_init(dev); |
1025 | /* start tvaudio thread */ | 1030 | /* start tvaudio thread */ |
@@ -1029,13 +1034,19 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) | |||
1029 | dev->name); | 1034 | dev->name); |
1030 | /* XXX: missing error handling here */ | 1035 | /* XXX: missing error handling here */ |
1031 | } | 1036 | } |
1032 | saa7134_tvaudio_do_scan(dev); | ||
1033 | } | 1037 | } |
1034 | 1038 | ||
1035 | saa7134_enable_i2s(dev); | 1039 | saa7134_enable_i2s(dev); |
1036 | return 0; | 1040 | return 0; |
1037 | } | 1041 | } |
1038 | 1042 | ||
1043 | int saa7134_tvaudio_close(struct saa7134_dev *dev) | ||
1044 | { | ||
1045 | dev->automute = 1; | ||
1046 | /* anything else to undo? */ | ||
1047 | return 0; | ||
1048 | } | ||
1049 | |||
1039 | int saa7134_tvaudio_fini(struct saa7134_dev *dev) | 1050 | int saa7134_tvaudio_fini(struct saa7134_dev *dev) |
1040 | { | 1051 | { |
1041 | /* shutdown tvaudio thread */ | 1052 | /* shutdown tvaudio thread */ |
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 9cf7914f6f90..417034eb6ad2 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
@@ -1462,6 +1462,8 @@ static int video_release(struct file *file) | |||
1462 | struct saa6588_command cmd; | 1462 | struct saa6588_command cmd; |
1463 | unsigned long flags; | 1463 | unsigned long flags; |
1464 | 1464 | ||
1465 | saa7134_tvaudio_close(dev); | ||
1466 | |||
1465 | /* turn off overlay */ | 1467 | /* turn off overlay */ |
1466 | if (res_check(fh, RESOURCE_OVERLAY)) { | 1468 | if (res_check(fh, RESOURCE_OVERLAY)) { |
1467 | spin_lock_irqsave(&dev->slock,flags); | 1469 | spin_lock_irqsave(&dev->slock,flags); |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 4ad9de4410d4..42fba4f93c72 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -818,6 +818,7 @@ void saa7134_tvaudio_init(struct saa7134_dev *dev); | |||
818 | int saa7134_tvaudio_init2(struct saa7134_dev *dev); | 818 | int saa7134_tvaudio_init2(struct saa7134_dev *dev); |
819 | int saa7134_tvaudio_fini(struct saa7134_dev *dev); | 819 | int saa7134_tvaudio_fini(struct saa7134_dev *dev); |
820 | int saa7134_tvaudio_do_scan(struct saa7134_dev *dev); | 820 | int saa7134_tvaudio_do_scan(struct saa7134_dev *dev); |
821 | int saa7134_tvaudio_close(struct saa7134_dev *dev); | ||
821 | 822 | ||
822 | int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value); | 823 | int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value); |
823 | 824 | ||