Skip to contentSkip to conversation

sound/soc/codecs: add LAPIS Semiconductor ML26124

PATCH Superseded Tomoya MORINAGA 4 participants 70 messages Feb 23, 2012 – Jun 13, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 sound/soc/codecs: add LAPIS Semiconductor ML26124

ML26124-01HB/ML26124-02GD is 16bit monaural audio CODEC which has high resistance to voltage noise. On chip regulator realizes power supply rejection ratio be over 90dB so more than 50dB is improved than ever. ML26124-01HB/ ML26124-02GD can deliver stable audio performance without being affected by noise from the power supply circuit and peripheral components. The chip also includes a composite video signal output, which can be applied to various portable device
requirements. The ML26124 is realized these functions into very small package
the size is only 2.56mm x 2.46mm therefore can be construct high quality sound system easily.
ML26124-01HB is 25pin WCSP package; ML26124-02GD is 32pin WQFN package.

---
V6
- Add break at "case SND_SOC_BIAS_ON:"
- Use switch() statement
- Delete ASoC cache code.

---
 sound/soc/codecs/Kconfig   |    4 +
 sound/soc/codecs/Makefile  |    2 +
 sound/soc/codecs/ml26124.c |  742 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/ml26124.h |  132 ++++++++
 4 files changed, 880 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/ml26124.c
 create mode 100644 sound/soc/codecs/ml26124.h
sound/soc/codecs/Kconfig +4 -0
index fa787d4..321ea08 100644
@@ -39,6 +39,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_MAX98095 if I2C
 	select SND_SOC_MAX9850 if I2C
 	select SND_SOC_MAX9877 if I2C
+	select SND_SOC_ML26124 if I2C
 	select SND_SOC_PCM3008
 	select SND_SOC_RT5631 if I2C
 	select SND_SOC_SGTL5000 if I2C
@@ -411,6 +412,9 @@ config SND_SOC_LM4857
 config SND_SOC_MAX9877
 	tristate
 
+config SND_SOC_ML26124
+	tristate
+
 config SND_SOC_TPA6130A2
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index a2c7842..b28f48e 100644
@@ -25,6 +25,7 @@ snd-soc-l3-objs := l3.o
 snd-soc-max98088-objs := max98088.o
 snd-soc-max98095-objs := max98095.o
 snd-soc-max9850-objs := max9850.o
+snd-soc-ml26124-objs := ml26124.o
 snd-soc-pcm3008-objs := pcm3008.o
 snd-soc-rt5631-objs := rt5631.o
 snd-soc-sgtl5000-objs := sgtl5000.o
@@ -126,6 +127,7 @@ obj-$(CONFIG_SND_SOC_JZ4740_CODEC)	+= snd-soc-jz4740-codec.o
 obj-$(CONFIG_SND_SOC_MAX98088)	+= snd-soc-max98088.o
 obj-$(CONFIG_SND_SOC_MAX98095)	+= snd-soc-max98095.o
 obj-$(CONFIG_SND_SOC_MAX9850)	+= snd-soc-max9850.o
+obj-$(CONFIG_SND_SOC_ML26124)	+= snd-soc-ml26124.o
 obj-$(CONFIG_SND_SOC_PCM3008)	+= snd-soc-pcm3008.o
 obj-$(CONFIG_SND_SOC_RT5631)	+= snd-soc-rt5631.o
 obj-$(CONFIG_SND_SOC_SGTL5000)  += snd-soc-sgtl5000.o
sound/soc/codecs/ml26124.c new file +742 -0

742 lines not on this page · raw message

sound/soc/codecs/ml26124.h new file +132 -0

132 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#1 lore raw

PATCH v3 1/1 sound/soc/lapis: add platform driver for ML7213

This driver is for LAPIS Semiconductor ML7213 IOH I2S.

---
V3
- Delete parameter "ignore_overrun"
- Obey kernel comment description rule
- if() statement replace switch() statement possible
- Care for read-modify-write
- Modify interrupt status condition
- Change DMA function name "filter()"
- Delete internal buffer
- Add mapping function between number and channel
- Delete magic numbers
- Commonalize/Reduce functions
- Use error macro (e.g. -ENOMEM) not negative integer value
- Use ASoC suspend/resume functions.

---
 sound/soc/Kconfig                |    1 +
 sound/soc/Makefile               |    1 +
 sound/soc/lapis/Kconfig          |    4 +
 sound/soc/lapis/Makefile         |    4 +
 sound/soc/lapis/ioh_i2s.h        |   39 +
 sound/soc/lapis/ml7213ioh-plat.c | 1543 ++++++++++++++++++++++++++++++++++++++
 sound/soc/lapis/ml7213ioh-plat.h |  367 +++++++++
 7 files changed, 1959 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/lapis/Kconfig
 create mode 100644 sound/soc/lapis/Makefile
 create mode 100644 sound/soc/lapis/ioh_i2s.h
 create mode 100644 sound/soc/lapis/ml7213ioh-plat.c
 create mode 100644 sound/soc/lapis/ml7213ioh-plat.h
sound/soc/Kconfig +1 -0
index 1381db8..ff7678f 100644
@@ -49,6 +49,7 @@ source "sound/soc/ep93xx/Kconfig"
 source "sound/soc/fsl/Kconfig"
 source "sound/soc/imx/Kconfig"
 source "sound/soc/jz4740/Kconfig"
+source "sound/soc/lapis/Kconfig"
 source "sound/soc/nuc900/Kconfig"
 source "sound/soc/omap/Kconfig"
 source "sound/soc/kirkwood/Kconfig"
sound/soc/Makefile +1 -0
index 9ea8ac8..9592f41 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_SND_SOC)	+= ep93xx/
 obj-$(CONFIG_SND_SOC)	+= fsl/
 obj-$(CONFIG_SND_SOC)   += imx/
 obj-$(CONFIG_SND_SOC)	+= jz4740/
+obj-$(CONFIG_SND_SOC)	+= lapis/
 obj-$(CONFIG_SND_SOC)	+= mid-x86/
 obj-$(CONFIG_SND_SOC)	+= mxs/
 obj-$(CONFIG_SND_SOC)	+= nuc900/
sound/soc/lapis/Kconfig new file +4 -0
new file mode 100644
index 0000000..551e385
@@ -0,0 +1,4 @@
+config SND_SOC_ML7213_PLATFORM
+	tristate "ML7213 IOH ASoC platform driver"
+	help
+	  This option enables support for the AC Link Controllers in ML7213 IOH SoC.
sound/soc/lapis/Makefile new file +4 -0
new file mode 100644
index 0000000..aba1630
@@ -0,0 +1,4 @@
+# Platform
+snd-soc-ml7213-plat-objs := ml7213ioh-plat.o
+
+obj-$(CONFIG_SND_SOC_ML7213_PLATFORM) += snd-soc-ml7213-plat.o
sound/soc/lapis/ioh_i2s.h new file +39 -0
new file mode 100644
index 0000000..9f19f70
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef ML7213_IOH_I2S
+#define ML7213_IOH_I2S
+
+enum ioh_bclkfs {
+	ML7213IOH_BCLKFS0 = 0,
+	ML7213IOH_BCLKFS1,
+	ML7213IOH_BCLKFS2,
+	ML7213IOH_BCLKFS3,
+	ML7213IOH_BCLKFS4,
+	ML7213IOH_BCLKFS5,
+};
+
+enum ioh_mclkfs {
+	ML7213IOH_MCLKFS0 = 6,
+	ML7213IOH_MCLKFS1,
+	ML7213IOH_MCLKFS2,
+	ML7213IOH_MCLKFS3,
+	ML7213IOH_MCLKFS4,
+	ML7213IOH_MCLKFS5,
+};
+
+#endif
sound/soc/lapis/ml7213ioh-plat.c new file +1543 -0

1,543 lines not on this page · raw message

sound/soc/lapis/ml7213ioh-plat.h new file +367 -0

367 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#2 lore raw

Re: [PATCH v3] sound/soc/lapis: add platform driver for ML7213

Quoted 1 line · Tomoya MORINAGA

This driver is for LAPIS Semiconductor ML7213 IOH I2S.

I just merged Lars-Peter's dmaengine library code which has been on the list for a week or so - this should be updated to use that next time it's posted. That should save a lot of code from the driver and make sure it's following best practices for dmaengine use.

sound/soc/lapis/ml7213ioh-plat.c line 37

Quoted 2 lines
sound/soc/lapis/ml7213ioh-plat.c new file +2 -0
+static struct ioh_i2s_data *i2s_data;
+static struct ioh_i2s_dma dmadata[MAX_I2S_CH];

Why are these needed, aren't they dynamically allocated by the driver?

sound/soc/lapis/ml7213ioh-plat.c line 786

Quoted 3 lines
sound/soc/lapis/ml7213ioh-plat.c new file +3 -0
+	case SNDRV_PCM_STREAM_CAPTURE:
+		offset =\
+		    ioh_rtd->dma->rx_cur_period * ioh_rtd->dma->period_bytes;

Drop the continuations, line breaks are just whitespace in C outside of macros and strings.

sound/soc/lapis/ml7213ioh-plat.c line 894

Quoted 3 lines
sound/soc/lapis/ml7213ioh-plat.c new file +3 -0
+	case SNDRV_PCM_FORMAT_S32_LE:
+		byte = 24;
+		break;

That looks wrong... are you sure you don't support S24_LE or something?

sound/soc/lapis/ml7213ioh-plat.c line 1009

Quoted 6 lines
sound/soc/lapis/ml7213ioh-plat.c new file +6 -0
+		switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+		case SND_SOC_DAIFMT_NB_NF:
+			cmn_reg[i] &= ~ML7213I2S_BCLKPOL;
+			break;
+		default:
+			return -EINVAL;

Looking at that code I suspect at least IB_NF is supported too...

sound/soc/lapis/ml7213ioh-plat.c line 1049

