From patchwork Tue Aug 7 14:56:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhi, Yong" X-Patchwork-Id: 10558787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3771114E5 for ; Tue, 7 Aug 2018 15:34:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25A8A291A7 for ; Tue, 7 Aug 2018 15:34:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19EDC29E7F; Tue, 7 Aug 2018 15:34:31 +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 192F9291A7 for ; Tue, 7 Aug 2018 15:34:29 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 13EDE267865; Tue, 7 Aug 2018 16:56:27 +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 7BE7226788C; Tue, 7 Aug 2018 16:56:24 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by alsa0.perex.cz (Postfix) with ESMTP id 69C2B267692 for ; Tue, 7 Aug 2018 16:56:19 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2018 07:56:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,455,1526367600"; d="scan'208";a="252051667" Received: from mrameshb-mobl.amr.corp.intel.com (HELO yzhi-desktop.amr.corp.intel.com) ([10.255.228.229]) by fmsmga005.fm.intel.com with ESMTP; 07 Aug 2018 07:56:16 -0700 From: Yong Zhi To: broonie@kernel.org, pierre-louis.bossart@linux.intel.com Date: Tue, 7 Aug 2018 09:56:05 -0500 Message-Id: <1533653765-26080-1-git-send-email-yong.zhi@intel.com> X-Mailer: git-send-email 2.7.4 Cc: alsa-devel@alsa-project.org, harshapriya.n@intel.com, vkoul@kernel.org, naveen.m@intel.com, sanyog.r.kale@intel.com, Yong Zhi Subject: [alsa-devel] [PATCH] ASoC: Intel: hdac_hdmi: Add sampling frequencies constraint 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 Playback of 44.1Khz contents with HDMI plugged returns "Invalid pipe config". This patch adds rate constraint to allow user space SRC to do the converting. Signed-off-by: Yong Zhi --- sound/soc/codecs/hdac_hdmi.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 7b8533abf637..b222a2e91463 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -288,6 +288,38 @@ static unsigned int sad_sample_bits_lpcm(const u8 *sad) return (sad[2] & 7); } +/** + * sad_sample_rates_lpcm - Find supported sampling frequencies + * + * @sad: pointer to CEA_SADs entry byte 2 which details sampling frequencies + * supported according to CEA-861 EDID V3. In little endian byte order. + * + * bit 7: Reserved (0) + * bit 6: 192kHz + * bit 5: 176kHz + * bit 4: 96kHz + * bit 3: 88kHz + * bit 2: 48kHz + * bit 1: 44kHz + * bit 0: 32kHz + * + * Return: bitmask of supported sampling frequencies. + */ +static u8 sad_sample_rates_lpcm(const u8 *sad) +{ + return (sad[1] & 0x7F); +} + +static const unsigned int cea_sampling_freqs[7] = { + SNDRV_PCM_RATE_32000, /* 0: 32000Hz */ + SNDRV_PCM_RATE_44100, /* 1: 44100Hz */ + SNDRV_PCM_RATE_48000, /* 2: 48000Hz */ + SNDRV_PCM_RATE_88200, /* 3: 88200Hz */ + SNDRV_PCM_RATE_96000, /* 4: 96000Hz */ + SNDRV_PCM_RATE_176400, /* 5: 176400Hz */ + SNDRV_PCM_RATE_192000, /* 6: 192000Hz */ +}; + static int hdac_hdmi_eld_limit_formats(struct snd_pcm_runtime *runtime, void *eld) { @@ -301,6 +333,8 @@ static int hdac_hdmi_eld_limit_formats(struct snd_pcm_runtime *runtime, for (i = drm_eld_sad_count(eld_buf); i > 0; i--, sad += 3) { if (sad_format(sad) == 1) { /* AUDIO_CODING_TYPE_LPCM */ + unsigned int rates = 0; + u8 sad_rates, j; /* * the controller support 20 and 24 bits in 32 bit @@ -308,6 +342,16 @@ static int hdac_hdmi_eld_limit_formats(struct snd_pcm_runtime *runtime, */ if (sad_sample_bits_lpcm(sad) & 0x6) formats |= SNDRV_PCM_FMTBIT_S32; + + sad_rates = sad_sample_rates_lpcm(sad); + /* Filter out 44.1, 88.2 and 176.4Khz */ + for (j = 0; j < 7; j += 2) + if (sad_rates & BIT(j)) + rates |= cea_sampling_freqs[j]; + + snd_pcm_hw_constraint_mask64(runtime, + SNDRV_PCM_HW_PARAM_RATE, + rates); } }