From patchwork Wed Dec 9 16:16:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Subhransu S. Prusty" X-Patchwork-Id: 7810401 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4462D9F350 for ; Wed, 9 Dec 2015 16:24:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F7B6204D8 for ; Wed, 9 Dec 2015 16:24:19 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D9141203DC for ; Wed, 9 Dec 2015 16:24:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E2233261B2A; Wed, 9 Dec 2015 17:24:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 09A58262631; Wed, 9 Dec 2015 17:18:25 +0100 (CET) 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 46F67262631; Wed, 9 Dec 2015 17:18:23 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by alsa0.perex.cz (Postfix) with ESMTP id CD8F2264F0F for ; Wed, 9 Dec 2015 17:15:33 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 09 Dec 2015 08:14:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,404,1444719600"; d="scan'208";a="837735940" Received: from subhransu-desktop.iind.intel.com ([10.223.96.57]) by orsmga001.jf.intel.com with ESMTP; 09 Dec 2015 08:14:44 -0800 From: "Subhransu S. Prusty" To: alsa-devel@alsa-project.org Date: Wed, 9 Dec 2015 21:46:21 +0530 Message-Id: <1449677781-7997-14-git-send-email-subhransu.s.prusty@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449677781-7997-1-git-send-email-subhransu.s.prusty@intel.com> References: <1449677405-7907-1-git-send-email-subhransu.s.prusty@intel.com> <1449677781-7997-1-git-send-email-subhransu.s.prusty@intel.com> Cc: tiwai@suse.de, lgirdwood@gmail.com, patches.audio@intel.com, broonie@kernel.org, Jeeja KP , Vinod Koul , "Subhransu S. Prusty" Subject: [alsa-devel] [PATCH v4 14/14] ASoC: hdac_hdmi: Fix to enable device configuration in hw_params 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 From: Jeeja KP User can keep the device open and with the device configuration done in pcm_open, this may fail. Anyway hw_params is the right place for this. So moving the configuration to hw_params and free in hw_free. Remove the redundant startup/shutdown ops. Signed-off-by: Jeeja KP Signed-off-by: Subhransu S. Prusty Signed-off-by: Vinod Koul --- sound/soc/codecs/hdac_hdmi.c | 100 ++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 58 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 03d18fb..cbd541a 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -375,52 +375,6 @@ static int hdac_hdmi_playback_prepare(struct snd_pcm_substream *substream, dai_map->pin->nid, dd->stream_tag, dd->format); } -static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai) -{ - struct hdac_ext_device *hdac = snd_soc_dai_get_drvdata(dai); - struct hdac_ext_dma_params *dd; - - if (dai->id > 0) { - dev_err(&hdac->hdac.dev, "Only one dai supported as of now\n"); - return -ENODEV; - } - - dd = kzalloc(sizeof(*dd), GFP_KERNEL); - if (!dd) - return -ENOMEM; - dd->format = snd_hdac_calc_stream_format(params_rate(hparams), - params_channels(hparams), params_format(hparams), - 24, 0); - - snd_soc_dai_set_dma_data(dai, substream, (void *)dd); - - return 0; -} - -static int hdac_hdmi_playback_cleanup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); - struct hdac_ext_dma_params *dd; - struct hdac_hdmi_priv *hdmi = edev->private_data; - struct hdac_hdmi_dai_pin_map *dai_map; - - dai_map = &hdmi->dai_map[dai->id]; - - snd_hdac_codec_write(&edev->hdac, dai_map->cvt->nid, 0, - AC_VERB_SET_CHANNEL_STREAMID, 0); - snd_hdac_codec_write(&edev->hdac, dai_map->cvt->nid, 0, - AC_VERB_SET_STREAM_FORMAT, 0); - - dd = (struct hdac_ext_dma_params *)snd_soc_dai_get_dma_data(dai, substream); - snd_soc_dai_set_dma_data(dai, substream, NULL); - - kfree(dd); - - return 0; -} - static int hdac_hdmi_enable_pin(struct hdac_ext_device *hdac, struct hdac_hdmi_dai_pin_map *dai_map) { @@ -532,8 +486,8 @@ static struct hdac_hdmi_pin *hdac_hdmi_get_pin_from_daistream( return NULL; } -static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) +static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai) { struct hdac_ext_device *hdac = snd_soc_dai_get_drvdata(dai); struct hdac_hdmi_priv *hdmi = hdac->private_data; @@ -541,6 +495,7 @@ static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, struct hdac_hdmi_cvt *cvt; struct hdac_hdmi_pin *pin; int ret; + struct hdac_ext_dma_params *dd; if (dai->id > 0) { dev_err(&hdac->hdac.dev, "Only one dai supported as of now\n"); @@ -573,25 +528,56 @@ static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, if (ret < 0) return ret; - return snd_pcm_hw_constraint_eld(substream->runtime, - pin->eld.eld_buffer); + ret = snd_pcm_hw_constraint_eld(substream->runtime, + dai_map->pin->eld.eld_buffer); + + if (ret < 0) + return ret; + + dd = kzalloc(sizeof(*dd), GFP_KERNEL); + if (!dd) + return -ENOMEM; + dd->format = snd_hdac_calc_stream_format(params_rate(hparams), + params_channels(hparams), params_format(hparams), + 24, 0); + + snd_soc_dai_set_dma_data(dai, substream, (void *)dd); + + return 0; } -static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream, +static int hdac_hdmi_playback_cleanup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct hdac_ext_device *hdac = snd_soc_dai_get_drvdata(dai); - struct hdac_hdmi_priv *hdmi = hdac->private_data; + struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); + struct hdac_ext_dma_params *dd; + struct hdac_hdmi_priv *hdmi = edev->private_data; struct hdac_hdmi_dai_pin_map *dai_map; dai_map = &hdmi->dai_map[dai->id]; - hdac_hdmi_set_power_state(hdac, dai_map, AC_PWRST_D3); + dd = (struct hdac_ext_dma_params *)snd_soc_dai_get_dma_data(dai, substream); - snd_hdac_codec_write(&hdac->hdac, dai_map->pin->nid, 0, + if (dd) { + snd_soc_dai_set_dma_data(dai, substream, NULL); + kfree(dd); + } + + if (dai_map->pin) { + snd_hdac_codec_write(&edev->hdac, dai_map->cvt->nid, 0, + AC_VERB_SET_CHANNEL_STREAMID, 0); + snd_hdac_codec_write(&edev->hdac, dai_map->cvt->nid, 0, + AC_VERB_SET_STREAM_FORMAT, 0); + + hdac_hdmi_set_power_state(edev, dai_map, AC_PWRST_D3); + + snd_hdac_codec_write(&edev->hdac, dai_map->pin->nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); - dai_map->pin = NULL; + dai_map->pin = NULL; + } + + return 0; } static int @@ -1026,8 +1012,6 @@ static void hdac_hdmi_skl_enable_dp12(struct hdac_device *hdac) } static struct snd_soc_dai_ops hdmi_dai_ops = { - .startup = hdac_hdmi_pcm_open, - .shutdown = hdac_hdmi_pcm_close, .hw_params = hdac_hdmi_set_hw_params, .prepare = hdac_hdmi_playback_prepare, .hw_free = hdac_hdmi_playback_cleanup,