All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH v2 0/1] design a way to change audio Jack state by software
@ 2020-12-16 11:46 Hui Wang
  2020-12-16 11:46 ` [RFC][PATCH v2 1/1] alsa: jack: implement software jack injection via debugfs Hui Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Hui Wang @ 2020-12-16 11:46 UTC (permalink / raw)
  To: alsa-devel, tiwai, perex, kai.vehmanen

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@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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-12-19 12:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 11:46 [RFC][PATCH v2 0/1] design a way to change audio Jack state by software Hui Wang
2020-12-16 11:46 ` [RFC][PATCH v2 1/1] alsa: jack: implement software jack injection via debugfs Hui Wang
2020-12-17 16:45   ` Kai Vehmanen
2020-12-18 15:17     ` Takashi Iwai
2020-12-19 12:07       ` Hui Wang
2020-12-19 10:17     ` Hui Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.