public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: Yauhen Kharuzhy <jekhor@gmail.com>,
	linux-sound@vger.kernel.org,
	Cezary Rojewski <cezary.rojewski@intel.com>,
	Liam Girdwood <liam.r.girdwood@linux.intel.com>,
	Mark Brown <broonie@kernel.org>
Cc: 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: Wed, 18 Feb 2026 11:31:38 +0100	[thread overview]
Message-ID: <218a9abc-87ab-45e2-8ec5-355cd6bd627b@linux.dev> (raw)
In-Reply-To: <20260217231324.1319392-2-jekhor@gmail.com>

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.

> +
> +	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?

> +	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.

> +	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,
> +	},
> +};
> +

  reply	other threads:[~2026-02-18 10:51 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 [this message]
2026-02-18 22:37     ` Yauhen Kharuzhy
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=218a9abc-87ab-45e2-8ec5-355cd6bd627b@linux.dev \
    --to=pierre-louis.bossart@linux.dev \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=hansg@kernel.org \
    --cc=jekhor@gmail.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    /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