mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shih-Yuan Lee <fourdollars@debian.org>
To: Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>
Cc: Shih-Yuan Lee <fourdollars@debian.org>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v1 0/2] ALSA: hda/cs420x: MacBook8,1 speakers and headset mic
Date: Tue,  1 Dec 2026 23:32:11 +0800	[thread overview]
Message-ID: <20261201153214.25157-1-fourdollars@debian.org> (raw)

This series adds audio support for the 12-inch MacBook (MacBook8,1,
codec SSID 106b:6400, Cirrus Logic CS4208), which currently has no
working internal speakers or headset microphone on mainline.

Patch 1 adds a CS4208_MB81 fixup for the four MAX98357B TDM speaker
amplifiers (digital pin 0x1d / converter 0x0a, enabled via GPIO0), with
a { FL, FR, NA, NA } channel map and GPIO0 automute on headphone
plug/unplug.

Patch 2 adds 4-pole TRRS headset mic support.  Pin 0x18 has no
mechanical jack sense, so CTIA/OMTP/3-pole polarity is detected with the
CS4208 HS3/HS4 impedance detector and routed via NID 0x24 CIR 0x1a.

Userspace needs a matching alsa-ucm-conf profile (SplitPCM to expose the
4-channel TDM PCM as a stereo sink); I will send that once this is
settled.  Background and reverse-engineering credits are in
https://bugzilla.kernel.org/show_bug.cgi?id=110561 (Leif Liddy,
Thomas Shirley, Zach Robinson and others).

Questions for review:

 - Patch 1 locks the "IEC958 Default PCM Playback Switch" read-only in
   HDA_FIXUP_ACT_BUILD to stop analog playback from being mirrored onto
   the 4-channel TDM converter.  Would you prefer a flag in
   hda_gen_spec (e.g. no_share_spdif) that skips
   snd_hda_create_spdif_share_sw() instead?
 - Patch 2 calls snd_hda_gen_fix_pin_power() for pin 0x18, because
   dyn_adc_switch does not propagate stream_enabled to the newly
   selected input pin when switching an already open capture stream.
   Should this be fixed in generic.c rather than worked around here?

Known limitations: speaker protection (pin 0x22 IV-sense) is not
implemented, so keep volume moderate.  Only MacBook8,1 was tested;
MacBook9,1/10,1 share the hardware family but are not added.

Testing, on a real MacBook8,1 (Ubuntu 7.0.0-44-generic, built as an
out-of-tree module of this cs420x.c since no mainline kernel with this
base is installed there):

 - Cold boot matches the quirk; speaker playback (4ch/44.1kHz/S16_LE
   via UCM SplitPCM), headphone plug/unplug with GPIO0 automute,
   internal mic, and TRRS headset mic hotplug all work.
 - Runtime PM D3 -> D0 resume and S3 suspend/resume keep working.  On
   this machine the codec does not wake the HDA link from D3 on jack
   plug/unplug, hence cs_init() re-runs debounced detection on resume.
 - Caveat for S3: on this MacBook8,1 suspend/resume is only reliable
   with three platform workarounds that are unrelated to this series:
   the ACPI LID0 wakeup source is disabled (otherwise the machine
   wakes again about 2 seconds after suspending with the lid open),
   the WiFi/Bluetooth kernel modules are unloaded before suspending,
   and my separate spi-pxa2xx patchset (currently under review) is
   applied.  Without those, suspend/resume fails or wakes up
   immediately regardless of this driver.
 - Analog headphone playback (hw:PCH,0, 48/96 kHz S32_LE) leaves
   converter 0x0a idle (stream=0).
 - checkpatch.pl --strict is clean, W=1 and sparse report nothing, and
   each patch builds on its own on top of v7.4-rc5-era master.
 - The locking and runtime-PM interaction of the headset detection
   (hs_mutex vs. runtime PM, unplug vs. resume, unsol vs. resume) was
   also modelled in SPIN and checked exhaustively.

Tool disclosure: I used an AI coding assistant for review feedback and
iteration on the code and for drafting parts of the changelogs, and the
SPIN model above was written with its help.  I reviewed and tested
everything myself and take responsibility for the submission.

Shih-Yuan Lee (2):
  ALSA: hda/cs420x: Add CS4208 TDM speaker fixup for MacBook8,1
  ALSA: hda/cs420x: Support headset mic type detection on MacBook8,1

 Documentation/sound/hd-audio/models.rst |   2 +
 sound/hda/codecs/cirrus/cs420x.c        | 751 +++++++++++++++++++++++-
 2 files changed, 747 insertions(+), 6 deletions(-)

-- 
2.39.5


             reply	other threads:[~2026-12-01 15:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 15:32 Shih-Yuan Lee [this message]
2026-12-01 15:32 ` [PATCH v1 1/2] ALSA: hda/cs420x: Add CS4208 TDM speaker fixup for MacBook8,1 Shih-Yuan Lee
2026-12-01 15:32 ` [PATCH v1 2/2] ALSA: hda/cs420x: Support headset mic type detection on MacBook8,1 Shih-Yuan Lee

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=20261201153214.25157-1-fourdollars@debian.org \
    --to=fourdollars@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.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

all inboxes | Powered by JetHome®