diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2008-01-16 02:30:38 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:30:00 -0500 |
commit | e85e09250ab552fab6925bcde7c77746101b2d40 (patch) | |
tree | 4ca130f7c846aaa8069d7d71a91ceabf2f5af22b /sound/pci/oxygen/oxygen_pcm.c | |
parent | 84aa6b7ba746e6f637444d0e14a9b75c0b49a612 (diff) |
[ALSA] oxygen: make all DMA channels configurable
Allow the card models to specify whether each of the hardware DMA
channels is used.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/oxygen/oxygen_pcm.c')
-rw-r--r-- | sound/pci/oxygen/oxygen_pcm.c | 72 |
1 files changed, 49 insertions, 23 deletions
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index 0f67defc2b2d..5f15d355a431 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c | |||
@@ -681,15 +681,22 @@ static void oxygen_pcm_free(struct snd_pcm *pcm) | |||
681 | int __devinit oxygen_pcm_init(struct oxygen *chip) | 681 | int __devinit oxygen_pcm_init(struct oxygen *chip) |
682 | { | 682 | { |
683 | struct snd_pcm *pcm; | 683 | struct snd_pcm *pcm; |
684 | int outs, ins; | ||
684 | int err; | 685 | int err; |
685 | 686 | ||
686 | err = snd_pcm_new(chip->card, "Analog", 0, 1, 1, &pcm); | 687 | outs = 1; /* OXYGEN_CHANNEL_MULTICH is always used */ |
688 | ins = !!(chip->model->used_channels & (OXYGEN_CHANNEL_A | | ||
689 | OXYGEN_CHANNEL_B)); | ||
690 | err = snd_pcm_new(chip->card, "Analog", 0, outs, ins, &pcm); | ||
687 | if (err < 0) | 691 | if (err < 0) |
688 | return err; | 692 | return err; |
689 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &oxygen_multich_ops); | 693 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &oxygen_multich_ops); |
690 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | 694 | if (chip->model->used_channels & OXYGEN_CHANNEL_A) |
691 | chip->model->record_from_dma_b ? | 695 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, |
692 | &oxygen_rec_b_ops : &oxygen_rec_a_ops); | 696 | &oxygen_rec_a_ops); |
697 | else if (chip->model->used_channels & OXYGEN_CHANNEL_B) | ||
698 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | ||
699 | &oxygen_rec_b_ops); | ||
693 | pcm->private_data = chip; | 700 | pcm->private_data = chip; |
694 | pcm->private_free = oxygen_pcm_free; | 701 | pcm->private_free = oxygen_pcm_free; |
695 | strcpy(pcm->name, "Analog"); | 702 | strcpy(pcm->name, "Analog"); |
@@ -697,32 +704,51 @@ int __devinit oxygen_pcm_init(struct oxygen *chip) | |||
697 | SNDRV_DMA_TYPE_DEV, | 704 | SNDRV_DMA_TYPE_DEV, |
698 | snd_dma_pci_data(chip->pci), | 705 | snd_dma_pci_data(chip->pci), |
699 | 512 * 1024, 2048 * 1024); | 706 | 512 * 1024, 2048 * 1024); |
700 | snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, | 707 | if (ins) |
701 | SNDRV_DMA_TYPE_DEV, | 708 | snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, |
702 | snd_dma_pci_data(chip->pci), | 709 | SNDRV_DMA_TYPE_DEV, |
703 | 128 * 1024, 256 * 1024); | ||
704 | |||
705 | err = snd_pcm_new(chip->card, "Digital", 1, 1, 1, &pcm); | ||
706 | if (err < 0) | ||
707 | return err; | ||
708 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &oxygen_spdif_ops); | ||
709 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &oxygen_rec_c_ops); | ||
710 | pcm->private_data = chip; | ||
711 | pcm->private_free = oxygen_pcm_free; | ||
712 | strcpy(pcm->name, "Digital"); | ||
713 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | ||
714 | snd_dma_pci_data(chip->pci), | 710 | snd_dma_pci_data(chip->pci), |
715 | 128 * 1024, 256 * 1024); | 711 | 128 * 1024, 256 * 1024); |
716 | 712 | ||
717 | if (chip->has_ac97_1) { | 713 | outs = !!(chip->model->used_channels & OXYGEN_CHANNEL_SPDIF); |
718 | err = snd_pcm_new(chip->card, "AC97", 2, 1, 0, &pcm); | 714 | ins = !!(chip->model->used_channels & OXYGEN_CHANNEL_C); |
715 | if (outs | ins) { | ||
716 | err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm); | ||
717 | if (err < 0) | ||
718 | return err; | ||
719 | if (outs) | ||
720 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, | ||
721 | &oxygen_spdif_ops); | ||
722 | if (ins) | ||
723 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | ||
724 | &oxygen_rec_c_ops); | ||
725 | pcm->private_data = chip; | ||
726 | pcm->private_free = oxygen_pcm_free; | ||
727 | strcpy(pcm->name, "Digital"); | ||
728 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | ||
729 | snd_dma_pci_data(chip->pci), | ||
730 | 128 * 1024, 256 * 1024); | ||
731 | } | ||
732 | |||
733 | outs = chip->has_ac97_1 && | ||
734 | (chip->model->used_channels & OXYGEN_CHANNEL_AC97); | ||
735 | ins = (chip->model->used_channels & (OXYGEN_CHANNEL_A | | ||
736 | OXYGEN_CHANNEL_B)) | ||
737 | == (OXYGEN_CHANNEL_A | OXYGEN_CHANNEL_B); | ||
738 | if (outs | ins) { | ||
739 | err = snd_pcm_new(chip->card, ins ? "Analog2" : "AC97", | ||
740 | 2, outs, ins, &pcm); | ||
719 | if (err < 0) | 741 | if (err < 0) |
720 | return err; | 742 | return err; |
721 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, | 743 | if (outs) |
722 | &oxygen_ac97_ops); | 744 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
745 | &oxygen_ac97_ops); | ||
746 | if (ins) | ||
747 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | ||
748 | &oxygen_rec_b_ops); | ||
723 | pcm->private_data = chip; | 749 | pcm->private_data = chip; |
724 | pcm->private_free = oxygen_pcm_free; | 750 | pcm->private_free = oxygen_pcm_free; |
725 | strcpy(pcm->name, "Front Panel"); | 751 | strcpy(pcm->name, ins ? "Analog 2" : "Front Panel"); |
726 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 752 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
727 | snd_dma_pci_data(chip->pci), | 753 | snd_dma_pci_data(chip->pci), |
728 | 128 * 1024, 256 * 1024); | 754 | 128 * 1024, 256 * 1024); |