18c2ecf20Sopenharmony_ci================== 28c2ecf20Sopenharmony_ciALSA Jack Controls 38c2ecf20Sopenharmony_ci================== 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciWhy we need Jack kcontrols 68c2ecf20Sopenharmony_ci========================== 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ciALSA uses kcontrols to export audio controls(switch, volume, Mux, ...) 98c2ecf20Sopenharmony_cito user space. This means userspace applications like pulseaudio can 108c2ecf20Sopenharmony_ciswitch off headphones and switch on speakers when no headphones are 118c2ecf20Sopenharmony_cipluged in. 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciThe old ALSA jack code only created input devices for each registered 148c2ecf20Sopenharmony_cijack. These jack input devices are not readable by userspace devices 158c2ecf20Sopenharmony_cithat run as non root. 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciThe new jack code creates embedded jack kcontrols for each jack that 188c2ecf20Sopenharmony_cican be read by any process. 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciThis can be combined with UCM to allow userspace to route audio more 218c2ecf20Sopenharmony_ciintelligently based on jack insertion or removal events. 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ciJack Kcontrol Internals 248c2ecf20Sopenharmony_ci======================= 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ciEach jack will have a kcontrol list, so that we can create a kcontrol 278c2ecf20Sopenharmony_ciand attach it to the jack, at jack creation stage. We can also add a 288c2ecf20Sopenharmony_cikcontrol to an existing jack, at anytime when required. 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ciThose kcontrols will be freed automatically when the Jack is freed. 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciHow to use jack kcontrols 338c2ecf20Sopenharmony_ci========================= 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciIn order to keep compatibility, snd_jack_new() has been modified by 368c2ecf20Sopenharmony_ciadding two params: 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ciinitial_kctl 398c2ecf20Sopenharmony_ci if true, create a kcontrol and add it to the jack list. 408c2ecf20Sopenharmony_ciphantom_jack 418c2ecf20Sopenharmony_ci Don't create a input device for phantom jacks. 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ciHDA jacks can set phantom_jack to true in order to create a phantom 448c2ecf20Sopenharmony_cijack and set initial_kctl to true to create an initial kcontrol with 458c2ecf20Sopenharmony_cithe correct id. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciASoC jacks should set initial_kctl as false. The pin name will be 488c2ecf20Sopenharmony_ciassigned as the jack kcontrol name. 49