public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yauhen Kharuzhy <jekhor@gmail.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Cc: linux-sound@vger.kernel.org,
	 Cezary Rojewski <cezary.rojewski@intel.com>,
	Liam Girdwood <liam.r.girdwood@linux.intel.com>,
	 Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org, Hans de Goede <hansg@kernel.org>
Subject: Re: [PATCH v1 1/2] ASoC: Intel: cht_yogabook: Add driver for Lenovo Yoga Book tablets
Date: Thu, 19 Feb 2026 00:37:35 +0200	[thread overview]
Message-ID: <aZY71atHyeZBE44B@jekhomev> (raw)
In-Reply-To: <218a9abc-87ab-45e2-8ec5-355cd6bd627b@linux.dev>

On Wed, Feb 18, 2026 at 11:31:38AM +0100, Pierre-Louis Bossart wrote:
> Thanks for the patch, looks mostly good to me, see below a couple of comments.
> 
> > +static int cht_yb_hp_event(struct snd_soc_dapm_widget *w,
> > +			   struct snd_kcontrol *k, int event)
> > +{
> > +	struct snd_soc_card *card = snd_soc_dapm_to_card(w->dapm);
> > +	struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
> > +
> > +	dev_dbg(card->dev, "HP event: %s\n",
> > +		SND_SOC_DAPM_EVENT_ON(event) ? "ON" : "OFF");
> > +
> > +	if (SND_SOC_DAPM_EVENT_ON(event)) {
> > +		msleep(20);
> > +		gpiod_set_value_cansleep(ctx->gpio_hp_en, 1);
> > +		msleep(50);
> > +	} else {
> > +		gpiod_set_value_cansleep(ctx->gpio_hp_en, 0);
> > +	}
> 
> It'd be worth having a comment on why you need the 2 separate msleep.
> IIRC for Broadwell we only had a common 70ms sleep for both enable and disable.

Actually I don't know, it just a copy-paste from the Lenovo Android
kernel code, and I didn't check what happens if this sleeps are removed,
AFAIR, if there are any sound artifacts or something else.

Will check.

> 
> > +
> > +	return 0;
> > +}
> > +
> > +static int cht_yb_spk_event(struct snd_soc_dapm_widget *w,
> > +			    struct snd_kcontrol *k, int event)
> > +{
> > +	struct snd_soc_card *card = snd_soc_dapm_to_card(w->dapm);
> > +	struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
> > +
> > +	dev_dbg(card->dev, "SPK event: %s\n",
> > +		SND_SOC_DAPM_EVENT_ON(event) ? "ON" : "OFF");
> > +
> > +	/* Black magic from the Lenovo's Android kernel
> > +	 * FIXME: Check if it is needed, an original comment:
> > +	 * "use gpio GPIO_SPK_EN to enable/disable ext boost pa
> > +	 * use mode 3"
> > +	 */
> > +	if (SND_SOC_DAPM_EVENT_ON(event)) {
> > +		gpiod_set_value_cansleep(ctx->gpio_spk_en1, 1);
> > +		udelay(2);
> > +		gpiod_set_value_cansleep(ctx->gpio_spk_en1, 0);
> > +		udelay(2);
> > +		gpiod_set_value_cansleep(ctx->gpio_spk_en1, 1);
> > +		udelay(2);
> > +		gpiod_set_value_cansleep(ctx->gpio_spk_en1, 0);
> > +		udelay(2);
> > +	}
> 
> That seems weird indeed, never seen this before. What happens if that block is removed?

Sure. Will check, I cannot remember if I checked this during initial porting...

> 
> > +	gpiod_set_value_cansleep(ctx->gpio_spk_en1,
> > +				 SND_SOC_DAPM_EVENT_ON(event));
> > +	gpiod_set_value_cansleep(ctx->gpio_spk_en2,
> > +				 SND_SOC_DAPM_EVENT_ON(event));
> > +	msleep(50);
> > +
> > +	return 0;
> > +}
> > +
> 
> > +static int cht_yb_codec_fixup(struct snd_soc_pcm_runtime *rtd,
> > +			      struct snd_pcm_hw_params *params)
> > +{
> > +	struct snd_interval *rate = hw_param_interval(params,
> > +			SNDRV_PCM_HW_PARAM_RATE);
> > +	struct snd_interval *channels = hw_param_interval(params,
> > +						SNDRV_PCM_HW_PARAM_CHANNELS);
> > +
> > +	/* The DSP will convert the FE rate to 48k, stereo, 24bits */
> > +	rate->min = rate->max = 48000;
> > +	channels->min = channels->max = 2;
> > +
> > +	/*
> > +	 * set SSP2 to 24-bit
> > +	 * Looks like strange black magic because ssp2-port supports S16LE
> > +	 * format only, taken from Intel's code
> > +	 */
> 
> No, SSP2 supports 24 bits in TDM mode. only SSP0 has firmware restrictions to S16LE.

Thanks, I even don't remember why I added this comment. To be removed.

> 
> > +	params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
> > +
> > +	return 0;
> > +}
> > +
> > +static struct snd_soc_jack_pin cht_yb_jack_pins[] = {
> > +	{
> > +		.pin = "Headphone",
> > +		.mask = SND_JACK_HEADPHONE,
> > +	},
> > +	{
> > +		.pin = "Headset Mic",
> > +		.mask = SND_JACK_MICROPHONE,
> > +	},
> > +};
> > +

-- 
Yauhen Kharuzhy

  reply	other threads:[~2026-02-18 22:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-17 23:13 [PATCH v1 0/2] Add ASoC machine driver for Lenovo YB1 tablets Yauhen Kharuzhy
2026-02-17 23:13 ` [PATCH v1 1/2] ASoC: Intel: cht_yogabook: Add driver for Lenovo Yoga Book tablets Yauhen Kharuzhy
2026-02-18 10:31   ` Pierre-Louis Bossart
2026-02-18 22:37     ` Yauhen Kharuzhy [this message]
2026-02-17 23:13 ` [PATCH v1 2/2] ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Book entries Yauhen Kharuzhy
2026-02-18 10:35   ` Pierre-Louis Bossart
2026-02-18 22:45     ` Yauhen Kharuzhy

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=aZY71atHyeZBE44B@jekhomev \
    --to=jekhor@gmail.com \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=hansg@kernel.org \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.dev \
    /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