From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
alsa-devel@alsa-project.org
Cc: tiwai@suse.de, Cezary Rojewski <cezary.rojewski@intel.com>,
broonie@kernel.org, Bard Liao <yung-chuan.liao@linux.intel.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>
Subject: Re: [PATCH 2/4] ALSA: hda: intel-nhlt: add intel_nhlt_ssp_mclk_mask()
Date: Wed, 24 Aug 2022 12:53:44 +0200 [thread overview]
Message-ID: <7fbe5d7d-05ee-0616-ac85-8813c5755671@linux.intel.com> (raw)
In-Reply-To: <1b8dc49b-9a06-c842-5dee-1f44f771b5f0@linux.intel.com>
On 8/23/2022 5:18 PM, Pierre-Louis Bossart wrote:
>
>>>>> +
>>>>> + fmt = (struct nhlt_fmt *)(epnt->config.caps +
>>>>> epnt->config.size);
>>>>> + cfg = fmt->fmt_config;
>>>>> +
>>>>> + /*
>>>>> + * In theory all formats should use the same MCLK but it
>>>>> doesn't hurt to
>>>>> + * double-check that the configuration is consistent
>>>>> + */
>>>>> + for (j = 0; j < fmt->fmt_count; j++) {
>>>>> + u32 *blob;
>>>>> + int mdivc_offset;
>>>>> +
>>>>> + if (cfg->config.size >= SSP_BLOB_V1_0_SIZE) {
>>>>> + blob = (u32 *)cfg->config.caps;
>>>>> +
>>>>> + if (blob[1] == SSP_BLOB_VER_2_0)
>>>>> + mdivc_offset = SSP_BLOB_V2_0_MDIVC_OFFSET;
>>>>> + else if (blob[1] == SSP_BLOB_VER_1_5)
>>>>> + mdivc_offset = SSP_BLOB_V1_5_MDIVC_OFFSET;
>>>>> + else
>>>>> + mdivc_offset = SSP_BLOB_V1_0_MDIVC_OFFSET;
>>>>> +
>>>>> + mclk_mask |= blob[mdivc_offset] & GENMASK(1, 0);
>>
>> One more thing, where does this GENMASK come from, as far as I can tell
>> HW specifies and FW uses one bit field to signal that MCLK is enabled?
>> (mdivc is simply a value written to HW register to configure it).
>
> There are two MCLK signals, that's the point of this patch. We need to
> find which one is used. Platforms typically use MCLK0 except when they
> don't..
>
> BIT(0) set in mdivc enables MCLK0
> BIT(1) set in mdivc enabled MCLK1
>
> see
> https://github.com/thesofproject/sof/blob/44a5200c87625588f0028aa08d560e68f2b8dc82/src/drivers/intel/ssp/mn.c#L150
>
>>>>> + }
>>>>> +
>>>>> + cfg = (struct nhlt_fmt_cfg *)(cfg->config.caps +
>>>>> cfg->config.size);
>>>>> + }
>>>>> + }
>>>>> + epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
>>>>> + }
>>>>> +
>>>>> + return mclk_mask;
>>>>
>>>> Although I understand that it is relegated to the caller, but if both
>>>> mclk being set is considered an error maybe add some kind of check here
>>>> instead and free callers from having to remember about it?
>>>>
>>>> if (hweight_long(mclk_mask) != 1)
>>>> return -EINVAL;
>>>>
>>>> return mclk_mask;
>>>
>>> I went back and forth multiple times on this one. I can't figure out if
>>> this would be a bug or a feature, it could be e.g. a test capability and
>>> it's supported in hardware. I decided to make the decision in the caller
>>> rather than a lower level in the library.
>>>
>>> If the tools used to generate NHLT don't support this multi-MCLK mode
>>> then we could indeed move the test here.
>>>
>>
>> Considering comment I added above I've asked Czarek to also check this
>> series. I'm not sure it even makes sense to name the field "_mask" when
>> it is one bit...
>
> it's two bits, see above.
So I've spend a bit talking with FW team, and you are right, I got
confused by one of the tables and some code that specified it as 1 bit
field and rest as reserved, while other documents do specify it as a
variable range of bits.
Going back to return value, the tool I have access to only has support
for MCLK0. I guess we can make the assumption for now that everyone
connects codec to one clock source and if someone later implements HW
where somehow 2 different clocks are used (depending on format) we can
refine the check later?
next prev parent reply other threads:[~2022-08-24 12:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-22 18:59 [PATCH 0/4] ASoC: SOF: Intel: override mclk_id for ES8336 support Pierre-Louis Bossart
2022-08-22 18:59 ` [PATCH 1/4] ASoC: SOF: add quirk to override topology mclk_id Pierre-Louis Bossart
2022-08-22 18:59 ` [PATCH 2/4] ALSA: hda: intel-nhlt: add intel_nhlt_ssp_mclk_mask() Pierre-Louis Bossart
2022-08-23 8:32 ` Takashi Iwai
2022-08-23 8:41 ` Pierre-Louis Bossart
2022-08-23 8:33 ` Amadeusz Sławiński
2022-08-23 8:52 ` Pierre-Louis Bossart
2022-08-23 14:55 ` Amadeusz Sławiński
2022-08-23 15:18 ` Pierre-Louis Bossart
2022-08-24 10:53 ` Amadeusz Sławiński [this message]
2022-08-24 11:17 ` Pierre-Louis Bossart
2022-08-22 18:59 ` [PATCH 3/4] ASoC: SOF: Intel: hda: override mclk_id after parsing NHLT SSP blob Pierre-Louis Bossart
2022-08-22 18:59 ` [PATCH 4/4] ASoC: SOF: Intel: hda: refine SSP count support Pierre-Louis Bossart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7fbe5d7d-05ee-0616-ac85-8813c5755671@linux.intel.com \
--to=amadeuszx.slawinski@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=tiwai@suse.de \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox