^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) ALSA Jack Controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) Why we need Jack kcontrols
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) ==========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ALSA uses kcontrols to export audio controls(switch, volume, Mux, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) to user space. This means userspace applications like pulseaudio can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) switch off headphones and switch on speakers when no headphones are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) pluged in.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) The old ALSA jack code only created input devices for each registered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) jack. These jack input devices are not readable by userspace devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) that run as non root.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) The new jack code creates embedded jack kcontrols for each jack that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) can be read by any process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) This can be combined with UCM to allow userspace to route audio more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) intelligently based on jack insertion or removal events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) Jack Kcontrol Internals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) Each jack will have a kcontrol list, so that we can create a kcontrol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) and attach it to the jack, at jack creation stage. We can also add a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) kcontrol to an existing jack, at anytime when required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) Those kcontrols will be freed automatically when the Jack is freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) How to use jack kcontrols
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) =========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) In order to keep compatibility, snd_jack_new() has been modified by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) adding two params:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) initial_kctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) if true, create a kcontrol and add it to the jack list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) phantom_jack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) Don't create a input device for phantom jacks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) HDA jacks can set phantom_jack to true in order to create a phantom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) jack and set initial_kctl to true to create an initial kcontrol with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) the correct id.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) ASoC jacks should set initial_kctl as false. The pin name will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) assigned as the jack kcontrol name.