Add proper USB audio support for Lenovo ThinkStation P620

Bug #1891461 reported by Kai-Heng Feng on 2020-08-13
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
HWE Next
Undecided
Unassigned
alsa-lib (Ubuntu)
High
Kai-Heng Feng
Focal
Undecided
Kai-Heng Feng
Groovy
High
Kai-Heng Feng
alsa-ucm-conf (Ubuntu)
High
Kai-Heng Feng
Focal
Undecided
Kai-Heng Feng
Groovy
High
Kai-Heng Feng
pulseaudio (Ubuntu)
Medium
Kai-Heng Feng
Focal
Medium
Kai-Heng Feng
Groovy
Medium
Kai-Heng Feng

Bug Description

[Impact]
Lenovo ThinkStation P620 uses TRX4 board, which doesn't have PCI audio in its chipset. Instead, it's equipped with two USB audio devices, "Main", which is for internal speaker and front headset, and "Rear", which is for rear panel I/Os.

However, both USB audio don't really work out of the box. Issues and fixes will be described together below.

[Fix for alsa-lib]
1) Both USB audio devices don't have S/PDIF port, so we need to disable them:
https://git.alsa-project.org/?p=alsa-lib.git;a=commit;h=464c2f8b61855cb22d61c4b232f74d6767fac5fb

[Fix for alsa-ucm-conf]
2) PulseAudio doesn't assign the correct stream for "Main" device, audio output stays at "Speaker" after "Headset" is selected. So we need UCM to let PulseAudio understand correct stream assignment.
In addition to that, in order to not let headset port availability invalidate speaker profile, we need two UCM profiles to separate "Speaker" and "Headset" logically:
https://github.com/alsa-project/alsa-ucm-conf/pull/42

[Fix for PulseAudio]
3) USB audio devices, UAC v2 and v3, support jack detection (insertion control). However, PulseAudio doesn't monitor USB jack mixer controls, so jack detection doesn't work at userspace level. We need to let PulseAudio be aware those jacks:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/e153fb870618b1dcf65f6fce1667ea76acc5a28b

4) When a headset gets plugged, PulseAudio switches the profile from "Speaker" to "Headset" automatically. However, when headset gets unplugged, PulseAudio switch the profile from "Headset" to "HDMI", skipping the "Speaker" profile. We need to fix priorities for profiles that are created from UCM to avoid the problem:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/dd70c3c5890ce27b9ba4bd041dea4a01c3e1fc0f

[Test]
Under g-c-c's Sound tab, "Speaker", "Headphone", "S/PDIF", etc. profiles are all selectable. Sound comes out from speaker even if "Headphone" is chosen. Microphone is already selected though there's no microphone plugged.

With the above fix all applied, open Gnome Control Center -> Sound tab.
Sink "Speaker" is selected. Only "Speaker" and "HDMI" are in the drop down menu.
Plug a headset to front port, "Headphone" and "Microphone" appears and automatically becomes default. Unplug the headset, sink switches back to "Speaker", and source switches to none.
Plug line-in, line-out and microphone to the rear panel, jack detection works for all three ports, and they all work correctly. Unplug rear line-in, line-out or microphone makes the option in dropdown menu disappears.

On other systems, nothing changed.

[Regression Potential]
For fix 1) and 2), The UCM in alsa-lib and alsa-ucm-conf strictly match kernel provided profile name, so no other device will be affected.

For fix 3), if there are UAC v2/v3 devices claim to support jack detection but don't really support it, this will make the PulseAudio consider its availability to "no".
AFAIK, the USB audios that have jack ports are mostly docking stations, which already have their own UCM profiles or PulseAudio profile-sets, so they are unaffected by this change.
If we ever see this kind of regression, the proper fix is to disable jack detection from kernel side.

For fix 4), if user depends on the old behavior (i.e. switch to another card while other profiles are still available), this will bring a behavioral change. However, all available profiles will still be available after the fix, so users can still be chose the preferred profile from the g-c-c dropdown menu.

Daniel van Vugt (vanvugt) wrote :

Obviously more information is required :)

Changed in alsa-lib (Ubuntu):
status: New → Incomplete
Changed in alsa-ucm-conf (Ubuntu):
status: New → Incomplete
Changed in pulseaudio (Ubuntu):
status: New → Incomplete
Daniel van Vugt (vanvugt) wrote :

... because USB audio should work already. If something doesn't work then please describe that.

Kai-Heng Feng (kaihengfeng) wrote :

PulseAudio debdiff for groovy

description: updated
Kai-Heng Feng (kaihengfeng) wrote :

PulseAudio debdiff for focal

Kai-Heng Feng (kaihengfeng) wrote :

Hit LP: #1891518 so I can't upload more debdiff...

The attachment "pulseaudio_13.99.1-1ubuntu9.debdiff" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]

tags: added: patch
Changed in pulseaudio (Ubuntu Focal):
status: New → In Progress
Changed in pulseaudio (Ubuntu Groovy):
status: Incomplete → In Progress
Changed in pulseaudio (Ubuntu Focal):
assignee: nobody → Kai-Heng Feng (kaihengfeng)
Changed in pulseaudio (Ubuntu Groovy):
assignee: nobody → Kai-Heng Feng (kaihengfeng)
Daniel van Vugt (vanvugt) wrote :

Please remove pulseaudio_13.99.1-1ubuntu9.debdiff from comment #3 because that version already exists. And create a new version 13.99.1-1ubuntu10 rebased on:

https://git.launchpad.net/~ubuntu-audio-dev/pulseaudio/log/
https://launchpad.net/ubuntu/+source/pulseaudio/1:13.99.1-1ubuntu9

Daniel van Vugt (vanvugt) wrote :

Please also remember to commit to git early. You should have full access...

https://git.launchpad.net/~ubuntu-audio-dev/pulseaudio/log/?h=ubuntu-focal

tags: added: focal groovy
Changed in pulseaudio (Ubuntu Focal):
importance: Undecided → Medium
Changed in pulseaudio (Ubuntu Groovy):
importance: Undecided → Medium
Changed in alsa-lib (Ubuntu Groovy):
status: Incomplete → New
Changed in alsa-ucm-conf (Ubuntu Groovy):
status: Incomplete → New
Daniel van Vugt (vanvugt) wrote :

Repository can be accessed via:

git://git.launchpad.net/~ubuntu-audio-dev/pulseaudio
git+ssh://git.launchpad.net/~ubuntu-audio-dev/pulseaudio
https://git.launchpad.net/~ubuntu-audio-dev/pulseaudio

Kai-Heng Feng (kaihengfeng) wrote :

Thanks. Rebased and pushed.

However, I can't attach the debdiff here because I am still hitting Launchpad Oops - LP: #1891518.

Kai-Heng Feng (kaihengfeng) wrote :

How do we proceed with alsa-lib and alsa-ucm-conf? Since I can't attach debdiff now...

Daniel van Vugt (vanvugt) wrote :

If the problem doesn't fix itself by next week I say report a bug against Launchpad:
https://bugs.launchpad.net/launchpad

Kai-Heng Feng (kaihengfeng) wrote :

I did... LP: #1891518.

Kai-Heng Feng (kaihengfeng) wrote :

alsa-lib debdiff for groovy

Kai-Heng Feng (kaihengfeng) wrote :

alsa-lib debdiff for focal

Kai-Heng Feng (kaihengfeng) wrote :

alsa-ucm-conf debdiff for groovy

Kai-Heng Feng (kaihengfeng) wrote :

alsa-ucm-conf debdiff for focal

