patch_conexant.c 96 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222
  1. /*
  2. * HD audio interface patch for Conexant HDA audio codec
  3. *
  4. * Copyright (c) 2006 Pototskiy Akex <alex.pototskiy@gmail.com>
  5. * Takashi Iwai <tiwai@suse.de>
  6. * Tobin Davis <tdavis@dsl-only.net>
  7. *
  8. * This driver is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This driver is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/init.h>
  23. #include <linux/delay.h>
  24. #include <linux/slab.h>
  25. #include <linux/pci.h>
  26. #include <sound/core.h>
  27. #include <sound/jack.h>
  28. #include "hda_codec.h"
  29. #include "hda_local.h"
  30. #include "hda_beep.h"
  31. #define CXT_PIN_DIR_IN 0x00
  32. #define CXT_PIN_DIR_OUT 0x01
  33. #define CXT_PIN_DIR_INOUT 0x02
  34. #define CXT_PIN_DIR_IN_NOMICBIAS 0x03
  35. #define CXT_PIN_DIR_INOUT_NOMICBIAS 0x04
  36. #define CONEXANT_HP_EVENT 0x37
  37. #define CONEXANT_MIC_EVENT 0x38
  38. /* Conexant 5051 specific */
  39. #define CXT5051_SPDIF_OUT 0x12
  40. #define CXT5051_PORTB_EVENT 0x38
  41. #define CXT5051_PORTC_EVENT 0x39
  42. #define AUTO_MIC_PORTB (1 << 1)
  43. #define AUTO_MIC_PORTC (1 << 2)
  44. struct conexant_jack {
  45. hda_nid_t nid;
  46. int type;
  47. struct snd_jack *jack;
  48. };
  49. struct conexant_spec {
  50. struct snd_kcontrol_new *mixers[5];
  51. int num_mixers;
  52. hda_nid_t vmaster_nid;
  53. const struct hda_verb *init_verbs[5]; /* initialization verbs
  54. * don't forget NULL
  55. * termination!
  56. */
  57. unsigned int num_init_verbs;
  58. /* playback */
  59. struct hda_multi_out multiout; /* playback set-up
  60. * max_channels, dacs must be set
  61. * dig_out_nid and hp_nid are optional
  62. */
  63. unsigned int cur_eapd;
  64. unsigned int hp_present;
  65. unsigned int auto_mic;
  66. unsigned int need_dac_fix;
  67. /* capture */
  68. unsigned int num_adc_nids;
  69. hda_nid_t *adc_nids;
  70. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  71. unsigned int cur_adc_idx;
  72. hda_nid_t cur_adc;
  73. unsigned int cur_adc_stream_tag;
  74. unsigned int cur_adc_format;
  75. /* capture source */
  76. const struct hda_input_mux *input_mux;
  77. hda_nid_t *capsrc_nids;
  78. unsigned int cur_mux[3];
  79. /* channel model */
  80. const struct hda_channel_mode *channel_mode;
  81. int num_channel_mode;
  82. /* PCM information */
  83. struct hda_pcm pcm_rec[2]; /* used in build_pcms() */
  84. unsigned int spdif_route;
  85. /* jack detection */
  86. struct snd_array jacks;
  87. /* dynamic controls, init_verbs and input_mux */
  88. struct auto_pin_cfg autocfg;
  89. struct hda_input_mux private_imux;
  90. hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
  91. unsigned int dell_automute;
  92. unsigned int port_d_mode;
  93. unsigned int dell_vostro:1;
  94. unsigned int ideapad:1;
  95. unsigned int thinkpad:1;
  96. unsigned int ext_mic_present;
  97. unsigned int recording;
  98. void (*capture_prepare)(struct hda_codec *codec);
  99. void (*capture_cleanup)(struct hda_codec *codec);
  100. /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
  101. * through the microphone jack.
  102. * When the user enables this through a mixer switch, both internal and
  103. * external microphones are disabled. Gain is fixed at 0dB. In this mode,
  104. * we also allow the bias to be configured through a separate mixer
  105. * control. */
  106. unsigned int dc_enable;
  107. unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */
  108. unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */
  109. unsigned int beep_amp;
  110. };
  111. static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
  112. struct hda_codec *codec,
  113. struct snd_pcm_substream *substream)
  114. {
  115. struct conexant_spec *spec = codec->spec;
  116. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
  117. hinfo);
  118. }
  119. static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  120. struct hda_codec *codec,
  121. unsigned int stream_tag,
  122. unsigned int format,
  123. struct snd_pcm_substream *substream)
  124. {
  125. struct conexant_spec *spec = codec->spec;
  126. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  127. stream_tag,
  128. format, substream);
  129. }
  130. static int conexant_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  131. struct hda_codec *codec,
  132. struct snd_pcm_substream *substream)
  133. {
  134. struct conexant_spec *spec = codec->spec;
  135. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  136. }
  137. /*
  138. * Digital out
  139. */
  140. static int conexant_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  141. struct hda_codec *codec,
  142. struct snd_pcm_substream *substream)
  143. {
  144. struct conexant_spec *spec = codec->spec;
  145. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  146. }
  147. static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  148. struct hda_codec *codec,
  149. struct snd_pcm_substream *substream)
  150. {
  151. struct conexant_spec *spec = codec->spec;
  152. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  153. }
  154. static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  155. struct hda_codec *codec,
  156. unsigned int stream_tag,
  157. unsigned int format,
  158. struct snd_pcm_substream *substream)
  159. {
  160. struct conexant_spec *spec = codec->spec;
  161. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  162. stream_tag,
  163. format, substream);
  164. }
  165. /*
  166. * Analog capture
  167. */
  168. static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  169. struct hda_codec *codec,
  170. unsigned int stream_tag,
  171. unsigned int format,
  172. struct snd_pcm_substream *substream)
  173. {
  174. struct conexant_spec *spec = codec->spec;
  175. if (spec->capture_prepare)
  176. spec->capture_prepare(codec);
  177. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  178. stream_tag, 0, format);
  179. return 0;
  180. }
  181. static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  182. struct hda_codec *codec,
  183. struct snd_pcm_substream *substream)
  184. {
  185. struct conexant_spec *spec = codec->spec;
  186. snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
  187. if (spec->capture_cleanup)
  188. spec->capture_cleanup(codec);
  189. return 0;
  190. }
  191. static struct hda_pcm_stream conexant_pcm_analog_playback = {
  192. .substreams = 1,
  193. .channels_min = 2,
  194. .channels_max = 2,
  195. .nid = 0, /* fill later */
  196. .ops = {
  197. .open = conexant_playback_pcm_open,
  198. .prepare = conexant_playback_pcm_prepare,
  199. .cleanup = conexant_playback_pcm_cleanup
  200. },
  201. };
  202. static struct hda_pcm_stream conexant_pcm_analog_capture = {
  203. .substreams = 1,
  204. .channels_min = 2,
  205. .channels_max = 2,
  206. .nid = 0, /* fill later */
  207. .ops = {
  208. .prepare = conexant_capture_pcm_prepare,
  209. .cleanup = conexant_capture_pcm_cleanup
  210. },
  211. };
  212. static struct hda_pcm_stream conexant_pcm_digital_playback = {
  213. .substreams = 1,
  214. .channels_min = 2,
  215. .channels_max = 2,
  216. .nid = 0, /* fill later */
  217. .ops = {
  218. .open = conexant_dig_playback_pcm_open,
  219. .close = conexant_dig_playback_pcm_close,
  220. .prepare = conexant_dig_playback_pcm_prepare
  221. },
  222. };
  223. static struct hda_pcm_stream conexant_pcm_digital_capture = {
  224. .substreams = 1,
  225. .channels_min = 2,
  226. .channels_max = 2,
  227. /* NID is set in alc_build_pcms */
  228. };
  229. static int cx5051_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  230. struct hda_codec *codec,
  231. unsigned int stream_tag,
  232. unsigned int format,
  233. struct snd_pcm_substream *substream)
  234. {
  235. struct conexant_spec *spec = codec->spec;
  236. spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
  237. spec->cur_adc_stream_tag = stream_tag;
  238. spec->cur_adc_format = format;
  239. snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
  240. return 0;
  241. }
  242. static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  243. struct hda_codec *codec,
  244. struct snd_pcm_substream *substream)
  245. {
  246. struct conexant_spec *spec = codec->spec;
  247. snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
  248. spec->cur_adc = 0;
  249. return 0;
  250. }
  251. static struct hda_pcm_stream cx5051_pcm_analog_capture = {
  252. .substreams = 1,
  253. .channels_min = 2,
  254. .channels_max = 2,
  255. .nid = 0, /* fill later */
  256. .ops = {
  257. .prepare = cx5051_capture_pcm_prepare,
  258. .cleanup = cx5051_capture_pcm_cleanup
  259. },
  260. };
  261. static int conexant_build_pcms(struct hda_codec *codec)
  262. {
  263. struct conexant_spec *spec = codec->spec;
  264. struct hda_pcm *info = spec->pcm_rec;
  265. codec->num_pcms = 1;
  266. codec->pcm_info = info;
  267. info->name = "CONEXANT Analog";
  268. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = conexant_pcm_analog_playback;
  269. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
  270. spec->multiout.max_channels;
  271. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
  272. spec->multiout.dac_nids[0];
  273. if (codec->vendor_id == 0x14f15051)
  274. info->stream[SNDRV_PCM_STREAM_CAPTURE] =
  275. cx5051_pcm_analog_capture;
  276. else
  277. info->stream[SNDRV_PCM_STREAM_CAPTURE] =
  278. conexant_pcm_analog_capture;
  279. info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
  280. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  281. if (spec->multiout.dig_out_nid) {
  282. info++;
  283. codec->num_pcms++;
  284. info->name = "Conexant Digital";
  285. info->pcm_type = HDA_PCM_TYPE_SPDIF;
  286. info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
  287. conexant_pcm_digital_playback;
  288. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
  289. spec->multiout.dig_out_nid;
  290. if (spec->dig_in_nid) {
  291. info->stream[SNDRV_PCM_STREAM_CAPTURE] =
  292. conexant_pcm_digital_capture;
  293. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
  294. spec->dig_in_nid;
  295. }
  296. }
  297. return 0;
  298. }
  299. static int conexant_mux_enum_info(struct snd_kcontrol *kcontrol,
  300. struct snd_ctl_elem_info *uinfo)
  301. {
  302. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  303. struct conexant_spec *spec = codec->spec;
  304. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  305. }
  306. static int conexant_mux_enum_get(struct snd_kcontrol *kcontrol,
  307. struct snd_ctl_elem_value *ucontrol)
  308. {
  309. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  310. struct conexant_spec *spec = codec->spec;
  311. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  312. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  313. return 0;
  314. }
  315. static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
  316. struct snd_ctl_elem_value *ucontrol)
  317. {
  318. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  319. struct conexant_spec *spec = codec->spec;
  320. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  321. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  322. spec->capsrc_nids[adc_idx],
  323. &spec->cur_mux[adc_idx]);
  324. }
  325. #ifdef CONFIG_SND_HDA_INPUT_JACK
  326. static void conexant_free_jack_priv(struct snd_jack *jack)
  327. {
  328. struct conexant_jack *jacks = jack->private_data;
  329. jacks->nid = 0;
  330. jacks->jack = NULL;
  331. }
  332. static int conexant_add_jack(struct hda_codec *codec,
  333. hda_nid_t nid, int type)
  334. {
  335. struct conexant_spec *spec;
  336. struct conexant_jack *jack;
  337. const char *name;
  338. int err;
  339. spec = codec->spec;
  340. snd_array_init(&spec->jacks, sizeof(*jack), 32);
  341. jack = snd_array_new(&spec->jacks);
  342. name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
  343. if (!jack)
  344. return -ENOMEM;
  345. jack->nid = nid;
  346. jack->type = type;
  347. err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
  348. if (err < 0)
  349. return err;
  350. jack->jack->private_data = jack;
  351. jack->jack->private_free = conexant_free_jack_priv;
  352. return 0;
  353. }
  354. static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
  355. {
  356. struct conexant_spec *spec = codec->spec;
  357. struct conexant_jack *jacks = spec->jacks.list;
  358. if (jacks) {
  359. int i;
  360. for (i = 0; i < spec->jacks.used; i++) {
  361. if (jacks->nid == nid) {
  362. unsigned int present;
  363. present = snd_hda_jack_detect(codec, nid);
  364. present = (present) ? jacks->type : 0 ;
  365. snd_jack_report(jacks->jack,
  366. present);
  367. }
  368. jacks++;
  369. }
  370. }
  371. }
  372. static int conexant_init_jacks(struct hda_codec *codec)
  373. {
  374. struct conexant_spec *spec = codec->spec;
  375. int i;
  376. for (i = 0; i < spec->num_init_verbs; i++) {
  377. const struct hda_verb *hv;
  378. hv = spec->init_verbs[i];
  379. while (hv->nid) {
  380. int err = 0;
  381. switch (hv->param ^ AC_USRSP_EN) {
  382. case CONEXANT_HP_EVENT:
  383. err = conexant_add_jack(codec, hv->nid,
  384. SND_JACK_HEADPHONE);
  385. conexant_report_jack(codec, hv->nid);
  386. break;
  387. case CXT5051_PORTC_EVENT:
  388. case CONEXANT_MIC_EVENT:
  389. err = conexant_add_jack(codec, hv->nid,
  390. SND_JACK_MICROPHONE);
  391. conexant_report_jack(codec, hv->nid);
  392. break;
  393. }
  394. if (err < 0)
  395. return err;
  396. ++hv;
  397. }
  398. }
  399. return 0;
  400. }
  401. #else
  402. static inline void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
  403. {
  404. }
  405. static inline int conexant_init_jacks(struct hda_codec *codec)
  406. {
  407. return 0;
  408. }
  409. #endif
  410. static int conexant_init(struct hda_codec *codec)
  411. {
  412. struct conexant_spec *spec = codec->spec;
  413. int i;
  414. for (i = 0; i < spec->num_init_verbs; i++)
  415. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  416. return 0;
  417. }
  418. static void conexant_free(struct hda_codec *codec)
  419. {
  420. #ifdef CONFIG_SND_HDA_INPUT_JACK
  421. struct conexant_spec *spec = codec->spec;
  422. if (spec->jacks.list) {
  423. struct conexant_jack *jacks = spec->jacks.list;
  424. int i;
  425. for (i = 0; i < spec->jacks.used; i++, jacks++) {
  426. if (jacks->jack)
  427. snd_device_free(codec->bus->card, jacks->jack);
  428. }
  429. snd_array_free(&spec->jacks);
  430. }
  431. #endif
  432. snd_hda_detach_beep_device(codec);
  433. kfree(codec->spec);
  434. }
  435. static struct snd_kcontrol_new cxt_capture_mixers[] = {
  436. {
  437. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  438. .name = "Capture Source",
  439. .info = conexant_mux_enum_info,
  440. .get = conexant_mux_enum_get,
  441. .put = conexant_mux_enum_put
  442. },
  443. {}
  444. };
  445. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  446. /* additional beep mixers; the actual parameters are overwritten at build */
  447. static struct snd_kcontrol_new cxt_beep_mixer[] = {
  448. HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
  449. HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT),
  450. { } /* end */
  451. };
  452. #endif
  453. static const char *slave_vols[] = {
  454. "Headphone Playback Volume",
  455. "Speaker Playback Volume",
  456. NULL
  457. };
  458. static const char *slave_sws[] = {
  459. "Headphone Playback Switch",
  460. "Speaker Playback Switch",
  461. NULL
  462. };
  463. static int conexant_build_controls(struct hda_codec *codec)
  464. {
  465. struct conexant_spec *spec = codec->spec;
  466. unsigned int i;
  467. int err;
  468. for (i = 0; i < spec->num_mixers; i++) {
  469. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  470. if (err < 0)
  471. return err;
  472. }
  473. if (spec->multiout.dig_out_nid) {
  474. err = snd_hda_create_spdif_out_ctls(codec,
  475. spec->multiout.dig_out_nid);
  476. if (err < 0)
  477. return err;
  478. err = snd_hda_create_spdif_share_sw(codec,
  479. &spec->multiout);
  480. if (err < 0)
  481. return err;
  482. spec->multiout.share_spdif = 1;
  483. }
  484. if (spec->dig_in_nid) {
  485. err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
  486. if (err < 0)
  487. return err;
  488. }
  489. /* if we have no master control, let's create it */
  490. if (spec->vmaster_nid &&
  491. !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
  492. unsigned int vmaster_tlv[4];
  493. snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
  494. HDA_OUTPUT, vmaster_tlv);
  495. err = snd_hda_add_vmaster(codec, "Master Playback Volume",
  496. vmaster_tlv, slave_vols);
  497. if (err < 0)
  498. return err;
  499. }
  500. if (spec->vmaster_nid &&
  501. !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
  502. err = snd_hda_add_vmaster(codec, "Master Playback Switch",
  503. NULL, slave_sws);
  504. if (err < 0)
  505. return err;
  506. }
  507. if (spec->input_mux) {
  508. err = snd_hda_add_new_ctls(codec, cxt_capture_mixers);
  509. if (err < 0)
  510. return err;
  511. }
  512. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  513. /* create beep controls if needed */
  514. if (spec->beep_amp) {
  515. struct snd_kcontrol_new *knew;
  516. for (knew = cxt_beep_mixer; knew->name; knew++) {
  517. struct snd_kcontrol *kctl;
  518. kctl = snd_ctl_new1(knew, codec);
  519. if (!kctl)
  520. return -ENOMEM;
  521. kctl->private_value = spec->beep_amp;
  522. err = snd_hda_ctl_add(codec, 0, kctl);
  523. if (err < 0)
  524. return err;
  525. }
  526. }
  527. #endif
  528. return 0;
  529. }
  530. static struct hda_codec_ops conexant_patch_ops = {
  531. .build_controls = conexant_build_controls,
  532. .build_pcms = conexant_build_pcms,
  533. .init = conexant_init,
  534. .free = conexant_free,
  535. };
  536. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  537. #define set_beep_amp(spec, nid, idx, dir) \
  538. ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
  539. #else
  540. #define set_beep_amp(spec, nid, idx, dir) /* NOP */
  541. #endif
  542. /*
  543. * EAPD control
  544. * the private value = nid | (invert << 8)
  545. */
  546. #define cxt_eapd_info snd_ctl_boolean_mono_info
  547. static int cxt_eapd_get(struct snd_kcontrol *kcontrol,
  548. struct snd_ctl_elem_value *ucontrol)
  549. {
  550. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  551. struct conexant_spec *spec = codec->spec;
  552. int invert = (kcontrol->private_value >> 8) & 1;
  553. if (invert)
  554. ucontrol->value.integer.value[0] = !spec->cur_eapd;
  555. else
  556. ucontrol->value.integer.value[0] = spec->cur_eapd;
  557. return 0;
  558. }
  559. static int cxt_eapd_put(struct snd_kcontrol *kcontrol,
  560. struct snd_ctl_elem_value *ucontrol)
  561. {
  562. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  563. struct conexant_spec *spec = codec->spec;
  564. int invert = (kcontrol->private_value >> 8) & 1;
  565. hda_nid_t nid = kcontrol->private_value & 0xff;
  566. unsigned int eapd;
  567. eapd = !!ucontrol->value.integer.value[0];
  568. if (invert)
  569. eapd = !eapd;
  570. if (eapd == spec->cur_eapd)
  571. return 0;
  572. spec->cur_eapd = eapd;
  573. snd_hda_codec_write_cache(codec, nid,
  574. 0, AC_VERB_SET_EAPD_BTLENABLE,
  575. eapd ? 0x02 : 0x00);
  576. return 1;
  577. }
  578. /* controls for test mode */
  579. #ifdef CONFIG_SND_DEBUG
  580. #define CXT_EAPD_SWITCH(xname, nid, mask) \
  581. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  582. .info = cxt_eapd_info, \
  583. .get = cxt_eapd_get, \
  584. .put = cxt_eapd_put, \
  585. .private_value = nid | (mask<<16) }
  586. static int conexant_ch_mode_info(struct snd_kcontrol *kcontrol,
  587. struct snd_ctl_elem_info *uinfo)
  588. {
  589. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  590. struct conexant_spec *spec = codec->spec;
  591. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  592. spec->num_channel_mode);
  593. }
  594. static int conexant_ch_mode_get(struct snd_kcontrol *kcontrol,
  595. struct snd_ctl_elem_value *ucontrol)
  596. {
  597. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  598. struct conexant_spec *spec = codec->spec;
  599. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  600. spec->num_channel_mode,
  601. spec->multiout.max_channels);
  602. }
  603. static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
  604. struct snd_ctl_elem_value *ucontrol)
  605. {
  606. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  607. struct conexant_spec *spec = codec->spec;
  608. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  609. spec->num_channel_mode,
  610. &spec->multiout.max_channels);
  611. if (err >= 0 && spec->need_dac_fix)
  612. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  613. return err;
  614. }
  615. #define CXT_PIN_MODE(xname, nid, dir) \
  616. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  617. .info = conexant_ch_mode_info, \
  618. .get = conexant_ch_mode_get, \
  619. .put = conexant_ch_mode_put, \
  620. .private_value = nid | (dir<<16) }
  621. #endif /* CONFIG_SND_DEBUG */
  622. /* Conexant 5045 specific */
  623. static hda_nid_t cxt5045_dac_nids[1] = { 0x19 };
  624. static hda_nid_t cxt5045_adc_nids[1] = { 0x1a };
  625. static hda_nid_t cxt5045_capsrc_nids[1] = { 0x1a };
  626. #define CXT5045_SPDIF_OUT 0x18
  627. static struct hda_channel_mode cxt5045_modes[1] = {
  628. { 2, NULL },
  629. };
  630. static struct hda_input_mux cxt5045_capture_source = {
  631. .num_items = 2,
  632. .items = {
  633. { "IntMic", 0x1 },
  634. { "ExtMic", 0x2 },
  635. }
  636. };
  637. static struct hda_input_mux cxt5045_capture_source_benq = {
  638. .num_items = 5,
  639. .items = {
  640. { "IntMic", 0x1 },
  641. { "ExtMic", 0x2 },
  642. { "LineIn", 0x3 },
  643. { "CD", 0x4 },
  644. { "Mixer", 0x0 },
  645. }
  646. };
  647. static struct hda_input_mux cxt5045_capture_source_hp530 = {
  648. .num_items = 2,
  649. .items = {
  650. { "ExtMic", 0x1 },
  651. { "IntMic", 0x2 },
  652. }
  653. };
  654. /* turn on/off EAPD (+ mute HP) as a master switch */
  655. static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
  656. struct snd_ctl_elem_value *ucontrol)
  657. {
  658. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  659. struct conexant_spec *spec = codec->spec;
  660. unsigned int bits;
  661. if (!cxt_eapd_put(kcontrol, ucontrol))
  662. return 0;
  663. /* toggle internal speakers mute depending of presence of
  664. * the headphone jack
  665. */
  666. bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
  667. snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
  668. HDA_AMP_MUTE, bits);
  669. bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
  670. snd_hda_codec_amp_stereo(codec, 0x11, HDA_OUTPUT, 0,
  671. HDA_AMP_MUTE, bits);
  672. return 1;
  673. }
  674. /* bind volumes of both NID 0x10 and 0x11 */
  675. static struct hda_bind_ctls cxt5045_hp_bind_master_vol = {
  676. .ops = &snd_hda_bind_vol,
  677. .values = {
  678. HDA_COMPOSE_AMP_VAL(0x10, 3, 0, HDA_OUTPUT),
  679. HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
  680. 0
  681. },
  682. };
  683. /* toggle input of built-in and mic jack appropriately */
  684. static void cxt5045_hp_automic(struct hda_codec *codec)
  685. {
  686. static struct hda_verb mic_jack_on[] = {
  687. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  688. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  689. {}
  690. };
  691. static struct hda_verb mic_jack_off[] = {
  692. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  693. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  694. {}
  695. };
  696. unsigned int present;
  697. present = snd_hda_jack_detect(codec, 0x12);
  698. if (present)
  699. snd_hda_sequence_write(codec, mic_jack_on);
  700. else
  701. snd_hda_sequence_write(codec, mic_jack_off);
  702. }
  703. /* mute internal speaker if HP is plugged */
  704. static void cxt5045_hp_automute(struct hda_codec *codec)
  705. {
  706. struct conexant_spec *spec = codec->spec;
  707. unsigned int bits;
  708. spec->hp_present = snd_hda_jack_detect(codec, 0x11);
  709. bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
  710. snd_hda_codec_amp_stereo(codec, 0x10, HDA_OUTPUT, 0,
  711. HDA_AMP_MUTE, bits);
  712. }
  713. /* unsolicited event for HP jack sensing */
  714. static void cxt5045_hp_unsol_event(struct hda_codec *codec,
  715. unsigned int res)
  716. {
  717. res >>= 26;
  718. switch (res) {
  719. case CONEXANT_HP_EVENT:
  720. cxt5045_hp_automute(codec);
  721. break;
  722. case CONEXANT_MIC_EVENT:
  723. cxt5045_hp_automic(codec);
  724. break;
  725. }
  726. }
  727. static struct snd_kcontrol_new cxt5045_mixers[] = {
  728. HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
  729. HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
  730. HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
  731. HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
  732. HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
  733. HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
  734. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
  735. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
  736. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
  737. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
  738. HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
  739. {
  740. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  741. .name = "Master Playback Switch",
  742. .info = cxt_eapd_info,
  743. .get = cxt_eapd_get,
  744. .put = cxt5045_hp_master_sw_put,
  745. .private_value = 0x10,
  746. },
  747. {}
  748. };
  749. static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
  750. HDA_CODEC_VOLUME("CD Capture Volume", 0x1a, 0x04, HDA_INPUT),
  751. HDA_CODEC_MUTE("CD Capture Switch", 0x1a, 0x04, HDA_INPUT),
  752. HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x4, HDA_INPUT),
  753. HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x4, HDA_INPUT),
  754. HDA_CODEC_VOLUME("Line In Capture Volume", 0x1a, 0x03, HDA_INPUT),
  755. HDA_CODEC_MUTE("Line In Capture Switch", 0x1a, 0x03, HDA_INPUT),
  756. HDA_CODEC_VOLUME("Line In Playback Volume", 0x17, 0x3, HDA_INPUT),
  757. HDA_CODEC_MUTE("Line In Playback Switch", 0x17, 0x3, HDA_INPUT),
  758. HDA_CODEC_VOLUME("Mixer Capture Volume", 0x1a, 0x0, HDA_INPUT),
  759. HDA_CODEC_MUTE("Mixer Capture Switch", 0x1a, 0x0, HDA_INPUT),
  760. {}
  761. };
  762. static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
  763. HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
  764. HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
  765. HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
  766. HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
  767. HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
  768. HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
  769. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
  770. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
  771. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
  772. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
  773. HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
  774. {
  775. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  776. .name = "Master Playback Switch",
  777. .info = cxt_eapd_info,
  778. .get = cxt_eapd_get,
  779. .put = cxt5045_hp_master_sw_put,
  780. .private_value = 0x10,
  781. },
  782. {}
  783. };
  784. static struct hda_verb cxt5045_init_verbs[] = {
  785. /* Line in, Mic */
  786. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
  787. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
  788. /* HP, Amp */
  789. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  790. {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
  791. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  792. {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
  793. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  794. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  795. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  796. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  797. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  798. /* Record selector: Int mic */
  799. {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
  800. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
  801. AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
  802. /* SPDIF route: PCM */
  803. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  804. { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
  805. /* EAPD */
  806. {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
  807. { } /* end */
  808. };
  809. static struct hda_verb cxt5045_benq_init_verbs[] = {
  810. /* Int Mic, Mic */
  811. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
  812. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
  813. /* Line In,HP, Amp */
  814. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  815. {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
  816. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  817. {0x11, AC_VERB_SET_CONNECT_SEL, 0x1},
  818. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  819. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  820. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  821. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  822. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  823. /* Record selector: Int mic */
  824. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x1},
  825. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
  826. AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
  827. /* SPDIF route: PCM */
  828. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  829. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  830. /* EAPD */
  831. {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
  832. { } /* end */
  833. };
  834. static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
  835. /* pin sensing on HP jack */
  836. {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
  837. { } /* end */
  838. };
  839. static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
  840. /* pin sensing on HP jack */
  841. {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
  842. { } /* end */
  843. };
  844. #ifdef CONFIG_SND_DEBUG
  845. /* Test configuration for debugging, modelled after the ALC260 test
  846. * configuration.
  847. */
  848. static struct hda_input_mux cxt5045_test_capture_source = {
  849. .num_items = 5,
  850. .items = {
  851. { "MIXER", 0x0 },
  852. { "MIC1 pin", 0x1 },
  853. { "LINE1 pin", 0x2 },
  854. { "HP-OUT pin", 0x3 },
  855. { "CD pin", 0x4 },
  856. },
  857. };
  858. static struct snd_kcontrol_new cxt5045_test_mixer[] = {
  859. /* Output controls */
  860. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
  861. HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  862. HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
  863. HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
  864. HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
  865. HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
  866. /* Modes for retasking pin widgets */
  867. CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
  868. CXT_PIN_MODE("LINE1 pin mode", 0x12, CXT_PIN_DIR_INOUT),
  869. /* EAPD Switch Control */
  870. CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
  871. /* Loopback mixer controls */
  872. HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
  873. HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
  874. HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
  875. HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
  876. HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
  877. HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
  878. HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
  879. HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
  880. HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
  881. HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
  882. {
  883. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  884. .name = "Input Source",
  885. .info = conexant_mux_enum_info,
  886. .get = conexant_mux_enum_get,
  887. .put = conexant_mux_enum_put,
  888. },
  889. /* Audio input controls */
  890. HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT),
  891. HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT),
  892. HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT),
  893. HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT),
  894. HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT),
  895. HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT),
  896. HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT),
  897. HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT),
  898. HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT),
  899. HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT),
  900. { } /* end */
  901. };
  902. static struct hda_verb cxt5045_test_init_verbs[] = {
  903. /* Set connections */
  904. { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
  905. { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
  906. { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
  907. /* Enable retasking pins as output, initially without power amp */
  908. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  909. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  910. /* Disable digital (SPDIF) pins initially, but users can enable
  911. * them via a mixer switch. In the case of SPDIF-out, this initverb
  912. * payload also sets the generation to 0, output to be in "consumer"
  913. * PCM format, copyright asserted, no pre-emphasis and no validity
  914. * control.
  915. */
  916. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  917. {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
  918. /* Start with output sum widgets muted and their output gains at min */
  919. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  920. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  921. /* Unmute retasking pin widget output buffers since the default
  922. * state appears to be output. As the pin mode is changed by the
  923. * user the pin mode control will take care of enabling the pin's
  924. * input/output buffers as needed.
  925. */
  926. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  927. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  928. /* Mute capture amp left and right */
  929. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  930. /* Set ADC connection select to match default mixer setting (mic1
  931. * pin)
  932. */
  933. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  934. {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
  935. /* Mute all inputs to mixer widget (even unconnected ones) */
  936. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
  937. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* Mic1 pin */
  938. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* Line pin */
  939. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* HP pin */
  940. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  941. { }
  942. };
  943. #endif
  944. /* initialize jack-sensing, too */
  945. static int cxt5045_init(struct hda_codec *codec)
  946. {
  947. conexant_init(codec);
  948. cxt5045_hp_automute(codec);
  949. return 0;
  950. }
  951. enum {
  952. CXT5045_LAPTOP_HPSENSE,
  953. CXT5045_LAPTOP_MICSENSE,
  954. CXT5045_LAPTOP_HPMICSENSE,
  955. CXT5045_BENQ,
  956. CXT5045_LAPTOP_HP530,
  957. #ifdef CONFIG_SND_DEBUG
  958. CXT5045_TEST,
  959. #endif
  960. CXT5045_MODELS
  961. };
  962. static const char *cxt5045_models[CXT5045_MODELS] = {
  963. [CXT5045_LAPTOP_HPSENSE] = "laptop-hpsense",
  964. [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
  965. [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
  966. [CXT5045_BENQ] = "benq",
  967. [CXT5045_LAPTOP_HP530] = "laptop-hp530",
  968. #ifdef CONFIG_SND_DEBUG
  969. [CXT5045_TEST] = "test",
  970. #endif
  971. };
  972. static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
  973. SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
  974. SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
  975. CXT5045_LAPTOP_HPSENSE),
  976. SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
  977. SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
  978. SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
  979. SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
  980. SND_PCI_QUIRK(0x1734, 0x110e, "Fujitsu V5505",
  981. CXT5045_LAPTOP_HPMICSENSE),
  982. SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
  983. SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
  984. SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
  985. SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
  986. CXT5045_LAPTOP_HPMICSENSE),
  987. SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
  988. {}
  989. };
  990. static int patch_cxt5045(struct hda_codec *codec)
  991. {
  992. struct conexant_spec *spec;
  993. int board_config;
  994. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  995. if (!spec)
  996. return -ENOMEM;
  997. codec->spec = spec;
  998. codec->pin_amp_workaround = 1;
  999. spec->multiout.max_channels = 2;
  1000. spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
  1001. spec->multiout.dac_nids = cxt5045_dac_nids;
  1002. spec->multiout.dig_out_nid = CXT5045_SPDIF_OUT;
  1003. spec->num_adc_nids = 1;
  1004. spec->adc_nids = cxt5045_adc_nids;
  1005. spec->capsrc_nids = cxt5045_capsrc_nids;
  1006. spec->input_mux = &cxt5045_capture_source;
  1007. spec->num_mixers = 1;
  1008. spec->mixers[0] = cxt5045_mixers;
  1009. spec->num_init_verbs = 1;
  1010. spec->init_verbs[0] = cxt5045_init_verbs;
  1011. spec->spdif_route = 0;
  1012. spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes);
  1013. spec->channel_mode = cxt5045_modes;
  1014. set_beep_amp(spec, 0x16, 0, 1);
  1015. codec->patch_ops = conexant_patch_ops;
  1016. board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
  1017. cxt5045_models,
  1018. cxt5045_cfg_tbl);
  1019. switch (board_config) {
  1020. case CXT5045_LAPTOP_HPSENSE:
  1021. codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
  1022. spec->input_mux = &cxt5045_capture_source;
  1023. spec->num_init_verbs = 2;
  1024. spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
  1025. spec->mixers[0] = cxt5045_mixers;
  1026. codec->patch_ops.init = cxt5045_init;
  1027. break;
  1028. case CXT5045_LAPTOP_MICSENSE:
  1029. codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
  1030. spec->input_mux = &cxt5045_capture_source;
  1031. spec->num_init_verbs = 2;
  1032. spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
  1033. spec->mixers[0] = cxt5045_mixers;
  1034. codec->patch_ops.init = cxt5045_init;
  1035. break;
  1036. default:
  1037. case CXT5045_LAPTOP_HPMICSENSE:
  1038. codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
  1039. spec->input_mux = &cxt5045_capture_source;
  1040. spec->num_init_verbs = 3;
  1041. spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
  1042. spec->init_verbs[2] = cxt5045_mic_sense_init_verbs;
  1043. spec->mixers[0] = cxt5045_mixers;
  1044. codec->patch_ops.init = cxt5045_init;
  1045. break;
  1046. case CXT5045_BENQ:
  1047. codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
  1048. spec->input_mux = &cxt5045_capture_source_benq;
  1049. spec->num_init_verbs = 1;
  1050. spec->init_verbs[0] = cxt5045_benq_init_verbs;
  1051. spec->mixers[0] = cxt5045_mixers;
  1052. spec->mixers[1] = cxt5045_benq_mixers;
  1053. spec->num_mixers = 2;
  1054. codec->patch_ops.init = cxt5045_init;
  1055. break;
  1056. case CXT5045_LAPTOP_HP530:
  1057. codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
  1058. spec->input_mux = &cxt5045_capture_source_hp530;
  1059. spec->num_init_verbs = 2;
  1060. spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
  1061. spec->mixers[0] = cxt5045_mixers_hp530;
  1062. codec->patch_ops.init = cxt5045_init;
  1063. break;
  1064. #ifdef CONFIG_SND_DEBUG
  1065. case CXT5045_TEST:
  1066. spec->input_mux = &cxt5045_test_capture_source;
  1067. spec->mixers[0] = cxt5045_test_mixer;
  1068. spec->init_verbs[0] = cxt5045_test_init_verbs;
  1069. break;
  1070. #endif
  1071. }
  1072. switch (codec->subsystem_id >> 16) {
  1073. case 0x103c:
  1074. case 0x1631:
  1075. case 0x1734:
  1076. case 0x17aa:
  1077. /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
  1078. * really bad sound over 0dB on NID 0x17. Fix max PCM level to
  1079. * 0 dB (originally it has 0x2b steps with 0dB offset 0x14)
  1080. */
  1081. snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
  1082. (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
  1083. (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  1084. (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  1085. (1 << AC_AMPCAP_MUTE_SHIFT));
  1086. break;
  1087. }
  1088. if (spec->beep_amp)
  1089. snd_hda_attach_beep_device(codec, spec->beep_amp);
  1090. return 0;
  1091. }
  1092. /* Conexant 5047 specific */
  1093. #define CXT5047_SPDIF_OUT 0x11
  1094. static hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */
  1095. static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
  1096. static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
  1097. static struct hda_channel_mode cxt5047_modes[1] = {
  1098. { 2, NULL },
  1099. };
  1100. static struct hda_input_mux cxt5047_toshiba_capture_source = {
  1101. .num_items = 2,
  1102. .items = {
  1103. { "ExtMic", 0x2 },
  1104. { "Line-In", 0x1 },
  1105. }
  1106. };
  1107. /* turn on/off EAPD (+ mute HP) as a master switch */
  1108. static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
  1109. struct snd_ctl_elem_value *ucontrol)
  1110. {
  1111. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1112. struct conexant_spec *spec = codec->spec;
  1113. unsigned int bits;
  1114. if (!cxt_eapd_put(kcontrol, ucontrol))
  1115. return 0;
  1116. /* toggle internal speakers mute depending of presence of
  1117. * the headphone jack
  1118. */
  1119. bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
  1120. /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
  1121. * pin widgets unlike other codecs. In this case, we need to
  1122. * set index 0x01 for the volume from the mixer amp 0x19.
  1123. */
  1124. snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
  1125. HDA_AMP_MUTE, bits);
  1126. bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
  1127. snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
  1128. HDA_AMP_MUTE, bits);
  1129. return 1;
  1130. }
  1131. /* mute internal speaker if HP is plugged */
  1132. static void cxt5047_hp_automute(struct hda_codec *codec)
  1133. {
  1134. struct conexant_spec *spec = codec->spec;
  1135. unsigned int bits;
  1136. spec->hp_present = snd_hda_jack_detect(codec, 0x13);
  1137. bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
  1138. /* See the note in cxt5047_hp_master_sw_put */
  1139. snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
  1140. HDA_AMP_MUTE, bits);
  1141. }
  1142. /* toggle input of built-in and mic jack appropriately */
  1143. static void cxt5047_hp_automic(struct hda_codec *codec)
  1144. {
  1145. static struct hda_verb mic_jack_on[] = {
  1146. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1147. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1148. {}
  1149. };
  1150. static struct hda_verb mic_jack_off[] = {
  1151. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1152. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1153. {}
  1154. };
  1155. unsigned int present;
  1156. present = snd_hda_jack_detect(codec, 0x15);
  1157. if (present)
  1158. snd_hda_sequence_write(codec, mic_jack_on);
  1159. else
  1160. snd_hda_sequence_write(codec, mic_jack_off);
  1161. }
  1162. /* unsolicited event for HP jack sensing */
  1163. static void cxt5047_hp_unsol_event(struct hda_codec *codec,
  1164. unsigned int res)
  1165. {
  1166. switch (res >> 26) {
  1167. case CONEXANT_HP_EVENT:
  1168. cxt5047_hp_automute(codec);
  1169. break;
  1170. case CONEXANT_MIC_EVENT:
  1171. cxt5047_hp_automic(codec);
  1172. break;
  1173. }
  1174. }
  1175. static struct snd_kcontrol_new cxt5047_base_mixers[] = {
  1176. HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT),
  1177. HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT),
  1178. HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT),
  1179. HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
  1180. HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
  1181. HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
  1182. HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
  1183. {
  1184. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1185. .name = "Master Playback Switch",
  1186. .info = cxt_eapd_info,
  1187. .get = cxt_eapd_get,
  1188. .put = cxt5047_hp_master_sw_put,
  1189. .private_value = 0x13,
  1190. },
  1191. {}
  1192. };
  1193. static struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = {
  1194. /* See the note in cxt5047_hp_master_sw_put */
  1195. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT),
  1196. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
  1197. {}
  1198. };
  1199. static struct snd_kcontrol_new cxt5047_hp_only_mixers[] = {
  1200. HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
  1201. { } /* end */
  1202. };
  1203. static struct hda_verb cxt5047_init_verbs[] = {
  1204. /* Line in, Mic, Built-in Mic */
  1205. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1206. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
  1207. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
  1208. /* HP, Speaker */
  1209. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1210. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */
  1211. {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */
  1212. /* Record selector: Mic */
  1213. {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
  1214. {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
  1215. AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
  1216. {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
  1217. {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
  1218. AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
  1219. {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
  1220. AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
  1221. /* SPDIF route: PCM */
  1222. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
  1223. /* Enable unsolicited events */
  1224. {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
  1225. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
  1226. { } /* end */
  1227. };
  1228. /* configuration for Toshiba Laptops */
  1229. static struct hda_verb cxt5047_toshiba_init_verbs[] = {
  1230. {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */
  1231. {}
  1232. };
  1233. /* Test configuration for debugging, modelled after the ALC260 test
  1234. * configuration.
  1235. */
  1236. #ifdef CONFIG_SND_DEBUG
  1237. static struct hda_input_mux cxt5047_test_capture_source = {
  1238. .num_items = 4,
  1239. .items = {
  1240. { "LINE1 pin", 0x0 },
  1241. { "MIC1 pin", 0x1 },
  1242. { "MIC2 pin", 0x2 },
  1243. { "CD pin", 0x3 },
  1244. },
  1245. };
  1246. static struct snd_kcontrol_new cxt5047_test_mixer[] = {
  1247. /* Output only controls */
  1248. HDA_CODEC_VOLUME("OutAmp-1 Volume", 0x10, 0x0, HDA_OUTPUT),
  1249. HDA_CODEC_MUTE("OutAmp-1 Switch", 0x10,0x0, HDA_OUTPUT),
  1250. HDA_CODEC_VOLUME("OutAmp-2 Volume", 0x1c, 0x0, HDA_OUTPUT),
  1251. HDA_CODEC_MUTE("OutAmp-2 Switch", 0x1c, 0x0, HDA_OUTPUT),
  1252. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
  1253. HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
  1254. HDA_CODEC_VOLUME("HeadPhone Playback Volume", 0x13, 0x0, HDA_OUTPUT),
  1255. HDA_CODEC_MUTE("HeadPhone Playback Switch", 0x13, 0x0, HDA_OUTPUT),
  1256. HDA_CODEC_VOLUME("Line1-Out Playback Volume", 0x14, 0x0, HDA_OUTPUT),
  1257. HDA_CODEC_MUTE("Line1-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1258. HDA_CODEC_VOLUME("Line2-Out Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  1259. HDA_CODEC_MUTE("Line2-Out Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  1260. /* Modes for retasking pin widgets */
  1261. CXT_PIN_MODE("LINE1 pin mode", 0x14, CXT_PIN_DIR_INOUT),
  1262. CXT_PIN_MODE("MIC1 pin mode", 0x15, CXT_PIN_DIR_INOUT),
  1263. /* EAPD Switch Control */
  1264. CXT_EAPD_SWITCH("External Amplifier", 0x13, 0x0),
  1265. /* Loopback mixer controls */
  1266. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x12, 0x01, HDA_INPUT),
  1267. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x12, 0x01, HDA_INPUT),
  1268. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x12, 0x02, HDA_INPUT),
  1269. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x12, 0x02, HDA_INPUT),
  1270. HDA_CODEC_VOLUME("LINE Playback Volume", 0x12, 0x0, HDA_INPUT),
  1271. HDA_CODEC_MUTE("LINE Playback Switch", 0x12, 0x0, HDA_INPUT),
  1272. HDA_CODEC_VOLUME("CD Playback Volume", 0x12, 0x04, HDA_INPUT),
  1273. HDA_CODEC_MUTE("CD Playback Switch", 0x12, 0x04, HDA_INPUT),
  1274. HDA_CODEC_VOLUME("Capture-1 Volume", 0x19, 0x0, HDA_INPUT),
  1275. HDA_CODEC_MUTE("Capture-1 Switch", 0x19, 0x0, HDA_INPUT),
  1276. HDA_CODEC_VOLUME("Capture-2 Volume", 0x19, 0x1, HDA_INPUT),
  1277. HDA_CODEC_MUTE("Capture-2 Switch", 0x19, 0x1, HDA_INPUT),
  1278. HDA_CODEC_VOLUME("Capture-3 Volume", 0x19, 0x2, HDA_INPUT),
  1279. HDA_CODEC_MUTE("Capture-3 Switch", 0x19, 0x2, HDA_INPUT),
  1280. HDA_CODEC_VOLUME("Capture-4 Volume", 0x19, 0x3, HDA_INPUT),
  1281. HDA_CODEC_MUTE("Capture-4 Switch", 0x19, 0x3, HDA_INPUT),
  1282. {
  1283. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1284. .name = "Input Source",
  1285. .info = conexant_mux_enum_info,
  1286. .get = conexant_mux_enum_get,
  1287. .put = conexant_mux_enum_put,
  1288. },
  1289. HDA_CODEC_VOLUME("Mic Boost Volume", 0x1a, 0x0, HDA_OUTPUT),
  1290. { } /* end */
  1291. };
  1292. static struct hda_verb cxt5047_test_init_verbs[] = {
  1293. /* Enable retasking pins as output, initially without power amp */
  1294. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1295. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1296. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1297. /* Disable digital (SPDIF) pins initially, but users can enable
  1298. * them via a mixer switch. In the case of SPDIF-out, this initverb
  1299. * payload also sets the generation to 0, output to be in "consumer"
  1300. * PCM format, copyright asserted, no pre-emphasis and no validity
  1301. * control.
  1302. */
  1303. {0x18, AC_VERB_SET_DIGI_CONVERT_1, 0},
  1304. /* Ensure mic1, mic2, line1 pin widgets take input from the
  1305. * OUT1 sum bus when acting as an output.
  1306. */
  1307. {0x1a, AC_VERB_SET_CONNECT_SEL, 0},
  1308. {0x1b, AC_VERB_SET_CONNECT_SEL, 0},
  1309. /* Start with output sum widgets muted and their output gains at min */
  1310. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1311. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1312. /* Unmute retasking pin widget output buffers since the default
  1313. * state appears to be output. As the pin mode is changed by the
  1314. * user the pin mode control will take care of enabling the pin's
  1315. * input/output buffers as needed.
  1316. */
  1317. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1318. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1319. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1320. /* Mute capture amp left and right */
  1321. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1322. /* Set ADC connection select to match default mixer setting (mic1
  1323. * pin)
  1324. */
  1325. {0x12, AC_VERB_SET_CONNECT_SEL, 0x00},
  1326. /* Mute all inputs to mixer widget (even unconnected ones) */
  1327. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  1328. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  1329. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  1330. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  1331. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  1332. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  1333. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  1334. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  1335. { }
  1336. };
  1337. #endif
  1338. /* initialize jack-sensing, too */
  1339. static int cxt5047_hp_init(struct hda_codec *codec)
  1340. {
  1341. conexant_init(codec);
  1342. cxt5047_hp_automute(codec);
  1343. return 0;
  1344. }
  1345. enum {
  1346. CXT5047_LAPTOP, /* Laptops w/o EAPD support */
  1347. CXT5047_LAPTOP_HP, /* Some HP laptops */
  1348. CXT5047_LAPTOP_EAPD, /* Laptops with EAPD support */
  1349. #ifdef CONFIG_SND_DEBUG
  1350. CXT5047_TEST,
  1351. #endif
  1352. CXT5047_MODELS
  1353. };
  1354. static const char *cxt5047_models[CXT5047_MODELS] = {
  1355. [CXT5047_LAPTOP] = "laptop",
  1356. [CXT5047_LAPTOP_HP] = "laptop-hp",
  1357. [CXT5047_LAPTOP_EAPD] = "laptop-eapd",
  1358. #ifdef CONFIG_SND_DEBUG
  1359. [CXT5047_TEST] = "test",
  1360. #endif
  1361. };
  1362. static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
  1363. SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
  1364. SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
  1365. CXT5047_LAPTOP),
  1366. SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
  1367. {}
  1368. };
  1369. static int patch_cxt5047(struct hda_codec *codec)
  1370. {
  1371. struct conexant_spec *spec;
  1372. int board_config;
  1373. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1374. if (!spec)
  1375. return -ENOMEM;
  1376. codec->spec = spec;
  1377. codec->pin_amp_workaround = 1;
  1378. spec->multiout.max_channels = 2;
  1379. spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
  1380. spec->multiout.dac_nids = cxt5047_dac_nids;
  1381. spec->multiout.dig_out_nid = CXT5047_SPDIF_OUT;
  1382. spec->num_adc_nids = 1;
  1383. spec->adc_nids = cxt5047_adc_nids;
  1384. spec->capsrc_nids = cxt5047_capsrc_nids;
  1385. spec->num_mixers = 1;
  1386. spec->mixers[0] = cxt5047_base_mixers;
  1387. spec->num_init_verbs = 1;
  1388. spec->init_verbs[0] = cxt5047_init_verbs;
  1389. spec->spdif_route = 0;
  1390. spec->num_channel_mode = ARRAY_SIZE(cxt5047_modes),
  1391. spec->channel_mode = cxt5047_modes,
  1392. codec->patch_ops = conexant_patch_ops;
  1393. board_config = snd_hda_check_board_config(codec, CXT5047_MODELS,
  1394. cxt5047_models,
  1395. cxt5047_cfg_tbl);
  1396. switch (board_config) {
  1397. case CXT5047_LAPTOP:
  1398. spec->num_mixers = 2;
  1399. spec->mixers[1] = cxt5047_hp_spk_mixers;
  1400. codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
  1401. break;
  1402. case CXT5047_LAPTOP_HP:
  1403. spec->num_mixers = 2;
  1404. spec->mixers[1] = cxt5047_hp_only_mixers;
  1405. codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
  1406. codec->patch_ops.init = cxt5047_hp_init;
  1407. break;
  1408. case CXT5047_LAPTOP_EAPD:
  1409. spec->input_mux = &cxt5047_toshiba_capture_source;
  1410. spec->num_mixers = 2;
  1411. spec->mixers[1] = cxt5047_hp_spk_mixers;
  1412. spec->num_init_verbs = 2;
  1413. spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
  1414. codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
  1415. break;
  1416. #ifdef CONFIG_SND_DEBUG
  1417. case CXT5047_TEST:
  1418. spec->input_mux = &cxt5047_test_capture_source;
  1419. spec->mixers[0] = cxt5047_test_mixer;
  1420. spec->init_verbs[0] = cxt5047_test_init_verbs;
  1421. codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
  1422. #endif
  1423. }
  1424. spec->vmaster_nid = 0x13;
  1425. switch (codec->subsystem_id >> 16) {
  1426. case 0x103c:
  1427. /* HP laptops have really bad sound over 0 dB on NID 0x10.
  1428. * Fix max PCM level to 0 dB (originally it has 0x1e steps
  1429. * with 0 dB offset 0x17)
  1430. */
  1431. snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT,
  1432. (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
  1433. (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  1434. (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  1435. (1 << AC_AMPCAP_MUTE_SHIFT));
  1436. break;
  1437. }
  1438. return 0;
  1439. }
  1440. /* Conexant 5051 specific */
  1441. static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
  1442. static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
  1443. static struct hda_channel_mode cxt5051_modes[1] = {
  1444. { 2, NULL },
  1445. };
  1446. static void cxt5051_update_speaker(struct hda_codec *codec)
  1447. {
  1448. struct conexant_spec *spec = codec->spec;
  1449. unsigned int pinctl;
  1450. /* headphone pin */
  1451. pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0;
  1452. snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1453. pinctl);
  1454. /* speaker pin */
  1455. pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
  1456. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1457. pinctl);
  1458. /* on ideapad there is an aditional speaker (subwoofer) to mute */
  1459. if (spec->ideapad)
  1460. snd_hda_codec_write(codec, 0x1b, 0,
  1461. AC_VERB_SET_PIN_WIDGET_CONTROL,
  1462. pinctl);
  1463. }
  1464. /* turn on/off EAPD (+ mute HP) as a master switch */
  1465. static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
  1466. struct snd_ctl_elem_value *ucontrol)
  1467. {
  1468. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1469. if (!cxt_eapd_put(kcontrol, ucontrol))
  1470. return 0;
  1471. cxt5051_update_speaker(codec);
  1472. return 1;
  1473. }
  1474. /* toggle input of built-in and mic jack appropriately */
  1475. static void cxt5051_portb_automic(struct hda_codec *codec)
  1476. {
  1477. struct conexant_spec *spec = codec->spec;
  1478. unsigned int present;
  1479. if (!(spec->auto_mic & AUTO_MIC_PORTB))
  1480. return;
  1481. present = snd_hda_jack_detect(codec, 0x17);
  1482. snd_hda_codec_write(codec, 0x14, 0,
  1483. AC_VERB_SET_CONNECT_SEL,
  1484. present ? 0x01 : 0x00);
  1485. }
  1486. /* switch the current ADC according to the jack state */
  1487. static void cxt5051_portc_automic(struct hda_codec *codec)
  1488. {
  1489. struct conexant_spec *spec = codec->spec;
  1490. unsigned int present;
  1491. hda_nid_t new_adc;
  1492. if (!(spec->auto_mic & AUTO_MIC_PORTC))
  1493. return;
  1494. present = snd_hda_jack_detect(codec, 0x18);
  1495. if (present)
  1496. spec->cur_adc_idx = 1;
  1497. else
  1498. spec->cur_adc_idx = 0;
  1499. new_adc = spec->adc_nids[spec->cur_adc_idx];
  1500. if (spec->cur_adc && spec->cur_adc != new_adc) {
  1501. /* stream is running, let's swap the current ADC */
  1502. snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
  1503. spec->cur_adc = new_adc;
  1504. snd_hda_codec_setup_stream(codec, new_adc,
  1505. spec->cur_adc_stream_tag, 0,
  1506. spec->cur_adc_format);
  1507. }
  1508. }
  1509. /* mute internal speaker if HP is plugged */
  1510. static void cxt5051_hp_automute(struct hda_codec *codec)
  1511. {
  1512. struct conexant_spec *spec = codec->spec;
  1513. spec->hp_present = snd_hda_jack_detect(codec, 0x16);
  1514. cxt5051_update_speaker(codec);
  1515. }
  1516. /* unsolicited event for HP jack sensing */
  1517. static void cxt5051_hp_unsol_event(struct hda_codec *codec,
  1518. unsigned int res)
  1519. {
  1520. int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20;
  1521. switch (res >> 26) {
  1522. case CONEXANT_HP_EVENT:
  1523. cxt5051_hp_automute(codec);
  1524. break;
  1525. case CXT5051_PORTB_EVENT:
  1526. cxt5051_portb_automic(codec);
  1527. break;
  1528. case CXT5051_PORTC_EVENT:
  1529. cxt5051_portc_automic(codec);
  1530. break;
  1531. }
  1532. conexant_report_jack(codec, nid);
  1533. }
  1534. static struct snd_kcontrol_new cxt5051_playback_mixers[] = {
  1535. HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
  1536. {
  1537. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1538. .name = "Master Playback Switch",
  1539. .info = cxt_eapd_info,
  1540. .get = cxt_eapd_get,
  1541. .put = cxt5051_hp_master_sw_put,
  1542. .private_value = 0x1a,
  1543. },
  1544. {}
  1545. };
  1546. static struct snd_kcontrol_new cxt5051_capture_mixers[] = {
  1547. HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
  1548. HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
  1549. HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT),
  1550. HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT),
  1551. HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT),
  1552. HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT),
  1553. {}
  1554. };
  1555. static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
  1556. HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
  1557. HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
  1558. HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT),
  1559. HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT),
  1560. {}
  1561. };
  1562. static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = {
  1563. HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT),
  1564. HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT),
  1565. {}
  1566. };
  1567. static struct snd_kcontrol_new cxt5051_f700_mixers[] = {
  1568. HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT),
  1569. HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT),
  1570. {}
  1571. };
  1572. static struct snd_kcontrol_new cxt5051_toshiba_mixers[] = {
  1573. HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT),
  1574. HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT),
  1575. HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT),
  1576. HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT),
  1577. {}
  1578. };
  1579. static struct hda_verb cxt5051_init_verbs[] = {
  1580. /* Line in, Mic */
  1581. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
  1582. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1583. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
  1584. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1585. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1586. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
  1587. /* SPK */
  1588. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1589. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  1590. /* HP, Amp */
  1591. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1592. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  1593. /* DAC1 */
  1594. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1595. /* Record selector: Int mic */
  1596. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
  1597. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
  1598. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
  1599. /* SPDIF route: PCM */
  1600. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1601. {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
  1602. /* EAPD */
  1603. {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
  1604. {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
  1605. { } /* end */
  1606. };
  1607. static struct hda_verb cxt5051_hp_dv6736_init_verbs[] = {
  1608. /* Line in, Mic */
  1609. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
  1610. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1611. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
  1612. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
  1613. /* SPK */
  1614. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1615. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  1616. /* HP, Amp */
  1617. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1618. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  1619. /* DAC1 */
  1620. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1621. /* Record selector: Int mic */
  1622. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
  1623. {0x14, AC_VERB_SET_CONNECT_SEL, 0x1},
  1624. /* SPDIF route: PCM */
  1625. {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
  1626. /* EAPD */
  1627. {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
  1628. {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
  1629. { } /* end */
  1630. };
  1631. static struct hda_verb cxt5051_lenovo_x200_init_verbs[] = {
  1632. /* Line in, Mic */
  1633. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
  1634. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1635. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
  1636. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1637. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1638. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
  1639. /* SPK */
  1640. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1641. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  1642. /* HP, Amp */
  1643. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1644. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  1645. /* Docking HP */
  1646. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1647. {0x19, AC_VERB_SET_CONNECT_SEL, 0x00},
  1648. /* DAC1 */
  1649. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1650. /* Record selector: Int mic */
  1651. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
  1652. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
  1653. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
  1654. /* SPDIF route: PCM */
  1655. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* needed for W500 Advanced Mini Dock 250410 */
  1656. {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
  1657. /* EAPD */
  1658. {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
  1659. {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
  1660. {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
  1661. { } /* end */
  1662. };
  1663. static struct hda_verb cxt5051_f700_init_verbs[] = {
  1664. /* Line in, Mic */
  1665. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
  1666. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1667. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
  1668. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
  1669. /* SPK */
  1670. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1671. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  1672. /* HP, Amp */
  1673. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1674. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  1675. /* DAC1 */
  1676. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1677. /* Record selector: Int mic */
  1678. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
  1679. {0x14, AC_VERB_SET_CONNECT_SEL, 0x1},
  1680. /* SPDIF route: PCM */
  1681. {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
  1682. /* EAPD */
  1683. {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
  1684. {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
  1685. { } /* end */
  1686. };
  1687. static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid,
  1688. unsigned int event)
  1689. {
  1690. snd_hda_codec_write(codec, nid, 0,
  1691. AC_VERB_SET_UNSOLICITED_ENABLE,
  1692. AC_USRSP_EN | event);
  1693. #ifdef CONFIG_SND_HDA_INPUT_JACK
  1694. conexant_add_jack(codec, nid, SND_JACK_MICROPHONE);
  1695. conexant_report_jack(codec, nid);
  1696. #endif
  1697. }
  1698. static struct hda_verb cxt5051_ideapad_init_verbs[] = {
  1699. /* Subwoofer */
  1700. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1701. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1702. { } /* end */
  1703. };
  1704. /* initialize jack-sensing, too */
  1705. static int cxt5051_init(struct hda_codec *codec)
  1706. {
  1707. struct conexant_spec *spec = codec->spec;
  1708. conexant_init(codec);
  1709. conexant_init_jacks(codec);
  1710. if (spec->auto_mic & AUTO_MIC_PORTB)
  1711. cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT);
  1712. if (spec->auto_mic & AUTO_MIC_PORTC)
  1713. cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT);
  1714. if (codec->patch_ops.unsol_event) {
  1715. cxt5051_hp_automute(codec);
  1716. cxt5051_portb_automic(codec);
  1717. cxt5051_portc_automic(codec);
  1718. }
  1719. return 0;
  1720. }
  1721. enum {
  1722. CXT5051_LAPTOP, /* Laptops w/ EAPD support */
  1723. CXT5051_HP, /* no docking */
  1724. CXT5051_HP_DV6736, /* HP without mic switch */
  1725. CXT5051_LENOVO_X200, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */
  1726. CXT5051_F700, /* HP Compaq Presario F700 */
  1727. CXT5051_TOSHIBA, /* Toshiba M300 & co */
  1728. CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */
  1729. CXT5051_MODELS
  1730. };
  1731. static const char *cxt5051_models[CXT5051_MODELS] = {
  1732. [CXT5051_LAPTOP] = "laptop",
  1733. [CXT5051_HP] = "hp",
  1734. [CXT5051_HP_DV6736] = "hp-dv6736",
  1735. [CXT5051_LENOVO_X200] = "lenovo-x200",
  1736. [CXT5051_F700] = "hp-700",
  1737. [CXT5051_TOSHIBA] = "toshiba",
  1738. [CXT5051_IDEAPAD] = "ideapad",
  1739. };
  1740. static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
  1741. SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736),
  1742. SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP),
  1743. SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700),
  1744. SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA),
  1745. SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
  1746. CXT5051_LAPTOP),
  1747. SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
  1748. SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200),
  1749. SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD),
  1750. {}
  1751. };
  1752. static int patch_cxt5051(struct hda_codec *codec)
  1753. {
  1754. struct conexant_spec *spec;
  1755. int board_config;
  1756. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1757. if (!spec)
  1758. return -ENOMEM;
  1759. codec->spec = spec;
  1760. codec->pin_amp_workaround = 1;
  1761. codec->patch_ops = conexant_patch_ops;
  1762. codec->patch_ops.init = cxt5051_init;
  1763. spec->multiout.max_channels = 2;
  1764. spec->multiout.num_dacs = ARRAY_SIZE(cxt5051_dac_nids);
  1765. spec->multiout.dac_nids = cxt5051_dac_nids;
  1766. spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT;
  1767. spec->num_adc_nids = 1; /* not 2; via auto-mic switch */
  1768. spec->adc_nids = cxt5051_adc_nids;
  1769. spec->num_mixers = 2;
  1770. spec->mixers[0] = cxt5051_capture_mixers;
  1771. spec->mixers[1] = cxt5051_playback_mixers;
  1772. spec->num_init_verbs = 1;
  1773. spec->init_verbs[0] = cxt5051_init_verbs;
  1774. spec->spdif_route = 0;
  1775. spec->num_channel_mode = ARRAY_SIZE(cxt5051_modes);
  1776. spec->channel_mode = cxt5051_modes;
  1777. spec->cur_adc = 0;
  1778. spec->cur_adc_idx = 0;
  1779. set_beep_amp(spec, 0x13, 0, HDA_OUTPUT);
  1780. codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
  1781. board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
  1782. cxt5051_models,
  1783. cxt5051_cfg_tbl);
  1784. spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC;
  1785. switch (board_config) {
  1786. case CXT5051_HP:
  1787. spec->mixers[0] = cxt5051_hp_mixers;
  1788. break;
  1789. case CXT5051_HP_DV6736:
  1790. spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs;
  1791. spec->mixers[0] = cxt5051_hp_dv6736_mixers;
  1792. spec->auto_mic = 0;
  1793. break;
  1794. case CXT5051_LENOVO_X200:
  1795. spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs;
  1796. break;
  1797. case CXT5051_F700:
  1798. spec->init_verbs[0] = cxt5051_f700_init_verbs;
  1799. spec->mixers[0] = cxt5051_f700_mixers;
  1800. spec->auto_mic = 0;
  1801. break;
  1802. case CXT5051_TOSHIBA:
  1803. spec->mixers[0] = cxt5051_toshiba_mixers;
  1804. spec->auto_mic = AUTO_MIC_PORTB;
  1805. break;
  1806. case CXT5051_IDEAPAD:
  1807. spec->init_verbs[spec->num_init_verbs++] =
  1808. cxt5051_ideapad_init_verbs;
  1809. spec->ideapad = 1;
  1810. break;
  1811. }
  1812. if (spec->beep_amp)
  1813. snd_hda_attach_beep_device(codec, spec->beep_amp);
  1814. return 0;
  1815. }
  1816. /* Conexant 5066 specific */
  1817. static hda_nid_t cxt5066_dac_nids[1] = { 0x10 };
  1818. static hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 };
  1819. static hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 };
  1820. #define CXT5066_SPDIF_OUT 0x21
  1821. /* OLPC's microphone port is DC coupled for use with external sensors,
  1822. * therefore we use a 50% mic bias in order to center the input signal with
  1823. * the DC input range of the codec. */
  1824. #define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
  1825. static struct hda_channel_mode cxt5066_modes[1] = {
  1826. { 2, NULL },
  1827. };
  1828. static void cxt5066_update_speaker(struct hda_codec *codec)
  1829. {
  1830. struct conexant_spec *spec = codec->spec;
  1831. unsigned int pinctl;
  1832. snd_printdd("CXT5066: update speaker, hp_present=%d\n",
  1833. spec->hp_present);
  1834. /* Port A (HP) */
  1835. pinctl = ((spec->hp_present & 1) && spec->cur_eapd) ? PIN_HP : 0;
  1836. snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1837. pinctl);
  1838. /* Port D (HP/LO) */
  1839. pinctl = ((spec->hp_present & 2) && spec->cur_eapd)
  1840. ? spec->port_d_mode : 0;
  1841. /* Mute if Port A is connected on Thinkpad */
  1842. if (spec->thinkpad && (spec->hp_present & 1))
  1843. pinctl = 0;
  1844. snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1845. pinctl);
  1846. /* CLASS_D AMP */
  1847. pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
  1848. snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1849. pinctl);
  1850. if (spec->dell_automute) {
  1851. /* DELL AIO Port Rule: PortA > PortD > IntSpk */
  1852. pinctl = (!(spec->hp_present & 1) && spec->cur_eapd)
  1853. ? PIN_OUT : 0;
  1854. snd_hda_codec_write(codec, 0x1c, 0,
  1855. AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl);
  1856. }
  1857. }
  1858. /* turn on/off EAPD (+ mute HP) as a master switch */
  1859. static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol,
  1860. struct snd_ctl_elem_value *ucontrol)
  1861. {
  1862. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1863. if (!cxt_eapd_put(kcontrol, ucontrol))
  1864. return 0;
  1865. cxt5066_update_speaker(codec);
  1866. return 1;
  1867. }
  1868. static const struct hda_input_mux cxt5066_olpc_dc_bias = {
  1869. .num_items = 3,
  1870. .items = {
  1871. { "Off", PIN_IN },
  1872. { "50%", PIN_VREF50 },
  1873. { "80%", PIN_VREF80 },
  1874. },
  1875. };
  1876. static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec)
  1877. {
  1878. struct conexant_spec *spec = codec->spec;
  1879. /* Even though port F is the DC input, the bias is controlled on port B.
  1880. * we also leave that port as an active input (but unselected) in DC mode
  1881. * just in case that is necessary to make the bias setting take effect. */
  1882. return snd_hda_codec_write_cache(codec, 0x1a, 0,
  1883. AC_VERB_SET_PIN_WIDGET_CONTROL,
  1884. cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index);
  1885. }
  1886. /* OLPC defers mic widget control until when capture is started because the
  1887. * microphone LED comes on as soon as these settings are put in place. if we
  1888. * did this before recording, it would give the false indication that recording
  1889. * is happening when it is not. */
  1890. static void cxt5066_olpc_select_mic(struct hda_codec *codec)
  1891. {
  1892. struct conexant_spec *spec = codec->spec;
  1893. if (!spec->recording)
  1894. return;
  1895. if (spec->dc_enable) {
  1896. /* in DC mode we ignore presence detection and just use the jack
  1897. * through our special DC port */
  1898. const struct hda_verb enable_dc_mode[] = {
  1899. /* disble internal mic, port C */
  1900. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  1901. /* enable DC capture, port F */
  1902. {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1903. {},
  1904. };
  1905. snd_hda_sequence_write(codec, enable_dc_mode);
  1906. /* port B input disabled (and bias set) through the following call */
  1907. cxt5066_set_olpc_dc_bias(codec);
  1908. return;
  1909. }
  1910. /* disable DC (port F) */
  1911. snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
  1912. /* external mic, port B */
  1913. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1914. spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0);
  1915. /* internal mic, port C */
  1916. snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1917. spec->ext_mic_present ? 0 : PIN_VREF80);
  1918. }
  1919. /* toggle input of built-in and mic jack appropriately */
  1920. static void cxt5066_olpc_automic(struct hda_codec *codec)
  1921. {
  1922. struct conexant_spec *spec = codec->spec;
  1923. unsigned int present;
  1924. if (spec->dc_enable) /* don't do presence detection in DC mode */
  1925. return;
  1926. present = snd_hda_codec_read(codec, 0x1a, 0,
  1927. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1928. if (present)
  1929. snd_printdd("CXT5066: external microphone detected\n");
  1930. else
  1931. snd_printdd("CXT5066: external microphone absent\n");
  1932. snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
  1933. present ? 0 : 1);
  1934. spec->ext_mic_present = !!present;
  1935. cxt5066_olpc_select_mic(codec);
  1936. }
  1937. /* toggle input of built-in digital mic and mic jack appropriately */
  1938. static void cxt5066_vostro_automic(struct hda_codec *codec)
  1939. {
  1940. unsigned int present;
  1941. struct hda_verb ext_mic_present[] = {
  1942. /* enable external mic, port B */
  1943. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1944. /* switch to external mic input */
  1945. {0x17, AC_VERB_SET_CONNECT_SEL, 0},
  1946. {0x14, AC_VERB_SET_CONNECT_SEL, 0},
  1947. /* disable internal digital mic */
  1948. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  1949. {}
  1950. };
  1951. static struct hda_verb ext_mic_absent[] = {
  1952. /* enable internal mic, port C */
  1953. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1954. /* switch to internal mic input */
  1955. {0x14, AC_VERB_SET_CONNECT_SEL, 2},
  1956. /* disable external mic, port B */
  1957. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  1958. {}
  1959. };
  1960. present = snd_hda_jack_detect(codec, 0x1a);
  1961. if (present) {
  1962. snd_printdd("CXT5066: external microphone detected\n");
  1963. snd_hda_sequence_write(codec, ext_mic_present);
  1964. } else {
  1965. snd_printdd("CXT5066: external microphone absent\n");
  1966. snd_hda_sequence_write(codec, ext_mic_absent);
  1967. }
  1968. }
  1969. /* toggle input of built-in digital mic and mic jack appropriately */
  1970. static void cxt5066_ideapad_automic(struct hda_codec *codec)
  1971. {
  1972. unsigned int present;
  1973. struct hda_verb ext_mic_present[] = {
  1974. {0x14, AC_VERB_SET_CONNECT_SEL, 0},
  1975. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1976. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  1977. {}
  1978. };
  1979. static struct hda_verb ext_mic_absent[] = {
  1980. {0x14, AC_VERB_SET_CONNECT_SEL, 2},
  1981. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1982. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  1983. {}
  1984. };
  1985. present = snd_hda_jack_detect(codec, 0x1b);
  1986. if (present) {
  1987. snd_printdd("CXT5066: external microphone detected\n");
  1988. snd_hda_sequence_write(codec, ext_mic_present);
  1989. } else {
  1990. snd_printdd("CXT5066: external microphone absent\n");
  1991. snd_hda_sequence_write(codec, ext_mic_absent);
  1992. }
  1993. }
  1994. /* toggle input of built-in digital mic and mic jack appropriately
  1995. order is: external mic -> dock mic -> interal mic */
  1996. static void cxt5066_thinkpad_automic(struct hda_codec *codec)
  1997. {
  1998. unsigned int ext_present, dock_present;
  1999. static struct hda_verb ext_mic_present[] = {
  2000. {0x14, AC_VERB_SET_CONNECT_SEL, 0},
  2001. {0x17, AC_VERB_SET_CONNECT_SEL, 1},
  2002. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2003. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2004. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2005. {}
  2006. };
  2007. static struct hda_verb dock_mic_present[] = {
  2008. {0x14, AC_VERB_SET_CONNECT_SEL, 0},
  2009. {0x17, AC_VERB_SET_CONNECT_SEL, 0},
  2010. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2011. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2012. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2013. {}
  2014. };
  2015. static struct hda_verb ext_mic_absent[] = {
  2016. {0x14, AC_VERB_SET_CONNECT_SEL, 2},
  2017. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2018. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2019. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2020. {}
  2021. };
  2022. ext_present = snd_hda_jack_detect(codec, 0x1b);
  2023. dock_present = snd_hda_jack_detect(codec, 0x1a);
  2024. if (ext_present) {
  2025. snd_printdd("CXT5066: external microphone detected\n");
  2026. snd_hda_sequence_write(codec, ext_mic_present);
  2027. } else if (dock_present) {
  2028. snd_printdd("CXT5066: dock microphone detected\n");
  2029. snd_hda_sequence_write(codec, dock_mic_present);
  2030. } else {
  2031. snd_printdd("CXT5066: external microphone absent\n");
  2032. snd_hda_sequence_write(codec, ext_mic_absent);
  2033. }
  2034. }
  2035. /* mute internal speaker if HP is plugged */
  2036. static void cxt5066_hp_automute(struct hda_codec *codec)
  2037. {
  2038. struct conexant_spec *spec = codec->spec;
  2039. unsigned int portA, portD;
  2040. /* Port A */
  2041. portA = snd_hda_jack_detect(codec, 0x19);
  2042. /* Port D */
  2043. portD = snd_hda_jack_detect(codec, 0x1c);
  2044. spec->hp_present = !!(portA);
  2045. spec->hp_present |= portD ? 2 : 0;
  2046. snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n",
  2047. portA, portD, spec->hp_present);
  2048. cxt5066_update_speaker(codec);
  2049. }
  2050. /* unsolicited event for jack sensing */
  2051. static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res)
  2052. {
  2053. struct conexant_spec *spec = codec->spec;
  2054. snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26);
  2055. switch (res >> 26) {
  2056. case CONEXANT_HP_EVENT:
  2057. cxt5066_hp_automute(codec);
  2058. break;
  2059. case CONEXANT_MIC_EVENT:
  2060. /* ignore mic events in DC mode; we're always using the jack */
  2061. if (!spec->dc_enable)
  2062. cxt5066_olpc_automic(codec);
  2063. break;
  2064. }
  2065. }
  2066. /* unsolicited event for jack sensing */
  2067. static void cxt5066_vostro_event(struct hda_codec *codec, unsigned int res)
  2068. {
  2069. snd_printdd("CXT5066_vostro: unsol event %x (%x)\n", res, res >> 26);
  2070. switch (res >> 26) {
  2071. case CONEXANT_HP_EVENT:
  2072. cxt5066_hp_automute(codec);
  2073. break;
  2074. case CONEXANT_MIC_EVENT:
  2075. cxt5066_vostro_automic(codec);
  2076. break;
  2077. }
  2078. }
  2079. /* unsolicited event for jack sensing */
  2080. static void cxt5066_ideapad_event(struct hda_codec *codec, unsigned int res)
  2081. {
  2082. snd_printdd("CXT5066_ideapad: unsol event %x (%x)\n", res, res >> 26);
  2083. switch (res >> 26) {
  2084. case CONEXANT_HP_EVENT:
  2085. cxt5066_hp_automute(codec);
  2086. break;
  2087. case CONEXANT_MIC_EVENT:
  2088. cxt5066_ideapad_automic(codec);
  2089. break;
  2090. }
  2091. }
  2092. /* unsolicited event for jack sensing */
  2093. static void cxt5066_thinkpad_event(struct hda_codec *codec, unsigned int res)
  2094. {
  2095. snd_printdd("CXT5066_thinkpad: unsol event %x (%x)\n", res, res >> 26);
  2096. switch (res >> 26) {
  2097. case CONEXANT_HP_EVENT:
  2098. cxt5066_hp_automute(codec);
  2099. break;
  2100. case CONEXANT_MIC_EVENT:
  2101. cxt5066_thinkpad_automic(codec);
  2102. break;
  2103. }
  2104. }
  2105. static const struct hda_input_mux cxt5066_analog_mic_boost = {
  2106. .num_items = 5,
  2107. .items = {
  2108. { "0dB", 0 },
  2109. { "10dB", 1 },
  2110. { "20dB", 2 },
  2111. { "30dB", 3 },
  2112. { "40dB", 4 },
  2113. },
  2114. };
  2115. static void cxt5066_set_mic_boost(struct hda_codec *codec)
  2116. {
  2117. struct conexant_spec *spec = codec->spec;
  2118. snd_hda_codec_write_cache(codec, 0x17, 0,
  2119. AC_VERB_SET_AMP_GAIN_MUTE,
  2120. AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT |
  2121. cxt5066_analog_mic_boost.items[spec->mic_boost].index);
  2122. if (spec->ideapad || spec->thinkpad) {
  2123. /* adjust the internal mic as well...it is not through 0x17 */
  2124. snd_hda_codec_write_cache(codec, 0x23, 0,
  2125. AC_VERB_SET_AMP_GAIN_MUTE,
  2126. AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT |
  2127. cxt5066_analog_mic_boost.
  2128. items[spec->mic_boost].index);
  2129. }
  2130. }
  2131. static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol,
  2132. struct snd_ctl_elem_info *uinfo)
  2133. {
  2134. return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo);
  2135. }
  2136. static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol,
  2137. struct snd_ctl_elem_value *ucontrol)
  2138. {
  2139. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2140. struct conexant_spec *spec = codec->spec;
  2141. ucontrol->value.enumerated.item[0] = spec->mic_boost;
  2142. return 0;
  2143. }
  2144. static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol,
  2145. struct snd_ctl_elem_value *ucontrol)
  2146. {
  2147. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2148. struct conexant_spec *spec = codec->spec;
  2149. const struct hda_input_mux *imux = &cxt5066_analog_mic_boost;
  2150. unsigned int idx;
  2151. idx = ucontrol->value.enumerated.item[0];
  2152. if (idx >= imux->num_items)
  2153. idx = imux->num_items - 1;
  2154. spec->mic_boost = idx;
  2155. if (!spec->dc_enable)
  2156. cxt5066_set_mic_boost(codec);
  2157. return 1;
  2158. }
  2159. static void cxt5066_enable_dc(struct hda_codec *codec)
  2160. {
  2161. const struct hda_verb enable_dc_mode[] = {
  2162. /* disable gain */
  2163. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2164. /* switch to DC input */
  2165. {0x17, AC_VERB_SET_CONNECT_SEL, 3},
  2166. {}
  2167. };
  2168. /* configure as input source */
  2169. snd_hda_sequence_write(codec, enable_dc_mode);
  2170. cxt5066_olpc_select_mic(codec); /* also sets configured bias */
  2171. }
  2172. static void cxt5066_disable_dc(struct hda_codec *codec)
  2173. {
  2174. /* reconfigure input source */
  2175. cxt5066_set_mic_boost(codec);
  2176. /* automic also selects the right mic if we're recording */
  2177. cxt5066_olpc_automic(codec);
  2178. }
  2179. static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol,
  2180. struct snd_ctl_elem_value *ucontrol)
  2181. {
  2182. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2183. struct conexant_spec *spec = codec->spec;
  2184. ucontrol->value.integer.value[0] = spec->dc_enable;
  2185. return 0;
  2186. }
  2187. static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol,
  2188. struct snd_ctl_elem_value *ucontrol)
  2189. {
  2190. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2191. struct conexant_spec *spec = codec->spec;
  2192. int dc_enable = !!ucontrol->value.integer.value[0];
  2193. if (dc_enable == spec->dc_enable)
  2194. return 0;
  2195. spec->dc_enable = dc_enable;
  2196. if (dc_enable)
  2197. cxt5066_enable_dc(codec);
  2198. else
  2199. cxt5066_disable_dc(codec);
  2200. return 1;
  2201. }
  2202. static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol,
  2203. struct snd_ctl_elem_info *uinfo)
  2204. {
  2205. return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo);
  2206. }
  2207. static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol,
  2208. struct snd_ctl_elem_value *ucontrol)
  2209. {
  2210. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2211. struct conexant_spec *spec = codec->spec;
  2212. ucontrol->value.enumerated.item[0] = spec->dc_input_bias;
  2213. return 0;
  2214. }
  2215. static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol,
  2216. struct snd_ctl_elem_value *ucontrol)
  2217. {
  2218. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2219. struct conexant_spec *spec = codec->spec;
  2220. const struct hda_input_mux *imux = &cxt5066_analog_mic_boost;
  2221. unsigned int idx;
  2222. idx = ucontrol->value.enumerated.item[0];
  2223. if (idx >= imux->num_items)
  2224. idx = imux->num_items - 1;
  2225. spec->dc_input_bias = idx;
  2226. if (spec->dc_enable)
  2227. cxt5066_set_olpc_dc_bias(codec);
  2228. return 1;
  2229. }
  2230. static void cxt5066_olpc_capture_prepare(struct hda_codec *codec)
  2231. {
  2232. struct conexant_spec *spec = codec->spec;
  2233. /* mark as recording and configure the microphone widget so that the
  2234. * recording LED comes on. */
  2235. spec->recording = 1;
  2236. cxt5066_olpc_select_mic(codec);
  2237. }
  2238. static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec)
  2239. {
  2240. struct conexant_spec *spec = codec->spec;
  2241. const struct hda_verb disable_mics[] = {
  2242. /* disable external mic, port B */
  2243. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2244. /* disble internal mic, port C */
  2245. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2246. /* disable DC capture, port F */
  2247. {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2248. {},
  2249. };
  2250. snd_hda_sequence_write(codec, disable_mics);
  2251. spec->recording = 0;
  2252. }
  2253. static struct hda_input_mux cxt5066_capture_source = {
  2254. .num_items = 4,
  2255. .items = {
  2256. { "Mic B", 0 },
  2257. { "Mic C", 1 },
  2258. { "Mic E", 2 },
  2259. { "Mic F", 3 },
  2260. },
  2261. };
  2262. static struct hda_bind_ctls cxt5066_bind_capture_vol_others = {
  2263. .ops = &snd_hda_bind_vol,
  2264. .values = {
  2265. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT),
  2266. HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT),
  2267. 0
  2268. },
  2269. };
  2270. static struct hda_bind_ctls cxt5066_bind_capture_sw_others = {
  2271. .ops = &snd_hda_bind_sw,
  2272. .values = {
  2273. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT),
  2274. HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT),
  2275. 0
  2276. },
  2277. };
  2278. static struct snd_kcontrol_new cxt5066_mixer_master[] = {
  2279. HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
  2280. {}
  2281. };
  2282. static struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = {
  2283. {
  2284. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2285. .name = "Master Playback Volume",
  2286. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
  2287. SNDRV_CTL_ELEM_ACCESS_TLV_READ |
  2288. SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
  2289. .subdevice = HDA_SUBDEV_AMP_FLAG,
  2290. .info = snd_hda_mixer_amp_volume_info,
  2291. .get = snd_hda_mixer_amp_volume_get,
  2292. .put = snd_hda_mixer_amp_volume_put,
  2293. .tlv = { .c = snd_hda_mixer_amp_tlv },
  2294. /* offset by 28 volume steps to limit minimum gain to -46dB */
  2295. .private_value =
  2296. HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28),
  2297. },
  2298. {}
  2299. };
  2300. static struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = {
  2301. {
  2302. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2303. .name = "DC Mode Enable Switch",
  2304. .info = snd_ctl_boolean_mono_info,
  2305. .get = cxt5066_olpc_dc_get,
  2306. .put = cxt5066_olpc_dc_put,
  2307. },
  2308. {
  2309. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2310. .name = "DC Input Bias Enum",
  2311. .info = cxt5066_olpc_dc_bias_enum_info,
  2312. .get = cxt5066_olpc_dc_bias_enum_get,
  2313. .put = cxt5066_olpc_dc_bias_enum_put,
  2314. },
  2315. {}
  2316. };
  2317. static struct snd_kcontrol_new cxt5066_mixers[] = {
  2318. {
  2319. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2320. .name = "Master Playback Switch",
  2321. .info = cxt_eapd_info,
  2322. .get = cxt_eapd_get,
  2323. .put = cxt5066_hp_master_sw_put,
  2324. .private_value = 0x1d,
  2325. },
  2326. {
  2327. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2328. .name = "Analog Mic Boost Capture Enum",
  2329. .info = cxt5066_mic_boost_mux_enum_info,
  2330. .get = cxt5066_mic_boost_mux_enum_get,
  2331. .put = cxt5066_mic_boost_mux_enum_put,
  2332. },
  2333. HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others),
  2334. HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others),
  2335. {}
  2336. };
  2337. static struct snd_kcontrol_new cxt5066_vostro_mixers[] = {
  2338. {
  2339. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2340. .name = "Int Mic Boost Capture Enum",
  2341. .info = cxt5066_mic_boost_mux_enum_info,
  2342. .get = cxt5066_mic_boost_mux_enum_get,
  2343. .put = cxt5066_mic_boost_mux_enum_put,
  2344. .private_value = 0x23 | 0x100,
  2345. },
  2346. {}
  2347. };
  2348. static struct hda_verb cxt5066_init_verbs[] = {
  2349. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */
  2350. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */
  2351. {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */
  2352. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */
  2353. /* Speakers */
  2354. {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2355. {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2356. /* HP, Amp */
  2357. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2358. {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2359. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2360. {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2361. /* DAC1 */
  2362. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2363. /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
  2364. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
  2365. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2366. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50},
  2367. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2368. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2369. /* no digital microphone support yet */
  2370. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2371. /* Audio input selector */
  2372. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
  2373. /* SPDIF route: PCM */
  2374. {0x20, AC_VERB_SET_CONNECT_SEL, 0x0},
  2375. {0x22, AC_VERB_SET_CONNECT_SEL, 0x0},
  2376. {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2377. {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2378. /* EAPD */
  2379. {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
  2380. /* not handling these yet */
  2381. {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
  2382. {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
  2383. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
  2384. {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
  2385. {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
  2386. {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
  2387. {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
  2388. {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0},
  2389. { } /* end */
  2390. };
  2391. static struct hda_verb cxt5066_init_verbs_olpc[] = {
  2392. /* Port A: headphones */
  2393. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2394. {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2395. /* Port B: external microphone */
  2396. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2397. /* Port C: internal microphone */
  2398. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2399. /* Port D: unused */
  2400. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2401. /* Port E: unused, but has primary EAPD */
  2402. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2403. {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
  2404. /* Port F: external DC input through microphone port */
  2405. {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2406. /* Port G: internal speakers */
  2407. {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2408. {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2409. /* DAC1 */
  2410. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2411. /* DAC2: unused */
  2412. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2413. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
  2414. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2415. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2416. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2417. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2418. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2419. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2420. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2421. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2422. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2423. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2424. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2425. /* Disable digital microphone port */
  2426. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2427. /* Audio input selectors */
  2428. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
  2429. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  2430. /* Disable SPDIF */
  2431. {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2432. {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2433. /* enable unsolicited events for Port A and B */
  2434. {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
  2435. {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
  2436. { } /* end */
  2437. };
  2438. static struct hda_verb cxt5066_init_verbs_vostro[] = {
  2439. /* Port A: headphones */
  2440. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2441. {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2442. /* Port B: external microphone */
  2443. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2444. /* Port C: unused */
  2445. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2446. /* Port D: unused */
  2447. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2448. /* Port E: unused, but has primary EAPD */
  2449. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2450. {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
  2451. /* Port F: unused */
  2452. {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2453. /* Port G: internal speakers */
  2454. {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2455. {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2456. /* DAC1 */
  2457. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2458. /* DAC2: unused */
  2459. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2460. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2461. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2462. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2463. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2464. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2465. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2466. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2467. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2468. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2469. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2470. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2471. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2472. /* Digital microphone port */
  2473. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2474. /* Audio input selectors */
  2475. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
  2476. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  2477. /* Disable SPDIF */
  2478. {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2479. {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2480. /* enable unsolicited events for Port A and B */
  2481. {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
  2482. {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
  2483. { } /* end */
  2484. };
  2485. static struct hda_verb cxt5066_init_verbs_ideapad[] = {
  2486. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */
  2487. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */
  2488. {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */
  2489. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */
  2490. /* Speakers */
  2491. {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2492. {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2493. /* HP, Amp */
  2494. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2495. {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2496. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2497. {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2498. /* DAC1 */
  2499. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2500. /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
  2501. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
  2502. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2503. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50},
  2504. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2505. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2506. {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */
  2507. /* Audio input selector */
  2508. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2},
  2509. {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */
  2510. /* SPDIF route: PCM */
  2511. {0x20, AC_VERB_SET_CONNECT_SEL, 0x0},
  2512. {0x22, AC_VERB_SET_CONNECT_SEL, 0x0},
  2513. {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2514. {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2515. /* internal microphone */
  2516. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable int mic */
  2517. /* EAPD */
  2518. {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
  2519. {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
  2520. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
  2521. { } /* end */
  2522. };
  2523. static struct hda_verb cxt5066_init_verbs_thinkpad[] = {
  2524. {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */
  2525. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */
  2526. /* Port G: internal speakers */
  2527. {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2528. {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2529. /* Port A: HP, Amp */
  2530. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2531. {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2532. /* Port B: Mic Dock */
  2533. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2534. /* Port C: Mic */
  2535. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2536. /* Port D: HP Dock, Amp */
  2537. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2538. {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
  2539. /* DAC1 */
  2540. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2541. /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */
  2542. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
  2543. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2544. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50},
  2545. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2546. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2547. {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */
  2548. /* Audio input selector */
  2549. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2},
  2550. {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */
  2551. /* SPDIF route: PCM */
  2552. {0x20, AC_VERB_SET_CONNECT_SEL, 0x0},
  2553. {0x22, AC_VERB_SET_CONNECT_SEL, 0x0},
  2554. {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2555. {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2556. /* internal microphone */
  2557. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable int mic */
  2558. /* EAPD */
  2559. {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
  2560. /* enable unsolicited events for Port A, B, C and D */
  2561. {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
  2562. {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
  2563. {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
  2564. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
  2565. { } /* end */
  2566. };
  2567. static struct hda_verb cxt5066_init_verbs_portd_lo[] = {
  2568. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2569. { } /* end */
  2570. };
  2571. /* initialize jack-sensing, too */
  2572. static int cxt5066_init(struct hda_codec *codec)
  2573. {
  2574. struct conexant_spec *spec = codec->spec;
  2575. snd_printdd("CXT5066: init\n");
  2576. conexant_init(codec);
  2577. if (codec->patch_ops.unsol_event) {
  2578. cxt5066_hp_automute(codec);
  2579. if (spec->dell_vostro)
  2580. cxt5066_vostro_automic(codec);
  2581. else if (spec->ideapad)
  2582. cxt5066_ideapad_automic(codec);
  2583. else if (spec->thinkpad)
  2584. cxt5066_thinkpad_automic(codec);
  2585. }
  2586. cxt5066_set_mic_boost(codec);
  2587. return 0;
  2588. }
  2589. static int cxt5066_olpc_init(struct hda_codec *codec)
  2590. {
  2591. struct conexant_spec *spec = codec->spec;
  2592. snd_printdd("CXT5066: init\n");
  2593. conexant_init(codec);
  2594. cxt5066_hp_automute(codec);
  2595. if (!spec->dc_enable) {
  2596. cxt5066_set_mic_boost(codec);
  2597. cxt5066_olpc_automic(codec);
  2598. } else {
  2599. cxt5066_enable_dc(codec);
  2600. }
  2601. return 0;
  2602. }
  2603. enum {
  2604. CXT5066_LAPTOP, /* Laptops w/ EAPD support */
  2605. CXT5066_DELL_LAPTOP, /* Dell Laptop */
  2606. CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */
  2607. CXT5066_DELL_VOSTO, /* Dell Vostro 1015i */
  2608. CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */
  2609. CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */
  2610. CXT5066_MODELS
  2611. };
  2612. static const char *cxt5066_models[CXT5066_MODELS] = {
  2613. [CXT5066_LAPTOP] = "laptop",
  2614. [CXT5066_DELL_LAPTOP] = "dell-laptop",
  2615. [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5",
  2616. [CXT5066_DELL_VOSTO] = "dell-vostro",
  2617. [CXT5066_IDEAPAD] = "ideapad",
  2618. [CXT5066_THINKPAD] = "thinkpad",
  2619. };
  2620. static struct snd_pci_quirk cxt5066_cfg_tbl[] = {
  2621. SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
  2622. CXT5066_LAPTOP),
  2623. SND_PCI_QUIRK(0x1028, 0x02f5, "Dell",
  2624. CXT5066_DELL_LAPTOP),
  2625. SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5),
  2626. SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO),
  2627. SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD),
  2628. SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5),
  2629. SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5),
  2630. SND_PCI_QUIRK(0x17aa, 0x21b2, "Thinkpad X100e", CXT5066_IDEAPAD),
  2631. SND_PCI_QUIRK(0x17aa, 0x21b3, "Thinkpad Edge 13 (197)", CXT5066_IDEAPAD),
  2632. SND_PCI_QUIRK(0x17aa, 0x21b4, "Thinkpad Edge", CXT5066_IDEAPAD),
  2633. SND_PCI_QUIRK(0x17aa, 0x3a0d, "ideapad", CXT5066_IDEAPAD),
  2634. SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD),
  2635. {}
  2636. };
  2637. static int patch_cxt5066(struct hda_codec *codec)
  2638. {
  2639. struct conexant_spec *spec;
  2640. int board_config;
  2641. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2642. if (!spec)
  2643. return -ENOMEM;
  2644. codec->spec = spec;
  2645. codec->patch_ops = conexant_patch_ops;
  2646. codec->patch_ops.init = conexant_init;
  2647. spec->dell_automute = 0;
  2648. spec->multiout.max_channels = 2;
  2649. spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids);
  2650. spec->multiout.dac_nids = cxt5066_dac_nids;
  2651. spec->multiout.dig_out_nid = CXT5066_SPDIF_OUT;
  2652. spec->num_adc_nids = 1;
  2653. spec->adc_nids = cxt5066_adc_nids;
  2654. spec->capsrc_nids = cxt5066_capsrc_nids;
  2655. spec->input_mux = &cxt5066_capture_source;
  2656. spec->port_d_mode = PIN_HP;
  2657. spec->num_init_verbs = 1;
  2658. spec->init_verbs[0] = cxt5066_init_verbs;
  2659. spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes);
  2660. spec->channel_mode = cxt5066_modes;
  2661. spec->cur_adc = 0;
  2662. spec->cur_adc_idx = 0;
  2663. set_beep_amp(spec, 0x13, 0, HDA_OUTPUT);
  2664. board_config = snd_hda_check_board_config(codec, CXT5066_MODELS,
  2665. cxt5066_models, cxt5066_cfg_tbl);
  2666. switch (board_config) {
  2667. default:
  2668. case CXT5066_LAPTOP:
  2669. spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
  2670. spec->mixers[spec->num_mixers++] = cxt5066_mixers;
  2671. break;
  2672. case CXT5066_DELL_LAPTOP:
  2673. spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
  2674. spec->mixers[spec->num_mixers++] = cxt5066_mixers;
  2675. spec->port_d_mode = PIN_OUT;
  2676. spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo;
  2677. spec->num_init_verbs++;
  2678. spec->dell_automute = 1;
  2679. break;
  2680. case CXT5066_OLPC_XO_1_5:
  2681. codec->patch_ops.init = cxt5066_olpc_init;
  2682. codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event;
  2683. spec->init_verbs[0] = cxt5066_init_verbs_olpc;
  2684. spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
  2685. spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc;
  2686. spec->mixers[spec->num_mixers++] = cxt5066_mixers;
  2687. spec->port_d_mode = 0;
  2688. spec->mic_boost = 3; /* default 30dB gain */
  2689. /* no S/PDIF out */
  2690. spec->multiout.dig_out_nid = 0;
  2691. /* input source automatically selected */
  2692. spec->input_mux = NULL;
  2693. /* our capture hooks which allow us to turn on the microphone LED
  2694. * at the right time */
  2695. spec->capture_prepare = cxt5066_olpc_capture_prepare;
  2696. spec->capture_cleanup = cxt5066_olpc_capture_cleanup;
  2697. break;
  2698. case CXT5066_DELL_VOSTO:
  2699. codec->patch_ops.init = cxt5066_init;
  2700. codec->patch_ops.unsol_event = cxt5066_vostro_event;
  2701. spec->init_verbs[0] = cxt5066_init_verbs_vostro;
  2702. spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
  2703. spec->mixers[spec->num_mixers++] = cxt5066_mixers;
  2704. spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers;
  2705. spec->port_d_mode = 0;
  2706. spec->dell_vostro = 1;
  2707. spec->mic_boost = 3; /* default 30dB gain */
  2708. /* no S/PDIF out */
  2709. spec->multiout.dig_out_nid = 0;
  2710. /* input source automatically selected */
  2711. spec->input_mux = NULL;
  2712. break;
  2713. case CXT5066_IDEAPAD:
  2714. codec->patch_ops.init = cxt5066_init;
  2715. codec->patch_ops.unsol_event = cxt5066_ideapad_event;
  2716. spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
  2717. spec->mixers[spec->num_mixers++] = cxt5066_mixers;
  2718. spec->init_verbs[0] = cxt5066_init_verbs_ideapad;
  2719. spec->port_d_mode = 0;
  2720. spec->ideapad = 1;
  2721. spec->mic_boost = 2; /* default 20dB gain */
  2722. /* no S/PDIF out */
  2723. spec->multiout.dig_out_nid = 0;
  2724. /* input source automatically selected */
  2725. spec->input_mux = NULL;
  2726. break;
  2727. case CXT5066_THINKPAD:
  2728. codec->patch_ops.init = cxt5066_init;
  2729. codec->patch_ops.unsol_event = cxt5066_thinkpad_event;
  2730. spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
  2731. spec->mixers[spec->num_mixers++] = cxt5066_mixers;
  2732. spec->init_verbs[0] = cxt5066_init_verbs_thinkpad;
  2733. spec->thinkpad = 1;
  2734. spec->port_d_mode = PIN_OUT;
  2735. spec->mic_boost = 2; /* default 20dB gain */
  2736. /* no S/PDIF out */
  2737. spec->multiout.dig_out_nid = 0;
  2738. /* input source automatically selected */
  2739. spec->input_mux = NULL;
  2740. break;
  2741. }
  2742. if (spec->beep_amp)
  2743. snd_hda_attach_beep_device(codec, spec->beep_amp);
  2744. return 0;
  2745. }
  2746. /*
  2747. */
  2748. static struct hda_codec_preset snd_hda_preset_conexant[] = {
  2749. { .id = 0x14f15045, .name = "CX20549 (Venice)",
  2750. .patch = patch_cxt5045 },
  2751. { .id = 0x14f15047, .name = "CX20551 (Waikiki)",
  2752. .patch = patch_cxt5047 },
  2753. { .id = 0x14f15051, .name = "CX20561 (Hermosa)",
  2754. .patch = patch_cxt5051 },
  2755. { .id = 0x14f15066, .name = "CX20582 (Pebble)",
  2756. .patch = patch_cxt5066 },
  2757. { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)",
  2758. .patch = patch_cxt5066 },
  2759. { .id = 0x14f15069, .name = "CX20585",
  2760. .patch = patch_cxt5066 },
  2761. {} /* terminator */
  2762. };
  2763. MODULE_ALIAS("snd-hda-codec-id:14f15045");
  2764. MODULE_ALIAS("snd-hda-codec-id:14f15047");
  2765. MODULE_ALIAS("snd-hda-codec-id:14f15051");
  2766. MODULE_ALIAS("snd-hda-codec-id:14f15066");
  2767. MODULE_ALIAS("snd-hda-codec-id:14f15067");
  2768. MODULE_ALIAS("snd-hda-codec-id:14f15069");
  2769. MODULE_LICENSE("GPL");
  2770. MODULE_DESCRIPTION("Conexant HD-audio codec");
  2771. static struct hda_codec_preset_list conexant_list = {
  2772. .preset = snd_hda_preset_conexant,
  2773. .owner = THIS_MODULE,
  2774. };
  2775. static int __init patch_conexant_init(void)
  2776. {
  2777. return snd_hda_add_codec_preset(&conexant_list);
  2778. }
  2779. static void __exit patch_conexant_exit(void)
  2780. {
  2781. snd_hda_delete_codec_preset(&conexant_list);
  2782. }
  2783. module_init(patch_conexant_init)
  2784. module_exit(patch_conexant_exit)