Message ID | 20250526-dualsense-hid-jack-v1-0-a65fee4a60cc@collabora.com |
---|---|
Headers | show |
Series | HID: playstation: Add support for audio jack handling on DualSense | expand |
Hi Cristian, Thanks for sharing your patches around audio. I need to have a closer look at some of those and how the console also behaves (we try to keep things in-sync'ish when possible). I need to double check the datasheets as well. The series does contain some other patches around style and stuff. Some of them for me are entering that slippery slope of what to change. There are some different styles in use around the kernel (e.g. uint32_t etcetera is fine). But then if you use super strict mode on checkpatch half the kernel almost needs to be touched. I'm a bit skeptical on those kind of patches. Thanks, Roderick On Mon, May 26, 2025 at 5:52 AM Cristian Ciocaltea <cristian.ciocaltea@collabora.com> wrote: > > The Sony DualSense wireless controller (PS5) provides an internal mono > speaker, in addition to the 3.5mm jack socket for headphone output and > headset microphone input. However, the default audio output path is set > to headphones, regardless of whether they are actually inserted or not. > > This patch series aims to improve the audio support by implementing the > following changes: > > * Detect when the plugged state of the audio jack changes and toggle > audio output between headphones and internal speaker, as required. > The latter is achieved by essentially routing the right channel of the > audio source to the mono speaker. > > * Adjust the speaker volume since its default level is too low and, > therefore, cannot generate any audible sound. > > * Register a dedicated input device for the audio jack and use it to > report all headphone and headset mic insert events. > > It's worth noting the latter is necessary since the controller complies > with v1.0 of the USB Audio Class spec (UAC1) and, therefore, cannot > advertise any jack detection capability. However, this feature can be > implemented in the generic USB audio driver via quirks, i.e. by > configuring an input handler to receive hotplug events from the HID > driver. > > Unrelated to the above, also provide a few driver cleanup patches, e.g. > make use of bitfields macros, simplify locking, fix coding style. > > Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> > --- > Cristian Ciocaltea (11): > HID: playstation: Make use of bitfield macros > HID: playstation: Add spaces around arithmetic operators > HID: playstation: Simplify locking with guard() and scoped_guard() > HID: playstation: Replace uint{32,16,8}_t with u{32,16,8} > HID: playstation: Correct spelling in comment sections > HID: playstation: Fix all alignment and line length issues > HID: playstation: Document spinlock_t usage > HID: playstation: Prefer kzalloc(sizeof(*buf)...) > HID: playstation: Rename DualSense input report status field > HID: playstation: Support DualSense audio jack hotplug detection > HID: playstation: Support DualSense audio jack event reporting > > drivers/hid/hid-playstation.c | 885 ++++++++++++++++++++++++------------------ > 1 file changed, 500 insertions(+), 385 deletions(-) > --- > base-commit: 7bac2c97af4078d7a627500c9bcdd5b033f97718 > change-id: 20250522-dualsense-hid-jack-d3cb65b75da1 > >
Hi Roderick, On 6/10/25 7:01 AM, Roderick Colenbrander wrote: > Hi Cristian, > > Thanks for sharing your patches around audio. I need to have a closer > look at some of those and how the console also behaves (we try to keep > things in-sync'ish when possible). I need to double check the > datasheets as well. No worries, take your time! > The series does contain some other patches around style and stuff. > Some of them for me are entering that slippery slope of what to > change. There are some different styles in use around the kernel (e.g. > uint32_t etcetera is fine). But then if you use super strict mode on > checkpatch half the kernel almost needs to be touched. I'm a bit > skeptical on those kind of patches. While I can understand that some of these patches might be perceived as unnecessary noise, I still think the sooner we do this type of cleanup, the better. And the rationale is that we should aim for consistency, at least for the actively maintained code. This should also encourage any new contributor who might touch the code to comply with the recommended style and/or best practices, instead of potentially falling into the trap of taking as reference some obsolete or non-conformant constructs, which would only bring additional mess. As a matter of fact, I initially planned to just focus on fixing up the patches introduced as part of this series, in order to make checkpatch happy. While doing it, I quickly realized some additional inconsistencies, hence I extended a bit the scope of the cleanup. That highlighted even more issues and after a few iterations I eventually ended up fixing them all. I'm aware that some of these checkpatch reports could be silenced by operating in non-strict mode, by I don't really like the idea. The reason is that some (or most?!) maintainers prefer or even demand using the strict mode, hence it's hard or impossible to always have then right switch set, particularly when touching multiple subsystems. Thanks, Cristian
The Sony DualSense wireless controller (PS5) provides an internal mono speaker, in addition to the 3.5mm jack socket for headphone output and headset microphone input. However, the default audio output path is set to headphones, regardless of whether they are actually inserted or not. This patch series aims to improve the audio support by implementing the following changes: * Detect when the plugged state of the audio jack changes and toggle audio output between headphones and internal speaker, as required. The latter is achieved by essentially routing the right channel of the audio source to the mono speaker. * Adjust the speaker volume since its default level is too low and, therefore, cannot generate any audible sound. * Register a dedicated input device for the audio jack and use it to report all headphone and headset mic insert events. It's worth noting the latter is necessary since the controller complies with v1.0 of the USB Audio Class spec (UAC1) and, therefore, cannot advertise any jack detection capability. However, this feature can be implemented in the generic USB audio driver via quirks, i.e. by configuring an input handler to receive hotplug events from the HID driver. Unrelated to the above, also provide a few driver cleanup patches, e.g. make use of bitfields macros, simplify locking, fix coding style. Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> --- Cristian Ciocaltea (11): HID: playstation: Make use of bitfield macros HID: playstation: Add spaces around arithmetic operators HID: playstation: Simplify locking with guard() and scoped_guard() HID: playstation: Replace uint{32,16,8}_t with u{32,16,8} HID: playstation: Correct spelling in comment sections HID: playstation: Fix all alignment and line length issues HID: playstation: Document spinlock_t usage HID: playstation: Prefer kzalloc(sizeof(*buf)...) HID: playstation: Rename DualSense input report status field HID: playstation: Support DualSense audio jack hotplug detection HID: playstation: Support DualSense audio jack event reporting drivers/hid/hid-playstation.c | 885 ++++++++++++++++++++++++------------------ 1 file changed, 500 insertions(+), 385 deletions(-) --- base-commit: 7bac2c97af4078d7a627500c9bcdd5b033f97718 change-id: 20250522-dualsense-hid-jack-d3cb65b75da1