All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* Headphone issues iMac 14.1 (A1418)
@ 2018-01-03 10:39 Freaky
  2018-01-04 14:48 ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Freaky @ 2018-01-03 10:39 UTC (permalink / raw
  To: alsa-devel

Hi there,

we're having issues enabling the headphone out on an iMac 14.1 (A1418).

The parameters snd-hda-intel.model=imac27 or snd-hda-intel.model=imac27_122
do not resolve the problem.

Plug detection seems to be working fine, upon plugging the headphone,
speaker-out will mute and headphone out will unmute. Unplugging it does the
reverse. There's no audio on the headphone out however.

We ran the hda analyzer python script and when enabling 'out-dir', 'enable'
and 'data' on the GPIO's marked as [2] the audio starts working.

If we unplug/plug the headphone then the audio is dead again. Need to
uncheck and check them and it will work again.

Ran alsa-info.sh, whilst the GPIO's marked as [2] were enabled:

http://www.alsa-project.org/db/?f=86db8b16d0118edd1feab9626c68eed4735b943e

Would be much obliged if can help with a solution for this. Preferably with
a kernel parameter as we run a stateless image that's used on a huge
variety of systems.

Tried different kernel versions by the way, problem still exists in 4.14.8
at least.

Thanks in advance and best wishes for the new year to you all!

Kind regards,

Ferry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Headphone issues iMac 14.1 (A1418)
  2018-01-03 10:39 Headphone issues iMac 14.1 (A1418) Freaky
@ 2018-01-04 14:48 ` Takashi Iwai
       [not found]   ` <CAEw6ZysYDerXhZZnBbLu3EzEOOqTdvE-dzq9_pLdcQNzS02_1g@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2018-01-04 14:48 UTC (permalink / raw
  To: Freaky; +Cc: alsa-devel

On Wed, 03 Jan 2018 11:39:57 +0100,
Freaky wrote:
> 
> Hi there,
> 
> we're having issues enabling the headphone out on an iMac 14.1 (A1418).
> 
> The parameters snd-hda-intel.model=imac27 or snd-hda-intel.model=imac27_122
> do not resolve the problem.
> 
> Plug detection seems to be working fine, upon plugging the headphone,
> speaker-out will mute and headphone out will unmute. Unplugging it does the
> reverse. There's no audio on the headphone out however.
> 
> We ran the hda analyzer python script and when enabling 'out-dir', 'enable'
> and 'data' on the GPIO's marked as [2] the audio starts working.
> 
> If we unplug/plug the headphone then the audio is dead again. Need to
> uncheck and check them and it will work again.
> 
> Ran alsa-info.sh, whilst the GPIO's marked as [2] were enabled:
> 
> http://www.alsa-project.org/db/?f=86db8b16d0118edd1feab9626c68eed4735b943e

Do you need to enable GPIO[2] for which output?  Does it control both
speaker and headphone outputs, or only one of them?

Also, no pin config change is needed but for GPIO setup?


thanks,

Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Headphone issues iMac 14.1 (A1418)
       [not found]   ` <CAEw6ZysYDerXhZZnBbLu3EzEOOqTdvE-dzq9_pLdcQNzS02_1g@mail.gmail.com>
@ 2018-01-04 16:35     ` Takashi Iwai
       [not found]       ` <CAEw6Zyszryna_596a0jM_0Rez9BrN5Zs21GE2BxwGFu5hhVz4Q@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2018-01-04 16:35 UTC (permalink / raw
  To: Freaky; +Cc: alsa-devel

On Thu, 04 Jan 2018 17:27:55 +0100,
Freaky wrote:
> 
> Hi Takashi,
> 
> we need it to get the headphone output working. Upon unplugging /
> replugging we need to check them again (they remain checked, but the output
> stops working). The speaker output (onboard speakers) works fine and the
> script we run doesn't appear to have any effect on the speaker output at
> all.

The alsa-info.sh output showed that GPIO[1] is also set, so I wonder
how and who sets it.  In anyway, could you check whether flipping any
such gpio bits turn on / off the headphone and the speaker outputs?
Try to toggle it while playing back, such as,
	hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DATA xxx
where xxx is the value to be written (0x00, 0x02, 0x04, 0x06, etc).

> Currently use a python script generated by the HDA Analyzer script that we
> run every 5 seconds from boot. Pasted the script below. We run it every 5
> seconds to ensure audio will work after replugging the headphones (although
> it might incur a small delay then of course). I don't notice any hick-ups
> in audio playback because of the script firing every 5 seconds.
> 
> There's no acpid running from which we could detect the plug event. Using a
> system based on Fedora 24. Have watched dbus-monitor (--sytem), but see no
> events there upon (un)plugging the headphones which we could use as trigger.

The headphone jack detection on HD-audio is usually done via HD-audio
codec unsolicited events.  You can check "Headphone Jack" ALSA control
element (e.g. watch the output of "amixer contents").


Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Headphone issues iMac 14.1 (A1418)
       [not found]       ` <CAEw6Zyszryna_596a0jM_0Rez9BrN5Zs21GE2BxwGFu5hhVz4Q@mail.gmail.com>
@ 2018-01-09 14:39         ` Takashi Iwai
       [not found]           ` <CAEw6Zyus0Aad0qvnN9a2xMY28=ADK5h244vG0wkeR+eCE7bedQ@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2018-01-09 14:39 UTC (permalink / raw
  To: Freaky; +Cc: alsa-devel

On Tue, 09 Jan 2018 15:16:38 +0100,
Freaky wrote:
> 
> Hi Takashi,
> 
> what exactly do you need us to test?
> 
> Running just:
> hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DATA 0x06
> doesn't produce sound on the headphones.
> 
> After running
> hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_MASK 0x0e
> hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DIRECTION 0x0e
> 
> It starts producing sound.
> 
> After replugging sound is gone. Only have to run the first one again to
> have sound again, the other 2 are no longer required then.
> 
> Tried, after executing all 3 commands, to replug and then use
> hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DATA XX
> 
> where XX
> 0x00 doesn't work
> 0x01 doesn't work
> 0x02 doesn't work
> 0x04 works
> 0x06 works
> 0x08 doesn't work
> 
> What's also somewhat odd, we run X as a user (auto logon). If I switch to
> console before there was any audio playing and execute:
> hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DATA 0x06
> hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_MASK 0x0e
> hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DIRECTION 0x0e

Both headphone and speaker outputs are controlled with different amps,
so test them individually.

And, does GPIO mask and direction need to be 0x0e, not 0x06?

So, try at first:
 hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_MASK 0x06
 hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DIR 0x06
 hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DATA 0x06

If this makes both speaker and headphone working, go to the next step.
Keep the following but change the data bits either 0x02 or 0x04:

 hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_MASK 0x06
 hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DIR 0x06
 hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DATA 0x02

and test whether the headphone and/or the speaker works.

Again with 0x04,

 hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DATA 0x04

test whether the headphone and/or the speaker works.

You might need to adjust the whole GPIO setup at each time you
plug/unplug the jack.  Check /proc/asound/card0/codec#0 output whether
the GPIO values are kept as expected before testing.

If it's confirmed that both the GPIO bit 0x02 and 0x04 (or vice versa)
correspond to the headphone and the speaker amps, I can cook up the
patch to add quirk easily.


thanks,

Takashi

> and switch back, start playing audio, there's no sound on the headphone.
> I'll need to run them again. This might be related to pulseaudio however.
> Just running the first command again doesn't suffice in that case. After
> audio has been on the headphones once, in all my tests so far, only the
> first command does suffice to get it working again and the 0x04 value then
> also works.
> 
> Any other values, order of commands, etc. you'd like us to test?
> 
> Thanks for the help so far :).
> 
> Kind regards,
> 
> On Thu, Jan 4, 2018 at 5:35 PM, Takashi Iwai <tiwai@suse.de> wrote:
> 
> > On Thu, 04 Jan 2018 17:27:55 +0100,
> > Freaky wrote:
> > >
> > > Hi Takashi,
> > >
> > > we need it to get the headphone output working. Upon unplugging /
> > > replugging we need to check them again (they remain checked, but the
> > output
> > > stops working). The speaker output (onboard speakers) works fine and the
> > > script we run doesn't appear to have any effect on the speaker output at
> > > all.
> >
> > The alsa-info.sh output showed that GPIO[1] is also set, so I wonder
> > how and who sets it.  In anyway, could you check whether flipping any
> > such gpio bits turn on / off the headphone and the speaker outputs?
> > Try to toggle it while playing back, such as,
> >         hda-verb /dev/snd/hwC1D0 0x01 SET_GPIO_DATA xxx
> > where xxx is the value to be written (0x00, 0x02, 0x04, 0x06, etc).
> >
> > > Currently use a python script generated by the HDA Analyzer script that
> > we
> > > run every 5 seconds from boot. Pasted the script below. We run it every 5
> > > seconds to ensure audio will work after replugging the headphones
> > (although
> > > it might incur a small delay then of course). I don't notice any hick-ups
> > > in audio playback because of the script firing every 5 seconds.
> > >
> > > There's no acpid running from which we could detect the plug event.
> > Using a
> > > system based on Fedora 24. Have watched dbus-monitor (--sytem), but see
> > no
> > > events there upon (un)plugging the headphones which we could use as
> > trigger.
> >
> > The headphone jack detection on HD-audio is usually done via HD-audio
> > codec unsolicited events.  You can check "Headphone Jack" ALSA control
> > element (e.g. watch the output of "amixer contents").
> >
> >
> > Takashi
> >
> [2  <text/html; UTF-8 (quoted-printable)>]
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Headphone issues iMac 14.1 (A1418)
       [not found]           ` <CAEw6Zyus0Aad0qvnN9a2xMY28=ADK5h244vG0wkeR+eCE7bedQ@mail.gmail.com>
@ 2018-01-09 16:30             ` Takashi Iwai
       [not found]               ` <CAEw6ZyuMxi4gF9HNCq3nYUADrH8QiPkJKNWW5VQ8JNs2nWaKeQ@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2018-01-09 16:30 UTC (permalink / raw
  To: Freaky; +Cc: alsa-devel

On Tue, 09 Jan 2018 16:40:09 +0100,
Freaky wrote:
> 
> Hi,
> 
> the speaker is always working on this Mac, whilst the headphone is
> unplugged that is, haven't gotten it to not function. That said, the
> unplug/plug events switch data I/O flags and unplugging the headphones
> correctly enables the speakers voiding anything I had done with hda-verb.
> 
> I'm not sure what the parameters do btw :). I understand the last parameter
> is some value being written and that it's probably a bunch of binary flags,
> but have little clue on what they exactly do.
> 
> >From flipping flags and looking at the alsa-info.sh it seems that each bit
> corresponds to a data I/O channel. 0x1 being IO[0], 0x2 IO[1], 0x4 IO[2],
> 0x8 IO[3].
> 
> When IO[3]'s data=1 there's audio on the speakers (0x8)
> So we wrote
> 0x0 and verified alsa-info, all data IO's are disabled. Audio is gone.
> Wrote 0x8, enabling bit 4, which flipped IO[3]'s data back to 1 and we have
> audio on speaker. I presume that makes it safe to assume IO[3] is the Amp
> for speaker.
> 
> Plugged the headphone and looked at alsa-info.
> Now IO[1]'s data is enabled and that seems to be where it goes wrong. wrote
> 0x0 ensuring all IO's data are disabled (checked headphones - no sound
> obviously) and then 0x4 which enabled only IO[2]'s data and there's audio
> again. I presume IO[2] is the Amp for the headphones thus.
> 
> Using only 0x4 works as well thus. I have no clue if there are any Amps
> behind IO[0] and IO[1] and if so where they would be heading I'm afraid.
> The driver enables IO[1]'s data upon plugging the headphone, which should
> be IO[2]'s data on this system and unplugging enabled IO[3]'s data. That
> might also be why I never have seen it as broken as I need to unplug the
> headphone first, which switches flags correctly for the speaker output.
> 
> Plugging / unplugging doesn't seem to have any effect on the other flags
> required (direction and enabled). However, they do need to be set initially
> and in an earlier test, when booted with the headphone already plugged and
> then enabling them before any audio was played audio still didn't work.
> Needed to enable them again. Perhaps pulse did something with the flags
> then though (restoring the state at first audio playback or something). I
> can test this if desired. Plugging/unplugging the headphones doesn't seem
> to affect any of the IO's direction nor enabled flags, they remain the same
> as they were.

OK, so this looks like the gpio 2/3 case, and it corresponds to
imac27_122 model.

Could you try to add the model option like below?  Create a module
config file, e.g. /etc/modprobe.d/50-hda.conf containing:

options snd-hda-intel model=,imac27_122

(Note the comma before imac27_122, it's no typo, but indicates to
 specify the second device -- where Haswell gives the HDMI/DP
 controller for the first PCI device while the second one is the
 analog I/O).

If this works, the patch like below should work without the model
option above.


Takashi

---
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 80bbadc83721..17660d03a314 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -408,6 +408,7 @@ static const struct snd_pci_quirk cs420x_fixup_tbl[] = {
 	/*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/
 
 	/* codec SSID */
+	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),

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: Headphone issues iMac 14.1 (A1418)
       [not found]               ` <CAEw6ZyuMxi4gF9HNCq3nYUADrH8QiPkJKNWW5VQ8JNs2nWaKeQ@mail.gmail.com>
@ 2018-01-10 10:14                 ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2018-01-10 10:14 UTC (permalink / raw
  To: Freaky; +Cc: alsa-devel

On Wed, 10 Jan 2018 09:46:27 +0100,
Freaky wrote:
> 
> Sorry, forgot to ask, is the patch going to be included upstream and/or
> would you like us to test it?

The official patch is below and I queued it now.
It'll be likely included in 4.15-final after rc8.


thanks,

Takashi

-- 8< --
From: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH] ALSA: hda - Apply the existing quirk to iMac 14,1

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.

BugLink: http://lkml.kernel.org/r/CAEw6Zyteav09VGHRfD5QwsfuWv5a43r0tFBNbfcHXoNrxVz7ew@mail.gmail.com
Reported-by: Freaky <freaky2000@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/patch_cirrus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 80bbadc83721..d6e079f4ec09 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -408,6 +408,7 @@ static const struct snd_pci_quirk cs420x_fixup_tbl[] = {
 	/*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/
 
 	/* codec SSID */
+	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),
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-01-10 10:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-03 10:39 Headphone issues iMac 14.1 (A1418) Freaky
2018-01-04 14:48 ` Takashi Iwai
     [not found]   ` <CAEw6ZysYDerXhZZnBbLu3EzEOOqTdvE-dzq9_pLdcQNzS02_1g@mail.gmail.com>
2018-01-04 16:35     ` Takashi Iwai
     [not found]       ` <CAEw6Zyszryna_596a0jM_0Rez9BrN5Zs21GE2BxwGFu5hhVz4Q@mail.gmail.com>
2018-01-09 14:39         ` Takashi Iwai
     [not found]           ` <CAEw6Zyus0Aad0qvnN9a2xMY28=ADK5h244vG0wkeR+eCE7bedQ@mail.gmail.com>
2018-01-09 16:30             ` Takashi Iwai
     [not found]               ` <CAEw6ZyuMxi4gF9HNCq3nYUADrH8QiPkJKNWW5VQ8JNs2nWaKeQ@mail.gmail.com>
2018-01-10 10:14                 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.