diff options
author | Jyri Sarha <jsarha@ti.com> | 2015-09-17 03:39:05 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-09-17 06:37:27 -0400 |
commit | 14a998be08e5286741021d3c81cc81e8d6d8a270 (patch) | |
tree | 0bfd7e747cb85174be946591c5f1918888baf78b | |
parent | dd55ff8346a972cca1ad056c8258ee96d090633e (diff) |
ASoC: davinci-mcasp: Get rid of bclk_lrclk_ratio in private data
The slot_width is for essentially same thing. Instead of storing
bclk_lrclk_ratio, just store the slot_width. Comments has been updated
accordingly and some variable names changed to more descriptive.
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/davinci/davinci-mcasp.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index fa47a39fac86..452f2a36e51c 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c | |||
@@ -87,7 +87,6 @@ struct davinci_mcasp { | |||
87 | u8 *serial_dir; | 87 | u8 *serial_dir; |
88 | u8 version; | 88 | u8 version; |
89 | u8 bclk_div; | 89 | u8 bclk_div; |
90 | u16 bclk_lrclk_ratio; | ||
91 | int streams; | 90 | int streams; |
92 | u32 irq_request[2]; | 91 | u32 irq_request[2]; |
93 | int dma_request[2]; | 92 | int dma_request[2]; |
@@ -558,8 +557,21 @@ static int __davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, | |||
558 | mcasp->bclk_div = div; | 557 | mcasp->bclk_div = div; |
559 | break; | 558 | break; |
560 | 559 | ||
561 | case 2: /* BCLK/LRCLK ratio */ | 560 | case 2: /* |
562 | mcasp->bclk_lrclk_ratio = div; | 561 | * BCLK/LRCLK ratio descries how many bit-clock cycles |
562 | * fit into one frame. The clock ratio is given for a | ||
563 | * full period of data (for I2S format both left and | ||
564 | * right channels), so it has to be divided by number | ||
565 | * of tdm-slots (for I2S - divided by 2). | ||
566 | * Instead of storing this ratio, we calculate a new | ||
567 | * tdm_slot width by dividing the the ratio by the | ||
568 | * number of configured tdm slots. | ||
569 | */ | ||
570 | mcasp->slot_width = div / mcasp->tdm_slots; | ||
571 | if (div % mcasp->tdm_slots) | ||
572 | dev_warn(mcasp->dev, | ||
573 | "%s(): BCLK/LRCLK %d is not divisible by %d tdm slots", | ||
574 | __func__, div, mcasp->tdm_slots); | ||
563 | break; | 575 | break; |
564 | 576 | ||
565 | default: | 577 | default: |
@@ -677,11 +689,13 @@ static int davinci_mcasp_set_tdm_slot(struct snd_soc_dai *dai, | |||
677 | } | 689 | } |
678 | 690 | ||
679 | static int davinci_config_channel_size(struct davinci_mcasp *mcasp, | 691 | static int davinci_config_channel_size(struct davinci_mcasp *mcasp, |
680 | int word_length) | 692 | int sample_width) |
681 | { | 693 | { |
682 | u32 fmt; | 694 | u32 fmt; |
683 | u32 tx_rotate = (word_length / 4) & 0x7; | 695 | u32 tx_rotate = (sample_width / 4) & 0x7; |
684 | u32 mask = (1ULL << word_length) - 1; | 696 | u32 mask = (1ULL << sample_width) - 1; |
697 | u32 slot_width = sample_width; | ||
698 | |||
685 | /* | 699 | /* |
686 | * For captured data we should not rotate, inversion and masking is | 700 | * For captured data we should not rotate, inversion and masking is |
687 | * enoguh to get the data to the right position: | 701 | * enoguh to get the data to the right position: |
@@ -694,31 +708,23 @@ static int davinci_config_channel_size(struct davinci_mcasp *mcasp, | |||
694 | u32 rx_rotate = 0; | 708 | u32 rx_rotate = 0; |
695 | 709 | ||
696 | /* | 710 | /* |
697 | * if s BCLK-to-LRCLK ratio has been configured via the set_clkdiv() | 711 | * Setting the tdm slot width either with set_clkdiv() or |
698 | * callback, take it into account here. That allows us to for example | 712 | * set_tdm_slot() allows us to for example send 32 bits per |
699 | * send 32 bits per channel to the codec, while only 16 of them carry | 713 | * channel to the codec, while only 16 of them carry audio |
700 | * audio payload. | 714 | * payload. |
701 | * The clock ratio is given for a full period of data (for I2S format | ||
702 | * both left and right channels), so it has to be divided by number of | ||
703 | * tdm-slots (for I2S - divided by 2). | ||
704 | */ | 715 | */ |
705 | if (mcasp->bclk_lrclk_ratio) { | 716 | if (mcasp->slot_width) { |
706 | u32 slot_length = mcasp->bclk_lrclk_ratio / mcasp->tdm_slots; | ||
707 | |||
708 | /* | 717 | /* |
709 | * When we have more bclk then it is needed for the data, we | 718 | * When we have more bclk then it is needed for the |
710 | * need to use the rotation to move the received samples to have | 719 | * data, we need to use the rotation to move the |
711 | * correct alignment. | 720 | * received samples to have correct alignment. |
712 | */ | 721 | */ |
713 | rx_rotate = (slot_length - word_length) / 4; | 722 | slot_width = mcasp->slot_width; |
714 | word_length = slot_length; | 723 | rx_rotate = (slot_width - sample_width) / 4; |
715 | } else if (mcasp->slot_width) { | ||
716 | rx_rotate = (mcasp->slot_width - word_length) / 4; | ||
717 | word_length = mcasp->slot_width; | ||
718 | } | 724 | } |
719 | 725 | ||
720 | /* mapping of the XSSZ bit-field as described in the datasheet */ | 726 | /* mapping of the XSSZ bit-field as described in the datasheet */ |
721 | fmt = (word_length >> 1) - 1; | 727 | fmt = (slot_width >> 1) - 1; |
722 | 728 | ||
723 | if (mcasp->op_mode != DAVINCI_MCASP_DIT_MODE) { | 729 | if (mcasp->op_mode != DAVINCI_MCASP_DIT_MODE) { |
724 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, RXSSZ(fmt), | 730 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, RXSSZ(fmt), |