tags: added: originate-from-1887127 originate-from-1887878 sutton
Changed in alsa-ucm-conf (Ubuntu Groovy):
importance: Undecided → High
status: New → Fix Committed
assignee: nobody → Kai-Heng Feng (kaihengfeng)
Changed in alsa-lib (Ubuntu Groovy):
assignee: nobody → Kai-Heng Feng (kaihengfeng)
importance: Undecided → High
status: New → Fix Committed
Changed in pulseaudio (Ubuntu Groovy):
status: In Progress → Fix Committed
Changed in alsa-lib (Ubuntu Focal):
assignee: nobody → Kai-Heng Feng (kaihengfeng)
Changed in alsa-ucm-conf (Ubuntu Focal):
assignee: nobody → Kai-Heng Feng (kaihengfeng)
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package alsa-ucm-conf - 1.2.2-1ubuntu3

---------------
alsa-ucm-conf (1.2.2-1ubuntu3) groovy; urgency=medium

  * d/p/0001-Add-support-for-Lenovo-ThinkStation-P620-Main-Audio.patch
    Add proper stream and jack assignment to Lenovo ThinkStation P620
    (LP: #1891461)

 -- Kai-Heng Feng <email address hidden> Tue, 18 Aug 2020 17:39:15 +0800

Changed in alsa-ucm-conf (Ubuntu Groovy):
status: Fix Committed → Fix Released
Changed in alsa-lib (Ubuntu Focal):
status: New → Fix Committed
Changed in alsa-ucm-conf (Ubuntu Focal):
status: New → Fix Committed
Changed in pulseaudio (Ubuntu Focal):
status: In Progress → Fix Committed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pulseaudio - 1:13.99.1-1ubuntu10

---------------
pulseaudio (1:13.99.1-1ubuntu10) groovy; urgency=medium

  * d/p/0001-alsa-mixer-Recognize-USB-audio-jack-mixer.patch:
    - recognize USB jack mixer to support jack detection (LP: #1891461)
  * d/p/0002-module-alsa-card-Set-a-minimum-profile-priority-if-i.patch:
    - resolve an issue when headset gets unplugged, HDMI audio is chosen
      instead of internal speaker (LP: #1891461)

 -- Kai-Heng Feng <email address hidden> Thu, 13 Aug 2020 16:58:42 +0800

Changed in pulseaudio (Ubuntu Groovy):
status: Fix Committed → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package alsa-lib - 1.2.2-2.3ubuntu3

---------------
alsa-lib (1.2.2-2.3ubuntu3) groovy; urgency=medium

  * d/p/0001-conf-USB-Audio-Disable-IEC958-on-Lenovo-ThinkStation.patch
    - Disable IEC958 on Lenovo ThinkStation P620 (LP: #1891461)

 -- Kai-Heng Feng <email address hidden> Thu, 13 Aug 2020 22:54:44 +0800

Changed in alsa-lib (Ubuntu Groovy):
status: Fix Committed → Fix Released

Hello Kai-Heng, or anyone else affected,

Accepted alsa-lib into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/alsa-lib/1.2.2-2.1ubuntu2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

tags: added: verification-needed verification-needed-focal
Łukasz Zemczak (sil2100) wrote :

Hello Kai-Heng, or anyone else affected,

Accepted alsa-ucm-conf into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/alsa-ucm-conf/1.2.2-1ubuntu0.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Łukasz Zemczak (sil2100) wrote :

Hello Kai-Heng, or anyone else affected,

Accepted pulseaudio into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/pulseaudio/1:13.99.1-1ubuntu3.6 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

All autopkgtests for the newly accepted alsa-lib (1.2.2-2.1ubuntu2) for focal have finished running.
The following regressions have been reported in tests triggered by the package:

asterisk/1:16.2.1~dfsg-2ubuntu1 (armhf)
gsequencer/3.1.3-1 (s390x)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/focal/update_excuses.html#alsa-lib

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Kai-Heng Feng (kaihengfeng) wrote :

Open GNOME Control Center's sound tab:
- USB Speaker is picked by default.
- USB Headphone and USB Mic was automatically picked as soon as headset is plugged.
- Automatically switch back to USB Speaker when headset is unplugged.
- No useless S/PDIF profile listed.
- Jack detection works on both front panel and rear panel.

tags: added: verification-done verification-done-focal
removed: verification-needed verification-needed-focal
Kai-Heng Feng (kaihengfeng) wrote :

autopkgtests regression isn't triggered by this SRU, alsa-lib only put the device in to S/PDIF blacklist, not behavioral change.

Launchpad Janitor (janitor) wrote :
Download full text (3.5 KiB)

This bug was fixed in the package alsa-lib - 1.2.2-2.1ubuntu2

---------------
alsa-lib (1.2.2-2.1ubuntu2) focal; urgency=medium

  * d/p/0001-conf-add-snd_config_is_array-function.patch
  * d/p/0001-Enabled-extended-namehints-in-alsa.conf.patch
  * d/p/0002-topology-use-snd_config_is_array-function.patch
  * d/p/0003-ucm-merge-the-array-items-from-the-condition-blocks.patch
  * d/p/0004-ucm-parse-SectionOnce-section-in-the-master-UCM-conf.patch
  * d/p/0005-ucm-execute-SectionDefaults-lately-when-the-first-ve.patch
  * d/p/0006-ucm-handle-set-_once-command.patch
  * d/p/0007-ucm-handle-set-_defaults-command.patch
  * d/p/0008-ucm-initialize-mgr-once_list.patch
  * d/p/0009-ucm-fix-SectionOnce-comment.patch
  * d/p/0010-ucm-fix-compilation-error-in-set_defaults_user.patch
  * d/p/0011-ucm-rename-SectionOnce-to-BootSequence.patch
  * d/p/0012-ucm-rename-_once-command-to-_boot-command.patch
  * d/p/0013-ucm-configuration-implement-in-place-Include.patch
  * d/p/0014-ucm-configuration-substitute-ConfDir-and-ConfTopDir.patch
  * d/p/0015-ucm-config-substitute-File-string-to-allow-variables.patch
  * d/p/0016-ucm-configuration-allow-to-define-the-configuration-.patch
  * d/p/0017-ucm-configuration-add-DefineRegex.patch
  * d/p/0018-ucm-substitute-arguments-in-sequences.patch
  * d/p/0019-ucm-allow-syntax-version-3.patch
  * d/p/0020-ucm-config-change-the-in-place-include-evaluation-or.patch
  * d/p/0021-ucm-allow-to-specify-the-toplevel-directory-using-as.patch
  * d/p/0022-ucm-substitute-also-value-strings.patch
  * d/p/0023-ucm-handle-strict-prefix-correctly-for-the-UCM-card-.patch
  * d/p/0024-ucm-String-condition-implement-Empty.patch
  * d/p/0025-ucm-Define-DefineRegex-is-supported-in-Syntax-3.patch
  * d/p/0026-ucm-substitute-OpenName.patch
  * d/p/0027-ucm-substitute-CardNumber.patch
  * d/p/0028-ucm-implement-the-toplevel-ucm-configuration-file-pa.patch
  * d/p/0029-ucm-substitute-device-modifier-names-too.patch
  * d/p/0030-ucm-substitute-device-strings-in-the-device-lists.patch
  * d/p/0031-ucm-substitute-component-sequence-string.patch
  * d/p/0032-ucm-substitute-verb-name-and-file-field.patch
  * d/p/0033-ucm-substitute-Comment-in-Transition-and-Device.patch
  * d/p/0034-ucm-substitute-RenameDevice-and-DeleteDevice-lists.patch
  * d/p/0035-ucm-substitute-arguments-in-sequences-only-for-synta.patch
  * d/p/0036-ucm-shuffle-code-in-compound_merge.patch
  * d/p/0037-ucm-implement-CardIdByName-substitution.patch
  * d/p/0038-ucm-allow-to-ignore-errors-for-the-value-substitutio.patch
  * d/p/0039-ucm-allow-to-use-the-defined-variables-in-the-substi.patch
  * d/p/0040-ucm-implement-CardNumberByName-substitution.patch
  * d/p/0041-ucm-fix-the-possible-buffer-overflow-substitution.patch
  * d/p/0042-ucm-simplify-get_by_card-in-parser.c.patch
  * d/p/0043-ucm-implement-AlwaysTrue-Condition.Type.patch
  * d/p/0044-ucm-Allow-empty-strings-in-var-.-substitutions.patch
  * d/p/0045-ucm-substitution-remove-duplicate-allow_empty-assign.patch
  * d/p/0046-ucm-fix-parse_get_safe_name-safe-name-must-be-checke.patch
  * d/p/0047-ucm-substitute-the-merged-tree-completely.patch
  * add Breaks alsa-ucm-conf (<= 1.2.2-1ubuntu0.1) in the d/control
  * add snd...

Read more...

Changed in alsa-lib (Ubuntu Focal):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for alsa-lib has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package alsa-ucm-conf - 1.2.2-1ubuntu0.2

---------------
alsa-ucm-conf (1.2.2-1ubuntu0.2) focal; urgency=medium

  * d/p/0003-ucm-fix-wrong-If-in-sequence-in-HiFi-dual.conf.patch
  * d/p/0004-ucm2-add-initial-ucm.conf-for-the-latest-alsa-lib.patch
  * d/p/0005-sof-hda-dsp-don-t-fail-if-Auto-Mute-control-is-not-p.patch
  * d/p/0006-ucm.conf-add-support-for-the-kernel-module-name-tree.patch
  * d/p/0007-sof-hda-dsp-make-Headphone-Playback-Switch-condition.patch
  * d/p/0008-sof-soundwire-initial-UCM2-version.patch
  * d/p/0009-sof-soundwire-cleanups-recommended-by-the-ucm-valida.patch
  * d/p/0010-sof-soundwire-rewrite-for-syntax-3.patch
  * d/p/0011-HDA-Intel-add-support-for-AMD-acp-microphone-devices.patch
  * d/p/0012-hda-hdmi-add-HDMI4-HDMI5-HDMI6-devices.patch
  * d/p/0013-amd-renoir-acp-use-the-machine-driver-s-name-for-top.patch
  * d/p/0014-amd-renoir-acp-add-syntax-in-the-Linked.patch
  * d/p/0015-HDA-Intel-only-bind-the-acp-dmic-to-the-soundcard-wi.patch
  * d/p/0016-Fix-invalid-Regex-Type-in-various-Condition-blocks.patch
    enable sound on AMD Renoir machines (LP: #1889217)

  [ Kai-Heng Feng ]
  * d/p/0017-Add-support-for-Lenovo-ThinkStation-P620-Main-Audio.patch
    Add proper stream and jack assignment to Lenovo ThinkStation P620
    (LP: #1891461)

 -- Hui Wang <email address hidden> Mon, 10 Aug 2020 15:05:02 +0800

Changed in alsa-ucm-conf (Ubuntu Focal):
status: Fix Committed → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pulseaudio - 1:13.99.1-1ubuntu3.6

---------------
pulseaudio (1:13.99.1-1ubuntu3.6) focal; urgency=medium

  [ Kai-Heng Feng ]
  * d/p/0001-alsa-mixer-Recognize-USB-audio-jack-mixer.patch:
    - recognize USB jack mixer to support jack detection (LP: #1891461)
  * d/p/0002-module-alsa-card-Set-a-minimum-profile-priority-if-i.patch:
    - resolve an issue when headset gets unplugged, HDMI audio is choosen
      instead of internal speaker (LP: #1891461)

  [ Hui Wang ]
  * d/p/0034-alsa-adjust-ucm-sink-source-priority-according-to-po.patch
  * d/p/0035-ucm-add-possibility-to-skip-the-UCM-card-completely-.patch
  * d/p/0036-device-port-queue-CARD-CHANGE-event-before-update-de.patch
    - Make the AMD acp sound card skipped in the PA, then the ucm could
      link it to other sound cards, it is easy for gnome to support AMD
      Renoir sound driver after this change. (LP: #1889217)

 -- Kai-Heng Feng <email address hidden> Thu, 13 Aug 2020 18:53:08 +0800

Changed in pulseaudio (Ubuntu Focal):
status: Fix Committed → Fix Released
Changed in hwe-next:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers