.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * linux/sound/arm/aaci.c - ARM PrimeCell AACI PL041 driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2 as |
---|
8 | | - * published by the Free Software Foundation. |
---|
9 | 6 | * |
---|
10 | 7 | * Documentation: ARM DDI 0173B |
---|
11 | 8 | */ |
---|
.. | .. |
---|
383 | 380 | static int aaci_rule_channels(struct snd_pcm_hw_params *p, |
---|
384 | 381 | struct snd_pcm_hw_rule *rule) |
---|
385 | 382 | { |
---|
386 | | - static unsigned int channel_list[] = { 2, 4, 6 }; |
---|
| 383 | + static const unsigned int channel_list[] = { 2, 4, 6 }; |
---|
387 | 384 | struct aaci *aaci = rule->private; |
---|
388 | 385 | unsigned int mask = 1 << 0, slots; |
---|
389 | 386 | |
---|
.. | .. |
---|
486 | 483 | snd_ac97_pcm_close(aacirun->pcm); |
---|
487 | 484 | aacirun->pcm_open = 0; |
---|
488 | 485 | |
---|
489 | | - /* |
---|
490 | | - * Clear out the DMA and any allocated buffers. |
---|
491 | | - */ |
---|
492 | | - snd_pcm_lib_free_pages(substream); |
---|
493 | | - |
---|
494 | 486 | return 0; |
---|
495 | 487 | } |
---|
496 | 488 | |
---|
.. | .. |
---|
505 | 497 | struct snd_pcm_hw_params *params) |
---|
506 | 498 | { |
---|
507 | 499 | struct aaci_runtime *aacirun = substream->runtime->private_data; |
---|
| 500 | + struct aaci *aaci = substream->private_data; |
---|
508 | 501 | unsigned int channels = params_channels(params); |
---|
509 | 502 | unsigned int rate = params_rate(params); |
---|
510 | 503 | int dbl = rate > 48000; |
---|
.. | .. |
---|
520 | 513 | if (dbl && channels != 2) |
---|
521 | 514 | return -EINVAL; |
---|
522 | 515 | |
---|
523 | | - err = snd_pcm_lib_malloc_pages(substream, |
---|
524 | | - params_buffer_bytes(params)); |
---|
525 | | - if (err >= 0) { |
---|
526 | | - struct aaci *aaci = substream->private_data; |
---|
| 516 | + err = snd_ac97_pcm_open(aacirun->pcm, rate, channels, |
---|
| 517 | + aacirun->pcm->r[dbl].slots); |
---|
527 | 518 | |
---|
528 | | - err = snd_ac97_pcm_open(aacirun->pcm, rate, channels, |
---|
529 | | - aacirun->pcm->r[dbl].slots); |
---|
| 519 | + aacirun->pcm_open = err == 0; |
---|
| 520 | + aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; |
---|
| 521 | + aacirun->cr |= channels_to_slotmask[channels + dbl * 2]; |
---|
530 | 522 | |
---|
531 | | - aacirun->pcm_open = err == 0; |
---|
532 | | - aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; |
---|
533 | | - aacirun->cr |= channels_to_slotmask[channels + dbl * 2]; |
---|
534 | | - |
---|
535 | | - /* |
---|
536 | | - * fifo_bytes is the number of bytes we transfer to/from |
---|
537 | | - * the FIFO, including padding. So that's x4. As we're |
---|
538 | | - * in compact mode, the FIFO is half the size. |
---|
539 | | - */ |
---|
540 | | - aacirun->fifo_bytes = aaci->fifo_depth * 4 / 2; |
---|
541 | | - } |
---|
| 523 | + /* |
---|
| 524 | + * fifo_bytes is the number of bytes we transfer to/from |
---|
| 525 | + * the FIFO, including padding. So that's x4. As we're |
---|
| 526 | + * in compact mode, the FIFO is half the size. |
---|
| 527 | + */ |
---|
| 528 | + aacirun->fifo_bytes = aaci->fifo_depth * 4 / 2; |
---|
542 | 529 | |
---|
543 | 530 | return err; |
---|
544 | 531 | } |
---|
.. | .. |
---|
638 | 625 | static const struct snd_pcm_ops aaci_playback_ops = { |
---|
639 | 626 | .open = aaci_pcm_open, |
---|
640 | 627 | .close = aaci_pcm_close, |
---|
641 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
642 | 628 | .hw_params = aaci_pcm_hw_params, |
---|
643 | 629 | .hw_free = aaci_pcm_hw_free, |
---|
644 | 630 | .prepare = aaci_pcm_prepare, |
---|
.. | .. |
---|
741 | 727 | static const struct snd_pcm_ops aaci_capture_ops = { |
---|
742 | 728 | .open = aaci_pcm_open, |
---|
743 | 729 | .close = aaci_pcm_close, |
---|
744 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
745 | 730 | .hw_params = aaci_pcm_hw_params, |
---|
746 | 731 | .hw_free = aaci_pcm_hw_free, |
---|
747 | 732 | .prepare = aaci_pcm_capture_prepare, |
---|
.. | .. |
---|
757 | 742 | { |
---|
758 | 743 | struct aaci *aaci = card->private_data; |
---|
759 | 744 | snd_power_change_state(card, SNDRV_CTL_POWER_D3cold); |
---|
760 | | - snd_pcm_suspend_all(aaci->pcm); |
---|
761 | 745 | return 0; |
---|
762 | 746 | } |
---|
763 | 747 | |
---|
.. | .. |
---|
827 | 811 | } |
---|
828 | 812 | }; |
---|
829 | 813 | |
---|
830 | | -static struct snd_ac97_bus_ops aaci_bus_ops = { |
---|
| 814 | +static const struct snd_ac97_bus_ops aaci_bus_ops = { |
---|
831 | 815 | .write = aaci_ac97_write, |
---|
832 | 816 | .read = aaci_ac97_read, |
---|
833 | 817 | }; |
---|
.. | .. |
---|
941 | 925 | |
---|
942 | 926 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops); |
---|
943 | 927 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops); |
---|
944 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
945 | | - NULL, 0, 64 * 1024); |
---|
| 928 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
| 929 | + aaci->card->dev, |
---|
| 930 | + 0, 64 * 1024); |
---|
946 | 931 | } |
---|
947 | 932 | |
---|
948 | 933 | return ret; |
---|
.. | .. |
---|
1070 | 1055 | return ret; |
---|
1071 | 1056 | } |
---|
1072 | 1057 | |
---|
1073 | | -static int aaci_remove(struct amba_device *dev) |
---|
| 1058 | +static void aaci_remove(struct amba_device *dev) |
---|
1074 | 1059 | { |
---|
1075 | 1060 | struct snd_card *card = amba_get_drvdata(dev); |
---|
1076 | 1061 | |
---|
.. | .. |
---|
1081 | 1066 | snd_card_free(card); |
---|
1082 | 1067 | amba_release_regions(dev); |
---|
1083 | 1068 | } |
---|
1084 | | - |
---|
1085 | | - return 0; |
---|
1086 | 1069 | } |
---|
1087 | 1070 | |
---|
1088 | 1071 | static struct amba_id aaci_ids[] = { |
---|