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