162306a36Sopenharmony_ci================== 262306a36Sopenharmony_ciALSA Jack Controls 362306a36Sopenharmony_ci================== 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciWhy we need Jack kcontrols 662306a36Sopenharmony_ci========================== 762306a36Sopenharmony_ci 862306a36Sopenharmony_ciALSA uses kcontrols to export audio controls(switch, volume, Mux, ...) 962306a36Sopenharmony_cito user space. This means userspace applications like pulseaudio can 1062306a36Sopenharmony_ciswitch off headphones and switch on speakers when no headphones are 1162306a36Sopenharmony_ciplugged in. 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ciThe old ALSA jack code only created input devices for each registered 1462306a36Sopenharmony_cijack. These jack input devices are not readable by userspace devices 1562306a36Sopenharmony_cithat run as non root. 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ciThe new jack code creates embedded jack kcontrols for each jack that 1862306a36Sopenharmony_cican be read by any process. 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ciThis can be combined with UCM to allow userspace to route audio more 2162306a36Sopenharmony_ciintelligently based on jack insertion or removal events. 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ciJack Kcontrol Internals 2462306a36Sopenharmony_ci======================= 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciEach jack will have a kcontrol list, so that we can create a kcontrol 2762306a36Sopenharmony_ciand attach it to the jack, at jack creation stage. We can also add a 2862306a36Sopenharmony_cikcontrol to an existing jack, at anytime when required. 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ciThose kcontrols will be freed automatically when the Jack is freed. 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ciHow to use jack kcontrols 3362306a36Sopenharmony_ci========================= 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ciIn order to keep compatibility, snd_jack_new() has been modified by 3662306a36Sopenharmony_ciadding two params: 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ciinitial_kctl 3962306a36Sopenharmony_ci if true, create a kcontrol and add it to the jack list. 4062306a36Sopenharmony_ciphantom_jack 4162306a36Sopenharmony_ci Don't create a input device for phantom jacks. 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ciHDA jacks can set phantom_jack to true in order to create a phantom 4462306a36Sopenharmony_cijack and set initial_kctl to true to create an initial kcontrol with 4562306a36Sopenharmony_cithe correct id. 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ciASoC jacks should set initial_kctl as false. The pin name will be 4862306a36Sopenharmony_ciassigned as the jack kcontrol name. 49