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 | |
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')
-rw-r--r-- | include/sound/asound.h | 30 | ||||
-rw-r--r-- | include/sound/pcm.h | 48 | ||||
-rw-r--r-- | include/sound/tlv.h | 8 |
3 files changed, 86 insertions, 0 deletions
diff --git a/include/sound/asound.h b/include/sound/asound.h index 0876a1e76aef..376e75632e07 100644 --- a/include/sound/asound.h +++ b/include/sound/asound.h | |||
@@ -472,6 +472,36 @@ enum { | |||
472 | SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, | 472 | SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, |
473 | }; | 473 | }; |
474 | 474 | ||
475 | /* channel positions */ | ||
476 | enum { | ||
477 | SNDRV_CHMAP_UNKNOWN = 0, | ||
478 | SNDRV_CHMAP_FL, /* front left */ | ||
479 | SNDRV_CHMAP_FC, /* front center */ | ||
480 | SNDRV_CHMAP_FR, /* front right */ | ||
481 | SNDRV_CHMAP_FLC, /* front left center */ | ||
482 | SNDRV_CHMAP_FRC, /* front right center */ | ||
483 | SNDRV_CHMAP_RL, /* rear left */ | ||
484 | SNDRV_CHMAP_RC, /* rear center */ | ||
485 | SNDRV_CHMAP_RR, /* rear right */ | ||
486 | SNDRV_CHMAP_RLC, /* rear left center */ | ||
487 | SNDRV_CHMAP_RRC, /* rear right center */ | ||
488 | SNDRV_CHMAP_SL, /* side left */ | ||
489 | SNDRV_CHMAP_SR, /* side right */ | ||
490 | SNDRV_CHMAP_LFE, /* LFE */ | ||
491 | SNDRV_CHMAP_FLW, /* front left wide */ | ||
492 | SNDRV_CHMAP_FRW, /* front right wide */ | ||
493 | SNDRV_CHMAP_FLH, /* front left high */ | ||
494 | SNDRV_CHMAP_FCH, /* front center high */ | ||
495 | SNDRV_CHMAP_FRH, /* front right high */ | ||
496 | SNDRV_CHMAP_TC, /* top center */ | ||
497 | SNDRV_CHMAP_NA, /* N/A, silent */ | ||
498 | SNDRV_CHMAP_LAST = SNDRV_CHMAP_NA, | ||
499 | }; | ||
500 | |||
501 | #define SNDRV_CHMAP_POSITION_MASK 0xffff | ||
502 | #define SNDRV_CHMAP_PHASE_INVERSE (0x01 << 16) | ||
503 | #define SNDRV_CHMAP_DRIVER_SPEC (0x02 << 16) | ||
504 | |||
475 | #define SNDRV_PCM_IOCTL_PVERSION _IOR('A', 0x00, int) | 505 | #define SNDRV_PCM_IOCTL_PVERSION _IOR('A', 0x00, int) |
476 | #define SNDRV_PCM_IOCTL_INFO _IOR('A', 0x01, struct snd_pcm_info) | 506 | #define SNDRV_PCM_IOCTL_INFO _IOR('A', 0x01, struct snd_pcm_info) |
477 | #define SNDRV_PCM_IOCTL_TSTAMP _IOW('A', 0x02, int) | 507 | #define SNDRV_PCM_IOCTL_TSTAMP _IOW('A', 0x02, int) |
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 */ |
diff --git a/include/sound/tlv.h b/include/sound/tlv.h index a64d8fe3f855..28c65e1ada21 100644 --- a/include/sound/tlv.h +++ b/include/sound/tlv.h | |||
@@ -86,4 +86,12 @@ | |||
86 | 86 | ||
87 | #define TLV_DB_GAIN_MUTE -9999999 | 87 | #define TLV_DB_GAIN_MUTE -9999999 |
88 | 88 | ||
89 | /* | ||
90 | * channel-mapping TLV items | ||
91 | * TLV length must match with num_channels | ||
92 | */ | ||
93 | #define SNDRV_CTL_TLVT_CHMAP_FIXED 0x101 /* fixed channel position */ | ||
94 | #define SNDRV_CTL_TLVT_CHMAP_VAR 0x102 /* channels freely swappable */ | ||
95 | #define SNDRV_CTL_TLVT_CHMAP_PAIRED 0x103 /* pair-wise swappable */ | ||
96 | |||
89 | #endif /* __SOUND_TLV_H */ | 97 | #endif /* __SOUND_TLV_H */ |