diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-01-19 21:46:02 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-01-21 14:01:47 -0500 |
commit | 4d805f7b6607f6e547dc22e5d57c201e43d21c05 (patch) | |
tree | 41ce090f7f9f3f4cc76e74101a108218da447f62 | |
parent | 0d032c19e764ad2f60292f58116f6c2a052a58ab (diff) |
ASoC: sh: fsi: Add snd_soc_dai_set_fmt support
This patch add snd_soc_dai_ops :: set_fmt to FSI driver and
select master/slave clock mode by snd_soc_dai_set_fmt on
fsi-xxx.c instead of platform infomation code.
This patch remove fsi_is_master function which is no longer needed.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | arch/arm/mach-shmobile/board-ag5evm.c | 4 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/board-ap4evb.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/board-mackerel.c | 2 | ||||
-rw-r--r-- | arch/sh/boards/mach-ecovec24/setup.c | 2 | ||||
-rw-r--r-- | arch/sh/boards/mach-se/7724/setup.c | 2 | ||||
-rw-r--r-- | include/sound/sh_fsi.h | 8 | ||||
-rw-r--r-- | sound/soc/sh/fsi-ak4642.c | 13 | ||||
-rw-r--r-- | sound/soc/sh/fsi-da7210.c | 12 | ||||
-rw-r--r-- | sound/soc/sh/fsi-hdmi.c | 11 | ||||
-rw-r--r-- | sound/soc/sh/fsi.c | 54 |
10 files changed, 63 insertions, 47 deletions
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c index c18a740a4159..9ee55e0fbeb1 100644 --- a/arch/arm/mach-shmobile/board-ag5evm.c +++ b/arch/arm/mach-shmobile/board-ag5evm.c | |||
@@ -119,9 +119,7 @@ static struct platform_device keysc_device = { | |||
119 | 119 | ||
120 | /* FSI A */ | 120 | /* FSI A */ |
121 | static struct sh_fsi_platform_info fsi_info = { | 121 | static struct sh_fsi_platform_info fsi_info = { |
122 | .porta_flags = SH_FSI_OUT_SLAVE_MODE | | 122 | .porta_flags = SH_FSI_OFMT(I2S) | |
123 | SH_FSI_IN_SLAVE_MODE | | ||
124 | SH_FSI_OFMT(I2S) | | ||
125 | SH_FSI_IFMT(I2S), | 123 | SH_FSI_IFMT(I2S), |
126 | }; | 124 | }; |
127 | 125 | ||
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c index 3cf0951caa2d..d503a74e30e4 100644 --- a/arch/arm/mach-shmobile/board-ap4evb.c +++ b/arch/arm/mach-shmobile/board-ap4evb.c | |||
@@ -674,8 +674,6 @@ static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable) | |||
674 | 674 | ||
675 | static struct sh_fsi_platform_info fsi_info = { | 675 | static struct sh_fsi_platform_info fsi_info = { |
676 | .porta_flags = SH_FSI_BRS_INV | | 676 | .porta_flags = SH_FSI_BRS_INV | |
677 | SH_FSI_OUT_SLAVE_MODE | | ||
678 | SH_FSI_IN_SLAVE_MODE | | ||
679 | SH_FSI_OFMT(PCM) | | 677 | SH_FSI_OFMT(PCM) | |
680 | SH_FSI_IFMT(PCM), | 678 | SH_FSI_IFMT(PCM), |
681 | 679 | ||
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c index 7b15d21f0f68..425962d5b29c 100644 --- a/arch/arm/mach-shmobile/board-mackerel.c +++ b/arch/arm/mach-shmobile/board-mackerel.c | |||
@@ -611,8 +611,6 @@ fsi_set_rate_end: | |||
611 | 611 | ||
612 | static struct sh_fsi_platform_info fsi_info = { | 612 | static struct sh_fsi_platform_info fsi_info = { |
613 | .porta_flags = SH_FSI_BRS_INV | | 613 | .porta_flags = SH_FSI_BRS_INV | |
614 | SH_FSI_OUT_SLAVE_MODE | | ||
615 | SH_FSI_IN_SLAVE_MODE | | ||
616 | SH_FSI_OFMT(PCM) | | 614 | SH_FSI_OFMT(PCM) | |
617 | SH_FSI_IFMT(PCM), | 615 | SH_FSI_IFMT(PCM), |
618 | 616 | ||
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index 33b662999fc6..037416f346cf 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c | |||
@@ -724,8 +724,6 @@ static struct platform_device camera_devices[] = { | |||
724 | /* FSI */ | 724 | /* FSI */ |
725 | static struct sh_fsi_platform_info fsi_info = { | 725 | static struct sh_fsi_platform_info fsi_info = { |
726 | .portb_flags = SH_FSI_BRS_INV | | 726 | .portb_flags = SH_FSI_BRS_INV | |
727 | SH_FSI_OUT_SLAVE_MODE | | ||
728 | SH_FSI_IN_SLAVE_MODE | | ||
729 | SH_FSI_OFMT(I2S) | | 727 | SH_FSI_OFMT(I2S) | |
730 | SH_FSI_IFMT(I2S), | 728 | SH_FSI_IFMT(I2S), |
731 | }; | 729 | }; |
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c index 527679394a25..b4aef05dd8b5 100644 --- a/arch/sh/boards/mach-se/7724/setup.c +++ b/arch/sh/boards/mach-se/7724/setup.c | |||
@@ -287,8 +287,6 @@ static struct platform_device ceu1_device = { | |||
287 | /* change J20, J21, J22 pin to 1-2 connection to use slave mode */ | 287 | /* change J20, J21, J22 pin to 1-2 connection to use slave mode */ |
288 | static struct sh_fsi_platform_info fsi_info = { | 288 | static struct sh_fsi_platform_info fsi_info = { |
289 | .porta_flags = SH_FSI_BRS_INV | | 289 | .porta_flags = SH_FSI_BRS_INV | |
290 | SH_FSI_OUT_SLAVE_MODE | | ||
291 | SH_FSI_IN_SLAVE_MODE | | ||
292 | SH_FSI_OFMT(PCM) | | 290 | SH_FSI_OFMT(PCM) | |
293 | SH_FSI_IFMT(PCM), | 291 | SH_FSI_IFMT(PCM), |
294 | }; | 292 | }; |
diff --git a/include/sound/sh_fsi.h b/include/sound/sh_fsi.h index d79894192ae3..18e43279f70f 100644 --- a/include/sound/sh_fsi.h +++ b/include/sound/sh_fsi.h | |||
@@ -17,12 +17,11 @@ | |||
17 | 17 | ||
18 | /* flags format | 18 | /* flags format |
19 | 19 | ||
20 | * 0xABCDEEFF | 20 | * 0xABC0EEFF |
21 | * | 21 | * |
22 | * A: channel size for TDM (input) | 22 | * A: channel size for TDM (input) |
23 | * B: channel size for TDM (ooutput) | 23 | * B: channel size for TDM (ooutput) |
24 | * C: inversion | 24 | * C: inversion |
25 | * D: mode | ||
26 | * E: input format | 25 | * E: input format |
27 | * F: output format | 26 | * F: output format |
28 | */ | 27 | */ |
@@ -46,11 +45,6 @@ | |||
46 | #define SH_FSI_LRS_INV (1 << 22) | 45 | #define SH_FSI_LRS_INV (1 << 22) |
47 | #define SH_FSI_BRS_INV (1 << 23) | 46 | #define SH_FSI_BRS_INV (1 << 23) |
48 | 47 | ||
49 | /* mode */ | ||
50 | #define SH_FSI_MODE_MASK 0x000F0000 | ||
51 | #define SH_FSI_IN_SLAVE_MODE (1 << 16) /* default master mode */ | ||
52 | #define SH_FSI_OUT_SLAVE_MODE (1 << 17) /* default master mode */ | ||
53 | |||
54 | /* DI format */ | 48 | /* DI format */ |
55 | #define SH_FSI_FMT_MASK 0x000000FF | 49 | #define SH_FSI_FMT_MASK 0x000000FF |
56 | #define SH_FSI_IFMT(x) (((SH_FSI_FMT_ ## x) & SH_FSI_FMT_MASK) << 8) | 50 | #define SH_FSI_IFMT(x) (((SH_FSI_FMT_ ## x) & SH_FSI_FMT_MASK) << 8) |
diff --git a/sound/soc/sh/fsi-ak4642.c b/sound/soc/sh/fsi-ak4642.c index a722a4c661ff..ce058c749e6a 100644 --- a/sound/soc/sh/fsi-ak4642.c +++ b/sound/soc/sh/fsi-ak4642.c | |||
@@ -23,15 +23,20 @@ struct fsi_ak4642_data { | |||
23 | 23 | ||
24 | static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd) | 24 | static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd) |
25 | { | 25 | { |
26 | struct snd_soc_dai *dai = rtd->codec_dai; | 26 | struct snd_soc_dai *codec = rtd->codec_dai; |
27 | struct snd_soc_dai *cpu = rtd->cpu_dai; | ||
27 | int ret; | 28 | int ret; |
28 | 29 | ||
29 | ret = snd_soc_dai_set_fmt(dai, SND_SOC_DAIFMT_LEFT_J | | 30 | ret = snd_soc_dai_set_fmt(codec, SND_SOC_DAIFMT_LEFT_J | |
30 | SND_SOC_DAIFMT_CBM_CFM); | 31 | SND_SOC_DAIFMT_CBM_CFM); |
31 | if (ret < 0) | 32 | if (ret < 0) |
32 | return ret; | 33 | return ret; |
33 | 34 | ||
34 | ret = snd_soc_dai_set_sysclk(dai, 0, 11289600, 0); | 35 | ret = snd_soc_dai_set_sysclk(codec, 0, 11289600, 0); |
36 | if (ret < 0) | ||
37 | return ret; | ||
38 | |||
39 | ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBS_CFS); | ||
35 | 40 | ||
36 | return ret; | 41 | return ret; |
37 | } | 42 | } |
diff --git a/sound/soc/sh/fsi-da7210.c b/sound/soc/sh/fsi-da7210.c index e8df9da92f71..9b24ed466ab1 100644 --- a/sound/soc/sh/fsi-da7210.c +++ b/sound/soc/sh/fsi-da7210.c | |||
@@ -15,11 +15,19 @@ | |||
15 | 15 | ||
16 | static int fsi_da7210_init(struct snd_soc_pcm_runtime *rtd) | 16 | static int fsi_da7210_init(struct snd_soc_pcm_runtime *rtd) |
17 | { | 17 | { |
18 | struct snd_soc_dai *dai = rtd->codec_dai; | 18 | struct snd_soc_dai *codec = rtd->codec_dai; |
19 | struct snd_soc_dai *cpu = rtd->cpu_dai; | ||
20 | int ret; | ||
19 | 21 | ||
20 | return snd_soc_dai_set_fmt(dai, | 22 | ret = snd_soc_dai_set_fmt(codec, |
21 | SND_SOC_DAIFMT_I2S | | 23 | SND_SOC_DAIFMT_I2S | |
22 | SND_SOC_DAIFMT_CBM_CFM); | 24 | SND_SOC_DAIFMT_CBM_CFM); |
25 | if (ret < 0) | ||
26 | return ret; | ||
27 | |||
28 | ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBS_CFS); | ||
29 | |||
30 | return ret; | ||
23 | } | 31 | } |
24 | 32 | ||
25 | static struct snd_soc_dai_link fsi_da7210_dai = { | 33 | static struct snd_soc_dai_link fsi_da7210_dai = { |
diff --git a/sound/soc/sh/fsi-hdmi.c b/sound/soc/sh/fsi-hdmi.c index a52dd8ec71d3..96d8ce3f3211 100644 --- a/sound/soc/sh/fsi-hdmi.c +++ b/sound/soc/sh/fsi-hdmi.c | |||
@@ -12,6 +12,16 @@ | |||
12 | #include <linux/platform_device.h> | 12 | #include <linux/platform_device.h> |
13 | #include <sound/sh_fsi.h> | 13 | #include <sound/sh_fsi.h> |
14 | 14 | ||
15 | static int fsi_hdmi_dai_init(struct snd_soc_pcm_runtime *rtd) | ||
16 | { | ||
17 | struct snd_soc_dai *cpu = rtd->cpu_dai; | ||
18 | int ret; | ||
19 | |||
20 | ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBM_CFM); | ||
21 | |||
22 | return ret; | ||
23 | } | ||
24 | |||
15 | static struct snd_soc_dai_link fsi_dai_link = { | 25 | static struct snd_soc_dai_link fsi_dai_link = { |
16 | .name = "HDMI", | 26 | .name = "HDMI", |
17 | .stream_name = "HDMI", | 27 | .stream_name = "HDMI", |
@@ -19,6 +29,7 @@ static struct snd_soc_dai_link fsi_dai_link = { | |||
19 | .codec_dai_name = "sh_mobile_hdmi-hifi", | 29 | .codec_dai_name = "sh_mobile_hdmi-hifi", |
20 | .platform_name = "sh_fsi2", | 30 | .platform_name = "sh_fsi2", |
21 | .codec_name = "sh-mobile-hdmi", | 31 | .codec_name = "sh-mobile-hdmi", |
32 | .init = fsi_hdmi_dai_init, | ||
22 | }; | 33 | }; |
23 | 34 | ||
24 | static struct snd_soc_card fsi_soc_card = { | 35 | static struct snd_soc_card fsi_soc_card = { |
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 1d0a16e80919..5f39f364effd 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c | |||
@@ -78,6 +78,8 @@ | |||
78 | /* CKG1 */ | 78 | /* CKG1 */ |
79 | #define ACKMD_MASK 0x00007000 | 79 | #define ACKMD_MASK 0x00007000 |
80 | #define BPFMD_MASK 0x00000700 | 80 | #define BPFMD_MASK 0x00000700 |
81 | #define DIMD (1 << 4) | ||
82 | #define DOMD (1 << 0) | ||
81 | 83 | ||
82 | /* A/B MST_CTLR */ | 84 | /* A/B MST_CTLR */ |
83 | #define BP (1 << 4) /* Fix the signal of Biphase output */ | 85 | #define BP (1 << 4) /* Fix the signal of Biphase output */ |
@@ -292,21 +294,6 @@ static inline struct fsi_stream *fsi_get_stream(struct fsi_priv *fsi, | |||
292 | return is_play ? &fsi->playback : &fsi->capture; | 294 | return is_play ? &fsi->playback : &fsi->capture; |
293 | } | 295 | } |
294 | 296 | ||
295 | static int fsi_is_master_mode(struct fsi_priv *fsi, int is_play) | ||
296 | { | ||
297 | u32 mode; | ||
298 | u32 flags = fsi_get_info_flags(fsi); | ||
299 | |||
300 | mode = is_play ? SH_FSI_OUT_SLAVE_MODE : SH_FSI_IN_SLAVE_MODE; | ||
301 | |||
302 | /* return | ||
303 | * 1 : master mode | ||
304 | * 0 : slave mode | ||
305 | */ | ||
306 | |||
307 | return (mode & flags) != mode; | ||
308 | } | ||
309 | |||
310 | static u32 fsi_get_port_shift(struct fsi_priv *fsi, int is_play) | 297 | static u32 fsi_get_port_shift(struct fsi_priv *fsi, int is_play) |
311 | { | 298 | { |
312 | int is_porta = fsi_is_port_a(fsi); | 299 | int is_porta = fsi_is_port_a(fsi); |
@@ -764,19 +751,11 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream, | |||
764 | u32 fmt; | 751 | u32 fmt; |
765 | u32 data; | 752 | u32 data; |
766 | int is_play = fsi_is_play(substream); | 753 | int is_play = fsi_is_play(substream); |
767 | int is_master; | ||
768 | 754 | ||
769 | io = fsi_get_stream(fsi, is_play); | 755 | io = fsi_get_stream(fsi, is_play); |
770 | 756 | ||
771 | pm_runtime_get_sync(dai->dev); | 757 | pm_runtime_get_sync(dai->dev); |
772 | 758 | ||
773 | /* CKG1 */ | ||
774 | data = is_play ? (1 << 0) : (1 << 4); | ||
775 | is_master = fsi_is_master_mode(fsi, is_play); | ||
776 | if (is_master) | ||
777 | fsi_reg_mask_set(fsi, CKG1, data, data); | ||
778 | else | ||
779 | fsi_reg_mask_set(fsi, CKG1, data, 0); | ||
780 | 759 | ||
781 | /* clock inversion (CKG2) */ | 760 | /* clock inversion (CKG2) */ |
782 | data = 0; | 761 | data = 0; |
@@ -893,6 +872,34 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd, | |||
893 | return ret; | 872 | return ret; |
894 | } | 873 | } |
895 | 874 | ||
875 | static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | ||
876 | { | ||
877 | struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai); | ||
878 | u32 data = 0; | ||
879 | int ret; | ||
880 | |||
881 | pm_runtime_get_sync(dai->dev); | ||
882 | |||
883 | /* set master/slave audio interface */ | ||
884 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
885 | case SND_SOC_DAIFMT_CBM_CFM: | ||
886 | data = DIMD | DOMD; | ||
887 | break; | ||
888 | case SND_SOC_DAIFMT_CBS_CFS: | ||
889 | break; | ||
890 | default: | ||
891 | ret = -EINVAL; | ||
892 | goto set_fmt_exit; | ||
893 | } | ||
894 | fsi_reg_mask_set(fsi, CKG1, (DIMD | DOMD), data); | ||
895 | ret = 0; | ||
896 | |||
897 | set_fmt_exit: | ||
898 | pm_runtime_put_sync(dai->dev); | ||
899 | |||
900 | return ret; | ||
901 | } | ||
902 | |||
896 | static int fsi_dai_hw_params(struct snd_pcm_substream *substream, | 903 | static int fsi_dai_hw_params(struct snd_pcm_substream *substream, |
897 | struct snd_pcm_hw_params *params, | 904 | struct snd_pcm_hw_params *params, |
898 | struct snd_soc_dai *dai) | 905 | struct snd_soc_dai *dai) |
@@ -979,6 +986,7 @@ static struct snd_soc_dai_ops fsi_dai_ops = { | |||
979 | .startup = fsi_dai_startup, | 986 | .startup = fsi_dai_startup, |
980 | .shutdown = fsi_dai_shutdown, | 987 | .shutdown = fsi_dai_shutdown, |
981 | .trigger = fsi_dai_trigger, | 988 | .trigger = fsi_dai_trigger, |
989 | .set_fmt = fsi_dai_set_fmt, | ||
982 | .hw_params = fsi_dai_hw_params, | 990 | .hw_params = fsi_dai_hw_params, |
983 | }; | 991 | }; |
984 | 992 | ||