From patchwork Wed Jul 5 10:17:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 9826269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ACBF360317 for ; Wed, 5 Jul 2017 10:17:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13A9824603 for ; Wed, 5 Jul 2017 10:17:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 083DE2582C; Wed, 5 Jul 2017 10:17:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6380B24603 for ; Wed, 5 Jul 2017 10:17:27 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2C673266ECA; Wed, 5 Jul 2017 12:17:25 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 91C2B266ECE; Wed, 5 Jul 2017 12:17:24 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 7FFE526698E for ; Wed, 5 Jul 2017 12:17:20 +0200 (CEST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 453A3ABD9; Wed, 5 Jul 2017 10:17:20 +0000 (UTC) Date: Wed, 05 Jul 2017 12:17:18 +0200 Message-ID: From: Takashi Iwai To: Arnaud Pouliquen In-Reply-To: <6a520509-962d-fc8a-45f6-512fde8034df@st.com> References: <87eftvmhir.wl%kuninori.morimoto.gx@renesas.com> <6a520509-962d-fc8a-45f6-512fde8034df@st.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.2 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: "Jon Medhurst \(Tixy\)" , Simon , Linux-ALSA , Kuninori Morimoto , Liam Girdwood , "linux-renesas-soc@vger.kernel.org" , Mark Brown , PhilippZabel , Colin Ian King , Vincent ABRIOU Subject: Re: [alsa-devel] [PATCH] ASoC: hdmi-codec: hdmi_codec_priv includes snd_kcontrol_new X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 05 Jul 2017 11:29:43 +0200, Arnaud Pouliquen wrote: > > > > On 07/05/2017 10:40 AM, Takashi Iwai wrote: > > On Wed, 05 Jul 2017 10:15:35 +0200, > > Kuninori Morimoto wrote: > >> > >> > >> From: Kuninori Morimoto > >> > >> Current hdmi-codec driver is using hdmi_controls for "ELD" control. > >> But, hdmi-codec driver might be used from many HDMIs. In such case, > >> they will use same "ELD" name and kernel will indicate below error. > >> > >> xxx: control x:x:x:ELD:x is already present > >> > >> hdmi_controls will be registered in soc_probe_component(), and we can > >> replace it by component driver probe function. > >> > >> This patch registers current hdmi_controls in new hdmi_probe(). > >> If hdmi-codec is used from only 1 device, it will use "ELD" as control name > >> (We can keep compatibility). > >> If hdmi-codec is used from many devices, it will use "ELD.x" as control name. > > > > The de facto standard way as HD-audio does is to pass the device > > number of each ELD control as same as the corresponding PCM stream > > number. > > > > > > thanks, > > > > Takashi > > > In theory, hdmi_codec_pcm_new already does the job. > snd_pcm_add_chmap_ctls instantiates the controls using PCM device ID. So > you should observe (with amixer) 2 controls with same name but not same > device ID. Indeed, we can add each ELD control there like a (totally untested) patch below. thanks, Takashi diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 22ed0dc88f0a..13d9cf5b1831 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -399,16 +399,13 @@ static int hdmi_codec_chmap_ctl_get(struct snd_kcontrol *kcontrol, return 0; } - -static const struct snd_kcontrol_new hdmi_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, - }, +static const struct snd_kcontrol_new hdmi_eld_ctl = { + .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, }; static int hdmi_codec_new_stream(struct snd_pcm_substream *substream, @@ -668,6 +665,7 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, { struct snd_soc_dai_driver *drv = dai->driver; struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + struct snd_kcontrol *kctl; int ret; dev_dbg(dai->dev, "%s()\n", __func__); @@ -686,7 +684,12 @@ 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; - return 0; + /* 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; + kctl->id.device = rtd->pcm->device; + return snd_ctl_add(rtd->card->snd_card, kctl); } static struct snd_soc_dai_driver hdmi_i2s_dai = { @@ -732,8 +735,6 @@ static int hdmi_of_xlate_dai_id(struct snd_soc_component *component, static struct snd_soc_codec_driver hdmi_codec = { .component_driver = { - .controls = hdmi_controls, - .num_controls = ARRAY_SIZE(hdmi_controls), .dapm_widgets = hdmi_widgets, .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets), .dapm_routes = hdmi_routes,