* [RFC][PATCH 1/3] ASoC: sh: fsi: move chan_num from fsi_stream to fsi_priv
2011-01-24 1:41 [RFC][PATCH 0/3] ASoC: sh: fsi: sound format selection Kuninori Morimoto
@ 2011-01-24 1:42 ` Kuninori Morimoto
2011-01-24 1:42 ` [RFC][PATCH 2/3] ASoC: sh: fsi: free from NULL pointer of struct sh_fsi_platform_info Kuninori Morimoto
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Kuninori Morimoto @ 2011-01-24 1:42 UTC (permalink / raw)
To: Mark Brown; +Cc: Linux-ALSA, Paul Mundt, Liam Girdwood
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/sh/fsi.c | 34 +++++++++++++++-------------------
1 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 5f39f36..605ea7f 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -130,7 +130,6 @@ struct fsi_stream {
struct snd_pcm_substream *substream;
int fifo_max_num;
- int chan_num;
int buff_offset;
int buff_len;
@@ -145,6 +144,7 @@ struct fsi_priv {
void __iomem *base;
struct fsi_master *master;
+ int chan_num;
struct fsi_stream playback;
struct fsi_stream capture;
@@ -348,7 +348,6 @@ static void fsi_stream_pop(struct fsi_priv *fsi, int is_play)
static int fsi_get_fifo_data_num(struct fsi_priv *fsi, int is_play)
{
u32 status;
- struct fsi_stream *io = fsi_get_stream(fsi, is_play);
int data_num;
status = is_play ?
@@ -356,7 +355,7 @@ static int fsi_get_fifo_data_num(struct fsi_priv *fsi, int is_play)
fsi_reg_read(fsi, DIFF_ST);
data_num = 0x1ff & (status >> 8);
- data_num *= io->chan_num;
+ data_num *= fsi->chan_num;
return data_num;
}
@@ -378,7 +377,7 @@ static int fsi_get_frame_width(struct fsi_priv *fsi, int is_play)
struct snd_pcm_substream *substream = io->substream;
struct snd_pcm_runtime *runtime = substream->runtime;
- return frames_to_bytes(runtime, 1) / io->chan_num;
+ return frames_to_bytes(runtime, 1) / fsi->chan_num;
}
static void fsi_count_fifo_err(struct fsi_priv *fsi)
@@ -571,10 +570,10 @@ static void fsi_fifo_init(struct fsi_priv *fsi,
* 7 channels: 32 ( 32 x 7 = 224)
* 8 channels: 32 ( 32 x 8 = 256)
*/
- for (i = 1; i < io->chan_num; i <<= 1)
+ for (i = 1; i < fsi->chan_num; i <<= 1)
io->fifo_max_num >>= 1;
dev_dbg(dai->dev, "%d channel %d store\n",
- io->chan_num, io->fifo_max_num);
+ fsi->chan_num, io->fifo_max_num);
/*
* set interrupt generation factor
@@ -650,7 +649,7 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int stream)
* data_num_max : number of FSI fifo free space
* data_num : number of ALSA residue data
*/
- data_num_max = io->fifo_max_num * io->chan_num;
+ data_num_max = io->fifo_max_num * fsi->chan_num;
data_num_max -= fsi_get_fifo_data_num(fsi, is_play);
data_num = data_residue_num;
@@ -746,14 +745,11 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream,
{
struct fsi_priv *fsi = fsi_get_priv(substream);
struct fsi_master *master = fsi_get_master(fsi);
- struct fsi_stream *io;
u32 flags = fsi_get_info_flags(fsi);
u32 fmt;
u32 data;
int is_play = fsi_is_play(substream);
- io = fsi_get_stream(fsi, is_play);
-
pm_runtime_get_sync(dai->dev);
@@ -776,29 +772,29 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream,
switch (fmt) {
case SH_FSI_FMT_MONO:
data = CR_MONO;
- io->chan_num = 1;
+ fsi->chan_num = 1;
break;
case SH_FSI_FMT_MONO_DELAY:
data = CR_MONO_D;
- io->chan_num = 1;
+ fsi->chan_num = 1;
break;
case SH_FSI_FMT_PCM:
data = CR_PCM;
- io->chan_num = 2;
+ fsi->chan_num = 2;
break;
case SH_FSI_FMT_I2S:
data = CR_I2S;
- io->chan_num = 2;
+ fsi->chan_num = 2;
break;
case SH_FSI_FMT_TDM:
- io->chan_num = is_play ?
+ fsi->chan_num = is_play ?
SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags);
- data = CR_TDM | (io->chan_num - 1);
+ data = CR_TDM | (fsi->chan_num - 1);
break;
case SH_FSI_FMT_TDM_DELAY:
- io->chan_num = is_play ?
+ fsi->chan_num = is_play ?
SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags);
- data = CR_TDM_D | (io->chan_num - 1);
+ data = CR_TDM_D | (fsi->chan_num - 1);
break;
case SH_FSI_FMT_SPDIF:
if (master->core->ver < 2) {
@@ -806,7 +802,7 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream,
return -EINVAL;
}
data = CR_BWS_16 | CR_DTMD_SPDIF_PCM | CR_PCM;
- io->chan_num = 2;
+ fsi->chan_num = 2;
fsi_spdif_clk_ctrl(fsi, 1);
fsi_reg_mask_set(fsi, OUT_SEL, DMMD, DMMD);
break;
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [RFC][PATCH 2/3] ASoC: sh: fsi: free from NULL pointer of struct sh_fsi_platform_info
2011-01-24 1:41 [RFC][PATCH 0/3] ASoC: sh: fsi: sound format selection Kuninori Morimoto
2011-01-24 1:42 ` [RFC][PATCH 1/3] ASoC: sh: fsi: move chan_num from fsi_stream to fsi_priv Kuninori Morimoto
@ 2011-01-24 1:42 ` Kuninori Morimoto
2011-01-24 1:43 ` [RFC][PATCH 3/3] ASoC: sh: fsi: modify selection method of I2S/PCM/SPDIF format Kuninori Morimoto
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Kuninori Morimoto @ 2011-01-24 1:42 UTC (permalink / raw)
To: Mark Brown; +Cc: Linux-ALSA, Paul Mundt, Liam Girdwood
Current FSI driver assumed master->info is not NULL.
This patch allow NULL in master->info
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/sh/fsi.c | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 605ea7f..3c53693 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -113,6 +113,8 @@
#define FSI_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE)
+typedef int (*set_rate_func)(struct device *dev, int is_porta, int rate, int enable);
+
/*
* FSI driver use below type name for variable
*
@@ -269,11 +271,22 @@ static struct fsi_priv *fsi_get_priv(struct snd_pcm_substream *substream)
return fsi_get_priv_frm_dai(fsi_get_dai(substream));
}
+static set_rate_func fsi_get_info_set_rate(struct fsi_master *master)
+{
+ if (!master->info)
+ return NULL;
+
+ return master->info->set_rate;
+}
+
static u32 fsi_get_info_flags(struct fsi_priv *fsi)
{
int is_porta = fsi_is_port_a(fsi);
struct fsi_master *master = fsi_get_master(fsi);
+ if (!master->info)
+ return 0;
+
return is_porta ? master->info->porta_flags :
master->info->portb_flags;
}
@@ -830,12 +843,12 @@ static void fsi_dai_shutdown(struct snd_pcm_substream *substream,
struct fsi_priv *fsi = fsi_get_priv(substream);
int is_play = fsi_is_play(substream);
struct fsi_master *master = fsi_get_master(fsi);
- int (*set_rate)(struct device *dev, int is_porta, int rate, int enable);
+ set_rate_func set_rate;
fsi_irq_disable(fsi, is_play);
fsi_clk_ctrl(fsi, 0);
- set_rate = master->info->set_rate;
+ set_rate = fsi_get_info_set_rate(master);
if (set_rate && fsi->rate)
set_rate(dai->dev, fsi_is_port_a(fsi), fsi->rate, 0);
fsi->rate = 0;
@@ -902,12 +915,12 @@ static int fsi_dai_hw_params(struct snd_pcm_substream *substream,
{
struct fsi_priv *fsi = fsi_get_priv(substream);
struct fsi_master *master = fsi_get_master(fsi);
- int (*set_rate)(struct device *dev, int is_porta, int rate, int enable);
+ set_rate_func set_rate;
int fsi_ver = master->core->ver;
long rate = params_rate(params);
int ret;
- set_rate = master->info->set_rate;
+ set_rate = fsi_get_info_set_rate(master);
if (!set_rate)
return 0;
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [RFC][PATCH 3/3] ASoC: sh: fsi: modify selection method of I2S/PCM/SPDIF format
2011-01-24 1:41 [RFC][PATCH 0/3] ASoC: sh: fsi: sound format selection Kuninori Morimoto
2011-01-24 1:42 ` [RFC][PATCH 1/3] ASoC: sh: fsi: move chan_num from fsi_stream to fsi_priv Kuninori Morimoto
2011-01-24 1:42 ` [RFC][PATCH 2/3] ASoC: sh: fsi: free from NULL pointer of struct sh_fsi_platform_info Kuninori Morimoto
@ 2011-01-24 1:43 ` Kuninori Morimoto
2011-01-25 14:11 ` [RFC][PATCH 0/3] ASoC: sh: fsi: sound format selection Mark Brown
2011-01-26 13:48 ` Mark Brown
4 siblings, 0 replies; 7+ messages in thread
From: Kuninori Morimoto @ 2011-01-24 1:43 UTC (permalink / raw)
To: Mark Brown; +Cc: Linux-ALSA, Paul Mundt, Liam Girdwood
Current format selection of FSI-codecs depended on platform information for FSI,
and chip default settings for codecs. It is not understandable/formal method.
This patch modify FSI and FSI-codecs to use snd_soc_dai_set_fmt.
But FSI can use I2S/PCM and SPDIF format today.
It can be selected to I2S/PCM by snd_soc_dai_set_fmt, but can not select SPDIF.
So, this patch change FSI platform information to have DAI/SPDIF mode.
If platform selects DAI mode (default),
FSI-codecs can select I2S/PCM by snd_soc_dai_set_fmt,
and if it is SPDIF mode, FSI become SPDIF format.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
arch/arm/mach-shmobile/board-ag5evm.c | 8 ---
arch/arm/mach-shmobile/board-ap4evb.c | 6 +-
arch/arm/mach-shmobile/board-mackerel.c | 6 +-
arch/sh/boards/mach-ecovec24/setup.c | 4 +-
arch/sh/boards/mach-se/7724/setup.c | 4 +-
include/sound/sh_fsi.h | 70 ++++++---------------
sound/soc/sh/fsi-ak4642.c | 3 +-
sound/soc/sh/fsi-da7210.c | 3 +-
sound/soc/sh/fsi.c | 106 ++++++++++++++++---------------
9 files changed, 84 insertions(+), 126 deletions(-)
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index 9ee55e0..343362d 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -118,11 +118,6 @@ static struct platform_device keysc_device = {
};
/* FSI A */
-static struct sh_fsi_platform_info fsi_info = {
- .porta_flags = SH_FSI_OFMT(I2S) |
- SH_FSI_IFMT(I2S),
-};
-
static struct resource fsi_resources[] = {
[0] = {
.name = "FSI",
@@ -141,9 +136,6 @@ static struct platform_device fsi_device = {
.id = -1,
.num_resources = ARRAY_SIZE(fsi_resources),
.resource = fsi_resources,
- .dev = {
- .platform_data = &fsi_info,
- },
};
static struct resource sh_mmcif_resources[] = {
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index 920ed81..17f528a 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -673,14 +673,12 @@ static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
}
static struct sh_fsi_platform_info fsi_info = {
- .porta_flags = SH_FSI_BRS_INV |
- SH_FSI_OFMT(PCM) |
- SH_FSI_IFMT(PCM),
+ .porta_flags = SH_FSI_BRS_INV,
.portb_flags = SH_FSI_BRS_INV |
SH_FSI_BRM_INV |
SH_FSI_LRS_INV |
- SH_FSI_OFMT(SPDIF),
+ SH_FSI_FMT_SPDIF,
.set_rate = fsi_set_rate,
};
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index aa4bcc3..73b8c90 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -614,14 +614,12 @@ fsi_set_rate_end:
}
static struct sh_fsi_platform_info fsi_info = {
- .porta_flags = SH_FSI_BRS_INV |
- SH_FSI_OFMT(PCM) |
- SH_FSI_IFMT(PCM),
+ .porta_flags = SH_FSI_BRS_INV,
.portb_flags = SH_FSI_BRS_INV |
SH_FSI_BRM_INV |
SH_FSI_LRS_INV |
- SH_FSI_OFMT(SPDIF),
+ SH_FSI_FMT_SPDIF,
.set_rate = fsi_set_rate,
};
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 037416f..b96b79b 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -723,9 +723,7 @@ static struct platform_device camera_devices[] = {
/* FSI */
static struct sh_fsi_platform_info fsi_info = {
- .portb_flags = SH_FSI_BRS_INV |
- SH_FSI_OFMT(I2S) |
- SH_FSI_IFMT(I2S),
+ .portb_flags = SH_FSI_BRS_INV,
};
static struct resource fsi_resources[] = {
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c
index b4aef05..c8bcf6a 100644
--- a/arch/sh/boards/mach-se/7724/setup.c
+++ b/arch/sh/boards/mach-se/7724/setup.c
@@ -286,9 +286,7 @@ static struct platform_device ceu1_device = {
/* FSI */
/* change J20, J21, J22 pin to 1-2 connection to use slave mode */
static struct sh_fsi_platform_info fsi_info = {
- .porta_flags = SH_FSI_BRS_INV |
- SH_FSI_OFMT(PCM) |
- SH_FSI_IFMT(PCM),
+ .porta_flags = SH_FSI_BRS_INV,
};
static struct resource fsi_resources[] = {
diff --git a/include/sound/sh_fsi.h b/include/sound/sh_fsi.h
index 18e4327..9a155f9 100644
--- a/include/sound/sh_fsi.h
+++ b/include/sound/sh_fsi.h
@@ -15,61 +15,29 @@
#define FSI_PORT_A 0
#define FSI_PORT_B 1
-/* flags format
-
- * 0xABC0EEFF
- *
- * A: channel size for TDM (input)
- * B: channel size for TDM (ooutput)
- * C: inversion
- * E: input format
- * F: output format
- */
-
#include <linux/clk.h>
#include <sound/soc.h>
-/* TDM channel */
-#define SH_FSI_SET_CH_I(x) ((x & 0xF) << 28)
-#define SH_FSI_SET_CH_O(x) ((x & 0xF) << 24)
-
-#define SH_FSI_CH_IMASK 0xF0000000
-#define SH_FSI_CH_OMASK 0x0F000000
-#define SH_FSI_GET_CH_I(x) ((x & SH_FSI_CH_IMASK) >> 28)
-#define SH_FSI_GET_CH_O(x) ((x & SH_FSI_CH_OMASK) >> 24)
-
-/* clock inversion */
-#define SH_FSI_INVERSION_MASK 0x00F00000
-#define SH_FSI_LRM_INV (1 << 20)
-#define SH_FSI_BRM_INV (1 << 21)
-#define SH_FSI_LRS_INV (1 << 22)
-#define SH_FSI_BRS_INV (1 << 23)
-
-/* DI format */
-#define SH_FSI_FMT_MASK 0x000000FF
-#define SH_FSI_IFMT(x) (((SH_FSI_FMT_ ## x) & SH_FSI_FMT_MASK) << 8)
-#define SH_FSI_OFMT(x) (((SH_FSI_FMT_ ## x) & SH_FSI_FMT_MASK) << 0)
-#define SH_FSI_GET_IFMT(x) ((x >> 8) & SH_FSI_FMT_MASK)
-#define SH_FSI_GET_OFMT(x) ((x >> 0) & SH_FSI_FMT_MASK)
-
-#define SH_FSI_FMT_MONO 0
-#define SH_FSI_FMT_MONO_DELAY 1
-#define SH_FSI_FMT_PCM 2
-#define SH_FSI_FMT_I2S 3
-#define SH_FSI_FMT_TDM 4
-#define SH_FSI_FMT_TDM_DELAY 5
-#define SH_FSI_FMT_SPDIF 6
-
-
-#define SH_FSI_IFMT_TDM_CH(x) \
- (SH_FSI_IFMT(TDM) | SH_FSI_SET_CH_I(x))
-#define SH_FSI_IFMT_TDM_DELAY_CH(x) \
- (SH_FSI_IFMT(TDM_DELAY) | SH_FSI_SET_CH_I(x))
+/*
+ * flags format
+ *
+ * 0x000000BA
+ *
+ * A: inversion
+ * B: format mode
+ */
-#define SH_FSI_OFMT_TDM_CH(x) \
- (SH_FSI_OFMT(TDM) | SH_FSI_SET_CH_O(x))
-#define SH_FSI_OFMT_TDM_DELAY_CH(x) \
- (SH_FSI_OFMT(TDM_DELAY) | SH_FSI_SET_CH_O(x))
+/* A: clock inversion */
+#define SH_FSI_INVERSION_MASK 0x0000000F
+#define SH_FSI_LRM_INV (1 << 0)
+#define SH_FSI_BRM_INV (1 << 1)
+#define SH_FSI_LRS_INV (1 << 2)
+#define SH_FSI_BRS_INV (1 << 3)
+
+/* B: format mode */
+#define SH_FSI_FMT_MASK 0x000000F0
+#define SH_FSI_FMT_DAI (0 << 4)
+#define SH_FSI_FMT_SPDIF (1 << 4)
/*
diff --git a/sound/soc/sh/fsi-ak4642.c b/sound/soc/sh/fsi-ak4642.c
index ce058c7..d6f4703 100644
--- a/sound/soc/sh/fsi-ak4642.c
+++ b/sound/soc/sh/fsi-ak4642.c
@@ -36,7 +36,8 @@ static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd)
if (ret < 0)
return ret;
- ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBS_CFS);
+ ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_LEFT_J |
+ SND_SOC_DAIFMT_CBS_CFS);
return ret;
}
diff --git a/sound/soc/sh/fsi-da7210.c b/sound/soc/sh/fsi-da7210.c
index 9b24ed4..dbafd7a 100644
--- a/sound/soc/sh/fsi-da7210.c
+++ b/sound/soc/sh/fsi-da7210.c
@@ -25,7 +25,8 @@ static int fsi_da7210_init(struct snd_soc_pcm_runtime *rtd)
if (ret < 0)
return ret;
- ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBS_CFS);
+ ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_I2S |
+ SND_SOC_DAIFMT_CBS_CFS);
return ret;
}
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 3c53693..0c9997e 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -757,9 +757,7 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct fsi_priv *fsi = fsi_get_priv(substream);
- struct fsi_master *master = fsi_get_master(fsi);
u32 flags = fsi_get_info_flags(fsi);
- u32 fmt;
u32 data;
int is_play = fsi_is_play(substream);
@@ -779,54 +777,6 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream,
fsi_reg_write(fsi, CKG2, data);
- /* do fmt, di fmt */
- data = 0;
- fmt = is_play ? SH_FSI_GET_OFMT(flags) : SH_FSI_GET_IFMT(flags);
- switch (fmt) {
- case SH_FSI_FMT_MONO:
- data = CR_MONO;
- fsi->chan_num = 1;
- break;
- case SH_FSI_FMT_MONO_DELAY:
- data = CR_MONO_D;
- fsi->chan_num = 1;
- break;
- case SH_FSI_FMT_PCM:
- data = CR_PCM;
- fsi->chan_num = 2;
- break;
- case SH_FSI_FMT_I2S:
- data = CR_I2S;
- fsi->chan_num = 2;
- break;
- case SH_FSI_FMT_TDM:
- fsi->chan_num = is_play ?
- SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags);
- data = CR_TDM | (fsi->chan_num - 1);
- break;
- case SH_FSI_FMT_TDM_DELAY:
- fsi->chan_num = is_play ?
- SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags);
- data = CR_TDM_D | (fsi->chan_num - 1);
- break;
- case SH_FSI_FMT_SPDIF:
- if (master->core->ver < 2) {
- dev_err(dai->dev, "This FSI can not use SPDIF\n");
- return -EINVAL;
- }
- data = CR_BWS_16 | CR_DTMD_SPDIF_PCM | CR_PCM;
- fsi->chan_num = 2;
- fsi_spdif_clk_ctrl(fsi, 1);
- fsi_reg_mask_set(fsi, OUT_SEL, DMMD, DMMD);
- break;
- default:
- dev_err(dai->dev, "unknown format.\n");
- return -EINVAL;
- }
- is_play ?
- fsi_reg_write(fsi, DO_FMT, data) :
- fsi_reg_write(fsi, DI_FMT, data);
-
/* irq clear */
fsi_irq_disable(fsi, is_play);
fsi_irq_clear_status(fsi);
@@ -881,9 +831,52 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd,
return ret;
}
+static int fsi_set_fmt_dai(struct fsi_priv *fsi, unsigned int fmt)
+{
+ u32 data = 0;
+
+ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+ case SND_SOC_DAIFMT_I2S:
+ data = CR_I2S;
+ fsi->chan_num = 2;
+ break;
+ case SND_SOC_DAIFMT_LEFT_J:
+ data = CR_PCM;
+ fsi->chan_num = 2;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ fsi_reg_write(fsi, DO_FMT, data);
+ fsi_reg_write(fsi, DI_FMT, data);
+
+ return 0;
+}
+
+static int fsi_set_fmt_spdif(struct fsi_priv *fsi)
+{
+ struct fsi_master *master = fsi_get_master(fsi);
+ u32 data = 0;
+
+ if (master->core->ver < 2)
+ return -EINVAL;
+
+ data = CR_BWS_16 | CR_DTMD_SPDIF_PCM | CR_PCM;
+ fsi->chan_num = 2;
+ fsi_spdif_clk_ctrl(fsi, 1);
+ fsi_reg_mask_set(fsi, OUT_SEL, DMMD, DMMD);
+
+ fsi_reg_write(fsi, DO_FMT, data);
+ fsi_reg_write(fsi, DI_FMT, data);
+
+ return 0;
+}
+
static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai);
+ u32 flags = fsi_get_info_flags(fsi);
u32 data = 0;
int ret;
@@ -901,7 +894,18 @@ static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
goto set_fmt_exit;
}
fsi_reg_mask_set(fsi, CKG1, (DIMD | DOMD), data);
- ret = 0;
+
+ /* set format */
+ switch (flags & SH_FSI_FMT_MASK) {
+ case SH_FSI_FMT_DAI:
+ ret = fsi_set_fmt_dai(fsi, fmt & SND_SOC_DAIFMT_FORMAT_MASK);
+ break;
+ case SH_FSI_FMT_SPDIF:
+ ret = fsi_set_fmt_spdif(fsi);
+ break;
+ default:
+ ret = -EINVAL;
+ }
set_fmt_exit:
pm_runtime_put_sync(dai->dev);
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread