All of lore.kernel.org
 help / color / mirror / Atom feed
From: Han Lu <han.lu@linux.intel.com>
To: Vinod Koul <vinod.koul@intel.com>, alsa-devel@alsa-project.org
Cc: patches.audio@intel.com, liam.r.girdwood@linux.intel.com,
	broonie@kernel.org, Jie Yang <yang.jie@linux.intel.com>,
	Liam Girdwood <lgirdwood@gmail.com>
Subject: Re: [PATCH 1/3] ASoC: Intel: Hsw: Move driver to use SND_SOC_BYTES_TLV
Date: Thu, 19 Nov 2015 14:56:47 +0800	[thread overview]
Message-ID: <564D72AF.7060206@linux.intel.com> (raw)
In-Reply-To: <1447853952-6414-2-git-send-email-vinod.koul@intel.com>

There was no special reason for me to use SND_SOC_BYTES_EXT here. But 
will this patch
influences user space, since the parameter list of hsw_waves_param_get() 
be modified?

Regards,
Han Lu

On 11/18/2015 09:39 PM, 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@intel.com>
> Cc: Jie Yang<yang.jie@linux.intel.com>
> Cc: Liam Girdwood<lgirdwood@gmail.com>
> ---
>   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),
>   };
>   

  parent reply	other threads:[~2015-11-19  6:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 13:39 [PATCH 0/3] ASoC: remove SND_SOC_BYTES_EXT Vinod Koul
2015-11-18 13:39 ` [PATCH 1/3] ASoC: Intel: Hsw: Move driver to use SND_SOC_BYTES_TLV Vinod Koul
2015-11-19  3:22   ` Keyon
2015-11-19  6:56   ` Han Lu [this message]
2015-11-18 13:39 ` [PATCH 2/3] ASoC: wm5102: " Vinod Koul
2015-11-19 14:22   ` Charles Keepax
     [not found]   ` <201511182144.8dDI1Wfc%fengguang.wu@intel.com>
2015-11-20 17:07     ` Vinod Koul
2015-11-18 13:39 ` [PATCH 3/3] ASoC: core: remove SND_SOC_BYTES_EXT Vinod Koul
2015-11-18 13:53 ` [PATCH 0/3] ASoC: " Takashi Iwai
2015-11-18 18:19   ` Vinod Koul
2015-11-21 14:08     ` Mark Brown
2015-11-22 16:17       ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=564D72AF.7060206@linux.intel.com \
    --to=han.lu@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=patches.audio@intel.com \
    --cc=vinod.koul@intel.com \
    --cc=yang.jie@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.