Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Lenovo ThinkStation P620 Main Audio #42

Closed

Conversation

khfeng
Copy link
Contributor

@khfeng khfeng commented Aug 6, 2020

This add support for internal speaker and front headset.

We need two separate configs to let PulseAudio understands they are two
different profiles, so the headset's port availability won't affect
speaker's profile availability.

@khfeng khfeng force-pushed the Lenovo-ThinkStation-P620-Main branch from 1949094 to 3307c61 Compare August 6, 2020 09:26
@khfeng khfeng force-pushed the Lenovo-ThinkStation-P620-Main branch from 3307c61 to fc489d2 Compare August 18, 2020 09:19
@perexg perexg force-pushed the master branch 2 times, most recently from 1b60507 to 79c21c1 Compare August 18, 2020 15:06
@perexg
Copy link
Member

perexg commented Aug 18, 2020

I'd prefer the conflicting devices scheme rather than two verbs.

@khfeng
Copy link
Contributor Author

khfeng commented Aug 19, 2020

Using the same verbs and conflicting devices still have same issue, i.e. unavailable headset port invalidates the PulseAudio profile.

I wonder if https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/290 helps, can you please rebase it on top of master?

@alpernebbi
Copy link
Contributor

I wonder if https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/290 helps

It definitely helps with my device, and I think it would help here. I also thought to use different verbs for it but used ConflictingDevice after seeing it works with that MR. You'd have a Speaker/Headphones conflict, and that MR would create two profiles (Speaker+Mic and Headphones+Mic) where plugging in things would switch between the two.

}
}

SectionDevice."Microphone" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be either "Mic" (if internal) or "Headset" (if external), see use-case.h

@perexg
Copy link
Member

perexg commented Aug 19, 2020

@khfeng : Please, use the conflicting devices and fix the mic device name. The mentioned PA MR from me should fix the problematic abstraction on the PA side. There's similar issue with the soundwire hardware.

@khfeng
Copy link
Contributor Author

khfeng commented Aug 19, 2020

@khfeng : Please, use the conflicting devices and fix the mic device name. The mentioned PA MR from me should fix the problematic abstraction on the PA side. There's similar issue with the soundwire hardware.

https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/290 doesn't solve the issue when ConflictingDevice is in use.

UCM was changed to

SectionDevice."Headphones" {
        Comment "Headphones"

        Value {
                PlaybackPriority 200
                PlaybackPCM "hw:${CardId},1"
                JackControl "Headphone - Output Jack"
        }

        ConflictingDevice [
                "Speaker"
        ]
}

SectionDevice."Mic" {
        Comment "Mic"

        Value {
                CapturePriority 200
                CapturePCM "hw:${CardId}"
                JackControl "Mic - Input Jack"
        }
}

SectionDevice."Speaker" {
        Comment "Speaker"

        Value {
                PlaybackPriority 100
                PlaybackPCM "hw:${CardId}"
                JackControl "Speaker - Output Jack"
        }

        ConflictingDevice [
                "Headphones"
        ]
}

Before headset gets plugged, Speaker profile is unavailable while the Speaker port is available:

Card #1                                                                                                                                                                                                                            
        Name: alsa_card.usb-Generic_USB_Audio-00                                                                                                                                                                                   
        Driver: module-alsa-card.c                                                                                                                                                                                                 
        Owner Module: 22                                                                                                                                                                                                           
        Properties:                                                                                                                                                                                                                
                alsa.card = "1"                                                                                                                                                                                                    
                alsa.card_name = "ThinkStation P620 Main"                                                                                                                                                                          
                alsa.long_card_name = "Lenovo-ThinkStation-P620-Main"                                                                                                                                                              
                alsa.driver_name = "snd_usb_audio"                                                                                                                                                                                 
                device.bus_path = "pci-0000:04:00.1-usb-0:1:1.0"                                                                                                                                                                   
                sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:02:00.0/0000:03:08.0/0000:04:00.1/usb3/3-1/3-1:1.0/sound/card1"   
                udev.id = "usb-Generic_USB_Audio-00"                                                                                                                                                                               
                device.bus = "usb"                                                                               
                device.vendor.id = "17aa" 
                device.vendor.name = "Generic"
                device.product.id = "104d"                                                                                                                                                                                         
                device.product.name = "USB Audio"
                device.serial = "Generic_USB_Audio"                                                              
                device.string = "1"                                                                              
                device.description = "USB Audio"                                                                 
                module-udev-detect.discovered = "1"                                                                                                                                                                                
                device.icon_name = "audio-card-usb"
        Profiles:                                                                                                
                HiFi (Speaker): Default (sinks: 1, sources: 1, priority: 8100, available: no)                                                                                                                                      
                HiFi (Headphones): Default (sinks: 1, sources: 1, priority: 8200, available: no)                                                                                                                                   
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
        Active Profile: off                                                                                      
        Ports:                                                                                                                                                                                                                     
                [Out] Speaker: Speaker (type: Speaker, priority: 100, latency offset: 0 usec, available group: Speaker - Output, available)          
                        Part of profile(s): HiFi (Speaker)
                [In] Mic: Mic (type: Mic, priority: 200, latency offset: 0 usec, available group: Mic - Input, not available)
                        Part of profile(s): HiFi (Speaker), HiFi (Headphones)                                                                                                                                                      
                [Out] Headphones: Headphones (type: Headphones, priority: 200, latency offset: 0 usec, available group: Headphone - Output, not available)
                        Part of profile(s): HiFi (Headphones)

