diff options
author | Ricardo Cerqueira <v4l@cerqueira.org> | 2005-11-09 00:38:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:31 -0500 |
commit | 79dd0c69f05fccb0396bdcd861ad4686ce888cda (patch) | |
tree | e027b7eede37e1212c3237f3a85824a4990e23ee | |
parent | 875c296b8ef42a796dc8db57a40b5e2228240c33 (diff) |
[PATCH] V4L: 925: saa7134 alsa is now a standalone module
Saa7134-alsa is now a standalone module
Signed-off-by: Ricardo Cerqueira <v4l@cerqueira.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/media/video/saa7134/saa7134-alsa.c | 110 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-core.c | 29 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-tvaudio.c | 3 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 8 |
4 files changed, 121 insertions, 29 deletions
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index bf454437b771..7972939cb46c 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c | |||
@@ -1,6 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SAA713x ALSA support for V4L | 2 | * SAA713x ALSA support for V4L |
3 | * Ricardo Cerqueira <v4l@cerqueira.org> | ||
4 | * | 3 | * |
5 | * | 4 | * |
6 | * Caveats: | 5 | * Caveats: |
@@ -37,9 +36,13 @@ | |||
37 | #include "saa7134.h" | 36 | #include "saa7134.h" |
38 | #include "saa7134-reg.h" | 37 | #include "saa7134-reg.h" |
39 | 38 | ||
40 | static unsigned int alsa_debug = 0; | 39 | static unsigned int debug = 0; |
41 | module_param(alsa_debug, int, 0644); | 40 | module_param(debug, int, 0644); |
42 | MODULE_PARM_DESC(alsa_debug,"enable debug messages [alsa]"); | 41 | MODULE_PARM_DESC(debug,"enable debug messages [alsa]"); |
42 | |||
43 | unsigned int dsp_nr = 0; | ||
44 | module_param(dsp_nr, int, 0444); | ||
45 | MODULE_PARM_DESC(dsp_nr, "alsa device number"); | ||
43 | 46 | ||
44 | /* | 47 | /* |
45 | * Configuration macros | 48 | * Configuration macros |
@@ -69,7 +72,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | |||
69 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 72 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
70 | static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; | 73 | static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; |
71 | 74 | ||
72 | #define dprintk(fmt, arg...) if (alsa_debug) \ | 75 | #define dprintk(fmt, arg...) if (debug) \ |
73 | printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) | 76 | printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) |
74 | 77 | ||
75 | /* | 78 | /* |
@@ -107,6 +110,7 @@ typedef struct snd_card_saa7134_pcm { | |||
107 | 110 | ||
108 | static snd_card_t *snd_saa7134_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; | 111 | static snd_card_t *snd_saa7134_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; |
109 | 112 | ||
113 | |||
110 | /* | 114 | /* |
111 | * saa7134 DMA audio stop | 115 | * saa7134 DMA audio stop |
112 | * | 116 | * |
@@ -189,12 +193,11 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) | |||
189 | /* next block addr */ | 193 | /* next block addr */ |
190 | next_blk = (dev->oss.dma_blk + 2) % dev->oss.blocks; | 194 | next_blk = (dev->oss.dma_blk + 2) % dev->oss.blocks; |
191 | saa_writel(reg,next_blk * dev->oss.blksize); | 195 | saa_writel(reg,next_blk * dev->oss.blksize); |
192 | if (alsa_debug > 2) | 196 | if (debug > 2) |
193 | dprintk("irq: ok, %s, next_blk=%d, addr=%x, blocks=%u, size=%u, read=%u\n", | 197 | dprintk("irq: ok, %s, next_blk=%d, addr=%x, blocks=%u, size=%u, read=%u\n", |
194 | (status & 0x10000000) ? "even" : "odd ", next_blk, | 198 | (status & 0x10000000) ? "even" : "odd ", next_blk, |
195 | next_blk * dev->oss.blksize, dev->oss.blocks, dev->oss.blksize, dev->oss.read_count); | 199 | next_blk * dev->oss.blksize, dev->oss.blocks, dev->oss.blksize, dev->oss.read_count); |
196 | 200 | ||
197 | |||
198 | /* update status & wake waiting readers */ | 201 | /* update status & wake waiting readers */ |
199 | dev->oss.dma_blk = (dev->oss.dma_blk + 1) % dev->oss.blocks; | 202 | dev->oss.dma_blk = (dev->oss.dma_blk + 1) % dev->oss.blocks; |
200 | dev->oss.read_count += dev->oss.blksize; | 203 | dev->oss.read_count += dev->oss.blksize; |
@@ -212,6 +215,41 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) | |||
212 | } | 215 | } |
213 | 216 | ||
214 | /* | 217 | /* |
218 | * IRQ request handler | ||
219 | * | ||
220 | * Runs along with saa7134's IRQ handler, discards anything that isn't | ||
221 | * DMA sound | ||
222 | * | ||
223 | */ | ||
224 | |||
225 | static irqreturn_t saa7134_alsa_irq(int irq, void *dev_id, struct pt_regs *regs) | ||
226 | { | ||
227 | struct saa7134_dev *dev = (struct saa7134_dev*) dev_id; | ||
228 | unsigned long report, status; | ||
229 | int loop, handled = 0; | ||
230 | |||
231 | for (loop = 0; loop < 10; loop++) { | ||
232 | report = saa_readl(SAA7134_IRQ_REPORT); | ||
233 | status = saa_readl(SAA7134_IRQ_STATUS); | ||
234 | |||
235 | if (report & SAA7134_IRQ_REPORT_DONE_RA3) { | ||
236 | handled = 1; | ||
237 | saa_writel(SAA7134_IRQ_REPORT,report); | ||
238 | saa7134_irq_alsa_done(dev, status); | ||
239 | } else { | ||
240 | goto out; | ||
241 | } | ||
242 | } | ||
243 | |||
244 | if (loop == 10) { | ||
245 | dprintk("error! looping IRQ!"); | ||
246 | } | ||
247 | |||
248 | out: | ||
249 | return IRQ_RETVAL(handled); | ||
250 | } | ||
251 | |||
252 | /* | ||
215 | * ALSA capture trigger | 253 | * ALSA capture trigger |
216 | * | 254 | * |
217 | * - One of the ALSA capture callbacks. | 255 | * - One of the ALSA capture callbacks. |
@@ -822,11 +860,9 @@ static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
822 | saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL1, 0xbbbb10); | 860 | saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL1, 0xbbbb10); |
823 | 861 | ||
824 | if (left || right) { // We've got data, turn the input on | 862 | if (left || right) { // We've got data, turn the input on |
825 | //saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL2, 0x101010); | ||
826 | saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, xbarin); | 863 | saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, xbarin); |
827 | saa_writel(SAA7133_ANALOG_IO_SELECT, anabar); | 864 | saa_writel(SAA7133_ANALOG_IO_SELECT, anabar); |
828 | } else { | 865 | } else { |
829 | //saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL2, 0x101010); | ||
830 | saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, 0); | 866 | saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, 0); |
831 | saa_writel(SAA7133_ANALOG_IO_SELECT, 0); | 867 | saa_writel(SAA7133_ANALOG_IO_SELECT, 0); |
832 | } | 868 | } |
@@ -889,9 +925,10 @@ static int snd_saa7134_dev_free(snd_device_t *device) | |||
889 | * | 925 | * |
890 | */ | 926 | */ |
891 | 927 | ||
892 | int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum) | 928 | int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum) |
893 | { | 929 | { |
894 | static int dev; | 930 | static int dev; |
931 | |||
895 | snd_card_t *card; | 932 | snd_card_t *card; |
896 | snd_card_saa7134_t *chip; | 933 | snd_card_saa7134_t *chip; |
897 | int err; | 934 | int err; |
@@ -899,6 +936,7 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum) | |||
899 | .dev_free = snd_saa7134_dev_free, | 936 | .dev_free = snd_saa7134_dev_free, |
900 | }; | 937 | }; |
901 | 938 | ||
939 | |||
902 | if (dev >= SNDRV_CARDS) | 940 | if (dev >= SNDRV_CARDS) |
903 | return -ENODEV; | 941 | return -ENODEV; |
904 | if (!enable[dev]) | 942 | if (!enable[dev]) |
@@ -906,6 +944,7 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum) | |||
906 | 944 | ||
907 | if (devicenum) { | 945 | if (devicenum) { |
908 | card = snd_card_new(devicenum, id[dev], THIS_MODULE, 0); | 946 | card = snd_card_new(devicenum, id[dev], THIS_MODULE, 0); |
947 | dsp_nr++; | ||
909 | } else { | 948 | } else { |
910 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); | 949 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); |
911 | } | 950 | } |
@@ -931,6 +970,15 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum) | |||
931 | chip->irq = saadev->pci->irq; | 970 | chip->irq = saadev->pci->irq; |
932 | chip->iobase = pci_resource_start(saadev->pci, 0); | 971 | chip->iobase = pci_resource_start(saadev->pci, 0); |
933 | 972 | ||
973 | err = request_irq(chip->pci->irq, saa7134_alsa_irq, | ||
974 | SA_SHIRQ | SA_INTERRUPT, saadev->name, saadev); | ||
975 | |||
976 | if (err < 0) { | ||
977 | printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n", | ||
978 | saadev->name, saadev->pci->irq); | ||
979 | return err; | ||
980 | } | ||
981 | |||
934 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 982 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { |
935 | snd_saa7134_free(chip); | 983 | snd_saa7134_free(chip); |
936 | return err; | 984 | return err; |
@@ -963,10 +1011,48 @@ __nodev: | |||
963 | return err; | 1011 | return err; |
964 | } | 1012 | } |
965 | 1013 | ||
966 | void alsa_card_saa7134_exit(void) | 1014 | /* |
1015 | * Module initializer | ||
1016 | * | ||
1017 | * Loops through present saa7134 cards, and assigns an ALSA device | ||
1018 | * to each one | ||
1019 | * | ||
1020 | */ | ||
1021 | |||
1022 | static int saa7134_alsa_init(void) | ||
1023 | { | ||
1024 | struct saa7134_dev *saadev = NULL; | ||
1025 | struct list_head *list; | ||
1026 | |||
1027 | printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n"); | ||
1028 | |||
1029 | list_for_each(list,&saa7134_devlist) { | ||
1030 | saadev = list_entry(list, struct saa7134_dev, devlist); | ||
1031 | alsa_card_saa7134_create(saadev,dsp_nr); | ||
1032 | } | ||
1033 | |||
1034 | if (saadev == NULL) | ||
1035 | printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n"); | ||
1036 | |||
1037 | return 0; | ||
1038 | |||
1039 | } | ||
1040 | |||
1041 | /* | ||
1042 | * Module destructor | ||
1043 | */ | ||
1044 | |||
1045 | void saa7134_alsa_exit(void) | ||
967 | { | 1046 | { |
968 | int idx; | 1047 | int idx; |
969 | for (idx = 0; idx < SNDRV_CARDS; idx++) { | 1048 | for (idx = 0; idx < SNDRV_CARDS; idx++) { |
970 | snd_card_free(snd_saa7134_cards[idx]); | 1049 | snd_card_free(snd_saa7134_cards[idx]); |
971 | } | 1050 | } |
1051 | printk(KERN_INFO "saa7134 ALSA driver for DMA sound unloaded\n"); | ||
1052 | return; | ||
972 | } | 1053 | } |
1054 | |||
1055 | module_init(saa7134_alsa_init); | ||
1056 | module_exit(saa7134_alsa_exit); | ||
1057 | MODULE_LICENSE("GPL"); | ||
1058 | MODULE_AUTHOR("Ricardo Cerqueira"); | ||
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 454b8a86c830..6c329c440572 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -574,6 +574,17 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs) | |||
574 | dev->name); | 574 | dev->name); |
575 | goto out; | 575 | goto out; |
576 | } | 576 | } |
577 | |||
578 | /* If alsa support is active and we get a sound report, exit | ||
579 | and let the saa7134-alsa module deal with it */ | ||
580 | |||
581 | if ((report & SAA7134_IRQ_REPORT_DONE_RA3) && alsa) { | ||
582 | if (irq_debug > 1) | ||
583 | printk(KERN_DEBUG "%s/irq: ignoring interrupt for ALSA\n", | ||
584 | dev->name); | ||
585 | goto out; | ||
586 | } | ||
587 | |||
577 | handled = 1; | 588 | handled = 1; |
578 | saa_writel(SAA7134_IRQ_REPORT,report); | 589 | saa_writel(SAA7134_IRQ_REPORT,report); |
579 | if (irq_debug) | 590 | if (irq_debug) |
@@ -598,8 +609,6 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs) | |||
598 | if ((report & SAA7134_IRQ_REPORT_DONE_RA3)) { | 609 | if ((report & SAA7134_IRQ_REPORT_DONE_RA3)) { |
599 | if (oss) { | 610 | if (oss) { |
600 | saa7134_irq_oss_done(dev,status); | 611 | saa7134_irq_oss_done(dev,status); |
601 | } else if (alsa) { | ||
602 | saa7134_irq_alsa_done(dev,status); | ||
603 | } | 612 | } |
604 | } | 613 | } |
605 | 614 | ||
@@ -1029,9 +1038,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1029 | printk(KERN_INFO "%s: registered device mixer%d\n", | 1038 | printk(KERN_INFO "%s: registered device mixer%d\n", |
1030 | dev->name,dev->oss.minor_mixer >> 4); | 1039 | dev->name,dev->oss.minor_mixer >> 4); |
1031 | } else if (alsa) { | 1040 | } else if (alsa) { |
1032 | alsa_card_saa7134_create(dev,dsp_nr[dev->nr]); | 1041 | request_module("saa7134-alsa"); |
1033 | printk(KERN_INFO "%s: registered ALSA devices\n", | ||
1034 | dev->name); | ||
1035 | } | 1042 | } |
1036 | break; | 1043 | break; |
1037 | } | 1044 | } |
@@ -1059,8 +1066,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1059 | case PCI_DEVICE_ID_PHILIPS_SAA7135: | 1066 | case PCI_DEVICE_ID_PHILIPS_SAA7135: |
1060 | if (oss) | 1067 | if (oss) |
1061 | unregister_sound_dsp(dev->oss.minor_dsp); | 1068 | unregister_sound_dsp(dev->oss.minor_dsp); |
1062 | else if (alsa) | ||
1063 | alsa_card_saa7134_exit(); | ||
1064 | break; | 1069 | break; |
1065 | } | 1070 | } |
1066 | fail4: | 1071 | fail4: |
@@ -1120,8 +1125,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) | |||
1120 | if (oss) { | 1125 | if (oss) { |
1121 | unregister_sound_mixer(dev->oss.minor_mixer); | 1126 | unregister_sound_mixer(dev->oss.minor_mixer); |
1122 | unregister_sound_dsp(dev->oss.minor_dsp); | 1127 | unregister_sound_dsp(dev->oss.minor_dsp); |
1123 | } else if (alsa) | 1128 | } |
1124 | alsa_card_saa7134_exit(); | ||
1125 | break; | 1129 | break; |
1126 | } | 1130 | } |
1127 | saa7134_unregister_video(dev); | 1131 | saa7134_unregister_video(dev); |
@@ -1214,6 +1218,13 @@ EXPORT_SYMBOL(saa7134_i2c_call_clients); | |||
1214 | EXPORT_SYMBOL(saa7134_devlist); | 1218 | EXPORT_SYMBOL(saa7134_devlist); |
1215 | EXPORT_SYMBOL(saa7134_boards); | 1219 | EXPORT_SYMBOL(saa7134_boards); |
1216 | 1220 | ||
1221 | /* ----------------- For ALSA -------------------------------- */ | ||
1222 | |||
1223 | EXPORT_SYMBOL(saa7134_pgtable_free); | ||
1224 | EXPORT_SYMBOL(saa7134_pgtable_build); | ||
1225 | EXPORT_SYMBOL(saa7134_pgtable_alloc); | ||
1226 | EXPORT_SYMBOL(saa7134_set_dmabits); | ||
1227 | |||
1217 | /* ----------------------------------------------------------- */ | 1228 | /* ----------------------------------------------------------- */ |
1218 | /* | 1229 | /* |
1219 | * Local variables: | 1230 | * Local variables: |
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index 3daf1b597958..93268427750d 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c | |||
@@ -1024,9 +1024,12 @@ int saa7134_tvaudio_do_scan(struct saa7134_dev *dev) | |||
1024 | return 0; | 1024 | return 0; |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | EXPORT_SYMBOL(saa_dsp_writel); | ||
1028 | |||
1027 | /* ----------------------------------------------------------- */ | 1029 | /* ----------------------------------------------------------- */ |
1028 | /* | 1030 | /* |
1029 | * Local variables: | 1031 | * Local variables: |
1030 | * c-basic-offset: 8 | 1032 | * c-basic-offset: 8 |
1031 | * End: | 1033 | * End: |
1032 | */ | 1034 | */ |
1035 | |||
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index d993344d37e4..1fdc9e147f87 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -665,14 +665,6 @@ void saa7134_input_fini(struct saa7134_dev *dev); | |||
665 | void saa7134_input_irq(struct saa7134_dev *dev); | 665 | void saa7134_input_irq(struct saa7134_dev *dev); |
666 | void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir); | 666 | void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir); |
667 | 667 | ||
668 | /* ----------------------------------------------------------- */ | ||
669 | /* saa7134-alsa.c */ | ||
670 | |||
671 | int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devnum); | ||
672 | void alsa_card_saa7134_exit(void); | ||
673 | void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status); | ||
674 | |||
675 | |||
676 | /* | 668 | /* |
677 | * Local variables: | 669 | * Local variables: |
678 | * c-basic-offset: 8 | 670 | * c-basic-offset: 8 |