diff options
Diffstat (limited to 'include/sound/pcm.h')
-rw-r--r-- | include/sound/pcm.h | 87 |
1 files changed, 62 insertions, 25 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index d0711bc8c914..6268a4192d5c 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h | |||
@@ -437,6 +437,7 @@ struct snd_pcm_str { | |||
437 | struct snd_info_entry *proc_xrun_debug_entry; | 437 | struct snd_info_entry *proc_xrun_debug_entry; |
438 | #endif | 438 | #endif |
439 | #endif | 439 | #endif |
440 | struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */ | ||
440 | }; | 441 | }; |
441 | 442 | ||
442 | struct snd_pcm { | 443 | struct snd_pcm { |
@@ -982,53 +983,42 @@ static int snd_pcm_lib_alloc_vmalloc_32_buffer | |||
982 | _snd_pcm_lib_alloc_vmalloc_buffer \ | 983 | _snd_pcm_lib_alloc_vmalloc_buffer \ |
983 | (subs, size, GFP_KERNEL | GFP_DMA32 | __GFP_ZERO) | 984 | (subs, size, GFP_KERNEL | GFP_DMA32 | __GFP_ZERO) |
984 | 985 | ||
986 | #define snd_pcm_get_dma_buf(substream) ((substream)->runtime->dma_buffer_p) | ||
987 | |||
985 | #ifdef CONFIG_SND_DMA_SGBUF | 988 | #ifdef CONFIG_SND_DMA_SGBUF |
986 | /* | 989 | /* |
987 | * SG-buffer handling | 990 | * SG-buffer handling |
988 | */ | 991 | */ |
989 | #define snd_pcm_substream_sgbuf(substream) \ | 992 | #define snd_pcm_substream_sgbuf(substream) \ |
990 | ((substream)->runtime->dma_buffer_p->private_data) | 993 | snd_pcm_get_dma_buf(substream)->private_data |
991 | |||
992 | static inline dma_addr_t | ||
993 | snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs) | ||
994 | { | ||
995 | struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream); | ||
996 | return snd_sgbuf_get_addr(sg, ofs); | ||
997 | } | ||
998 | |||
999 | static inline void * | ||
1000 | snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs) | ||
1001 | { | ||
1002 | struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream); | ||
1003 | return snd_sgbuf_get_ptr(sg, ofs); | ||
1004 | } | ||
1005 | 994 | ||
1006 | struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, | 995 | struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, |
1007 | unsigned long offset); | 996 | unsigned long offset); |
1008 | unsigned int snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, | ||
1009 | unsigned int ofs, unsigned int size); | ||
1010 | |||
1011 | #else /* !SND_DMA_SGBUF */ | 997 | #else /* !SND_DMA_SGBUF */ |
1012 | /* | 998 | /* |
1013 | * fake using a continuous buffer | 999 | * fake using a continuous buffer |
1014 | */ | 1000 | */ |
1001 | #define snd_pcm_sgbuf_ops_page NULL | ||
1002 | #endif /* SND_DMA_SGBUF */ | ||
1003 | |||
1015 | static inline dma_addr_t | 1004 | static inline dma_addr_t |
1016 | snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs) | 1005 | snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs) |
1017 | { | 1006 | { |
1018 | return substream->runtime->dma_addr + ofs; | 1007 | return snd_sgbuf_get_addr(snd_pcm_get_dma_buf(substream), ofs); |
1019 | } | 1008 | } |
1020 | 1009 | ||
1021 | static inline void * | 1010 | static inline void * |
1022 | snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs) | 1011 | snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs) |
1023 | { | 1012 | { |
1024 | return substream->runtime->dma_area + ofs; | 1013 | return snd_sgbuf_get_ptr(snd_pcm_get_dma_buf(substream), ofs); |
1025 | } | 1014 | } |
1026 | 1015 | ||
1027 | #define snd_pcm_sgbuf_ops_page NULL | 1016 | static inline unsigned int |
1028 | 1017 | snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, | |
1029 | #define snd_pcm_sgbuf_get_chunk_size(subs, ofs, size) (size) | 1018 | unsigned int ofs, unsigned int size) |
1030 | 1019 | { | |
1031 | #endif /* SND_DMA_SGBUF */ | 1020 | return snd_sgbuf_get_chunk_size(snd_pcm_get_dma_buf(substream), ofs, size); |
1021 | } | ||
1032 | 1022 | ||
1033 | /* handle mmap counter - PCM mmap callback should handle this counter properly */ | 1023 | /* handle mmap counter - PCM mmap callback should handle this counter properly */ |
1034 | static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area) | 1024 | static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area) |
@@ -1086,4 +1076,51 @@ static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream | |||
1086 | return "Capture"; | 1076 | return "Capture"; |
1087 | } | 1077 | } |
1088 | 1078 | ||
1079 | /* | ||
1080 | * PCM channel-mapping control API | ||
1081 | */ | ||
1082 | /* array element of channel maps */ | ||
1083 | struct snd_pcm_chmap_elem { | ||
1084 | unsigned char channels; | ||
1085 | unsigned char map[15]; | ||
1086 | }; | ||
1087 | |||
1088 | /* channel map information; retrieved via snd_kcontrol_chip() */ | ||
1089 | struct snd_pcm_chmap { | ||
1090 | struct snd_pcm *pcm; /* assigned PCM instance */ | ||
1091 | int stream; /* PLAYBACK or CAPTURE */ | ||
1092 | struct snd_kcontrol *kctl; | ||
1093 | const struct snd_pcm_chmap_elem *chmap; | ||
1094 | unsigned int max_channels; | ||
1095 | unsigned int channel_mask; /* optional: active channels bitmask */ | ||
1096 | void *private_data; /* optional: private data pointer */ | ||
1097 | }; | ||
1098 | |||
1099 | /* get the PCM substream assigned to the given chmap info */ | ||
1100 | static inline struct snd_pcm_substream * | ||
1101 | snd_pcm_chmap_substream(struct snd_pcm_chmap *info, unsigned int idx) | ||
1102 | { | ||
1103 | struct snd_pcm_substream *s; | ||
1104 | for (s = info->pcm->streams[info->stream].substream; s; s = s->next) | ||
1105 | if (s->number == idx) | ||
1106 | return s; | ||
1107 | return NULL; | ||
1108 | } | ||
1109 | |||
1110 | /* ALSA-standard channel maps (RL/RR prior to C/LFE) */ | ||
1111 | extern const struct snd_pcm_chmap_elem snd_pcm_std_chmaps[]; | ||
1112 | /* Other world's standard channel maps (C/LFE prior to RL/RR) */ | ||
1113 | extern const struct snd_pcm_chmap_elem snd_pcm_alt_chmaps[]; | ||
1114 | |||
1115 | /* bit masks to be passed to snd_pcm_chmap.channel_mask field */ | ||
1116 | #define SND_PCM_CHMAP_MASK_24 ((1U << 2) | (1U << 4)) | ||
1117 | #define SND_PCM_CHMAP_MASK_246 (SND_PCM_CHMAP_MASK_24 | (1U << 6)) | ||
1118 | #define SND_PCM_CHMAP_MASK_2468 (SND_PCM_CHMAP_MASK_246 | (1U << 8)) | ||
1119 | |||
1120 | int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, | ||
1121 | const struct snd_pcm_chmap_elem *chmap, | ||
1122 | int max_channels, | ||
1123 | unsigned long private_value, | ||
1124 | struct snd_pcm_chmap **info_ret); | ||
1125 | |||
1089 | #endif /* __SOUND_PCM_H */ | 1126 | #endif /* __SOUND_PCM_H */ |