1 ============================
2 ALSA Jack Software Injection
3 ============================
5 Simple Introduction On Jack Injection
6 =====================================
8 Here jack injection means users could inject plugin or plugout events
9 to the audio jacks through debugfs interface, it is helpful to
10 validate ALSA userspace changes. For example, we change the audio
11 profile switching code in the pulseaudio, and we want to verify if the
12 change works as expected and if the change introduce the regression,
13 in this case, we could inject plugin or plugout events to an audio
14 jack or to some audio jacks, we don't need to physically access the
15 machine and plug/unplug physical devices to the audio jack.
17 In this design, an audio jack doesn't equal to a physical audio jack.
18 Sometimes a physical audio jack contains multi functions, and the
19 ALSA driver creates multi ``jack_kctl`` for a ``snd_jack``, here the
20 ``snd_jack`` represents a physical audio jack and the ``jack_kctl``
21 represents a function, for example a physical jack has two functions:
22 headphone and mic_in, the ALSA ASoC driver will build 2 ``jack_kctl``
23 for this jack. The jack injection is implemented based on the
24 ``jack_kctl`` instead of ``snd_jack``.
26 To inject events to audio jacks, we need to enable the jack injection
27 via ``sw_inject_enable`` first, once it is enabled, this jack will not
28 change the state by hardware events anymore, we could inject plugin or
29 plugout events via ``jackin_inject`` and check the jack state via
30 ``status``, after we finish our test, we need to disable the jack
31 injection via ``sw_inject_enable`` too, once it is disabled, the jack
32 state will be restored according to the last reported hardware events
33 and will change by future hardware events.
35 The Layout of Jack Injection Interface
36 ======================================
38 If users enable the SND_JACK_INJECTION_DEBUG in the kernel, the audio
39 jack injection interface will be created as below:
42 $debugfs_mount_dir/sound
44 |-- |-- HDMI_DP_pcm_10_Jack
45 |-- |-- |-- jackin_inject
49 |-- |-- |-- sw_inject_enable
52 |-- |-- HDMI_DP_pcm_9_Jack
57 |-- |-- sw_inject_enable
60 |-- HDMI_DP_pcm_5_Jack
65 |-- |-- sw_inject_enable
73 |-- |-- sw_inject_enable
83 The Explanation Of The Nodes
84 ======================================
87 read-only, get jack_kctl->kctl's id
90 sound/card1/Headphone_Jack# cat kctl_id
94 read-only, get jack_kctl's supported events mask_bits
97 sound/card1/Headphone_Jack# cat mask_bits
98 0x0001 HEADPHONE(0x0001)
101 read-only, get jack_kctl's current status
103 - headphone unplugged:
107 sound/card1/Headphone_Jack# cat status
114 sound/card1/Headphone_Jack# cat status
118 read-only, get snd_jack's supported events from type (all supported events on the physical audio jack)
121 sound/card1/Headphone_Jack# cat type
122 0x7803 HEADPHONE(0x0001) MICROPHONE(0x0002) BTN_3(0x0800) BTN_2(0x1000) BTN_1(0x2000) BTN_0(0x4000)
125 read-write, enable or disable injection
127 - injection disabled:
131 sound/card1/Headphone_Jack# cat sw_inject_enable
132 Jack: Headphone Jack Inject Enabled: 0
138 sound/card1/Headphone_Jack# cat sw_inject_enable
139 Jack: Headphone Jack Inject Enabled: 1
141 - to enable jack injection:
145 sound/card1/Headphone_Jack# echo 1 > sw_inject_enable
147 - to disable jack injection:
151 sound/card1/Headphone_Jack# echo 0 > sw_inject_enable
154 write-only, inject plugin or plugout
160 sound/card1/Headphone_Jack# echo 1 > jackin_inject
166 sound/card1/Headphone_Jack# echo 0 > jackin_inject