diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2012-02-03 03:57:25 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-02-03 06:55:40 -0500 |
commit | 180346ede352b12c72c5aeba2fc806fd32880c16 (patch) | |
tree | fb6beecbc664be92fba6efbe2e3fd5e1f9bccb5a /sound/soc/sh | |
parent | 938e2a8da5b2c1cb21c200e97736259948a3d12c (diff) |
ASoC: fsi: add .start_stop handler to fsi_stream_handler
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/sh')
-rw-r--r-- | sound/soc/sh/fsi.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 7dec144b8466..8d05e59c8831 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c | |||
@@ -203,6 +203,8 @@ struct fsi_stream_handler { | |||
203 | int (*probe)(struct fsi_priv *fsi, struct fsi_stream *io); | 203 | int (*probe)(struct fsi_priv *fsi, struct fsi_stream *io); |
204 | int (*transfer)(struct fsi_priv *fsi, struct fsi_stream *io); | 204 | int (*transfer)(struct fsi_priv *fsi, struct fsi_stream *io); |
205 | int (*remove)(struct fsi_priv *fsi, struct fsi_stream *io); | 205 | int (*remove)(struct fsi_priv *fsi, struct fsi_stream *io); |
206 | void (*start_stop)(struct fsi_priv *fsi, struct fsi_stream *io, | ||
207 | int enable); | ||
206 | }; | 208 | }; |
207 | #define fsi_stream_handler_call(io, func, args...) \ | 209 | #define fsi_stream_handler_call(io, func, args...) \ |
208 | (!(io) ? -ENODEV : \ | 210 | (!(io) ? -ENODEV : \ |
@@ -513,6 +515,12 @@ static int fsi_stream_transfer(struct fsi_stream *io) | |||
513 | return fsi_stream_handler_call(io, transfer, fsi, io); | 515 | return fsi_stream_handler_call(io, transfer, fsi, io); |
514 | } | 516 | } |
515 | 517 | ||
518 | #define fsi_stream_start(fsi, io)\ | ||
519 | fsi_stream_handler_call(io, start_stop, fsi, io, 1) | ||
520 | |||
521 | #define fsi_stream_stop(fsi, io)\ | ||
522 | fsi_stream_handler_call(io, start_stop, fsi, io, 0) | ||
523 | |||
516 | static int fsi_stream_probe(struct fsi_priv *fsi) | 524 | static int fsi_stream_probe(struct fsi_priv *fsi) |
517 | { | 525 | { |
518 | struct fsi_stream *io; | 526 | struct fsi_stream *io; |
@@ -691,24 +699,6 @@ static int fsi_set_master_clk(struct device *dev, struct fsi_priv *fsi, | |||
691 | return ret; | 699 | return ret; |
692 | } | 700 | } |
693 | 701 | ||
694 | #define fsi_port_start(f, i) __fsi_port_clk_ctrl(f, i, 1) | ||
695 | #define fsi_port_stop(f, i) __fsi_port_clk_ctrl(f, i, 0) | ||
696 | static void __fsi_port_clk_ctrl(struct fsi_priv *fsi, struct fsi_stream *io, | ||
697 | int enable) | ||
698 | { | ||
699 | struct fsi_master *master = fsi_get_master(fsi); | ||
700 | u32 clk = fsi_is_port_a(fsi) ? CRA : CRB; | ||
701 | |||
702 | if (enable) | ||
703 | fsi_irq_enable(fsi, io); | ||
704 | else | ||
705 | fsi_irq_disable(fsi, io); | ||
706 | |||
707 | if (fsi_is_clk_master(fsi)) | ||
708 | fsi_master_mask_set(master, CLK_RST, clk, (enable) ? clk : 0); | ||
709 | } | ||
710 | |||
711 | |||
712 | /* | 702 | /* |
713 | * pio data transfer handler | 703 | * pio data transfer handler |
714 | */ | 704 | */ |
@@ -845,12 +835,29 @@ static int fsi_pio_push(struct fsi_priv *fsi, struct fsi_stream *io) | |||
845 | samples); | 835 | samples); |
846 | } | 836 | } |
847 | 837 | ||
838 | static void fsi_pio_start_stop(struct fsi_priv *fsi, struct fsi_stream *io, | ||
839 | int enable) | ||
840 | { | ||
841 | struct fsi_master *master = fsi_get_master(fsi); | ||
842 | u32 clk = fsi_is_port_a(fsi) ? CRA : CRB; | ||
843 | |||
844 | if (enable) | ||
845 | fsi_irq_enable(fsi, io); | ||
846 | else | ||
847 | fsi_irq_disable(fsi, io); | ||
848 | |||
849 | if (fsi_is_clk_master(fsi)) | ||
850 | fsi_master_mask_set(master, CLK_RST, clk, (enable) ? clk : 0); | ||
851 | } | ||
852 | |||
848 | static struct fsi_stream_handler fsi_pio_push_handler = { | 853 | static struct fsi_stream_handler fsi_pio_push_handler = { |
849 | .transfer = fsi_pio_push, | 854 | .transfer = fsi_pio_push, |
855 | .start_stop = fsi_pio_start_stop, | ||
850 | }; | 856 | }; |
851 | 857 | ||
852 | static struct fsi_stream_handler fsi_pio_pop_handler = { | 858 | static struct fsi_stream_handler fsi_pio_pop_handler = { |
853 | .transfer = fsi_pio_pop, | 859 | .transfer = fsi_pio_pop, |
860 | .start_stop = fsi_pio_start_stop, | ||
854 | }; | 861 | }; |
855 | 862 | ||
856 | static irqreturn_t fsi_interrupt(int irq, void *data) | 863 | static irqreturn_t fsi_interrupt(int irq, void *data) |
@@ -1033,10 +1040,10 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd, | |||
1033 | fsi_stream_init(fsi, io, substream); | 1040 | fsi_stream_init(fsi, io, substream); |
1034 | ret = fsi_stream_transfer(io); | 1041 | ret = fsi_stream_transfer(io); |
1035 | if (0 == ret) | 1042 | if (0 == ret) |
1036 | fsi_port_start(fsi, io); | 1043 | fsi_stream_start(fsi, io); |
1037 | break; | 1044 | break; |
1038 | case SNDRV_PCM_TRIGGER_STOP: | 1045 | case SNDRV_PCM_TRIGGER_STOP: |
1039 | fsi_port_stop(fsi, io); | 1046 | fsi_stream_stop(fsi, io); |
1040 | fsi_stream_quit(fsi, io); | 1047 | fsi_stream_quit(fsi, io); |
1041 | break; | 1048 | break; |
1042 | } | 1049 | } |
@@ -1436,7 +1443,7 @@ static void __fsi_suspend(struct fsi_priv *fsi, | |||
1436 | if (!fsi_stream_is_working(fsi, io)) | 1443 | if (!fsi_stream_is_working(fsi, io)) |
1437 | return; | 1444 | return; |
1438 | 1445 | ||
1439 | fsi_port_stop(fsi, io); | 1446 | fsi_stream_stop(fsi, io); |
1440 | fsi_hw_shutdown(fsi, dev); | 1447 | fsi_hw_shutdown(fsi, dev); |
1441 | } | 1448 | } |
1442 | 1449 | ||
@@ -1452,7 +1459,7 @@ static void __fsi_resume(struct fsi_priv *fsi, | |||
1452 | if (fsi_is_clk_master(fsi) && fsi->rate) | 1459 | if (fsi_is_clk_master(fsi) && fsi->rate) |
1453 | fsi_set_master_clk(dev, fsi, fsi->rate, 1); | 1460 | fsi_set_master_clk(dev, fsi, fsi->rate, 1); |
1454 | 1461 | ||
1455 | fsi_port_start(fsi, io); | 1462 | fsi_stream_start(fsi, io); |
1456 | } | 1463 | } |
1457 | 1464 | ||
1458 | static int fsi_suspend(struct device *dev) | 1465 | static int fsi_suspend(struct device *dev) |