ALSA: Add USB audio device jack type
authorWesley Cheng <quic_wcheng@quicinc.com>
Wed, 9 Apr 2025 19:47:40 +0000 (12:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Apr 2025 11:02:30 +0000 (13:02 +0200)
Add an USB jack type, in order to support notifying of a valid USB audio
device.  Since USB audio devices can have a slew of different
configurations that reach beyond the basic headset and headphone use cases,
classify these devices differently.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20250409194804.3773260-8-quic_wcheng@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/mod_devicetable.h
include/sound/jack.h
include/uapi/linux/input-event-codes.h
sound/core/jack.c

index bd7e60c0b72f0b7dc9531869eb1c6d55e32be932..dde836875deb138f0074d8d545f16ccf4fc445d3 100644 (file)
@@ -340,7 +340,7 @@ struct pcmcia_device_id {
 #define INPUT_DEVICE_ID_LED_MAX                0x0f
 #define INPUT_DEVICE_ID_SND_MAX                0x07
 #define INPUT_DEVICE_ID_FF_MAX         0x7f
-#define INPUT_DEVICE_ID_SW_MAX         0x10
+#define INPUT_DEVICE_ID_SW_MAX         0x11
 #define INPUT_DEVICE_ID_PROP_MAX       0x1f
 
 #define INPUT_DEVICE_ID_MATCH_BUS      1
index 1ed90e2109e9be5a803fd49359e328febbbf9d03..bd3f62281c97efd8d5ce837a0ca7d8d7fa89ee0c 100644 (file)
@@ -22,6 +22,7 @@ struct input_dev;
  * @SND_JACK_VIDEOOUT: Video out
  * @SND_JACK_AVOUT: AV (Audio Video) out
  * @SND_JACK_LINEIN:  Line in
+ * @SND_JACK_USB: USB audio device
  * @SND_JACK_BTN_0: Button 0
  * @SND_JACK_BTN_1: Button 1
  * @SND_JACK_BTN_2: Button 2
@@ -43,6 +44,7 @@ enum snd_jack_types {
        SND_JACK_VIDEOOUT       = 0x0010,
        SND_JACK_AVOUT          = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT,
        SND_JACK_LINEIN         = 0x0020,
+       SND_JACK_USB            = 0x0040,
 
        /* Kept separate from switches to facilitate implementation */
        SND_JACK_BTN_0          = 0x4000,
@@ -54,7 +56,7 @@ enum snd_jack_types {
 };
 
 /* Keep in sync with definitions above */
-#define SND_JACK_SWITCH_TYPES 6
+#define SND_JACK_SWITCH_TYPES 7
 
 struct snd_jack {
        struct list_head kctl_list;
index 5a199f3d4a26a22a94e51d4b53aeed3767c97bce..3b2524e4b667d1e7cc02ff5cb674e7c2ac069a66 100644 (file)
 #define SW_MUTE_DEVICE         0x0e  /* set = device disabled */
 #define SW_PEN_INSERTED                0x0f  /* set = pen inserted */
 #define SW_MACHINE_COVER       0x10  /* set = cover closed */
-#define SW_MAX                 0x10
+#define SW_USB_INSERT          0x11  /* set = USB audio device connected */
+#define SW_MAX                 0x11
 #define SW_CNT                 (SW_MAX+1)
 
 /*
index e4bcecdf89b7ec0bccb0d113784c32ecf2620a68..de7c603e92b7f864c037fb40ae22da5284ed8ff7 100644 (file)
@@ -34,6 +34,7 @@ static const int jack_switch_types[SND_JACK_SWITCH_TYPES] = {
        SW_JACK_PHYSICAL_INSERT,
        SW_VIDEOOUT_INSERT,
        SW_LINEIN_INSERT,
+       SW_USB_INSERT,
 };
 #endif /* CONFIG_SND_JACK_INPUT_DEV */
 
@@ -241,8 +242,9 @@ static ssize_t jack_kctl_id_read(struct file *file,
 static const char * const jack_events_name[] = {
        "HEADPHONE(0x0001)", "MICROPHONE(0x0002)", "LINEOUT(0x0004)",
        "MECHANICAL(0x0008)", "VIDEOOUT(0x0010)", "LINEIN(0x0020)",
-       "", "", "", "BTN_5(0x0200)", "BTN_4(0x0400)", "BTN_3(0x0800)",
-       "BTN_2(0x1000)", "BTN_1(0x2000)", "BTN_0(0x4000)", "",
+       "USB(0x0040)", "", "", "BTN_5(0x0200)", "BTN_4(0x0400)",
+       "BTN_3(0x0800)", "BTN_2(0x1000)", "BTN_1(0x2000)", "BTN_0(0x4000)",
+       "",
 };
 
 /* the recommended buffer size is 256 */