From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: Roderick Colenbrander <roderick.colenbrander@sony.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Henrik Rydberg <rydberg@bitmath.org>
Cc: kernel@collabora.com, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 11/11] HID: playstation: Support DualSense audio jack event reporting
Date: Mon, 26 May 2025 15:51:34 +0300 [thread overview]
Message-ID: <20250526-dualsense-hid-jack-v1-11-a65fee4a60cc@collabora.com> (raw)
In-Reply-To: <20250526-dualsense-hid-jack-v1-0-a65fee4a60cc@collabora.com>
The DualSense controller complies with v1.0 of the USB Audio Class spec
(UAC1), hence it 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.
Register a dedicated input device for the audio jack and use it to
report all headphone and headset mic insert events.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/hid/hid-playstation.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
index ed8e67c5bf5d3a9e9721da31a6bd84f0b6802b14..1231165098691398cd471e71cb9787651f753023 100644
--- a/drivers/hid/hid-playstation.c
+++ b/drivers/hid/hid-playstation.c
@@ -178,6 +178,7 @@ struct dualsense {
struct input_dev *gamepad;
struct input_dev *sensors;
struct input_dev *touchpad;
+ struct input_dev *jack;
/* Update version is used as a feature/capability version. */
u16 update_version;
@@ -958,6 +959,25 @@ static struct input_dev *ps_touchpad_create(struct hid_device *hdev, int width,
return touchpad;
}
+static struct input_dev *ps_headset_jack_create(struct hid_device *hdev)
+{
+ struct input_dev *jack;
+ int ret;
+
+ jack = ps_allocate_input_dev(hdev, "Headset Jack");
+ if (IS_ERR(jack))
+ return ERR_CAST(jack);
+
+ input_set_capability(jack, EV_SW, SW_HEADPHONE_INSERT);
+ input_set_capability(jack, EV_SW, SW_MICROPHONE_INSERT);
+
+ ret = input_register_device(jack);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return jack;
+}
+
static ssize_t firmware_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -1360,8 +1380,15 @@ static void dualsense_output_worker(struct work_struct *work)
common->audio_flags2 =
FIELD_PREP(DS_OUTPUT_AUDIO_FLAGS2_SP_PREAMP_GAIN, 0x2);
}
+
+ input_report_switch(ds->jack, SW_HEADPHONE_INSERT, val);
}
+ val = ds->plugged_state & DS_STATUS_PLUGGED_MIC;
+ if (val != (ds->prev_plugged_state & DS_STATUS_PLUGGED_MIC))
+ input_report_switch(ds->jack, SW_MICROPHONE_INSERT, val);
+
+ input_sync(ds->jack);
ds->prev_plugged_state = ds->plugged_state;
}
@@ -1775,6 +1802,12 @@ static struct ps_device *dualsense_create(struct hid_device *hdev)
goto err;
}
+ ds->jack = ps_headset_jack_create(hdev);
+ if (IS_ERR(ds->jack)) {
+ ret = PTR_ERR(ds->jack);
+ goto err;
+ }
+
ret = ps_device_register_battery(ps_dev);
if (ret)
goto err;
--
2.49.0
next prev parent reply other threads:[~2025-05-26 12:52 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-26 12:51 [PATCH 00/11] HID: playstation: Add support for audio jack handling on DualSense Cristian Ciocaltea
2025-05-26 12:51 ` [PATCH 01/11] HID: playstation: Make use of bitfield macros Cristian Ciocaltea
2025-06-10 4:07 ` Roderick Colenbrander
2025-06-12 8:20 ` Cristian Ciocaltea
2025-05-26 12:51 ` [PATCH 02/11] HID: playstation: Add spaces around arithmetic operators Cristian Ciocaltea
2025-06-10 4:19 ` Roderick Colenbrander
2025-06-12 8:30 ` Cristian Ciocaltea
2025-05-26 12:51 ` [PATCH 03/11] HID: playstation: Simplify locking with guard() and scoped_guard() Cristian Ciocaltea
2025-06-10 4:28 ` Roderick Colenbrander
2025-06-12 8:41 ` Cristian Ciocaltea
2025-05-26 12:51 ` [PATCH 04/11] HID: playstation: Replace uint{32,16,8}_t with u{32,16,8} Cristian Ciocaltea
2025-06-10 4:30 ` Roderick Colenbrander
2025-06-12 8:52 ` Cristian Ciocaltea
2025-05-26 12:51 ` [PATCH 05/11] HID: playstation: Correct spelling in comment sections Cristian Ciocaltea
2025-05-26 12:51 ` [PATCH 06/11] HID: playstation: Fix all alignment and line length issues Cristian Ciocaltea
2025-05-26 12:51 ` [PATCH 07/11] HID: playstation: Document spinlock_t usage Cristian Ciocaltea
2025-05-26 12:51 ` [PATCH 08/11] HID: playstation: Prefer kzalloc(sizeof(*buf)...) Cristian Ciocaltea
2025-05-26 12:51 ` [PATCH 09/11] HID: playstation: Rename DualSense input report status field Cristian Ciocaltea
2025-06-10 4:40 ` Roderick Colenbrander
2025-06-12 8:59 ` Cristian Ciocaltea
2025-05-26 12:51 ` [PATCH 10/11] HID: playstation: Support DualSense audio jack hotplug detection Cristian Ciocaltea
2025-06-10 5:04 ` Roderick Colenbrander
2025-06-12 9:14 ` Cristian Ciocaltea
2025-05-26 12:51 ` Cristian Ciocaltea [this message]
2025-06-10 4:01 ` [PATCH 00/11] HID: playstation: Add support for audio jack handling on DualSense Roderick Colenbrander
2025-06-12 8:00 ` Cristian Ciocaltea
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250526-dualsense-hid-jack-v1-11-a65fee4a60cc@collabora.com \
--to=cristian.ciocaltea@collabora.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=kernel@collabora.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roderick.colenbrander@sony.com \
--cc=rydberg@bitmath.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®