Re: Fix headphone jack on Cirrus 4206

2021-09-11 Thread Tracey Emery
On Sat, Sep 11, 2021 at 06:07:10PM +0200, Mark Kettenis wrote:
> > Date: Sat, 11 Sep 2021 08:53:00 -0600
> > From: Tracey Emery 
> > 
> > On Sat, Sep 11, 2021 at 02:14:56PM +0200, Mark Kettenis wrote:
> > > > Date: Fri, 10 Sep 2021 18:27:07 -0600
> > > > From: Tracey Emery 
> > > > 
> > > > Hello,
> > > > 
> > > > After reading some Linux commits, it shows the GPIO2 on the CS4206 chips
> > > > needs to be unmuted to make the headphone jack work. The following diff
> > > > fixed the headphone jack problem on my iMac12,2, amd64.
> > > > 
> > > > ok?
> > > 
> > > I don't think this is right.  The Linux code either frobs GPIOs 1 & 2
> > > or GPIOs 1 & 3.
> > > 
> > 
> > The code is a quirk in alsa.
> > 
> > iMac 14,1 requires the same quirk as iMac 12,2, using GPIO 2 and 3 for
> > headphone and speaker output amps.  Add the codec SSID quirk entry
> > (106b:0600) accordingly.
> > 
> > SND_PCI_QUIRK(0x106b, 0x0600, "iMac 14,1", CS420X_IMAC27_122),
> > SND_PCI_QUIRK(0x106b, 0x1c00, "MacBookPro 8,1", CS420X_MBP81),
> > SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122),
> > SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101),
> > 
> > An option has to be set in their modprobe.d directory to enable the
> > heaphone jack:
> > 
> > options snd-hda-intel model=imac27
> > 
> > Without the patch below, there is signal on the headphone jack, but its
> > volume is all the way down and not controlable. With GPIO2 unmuted,
> > there is plenty of volume. Perhaps, another approach needs to be taken?
> > Does this break other Macs with that Cirrus audio chip?
> > 
> > > I also don't quite see how this would match the iMac12,2.  Can you
> > > show the pcidump -vxx output for this machine?
> > 
> > I'm sorry, it's 12,1. That is a typo. The pcidump is attached, although
> > rather large.
> 
> So your model is supposed to be handled by:
> 
> /* this conflicts with too many other models */
> /*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/
> 
> That one is commented out and the comment above it suggests it might
> indeed break other machines.  The comment in our code suggests that
> the same subid is used for the MacbookAir4,1.
> 

Well, if it's going to break other Macs, then I'll just keep the patch
local, so the machine is useful for me with OpenBSD.

> Looking at the Linux code it actually actually applies two quirks.
> There is an imac27_pincfgs fixup and then it chains to the
> CS420X_GPIO13 fixup.  The latter only touches gpio 1 and 3, so I am
> puzzled by your statement that gpio 2 fixes things.

Sorry, I don't know what else to say. With AZ_QRK_GPIO_UNMUTE_2 it
works. If that doesn't mean it unmutes GPIO2, then I must be saying
something incorrectly.

The datasheet for the chip shows three analog outputs:

AOUTA1,AOUTB1
AOUTA2,AOUTB2
AOUTA3,AOUTB3

I figured AZ_QRK_GPIO_UNMUTE_2 enabled AOUTA2/B2 and thought Apple tied
the headphone jack to that output.

I'll drop the diff.

Thanks.

> 
> > > > diff 51d7e35078715d4d1d1e1bf2fb89362bad8797d8 /usr/src
> > > > blob - e3b969d585a96910eca98d31bedc8ba08455f763
> > > > file + sys/dev/pci/azalia_codec.c
> > > > --- sys/dev/pci/azalia_codec.c
> > > > +++ sys/dev/pci/azalia_codec.c
> > > > @@ -71,7 +71,7 @@ azalia_codec_init_vtbl(codec_t *this)
> > > > this->subid == 0x72708086 ||/* APPLE_MBA4_1 
> > > > */
> > > > this->subid == 0xcb7910de) {/* APPLE_MBP5_5 
> > > > */
> > > > this->qrks |= AZ_QRK_GPIO_UNMUTE_1 |
> > > > -   AZ_QRK_GPIO_UNMUTE_3;
> > > > +   AZ_QRK_GPIO_UNMUTE_2 | AZ_QRK_GPIO_UNMUTE_3;
> > > > }
> > > > break;
> > > > case 0x10134208:
> > > > 
> > > > 
> > 
> > -- 
> > 
> > Tracey Emery
> > 
> > [2:text/plain Show Save:pcidump.txt (333kB)]
> > 

-- 

Tracey Emery



Re: Fix headphone jack on Cirrus 4206

2021-09-11 Thread Mark Kettenis
> Date: Sat, 11 Sep 2021 08:53:00 -0600
> From: Tracey Emery 
> 
> On Sat, Sep 11, 2021 at 02:14:56PM +0200, Mark Kettenis wrote:
> > > Date: Fri, 10 Sep 2021 18:27:07 -0600
> > > From: Tracey Emery 
> > > 
> > > Hello,
> > > 
> > > After reading some Linux commits, it shows the GPIO2 on the CS4206 chips
> > > needs to be unmuted to make the headphone jack work. The following diff
> > > fixed the headphone jack problem on my iMac12,2, amd64.
> > > 
> > > ok?
> > 
> > I don't think this is right.  The Linux code either frobs GPIOs 1 & 2
> > or GPIOs 1 & 3.
> > 
> 
> The code is a quirk in alsa.
> 
> iMac 14,1 requires the same quirk as iMac 12,2, using GPIO 2 and 3 for
> headphone and speaker output amps.  Add the codec SSID quirk entry
> (106b:0600) accordingly.
> 
> SND_PCI_QUIRK(0x106b, 0x0600, "iMac 14,1", CS420X_IMAC27_122),
> SND_PCI_QUIRK(0x106b, 0x1c00, "MacBookPro 8,1", CS420X_MBP81),
> SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122),
> SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101),
> 
> An option has to be set in their modprobe.d directory to enable the
> heaphone jack:
> 
> options snd-hda-intel model=imac27
> 
> Without the patch below, there is signal on the headphone jack, but its
> volume is all the way down and not controlable. With GPIO2 unmuted,
> there is plenty of volume. Perhaps, another approach needs to be taken?
> Does this break other Macs with that Cirrus audio chip?
> 
> > I also don't quite see how this would match the iMac12,2.  Can you
> > show the pcidump -vxx output for this machine?
> 
> I'm sorry, it's 12,1. That is a typo. The pcidump is attached, although
> rather large.

So your model is supposed to be handled by:

/* this conflicts with too many other models */
/*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/

That one is commented out and the comment above it suggests it might
indeed break other machines.  The comment in our code suggests that
the same subid is used for the MacbookAir4,1.

Looking at the Linux code it actually actually applies two quirks.
There is an imac27_pincfgs fixup and then it chains to the
CS420X_GPIO13 fixup.  The latter only touches gpio 1 and 3, so I am
puzzled by your statement that gpio 2 fixes things.

> > > diff 51d7e35078715d4d1d1e1bf2fb89362bad8797d8 /usr/src
> > > blob - e3b969d585a96910eca98d31bedc8ba08455f763
> > > file + sys/dev/pci/azalia_codec.c
> > > --- sys/dev/pci/azalia_codec.c
> > > +++ sys/dev/pci/azalia_codec.c
> > > @@ -71,7 +71,7 @@ azalia_codec_init_vtbl(codec_t *this)
> > >   this->subid == 0x72708086 ||/* APPLE_MBA4_1 */
> > >   this->subid == 0xcb7910de) {/* APPLE_MBP5_5 */
> > >   this->qrks |= AZ_QRK_GPIO_UNMUTE_1 |
> > > - AZ_QRK_GPIO_UNMUTE_3;
> > > + AZ_QRK_GPIO_UNMUTE_2 | AZ_QRK_GPIO_UNMUTE_3;
> > >   }
> > >   break;
> > >   case 0x10134208:
> > > 
> > > 
> 
> -- 
> 
> Tracey Emery
> 
> [2:text/plain Show Save:pcidump.txt (333kB)]
> 



Re: Fix headphone jack on Cirrus 4206

2021-09-11 Thread Mark Kettenis
> Date: Fri, 10 Sep 2021 18:27:07 -0600
> From: Tracey Emery 
> 
> Hello,
> 
> After reading some Linux commits, it shows the GPIO2 on the CS4206 chips
> needs to be unmuted to make the headphone jack work. The following diff
> fixed the headphone jack problem on my iMac12,2, amd64.
> 
> ok?

I don't think this is right.  The Linux code either frobs GPIOs 1 & 2
or GPIOs 1 & 3.

I also don't quite see how this would match the iMac12,2.  Can you
show the pcidump -vxx output for this machine?


> diff 51d7e35078715d4d1d1e1bf2fb89362bad8797d8 /usr/src
> blob - e3b969d585a96910eca98d31bedc8ba08455f763
> file + sys/dev/pci/azalia_codec.c
> --- sys/dev/pci/azalia_codec.c
> +++ sys/dev/pci/azalia_codec.c
> @@ -71,7 +71,7 @@ azalia_codec_init_vtbl(codec_t *this)
>   this->subid == 0x72708086 ||/* APPLE_MBA4_1 */
>   this->subid == 0xcb7910de) {/* APPLE_MBP5_5 */
>   this->qrks |= AZ_QRK_GPIO_UNMUTE_1 |
> - AZ_QRK_GPIO_UNMUTE_3;
> + AZ_QRK_GPIO_UNMUTE_2 | AZ_QRK_GPIO_UNMUTE_3;
>   }
>   break;
>   case 0x10134208:
> 
>