alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Jassi Brar <jassi.brar@samsung.com>
To: alsa-devel@alsa-project.org
Cc: broonie@opensource.wolfsonmicro.com,
	Jassi Brar <jassi.brar@samsung.com>,
	ben-linux@fluff.org
Subject: [PATCH 18/20] ASoC: S3C: I2S: Move set_sysclk callback to common code
Date: Wed, 10 Mar 2010 16:49:07 +0900	[thread overview]
Message-ID: <1268207349-9979-18-git-send-email-jassi.brar@samsung.com> (raw)
In-Reply-To: <1268207349-9979-17-git-send-email-jassi.brar@samsung.com>

Now that we can specify feature of a particular controller, we can
avoid multiple copies of same code by defining the CDCLKCON bit
feature in controller specific code and detecting that flag in the
code common to all controllers.

Signed-off-by: Jassi Brar <jassi.brar@samsung.com>
---
 sound/soc/s3c24xx/s3c-i2s-v2.c  |   47 +++++++++++++++++++++++++++++++++++++++
 sound/soc/s3c24xx/s3c2412-i2s.c |   27 ----------------------
 sound/soc/s3c24xx/s3c64xx-i2s.c |   43 ++---------------------------------
 3 files changed, 50 insertions(+), 67 deletions(-)

diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c
index ecb3054..7d2edc0 100644
--- a/sound/soc/s3c24xx/s3c-i2s-v2.c
+++ b/sound/soc/s3c24xx/s3c-i2s-v2.c
@@ -325,6 +325,52 @@ static int s3c_i2sv2_hw_params(struct snd_pcm_substream *substream,
 
 	writel(iismod, i2s->regs + S3C2412_IISMOD);
 	pr_debug("%s: w: IISMOD: %x\n", __func__, iismod);
+
+	return 0;
+}
+
+static int s3c_i2sv2_set_sysclk(struct snd_soc_dai *cpu_dai,
+				  int clk_id, unsigned int freq, int dir)
+{
+	struct s3c_i2sv2_info *i2s = to_info(cpu_dai);
+	u32 iismod = readl(i2s->regs + S3C2412_IISMOD);
+
+	pr_debug("Entered %s\n", __func__);
+	pr_debug("%s r: IISMOD: %x \n", __func__, iismod);
+
+	switch (clk_id) {
+	case S3C_I2SV2_CLKSRC_PCLK:
+		iismod &= ~S3C2412_IISMOD_IMS_SYSMUX;
+		break;
+
+	case S3C_I2SV2_CLKSRC_AUDIOBUS:
+		iismod |= S3C2412_IISMOD_IMS_SYSMUX;
+		break;
+
+	case S3C_I2SV2_CLKSRC_CDCLK:
+		/* Error if controller doesn't have the CDCLKCON bit */
+		if (!(i2s->feature & S3C_FEATURE_CDCLKCON))
+			return -EINVAL;
+
+		switch (dir) {
+		case SND_SOC_CLOCK_IN:
+			iismod |= S3C64XX_IISMOD_CDCLKCON;
+			break;
+		case SND_SOC_CLOCK_OUT:
+			iismod &= ~S3C64XX_IISMOD_CDCLKCON;
+			break;
+		default:
+			return -EINVAL;
+		}
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	writel(iismod, i2s->regs + S3C2412_IISMOD);
+	pr_debug("%s w: IISMOD: %x \n", __func__, iismod);
+
 	return 0;
 }
 
@@ -697,6 +743,7 @@ int s3c_i2sv2_register_dai(struct snd_soc_dai *dai)
 		ops->hw_params = s3c_i2sv2_hw_params;
 	ops->set_fmt = s3c2412_i2s_set_fmt;
 	ops->set_clkdiv = s3c2412_i2s_set_clkdiv;
+	ops->set_sysclk = s3c_i2sv2_set_sysclk;
 
 	/* Allow overriding by (for example) IISv4 */
 	if (!ops->delay)
diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c
index fe90867..e351376 100644
--- a/sound/soc/s3c24xx/s3c2412-i2s.c
+++ b/sound/soc/s3c24xx/s3c2412-i2s.c
@@ -65,32 +65,6 @@ static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = {
 
 static struct s3c_i2sv2_info s3c2412_i2s;
 
-/*
- * Set S3C2412 Clock source
- */
-static int s3c2412_i2s_set_sysclk(struct snd_soc_dai *cpu_dai,
-				  int clk_id, unsigned int freq, int dir)
-{
-	u32 iismod = readl(s3c2412_i2s.regs + S3C2412_IISMOD);
-
-	pr_debug("%s(%p, %d, %u, %d)\n", __func__, cpu_dai, clk_id,
-	    freq, dir);
-
-	switch (clk_id) {
-	case S3C2412_CLKSRC_PCLK:
-		iismod &= ~S3C2412_IISMOD_IMS_SYSMUX;
-		break;
-	case S3C2412_CLKSRC_I2SCLK:
-		iismod |= S3C2412_IISMOD_IMS_SYSMUX;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	writel(iismod, s3c2412_i2s.regs + S3C2412_IISMOD);
-	return 0;
-}
-
 static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai)
 {
 	return cpu_dai->private_data;
@@ -172,7 +146,6 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream,
 	SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
 
 static struct snd_soc_dai_ops s3c2412_i2s_dai_ops = {
-	.set_sysclk	= s3c2412_i2s_set_sysclk,
 	.hw_params	= s3c2412_i2s_hw_params,
 };
 
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.c b/sound/soc/s3c24xx/s3c64xx-i2s.c
index 1a29564..03cce8a 100644
--- a/sound/soc/s3c24xx/s3c64xx-i2s.c
+++ b/sound/soc/s3c24xx/s3c64xx-i2s.c
@@ -54,43 +54,6 @@ static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai)
 	return cpu_dai->private_data;
 }
 
-static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai,
-				  int clk_id, unsigned int freq, int dir)
-{
-	struct s3c_i2sv2_info *i2s = to_info(cpu_dai);
-	u32 iismod = readl(i2s->regs + S3C2412_IISMOD);
-
-	switch (clk_id) {
-	case S3C64XX_CLKSRC_PCLK:
-		iismod &= ~S3C2412_IISMOD_IMS_SYSMUX;
-		break;
-
-	case S3C64XX_CLKSRC_MUX:
-		iismod |= S3C2412_IISMOD_IMS_SYSMUX;
-		break;
-
-	case S3C64XX_CLKSRC_CDCLK:
-		switch (dir) {
-		case SND_SOC_CLOCK_IN:
-			iismod |= S3C64XX_IISMOD_CDCLKCON;
-			break;
-		case SND_SOC_CLOCK_OUT:
-			iismod &= ~S3C64XX_IISMOD_CDCLKCON;
-			break;
-		default:
-			return -EINVAL;
-		}
-		break;
-
-	default:
-		return -EINVAL;
-	}
-
-	writel(iismod, i2s->regs + S3C2412_IISMOD);
-
-	return 0;
-}
-
 static int s3c64xx_i2s_probe(struct platform_device *pdev,
 			     struct snd_soc_dai *dai)
 {
@@ -115,9 +78,7 @@ static int s3c64xx_i2s_probe(struct platform_device *pdev,
 }
 
 
-static struct snd_soc_dai_ops s3c64xx_i2s_dai_ops = {
-	.set_sysclk	= s3c64xx_i2s_set_sysclk,	
-};
+static struct snd_soc_dai_ops s3c64xx_i2s_dai_ops;
 
 static __devinit int s3c64xx_iis_dev_probe(struct platform_device *pdev)
 {
@@ -147,6 +108,8 @@ static __devinit int s3c64xx_iis_dev_probe(struct platform_device *pdev)
 	dai->probe = s3c64xx_i2s_probe;
 	dai->ops = &s3c64xx_i2s_dai_ops;
 
+	i2s->feature |= S3C_FEATURE_CDCLKCON;
+
 	i2s->dma_capture = &s3c64xx_i2s_pcm_stereo_in[pdev->id];
 	i2s->dma_playback = &s3c64xx_i2s_pcm_stereo_out[pdev->id];
 
-- 
1.6.2.5

  reply	other threads:[~2010-03-10  8:23 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-10  7:48 [PATCH 01/20] ASoC: S3C: I2Sv2: Add missing semicolon Jassi Brar
2010-03-10  7:48 ` [PATCH 02/20] ASoC: S3C: I2Sv2: Reject immidiate register value Jassi Brar
2010-03-10  7:48   ` [PATCH 03/20] ASoC: S3C64XX: I2S: Make BCLK independent of sample size Jassi Brar
2010-03-10  7:48     ` [PATCH 04/20] ASoC: S3C: I2Sv2: Remove S3C_IIS_V2_SUPPORTED define Jassi Brar
2010-03-10  7:48       ` [PATCH 05/20] ASoC: S3C: I2Sv2: Unify clock source IDs Jassi Brar
2010-03-10  7:48         ` [PATCH 06/20] ASoC: s3c-i2s-v2 remove unnecessary headers Jassi Brar
2010-03-10  7:48           ` [PATCH 07/20] ASoC: s3c64xx-i2s remove unncessary headers Jassi Brar
2010-03-10  7:48             ` [PATCH 08/20] ASoC: S3C64XX: I2S: Move RATE and FMT defines to header Jassi Brar
2010-03-10  7:48               ` [PATCH 09/20] ASoC: S3C: I2Sv2: Segregate hw_params callback Jassi Brar
2010-03-10  7:48                 ` [PATCH 10/20] ASoC: S3C: I2Sv2: Move register definitions closer to driver Jassi Brar
2010-03-10  7:49                   ` [PATCH 11/20] ASoC: SAMSUNG: I2S: Add bit definitions Jassi Brar
2010-03-10  7:49                     ` [PATCH 12/20] ASoC: S3C2412: I2S: Debug IMS field Jassi Brar
2010-03-10  7:49                       ` [PATCH 13/20] ASoC: S3C2412: I2S: Return correct source clock Jassi Brar
2010-03-10  7:49                         ` [PATCH 14/20] ASoC: S3C: I2Sv2: Discard redundant field iis_clk Jassi Brar
2010-03-10  7:49                           ` [PATCH 15/20] ASoC: S3C: I2Sv2: Unify i2s_get_clock callback Jassi Brar
2010-03-10  7:49                             ` [PATCH 16/20] ASoC: S3C64XX: I2S: Use s3c2412 defines Jassi Brar
2010-03-10  7:49                               ` [PATCH 17/20] ASoC: S3C: I2Sv2: Define new field for controller features Jassi Brar
2010-03-10  7:49                                 ` Jassi Brar [this message]
2010-03-10  7:49                                   ` [PATCH 19/20] ASoC: S3C64XX: IISv4: Add CPU driver Jassi Brar
2010-03-10  7:49                                     ` [PATCH 20/20] ASoC: SMDK64XX: Switch to IISv4 " Jassi Brar
2010-03-10 11:40                                       ` Mark Brown
2010-03-10 13:05                                         ` jassi brar
2010-03-10 11:39                                     ` [PATCH 19/20] ASoC: S3C64XX: IISv4: Add " Mark Brown
2010-03-10 12:57                                       ` jassi brar
2010-03-10 11:09                                 ` [PATCH 17/20] ASoC: S3C: I2Sv2: Define new field for controller features Mark Brown
2010-03-10 11:11                                   ` Mark Brown
2010-03-10 11:00                     ` [PATCH 11/20] ASoC: SAMSUNG: I2S: Add bit definitions Mark Brown
2010-03-10 12:24                       ` jassi brar
2010-03-10 12:38                         ` Mark Brown
2010-03-10 12:49                           ` jassi brar
2010-03-10 12:56                             ` Mark Brown
2010-03-10 13:03                               ` jassi brar
2010-03-10 14:11                                 ` Mark Brown
2010-04-27  2:55                   ` [PATCH 10/20] ASoC: S3C: I2Sv2: Move register definitions closer to driver Ben Dooks
2010-03-10 14:14                 ` [PATCH 09/20] ASoC: S3C: I2Sv2: Segregate hw_params callback Mark Brown
2010-03-10 18:46                   ` Mark Brown
2010-03-10 10:51               ` [PATCH 08/20] ASoC: S3C64XX: I2S: Move RATE and FMT defines to header Mark Brown
2010-03-10 12:52                 ` jassi brar
2010-03-10 12:59                   ` Mark Brown
2010-03-10 13:01             ` [PATCH 07/20] ASoC: s3c64xx-i2s remove unncessary headers Mark Brown
2010-03-10 13:01           ` [PATCH 06/20] ASoC: s3c-i2s-v2 remove unnecessary headers Mark Brown
2010-03-10 13:01         ` [PATCH 05/20] ASoC: S3C: I2Sv2: Unify clock source IDs Mark Brown
2010-03-10 10:49       ` [PATCH 04/20] ASoC: S3C: I2Sv2: Remove S3C_IIS_V2_SUPPORTED define Mark Brown
2010-03-10 12:38         ` jassi brar
2010-03-10 12:51           ` Mark Brown
2010-03-10 12:31     ` [PATCH 03/20] ASoC: S3C64XX: I2S: Make BCLK independent of sample size Mark Brown
2010-03-10 12:46       ` jassi brar
2010-03-10 13:00         ` Mark Brown
2010-03-10 10:32   ` [PATCH 02/20] ASoC: S3C: I2Sv2: Reject immidiate register value Mark Brown
2010-03-10 12:27     ` jassi brar
2010-03-10 12:48       ` Mark Brown
2010-03-10 12:32 ` [PATCH 01/20] ASoC: S3C: I2Sv2: Add missing semicolon Mark Brown
2010-03-10 13:00 ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2010-03-10  8:12 [PATCH 18/20] ASoC: S3C: I2S: Move set_sysclk callback to common code Jassi Brar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1268207349-9979-18-git-send-email-jassi.brar@samsung.com \
    --to=jassi.brar@samsung.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=ben-linux@fluff.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).