[alsa-devel] [PATCH 1/3] ASoC: Intel: Hsw: Move driver to use SND_SOC_BYTES_TLV

Keyon yang.jie at linux.intel.com
Thu Nov 19 04:22:08 CET 2015


+ Han who is the author of this part.

On 2015年11月18日 21:39, Vinod Koul wrote:
> Haswell driver was using SND_SOC_BYTES_EXT. Since we want to
> remove this, convert it to use SND_SOC_BYTES_TLV
>
> Signed-off-by: Vinod Koul <vinod.koul at intel.com>
> Cc: Jie Yang <yang.jie at linux.intel.com>
> Cc: Liam Girdwood <lgirdwood at gmail.com>

looks fine for me, but let's wait Han's confirmation about it.

thanks,
~Keyon

> ---
>   sound/soc/intel/haswell/sst-haswell-pcm.c | 50 ++++++++++++++++++++++++-------
>   1 file changed, 40 insertions(+), 10 deletions(-)
>
> diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c
> index 1aa819c7e09b..65594dff291a 100644
> --- a/sound/soc/intel/haswell/sst-haswell-pcm.c
> +++ b/sound/soc/intel/haswell/sst-haswell-pcm.c
> @@ -368,41 +368,71 @@ static int hsw_waves_switch_put(struct snd_kcontrol *kcontrol,
>   }
>
>   static int hsw_waves_param_get(struct snd_kcontrol *kcontrol,
> -				struct snd_ctl_elem_value *ucontrol)
> +			unsigned int __user *data, unsigned int size)
>   {
>   	struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
>   	struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform);
>   	struct sst_hsw *hsw = pdata->hsw;
> +	u8 *buffer;
> +	int ret;
> +
> +	buffer = kzalloc(size, GFP_KERNEL);
> +	if (!buffer)
> +		return -ENOMEM;
>
>   	/* return a matching line from param buffer */
> -	return sst_hsw_load_param_line(hsw, ucontrol->value.bytes.data);
> +	ret = sst_hsw_load_param_line(hsw, buffer);
> +	if (ret)
> +		goto err;
> +
> +	if (copy_to_user(data, buffer, size))
> +		ret = -EFAULT;
> +
> +err:
> +	kfree(buffer);
> +	return ret;
>   }
>
>   static int hsw_waves_param_put(struct snd_kcontrol *kcontrol,
> -				struct snd_ctl_elem_value *ucontrol)
> +		const unsigned int __user *data, unsigned int size)
>   {
>   	struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
>   	struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform);
>   	struct sst_hsw *hsw = pdata->hsw;
> -	int ret;
> +	int ret = 0;
>   	enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES;
> -	int param_id = ucontrol->value.bytes.data[0];
> +	int param_id;
>   	int param_size = WAVES_PARAM_COUNT;
> +	u8 *buffer;
> +
> +	buffer = kzalloc(size, GFP_KERNEL);
> +	if (!buffer)
> +		return -ENOMEM;
> +
> +	if (copy_from_user(buffer, data, size)) {
> +		ret = -EFAULT;
> +		goto exit;
> +	}
> +
> +	param_id = *buffer;
>
>   	/* clear param buffer and reset buffer index */
>   	if (param_id == 0xFF) {
>   		sst_hsw_reset_param_buf(hsw);
> -		return 0;
> +		goto exit;
>   	}
>
>   	/* store params into buffer */
> -	ret = sst_hsw_store_param_line(hsw, ucontrol->value.bytes.data);
> +	ret = sst_hsw_store_param_line(hsw, buffer);
>   	if (ret < 0)
> -		return ret;
> +		goto exit;
>
>   	if (sst_hsw_is_module_active(hsw, id))
>   		ret = sst_hsw_module_set_param(hsw, id, 0, param_id,
> -				param_size, ucontrol->value.bytes.data);
> +						param_size, buffer);
> +
> +exit:
> +	kfree(buffer);
>   	return ret;
>   }
>
> @@ -431,7 +461,7 @@ static const struct snd_kcontrol_new hsw_volume_controls[] = {
>   	SOC_SINGLE_BOOL_EXT("Waves Switch", 0,
>   		hsw_waves_switch_get, hsw_waves_switch_put),
>   	/* set parameters to module waves */
> -	SND_SOC_BYTES_EXT("Waves Set Param", WAVES_PARAM_COUNT,
> +	SND_SOC_BYTES_TLV("Waves Set Param", WAVES_PARAM_COUNT,
>   		hsw_waves_param_get, hsw_waves_param_put),
>   };
>
>


More information about the Alsa-devel mailing list