Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751850AbdIOAbD (ORCPT ); Thu, 14 Sep 2017 20:31:03 -0400 Received: from mail-co1nam03on0130.outbound.protection.outlook.com ([104.47.40.130]:19017 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751658AbdIOAa7 (ORCPT ); Thu, 14 Sep 2017 20:30:59 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=RyanS.Lee@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/2] ASoC: max98927: Added support for DSP_A and DSP_B format Date: Thu, 14 Sep 2017 17:30:38 -0700 Message-Id: <1505435439-18012-3-git-send-email-ryans.lee@maximintegrated.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505435439-18012-1-git-send-email-ryans.lee@maximintegrated.com> References: <1505435439-18012-1-git-send-email-ryans.lee@maximintegrated.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [204.17.143.20] X-ClientProxiedBy: MWHPR2201CA0034.namprd22.prod.outlook.com (10.174.164.47) To BLUPR11MB0835.namprd11.prod.outlook.com (10.163.217.145) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f99789eb-0138-4f61-c1f4-08d4fbd1071a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BLUPR11MB0835; X-Microsoft-Exchange-Diagnostics: 1;BLUPR11MB0835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OpHD4db8ivkJA4wl9dYQJUh95oPOsh2TViarZKNd4RAUHtCt+x+XzTZbF7k8wlpus6COgLhHDrWaOROc3f7lkll87K4PYQVkd6TWIMEIZDvRTgM73/bxAFDV5E11LlwELQPaOQhaII0hX4wNIlW6o+s+/9qL2GDpRhydykoCq7cKvPo3CCYXjO7w2VLX0lDWx1riPBptB66gjnmf54inCKecppyPfSN+h/bFrfg55nnuB8NJL87NWPhM2ey+O8MiJ9dsVFydKQbFhq96TSoxR+0h/EE8CH0cEuP+NTPT+EJpr92eRr691LEMPVIaRatmAAjC3gTCvhDKNJ8w7ZA3LyyKGIxPgtcueGDtH;4:tCsB2WSfChH8LtKLtzTD8p0Gj+rxjR9Yb27/Hn+10fjFrptTfZip+WuXIqfvFN5tiwHadkDThv5iEvmFpalYdcgDKb4XhOkANyCww0tG2J9mxue6oj3WJOX0T4WmjOiENVcPlBKn6lWaw5BcqjmLK/n0VZyxtmVqApnURg3FjBIEn8PDEBUvDLFRMorZStx7nI3+hft1qhjTRelM/wDNtBv4CLvjQXNUL7Q67KI0T04XVzp1HxDvCwITnAzZl03a/JF57ZqFmbBSMeEGtoip2PPwhNbOkT7Twf/kGjuehGU= X-Exchange-Antispam-Report-Test: UriScan:(108721460000369); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123558100)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BLUPR11MB0835;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BLUPR11MB0835; X-Forefront-PRVS: 0431F981D8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(376002)(346002)(199003)(54534003)(189002)(6512007)(5003940100001)(6486002)(305945005)(53416004)(101416001)(7736002)(2950100002)(5660300001)(97736004)(25786009)(2906002)(106356001)(68736007)(6506006)(76176999)(50466002)(189998001)(8936002)(6666003)(86362001)(53936002)(33646002)(36756003)(478600001)(81166006)(4326008)(50226002)(72206003)(66066001)(105586002)(39060400002)(50986999)(48376002)(110136004)(81156014)(16526017)(8676002)(16586007)(3846002)(69596002)(316002)(47776003)(6116002)(2004002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR11MB0835;H:ryan-ThinkPad-T430.maxim-ic.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR11MB0835;23:4GYqYYNKOWXKso9RHuWj7QAUL29+0fzii7n2A3IOw?= =?us-ascii?Q?U/vpkN7DO16iKqDE/36rvwZAUBZJxTx52LoeGvifWdcn/GrkUZxO8ZtapbwH?= =?us-ascii?Q?Zc6WIL4jyvjj5CLDHBT76/Eu72yT7pWeJEj24rZOTOlaXmt602YQ0J6zmRvh?= =?us-ascii?Q?p6nkSIXWJyWJ9yYIAGOW1yBhRlx3PM09Adq+J2MOi1OG04zNOrw7DuzdsZm2?= =?us-ascii?Q?VHP8ChFiE9OJUOzpMmbD6upbTVf8D8Qa508GsXbP+ALiHDiUC7svd61RN5mf?= =?us-ascii?Q?5OHbE5Pq1eq2bFoYAyc3JWkHOmExRHSEvgX/gluorbNcW0s3EVoVY9dFfw2W?= =?us-ascii?Q?rGK1KRr+UfGr+0E9kJtvzQEe4oJBC82Spy8BzC8M5kwzy6D/QoUOSQNx3/py?= =?us-ascii?Q?X7uZl3N8wl/xEa5XSK60KgfNRWKnrmTMGrxEtXaHMZb0JNBq2MP9BinACQfy?= =?us-ascii?Q?5N1NX/SFkKXuGS1P8JBpqEw5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rfI+uFOAw5j0k+Ndv/+xqS/mJMRVbEwWwlWUE0WQqHRYmt9ARxT3Fa63+XxwxooF64IhGuXJsRSs/w95i9U1U5OuP/HyttpZXwxYOfc062FQhisAyB6xNVZ7TDD7Mnfg6q1Wsa86ZIhBit6QCubtzjuX+ZR7XKsd8vm1TQD24srKCP84hjPjiGRXr6XTowIkt81TOxevMbgyMwE5rE2amuKAxAIyF+TPZrlfRBev88AkGpPe9wcAkn87vX9n4ooJqAldSrA==;5:r9hLM3PXH/MCNDFOwi0yjwTRx8NA1a/Uz7dqUlTORDkpW4Bcyy4fDPzfYHREIY+19ifZewWHzQO1uQwk/zGwAqOjfjBmYplhQPZ/GFEQig+PWROe1JvdQ2rcBLmifLxjWtw+PYneZAQWOeUXX/smTn86Av8rGhi3fxUU84gq0xo=;24:oamBP/zO8T+CIWXdb0owKXD0YoMO02dGoMPBkMc6kIoe2X/aEkak4PHUgt5HocKVapluQAql+OlSqZbvfoPZuMdNR67R81dPcBtuieP4zBk=;7:qR0u7Viob/W74FaEunrrlLV+jCgaH8kTQ85/J4XEAldp+937WhxDD5tH7+X7JcTA45LElf1y91RjPbMiY8MS6O9V8UVPgitBKi0OYhwkqzgeUIT5gAuxF9TTpHRJpNuL+LlvfRp1+S2c0etji1vfgSCjeJs1QuYjRKwrCoxkXb2l27HEv8z7+6pNXZrpuzVsuN14EvZSHHbFOpaMI2ive23kNY+hIe64rQ5SCo1zT+0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: maximintegrated.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2017 00:30:54.2481 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fbd909df-ea69-4788-a554-f24b7854ad03 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR11MB0835 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4308 Lines: 126 Signed-off-by: Ryan Lee --- Changelog: Modified copyright date Added support for DSP_A and DSP_B format. Added 'use_pdm' variable to distinguish configuration for pcm and pdm. Maxim's TDM_MODE1 is matched with DSP_A Maxim's TDM_MODE0 is matched with DSP_B sound/soc/codecs/max98927.c | 35 ++++++++++++++++++++--------------- sound/soc/codecs/max98927.h | 6 ++++-- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index d9dbbe7..6f7b3ef 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,11 @@ 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); - - /* pdm channel configuration */ - if (max98927->iface & SND_SOC_DAIFMT_PDM) { + MAX98927_R0035_PDM_RX_CTRL, + MAX98927_PDM_RX_EN_MASK, 0); + } else { + /* pdm channel configuration */ regmap_update_bits(max98927->regmap, MAX98927_R0035_PDM_RX_CTRL, MAX98927_PDM_RX_EN_MASK, 1); @@ -231,10 +235,11 @@ 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; } 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