提交 4e62d84d 编写于 作者: K Kuninori Morimoto 提交者: Mark Brown

ASoC: fsi: tidyup: fsi_stream_xx() functions were gathered

This patch gathered fsi_stream_xxx() functions in order to make it readable.
Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 c1e6f10e
...@@ -338,22 +338,6 @@ static u32 fsi_get_info_flags(struct fsi_priv *fsi) ...@@ -338,22 +338,6 @@ static u32 fsi_get_info_flags(struct fsi_priv *fsi)
master->info->portb_flags; 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 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 u32 fsi_get_port_shift(struct fsi_priv *fsi, int is_play) static u32 fsi_get_port_shift(struct fsi_priv *fsi, int is_play)
{ {
int is_porta = fsi_is_port_a(fsi); int is_porta = fsi_is_port_a(fsi);
...@@ -377,10 +361,60 @@ static int fsi_sample2frame(struct fsi_priv *fsi, int samples) ...@@ -377,10 +361,60 @@ static int fsi_sample2frame(struct fsi_priv *fsi, int samples)
return samples / fsi->chan_num; return samples / fsi->chan_num;
} }
static int fsi_get_current_fifo_samples(struct fsi_priv *fsi, int is_play)
{
u32 status;
int frames;
status = is_play ?
fsi_reg_read(fsi, DOFF_ST) :
fsi_reg_read(fsi, DIFF_ST);
frames = 0x1ff & (status >> 8);
return fsi_frame2sample(fsi, frames);
}
static void fsi_count_fifo_err(struct fsi_priv *fsi)
{
u32 ostatus = fsi_reg_read(fsi, DOFF_ST);
u32 istatus = fsi_reg_read(fsi, DIFF_ST);
if (ostatus & ERR_OVER)
fsi->playback.oerr_num++;
if (ostatus & ERR_UNDER)
fsi->playback.uerr_num++;
if (istatus & ERR_OVER)
fsi->capture.oerr_num++;
if (istatus & ERR_UNDER)
fsi->capture.uerr_num++;
fsi_reg_write(fsi, DOFF_ST, 0);
fsi_reg_write(fsi, DIFF_ST, 0);
}
/*
* fsi_stream_xx() function
*/
#define fsi_is_play(substream) fsi_stream_is_play(substream->stream)
static inline int fsi_stream_is_play(int stream)
{
return stream == SNDRV_PCM_STREAM_PLAYBACK;
}
static inline struct fsi_stream *fsi_stream_get(struct fsi_priv *fsi,
int is_play)
{
return is_play ? &fsi->playback : &fsi->capture;
}
static int fsi_stream_is_working(struct fsi_priv *fsi, static int fsi_stream_is_working(struct fsi_priv *fsi,
int is_play) int is_play)
{ {
struct fsi_stream *io = fsi_get_stream(fsi, is_play); struct fsi_stream *io = fsi_stream_get(fsi, is_play);
struct fsi_master *master = fsi_get_master(fsi); struct fsi_master *master = fsi_get_master(fsi);
unsigned long flags; unsigned long flags;
int ret; int ret;
...@@ -396,7 +430,7 @@ static void fsi_stream_push(struct fsi_priv *fsi, ...@@ -396,7 +430,7 @@ static void fsi_stream_push(struct fsi_priv *fsi,
int is_play, int is_play,
struct snd_pcm_substream *substream) struct snd_pcm_substream *substream)
{ {
struct fsi_stream *io = fsi_get_stream(fsi, is_play); struct fsi_stream *io = fsi_stream_get(fsi, is_play);
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct fsi_master *master = fsi_get_master(fsi); struct fsi_master *master = fsi_get_master(fsi);
unsigned long flags; unsigned long flags;
...@@ -415,7 +449,7 @@ static void fsi_stream_push(struct fsi_priv *fsi, ...@@ -415,7 +449,7 @@ static void fsi_stream_push(struct fsi_priv *fsi,
static void fsi_stream_pop(struct fsi_priv *fsi, int is_play) static void fsi_stream_pop(struct fsi_priv *fsi, int is_play)
{ {
struct fsi_stream *io = fsi_get_stream(fsi, is_play); struct fsi_stream *io = fsi_stream_get(fsi, is_play);
struct snd_soc_dai *dai = fsi_get_dai(io->substream); struct snd_soc_dai *dai = fsi_get_dai(io->substream);
struct fsi_master *master = fsi_get_master(fsi); struct fsi_master *master = fsi_get_master(fsi);
unsigned long flags; unsigned long flags;
...@@ -439,41 +473,6 @@ static void fsi_stream_pop(struct fsi_priv *fsi, int is_play) ...@@ -439,41 +473,6 @@ static void fsi_stream_pop(struct fsi_priv *fsi, int is_play)
spin_unlock_irqrestore(&master->lock, flags); spin_unlock_irqrestore(&master->lock, flags);
} }
static int fsi_get_current_fifo_samples(struct fsi_priv *fsi, int is_play)
{
u32 status;
int frames;
status = is_play ?
fsi_reg_read(fsi, DOFF_ST) :
fsi_reg_read(fsi, DIFF_ST);
frames = 0x1ff & (status >> 8);
return fsi_frame2sample(fsi, frames);
}
static void fsi_count_fifo_err(struct fsi_priv *fsi)
{
u32 ostatus = fsi_reg_read(fsi, DOFF_ST);
u32 istatus = fsi_reg_read(fsi, DIFF_ST);
if (ostatus & ERR_OVER)
fsi->playback.oerr_num++;
if (ostatus & ERR_UNDER)
fsi->playback.uerr_num++;
if (istatus & ERR_OVER)
fsi->capture.oerr_num++;
if (istatus & ERR_UNDER)
fsi->capture.uerr_num++;
fsi_reg_write(fsi, DOFF_ST, 0);
fsi_reg_write(fsi, DIFF_ST, 0);
}
/* /*
* dma function * dma function
*/ */
...@@ -481,7 +480,7 @@ static void fsi_count_fifo_err(struct fsi_priv *fsi) ...@@ -481,7 +480,7 @@ static void fsi_count_fifo_err(struct fsi_priv *fsi)
static u8 *fsi_dma_get_area(struct fsi_priv *fsi, int stream) static u8 *fsi_dma_get_area(struct fsi_priv *fsi, int stream)
{ {
int is_play = fsi_stream_is_play(stream); int is_play = fsi_stream_is_play(stream);
struct fsi_stream *io = fsi_get_stream(fsi, is_play); struct fsi_stream *io = fsi_stream_get(fsi, is_play);
struct snd_pcm_runtime *runtime = io->substream->runtime; struct snd_pcm_runtime *runtime = io->substream->runtime;
return runtime->dma_area + return runtime->dma_area +
...@@ -698,7 +697,7 @@ static void fsi_fifo_init(struct fsi_priv *fsi, ...@@ -698,7 +697,7 @@ static void fsi_fifo_init(struct fsi_priv *fsi,
struct device *dev) struct device *dev)
{ {
struct fsi_master *master = fsi_get_master(fsi); struct fsi_master *master = fsi_get_master(fsi);
struct fsi_stream *io = fsi_get_stream(fsi, is_play); struct fsi_stream *io = fsi_stream_get(fsi, is_play);
u32 shift, i; u32 shift, i;
int frame_capa; int frame_capa;
...@@ -753,7 +752,7 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int stream) ...@@ -753,7 +752,7 @@ static int fsi_fifo_data_ctrl(struct fsi_priv *fsi, int stream)
struct snd_pcm_runtime *runtime; struct snd_pcm_runtime *runtime;
struct snd_pcm_substream *substream = NULL; struct snd_pcm_substream *substream = NULL;
int is_play = fsi_stream_is_play(stream); int is_play = fsi_stream_is_play(stream);
struct fsi_stream *io = fsi_get_stream(fsi, is_play); struct fsi_stream *io = fsi_stream_get(fsi, is_play);
int sample_residues; int sample_residues;
int samples; int samples;
int samples_max; int samples_max;
...@@ -1150,7 +1149,7 @@ static int fsi_hw_free(struct snd_pcm_substream *substream) ...@@ -1150,7 +1149,7 @@ static int fsi_hw_free(struct snd_pcm_substream *substream)
static snd_pcm_uframes_t fsi_pointer(struct snd_pcm_substream *substream) static snd_pcm_uframes_t fsi_pointer(struct snd_pcm_substream *substream)
{ {
struct fsi_priv *fsi = fsi_get_priv(substream); struct fsi_priv *fsi = fsi_get_priv(substream);
struct fsi_stream *io = fsi_get_stream(fsi, fsi_is_play(substream)); struct fsi_stream *io = fsi_stream_get(fsi, fsi_is_play(substream));
int samples_pos = io->buff_sample_pos - 1; int samples_pos = io->buff_sample_pos - 1;
if (samples_pos < 0) if (samples_pos < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册