Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-23 Thread Sebastian Reichel
Hi,

On Fri, Feb 23, 2018 at 09:07:14AM +0100, Pavel Machek wrote:
> On Fri 2018-02-16 14:27:16, Mark Brown wrote:
> > On Fri, Feb 16, 2018 at 02:51:13PM +0100, Sebastian Reichel wrote:
> > > On Fri, Feb 16, 2018 at 11:39:01AM +, Mark Brown wrote:
> > 
> > > > We don't have default lines like this for other MFDs...
> > 
> > > Is there a reason not to add them? It looks very useful to me:
> > 
> > Consistency.  It's a lot easier to apply a single rule to everything
> > than it is to have to individually think through and discuss the
> > decisions on every individual driver, especially when there will
> > inevitably be some cases where there are conflicting requirements from
> > different users.  As you said in the rest of your mail hand configuring
> > kernels is already a very specialist thing at the best of times.
> 
> Yes, so please don't make it any harder than it needs to be. Having to
> enable (by hand) more than one option per chip is annoying and error-prone.

I will drop this and instead provide a new patch, which converts all
codecs depending on MFD_XYZ to have "default MFD_XYZ". This means,
that there will be consistency and we can discuss this with a bigger
audience without blocking the actual driver patches.

-- Sebastian


signature.asc
Description: PGP signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-23 Thread Sebastian Reichel
Hi,

On Fri, Feb 23, 2018 at 09:07:14AM +0100, Pavel Machek wrote:
> On Fri 2018-02-16 14:27:16, Mark Brown wrote:
> > On Fri, Feb 16, 2018 at 02:51:13PM +0100, Sebastian Reichel wrote:
> > > On Fri, Feb 16, 2018 at 11:39:01AM +, Mark Brown wrote:
> > 
> > > > We don't have default lines like this for other MFDs...
> > 
> > > Is there a reason not to add them? It looks very useful to me:
> > 
> > Consistency.  It's a lot easier to apply a single rule to everything
> > than it is to have to individually think through and discuss the
> > decisions on every individual driver, especially when there will
> > inevitably be some cases where there are conflicting requirements from
> > different users.  As you said in the rest of your mail hand configuring
> > kernels is already a very specialist thing at the best of times.
> 
> Yes, so please don't make it any harder than it needs to be. Having to
> enable (by hand) more than one option per chip is annoying and error-prone.

I will drop this and instead provide a new patch, which converts all
codecs depending on MFD_XYZ to have "default MFD_XYZ". This means,
that there will be consistency and we can discuss this with a bigger
audience without blocking the actual driver patches.

-- Sebastian


signature.asc
Description: PGP signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-23 Thread Pavel Machek
On Fri 2018-02-16 14:27:16, Mark Brown wrote:
> On Fri, Feb 16, 2018 at 02:51:13PM +0100, Sebastian Reichel wrote:
> > On Fri, Feb 16, 2018 at 11:39:01AM +, Mark Brown wrote:
> 
> > > We don't have default lines like this for other MFDs...
> 
> > Is there a reason not to add them? It looks very useful to me:
> 
> Consistency.  It's a lot easier to apply a single rule to everything
> than it is to have to individually think through and discuss the
> decisions on every individual driver, especially when there will
> inevitably be some cases where there are conflicting requirements from
> different users.  As you said in the rest of your mail hand configuring
> kernels is already a very specialist thing at the best of times.

Yes, so please don't make it any harder than it needs to be. Having to
enable (by hand) more than one option per chip is annoying and error-prone.

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-23 Thread Pavel Machek
On Fri 2018-02-16 14:27:16, Mark Brown wrote:
> On Fri, Feb 16, 2018 at 02:51:13PM +0100, Sebastian Reichel wrote:
> > On Fri, Feb 16, 2018 at 11:39:01AM +, Mark Brown wrote:
> 
> > > We don't have default lines like this for other MFDs...
> 
> > Is there a reason not to add them? It looks very useful to me:
> 
> Consistency.  It's a lot easier to apply a single rule to everything
> than it is to have to individually think through and discuss the
> decisions on every individual driver, especially when there will
> inevitably be some cases where there are conflicting requirements from
> different users.  As you said in the rest of your mail hand configuring
> kernels is already a very specialist thing at the best of times.

Yes, so please don't make it any harder than it needs to be. Having to
enable (by hand) more than one option per chip is annoying and error-prone.

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-16 Thread Mark Brown
On Fri, Feb 16, 2018 at 02:51:13PM +0100, Sebastian Reichel wrote:
> On Fri, Feb 16, 2018 at 11:39:01AM +, Mark Brown wrote:

> > We don't have default lines like this for other MFDs...

> Is there a reason not to add them? It looks very useful to me:

Consistency.  It's a lot easier to apply a single rule to everything
than it is to have to individually think through and discuss the
decisions on every individual driver, especially when there will
inevitably be some cases where there are conflicting requirements from
different users.  As you said in the rest of your mail hand configuring
kernels is already a very specialist thing at the best of times.


signature.asc
Description: PGP signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-16 Thread Mark Brown
On Fri, Feb 16, 2018 at 02:51:13PM +0100, Sebastian Reichel wrote:
> On Fri, Feb 16, 2018 at 11:39:01AM +, Mark Brown wrote:

> > We don't have default lines like this for other MFDs...

> Is there a reason not to add them? It looks very useful to me:

Consistency.  It's a lot easier to apply a single rule to everything
than it is to have to individually think through and discuss the
decisions on every individual driver, especially when there will
inevitably be some cases where there are conflicting requirements from
different users.  As you said in the rest of your mail hand configuring
kernels is already a very specialist thing at the best of times.


signature.asc
Description: PGP signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-16 Thread Sebastian Reichel
Hi Mark,

On Fri, Feb 16, 2018 at 11:39:01AM +, Mark Brown wrote:
> On Wed, Feb 14, 2018 at 11:07:39PM +0100, Sebastian Reichel wrote:
> 
> > +config SND_SOC_CPCAP
> > +   tristate "Motorola CPCAP codec"
> > +   depends on MFD_CPCAP
> > +   default MFD_CPCAP
> > +
> 
> We don't have default lines like this for other MFDs...

Is there a reason not to add them? It looks very useful to me:

99% of people are not interested in the MFD. They don't enable
it and are not affected at all. They do not even see extra
configuration entry due to the dependency.

0.9% of people have the MFD in their system and want their
hardware to 'just work'. With this line it's enough to enable
the MFD and the audio subsystem, so less knowledge and configuration
is required.

0.1% of people have special requirements and want the MFD
and generic audio support, but no support for the MFD audio
codec. There is a high chance, that they know how to configure
it properly :)

> > +   SOC_ENUM("Hifi Left Phase Playback Switch",
> > +   cpcap_hifi_l_phase_inv_enum),
> > +   SOC_ENUM("Ext Left Phase Playback Switch",
> > +   cpcap_ext_l_phase_inv_enum),
> 
> If this is a Switch control it should be a simple on/off binary control.
> If it's an enumeration it shouldn't have Switch at the end of the name
> since that's a keyword interpreted by userspace.  Either option seems
> fine in this case, if it's a switch it should be "Foo Invert Switch" or
> similar.

Ok.

-- Sebastian


signature.asc
Description: PGP signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-16 Thread Sebastian Reichel
Hi Mark,

On Fri, Feb 16, 2018 at 11:39:01AM +, Mark Brown wrote:
> On Wed, Feb 14, 2018 at 11:07:39PM +0100, Sebastian Reichel wrote:
> 
> > +config SND_SOC_CPCAP
> > +   tristate "Motorola CPCAP codec"
> > +   depends on MFD_CPCAP
> > +   default MFD_CPCAP
> > +
> 
> We don't have default lines like this for other MFDs...

Is there a reason not to add them? It looks very useful to me:

99% of people are not interested in the MFD. They don't enable
it and are not affected at all. They do not even see extra
configuration entry due to the dependency.

