Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp368158pxj; Fri, 7 May 2021 10:20:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4r7oLfIv7pxgacXtEvrzm1yriGAvZ315H1gGKlyT9Ys3WgeYQduWiI8A+Oh2/PndekER9 X-Received: by 2002:a17:902:6ac6:b029:ee:e9ac:5a19 with SMTP id i6-20020a1709026ac6b02900eee9ac5a19mr10878062plt.43.1620408017750; Fri, 07 May 2021 10:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620408017; cv=none; d=google.com; s=arc-20160816; b=q3BPzgB2qS0vt148xgZKAXAEpVF1xBk4y+NcyNZras3W4CxgmCby5Xr6K3/aIeuEME VBJ0dFo1eejtv/UWY7G5jZjSb6r0z+Xyb3CJ7VBCq6nbF2wVZ2B20mRn7OQJ6U05K4JB zgX+vM1dNpGnA+7YoG13NmArhVfj0tLhngffYv8nU8rfeHBb9DHes0JBE4BXiv3MZAWu 3P3zl67MZweVAX9ygd9okybwgaGzSE2n6AfuF0+dqbfCU/U6G5vG4C6Ta44qbsJJPt7U zBtS0W9/9eZyGt5+NlGstzCgKbXl0OyvBlFFWFwKdSoeQhANCoHtFLwcl+glMoZVES7b uWKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=p4zNkQ6XqSu531sqVPafbjFGIX0E1EULqXXdj3asw88=; b=Lg7Ioyl5xe43tIMRk4Umgtc56tq9Bq4jWiYQl9j8Dz0Wi/FMYREInx/RmziWQlVU2F ORGER789QnCrjVFoxQELLtkasPThed0fgC0gWQBMtn8ruXdKNeTGju/Cj+nYOp+pKNXp QUJHW0iz0BdUKMR70meUHbPiv5y5K90ZGe1/e/+ZJerMZ7jDYVi1iMroazjvTbMnXN4e uoVB0NkbefGhEalikJA5eOr9C1zZAMh7/NuxVzNN0zfjNu+c/mRYQtQWkaAtBfdU1dR+ fQNhpLPI2n7Ilya5QrCUabIyGmWJvfdLNw4eQ1oWZfvuJJ50F/OTXov336BpKxiV+MpJ GAGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=b+o1gs9k; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=sfgEYNl3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si14680985pjs.23.2021.05.07.10.20.05; Fri, 07 May 2021 10:20:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=b+o1gs9k; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=sfgEYNl3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236850AbhEGOF4 (ORCPT + 99 others); Fri, 7 May 2021 10:05:56 -0400 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:39111 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236344AbhEGOFy (ORCPT ); Fri, 7 May 2021 10:05:54 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id A409BC82; Fri, 7 May 2021 10:04:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 07 May 2021 10:04:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=p4zNkQ6XqSu53 1sqVPafbjFGIX0E1EULqXXdj3asw88=; b=b+o1gs9kqt42h8FDXMFQBMaAq5EIY Y61zxCthjPYd0PYYRRmVFk4Y6hbhQSbyda3qcwLQ0W6UwbomliRnH3DnqesUPUox dn0v9KN5aYmE1zpMqK66JWUO8akYPvTTC58WSDoX3gMRDNhxe8kUeOEeKMusy4jr oPnYlbQ8G+JfCUFIEC+y5PldrOgBiePSU87UTJlDcW8aDzGA0oHLUPnwhC3dEWLD cLeVUiMCbKAQND18f3JGccjePbq/ONBi1C2uIlFfNycXFncEjsUgxonjV1iPXZOo zcxUmyZ0ja3I+eYItvRAKsXgIH3cErYa2XsWGfs9qSyLj3hj3u9XX4FEQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=p4zNkQ6XqSu531sqVPafbjFGIX0E1EULqXXdj3asw88=; b=sfgEYNl3 KEYOaerCWT0EZO7ibWnt8UIbcFyT7qlk56JtzvjvAv8caTmTPrxq84a+oaNFQiKK 3tPXP50iyFZeerowCaIQpT8+aaGScaFWZ78sQ5cDXKAQte/lMjwV7kP/kOjxv84r nrwAiHbFNGaeSdqn/PAaSjOV2TbgDselj/+5sGMsZgFeHKWVDhzNc902tYBK9zAh K1MmlV1eCexg8rjJOtYQP3km3ppxyoa9/JIWxBl+0Z91XHOKoeUB0Qe1ojGTSKlE hN6Jy4uoBd8lSjBUIyuhN21Nvx+AFSemwDhaWYcFc9BvnxFBoignlgq5iKO97suW sgU0c2KCA0lXqw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdegvddgjedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepudenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 May 2021 10:04:51 -0400 (EDT) From: Maxime Ripard To: Mark Brown , Takashi Iwai , Liam Girdwood , Jaroslav Kysela , dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard Cc: Nicolas Saenz Julienne , Rob Herring , devicetree@vger.kernel.org, alsa-devel@alsa-project.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, Maxime Ripard , linux-kernel@vger.kernel.org, Dave Stevenson , Phil Elwell , Tim Gover , Dom Cobley , Daniel Vetter , linux-rpi-kernel@lists.infradead.org, Eric Anholt Subject: [PATCH 02/11] ASoC: hdmi-codec: Rework to support more controls Date: Fri, 7 May 2021 16:03:25 +0200 Message-Id: <20210507140334.204865-3-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507140334.204865-1-maxime@cerno.tech> References: <20210507140334.204865-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We're going to add more controls to support the IEC958 output, so let's rework the control registration a bit to support more of them. Signed-off-by: Maxime Ripard --- sound/soc/codecs/hdmi-codec.c | 43 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 422539f933de..bc0d695d2df0 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -621,21 +621,23 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\ SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) -static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, - struct snd_soc_dai *dai) -{ - struct snd_soc_dai_driver *drv = dai->driver; - struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); - struct snd_kcontrol *kctl; - struct snd_kcontrol_new hdmi_eld_ctl = { - .access = SNDRV_CTL_ELEM_ACCESS_READ | - SNDRV_CTL_ELEM_ACCESS_VOLATILE, +struct snd_kcontrol_new hdmi_codec_controls[] = { + { + .access = (SNDRV_CTL_ELEM_ACCESS_READ | + SNDRV_CTL_ELEM_ACCESS_VOLATILE), .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "ELD", .info = hdmi_eld_ctl_info, .get = hdmi_eld_ctl_get, - .device = rtd->pcm->device, - }; + }, +}; + +static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_dai *dai) +{ + struct snd_soc_dai_driver *drv = dai->driver; + struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + unsigned int i; int ret; ret = snd_pcm_add_chmap_ctls(rtd->pcm, SNDRV_PCM_STREAM_PLAYBACK, @@ -652,12 +654,21 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps; hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; - /* add ELD ctl with the device number corresponding to the PCM stream */ - kctl = snd_ctl_new1(&hdmi_eld_ctl, dai->component); - if (!kctl) - return -ENOMEM; + for (i = 0; i < ARRAY_SIZE(hdmi_codec_controls); i++) { + struct snd_kcontrol *kctl; - return snd_ctl_add(rtd->card->snd_card, kctl); + /* add ELD ctl with the device number corresponding to the PCM stream */ + kctl = snd_ctl_new1(&hdmi_codec_controls[i], dai->component); + if (!kctl) + return -ENOMEM; + + kctl->id.device = rtd->pcm->device; + ret = snd_ctl_add(rtd->card->snd_card, kctl); + if (ret < 0) + return ret; + } + + return 0; } static int hdmi_dai_probe(struct snd_soc_dai *dai) -- 2.31.1