From patchwork Wed Nov 18 13:39:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 7649261 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5599C9F1D3 for ; Wed, 18 Nov 2015 13:36:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EE732062A for ; Wed, 18 Nov 2015 13:36:44 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 5170920602 for ; Wed, 18 Nov 2015 13:36:43 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 977E92659A2; Wed, 18 Nov 2015 14:36:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id ACB9B2657B4; Wed, 18 Nov 2015 14:36:09 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 818C92654C6; Wed, 18 Nov 2015 14:36:08 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by alsa0.perex.cz (Postfix) with ESMTP id 38A4B265473 for ; Wed, 18 Nov 2015 14:36:01 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 18 Nov 2015 05:35:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,313,1444719600"; d="scan'208";a="688455534" Received: from vkoul-udesk7.iind.intel.com ([10.223.84.34]) by orsmga003.jf.intel.com with ESMTP; 18 Nov 2015 05:35:29 -0800 From: Vinod Koul To: alsa-devel@alsa-project.org Date: Wed, 18 Nov 2015 19:09:10 +0530 Message-Id: <1447853952-6414-2-git-send-email-vinod.koul@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447853952-6414-1-git-send-email-vinod.koul@intel.com> References: <1447853952-6414-1-git-send-email-vinod.koul@intel.com> Cc: patches.audio@intel.com, Jie Yang , Liam Girdwood , liam.r.girdwood@linux.intel.com, Vinod Koul , broonie@kernel.org Subject: [alsa-devel] [PATCH 1/3] ASoC: Intel: Hsw: Move driver to use SND_SOC_BYTES_TLV X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Jie Yang Cc: Liam Girdwood --- 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), };