Skip to contentSkip to conversation

ASoC: SAMSUNG: Add quirk to support Exynos4 PCM audio

PATCH Superseded Sangbeom Kim 2 participants 3 messages Apr 28, 2011

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ASoC: SAMSUNG: Add quirk to support Exynos4 PCM audio

Exynos4 pcm block is different from previous one.
Unlike previous one, Exynos4 doesn't have SCLK divider in the pcm block. For this reason, This patch added quirk handling for Exynos4 pcm cpu driver.

---
 sound/soc/samsung/pcm.c |   46 +++++++++++++++++++++++++++++-----------------
 1 files changed, 29 insertions(+), 17 deletions(-)
sound/soc/samsung/pcm.c +29 -17
index 9c7e8b4..adfb251 100644
@@ -10,7 +10,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-
 #include <linux/clk.h>
 #include <linux/io.h>
 
@@ -128,6 +127,7 @@ struct s3c_pcm_info {
 
 	struct s3c_dma_params	*dma_playback;
 	struct s3c_dma_params	*dma_capture;
+	u32	quirks;
 };
 
 static struct s3c2410_dma_client s3c_pcm_dma_client_out = {
@@ -278,7 +278,7 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
 	struct clk *clk;
 	int sclk_div, sync_div;
 	unsigned long flags;
-	u32 clkctl;
+	u32 clkctl = 0;
 
 	dev_dbg(pcm->dev, "Entered %s\n", __func__);
 
@@ -299,25 +299,34 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
 
 	spin_lock_irqsave(&pcm->lock, flags);
 
-	/* Get hold of the PCMSOURCE_CLK */
-	clkctl = readl(regs + S3C_PCM_CLKCTL);
-	if (clkctl & S3C_PCM_CLKCTL_SERCLKSEL_PCLK)
-		clk = pcm->pclk;
-	else
+	if (pcm->quirks == QUIRK_NO_DIV) {
 		clk = pcm->cclk;
+		if (clk_get_rate(clk) != (pcm->sclk_per_fs*params_rate(params))) {
+			clk_set_rate(clk, pcm->sclk_per_fs*params_rate(params));
+		}
+		sync_div = clk_get_rate(clk)/(params_rate(params))-1;
+	}
+	else {
+		/* Get hold of the PCMSOURCE_CLK */
+		clkctl = readl(regs + S3C_PCM_CLKCTL);
+		if (clkctl & S3C_PCM_CLKCTL_SERCLKSEL_PCLK)
+			clk = pcm->pclk;
+		else
+			clk = pcm->cclk;
 
-	/* Set the SCLK divider */
-	sclk_div = clk_get_rate(clk) / pcm->sclk_per_fs /
-					params_rate(params) / 2 - 1;
+		/* Set the SCLK divider */
+		sclk_div = clk_get_rate(clk) / pcm->sclk_per_fs /
+				params_rate(params) / 2 - 1;
 
-	clkctl &= ~(S3C_PCM_CLKCTL_SCLKDIV_MASK
-			<< S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
-	clkctl |= ((sclk_div & S3C_PCM_CLKCTL_SCLKDIV_MASK)
-			<< S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
+		clkctl &= ~(S3C_PCM_CLKCTL_SCLKDIV_MASK
+				<< S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
+		clkctl |= ((sclk_div & S3C_PCM_CLKCTL_SCLKDIV_MASK)
+				<< S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
 
-	/* Set the SYNC divider */
-	sync_div = pcm->sclk_per_fs - 1;
+		sync_div = pcm->sclk_per_fs - 1;
+	}
 
+	/* Set the SYNC divider */
 	clkctl &= ~(S3C_PCM_CLKCTL_SYNCDIV_MASK
 				<< S3C_PCM_CLKCTL_SYNCDIV_SHIFT);
 	clkctl |= ((sync_div & S3C_PCM_CLKCTL_SYNCDIV_MASK)
@@ -330,7 +339,6 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
 	dev_dbg(pcm->dev, "PCMSOURCE_CLK-%lu SCLK=%ufs SCLK_DIV=%d SYNC_DIV=%d\n",
 				clk_get_rate(clk), pcm->sclk_per_fs,
 				sclk_div, sync_div);
-
 	return 0;
 }
 
@@ -494,6 +502,7 @@ static __devinit int s3c_pcm_dev_probe(struct platform_device *pdev)
 	struct s3c_pcm_info *pcm;
 	struct resource *mem_res, *dmatx_res, *dmarx_res;
 	struct s3c_audio_pdata *pcm_pdata;
+	struct samsung_i2s *pcm_cfg;
 	int ret;
 
 	/* Check for valid device index */
@@ -531,6 +540,9 @@ static __devinit int s3c_pcm_dev_probe(struct platform_device *pdev)
 	pcm = &s3c_pcm[pdev->id];
 	pcm->dev = &pdev->dev;
 
+	pcm_cfg = &pcm_pdata->type.pcm;
+	pcm->quirks = pcm_cfg->quirks;
+
 	spin_lock_init(&pcm->lock);
 
 	/* Default is 128fs */
Signature · 1 line
1.7.1
#1 lore raw
Quoted 96 lines · Sangbeom Kim

Exynos4 pcm block is different from previous one.
Unlike previous one, Exynos4 doesn't have SCLK divider in the pcm block. For this reason, This patch added quirk handling for Exynos4 pcm cpu driver.

---
 sound/soc/samsung/pcm.c |   46 +++++++++++++++++++++++++++++-----------------

 1 files changed, 29 insertions(+), 17 deletions(-)
sound/soc/samsung/pcm.c +25 -16
index 9c7e8b4..adfb251 100644
@@ -10,7 +10,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-
  #include <linux/clk.h>
  #include <linux/io.h>
 
@@ -128,6 +127,7 @@ struct s3c_pcm_info {
 
        struct s3c_dma_params   *dma_playback;
        struct s3c_dma_params   *dma_capture;
+       u32     quirks;
  };
 
  static struct s3c2410_dma_client s3c_pcm_dma_client_out = {
@@ -278,7 +278,7 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
        struct clk *clk;
        int sclk_div, sync_div;
        unsigned long flags;
-       u32 clkctl;
+       u32 clkctl = 0;
 
        dev_dbg(pcm->dev, "Entered %s\n", __func__);
 
@@ -299,25 +299,34 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
 
        spin_lock_irqsave(&pcm->lock, flags);
 
-       /* Get hold of the PCMSOURCE_CLK */
-       clkctl = readl(regs + S3C_PCM_CLKCTL);
-       if (clkctl & S3C_PCM_CLKCTL_SERCLKSEL_PCLK)
-               clk = pcm->pclk;
-       else
+       if (pcm->quirks == QUIRK_NO_DIV) {
                clk = pcm->cclk;
+               if (clk_get_rate(clk) != (pcm->sclk_per_fs*params_rate(params))) {
+                       clk_set_rate(clk, pcm->sclk_per_fs*params_rate(params));
+               }
+               sync_div = clk_get_rate(clk)/(params_rate(params))-1;
+       }
+       else {
+               /* Get hold of the PCMSOURCE_CLK */
+               clkctl = readl(regs + S3C_PCM_CLKCTL);
+               if (clkctl & S3C_PCM_CLKCTL_SERCLKSEL_PCLK)
+                       clk = pcm->pclk;
+               else
+                       clk = pcm->cclk;
 
-       /* Set the SCLK divider */
-       sclk_div = clk_get_rate(clk) / pcm->sclk_per_fs /
-                                       params_rate(params) / 2 - 1;
+               /* Set the SCLK divider */
+               sclk_div = clk_get_rate(clk) / pcm->sclk_per_fs /
+                               params_rate(params) / 2 - 1;
 
-       clkctl &= ~(S3C_PCM_CLKCTL_SCLKDIV_MASK
-                       << S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
-       clkctl |= ((sclk_div & S3C_PCM_CLKCTL_SCLKDIV_MASK)
-                       << S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
+               clkctl &= ~(S3C_PCM_CLKCTL_SCLKDIV_MASK
+                               << S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
+               clkctl |= ((sclk_div & S3C_PCM_CLKCTL_SCLKDIV_MASK)
+                               << S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
 
-       /* Set the SYNC divider */
-       sync_div = pcm->sclk_per_fs - 1;
+               sync_div = pcm->sclk_per_fs - 1;
+       }
 
+       /* Set the SYNC divider */

       clkctl &= ~(S3C_PCM_CLKCTL_SYNCDIV_MASK
                               << S3C_PCM_CLKCTL_SYNCDIV_SHIFT); clkctl |= ((sync_div & S3C_PCM_CLKCTL_SYNCDIV_MASK)

sound/soc/samsung/pcm.c +0 -1
@@ -330,7 +339,6 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
        dev_dbg(pcm->dev, "PCMSOURCE_CLK-%lu SCLK=%ufs SCLK_DIV=%d SYNC_DIV=%d\n",
                                clk_get_rate(clk), pcm->sclk_per_fs,
                                sclk_div, sync_div);
-
        return 0;
  }
 

sound/soc/samsung/pcm.c static __devinit int s3c_pcm_dev_probe(struct platform_device *pdev) · line 505

Quoted 4 lines
sound/soc/samsung/pcm.c +1 -0
@@ -494,6 +502,7 @@ static __devinit int s3c_pcm_dev_probe(struct platform_device *pdev)
        struct s3c_pcm_info *pcm;
        struct resource *mem_res, *dmatx_res, *dmarx_res;
        struct s3c_audio_pdata *pcm_pdata;
+       struct samsung_i2s *pcm_cfg;

Oh dear, perhaps you forgot to test before sending ?
_______________________________________________
Alsa-devel mailing list [email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#2 lore raw
Quoted 107 lines · Jassi Brar

Subject: Re: [alsa-devel] [PATCH V2] ASoC: SAMSUNG: Add quirk to support Exynos4 PCM audio

Quoted 3 lines · Sangbeom Kim

Exynos4 pcm block is different from previous one.
Unlike previous one, Exynos4 doesn't have SCLK divider in the pcm block. For this reason, This patch added quirk handling for Exynos4 pcm cpu

driver.

Quoted 4 lines
---
 sound/soc/samsung/pcm.c |   46 +++++++++++++++++++++++++++++-----------

------

sound/soc/samsung/pcm.c static int s3c_pcm_hw_params(struct

Quoted 23 lines
 1 files changed, 29 insertions(+), 17 deletions(-)
sound/soc/samsung/pcm.c +1 -1
index 9c7e8b4..adfb251 100644
@@ -10,7 +10,6 @@
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
-
 #include <linux/clk.h>
 #include <linux/io.h>
 
@@ -128,6 +127,7 @@ struct s3c_pcm_info {
 
       struct s3c_dma_params   *dma_playback;
       struct s3c_dma_params   *dma_capture;
+       u32     quirks;
 };
 
 static struct s3c2410_dma_client s3c_pcm_dma_client_out = {
@@ -278,7 +278,7 @@ static int s3c_pcm_hw_params(struct

snd_pcm_substream *substream,

sound/soc/samsung/pcm.c static int s3c_pcm_hw_params(struct

Quoted 9 lines
sound/soc/samsung/pcm.c +1 -1
       struct clk *clk;
       int sclk_div, sync_div;
       unsigned long flags;
-       u32 clkctl;
+       u32 clkctl = 0;
 
       dev_dbg(pcm->dev, "Entered %s\n", __func__);
 
@@ -299,25 +299,34 @@ static int s3c_pcm_hw_params(struct

snd_pcm_substream *substream,

sound/soc/samsung/pcm.c static int s3c_pcm_hw_params(struct

Quoted 51 lines
sound/soc/samsung/pcm.c +23 -14
       spin_lock_irqsave(&pcm->lock, flags);
 
-       /* Get hold of the PCMSOURCE_CLK */
-       clkctl = readl(regs + S3C_PCM_CLKCTL);
-       if (clkctl & S3C_PCM_CLKCTL_SERCLKSEL_PCLK)
-               clk = pcm->pclk;
-       else
+       if (pcm->quirks == QUIRK_NO_DIV) {
               clk = pcm->cclk;
+               if (clk_get_rate(clk) != (pcm-
 sclk_per_fs*params_rate(params))) {
+                       clk_set_rate(clk, pcm-
 sclk_per_fs*params_rate(params));
+               }
+               sync_div = clk_get_rate(clk)/(params_rate(params))-1;
+       }
+       else {
+               /* Get hold of the PCMSOURCE_CLK */
+               clkctl = readl(regs + S3C_PCM_CLKCTL);
+               if (clkctl & S3C_PCM_CLKCTL_SERCLKSEL_PCLK)
+                       clk = pcm->pclk;
+               else
+                       clk = pcm->cclk;
 
-       /* Set the SCLK divider */
-       sclk_div = clk_get_rate(clk) / pcm->sclk_per_fs /
-                                       params_rate(params) / 2 - 1;
+               /* Set the SCLK divider */
+               sclk_div = clk_get_rate(clk) / pcm->sclk_per_fs /
+                               params_rate(params) / 2 - 1;
 
-       clkctl &= ~(S3C_PCM_CLKCTL_SCLKDIV_MASK
-                       << S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
-       clkctl |= ((sclk_div & S3C_PCM_CLKCTL_SCLKDIV_MASK)
-                       << S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
+               clkctl &= ~(S3C_PCM_CLKCTL_SCLKDIV_MASK
+                               << S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
+               clkctl |= ((sclk_div & S3C_PCM_CLKCTL_SCLKDIV_MASK)
+                               << S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
 
-       /* Set the SYNC divider */
-       sync_div = pcm->sclk_per_fs - 1;
+               sync_div = pcm->sclk_per_fs - 1;
+       }
 
+       /* Set the SYNC divider */
       clkctl &= ~(S3C_PCM_CLKCTL_SYNCDIV_MASK
                               << S3C_PCM_CLKCTL_SYNCDIV_SHIFT);
       clkctl |= ((sync_div & S3C_PCM_CLKCTL_SYNCDIV_MASK)
sound/soc/samsung/pcm.c +0 -0
@@ -330,7 +339,6 @@ static int s3c_pcm_hw_params(struct

snd_pcm_substream *substream,

sound/soc/samsung/pcm.c static int s3c_pcm_hw_params(struct · line 339

Quoted 1 line
sound/soc/samsung/pcm.c +0 -0
       dev_dbg(pcm->dev, "PCMSOURCE_CLK-%lu SCLK=%ufs SCLK_DIV=%d

SYNC_DIV=%d\n",

Quoted 6 lines
sound/soc/samsung/pcm.c +0 -1
                               clk_get_rate(clk), pcm->sclk_per_fs,
                               sclk_div, sync_div);
-
       return 0;
 }
 
Quoted 8 lines

sound/soc/samsung/pcm.c static __devinit int s3c_pcm_dev_probe(struct

Quoted 1 line
sound/soc/samsung/pcm.c +0 -0
@@ -494,6 +502,7 @@ static __devinit int s3c_pcm_dev_probe(struct

platform_device *pdev)

sound/soc/samsung/pcm.c static __devinit int s3c_pcm_dev_probe(struct platform_device *pdev) · line 505

Quoted 4 lines
sound/soc/samsung/pcm.c +1 -0
       struct s3c_pcm_info *pcm;
       struct resource *mem_res, *dmatx_res, *dmarx_res;
       struct s3c_audio_pdata *pcm_pdata;
+       struct samsung_i2s *pcm_cfg;

Oh dear, perhaps you forgot to test before sending ?

I did test and PCM working is fine on SMDKV310 and SMDKV210. But It was my mistake. samsung_i2s was used unintentionally. I will resubmit it.
Thanks,

Quoted 4 lines

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel