git: 23db5fccb60a - main - hda: add macbook air 6,1 and 6,2 GPIO to enable amplifier

From: Adrian Chadd <adrian_at_FreeBSD.org>
Date: Sat, 22 Mar 2025 15:57:22 UTC
The branch main has been updated by adrian:

URL: https://cgit.FreeBSD.org/src/commit/?id=23db5fccb60a1b008c7cbd3a6b88f9a6b1bac167

commit 23db5fccb60a1b008c7cbd3a6b88f9a6b1bac167
Author:     Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2023-01-24 07:37:14 +0000
Commit:     Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2025-03-22 15:56:34 +0000

    hda: add macbook air 6,1 and 6,2 GPIO to enable amplifier
    
    GPIO0 needs to be flipped on to enable the amplifier.
    
    The CS4208 looks /sort/ of like previous cirrus logic codecs,
    enough for audio to work.  This actually provides working audio
    on my mbair 6,2 but it doesn't yet detect the jack.
    
    That requires patches to the pin configs, which is going to
    need some further work.
    
    Differential Revision: https://reviews.freebsd.org/D49350
    Reviewed by: christos
---
 sys/dev/sound/pci/hda/hdaa.c         | 2 +-
 sys/dev/sound/pci/hda/hdaa_patches.c | 6 ++++++
 sys/dev/sound/pci/hda/hdac.h         | 3 +++
 sys/dev/sound/pci/hda/hdacc.c        | 1 +
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c
index ac62c04b5374..1e486b01b168 100644
--- a/sys/dev/sound/pci/hda/hdaa.c
+++ b/sys/dev/sound/pci/hda/hdaa.c
@@ -2912,7 +2912,7 @@ hdaa_dump_gpo(struct hdaa_devinfo *devinfo)
 		data = hda_command(dev,
 		    HDA_CMD_GET_GPO_DATA(0, devinfo->nid));
 		for (i = 0; i < HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap); i++) {
-			device_printf(dev, " GPO%d: state=%d", i,
+			device_printf(dev, " GPO%d: state=%d\n", i,
 				    (data >> i) & 1);
 		}
 	}
diff --git a/sys/dev/sound/pci/hda/hdaa_patches.c b/sys/dev/sound/pci/hda/hdaa_patches.c
index 8ad1c845c254..0e88a63e2423 100644
--- a/sys/dev/sound/pci/hda/hdaa_patches.c
+++ b/sys/dev/sound/pci/hda/hdaa_patches.c
@@ -113,6 +113,12 @@ static const struct {
 	{ APPLE_MACBOOKAIR31, HDA_CODEC_CS4206, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) },
+	{ HDA_MATCH_ALL, HDA_CODEC_CS4208, APPLE_MACBOOKAIR61,
+	    0, 0,
+	    HDAA_GPIO_SET(0) },
+	{ HDA_MATCH_ALL, HDA_CODEC_CS4208, APPLE_MACBOOKAIR62,
+	    0, 0,
+	    HDAA_GPIO_SET(0) },
 	{ APPLE_MACBOOKPRO55, HDA_CODEC_CS4206, HDA_MATCH_ALL,
 	    0, 0,
 	    HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) },
diff --git a/sys/dev/sound/pci/hda/hdac.h b/sys/dev/sound/pci/hda/hdac.h
index 9b11dcba32a8..231839327530 100644
--- a/sys/dev/sound/pci/hda/hdac.h
+++ b/sys/dev/sound/pci/hda/hdac.h
@@ -426,6 +426,8 @@
  */
 #define APPLE_INTEL_MAC		0x76808384
 #define APPLE_MACBOOKAIR31	0x0d9410de
+#define APPLE_MACBOOKAIR61	0x106b7100
+#define APPLE_MACBOOKAIR62	0x106b7200
 #define APPLE_MACBOOKPRO55	0xcb7910de
 #define APPLE_MACBOOKPRO71	0xcb8910de
 
@@ -540,6 +542,7 @@
 #define CIRRUSLOGIC_VENDORID	0x1013
 #define HDA_CODEC_CS4206	HDA_CODEC_CONSTRUCT(CIRRUSLOGIC, 0x4206)
 #define HDA_CODEC_CS4207	HDA_CODEC_CONSTRUCT(CIRRUSLOGIC, 0x4207)
+#define HDA_CODEC_CS4208	HDA_CODEC_CONSTRUCT(CIRRUSLOGIC, 0x4208)
 #define HDA_CODEC_CS4210	HDA_CODEC_CONSTRUCT(CIRRUSLOGIC, 0x4210)
 #define HDA_CODEC_CSXXXX	HDA_CODEC_CONSTRUCT(CIRRUSLOGIC, 0xffff)
 
diff --git a/sys/dev/sound/pci/hda/hdacc.c b/sys/dev/sound/pci/hda/hdacc.c
index b4321a5bf998..4198982c9c2a 100644
--- a/sys/dev/sound/pci/hda/hdacc.c
+++ b/sys/dev/sound/pci/hda/hdacc.c
@@ -74,6 +74,7 @@ static const struct {
 } hdacc_codecs[] = {
 	{ HDA_CODEC_CS4206, 0,		"Cirrus Logic CS4206" },
 	{ HDA_CODEC_CS4207, 0,		"Cirrus Logic CS4207" },
+	{ HDA_CODEC_CS4208, 0,		"Cirrus Logic CS4208" },
 	{ HDA_CODEC_CS4210, 0,		"Cirrus Logic CS4210" },
 	{ HDA_CODEC_ALC215, 0,		"Realtek ALC215" },
 	{ HDA_CODEC_ALC221, 0,		"Realtek ALC221" },