rz-ssi.c (d2fe7fc51fc326368ab052247f3e1070858f3393) | rz-ssi.c (7276d3f329c633340f3c539ce35ed254d2fe467b) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2// 3// Renesas RZ/G2L ASoC Serial Sound Interface (SSIF-2) Driver 4// 5// Copyright (C) 2021 Renesas Electronics Corp. 6// Copyright (C) 2019 Chris Brandt. 7// 8 --- 394 unchanged lines hidden (view full) --- 403 strm->period_counter = current_period; 404 } 405} 406 407static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) 408{ 409 struct snd_pcm_substream *substream = strm->substream; 410 struct snd_pcm_runtime *runtime; | 1// SPDX-License-Identifier: GPL-2.0 2// 3// Renesas RZ/G2L ASoC Serial Sound Interface (SSIF-2) Driver 4// 5// Copyright (C) 2021 Renesas Electronics Corp. 6// Copyright (C) 2019 Chris Brandt. 7// 8 --- 394 unchanged lines hidden (view full) --- 403 strm->period_counter = current_period; 404 } 405} 406 407static int rz_ssi_pio_recv(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) 408{ 409 struct snd_pcm_substream *substream = strm->substream; 410 struct snd_pcm_runtime *runtime; |
411 bool done = false; | |
412 u16 *buf; 413 int fifo_samples; 414 int frames_left; 415 int samples; 416 int i; 417 418 if (!rz_ssi_stream_is_valid(ssi, strm)) 419 return -EINVAL; 420 421 runtime = substream->runtime; 422 | 411 u16 *buf; 412 int fifo_samples; 413 int frames_left; 414 int samples; 415 int i; 416 417 if (!rz_ssi_stream_is_valid(ssi, strm)) 418 return -EINVAL; 419 420 runtime = substream->runtime; 421 |
423 while (!done) { | 422 do { |
424 /* frames left in this period */ 425 frames_left = runtime->period_size - 426 (strm->buffer_pos % runtime->period_size); 427 if (!frames_left) 428 frames_left = runtime->period_size; 429 430 /* Samples in RX FIFO */ 431 fifo_samples = (rz_ssi_reg_readl(ssi, SSIFSR) >> --- 7 unchanged lines hidden (view full) --- 439 frames_left--; 440 } 441 442 /* not enough samples yet */ 443 if (!samples) 444 break; 445 446 /* calculate new buffer index */ | 423 /* frames left in this period */ 424 frames_left = runtime->period_size - 425 (strm->buffer_pos % runtime->period_size); 426 if (!frames_left) 427 frames_left = runtime->period_size; 428 429 /* Samples in RX FIFO */ 430 fifo_samples = (rz_ssi_reg_readl(ssi, SSIFSR) >> --- 7 unchanged lines hidden (view full) --- 438 frames_left--; 439 } 440 441 /* not enough samples yet */ 442 if (!samples) 443 break; 444 445 /* calculate new buffer index */ |
447 buf = (u16 *)(runtime->dma_area); | 446 buf = (u16 *)runtime->dma_area; |
448 buf += strm->buffer_pos * runtime->channels; 449 450 /* Note, only supports 16-bit samples */ 451 for (i = 0; i < samples; i++) 452 *buf++ = (u16)(rz_ssi_reg_readl(ssi, SSIFRDR) >> 16); 453 454 rz_ssi_reg_mask_setl(ssi, SSIFSR, SSIFSR_RDF, 0); 455 rz_ssi_pointer_update(strm, samples / runtime->channels); | 447 buf += strm->buffer_pos * runtime->channels; 448 449 /* Note, only supports 16-bit samples */ 450 for (i = 0; i < samples; i++) 451 *buf++ = (u16)(rz_ssi_reg_readl(ssi, SSIFRDR) >> 16); 452 453 rz_ssi_reg_mask_setl(ssi, SSIFSR, SSIFSR_RDF, 0); 454 rz_ssi_pointer_update(strm, samples / runtime->channels); |
455 } while (!frames_left && fifo_samples >= runtime->channels); |
|
456 | 456 |
457 /* check if there are no more samples in the RX FIFO */ 458 if (!(!frames_left && fifo_samples >= runtime->channels)) 459 done = true; 460 } 461 | |
462 return 0; 463} 464 465static int rz_ssi_pio_send(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) 466{ 467 struct snd_pcm_substream *substream = strm->substream; 468 struct snd_pcm_runtime *runtime = substream->runtime; 469 int sample_space; --- 608 unchanged lines hidden --- | 457 return 0; 458} 459 460static int rz_ssi_pio_send(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) 461{ 462 struct snd_pcm_substream *substream = strm->substream; 463 struct snd_pcm_runtime *runtime = substream->runtime; 464 int sample_space; --- 608 unchanged lines hidden --- |