diff options
| author | Takashi Iwai <tiwai@suse.de> | 2012-07-27 12:27:00 -0400 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2012-09-06 12:01:16 -0400 |
| commit | 2d3391ec0ecca37efb6bc995906292f47522b471 (patch) | |
| tree | 129e8bce7b18bb9de48d6bc0e63806d22b40ad99 /include/sound/pcm.h | |
| parent | a8d372f171db9b90a64778fbcd9237c9bc256e06 (diff) | |
ALSA: PCM: channel mapping API implementation
This patch implements the basic data types for the standard channel
mapping API handling.
- The definitions of the channel positions and the new TLV types are
added in sound/asound.h and sound/tlv.h, so that they can be
referred from user-space.
- Introduced a new helper function snd_pcm_add_chmap_ctls() to create
control elements representing the channel maps for each PCM
(sub)stream.
- Some standard pre-defined channel maps are provided for
convenience.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound/pcm.h')
| -rw-r--r-- | include/sound/pcm.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index cdca2ab1e711..669c85a7fb03 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 { |
| @@ -1086,4 +1087,51 @@ static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream | |||
| 1086 | return "Capture"; | 1087 | return "Capture"; |
| 1087 | } | 1088 | } |
| 1088 | 1089 | ||
| 1090 | /* | ||
| 1091 | * PCM channel-mapping control API | ||
| 1092 | */ | ||
| 1093 | /* array element of channel maps */ | ||
| 1094 | struct snd_pcm_chmap_elem { | ||
| 1095 | unsigned char channels; | ||
| 1096 | unsigned char map[15]; | ||
| 1097 | }; | ||
| 1098 | |||
| 1099 | /* channel map information; retrieved via snd_kcontrol_chip() */ | ||
| 1100 | struct snd_pcm_chmap { | ||
| 1101 | struct snd_pcm *pcm; /* assigned PCM instance */ | ||
| 1102 | int stream; /* PLAYBACK or CAPTURE */ | ||
| 1103 | struct snd_kcontrol *kctl; | ||
| 1104 | const struct snd_pcm_chmap_elem *chmap; | ||
| 1105 | unsigned int max_channels; | ||
| 1106 | unsigned int channel_mask; /* optional: active channels bitmask */ | ||
| 1107 | void *private_data; /* optional: private data pointer */ | ||
| 1108 | }; | ||
| 1109 | |||
| 1110 | /* get the PCM substream assigned to the given chmap info */ | ||
| 1111 | static inline struct snd_pcm_substream * | ||
| 1112 | snd_pcm_chmap_substream(struct snd_pcm_chmap *info, unsigned int idx) | ||
| 1113 | { | ||
| 1114 | struct snd_pcm_substream *s; | ||
| 1115 | for (s = info->pcm->streams[info->stream].substream; s; s = s->next) | ||
| 1116 | if (s->number == idx) | ||
| 1117 | return s; | ||
| 1118 | return NULL; | ||
| 1119 | } | ||
| 1120 | |||
| 1121 | /* ALSA-standard channel maps (RL/RR prior to C/LFE) */ | ||
| 1122 | extern const struct snd_pcm_chmap_elem snd_pcm_std_chmaps[]; | ||
| 1123 | /* Other world's standard channel maps (C/LFE prior to RL/RR) */ | ||
| 1124 | extern const struct snd_pcm_chmap_elem snd_pcm_alt_chmaps[]; | ||
| 1125 | |||
| 1126 | /* bit masks to be passed to snd_pcm_chmap.channel_mask field */ | ||
| 1127 | #define SND_PCM_CHMAP_MASK_24 ((1U << 2) | (1U << 4)) | ||
| 1128 | #define SND_PCM_CHMAP_MASK_246 (SND_PCM_CHMAP_MASK_24 | (1U << 6)) | ||
| 1129 | #define SND_PCM_CHMAP_MASK_2468 (SND_PCM_CHMAP_MASK_246 | (1U << 8)) | ||
| 1130 | |||
| 1131 | int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, | ||
| 1132 | const struct snd_pcm_chmap_elem *chmap, | ||
| 1133 | int max_channels, | ||
| 1134 | unsigned long private_value, | ||
| 1135 | struct snd_pcm_chmap **info_ret); | ||
| 1136 | |||
| 1089 | #endif /* __SOUND_PCM_H */ | 1137 | #endif /* __SOUND_PCM_H */ |
