1*4882a593Smuzhiyun================== 2*4882a593SmuzhiyunALSA Jack Controls 3*4882a593Smuzhiyun================== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunWhy we need Jack kcontrols 6*4882a593Smuzhiyun========================== 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunALSA uses kcontrols to export audio controls(switch, volume, Mux, ...) 9*4882a593Smuzhiyunto user space. This means userspace applications like pulseaudio can 10*4882a593Smuzhiyunswitch off headphones and switch on speakers when no headphones are 11*4882a593Smuzhiyunpluged in. 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunThe old ALSA jack code only created input devices for each registered 14*4882a593Smuzhiyunjack. These jack input devices are not readable by userspace devices 15*4882a593Smuzhiyunthat run as non root. 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunThe new jack code creates embedded jack kcontrols for each jack that 18*4882a593Smuzhiyuncan be read by any process. 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunThis can be combined with UCM to allow userspace to route audio more 21*4882a593Smuzhiyunintelligently based on jack insertion or removal events. 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunJack Kcontrol Internals 24*4882a593Smuzhiyun======================= 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunEach jack will have a kcontrol list, so that we can create a kcontrol 27*4882a593Smuzhiyunand attach it to the jack, at jack creation stage. We can also add a 28*4882a593Smuzhiyunkcontrol to an existing jack, at anytime when required. 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunThose kcontrols will be freed automatically when the Jack is freed. 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunHow to use jack kcontrols 33*4882a593Smuzhiyun========================= 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunIn order to keep compatibility, snd_jack_new() has been modified by 36*4882a593Smuzhiyunadding two params: 37*4882a593Smuzhiyun 38*4882a593Smuzhiyuninitial_kctl 39*4882a593Smuzhiyun if true, create a kcontrol and add it to the jack list. 40*4882a593Smuzhiyunphantom_jack 41*4882a593Smuzhiyun Don't create a input device for phantom jacks. 42*4882a593Smuzhiyun 43*4882a593SmuzhiyunHDA jacks can set phantom_jack to true in order to create a phantom 44*4882a593Smuzhiyunjack and set initial_kctl to true to create an initial kcontrol with 45*4882a593Smuzhiyunthe correct id. 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunASoC jacks should set initial_kctl as false. The pin name will be 48*4882a593Smuzhiyunassigned as the jack kcontrol name. 49