Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp894077imu; Wed, 28 Nov 2018 01:01:55 -0800 (PST) X-Google-Smtp-Source: AJdET5fj8mCsrynj0tom37TDlCIlHaZTmwOE7OCeO8BuHpdcqIuK137/8s1iyPYQPI8ZORkkgk4X X-Received: by 2002:a62:e0d8:: with SMTP id d85mr36042123pfm.214.1543395715650; Wed, 28 Nov 2018 01:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543395715; cv=none; d=google.com; s=arc-20160816; b=ShxAToAQSiJfjwbWDLyH0z1s28gjYWp6zAUOslPoohPEkjpkS4vwc/dnnKBsfQv4Pg h5HKE5ot/Yh/StDLREiSMe9o+Cexkht6gPmSucVaEH5cg6lVc1CaQBWD5BLJ6lzua1x0 kzM2d9ZhIiI1l+t69rPbRxh4OZhWhH3r8vN4lKIbcdSMxHOZyHEtfBCE4NH1hi2kouKI d2QC4ImQbaAFjYv+MwWqFgNIeN6hyNvZ3HSURe2Akx2GMUi+hqXhANsQERwMqxD9jvFj E5gW7jZgTr24HuBOmaB2Fj0woNepxhZGaxJ/+FAxEHlQQgApCP860dqsOV34o4sz/IFM Lxvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AgtufxcsUbbhvbpoGvQbrCYqqvfC+nhS1gPzSq1nZsg=; b=BpfOo/FsvR4p7XHE+2W96swFDTQcus6He2xHNde0g98dmFN4I72W6YOhPi6fI3ofJ3 Cs+uLiigXNIetp38+2lG6QdEnTw8oc0S75k7eVKX/IIDDcVgV+W+ZB71j2kz34LaB1xJ yOkXatuulCVnR9g+W1NsP7BC5ArLWB5MY8wH7tBsscqVwrii9POGIL/c8E1kml6b/1WA ymfwhSFpAfz2aXobLylQqhfAV8lvqd7W48mMQpbamWzITztCdJ/xf0FTyuk3NmEPrnZu bLoMQIujA19ZXiQoZTQNUuT0yFlOceweMr4hQi17hTUMCiK4UAFaDwuOwATpoMGNPe92 J9IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R4DEGG3W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e69si6947618pfg.137.2018.11.28.01.01.39; Wed, 28 Nov 2018 01:01:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R4DEGG3W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727866AbeK1UBx (ORCPT + 99 others); Wed, 28 Nov 2018 15:01:53 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35528 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727519AbeK1UBw (ORCPT ); Wed, 28 Nov 2018 15:01:52 -0500 Received: by mail-pg1-f195.google.com with SMTP id s198so9211859pgs.2 for ; Wed, 28 Nov 2018 01:00:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AgtufxcsUbbhvbpoGvQbrCYqqvfC+nhS1gPzSq1nZsg=; b=R4DEGG3WzGXLxE/Xr3i1Bk9w7aN4nUT5Yx4BHnfpp+Tr09GeZMVqcUrlK4INlQDWAL Tr93wBMuIYPYXQUzNahuS2AUMKhiY3gf5mio86V4aP4BQlK/hZPMxpyjQ3XQxCupBnfa Eg1+Sj4egf5N3e/GL7iehXVY5hgSUhsbLDBl0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AgtufxcsUbbhvbpoGvQbrCYqqvfC+nhS1gPzSq1nZsg=; b=KqfcGUgXdcX7QcbPsJXXL9lJk0evgVANikpySHzdIoSUYxDprhysbSdNmexhZAqjnd o9GVj18nEnLfbmLBTqJxhnU6EhSYONWlqloM/CqIrmSVUdB06ukG4EYLlJbmTvqryhhj 0O4p8e8HYv/nuLmqkLe1rxtwtuKA6LtpinTZ499OPfPMnIJDRt2oiLTKlaGSRrBJFKwX Gfr8wOyVSjlNRdEiK+3jxNYOy3v7O7oHEGE58HJPArBakBWRt/6o2xDGBhPVcchC6zqy BW6mLshpFbak+ylPnSzOdjIc4cPC4USKuSc8D6tGv9MZ8OLqn4yM9ppHTlKaWvMGp53E N26Q== X-Gm-Message-State: AA+aEWbTgmuoAcXbtr3OC2p9du+rJ6ZRQxU6C1gY8xD/IBM5rthcoYn5 wWVWXyCoKQkCKUEobTT8Tw1y3EsvpBU= X-Received: by 2002:a62:c3:: with SMTP id 186mr19911725pfa.24.1543395658927; Wed, 28 Nov 2018 01:00:58 -0800 (PST) Received: from cychiang-z840.tpe.corp.google.com ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id i72sm11568607pfe.181.2018.11.28.01.00.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 01:00:58 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Cc: Mark Brown , alsa-devel@alsa-project.org, dgreid@chromium.org, tzungbi@chromium.org, Rohit kumar , Cheng-Yi Chiang Subject: [PATCH v2 3/5] ASoC: sdm845: Add TDM configuration for speaker Date: Wed, 28 Nov 2018 17:00:35 +0800 Message-Id: <20181128090037.257359-3-cychiang@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181128090037.257359-1-cychiang@chromium.org> References: <20181128090037.257359-1-cychiang@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Set TDM time slots and DAI format for speaker codec. Signed-off-by: Cheng-Yi Chiang --- sound/soc/qcom/sdm845.c | 69 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 43c03f8e8cdc2..d0df7ec6042e2 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -6,9 +6,11 @@ #include #include #include +#include #include #include #include +#include #include #include "common.h" #include "qdsp6/q6afe.h" @@ -17,6 +19,10 @@ #define DEFAULT_MCLK_RATE 24576000 #define TDM_BCLK_RATE 6144000 #define MI2S_BCLK_RATE 1536000 +#define LEFT_SPK_TDM_TX_MASK 0x30 +#define RIGHT_SPK_TDM_TX_MASK 0xC0 +#define SPK_TDM_RX_MASK 0x03 +#define NUM_TDM_SLOTS 8 struct sdm845_snd_data { struct snd_soc_jack jack; @@ -34,7 +40,7 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int ret = 0, j; int channels, slot_width; switch (params_format(params)) { @@ -81,6 +87,35 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, goto end; } } + + for (j = 0; j < rtd->num_codecs; j++) { + struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; + + if (!strcmp(codec_dai->component->name_prefix, "Left")) { + ret = snd_soc_dai_set_tdm_slot( + codec_dai, LEFT_SPK_TDM_TX_MASK, + SPK_TDM_RX_MASK, NUM_TDM_SLOTS, + slot_width); + if (ret < 0) { + dev_err(rtd->dev, + "DEV0 TDM slot err:%d\n", ret); + return ret; + } + } + + if (!strcmp(codec_dai->component->name_prefix, "Right")) { + ret = snd_soc_dai_set_tdm_slot( + codec_dai, RIGHT_SPK_TDM_TX_MASK, + SPK_TDM_RX_MASK, NUM_TDM_SLOTS, + slot_width); + if (ret < 0) { + dev_err(rtd->dev, + "DEV1 TDM slot err:%d\n", ret); + return ret; + } + } + } + end: return ret; } @@ -155,10 +190,14 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) static int sdm845_snd_startup(struct snd_pcm_substream *substream) { unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; + unsigned int codec_dai_fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_card *card = rtd->card; struct sdm845_snd_data *data = snd_soc_card_get_drvdata(card); struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int j; + int ret; switch (cpu_dai->id) { case PRIMARY_MI2S_RX: @@ -190,6 +229,34 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream) Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT, TDM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); } + + codec_dai_fmt |= SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_DSP_B; + + for (j = 0; j < rtd->num_codecs; j++) { + codec_dai = rtd->codec_dais[j]; + + if (!strcmp(codec_dai->component->name_prefix, + "Left")) { + ret = snd_soc_dai_set_fmt( + codec_dai, codec_dai_fmt); + if (ret < 0) { + dev_err(rtd->dev, + "Left TDM fmt err:%d\n", ret); + return ret; + } + } + + if (!strcmp(codec_dai->component->name_prefix, + "Right")) { + ret = snd_soc_dai_set_fmt( + codec_dai, codec_dai_fmt); + if (ret < 0) { + dev_err(rtd->dev, + "Right TDM slot err:%d\n", ret); + return ret; + } + } + } break; default: -- 2.20.0.rc0.387.gc7a69e6b6c-goog