Lines Matching full:io
14 #include <linux/io.h>
107 /* IO SHIFT / MACRO */
268 int (*init)(struct fsi_priv *fsi, struct fsi_stream *io);
269 int (*quit)(struct fsi_priv *fsi, struct fsi_stream *io);
270 int (*probe)(struct fsi_priv *fsi, struct fsi_stream *io, struct device *dev);
271 int (*transfer)(struct fsi_priv *fsi, struct fsi_stream *io);
272 int (*remove)(struct fsi_priv *fsi, struct fsi_stream *io);
273 int (*start_stop)(struct fsi_priv *fsi, struct fsi_stream *io,
276 #define fsi_stream_handler_call(io, func, args...) \ argument
277 (!(io) ? -ENODEV : \
278 !((io)->handler->func) ? 0 : \
279 (io)->handler->func(args))
300 struct fsi_stream *io) in fsi_stream_is_play() argument
302 return &fsi->playback == io; in fsi_stream_is_play()
428 static u32 fsi_get_port_shift(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_get_port_shift() argument
430 int is_play = fsi_stream_is_play(fsi, io); in fsi_get_port_shift()
453 struct fsi_stream *io) in fsi_get_current_fifo_samples() argument
455 int is_play = fsi_stream_is_play(fsi, io); in fsi_get_current_fifo_samples()
499 struct fsi_stream *io) in fsi_stream_is_working() argument
506 ret = !!(io->substream && io->substream->runtime); in fsi_stream_is_working()
512 static struct fsi_priv *fsi_stream_to_priv(struct fsi_stream *io) in fsi_stream_to_priv() argument
514 return io->priv; in fsi_stream_to_priv()
518 struct fsi_stream *io, in fsi_stream_init() argument
526 io->substream = substream; in fsi_stream_init()
527 io->buff_sample_capa = fsi_frame2sample(fsi, runtime->buffer_size); in fsi_stream_init()
528 io->buff_sample_pos = 0; in fsi_stream_init()
529 io->period_samples = fsi_frame2sample(fsi, runtime->period_size); in fsi_stream_init()
530 io->period_pos = 0; in fsi_stream_init()
531 io->sample_width = samples_to_bytes(runtime, 1); in fsi_stream_init()
532 io->bus_option = 0; in fsi_stream_init()
533 io->oerr_num = -1; /* ignore 1st err */ in fsi_stream_init()
534 io->uerr_num = -1; /* ignore 1st err */ in fsi_stream_init()
535 fsi_stream_handler_call(io, init, fsi, io); in fsi_stream_init()
539 static void fsi_stream_quit(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_stream_quit() argument
541 struct snd_soc_dai *dai = fsi_get_dai(io->substream); in fsi_stream_quit()
547 if (io->oerr_num > 0) in fsi_stream_quit()
548 dev_err(dai->dev, "over_run = %d\n", io->oerr_num); in fsi_stream_quit()
550 if (io->uerr_num > 0) in fsi_stream_quit()
551 dev_err(dai->dev, "under_run = %d\n", io->uerr_num); in fsi_stream_quit()
553 fsi_stream_handler_call(io, quit, fsi, io); in fsi_stream_quit()
554 io->substream = NULL; in fsi_stream_quit()
555 io->buff_sample_capa = 0; in fsi_stream_quit()
556 io->buff_sample_pos = 0; in fsi_stream_quit()
557 io->period_samples = 0; in fsi_stream_quit()
558 io->period_pos = 0; in fsi_stream_quit()
559 io->sample_width = 0; in fsi_stream_quit()
560 io->bus_option = 0; in fsi_stream_quit()
561 io->oerr_num = 0; in fsi_stream_quit()
562 io->uerr_num = 0; in fsi_stream_quit()
566 static int fsi_stream_transfer(struct fsi_stream *io) in fsi_stream_transfer() argument
568 struct fsi_priv *fsi = fsi_stream_to_priv(io); in fsi_stream_transfer()
572 return fsi_stream_handler_call(io, transfer, fsi, io); in fsi_stream_transfer()
575 #define fsi_stream_start(fsi, io)\ argument
576 fsi_stream_handler_call(io, start_stop, fsi, io, 1)
578 #define fsi_stream_stop(fsi, io)\ argument
579 fsi_stream_handler_call(io, start_stop, fsi, io, 0)
583 struct fsi_stream *io; in fsi_stream_probe() local
586 io = &fsi->playback; in fsi_stream_probe()
587 ret1 = fsi_stream_handler_call(io, probe, fsi, io, dev); in fsi_stream_probe()
589 io = &fsi->capture; in fsi_stream_probe()
590 ret2 = fsi_stream_handler_call(io, probe, fsi, io, dev); in fsi_stream_probe()
602 struct fsi_stream *io; in fsi_stream_remove() local
605 io = &fsi->playback; in fsi_stream_remove()
606 ret1 = fsi_stream_handler_call(io, remove, fsi, io); in fsi_stream_remove()
608 io = &fsi->capture; in fsi_stream_remove()
609 ret2 = fsi_stream_handler_call(io, remove, fsi, io); in fsi_stream_remove()
622 static void fsi_format_bus_setup(struct fsi_priv *fsi, struct fsi_stream *io, in fsi_format_bus_setup() argument
626 int is_play = fsi_stream_is_play(fsi, io); in fsi_format_bus_setup()
670 static void fsi_irq_enable(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_irq_enable() argument
672 u32 data = AB_IO(1, fsi_get_port_shift(fsi, io)); in fsi_irq_enable()
679 static void fsi_irq_disable(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_irq_disable() argument
681 u32 data = AB_IO(1, fsi_get_port_shift(fsi, io)); in fsi_irq_disable()
1043 static void fsi_pointer_update(struct fsi_stream *io, int size) in fsi_pointer_update() argument
1045 io->buff_sample_pos += size; in fsi_pointer_update()
1047 if (io->buff_sample_pos >= in fsi_pointer_update()
1048 io->period_samples * (io->period_pos + 1)) { in fsi_pointer_update()
1049 struct snd_pcm_substream *substream = io->substream; in fsi_pointer_update()
1052 io->period_pos++; in fsi_pointer_update()
1054 if (io->period_pos >= runtime->periods) { in fsi_pointer_update()
1055 io->buff_sample_pos = 0; in fsi_pointer_update()
1056 io->period_pos = 0; in fsi_pointer_update()
1116 static u8 *fsi_pio_get_area(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_pio_get_area() argument
1118 struct snd_pcm_runtime *runtime = io->substream->runtime; in fsi_pio_get_area()
1121 samples_to_bytes(runtime, io->buff_sample_pos); in fsi_pio_get_area()
1124 static int fsi_pio_transfer(struct fsi_priv *fsi, struct fsi_stream *io, in fsi_pio_transfer() argument
1131 if (!fsi_stream_is_working(fsi, io)) in fsi_pio_transfer()
1134 buf = fsi_pio_get_area(fsi, io); in fsi_pio_transfer()
1136 switch (io->sample_width) { in fsi_pio_transfer()
1147 fsi_pointer_update(io, samples); in fsi_pio_transfer()
1152 static int fsi_pio_pop(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_pio_pop() argument
1158 sample_residues = fsi_get_current_fifo_samples(fsi, io); in fsi_pio_pop()
1159 sample_space = io->buff_sample_capa - io->buff_sample_pos; in fsi_pio_pop()
1163 return fsi_pio_transfer(fsi, io, in fsi_pio_pop()
1169 static int fsi_pio_push(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_pio_push() argument
1175 sample_residues = io->buff_sample_capa - io->buff_sample_pos; in fsi_pio_push()
1176 sample_space = io->fifo_sample_capa - in fsi_pio_push()
1177 fsi_get_current_fifo_samples(fsi, io); in fsi_pio_push()
1181 return fsi_pio_transfer(fsi, io, in fsi_pio_push()
1187 static int fsi_pio_start_stop(struct fsi_priv *fsi, struct fsi_stream *io, in fsi_pio_start_stop() argument
1194 fsi_irq_enable(fsi, io); in fsi_pio_start_stop()
1196 fsi_irq_disable(fsi, io); in fsi_pio_start_stop()
1204 static int fsi_pio_push_init(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_pio_push_init() argument
1214 io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | in fsi_pio_push_init()
1217 io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | in fsi_pio_push_init()
1222 static int fsi_pio_pop_init(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_pio_pop_init() argument
1227 io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | in fsi_pio_pop_init()
1274 static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_dma_init() argument
1280 io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | in fsi_dma_init()
1288 struct fsi_stream *io = (struct fsi_stream *)data; in fsi_dma_complete() local
1289 struct fsi_priv *fsi = fsi_stream_to_priv(io); in fsi_dma_complete()
1291 fsi_pointer_update(io, io->period_samples); in fsi_dma_complete()
1296 static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_dma_transfer() argument
1298 struct snd_soc_dai *dai = fsi_get_dai(io->substream); in fsi_dma_transfer()
1299 struct snd_pcm_substream *substream = io->substream; in fsi_dma_transfer()
1301 int is_play = fsi_stream_is_play(fsi, io); in fsi_dma_transfer()
1310 desc = dmaengine_prep_dma_cyclic(io->chan, in fsi_dma_transfer()
1322 desc->callback_param = io; in fsi_dma_transfer()
1329 dma_async_issue_pending(io->chan); in fsi_dma_transfer()
1353 static int fsi_dma_push_start_stop(struct fsi_priv *fsi, struct fsi_stream *io, in fsi_dma_push_start_stop() argument
1362 dmaengine_terminate_all(io->chan); in fsi_dma_push_start_stop()
1370 static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io, struct device *dev) in fsi_dma_probe() argument
1372 int is_play = fsi_stream_is_play(fsi, io); in fsi_dma_probe()
1379 io->chan = dma_request_channel(mask, shdma_chan_filter, in fsi_dma_probe()
1380 (void *)io->dma_id); in fsi_dma_probe()
1382 io->chan = dma_request_chan(dev, is_play ? "tx" : "rx"); in fsi_dma_probe()
1383 if (IS_ERR(io->chan)) in fsi_dma_probe()
1384 io->chan = NULL; in fsi_dma_probe()
1386 if (io->chan) { in fsi_dma_probe()
1400 ret = dmaengine_slave_config(io->chan, &cfg); in fsi_dma_probe()
1402 dma_release_channel(io->chan); in fsi_dma_probe()
1403 io->chan = NULL; in fsi_dma_probe()
1407 if (!io->chan) { in fsi_dma_probe()
1424 static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io) in fsi_dma_remove() argument
1426 fsi_stream_stop(fsi, io); in fsi_dma_remove()
1428 if (io->chan) in fsi_dma_remove()
1429 dma_release_channel(io->chan); in fsi_dma_remove()
1431 io->chan = NULL; in fsi_dma_remove()
1447 struct fsi_stream *io, in fsi_fifo_init() argument
1451 int is_play = fsi_stream_is_play(fsi, io); in fsi_fifo_init()
1457 shift >>= fsi_get_port_shift(fsi, io); in fsi_fifo_init()
1486 io->fifo_sample_capa = fsi_frame2sample(fsi, frame_capa); in fsi_fifo_init()
1502 struct fsi_stream *io, in fsi_hw_startup() argument
1533 switch (io->sample_width) { in fsi_hw_startup()
1535 data = BUSOP_GET(16, io->bus_option); in fsi_hw_startup()
1538 data = BUSOP_GET(24, io->bus_option); in fsi_hw_startup()
1541 fsi_format_bus_setup(fsi, io, data, dev); in fsi_hw_startup()
1544 fsi_irq_disable(fsi, io); in fsi_hw_startup()
1548 fsi_fifo_init(fsi, io, dev); in fsi_hw_startup()
1589 struct fsi_stream *io = fsi_stream_get(fsi, substream); in fsi_dai_trigger() local
1594 fsi_stream_init(fsi, io, substream); in fsi_dai_trigger()
1596 ret = fsi_hw_startup(fsi, io, dai->dev); in fsi_dai_trigger()
1598 ret = fsi_stream_start(fsi, io); in fsi_dai_trigger()
1600 ret = fsi_stream_transfer(io); in fsi_dai_trigger()
1605 fsi_stream_stop(fsi, io); in fsi_dai_trigger()
1606 fsi_stream_quit(fsi, io); in fsi_dai_trigger()
1768 struct fsi_stream *io = fsi_stream_get(fsi, substream); in fsi_pointer() local
1770 return fsi_sample2frame(fsi, io->buff_sample_pos); in fsi_pointer()
2047 struct fsi_stream *io, in __fsi_suspend() argument
2050 if (!fsi_stream_is_working(fsi, io)) in __fsi_suspend()
2053 fsi_stream_stop(fsi, io); in __fsi_suspend()
2058 struct fsi_stream *io, in __fsi_resume() argument
2061 if (!fsi_stream_is_working(fsi, io)) in __fsi_resume()
2064 fsi_hw_startup(fsi, io, dev); in __fsi_resume()
2065 fsi_stream_start(fsi, io); in __fsi_resume()