From: Takashi Iwai Subject: Re: [PATCH] ASoC: codec: hdac_hdmi: fix pin connections at cvt enable Date: Wed, 12 Jun 2019 14:12:40 +0200 Message-ID: References: <20190612115509.3400-1-kai.vehmanen@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 78B85F80791 for ; Wed, 12 Jun 2019 14:12:41 +0200 (CEST) In-Reply-To: <20190612115509.3400-1-kai.vehmanen@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: Kai Vehmanen Cc: libin.yang@intel.com, alsa-devel@alsa-project.org, broonie@kernel.org, pierre-louis.bossart@linux.intel.com List-Id: alsa-devel@alsa-project.org On Wed, 12 Jun 2019 13:55:09 +0200, Kai Vehmanen wrote: > > In display codecs supported by hdac_hdmi, the connection indices are > shared by all converters. At boot and resume from suspend, > the connection state may be reset to default values. > > In case of multiple connected pins (multiple monitors connected > with audio capability), routing and mute status of pins that > are not connected to any PCM, may interfere with other pins. > E.g. after resume from S3 with multiple monitors, unless > all converters are in active use, playback to some PCMs may > be muted due to the default settings of unrelated converters. > > Avoid this by ensuring all pin:cvt selections are correct > in codec whenever a converter is enabled for playback. > > Signed-off-by: Kai Vehmanen > --- > sound/soc/codecs/hdac_hdmi.c | 41 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c > index 660e0587f3999..bb87240d2fb22 100644 > --- a/sound/soc/codecs/hdac_hdmi.c > +++ b/sound/soc/codecs/hdac_hdmi.c > @@ -546,6 +546,39 @@ static struct hdac_hdmi_port *hdac_hdmi_get_port_from_cvt( > return NULL; > } > > +/** > + * Go through all converters and ensure connection is set to > + * the correct pin as set via kcontrols. > + */ > +static void hdac_hdmi_verify_connect_sel_all_pins(struct hdac_device *hdev) > +{ > + struct hdac_hdmi_port *port; > + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); > + struct hdac_hdmi_cvt *cvt; > + int cvt_idx = 0; > + int curr; > + > + list_for_each_entry(cvt, &hdmi->cvt_list, head) { > + port = hdac_hdmi_get_port_from_cvt(hdev, hdmi, cvt); > + if (port && port->pin) { > + curr = snd_hdac_codec_read(hdev, port->pin->nid, > + 0, AC_VERB_GET_CONNECT_SEL, > + 0); > + if (curr != cvt_idx) { > + snd_hdac_codec_write(hdev, > + port->pin->nid, 0, > + AC_VERB_SET_CONNECT_SEL, > + cvt_idx); > + dev_dbg(&hdev->dev, > + "%s: %s set connect %d -> %d\n", > + __func__, cvt->name, port->pin->nid, > + cvt_idx); You can simply restore all pins without reading. The read costs much more time than writes. thanks, Takashi