es7210_snd_controls.c 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581
  1. /*
  2. * ALSA SoC ES7210 adc driver
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.^M
  7. *
  8. * Notes:
  9. * ES7210 is a 4-ch ADC of Everest
  10. * This file is used for snd_soc_controls for es7210, such as
  11. * PGA gain control, mute, volume and suspend
  12. */
  13. static const DECLARE_TLV_DB_SCALE(mic_boost_tlv, 0, 300, 0);
  14. static const DECLARE_TLV_DB_SCALE(direct_gain_tlv, -9550, 50, 0);
  15. #if ES7210_CHANNELS_MAX > 0
  16. static int es7210_micboost1_setting_set(struct snd_kcontrol *kcontrol,
  17. struct snd_ctl_elem_value *ucontrol)
  18. {
  19. es7210_update_bits(0x43,
  20. 0x0F,
  21. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[0]);
  22. return 0;
  23. }
  24. static int es7210_micboost1_setting_get(struct snd_kcontrol *kcontrol,
  25. struct snd_ctl_elem_value *ucontrol)
  26. {
  27. u8 val;
  28. es7210_read(0x43, &val, i2c_clt1[0]);
  29. ucontrol->value.integer.value[0] = val & 0x0f;
  30. return 0;
  31. }
  32. static int es7210_micboost2_setting_set(struct snd_kcontrol *kcontrol,
  33. struct snd_ctl_elem_value *ucontrol)
  34. {
  35. es7210_update_bits(0x44,
  36. 0x0F,
  37. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[0]);
  38. return 0;
  39. }
  40. static int es7210_micboost2_setting_get(struct snd_kcontrol *kcontrol,
  41. struct snd_ctl_elem_value *ucontrol)
  42. {
  43. u8 val;
  44. es7210_read(0x44, &val, i2c_clt1[0]);
  45. ucontrol->value.integer.value[0] = val & 0x0f;
  46. return 0;
  47. }
  48. static int es7210_micboost3_setting_set(struct snd_kcontrol *kcontrol,
  49. struct snd_ctl_elem_value *ucontrol)
  50. {
  51. es7210_update_bits(0x45,
  52. 0x0F,
  53. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[0]);
  54. return 0;
  55. }
  56. static int es7210_micboost3_setting_get(struct snd_kcontrol *kcontrol,
  57. struct snd_ctl_elem_value *ucontrol)
  58. {
  59. u8 val;
  60. es7210_read(0x45, &val, i2c_clt1[0]);
  61. ucontrol->value.integer.value[0] = val & 0x0f;
  62. return 0;
  63. }
  64. static int es7210_micboost4_setting_set(struct snd_kcontrol *kcontrol,
  65. struct snd_ctl_elem_value *ucontrol)
  66. {
  67. es7210_update_bits(0x46,
  68. 0x0F,
  69. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[0]);
  70. return 0;
  71. }
  72. static int es7210_micboost4_setting_get(struct snd_kcontrol *kcontrol,
  73. struct snd_ctl_elem_value *ucontrol)
  74. {
  75. u8 val;
  76. es7210_read(0x46, &val, i2c_clt1[0]);
  77. ucontrol->value.integer.value[0] = val & 0x0f;
  78. return 0;
  79. }
  80. static int es7210_adc1_mute_set(struct snd_kcontrol *kcontrol,
  81. struct snd_ctl_elem_value *ucontrol)
  82. {
  83. es7210_update_bits(ES7210_ADC12_MUTE_REG15,
  84. 0x01,
  85. ucontrol->value.integer.value[0] & 0x01,
  86. i2c_clt1[0]);
  87. return 0;
  88. }
  89. static int es7210_adc1_mute_get(struct snd_kcontrol *kcontrol,
  90. struct snd_ctl_elem_value *ucontrol)
  91. {
  92. u8 val;
  93. es7210_read(ES7210_ADC12_MUTE_REG15, &val, i2c_clt1[0]);
  94. ucontrol->value.integer.value[0] = val & 0x01;
  95. return 0;
  96. }
  97. static int es7210_adc2_mute_set(struct snd_kcontrol *kcontrol,
  98. struct snd_ctl_elem_value *ucontrol)
  99. {
  100. es7210_update_bits(ES7210_ADC12_MUTE_REG15,
  101. 0x02,
  102. (ucontrol->value.integer.value[0] & 0x01) << 1,
  103. i2c_clt1[0]);
  104. return 0;
  105. }
  106. static int es7210_adc2_mute_get(struct snd_kcontrol *kcontrol,
  107. struct snd_ctl_elem_value *ucontrol)
  108. {
  109. u8 val;
  110. es7210_read(ES7210_ADC12_MUTE_REG15, &val, i2c_clt1[0]);
  111. ucontrol->value.integer.value[0] = (val & 0x02) >> 1;
  112. return 0;
  113. }
  114. static int es7210_adc3_mute_set(struct snd_kcontrol *kcontrol,
  115. struct snd_ctl_elem_value *ucontrol)
  116. {
  117. es7210_update_bits(ES7210_ADC34_MUTE_REG14,
  118. 0x01,
  119. ucontrol->value.integer.value[0] & 0x01,
  120. i2c_clt1[0]);
  121. return 0;
  122. }
  123. static int es7210_adc3_mute_get(struct snd_kcontrol *kcontrol,
  124. struct snd_ctl_elem_value *ucontrol)
  125. {
  126. u8 val;
  127. es7210_read(ES7210_ADC34_MUTE_REG14, &val, i2c_clt1[0]);
  128. ucontrol->value.integer.value[0] = val & 0x01;
  129. return 0;
  130. }
  131. static int es7210_adc4_mute_set(struct snd_kcontrol *kcontrol,
  132. struct snd_ctl_elem_value *ucontrol)
  133. {
  134. es7210_update_bits(ES7210_ADC34_MUTE_REG14,
  135. 0x02,
  136. (ucontrol->value.integer.value[0] & 0x01) << 1,
  137. i2c_clt1[0]);
  138. return 0;
  139. }
  140. static int es7210_adc4_mute_get(struct snd_kcontrol *kcontrol,
  141. struct snd_ctl_elem_value *ucontrol)
  142. {
  143. u8 val;
  144. es7210_read(ES7210_ADC34_MUTE_REG14, &val, i2c_clt1[0]);
  145. ucontrol->value.integer.value[0] = (val & 0x02) >> 1;
  146. return 0;
  147. }
  148. static int es7210_adc12_suspend_set(struct snd_kcontrol *kcontrol,
  149. struct snd_ctl_elem_value *ucontrol)
  150. {
  151. u8 val;
  152. if ((ucontrol->value.integer.value[0] & 0x01) == 1) { //suspend
  153. es7210_update_bits(0x4b, 0xff, 0xff, i2c_clt1[0]);
  154. es7210_update_bits(0x01, 0x2a, 0x2a, i2c_clt1[0]);
  155. } else {
  156. es7210_update_bits(0x4b, 0xff, 0x00, i2c_clt1[0]);
  157. es7210_read(0x01, &val, i2c_clt1[0]);
  158. val &= 0x34;
  159. es7210_write(0x01, val, i2c_clt1[0]);
  160. }
  161. return 0;
  162. }
  163. static int es7210_adc12_suspend_get(struct snd_kcontrol *kcontrol,
  164. struct snd_ctl_elem_value *ucontrol)
  165. {
  166. u8 val;
  167. es7210_read(0x4b, &val, i2c_clt1[0]);
  168. ucontrol->value.integer.value[0] = val & 0x01;
  169. return 0;
  170. }
  171. static int es7210_adc34_suspend_set(struct snd_kcontrol *kcontrol,
  172. struct snd_ctl_elem_value *ucontrol)
  173. {
  174. u8 val;
  175. if ((ucontrol->value.integer.value[0] & 0x01) == 1) { //suspend
  176. es7210_update_bits(0x4c, 0xff, 0xff, i2c_clt1[0]);
  177. es7210_update_bits(0x01, 0x34, 0x34, i2c_clt1[0]);
  178. } else {
  179. es7210_update_bits(0x4c, 0xff, 0x00, i2c_clt1[0]);
  180. es7210_read(0x01, &val, i2c_clt1[0]);
  181. val &= 0x2a;
  182. es7210_write(0x01, val, i2c_clt1[0]);
  183. }
  184. return 0;
  185. }
  186. static int es7210_adc34_suspend_get(struct snd_kcontrol *kcontrol,
  187. struct snd_ctl_elem_value *ucontrol)
  188. {
  189. u8 val;
  190. es7210_read(0x4c, &val, i2c_clt1[0]);
  191. ucontrol->value.integer.value[0] = val & 0x01;
  192. return 0;
  193. }
  194. #endif
  195. #if ES7210_CHANNELS_MAX > 4
  196. static int es7210_micboost5_setting_set(struct snd_kcontrol *kcontrol,
  197. struct snd_ctl_elem_value *ucontrol)
  198. {
  199. es7210_update_bits(0x43,
  200. 0x0F,
  201. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[1]);
  202. return 0;
  203. }
  204. static int es7210_micboost5_setting_get(struct snd_kcontrol *kcontrol,
  205. struct snd_ctl_elem_value *ucontrol)
  206. {
  207. u8 val;
  208. es7210_read(0x43, &val, i2c_clt1[1]);
  209. ucontrol->value.integer.value[0] = val & 0x0f;
  210. return 0;
  211. }
  212. static int es7210_micboost6_setting_set(struct snd_kcontrol *kcontrol,
  213. struct snd_ctl_elem_value *ucontrol)
  214. {
  215. es7210_update_bits(0x44,
  216. 0x0F,
  217. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[1]);
  218. return 0;
  219. }
  220. static int es7210_micboost6_setting_get(struct snd_kcontrol *kcontrol,
  221. struct snd_ctl_elem_value *ucontrol)
  222. {
  223. u8 val;
  224. es7210_read(0x44, &val, i2c_clt1[1]);
  225. ucontrol->value.integer.value[0] = val & 0x0f;
  226. return 0;
  227. }
  228. static int es7210_micboost7_setting_set(struct snd_kcontrol *kcontrol,
  229. struct snd_ctl_elem_value *ucontrol)
  230. {
  231. es7210_update_bits(0x45,
  232. 0x0F,
  233. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[1]);
  234. return 0;
  235. }
  236. static int es7210_micboost7_setting_get(struct snd_kcontrol *kcontrol,
  237. struct snd_ctl_elem_value *ucontrol)
  238. {
  239. u8 val;
  240. es7210_read(0x45, &val, i2c_clt1[1]);
  241. ucontrol->value.integer.value[0] = val & 0x0f;
  242. return 0;
  243. }
  244. static int es7210_micboost8_setting_set(struct snd_kcontrol *kcontrol,
  245. struct snd_ctl_elem_value *ucontrol)
  246. {
  247. es7210_update_bits(0x46,
  248. 0x0F,
  249. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[1]);
  250. return 0;
  251. }
  252. static int es7210_micboost8_setting_get(struct snd_kcontrol *kcontrol,
  253. struct snd_ctl_elem_value *ucontrol)
  254. {
  255. u8 val;
  256. es7210_read(0x46, &val, i2c_clt1[1]);
  257. ucontrol->value.integer.value[0] = val & 0x0f;
  258. return 0;
  259. }
  260. static int es7210_adc5_mute_set(struct snd_kcontrol *kcontrol,
  261. struct snd_ctl_elem_value *ucontrol)
  262. {
  263. es7210_update_bits(ES7210_ADC12_MUTE_REG15,
  264. 0x01,
  265. ucontrol->value.integer.value[0] & 0x01,
  266. i2c_clt1[1]);
  267. return 0;
  268. }
  269. static int es7210_adc5_mute_get(struct snd_kcontrol *kcontrol,
  270. struct snd_ctl_elem_value *ucontrol)
  271. {
  272. u8 val;
  273. es7210_read(ES7210_ADC12_MUTE_REG15, &val, i2c_clt1[1]);
  274. ucontrol->value.integer.value[0] = val & 0x01;
  275. return 0;
  276. }
  277. static int es7210_adc6_mute_set(struct snd_kcontrol *kcontrol,
  278. struct snd_ctl_elem_value *ucontrol)
  279. {
  280. es7210_update_bits(ES7210_ADC12_MUTE_REG15,
  281. 0x02,
  282. (ucontrol->value.integer.value[0] & 0x01) << 1,
  283. i2c_clt1[1]);
  284. return 0;
  285. }
  286. static int es7210_adc6_mute_get(struct snd_kcontrol *kcontrol,
  287. struct snd_ctl_elem_value *ucontrol)
  288. {
  289. u8 val;
  290. es7210_read(ES7210_ADC12_MUTE_REG15, &val, i2c_clt1[1]);
  291. ucontrol->value.integer.value[0] = (val & 0x02) >> 1;
  292. return 0;
  293. }
  294. static int es7210_adc7_mute_set(struct snd_kcontrol *kcontrol,
  295. struct snd_ctl_elem_value *ucontrol)
  296. {
  297. es7210_update_bits(ES7210_ADC34_MUTE_REG14,
  298. 0x01,
  299. ucontrol->value.integer.value[0] & 0x01,
  300. i2c_clt1[1]);
  301. return 0;
  302. }
  303. static int es7210_adc7_mute_get(struct snd_kcontrol *kcontrol,
  304. struct snd_ctl_elem_value *ucontrol)
  305. {
  306. u8 val;
  307. es7210_read(ES7210_ADC34_MUTE_REG14, &val, i2c_clt1[1]);
  308. ucontrol->value.integer.value[0] = val & 0x01;
  309. return 0;
  310. }
  311. static int es7210_adc8_mute_set(struct snd_kcontrol *kcontrol,
  312. struct snd_ctl_elem_value *ucontrol)
  313. {
  314. es7210_update_bits(ES7210_ADC34_MUTE_REG14,
  315. 0x02,
  316. (ucontrol->value.integer.value[0] & 0x01) << 1,
  317. i2c_clt1[1]);
  318. return 0;
  319. }
  320. static int es7210_adc8_mute_get(struct snd_kcontrol *kcontrol,
  321. struct snd_ctl_elem_value *ucontrol)
  322. {
  323. u8 val;
  324. es7210_read(ES7210_ADC34_MUTE_REG14, &val, i2c_clt1[1]);
  325. ucontrol->value.integer.value[0] = (val & 0x02) >> 1;
  326. return 0;
  327. }
  328. static int es7210_adc56_suspend_set(struct snd_kcontrol *kcontrol,
  329. struct snd_ctl_elem_value *ucontrol)
  330. {
  331. u8 val;
  332. if ((ucontrol->value.integer.value[0] & 0x01) == 1) { //suspend
  333. es7210_update_bits(0x4b, 0xff, 0xff, i2c_clt1[1]);
  334. es7210_update_bits(0x01, 0x2a, 0x2a, i2c_clt1[1]);
  335. } else {
  336. es7210_update_bits(0x4b, 0xff, 0x00, i2c_clt1[1]);
  337. es7210_read(0x01, &val, i2c_clt1[1]);
  338. val &= 0x34;
  339. es7210_write(0x01, val, i2c_clt1[1]);
  340. }
  341. return 0;
  342. }
  343. static int es7210_adc56_suspend_get(struct snd_kcontrol *kcontrol,
  344. struct snd_ctl_elem_value *ucontrol)
  345. {
  346. u8 val;
  347. es7210_read(0x4b, &val, i2c_clt1[1]);
  348. ucontrol->value.integer.value[0] = val & 0x01;
  349. return 0;
  350. }
  351. static int es7210_adc78_suspend_set(struct snd_kcontrol *kcontrol,
  352. struct snd_ctl_elem_value *ucontrol)
  353. {
  354. u8 val;
  355. if ((ucontrol->value.integer.value[0] & 0x01) == 1) { //suspend
  356. es7210_update_bits(0x4c, 0xff, 0xff, i2c_clt1[1]);
  357. es7210_update_bits(0x01, 0x34, 0x34, i2c_clt1[1]);
  358. } else {
  359. es7210_update_bits(0x4c, 0xff, 0x00, i2c_clt1[1]);
  360. es7210_read(0x01, &val, i2c_clt1[1]);
  361. val &= 0x2a;
  362. es7210_write(0x01, val, i2c_clt1[1]);
  363. }
  364. return 0;
  365. }
  366. static int es7210_adc78_suspend_get(struct snd_kcontrol *kcontrol,
  367. struct snd_ctl_elem_value *ucontrol)
  368. {
  369. u8 val;
  370. es7210_read(0x4c, &val, i2c_clt1[1]);
  371. ucontrol->value.integer.value[0] = val & 0x01;
  372. return 0;
  373. }
  374. #endif
  375. #if ES7210_CHANNELS_MAX > 8
  376. static int es7210_micboost9_setting_set(struct snd_kcontrol *kcontrol,
  377. struct snd_ctl_elem_value *ucontrol)
  378. {
  379. es7210_update_bits(0x43,
  380. 0x0F,
  381. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[2]);
  382. return 0;
  383. }
  384. static int es7210_micboost9_setting_get(struct snd_kcontrol *kcontrol,
  385. struct snd_ctl_elem_value *ucontrol)
  386. {
  387. u8 val;
  388. es7210_read(0x43, &val, i2c_clt1[2]);
  389. ucontrol->value.integer.value[0] = val & 0x0f;
  390. return 0;
  391. }
  392. static int es7210_micboost10_setting_set(struct snd_kcontrol *kcontrol,
  393. struct snd_ctl_elem_value *ucontrol)
  394. {
  395. es7210_update_bits(0x44,
  396. 0x0F,
  397. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[2]);
  398. return 0;
  399. }
  400. static int es7210_micboost10_setting_get(struct snd_kcontrol *kcontrol,
  401. struct snd_ctl_elem_value *ucontrol)
  402. {
  403. u8 val;
  404. es7210_read(0x44, &val, i2c_clt1[2]);
  405. ucontrol->value.integer.value[0] = val & 0x0f;
  406. return 0;
  407. }
  408. static int es7210_micboost11_setting_set(struct snd_kcontrol *kcontrol,
  409. struct snd_ctl_elem_value *ucontrol)
  410. {
  411. es7210_update_bits(0x45,
  412. 0x0F,
  413. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[2]);
  414. return 0;
  415. }
  416. static int es7210_micboost11_setting_get(struct snd_kcontrol *kcontrol,
  417. struct snd_ctl_elem_value *ucontrol)
  418. {
  419. u8 val;
  420. es7210_read(0x45, &val, i2c_clt1[2]);
  421. ucontrol->value.integer.value[0] = val & 0x0f;
  422. return 0;
  423. }
  424. static int es7210_micboost12_setting_set(struct snd_kcontrol *kcontrol,
  425. struct snd_ctl_elem_value *ucontrol)
  426. {
  427. es7210_update_bits(0x46,
  428. 0x0F,
  429. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[2]);
  430. return 0;
  431. }
  432. static int es7210_micboost12_setting_get(struct snd_kcontrol *kcontrol,
  433. struct snd_ctl_elem_value *ucontrol)
  434. {
  435. u8 val;
  436. es7210_read(0x46, &val, i2c_clt1[2]);
  437. ucontrol->value.integer.value[0] = val & 0x0f;
  438. return 0;
  439. }
  440. static int es7210_adc9_mute_set(struct snd_kcontrol *kcontrol,
  441. struct snd_ctl_elem_value *ucontrol)
  442. {
  443. es7210_update_bits(ES7210_ADC12_MUTE_REG15, 0x01,
  444. ucontrol->value.integer.value[0] & 0x01,
  445. i2c_clt1[2]);
  446. return 0;
  447. }
  448. static int es7210_adc9_mute_get(struct snd_kcontrol *kcontrol,
  449. struct snd_ctl_elem_value *ucontrol)
  450. {
  451. u8 val;
  452. es7210_read(ES7210_ADC12_MUTE_REG15, &val, i2c_clt1[2]);
  453. ucontrol->value.integer.value[0] = val & 0x01;
  454. return 0;
  455. }
  456. static int es7210_adc10_mute_set(struct snd_kcontrol *kcontrol,
  457. struct snd_ctl_elem_value *ucontrol)
  458. {
  459. es7210_update_bits(ES7210_ADC12_MUTE_REG15,
  460. 0x02,
  461. (ucontrol->value.integer.value[0] & 0x01) << 1,
  462. i2c_clt1[2]);
  463. return 0;
  464. }
  465. static int es7210_adc10_mute_get(struct snd_kcontrol *kcontrol,
  466. struct snd_ctl_elem_value *ucontrol)
  467. {
  468. u8 val;
  469. es7210_read(ES7210_ADC12_MUTE_REG15, &val, i2c_clt1[2]);
  470. ucontrol->value.integer.value[0] = (val & 0x02) >> 1;
  471. return 0;
  472. }
  473. static int es7210_adc11_mute_set(struct snd_kcontrol *kcontrol,
  474. struct snd_ctl_elem_value *ucontrol)
  475. {
  476. es7210_update_bits(ES7210_ADC34_MUTE_REG14,
  477. 0x01,
  478. ucontrol->value.integer.value[0] & 0x01,
  479. i2c_clt1[2]);
  480. return 0;
  481. }
  482. static int es7210_adc11_mute_get(struct snd_kcontrol *kcontrol,
  483. struct snd_ctl_elem_value *ucontrol)
  484. {
  485. u8 val;
  486. es7210_read(ES7210_ADC34_MUTE_REG14, &val, i2c_clt1[2]);
  487. ucontrol->value.integer.value[0] = val & 0x01;
  488. return 0;
  489. }
  490. static int es7210_adc12_mute_set(struct snd_kcontrol *kcontrol,
  491. struct snd_ctl_elem_value *ucontrol)
  492. {
  493. es7210_update_bits(ES7210_ADC34_MUTE_REG14,
  494. 0x02,
  495. (ucontrol->value.integer.value[0] & 0x01) << 1,
  496. i2c_clt1[2]);
  497. return 0;
  498. }
  499. static int es7210_adc12_mute_get(struct snd_kcontrol *kcontrol,
  500. struct snd_ctl_elem_value *ucontrol)
  501. {
  502. u8 val;
  503. es7210_read(ES7210_ADC34_MUTE_REG14, &val, i2c_clt1[2]);
  504. ucontrol->value.integer.value[0] = (val & 0x02) >> 1;
  505. return 0;
  506. }
  507. static int es7210_adc910_suspend_set(struct snd_kcontrol *kcontrol,
  508. struct snd_ctl_elem_value *ucontrol)
  509. {
  510. u8 val;
  511. if ((ucontrol->value.integer.value[0] & 0x01) == 1) { //suspend
  512. es7210_update_bits(0x4b, 0xff, 0xff, i2c_clt1[2]);
  513. es7210_update_bits(0x01, 0x2a, 0x2a, i2c_clt1[2]);
  514. } else {
  515. es7210_update_bits(0x4b, 0xff, 0x00, i2c_clt1[2]);
  516. es7210_read(0x01, &val, i2c_clt1[2]);
  517. val &= 0x34;
  518. es7210_write(0x01, val, i2c_clt1[2]);
  519. }
  520. return 0;
  521. }
  522. static int es7210_adc910_suspend_get(struct snd_kcontrol *kcontrol,
  523. struct snd_ctl_elem_value *ucontrol)
  524. {
  525. u8 val;
  526. es7210_read(0x4b, &val, i2c_clt1[2]);
  527. ucontrol->value.integer.value[0] = val & 0x01;
  528. return 0;
  529. }
  530. static int es7210_adc1112_suspend_set(struct snd_kcontrol *kcontrol,
  531. struct snd_ctl_elem_value *ucontrol)
  532. {
  533. u8 val;
  534. if ((ucontrol->value.integer.value[0] & 0x01) == 1) { //suspend
  535. es7210_update_bits(0x4c, 0xff, 0xff, i2c_clt1[2]);
  536. es7210_update_bits(0x01, 0x34, 0x34, i2c_clt1[2]);
  537. } else {
  538. es7210_update_bits(0x4c, 0xff, 0x00, i2c_clt1[2]);
  539. es7210_read(0x01, &val, i2c_clt1[2]);
  540. val &= 0x2a;
  541. es7210_write(0x01, val, i2c_clt1[2]);
  542. }
  543. return 0;
  544. }
  545. static int es7210_adc1112_suspend_get(struct snd_kcontrol *kcontrol,
  546. struct snd_ctl_elem_value *ucontrol)
  547. {
  548. u8 val;
  549. es7210_read(0x4c, &val, i2c_clt1[2]);
  550. ucontrol->value.integer.value[0] = val & 0x01;
  551. return 0;
  552. }
  553. #endif
  554. #if ES7210_CHANNELS_MAX > 12
  555. static int es7210_micboost13_setting_set(struct snd_kcontrol *kcontrol,
  556. struct snd_ctl_elem_value *ucontrol)
  557. {
  558. es7210_update_bits(0x43,
  559. 0x0F,
  560. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[3]);
  561. return 0;
  562. }
  563. static int es7210_micboost13_setting_get(struct snd_kcontrol *kcontrol,
  564. struct snd_ctl_elem_value *ucontrol)
  565. {
  566. u8 val;
  567. es7210_read(0x43, &val, i2c_clt1[3]);
  568. ucontrol->value.integer.value[0] = val & 0x0f;
  569. return 0;
  570. }
  571. static int es7210_micboost14_setting_set(struct snd_kcontrol *kcontrol,
  572. struct snd_ctl_elem_value *ucontrol)
  573. {
  574. es7210_update_bits(0x44,
  575. 0x0F,
  576. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[3]);
  577. return 0;
  578. }
  579. static int es7210_micboost14_setting_get(struct snd_kcontrol *kcontrol,
  580. struct snd_ctl_elem_value *ucontrol)
  581. {
  582. u8 val;
  583. es7210_read(0x44, &val, i2c_clt1[3]);
  584. ucontrol->value.integer.value[0] = val & 0x0f;
  585. return 0;
  586. }
  587. static int es7210_micboost15_setting_set(struct snd_kcontrol *kcontrol,
  588. struct snd_ctl_elem_value *ucontrol)
  589. {
  590. es7210_update_bits(0x45,
  591. 0x0F,
  592. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[3]);
  593. return 0;
  594. }
  595. static int es7210_micboost15_setting_get(struct snd_kcontrol *kcontrol,
  596. struct snd_ctl_elem_value *ucontrol)
  597. {
  598. u8 val;
  599. es7210_read(0x45, &val, i2c_clt1[3]);
  600. ucontrol->value.integer.value[0] = val & 0x0f;
  601. return 0;
  602. }
  603. static int es7210_micboost16_setting_set(struct snd_kcontrol *kcontrol,
  604. struct snd_ctl_elem_value *ucontrol)
  605. {
  606. es7210_update_bits(0x46,
  607. 0x0F,
  608. ucontrol->value.integer.value[0] & 0x0f, i2c_clt1[3]);
  609. return 0;
  610. }
  611. static int es7210_micboost16_setting_get(struct snd_kcontrol *kcontrol,
  612. struct snd_ctl_elem_value *ucontrol)
  613. {
  614. u8 val;
  615. es7210_read(0x46, &val, i2c_clt1[3]);
  616. ucontrol->value.integer.value[0] = val & 0x0f;
  617. return 0;
  618. }
  619. static int es7210_adc13_mute_set(struct snd_kcontrol *kcontrol,
  620. struct snd_ctl_elem_value *ucontrol)
  621. {
  622. es7210_update_bits(ES7210_ADC12_MUTE_REG15, 0x01,
  623. ucontrol->value.integer.value[0] & 0x01,
  624. i2c_clt1[3]);
  625. return 0;
  626. }
  627. static int es7210_adc13_mute_get(struct snd_kcontrol *kcontrol,
  628. struct snd_ctl_elem_value *ucontrol)
  629. {
  630. u8 val;
  631. es7210_read(ES7210_ADC12_MUTE_REG15, &val, i2c_clt1[3]);
  632. ucontrol->value.integer.value[0] = val & 0x01;
  633. return 0;
  634. }
  635. static int es7210_adc14_mute_set(struct snd_kcontrol *kcontrol,
  636. struct snd_ctl_elem_value *ucontrol)
  637. {
  638. es7210_update_bits(ES7210_ADC12_MUTE_REG15,
  639. 0x02,
  640. (ucontrol->value.integer.value[0] & 0x01) << 1,
  641. i2c_clt1[3]);
  642. return 0;
  643. }
  644. static int es7210_adc14_mute_get(struct snd_kcontrol *kcontrol,
  645. struct snd_ctl_elem_value *ucontrol)
  646. {
  647. u8 val;
  648. es7210_read(ES7210_ADC12_MUTE_REG15, &val, i2c_clt1[3]);
  649. ucontrol->value.integer.value[0] = (val & 0x02) >> 1;
  650. return 0;
  651. }
  652. static int es7210_adc15_mute_set(struct snd_kcontrol *kcontrol,
  653. struct snd_ctl_elem_value *ucontrol)
  654. {
  655. es7210_update_bits(ES7210_ADC34_MUTE_REG14,
  656. 0x01,
  657. ucontrol->value.integer.value[0] & 0x01,
  658. i2c_clt1[3]);
  659. return 0;
  660. }
  661. static int es7210_adc15_mute_get(struct snd_kcontrol *kcontrol,
  662. struct snd_ctl_elem_value *ucontrol)
  663. {
  664. u8 val;
  665. es7210_read(ES7210_ADC34_MUTE_REG14, &val, i2c_clt1[3]);
  666. ucontrol->value.integer.value[0] = val & 0x01;
  667. return 0;
  668. }
  669. static int es7210_adc16_mute_set(struct snd_kcontrol *kcontrol,
  670. struct snd_ctl_elem_value *ucontrol)
  671. {
  672. es7210_update_bits(ES7210_ADC34_MUTE_REG14,
  673. 0x02,
  674. (ucontrol->value.integer.value[0] & 0x01) << 1,
  675. i2c_clt1[3]);
  676. return 0;
  677. }
  678. static int es7210_adc16_mute_get(struct snd_kcontrol *kcontrol,
  679. struct snd_ctl_elem_value *ucontrol)
  680. {
  681. u8 val;
  682. es7210_read(ES7210_ADC34_MUTE_REG14, &val, i2c_clt1[3]);
  683. ucontrol->value.integer.value[0] = (val & 0x02) >> 1;
  684. return 0;
  685. }
  686. static int es7210_adc1314_suspend_set(struct snd_kcontrol *kcontrol,
  687. struct snd_ctl_elem_value *ucontrol)
  688. {
  689. u8 val;
  690. if ((ucontrol->value.integer.value[0] & 0x01) == 1) { //suspend
  691. es7210_update_bits(0x4b, 0xff, 0xff, i2c_clt1[3]);
  692. es7210_update_bits(0x01, 0x2a, 0x2a, i2c_clt1[3]);
  693. } else {
  694. es7210_update_bits(0x4b, 0xff, 0x00, i2c_clt1[3]);
  695. es7210_read(0x01, &val, i2c_clt1[3]);
  696. val &= 0x34;
  697. es7210_write(0x01, val, i2c_clt1[3]);
  698. }
  699. return 0;
  700. }
  701. static int es7210_adc1314_suspend_get(struct snd_kcontrol *kcontrol,
  702. struct snd_ctl_elem_value *ucontrol)
  703. {
  704. u8 val;
  705. es7210_read(0x4b, &val, i2c_clt1[3]);
  706. ucontrol->value.integer.value[0] = val & 0x01;
  707. return 0;
  708. }
  709. static int es7210_adc1516_suspend_set(struct snd_kcontrol *kcontrol,
  710. struct snd_ctl_elem_value *ucontrol)
  711. {
  712. u8 val;
  713. if ((ucontrol->value.integer.value[0] & 0x01) == 1) { //suspend
  714. es7210_update_bits(0x4c, 0xff, 0xff, i2c_clt1[3]);
  715. es7210_update_bits(0x01, 0x34, 0x34, i2c_clt1[3]);
  716. } else {
  717. es7210_update_bits(0x4c, 0xff, 0x00, i2c_clt1[3]);
  718. es7210_read(0x01, &val, i2c_clt1[3]);
  719. val &= 0x2a;
  720. es7210_write(0x01, val, i2c_clt1[3]);
  721. }
  722. return 0;
  723. }
  724. static int es7210_adc1516_suspend_get(struct snd_kcontrol *kcontrol,
  725. struct snd_ctl_elem_value *ucontrol)
  726. {
  727. u8 val;
  728. es7210_read(0x4c, &val, i2c_clt1[3]);
  729. ucontrol->value.integer.value[0] = val & 0x01;
  730. return 0;
  731. }
  732. #endif
  733. #if ES7210_CHANNELS_MAX > 0
  734. static int es7210_direct_gain_1_set(struct snd_kcontrol *kcontrol,
  735. struct snd_ctl_elem_value *ucontrol)
  736. {
  737. es7210_update_bits(0x1e,
  738. 0xFF,
  739. ucontrol->value.integer.value[0], i2c_clt1[0]);
  740. return 0;
  741. }
  742. static int es7210_direct_gain_1_get(struct snd_kcontrol *kcontrol,
  743. struct snd_ctl_elem_value *ucontrol)
  744. {
  745. u8 val;
  746. es7210_read(0x1e, &val, i2c_clt1[0]);
  747. ucontrol->value.integer.value[0] = val;
  748. return 0;
  749. }
  750. static int es7210_direct_gain_2_set(struct snd_kcontrol *kcontrol,
  751. struct snd_ctl_elem_value *ucontrol)
  752. {
  753. es7210_update_bits(0x1D,
  754. 0xFF,
  755. ucontrol->value.integer.value[0], i2c_clt1[0]);
  756. return 0;
  757. }
  758. static int es7210_direct_gain_2_get(struct snd_kcontrol *kcontrol,
  759. struct snd_ctl_elem_value *ucontrol)
  760. {
  761. u8 val;
  762. es7210_read(0x1D, &val, i2c_clt1[0]);
  763. ucontrol->value.integer.value[0] = val;
  764. return 0;
  765. }
  766. static int es7210_direct_gain_3_set(struct snd_kcontrol *kcontrol,
  767. struct snd_ctl_elem_value *ucontrol)
  768. {
  769. es7210_update_bits(0x1C,
  770. 0xFF,
  771. ucontrol->value.integer.value[0], i2c_clt1[0]);
  772. return 0;
  773. }
  774. static int es7210_direct_gain_3_get(struct snd_kcontrol *kcontrol,
  775. struct snd_ctl_elem_value *ucontrol)
  776. {
  777. u8 val;
  778. es7210_read(0x1C, &val, i2c_clt1[0]);
  779. ucontrol->value.integer.value[0] = val;
  780. return 0;
  781. }
  782. static int es7210_direct_gain_4_set(struct snd_kcontrol *kcontrol,
  783. struct snd_ctl_elem_value *ucontrol)
  784. {
  785. es7210_update_bits(0x1B,
  786. 0xFF,
  787. ucontrol->value.integer.value[0], i2c_clt1[0]);
  788. return 0;
  789. }
  790. static int es7210_direct_gain_4_get(struct snd_kcontrol *kcontrol,
  791. struct snd_ctl_elem_value *ucontrol)
  792. {
  793. u8 val;
  794. es7210_read(0x1B, &val, i2c_clt1[0]);
  795. ucontrol->value.integer.value[0] = val;
  796. return 0;
  797. }
  798. static int es7210_direct_gain_12_sameon_set(struct snd_kcontrol *kcontrol,
  799. struct snd_ctl_elem_value
  800. *ucontrol)
  801. {
  802. es7210_update_bits(0x1a,
  803. 0x01,
  804. ucontrol->value.integer.value[0], i2c_clt1[0]);
  805. return 0;
  806. }
  807. static int es7210_direct_gain_12_sameon_get(struct snd_kcontrol *kcontrol,
  808. struct snd_ctl_elem_value
  809. *ucontrol)
  810. {
  811. u8 val;
  812. es7210_read(0x1a, &val, i2c_clt1[0]);
  813. ucontrol->value.integer.value[0] = val;
  814. return 0;
  815. }
  816. static int es7210_direct_gain_34_sameon_set(struct snd_kcontrol *kcontrol,
  817. struct snd_ctl_elem_value
  818. *ucontrol)
  819. {
  820. es7210_update_bits(0x1a,
  821. 0x02,
  822. ucontrol->value.integer.value[0], i2c_clt1[0]);
  823. return 0;
  824. }
  825. static int es7210_direct_gain_34_sameon_get(struct snd_kcontrol *kcontrol,
  826. struct snd_ctl_elem_value
  827. *ucontrol)
  828. {
  829. u8 val;
  830. es7210_read(0x1a, &val, i2c_clt1[0]);
  831. ucontrol->value.integer.value[0] = val;
  832. return 0;
  833. }
  834. #endif
  835. #if ES7210_CHANNELS_MAX > 4
  836. static int es7210_direct_gain_5_set(struct snd_kcontrol *kcontrol,
  837. struct snd_ctl_elem_value *ucontrol)
  838. {
  839. es7210_update_bits(0x1e,
  840. 0xFF,
  841. ucontrol->value.integer.value[0], i2c_clt1[1]);
  842. return 0;
  843. }
  844. static int es7210_direct_gain_5_get(struct snd_kcontrol *kcontrol,
  845. struct snd_ctl_elem_value *ucontrol)
  846. {
  847. u8 val;
  848. es7210_read(0x1e, &val, i2c_clt1[1]);
  849. ucontrol->value.integer.value[0] = val;
  850. return 0;
  851. }
  852. static int es7210_direct_gain_6_set(struct snd_kcontrol *kcontrol,
  853. struct snd_ctl_elem_value *ucontrol)
  854. {
  855. es7210_update_bits(0x1D,
  856. 0xFF,
  857. ucontrol->value.integer.value[0], i2c_clt1[1]);
  858. return 0;
  859. }
  860. static int es7210_direct_gain_6_get(struct snd_kcontrol *kcontrol,
  861. struct snd_ctl_elem_value *ucontrol)
  862. {
  863. u8 val;
  864. es7210_read(0x1D, &val, i2c_clt1[1]);
  865. ucontrol->value.integer.value[0] = val;
  866. return 0;
  867. }
  868. static int es7210_direct_gain_7_set(struct snd_kcontrol *kcontrol,
  869. struct snd_ctl_elem_value *ucontrol)
  870. {
  871. es7210_update_bits(0x1C,
  872. 0xFF,
  873. ucontrol->value.integer.value[0], i2c_clt1[1]);
  874. return 0;
  875. }
  876. static int es7210_direct_gain_7_get(struct snd_kcontrol *kcontrol,
  877. struct snd_ctl_elem_value *ucontrol)
  878. {
  879. u8 val;
  880. es7210_read(0x1C, &val, i2c_clt1[1]);
  881. ucontrol->value.integer.value[0] = val;
  882. return 0;
  883. }
  884. static int es7210_direct_gain_8_set(struct snd_kcontrol *kcontrol,
  885. struct snd_ctl_elem_value *ucontrol)
  886. {
  887. es7210_update_bits(0x1B,
  888. 0xFF,
  889. ucontrol->value.integer.value[0], i2c_clt1[1]);
  890. return 0;
  891. }
  892. static int es7210_direct_gain_8_get(struct snd_kcontrol *kcontrol,
  893. struct snd_ctl_elem_value *ucontrol)
  894. {
  895. u8 val;
  896. es7210_read(0x1B, &val, i2c_clt1[1]);
  897. ucontrol->value.integer.value[0] = val;
  898. return 0;
  899. }
  900. static int es7210_direct_gain_56_sameon_set(struct snd_kcontrol *kcontrol,
  901. struct snd_ctl_elem_value
  902. *ucontrol)
  903. {
  904. es7210_update_bits(0x1a, 0
  905. x01, ucontrol->value.integer.value[0], i2c_clt1[1]);
  906. return 0;
  907. }
  908. static int es7210_direct_gain_56_sameon_get(struct snd_kcontrol *kcontrol,
  909. struct snd_ctl_elem_value
  910. *ucontrol)
  911. {
  912. u8 val;
  913. es7210_read(0x1a, &val, i2c_clt1[1]);
  914. ucontrol->value.integer.value[0] = val;
  915. return 0;
  916. }
  917. static int es7210_direct_gain_78_sameon_set(struct snd_kcontrol *kcontrol,
  918. struct snd_ctl_elem_value
  919. *ucontrol)
  920. {
  921. es7210_update_bits(0x1a,
  922. 0x02,
  923. ucontrol->value.integer.value[0], i2c_clt1[1]);
  924. return 0;
  925. }
  926. static int es7210_direct_gain_78_sameon_get(struct snd_kcontrol *kcontrol,
  927. struct snd_ctl_elem_value
  928. *ucontrol)
  929. {
  930. u8 val;
  931. es7210_read(0x1a, &val, i2c_clt1[1]);
  932. ucontrol->value.integer.value[0] = val;
  933. return 0;
  934. }
  935. #endif
  936. #if ES7210_CHANNELS_MAX > 8
  937. static int es7210_direct_gain_9_set(struct snd_kcontrol *kcontrol,
  938. struct snd_ctl_elem_value *ucontrol)
  939. {
  940. es7210_update_bits(0x1e,
  941. 0xFF,
  942. ucontrol->value.integer.value[0], i2c_clt1[2]);
  943. return 0;
  944. }
  945. static int es7210_direct_gain_9_get(struct snd_kcontrol *kcontrol,
  946. struct snd_ctl_elem_value *ucontrol)
  947. {
  948. u8 val;
  949. es7210_read(0x1e, &val, i2c_clt1[2]);
  950. ucontrol->value.integer.value[0] = val;
  951. return 0;
  952. }
  953. static int es7210_direct_gain_10_set(struct snd_kcontrol *kcontrol,
  954. struct snd_ctl_elem_value *ucontrol)
  955. {
  956. es7210_update_bits(0x1D,
  957. 0xFF,
  958. ucontrol->value.integer.value[0], i2c_clt1[2]);
  959. return 0;
  960. }
  961. static int es7210_direct_gain_10_get(struct snd_kcontrol *kcontrol,
  962. struct snd_ctl_elem_value *ucontrol)
  963. {
  964. u8 val;
  965. es7210_read(0x1D, &val, i2c_clt1[2]);
  966. ucontrol->value.integer.value[0] = val;
  967. return 0;
  968. }
  969. static int es7210_direct_gain_11_set(struct snd_kcontrol *kcontrol,
  970. struct snd_ctl_elem_value *ucontrol)
  971. {
  972. es7210_update_bits(0x1C,
  973. 0xFF,
  974. ucontrol->value.integer.value[0], i2c_clt1[2]);
  975. return 0;
  976. }
  977. static int es7210_direct_gain_11_get(struct snd_kcontrol *kcontrol,
  978. struct snd_ctl_elem_value *ucontrol)
  979. {
  980. u8 val;
  981. es7210_read(0x1C, &val, i2c_clt1[2]);
  982. ucontrol->value.integer.value[0] = val;
  983. return 0;
  984. }
  985. static int es7210_direct_gain_12_set(struct snd_kcontrol *kcontrol,
  986. struct snd_ctl_elem_value *ucontrol)
  987. {
  988. es7210_update_bits(0x1B,
  989. 0xFF,
  990. ucontrol->value.integer.value[0], i2c_clt1[2]);
  991. return 0;
  992. }
  993. static int es7210_direct_gain_12_get(struct snd_kcontrol *kcontrol,
  994. struct snd_ctl_elem_value *ucontrol)
  995. {
  996. u8 val;
  997. es7210_read(0x1B, &val, i2c_clt1[2]);
  998. ucontrol->value.integer.value[0] = val;
  999. return 0;
  1000. }
  1001. static int es7210_direct_gain_9_10_sameon_set(struct snd_kcontrol *kcontrol,
  1002. struct snd_ctl_elem_value
  1003. *ucontrol)
  1004. {
  1005. es7210_update_bits(0x1a,
  1006. 0x01,
  1007. ucontrol->value.integer.value[0], i2c_clt1[2]);
  1008. return 0;
  1009. }
  1010. static int es7210_direct_gain_9_10_sameon_get(struct snd_kcontrol *kcontrol,
  1011. struct snd_ctl_elem_value
  1012. *ucontrol)
  1013. {
  1014. u8 val;
  1015. es7210_read(0x1a, &val, i2c_clt1[2]);
  1016. ucontrol->value.integer.value[0] = val;
  1017. return 0;
  1018. }
  1019. static int es7210_direct_gain_11_12_sameon_set(struct snd_kcontrol *kcontrol,
  1020. struct snd_ctl_elem_value
  1021. *ucontrol)
  1022. {
  1023. es7210_update_bits(0x1a,
  1024. 0x02,
  1025. ucontrol->value.integer.value[0], i2c_clt1[2]);
  1026. return 0;
  1027. }
  1028. static int es7210_direct_gain_11_12_sameon_get(struct snd_kcontrol *kcontrol,
  1029. struct snd_ctl_elem_value
  1030. *ucontrol)
  1031. {
  1032. u8 val;
  1033. es7210_read(0x1a, &val, i2c_clt1[2]);
  1034. ucontrol->value.integer.value[0] = val;
  1035. return 0;
  1036. }
  1037. #endif
  1038. #if ES7210_CHANNELS_MAX > 12
  1039. static int es7210_direct_gain_13_set(struct snd_kcontrol *kcontrol,
  1040. struct snd_ctl_elem_value *ucontrol)
  1041. {
  1042. es7210_update_bits(0x1e,
  1043. 0xFF,
  1044. ucontrol->value.integer.value[0], i2c_clt1[3]);
  1045. return 0;
  1046. }
  1047. static int es7210_direct_gain_13_get(struct snd_kcontrol *kcontrol,
  1048. struct snd_ctl_elem_value *ucontrol)
  1049. {
  1050. u8 val;
  1051. es7210_read(0x1e, &val, i2c_clt1[3]);
  1052. ucontrol->value.integer.value[0] = val;
  1053. return 0;
  1054. }
  1055. static int es7210_direct_gain_14_set(struct snd_kcontrol *kcontrol,
  1056. struct snd_ctl_elem_value *ucontrol)
  1057. {
  1058. es7210_update_bits(0x1D,
  1059. 0xFF,
  1060. ucontrol->value.integer.value[0], i2c_clt1[3]);
  1061. return 0;
  1062. }
  1063. static int es7210_direct_gain_14_get(struct snd_kcontrol *kcontrol,
  1064. struct snd_ctl_elem_value *ucontrol)
  1065. {
  1066. u8 val;
  1067. es7210_read(0x1D, &val, i2c_clt1[3]);
  1068. ucontrol->value.integer.value[0] = val;
  1069. return 0;
  1070. }
  1071. static int es7210_direct_gain_15_set(struct snd_kcontrol *kcontrol,
  1072. struct snd_ctl_elem_value *ucontrol)
  1073. {
  1074. es7210_update_bits(0x1C,
  1075. 0xFF,
  1076. ucontrol->value.integer.value[0], i2c_clt1[3]);
  1077. return 0;
  1078. }
  1079. static int es7210_direct_gain_15_get(struct snd_kcontrol *kcontrol,
  1080. struct snd_ctl_elem_value *ucontrol)
  1081. {
  1082. u8 val;
  1083. es7210_read(0x1C, &val, i2c_clt1[3]);
  1084. ucontrol->value.integer.value[0] = val;
  1085. return 0;
  1086. }
  1087. static int es7210_direct_gain_16_set(struct snd_kcontrol *kcontrol,
  1088. struct snd_ctl_elem_value *ucontrol)
  1089. {
  1090. es7210_update_bits(0x1B,
  1091. 0xFF,
  1092. ucontrol->value.integer.value[0], i2c_clt1[3]);
  1093. return 0;
  1094. }
  1095. static int es7210_direct_gain_16_get(struct snd_kcontrol *kcontrol,
  1096. struct snd_ctl_elem_value *ucontrol)
  1097. {
  1098. u8 val;
  1099. es7210_read(0x1B, &val, i2c_clt1[3]);
  1100. ucontrol->value.integer.value[0] = val;
  1101. return 0;
  1102. }
  1103. static int es7210_direct_gain_13_14_sameon_set(struct snd_kcontrol *kcontrol,
  1104. struct snd_ctl_elem_value
  1105. *ucontrol)
  1106. {
  1107. es7210_update_bits(0x1a,
  1108. 0x01,
  1109. ucontrol->value.integer.value[0], i2c_clt1[3]);
  1110. return 0;
  1111. }
  1112. static int es7210_direct_gain_13_14_sameon_get(struct snd_kcontrol *kcontrol,
  1113. struct snd_ctl_elem_value
  1114. *ucontrol)
  1115. {
  1116. u8 val;
  1117. es7210_read(0x1a, &val, i2c_clt1[3]);
  1118. ucontrol->value.integer.value[0] = val;
  1119. return 0;
  1120. }
  1121. static int es7210_direct_gain_15_16_sameon_set(struct snd_kcontrol *kcontrol,
  1122. struct snd_ctl_elem_value
  1123. *ucontrol)
  1124. {
  1125. es7210_update_bits(0x1a,
  1126. 0x02,
  1127. ucontrol->value.integer.value[0], i2c_clt1[3]);
  1128. return 0;
  1129. }
  1130. static int es7210_direct_gain_15_16_sameon_get(struct snd_kcontrol *kcontrol,
  1131. struct snd_ctl_elem_value
  1132. *ucontrol)
  1133. {
  1134. u8 val;
  1135. es7210_read(0x1a, &val, i2c_clt1[3]);
  1136. ucontrol->value.integer.value[0] = val;
  1137. return 0;
  1138. }
  1139. #endif
  1140. static const struct snd_kcontrol_new es7210_snd_controls[] = {
  1141. #if ES7210_CHANNELS_MAX > 0
  1142. SOC_SINGLE_EXT_TLV("PGA1_setting", 0x43, 0, 0x0F, 0,
  1143. es7210_micboost1_setting_get,
  1144. es7210_micboost1_setting_set,
  1145. mic_boost_tlv),
  1146. SOC_SINGLE_EXT_TLV("PGA2_setting", 0x44, 0, 0x0F, 0,
  1147. es7210_micboost2_setting_get,
  1148. es7210_micboost2_setting_set,
  1149. mic_boost_tlv),
  1150. SOC_SINGLE_EXT_TLV("PGA3_setting", 0x45, 0, 0x0F, 0,
  1151. es7210_micboost3_setting_get,
  1152. es7210_micboost3_setting_set,
  1153. mic_boost_tlv),
  1154. SOC_SINGLE_EXT_TLV("PGA4_setting", 0x46, 0, 0x0F, 0,
  1155. es7210_micboost4_setting_get,
  1156. es7210_micboost4_setting_set,
  1157. mic_boost_tlv),
  1158. SOC_SINGLE_EXT("ADC1_MUTE", ES7210_ADC12_MUTE_REG15,
  1159. 0, 1, 0,
  1160. es7210_adc1_mute_get,
  1161. es7210_adc1_mute_set),
  1162. SOC_SINGLE_EXT("ADC2_MUTE", ES7210_ADC12_MUTE_REG15,
  1163. 1, 1, 0,
  1164. es7210_adc2_mute_get,
  1165. es7210_adc2_mute_set),
  1166. SOC_SINGLE_EXT("ADC3_MUTE", ES7210_ADC34_MUTE_REG14,
  1167. 0, 1, 0,
  1168. es7210_adc3_mute_get,
  1169. es7210_adc3_mute_set),
  1170. SOC_SINGLE_EXT("ADC4_MUTE", ES7210_ADC34_MUTE_REG14,
  1171. 1, 1, 0,
  1172. es7210_adc4_mute_get,
  1173. es7210_adc4_mute_set),
  1174. SOC_SINGLE_EXT_TLV("ADC1_DIRECT_GAIN",
  1175. ES7210_ALC1_MAX_GAIN_REG1E,
  1176. 0, 0xff, 0,
  1177. es7210_direct_gain_1_get,
  1178. es7210_direct_gain_1_set,
  1179. direct_gain_tlv),
  1180. SOC_SINGLE_EXT_TLV("ADC2_DIRECT_GAIN",
  1181. ES7210_ALC2_MAX_GAIN_REG1D,
  1182. 0, 0xff, 0,
  1183. es7210_direct_gain_2_get,
  1184. es7210_direct_gain_2_set,
  1185. direct_gain_tlv),
  1186. SOC_SINGLE_EXT_TLV("ADC3_DIRECT_GAIN",
  1187. ES7210_ALC3_MAX_GAIN_REG1C,
  1188. 0, 0xff, 0,
  1189. es7210_direct_gain_3_get,
  1190. es7210_direct_gain_3_set,
  1191. direct_gain_tlv),
  1192. SOC_SINGLE_EXT_TLV("ADC4_DIRECT_GAIN",
  1193. ES7210_ALC4_MAX_GAIN_REG1B,
  1194. 0, 0xff, 0,
  1195. es7210_direct_gain_4_get,
  1196. es7210_direct_gain_4_set,
  1197. direct_gain_tlv),
  1198. SOC_SINGLE_EXT("DIRECT_1_2_GAIN_SAME_ON",
  1199. ES7210_ALC_COM_CFG2_REG1A,
  1200. 0, 1, 0,
  1201. es7210_direct_gain_12_sameon_get,
  1202. es7210_direct_gain_12_sameon_set),
  1203. SOC_SINGLE_EXT("DIRECT_3_4_GAIN_SAME_ON",
  1204. ES7210_ALC_COM_CFG2_REG1A, 1, 1, 0,
  1205. es7210_direct_gain_34_sameon_get,
  1206. es7210_direct_gain_34_sameon_set),
  1207. SOC_SINGLE_EXT("ADC12_SUSPEND",
  1208. 0x4b, 0, 1, 0,
  1209. es7210_adc12_suspend_get,
  1210. es7210_adc12_suspend_set),
  1211. SOC_SINGLE_EXT("ADC34_SUSPEND",
  1212. 0x4c, 0, 1, 0,
  1213. es7210_adc34_suspend_get,
  1214. es7210_adc34_suspend_set),
  1215. #endif
  1216. #if ES7210_CHANNELS_MAX > 4
  1217. SOC_SINGLE_EXT_TLV("PGA5_setting", 0x43, 0, 0x0F, 0,
  1218. es7210_micboost5_setting_get,
  1219. es7210_micboost5_setting_set,
  1220. mic_boost_tlv),
  1221. SOC_SINGLE_EXT_TLV("PGA6_setting", 0x44, 0, 0x0F, 0,
  1222. es7210_micboost6_setting_get,
  1223. es7210_micboost6_setting_set,
  1224. mic_boost_tlv),
  1225. SOC_SINGLE_EXT_TLV("PGA7_setting", 0x45, 0, 0x0F, 0,
  1226. es7210_micboost7_setting_get,
  1227. es7210_micboost7_setting_set,
  1228. mic_boost_tlv),
  1229. SOC_SINGLE_EXT_TLV("PGA8_setting", 0x46, 0, 0x0F, 0,
  1230. es7210_micboost8_setting_get,
  1231. es7210_micboost8_setting_set,
  1232. mic_boost_tlv),
  1233. SOC_SINGLE_EXT("ADC5_MUTE", ES7210_ADC12_MUTE_REG15,
  1234. 0, 1, 0,
  1235. es7210_adc5_mute_get,
  1236. es7210_adc5_mute_set),
  1237. SOC_SINGLE_EXT("ADC6_MUTE", ES7210_ADC12_MUTE_REG15,
  1238. 1, 1, 0,
  1239. es7210_adc6_mute_get,
  1240. es7210_adc6_mute_set),
  1241. SOC_SINGLE_EXT("ADC7_MUTE", ES7210_ADC34_MUTE_REG14,
  1242. 0, 1, 0,
  1243. es7210_adc7_mute_get,
  1244. es7210_adc7_mute_set),
  1245. SOC_SINGLE_EXT("ADC8_MUTE", ES7210_ADC34_MUTE_REG14,
  1246. 1, 1, 0,
  1247. es7210_adc8_mute_get,
  1248. es7210_adc8_mute_set),
  1249. SOC_SINGLE_EXT_TLV("ADC5_DIRECT_GAIN",
  1250. ES7210_ALC1_MAX_GAIN_REG1E,
  1251. 0, 0xff, 0,
  1252. es7210_direct_gain_5_get,
  1253. es7210_direct_gain_5_set,
  1254. direct_gain_tlv),
  1255. SOC_SINGLE_EXT_TLV("ADC6_DIRECT_GAIN",
  1256. ES7210_ALC2_MAX_GAIN_REG1D,
  1257. 0, 0xff, 0,
  1258. es7210_direct_gain_6_get,
  1259. es7210_direct_gain_6_set,
  1260. direct_gain_tlv),
  1261. SOC_SINGLE_EXT_TLV("ADC7_DIRECT_GAIN",
  1262. ES7210_ALC3_MAX_GAIN_REG1C,
  1263. 0, 0xff, 0,
  1264. es7210_direct_gain_7_get,
  1265. es7210_direct_gain_7_set,
  1266. direct_gain_tlv),
  1267. SOC_SINGLE_EXT_TLV("ADC8_DIRECT_GAIN",
  1268. ES7210_ALC4_MAX_GAIN_REG1B,
  1269. 0, 0xff, 0,
  1270. es7210_direct_gain_8_get,
  1271. es7210_direct_gain_8_set,
  1272. direct_gain_tlv),
  1273. SOC_SINGLE_EXT("DIRECT_5_6_GAIN_SAME_ON",
  1274. ES7210_ALC_COM_CFG2_REG1A,
  1275. 0, 1, 0,
  1276. es7210_direct_gain_56_sameon_get,
  1277. es7210_direct_gain_56_sameon_set),
  1278. SOC_SINGLE_EXT("DIRECT_7_8_GAIN_SAME_ON",
  1279. ES7210_ALC_COM_CFG2_REG1A,
  1280. 1, 1, 0,
  1281. es7210_direct_gain_78_sameon_get,
  1282. es7210_direct_gain_78_sameon_set),
  1283. SOC_SINGLE_EXT("ADC56_SUSPEND",
  1284. 0x4b, 0, 1, 0,
  1285. es7210_adc56_suspend_get,
  1286. es7210_adc56_suspend_set),
  1287. SOC_SINGLE_EXT("ADC78_SUSPEND",
  1288. 0x4c, 0, 1, 0,
  1289. es7210_adc78_suspend_get,
  1290. es7210_adc78_suspend_set),
  1291. #endif
  1292. #if ES7210_CHANNELS_MAX > 8
  1293. SOC_SINGLE_EXT_TLV("PGA9_setting", 0x43, 0, 0x0F, 0,
  1294. es7210_micboost9_setting_get,
  1295. es7210_micboost9_setting_set,
  1296. mic_boost_tlv),
  1297. SOC_SINGLE_EXT_TLV("PGA10_setting", 0x44, 0, 0x0F, 0,
  1298. es7210_micboost10_setting_get,
  1299. es7210_micboost10_setting_set,
  1300. mic_boost_tlv),
  1301. SOC_SINGLE_EXT_TLV("PGA11_setting", 0x45, 0, 0x0F, 0,
  1302. es7210_micboost11_setting_get,
  1303. es7210_micboost11_setting_set,
  1304. mic_boost_tlv),
  1305. SOC_SINGLE_EXT_TLV("PGA12_setting", 0x46, 0, 0x0F, 0,
  1306. es7210_micboost12_setting_get,
  1307. es7210_micboost12_setting_set,
  1308. mic_boost_tlv),
  1309. SOC_SINGLE_EXT("ADC9_MUTE", ES7210_ADC12_MUTE_REG15,
  1310. 0, 1, 0,
  1311. es7210_adc9_mute_get,
  1312. es7210_adc9_mute_set),
  1313. SOC_SINGLE_EXT("ADC10_MUTE", ES7210_ADC12_MUTE_REG15,
  1314. 1, 1, 0,
  1315. es7210_adc10_mute_get,
  1316. es7210_adc10_mute_set),
  1317. SOC_SINGLE_EXT("ADC11_MUTE", ES7210_ADC34_MUTE_REG14,
  1318. 0, 1, 0,
  1319. es7210_adc11_mute_get,
  1320. es7210_adc11_mute_set),
  1321. SOC_SINGLE_EXT("ADC12_MUTE", ES7210_ADC34_MUTE_REG14,
  1322. 1, 1, 0,
  1323. es7210_adc12_mute_get,
  1324. es7210_adc12_mute_set),
  1325. SOC_SINGLE_EXT_TLV("ADC9_DIRECT_GAIN",
  1326. ES7210_ALC1_MAX_GAIN_REG1E,
  1327. 0, 0xff, 0,
  1328. es7210_direct_gain_9_get,
  1329. es7210_direct_gain_9_set,
  1330. direct_gain_tlv),
  1331. SOC_SINGLE_EXT_TLV("ADC10_DIRECT_GAIN",
  1332. ES7210_ALC2_MAX_GAIN_REG1D,
  1333. 0, 0xff, 0,
  1334. es7210_direct_gain_10_get,
  1335. es7210_direct_gain_10_set,
  1336. direct_gain_tlv),
  1337. SOC_SINGLE_EXT_TLV("ADC11_DIRECT_GAIN",
  1338. ES7210_ALC3_MAX_GAIN_REG1C,
  1339. 0, 0xff, 0,
  1340. es7210_direct_gain_11_get,
  1341. es7210_direct_gain_11_set,
  1342. direct_gain_tlv),
  1343. SOC_SINGLE_EXT_TLV("ADC12_DIRECT_GAIN",
  1344. ES7210_ALC4_MAX_GAIN_REG1B,
  1345. 0, 0xff, 0,
  1346. es7210_direct_gain_12_get,
  1347. es7210_direct_gain_12_set,
  1348. direct_gain_tlv),
  1349. SOC_SINGLE_EXT("DIRECT_9_10_GAIN_SAME_ON",
  1350. ES7210_ALC_COM_CFG2_REG1A,
  1351. 0, 1, 0,
  1352. es7210_direct_gain_9_10_sameon_get,
  1353. es7210_direct_gain_9_10_sameon_set),
  1354. SOC_SINGLE_EXT("DIRECT_11_12_GAIN_SAME_ON",
  1355. ES7210_ALC_COM_CFG2_REG1A,
  1356. 1, 1, 0,
  1357. es7210_direct_gain_11_12_sameon_get,
  1358. es7210_direct_gain_11_12_sameon_set),
  1359. SOC_SINGLE_EXT("ADC910_SUSPEND",
  1360. 0x4b, 0, 1, 0,
  1361. es7210_adc910_suspend_get,
  1362. es7210_adc910_suspend_set),
  1363. SOC_SINGLE_EXT("ADC1112_SUSPEND",
  1364. 0x4c, 0, 1, 0,
  1365. es7210_adc1112_suspend_get,
  1366. es7210_adc1112_suspend_set),
  1367. #endif
  1368. #if ES7210_CHANNELS_MAX > 12
  1369. SOC_SINGLE_EXT_TLV("PGA13_setting", 0x43, 0, 0x0F, 0,
  1370. es7210_micboost13_setting_get,
  1371. es7210_micboost13_setting_set,
  1372. mic_boost_tlv),
  1373. SOC_SINGLE_EXT_TLV("PGA14_setting", 0x44, 0, 0x0F, 0,
  1374. es7210_micboost14_setting_get,
  1375. es7210_micboost14_setting_set,
  1376. mic_boost_tlv),
  1377. SOC_SINGLE_EXT_TLV("PGA15_setting", 0x45, 0, 0x0F, 0,
  1378. es7210_micboost15_setting_get,
  1379. es7210_micboost15_setting_set,
  1380. mic_boost_tlv),
  1381. SOC_SINGLE_EXT_TLV("PGA16_setting", 0x46, 0, 0x0F, 0,
  1382. es7210_micboost16_setting_get,
  1383. es7210_micboost16_setting_set,
  1384. mic_boost_tlv),
  1385. SOC_SINGLE_EXT("ADC13_MUTE", ES7210_ADC12_MUTE_REG15,
  1386. 0, 1, 0,
  1387. es7210_adc13_mute_get,
  1388. es7210_adc13_mute_set),
  1389. SOC_SINGLE_EXT("ADC14_MUTE", ES7210_ADC12_MUTE_REG15,
  1390. 1, 1, 0,
  1391. es7210_adc14_mute_get,
  1392. es7210_adc14_mute_set),
  1393. SOC_SINGLE_EXT("ADC15_MUTE", ES7210_ADC34_MUTE_REG14,
  1394. 0, 1, 0,
  1395. es7210_adc15_mute_get,
  1396. es7210_adc15_mute_set),
  1397. SOC_SINGLE_EXT("ADC16_MUTE", ES7210_ADC34_MUTE_REG14,
  1398. 1, 1, 0,
  1399. es7210_adc16_mute_get,
  1400. es7210_adc16_mute_set),
  1401. SOC_SINGLE_EXT_TLV("ADC13_DIRECT_GAIN",
  1402. ES7210_ALC1_MAX_GAIN_REG1E,
  1403. 0, 0xff, 0,
  1404. es7210_direct_gain_13_get,
  1405. es7210_direct_gain_13_set,
  1406. direct_gain_tlv),
  1407. SOC_SINGLE_EXT_TLV("ADC14_DIRECT_GAIN",
  1408. ES7210_ALC2_MAX_GAIN_REG1D,
  1409. 0, 0xff, 0,
  1410. es7210_direct_gain_14_get,
  1411. es7210_direct_gain_14_set,
  1412. direct_gain_tlv),
  1413. SOC_SINGLE_EXT_TLV("ADC15_DIRECT_GAIN",
  1414. ES7210_ALC3_MAX_GAIN_REG1C,
  1415. 0, 0xff, 0,
  1416. es7210_direct_gain_15_get,
  1417. es7210_direct_gain_15_set,
  1418. direct_gain_tlv),
  1419. SOC_SINGLE_EXT_TLV("ADC16_DIRECT_GAIN",
  1420. ES7210_ALC4_MAX_GAIN_REG1B,
  1421. 0, 0xff, 0,
  1422. es7210_direct_gain_16_get,
  1423. es7210_direct_gain_16_set,
  1424. direct_gain_tlv),
  1425. SOC_SINGLE_EXT("DIRECT_13_14_GAIN_SAME_ON",
  1426. ES7210_ALC_COM_CFG2_REG1A,
  1427. 0, 1, 0,
  1428. es7210_direct_gain_13_14_sameon_get,
  1429. es7210_direct_gain_13_14_sameon_set),
  1430. SOC_SINGLE_EXT("DIRECT_15_16_GAIN_SAME_ON",
  1431. ES7210_ALC_COM_CFG2_REG1A,
  1432. 1, 1, 0,
  1433. es7210_direct_gain_15_16_sameon_get,
  1434. es7210_direct_gain_15_16_sameon_set),
  1435. SOC_SINGLE_EXT("ADC1314_SUSPEND",
  1436. 0x4b, 0, 1, 0,
  1437. es7210_adc1314_suspend_get,
  1438. es7210_adc1314_suspend_set),
  1439. SOC_SINGLE_EXT("ADC1516_SUSPEND",
  1440. 0x4c, 0, 1, 0,
  1441. es7210_adc1516_suspend_get,
  1442. es7210_adc1516_suspend_set),
  1443. #endif
  1444. };