Opened 14 months ago

Last modified 7 weeks ago

#14242 new bug

Intel HDA driver: no sound, broken preferences on Thinkpad X220

Reported by: tidux Owned by: korli
Priority: normal Milestone: R1/beta2
Component: Drivers/Audio/HDA Version: R1/Development
Keywords: Cc: ttcoder
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

The sound is known working on this laptop under both Windows 10 and Linux, and was not in a muted state before booting in to Haiku. This is a fresh boot of live media. The headphone channel is not in fact outputting sound to the headphones despite the UI suggesting it will.

~> uname -a Haiku shredder 1 hrev52060 Jul 3 2018 17:02:37 x86_64 x86_64 Haiku

See attached screenshot for the display errors in Media Preferences.

Attachments (7)

broken_hda_x220.png (32.4 KB ) - added by tidux 14 months ago.
screenshot of issue
syslog (189.5 KB ) - added by tidux 14 months ago.
syslog with working sound, broken prefs UI
dmesg_hda.log (924 bytes ) - added by tidux 10 months ago.
dmesg output
lspci.log (10.6 KB ) - added by tidux 10 months ago.
linux lspci -vvv
x220_driver_pin_configs (48 bytes ) - added by tidux 9 months ago.
x220_trace (1.3 KB ) - added by tidux 9 months ago.
hda_trace_reconfig.txt (355.6 KB ) - added by tidux 9 months ago.
Trace of reconfiguring codec, starting pulseaudio again, and beginning audio playback.

Download all attachments as: .zip

Change History (28)

by tidux, 14 months ago

Attachment: broken_hda_x220.png added

screenshot of issue

comment:1 by waddlesplash, 14 months ago

Please attach a syslog.

comment:2 by waddlesplash, 14 months ago

Oh, and try warm-rebooting from Linux. Sometimes HDA works in that state.

by tidux, 14 months ago

Attachment: syslog added

syslog with working sound, broken prefs UI

comment:3 by tidux, 14 months ago

Warm-booting from Linux allowed sound to work, but the Media Preferences GUI for the HDA device is still broken in the same manner as before. See attached syslog. If warm-booting from Linux works but cold boot does not, this suggests the driver is not initializing the hardware correctly.

comment:4 by waddlesplash, 13 months ago

korli: if you could try to investigate some of these HDA issues before beta1, that would be excellent...

comment:5 by tidux, 11 months ago

Still present in Beta 1. It looks like the channels are being mapped as inputs when they're outputs or vice versa. Looking at the Linux kernel code for the HDA driver and eyeballing the comparison it looks like there's a lot more work going into device initialization on the Linux side... and this laptop's sound works on Linux. Might be a place to look.

comment:6 by ttcoder, 10 months ago

@tidux I'm working on #14581 , which has the very same internals (if not quite the same vendor/id), including the same "widget IDs" and so on.

