From patchwork Wed Jul 11 06:30:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Periyasamy X-Patchwork-Id: 10518825 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 496A86032C for ; Wed, 11 Jul 2018 06:36:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36FAB28684 for ; Wed, 11 Jul 2018 06:36:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B0F528DA1; Wed, 11 Jul 2018 06:36:01 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham 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 1D24728684 for ; Wed, 11 Jul 2018 06:35:59 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8F665267711; Wed, 11 Jul 2018 08:35:57 +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 EC7BC267712; Wed, 11 Jul 2018 08:35:54 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by alsa0.perex.cz (Postfix) with ESMTP id CBCA5267700 for ; Wed, 11 Jul 2018 08:35:50 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 23:35:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,337,1526367600"; d="scan'208";a="66028954" Received: from mtbf-optiplex-9010.iind.intel.com ([10.223.96.13]) by orsmga003.jf.intel.com with ESMTP; 10 Jul 2018 23:34:49 -0700 From: Sriram Periyasamy To: ALSA ML , Mark Brown Date: Wed, 11 Jul 2018 12:00:43 +0530 Message-Id: <1531290643-29312-1-git-send-email-sriramx.periyasamy@intel.com> X-Mailer: git-send-email 2.7.4 Cc: Takashi Iwai , Sriram Periyasamy , Guneshwor Singh , Liam Girdwood , Patches Audio , Jeeja KP , Sanyog Kale Subject: [alsa-devel] [PATCH v2] ASoC: hdac_hdmi: Program pin-port-mux during jack report event 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP During d3/d0 cycle, the connection selection index of all pins points to the default value. This needs to be restored to ensure audio is restored after d3/d0 cycle. So store the connection selection index and program it during jack report event which gets invoked in cases like d3/d0 cycle, hot plug detection when multiple displays are connected. Signed-off-by: Sriram Periyasamy Signed-off-by: Sanyog Kale Signed-off-by: Jeeja KP Signed-off-by: Guneshwor Singh --- v1 -> v2: - Runtime resume the device explicitly in order to use snd_hdac_codec_write() sound/soc/codecs/hdac_hdmi.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 84f7a7a36e4b..dd5863830eef 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -83,6 +83,7 @@ struct hdac_hdmi_pin { struct list_head head; hda_nid_t nid; bool mst_capable; + int conn_index; struct hdac_hdmi_port *ports; int num_ports; struct hdac_ext_device *edev; @@ -141,6 +142,9 @@ struct hdac_hdmi_priv { #define hdev_to_hdmi_priv(_hdev) ((to_ehdac_device(_hdev))->private_data) +static int hdac_hdmi_port_select_set(struct hdac_ext_device *edev, + struct hdac_hdmi_port *port); + static struct hdac_hdmi_pcm * hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi, struct hdac_hdmi_cvt *cvt) @@ -167,6 +171,30 @@ static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm, if (is_connect) { /* + * Increment the usage count to ensure that the device + * is runtime active to send verb across. + */ + pm_runtime_get_sync(&edev->hdev.dev); + + /* set the device if pin is mst_capable */ + if (hdac_hdmi_port_select_set(edev, port) < 0) { + dev_err(&edev->hdev.dev, + "port %d device select fail\n", port->id); + return; + } + + /* + * Restore the connection selection index of the + * respective pin. + */ + if (port->pin->conn_index > 0) + snd_hdac_codec_write(&edev->hdev, port->pin->nid, + 0, AC_VERB_SET_CONNECT_SEL, + port->pin->conn_index - 1); + + pm_runtime_put_sync(&edev->hdev.dev); + + /* * Report Jack connect event when a device is connected * for the first time where same PCM is attached to multiple * ports. @@ -903,6 +931,9 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol, } } + if (ucontrol->value.enumerated.item[0] > 0) + port->pin->conn_index = ucontrol->value.enumerated.item[0]; + /* * Jack status is not reported during device probe as the * PCMs are not registered by then. So report it here.