From 8e47f98c27577013660eacc76aa5667a07f61071 Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Fri, 8 May 2020 08:17:22 +0800 Subject: [PATCH 1/2] Revert "ALSA: PCM: User control API implementation" This reverts commit 8625c90a01f85be6dff058d922954adc49bf5e0a. This change has been moved out of ASoC. Change-Id: Ifc18eed2e21925f6edcf746902e1fe22a58774a4 Signed-off-by: Meng Wang --- include/sound/pcm.h | 27 +------------ sound/core/pcm.c | 4 -- sound/core/pcm_lib.c | 93 -------------------------------------------- 3 files changed, 1 insertion(+), 123 deletions(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 50c0380a5d54..54b34a16f741 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -513,7 +513,6 @@ struct snd_pcm_str { struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */ #ifdef CONFIG_AUDIO_QGKI struct snd_kcontrol *vol_kctl; /* volume controls */ - struct snd_kcontrol *usr_kctl; /* user controls */ #endif struct device dev; }; @@ -1433,7 +1432,6 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format) #ifdef CONFIG_AUDIO_QGKI #define SND_PCM_ADD_VOLUME_CTL 1 -#define SND_PCM_ADD_USR_CTL 1 /* * PCM Volume control API */ @@ -1457,31 +1455,8 @@ int snd_pcm_add_volume_ctls(struct snd_pcm *pcm, int stream, int max_length, unsigned long private_value, struct snd_pcm_volume **info_ret); - -/* - * PCM User control API - */ -/* array element of usr elem */ -struct snd_pcm_usr_elem { - int val[128]; -}; - -/* pp information; retrieved via snd_kcontrol_chip() */ -struct snd_pcm_usr { - struct snd_pcm *pcm; /* assigned PCM instance */ - int stream; /* PLAYBACK or CAPTURE */ - struct snd_kcontrol *kctl; - const struct snd_pcm_usr_elem *usr; - int max_length; - void *private_data; /* optional: private data pointer */ -}; - -int snd_pcm_add_usr_ctls(struct snd_pcm *pcm, int stream, - const struct snd_pcm_usr_elem *usr, - int max_length, int max_control_str_len, - unsigned long private_value, - struct snd_pcm_usr **info_ret); #endif + /* printk helpers */ #define pcm_err(pcm, fmt, args...) \ dev_err((pcm)->card->dev, fmt, ##args) diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 021127fa9b46..86062c96644f 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -821,10 +821,6 @@ static void free_chmap(struct snd_pcm_str *pstr) snd_ctl_remove(pstr->pcm->card, pstr->vol_kctl); pstr->vol_kctl = NULL; } - if (pstr->usr_kctl) { - snd_ctl_remove(pstr->pcm->card, pstr->usr_kctl); - pstr->usr_kctl = NULL; - } #endif } diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 9d6c7b0b8c1d..d88fc7a7e328 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -32,7 +32,6 @@ #ifdef CONFIG_AUDIO_QGKI #define STRING_LENGTH_OF_INT 12 -#define MAX_USR_CTRL_CNT 128 #endif static int fill_silence_frames(struct snd_pcm_substream *substream, @@ -2565,96 +2564,4 @@ int snd_pcm_add_volume_ctls(struct snd_pcm *pcm, int stream, return 0; } EXPORT_SYMBOL(snd_pcm_add_volume_ctls); - -static int pcm_usr_ctl_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = MAX_USR_CTRL_CNT; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = INT_MAX; - return 0; -} - -static void pcm_usr_ctl_private_free(struct snd_kcontrol *kcontrol) -{ - struct snd_pcm_usr *info = snd_kcontrol_chip(kcontrol); - - info->pcm->streams[info->stream].usr_kctl = NULL; - kfree(info); -} - -/** - * snd_pcm_add_usr_ctls - create user control elements - * @pcm: the assigned PCM instance - * @stream: stream direction - * @max_length: the max length of the user parameter of stream - * @private_value: the value passed to each kcontrol's private_value field - * @info_ret: store struct snd_pcm_usr instance if non-NULL - * - * Create usr control elements assigned to the given PCM stream(s). - * Returns zero if succeed, or a negative error value. - */ -int snd_pcm_add_usr_ctls(struct snd_pcm *pcm, int stream, - const struct snd_pcm_usr_elem *usr, - int max_length, int max_kctrl_str_len, - unsigned long private_value, - struct snd_pcm_usr **info_ret) -{ - struct snd_pcm_usr *info; - struct snd_kcontrol_new knew = { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, - .info = pcm_usr_ctl_info, - }; - int err; - char *buf; - - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) - return -ENOMEM; - - info->pcm = pcm; - info->stream = stream; - info->usr = usr; - info->max_length = max_length; - buf = kzalloc(max_kctrl_str_len, GFP_KERNEL); - if (!buf) { - pr_err("%s: buffer allocation failed\n", __func__); - kfree(info); - return -ENOMEM; - } - knew.name = buf; - if (stream == SNDRV_PCM_STREAM_PLAYBACK) - snprintf(buf, max_kctrl_str_len, "%s %d %s", - "Playback", pcm->device, "User kcontrol"); - else - snprintf(buf, max_kctrl_str_len, "%s %d %s", - "Capture", pcm->device, "User kcontrol"); - knew.device = pcm->device; - knew.count = pcm->streams[stream].substream_count; - knew.private_value = private_value; - info->kctl = snd_ctl_new1(&knew, info); - if (!info->kctl) { - kfree(info); - kfree(knew.name); - pr_err("%s: snd_ctl_new failed\n", __func__); - return -ENOMEM; - } - info->kctl->private_free = pcm_usr_ctl_private_free; - err = snd_ctl_add(pcm->card, info->kctl); - if (err < 0) { - kfree(info); - kfree(knew.name); - pr_err("%s: snd_ctl_add failed:%d\n", __func__, - err); - return -ENOMEM; - } - pcm->streams[stream].usr_kctl = info->kctl; - if (info_ret) - *info_ret = info; - kfree(knew.name); - return 0; -} -EXPORT_SYMBOL(snd_pcm_add_usr_ctls); #endif From abe8606bca693a4a111e38c4231902716c57dbcd Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Fri, 8 May 2020 08:18:14 +0800 Subject: [PATCH 2/2] Revert "ALSA: PCM: volume API implementation" This reverts commit a1682a646a89b44009b40392d7f6e68250abd39e. This change has been moved out of ASoC framework. Change-Id: I9903cace676569d3d045760a77a864687e402bb9 Signed-off-by: Meng Wang --- include/sound/pcm.h | 30 -------------- sound/core/pcm.c | 6 --- sound/core/pcm_lib.c | 97 -------------------------------------------- 3 files changed, 133 deletions(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 54b34a16f741..9921c080a885 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -511,9 +511,6 @@ struct snd_pcm_str { #endif #endif struct snd_kcontrol *chmap_kctl; /* channel-mapping controls */ -#ifdef CONFIG_AUDIO_QGKI - struct snd_kcontrol *vol_kctl; /* volume controls */ -#endif struct device dev; }; @@ -1430,33 +1427,6 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format) return 1ULL << (__force int) pcm_format; } -#ifdef CONFIG_AUDIO_QGKI -#define SND_PCM_ADD_VOLUME_CTL 1 -/* - * PCM Volume control API - */ -/* array element of volume */ -struct snd_pcm_volume_elem { - int volume; -}; - -/* pp information; retrieved via snd_kcontrol_chip() */ -struct snd_pcm_volume { - struct snd_pcm *pcm; /* assigned PCM instance */ - int stream; /* PLAYBACK or CAPTURE */ - struct snd_kcontrol *kctl; - const struct snd_pcm_volume_elem *volume; - int max_length; - void *private_data; /* optional: private data pointer */ -}; - -int snd_pcm_add_volume_ctls(struct snd_pcm *pcm, int stream, - const struct snd_pcm_volume_elem *volume, - int max_length, - unsigned long private_value, - struct snd_pcm_volume **info_ret); -#endif - /* printk helpers */ #define pcm_err(pcm, fmt, args...) \ dev_err((pcm)->card->dev, fmt, ##args) diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 86062c96644f..15d4ff893aba 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -816,12 +816,6 @@ static void free_chmap(struct snd_pcm_str *pstr) snd_ctl_remove(pstr->pcm->card, pstr->chmap_kctl); pstr->chmap_kctl = NULL; } -#ifdef CONFIG_AUDIO_QGKI - if (pstr->vol_kctl) { - snd_ctl_remove(pstr->pcm->card, pstr->vol_kctl); - pstr->vol_kctl = NULL; - } -#endif } static void snd_pcm_free_stream(struct snd_pcm_str * pstr) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index d88fc7a7e328..94e5c32f63cc 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -30,10 +30,6 @@ #define trace_applptr(substream, prev, curr) #endif -#ifdef CONFIG_AUDIO_QGKI -#define STRING_LENGTH_OF_INT 12 -#endif - static int fill_silence_frames(struct snd_pcm_substream *substream, snd_pcm_uframes_t off, snd_pcm_uframes_t frames); @@ -2411,26 +2407,6 @@ static void pcm_chmap_ctl_private_free(struct snd_kcontrol *kcontrol) kfree(info); } -#ifdef CONFIG_AUDIO_QGKI -static int pcm_volume_ctl_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 0x2000; - return 0; -} - -static void pcm_volume_ctl_private_free(struct snd_kcontrol *kcontrol) -{ - struct snd_pcm_volume *info = snd_kcontrol_chip(kcontrol); - - info->pcm->streams[info->stream].vol_kctl = NULL; - kfree(info); -} -#endif - /** * snd_pcm_add_chmap_ctls - create channel-mapping control elements * @pcm: the assigned PCM instance @@ -2492,76 +2468,3 @@ int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, return 0; } EXPORT_SYMBOL_GPL(snd_pcm_add_chmap_ctls); - -#ifdef CONFIG_AUDIO_QGKI -/** - * snd_pcm_add_volume_ctls - create volume control elements - * @pcm: the assigned PCM instance - * @stream: stream direction - * @max_length: the max length of the volume parameter of stream - * @private_value: the value passed to each kcontrol's private_value field - * @info_ret: store struct snd_pcm_volume instance if non-NULL - * - * Create volume control elements assigned to the given PCM stream(s). - * Returns zero if succeed, or a negative error value. - */ -int snd_pcm_add_volume_ctls(struct snd_pcm *pcm, int stream, - const struct snd_pcm_volume_elem *volume, - int max_length, - unsigned long private_value, - struct snd_pcm_volume **info_ret) -{ - struct snd_pcm_volume *info; - struct snd_kcontrol_new knew = { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | - SNDRV_CTL_ELEM_ACCESS_READWRITE, - .info = pcm_volume_ctl_info, - }; - int err; - int size; - - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) - return -ENOMEM; - info->pcm = pcm; - info->stream = stream; - info->volume = volume; - info->max_length = max_length; - size = sizeof("Playback ") + sizeof(" Volume") + - STRING_LENGTH_OF_INT*sizeof(char) + 1; - knew.name = kzalloc(size, GFP_KERNEL); - if (!knew.name) { - kfree(info); - return -ENOMEM; - } - if (stream == SNDRV_PCM_STREAM_PLAYBACK) - snprintf((char *)knew.name, size, "%s %d %s", - "Playback", pcm->device, "Volume"); - else - snprintf((char *)knew.name, size, "%s %d %s", - "Capture", pcm->device, "Volume"); - knew.device = pcm->device; - knew.count = pcm->streams[stream].substream_count; - knew.private_value = private_value; - info->kctl = snd_ctl_new1(&knew, info); - if (!info->kctl) { - kfree(info); - kfree(knew.name); - return -ENOMEM; - } - info->kctl->private_free = pcm_volume_ctl_private_free; - err = snd_ctl_add(pcm->card, info->kctl); - if (err < 0) { - kfree(info); - kfree(knew.name); - return -ENOMEM; - } - pcm->streams[stream].vol_kctl = info->kctl; - if (info_ret) - *info_ret = info; - kfree(knew.name); - return 0; -} -EXPORT_SYMBOL(snd_pcm_add_volume_ctls); -#endif