Quoted 6 lines
sound/soc/lapis/ml7213ioh-plat.c new file +5 -0
+static int ml7213i2s_dai_set_clkdiv(struct snd_soc_dai *dai,
+				  int div_id, int div)
+{
 
+	switch (div_id) {
+	case ML7213IOH_BCLKFS0:

This all looks like BCLK/sample calculations that the driver should really be able to figure out for itself rather than forcing every user to replicate the code to do the calculation, calculation in hw_params would be more normal.

sound/soc/lapis/ml7213ioh-plat.c line 1179

Quoted 2 lines
sound/soc/lapis/ml7213ioh-plat.c new file +2 -0
+#ifdef CONFIG_PM
+static void ioh_i2s_save_reg_conf(void)

This stuff has exactly one caller, just inline it. It's also *very* suspicious that it's not taking an argument specifying the device...

sound/soc/lapis/ml7213ioh-plat.c line 1269

Quoted 3 lines
sound/soc/lapis/ml7213ioh-plat.c new file +3 -0
+#else
+#define ml7213i2s_soc_suspend NULL
+#define spdif_soc_resume NULL

Hrm?

sound/soc/lapis/ml7213ioh-plat.c line 1300

Quoted 4 lines
sound/soc/lapis/ml7213ioh-plat.c new file +4 -0
+#ifdef CONFIG_PM
+	.suspend = ml7213i2s_soc_suspend,
+	.resume = ml7213i2s_soc_resume,
+#endif

The whole point with defining the functions to NULL above is to avoid the ifdef here.

sound/soc/lapis/ml7213ioh-plat.c line 1351

Quoted 6 lines
sound/soc/lapis/ml7213ioh-plat.c new file +4 -0
+static struct platform_driver ioh_i2s_driver_plat = {
 
+static struct platform_driver ioh_dai_driver_plat = {
 
+static int ioh_i2s_pci_probe(struct pci_dev *pdev,
+			     const struct pci_device_id *id)

Why are you creating these platform devices? I don't understand the function they serve. The code handling them looks to have quite a few problems but I'm not clear they should be there in the first place.

sound/soc/lapis/ml7213ioh-plat.c line 1393

Quoted 6 lines
sound/soc/lapis/ml7213ioh-plat.c new file +6 -0
+	rv = request_irq(pdev->irq, ioh_i2s_irq, IRQF_SHARED, "ml7213_ioh",
+			 pdev);
+	if (rv != 0) {
+		printk(KERN_ERR "Failed to allocate irq\n");
+		goto out_irq;
+	}

Are you *sure* you're ready to handle interrupts at this point?

#3 lore raw

Re: [PATCH v3] sound/soc/lapis: add platform driver for ML7213

2012年3月3日1:39 Mark Brown <[email protected]>:

Quoted 7 lines · Tomoya MORINAGA
Quoted 1 line

This driver is for LAPIS Semiconductor ML7213 IOH I2S.

I just merged Lars-Peter's dmaengine library code which has been on the list for a week or so - this should be updated to use that next time it's posted. That should save a lot of code from the driver and make sure it's following best practices for dmaengine use.

Sorry, we can't use this library.

Quoted 4 lines

sound/soc/lapis/ml7213ioh-plat.c line 37

Quoted 2 lines
sound/soc/lapis/ml7213ioh-plat.c new file +2 -0
+static struct ioh_i2s_data *i2s_data;
+static struct ioh_i2s_dma dmadata[MAX_I2S_CH];

Why are these needed, aren't they dynamically allocated by the driver?

You mean ASoC driver can't use global variable ?

Quoted 6 lines

sound/soc/lapis/ml7213ioh-plat.c line 786

Quoted 3 lines
sound/soc/lapis/ml7213ioh-plat.c new file +3 -0
+     case SNDRV_PCM_STREAM_CAPTURE:
+             offset =\
+                 ioh_rtd->dma->rx_cur_period * ioh_rtd->dma->period_bytes;

Drop the continuations, line breaks are just whitespace in C outside of macros and strings.

I see.

Quoted 6 lines

sound/soc/lapis/ml7213ioh-plat.c line 894

Quoted 4 lines
sound/soc/lapis/ml7213ioh-plat.c new file +3 -0
+     case SNDRV_PCM_FORMAT_S32_LE:
+             byte = 24;
+             break;

That looks wrong... are you sure you don't support S24_LE or something?

This is correct.
Because maximum transmit size of ML7213's I2S hw is 24bit.

Quoted 8 lines

sound/soc/lapis/ml7213ioh-plat.c line 1009

Quoted 6 lines
sound/soc/lapis/ml7213ioh-plat.c new file +6 -0
+             switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+             case SND_SOC_DAIFMT_NB_NF:
+                     cmn_reg[i] &= ~ML7213I2S_BCLKPOL;
+                     break;
+             default:
+                     return -EINVAL;

Looking at that code I suspect at least IB_NF is supported too...

Yes, our ML7213 I2s looks supporting IB_NF.
I'll add.

Quoted 11 lines

sound/soc/lapis/ml7213ioh-plat.c line 1049

Quoted 6 lines
sound/soc/lapis/ml7213ioh-plat.c new file +5 -0
+static int ml7213i2s_dai_set_clkdiv(struct snd_soc_dai *dai,
+                               int div_id, int div)
+{
 
+     switch (div_id) {
+     case ML7213IOH_BCLKFS0:

This all looks like BCLK/sample calculations that the driver should really be able to figure out for itself rather than forcing every user to replicate the code to do the calculation, calculation in hw_params would be more normal.

OK, this will move to hw_params().
and will delete snd_soc_dai_set_clkdiv() of machine driver.

Quoted 6 lines

sound/soc/lapis/ml7213ioh-plat.c line 1179

Quoted 3 lines
sound/soc/lapis/ml7213ioh-plat.c new file +2 -0
+#ifdef CONFIG_PM
+static void ioh_i2s_save_reg_conf(void)

This stuff has exactly one caller, just inline it. It's also *very* suspicious that it's not taking an argument specifying the device...

I see.
I'll open these codes.

Quoted 6 lines

sound/soc/lapis/ml7213ioh-plat.c line 1269

Quoted 4 lines
sound/soc/lapis/ml7213ioh-plat.c new file +3 -0
+#else
+#define ml7213i2s_soc_suspend NULL
+#define spdif_soc_resume NULL

Hrm?

Ah, I'll modify it to ml7213i2s_soc_resume .

Quoted 8 lines

sound/soc/lapis/ml7213ioh-plat.c line 1300

Quoted 5 lines
sound/soc/lapis/ml7213ioh-plat.c new file +4 -0
+#ifdef CONFIG_PM
+     .suspend = ml7213i2s_soc_suspend,
+     .resume = ml7213i2s_soc_resume,
+#endif

The whole point with defining the functions to NULL above is to avoid the ifdef here.

I'll delete this "#ifdef".

Quoted 12 lines

sound/soc/lapis/ml7213ioh-plat.c line 1351

Quoted 7 lines
sound/soc/lapis/ml7213ioh-plat.c new file +4 -0
+static struct platform_driver ioh_i2s_driver_plat = {
 
+static struct platform_driver ioh_dai_driver_plat = {
 
+static int ioh_i2s_pci_probe(struct pci_dev *pdev,
+                          const struct pci_device_id *id)

Why are you creating these platform devices? I don't understand the function they serve. The code handling them looks to have quite a few problems but I'm not clear they should be there in the first place.

if these platform devices aren't used, device detection doesn't work correctly. So, I added these.
I don't know other way.
Can you show other way ?

Quoted 8 lines

sound/soc/lapis/ml7213ioh-plat.c line 1393

Quoted 6 lines
sound/soc/lapis/ml7213ioh-plat.c new file +6 -0
+     rv = request_irq(pdev->irq, ioh_i2s_irq, IRQF_SHARED, "ml7213_ioh",
+                      pdev);
+     if (rv != 0) {
+             printk(KERN_ERR "Failed to allocate irq\n");
+             goto out_irq;
+     }

Are you *sure* you're ready to handle interrupts at this point?

This is just registering interrupt handler.
As long as interrupt register is not enabled, the interrupt handler is not called.
This is common request_irq description.
What's is your concern ?

thanks,

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#4 lore raw

Re: [PATCH v3] sound/soc/lapis: add platform driver for ML7213

Quoted 8 lines · Tomoya MORINAGA

2012年3月3日1:39 Mark Brown <[email protected]>:

Quoted 4 lines

I just merged Lars-Peter's dmaengine library code which has been on the list for a week or so - this should be updated to use that next time it's posted. That should save a lot of code from the driver and make sure it's following best practices for dmaengine use.

Sorry, we can't use this library.

This sort of response really isn't on. Do you have some reason for saying this? Flat out refusing to do things with no reason is not useful.

Quoted 6 lines
Quoted 4 lines

sound/soc/lapis/ml7213ioh-plat.c line 37

Quoted 2 lines
sound/soc/lapis/ml7213ioh-plat.c new file +2 -0
+static struct ioh_i2s_data *i2s_data;
+static struct ioh_i2s_dma dmadata[MAX_I2S_CH];

Why are these needed, aren't they dynamically allocated by the driver?

You mean ASoC driver can't use global variable ?

In general no Linux driver should be using a global variable except for things like this.

Quoted 9 lines
Quoted 5 lines

sound/soc/lapis/ml7213ioh-plat.c line 894

Quoted 3 lines
sound/soc/lapis/ml7213ioh-plat.c new file +3 -0
+     case SNDRV_PCM_FORMAT_S32_LE:
+             byte = 24;
+             break;

That looks wrong... are you sure you don't support S24_LE or something?

This is correct.

Because maximum transmit size of ML7213's I2S hw is 24bit.

Note we often lay out 24 bit audio in 32 bit blocks.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
sound/soc/lapis/ml7213ioh-plat.c new file +4 -0
+static struct platform_driver ioh_i2s_driver_plat = {
 
+static struct platform_driver ioh_dai_driver_plat = {
 
+static int ioh_i2s_pci_probe(struct pci_dev *pdev,
+                          const struct pci_device_id *id)
Quoted 6 lines
Quoted 3 lines

Why are you creating these platform devices? I don't understand the function they serve. The code handling them looks to have quite a few problems but I'm not clear they should be there in the first place.

if these platform devices aren't used, device detection doesn't work correctly. So, I added these.

You've not actually mentioned the problem you were seeing...

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
sound/soc/lapis/ml7213ioh-plat.c new file +6 -0
+     rv = request_irq(pdev->irq, ioh_i2s_irq, IRQF_SHARED, "ml7213_ioh",
+                      pdev);
+     if (rv != 0) {
+             printk(KERN_ERR "Failed to allocate irq\n");
+             goto out_irq;
+     }
Quoted 7 lines
Quoted 1 line

Are you *sure* you're ready to handle interrupts at this point?

This is just registering interrupt handler.
As long as interrupt register is not enabled, the interrupt handler is not called.
This is common request_irq description.
What's is your concern ?

Apart from anything else you've got the interrupt requested as IRQF_SHARED so the interrupt could get called at any time. It's also not clear that you've got the hardware in a known good state.

#5 lore raw

Re: [PATCH v3] sound/soc/lapis: add platform driver for ML7213

Quoted 8 lines · Mark Brown
Quoted 5 lines
Quoted 4 lines

I just merged Lars-Peter's dmaengine library code which has been on the list for a week or so - this should be updated to use that next time it's posted.  That should save a lot of code from the driver and make sure it's following best practices for dmaengine use.

Sorry, we can't use this library.

This sort of response really isn't on.  Do you have some reason for saying this?  Flat out refusing to do things with no reason is not useful.

Current Intel's dma driver (pch_dma) doesn't work on this library. Because the library uses function which pch_dma doesn't support. e.g. device_prep_dma_cyclic
So, we can't use this library.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

sound/soc/lapis/ml7213ioh-plat.c line 37

Quoted 2 lines
sound/soc/lapis/ml7213ioh-plat.c new file +2 -0
+static struct ioh_i2s_data *i2s_data;
+static struct ioh_i2s_dma dmadata[MAX_I2S_CH];

Why are these needed, aren't they dynamically allocated by the driver?

You mean ASoC driver can't use global variable ?

In general no Linux driver should be using a global variable except for things like this.

I see. I'll use dynamic allocation.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

+     case SNDRV_PCM_FORMAT_S32_LE:
+             byte = 24;
+             break;

That looks wrong...  are you sure you don't support S24_LE or something?

This is correct.
Because maximum transmit size of ML7213's I2S hw is 24bit.

Note we often lay out 24 bit audio in 32 bit blocks.

24bit data doesn't work on our system.
So, we don't support S24_LE.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
sound/soc/lapis/ml7213ioh-plat.c new file +2 -0
+static struct platform_driver ioh_i2s_driver_plat = {
 
+static struct platform_driver ioh_dai_driver_plat = {
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

+static int ioh_i2s_pci_probe(struct pci_dev *pdev,
+                          const struct pci_device_id *id)

Why are you creating these platform devices?  I don't understand the function they serve.  The code handling them looks to have quite a few problems but I'm not clear they should be there in the first place.

if these platform devices aren't used, device detection doesn't work correctly. So, I added these.

You've not actually mentioned the problem you were seeing...

I saw mapping problem between machine driver and platform driver. e.g. cpu_dai_name "ml7213ioh"

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

+     rv = request_irq(pdev->irq, ioh_i2s_irq, IRQF_SHARED, "ml7213_ioh",
+                      pdev);
+     if (rv != 0) {
+             printk(KERN_ERR "Failed to allocate irq\n");
+             goto out_irq;
+     }

Are you *sure* you're ready to handle interrupts at this point?

Quoted 8 lines
Quoted 5 lines

This is just registering interrupt handler.
As long as interrupt register is not enabled, the interrupt handler is not called.
This is common request_irq description.
What's is your concern ?

Apart from anything else you've got the interrupt requested as IRQF_SHARED so the interrupt could get called at any time.  It's also not clear that you've got the hardware in a known good state.

Do you mean request_irq should move to somewhere, like open() or hw_params() or ... ?

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#6 lore raw

Re: [PATCH v3] sound/soc/lapis: add platform driver for ML7213

Quoted 9 lines · Tomoya MORINAGA

On Tue, Mar 6, 2012 at 8:52 PM, Mark Brown

Quoted 4 lines
Quoted 2 lines

if these platform devices aren't used, device detection doesn't work correctly. So, I added these.

You've not actually mentioned the problem you were seeing...

I saw mapping problem between machine driver and platform driver. e.g. cpu_dai_name "ml7213ioh"

You've still not explained the problem you're seeing but this sounds like something that should work. Please address the

Quoted 6 lines
Quoted 3 lines

Apart from anything else you've got the interrupt requested as IRQF_SHARED so the interrupt could get called at any time.  It's also not clear that you've got the hardware in a known good state.

Do you mean request_irq should move to somewhere, like open() or hw_params() or ... ?

You need to do enough hardware and software initialisation prior to requesting the interrupt to ensure that if an interrupt does happen it won't cause any ill effects. Checks in the interrupt handler to make sure things like the ALSA layer stuff have been set up can also be used to make the interrupt handler safer.

#7 lore raw

Re: [PATCH v3] sound/soc/lapis: add platform driver for ML7213

Quoted 7 lines · Mark Brown
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

if these platform devices aren't used, device detection doesn't work correctly. So, I added these.

You've not actually mentioned the problem you were seeing...

I saw mapping problem between machine driver and platform driver. e.g.  cpu_dai_name "ml7213ioh"

You've still not explained the problem you're seeing but this sounds like something that should work.  Please address the

* Faced problem if there are no platform settings.
machine driver's hw_params is not called
platform_driver's functions(snd_pcm_ops, snd_soc_platform_driver) are not called.

As a result, the following message is not showed . (by soc_pcm.c) printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name,

         cpu_dai->name);
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

Apart from anything else you've got the interrupt requested as IRQF_SHARED so the interrupt could get called at any time.  It's also not clear that you've got the hardware in a known good state.

Do you mean request_irq should move to somewhere, like open() or hw_params() or ... ?

You need to do enough hardware and software initialisation prior to requesting the interrupt to ensure that if an interrupt does happen it won't cause any ill effects.  Checks in the interrupt handler to make sure things like the ALSA layer stuff have been set up can also be used to make the interrupt handler safer.

I can understand your concern.
Let me clarify your think.
You think that interrupt handler must check whether ALSA initialization has already finished or not before interrupt process executes. Right?

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#8 lore raw

Re: [PATCH v3] sound/soc/lapis: add platform driver for ML7213

Quoted 5 lines · Tomoya MORINAGA

On Wed, Mar 7, 2012 at 8:46 PM, Mark Brown

Quoted 2 lines

You've still not explained the problem you're seeing but this sounds like something that should work.  Please address the

Quoted 8 lines

* Faced problem if there are no platform settings.
machine driver's hw_params is not called
platform_driver's functions(snd_pcm_ops, snd_soc_platform_driver) are not called.

As a result, the following message is not showed . (by soc_pcm.c) printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name,

         cpu_dai->name);

This makes no sense. Registering a platform device will have *no* impact on ASoC, it only cares if the relevant ASoC function drivers have come up. Probably there was some other problem with what you were doing but it's hard to say...

Quoted 5 lines

I can understand your concern.
Let me clarify your think.
You think that interrupt handler must check whether ALSA initialization has already finished or not before interrupt process executes. Right?

Or it should be safe to run even in the card has not come up yet, either way is fine.

#9 lore raw

Re: [PATCH v3] sound/soc/lapis: add platform driver for ML7213

Quoted 9 lines · Mark Brown
Quoted 9 lines
Quoted 2 lines

You've still not explained the problem you're seeing but this sounds like something that should work.  Please address the

* Faced problem if there are no platform settings.
machine driver's hw_params is not called
platform_driver's functions(snd_pcm_ops, snd_soc_platform_driver) are not called.
As a result, the following message is not showed . (by soc_pcm.c) printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name, cpu_dai->name);

Quoted 4 lines

This makes no sense.  Registering a platform device will have *no* impact on ASoC, it only cares if the relevant ASoC function drivers have come up.  Probably there was some other problem with what you were doing but it's hard to say...

I've confirmed that driver detected by ASoC correctly without these platform functions.
Please check next patch series.

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#10 lore raw

PATCH v4 1/1 sound/soc/lapis: add platform driver for ML7213

This driver is for LAPIS Semiconductor ML7213 IOH I2S.

---
V4
- Delete redundant "struct platform_device" settings
- Move request_irq to at pcm_new()
- Allocate memory with dynamically not static
- Delete redundant '\' deteminations
- Add SND_SOC_DAIFMT_IB_NF setting
- Move dai_set_clkdiv() to dai_hw_params()
- Melt ioh_i2s_save/restore_reg_conf into ml7213i2s_soc_suspend/resume
- Delete redundant "#ifdef CONFIG_PM" condition correctly

---
 sound/soc/Kconfig                |    1 +
 sound/soc/Makefile               |    1 +
 sound/soc/lapis/Kconfig          |    4 +
 sound/soc/lapis/Makefile         |    4 +
 sound/soc/lapis/ioh_i2s.h        |   39 ++
 sound/soc/lapis/ml7213ioh-plat.c | 1320 ++++++++++++++++++++++++++++++++++++++
 sound/soc/lapis/ml7213ioh-plat.h |  376 +++++++++++
 7 files changed, 1745 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/lapis/Kconfig
 create mode 100644 sound/soc/lapis/Makefile
 create mode 100644 sound/soc/lapis/ioh_i2s.h
 create mode 100644 sound/soc/lapis/ml7213ioh-plat.c
 create mode 100644 sound/soc/lapis/ml7213ioh-plat.h
sound/soc/Kconfig +1 -0
index 91c9855..97d0d33 100644
@@ -37,6 +37,7 @@ source "sound/soc/ep93xx/Kconfig"
 source "sound/soc/fsl/Kconfig"
 source "sound/soc/imx/Kconfig"
 source "sound/soc/jz4740/Kconfig"
+source "sound/soc/lapis/Kconfig"
 source "sound/soc/nuc900/Kconfig"
 source "sound/soc/omap/Kconfig"
 source "sound/soc/kirkwood/Kconfig"
sound/soc/Makefile +1 -0
index 2feaf37..1f266ee 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_SND_SOC)	+= ep93xx/
 obj-$(CONFIG_SND_SOC)	+= fsl/
 obj-$(CONFIG_SND_SOC)   += imx/
 obj-$(CONFIG_SND_SOC)	+= jz4740/
+obj-$(CONFIG_SND_SOC)	+= lapis/
 obj-$(CONFIG_SND_SOC)	+= mid-x86/
 obj-$(CONFIG_SND_SOC)	+= mxs/
 obj-$(CONFIG_SND_SOC)	+= nuc900/
sound/soc/lapis/Kconfig new file +4 -0
new file mode 100644
index 0000000..551e385
@@ -0,0 +1,4 @@
+config SND_SOC_ML7213_PLATFORM
+	tristate "ML7213 IOH ASoC platform driver"
+	help
+	  This option enables support for the AC Link Controllers in ML7213 IOH SoC.
sound/soc/lapis/Makefile new file +4 -0
new file mode 100644
index 0000000..aba1630
@@ -0,0 +1,4 @@
+# Platform
+snd-soc-ml7213-plat-objs := ml7213ioh-plat.o
+
+obj-$(CONFIG_SND_SOC_ML7213_PLATFORM) += snd-soc-ml7213-plat.o
sound/soc/lapis/ioh_i2s.h new file +39 -0
new file mode 100644
index 0000000..9f19f70
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef ML7213_IOH_I2S
+#define ML7213_IOH_I2S
+
+enum ioh_bclkfs {
+	ML7213IOH_BCLKFS0 = 0,
+	ML7213IOH_BCLKFS1,
+	ML7213IOH_BCLKFS2,
+	ML7213IOH_BCLKFS3,
+	ML7213IOH_BCLKFS4,
+	ML7213IOH_BCLKFS5,
+};
+
+enum ioh_mclkfs {
+	ML7213IOH_MCLKFS0 = 6,
+	ML7213IOH_MCLKFS1,
+	ML7213IOH_MCLKFS2,
+	ML7213IOH_MCLKFS3,
+	ML7213IOH_MCLKFS4,
+	ML7213IOH_MCLKFS5,
+};
+
+#endif
sound/soc/lapis/ml7213ioh-plat.c new file +1320 -0

1,320 lines not on this page · raw message

sound/soc/lapis/ml7213ioh-plat.h new file +376 -0

376 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#11 lore raw

PATCH v5 1/1 sound/soc/lapis: add platform driver for ML7213

This driver is for LAPIS Semiconductor ML7213 IOH I2S.

---
v5
- Modify codec master/slave setting
- Fix DMA setting some issues
- FIX I2S setting some issues

---
 sound/soc/Kconfig                |    1 +
 sound/soc/Makefile               |    1 +
 sound/soc/lapis/Kconfig          |    4 +
 sound/soc/lapis/Makefile         |    4 +
 sound/soc/lapis/ioh_i2s.h        |   39 ++
 sound/soc/lapis/ml7213ioh-plat.c | 1388 ++++++++++++++++++++++++++++++++++++++
 sound/soc/lapis/ml7213ioh-plat.h |  381 +++++++++++
 7 files changed, 1818 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/lapis/Kconfig
 create mode 100644 sound/soc/lapis/Makefile
 create mode 100644 sound/soc/lapis/ioh_i2s.h
 create mode 100644 sound/soc/lapis/ml7213ioh-plat.c
 create mode 100644 sound/soc/lapis/ml7213ioh-plat.h
sound/soc/Kconfig +1 -0
index 91c9855..97d0d33 100644
@@ -37,6 +37,7 @@ source "sound/soc/ep93xx/Kconfig"
 source "sound/soc/fsl/Kconfig"
 source "sound/soc/imx/Kconfig"
 source "sound/soc/jz4740/Kconfig"
+source "sound/soc/lapis/Kconfig"
 source "sound/soc/nuc900/Kconfig"
 source "sound/soc/omap/Kconfig"
 source "sound/soc/kirkwood/Kconfig"
sound/soc/Makefile +1 -0
index 2feaf37..1f266ee 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_SND_SOC)	+= ep93xx/
 obj-$(CONFIG_SND_SOC)	+= fsl/
 obj-$(CONFIG_SND_SOC)   += imx/
 obj-$(CONFIG_SND_SOC)	+= jz4740/
+obj-$(CONFIG_SND_SOC)	+= lapis/
 obj-$(CONFIG_SND_SOC)	+= mid-x86/
 obj-$(CONFIG_SND_SOC)	+= mxs/
 obj-$(CONFIG_SND_SOC)	+= nuc900/
sound/soc/lapis/Kconfig new file +4 -0
new file mode 100644
index 0000000..551e385
@@ -0,0 +1,4 @@
+config SND_SOC_ML7213_PLATFORM
+	tristate "ML7213 IOH ASoC platform driver"
+	help
+	  This option enables support for the AC Link Controllers in ML7213 IOH SoC.
sound/soc/lapis/Makefile new file +4 -0
new file mode 100644
index 0000000..aba1630
@@ -0,0 +1,4 @@
+# Platform
+snd-soc-ml7213-plat-objs := ml7213ioh-plat.o
+
+obj-$(CONFIG_SND_SOC_ML7213_PLATFORM) += snd-soc-ml7213-plat.o
sound/soc/lapis/ioh_i2s.h new file +39 -0
new file mode 100644
index 0000000..9f19f70
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef ML7213_IOH_I2S
+#define ML7213_IOH_I2S
+
+enum ioh_bclkfs {
+	ML7213IOH_BCLKFS0 = 0,
+	ML7213IOH_BCLKFS1,
+	ML7213IOH_BCLKFS2,
+	ML7213IOH_BCLKFS3,
+	ML7213IOH_BCLKFS4,
+	ML7213IOH_BCLKFS5,
+};
+
+enum ioh_mclkfs {
+	ML7213IOH_MCLKFS0 = 6,
+	ML7213IOH_MCLKFS1,
+	ML7213IOH_MCLKFS2,
+	ML7213IOH_MCLKFS3,
+	ML7213IOH_MCLKFS4,
+	ML7213IOH_MCLKFS5,
+};
+
+#endif
sound/soc/lapis/ml7213ioh-plat.c new file +1388 -0

1,388 lines not on this page · raw message

sound/soc/lapis/ml7213ioh-plat.h new file +381 -0

381 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#12 lore raw

Re: [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 1 line · Tomoya MORINAGA

This driver is for LAPIS Semiconductor ML7213 IOH I2S.

So, I just said to the SPEAr guys that I really want to see support for non-cyclic dmaengine added to the helper library rather than open coding. We're seeing lots of platforms moving to dmaengine (as well as those that are in already yours is one of three out of tree platforms I'm aware of that have actively submitted stuff) and with this number of platforms we really need to get stuff factored out - there's enough people working on these platforms that it should be possible to add the support to the dmaengine library code.

A few relatively minor comments below and due to the above I haven't really reviwed the DMA but overall this looks pretty good.

sound/soc/lapis/ml7213ioh-plat.c line 36

Quoted 2 lines
sound/soc/lapis/ml7213ioh-plat.c new file +2 -0
+static struct ioh_i2s_data *i2s_data;
+static struct ioh_i2s_dma *dmadata;

These shouldn't be global, they should be device specific and passed around.

Quoted 4 lines
sound/soc/lapis/ml7213ioh-plat.c new file +4 -0
+static int ml7213i2s_dai_set_dai_sysclk(struct snd_soc_dai *dai,
+					int clk_id, unsigned int freq, int dir)
+{
+	u32 reg[MAX_I2S_CH];

sound/soc/lapis/ml7213ioh-plat.c line 1072

Quoted 10 lines
sound/soc/lapis/ml7213ioh-plat.c new file +10 -0
+	void *iobase = i2s_data->iobase;
+	int i;
+
+	for (i = 0; i < MAX_I2S_CH; i++) {
+		reg[i] = ioread32(iobase + I2SCLKCNT0_OFFSET + 0x10 * i);
+		if (clk_id == IOH_MASTERCLKSEL_MCLK)
+			reg[i] &= ~ML7213I2S_MASTER_CLK_SEL;
+		else if (clk_id == IOH_MASTERCLKSEL_MLBCLK)
+			reg[i] |= ML7213I2S_MASTER_CLK_SEL;
+		iowrite32(reg[i], iobase + I2SCLKCNT0_OFFSET + 0x10 * i);

This looks like it should be a switch statement on clk_id, this will also catch bad parameters that might get passed in.

sound/soc/lapis/ml7213ioh-plat.c line 1096

Quoted 6 lines
sound/soc/lapis/ml7213ioh-plat.c new file +6 -0
+		if ((slot < MAX_I2S_CH) &&
+				(!(tx_mapped & (1 << slot)))) {
+			dmadata[i].mapped_tx_ch = slot;
+			tx_mapped |= 1 << slot;
+		} else
+			return -EINVAL;

Braces on both sides of the if please.

#13 lore raw

Re: [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 8 lines · Mark Brown

So, I just said to the SPEAr guys that I really want to see support for non-cyclic dmaengine added to the helper library rather than open coding.  We're seeing lots of platforms moving to dmaengine (as well as those that are in already yours is one of three out of tree platforms I'm aware of that have actively submitted stuff) and with this number of platforms we really need to get stuff factored out - there's enough people working on these platforms that it should be possible to add the support to the dmaengine library code.

Do you mean you don't accept our platform/machine driver's patches unless your DMA library will have supported non-cyclic dmaengine ? Or if I'll modify your minor comments, can you accept our patches ?

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#14 lore raw

Re: [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 9 lines · Tomoya MORINAGA

On Thu, Mar 22, 2012 at 1:09 AM, Mark Brown

Quoted 3 lines

So, I just said to the SPEAr guys that I really want to see support for non-cyclic dmaengine added to the helper library rather than open coding. ?We're seeing lots of platforms moving to dmaengine (as well as

Do you mean you don't accept our platform/machine driver's patches unless your DMA library will have supported non-cyclic dmaengine ? Or if I'll modify your minor comments, can you accept our patches ?

I really want to see the dmaengine interaction factored out into a library. Like I say we've got lots of platforms doing this all being submitted at the same time, plus most of the work already there in the form of the base library. It shouldn't be too much work for the various platforms to collaborate on factoring this code out.

#15 lore raw

Re: [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 3 lines · Mark Brown

So, I just said to the SPEAr guys that I really want to see support for non-cyclic dmaengine added to the helper library rather than open coding. ?We're seeing lots of platforms moving to dmaengine (as well as

What is going on this ?
Let me know this status.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#16 lore raw

Re: [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 8 lines · Tomoya MORINAGA

On Tue, Mar 27, 2012 at 12:40 AM, Mark Brown

Quoted 3 lines

So, I just said to the SPEAr guys that I really want to see support for non-cyclic dmaengine added to the helper library rather than open coding. ?We're seeing lots of platforms moving to dmaengine (as well as

What is going on this ?
Let me know this status.

Nobody seems to be working on it as far as I can tell, I've certainly not seen any patches.

#17 lore raw

Re: [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 9 lines · Mark Brown
Quoted 6 lines
Quoted 3 lines

So, I just said to the SPEAr guys that I really want to see support for non-cyclic dmaengine added to the helper library rather than open coding. ?We're seeing lots of platforms moving to dmaengine (as well as

What is going on this ?
Let me know this status.

Nobody seems to be working on it as far as I can tell, I've certainly not seen any patches.

If so, could you accept current platform/machine driver ?

thanks in advance.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#18 lore raw

Re: [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 6 lines · Tomoya MORINAGA

On Wed, May 23, 2012 at 6:41 PM, Mark Brown

Quoted 2 lines

Nobody seems to be working on it as far as I can tell, I've certainly not seen any patches.

If so, could you accept current platform/machine driver ?

Ideally what would be happening here is that you or other people who have such systems would be working to add the required support to the core code, there's clearly a need for common code here as there are a number of different systems that don't have cyclic DMA and it wouldn't be great to end up with duplicated code.

Is there some great difficulty in factoring out the support for non-cyclic audio DMA on dmaengine - it seems like if there is we must have a serious problem in dmaengine which we should fix? If there is a substantial difficulty then that's different but it doesn't feel like we've tried doing common code yet, if there's problems doing that I'd like to understand what they are before we jump ahead of ourselves.

#19 lore raw

Re: [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 11 lines · Mark Brown
Quoted 4 lines
Quoted 2 lines

Nobody seems to be working on it as far as I can tell, I've certainly not seen any patches.

If so, could you accept current platform/machine driver ?

Ideally what would be happening here is that you or other people who have such systems would be working to add the required support to the core code, there's clearly a need for common code here as there are a number of different systems that don't have cyclic DMA and it wouldn't be great to end up with duplicated code.

Quoted 6 lines

Is there some great difficulty in factoring out the support for non-cyclic audio DMA on dmaengine - it seems like if there is we must have a serious problem in dmaengine which we should fix?  If there is a substantial difficulty then that's different but it doesn't feel like we've tried doing common code yet, if there's problems doing that I'd like to understand what they are before we jump ahead of ourselves.

I'm not so familiar with Linux's DMA idea.
So we don't know whether non-cyclic dmaengine has problem or not.

Until now, we've developed device drivers use DMA driver like UART, SPI. These drivers are implemented using the same way, you called "non-cyclic", and already applied.

As you said, common code for DMA code can be best solution. However, currently, the code is nothing.
So, I want you to accept our driver as first step.
Because I think supporting new device is more important for linux than dmaengine common.

thanks

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#20 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 20 lines · Tomoya MORINAGA
Quoted 11 lines · Mark Brown
Quoted 4 lines
Quoted 2 lines

Nobody seems to be working on it as far as I can tell, I've certainly not seen any patches.

If so, could you accept current platform/machine driver ?

Ideally what would be happening here is that you or other people who have such systems would be working to add the required support to the core code, there's clearly a need for common code here as there are a number of different systems that don't have cyclic DMA and it wouldn't be great to end up with duplicated code.

Quoted 6 lines

Is there some great difficulty in factoring out the support for non-cyclic audio DMA on dmaengine - it seems like if there is we must have a serious problem in dmaengine which we should fix? If there is a substantial difficulty then that's different but it doesn't feel like we've tried doing common code yet, if there's problems doing that I'd like to understand what they are before we jump ahead of ourselves.

Quoted 2 lines

I'm not so familiar with Linux's DMA idea.
So we don't know whether non-cyclic dmaengine has problem or not.

First you should not be writing your own dma driver, it *needs* to use dmaenegine. We already have bunch of driver supported, so there may be a case that existing driver works straight or with little modifications. Using your own dma driver is a dead road, so sooner you move over better it is.

One you move then it would be easy for you to use soc-dmaengine. If your driver doesn't support cyclic; nothing stops from you emulating that in S/W. And given that you have already contributed to dmaengine subsystem, it should be easy for you :)

Quoted 12 lines

Until now, we've developed device drivers use DMA driver like UART, SPI. These drivers are implemented using the same way, you called "non-cyclic", and already applied.

As you said, common code for DMA code can be best solution. However, currently, the code is nothing.
So, I want you to accept our driver as first step.
Because I think supporting new device is more important for linux than dmaengine common.

thanks

Signature · 1 line
~Vinod
#21 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 5 lines · Vinod Koul
Quoted 4 lines · Tomoya MORINAGA

On Thu, May 24, 2012 at 7:07 PM, Mark Brown

I'm not so familiar with Linux's DMA idea.
So we don't know whether non-cyclic dmaengine has problem or not.

Nobody has written the code, this is the problem! If the code is not there, you should try to write it. If there is some great problem writing the code then you should t

Quoted 2 lines

First you should not be writing your own dma driver, it *needs* to use dmaenegine. We already have bunch of driver supported, so there may be a

He's already done that, their current code is all open coded dmaengine stuff.

Quoted 5 lines
Quoted 5 lines

As you said, common code for DMA code can be best solution. However, currently, the code is nothing.
So, I want you to accept our driver as first step.
Because I think supporting new device is more important for linux than dmaengine common.

The existing code is far from nothing, there is a fairly substantial dmaengine library there already which should share a big chunk of code with any cyclic support. If you were saying "this is too hard for $REASON" that'd be one thing but that's not what you're saying here. It's possible that there is actually some substantial difficult but my first instinct would be that it should be relatively straightforward.

#22 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 6 lines · Mark Brown
Quoted 2 lines
Quoted 2 lines

I'm not so familiar with Linux's DMA idea.
So we don't know whether non-cyclic dmaengine has problem or not.

Nobody has written the code, this is the problem!  If the code is not there, you should try to write it.  If there is some great problem writing the code then you should t

The latter of the above seems dropped...

Quoted 5 lines
Quoted 2 lines

First you should not be writing your own dma driver, it *needs* to use dmaenegine. We already have bunch of driver supported, so there may be a

He's already done that, their current code is all open coded dmaengine stuff.

I don't understand why you say so ?
I don't use any own dma driver, right ? I use only dmaengine's. If there is own, let me show.

Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

As you said, common code for DMA code can be best solution. However, currently, the code is nothing.
So, I want you to accept our driver as first step.
Because I think supporting new device is more important for linux than dmaengine common.

The existing code is far from nothing, there is a fairly substantial dmaengine library there already which should share a big chunk of code with any cyclic support.  If you were saying "this is too hard for $REASON" that'd be one thing but that's not what you're saying here.

If our ASoC supports cyclic dma mode, we must modify both pch_dma driver and our ASoC driver.
I don't want to do this.
Because I can't understand the merit. In plain words, to me, this looks insignificant things.
In fact, current all applied ASoC drivers use dmaengine don't use cyclic mode, right ?

Quoted 2 lines

It's possible that there is actually some substantial difficult but my first instinct would be that it should be relatively straightforward.

Let me clarify your saying again.
Which do you want ?
1) pch_dma must support cyclic dma mode and our ASoC driver must use
the cyclic dma function.
2) Non-cyclic dma engine should be added to alsa-dmaengine by myself.
3) Other

Thanks

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#23 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 8 lines · Tomoya MORINAGA
Quoted 3 lines · Mark Brown

Nobody has written the code, this is the problem!  If the code is not there, you should try to write it.  If there is some great problem writing the code then you should t

The latter of the above seems dropped...

...tell us.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

First you should not be writing your own dma driver, it *needs* to use dmaenegine. We already have bunch of driver supported, so there may be a

He's already done that, their current code is all open coded dmaengine stuff.

I don't understand why you say so ?
I don't use any own dma driver, right ? I use only dmaengine's. If there is own, let me show.

Please re-read what I wrote.

Quoted 7 lines
Quoted 4 lines

The existing code is far from nothing, there is a fairly substantial dmaengine library there already which should share a big chunk of code with any cyclic support.  If you were saying "this is too hard for $REASON" that'd be one thing but that's not what you're saying here.

If our ASoC supports cyclic dma mode, we must modify both pch_dma driver and our ASoC driver.

No, all current mainline drivers using the library use cyclic DMA.

Quoted 3 lines

I don't want to do this.
Because I can't understand the merit. In plain words, to me, this looks insignificant things.

The purpose of this change is to factor code out of individual drivers into generic code rather than having lots of people writing exactly the same code. Code duplication at this level is pointless and makes more work for everyone who will have to maintain the code going forward.

Having looked at Russell's out of tree code I'm even more convinced that the amount of new code needed for non-cyclic DMA should be pretty trivial.

Quoted 8 lines
Quoted 2 lines

It's possible that there is actually some substantial difficult but my first instinct would be that it should be relatively straightforward.

Let me clarify your saying again.
Which do you want ?
1) pch_dma must support cyclic dma mode and our ASoC driver must use
the cyclic dma function.
2) Non-cyclic dma engine should be added to alsa-dmaengine by myself.

Either of these options are fine.

Quoted 1 line

3) Other

This would be someone else doing one of the above things.

#24 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 8 lines · Mark Brown
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

First you should not be writing your own dma driver, it *needs* to use dmaenegine. We already have bunch of driver supported, so there may be a

He's already done that, their current code is all open coded dmaengine stuff.

I don't understand why you say so ?
I don't use any own dma driver, right ? I use only dmaengine's. If there is own, let me show.

Please re-read what I wrote.

Let me clarify.
Do you say native DMA driver API like dmaengine_prep_slave_sg(), dmaengine_submit() shouldn't be used from ASoC driver, right ?

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

The existing code is far from nothing, there is a fairly substantial dmaengine library there already which should share a big chunk of code with any cyclic support.  If you were saying "this is too hard for $REASON" that'd be one thing but that's not what you're saying here.

If our ASoC supports cyclic dma mode, we must modify both pch_dma driver and our ASoC driver.

No, all current mainline drivers using the library use cyclic DMA.

I can't see any driver uses cyclic DMA. (I saw linux-next's tree from kernel.org.)
Where is your saying "current mainline" ?

Quoted 7 lines
Quoted 3 lines

I don't want to do this.
Because I can't understand the merit. In plain words, to me, this looks insignificant things.

The purpose of this change is to factor code out of individual drivers into generic code rather than having lots of people writing exactly the same code.  Code duplication at this level is pointless and makes more work for everyone who will have to maintain the code going forward.

I understand your saying "merit".

However I think it seems difficult for supporting all devices. Because hardware dependency control code can't be added.
For example, for ML7213, needs interrupt control both before/after DMA transfer. However, in case of using soc-dmaengine, the control can't be done. Because the processing is in soc-dmaengine.

Quoted 3 lines

Having looked at Russell's out of tree code I'm even more convinced that the amount of new code needed for non-cyclic DMA should be pretty trivial.

I don't know what you are talking about.

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#25 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 7 lines · Tomoya MORINAGA

On Wed, May 30, 2012 at 9:14 PM, Mark Brown

Quoted 1 line

Please re-read what I wrote.

Let me clarify.
Do you say native DMA driver API like dmaengine_prep_slave_sg(), dmaengine_submit() shouldn't be used from ASoC driver, right ?

Your driver should be written in terms of the ASoC DMA framework.

Quoted 5 lines
Quoted 1 line

No, all current mainline drivers using the library use cyclic DMA.

I can't see any driver uses cyclic DMA. (I saw linux-next's tree from kernel.org.)
Where is your saying "current mainline" ?

Linus' tree, or mine. Have you even looked at the soc-dmaengine-pcm code? It uncondtionally requests a cyclic channel.

Quoted 5 lines

However I think it seems difficult for supporting all devices. Because hardware dependency control code can't be added.
For example, for ML7213, needs interrupt control both before/after DMA transfer. However, in case of using soc-dmaengine, the control can't be done. Because the processing is in soc-dmaengine.

Please be more specific. What are the concrete problems that you see? Why is it not possible to address them within the framework?

#26 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 7 lines · Mark Brown
Quoted 5 lines
Quoted 1 line

Please re-read what I wrote.

Let me clarify.
Do you say native DMA driver API like dmaengine_prep_slave_sg(), dmaengine_submit() shouldn't be used from ASoC driver, right ?

Your driver should be written in terms of the ASoC DMA framework.

I understand your order.
But isn't it only me ?
You mean all ASoC driver uses dmaengine should be written in terms of the ASoC DMA framework.
Right ?

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

No, all current mainline drivers using the library use cyclic DMA.

I can't see any driver uses cyclic DMA. (I saw linux-next's tree from kernel.org.)
Where is your saying "current mainline" ?

Linus' tree, or mine.

Sorry, I couldn't find.
Is your saying Linus's tree this ?
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
However, any ASoC driver doesn't use cyclic DMA's.

Quoted 2 lines

Have you even looked at the soc-dmaengine-pcm code?  It uncondtionally requests a cyclic channel.

I already saw soc-dmaengine-pcm.c

Quoted 7 lines
Quoted 5 lines

However I think it seems difficult for supporting all devices. Because hardware dependency control code can't be added.
For example, for ML7213, needs interrupt control both before/after DMA transfer. However,  in case of using soc-dmaengine, the control can't be done. Because the processing is in soc-dmaengine.

Please be more specific.  What are the concrete problems that you see? Why is it not possible to address them within the framework?

I show the code.
+static void i2s_dma_tx_complete(void *arg)
+{
...

+
+ ioh_i2s_irq_ctrl(ioh->number, SNDRV_PCM_STREAM_PLAYBACK,
IOH_EN_IRQ); ##<<Interrupt control
+}

Our device needs interrupt control both before/after DMA transfer like above. In your soc-dma-engine, DMA transfer complete code is in soc-dma-engine, right ? So, the vendor specific code like the above can't be written.

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#27 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 6 lines · Tomoya MORINAGA
Quoted 1 line

Linus' tree, or mine.

Sorry, I couldn't find.
Is your saying Linus's tree this ?
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
However, any ASoC driver doesn't use cyclic DMA's.

$ grep CYCLIC sound/soc/soc-dmaengine-pcm.c 
	dma_cap_set(DMA_CYCLIC, mask);
#28 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 7 lines · Mark Brown
Quoted 4 lines

Sorry, I couldn't find.
Is your saying Linus's tree this ?
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
However, any ASoC driver doesn't use cyclic DMA's.

$ grep CYCLIC sound/soc/soc-dmaengine-pcm.c
       dma_cap_set(DMA_CYCLIC, mask);

I already saw this.

You said "all current mainline drivers using the library use cyclic DMA." Does this mean the following drivers use "snd_dmaengine_pcm_open" ?
ep93xx-pcm
imx-pcm-dma-mx2
mxs-pcm

However, the following drivers don't use any ASoC DMA framework, right ?. E.g. these drivers call dma_request_channel directly.
siu_pcm
fsi
txx9aclc

That is to say, some drivers ASoC DMA framework. However some drivers don't use any ASoC DMA framework.

Why didn't you do porting to your saying "ASoC DMA framework"?

thanks.

--
ROHM Co., Ltd.
tomoya

#29 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 2 lines · Tomoya MORINAGA

That is to say, some drivers ASoC DMA framework. However some drivers don't use any ASoC DMA framework.

There are some drivers that predate the availibility of the dmaengine framework.

Quoted 1 line

Why didn't you do porting to your saying "ASoC DMA framework"?

This, and the fact that the PCH driver uses dmaengine without using any shared code, is the topic of the discussion. It is entirely natural that there are no open coded drivers using cyclic DMA via dmaengine, they have all had that code factored out.

Please stop this and at least look at factoring this code out. If it turns out that there's some reason why it's a lot of work that's one thing but it seems clear that you've not even looked yet. It's like the previous issues where you were sending patches which would clearly not run successfully, it's not a very positive approach.

#30 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 2 lines · Mark Brown

There are some drivers that predate the availibility of the dmaengine framework.

In case, you develop a new ASoC framework, all previous ASoC drivers should be adopted to the framework by yourself, don't you ? Because a new developer must be confused by this.

Quoted 10 lines

This, and the fact that the PCH driver uses dmaengine without using any shared code, is the topic of the discussion.  It is entirely natural that there are no open coded drivers using cyclic DMA via dmaengine, they have all had that code factored out.

Please stop this and at least look at factoring this code out.  If it turns out that there's some reason why it's a lot of work that's one thing but it seems clear that you've not even looked yet.  It's like the previous issues where you were sending patches which would clearly not run successfully, it's not a very positive approach.

OK, I'll stop this.

I wanted to finish adding these patch series to upstream because we spent much resource on this.
But I'm involved in other work, so I can't start now.

Until now thank you for your support.
Regards.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#31 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

Quoted 8 lines · Tomoya MORINAGA

On Mon, Jun 11, 2012 at 5:54 PM, Mark Brown

Quoted 2 lines

There are some drivers that predate the availibility of the dmaengine framework.

In case, you develop a new ASoC framework, all previous ASoC drivers should be adopted to the framework by yourself, don't you ? Because a new developer must be confused by this.

This is exactly what Lars-Peter did, he updated all the drivers that used cyclic mode to use the framework. Drivers using non-cyclic mode weren't updated as there is some additional work needed in the framework.

That said, you don't always want to do this - depending on the change involved it's sometimes simpler and easier to move things over piecemeal unless there's an actual issue being created by the lack of the new firmware.

#32 lore raw

Re: [alsa-devel] [PATCH v5] sound/soc/lapis: add platform driver for ML7213

In reply to Vinod Koul
Quoted 18 lines · Vinod Koul
Quoted 18 lines
Quoted 17 lines
Quoted 4 lines
Quoted 2 lines

Nobody seems to be working on it as far as I can tell, I've certainly not seen any patches.

If so, could you accept current platform/machine driver ?

Ideally what would be happening here is that you or other people who have such systems would be working to add the required support to the core code, there's clearly a need for common code here as there are a number of different systems that don't have cyclic DMA and it wouldn't be great to end up with duplicated code.

Is there some great difficulty in factoring out the support for non-cyclic audio DMA on dmaengine - it seems like if there is we must have a serious problem in dmaengine which we should fix?  If there is a substantial difficulty then that's different but it doesn't feel like we've tried doing common code yet, if there's problems doing that I'd like to understand what they are before we jump ahead of ourselves.

Quoted 7 lines
Quoted 2 lines

I'm not so familiar with Linux's DMA idea.
So we don't know whether non-cyclic dmaengine has problem or not.

First you should not be writing your own dma driver, it *needs* to use dmaenegine. We already have bunch of driver supported, so there may be a case that existing driver works straight or with little modifications. Using your own dma driver is a dead road, so sooner you move over better it is.

I've never developed our own dma driver.
I've developed our ASoC driver using linux standard DMA framework.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#33 lore raw

PATCH v5 1/1 sound/soc/lapis: add machine driver for ML7213 Carrier Board

In reply to Tomoya MORINAGA

This machine driver is for LAPIS Semiconductor ML7213 Carrier Board.

---
V5
- Add channe_map function
- Use error macro (e.g. -ENOMEM) not negative integer value
- Add clock configuration for codec

---
 sound/soc/lapis/Kconfig             |    5 +
 sound/soc/lapis/Makefile            |    2 +
 sound/soc/lapis/ml7213ioh-machine.c |  209 +++++++++++++++++++++++++++++++++++
 3 files changed, 216 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/lapis/ml7213ioh-machine.c
sound/soc/lapis/Kconfig +5 -0
index 551e385..e869e0c 100644
@@ -2,3 +2,8 @@ config SND_SOC_ML7213_PLATFORM
 	tristate "ML7213 IOH ASoC platform driver"
 	help
 	  This option enables support for the AC Link Controllers in ML7213 IOH SoC.
+config SND_SOC_ML7213_MACHINE
+	tristate "ML7213 IOH ASoC machine driver"
+	select SND_SOC_ML7213_PLATFORM
+	help
+	  This is ASoC machine driver for ML7213 IOH
sound/soc/lapis/Makefile +2 -0
index aba1630..7ec4bea 100644
@@ -1,4 +1,6 @@
 # Platform
+snd-soc-ml7213-machine-objs := ml7213ioh-machine.o
 snd-soc-ml7213-plat-objs := ml7213ioh-plat.o
 
 obj-$(CONFIG_SND_SOC_ML7213_PLATFORM) += snd-soc-ml7213-plat.o
+obj-$(CONFIG_SND_SOC_ML7213_MACHINE) += snd-soc-ml7213-machine.o
sound/soc/lapis/ml7213ioh-machine.c new file +209 -0

209 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#34 lore raw

Re: [PATCH v5] sound/soc/lapis: add machine driver for ML7213 Carrier Board

sound/soc/lapis/Kconfig config SND_SOC_ML7213_PLATFORM · line 9

Quoted 6 lines · Tomoya MORINAGA
sound/soc/lapis/Kconfig +5 -0
 	  This option enables support for the AC Link Controllers in ML7213 IOH SoC.
+config SND_SOC_ML7213_MACHINE
+	tristate "ML7213 IOH ASoC machine driver"
+	select SND_SOC_ML7213_PLATFORM
+	help
+	  This is ASoC machine driver for ML7213 IOH

This needs to depend on the CODEC as well, how have you tested?

You're also missing a blank line between this and the previous stanza.

sound/soc/lapis/ml7213ioh-machine.c line 86

Quoted 4 lines
sound/soc/lapis/ml7213ioh-machine.c new file +4 -0
+	default:
+		pr_err("%s: Failed not support format\n", __func__);
+		return -EINVAL;
+		break;

return followed by break isn't entirely sensible.

sound/soc/lapis/ml7213ioh-machine.c line 184

Quoted 9 lines
sound/soc/lapis/ml7213ioh-machine.c new file +9 -0
+static struct platform_device *ioh_snd_device;
+
+
+static int __init ioh_i2s_init(void)
+{
+	int ret;
+	ioh_snd_device = platform_device_alloc("soc-audio", -1);
+	if (!ioh_snd_device)
+		return -ENOMEM;

Use snd_soc_register_card() and a real device.

#35 lore raw

Re: [PATCH v5] sound/soc/lapis: add machine driver for ML7213 Carrier Board

2012年3月2日22:05 Mark Brown <[email protected]>:

Quoted 10 lines · Tomoya MORINAGA

sound/soc/lapis/Kconfig config SND_SOC_ML7213_PLATFORM · line 9

Quoted 7 lines

This option enables support for the AC Link Controllers in ML7213 IOH SoC.

sound/soc/lapis/Kconfig +5 -0
+config SND_SOC_ML7213_MACHINE
+     tristate "ML7213 IOH ASoC machine driver"
+     select SND_SOC_ML7213_PLATFORM
+     help
+       This is ASoC machine driver for ML7213 IOH

This needs to depend on the CODEC as well, how have you tested?

OK, will add this.

When I test this, I selected "Build all ASoC ...." of Kconfig

Quoted 1 line

You're also missing a blank line between this and the previous stanza.

Sorry, I can't understand your saying.

Quoted 12 lines

sound/soc/lapis/ml7213ioh-machine.c line 184

Quoted 10 lines
sound/soc/lapis/ml7213ioh-machine.c new file +9 -0
+static struct platform_device *ioh_snd_device;
+
+
+static int __init ioh_i2s_init(void)
+{
+     int ret;
+     ioh_snd_device = platform_device_alloc("soc-audio", -1);
+     if (!ioh_snd_device)
+             return -ENOMEM;

Use snd_soc_register_card() and a real device.

OK.
As a matter of interest, why do you recommend me to use snd_soc_register_card() ?
At present, many ASoC drivers use platform_device_alloc.

thanks,

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#36 lore raw

Re: [PATCH v5] sound/soc/lapis: add machine driver for ML7213 Carrier Board

Quoted 5 lines · Tomoya MORINAGA

2012年3月2日22:05 Mark Brown <[email protected]>:

Quoted 1 line

You're also missing a blank line between this and the previous stanza.

Sorry, I can't understand your saying.

Your file should look like other similar files in the kernel.

Quoted 4 lines
Quoted 1 line

Use snd_soc_register_card() and a real device.

OK.
As a matter of interest, why do you recommend me to use snd_soc_register_card() ?

It's been the standard since 2.6.38.

#37 lore raw

Re: [PATCH v5] sound/soc/lapis: add machine driver for ML7213 Carrier Board

Quoted 3 lines · Mark Brown
Quoted 2 lines
Quoted 1 line

You're also missing a blank line between this and the previous stanza.

Sorry, I can't understand your saying.

Your file should look like other similar files in the kernel.

Aha, I could understand.
Need to add blank line before "config SND_SOC_ML7213_MACHINE" line.

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#38 lore raw

PATCH v6 1/1 sound/soc/lapis: add machine driver for ML7213 Carrier Board

This machine driver is for LAPIS Semiconductor ML7213 Carrier Board.

---
V6
- Add master/slave settings
- Use snd_soc_register_card
- Move set_clkdiv to dai_hw_params

---
 sound/soc/lapis/Kconfig             |    7 ++
 sound/soc/lapis/Makefile            |    2 +
 sound/soc/lapis/ml7213ioh-machine.c |  179 +++++++++++++++++++++++++++++++++++
 3 files changed, 188 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/lapis/ml7213ioh-machine.c
sound/soc/lapis/Kconfig +7 -0
index 551e385..9bc1b4d 100644
@@ -2,3 +2,10 @@ config SND_SOC_ML7213_PLATFORM
 	tristate "ML7213 IOH ASoC platform driver"
 	help
 	  This option enables support for the AC Link Controllers in ML7213 IOH SoC.
+
+config SND_SOC_ML7213_MACHINE
+	tristate "ML7213 IOH ASoC machine driver"
+	select SND_SOC_ML7213_PLATFORM
+	select SND_SOC_ML26124
+	help
+	  This is ASoC machine driver for ML7213 IOH
sound/soc/lapis/Makefile +2 -0
index aba1630..7ec4bea 100644
@@ -1,4 +1,6 @@
 # Platform
+snd-soc-ml7213-machine-objs := ml7213ioh-machine.o
 snd-soc-ml7213-plat-objs := ml7213ioh-plat.o
 
 obj-$(CONFIG_SND_SOC_ML7213_PLATFORM) += snd-soc-ml7213-plat.o
+obj-$(CONFIG_SND_SOC_ML7213_MACHINE) += snd-soc-ml7213-machine.o
sound/soc/lapis/ml7213ioh-machine.c new file +179 -0

179 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#39 lore raw

Re: [PATCH v6] sound/soc/lapis: add machine driver for ML7213 Carrier Board

sound/soc/lapis/ml7213ioh-machine.c line 103

Quoted 9 lines · Tomoya MORINAGA
sound/soc/lapis/ml7213ioh-machine.c new file +9 -0
+	/* set codec DAI configuration */
+	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+				 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+	if (ret < 0)
+		return ret;
+
+	/* set cpu DAI configuration */
+	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+				 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);

This looks very broken, you're setting the two ends of the link to different configurations. If this is needed it should be documented why.

Also, this should be set in the dai_link structure as data rather than set each time.

#40 lore raw

Re: [PATCH v6] sound/soc/lapis: add machine driver for ML7213 Carrier Board

Quoted 12 lines · Mark Brown
Quoted 9 lines · Tomoya MORINAGA

+     /* set codec DAI configuration */
+     ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+                              SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+     if (ret < 0)
+             return ret;
+
+     /* set cpu DAI configuration */
+     ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+                              SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);

Quoted 5 lines

This looks very broken, you're setting the two ends of the link to different configurations.  If this is needed it should be documented why.

Also, this should be set in the dai_link structure as data rather than set each time.

OK.
codec is slave, i2s controller is master.
So, I'll use SND_SOC_DAIFMT_CBS_CFM.

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#41 lore raw

Re: [PATCH v6] sound/soc/lapis: add machine driver for ML7213 Carrier Board

Quoted 3 lines · Tomoya MORINAGA

OK.
codec is slave, i2s controller is master.
So, I'll use SND_SOC_DAIFMT_CBS_CFM.

That means "Codec bit clock master frame clock slave". Are you sure that's what you want?

#42 lore raw

Re: [PATCH v6] sound/soc/lapis: add machine driver for ML7213 Carrier Board

Quoted 8 lines · Mark Brown
Quoted 3 lines · Tomoya MORINAGA

OK.
codec is slave, i2s controller is master.
So, I'll use SND_SOC_DAIFMT_CBS_CFM.

That means "Codec bit clock master frame clock slave".  Are you sure that's what you want?

Let me clarify the above.
Does the above "frame clock" mean "data line" of I2S? If yes, I should have used 'SND_SOC_DAIFMT_CBS_CFS'.

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#43 lore raw

Re: [PATCH v6] sound/soc/lapis: add machine driver for ML7213 Carrier Board

Quoted 8 lines · Tomoya MORINAGA

On Thu, Mar 15, 2012 at 7:50 PM, Mark Brown

Quoted 2 lines

That means "Codec bit clock master frame clock slave".  Are you sure that's what you want?

Let me clarify the above.
Does the above "frame clock" mean "data line" of I2S? If yes, I should have used 'SND_SOC_DAIFMT_CBS_CFS'.

No, it means the clock which runs at sample rate (usually called the frame clock or LRCLK).

#44 lore raw

Re: [PATCH v6] sound/soc/lapis: add machine driver for ML7213 Carrier Board

Quoted 9 lines · Mark Brown
Quoted 6 lines
Quoted 2 lines

That means "Codec bit clock master frame clock slave".  Are you sure that's what you want?

Let me clarify the above.
Does the above "frame clock" mean "data line" of I2S? If yes, I should have used 'SND_SOC_DAIFMT_CBS_CFS'.

No, it means the clock which runs at sample rate (usually called the frame clock or LRCLK).

I could understand it.
The LRCLK is also the same as bit clock for ML26124. So, I'll use 'SND_SOC_DAIFMT_CBS_CFS'.

thanks

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#45 lore raw

PATCH v7 1/1 sound/soc/lapis: add machine driver for ML7213 Carrier Board

This machine driver is for
LAPIS Semiconductor ML7213 Carrier Board + ML26124 Reference Board

---
v7
- Modify codec master/slave setting
- Add MICBIAS setting
- Add some snd_soc_dapm_enable_pin settings

---
 sound/soc/lapis/Kconfig             |    7 ++
 sound/soc/lapis/Makefile            |    2 +
 sound/soc/lapis/ml7213ioh-machine.c |  186 +++++++++++++++++++++++++++++++++++
 3 files changed, 195 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/lapis/ml7213ioh-machine.c
sound/soc/lapis/Kconfig +7 -0
index 551e385..9bc1b4d 100644
@@ -2,3 +2,10 @@ config SND_SOC_ML7213_PLATFORM
 	tristate "ML7213 IOH ASoC platform driver"
 	help
 	  This option enables support for the AC Link Controllers in ML7213 IOH SoC.
+
+config SND_SOC_ML7213_MACHINE
+	tristate "ML7213 IOH ASoC machine driver"
+	select SND_SOC_ML7213_PLATFORM
+	select SND_SOC_ML26124
+	help
+	  This is ASoC machine driver for ML7213 IOH
sound/soc/lapis/Makefile +2 -0
index aba1630..7ec4bea 100644
@@ -1,4 +1,6 @@
 # Platform
+snd-soc-ml7213-machine-objs := ml7213ioh-machine.o
 snd-soc-ml7213-plat-objs := ml7213ioh-plat.o
 
 obj-$(CONFIG_SND_SOC_ML7213_PLATFORM) += snd-soc-ml7213-plat.o
+obj-$(CONFIG_SND_SOC_ML7213_MACHINE) += snd-soc-ml7213-machine.o
sound/soc/lapis/ml7213ioh-machine.c new file +186 -0

186 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#46 lore raw

Re: [PATCH v7] sound/soc/lapis: add machine driver for ML7213 Carrier Board

sound/soc/lapis/ml7213ioh-machine.c line 89

Quoted 8 lines · Tomoya MORINAGA
sound/soc/lapis/ml7213ioh-machine.c new file +7 -0
+static int ml7213_hw_params(struct snd_pcm_substream *substream,
+			    struct snd_pcm_hw_params *hw_params)
+{
 
+	default:
+		pr_err("%s: Failed not support format\n", __func__);
+		return -EINVAL;
+		break;

No need for the break.

sound/soc/lapis/ml7213ioh-machine.c line 112

Quoted 3 lines
sound/soc/lapis/ml7213ioh-machine.c new file +3 -0
+	snd_soc_dapm_enable_pin(dapm, "Speaker");
+	snd_soc_dapm_enable_pin(dapm, "AnalogMIC");
+	snd_soc_dapm_enable_pin(dapm, "MICBIAS");

Why are you doing thiS? You never disable these things so if this were needed you may as well do it on init, but since the default state is enabled anyway this shouldn't be doing anytihng.

sound/soc/lapis/ml7213ioh-machine.c line 175

Quoted 5 lines
sound/soc/lapis/ml7213ioh-machine.c new file +5 -0
+static int __init lapis_ml7213_ml26124_init(void)
+{
+	return platform_driver_register(&snd_ml7213crb_driver);
+}
+module_init(lapis_ml7213_ml26124_init);

module_platform_driver().

Quoted 1 line

+MODULE_ALIAS("platform: lapis-ml7213ioh-CRB");

No space after the colon.

#47 lore raw

Re: [PATCH v7] sound/soc/lapis: add machine driver for ML7213 Carrier Board

Quoted 7 lines · Mark Brown
Quoted 3 lines

+     snd_soc_dapm_enable_pin(dapm, "Speaker");
+     snd_soc_dapm_enable_pin(dapm, "AnalogMIC");
+     snd_soc_dapm_enable_pin(dapm, "MICBIAS");

Why are you doing thiS?  You never disable these things so if this were needed you may as well do it on init, but since the default state is enabled anyway this shouldn't be doing anytihng.

OK.
I've confirmed if deleting these lines, both playback/capture work well. So, I'll delete these.

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#48 lore raw
In reply to Tomoya MORINAGA

sound/soc/codecs/ml26124.c line 103

Quoted 2 lines · Tomoya MORINAGA
sound/soc/codecs/ml26124.c new file +2 -0
+	SOC_SINGLE_TLV("Playback Limitter Min Input Volume",
+			ML26124_PL_MAXMIN_GAIN, 0, 7, 0, mingain),

Limiter.

sound/soc/codecs/ml26124.c line 111

Quoted 2 lines
sound/soc/codecs/ml26124.c new file +2 -0
+	SOC_SINGLE("Zero Cross Comparator Switch", ML26124_PW_ZCCMP_PW_MNG, 1,
+		    1, 0),

Usually just "ZC Switch".

sound/soc/codecs/ml26124.c line 120

Quoted 1 line
sound/soc/codecs/ml26124.c new file +1 -0
+	SOC_SINGLE("Digital Switch", ML26124_DVOL_CTL, 4, 1, 0),

This should probably be Digital Playback Switch so it lines up with the volume control in the UIs (and the Volume controls should be Digital X Volume).

sound/soc/codecs/ml26124.c line 299

Quoted 2 lines
sound/soc/codecs/ml26124.c new file +2 -0
+static int ml26124_update_bits(struct snd_soc_codec *codec, unsigned short reg,
+				unsigned int mask, unsigned int value)

Why are you open coding this in your driver? There is no point in replicating subsystem functionality.

sound/soc/codecs/ml26124.c line 465

Quoted 3 lines
sound/soc/codecs/ml26124.c new file +3 -0
+if (!priv)
+	return -1;
+

Coding style and return real error codes (though this looks like it should never happen).

sound/soc/codecs/ml26124.c line 515

Quoted 10 lines
sound/soc/codecs/ml26124.c new file +10 -0
+static int ml26124_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
+				  int div_id, int div)
+{
+	struct snd_soc_codec *codec = codec_dai->codec;
+
+	switch (div_id) {
+	case ML26124_MCLK:
+		ml26124_update_bits(codec, ML26124_CLK_CTL,
+				      BIT(0) | BIT(1), div);
+		break;

Why can't the driver calculate this automatically given the MCLK?

sound/soc/codecs/ml26124.c line 528

Quoted 2 lines
sound/soc/codecs/ml26124.c new file +2 -0
+	case SND_SOC_BIAS_ON:
+		pr_debug("%s: level=ON priv=%p\n", __func__, priv);

There's already more than enough logging in the subsystem for this.

sound/soc/codecs/ml26124.c line 532

Quoted 4 lines
sound/soc/codecs/ml26124.c new file +4 -0
+		/* VMID ON */
+		ml26124_update_bits(codec, ML26124_PW_REF_PW_MNG,
+				    ML26124_VMID, ML26124_VMID);
+		msleep(500);

This looks like it should be _STANDBY - usually VMID must be on to power everything else.

sound/soc/codecs/ml26124.c line 563

Quoted 11 lines
sound/soc/codecs/ml26124.c new file +11 -0
+static int ml26124_pcm_trigger(struct snd_pcm_substream *substream,
+			      int cmd, struct snd_soc_dai *codec_dai)
+{
+	struct snd_soc_codec *codec = codec_dai->codec;
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_STOP:
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+		ml26124_update_bits(codec, ML26124_REC_PLYBAK_RUN, 0x3,
+				    0);

I'm not sure you've tested this, you can't do I2C I/O from atomic context and trigger is atomic. What does this control actually do?

Review

Quoted 2 lines
(quoted diff) +2 -0
+		return 0;
+		break;

Duplicate return and break here.

sound/soc/codecs/ml26124.c line 621

Quoted 6 lines
sound/soc/codecs/ml26124.c new file +6 -0
+static int ml26124_resume(struct snd_soc_codec *codec)
+{
+	struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
+
+	regcache_sync(priv->regmap);
+	ml26124_set_bias_level(codec, SND_SOC_BIAS_STANDBY);

Setting the bias level will duplicate the sync.

sound/soc/codecs/ml26124.c line 640

Quoted 11 lines
sound/soc/codecs/ml26124.c new file +11 -0
+static int ml26124_probe(struct snd_soc_codec *codec)
+{
+	int ret;
+	struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
+	codec->control_data = priv->regmap;
+
+	ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
+		return ret;
+	}

You're mixing regmap API usage and ASoC level I2C, this should be _REGMAP.

sound/soc/codecs/ml26124.c line 652

Quoted 2 lines
sound/soc/codecs/ml26124.c new file +2 -0
+/* power down chip */
+static struct snd_soc_codec_driver soc_codec_dev_ml26124 = {

This comment is misplaced.

sound/soc/codecs/ml26124.c line 714

Quoted 3 lines
sound/soc/codecs/ml26124.c new file +3 -0
+static struct i2c_driver ml26124_i2c_driver = {
+	.driver = {
+		.name = "ml26124-codec",

No -codec, the device only does one thing.

sound/soc/codecs/ml26124.c line 727

Quoted 6 lines
sound/soc/codecs/ml26124.c new file +6 -0
+static int __init ml26124_modinit(void)
+{
+	int ret;
+
+	ret = i2c_add_driver(&ml26124_i2c_driver);
+	if (ret != 0)

module_i2c_driver().

#49 lore raw

2012年3月1日8:51 Mark Brown <[email protected]>:

Quoted 5 lines
Quoted 1 line

+ SOC_SINGLE("Digital Switch", ML26124_DVOL_CTL, 4, 1, 0),

This should probably be Digital Playback Switch so it lines up with the volume control in the UIs (and the Volume controls should be Digital X Volume).

No, not only Playback but also for both Playback and Capture.

Quoted 4 lines
Quoted 4 lines
sound/soc/codecs/ml26124.c new file +4 -0
+static int ml26124_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
+                               int div_id, int div)
+{
+     struct snd_soc_codec *codec = codec_dai->codec;
Quoted 8 lines

sound/soc/codecs/ml26124.c line 515

Quoted 6 lines
sound/soc/codecs/ml26124.c new file +6 -0
+
+     switch (div_id) {
+     case ML26124_MCLK:
+             ml26124_update_bits(codec, ML26124_CLK_CTL,
+                                   BIT(0) | BIT(1), div);
+             break;

Why can't the driver calculate this automatically given the MCLK?

Sorry, I can't understand your saying.
Why does this driver need to calculate ?
I think this driver can use "div" value directly.

Quoted 6 lines
Quoted 6 lines
sound/soc/codecs/ml26124.c new file +6 -0
+static int ml26124_pcm_trigger(struct snd_pcm_substream *substream,
+                           int cmd, struct snd_soc_dai *codec_dai)
+{
+     struct snd_soc_codec *codec = codec_dai->codec;
+
+     switch (cmd) {
Quoted 8 lines

sound/soc/codecs/ml26124.c line 563

Quoted 5 lines
sound/soc/codecs/ml26124.c new file +5 -0
+     case SNDRV_PCM_TRIGGER_STOP:
+     case SNDRV_PCM_TRIGGER_SUSPEND:
+     case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+             ml26124_update_bits(codec, ML26124_REC_PLYBAK_RUN, 0x3,
+                                 0);

I'm not sure you've tested this, you can't do I2C I/O from atomic context and trigger is atomic. What does this control actually do?

This control starts ether Recording or Playing or both. Anyway, this processing must be moved somewhere.

Quoted 16 lines

sound/soc/codecs/ml26124.c line 640

Quoted 12 lines
sound/soc/codecs/ml26124.c new file +11 -0
+static int ml26124_probe(struct snd_soc_codec *codec)
+{
+     int ret;
+     struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
+     codec->control_data = priv->regmap;
+
+     ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
+     if (ret < 0) {
+             dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
+             return ret;
+     }

You're mixing regmap API usage and ASoC level I2C, this should be _REGMAP.

Currently, it seems codec control via i2c works well. Let me know why I should use SND_SOC_REGMAP not _I2C.

Quoted 8 lines

sound/soc/codecs/ml26124.c line 727

Quoted 6 lines
sound/soc/codecs/ml26124.c new file +6 -0
+static int __init ml26124_modinit(void)
+{
+     int ret;
+
+     ret = i2c_add_driver(&ml26124_i2c_driver);
+     if (ret != 0)

module_i2c_driver().

Sorry, I can't understand your saying.

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#50 lore raw
Quoted 13 lines · Tomoya MORINAGA

2012年3月1日8:51 Mark Brown <[email protected]>:

Quoted 10 lines
Quoted 10 lines
sound/soc/codecs/ml26124.c new file +9 -0
+static int ml26124_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
+                               int div_id, int div)
+{
+     struct snd_soc_codec *codec = codec_dai->codec;
 
+     switch (div_id) {
+     case ML26124_MCLK:
+             ml26124_update_bits(codec, ML26124_CLK_CTL,
+                                   BIT(0) | BIT(1), div);
+             break;
Quoted 5 lines
Quoted 1 line

Why can't the driver calculate this automatically given the MCLK?

Sorry, I can't understand your saying.
Why does this driver need to calculate ?
I think this driver can use "div" value directly.

Why does the user have to set this divider by hand at all? There's already a set_sysclk() function, just have the user specify the clock they're providing.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

+ ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);

You're mixing regmap API usage and ASoC level I2C, this should be _REGMAP.

Currently, it seems codec control via i2c works well. Let me know why I should use SND_SOC_REGMAP not _I2C.

Have you checked what _I2C and _REGMAP do?

Quoted 10 lines
Quoted 8 lines

sound/soc/codecs/ml26124.c line 727

Quoted 6 lines
sound/soc/codecs/ml26124.c new file +6 -0
+static int __init ml26124_modinit(void)
+{
+     int ret;
+
+     ret = i2c_add_driver(&ml26124_i2c_driver);
+     if (ret != 0)

module_i2c_driver().

Sorry, I can't understand your saying.

Use module_i2c_driver().

#51 lore raw

2012年3月2日21:58 Mark Brown <[email protected]>:

Quoted 13 lines
Quoted 12 lines
Quoted 12 lines

sound/soc/codecs/ml26124.c line 515

Quoted 10 lines
sound/soc/codecs/ml26124.c new file +9 -0
+static int ml26124_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
+                               int div_id, int div)
+{
+     struct snd_soc_codec *codec = codec_dai->codec;
 
+     switch (div_id) {
+     case ML26124_MCLK:
+             ml26124_update_bits(codec, ML26124_CLK_CTL,
+                                   BIT(0) | BIT(1), div);
+             break;

Why can't the driver calculate this automatically given the MCLK?

Quoted 7 lines
Quoted 3 lines

Sorry, I can't understand your saying.
Why does this driver need to calculate ?
I think this driver can use "div" value directly.

Why does the user have to set this divider by hand at all? There's already a set_sysclk() function, just have the user specify the clock they're providing.

I see.
This processing will move to set_sysclk()

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+ ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);

You're mixing regmap API usage and ASoC level I2C, this should be _REGMAP.

Currently, it seems codec control via i2c works well. Let me know why I should use SND_SOC_REGMAP not _I2C.

Have you checked what _I2C and _REGMAP do?

I've just checked it.
If SND_SOC_REGMAP is used, it seems there is no processing in it. So, can I delete snd_soc_codec_set_cache_io ?

Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

sound/soc/codecs/ml26124.c line 727

Quoted 7 lines
sound/soc/codecs/ml26124.c new file +6 -0
+static int __init ml26124_modinit(void)
+{
+     int ret;
+
+     ret = i2c_add_driver(&ml26124_i2c_driver);
+     if (ret != 0)

module_i2c_driver().

Quoted 3 lines
Quoted 1 line

Sorry, I can't understand your saying.

Use module_i2c_driver().

I understand.
As a matter of interest, why can I use module_i2c_driver ? There is no ASoC driver uses module_i2c_driver.

Quoted 5 lines

sound/soc/codecs/ml26124.c line 299

Quoted 2 lines
sound/soc/codecs/ml26124.c new file +2 -0
+static int ml26124_update_bits(struct snd_soc_codec *codec, unsigned short reg,
+                             unsigned int mask, unsigned int value)

Why are you open coding this in your driver? There is no point in replicating subsystem functionality.

For ML26124 spec, it's necessary.
Because the codec's register read-address and write-address is not the same. E.G.
Sampling Rate Register
R: offset=0
W: offset=1

thanks,

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#52 lore raw
Quoted 8 lines · Tomoya MORINAGA

2012年3月2日21:58 Mark Brown <[email protected]>:

Quoted 3 lines
Quoted 1 line

Let me know why I should use SND_SOC_REGMAP not _I2C.

Have you checked what _I2C and _REGMAP do?

I've just checked it.
If SND_SOC_REGMAP is used, it seems there is no processing in it.

This is not the case.

Quoted 1 line

So, can I delete snd_soc_codec_set_cache_io ?

No.

Quoted 5 lines
Quoted 1 line

Use module_i2c_driver().

I understand.

As a matter of interest, why can I use module_i2c_driver ?

It is best practice.

Quoted 1 line

There is no ASoC driver uses module_i2c_driver.

This is not the case. As I have *REPEATEDLY* told you you should be sumbitting code against current development versions of the subsystem.

Quoted 6 lines
Quoted 5 lines

sound/soc/codecs/ml26124.c line 299

Quoted 2 lines
sound/soc/codecs/ml26124.c new file +2 -0
+static int ml26124_update_bits(struct snd_soc_codec *codec, unsigned short reg,
+                             unsigned int mask, unsigned int value)

Why are you open coding this in your driver? There is no point in replicating subsystem functionality.

Quoted 6 lines

For ML26124 spec, it's necessary.
Because the codec's register read-address and write-address is not the same. E.G.
Sampling Rate Register
R: offset=0
W: offset=1

This is not what the above prototype says, the above prototype has only one register in it. You need to make this *much* clearer for the registers it's affecting.

#53 lore raw

On Tue, Mar 06, 2012 19:00 Mark Brown <[email protected]>:

Quoted 2 lines

This is not the case. As I have *REPEATEDLY* told you you should be sumbitting code against current development versions of the subsystem.

You are right. v3.3-rc6 uses it. sorry for inconvenience.

Quoted 12 lines
Quoted 11 lines
Quoted 4 lines

sound/soc/codecs/ml26124.c line 299

Quoted 2 lines
sound/soc/codecs/ml26124.c new file +2 -0
+static int ml26124_update_bits(struct snd_soc_codec *codec, unsigned short reg,
+                             unsigned int mask, unsigned int value)

Why are you open coding this in your driver? There is no point in replicating subsystem functionality.

For ML26124 spec, it's necessary.
Because the codec's register read-address and write-address is not the same. E.G.
Sampling Rate Register
R: offset=0
W: offset=1

Quoted 3 lines

This is not what the above prototype says, the above prototype has only one register in it. You need to make this *much* clearer for the registers it's affecting.

Sorry, I couldn't understand your saying / concern.
Do you mean I shouldn't use ml26124_update_bits() but snd_soc_update_bits() ?

thanks,

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#54 lore raw
Quoted 8 lines · Tomoya MORINAGA

On Tue, Mar 06, 2012 19:00 Mark Brown <[email protected]>:

Quoted 3 lines

This is not what the above prototype says, the above prototype has only one register in it. You need to make this *much* clearer for the registers it's affecting.

Sorry, I couldn't understand your saying / concern.
Do you mean I shouldn't use ml26124_update_bits() but snd_soc_update_bits() ?

Ideally you should be using the framework features. If there is some reason why you can't you need to make it much clearer what the reason is so people reading the code can understand.

#55 lore raw
Quoted 8 lines · Mark Brown
Quoted 5 lines
Quoted 3 lines

This is not what the above prototype says, the above prototype has only one register in it.  You need to make this *much* clearer for the registers it's affecting.

Sorry, I couldn't understand your saying / concern.
Do you mean I shouldn't use ml26124_update_bits() but snd_soc_update_bits() ?

Ideally you should be using the framework features.  If there is some reason why you can't you need to make it much clearer what the reason is so people reading the code can understand.

If possible, I want to use framework features. However, I judged it is not possible.
Let me confirm again.
As I said before, all ML26124 registers need to be accessed by different address when read and write.
Like below
R W
$00h $01h Sampling setting
$02h $03h PLL setting
...

Even so, can I use framework features ?

thanks,

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#56 lore raw
Quoted 11 lines · Tomoya MORINAGA

If possible, I want to use framework features. However, I judged it is not possible.
Let me confirm again.
As I said before, all ML26124 registers need to be accessed by different address when read and write.
Like below
R W
$00h $01h Sampling setting
$02h $03h PLL setting
...

Quoted 1 line

Even so, can I use framework features ?

No, in which case (to repeat what I said previously) you need to make the code *much* clearer so the reader can understand what it is doing and why it's having to open code this stuff.

#57 lore raw
Quoted 11 lines · Mark Brown
Quoted 11 lines

If possible, I want to use framework features. However, I judged it is not possible.
Let me confirm again.
As I said before, all ML26124 registers need to be accessed by different address when read and write.
Like below
R       W
$00h $01h Sampling setting
$02h $03h PLL setting
...
Even so, can I use framework features ?

Quoted 3 lines

No, in which case (to repeat what I said previously) you need to make the code *much* clearer so the reader can understand what it is doing and why it's having to open code this stuff.

I understand you agree to use ml26124_update_bits(), right ?
If so, do you mean that I should just add explanation (like as I explained before)
why the function() is necessary to above prototype of ml26124_update_bits() ?

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#58 lore raw
Quoted 3 lines · Tomoya MORINAGA

If so, do you mean that I should just add explanation (like as I explained before)
why the function() is necessary to above prototype of ml26124_update_bits() ?

Probably also make the interface clearer about the fact that it operates on multiple registers too.

#59 lore raw

PATCH v7 1/1 sound/soc/codecs: add LAPIS Semiconductor ML26124

ML26124-01HB/ML26124-02GD is 16bit monaural audio CODEC which has high resistance to voltage noise. On chip regulator realizes power supply rejection ratio be over 90dB so more than 50dB is improved than ever. ML26124-01HB/ ML26124-02GD can deliver stable audio performance without being affected by noise from the power supply circuit and peripheral components. The chip also includes a composite video signal output, which can be applied to various portable device
requirements. The ML26124 is realized these functions into very small package
the size is only 2.56mm x 2.46mm therefore can be construct high quality sound system easily.
ML26124-01HB is 25pin WCSP package; ML26124-02GD is 32pin WQFN package.

---
V7
- Add explanation of "ml26124_update_bits()"
- Use module_i2c_driver()
- ml26124_set_dai_clkdiv() moved to ml26124_set_dai_sysclk()
- VMID_ON moved to SND_SOC_BIAS_STANDBY
- Deleted redundant regcache_sync
- Modified SND_SOC_I2C to SND_SOC_REGMAP of snd_soc_codec_set_cache_io()
- Deleted "-codec" post-fix

---
 sound/soc/codecs/Kconfig   |    4 +
 sound/soc/codecs/Makefile  |    2 +
 sound/soc/codecs/ml26124.c |  707 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/ml26124.h |  132 ++++++++
 4 files changed, 845 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/ml26124.c
 create mode 100644 sound/soc/codecs/ml26124.h
sound/soc/codecs/Kconfig +4 -0
index 6508e8b..e314a66 100644
@@ -42,6 +42,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_MAX9850 if I2C
 	select SND_SOC_MAX9768 if I2C
 	select SND_SOC_MAX9877 if I2C
+	select SND_SOC_ML26124 if I2C
 	select SND_SOC_PCM3008
 	select SND_SOC_RT5631 if I2C
 	select SND_SOC_SGTL5000 if I2C
@@ -436,5 +437,8 @@ config SND_SOC_MAX9768
 config SND_SOC_MAX9877
 	tristate
 
+config SND_SOC_ML26124
+	tristate
+
 config SND_SOC_TPA6130A2
 	tristate
sound/soc/codecs/Makefile +2 -0
index 6662eb0..9108ee9 100644
@@ -29,6 +29,7 @@ snd-soc-max9768-objs := max9768.o
 snd-soc-max98088-objs := max98088.o
 snd-soc-max98095-objs := max98095.o
 snd-soc-max9850-objs := max9850.o
+snd-soc-ml26124-objs := ml26124.o
 snd-soc-pcm3008-objs := pcm3008.o
 snd-soc-rt5631-objs := rt5631.o
 snd-soc-sgtl5000-objs := sgtl5000.o
@@ -135,6 +136,7 @@ obj-$(CONFIG_SND_SOC_MAX9768)	+= snd-soc-max9768.o
 obj-$(CONFIG_SND_SOC_MAX98088)	+= snd-soc-max98088.o
 obj-$(CONFIG_SND_SOC_MAX98095)	+= snd-soc-max98095.o
 obj-$(CONFIG_SND_SOC_MAX9850)	+= snd-soc-max9850.o
+obj-$(CONFIG_SND_SOC_ML26124)	+= snd-soc-ml26124.o
 obj-$(CONFIG_SND_SOC_PCM3008)	+= snd-soc-pcm3008.o
 obj-$(CONFIG_SND_SOC_RT5631)	+= snd-soc-rt5631.o
 obj-$(CONFIG_SND_SOC_SGTL5000)  += snd-soc-sgtl5000.o
sound/soc/codecs/ml26124.c new file +707 -0

707 lines not on this page · raw message

sound/soc/codecs/ml26124.h new file +132 -0

132 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#60 lore raw

On Fri, Mar 09, 2012 at 03:37:06PM +0900, Tomoya MORINAGA wrote:

A substantial improvement on previous versions but there's still a few issues, though they're now fairly small.

sound/soc/codecs/ml26124.c line 497

Quoted 12 lines
sound/soc/codecs/ml26124.c new file +12 -0
+	/* SAI configuration */
+	if (priv->channels == 1) {
+		ml26124_update_bits(codec, ML26124_SAI_TRANS_CTL, mask,
+				ML26124_SAI_NO_DELAY | ML26124_SAI_FRAME_SYNC);
+		ml26124_update_bits(codec, ML26124_SAI_RCV_CTL, mask,
+				ML26124_SAI_NO_DELAY | ML26124_SAI_FRAME_SYNC);
+	} else {
+		ml26124_update_bits(codec, ML26124_SAI_TRANS_CTL, mask,
+				    ML26124_SAI_NO_DELAY);
+		ml26124_update_bits(codec, ML26124_SAI_RCV_CTL, mask,
+				    ML26124_SAI_NO_DELAY);
+	}

What happens if the system switches between 1 channel mode and multi-channel mode at runtime? It looks like _SYNC will never be cleared.

Quoted 13 lines
sound/soc/codecs/ml26124.c new file +13 -0
+static int ml26124_set_dai_sysclk(struct snd_soc_dai *codec_dai,
+		int clk_id, unsigned int freq, int dir)
+{
+	struct snd_soc_codec *codec = codec_dai->codec;
+	struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
+
+	switch (clk_id) {
+	case ML26124_USE_PLL:
+		ml26124_update_bits(codec, ML26124_CLK_CTL,
+				    BIT(0) | BIT(1), 0);
+		break;
+	case ML26124_USE_MCLKI_256FS:
+		ml26124_update_bits(codec, ML26124_CLK_CTL,

sound/soc/codecs/ml26124.c line 525

Quoted 10 lines
sound/soc/codecs/ml26124.c new file +10 -0
+				    BIT(0) | BIT(1), 1);
+		break;
+	case ML26124_USE_MCLKI_512FS:
+		ml26124_update_bits(codec, ML26124_CLK_CTL,
+				    BIT(0) | BIT(1), 2);
+		break;
+	case ML26124_USE_MCLKI_1024FS:
+		ml26124_update_bits(codec, ML26124_CLK_CTL,
+				    BIT(0) | BIT(1), 3);
+		break;

Why not just specify the MCLK rate and then calculate the division based on the sample rate?

sound/soc/codecs/ml26124.c line 533

Quoted 4 lines
sound/soc/codecs/ml26124.c new file +4 -0
+	switch (freq) {
+	case 12288000:
+		priv->mclk = freq;
+		break;

This is especially true given that only one MCLK rate is supported.

sound/soc/codecs/ml26124.c line 553

Quoted 5 lines
sound/soc/codecs/ml26124.c new file +5 -0
+	case SND_SOC_BIAS_STANDBY:
+		/* VMID ON */
+		ml26124_update_bits(codec, ML26124_PW_REF_PW_MNG,
+				    ML26124_VMID, ML26124_VMID);
+		msleep(500);

This will sleep for 500ms when powering down which probably isn't what's desired...

#61 lore raw
Quoted 14 lines · Mark Brown
Quoted 4 lines · Tomoya MORINAGA

+     /* SAI configuration */
+     if (priv->channels == 1) {
+             ml26124_update_bits(codec, ML26124_SAI_TRANS_CTL, mask,
+                             ML26124_SAI_NO_DELAY | ML26124_SAI_FRAME_SYNC);

Quoted 8 lines

+             ml26124_update_bits(codec, ML26124_SAI_RCV_CTL, mask,
+                             ML26124_SAI_NO_DELAY | ML26124_SAI_FRAME_SYNC);
+     } else {
+             ml26124_update_bits(codec, ML26124_SAI_TRANS_CTL, mask,
+                                 ML26124_SAI_NO_DELAY);
+             ml26124_update_bits(codec, ML26124_SAI_RCV_CTL, mask,
+                                 ML26124_SAI_NO_DELAY);
+     }

Quoted 3 lines

What happens if the system switches between 1 channel mode and multi-channel mode at runtime?  It looks like _SYNC will never be cleared.

Sorry, 'priv->channels == 1' means for telephone codec. However, we don't support this function.
So, I'll delete these lines.

Quoted 18 lines
Quoted 18 lines
sound/soc/codecs/ml26124.c new file +18 -0
+static int ml26124_set_dai_sysclk(struct snd_soc_dai *codec_dai,
+             int clk_id, unsigned int freq, int dir)
+{
+     struct snd_soc_codec *codec = codec_dai->codec;
+     struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
+
+     switch (clk_id) {
+     case ML26124_USE_PLL:
+             ml26124_update_bits(codec, ML26124_CLK_CTL,
+                                 BIT(0) | BIT(1), 0);
+             break;
+     case ML26124_USE_MCLKI_256FS:
+             ml26124_update_bits(codec, ML26124_CLK_CTL,
+                                 BIT(0) | BIT(1), 1);
+             break;
+     case ML26124_USE_MCLKI_512FS:
+             ml26124_update_bits(codec, ML26124_CLK_CTL,
+                                 BIT(0) | BIT(1), 2);
Quoted 8 lines
Quoted 5 lines

+             break;
+     case ML26124_USE_MCLKI_1024FS:
+             ml26124_update_bits(codec, ML26124_CLK_CTL,
+                                 BIT(0) | BIT(1), 3);
+             break;

Why not just specify the MCLK rate and then calculate the division based on the sample rate?

OK, I'll do like your saying.

Quoted 9 lines
Quoted 6 lines

+     case SND_SOC_BIAS_STANDBY:
+             /* VMID ON */
+             ml26124_update_bits(codec, ML26124_PW_REF_PW_MNG,
+                                 ML26124_VMID, ML26124_VMID);
+             msleep(500);

This will sleep for 500ms when powering down which probably isn't what's desired...

I'll Move into "if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)" condition.

thanks.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#62 lore raw
In reply to Tomoya MORINAGA
Quoted 13 lines · Tomoya MORINAGA
Quoted 11 lines · Mark Brown
Quoted 11 lines

If possible, I want to use framework features. However, I judged it is not possible.
Let me confirm again.
As I said before, all ML26124 registers need to be accessed by different address when read and write.
Like below
R W
$00h $01h Sampling setting
$02h $03h PLL setting
...
Even so, can I use framework features ?

Quoted 6 lines
Quoted 3 lines

No, in which case (to repeat what I said previously) you need to make the code *much* clearer so the reader can understand what it is doing and why it's having to open code this stuff.

thanks.

If this is for all registers, how does stuff like DAPM work, which uses the framework internal update_bits function?

If it's the case that the write address is always read address + 1 you can still use the framework if you set write_flag_mask to 0x01 in your regmap config. In my opinion it even makes sense to shift all the register numbers to the left by one and use a 7/9 instead of a 8/8 addr/reg layout. This will reduce the amount of memory wasted due to holes in the register cache.

#63 lore raw
Quoted 2 lines · Lars-Peter Clausen

If this is for all registers, how does stuff like DAPM work, which uses the framework internal update_bits function?

I was assuming that this was just for specific registers which were weird (frankly I've no idea what the chip designers were thinking if this is actually needed).

Though based on some of the issues I found on previous versions there's every chance that there's not been any testing... if that's the case it's possible this is a misunderstanding of the I2C read/write handling with the chip address?

#64 lore raw
In reply to Lars-Peter Clausen
Quoted 8 lines · Lars-Peter Clausen

If this is for all registers, how does stuff like DAPM work, which uses the framework internal update_bits function?

If it's the case that the write address is always read address + 1 you can still use the framework if you set write_flag_mask to 0x01 in your regmap config. In my opinion it even makes sense to shift all the register numbers to the left by one and use a 7/9 instead of a 8/8 addr/reg layout. This will reduce the amount of memory wasted due to holes in the register cache.

Thank you for your information.
I've just been investigating these.
I also found ASoC core access i2c driver via snd_soc_update_bits or others. As a result, write register address is the same as read's.

I'll try to implement these.

BTW, currently, by settting ML26124 codec with fixed value, I've confirmed both playback and capture work well.

thanks

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#65 lore raw
Quoted 14 lines · Tomoya MORINAGA
Quoted 8 lines

If this is for all registers, how does stuff like DAPM work, which uses the framework internal update_bits function?

If it's the case that the write address is always read address + 1 you can still use the framework if you set write_flag_mask to 0x01 in your regmap config. In my opinion it even makes sense to shift all the register numbers to the left by one and use a 7/9 instead of a 8/8 addr/reg layout. This will reduce the amount of memory wasted due to holes in the register cache.

Thank you for your information.
I've just been investigating these.
I also found ASoC core access i2c driver via snd_soc_update_bits or others. As a result, write register address is the same as read's.

Quoted 4 lines

I'll try to implement these.

BTW, currently, by settting ML26124 codec with fixed value, I've confirmed both playback and capture work well.

Thank you for your help,
almost of ML26124 registers can be set correctly except SUPPLY. So, I have a question.

When SND_SOC_DAPM_SUPPLY is executed ?
or
Do I need to execute from application (like amixer) ?

thanks in advance.

Signature · 2 lines
ROHM Co., Ltd.
tomoya
#66 lore raw
Quoted 3 lines · Tomoya MORINAGA

When SND_SOC_DAPM_SUPPLY is executed ?
or
Do I need to execute from application (like amixer) ?

As with all DAPM widgets it is automatically managed by DAPM as needed.

#67 lore raw

PATCH v8 1/1 sound/soc/codecs: add LAPIS Semiconductor ML26124

ML26124-01HB/ML26124-02GD is 16bit monaural audio CODEC which has high resistance to voltage noise. On chip regulator realizes power supply rejection ratio be over 90dB so more than 50dB is improved than ever. ML26124-01HB/ ML26124-02GD can deliver stable audio performance without being affected by noise from the power supply circuit and peripheral components. The chip also includes a composite video signal output, which can be applied to various portable device
requirements. The ML26124 is realized these functions into very small package
the size is only 2.56mm x 2.46mm therefore can be construct high quality sound system easily.
ML26124-01HB is 25pin WCSP package; ML26124-02GD is 32pin WQFN package.

---
v8
- Modify codec master/slave setting
- Modify interconnection/dapm setting
- Use snd_soc_update_bits not ml26124_update_bits which is delted
- Change Regmap setting (Add .write_flag_mask = 0x01)

---
 sound/soc/codecs/Kconfig   |    4 +
 sound/soc/codecs/Makefile  |    2 +
 sound/soc/codecs/ml26124.c |  681 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/ml26124.h |  184 ++++++++++++
 4 files changed, 871 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/ml26124.c
 create mode 100644 sound/soc/codecs/ml26124.h
sound/soc/codecs/Kconfig +4 -0
index 6508e8b..e314a66 100644
@@ -42,6 +42,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_MAX9850 if I2C
 	select SND_SOC_MAX9768 if I2C
 	select SND_SOC_MAX9877 if I2C
+	select SND_SOC_ML26124 if I2C
 	select SND_SOC_PCM3008
 	select SND_SOC_RT5631 if I2C
 	select SND_SOC_SGTL5000 if I2C
@@ -436,5 +437,8 @@ config SND_SOC_MAX9768
 config SND_SOC_MAX9877
 	tristate
 
+config SND_SOC_ML26124
+	tristate
+
 config SND_SOC_TPA6130A2
 	tristate
sound/soc/codecs/Makefile +2 -0
index 6662eb0..9108ee9 100644
@@ -29,6 +29,7 @@ snd-soc-max9768-objs := max9768.o
 snd-soc-max98088-objs := max98088.o
 snd-soc-max98095-objs := max98095.o
 snd-soc-max9850-objs := max9850.o
+snd-soc-ml26124-objs := ml26124.o
 snd-soc-pcm3008-objs := pcm3008.o
 snd-soc-rt5631-objs := rt5631.o
 snd-soc-sgtl5000-objs := sgtl5000.o
@@ -135,6 +136,7 @@ obj-$(CONFIG_SND_SOC_MAX9768)	+= snd-soc-max9768.o
 obj-$(CONFIG_SND_SOC_MAX98088)	+= snd-soc-max98088.o
 obj-$(CONFIG_SND_SOC_MAX98095)	+= snd-soc-max98095.o
 obj-$(CONFIG_SND_SOC_MAX9850)	+= snd-soc-max9850.o
+obj-$(CONFIG_SND_SOC_ML26124)	+= snd-soc-ml26124.o
 obj-$(CONFIG_SND_SOC_PCM3008)	+= snd-soc-pcm3008.o
 obj-$(CONFIG_SND_SOC_RT5631)	+= snd-soc-rt5631.o
 obj-$(CONFIG_SND_SOC_SGTL5000)  += snd-soc-sgtl5000.o
sound/soc/codecs/ml26124.c new file +681 -0

681 lines not on this page · raw message

sound/soc/codecs/ml26124.h new file +184 -0

184 lines not on this page · raw message

Signature · 1 line
1.7.7.6
Applied
#68 lore raw
Quoted 2 lines · Tomoya MORINAGA

ML26124-01HB/ML26124-02GD is 16bit monaural audio CODEC which has high resistance to voltage noise. On chip regulator realizes power supply rejection

Applied, thanks, but:

- Stop sending patches as followups to old patches, this really doesn't
- Do try to use subject lines for your patches which are consistent with the subsystem.

#69 lore raw
Quoted 8 lines · Mark Brown
Quoted 2 lines

ML26124-01HB/ML26124-02GD is 16bit monaural audio CODEC which has high resistance to voltage noise. On chip regulator realizes power supply rejection

Applied, thanks, but:

 - Stop sending patches as followups to old patches, this really doesn't
 - Do try to use subject lines for your patches which are consistent with the subsystem.

OK.
I'll do the above.

thanks

Signature · 2 lines
ROHM Co., Ltd.
tomoya