diff options
author | Maxim Levitsky <maximlevitsky@gmail.com> | 2007-10-22 23:58:59 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:02:46 -0500 |
commit | f36224d3992a7734349cdd6289ff73c3d007ce09 (patch) | |
tree | df4735db1be35a5abc3150407fa721785c9c231d /drivers/media/video/saa7134/saa7134-tvaudio.c | |
parent | 5c01203fd289214ae3062dab4039fcbab4b2b84f (diff) |
V4L/DVB (6670): V4L: saa7134: tvaudio cleanups
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>
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-tvaudio.c')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-tvaudio.c | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index f8e304c7623..4e9810469ae 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c | |||
@@ -163,32 +163,6 @@ static struct saa7134_tvaudio tvaudio[] = { | |||
163 | 163 | ||
164 | /* ------------------------------------------------------------------ */ | 164 | /* ------------------------------------------------------------------ */ |
165 | 165 | ||
166 | static void tvaudio_init(struct saa7134_dev *dev) | ||
167 | { | ||
168 | int clock = saa7134_boards[dev->board].audio_clock; | ||
169 | |||
170 | if (UNSET != audio_clock_override) | ||
171 | clock = audio_clock_override; | ||
172 | |||
173 | /* init all audio registers */ | ||
174 | saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x00); | ||
175 | if (need_resched()) | ||
176 | schedule(); | ||
177 | else | ||
178 | udelay(10); | ||
179 | |||
180 | saa_writeb(SAA7134_AUDIO_CLOCK0, clock & 0xff); | ||
181 | saa_writeb(SAA7134_AUDIO_CLOCK1, (clock >> 8) & 0xff); | ||
182 | saa_writeb(SAA7134_AUDIO_CLOCK2, (clock >> 16) & 0xff); | ||
183 | /* frame locked audio is mandatory for NICAM */ | ||
184 | saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x01); | ||
185 | |||
186 | saa_writeb(SAA7134_NICAM_ERROR_LOW, 0x14); | ||
187 | saa_writeb(SAA7134_NICAM_ERROR_HIGH, 0x50); | ||
188 | saa_writeb(SAA7134_MONITOR_SELECT, 0xa0); | ||
189 | saa_writeb(SAA7134_FM_DEMATRIX, 0x80); | ||
190 | } | ||
191 | |||
192 | static u32 tvaudio_carr2reg(u32 carrier) | 166 | static u32 tvaudio_carr2reg(u32 carrier) |
193 | { | 167 | { |
194 | u64 a = carrier; | 168 | u64 a = carrier; |
@@ -517,9 +491,13 @@ static int tvaudio_thread(void *data) | |||
517 | dev->thread.scan1 = dev->thread.scan2; | 491 | dev->thread.scan1 = dev->thread.scan2; |
518 | dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); | 492 | dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); |
519 | dev->tvaudio = NULL; | 493 | dev->tvaudio = NULL; |
520 | tvaudio_init(dev); | 494 | |
495 | saa_writeb(SAA7134_MONITOR_SELECT, 0xa0); | ||
496 | saa_writeb(SAA7134_FM_DEMATRIX, 0x80); | ||
497 | |||
521 | if (dev->ctl_automute) | 498 | if (dev->ctl_automute) |
522 | dev->automute = 1; | 499 | dev->automute = 1; |
500 | |||
523 | mute_input_7134(dev); | 501 | mute_input_7134(dev); |
524 | 502 | ||
525 | /* give the tuner some time */ | 503 | /* give the tuner some time */ |
@@ -784,27 +762,15 @@ static int mute_input_7133(struct saa7134_dev *dev) | |||
784 | static int tvaudio_thread_ddep(void *data) | 762 | static int tvaudio_thread_ddep(void *data) |
785 | { | 763 | { |
786 | struct saa7134_dev *dev = data; | 764 | struct saa7134_dev *dev = data; |
787 | u32 value, norms, clock; | 765 | u32 value, norms; |
788 | 766 | ||
789 | 767 | ||
790 | set_freezable(); | 768 | set_freezable(); |
791 | |||
792 | clock = saa7134_boards[dev->board].audio_clock; | ||
793 | if (UNSET != audio_clock_override) | ||
794 | clock = audio_clock_override; | ||
795 | saa_writel(0x598 >> 2, clock); | ||
796 | |||
797 | /* unmute */ | ||
798 | saa_dsp_writel(dev, 0x474 >> 2, 0x00); | ||
799 | saa_dsp_writel(dev, 0x450 >> 2, 0x00); | ||
800 | |||
801 | for (;;) { | 769 | for (;;) { |
802 | tvaudio_sleep(dev,-1); | 770 | tvaudio_sleep(dev,-1); |
803 | if (kthread_should_stop()) | 771 | if (kthread_should_stop()) |
804 | goto done; | 772 | goto done; |
805 | |||
806 | restart: | 773 | restart: |
807 | |||
808 | try_to_freeze(); | 774 | try_to_freeze(); |
809 | 775 | ||
810 | dev->thread.scan1 = dev->thread.scan2; | 776 | dev->thread.scan1 = dev->thread.scan2; |
@@ -978,6 +944,38 @@ int saa7134_tvaudio_getstereo(struct saa7134_dev *dev) | |||
978 | return retval; | 944 | return retval; |
979 | } | 945 | } |
980 | 946 | ||
947 | void saa7134_tvaudio_init(struct saa7134_dev *dev) | ||
948 | { | ||
949 | int clock = saa7134_boards[dev->board].audio_clock; | ||
950 | |||
951 | if (UNSET != audio_clock_override) | ||
952 | clock = audio_clock_override; | ||
953 | |||
954 | switch (dev->pci->device) { | ||
955 | case PCI_DEVICE_ID_PHILIPS_SAA7134: | ||
956 | /* init all audio registers */ | ||
957 | saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x00); | ||
958 | if (need_resched()) | ||
959 | schedule(); | ||
960 | else | ||
961 | udelay(10); | ||
962 | |||
963 | saa_writeb(SAA7134_AUDIO_CLOCK0, clock & 0xff); | ||
964 | saa_writeb(SAA7134_AUDIO_CLOCK1, (clock >> 8) & 0xff); | ||
965 | saa_writeb(SAA7134_AUDIO_CLOCK2, (clock >> 16) & 0xff); | ||
966 | /* frame locked audio is mandatory for NICAM */ | ||
967 | saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x01); | ||
968 | saa_writeb(SAA7134_NICAM_ERROR_LOW, 0x14); | ||
969 | saa_writeb(SAA7134_NICAM_ERROR_HIGH, 0x50); | ||
970 | break; | ||
971 | case PCI_DEVICE_ID_PHILIPS_SAA7133: | ||
972 | case PCI_DEVICE_ID_PHILIPS_SAA7135: | ||
973 | saa_writel(0x598 >> 2, clock); | ||
974 | saa_dsp_writel(dev, 0x474 >> 2, 0x00); | ||
975 | saa_dsp_writel(dev, 0x450 >> 2, 0x00); | ||
976 | } | ||
977 | } | ||
978 | |||
981 | int saa7134_tvaudio_init2(struct saa7134_dev *dev) | 979 | int saa7134_tvaudio_init2(struct saa7134_dev *dev) |
982 | { | 980 | { |
983 | int (*my_thread)(void *data) = NULL; | 981 | int (*my_thread)(void *data) = NULL; |
@@ -994,6 +992,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) | |||
994 | 992 | ||
995 | dev->thread.thread = NULL; | 993 | dev->thread.thread = NULL; |
996 | if (my_thread) { | 994 | if (my_thread) { |
995 | saa7134_tvaudio_init(dev); | ||
997 | /* start tvaudio thread */ | 996 | /* start tvaudio thread */ |
998 | dev->thread.thread = kthread_run(my_thread, dev, "%s", dev->name); | 997 | dev->thread.thread = kthread_run(my_thread, dev, "%s", dev->name); |
999 | if (IS_ERR(dev->thread.thread)) { | 998 | if (IS_ERR(dev->thread.thread)) { |