From patchwork Thu Jun 27 10:18:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714102 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2D7A139D0A for ; Thu, 27 Jun 2024 10:18:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483496; cv=none; b=ieU7Wlz3mWfxSIR2nlm50BM2KwJsYMzGzYAHgx4ZP/LmT3VnvBqxnI/NBkvB40EjHFjkJX780LQUle+bSF8nK4xIzsb24SVSvFzXsI/zd8Cs0CzgnERB/hpRIbNXOpw7UV488AvJNFIOiaguU6YHMpwE2UOujEh7DcP1cDw/ceI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483496; c=relaxed/simple; bh=yD+q2RDG/dZR0awJAesqv90yprhbvZCmeolGMXjZR+8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=LYRX1jxenKvPhTT5PEknPZOjsDqbg/JUfN6djWWHi2r1eSnqVv/vtJEAy4Ie0Ng6W6U5PFy7Y38m5lndXbH36s0OZqveYXrxvXP8KEXNxWmeSDKh2u4T2Qht824/QjppXLNVkRM7U8iL+Vfj+89HJ+kU9hdc27rdF8RnXBKf4u0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=afH84Mvm; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="afH84Mvm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483495; x=1751019495; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yD+q2RDG/dZR0awJAesqv90yprhbvZCmeolGMXjZR+8=; b=afH84MvmSYYFNmGmeSqXh423J792s2qdk98YbruVENNphaR8rxymyuXA vCSmVthaqiMUdrN0SSux5AdizIV3uzAMjgXSYgKcq2XS9GYifIV6FAJe0 qwR8x98bhoJ+TYTNsMGV9TTUpnWHJiE6n58rkhEZqLtg6M6OJ7kCvn1QG z7e6Nuh0Z+yyLNtgMnZi8JkyzUlv9IBM5D+Re6h708osSRxepZ5F17LM0 bmDTD6H+ab1nGjyEuyK73c9n1a4RXWZXMXHw5YREvsM8IttBVq9rBuy+U 7Eg4QZI+eNUuzH5qDXdYgu1klIS01Qad1JydVtFqTuaedyOxVzvU6r1Iq w==; X-CSE-ConnectionGUID: mlQLmyolTtajebWabqNKFw== X-CSE-MsgGUID: 2aErNYRoQ+i5WbL/by3XcQ== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487567" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487567" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:14 -0700 X-CSE-ConnectionGUID: 8ZBS3PezSWq1QW3MK/6hRg== X-CSE-MsgGUID: IuhQhnHlR6u78amgENGfpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45079963" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:13 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 01/13] ASoC: topology: Simplify code Date: Thu, 27 Jun 2024 12:18:38 +0200 Message-Id: <20240627101850.2191513-2-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of using goto, when there is no controls, just do a loop when there are. Overall the check seems to be a bit redundant as num_kcontrols will only be above 0 if kcontrols are set anyway, but let's keep it, while simplifying code. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 4b166294602fa..dff83d49a8f61 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -394,13 +394,9 @@ static void soc_tplg_remove_widget(struct snd_soc_component *comp, if (dobj->unload) dobj->unload(comp, dobj); - if (!w->kcontrols) - goto free_news; - - for (i = 0; w->kcontrols && i < w->num_kcontrols; i++) - snd_ctl_remove(card, w->kcontrols[i]); - -free_news: + if (w->kcontrols) + for (i = 0; i < w->num_kcontrols; i++) + snd_ctl_remove(card, w->kcontrols[i]); list_del(&dobj->list); From patchwork Thu Jun 27 10:18:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714103 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A65F139D0A for ; Thu, 27 Jun 2024 10:18:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483499; cv=none; b=QGAOOyagPl6tL5dP2A94yj3cm2QlkOnj2jA3JlZBVfzKWX+okSz/Rw5EDdDGIVd1VIdUjiGnQIBDNtWePRvXtmL948P+czJM6LOkb+OFjhuq8f48VRHxby6glWkRcc/371dz1hUKhw0i2SClGQvSJ4UZ2AYLg5z/cWTwGNojtiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483499; c=relaxed/simple; bh=sZ1HP9Nhuz6+cIYRvSAKLNHESTSDtRQH13w1tRwp2bY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=nhmIDEVweb0/E9fHHNWul7QzsemBedlOTc3nvQ8W0o0jwLkX/84eCokgIb+urqVIMGK9XHB1/pctLCeZSYn4RKyxSRrxNba4wrPdcZmp5HGOvdyVNb+bVnpYrM6o6hg4UrxRy5VENZ5VU+u4E8+wCRDMgrVBn2AG3WorSBahDvE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ax3vhFIV; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ax3vhFIV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483497; x=1751019497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sZ1HP9Nhuz6+cIYRvSAKLNHESTSDtRQH13w1tRwp2bY=; b=ax3vhFIV9P9Dbzww4yJWm/N4C59nNphAEQ+MgEax/Z1X90xx7YlFw1vr 15r3CvwDOy6xX12yRxTmirGcXLAZ5nMWJ/PKezrtr4fG2yrx87fqzBL7B /wI/hvfbCLWw5ztX/HS2LmTbCQesy+L+vCcHMcTI8HlPJbrT/nkUpO68Y ATt9MBoterO1ZPbv4gr1PFp55qyRq1Qgu+lfjU7jMhPmCDwm2VEP2Rmwp lVzC9iJy5ONvFglV1Bu7EXyHpQWi/C4p7x12szy4XD4LeQDLSChrSUm6A qaC2UufzpiKckiBWBlmZ0JfDANSFECJS64e8xOONpGHpPGJaXBMsBqPzX Q==; X-CSE-ConnectionGUID: C95k6x1TRzuLGOkDMYG92A== X-CSE-MsgGUID: AUAKQgwVSuG5mIGhSTwM3Q== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487574" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487574" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:16 -0700 X-CSE-ConnectionGUID: Vs0BjLs+TeiaQ4q7Q3BapA== X-CSE-MsgGUID: X/5kV8sCTiyUXtRMroWPUw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45079969" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:15 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 02/13] ASoC: topology: Do not do unnecessary dobj management Date: Thu, 27 Jun 2024 12:18:39 +0200 Message-Id: <20240627101850.2191513-3-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Widget kcontrols do not need to be managed as topology dynamic objects with an index and a linked list. As they are always associated with a widget which is already a topology dynamic object, thus all addition/removals of a widget will by design manage the kcontrol. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index dff83d49a8f61..bd29b40acb991 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1134,8 +1134,6 @@ static int soc_tplg_dapm_widget_dmixer_create(struct soc_tplg *tplg, struct snd_ sm->min = le32_to_cpu(mc->min); sm->invert = le32_to_cpu(mc->invert); sm->platform_max = le32_to_cpu(mc->platform_max); - sm->dobj.index = tplg->index; - INIT_LIST_HEAD(&sm->dobj.list); /* map io handlers */ err = soc_tplg_kcontrol_bind_io(&mc->hdr, kc, tplg); @@ -1198,7 +1196,6 @@ static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_k se->items = le32_to_cpu(ec->items); se->mask = le32_to_cpu(ec->mask); - se->dobj.index = tplg->index; switch (le32_to_cpu(ec->hdr.ops.info)) { case SND_SOC_TPLG_CTL_ENUM_VALUE: @@ -1273,7 +1270,6 @@ static int soc_tplg_dapm_widget_dbytes_create(struct soc_tplg *tplg, struct snd_ kc->access = le32_to_cpu(be->hdr.access); sbe->max = le32_to_cpu(be->max); - INIT_LIST_HEAD(&sbe->dobj.list); /* map standard io handlers and check for external handlers */ err = soc_tplg_kcontrol_bind_io(&be->hdr, kc, tplg); From patchwork Thu Jun 27 10:18:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714104 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B59513C9D9 for ; Thu, 27 Jun 2024 10:18:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483500; cv=none; b=iiB7MLIuyGPHBw0ssNza3GhhzQLlMoyW411zEmLiAVT8cFnFvhfS8B+GTOX7rE3CiouVNI1v/KDZ/2pwmXyQ3Zp4aUpBwhwQJPHaHbhG/ZeitbK+cR1qaeF1KiU1/o8RyiEBM6LIop9GY9pRVXePLFYQJFQ3men5LTmM4rVgkDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483500; c=relaxed/simple; bh=vaSHlE11GGCI6hcWIEjCBQr+nTUhmZIOlw0Pkp4y+Ok=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=GiV6Qtb1OpQuiV57y3k51LtW9eIlcbZesTu8IJ3Un7u+V/5hsZytwprkYgX5Np3KwZ7ZAgNQvladPX06SnkIqXW82YvC6nEOx7bLjaUw5JcLnGBX2vl8AKrU08iXRrhA82yHZ8dB91MnZuHXwaXkpPtm5t4/Eua0wEBH2mAcYE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=f1W58dHF; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="f1W58dHF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483499; x=1751019499; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vaSHlE11GGCI6hcWIEjCBQr+nTUhmZIOlw0Pkp4y+Ok=; b=f1W58dHFOCoda/3GYhWZFc2nJF9ZfxffUaNClnTyCNFxUL1WTu6Dd/Zn V8bX763efcX5gc538g6JhfC6yta4i9BCOWGODNGATlJSax87erBdI6jpM XpmNlFkJkp0T3fOiwSWlWjo8CQXCtufPTudYYyfxufidrmcM2obmF7Dmn YhIFECp6bUk0pkcBTY6Liz6M3278aTQMwaBcBK1qUDwjF9hA1n6DGFw0y SZcmZOcmxLmbFuKPe+eAn1etQE/kTZkiw8cQ4NZ+lXbOc9SNs/Y7I1TQL ekCUdHCheskYs7S/p+n4mYmWh2PG1ij4/4Puur+xukpfF29VH9NP+ziiG w==; X-CSE-ConnectionGUID: yHNI303XSYO7N4ia2cveSQ== X-CSE-MsgGUID: /pZ5CHWSS7yXUnzho6F11Q== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487579" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487579" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:19 -0700 X-CSE-ConnectionGUID: hMy5mUDXTyeYkWN7yebTbQ== X-CSE-MsgGUID: Wv4AMbgiQCuioyAtUYMYeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45079980" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:17 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 03/13] ASoC: topology: Properly initialize soc_enum values Date: Thu, 27 Jun 2024 12:18:40 +0200 Message-Id: <20240627101850.2191513-4-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 soc_tplg_denum_create_values() should properly set its values field. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index bd29b40acb991..15c006c47d804 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -847,6 +847,8 @@ static int soc_tplg_denum_create_values(struct soc_tplg *tplg, struct soc_enum * se->dobj.control.dvalues[i] = le32_to_cpu(ec->values[i]); } + se->items = le32_to_cpu(ec->items); + se->values = (const unsigned int *)se->dobj.control.dvalues; return 0; } From patchwork Thu Jun 27 10:18:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714105 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DFA813C9D9 for ; Thu, 27 Jun 2024 10:18:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483503; cv=none; b=mxeno5kZS/yU4ZOJWfd6ZbD6TPl8BrA9JFEVMiiqJY9kHrDjN/YByeKGwy6dVOOIPl0/aa/KBYIJVFehMbmapSYYyAnJ/o7t4YZDtLOiLHJ81qV5LFOvqpqOn9whru4oDBlLsUEMIjyu5Tw0KVHULrN0HuHl8RfKs9TGFUO4R88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483503; c=relaxed/simple; bh=plj2VxixQDsHaludgtkK9C3QWSXWXsi6xLU+EB9hz4c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ljOgNO4gxW/tdR2G5n/egkJdPrHYJ3jHoaOnwkI1cuSKanYYFAGZJP+kn755yGDoUHFgwuYTawsnw0XYTW/4OiP3liy8vyKM1TWuR26bcDwUeaVH5Dy+qTzgjEry82pP2nmtBS0cX0hsjLWhNzmn75lJRcfJINjFgEGjcUyY7Ls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AhCI3EMR; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AhCI3EMR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483501; x=1751019501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=plj2VxixQDsHaludgtkK9C3QWSXWXsi6xLU+EB9hz4c=; b=AhCI3EMRzSDWqfnW/fu0UdSeKHcWhFskm4ipCgA3EdczjNFI1Q6kJ3bO 4ZN0NGiqKNHsFZVdvIreAw5T6PfMZiojO19GmhucoEwmHp58BYpQV3JZ/ 3EF3gJKq3BJUbAlsCBY2YRUeTeyIF5wTpqAy1gqBO8V01aprtIURKW3sH VbA1BmGmp4fbBryx5nCobb3armNR9wcum5H3eTjJrM2kdk8kiIM8BqRXo DPP2ItYCAu3gt4YG7METPeRazSNVW5h+8+/dYhn17qOBqtZED562Lz35P Wf6ptyt0BVDD6HNS9/AKGeH8h+TbXR5FUv7cX9fCATkq4XlkiruLwL1IG Q==; X-CSE-ConnectionGUID: 0hxmdazZSSiQqUGJhGRN9A== X-CSE-MsgGUID: 7ROjYX6MSaKtjl0lQu5C9A== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487586" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487586" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:21 -0700 X-CSE-ConnectionGUID: m9ypiWyIS+OrEEE+jeLiMA== X-CSE-MsgGUID: HuHkn05+SuiVT7fKBf6vfg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45079986" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:19 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 04/13] ASoC: topology: Cleanup soc_tplg_dapm_widget_dbytes_create Date: Thu, 27 Jun 2024 12:18:41 +0200 Message-Id: <20240627101850.2191513-5-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Minor cleanups to increase readability. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 15c006c47d804..73e1279758223 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1249,25 +1249,22 @@ static int soc_tplg_dapm_widget_dbytes_create(struct soc_tplg *tplg, struct snd_ be = (struct snd_soc_tplg_bytes_control *)tplg->pos; /* validate kcontrol */ - if (strnlen(be->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == - SNDRV_CTL_ELEM_ID_NAME_MAXLEN) + if (strnlen(be->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN) return -EINVAL; sbe = devm_kzalloc(tplg->dev, sizeof(*sbe), GFP_KERNEL); if (!sbe) return -ENOMEM; - tplg->pos += (sizeof(struct snd_soc_tplg_bytes_control) + - le32_to_cpu(be->priv.size)); + tplg->pos += (sizeof(struct snd_soc_tplg_bytes_control) + le32_to_cpu(be->priv.size)); - dev_dbg(tplg->dev, - "ASoC: adding bytes kcontrol %s with access 0x%x\n", + dev_dbg(tplg->dev, "ASoC: adding bytes kcontrol %s with access 0x%x\n", be->hdr.name, be->hdr.access); - kc->private_value = (long)sbe; kc->name = devm_kstrdup(tplg->dev, be->hdr.name, GFP_KERNEL); if (!kc->name) return -ENOMEM; + kc->private_value = (long)sbe; kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; kc->access = le32_to_cpu(be->hdr.access); @@ -1281,11 +1278,7 @@ static int soc_tplg_dapm_widget_dbytes_create(struct soc_tplg *tplg, struct snd_ } /* pass control to driver for optional further init */ - err = soc_tplg_control_load(tplg, kc, &be->hdr); - if (err < 0) - return err; - - return 0; + return soc_tplg_control_load(tplg, kc, &be->hdr); } static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg, From patchwork Thu Jun 27 10:18:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714106 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6866513C9D9 for ; Thu, 27 Jun 2024 10:18:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483504; cv=none; b=e0nSjzKI5YZljlzElR/dv2eHo2G7hO1FmVCg8j+TVPOjfjz4H3mhkCu+wc1ApVK1dCK4Yw2P1Mkudd56lTUFiPPU8dDupkQ53VCGzoYRdsvjdaqxNOGiadtdKbxLKy4xNYPCBPvNiwIPshb7MvGByNaZu5qaTV63RHEqPPfugFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483504; c=relaxed/simple; bh=MFCt6tH0KGIBBZ8/lzYm5PggqPJ6uRF2WwAFwEKM9Lc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=WlywnCkCaKczSvPjL4WY918K3lVBD9lUN0NXqvUktuctnWn6iBozxNS0LNK1ZQXn5jJbG/BmTh0WclGT8CeqVE+/Y0GzQWY4pKBf9hfzZ1/WT+UnPys2/g71gSLitw3oopzOzDXAcXj+c6X/RyFMarp457/FyJvI1xuoQjrozik= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lAKLC+dM; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lAKLC+dM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483503; x=1751019503; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MFCt6tH0KGIBBZ8/lzYm5PggqPJ6uRF2WwAFwEKM9Lc=; b=lAKLC+dMTQ7C2porPoIpxSbny5aApVWEE/K+puNwln5yqWqsJ18m1mVn LRC4WcXhgd+t87HIrc/DzRtiHiAY6+Doj3SHVDsi+1RA5uI28YU7lKkUZ wg8ymdUG3ad0UJEN8hdV7IJOmscjQ37fshYdKrNmEhSE3sdDb0dIMBoiM CNcF2NwfSgivmHjxj5TMxW6ALpOF5svYIj3jPIOiK2kMnYCZaXIinwbux 3R7HEwxjot+A6DZRs3FLlJum3Q0Ci+LCzHY1+RLCMVqt2xDkobFc7tQey 4vsicrVbJ6ui4DuTScserV4HCBIJnEQi0HQ+JtY4dqLcssmFov9Z7ruV7 g==; X-CSE-ConnectionGUID: vSuLJU9IRVqXoW/YgBqeSA== X-CSE-MsgGUID: qUpZgXhDSICiwSgct+jnrg== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487591" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487591" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:23 -0700 X-CSE-ConnectionGUID: MZwQdxUpQbi8O+d82AS6+g== X-CSE-MsgGUID: DLqgjPDYQemyIPCCpNjiKQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45079991" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:21 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 05/13] ASoC: topology: Cleanup soc_tplg_dapm_widget_dmixer_create Date: Thu, 27 Jun 2024 12:18:42 +0200 Message-Id: <20240627101850.2191513-6-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Minor cleanups to increase readability. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 73e1279758223..242d8b9c2f03d 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1094,43 +1094,37 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, static int soc_tplg_dapm_widget_dmixer_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) { - struct soc_mixer_control *sm; struct snd_soc_tplg_mixer_control *mc; + struct soc_mixer_control *sm; int err; mc = (struct snd_soc_tplg_mixer_control *)tplg->pos; /* validate kcontrol */ - if (strnlen(mc->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == - SNDRV_CTL_ELEM_ID_NAME_MAXLEN) + if (strnlen(mc->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN) return -EINVAL; sm = devm_kzalloc(tplg->dev, sizeof(*sm), GFP_KERNEL); if (!sm) return -ENOMEM; - tplg->pos += sizeof(struct snd_soc_tplg_mixer_control) + - le32_to_cpu(mc->priv.size); + tplg->pos += sizeof(struct snd_soc_tplg_mixer_control) + le32_to_cpu(mc->priv.size); - dev_dbg(tplg->dev, " adding DAPM widget mixer control %s\n", - mc->hdr.name); + dev_dbg(tplg->dev, "ASoC: adding mixer kcontrol %s with access 0x%x\n", + mc->hdr.name, mc->hdr.access); - kc->private_value = (long)sm; kc->name = devm_kstrdup(tplg->dev, mc->hdr.name, GFP_KERNEL); if (!kc->name) return -ENOMEM; + kc->private_value = (long)sm; kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; kc->access = le32_to_cpu(mc->hdr.access); /* we only support FL/FR channel mapping atm */ - sm->reg = tplg_chan_get_reg(tplg, mc->channel, - SNDRV_CHMAP_FL); - sm->rreg = tplg_chan_get_reg(tplg, mc->channel, - SNDRV_CHMAP_FR); - sm->shift = tplg_chan_get_shift(tplg, mc->channel, - SNDRV_CHMAP_FL); - sm->rshift = tplg_chan_get_shift(tplg, mc->channel, - SNDRV_CHMAP_FR); + sm->reg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FL); + sm->rreg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FR); + sm->shift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FL); + sm->rshift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FR); sm->max = le32_to_cpu(mc->max); sm->min = le32_to_cpu(mc->min); @@ -1147,17 +1141,12 @@ static int soc_tplg_dapm_widget_dmixer_create(struct soc_tplg *tplg, struct snd_ /* create any TLV data */ err = soc_tplg_create_tlv(tplg, kc, &mc->hdr); if (err < 0) { - dev_err(tplg->dev, "ASoC: failed to create TLV %s\n", - mc->hdr.name); + dev_err(tplg->dev, "ASoC: failed to create TLV %s\n", mc->hdr.name); return err; } /* pass control to driver for optional further init */ - err = soc_tplg_control_load(tplg, kc, &mc->hdr); - if (err < 0) - return err; - - return 0; + return soc_tplg_control_load(tplg, kc, &mc->hdr); } static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) From patchwork Thu Jun 27 10:18:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714107 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA39813C9D9 for ; Thu, 27 Jun 2024 10:18:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483507; cv=none; b=FIJ/A2fiASABcJsTWfd9iKVjDY2rGMJNA6iNId4uYhWMsCrv+jglUeuW/LyEsA8PEM7YFWKu1pyHMADnWx7GtP+XhC+dqFK7ptMSJNGfA79TQSQXQpoMYpJwelMb6Rf3klEuqui2winc23rX3mtG3/gqK0WieYOabLy2qKkvfzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483507; c=relaxed/simple; bh=0WW7+/n9KOypjkZa8h7NHcqIFmK1fLlycdpTYjfcuEo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=DQQE5aGZIci9xoUb4Mv008YHy4uMR1e/NDVE2My9xf7EBgufYBjvDWd5SOkBWJwz/KTnXPbeYXlpHjECsA0PUgLkQpaxs1D3gD+y9/vAadU18lTcjZ2cB7kCXS3RxIkLMs/3TjcoL8lv4eW+5HVFr3tzAuj3fbcJwO4VKn21fk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bl76sPg3; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bl76sPg3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483506; x=1751019506; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0WW7+/n9KOypjkZa8h7NHcqIFmK1fLlycdpTYjfcuEo=; b=bl76sPg3rXgFyZZnZ4/W0e+Sr289P5huccUsquvP07Aia6UEE1pkpU3b JU2cwqeMQXaWvhUbJU7XqBfh2uJUy1tmfo6QVP6pF933xwoM7g63SGcjV wyiFcIZ+dfbZHB7TchYFLksgiaFQJc078bkSmNbWUz2Is/o4pEcL1To8/ c/eqGxEj0RElUWK226JqrJvVPJzOQeeuhvs8zaSBbAZqqVK8A3rIsCClS 5LPeDICisOzlxv8m1awXwZSy3dP2PdSmI1jqJg/txNo0A4+8xruhNKyWu 42Mq3+5hHOtFKJ3qWmS4VzVQ7C49mLy3VlAK+pJTcRXi61WRoleCrD8t0 Q==; X-CSE-ConnectionGUID: lFuXP5YkQ4qrtSKJJdZiUg== X-CSE-MsgGUID: Cq/OqEpARsiu5jqCv1LFkQ== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487596" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487596" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:25 -0700 X-CSE-ConnectionGUID: gcrRgtXXTjKw4Vgmn8Hxfg== X-CSE-MsgGUID: Z+tU92ydS+SNGIQprOQabQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45080000" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:23 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 06/13] ASoC: topology: Cleanup soc_tplg_dapm_widget_denum_create Date: Thu, 27 Jun 2024 12:18:43 +0200 Message-Id: <20240627101850.2191513-7-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Minor cleanups to increase readability. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 242d8b9c2f03d..6a2a8249903d3 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1156,36 +1156,31 @@ static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_k int err; ec = (struct snd_soc_tplg_enum_control *)tplg->pos; + /* validate kcontrol */ - if (strnlen(ec->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == - SNDRV_CTL_ELEM_ID_NAME_MAXLEN) + if (strnlen(ec->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN) return -EINVAL; se = devm_kzalloc(tplg->dev, sizeof(*se), GFP_KERNEL); if (!se) return -ENOMEM; - tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) + - le32_to_cpu(ec->priv.size)); + tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) + le32_to_cpu(ec->priv.size)); - dev_dbg(tplg->dev, " adding DAPM widget enum control %s\n", - ec->hdr.name); + dev_dbg(tplg->dev, "ASoC: adding enum kcontrol %s size %d\n", ec->hdr.name, ec->items); - kc->private_value = (long)se; kc->name = devm_kstrdup(tplg->dev, ec->hdr.name, GFP_KERNEL); if (!kc->name) return -ENOMEM; + kc->private_value = (long)se; kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; kc->access = le32_to_cpu(ec->hdr.access); /* we only support FL/FR channel mapping atm */ se->reg = tplg_chan_get_reg(tplg, ec->channel, SNDRV_CHMAP_FL); - se->shift_l = tplg_chan_get_shift(tplg, ec->channel, - SNDRV_CHMAP_FL); - se->shift_r = tplg_chan_get_shift(tplg, ec->channel, - SNDRV_CHMAP_FR); + se->shift_l = tplg_chan_get_shift(tplg, ec->channel, SNDRV_CHMAP_FL); + se->shift_r = tplg_chan_get_shift(tplg, ec->channel, SNDRV_CHMAP_FR); - se->items = le32_to_cpu(ec->items); se->mask = le32_to_cpu(ec->mask); switch (le32_to_cpu(ec->hdr.ops.info)) { @@ -1193,8 +1188,7 @@ static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_k case SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE: err = soc_tplg_denum_create_values(tplg, se, ec); if (err < 0) { - dev_err(tplg->dev, "ASoC: could not create values for %s\n", - ec->hdr.name); + dev_err(tplg->dev, "ASoC: could not create values for %s\n", ec->hdr.name); return err; } fallthrough; @@ -1203,8 +1197,7 @@ static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_k case SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT: err = soc_tplg_denum_create_texts(tplg, se, ec); if (err < 0) { - dev_err(tplg->dev, "ASoC: could not create texts for %s\n", - ec->hdr.name); + dev_err(tplg->dev, "ASoC: could not create texts for %s\n", ec->hdr.name); return err; } break; @@ -1222,11 +1215,7 @@ static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_k } /* pass control to driver for optional further init */ - err = soc_tplg_control_load(tplg, kc, &ec->hdr); - if (err < 0) - return err; - - return 0; + return soc_tplg_control_load(tplg, kc, &ec->hdr); } static int soc_tplg_dapm_widget_dbytes_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) From patchwork Thu Jun 27 10:18:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714108 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCB3913C9D9 for ; Thu, 27 Jun 2024 10:18:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483509; cv=none; b=bMzH7Mu+ItGsSL0353ScaDTzhEIKGsJiaj9uny987kwdbwFDvYVeBDAPDHspbnPRAHFVyiqCk5Job1mm1SBD5hHjZers32Tm49WZawiXoXw3j+0UxtB720fCHZeLV9jOyJ90GQ/+QzpKH3jsxhyoRfs+MrRYjS4oxUDSNorjS+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483509; c=relaxed/simple; bh=RQytEy+q9wC+KnpjaBM5dhyhv1wUSTFdqwetEaUm9Ls=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=byu9T/L29Xq1NAUL4fhhaFihQ1o5SdI7tuvc6ZTfB6luicr42/Q+H4X9Oa3wWdxYKd3C2/HPF0ptkrymvxyf91allRmuCq1Gkn4lVfgmKCAE6uErIQsCB8ufphK8RWsIU7t7LtlwMGEYp5CP4mU+SVMirKlBbsJZd8nr50uyPJc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fsmo/fE6; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fsmo/fE6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483508; x=1751019508; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RQytEy+q9wC+KnpjaBM5dhyhv1wUSTFdqwetEaUm9Ls=; b=fsmo/fE6NaF8bl4oVL+feaWnCh6GUTvCmCf2tLa94Kln5b/vgNT/j701 l1HWaB+qZ0Ku66XAJTAzslsd+lelyVqTt4ewuLlTS/3hAUiZOAsiU5Imf xz2SvsX+FN9DxAflicjOYu3YsLc9kzkGHGFmv+hae6/22Rs7CDd2IjKzO oUAWCo/8RB8mr/enodG60Vv0TfPux42WRd7S5MFXC5onMRcuMQpOcPvoD Ai3MwWaxqf/FS7YICbtbNw4tcefORaaWnP8fSftPpaFacyBRa8Se2E6w2 v22rDVj0+4nFySVIJQS+LyKsNHBcFNnqXuf2cmUGMbeZkR+tVvf3jJs30 Q==; X-CSE-ConnectionGUID: wRGeHpc/SG28RgN0BvPStw== X-CSE-MsgGUID: cqXNq88DRQKrfppwDUDSDQ== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487600" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487600" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:27 -0700 X-CSE-ConnectionGUID: F6/CWkPsTJyi4dQ+z87wEQ== X-CSE-MsgGUID: 43k+PNLzT8yApO3SvAki5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45080003" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:26 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 07/13] ASoC: topology: Correctly set shift_r in soc_tplg_denum_create() Date: Thu, 27 Jun 2024 12:18:44 +0200 Message-Id: <20240627101850.2191513-8-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This aligns soc_tplg_denum_create() with soc_tplg_dapm_widget_denum_create(), as there is no reason for difference in behavior. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 6a2a8249903d3..e6eb514de5697 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -891,7 +891,7 @@ static int soc_tplg_denum_create(struct soc_tplg *tplg, size_t size) se->shift_l = tplg_chan_get_shift(tplg, ec->channel, SNDRV_CHMAP_FL); se->shift_r = tplg_chan_get_shift(tplg, ec->channel, - SNDRV_CHMAP_FL); + SNDRV_CHMAP_FR); se->mask = le32_to_cpu(ec->mask); se->dobj.index = tplg->index; From patchwork Thu Jun 27 10:18:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714109 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3F6713C9D9 for ; Thu, 27 Jun 2024 10:18:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483511; cv=none; b=kxjb3CDhBlZEU1IEmfCHJyhvSwJAJ1UMWC7CIT3KFKgCPQ4tM5uLaq4pqvd3V+tCASKKvztjreXs4bvnKFiRyYCJ5h2CtGOTDZHuSuQ4cuch4fXcel69n9Q8SWjMyaCRzD5fCxOoxUHIXq1dkBbR8zypFVdaoc/++my8mcg1RFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483511; c=relaxed/simple; bh=0Tane6+zwwCopyy1Lp+QClQeNV+y1kY20pL2+Kk9anU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Qg87z+1HKnlJk/EJpv/FDhwlN/426hGc+ib4+MdSeDjJuCxSk93uNKYkYtxJrtnuYHn2UB80bWWE7xbsJxTb4lDUY9/0mkflOMOvqRoVoDNxuvKDPHd9KRUOWFdDnX+1Yjf3A7Wk05mcnXOaQp8hdNopwG6ePoIpl7u+ClCEPgA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fVaYhuFJ; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fVaYhuFJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483510; x=1751019510; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0Tane6+zwwCopyy1Lp+QClQeNV+y1kY20pL2+Kk9anU=; b=fVaYhuFJCj87mDIjiYEELQ3dp3NemDQ9b7OmT0GlCnkdoVvws17+abKU /r2sFcQGKmOWMVgwe0hix8ui126/tyGpgzZoear10hgUjQYklHRfjOG7d 0mpHBZbu1RFJinvO5Hl3eUp2LR6ebdb9/GzxcicAMjhZpgGmQzmQ2qCdn HuLpAnrdxIHCsL5wkoHGZxU8e3DzbNGkxzbUOQ8GlIBR7Tbq2zIiBaAD+ O9OX94Txa+LjqSy2XDLfNFbR9jpkCtCsDzFoR4Kv6R8q6CrBolSP/Fe7p Nh0jha7R9kmstvONs+2BAzuwJ3m8iQvCrHvrrsRfbR96k1GUNiE7ESG9j g==; X-CSE-ConnectionGUID: AADxrysCRpaH0JqlUYAI2w== X-CSE-MsgGUID: A4yFuNIsTfmsbt3UA3SDFw== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487605" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487605" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:30 -0700 X-CSE-ConnectionGUID: qrHtzcFJSquj4c6mY6yM8g== X-CSE-MsgGUID: VvPUZtS5T0WKhg5VE5O+RA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45080007" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:28 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 08/13] ASoC: topology: Align dynamic object initialization for controls Date: Thu, 27 Jun 2024 12:18:45 +0200 Message-Id: <20240627101850.2191513-9-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 soc_tplg_dbytes_create() missed se->dobj.index initialization, so add it there. Additionally separate dynamic object initialization into separate logical block code. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index e6eb514de5697..72bd3823a0154 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -677,10 +677,12 @@ static int soc_tplg_dbytes_create(struct soc_tplg *tplg, size_t size) kc.access = le32_to_cpu(be->hdr.access); sbe->max = le32_to_cpu(be->max); + + INIT_LIST_HEAD(&sbe->dobj.list); sbe->dobj.type = SND_SOC_DOBJ_BYTES; + sbe->dobj.index = tplg->index; if (tplg->ops) sbe->dobj.unload = tplg->ops->control_unload; - INIT_LIST_HEAD(&sbe->dobj.list); /* map io handlers */ ret = soc_tplg_kcontrol_bind_io(&be->hdr, &kc, tplg); @@ -750,11 +752,12 @@ static int soc_tplg_dmixer_create(struct soc_tplg *tplg, size_t size) sm->min = le32_to_cpu(mc->min); sm->invert = le32_to_cpu(mc->invert); sm->platform_max = le32_to_cpu(mc->platform_max); - sm->dobj.index = tplg->index; + + INIT_LIST_HEAD(&sm->dobj.list); sm->dobj.type = SND_SOC_DOBJ_MIXER; + sm->dobj.index = tplg->index; if (tplg->ops) sm->dobj.unload = tplg->ops->control_unload; - INIT_LIST_HEAD(&sm->dobj.list); /* map io handlers */ ret = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc, tplg); @@ -894,11 +897,12 @@ static int soc_tplg_denum_create(struct soc_tplg *tplg, size_t size) SNDRV_CHMAP_FR); se->mask = le32_to_cpu(ec->mask); - se->dobj.index = tplg->index; + + INIT_LIST_HEAD(&se->dobj.list); se->dobj.type = SND_SOC_DOBJ_ENUM; + se->dobj.index = tplg->index; if (tplg->ops) se->dobj.unload = tplg->ops->control_unload; - INIT_LIST_HEAD(&se->dobj.list); switch (le32_to_cpu(ec->hdr.ops.info)) { case SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE: From patchwork Thu Jun 27 10:18:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714110 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2259713C9D9 for ; Thu, 27 Jun 2024 10:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483513; cv=none; b=N5zhyk0oc1D2WZQ74erRaGuYs+RY3Tzy8XVTdZgDAJxNAvQqidqdfKixqIYFBJwBg7bl4Gil22qK8nhHMdBjJpYxu8Xt6Qh9Zdk7tlXj8JVHfbc5/PP2wWWBxBfZ3fdt5cykIKjti8QI5pBb2e7xJO7EudxSw1HOtHGx3X02qms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483513; c=relaxed/simple; bh=k2x0e/4Y/a3+pPZ4CWk+KqwHvptBYN8i0AcquIEu8/w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=q7bnhsIO/To5/ZnYibH6Uzzu59N06zJ1D9Y9wGDDRLwAl0G5Kg88HTfiGRsi4ARBmShxNWIk3XL6o8UnaPw/xZTj3Tsj8KrET7jWrQDCSvRwvDSGp8a4PjO9wVFnMLXIaXQ/qxgi0/2EZFmPf7oG7lExB7KNf3+l3nIlUPk5mRY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=cHBQ87Q6; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cHBQ87Q6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483512; x=1751019512; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k2x0e/4Y/a3+pPZ4CWk+KqwHvptBYN8i0AcquIEu8/w=; b=cHBQ87Q6hTLtYgJ6GP3W0YGnE6bqm7Xv0txyJJ6dNdga2ybliNNwwG0B h8Mk4CWHyHO9VOhjGWr5dk+IyDGAsPv7L9dqgHgDb+MlxOKe/z91U/Ntf dIKCgH4W2+LJ4yt6DFQiinnSofT/CBErhqKSrCltyMVC+vrkIel1jxrx5 YqI+bZ+OH0adGCNJYQWkYRiCstCPEcXJDFZ/1ZadnQrK4Gd/gHHwQC/3h m8cvpWy9ap2aKAUsjFuSfxV4YEdb5HIQ7laE4o5gwqlvUWNZfXJ9G137z JrivR5+JvDDcuN01McrCtc1ifLTQHDhV6zes8oN7O4uVG/LFKUDJzEsQt Q==; X-CSE-ConnectionGUID: UG20REkGQKO1PB3zMUhZSQ== X-CSE-MsgGUID: ZDiSfn9iQYKTD5/PnVwUsw== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487610" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487610" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:32 -0700 X-CSE-ConnectionGUID: m7ErnX2VSpK1DkVtugwJAg== X-CSE-MsgGUID: hhB197LHRLuI7AaVKa2iYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45080011" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:30 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 09/13] ASoC: topology: Rename function creating widget kcontrol Date: Thu, 27 Jun 2024 12:18:46 +0200 Message-Id: <20240627101850.2191513-10-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In following patches it will be reused to also create standalone kcontrol, so it makes sense to name it in more generic way. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 72bd3823a0154..f85cf67f74b1e 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1096,7 +1096,7 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, return ret; } -static int soc_tplg_dapm_widget_dmixer_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) +static int soc_tplg_control_dmixer_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) { struct snd_soc_tplg_mixer_control *mc; struct soc_mixer_control *sm; @@ -1153,7 +1153,7 @@ static int soc_tplg_dapm_widget_dmixer_create(struct soc_tplg *tplg, struct snd_ return soc_tplg_control_load(tplg, kc, &mc->hdr); } -static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) +static int soc_tplg_control_denum_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) { struct snd_soc_tplg_enum_control *ec; struct soc_enum *se; @@ -1222,7 +1222,7 @@ static int soc_tplg_dapm_widget_denum_create(struct soc_tplg *tplg, struct snd_k return soc_tplg_control_load(tplg, kc, &ec->hdr); } -static int soc_tplg_dapm_widget_dbytes_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) +static int soc_tplg_control_dbytes_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) { struct snd_soc_tplg_bytes_control *be; struct soc_bytes_ext *sbe; @@ -1350,7 +1350,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg, kc[i].index = mixer_count; kcontrol_type[i] = SND_SOC_TPLG_TYPE_MIXER; mixer_count++; - ret = soc_tplg_dapm_widget_dmixer_create(tplg, &kc[i]); + ret = soc_tplg_control_dmixer_create(tplg, &kc[i]); if (ret < 0) goto hdr_err; break; @@ -1363,7 +1363,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg, kc[i].index = enum_count; kcontrol_type[i] = SND_SOC_TPLG_TYPE_ENUM; enum_count++; - ret = soc_tplg_dapm_widget_denum_create(tplg, &kc[i]); + ret = soc_tplg_control_denum_create(tplg, &kc[i]); if (ret < 0) goto hdr_err; break; @@ -1372,7 +1372,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg, kc[i].index = bytes_count; kcontrol_type[i] = SND_SOC_TPLG_TYPE_BYTES; bytes_count++; - ret = soc_tplg_dapm_widget_dbytes_create(tplg, &kc[i]); + ret = soc_tplg_control_dbytes_create(tplg, &kc[i]); if (ret < 0) goto hdr_err; break; From patchwork Thu Jun 27 10:18:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714111 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD7E513C9CA for ; Thu, 27 Jun 2024 10:18:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483516; cv=none; b=K/Z4JEdhjYqJtrrMLkEnaLt/qYNL6OonzlzDbxvPSxA0htuLoFZGrgx/w4qIhLPV3SC8bGyVY3z71Zv5KydpztbS6HkoDMTSbF7yI6jm36NFg3TAoxw56zdRmnWeufvnndRKpuoEM3ZW5zQ0AUCG42mCuA5L5FRnZeEvaLk5bME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483516; c=relaxed/simple; bh=BiWqxlghZ1dI3jjoQgUdqkbb4nPuhdJq1pYX8zubO+Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ZrHGDbl43kjHKKhZvZ1vlNrK08gYNzZtb8SDdFS+Wk44JofNErPbFTmMvxW2DXcRM/oO7vifOJrtpgTWh4ygVlfnaV+1bd3Knezs5+LXJL2wOlCCVYJua+7NOufQbl+iG4+VDCgkDSioxtRepfDk5WH30mMsDVgH/tOjxnwVmho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UT8qa1pq; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UT8qa1pq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483515; x=1751019515; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BiWqxlghZ1dI3jjoQgUdqkbb4nPuhdJq1pYX8zubO+Y=; b=UT8qa1pqYJAa95tvievvOKionkzvdoi1unVAm8586lA+Mc2QFys6ZJIh O8XXx6f/TemJ5i+E/7JR+dTfvthMGUYC79wYkaUxkW5uhI0oMnyRfbhan YSGzo91yUXhye+C932jlyWL2/+HoDRSvHp0wqMYduUpf38biwLejALpzO 6xY/2bmFivJPjz5KfWwC1DhXayT+L099khTrd4/pXm2j1hsdk1OG805xx +nBGum9LM4E0rFwjJJX8JNSzRcJmRrxofp4J8TF6E5WMvYUB3jUZtdUqP xQrQwb36JbQGGQpp2w80IW8u8Wk32eyRVFLg4KTKjqqvDZww/MvMsXuuZ Q==; X-CSE-ConnectionGUID: qT8Lqy10TP6kF4O2K4bB3Q== X-CSE-MsgGUID: v3FVHKGMTUuZBoUz2al6Mw== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487614" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487614" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:34 -0700 X-CSE-ConnectionGUID: CHCea0W+S9yBx8f2zR/+nw== X-CSE-MsgGUID: ELzkdgOyQjWL6NviqY0ZeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45080015" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:32 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 10/13] ASoC: topology: Reshuffle function placement Date: Thu, 27 Jun 2024 12:18:47 +0200 Message-Id: <20240627101850.2191513-11-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In preparation for following cleanups move functions around. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 466 +++++++++++++++++++-------------------- 1 file changed, 233 insertions(+), 233 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index f85cf67f74b1e..5aab1df7e2606 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -640,6 +640,239 @@ static int soc_tplg_create_tlv(struct soc_tplg *tplg, return 0; } +static int soc_tplg_control_dmixer_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) +{ + struct snd_soc_tplg_mixer_control *mc; + struct soc_mixer_control *sm; + int err; + + mc = (struct snd_soc_tplg_mixer_control *)tplg->pos; + + /* validate kcontrol */ + if (strnlen(mc->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN) + return -EINVAL; + + sm = devm_kzalloc(tplg->dev, sizeof(*sm), GFP_KERNEL); + if (!sm) + return -ENOMEM; + + tplg->pos += sizeof(struct snd_soc_tplg_mixer_control) + le32_to_cpu(mc->priv.size); + + dev_dbg(tplg->dev, "ASoC: adding mixer kcontrol %s with access 0x%x\n", + mc->hdr.name, mc->hdr.access); + + kc->name = devm_kstrdup(tplg->dev, mc->hdr.name, GFP_KERNEL); + if (!kc->name) + return -ENOMEM; + kc->private_value = (long)sm; + kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; + kc->access = le32_to_cpu(mc->hdr.access); + + /* we only support FL/FR channel mapping atm */ + sm->reg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FL); + sm->rreg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FR); + sm->shift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FL); + sm->rshift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FR); + + sm->max = le32_to_cpu(mc->max); + sm->min = le32_to_cpu(mc->min); + sm->invert = le32_to_cpu(mc->invert); + sm->platform_max = le32_to_cpu(mc->platform_max); + + /* map io handlers */ + err = soc_tplg_kcontrol_bind_io(&mc->hdr, kc, tplg); + if (err) { + soc_control_err(tplg, &mc->hdr, mc->hdr.name); + return err; + } + + /* create any TLV data */ + err = soc_tplg_create_tlv(tplg, kc, &mc->hdr); + if (err < 0) { + dev_err(tplg->dev, "ASoC: failed to create TLV %s\n", mc->hdr.name); + return err; + } + + /* pass control to driver for optional further init */ + return soc_tplg_control_load(tplg, kc, &mc->hdr); +} + +static int soc_tplg_denum_create_texts(struct soc_tplg *tplg, struct soc_enum *se, + struct snd_soc_tplg_enum_control *ec) +{ + int i, ret; + + if (le32_to_cpu(ec->items) > ARRAY_SIZE(ec->texts)) + return -EINVAL; + + se->dobj.control.dtexts = + devm_kcalloc(tplg->dev, le32_to_cpu(ec->items), sizeof(char *), GFP_KERNEL); + if (se->dobj.control.dtexts == NULL) + return -ENOMEM; + + for (i = 0; i < le32_to_cpu(ec->items); i++) { + + if (strnlen(ec->texts[i], SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == + SNDRV_CTL_ELEM_ID_NAME_MAXLEN) { + ret = -EINVAL; + goto err; + } + + se->dobj.control.dtexts[i] = devm_kstrdup(tplg->dev, ec->texts[i], GFP_KERNEL); + if (!se->dobj.control.dtexts[i]) { + ret = -ENOMEM; + goto err; + } + } + + se->items = le32_to_cpu(ec->items); + se->texts = (const char * const *)se->dobj.control.dtexts; + return 0; + +err: + return ret; +} + +static int soc_tplg_denum_create_values(struct soc_tplg *tplg, struct soc_enum *se, + struct snd_soc_tplg_enum_control *ec) +{ + int i; + + /* + * Following "if" checks if we have at most SND_SOC_TPLG_NUM_TEXTS + * values instead of using ARRAY_SIZE(ec->values) due to the fact that + * it is oversized for its purpose. Additionally it is done so because + * it is defined in UAPI header where it can't be easily changed. + */ + if (le32_to_cpu(ec->items) > SND_SOC_TPLG_NUM_TEXTS) + return -EINVAL; + + se->dobj.control.dvalues = devm_kcalloc(tplg->dev, le32_to_cpu(ec->items), + sizeof(*se->dobj.control.dvalues), + GFP_KERNEL); + if (!se->dobj.control.dvalues) + return -ENOMEM; + + /* convert from little-endian */ + for (i = 0; i < le32_to_cpu(ec->items); i++) { + se->dobj.control.dvalues[i] = le32_to_cpu(ec->values[i]); + } + + se->items = le32_to_cpu(ec->items); + se->values = (const unsigned int *)se->dobj.control.dvalues; + return 0; +} + +static int soc_tplg_control_denum_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) +{ + struct snd_soc_tplg_enum_control *ec; + struct soc_enum *se; + int err; + + ec = (struct snd_soc_tplg_enum_control *)tplg->pos; + + /* validate kcontrol */ + if (strnlen(ec->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN) + return -EINVAL; + + se = devm_kzalloc(tplg->dev, sizeof(*se), GFP_KERNEL); + if (!se) + return -ENOMEM; + + tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) + le32_to_cpu(ec->priv.size)); + + dev_dbg(tplg->dev, "ASoC: adding enum kcontrol %s size %d\n", ec->hdr.name, ec->items); + + kc->name = devm_kstrdup(tplg->dev, ec->hdr.name, GFP_KERNEL); + if (!kc->name) + return -ENOMEM; + kc->private_value = (long)se; + kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; + kc->access = le32_to_cpu(ec->hdr.access); + + /* we only support FL/FR channel mapping atm */ + se->reg = tplg_chan_get_reg(tplg, ec->channel, SNDRV_CHMAP_FL); + se->shift_l = tplg_chan_get_shift(tplg, ec->channel, SNDRV_CHMAP_FL); + se->shift_r = tplg_chan_get_shift(tplg, ec->channel, SNDRV_CHMAP_FR); + + se->mask = le32_to_cpu(ec->mask); + + switch (le32_to_cpu(ec->hdr.ops.info)) { + case SND_SOC_TPLG_CTL_ENUM_VALUE: + case SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE: + err = soc_tplg_denum_create_values(tplg, se, ec); + if (err < 0) { + dev_err(tplg->dev, "ASoC: could not create values for %s\n", ec->hdr.name); + return err; + } + fallthrough; + case SND_SOC_TPLG_CTL_ENUM: + case SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE: + case SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT: + err = soc_tplg_denum_create_texts(tplg, se, ec); + if (err < 0) { + dev_err(tplg->dev, "ASoC: could not create texts for %s\n", ec->hdr.name); + return err; + } + break; + default: + dev_err(tplg->dev, "ASoC: invalid enum control type %d for %s\n", + ec->hdr.ops.info, ec->hdr.name); + return -EINVAL; + } + + /* map io handlers */ + err = soc_tplg_kcontrol_bind_io(&ec->hdr, kc, tplg); + if (err) { + soc_control_err(tplg, &ec->hdr, ec->hdr.name); + return err; + } + + /* pass control to driver for optional further init */ + return soc_tplg_control_load(tplg, kc, &ec->hdr); +} + +static int soc_tplg_control_dbytes_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) +{ + struct snd_soc_tplg_bytes_control *be; + struct soc_bytes_ext *sbe; + int err; + + be = (struct snd_soc_tplg_bytes_control *)tplg->pos; + + /* validate kcontrol */ + if (strnlen(be->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN) + return -EINVAL; + + sbe = devm_kzalloc(tplg->dev, sizeof(*sbe), GFP_KERNEL); + if (!sbe) + return -ENOMEM; + + tplg->pos += (sizeof(struct snd_soc_tplg_bytes_control) + le32_to_cpu(be->priv.size)); + + dev_dbg(tplg->dev, "ASoC: adding bytes kcontrol %s with access 0x%x\n", + be->hdr.name, be->hdr.access); + + kc->name = devm_kstrdup(tplg->dev, be->hdr.name, GFP_KERNEL); + if (!kc->name) + return -ENOMEM; + kc->private_value = (long)sbe; + kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; + kc->access = le32_to_cpu(be->hdr.access); + + sbe->max = le32_to_cpu(be->max); + + /* map standard io handlers and check for external handlers */ + err = soc_tplg_kcontrol_bind_io(&be->hdr, kc, tplg); + if (err) { + soc_control_err(tplg, &be->hdr, be->hdr.name); + return err; + } + + /* pass control to driver for optional further init */ + return soc_tplg_control_load(tplg, kc, &be->hdr); +} + static int soc_tplg_dbytes_create(struct soc_tplg *tplg, size_t size) { struct snd_soc_tplg_bytes_control *be; @@ -789,72 +1022,6 @@ static int soc_tplg_dmixer_create(struct soc_tplg *tplg, size_t size) return ret; } -static int soc_tplg_denum_create_texts(struct soc_tplg *tplg, struct soc_enum *se, - struct snd_soc_tplg_enum_control *ec) -{ - int i, ret; - - if (le32_to_cpu(ec->items) > ARRAY_SIZE(ec->texts)) - return -EINVAL; - - se->dobj.control.dtexts = - devm_kcalloc(tplg->dev, le32_to_cpu(ec->items), sizeof(char *), GFP_KERNEL); - if (se->dobj.control.dtexts == NULL) - return -ENOMEM; - - for (i = 0; i < le32_to_cpu(ec->items); i++) { - - if (strnlen(ec->texts[i], SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == - SNDRV_CTL_ELEM_ID_NAME_MAXLEN) { - ret = -EINVAL; - goto err; - } - - se->dobj.control.dtexts[i] = devm_kstrdup(tplg->dev, ec->texts[i], GFP_KERNEL); - if (!se->dobj.control.dtexts[i]) { - ret = -ENOMEM; - goto err; - } - } - - se->items = le32_to_cpu(ec->items); - se->texts = (const char * const *)se->dobj.control.dtexts; - return 0; - -err: - return ret; -} - -static int soc_tplg_denum_create_values(struct soc_tplg *tplg, struct soc_enum *se, - struct snd_soc_tplg_enum_control *ec) -{ - int i; - - /* - * Following "if" checks if we have at most SND_SOC_TPLG_NUM_TEXTS - * values instead of using ARRAY_SIZE(ec->values) due to the fact that - * it is oversized for its purpose. Additionally it is done so because - * it is defined in UAPI header where it can't be easily changed. - */ - if (le32_to_cpu(ec->items) > SND_SOC_TPLG_NUM_TEXTS) - return -EINVAL; - - se->dobj.control.dvalues = devm_kcalloc(tplg->dev, le32_to_cpu(ec->items), - sizeof(*se->dobj.control.dvalues), - GFP_KERNEL); - if (!se->dobj.control.dvalues) - return -ENOMEM; - - /* convert from little-endian */ - for (i = 0; i < le32_to_cpu(ec->items); i++) { - se->dobj.control.dvalues[i] = le32_to_cpu(ec->values[i]); - } - - se->items = le32_to_cpu(ec->items); - se->values = (const unsigned int *)se->dobj.control.dvalues; - return 0; -} - static int soc_tplg_denum_create(struct soc_tplg *tplg, size_t size) { struct snd_soc_tplg_enum_control *ec; @@ -1096,173 +1263,6 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, return ret; } -static int soc_tplg_control_dmixer_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) -{ - struct snd_soc_tplg_mixer_control *mc; - struct soc_mixer_control *sm; - int err; - - mc = (struct snd_soc_tplg_mixer_control *)tplg->pos; - - /* validate kcontrol */ - if (strnlen(mc->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN) - return -EINVAL; - - sm = devm_kzalloc(tplg->dev, sizeof(*sm), GFP_KERNEL); - if (!sm) - return -ENOMEM; - - tplg->pos += sizeof(struct snd_soc_tplg_mixer_control) + le32_to_cpu(mc->priv.size); - - dev_dbg(tplg->dev, "ASoC: adding mixer kcontrol %s with access 0x%x\n", - mc->hdr.name, mc->hdr.access); - - kc->name = devm_kstrdup(tplg->dev, mc->hdr.name, GFP_KERNEL); - if (!kc->name) - return -ENOMEM; - kc->private_value = (long)sm; - kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; - kc->access = le32_to_cpu(mc->hdr.access); - - /* we only support FL/FR channel mapping atm */ - sm->reg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FL); - sm->rreg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FR); - sm->shift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FL); - sm->rshift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FR); - - sm->max = le32_to_cpu(mc->max); - sm->min = le32_to_cpu(mc->min); - sm->invert = le32_to_cpu(mc->invert); - sm->platform_max = le32_to_cpu(mc->platform_max); - - /* map io handlers */ - err = soc_tplg_kcontrol_bind_io(&mc->hdr, kc, tplg); - if (err) { - soc_control_err(tplg, &mc->hdr, mc->hdr.name); - return err; - } - - /* create any TLV data */ - err = soc_tplg_create_tlv(tplg, kc, &mc->hdr); - if (err < 0) { - dev_err(tplg->dev, "ASoC: failed to create TLV %s\n", mc->hdr.name); - return err; - } - - /* pass control to driver for optional further init */ - return soc_tplg_control_load(tplg, kc, &mc->hdr); -} - -static int soc_tplg_control_denum_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) -{ - struct snd_soc_tplg_enum_control *ec; - struct soc_enum *se; - int err; - - ec = (struct snd_soc_tplg_enum_control *)tplg->pos; - - /* validate kcontrol */ - if (strnlen(ec->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN) - return -EINVAL; - - se = devm_kzalloc(tplg->dev, sizeof(*se), GFP_KERNEL); - if (!se) - return -ENOMEM; - - tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) + le32_to_cpu(ec->priv.size)); - - dev_dbg(tplg->dev, "ASoC: adding enum kcontrol %s size %d\n", ec->hdr.name, ec->items); - - kc->name = devm_kstrdup(tplg->dev, ec->hdr.name, GFP_KERNEL); - if (!kc->name) - return -ENOMEM; - kc->private_value = (long)se; - kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; - kc->access = le32_to_cpu(ec->hdr.access); - - /* we only support FL/FR channel mapping atm */ - se->reg = tplg_chan_get_reg(tplg, ec->channel, SNDRV_CHMAP_FL); - se->shift_l = tplg_chan_get_shift(tplg, ec->channel, SNDRV_CHMAP_FL); - se->shift_r = tplg_chan_get_shift(tplg, ec->channel, SNDRV_CHMAP_FR); - - se->mask = le32_to_cpu(ec->mask); - - switch (le32_to_cpu(ec->hdr.ops.info)) { - case SND_SOC_TPLG_CTL_ENUM_VALUE: - case SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE: - err = soc_tplg_denum_create_values(tplg, se, ec); - if (err < 0) { - dev_err(tplg->dev, "ASoC: could not create values for %s\n", ec->hdr.name); - return err; - } - fallthrough; - case SND_SOC_TPLG_CTL_ENUM: - case SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE: - case SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT: - err = soc_tplg_denum_create_texts(tplg, se, ec); - if (err < 0) { - dev_err(tplg->dev, "ASoC: could not create texts for %s\n", ec->hdr.name); - return err; - } - break; - default: - dev_err(tplg->dev, "ASoC: invalid enum control type %d for %s\n", - ec->hdr.ops.info, ec->hdr.name); - return -EINVAL; - } - - /* map io handlers */ - err = soc_tplg_kcontrol_bind_io(&ec->hdr, kc, tplg); - if (err) { - soc_control_err(tplg, &ec->hdr, ec->hdr.name); - return err; - } - - /* pass control to driver for optional further init */ - return soc_tplg_control_load(tplg, kc, &ec->hdr); -} - -static int soc_tplg_control_dbytes_create(struct soc_tplg *tplg, struct snd_kcontrol_new *kc) -{ - struct snd_soc_tplg_bytes_control *be; - struct soc_bytes_ext *sbe; - int err; - - be = (struct snd_soc_tplg_bytes_control *)tplg->pos; - - /* validate kcontrol */ - if (strnlen(be->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN) - return -EINVAL; - - sbe = devm_kzalloc(tplg->dev, sizeof(*sbe), GFP_KERNEL); - if (!sbe) - return -ENOMEM; - - tplg->pos += (sizeof(struct snd_soc_tplg_bytes_control) + le32_to_cpu(be->priv.size)); - - dev_dbg(tplg->dev, "ASoC: adding bytes kcontrol %s with access 0x%x\n", - be->hdr.name, be->hdr.access); - - kc->name = devm_kstrdup(tplg->dev, be->hdr.name, GFP_KERNEL); - if (!kc->name) - return -ENOMEM; - kc->private_value = (long)sbe; - kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; - kc->access = le32_to_cpu(be->hdr.access); - - sbe->max = le32_to_cpu(be->max); - - /* map standard io handlers and check for external handlers */ - err = soc_tplg_kcontrol_bind_io(&be->hdr, kc, tplg); - if (err) { - soc_control_err(tplg, &be->hdr, be->hdr.name); - return err; - } - - /* pass control to driver for optional further init */ - return soc_tplg_control_load(tplg, kc, &be->hdr); -} - static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg, struct snd_soc_tplg_dapm_widget *w) { From patchwork Thu Jun 27 10:18:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714112 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D822B13C9CA for ; Thu, 27 Jun 2024 10:18:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483518; cv=none; b=NFkSSsl2QewXiTzO5W+8Vv5JFW5gJB+wDpX3IB4054rO7b0R9cKgBnOeB5kvWwBfxtPZ+esP9M4efF0a0fUI2yqOYhaNMgR7k1IfdUcDEu6bcF/3yG9zqmZqyF0oO8Q9ABDPBlDUCidcfwPh+nWjwWEZa0ihOB3/mExLQ7Bx1U0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483518; c=relaxed/simple; bh=dv9pKybRB6RToP7aV6WyFJADAdrtGqxesQBR9Rf5FDI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=QTxwM9UUywb9aGwULUFpJo5siIvI12bw2xNnOD+HREurwn1LCBTv32lub1d/2u5eORh1vI+a+aukFy2dr5NTqU4C9VLzsRd0zpxI3e6mZBUvpne61LvdwG0YipIB0ANZGSOIJQQRXJ7Ugph2m2WGZn4grwbvDKYQLsl/F3bEeCM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NCskipD3; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NCskipD3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483517; x=1751019517; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dv9pKybRB6RToP7aV6WyFJADAdrtGqxesQBR9Rf5FDI=; b=NCskipD3dyn0tpiU9YqWVdKjAHicxWfcW2kjje+wiMB05nXg0i3wCchg eUH8QM9tMbbAvhvD7AsgdWbEf/bcxXfJ29sAUfnk9RoHzySqar/rJTHSt J8qXgacqKT6AZ39Sp8eRIzBwzC6qLEjgFG24Ile3juixrJF74vlGOv2mW oh8shYCjUprbvZUhQUQm9+q3+bEFqsfWxjwrwxVwG1BDvE3DU4BmGjPWS wbOBTjrAGYyyxYuO4zr51HRyDQX+I3+ZBxCo1ZHcLBgvHcSxo3i0ZVmeb THqbDLlocT9EvyNo5o5BVFxoAMe0EiJEhPnB9MvlWwFv31qbvFAKD5H2h g==; X-CSE-ConnectionGUID: h1w4hlIGQYGmliPqTwjekQ== X-CSE-MsgGUID: jlcKDn6cShy9Ef+cHABXpg== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487621" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487621" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:37 -0700 X-CSE-ConnectionGUID: Bd4DWy3eSYOM58OvcuD1BQ== X-CSE-MsgGUID: kG9bg0VXTc+tah28DqMzBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45080019" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:35 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 11/13] ASoC: topology: Unify code for creating standalone and widget bytes control Date: Thu, 27 Jun 2024 12:18:48 +0200 Message-Id: <20240627101850.2191513-12-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Code used to create standalone and widget bytes control is same, with exception that in standalone case dynamic object needs to be registered and control created directly. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 51 +++++++--------------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 5aab1df7e2606..b10a6be8f75b3 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -875,41 +875,21 @@ static int soc_tplg_control_dbytes_create(struct soc_tplg *tplg, struct snd_kcon static int soc_tplg_dbytes_create(struct soc_tplg *tplg, size_t size) { - struct snd_soc_tplg_bytes_control *be; + struct snd_kcontrol_new kc = {0}; struct soc_bytes_ext *sbe; - struct snd_kcontrol_new kc; - int ret = 0; + int ret; if (soc_tplg_check_elem_count(tplg, sizeof(struct snd_soc_tplg_bytes_control), 1, size, "mixer bytes")) return -EINVAL; - be = (struct snd_soc_tplg_bytes_control *)tplg->pos; - - /* validate kcontrol */ - if (strnlen(be->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == - SNDRV_CTL_ELEM_ID_NAME_MAXLEN) - return -EINVAL; - - sbe = devm_kzalloc(tplg->dev, sizeof(*sbe), GFP_KERNEL); - if (sbe == NULL) - return -ENOMEM; - - tplg->pos += (sizeof(struct snd_soc_tplg_bytes_control) + - le32_to_cpu(be->priv.size)); - - dev_dbg(tplg->dev, - "ASoC: adding bytes kcontrol %s with access 0x%x\n", - be->hdr.name, be->hdr.access); - - memset(&kc, 0, sizeof(kc)); - kc.name = be->hdr.name; - kc.private_value = (long)sbe; - kc.iface = SNDRV_CTL_ELEM_IFACE_MIXER; - kc.access = le32_to_cpu(be->hdr.access); + ret = soc_tplg_control_dbytes_create(tplg, &kc); + if (ret) + return ret; - sbe->max = le32_to_cpu(be->max); + /* register dynamic object */ + sbe = (struct soc_bytes_ext *)&kc.private_value; INIT_LIST_HEAD(&sbe->dobj.list); sbe->dobj.type = SND_SOC_DOBJ_BYTES; @@ -917,26 +897,13 @@ static int soc_tplg_dbytes_create(struct soc_tplg *tplg, size_t size) if (tplg->ops) sbe->dobj.unload = tplg->ops->control_unload; - /* map io handlers */ - ret = soc_tplg_kcontrol_bind_io(&be->hdr, &kc, tplg); - if (ret) { - soc_control_err(tplg, &be->hdr, be->hdr.name); - goto err; - } - - /* pass control to driver for optional further init */ - ret = soc_tplg_control_load(tplg, &kc, &be->hdr); - if (ret < 0) - goto err; - - /* register control here */ + /* create control directly */ ret = soc_tplg_add_kcontrol(tplg, &kc, &sbe->dobj.control.kcontrol); if (ret < 0) - goto err; + return ret; list_add(&sbe->dobj.list, &tplg->comp->dobj_list); -err: return ret; } From patchwork Thu Jun 27 10:18:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714113 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25A5313C9CA for ; Thu, 27 Jun 2024 10:18:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483520; cv=none; b=VBNc7MpMQDOHQvxC4aUneg7UgDHAWJhb91QyZSCbVD1coTWJYU19IwCHRuZKkAZxR7iY73qxOtK/4mmqbOAhyCR0+jTAD1FJ/rYZc94oNoknNBBEoltHFnWzLOvNFYKeiI5jW5fOMSeylXx0WLJ/hhG/8zOYmbNuSzwPKkt7BT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483520; c=relaxed/simple; bh=t1XJ5w4SobJyrTf45CYol5GsS11FIxdu+98QxmxPPFg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=XVwtTmeaSMMd115wc2dNgD6aoowgSgFaXzLk5dJOzB1KxqKQ3Gvpd5O1rWtaslKGDx25Fv5ZpPwqiLoJCagkRWG4ZXAk22f/ZSJcVOV7uW9P0CPv1Z4Krr48WIO1qrrojlAl1R6Gc7iZydIgkQmdeZW/taoazU8ZpxNbaigcUdg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ggp6f7SZ; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ggp6f7SZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483519; x=1751019519; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=t1XJ5w4SobJyrTf45CYol5GsS11FIxdu+98QxmxPPFg=; b=Ggp6f7SZdT9Gu6vM785VAu59l61UQAEZH4cCKoU26ep6/k4JXyWc+E3j p7f1iw/7xG8xmiQvJZDEx8ymXFp81QifnzUjMbiQBHbwR5xiCRC0AkdgF LwnpVFKgBDD2pUOmrmI1BhxwK56jTqNaVOxmtbmbVBf+se+3X3CcY5O1X nLOlSE4lhlgVkQX4GEycxWIyNl69B9QmyNcYukYE+IktA3g7JKHVoCfIk ZA8Bt+Zq02S8LJ+rqtWsrtXO5xBh8I1e0oTUbnzKDmMuXA2x8WYcFnSzm dGR4PL5REyJ6y1IJ50mL6bcrDqaaiHWLDECvdSnXHzX3+EpT5VActiyVS g==; X-CSE-ConnectionGUID: oobKEpFlQ7KErgaAlYM8tg== X-CSE-MsgGUID: bT8DyRDnSvWiE1v90p3Elg== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487627" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487627" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:39 -0700 X-CSE-ConnectionGUID: KfxSmJAgTtqP3L9IGSFroA== X-CSE-MsgGUID: xLSL77ErT2GA16Capnx4qA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45080022" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:37 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 12/13] ASoC: topology: Unify code for creating standalone and widget mixer control Date: Thu, 27 Jun 2024 12:18:49 +0200 Message-Id: <20240627101850.2191513-13-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Code used to create standalone and widget mixer control is same, with exception that in standalone case dynamic object needs to be registered and control created directly. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 66 ++++++---------------------------------- 1 file changed, 9 insertions(+), 57 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index b10a6be8f75b3..5fde448082467 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -909,49 +909,21 @@ static int soc_tplg_dbytes_create(struct soc_tplg *tplg, size_t size) static int soc_tplg_dmixer_create(struct soc_tplg *tplg, size_t size) { - struct snd_soc_tplg_mixer_control *mc; + struct snd_kcontrol_new kc = {0}; struct soc_mixer_control *sm; - struct snd_kcontrol_new kc; - int ret = 0; + int ret; if (soc_tplg_check_elem_count(tplg, sizeof(struct snd_soc_tplg_mixer_control), 1, size, "mixers")) return -EINVAL; - mc = (struct snd_soc_tplg_mixer_control *)tplg->pos; - - /* validate kcontrol */ - if (strnlen(mc->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == - SNDRV_CTL_ELEM_ID_NAME_MAXLEN) - return -EINVAL; - - sm = devm_kzalloc(tplg->dev, sizeof(*sm), GFP_KERNEL); - if (sm == NULL) - return -ENOMEM; - tplg->pos += (sizeof(struct snd_soc_tplg_mixer_control) + - le32_to_cpu(mc->priv.size)); - - dev_dbg(tplg->dev, - "ASoC: adding mixer kcontrol %s with access 0x%x\n", - mc->hdr.name, mc->hdr.access); - - memset(&kc, 0, sizeof(kc)); - kc.name = mc->hdr.name; - kc.private_value = (long)sm; - kc.iface = SNDRV_CTL_ELEM_IFACE_MIXER; - kc.access = le32_to_cpu(mc->hdr.access); - - /* we only support FL/FR channel mapping atm */ - sm->reg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FL); - sm->rreg = tplg_chan_get_reg(tplg, mc->channel, SNDRV_CHMAP_FR); - sm->shift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FL); - sm->rshift = tplg_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FR); + ret = soc_tplg_control_dmixer_create(tplg, &kc); + if (ret) + return ret; - sm->max = le32_to_cpu(mc->max); - sm->min = le32_to_cpu(mc->min); - sm->invert = le32_to_cpu(mc->invert); - sm->platform_max = le32_to_cpu(mc->platform_max); + /* register dynamic object */ + sm = (struct soc_mixer_control *)&kc.private_value; INIT_LIST_HEAD(&sm->dobj.list); sm->dobj.type = SND_SOC_DOBJ_MIXER; @@ -959,33 +931,13 @@ static int soc_tplg_dmixer_create(struct soc_tplg *tplg, size_t size) if (tplg->ops) sm->dobj.unload = tplg->ops->control_unload; - /* map io handlers */ - ret = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc, tplg); - if (ret) { - soc_control_err(tplg, &mc->hdr, mc->hdr.name); - goto err; - } - - /* create any TLV data */ - ret = soc_tplg_create_tlv(tplg, &kc, &mc->hdr); - if (ret < 0) { - dev_err(tplg->dev, "ASoC: failed to create TLV %s\n", mc->hdr.name); - goto err; - } - - /* pass control to driver for optional further init */ - ret = soc_tplg_control_load(tplg, &kc, &mc->hdr); - if (ret < 0) - goto err; - - /* register control here */ + /* create control directly */ ret = soc_tplg_add_kcontrol(tplg, &kc, &sm->dobj.control.kcontrol); if (ret < 0) - goto err; + return ret; list_add(&sm->dobj.list, &tplg->comp->dobj_list); -err: return ret; } From patchwork Thu Jun 27 10:18:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13714114 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DFFE13C9CA for ; Thu, 27 Jun 2024 10:18:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483522; cv=none; b=qYtsj5XJ5oPG9kBbkLYc/F0cRVAPShG7JYwXquJ1zRnPDFF4ot+koKbjH6musK89L9O5lvKHGhGzAh9Sq4jkH5/ZEZWnd9t1MsJ0qpzQlB3cHeA2RUW9U4ww/LPhinpOkhBbmmO6hQpIE7uhP/veVF0bSzkkg5utVQ0oYKskmRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719483522; c=relaxed/simple; bh=TRfbs6tOEaK/do77yThChQst8aG6N6RDwTxuk2T94MA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=s5jgaWXEOqWjOhZjYl5kuqbJOWiyU7Dshq/Y1k/bw/5C9aEWyHRT1xBzgpEt3rfGLsJzW2Yl6BRrhcAArKq3ys+I9Dcg9QJoIZcb7JLHNRZgrje6VJFYoAON73LKaCzvXP4UlgfKhsa7gKCxXpdBIgGhc6Z1zHhPb7PQyC/caw4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dZd9UKPk; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dZd9UKPk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719483521; x=1751019521; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TRfbs6tOEaK/do77yThChQst8aG6N6RDwTxuk2T94MA=; b=dZd9UKPk2vXsJr+fz5xyufMuTdvfLHAlZtSQrxkmCR3t0zQxIoAuYocK slbD0sjfW6auodbOKAfaHluXRwSPe/50KQXt8c93bThUcwj3lnTv6eSLn d6RuGFC5AleqTCKNrBSd7Ni21n3RcMz/G5QYoJxZpwEqqmldPS+yVQsGq skXtLZtQ9+cxUm7spD1DEH2Sk/Q+sWPCmnf9++i0OmtuEfm3b6PBkvL2D QaOWrXtfKI7Hjp5XYHjHlXFqpp3LSFUh6xD2A7M5oHQWM3TXcR+KJuPxw OVKIizVZph2dQpe5TgxBtl0e9/z/qFq+3jsPrjkZoQ1HcbI9lq+8yB/k+ g==; X-CSE-ConnectionGUID: Fzlgrw+fTCyiReRBxbdJTQ== X-CSE-MsgGUID: YJ6iwZH/T4SgeZu8jPP2Qw== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="19487633" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="19487633" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:18:41 -0700 X-CSE-ConnectionGUID: 3ktgrOA2QvWHYa1z6Ad01Q== X-CSE-MsgGUID: LYwgNeKGQXWJfK1H3ZLtvw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="45080026" Received: from dev2.igk.intel.com ([10.237.148.94]) by orviesa008.jf.intel.com with ESMTP; 27 Jun 2024 03:18:39 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 13/13] ASoC: topology: Unify code for creating standalone and widget enum control Date: Thu, 27 Jun 2024 12:18:50 +0200 Message-Id: <20240627101850.2191513-14-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> References: <20240627101850.2191513-1-amadeuszx.slawinski@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Code used to create standalone and widget enum control is same, with exception that in standalone case dynamic object needs to be registered and control created directly. Signed-off-by: Amadeusz Sławiński --- sound/soc/soc-topology.c | 86 +++++----------------------------------- 1 file changed, 9 insertions(+), 77 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 5fde448082467..af5d42b57be7e 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -943,46 +943,21 @@ static int soc_tplg_dmixer_create(struct soc_tplg *tplg, size_t size) static int soc_tplg_denum_create(struct soc_tplg *tplg, size_t size) { - struct snd_soc_tplg_enum_control *ec; + struct snd_kcontrol_new kc = {0}; struct soc_enum *se; - struct snd_kcontrol_new kc; - int ret = 0; + int ret; if (soc_tplg_check_elem_count(tplg, sizeof(struct snd_soc_tplg_enum_control), 1, size, "enums")) return -EINVAL; - ec = (struct snd_soc_tplg_enum_control *)tplg->pos; - - /* validate kcontrol */ - if (strnlen(ec->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == - SNDRV_CTL_ELEM_ID_NAME_MAXLEN) - return -EINVAL; - - se = devm_kzalloc(tplg->dev, (sizeof(*se)), GFP_KERNEL); - if (se == NULL) - return -ENOMEM; - - tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) + - le32_to_cpu(ec->priv.size)); - - dev_dbg(tplg->dev, "ASoC: adding enum kcontrol %s size %d\n", - ec->hdr.name, ec->items); - - memset(&kc, 0, sizeof(kc)); - kc.name = ec->hdr.name; - kc.private_value = (long)se; - kc.iface = SNDRV_CTL_ELEM_IFACE_MIXER; - kc.access = le32_to_cpu(ec->hdr.access); - - se->reg = tplg_chan_get_reg(tplg, ec->channel, SNDRV_CHMAP_FL); - se->shift_l = tplg_chan_get_shift(tplg, ec->channel, - SNDRV_CHMAP_FL); - se->shift_r = tplg_chan_get_shift(tplg, ec->channel, - SNDRV_CHMAP_FR); + ret = soc_tplg_control_denum_create(tplg, &kc); + if (ret) + return ret; - se->mask = le32_to_cpu(ec->mask); + /* register dynamic object */ + se = (struct soc_enum *)kc.private_value; INIT_LIST_HEAD(&se->dobj.list); se->dobj.type = SND_SOC_DOBJ_ENUM; @@ -990,56 +965,13 @@ static int soc_tplg_denum_create(struct soc_tplg *tplg, size_t size) if (tplg->ops) se->dobj.unload = tplg->ops->control_unload; - switch (le32_to_cpu(ec->hdr.ops.info)) { - case SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE: - case SND_SOC_TPLG_CTL_ENUM_VALUE: - ret = soc_tplg_denum_create_values(tplg, se, ec); - if (ret < 0) { - dev_err(tplg->dev, - "ASoC: could not create values for %s\n", - ec->hdr.name); - goto err; - } - fallthrough; - case SND_SOC_TPLG_CTL_ENUM: - case SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE: - case SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT: - ret = soc_tplg_denum_create_texts(tplg, se, ec); - if (ret < 0) { - dev_err(tplg->dev, - "ASoC: could not create texts for %s\n", - ec->hdr.name); - goto err; - } - break; - default: - ret = -EINVAL; - dev_err(tplg->dev, - "ASoC: invalid enum control type %d for %s\n", - ec->hdr.ops.info, ec->hdr.name); - goto err; - } - - /* map io handlers */ - ret = soc_tplg_kcontrol_bind_io(&ec->hdr, &kc, tplg); - if (ret) { - soc_control_err(tplg, &ec->hdr, ec->hdr.name); - goto err; - } - - /* pass control to driver for optional further init */ - ret = soc_tplg_control_load(tplg, &kc, &ec->hdr); - if (ret < 0) - goto err; - - /* register control here */ + /* create control directly */ ret = soc_tplg_add_kcontrol(tplg, &kc, &se->dobj.control.kcontrol); if (ret < 0) - goto err; + return ret; list_add(&se->dobj.list, &tplg->comp->dobj_list); -err: return ret; }