diff options
author | Ivan Orlov <ivan.orlov0322@gmail.com> | 2023-09-27 14:35:55 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2023-10-06 12:11:40 +0300 |
commit | e299a9fd433fe13702724f7f9b2f0f49f5345126 (patch) | |
tree | 749fb2c6088548b7d18c01a53330fa235dc8ad5a | |
parent | 462494565c27ea15d5deebd3605cb826c95ac98f (diff) | |
download | linux-e299a9fd433fe13702724f7f9b2f0f49f5345126.tar.xz |
ALSA: aloop: Add control element for getting the access mode
Add new control element 'PCM Slave Access Mode' which shows the access
mode (interleaved/non-interleaved) for the PCM playing device. Add
corresponding control change notification calls.
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230927113555.14877-2-ivan.orlov0322@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/drivers/aloop.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index ab116b1fed96..e87dc67f33c6 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -119,11 +119,13 @@ struct loopback_setup { unsigned int rate_shift; snd_pcm_format_t format; unsigned int rate; + snd_pcm_access_t access; unsigned int channels; struct snd_ctl_elem_id active_id; struct snd_ctl_elem_id format_id; struct snd_ctl_elem_id rate_id; struct snd_ctl_elem_id channels_id; + struct snd_ctl_elem_id access_id; }; struct loopback { @@ -367,6 +369,11 @@ static int loopback_check_format(struct loopback_cable *cable, int stream) &setup->channels_id); setup->channels = runtime->channels; } + if (setup->access != runtime->access) { + snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, + &setup->access_id); + setup->access = runtime->access; + } } return 0; } @@ -1520,6 +1527,30 @@ static int loopback_channels_get(struct snd_kcontrol *kcontrol, return 0; } +static int loopback_access_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + const char * const texts[] = {"Interleaved", "Non-interleaved"}; + + return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts); +} + +static int loopback_access_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct loopback *loopback = snd_kcontrol_chip(kcontrol); + snd_pcm_access_t access; + + mutex_lock(&loopback->cable_lock); + access = loopback->setup[kcontrol->id.subdevice][kcontrol->id.device].access; + + ucontrol->value.enumerated.item[0] = access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED || + access == SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED; + + mutex_unlock(&loopback->cable_lock); + return 0; +} + static const struct snd_kcontrol_new loopback_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1566,7 +1597,15 @@ static const struct snd_kcontrol_new loopback_controls[] = { .name = "PCM Slave Channels", .info = loopback_channels_info, .get = loopback_channels_get -} +}, +#define ACCESS_IDX 6 +{ + .access = SNDRV_CTL_ELEM_ACCESS_READ, + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = "PCM Slave Access Mode", + .info = loopback_access_info, + .get = loopback_access_get, +}, }; static int loopback_mixer_new(struct loopback *loopback, int notify) @@ -1587,6 +1626,7 @@ static int loopback_mixer_new(struct loopback *loopback, int notify) setup->notify = notify; setup->rate_shift = NO_PITCH; setup->format = SNDRV_PCM_FORMAT_S16_LE; + setup->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED; setup->rate = 48000; setup->channels = 2; for (idx = 0; idx < ARRAY_SIZE(loopback_controls); @@ -1618,6 +1658,9 @@ static int loopback_mixer_new(struct loopback *loopback, int notify) case CHANNELS_IDX: setup->channels_id = kctl->id; break; + case ACCESS_IDX: + setup->access_id = kctl->id; + break; default: break; } |