0.9% of people have the MFD in their system and want their
hardware to 'just work'. With this line it's enough to enable
the MFD and the audio subsystem, so less knowledge and configuration
is required.

0.1% of people have special requirements and want the MFD
and generic audio support, but no support for the MFD audio
codec. There is a high chance, that they know how to configure
it properly :)

> > +   SOC_ENUM("Hifi Left Phase Playback Switch",
> > +   cpcap_hifi_l_phase_inv_enum),
> > +   SOC_ENUM("Ext Left Phase Playback Switch",
> > +   cpcap_ext_l_phase_inv_enum),
> 
> If this is a Switch control it should be a simple on/off binary control.
> If it's an enumeration it shouldn't have Switch at the end of the name
> since that's a keyword interpreted by userspace.  Either option seems
> fine in this case, if it's a switch it should be "Foo Invert Switch" or
> similar.

Ok.

-- Sebastian


signature.asc
Description: PGP signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-16 Thread Sebastian Reichel
Hi Philippe,

On Thu, Feb 15, 2018 at 10:50:22AM +0100, Philippe Ombredanne wrote:
> Dear Sebastian,
> 
> On Wed, Feb 14, 2018 at 11:07 PM, Sebastian Reichel
>  wrote:
> > 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 
> 
> 
> 
> > --- /dev/null
> > +++ b/sound/soc/codecs/cpcap.c
> > @@ -0,0 +1,1588 @@
> > +/*
> > + * 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.
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + */
> 
> Could you consider using the new SPDX tags instead of this fine but
> long legalese? [1]

Sure. Thanks for the hint.

> 
> 
> > +MODULE_ALIAS("platform:cpcap-codec");
> > +MODULE_DESCRIPTION("ASoC CPCAP codec driver");
> > +MODULE_AUTHOR("Sebastian Reichel");
> > +MODULE_LICENSE("GPL");
> 
> This does not match your license: per module.h, GPL means GPL-2.0 or
> later. You notice above is GPL-2.0, not "or later"

Indeed. I will fix this in the next revision.

> [1] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/license-rules.rst

-- Sebastian


signature.asc
Description: PGP signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-16 Thread Sebastian Reichel
Hi Philippe,

On Thu, Feb 15, 2018 at 10:50:22AM +0100, Philippe Ombredanne wrote:
> Dear Sebastian,
> 
> On Wed, Feb 14, 2018 at 11:07 PM, Sebastian Reichel
>  wrote:
> > 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 
> 
> 
> 
> > --- /dev/null
> > +++ b/sound/soc/codecs/cpcap.c
> > @@ -0,0 +1,1588 @@
> > +/*
> > + * 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.
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + */
> 
> Could you consider using the new SPDX tags instead of this fine but
> long legalese? [1]

Sure. Thanks for the hint.

> 
> 
> > +MODULE_ALIAS("platform:cpcap-codec");
> > +MODULE_DESCRIPTION("ASoC CPCAP codec driver");
> > +MODULE_AUTHOR("Sebastian Reichel");
> > +MODULE_LICENSE("GPL");
> 
> This does not match your license: per module.h, GPL means GPL-2.0 or
> later. You notice above is GPL-2.0, not "or later"

Indeed. I will fix this in the next revision.

> [1] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/license-rules.rst

-- Sebastian


signature.asc
Description: PGP signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-16 Thread Mark Brown
On Wed, Feb 14, 2018 at 11:07:39PM +0100, Sebastian Reichel wrote:

> +config SND_SOC_CPCAP
> + tristate "Motorola CPCAP codec"
> + depends on MFD_CPCAP
> + default MFD_CPCAP
> +

We don't have default lines like this for other MFDs...

> + SOC_ENUM("Hifi Left Phase Playback Switch",
> + cpcap_hifi_l_phase_inv_enum),
> + SOC_ENUM("Ext Left Phase Playback Switch",
> + cpcap_ext_l_phase_inv_enum),

If this is a Switch control it should be a simple on/off binary control.
If it's an enumeration it shouldn't have Switch at the end of the name
since that's a keyword interpreted by userspace.  Either option seems
fine in this case, if it's a switch it should be "Foo Invert Switch" or
similar.


