diff options
author | Ricardo Cerqueira <v4l@cerqueira.org> | 2005-11-13 19:07:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-13 21:14:18 -0500 |
commit | c817e7634260b298fc03b856ddb53d9aa77326b5 (patch) | |
tree | 6e0259424ddf11f10e18a3e7b939d66ccf955f36 /drivers/media/video/saa7134 | |
parent | 770599d07564f049234d0a5eb0ef3d607d747878 (diff) |
[PATCH] v4l: (930) Alsa fixes and improvements
- Fix nasty IRQ hook bug.
- Fix multiple board support in saa7134-alsa
- Minor comment updates
- SAA7134/ALSA IRQ management improvements
- Removed superfluous stop_dma() from saa7134-alsa IRQ handler
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>
Diffstat (limited to 'drivers/media/video/saa7134')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-alsa.c | 90 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-core.c | 1 |
2 files changed, 46 insertions, 45 deletions
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index 4f3c42354329..289d04064b70 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c | |||
@@ -56,6 +56,8 @@ static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; | |||
56 | module_param_array(index, int, NULL, 0444); | 56 | module_param_array(index, int, NULL, 0444); |
57 | MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s)."); | 57 | MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s)."); |
58 | 58 | ||
59 | int position; | ||
60 | |||
59 | #define dprintk(fmt, arg...) if (debug) \ | 61 | #define dprintk(fmt, arg...) if (debug) \ |
60 | printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) | 62 | printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) |
61 | 63 | ||
@@ -100,13 +102,11 @@ static snd_card_t *snd_saa7134_cards[SNDRV_CARDS]; | |||
100 | * | 102 | * |
101 | * Called when the capture device is released or the buffer overflows | 103 | * Called when the capture device is released or the buffer overflows |
102 | * | 104 | * |
103 | * - Copied verbatim from saa7134-oss's dsp_dma_stop. Can be dropped | 105 | * - Copied verbatim from saa7134-oss's dsp_dma_stop. |
104 | * if we just share dsp_dma_stop and use it here | ||
105 | * | 106 | * |
106 | */ | 107 | */ |
107 | 108 | ||
108 | static void saa7134_dma_stop(struct saa7134_dev *dev) | 109 | static void saa7134_dma_stop(struct saa7134_dev *dev) |
109 | |||
110 | { | 110 | { |
111 | dev->dmasound.dma_blk = -1; | 111 | dev->dmasound.dma_blk = -1; |
112 | dev->dmasound.dma_running = 0; | 112 | dev->dmasound.dma_running = 0; |
@@ -118,8 +118,7 @@ static void saa7134_dma_stop(struct saa7134_dev *dev) | |||
118 | * | 118 | * |
119 | * Called when preparing the capture device for use | 119 | * Called when preparing the capture device for use |
120 | * | 120 | * |
121 | * - Copied verbatim from saa7134-oss's dsp_dma_start. Can be dropped | 121 | * - Copied verbatim from saa7134-oss's dsp_dma_start. |
122 | * if we just share dsp_dma_start and use it here | ||
123 | * | 122 | * |
124 | */ | 123 | */ |
125 | 124 | ||
@@ -171,7 +170,6 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) | |||
171 | dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count, | 170 | dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count, |
172 | dev->dmasound.bufsize, dev->dmasound.blocks); | 171 | dev->dmasound.bufsize, dev->dmasound.blocks); |
173 | snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN); | 172 | snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN); |
174 | saa7134_dma_stop(dev); | ||
175 | goto done; | 173 | goto done; |
176 | } | 174 | } |
177 | 175 | ||
@@ -209,7 +207,8 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) | |||
209 | 207 | ||
210 | static irqreturn_t saa7134_alsa_irq(int irq, void *dev_id, struct pt_regs *regs) | 208 | static irqreturn_t saa7134_alsa_irq(int irq, void *dev_id, struct pt_regs *regs) |
211 | { | 209 | { |
212 | struct saa7134_dev *dev = (struct saa7134_dev*) dev_id; | 210 | snd_card_saa7134_t *saa7134 = dev_id; |
211 | struct saa7134_dev *dev = saa7134->saadev; | ||
213 | unsigned long report, status; | 212 | unsigned long report, status; |
214 | int loop, handled = 0; | 213 | int loop, handled = 0; |
215 | 214 | ||
@@ -253,18 +252,18 @@ static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream, | |||
253 | int err = 0; | 252 | int err = 0; |
254 | 253 | ||
255 | spin_lock_irq(&dev->slock); | 254 | spin_lock_irq(&dev->slock); |
256 | if (cmd == SNDRV_PCM_TRIGGER_START) { | 255 | if (cmd == SNDRV_PCM_TRIGGER_START) { |
257 | /* start dma */ | 256 | /* start dma */ |
258 | saa7134_dma_start(dev); | 257 | saa7134_dma_start(dev); |
259 | } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { | 258 | } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { |
260 | /* stop dma */ | 259 | /* stop dma */ |
261 | saa7134_dma_stop(dev); | 260 | saa7134_dma_stop(dev); |
262 | } else { | 261 | } else { |
263 | err = -EINVAL; | 262 | err = -EINVAL; |
264 | } | 263 | } |
265 | spin_unlock_irq(&dev->slock); | 264 | spin_unlock_irq(&dev->slock); |
266 | 265 | ||
267 | return err; | 266 | return err; |
268 | } | 267 | } |
269 | 268 | ||
270 | /* | 269 | /* |
@@ -275,8 +274,8 @@ static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream, | |||
275 | * Must be called during the preparation stage, before memory is | 274 | * Must be called during the preparation stage, before memory is |
276 | * allocated | 275 | * allocated |
277 | * | 276 | * |
278 | * - Copied verbatim from saa7134-oss. Can be dropped | 277 | * - Copied verbatim from saa7134-oss. |
279 | * if we just share dsp_buffer_conf from OSS. | 278 | * |
280 | */ | 279 | */ |
281 | 280 | ||
282 | static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) | 281 | static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) |
@@ -307,8 +306,8 @@ static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) | |||
307 | * ALSA, but I was unable to use ALSA's own DMA, and had to force the | 306 | * ALSA, but I was unable to use ALSA's own DMA, and had to force the |
308 | * usage of V4L's | 307 | * usage of V4L's |
309 | * | 308 | * |
310 | * - Copied verbatim from saa7134-oss. Can be dropped | 309 | * - Copied verbatim from saa7134-oss. |
311 | * if we just share dsp_buffer_init from OSS. | 310 | * |
312 | */ | 311 | */ |
313 | 312 | ||
314 | static int dsp_buffer_init(struct saa7134_dev *dev) | 313 | static int dsp_buffer_init(struct saa7134_dev *dev) |
@@ -369,7 +368,7 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) | |||
369 | 368 | ||
370 | err = dsp_buffer_init(dev); | 369 | err = dsp_buffer_init(dev); |
371 | if (0 != err) | 370 | if (0 != err) |
372 | goto fail2; | 371 | return err; |
373 | 372 | ||
374 | /* prepare buffer */ | 373 | /* prepare buffer */ |
375 | if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->dmasound.dma))) | 374 | if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->dmasound.dma))) |
@@ -560,10 +559,8 @@ static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime) | |||
560 | static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream, | 559 | static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream, |
561 | snd_pcm_hw_params_t * hw_params) | 560 | snd_pcm_hw_params_t * hw_params) |
562 | { | 561 | { |
563 | |||
564 | return 0; | 562 | return 0; |
565 | 563 | ||
566 | |||
567 | } | 564 | } |
568 | 565 | ||
569 | /* | 566 | /* |
@@ -790,7 +787,6 @@ static int snd_saa7134_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
790 | static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 787 | static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) |
791 | { | 788 | { |
792 | snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); | 789 | snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); |
793 | unsigned long flags; | ||
794 | int change, addr = kcontrol->private_value; | 790 | int change, addr = kcontrol->private_value; |
795 | int left, right; | 791 | int left, right; |
796 | u32 anabar, xbarin; | 792 | u32 anabar, xbarin; |
@@ -801,14 +797,14 @@ static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
801 | 797 | ||
802 | left = ucontrol->value.integer.value[0] & 1; | 798 | left = ucontrol->value.integer.value[0] & 1; |
803 | right = ucontrol->value.integer.value[1] & 1; | 799 | right = ucontrol->value.integer.value[1] & 1; |
804 | spin_lock_irqsave(&chip->mixer_lock, flags); | 800 | spin_lock_irq(&chip->mixer_lock); |
805 | 801 | ||
806 | change = chip->capture_source[addr][0] != left || | 802 | change = chip->capture_source[addr][0] != left || |
807 | chip->capture_source[addr][1] != right; | 803 | chip->capture_source[addr][1] != right; |
808 | chip->capture_source[addr][0] = left; | 804 | chip->capture_source[addr][0] = left; |
809 | chip->capture_source[addr][1] = right; | 805 | chip->capture_source[addr][1] = right; |
810 | dev->dmasound.input=addr; | 806 | dev->dmasound.input=addr; |
811 | spin_unlock_irqrestore(&chip->mixer_lock, flags); | 807 | spin_unlock_irq(&chip->mixer_lock); |
812 | 808 | ||
813 | 809 | ||
814 | if (change) { | 810 | if (change) { |
@@ -898,28 +894,33 @@ static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip) | |||
898 | return 0; | 894 | return 0; |
899 | } | 895 | } |
900 | 896 | ||
901 | static int snd_saa7134_free(snd_card_saa7134_t *chip) | 897 | static void snd_saa7134_free(snd_card_t * card) |
902 | { | 898 | { |
903 | return 0; | 899 | return; |
904 | } | 900 | } |
905 | 901 | ||
906 | static int snd_saa7134_dev_free(snd_device_t *device) | 902 | static int snd_saa7134_dev_free(snd_device_t *device) |
907 | { | 903 | { |
908 | snd_card_saa7134_t *chip = device->device_data; | 904 | snd_card_saa7134_t *chip = device->device_data; |
909 | return snd_saa7134_free(chip); | 905 | |
906 | if (chip->irq >= 0) { | ||
907 | synchronize_irq(chip->irq); | ||
908 | free_irq(chip->irq, (void *) chip); | ||
909 | } | ||
910 | |||
911 | return 0; | ||
910 | } | 912 | } |
911 | 913 | ||
912 | /* | 914 | /* |
913 | * ALSA initialization | 915 | * ALSA initialization |
914 | * | 916 | * |
915 | * Called by saa7134-core, it creates the basic structures and registers | 917 | * Called by the init routine, once for each saa7134 device present, |
916 | * the ALSA devices | 918 | * it creates the basic structures and registers the ALSA devices |
917 | * | 919 | * |
918 | */ | 920 | */ |
919 | 921 | ||
920 | int alsa_card_saa7134_create (struct saa7134_dev *saadev) | 922 | int alsa_card_saa7134_create(struct saa7134_dev *saadev, int dev) |
921 | { | 923 | { |
922 | static int dev; | ||
923 | 924 | ||
924 | snd_card_t *card; | 925 | snd_card_t *card; |
925 | snd_card_saa7134_t *chip; | 926 | snd_card_saa7134_t *chip; |
@@ -934,7 +935,7 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev) | |||
934 | if (!enable[dev]) | 935 | if (!enable[dev]) |
935 | return -ENODEV; | 936 | return -ENODEV; |
936 | 937 | ||
937 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); | 938 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(snd_card_saa7134_t)); |
938 | 939 | ||
939 | if (card == NULL) | 940 | if (card == NULL) |
940 | return -ENOMEM; | 941 | return -ENOMEM; |
@@ -943,10 +944,8 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev) | |||
943 | 944 | ||
944 | /* Card "creation" */ | 945 | /* Card "creation" */ |
945 | 946 | ||
946 | chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); | 947 | card->private_free = snd_saa7134_free; |
947 | if (chip == NULL) { | 948 | chip = (snd_card_saa7134_t *) card->private_data; |
948 | return -ENOMEM; | ||
949 | } | ||
950 | 949 | ||
951 | spin_lock_init(&chip->lock); | 950 | spin_lock_init(&chip->lock); |
952 | spin_lock_init(&chip->mixer_lock); | 951 | spin_lock_init(&chip->mixer_lock); |
@@ -960,7 +959,7 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev) | |||
960 | chip->iobase = pci_resource_start(saadev->pci, 0); | 959 | chip->iobase = pci_resource_start(saadev->pci, 0); |
961 | 960 | ||
962 | err = request_irq(saadev->pci->irq, saa7134_alsa_irq, | 961 | err = request_irq(saadev->pci->irq, saa7134_alsa_irq, |
963 | SA_SHIRQ | SA_INTERRUPT, saadev->name, saadev); | 962 | SA_SHIRQ | SA_INTERRUPT, saadev->name, (void *)chip); |
964 | 963 | ||
965 | if (err < 0) { | 964 | if (err < 0) { |
966 | printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n", | 965 | printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n", |
@@ -993,7 +992,6 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev) | |||
993 | 992 | ||
994 | __nodev: | 993 | __nodev: |
995 | snd_card_free(card); | 994 | snd_card_free(card); |
996 | kfree(chip); | ||
997 | return err; | 995 | return err; |
998 | } | 996 | } |
999 | 997 | ||
@@ -1007,21 +1005,23 @@ __nodev: | |||
1007 | 1005 | ||
1008 | static int saa7134_alsa_init(void) | 1006 | static int saa7134_alsa_init(void) |
1009 | { | 1007 | { |
1010 | struct saa7134_dev *saadev = NULL; | 1008 | struct saa7134_dev *saadev = NULL; |
1011 | struct list_head *list; | 1009 | struct list_head *list; |
1012 | 1010 | ||
1013 | printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n"); | 1011 | position = 0; |
1014 | 1012 | ||
1015 | list_for_each(list,&saa7134_devlist) { | 1013 | printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n"); |
1016 | saadev = list_entry(list, struct saa7134_dev, devlist); | 1014 | |
1017 | alsa_card_saa7134_create(saadev); | 1015 | list_for_each(list,&saa7134_devlist) { |
1018 | } | 1016 | saadev = list_entry(list, struct saa7134_dev, devlist); |
1017 | alsa_card_saa7134_create(saadev,position); | ||
1018 | position++; | ||
1019 | } | ||
1019 | 1020 | ||
1020 | if (saadev == NULL) | 1021 | if (saadev == NULL) |
1021 | printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n"); | 1022 | printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n"); |
1022 | 1023 | ||
1023 | return 0; | 1024 | return 0; |
1024 | |||
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | /* | 1027 | /* |
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 19b88744fb31..3d89a33289ed 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -1064,6 +1064,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1064 | 1064 | ||
1065 | /* check for signal */ | 1065 | /* check for signal */ |
1066 | saa7134_irq_video_intl(dev); | 1066 | saa7134_irq_video_intl(dev); |
1067 | |||
1067 | return 0; | 1068 | return 0; |
1068 | 1069 | ||
1069 | fail5: | 1070 | fail5: |