After headset gets plugged, Speaker profile becomes available:

Card #1                                                                                                                                                                                                                            
        Name: alsa_card.usb-Generic_USB_Audio-00                                                                                                                                                                                   
        Driver: module-alsa-card.c                                                                                                                                                                                                 
        Owner Module: 22                                                                                                                                                                                                           
        Properties:                                                                                                                                                                                                                
                alsa.card = "1"                                                                                                                                                                                                    
                alsa.card_name = "ThinkStation P620 Main"                                                                                                                                                                          
                alsa.long_card_name = "Lenovo-ThinkStation-P620-Main"                                                                                                                                                              
                alsa.driver_name = "snd_usb_audio"                                                                                                                                                                                 
                device.bus_path = "pci-0000:04:00.1-usb-0:1:1.0"                                                                                                                                                                   
                sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:02:00.0/0000:03:08.0/0000:04:00.1/usb3/3-1/3-1:1.0/sound/card1"   
                udev.id = "usb-Generic_USB_Audio-00"                                                                                                                                                                               
                device.bus = "usb"                                                                               
                device.vendor.id = "17aa" 
                device.vendor.name = "Generic"
                device.product.id = "104d"                                                                                                                                                                                         
                device.product.name = "USB Audio"
                device.serial = "Generic_USB_Audio"                                                              
                device.string = "1"                                                                              
                device.description = "USB Audio"                                                                 
                module-udev-detect.discovered = "1"                                                                                                                                                                                
                device.icon_name = "audio-card-usb"
        Profiles:                                                                                                
                HiFi (Speaker): Default (sinks: 1, sources: 1, priority: 8100, available: yes)                                                                                                                                     
                HiFi (Headphones): Default (sinks: 1, sources: 1, priority: 8200, available: yes)                                                                                                                                  
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
        Active Profile: off                                                                                      
        Ports:                                                                                                                                                                                                                     
                [Out] Speaker: Speaker (type: Speaker, priority: 100, latency offset: 0 usec, available group: Speaker - Output, available)          
                        Part of profile(s): HiFi (Speaker)
                [In] Mic: Mic (type: Mic, priority: 200, latency offset: 0 usec, available group: Mic - Input, available)
                        Part of profile(s): HiFi (Speaker), HiFi (Headphones)                                                                                                                                                      
                [Out] Headphones: Headphones (type: Headphones, priority: 200, latency offset: 0 usec, available group: Headphone - Output, available)
                        Part of profile(s): HiFi (Headphones)

@alpernebbi
Copy link
Contributor

OK, I hadn't understood what you meant until now. "Mic" being in both profiles makes both unavailable when "Mic" is unavailable. Regardless, if you switch manually to one of the profiles I think plugging the headset in and out will start switching between the two as expected. Otherwise, you can also try adding a Speaker/Mic conflict and you should hopefully get the two profiles you wanted from the start (Speaker-only and Headphones+Mic), though I believe the conflicts are really for parts that cannot work together on the hardware.

@perexg
Copy link
Member

perexg commented Aug 20, 2020

OK, I hadn't understood what you meant until now. "Mic" being in both profiles makes both unavailable when "Mic" is unavailable.

It seems like another issue in PA. If you revert the "dangerous" commit bellow, all should work as expected.

References:

@khfeng
Copy link
Contributor Author

khfeng commented Aug 20, 2020

OK, I hadn't understood what you meant until now. "Mic" being in both profiles makes both unavailable when "Mic" is unavailable.

It seems like another issue in PA. If you revert the "dangerous" commit bellow, all should work as expected.

References:

Yes that commit solves the issue.
Push a new UCM with single verb.

@khfeng khfeng force-pushed the Lenovo-ThinkStation-P620-Main branch from fc489d2 to fea08a0 Compare August 20, 2020 14:15
@alpernebbi
Copy link
Contributor

Sorry for bothering you again, but I suspect you don't even need the ConflictingDevice parts (or multiple PA profiles) since reverting that commit solves your problem. Can you test with those sections removed? I don't want my earlier confusion to cause more weirdness.

@khfeng
Copy link
Contributor Author

khfeng commented Aug 22, 2020

Sorry for bothering you again, but I suspect you don't even need the ConflictingDevice parts (or multiple PA profiles) since reverting that commit solves your problem. Can you test with those sections removed? I don't want my earlier confusion to cause more weirdness.

I didn't revert the commit per se, I use https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/355 to instead. With the patch applied, it works flawlessly without ConflictingDevice.

I'll push a new one.

This add support for its internal speaker and front headset.
@khfeng khfeng force-pushed the Lenovo-ThinkStation-P620-Main branch from fea08a0 to 6ac2113 Compare August 22, 2020 12:19
@khfeng
Copy link
Contributor Author

khfeng commented Sep 4, 2020

@perexg any improvement to make?

@perexg
Copy link
Member

perexg commented Sep 7, 2020

Merged in ce06a25 . Thanks. Please, add signed-off-by line next time.

@perexg perexg closed this Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants