Lines Matching full:io

14 #include <linux/io.h>
108 /* IO SHIFT / MACRO */
269 int (*init)(struct fsi_priv *fsi, struct fsi_stream *io);
270 int (*quit)(struct fsi_priv *fsi, struct fsi_stream *io);
271 int (*probe)(struct fsi_priv *fsi, struct fsi_stream *io, struct device *dev);
272 int (*transfer)(struct fsi_priv *fsi, struct fsi_stream *io);
273 int (*remove)(struct fsi_priv *fsi, struct fsi_stream *io);
274 int (*start_stop)(struct fsi_priv *fsi, struct fsi_stream *io,
277 #define fsi_stream_handler_call(io, func, args...) \ argument
278 (!(io) ? -ENODEV : \
279 !((io)->handler->func) ? 0 : \
280 (io)->handler->func(args))
301 struct fsi_stream *io) in fsi_stream_is_play() argument
303 return &fsi->playback == io; in fsi_stream_is_play()
429 static u32 fsi_get_port_shift(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_get_port_shift() argument
431 int is_play = fsi_stream_is_play(fsi, io); in fsi_get_port_shift()
454 struct fsi_stream *io) in fsi_get_current_fifo_samples() argument
456 int is_play = fsi_stream_is_play(fsi, io); in fsi_get_current_fifo_samples()
500 struct fsi_stream *io) in fsi_stream_is_working() argument
507 ret = !!(io->substream && io->substream->runtime); in fsi_stream_is_working()
513 static struct fsi_priv *fsi_stream_to_priv(struct fsi_stream *io) in fsi_stream_to_priv() argument
515 return io->priv; in fsi_stream_to_priv()
519 struct fsi_stream *io, in fsi_stream_init() argument
527 io->substream = substream; in fsi_stream_init()
528 io->buff_sample_capa = fsi_frame2sample(fsi, runtime->buffer_size); in fsi_stream_init()
529 io->buff_sample_pos = 0; in fsi_stream_init()
530 io->period_samples = fsi_frame2sample(fsi, runtime->period_size); in fsi_stream_init()
531 io->period_pos = 0; in fsi_stream_init()
532 io->sample_width = samples_to_bytes(runtime, 1); in fsi_stream_init()
533 io->bus_option = 0; in fsi_stream_init()
534 io->oerr_num = -1; /* ignore 1st err */ in fsi_stream_init()
535 io->uerr_num = -1; /* ignore 1st err */ in fsi_stream_init()
536 fsi_stream_handler_call(io, init, fsi, io); in fsi_stream_init()
540 static void fsi_stream_quit(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_stream_quit() argument
542 struct snd_soc_dai *dai = fsi_get_dai(io->substream); in fsi_stream_quit()
548 if (io->oerr_num > 0) in fsi_stream_quit()
549 dev_err(dai->dev, "over_run = %d\n", io->oerr_num); in fsi_stream_quit()
551 if (io->uerr_num > 0) in fsi_stream_quit()
552 dev_err(dai->dev, "under_run = %d\n", io->uerr_num); in fsi_stream_quit()
554 fsi_stream_handler_call(io, quit, fsi, io); in fsi_stream_quit()
555 io->substream = NULL; in fsi_stream_quit()
556 io->buff_sample_capa = 0; in fsi_stream_quit()
557 io->buff_sample_pos = 0; in fsi_stream_quit()
558 io->period_samples = 0; in fsi_stream_quit()
559 io->period_pos = 0; in fsi_stream_quit()
560 io->sample_width = 0; in fsi_stream_quit()
561 io->bus_option = 0; in fsi_stream_quit()
562 io->oerr_num = 0; in fsi_stream_quit()
563 io->uerr_num = 0; in fsi_stream_quit()
567 static int fsi_stream_transfer(struct fsi_stream *io) in fsi_stream_transfer() argument
569 struct fsi_priv *fsi = fsi_stream_to_priv(io); in fsi_stream_transfer()
573 return fsi_stream_handler_call(io, transfer, fsi, io); in fsi_stream_transfer()
576 #define fsi_stream_start(fsi, io)\ argument
577 fsi_stream_handler_call(io, start_stop, fsi, io, 1)
579 #define fsi_stream_stop(fsi, io)\ argument
580 fsi_stream_handler_call(io, start_stop, fsi, io, 0)
584 struct fsi_stream *io; in fsi_stream_probe() local
587 io = &fsi->playback; in fsi_stream_probe()
588 ret1 = fsi_stream_handler_call(io, probe, fsi, io, dev); in fsi_stream_probe()
590 io = &fsi->capture; in fsi_stream_probe()
591 ret2 = fsi_stream_handler_call(io, probe, fsi, io, dev); in fsi_stream_probe()
603 struct fsi_stream *io; in fsi_stream_remove() local
606 io = &fsi->playback; in fsi_stream_remove()
607 ret1 = fsi_stream_handler_call(io, remove, fsi, io); in fsi_stream_remove()
609 io = &fsi->capture; in fsi_stream_remove()
610 ret2 = fsi_stream_handler_call(io, remove, fsi, io); in fsi_stream_remove()
623 static void fsi_format_bus_setup(struct fsi_priv *fsi, struct fsi_stream *io, in fsi_format_bus_setup() argument
627 int is_play = fsi_stream_is_play(fsi, io); in fsi_format_bus_setup()
671 static void fsi_irq_enable(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_irq_enable() argument
673 u32 data = AB_IO(1, fsi_get_port_shift(fsi, io)); in fsi_irq_enable()
680 static void fsi_irq_disable(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_irq_disable() argument
682 u32 data = AB_IO(1, fsi_get_port_shift(fsi, io)); in fsi_irq_disable()
1044 static void fsi_pointer_update(struct fsi_stream *io, int size) in fsi_pointer_update() argument
1046 io->buff_sample_pos += size; in fsi_pointer_update()
1048 if (io->buff_sample_pos >= in fsi_pointer_update()
1049 io->period_samples * (io->period_pos + 1)) { in fsi_pointer_update()
1050 struct snd_pcm_substream *substream = io->substream; in fsi_pointer_update()
1053 io->period_pos++; in fsi_pointer_update()
1055 if (io->period_pos >= runtime->periods) { in fsi_pointer_update()
1056 io->buff_sample_pos = 0; in fsi_pointer_update()
1057 io->period_pos = 0; in fsi_pointer_update()
1117 static u8 *fsi_pio_get_area(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_pio_get_area() argument
1119 struct snd_pcm_runtime *runtime = io->substream->runtime; in fsi_pio_get_area()
1122 samples_to_bytes(runtime, io->buff_sample_pos); in fsi_pio_get_area()
1125 static int fsi_pio_transfer(struct fsi_priv *fsi, struct fsi_stream *io, in fsi_pio_transfer() argument
1132 if (!fsi_stream_is_working(fsi, io)) in fsi_pio_transfer()
1135 buf = fsi_pio_get_area(fsi, io); in fsi_pio_transfer()
1137 switch (io->sample_width) { in fsi_pio_transfer()
1148 fsi_pointer_update(io, samples); in fsi_pio_transfer()
1153 static int fsi_pio_pop(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_pio_pop() argument
1159 sample_residues = fsi_get_current_fifo_samples(fsi, io); in fsi_pio_pop()
1160 sample_space = io->buff_sample_capa - io->buff_sample_pos; in fsi_pio_pop()
1164 return fsi_pio_transfer(fsi, io, in fsi_pio_pop()
1170 static int fsi_pio_push(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_pio_push() argument
1176 sample_residues = io->buff_sample_capa - io->buff_sample_pos; in fsi_pio_push()
1177 sample_space = io->fifo_sample_capa - in fsi_pio_push()
1178 fsi_get_current_fifo_samples(fsi, io); in fsi_pio_push()
1182 return fsi_pio_transfer(fsi, io, in fsi_pio_push()
1188 static int fsi_pio_start_stop(struct fsi_priv *fsi, struct fsi_stream *io, in fsi_pio_start_stop() argument
1195 fsi_irq_enable(fsi, io); in fsi_pio_start_stop()
1197 fsi_irq_disable(fsi, io); in fsi_pio_start_stop()
1205 static int fsi_pio_push_init(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_pio_push_init() argument
1215 io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | in fsi_pio_push_init()
1218 io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | in fsi_pio_push_init()
1223 static int fsi_pio_pop_init(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_pio_pop_init() argument
1228 io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | in fsi_pio_pop_init()
1275 static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_dma_init() argument
1281 io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | in fsi_dma_init()
1289 struct fsi_stream *io = (struct fsi_stream *)data; in fsi_dma_complete() local
1290 struct fsi_priv *fsi = fsi_stream_to_priv(io); in fsi_dma_complete()
1292 fsi_pointer_update(io, io->period_samples); in fsi_dma_complete()
1297 static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_dma_transfer() argument
1299 struct snd_soc_dai *dai = fsi_get_dai(io->substream); in fsi_dma_transfer()
1300 struct snd_pcm_substream *substream = io->substream; in fsi_dma_transfer()
1302 int is_play = fsi_stream_is_play(fsi, io); in fsi_dma_transfer()
1311 desc = dmaengine_prep_dma_cyclic(io->chan, in fsi_dma_transfer()
1323 desc->callback_param = io; in fsi_dma_transfer()
1330 dma_async_issue_pending(io->chan); in fsi_dma_transfer()
1354 static int fsi_dma_push_start_stop(struct fsi_priv *fsi, struct fsi_stream *io, in fsi_dma_push_start_stop() argument
1363 dmaengine_terminate_all(io->chan); in fsi_dma_push_start_stop()
1371 static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io, struct device *dev) in fsi_dma_probe() argument
1373 int is_play = fsi_stream_is_play(fsi, io); in fsi_dma_probe()
1380 io->chan = dma_request_channel(mask, shdma_chan_filter, in fsi_dma_probe()
1381 (void *)io->dma_id); in fsi_dma_probe()
1383 io->chan = dma_request_slave_channel(dev, is_play ? "tx" : "rx"); in fsi_dma_probe()
1385 if (io->chan) { in fsi_dma_probe()
1399 ret = dmaengine_slave_config(io->chan, &cfg); in fsi_dma_probe()
1401 dma_release_channel(io->chan); in fsi_dma_probe()
1402 io->chan = NULL; in fsi_dma_probe()
1406 if (!io->chan) { in fsi_dma_probe()
1423 static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_dma_remove() argument
1425 fsi_stream_stop(fsi, io); in fsi_dma_remove()
1427 if (io->chan) in fsi_dma_remove()
1428 dma_release_channel(io->chan); in fsi_dma_remove()
1430 io->chan = NULL; in fsi_dma_remove()
1446 struct fsi_stream *io, in fsi_fifo_init() argument
1450 int is_play = fsi_stream_is_play(fsi, io); in fsi_fifo_init()
1456 shift >>= fsi_get_port_shift(fsi, io); in fsi_fifo_init()
1485 io->fifo_sample_capa = fsi_frame2sample(fsi, frame_capa); in fsi_fifo_init()
1501 struct fsi_stream *io, in fsi_hw_startup() argument
1532 switch (io->sample_width) { in fsi_hw_startup()
1534 data = BUSOP_GET(16, io->bus_option); in fsi_hw_startup()
1537 data = BUSOP_GET(24, io->bus_option); in fsi_hw_startup()
1540 fsi_format_bus_setup(fsi, io, data, dev); in fsi_hw_startup()
1543 fsi_irq_disable(fsi, io); in fsi_hw_startup()
1547 fsi_fifo_init(fsi, io, dev); in fsi_hw_startup()
1588 struct fsi_stream *io = fsi_stream_get(fsi, substream); in fsi_dai_trigger() local
1593 fsi_stream_init(fsi, io, substream); in fsi_dai_trigger()
1595 ret = fsi_hw_startup(fsi, io, dai->dev); in fsi_dai_trigger()
1597 ret = fsi_stream_start(fsi, io); in fsi_dai_trigger()
1599 ret = fsi_stream_transfer(io); in fsi_dai_trigger()
1604 fsi_stream_stop(fsi, io); in fsi_dai_trigger()
1605 fsi_stream_quit(fsi, io); in fsi_dai_trigger()
1767 struct fsi_stream *io = fsi_stream_get(fsi, substream); in fsi_pointer() local
1769 return fsi_sample2frame(fsi, io->buff_sample_pos); in fsi_pointer()
2048 struct fsi_stream *io, in __fsi_suspend() argument
2051 if (!fsi_stream_is_working(fsi, io)) in __fsi_suspend()
2054 fsi_stream_stop(fsi, io); in __fsi_suspend()
2059 struct fsi_stream *io, in __fsi_resume() argument
2062 if (!fsi_stream_is_working(fsi, io)) in __fsi_resume()
2065 fsi_hw_startup(fsi, io, dev); in __fsi_resume()
2066 fsi_stream_start(fsi, io); in __fsi_resume()