* [PATCH 0/2] ASoC: simultaneous playback/recorde support for SH board
@ 2010-10-12 4:38 Kuninori Morimoto
2010-10-12 4:39 ` [PATCH 1/2] ASoC: fsi: simultaneous playback/recorde support Kuninori Morimoto, Kuninori Morimoto
2010-10-12 4:39 ` [PATCH 2/2] ASoC: ak4642: " Kuninori Morimoto, Kuninori Morimoto
0 siblings, 2 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2010-10-12 4:38 UTC (permalink / raw)
To: Mark Brown; +Cc: Linux-ALSA, Liam Girdwood
Dear Mark, Liam
These are simultaneous playback/recorde support for FSI and ak4642
Kuninori Morimoto (2):
ASoC: fsi: simultaneous playback/recorde support
ASoC: ak4642: simultaneous playback/recorde support
Best regards
--
Kuninori Morimoto
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH 1/2] ASoC: fsi: simultaneous playback/recorde support 2010-10-12 4:38 [PATCH 0/2] ASoC: simultaneous playback/recorde support for SH board Kuninori Morimoto @ 2010-10-12 4:39 ` Kuninori Morimoto, Kuninori Morimoto 2010-10-12 9:19 ` Liam Girdwood 2010-10-12 4:39 ` [PATCH 2/2] ASoC: ak4642: " Kuninori Morimoto, Kuninori Morimoto 1 sibling, 1 reply; 11+ messages in thread From: Kuninori Morimoto, Kuninori Morimoto @ 2010-10-12 4:39 UTC (permalink / raw) To: Mark Brown; +Cc: Linux-ALSA, Liam Girdwood Current FSI driver had not cared about simultaneous playback/recorde on same port. This patch add new fsi_stream struct to care it, Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> --- sound/soc/sh/fsi.c | 142 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 86 insertions(+), 56 deletions(-) diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 895ce75..0c80d10 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -48,6 +48,10 @@ #define MREG_START A_MST_CTLR #define MREG_END FIFO_SZ +/* is */ +#define IS_PLAY 1 +#define IS_CAPTURE 0 + /* DO_FMT */ /* DI_FMT */ #define CR_MONO (0x0 << 4) @@ -113,10 +117,8 @@ * struct */ -struct fsi_priv { - void __iomem *base; +struct fsi_stream { struct snd_pcm_substream *substream; - struct fsi_master *master; int fifo_max_num; int chan_num; @@ -125,6 +127,14 @@ struct fsi_priv { int buff_len; int period_len; int period_num; +}; + +struct fsi_priv { + void __iomem *base; + struct fsi_master *master; + + struct fsi_stream playback; + struct fsi_stream capture; u32 mst_ctrl; }; @@ -294,6 +304,11 @@ static u32 fsi_get_info_flags(struct fsi_priv *fsi) master->info->portb_flags; } +static struct fsi_stream *fsi_get_stream(struct fsi_priv *fsi, int is_play) +{ + return is_play ? &fsi->playback : &fsi->capture; +} + static int fsi_is_play(struct snd_pcm_substream *substream) { return substream->stream == SNDRV_PCM_STREAM_PLAYBACK; @@ -328,35 +343,41 @@ static u32 fsi_get_port_shift(struct fsi_priv *fsi, int is_play) } static void fsi_stream_push(struct fsi_priv *fsi, + int is_play, struct snd_pcm_substream *substream, u32 buffer_len, u32 period_len) { - fsi->substream = substream; - fsi->buff_len = buffer_len; - fsi->buff_offset = 0; - fsi->period_len = period_len; - fsi->period_num = 0; + struct fsi_stream *io = fsi_get_stream(fsi, is_play); + + io->substream = substream; + io->buff_len = buffer_len; + io->buff_offset = 0; + io->period_len = period_len; + io->period_num = 0; } -static void fsi_stream_pop(struct fsi_priv *fsi) +static void fsi_stream_pop(struct fsi_priv *fsi, int is_play) { - fsi->substream = NULL; - fsi->buff_len = 0; - fsi->buff_offset = 0; - fsi->period_len = 0; - fsi->period_num = 0; + struct fsi_stream *io = fsi_get_stream(fsi, is_play); + + io->substream = NULL; + io->buff_len = 0; + io->buff_offset = 0; + io->period_len = 0; + io->period_num = 0; } static int fsi_get_fifo_data_num(struct fsi_priv *fsi, int is_play) { u32 status; u32 reg = is_play ? DOFF_ST : DIFF_ST; + struct fsi_stream *io = fsi_get_stream(fsi, is_play); int data_num; status = fsi_reg_read(fsi, reg); data_num = 0x1ff & (status >> 8); - data_num *= fsi->chan_num; + data_num *= io->chan_num; return data_num; } @@ -372,21 +393,24 @@ static int fsi_num2len(int num, int width) return num * width; } -static int fsi_get_frame_width(struct fsi_priv *fsi) +static int fsi_get_frame_width(struct fsi_priv *fsi, int is_play) { - struct snd_pcm_substream *substream = fsi->substream; + struct fsi_stream *io = fsi_get_stream(fsi, is_play); + struct snd_pcm_substream *substream = io->substream; struct snd_pcm_runtime *runtime = substream->runtime; - return frames_to_bytes(runtime, 1) / fsi->chan_num; + return frames_to_bytes(runtime, 1) / io->chan_num; } /* * dma function */ -static u8 *fsi_dma_get_area(struct fsi_priv *fsi) +static u8 *fsi_dma_get_area(struct fsi_priv *fsi, int is_play) { - return fsi->substream->runtime->dma_area + fsi->buff_offset; + struct fsi_stream *io = fsi_get_stream(fsi, is_play); + + return io->substream->runtime->dma_area + io->buff_offset; } static void fsi_dma_soft_push16(struct fsi_priv *fsi, int num) @@ -394,7 +418,7 @@ static void fsi_dma_soft_push16(struct fsi_priv *fsi, int num) u16 *start; int i; - start = (u16 *)fsi_dma_get_area(fsi); + start = (u16 *)fsi_dma_get_area(fsi, IS_PLAY); for (i = 0; i < num; i++) fsi_reg_write(fsi, DODT, ((u32)*(start + i) << 8)); @@ -405,7 +429,7 @@ static void fsi_dma_soft_pop16(struct fsi_priv *fsi, int num) u16 *start; int i; - start = (u16 *)fsi_dma_get_area(fsi); + start = (u16 *)fsi_dma_get_area(fsi, IS_CAPTURE); for (i = 0; i < num; i++) *(start + i) = (u16)(fsi_reg_read(fsi, DIDT) >> 8); @@ -416,7 +440,7 @@ static void fsi_dma_soft_push32(struct fsi_priv *fsi, int num) u32 *start; int i; - start = (u32 *)fsi_dma_get_area(fsi); + start = (u32 *)fsi_dma_get_area(fsi, IS_PLAY); for (i = 0; i < num; i++) fsi_reg_write(fsi, DODT, *(start + i)); @@ -427,7 +451,7 @@ static void fsi_dma_soft_pop32(struct fsi_priv *fsi, int num) u32 *start; int i; - start = (u32 *)fsi_dma_get_area(fsi); + start = (u32 *)fsi_dma_get_area(fsi, IS_CAPTURE); for (i = 0; i < num; i++) *(start + i) = fsi_reg_read(fsi, DIDT); @@ -518,14 +542,15 @@ static void fsi_fifo_init(struct fsi_priv *fsi, struct snd_soc_dai *dai) { struct fsi_master *master = fsi_get_master(fsi); + struct fsi_stream *io = fsi_get_stream(fsi, is_play); u32 ctrl, shift, i; /* get on-chip RAM capacity */ shift = fsi_master_read(master, FIFO_SZ); shift >>= fsi_get_port_shift(fsi, is_play); shift &= FIFO_SZ_MASK; - fsi->fifo_max_num = 256 << shift; - dev_dbg(dai->dev, "fifo = %d words\n", fsi->fifo_max_num); + io->fifo_max_num = 256 << shift; + dev_dbg(dai->dev, "fifo = %d words\n", io->fifo_max_num); /* * The maximum number of sample data varies depending @@ -546,10 +571,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 < fsi->chan_num; i <<= 1) - fsi->fifo_max_num >>= 1; + for (i = 1; i < io->chan_num; i <<= 1) + io->fifo_max_num >>= 1; dev_dbg(dai->dev, "%d channel %d store\n", - fsi->chan_num, fsi->fifo_max_num); + io->chan_num, io->fifo_max_num); ctrl = is_play ? DOFF_CTL : DIFF_CTL; @@ -576,6 +601,7 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int is_play) { struct snd_pcm_runtime *runtime; struct snd_pcm_substream *substream = NULL; + struct fsi_stream *io = fsi_get_stream(fsi, is_play); u32 status_reg = is_play ? DOFF_ST : DIFF_ST; int data_residue_num; int data_num; @@ -585,32 +611,32 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int is_play) void (*fn)(struct fsi_priv *fsi, int size); if (!fsi || - !fsi->substream || - !fsi->substream->runtime) + !io->substream || + !io->substream->runtime) return -EINVAL; over_period = 0; - substream = fsi->substream; + substream = io->substream; runtime = substream->runtime; /* FSI FIFO has limit. * So, this driver can not send periods data at a time */ - if (fsi->buff_offset >= - fsi_num2offset(fsi->period_num + 1, fsi->period_len)) { + if (io->buff_offset >= + fsi_num2offset(io->period_num + 1, io->period_len)) { over_period = 1; - fsi->period_num = (fsi->period_num + 1) % runtime->periods; + io->period_num = (io->period_num + 1) % runtime->periods; - if (0 == fsi->period_num) - fsi->buff_offset = 0; + if (0 == io->period_num) + io->buff_offset = 0; } /* get 1 channel data width */ - ch_width = fsi_get_frame_width(fsi); + ch_width = fsi_get_frame_width(fsi, is_play); /* get residue data number of alsa */ - data_residue_num = fsi_len2num(fsi->buff_len - fsi->buff_offset, + data_residue_num = fsi_len2num(io->buff_len - io->buff_offset, ch_width); if (is_play) { @@ -620,7 +646,7 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int is_play) * data_num_max : number of FSI fifo free space * data_num : number of ALSA residue data */ - data_num_max = fsi->fifo_max_num * fsi->chan_num; + data_num_max = io->fifo_max_num * io->chan_num; data_num_max -= fsi_get_fifo_data_num(fsi, is_play); data_num = data_residue_num; @@ -662,7 +688,7 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int is_play) fn(fsi, data_num); /* update buff_offset */ - fsi->buff_offset += fsi_num2offset(data_num, ch_width); + io->buff_offset += fsi_num2offset(data_num, ch_width); /* check fifo status */ if (!startup) { @@ -687,12 +713,12 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int is_play) static int fsi_data_pop(struct fsi_priv *fsi, int startup) { - return fsi_fifo_data_ctrl(fsi, startup, 0); + return fsi_fifo_data_ctrl(fsi, startup, IS_CAPTURE); } static int fsi_data_push(struct fsi_priv *fsi, int startup) { - return fsi_fifo_data_ctrl(fsi, startup, 1); + return fsi_fifo_data_ctrl(fsi, startup, IS_PLAY); } static irqreturn_t fsi_interrupt(int irq, void *data) @@ -726,14 +752,17 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct fsi_priv *fsi = fsi_get_priv(substream); - u32 flags = fsi_get_info_flags(fsi); struct fsi_master *master = fsi_get_master(fsi); + struct fsi_stream *io; + u32 flags = fsi_get_info_flags(fsi); u32 fmt; u32 reg; u32 data; int is_play = fsi_is_play(substream); int is_master; + io = fsi_get_stream(fsi, is_play); + pm_runtime_get_sync(dai->dev); /* CKG1 */ @@ -764,29 +793,29 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream, switch (fmt) { case SH_FSI_FMT_MONO: data = CR_MONO; - fsi->chan_num = 1; + io->chan_num = 1; break; case SH_FSI_FMT_MONO_DELAY: data = CR_MONO_D; - fsi->chan_num = 1; + io->chan_num = 1; break; case SH_FSI_FMT_PCM: data = CR_PCM; - fsi->chan_num = 2; + io->chan_num = 2; break; case SH_FSI_FMT_I2S: data = CR_I2S; - fsi->chan_num = 2; + io->chan_num = 2; break; case SH_FSI_FMT_TDM: - fsi->chan_num = is_play ? + io->chan_num = is_play ? SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags); - data = CR_TDM | (fsi->chan_num - 1); + data = CR_TDM | (io->chan_num - 1); break; case SH_FSI_FMT_TDM_DELAY: - fsi->chan_num = is_play ? + io->chan_num = is_play ? SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags); - data = CR_TDM_D | (fsi->chan_num - 1); + data = CR_TDM_D | (io->chan_num - 1); break; case SH_FSI_FMT_SPDIF: if (master->core->ver < 2) { @@ -794,7 +823,7 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream, return -EINVAL; } data = CR_SPDIF; - fsi->chan_num = 2; + io->chan_num = 2; fsi_spdif_clk_ctrl(fsi, 1); fsi_reg_mask_set(fsi, OUT_SEL, 0x0010, 0x0010); break; @@ -836,14 +865,14 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd, switch (cmd) { case SNDRV_PCM_TRIGGER_START: - fsi_stream_push(fsi, substream, + fsi_stream_push(fsi, is_play, substream, frames_to_bytes(runtime, runtime->buffer_size), frames_to_bytes(runtime, runtime->period_size)); ret = is_play ? fsi_data_push(fsi, 1) : fsi_data_pop(fsi, 1); break; case SNDRV_PCM_TRIGGER_STOP: fsi_irq_disable(fsi, is_play); - fsi_stream_pop(fsi); + fsi_stream_pop(fsi, is_play); break; } @@ -991,9 +1020,10 @@ static snd_pcm_uframes_t fsi_pointer(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct fsi_priv *fsi = fsi_get_priv(substream); + struct fsi_stream *io = fsi_get_stream(fsi, fsi_is_play(substream)); long location; - location = (fsi->buff_offset - 1); + location = (io->buff_offset - 1); if (location < 0) location = 0; -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] ASoC: fsi: simultaneous playback/recorde support 2010-10-12 4:39 ` [PATCH 1/2] ASoC: fsi: simultaneous playback/recorde support Kuninori Morimoto, Kuninori Morimoto @ 2010-10-12 9:19 ` Liam Girdwood 2010-10-12 9:33 ` Kuninori Morimoto 0 siblings, 1 reply; 11+ messages in thread From: Liam Girdwood @ 2010-10-12 9:19 UTC (permalink / raw) To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown On Tue, 2010-10-12 at 13:39 +0900, Kuninori Morimoto wrote: > Current FSI driver had not cared about simultaneous > playback/recorde on same port. > This patch add new fsi_stream struct to care it, > > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> > --- > sound/soc/sh/fsi.c | 142 +++++++++++++++++++++++++++++++-------------------- > 1 files changed, 86 insertions(+), 56 deletions(-) > > diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c > index 895ce75..0c80d10 100644 > --- a/sound/soc/sh/fsi.c > +++ b/sound/soc/sh/fsi.c > @@ -48,6 +48,10 @@ > #define MREG_START A_MST_CTLR > #define MREG_END FIFO_SZ > > +/* is */ > +#define IS_PLAY 1 > +#define IS_CAPTURE 0 Please use SNDRV_PCM_STREAM_PLAYBACK and SNDRV_PCM_STREAM_CAPTURE here. -- Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] ASoC: fsi: simultaneous playback/recorde support 2010-10-12 9:19 ` Liam Girdwood @ 2010-10-12 9:33 ` Kuninori Morimoto 2010-10-12 9:41 ` Liam Girdwood 0 siblings, 1 reply; 11+ messages in thread From: Kuninori Morimoto @ 2010-10-12 9:33 UTC (permalink / raw) To: Liam Girdwood; +Cc: Linux-ALSA, Mark Brown Dear Liam Thank you for your checking patch > > +/* is */ > > +#define IS_PLAY 1 > > +#define IS_CAPTURE 0 > > Please use SNDRV_PCM_STREAM_PLAYBACK and SNDRV_PCM_STREAM_CAPTURE here. understand but ... I think SNDRV_PCM_STREAM_PLAYBACK = 0 SNDRV_PCM_STREAM_CAPTURE = 1 But in fsi driver, IS_PLAY needs 1, IS_CAPTURE needs 0 for now. should I modify all of these ? Best regards -- Kuninori Morimoto ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] ASoC: fsi: simultaneous playback/recorde support 2010-10-12 9:33 ` Kuninori Morimoto @ 2010-10-12 9:41 ` Liam Girdwood 2010-10-12 10:19 ` [PATCH 1/2 v2] " Kuninori Morimoto 0 siblings, 1 reply; 11+ messages in thread From: Liam Girdwood @ 2010-10-12 9:41 UTC (permalink / raw) To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown On Tue, 2010-10-12 at 18:33 +0900, Kuninori Morimoto wrote: > Dear Liam > > Thank you for your checking patch > > > > +/* is */ > > > +#define IS_PLAY 1 > > > +#define IS_CAPTURE 0 > > > > Please use SNDRV_PCM_STREAM_PLAYBACK and SNDRV_PCM_STREAM_CAPTURE here. > > understand but ... > I think > SNDRV_PCM_STREAM_PLAYBACK = 0 > SNDRV_PCM_STREAM_CAPTURE = 1 > > But in fsi driver, IS_PLAY needs 1, IS_CAPTURE needs 0 for now. > should I modify all of these ? Yes, we need to keep consistency with ALSA. Thanks Liam -- Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/2 v2] ASoC: fsi: simultaneous playback/recorde support 2010-10-12 9:41 ` Liam Girdwood @ 2010-10-12 10:19 ` Kuninori Morimoto 2010-10-15 10:06 ` Mark Brown 0 siblings, 1 reply; 11+ messages in thread From: Kuninori Morimoto @ 2010-10-12 10:19 UTC (permalink / raw) To: Liam Girdwood; +Cc: Linux-ALSA, Mark Brown Current FSI driver had not cared about simultaneous playback/capture on same port. This patch add new fsi_stream struct to care it, Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> --- v1 -> v2 - remove IS_PLAY, IS_CAPTURE and SNDRV_PCM_STREAM_PLAYBACK/CAPTURE are used - fsi_get_stream become inline - fsi_stream_is_play function was added sound/soc/sh/fsi.c | 152 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 94 insertions(+), 58 deletions(-) diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index dfc04bc..507e709 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -113,10 +113,8 @@ * struct */ -struct fsi_priv { - void __iomem *base; +struct fsi_stream { struct snd_pcm_substream *substream; - struct fsi_master *master; int fifo_max_num; int chan_num; @@ -125,6 +123,14 @@ struct fsi_priv { int buff_len; int period_len; int period_num; +}; + +struct fsi_priv { + void __iomem *base; + struct fsi_master *master; + + struct fsi_stream playback; + struct fsi_stream capture; u32 mst_ctrl; }; @@ -294,9 +300,20 @@ static u32 fsi_get_info_flags(struct fsi_priv *fsi) master->info->portb_flags; } +static inline int fsi_stream_is_play(int stream) +{ + return stream == SNDRV_PCM_STREAM_PLAYBACK; +} + static inline int fsi_is_play(struct snd_pcm_substream *substream) { - return substream->stream == SNDRV_PCM_STREAM_PLAYBACK; + return fsi_stream_is_play(substream->stream); +} + +static inline struct fsi_stream *fsi_get_stream(struct fsi_priv *fsi, + int is_play) +{ + return is_play ? &fsi->playback : &fsi->capture; } static int fsi_is_master_mode(struct fsi_priv *fsi, int is_play) @@ -328,35 +345,41 @@ static u32 fsi_get_port_shift(struct fsi_priv *fsi, int is_play) } static void fsi_stream_push(struct fsi_priv *fsi, + int is_play, struct snd_pcm_substream *substream, u32 buffer_len, u32 period_len) { - fsi->substream = substream; - fsi->buff_len = buffer_len; - fsi->buff_offset = 0; - fsi->period_len = period_len; - fsi->period_num = 0; + struct fsi_stream *io = fsi_get_stream(fsi, is_play); + + io->substream = substream; + io->buff_len = buffer_len; + io->buff_offset = 0; + io->period_len = period_len; + io->period_num = 0; } -static void fsi_stream_pop(struct fsi_priv *fsi) +static void fsi_stream_pop(struct fsi_priv *fsi, int is_play) { - fsi->substream = NULL; - fsi->buff_len = 0; - fsi->buff_offset = 0; - fsi->period_len = 0; - fsi->period_num = 0; + struct fsi_stream *io = fsi_get_stream(fsi, is_play); + + io->substream = NULL; + io->buff_len = 0; + io->buff_offset = 0; + io->period_len = 0; + io->period_num = 0; } static int fsi_get_fifo_data_num(struct fsi_priv *fsi, int is_play) { u32 status; u32 reg = is_play ? DOFF_ST : DIFF_ST; + struct fsi_stream *io = fsi_get_stream(fsi, is_play); int data_num; status = fsi_reg_read(fsi, reg); data_num = 0x1ff & (status >> 8); - data_num *= fsi->chan_num; + data_num *= io->chan_num; return data_num; } @@ -372,21 +395,25 @@ static int fsi_num2len(int num, int width) return num * width; } -static int fsi_get_frame_width(struct fsi_priv *fsi) +static int fsi_get_frame_width(struct fsi_priv *fsi, int is_play) { - struct snd_pcm_substream *substream = fsi->substream; + struct fsi_stream *io = fsi_get_stream(fsi, is_play); + struct snd_pcm_substream *substream = io->substream; struct snd_pcm_runtime *runtime = substream->runtime; - return frames_to_bytes(runtime, 1) / fsi->chan_num; + return frames_to_bytes(runtime, 1) / io->chan_num; } /* * dma function */ -static u8 *fsi_dma_get_area(struct fsi_priv *fsi) +static u8 *fsi_dma_get_area(struct fsi_priv *fsi, int stream) { - return fsi->substream->runtime->dma_area + fsi->buff_offset; + int is_play = fsi_stream_is_play(stream); + struct fsi_stream *io = fsi_get_stream(fsi, is_play); + + return io->substream->runtime->dma_area + io->buff_offset; } static void fsi_dma_soft_push16(struct fsi_priv *fsi, int num) @@ -394,7 +421,7 @@ static void fsi_dma_soft_push16(struct fsi_priv *fsi, int num) u16 *start; int i; - start = (u16 *)fsi_dma_get_area(fsi); + start = (u16 *)fsi_dma_get_area(fsi, SNDRV_PCM_STREAM_PLAYBACK); for (i = 0; i < num; i++) fsi_reg_write(fsi, DODT, ((u32)*(start + i) << 8)); @@ -405,7 +432,8 @@ static void fsi_dma_soft_pop16(struct fsi_priv *fsi, int num) u16 *start; int i; - start = (u16 *)fsi_dma_get_area(fsi); + start = (u16 *)fsi_dma_get_area(fsi, SNDRV_PCM_STREAM_CAPTURE); + for (i = 0; i < num; i++) *(start + i) = (u16)(fsi_reg_read(fsi, DIDT) >> 8); @@ -416,7 +444,8 @@ static void fsi_dma_soft_push32(struct fsi_priv *fsi, int num) u32 *start; int i; - start = (u32 *)fsi_dma_get_area(fsi); + start = (u32 *)fsi_dma_get_area(fsi, SNDRV_PCM_STREAM_PLAYBACK); + for (i = 0; i < num; i++) fsi_reg_write(fsi, DODT, *(start + i)); @@ -427,7 +456,7 @@ static void fsi_dma_soft_pop32(struct fsi_priv *fsi, int num) u32 *start; int i; - start = (u32 *)fsi_dma_get_area(fsi); + start = (u32 *)fsi_dma_get_area(fsi, SNDRV_PCM_STREAM_CAPTURE); for (i = 0; i < num; i++) *(start + i) = fsi_reg_read(fsi, DIDT); @@ -518,14 +547,15 @@ static void fsi_fifo_init(struct fsi_priv *fsi, struct snd_soc_dai *dai) { struct fsi_master *master = fsi_get_master(fsi); + struct fsi_stream *io = fsi_get_stream(fsi, is_play); u32 ctrl, shift, i; /* get on-chip RAM capacity */ shift = fsi_master_read(master, FIFO_SZ); shift >>= fsi_get_port_shift(fsi, is_play); shift &= FIFO_SZ_MASK; - fsi->fifo_max_num = 256 << shift; - dev_dbg(dai->dev, "fifo = %d words\n", fsi->fifo_max_num); + io->fifo_max_num = 256 << shift; + dev_dbg(dai->dev, "fifo = %d words\n", io->fifo_max_num); /* * The maximum number of sample data varies depending @@ -546,10 +576,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 < fsi->chan_num; i <<= 1) - fsi->fifo_max_num >>= 1; + for (i = 1; i < io->chan_num; i <<= 1) + io->fifo_max_num >>= 1; dev_dbg(dai->dev, "%d channel %d store\n", - fsi->chan_num, fsi->fifo_max_num); + io->chan_num, io->fifo_max_num); ctrl = is_play ? DOFF_CTL : DIFF_CTL; @@ -572,10 +602,12 @@ static void fsi_soft_all_reset(struct fsi_master *master) mdelay(10); } -static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int is_play) +static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int stream) { struct snd_pcm_runtime *runtime; struct snd_pcm_substream *substream = NULL; + int is_play = fsi_stream_is_play(stream); + struct fsi_stream *io = fsi_get_stream(fsi, is_play); u32 status_reg = is_play ? DOFF_ST : DIFF_ST; int data_residue_num; int data_num; @@ -585,32 +617,32 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int is_play) void (*fn)(struct fsi_priv *fsi, int size); if (!fsi || - !fsi->substream || - !fsi->substream->runtime) + !io->substream || + !io->substream->runtime) return -EINVAL; over_period = 0; - substream = fsi->substream; + substream = io->substream; runtime = substream->runtime; /* FSI FIFO has limit. * So, this driver can not send periods data at a time */ - if (fsi->buff_offset >= - fsi_num2offset(fsi->period_num + 1, fsi->period_len)) { + if (io->buff_offset >= + fsi_num2offset(io->period_num + 1, io->period_len)) { over_period = 1; - fsi->period_num = (fsi->period_num + 1) % runtime->periods; + io->period_num = (io->period_num + 1) % runtime->periods; - if (0 == fsi->period_num) - fsi->buff_offset = 0; + if (0 == io->period_num) + io->buff_offset = 0; } /* get 1 channel data width */ - ch_width = fsi_get_frame_width(fsi); + ch_width = fsi_get_frame_width(fsi, is_play); /* get residue data number of alsa */ - data_residue_num = fsi_len2num(fsi->buff_len - fsi->buff_offset, + data_residue_num = fsi_len2num(io->buff_len - io->buff_offset, ch_width); if (is_play) { @@ -620,7 +652,7 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int is_play) * data_num_max : number of FSI fifo free space * data_num : number of ALSA residue data */ - data_num_max = fsi->fifo_max_num * fsi->chan_num; + data_num_max = io->fifo_max_num * io->chan_num; data_num_max -= fsi_get_fifo_data_num(fsi, is_play); data_num = data_residue_num; @@ -662,7 +694,7 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int is_play) fn(fsi, data_num); /* update buff_offset */ - fsi->buff_offset += fsi_num2offset(data_num, ch_width); + io->buff_offset += fsi_num2offset(data_num, ch_width); /* check fifo status */ if (!startup) { @@ -687,12 +719,12 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int startup, int is_play) static int fsi_data_pop(struct fsi_priv *fsi, int startup) { - return fsi_fifo_data_ctrl(fsi, startup, 0); + return fsi_fifo_data_ctrl(fsi, startup, SNDRV_PCM_STREAM_CAPTURE); } static int fsi_data_push(struct fsi_priv *fsi, int startup) { - return fsi_fifo_data_ctrl(fsi, startup, 1); + return fsi_fifo_data_ctrl(fsi, startup, SNDRV_PCM_STREAM_PLAYBACK); } static irqreturn_t fsi_interrupt(int irq, void *data) @@ -726,14 +758,17 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct fsi_priv *fsi = fsi_get_priv(substream); - u32 flags = fsi_get_info_flags(fsi); struct fsi_master *master = fsi_get_master(fsi); + struct fsi_stream *io; + u32 flags = fsi_get_info_flags(fsi); u32 fmt; u32 reg; u32 data; int is_play = fsi_is_play(substream); int is_master; + io = fsi_get_stream(fsi, is_play); + pm_runtime_get_sync(dai->dev); /* CKG1 */ @@ -764,29 +799,29 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream, switch (fmt) { case SH_FSI_FMT_MONO: data = CR_MONO; - fsi->chan_num = 1; + io->chan_num = 1; break; case SH_FSI_FMT_MONO_DELAY: data = CR_MONO_D; - fsi->chan_num = 1; + io->chan_num = 1; break; case SH_FSI_FMT_PCM: data = CR_PCM; - fsi->chan_num = 2; + io->chan_num = 2; break; case SH_FSI_FMT_I2S: data = CR_I2S; - fsi->chan_num = 2; + io->chan_num = 2; break; case SH_FSI_FMT_TDM: - fsi->chan_num = is_play ? + io->chan_num = is_play ? SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags); - data = CR_TDM | (fsi->chan_num - 1); + data = CR_TDM | (io->chan_num - 1); break; case SH_FSI_FMT_TDM_DELAY: - fsi->chan_num = is_play ? + io->chan_num = is_play ? SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags); - data = CR_TDM_D | (fsi->chan_num - 1); + data = CR_TDM_D | (io->chan_num - 1); break; case SH_FSI_FMT_SPDIF: if (master->core->ver < 2) { @@ -794,7 +829,7 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream, return -EINVAL; } data = CR_SPDIF; - fsi->chan_num = 2; + io->chan_num = 2; fsi_spdif_clk_ctrl(fsi, 1); fsi_reg_mask_set(fsi, OUT_SEL, 0x0010, 0x0010); break; @@ -836,14 +871,14 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd, switch (cmd) { case SNDRV_PCM_TRIGGER_START: - fsi_stream_push(fsi, substream, + fsi_stream_push(fsi, is_play, substream, frames_to_bytes(runtime, runtime->buffer_size), frames_to_bytes(runtime, runtime->period_size)); ret = is_play ? fsi_data_push(fsi, 1) : fsi_data_pop(fsi, 1); break; case SNDRV_PCM_TRIGGER_STOP: fsi_irq_disable(fsi, is_play); - fsi_stream_pop(fsi); + fsi_stream_pop(fsi, is_play); break; } @@ -991,9 +1026,10 @@ static snd_pcm_uframes_t fsi_pointer(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct fsi_priv *fsi = fsi_get_priv(substream); + struct fsi_stream *io = fsi_get_stream(fsi, fsi_is_play(substream)); long location; - location = (fsi->buff_offset - 1); + location = (io->buff_offset - 1); if (location < 0) location = 0; -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2 v2] ASoC: fsi: simultaneous playback/recorde support 2010-10-12 10:19 ` [PATCH 1/2 v2] " Kuninori Morimoto @ 2010-10-15 10:06 ` Mark Brown 0 siblings, 0 replies; 11+ messages in thread From: Mark Brown @ 2010-10-15 10:06 UTC (permalink / raw) To: Kuninori Morimoto; +Cc: Linux-ALSA, Liam Girdwood On Tue, Oct 12, 2010 at 07:19:28PM +0900, Kuninori Morimoto wrote: > Current FSI driver had not cared about simultaneous > playback/capture on same port. > This patch add new fsi_stream struct to care it, > > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Applied, thanks. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/2] ASoC: ak4642: simultaneous playback/recorde support 2010-10-12 4:38 [PATCH 0/2] ASoC: simultaneous playback/recorde support for SH board Kuninori Morimoto 2010-10-12 4:39 ` [PATCH 1/2] ASoC: fsi: simultaneous playback/recorde support Kuninori Morimoto, Kuninori Morimoto @ 2010-10-12 4:39 ` Kuninori Morimoto, Kuninori Morimoto 2010-10-12 9:38 ` Liam Girdwood 2010-10-12 10:00 ` Mark Brown 1 sibling, 2 replies; 11+ messages in thread From: Kuninori Morimoto, Kuninori Morimoto @ 2010-10-12 4:39 UTC (permalink / raw) To: Mark Brown; +Cc: Linux-ALSA, Liam Girdwood Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> --- sound/soc/codecs/ak4642.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index a95ff4f..009068f 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -220,7 +220,7 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, ak4642_write(codec, 0x0e, 0x19); ak4642_write(codec, 0x09, 0x91); ak4642_write(codec, 0x0c, 0x91); - ak4642_write(codec, 0x00, 0x64); + snd_soc_update_bits(codec, 0x00, 0x64, 0x64); snd_soc_update_bits(codec, PW_MGMT2, PMHP_MASK, PMHP); snd_soc_update_bits(codec, PW_MGMT2, HPMTN, HPMTN); } else { @@ -242,7 +242,7 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, ak4642_write(codec, 0x08, 0xe1); ak4642_write(codec, 0x0b, 0x00); ak4642_write(codec, 0x07, 0x21); - ak4642_write(codec, 0x00, 0x41); + snd_soc_update_bits(codec, 0x00, 0x41, 0x41); ak4642_write(codec, 0x10, 0x01); } @@ -259,12 +259,12 @@ static void ak4642_dai_shutdown(struct snd_pcm_substream *substream, /* stop headphone output */ snd_soc_update_bits(codec, PW_MGMT2, HPMTN, 0); snd_soc_update_bits(codec, PW_MGMT2, PMHP_MASK, 0); - ak4642_write(codec, 0x00, 0x40); + snd_soc_update_bits(codec, 0x00, 0x64, 0x40); ak4642_write(codec, 0x0e, 0x11); ak4642_write(codec, 0x0f, 0x08); } else { /* stop stereo input */ - ak4642_write(codec, 0x00, 0x40); + snd_soc_update_bits(codec, 0x00, 0x41, 0x40); ak4642_write(codec, 0x10, 0x00); ak4642_write(codec, 0x07, 0x01); } -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] ASoC: ak4642: simultaneous playback/recorde support 2010-10-12 4:39 ` [PATCH 2/2] ASoC: ak4642: " Kuninori Morimoto, Kuninori Morimoto @ 2010-10-12 9:38 ` Liam Girdwood 2010-10-12 10:00 ` Mark Brown 1 sibling, 0 replies; 11+ messages in thread From: Liam Girdwood @ 2010-10-12 9:38 UTC (permalink / raw) To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown On Tue, 2010-10-12 at 13:39 +0900, Kuninori Morimoto wrote: > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> > --- > sound/soc/codecs/ak4642.c | 8 ++++---- > 1 files changed, 4 insertions(+), 4 deletions(-) Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> -- Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] ASoC: ak4642: simultaneous playback/recorde support 2010-10-12 4:39 ` [PATCH 2/2] ASoC: ak4642: " Kuninori Morimoto, Kuninori Morimoto 2010-10-12 9:38 ` Liam Girdwood @ 2010-10-12 10:00 ` Mark Brown 2010-10-12 10:22 ` Kuninori Morimoto 1 sibling, 1 reply; 11+ messages in thread From: Mark Brown @ 2010-10-12 10:00 UTC (permalink / raw) To: Kuninori Morimoto; +Cc: Linux-ALSA, Liam Girdwood On Tue, Oct 12, 2010 at 01:39:25PM +0900, Kuninori Morimoto wrote: > ak4642_write(codec, 0x09, 0x91); > ak4642_write(codec, 0x0c, 0x91); > - ak4642_write(codec, 0x00, 0x64); > + snd_soc_update_bits(codec, 0x00, 0x64, 0x64); Applied, but given all the magic numbers this is pretty much illegible - it'd be good if when updating the driver you could start to convert the magic numbers into #defines. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] ASoC: ak4642: simultaneous playback/recorde support 2010-10-12 10:00 ` Mark Brown @ 2010-10-12 10:22 ` Kuninori Morimoto 0 siblings, 0 replies; 11+ messages in thread From: Kuninori Morimoto @ 2010-10-12 10:22 UTC (permalink / raw) To: Mark Brown; +Cc: Linux-ALSA, Liam Girdwood Dear Mark Thank you > > ak4642_write(codec, 0x09, 0x91); > > ak4642_write(codec, 0x0c, 0x91); > > - ak4642_write(codec, 0x00, 0x64); > > + snd_soc_update_bits(codec, 0x00, 0x64, 0x64); > > Applied, but given all the magic numbers this is pretty much illegible - > it'd be good if when updating the driver you could start to convert the > magic numbers into #defines. understand. I will work for it next week. Best regards -- Kuninori Morimoto ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-10-15 10:06 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-10-12 4:38 [PATCH 0/2] ASoC: simultaneous playback/recorde support for SH board Kuninori Morimoto 2010-10-12 4:39 ` [PATCH 1/2] ASoC: fsi: simultaneous playback/recorde support Kuninori Morimoto, Kuninori Morimoto 2010-10-12 9:19 ` Liam Girdwood 2010-10-12 9:33 ` Kuninori Morimoto 2010-10-12 9:41 ` Liam Girdwood 2010-10-12 10:19 ` [PATCH 1/2 v2] " Kuninori Morimoto 2010-10-15 10:06 ` Mark Brown 2010-10-12 4:39 ` [PATCH 2/2] ASoC: ak4642: " Kuninori Morimoto, Kuninori Morimoto 2010-10-12 9:38 ` Liam Girdwood 2010-10-12 10:00 ` Mark Brown 2010-10-12 10:22 ` Kuninori Morimoto
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).