aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/sh/fsi.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2010-09-17 00:48:32 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-09-19 11:10:56 -0400
commitb9fde18c0582583cf12a4b1c02f621d3addd0a97 (patch)
tree87ea07285c93b62ddc7206b0b7e448f058b42c28 /sound/soc/sh/fsi.c
parentc8fe2574cf860ace03785953878c4c7a0190d064 (diff)
ASoC: fsi: Add fsi_dma_soft_push/pop function
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/sh/fsi.c')
-rw-r--r--sound/soc/sh/fsi.c72
1 files changed, 54 insertions, 18 deletions
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 07a0350f771e..363b37a603cb 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -348,11 +348,59 @@ static int fsi_get_fifo_residue(struct fsi_priv *fsi, int is_play)
348 return residue; 348 return residue;
349} 349}
350 350
351/*
352 * dma function
353 */
354
351static u8 *fsi_dma_get_area(struct fsi_priv *fsi) 355static u8 *fsi_dma_get_area(struct fsi_priv *fsi)
352{ 356{
353 return fsi->substream->runtime->dma_area + fsi->byte_offset; 357 return fsi->substream->runtime->dma_area + fsi->byte_offset;
354} 358}
355 359
360static void fsi_dma_soft_push16(struct fsi_priv *fsi, int size)
361{
362 u16 *start;
363 int i;
364
365 start = (u16 *)fsi_dma_get_area(fsi);
366
367 for (i = 0; i < size; i++)
368 fsi_reg_write(fsi, DODT, ((u32)*(start + i) << 8));
369}
370
371static void fsi_dma_soft_pop16(struct fsi_priv *fsi, int size)
372{
373 u16 *start;
374 int i;
375
376 start = (u16 *)fsi_dma_get_area(fsi);
377
378 for (i = 0; i < size; i++)
379 *(start + i) = (u16)(fsi_reg_read(fsi, DIDT) >> 8);
380}
381
382static void fsi_dma_soft_push32(struct fsi_priv *fsi, int size)
383{
384 u32 *start;
385 int i;
386
387 start = (u32 *)fsi_dma_get_area(fsi);
388
389 for (i = 0; i < size; i++)
390 fsi_reg_write(fsi, DODT, *(start + i));
391}
392
393static void fsi_dma_soft_pop32(struct fsi_priv *fsi, int size)
394{
395 u32 *start;
396 int i;
397
398 start = (u32 *)fsi_dma_get_area(fsi);
399
400 for (i = 0; i < size; i++)
401 *(start + i) = fsi_reg_read(fsi, DIDT);
402}
403
356/* 404/*
357 * irq function 405 * irq function
358 */ 406 */
@@ -500,8 +548,7 @@ static int fsi_data_push(struct fsi_priv *fsi, int startup)
500 int send; 548 int send;
501 int fifo_free; 549 int fifo_free;
502 int width; 550 int width;
503 u8 *start; 551 int over_period;
504 int i, over_period;
505 552
506 if (!fsi || 553 if (!fsi ||
507 !fsi->substream || 554 !fsi->substream ||
@@ -538,17 +585,12 @@ static int fsi_data_push(struct fsi_priv *fsi, int startup)
538 if (fifo_free < send) 585 if (fifo_free < send)
539 send = fifo_free; 586 send = fifo_free;
540 587
541 start = fsi_dma_get_area(fsi);
542
543 switch (width) { 588 switch (width) {
544 case 2: 589 case 2:
545 for (i = 0; i < send; i++) 590 fsi_dma_soft_push16(fsi, send);
546 fsi_reg_write(fsi, DODT,
547 ((u32)*((u16 *)start + i) << 8));
548 break; 591 break;
549 case 4: 592 case 4:
550 for (i = 0; i < send; i++) 593 fsi_dma_soft_push32(fsi, send);
551 fsi_reg_write(fsi, DODT, *((u32 *)start + i));
552 break; 594 break;
553 default: 595 default:
554 return -EINVAL; 596 return -EINVAL;
@@ -583,8 +625,7 @@ static int fsi_data_pop(struct fsi_priv *fsi, int startup)
583 int free; 625 int free;
584 int fifo_fill; 626 int fifo_fill;
585 int width; 627 int width;
586 u8 *start; 628 int over_period;
587 int i, over_period;
588 629
589 if (!fsi || 630 if (!fsi ||
590 !fsi->substream || 631 !fsi->substream ||
@@ -620,17 +661,12 @@ static int fsi_data_pop(struct fsi_priv *fsi, int startup)
620 if (free < fifo_fill) 661 if (free < fifo_fill)
621 fifo_fill = free; 662 fifo_fill = free;
622 663
623 start = fsi_dma_get_area(fsi);
624
625 switch (width) { 664 switch (width) {
626 case 2: 665 case 2:
627 for (i = 0; i < fifo_fill; i++) 666 fsi_dma_soft_pop16(fsi, fifo_fill);
628 *((u16 *)start + i) =
629 (u16)(fsi_reg_read(fsi, DIDT) >> 8);
630 break; 667 break;
631 case 4: 668 case 4:
632 for (i = 0; i < fifo_fill; i++) 669 fsi_dma_soft_pop32(fsi, fifo_fill);
633 *((u32 *)start + i) = fsi_reg_read(fsi, DIDT);
634 break; 670 break;
635 default: 671 default:
636 return -EINVAL; 672 return -EINVAL;