Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751803AbdIOAa7 (ORCPT ); Thu, 14 Sep 2017 20:30:59 -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 S1751658AbdIOAa5 (ORCPT ); Thu, 14 Sep 2017 20:30:57 -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:36 -0700 Message-Id: <1505435439-18012-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: 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: 6be1fb99-9632-45a1-be25-08d4fbd10574 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;3:4K669ZCcQm1nq4XlJbb2maF30HWF3AH1vuiuHEr/q/6FpaDUA6p69UK4zWBK4d7eXqeRVkHFYct8Q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g7ijnLKRxpQrGFDjy/CHZDBiuniWo0j3UiYr1MAyyheddxdEFKYt3XMM7t/mMmXlsVUn+OVLgDzIeVC/Pnl68WGKoqxZhcgMYN3BSK2pVy9WePyy19nEQXCQUh6KF1TRj0COBXZkRvxlJU0yB8n+jpU/db9whQQ8phQy7ktyNW0Qh/EvOMhw9jsQttj9dhhPGhDjS5/FIIyqaM2lR+37dLmNm4jlzytLzIwiaHcraui6YCAQN0Dl4ubo9JNnuFZHc7nToL6u/1vxsy;4:SHP28ZhTf004iVD9UEnrdHo0Lfk/4gwafGAj3vudS+MJApitxJdSmAXPdgNUtYnkjz7kIEVhiV+JZNvRxR1on+7OJAiRivfaxzirC844Z3Zplwq6/LG7RFfiTosafmT1IBmkspnjJwB9ggIhZqohVhjbnpdMmBiLxVcW8vc85dHwJMCOvEFJhA1cYfmgr23VkDyWdOXlCB3RI4xcxkOe/A78htV1nQjPln6tqOiJyHxNFG+o5WvpUNCjpxpVTP2hEAnDszFvXlp9UrF89W7xgKKzl0ZLO+Pod6zRy8WySAc= 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)(189002)(6512007)(5003940100001)(6486002)(305945005)(53416004)(101416001)(7736002)(5660300001)(97736004)(25786009)(2906002)(106356001)(68736007)(6506006)(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:KwFjF2mJ6lnGAqES+gU1VhvVhEMWWl4Uf4EJtXD9J?= =?us-ascii?Q?CYuNyIZBtqHeTecghBCvRcBRuarg5/PsToFkBb5QcN4OXVaLwj+Zg6DKETjG?= =?us-ascii?Q?AVhsr+UZjc56SHte5YbG4REP7Q2WCwE1Vi2z1pvmgOkCwdSSU9LqWYwebkgp?= =?us-ascii?Q?3z6k3S4M9X2qpnWeOlSFXNAmz3T66QMZljNp3HvjNSVsHNNglGfvby5SFH8f?= =?us-ascii?Q?MjrjF8b2W7n7KOVgN4ALgn39FNSzU99qenRqFat68ftAOAt7iODi/6I9hwpY?= =?us-ascii?Q?+rYwVPiWMGaD77x/WgNL54nQTAB3q1mCXbgMMj0nvvCdQns9VO+FeSyCzFn3?= =?us-ascii?Q?z8oV5B9MEo1+PT9/8dJ+3BTCiwWpv7fMwVzeN/ln1ut0z64ztqGktgEpy+8t?= =?us-ascii?Q?HhMEZPC5BFIDsaRioe/LRc8MkMpnygpaPT4QPJ8PCWtt+vuKsEdTpm4iA6Av?= =?us-ascii?Q?q15TCouX8f9q58QgbeFXIoAqUYbT19JE20kAFasRTCC0BhRCUizt5GbgH2Vi?= =?us-ascii?Q?MNiqlOKRSXLdTjKtgy3ghtLhEHDDDAPfVZQH66lxZpSJ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W05X+g3GUHZoZiT5Rl1IUQNsu3P05Sh87WvtN7e3niLIZGKQs2WJITYmZzR/krw==;5:iT6RlrkvqjOTsdA0rHMoCIG+41gOEeKBHAlvWqv7eCYAFHEQ0JN26V8Y50glqLSJdiMwv1Ljc2CVGn35SumPGTATPzWK4bUgwnnBUWB2uaRCIX6AvjatbF4aiMOaWc/N/dHEuycw/WQJy8fySMPX285HJ6jxU0l6692G8BrcB2c=;24:Vx8pun2fo8h7gG3Whiv5ADWxAkzHftiSidpqLE3n7kECdzGLyC+WMnD2yPZMeZQ268krva9cuQwjDLO6rtFGvLpW9FzmV6Ua+9101f5dZNE=;7:5dlGFPXcgKb6IUGfq4u1SfV7JKBTJGM7EL6i8/6npLXN0HILdE9x3ZrzqVBT6P7xoWSRUD6NMetoz+7xDulj5jzOqo5q5N0nc/lHRiOUJHOHO4edO2WZoRIH6eoxx2jFZZKFND82sR2fPSGPBP1QnUy0ou+tNW69OQRuFKGHHt76yFt2LVrun6n0S6Smt5f55OWxWI42lvJgN0ed7iMm/z6V/fHRJe6MY7olO5Q7ty8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: maximintegrated.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2017 00:30:51.4824 (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: 4079 Lines: 119 Signed-off-by: Ryan Lee --- 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