raffaele.recalc...@bticino.it wrote:
> -----Troy Kisky <troy.ki...@boundarydevices.com> ha scritto: -----
> 
>> Per: Raffaele Recalcati <lamiapost...@gmail.com>
>> Da: Troy Kisky <troy.ki...@boundarydevices.com>
>> Data: 02/07/2010 22.57
>> Cc: davinci-linux-open-source@linux.davincidsp.com, Mark Brown
>> <broo...@opensource.wolfsonmicro.com>, Raffaele Recalcati
>> <raffaele.recalc...@bticino.it>
>> Oggetto: Re: [PATCH 3/3] ASoC: DaVinci: More accurate calculation for
>> clock divider for McBSP (I2S)
>>
>> Raffaele Recalcati wrote:
>>>  @@ -447,6 +448,24 @@ static int davinci_i2s_hw_params(struct
>> snd_pcm_substream *substream,
> 8 - 1);
>>>  +                        if (dev->i2s_accurate_clock) {
>>>  +                                    clk_div = 256;
>>>  +                                    do {
>>>  +
> framesize = (freq / (--clk_div)) /
>>>  +                                                params->rate_num *
>>>  +                                                            params->
> rate_den;
>>>  +
> } while (((framesize < 33) || (framesize > 4095))
>> &&
>>>  +                                                 (clk_div));
>>>  +                                    clk_div--;
>>>  +                                    srgr |= DAVINCI_MCBSP_SRGR_FPER
> (framesize - 1);
>>>  +                        } else {
>>>  +                                    /* symmetric waveforms */
>>>  +
> clk_div = freq / (mcbsp_word_length * 16) /
>>>  +                                                  params->
> rate_num * params->rate_den;
>>>  +                                    srgr |= DAVINCI_MCBSP_SRGR_FPER
> (mcbsp_word_length *
>>>  +
> 16 - 1);
>>>  +                        }
>>>  +
>>>                           /* symmetric waveforms */
>>>                           clk_div = freq / (mcbsp_word_length * 16) /
>>>                                         params->rate_num * params->
> rate_den;
>> Can you test to see if this works to replace all the above ?
>>
>>                         unsigned cycles;
>>                         framesize = mcbsp_word_length * 16;
>>                         cycles = (freq / params->rate_num) * params->
> rate_den;
>>                          clk_div = cycles / framesize;
>>
>>                         if (dev->i2s_accurate_clock) {
>>                                     framesize = cycles / clk_div;
>>                                     if (framesize > 4096))
>>                                                 framesize = 4096;
>>                         }
>>                         srgr |= DAVINCI_MCBSP_SRGR_FPER(framesize - 1);
> 
> yes, it works.
> Now I'm trying to understand the differences:
> 
> your solution with i2s_accurate_clock enabled:
> davinci-asp davinci-asp.0: framesize = 32
> davinci-asp davinci-asp.0: clk_div = 86
> 
> your solution with i2s_accurate_clock NOT enabled:
> 
> davinci-asp davinci-asp.0: framesize = 32
> 
> davinci-asp davinci-asp.0: clk_div = 86
> 
> the same.
> 
> 
> 
> my solution with i2s_accurate_clock enabled:
> 
> davinci-asp davinci-asp.0: my framesize = 33
> davinci-asp
> davinci-asp.0: clk_div = 82
> 
> here the continuous serial clock is faster
> 
> my solution with i2s_accurate_clock NOT enabled
> davinci-asp davinci-asp.0: my framesize = 32
> davinci-asp davinci-asp.0: clk_div = 86
> 
> here the continuous
> serial clock is the same as yours.
> 
> 
> it "seems" better my and Davide solution.
> 

Indeed, your algorithm may produce more accurate results for the specific rate
that you tested for. However, that seems more luck than anything. How do you
know that a frame size of 33 will always give more accurate results than a frame
size of 32? If your going to loop, you need to calculate the error and minimize 
that
and not just stop when framesize finally reaches your minimum size of 33.

Also, you may want to stop when your framesize > twice your minimum framesize.
Otherwise you may end up with a very very fast clock most of which is garbage 
cycles.

Troy
_______________________________________________
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to