Does Linux produce some sort of "syslog" like Haiku, and if so could you attach it here (or ask me for my email addy if you'd rather send off-ticket). That could be a life saver.

Also what do you mean by " It looks like the channels are being mapped as inputs when they're outputs or vice versa.". Is that something you see in Media Prefs, or in the sylog, or somewhere else ?

Thanks

/me prepares to look up the linux code on github, but would rather do that only if all else fails

Last edited 10 months ago by ttcoder (previous) (diff)

comment:7 by pulkomandy, 10 months ago

Milestone: UnscheduledR1/beta2

comment:8 by tidux, 10 months ago

Here's all the output of Linux dmesg (kernel messages) generated by the HDA driver, and "lspci -vvv" output.

by tidux, 10 months ago

Attachment: dmesg_hda.log added

dmesg output

by tidux, 10 months ago

Attachment: lspci.log added

linux lspci -vvv

comment:10 by ttcoder, 10 months ago

@tidux Let's go straight for better tracing options; with some luck it will be like a cheat sheet, leading to a fairly quick fix.

I've found this page https://www.kernel.org/doc/html/latest/sound/hd-audio/notes.html. It mentions a few hints. Here's those that seem most interesting to me; the first one might not be so easy, if so proceed to the next ones:

In general, I recommend you to enable the sound debug option,
CONFIG_SND_DEBUG=y, no matter whether you are debugging or not. This enables snd_printd() macro and others,
and you’ll get additional kernel messages at probing.

(those seem to be C++ defines, meaning you need to recompile the linux driver ?)

Seems it's possible to get pin configs directly from terminal; unfortunately the init_verbs can probably not get retrieved, but pin configs might be interesting anyway:

The following sysfs files are available under each codec-hwdep
device directory (e.g. /sys/class/sound/hwC0D0):
 (..)
driver_pin_configs: Shows the pin default values set by the codec
parser explicitly. This doesn’t show all pin values but only the changed values by the parser.

The document mentions "hwC0D0" in the path, whereas your dmesg output mentions "hdaudioC0D0". So some adapting might be needed. Anyway presumably you would retrieve the data by typing something like this in a terminal/xterm:

cat /sys/class/sound/hwC0D0/driver_pin_configs

This is the tracing that seems most hopeful to me:

The hd-audio driver gives a few basic tracepoints. hda:hda_send_cmd traces each CORB write (..)

Enabling all tracepoints can be done like
# echo 1 > /sys/kernel/debug/tracing/events/hda/enable

then after some commands, you can [get] traces from /sys/kernel/debug/tracing/trace file

I likely can decode the output by hand, the "hda-decode-verb" stuff mentionned below might not be necessary.

I wonder if it retro-actively includes tracing produced by the hda driver during boot-up though. If it does not, maybe it's possible to trigger a re-init of the driver, by hand, using the "reconfig" trick described in the document, after activating tracing.

Last edited 10 months ago by ttcoder (previous) (diff)

comment:11 by tidux, 10 months ago

CONFIG_SND_DEBUG=y is a kernel configuration option (from the Kconfig file, can be set graphically via "make menuconfig" at build time) and would require rebuilding the kernel. I'll check the other stuff later today when I have access to the machine.

comment:12 by ttcoder, 10 months ago

Thanks tidux, appreciated. As soon as I get your data I'll report on my findings (either in your ticket or mine) as before.

Last edited 10 months ago by ttcoder (previous) (diff)

by tidux, 9 months ago

Attachment: x220_driver_pin_configs added

by tidux, 9 months ago

Attachment: x220_trace added

comment:13 by tidux, 9 months ago

Uploads delayed by Trac outage. Here you go.

comment:14 by tidux, 9 months ago

Bumping ticket since Trac email notifications were broken earlier today, thanks waddlesplash for the fix.

comment:15 by ttcoder, 9 months ago

Testing to see if I can get past the horrid captchas..

Edit: I've had to solve 20 catpchas to post (in Web+), dang it.

Anyway, even though the above is only four HDA verbs, that gave me enough to work with for a couple days, to "retool". Confirmed that implementing just those 4 verbs in haiku is not enough to get audio working. Now I'm ready for the full thing :-)

In other words,

You should type both those lines in terminal:

echo 1 > /sys/kernel/debug/tracing/events/hda/enable
echo 1 > /sys/class/sound/hwC0D0/reconfig

That will trigger a (second) reconfiguration *after* tracing-logging is enabled, so that the log will contain the whole initialization sequence.

The log should then contain many more than four verbs, it should be a flood comparable to this (partial) Haiku listing:

Welcome to the Haiku shell.

/boot/system/var/log> grep hda-verb syslog
KERN: hda: widgets: KERN:   hda-verb       <0x010a0000>:  [0] nid 0x10 (16) : pload 0x0   vid 0xa0000 (VID_GET_CONVERTER_FORMAT)
KERN:   hda-verb       <0x01420811>:  [0] nid 0x14 (20) : pload 0x811   vid 0x20000 (VID_SET_CONVERTER_FORMAT)
KERN:   hda-verb       <0x01470620>:  [0] nid 0x14 (20) : pload 0x20   vid 0x70600 (VID_SET_CONVERTER_STREAM_CHANNEL)
KERN: 20   hda-verb       <0x010a0000>:  [0] nid 0x10 (16) : pload 0x0   vid 0xa0000 (VID_GET_CONVERTER_FORMAT)
KERN:   hda-verb       <0x01520811>:  [0] nid 0x15 (21) : pload 0x811   vid 0x20000 (VID_SET_CONVERTER_FORMAT)
KERN:   hda-verb       <0x01570620>:  [0] nid 0x15 (21) : pload 0x20   vid 0x70600 (VID_SET_CONVERTER_STREAM_CHANNEL)
KERN: hda: widgets: KERN:   hda-verb       <0x010a0000>:  [0] nid 0x10 (16) : pload 0x0   vid 0xa0000 (VID_GET_CONVERTER_FORMAT)
KERN:   hda-verb       <0x01024011>:  [0] nid 0x10 (16) : pload 0x4011   vid 0x20000 (VID_SET_CONVERTER_FORMAT)
KERN:   hda-verb       <0x01070610>:  [0] nid 0x10 (16) : pload 0x10   vid 0x70600 (VID_SET_CONVERTER_STREAM_CHANNEL)
KERN: hda: widgets: KERN:   hda-verb       <0x010a0000>:  [0] nid 0x10 (16) : pload 0x0   vid 0xa0000 (VID_GET_CONVERTER_FORMAT)
KERN:   hda-verb       <0x01420811>:  [0] nid 0x14 (20) : pload 0x811   vid 0x20000 (VID_SET_CONVERTER_FORMAT)
KERN:   hda-verb       <0x01470620>:  [0] nid 0x14 (20) : pload 0x20   vid 0x70600 (VID_SET_CONVERTER_STREAM_CHANNEL)
KERN: 20   hda-verb       <0x010a0000>:  [0] nid 0x10 (16) : pload 0x0   vid 0xa0000 (VID_GET_CONVERTER_FORMAT)
KERN:   hda-verb       <0x01520811>:  [0] nid 0x15 (21) : pload 0x811   vid 0x20000 (VID_SET_CONVERTER_FORMAT)
KERN:   hda-verb       <0x01570620>:  [0] nid 0x15 (21) : pload 0x20   vid 0x70600 (VID_SET_CONVERTER_STREAM_CHANNEL)
KERN:   hda-verb       <0x010ba000>:  [0] nid 0x10 (16) : pload 0xa000   vid 0xb0000 (VID_GET_AMPLIFIER_GAIN_MUTE)
KERN:   hda-verb       <0x010b8000>:  [0] nid 0x10 (16) : pload 0x8000   vid 0xb0000 (VID_GET_AMPLIFIER_GAIN_MUTE)
KERN:   hda-verb       <0x0103a04a>:  [0] nid 0x10 (16) : pload 0xa04a   vid 0x30000 (VID_SET_AMPLIFIER_GAIN_MUTE)
KERN:   hda-verb       <0x0103904a>:  [0] nid 0x10 (16) : pload 0x904a   vid 0x30000 (VID_SET_AMPLIFIER_GAIN_MUTE)
KERN:   hda-verb       <0x010ba000>:  [0] nid 0x10 (16) : pload 0xa000   vid 0xb0000 (VID_GET_AMPLIFIER_GAIN_MUTE)

Then I'll ruthlessly adapt my code to match your log line-for-line. Thanks!

Last edited 9 months ago by ttcoder (previous) (diff)

comment:16 by ttcoder, 9 months ago

A quick drive-by "ping", just in case the bulk of the message above was missed (being edited after the fact and what-not...) Seems today I can post to tickets again without being mauled by captchas though, nice!

comment:17 by ttcoder, 9 months ago

Cc: ttcoder added

by tidux, 9 months ago

Attachment: hda_trace_reconfig.txt added

Trace of reconfiguring codec, starting pulseaudio again, and beginning audio playback.

comment:18 by tidux, 9 months ago

Full trace added.

comment:19 by ttcoder, 9 months ago

@tidux please see ticket:14581#comment:10

comment:20 by waddlesplash, 7 months ago

FWIW, the media preferences brokenness is tracked as #9430.

comment:21 by tidux, 7 weeks ago

The media preferences window layout is fixed, but channels are still mapped incorrectly on cold boot as of hrev53233 x86_gcc2hybrid.

Note: See TracTickets for help on using tickets.