Re: [PATCHv5 2/5] ASoC: codec: cpcap: new codec
On Fri, Feb 23, 2018 at 09:02:51PM +0100, Sebastian Reichel wrote: > + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { > + case SND_SOC_DAIFMT_I2S: > + val |= BIT(CPCAP_BIT_ST_DIG_AUD_FS0); > + val |= BIT(CPCAP_BIT_ST_DIG_AUD_FS1); > + break; > + default: > + /* 01 - 4 slots network mode */ > + val |= BIT(CPCAP_BIT_ST_DIG_AUD_FS0); > + val &= ~BIT(CPCAP_BIT_ST_DIG_AUD_FS1); > + /* L on slot 1 */ > + val |= BIT(CPCAP_BIT_ST_L_TIMESLOT0); > + break; > + } The default case here is really one specific mode, it looks like it's either DSP_A or DSP_B. Most likely DSP_A but you should check. Otherwise this looks good so I'll apply it, please send a followup patch fixing this to match only the specific mode that's actually supported. signature.asc Description: PGP signature
Re: [alsa-devel] [PATCHv5 2/5] ASoC: codec: cpcap: new codec
Hi Sebastian, I love your patch! Perhaps something to improve: [auto build test WARNING on robh/for-next] [also build test WARNING on v4.16-rc2 next-20180223] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Sebastian-Reichel/Motorola-Droid-4-Audio-Support/20180226-063007 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__ sparse warnings: (new ones prefixed by >>) >> sound/soc/codecs/cpcap.c:1406:54: sparse: restricted snd_pcm_format_t >> degrades to integer vim +1406 sound/soc/codecs/cpcap.c 1396 1397 static struct snd_soc_dai_driver cpcap_dai[] = { 1398 { 1399 .id = 0, 1400 .name = "cpcap-hifi", 1401 .playback = { 1402 .stream_name = "HiFi Playback", 1403 .channels_min = 2, 1404 .channels_max = 2, 1405 .rates = SNDRV_PCM_RATE_8000_48000, > 1406 .formats = SNDRV_PCM_FMTBIT_S16_LE | > SNDRV_PCM_FORMAT_S24_LE, 1407 }, 1408 .ops = &cpcap_dai_hifi_ops, 1409 }, 1410 { 1411 .id = 1, 1412 .name = "cpcap-voice", 1413 .playback = { 1414 .stream_name = "Voice Playback", 1415 .channels_min = 1, 1416 .channels_max = 1, 1417 .rates = SNDRV_PCM_RATE_8000_48000, 1418 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1419 }, 1420 .capture = { 1421 .stream_name = "Voice Capture", 1422 .channels_min = 1, 1423 .channels_max = 2, 1424 .rates = SNDRV_PCM_RATE_8000_48000, 1425 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1426 }, 1427 .ops = &cpcap_dai_voice_ops, 1428 }, 1429 }; 1430 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
[PATCHv5 2/5] ASoC: codec: cpcap: new codec
Motorola CPCAP is a PMIC with audio functionality, that can be found on Motorola Droid 4 and probably a few other phones from Motorola's Droid series. The driver has been written from scratch using Motorola's Android driver, register dumps from running Android and datasheet for NXP MC13783UG (which is similar to Motorola CPCAP, but not the same). The chip provides two audio interfaces, that can be muxed to two different audio codecs. One provides support for stereo output (named StDAC or HiFi), while the other only provides mono output (named Voice). Only the Voice codec provides a Capture interface. Signed-off-by: Sebastian Reichel --- sound/soc/codecs/Kconfig |4 + sound/soc/codecs/Makefile |2 + sound/soc/codecs/cpcap.c | 1568 + 3 files changed, 1574 insertions(+) create mode 100644 sound/soc/codecs/cpcap.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..5bd94841feb6 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -408,6 +408,10 @@ config SND_SOC_ALC5632 config SND_SOC_BT_SCO tristate "Dummy BT SCO codec driver" +config SND_SOC_CPCAP + tristate "Motorola CPCAP codec" + depends on MFD_CPCAP + config SND_SOC_CQ0093VC tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index da1571336f1e..2aeee1ba034e 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -36,6 +36,7 @@ snd-soc-ak4671-objs := ak4671.o snd-soc-ak5386-objs := ak5386.o snd-soc-arizona-objs := arizona.o snd-soc-bt-sco-objs := bt-sco.o +snd-soc-cpcap-objs := cpcap.o snd-soc-cq93vc-objs := cq93vc.o snd-soc-cs35l32-objs := cs35l32.o snd-soc-cs35l33-objs := cs35l33.o @@ -282,6 +283,7 @@ obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o +obj-$(CONFIG_SND_SOC_CPCAP)+= snd-soc-cpcap.o obj-$(CONFIG_SND_SOC_CS35L32) += snd-soc-cs35l32.o obj-$(CONFIG_SND_SOC_CS35L33) += snd-soc-cs35l33.o obj-$(CONFIG_SND_SOC_CS35L34) += snd-soc-cs35l34.o diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c new file mode 100644 index ..aedb267d4581 --- /dev/null +++ b/sound/soc/codecs/cpcap.c @@ -0,0 +1,1568 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * ALSA SoC CPCAP codec driver + * + * Copyright (C) 2017 - 2018 Sebastian Reichel + * + * Very loosely based on original driver from Motorola: + * Copyright (C) 2007 - 2009 Motorola, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Register 513 CPCAP_REG_CC --- CODEC */ +#define CPCAP_BIT_CDC_CLK215 +#define CPCAP_BIT_CDC_CLK114 +#define CPCAP_BIT_CDC_CLK013 +#define CPCAP_BIT_CDC_SR3 12 +#define CPCAP_BIT_CDC_SR2 11 +#define CPCAP_BIT_CDC_SR1 10 +#define CPCAP_BIT_CDC_SR0 9 +#define CPCAP_BIT_CDC_CLOCK_TREE_RESET8 +#define CPCAP_BIT_MIC2_CDC_EN 7 +#define CPCAP_BIT_CDC_EN_RX 6 +#define CPCAP_BIT_DF_RESET5 +#define CPCAP_BIT_MIC1_CDC_EN 4 +#define CPCAP_BIT_AUDOHPF_1 3 +#define CPCAP_BIT_AUDOHPF_0 2 +#define CPCAP_BIT_AUDIHPF_1 1 +#define CPCAP_BIT_AUDIHPF_0 0 + +/* Register 514 CPCAP_REG_CDI--- CODEC Digital Audio Interface */ +#define CPCAP_BIT_CDC_PLL_SEL 15 +#define CPCAP_BIT_CLK_IN_SEL 13 +#define CPCAP_BIT_DIG_AUD_IN 12 +#define CPCAP_BIT_CDC_CLK_EN 11 +#define CPCAP_BIT_CDC_DIG_AUD_FS1 10 +#define CPCAP_BIT_CDC_DIG_AUD_FS0 9 +#define CPCAP_BIT_MIC2_TIMESLOT2 8 +#define CPCAP_BIT_MIC2_TIMESLOT1 7 +#define CPCAP_BIT_MIC2_TIMESLOT0 6 +#define CPCAP_BIT_MIC1_RX_TIMESLOT2 5 +#define CPCAP_BIT_MIC1_RX_TIMESLOT1 4 +#define CPCAP_BIT_MIC1_RX_TIMESLOT0 3 +#define CPCAP_BIT_FS_INV 2 +#define CPCAP_BIT_CLK_INV 1 +#define CPCAP_BIT_SMB_CDC 0 + +/* Register 515 CPCAP_REG_SDAC --- Stereo DAC */ +#define CPCAP_BIT_FSYNC_CLK_IN_COMMON 11 +#define CPCAP_BIT_SLAVE_PLL_CLK_INPUT 10 +#define CPCAP_BIT_ST_CLOCK_TREE_RESET 9 +#define CPCAP_BIT_DF_RESET_ST_DAC 8 +#define CPCAP_BIT_ST_SR3 7 +#define CPCAP_BIT_ST_SR2 6 +#define CPCAP_BIT_ST_SR1 5 +#define CPCAP_BIT_ST_SR0 4 +#define CPCAP_BIT_ST_DAC_CLK2 3 +#define CPCAP_BIT_ST_DAC_CLK1 2 +#define CPCAP_BIT_ST_DAC_CLK0 1 +#define CPCAP_BIT_ST_DAC_EN 0 + +/* Register 516 CPCAP_REG_SDACDI --- Stereo DAC Digital Audio Interface */ +#define CPCAP_BIT_ST_L_TIMESLOT2 13 +#define CPCAP_BIT_ST_L_TIMESLOT1 12 +#define