[alsa-devel] SGTL500 and its external MCLK

jonsmirl at gmail.com jonsmirl at gmail.com
Sat Aug 9 18:42:43 CEST 2014


On Fri, Aug 8, 2014 at 1:07 PM, jonsmirl at gmail.com <jonsmirl at gmail.com> wrote:
> On Fri, Aug 8, 2014 at 1:29 AM, Nicolin Chen <Guangyu.Chen at freescale.com> wrote:
>> On Thu, Aug 07, 2014 at 03:37:47PM -0400, jonsmirl at gmail.com wrote:
>>> Since the sgtl5000 driver has the handle to the clock, can't it just
>>> ask the clock for its rate? If it directly asked the clock for its
>>> rate it looks like this codec could be bound with simple-audio-card
>>> and not need a machine driver.
>>
>> I think Simple Card should already have the capability to support
>> this without changing sgtl5000's code. It has two properties that
>> can make it call set_sysclk() for you during the init(). They are
>> 'clocks' and 'system-clock-frequency'. Please refer to its binding
>> doc for details.

Simple has a hard coded clock ID of zero. Which just happens to match
codecs/sgtl5000.h:#define SGTL5000_SYSCLK 0x00

Lucky coincidence?

static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
     struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
unsigned int mclk;
int ret = 0;

if (priv->mclk_fs) {
mclk = params_rate(params) * priv->mclk_fs;
ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
    SND_SOC_CLOCK_IN);
}

return ret;
}



>>
>> And the topic why not let sgtl5000 fully control the clock has been
>> discussed in this thread:
>> http://comments.gmane.org/gmane.linux.alsa.devel/109093
>>
>> So I think the change can be done as well?
>
> I tried hacking on it some. One problem is with clocks that aren't
> 100% accurate. For example my clock is off a little - 22.571428. So
> when the code divides that by 44100 it gets 511.8 which truncates to
> 511 and the test for equal to 512 fails.
>
>
>>
>> Best regards,
>> Nicolin
>
>
>
> --
> Jon Smirl
> jonsmirl at gmail.com



-- 
Jon Smirl
jonsmirl at gmail.com


More information about the Alsa-devel mailing list