From patchwork Thu Jun 9 03:26:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ranjani Sridharan X-Patchwork-Id: 580693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D30F7C433EF for ; Thu, 9 Jun 2022 03:31:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 212D11FF6; Thu, 9 Jun 2022 05:30:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 212D11FF6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1654745496; bh=OwMqO5qYXuwwqtDPuaaXxPiB4AO+BT3PNka7zZiUegc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=thHFS905t0bX4d+1kE1zHxQoyGPXltg7eH2x2eZjaqc2GihMtRoT076W0h6BJWq94 QVShCGM9Z2Fn0CnYaiWZkuyu+4EUPtLngMaBsbHuxbthAStzbo21jQSGkN3MYHSEgC T0MLkWf8zCQ2TvzB3n+I4KibgN21QGFuQChq4JLE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EAADAF8053E; Thu, 9 Jun 2022 05:27:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 436E3F80520; Thu, 9 Jun 2022 05:27:38 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D738EF80520 for ; Thu, 9 Jun 2022 05:27:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D738EF80520 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="oA6f1D6U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654745236; x=1686281236; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OwMqO5qYXuwwqtDPuaaXxPiB4AO+BT3PNka7zZiUegc=; b=oA6f1D6U309k1lEzbGRNiRt2GRwAwHJ1VSBuumnZ5UJ9uvZavmXRJyo1 8E5NOO9LJ597Gzk2Cx3YEfyUGPekojHWzYDteLRg5XnU7+L75jimtjjS5 pm4XQw0HJ2OqIHl4kXlidEiKx3GGe4jdIxj91l0p/QI0pI69LJ6uv1m8v w81fVg2evE+VigicARlfsn0IAEFVRA0vFNlLgsfwRqJVxLB3RPGd/81YU xDVDwkfi7W1N0fRe2jr3KJvHa+ByIKJRYtPqZSeyOmYMLRHFaDMJQ8o7f ZYJPa5cKfXL1kwhT6+1hLaJFmKRK30S/gpwCtugu12Kv9ZNZzt7ZVJblT g==; X-IronPort-AV: E=McAfee;i="6400,9594,10372"; a="341219556" X-IronPort-AV: E=Sophos;i="5.91,287,1647327600"; d="scan'208";a="341219556" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2022 20:26:59 -0700 X-IronPort-AV: E=Sophos;i="5.91,287,1647327600"; d="scan'208";a="585260238" Received: from mandalag-mobl.amr.corp.intel.com (HELO rsridh2-mobl1.localdomain) ([10.254.38.40]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2022 20:26:59 -0700 From: Ranjani Sridharan To: alsa-devel@alsa-project.org Subject: [PATCH 08/23] ASoC: SOF: ipc4-topology: Add support for parsing mixer widgets Date: Wed, 8 Jun 2022 20:26:28 -0700 Message-Id: <20220609032643.916882-9-ranjani.sridharan@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609032643.916882-1-ranjani.sridharan@linux.intel.com> References: <20220609032643.916882-1-ranjani.sridharan@linux.intel.com> MIME-Version: 1.0 Cc: tiwai@suse.de, Bard Liao , Ranjani Sridharan , Pierre-Louis Bossart , broonie@kernel.org, Paul Olaru , =?utf-8?q?P=C3=A9t?= =?utf-8?q?er_Ujfalusi?= , Rander Wang X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add support for parsing and preparing mixer type widgets. Define the token ID's and the associated token arrays needed to parse these widgets. Co-developed-by: Rander Wang Signed-off-by: Rander Wang Co-developed-by: Bard Liao Signed-off-by: Bard Liao Signed-off-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Paul Olaru --- sound/soc/sof/ipc4-topology.c | 68 +++++++++++++++++++++++++++++++++++ sound/soc/sof/ipc4-topology.h | 12 +++++++ 2 files changed, 80 insertions(+) diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index 30549573bd34..35457fe4edd9 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -624,6 +624,35 @@ static int sof_ipc4_widget_setup_comp_pga(struct snd_sof_widget *swidget) return ret; } +static int sof_ipc4_widget_setup_comp_mixer(struct snd_sof_widget *swidget) +{ + struct snd_soc_component *scomp = swidget->scomp; + struct sof_ipc4_mixer *mixer; + int ret; + + dev_dbg(scomp->dev, "Updating IPC structure for %s\n", swidget->widget->name); + + mixer = kzalloc(sizeof(*mixer), GFP_KERNEL); + if (!mixer) + return -ENOMEM; + + swidget->private = mixer; + + /* The out_audio_fmt in topology is ignored as it is not required to be sent to the FW */ + ret = sof_ipc4_get_audio_fmt(scomp, swidget, &mixer->available_fmt, false); + if (ret) + goto err; + + ret = sof_ipc4_widget_setup_msg(swidget, &mixer->msg); + if (ret) + goto err; + + return 0; +err: + kfree(mixer); + return ret; +} + static void sof_ipc4_update_pipeline_mem_usage(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget, struct sof_ipc4_base_module_cfg *base_config) @@ -974,6 +1003,33 @@ static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget, return sof_ipc4_widget_assign_instance_id(sdev, swidget); } +static int sof_ipc4_prepare_mixer_module(struct snd_sof_widget *swidget, + struct snd_pcm_hw_params *fe_params, + struct snd_sof_platform_stream_params *platform_params, + struct snd_pcm_hw_params *pipeline_params, int dir) +{ + struct snd_soc_component *scomp = swidget->scomp; + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct sof_ipc4_mixer *mixer = swidget->private; + int ret; + + /* only 32bit is supported by mixer */ + mixer->available_fmt.ref_audio_fmt = &mixer->available_fmt.base_config->audio_fmt; + + /* output format is not required to be sent to the FW for mixer */ + ret = sof_ipc4_init_audio_fmt(sdev, swidget, &mixer->base_config, + NULL, pipeline_params, &mixer->available_fmt, + sizeof(mixer->base_config)); + if (ret < 0) + return ret; + + /* update pipeline memory usage */ + sof_ipc4_update_pipeline_mem_usage(sdev, swidget, &mixer->base_config); + + /* assign instance ID */ + return sof_ipc4_widget_assign_instance_id(sdev, swidget); +} + static enum sof_tokens host_token_list[] = { SOF_COMP_TOKENS, SOF_AUDIO_FMT_NUM_TOKENS, @@ -1011,6 +1067,14 @@ static enum sof_tokens pga_token_list[] = { SOF_COMP_EXT_TOKENS, }; +static enum sof_tokens mixer_token_list[] = { + SOF_COMP_TOKENS, + SOF_AUDIO_FMT_NUM_TOKENS, + SOF_IN_AUDIO_FORMAT_TOKENS, + SOF_AUDIO_FORMAT_BUFFER_SIZE_TOKENS, + SOF_COMP_EXT_TOKENS, +}; + static const struct sof_ipc_tplg_widget_ops tplg_ipc4_widget_ops[SND_SOC_DAPM_TYPE_COUNT] = { [snd_soc_dapm_aif_in] = {sof_ipc4_widget_setup_pcm, sof_ipc4_widget_free_comp_pcm, host_token_list, ARRAY_SIZE(host_token_list), NULL, @@ -1035,6 +1099,10 @@ static const struct sof_ipc_tplg_widget_ops tplg_ipc4_widget_ops[SND_SOC_DAPM_TY pga_token_list, ARRAY_SIZE(pga_token_list), NULL, sof_ipc4_prepare_gain_module, sof_ipc4_unprepare_generic_module}, + [snd_soc_dapm_mixer] = {sof_ipc4_widget_setup_comp_mixer, sof_ipc4_widget_free_comp, + mixer_token_list, ARRAY_SIZE(mixer_token_list), + NULL, sof_ipc4_prepare_mixer_module, + sof_ipc4_unprepare_generic_module}, }; const struct sof_ipc_tplg_ops ipc4_tplg_ops = { diff --git a/sound/soc/sof/ipc4-topology.h b/sound/soc/sof/ipc4-topology.h index 060123826db4..eebf46b24430 100644 --- a/sound/soc/sof/ipc4-topology.h +++ b/sound/soc/sof/ipc4-topology.h @@ -188,4 +188,16 @@ struct sof_ipc4_gain { struct sof_ipc4_msg msg; }; +/** + * struct sof_ipc4_mixer - mixer config data + * @base_config: IPC base config data + * @available_fmt: Available audio format + * @msg: IPC4 message struct containing header and data info + */ +struct sof_ipc4_mixer { + struct sof_ipc4_base_module_cfg base_config; + struct sof_ipc4_available_audio_format available_fmt; + struct sof_ipc4_msg msg; +}; + #endif