[RFC][PATCH v2 0/1] design a way to change audio Jack state by software
Hui Wang
hui.wang at canonical.com
Wed Dec 16 12:46:27 CET 2020
the changes in the V2:
- using debugfs instead of sysfs
- using jack_ctrl to create a folder instead of snd_jack, since ASoC drivers
could create multi jack_ctrls within a snd_jack
- create a folder for each jack_ctrl instead for all jack_ctrls
This is the layout of folder on a machine with 2 sound cards:
root at hwang4-ThinkPad-P1-Gen-3:/sys/kernel/debug# tree /sys/kernel/debug/sound-core/
/sys/kernel/debug/sound-core/
├── card0
│ ├── HDMI!DP,pcm=10 Jack
│ │ ├── jackin_inject
│ │ └── sw_inject_enable
│ ├── HDMI!DP,pcm=11 Jack
│ │ ├── jackin_inject
│ │ └── sw_inject_enable
│ ├── HDMI!DP,pcm=3 Jack
│ │ ├── jackin_inject
│ │ └── sw_inject_enable
│ ├── HDMI!DP,pcm=7 Jack
│ │ ├── jackin_inject
│ │ └── sw_inject_enable
│ ├── HDMI!DP,pcm=8 Jack
│ │ ├── jackin_inject
│ │ └── sw_inject_enable
│ └── HDMI!DP,pcm=9 Jack
│ ├── jackin_inject
│ └── sw_inject_enable
└── card1
├── HDMI!DP,pcm=3 Jack
│ ├── jackin_inject
│ └── sw_inject_enable
├── HDMI!DP,pcm=4 Jack
│ ├── jackin_inject
│ └── sw_inject_enable
├── HDMI!DP,pcm=5 Jack
│ ├── jackin_inject
│ └── sw_inject_enable
├── Headphone Jack
│ ├── jackin_inject
│ └── sw_inject_enable
├── Headset Jack
│ ├── jackin_inject
│ └── sw_inject_enable
└── Mic Jack
├── jackin_inject
└── sw_inject_enable
The sw_inject_enable has rw mode, the jackin_inject has write_only mode.
If users want to inject a plugin to Headphone Jack, they could run:
echo 1 > 'Headphone Jack'/sw_inject_enable /* now, this jack state can't be changed by hw events */
cat 'Headphone Jack'/sw_inject_enable
ack: Headphone Jack Inject Enabled: 1
echo 1 > 'Headphone Jack'/jackin_inject /* this will inject a plugin to Headphone Jack */
After testing, run
echo 0 > 'Headphone Jack'/sw_inject_enable /* the hw events will change the jack state */
Hui Wang (1):
alsa: jack: implement software jack injection via debugfs
include/sound/core.h | 2 +
sound/core/init.c | 7 ++
sound/core/jack.c | 202 ++++++++++++++++++++++++++++++++++++-------
sound/core/sound.c | 8 ++
4 files changed, 188 insertions(+), 31 deletions(-)
--
2.25.1
More information about the Alsa-devel
mailing list