signature.asc
Description: PGP signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-16 Thread Mark Brown
On Wed, Feb 14, 2018 at 11:07:39PM +0100, Sebastian Reichel wrote:

> +config SND_SOC_CPCAP
> + tristate "Motorola CPCAP codec"
> + depends on MFD_CPCAP
> + default MFD_CPCAP
> +

We don't have default lines like this for other MFDs...

> + SOC_ENUM("Hifi Left Phase Playback Switch",
> + cpcap_hifi_l_phase_inv_enum),
> + SOC_ENUM("Ext Left Phase Playback Switch",
> + cpcap_ext_l_phase_inv_enum),

If this is a Switch control it should be a simple on/off binary control.
If it's an enumeration it shouldn't have Switch at the end of the name
since that's a keyword interpreted by userspace.  Either option seems
fine in this case, if it's a switch it should be "Foo Invert Switch" or
similar.


signature.asc
Description: PGP signature


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-15 Thread Philippe Ombredanne
Dear Sebastian,

On Wed, Feb 14, 2018 at 11:07 PM, Sebastian Reichel
 wrote:
> 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 



> --- /dev/null
> +++ b/sound/soc/codecs/cpcap.c
> @@ -0,0 +1,1588 @@
> +/*
> + * 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.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + */

Could you consider using the new SPDX tags instead of this fine but
long legalese? [1]



> +MODULE_ALIAS("platform:cpcap-codec");
> +MODULE_DESCRIPTION("ASoC CPCAP codec driver");
> +MODULE_AUTHOR("Sebastian Reichel");
> +MODULE_LICENSE("GPL");

This does not match your license: per module.h, GPL means GPL-2.0 or
later. You notice above is GPL-2.0, not "or later"

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/license-rules.rst

-- 
Cordially
Philippe Ombredanne


Re: [PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-15 Thread Philippe Ombredanne
Dear Sebastian,

On Wed, Feb 14, 2018 at 11:07 PM, Sebastian Reichel
 wrote:
> 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 



> --- /dev/null
> +++ b/sound/soc/codecs/cpcap.c
> @@ -0,0 +1,1588 @@
> +/*
> + * 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.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + */

Could you consider using the new SPDX tags instead of this fine but
long legalese? [1]



> +MODULE_ALIAS("platform:cpcap-codec");
> +MODULE_DESCRIPTION("ASoC CPCAP codec driver");
> +MODULE_AUTHOR("Sebastian Reichel");
> +MODULE_LICENSE("GPL");

This does not match your license: per module.h, GPL means GPL-2.0 or
later. You notice above is GPL-2.0, not "or later"

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/license-rules.rst

-- 
Cordially
Philippe Ombredanne


[PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-14 Thread Sebastian Reichel
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  |5 +
 sound/soc/codecs/Makefile |2 +
 sound/soc/codecs/cpcap.c  | 1588 +
 3 files changed, 1595 insertions(+)
 create mode 100644 sound/soc/codecs/cpcap.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 2b331f7266ab..25be0c64bb1a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -408,6 +408,11 @@ 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
+   default 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 ..0d5a6ce7978f
--- /dev/null
+++ b/sound/soc/codecs/cpcap.c
@@ -0,0 +1,1588 @@
+/*
+ * 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.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#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

[PATCHv4 2/4] ASoC: codec: cpcap: new codec

2018-02-14 Thread Sebastian Reichel
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  |5 +
 sound/soc/codecs/Makefile |2 +
 sound/soc/codecs/cpcap.c  | 1588 +
 3 files changed, 1595 insertions(+)
 create mode 100644 sound/soc/codecs/cpcap.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 2b331f7266ab..25be0c64bb1a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -408,6 +408,11 @@ 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
+   default 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 ..0d5a6ce7978f
--- /dev/null
+++ b/sound/soc/codecs/cpcap.c
@@ -0,0 +1,1588 @@
+/*
+ * 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.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#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