From patchwork Wed Jun 20 11:08:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Periyasamy X-Patchwork-Id: 10477055 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 718A9600F6 for ; Wed, 20 Jun 2018 11:20:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E0C42879C for ; Wed, 20 Jun 2018 11:20:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5072728E1D; Wed, 20 Jun 2018 11:20:04 +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 2C27A2879C for ; Wed, 20 Jun 2018 11:20:02 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8074A26720C; Wed, 20 Jun 2018 13:20:00 +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 0F47E2673CB; Wed, 20 Jun 2018 13:19:58 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by alsa0.perex.cz (Postfix) with ESMTP id 80EFE266E0E for ; Wed, 20 Jun 2018 13:19:53 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2018 04:19:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,247,1526367600"; d="scan'208";a="50464278" Received: from mtbf-optiplex-9010.iind.intel.com ([10.223.96.13]) by orsmga007.jf.intel.com with ESMTP; 20 Jun 2018 04:19:49 -0700 From: Sriram Periyasamy To: ALSA ML , Mark Brown Date: Wed, 20 Jun 2018 16:38:21 +0530 Message-Id: <1529492902-6600-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] [RESEND][PATCH] 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 Acked-by: Vinod Koul --- sound/soc/codecs/hdac_hdmi.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 84f7a7a36e4b..7eb5a7138483 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -32,6 +32,7 @@ #include #include "../../hda/local.h" #include "hdac_hdmi.h" +#include #define NAME_SIZE 32 @@ -83,6 +84,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 +143,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) @@ -159,6 +164,7 @@ static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm, struct hdac_hdmi_port *port, bool is_connect) { struct hdac_ext_device *edev = port->pin->edev; + int cmd, err; if (is_connect) snd_soc_dapm_enable_pin(port->dapm, port->jack_pin); @@ -166,6 +172,29 @@ static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm, snd_soc_dapm_disable_pin(port->dapm, port->jack_pin); if (is_connect) { + /* 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) { + cmd = snd_hdac_regmap_encode_verb(port->pin->nid, + AC_VERB_SET_CONNECT_SEL); + err = snd_hdac_regmap_write_raw(&edev->hdev, cmd, + port->pin->conn_index - 1); + if (err < 0) { + dev_err(&edev->hdev.dev, + "pin %d conn select index fail %d\n", + port->pin->nid, err); + return; + } + } + /* * Report Jack connect event when a device is connected * for the first time where same PCM is attached to multiple @@ -903,6 +932,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.