Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752321AbdFSWHo (ORCPT ); Mon, 19 Jun 2017 18:07:44 -0400 Received: from mail-bn3nam01on0132.outbound.protection.outlook.com ([104.47.33.132]:51130 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751022AbdFSWHk (ORCPT ); Mon, 19 Jun 2017 18:07:40 -0400 Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=maximintegrated.com; From: Ryan Lee To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, ryans.lee@maximintegrated.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: ryan.lee.maxim@gmail.com Subject: [PATCH 1/7] staging: max98927: Added TDM support Date: Mon, 19 Jun 2017 15:07:20 -0700 Message-Id: <1497910046-3369-1-git-send-email-ryans.lee@maximintegrated.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [204.17.143.20] X-ClientProxiedBy: CY4PR2201CA0021.namprd22.prod.outlook.com (10.171.208.159) To BLUPR11MB0833.namprd11.prod.outlook.com (10.163.217.143) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 352cc02d-f50d-4571-0619-08d4b75f983a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(201703131423075)(201703031133081);SRVR:BLUPR11MB0833; X-Microsoft-Exchange-Diagnostics: 1;BLUPR11MB0833;3:6PYWs1ceWwcreTCrLGfUHs4XQ1N++5aOv1zdT4y596+uQhYRJ1LBi7GtQH/EYXHIShOH3FcJzjNvwaPL7OMRWqYqae5ByJxKWZPszzt3DShMNxAVKVy8v4FASUrA9vSb5usJse6aTxd6LPG+h9sX8hS+tC0h9oQyMnY1zpLDdXqLo4tmZq04rD+J0eyKgFH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Yh7Ze/o8NFhwNMKZXykQM3/J+N+8pOjw0D1S+4fWtb+277hEHP/ZTZObsqRjORGrzVPhWsqqgwggKi9XnrJOJvbgkZ+HNDV8o/AH7H/KQEFVLIH+tcTzLl34sZtgrf9pNb7dp5uE98BQncKuDgTxo94L7igmsionSbUo9b5SxvbK3mNlGDa4UghGzdbPqgkZ1z70uMxhyTMlS+ztntn8M9u6k5banAgTtmEdfJDlo0BGF0n7JWtkigacAAGnwqICscDEceG/1bWJGNjMTknHSi1Yoq9nPV6tQdf1DpzYA6M6XPcbqvDB4eUFo/VTTruTzUSL8Dz X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(108721460000369); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(100000703101)(100105400095)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123558100)(20161123555025)(20161123564025)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BLUPR11MB0833;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BLUPR11MB0833; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR11MB0833;4:T6Rie4s3JzU++QlwhkPhL0pBMjXExCAeY4Y04uCO++?= =?us-ascii?Q?XXXa2VM51qDIx0JNzLFPDTjhigBQj8VU5wUxphQ2XmP44jjmJ2CvOvIHSYII?= =?us-ascii?Q?vGpppzq90HskGBlXifZOjMs+y6fuN7TFpzKmxJ3M82HfbWjbiIqQnvV7VPbU?= =?us-ascii?Q?Xv5pWdcTDk9B0A4CvrHP4Ny+XFnNscavvTrzlhVN8a9W0GNbx3e20JKAe0L8?= =?us-ascii?Q?Y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tHu7f?= =?us-ascii?Q?lEwG6Q6r3r/+5ZOeBqj4dQL29uu15PpSlfWkAcqpAkeSEYwu6rvqawnGtA40?= =?us-ascii?Q?qCG6vr1h/QEdRCeB6Dk6EfVHoqigbI+Dpz?= X-Forefront-PRVS: 0343AC1D30 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(39400400002)(39410400002)(39850400002)(39860400002)(39840400002)(39450400003)(6486002)(53416004)(7736002)(42186005)(189998001)(81166006)(50226002)(8676002)(5003940100001)(86362001)(50466002)(5660300001)(53936002)(6512007)(2906002)(36756003)(305945005)(66066001)(4326008)(6666003)(110136004)(38730400002)(47776003)(478600001)(33646002)(3846002)(50986999)(72206003)(25786009)(6506006)(2004002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR11MB0833;H:ryan-linux.maxim-ic.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR11MB0833;23:KzlvxIRPv8u9CxMnVuWlWuXs4YAABfgOTjrGYVSCk?= =?us-ascii?Q?kfa5siscjbomUwkrBi54851gtZ8pfIc7k4PtgLyNCbTsGpayX53YCHTc/WUT?= =?us-ascii?Q?YK3zKOS0aTLnpCqI6lSfZR2olcGYjzJ4Vs9T+qynqjDdal80Aql4GHljbuwV?= =?us-ascii?Q?dBsPZfUbSz6VvZAkA5/tCpEAYtHoulYnUgzOphMefA1BeEVxfMU0c8iiALj5?= =?us-ascii?Q?FLEy1hzT7DjQzqaCsaAIRGgFgG8gc2mb3YxdXyIiN2spMBk23yqw7jEzY+x6?= =?us-ascii?Q?7XQ6FORzFAIh4OrvE9qV7NTpCCTpHThvUaj3VGhOtZFIe41OzPLgzN5JnNI8?= =?us-ascii?Q?UBgzjHqS+iiCAWGg80JpN8Jv7lXToB3qhQd9R/xzOld09gjSA9/tyrJxRPn3?= =?us-ascii?Q?TPMutA42lMJ8lmTV0tDVL9FJQLYdKc3woGmh8gpB1qfX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LxaHwMF6rzvhBoQncp6n/mn49pO?= =?us-ascii?Q?ZIswDqZqC2uOTr+lA1Nm9lFFLD0IfjQtsOkCz+4D4RKawa5NPYai7pEuTxDd?= =?us-ascii?Q?sEZFli5/RXhUtyhQU6Cs2EAc7O5S7fH1WQl9Pft/dgKorMU6vUR4op2j405d?= =?us-ascii?Q?09y062uQ8EnS3g3aaghFTVSW2xaKZCE+yxu+eE8d/o01NV9TfJtLt6hsHnmB?= =?us-ascii?Q?ALjnr4N/Y7OoTQ2xjvf1CDfR3yudObMW4UeuIlcegSv0CCStM8iBok32GGLx?= =?us-ascii?Q?nwsApvYFY9bMFC8RYaqioaSUjSwGoGSK5sc5yTANhxuNhctC/vE3zQ+JSTSY?= =?us-ascii?Q?wxjuUe8qtHgUuORSVGc2xBlMFf1fqqahhMpa9gV7hcAYL6nPaJ95Ehoa4zjx?= =?us-ascii?Q?XMYDE9srBDXzjIUwDKpfTkMZctEE2WHDY4SvcgdOI7MjvBSVnGs3o5Q7gR0D?= =?us-ascii?Q?ht8TYQeuPv7emXU0JqilrV6E+IQ6RusTZHiVepjOxlavBEHlFDA2xctUGvoI?= =?us-ascii?Q?lCv56wKccXMRV+oNMwdU0mFJJp1OasFiMdSaTkTkyx0qHrA4KimXJFrltX58?= =?us-ascii?Q?a234m1C2hwOtrvFBhXEMbvufq3ZHUcSyuR1bFPxJ9gfjB2A4Qf8OVDTlMpHX?= =?us-ascii?Q?MBXDH7rBCgsHU3C9Auvh24b9MJTPxboyZQppm/lzhToXI2y8neu2D0eIhbon?= =?us-ascii?Q?475Lc2sAM1eoLFdwuPNb/1Rq5hB74ZPPlECoGZlDZKTGJNasJBM2WVcy+F26?= =?us-ascii?Q?Fuy168PJLBLemIebBqOJYK?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR11MB0833;5:FxuR3dUMngESBa6husWJojhkVpbZ7dROG12wjx5OCDVRLwVD6wIpNSwLc+pf92C5VSXBOmCZOMaZC/UKwsfJa/H7/E3EHVm7EQQsSShEtOavcBsyGWIXllFSe5/9g78Zatz8WN6f34BUJp3zlNLRofbCvNkjT7hipLTTSK8vLea39bcWRjBGkwZtAXnuykOPVSj1YQ7C8y4p0Niow8FxaoHvHS5qb0L6y/wrw2zqKEBoRlDtt6JmB3VW/Xmct2MINARTfeAX2gPMKv3r82/6vtzdtoCYb2mJxykLzZ38Pna++Gn4ECXchsoKXdXUyrjRwb9XRLzVd45BaMaRtR0ASLp0EiDcUMLWCND20CcLOFBLi751/4uGuiAq9V0nzVaSqbjqeMpDs4FwSmAu5vKneOijVVXsT8YBOILyNgspu2xwbxDqLziThZca5qCsh2kqlKhlOynzFEkuzkscWopILRLlCvrw3dFubVnQiOXEL5DyLNtNNFWh5uwkR+Rf93HZ;24:8TwqFyrGK3AKzniQ4a9G91WfN8b1lQVmPK1N9rr83bxweLnESvk7z3hWTEnFD89w3TWlvVKE/06zN02gSW17X6TwEFpQ1CfCZO7rOR+L+OY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BLUPR11MB0833;7:qnEMIconZAjPDMDK8O+2NRzWXrUDOgNSovVPEg1WvGxGCRE9cyMeKbFuB4b2OpnjkNctOHybECgiufpOvv0UeWmJSJ+xcb8Fh6xx5Kan1VCZin6US0U3IWc/b0zN1O+3tXPXwdJxd57iNzNKFQ8oWGUZopKZacwHViLb02r31KgZJzdOmJ9i2BAGvxYu1VC3k49wWLQGvOg6juVSOVaGuHLErpLUua7HlsHFAWhnL6R1kiHBPEDjmicz30ketYW6JqKegaiWLLlgIBoXKdC5eRXPGQ0bh25lovuete3s54SVDvT803NerYtkBNLLh55xkxiRGQNppCgPUCmHHcw+O03aCCg3rlIyKmFp7EvfxdR5EyH6uKY7mWuqQ/8qWonat6sHSkfrKHlbrvrjuVK/B2RTlwfoCRlKAwLlfss+GcUyAiLzyGnu+61zJ5a7w8JPplqDR6RwNoSS2ogxn7sfyC9KVRL4fSNHuqHODF2bL5rjeloo924GIW+NZrWxvqzShRTYum4EHU1wtyQRwjdKwgR1PQqr13dDGTzsS8IXIjOAIkGr+t8KTO+HY2TkjIYw/qNYtfSdufIQU1T7PXoKBQMMnZHF2gO3c5a6/Cp0yBzVX0agD2euHWYEDKsaCH0Wm5lXhmd8bMUz+wXm8YY/IVLKtXc2kwbPJqfoEBFtdSuKZ5s6BPzK91str3tBu7tqK0O3xmrv9+CasNBGQTX5Camfp2fLOmtTuWFFjZQ5jJQA0EzqCnzb+fxzTMIr7DJrvsh0MZk3io/T8A0WySigDAnmD4hjcb6ZKerKuV0AHcY= X-OriginatorOrg: maximintegrated.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2017 22:07:36.1985 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR11MB0833 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7571 Lines: 256 Signed-off-by: Ryan Lee --- sound/soc/codecs/max98927.c | 141 ++++++++++++++++++++++++++++++++++++-------- sound/soc/codecs/max98927.h | 6 +- 2 files changed, 120 insertions(+), 27 deletions(-) diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index b5ee294..99d6e41 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -1,7 +1,7 @@ /* * max98927.c -- MAX98927 ALSA Soc Audio driver * - * Copyright (C) 2016 Maxim Integrated Products + * Copyright (C) 2016-2017 Maxim Integrated Products * Author: Ryan Lee * * This program is free software; you can redistribute it and/or modify it @@ -146,6 +146,7 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); unsigned int mode = 0; unsigned int format = 0; + bool use_pdm = false; unsigned int invert = 0; dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); @@ -187,22 +188,27 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) /* interface format */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - max98927->iface |= SND_SOC_DAIFMT_I2S; format = MAX98927_PCM_FORMAT_I2S; break; case SND_SOC_DAIFMT_LEFT_J: - max98927->iface |= SND_SOC_DAIFMT_LEFT_J; format = MAX98927_PCM_FORMAT_LJ; break; + case SND_SOC_DAIFMT_DSP_A: + format = MAX98927_PCM_FORMAT_TDM_MODE1; + break; + case SND_SOC_DAIFMT_DSP_B: + format = MAX98927_PCM_FORMAT_TDM_MODE0; + break; case SND_SOC_DAIFMT_PDM: - max98927->iface |= SND_SOC_DAIFMT_PDM; + use_pdm = true; break; default: return -EINVAL; } + max98927->iface = fmt & SND_SOC_DAIFMT_FORMAT_MASK; - /* pcm channel configuration */ - if (max98927->iface & (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J)) { + if (!use_pdm) { + /* pcm channel configuration */ regmap_update_bits(max98927->regmap, MAX98927_R0018_PCM_RX_EN_A, MAX98927_PCM_RX_CH0_EN | MAX98927_PCM_RX_CH1_EN, @@ -217,13 +223,12 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) MAX98927_R003B_SPK_SRC_SEL, MAX98927_SPK_SRC_MASK, 0); - } else regmap_update_bits(max98927->regmap, - MAX98927_R0018_PCM_RX_EN_A, - MAX98927_PCM_RX_CH0_EN | MAX98927_PCM_RX_CH1_EN, 0); + MAX98927_R0035_PDM_RX_CTRL, + MAX98927_PDM_RX_EN_MASK, 0); - /* pdm channel configuration */ - if (max98927->iface & SND_SOC_DAIFMT_PDM) { + } else { + /* pdm channel configuration */ regmap_update_bits(max98927->regmap, MAX98927_R0035_PDM_RX_CTRL, MAX98927_PDM_RX_EN_MASK, 1); @@ -231,10 +236,12 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) regmap_update_bits(max98927->regmap, MAX98927_R003B_SPK_SRC_SEL, MAX98927_SPK_SRC_MASK, 3); - } else + regmap_update_bits(max98927->regmap, - MAX98927_R0035_PDM_RX_CTRL, - MAX98927_PDM_RX_EN_MASK, 0); + MAX98927_R0018_PCM_RX_EN_A, + MAX98927_PCM_RX_CH0_EN | MAX98927_PCM_RX_CH1_EN, 0); + + } return 0; } @@ -245,6 +252,21 @@ static const int rate_table[] = { 13000000, 19200000, }; +/* BCLKs per LRCLK */ +static const int bclk_sel_table[] = { + 32, 48, 64, 96, 128, 192, 256, 384, 512, +}; + +static int max98927_get_bclk_sel(int bclk) +{ + int i; + /* match BCLKs per LRCLK */ + for (i = 0; i < ARRAY_SIZE(bclk_sel_table); i++) { + if (bclk_sel_table[i] == bclk) + return i + 2; + } + return 0; +} static int max98927_set_clock(struct max98927_priv *max98927, struct snd_pcm_hw_params *params) { @@ -270,19 +292,17 @@ static int max98927_set_clock(struct max98927_priv *max98927, i << MAX98927_PCM_MASTER_MODE_MCLK_RATE_SHIFT); } - switch (blr_clk_ratio) { - case 32: - value = 2; - break; - case 48: - value = 3; - break; - case 64: - value = 4; - break; - default: + if ((max98927->iface == SND_SOC_DAIFMT_DSP_A) || + (max98927->iface == SND_SOC_DAIFMT_DSP_B)) + return 0; + + /* BCLK configuration */ + value = max98927_get_bclk_sel(blr_clk_ratio); + if (!value) { + dev_err(codec->dev, "BCLK %d not supported\n", blr_clk_ratio); return -EINVAL; } + regmap_update_bits(max98927->regmap, MAX98927_R0022_PCM_CLK_SETUP, MAX98927_PCM_CLK_SETUP_BSEL_MASK, @@ -386,6 +406,76 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } +static int max98927_dai_tdm_slot(struct snd_soc_dai *dai, + unsigned int tx_mask, unsigned int rx_mask, + int slots, int slot_width) +{ + struct snd_soc_codec *codec = dai->codec; + struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + int bsel = 0; + unsigned int chan_sz = 0; + + /* BCLK configuration */ + bsel = max98927_get_bclk_sel(slots * slot_width); + if (bsel == 0) { + dev_err(codec->dev, "BCLK %d not supported\n", + slots * slot_width); + return -EINVAL; + } + + regmap_update_bits(max98927->regmap, + MAX98927_R0022_PCM_CLK_SETUP, + MAX98927_PCM_CLK_SETUP_BSEL_MASK, + bsel); + + /* Channel size configuration */ + switch (slot_width) { + case 16: + chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_16; + break; + case 24: + chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_24; + break; + case 32: + chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_32; + break; + default: + dev_err(codec->dev, "format unsupported %d\n", + slot_width); + return -EINVAL; + } + + regmap_update_bits(max98927->regmap, + MAX98927_R0020_PCM_MODE_CFG, + MAX98927_PCM_MODE_CFG_CHANSZ_MASK, chan_sz); + + /* Rx slot configuration */ + regmap_write(max98927->regmap, + MAX98927_R0018_PCM_RX_EN_A, + rx_mask & 0xFF); + regmap_write(max98927->regmap, + MAX98927_R0019_PCM_RX_EN_B, + (rx_mask & 0xFF00) >> 8); + + /* Tx slot configuration */ + regmap_write(max98927->regmap, + MAX98927_R001A_PCM_TX_EN_A, + tx_mask & 0xFF); + regmap_write(max98927->regmap, + MAX98927_R001B_PCM_TX_EN_B, + (tx_mask & 0xFF00) >> 8); + + /* Tx slot Hi-Z configuration */ + regmap_write(max98927->regmap, + MAX98927_R001C_PCM_TX_HIZ_CTRL_A, + ~tx_mask & 0xFF); + regmap_write(max98927->regmap, + MAX98927_R001D_PCM_TX_HIZ_CTRL_B, + (~tx_mask & 0xFF00) >> 8); + + return 0; +} + #define MAX98927_RATES SNDRV_PCM_RATE_8000_48000 #define MAX98927_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ @@ -405,6 +495,7 @@ static const struct snd_soc_dai_ops max98927_dai_ops = { .set_sysclk = max98927_dai_set_sysclk, .set_fmt = max98927_dai_set_fmt, .hw_params = max98927_dai_hw_params, + .set_tdm_slot = max98927_dai_tdm_slot, }; static int max98927_dac_event(struct snd_soc_dapm_widget *w, diff --git a/sound/soc/codecs/max98927.h b/sound/soc/codecs/max98927.h index ece6a60..bf7a6f92 100644 --- a/sound/soc/codecs/max98927.h +++ b/sound/soc/codecs/max98927.h @@ -1,7 +1,7 @@ /* * max98927.h -- MAX98927 ALSA Soc Audio driver * - * Copyright 2013-15 Maxim Integrated Products + * Copyright (C) 2016-2017 Maxim Integrated Products * Author: Ryan Lee * * This program is free software; you can redistribute it and/or modify it @@ -161,7 +161,9 @@ #define MAX98927_PCM_MODE_CFG_FORMAT_SHIFT (3) #define MAX98927_PCM_FORMAT_I2S (0x0 << 0) #define MAX98927_PCM_FORMAT_LJ (0x1 << 0) - +#define MAX98927_PCM_FORMAT_TDM_MODE0 (0x3 << 0) +#define MAX98927_PCM_FORMAT_TDM_MODE1 (0x4 << 0) +#define MAX98927_PCM_FORMAT_TDM_MODE2 (0x5 << 0) #define MAX98927_PCM_MODE_CFG_CHANSZ_MASK (0x3 << 6) #define MAX98927_PCM_MODE_CFG_CHANSZ_16 (0x1 << 6) #define MAX98927_PCM_MODE_CFG_CHANSZ_24 (0x2 << 6) -- 2.7.4