msp3400-kthreads.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  1. /*
  2. * Programming the mspx4xx sound processor family
  3. *
  4. * (c) 1997-2001 Gerd Knorr <kraxel@bytesex.org>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/module.h>
  22. #include <linux/slab.h>
  23. #include <linux/i2c.h>
  24. #include <linux/videodev.h>
  25. #include <linux/videodev2.h>
  26. #include <media/v4l2-common.h>
  27. #include <media/msp3400.h>
  28. #include <linux/kthread.h>
  29. #include <linux/suspend.h>
  30. #include "msp3400-driver.h"
  31. /* this one uses the automatic sound standard detection of newer msp34xx
  32. chip versions */
  33. static struct {
  34. int retval;
  35. int main, second;
  36. char *name;
  37. } msp_stdlist[] = {
  38. { 0x0000, 0, 0, "could not detect sound standard" },
  39. { 0x0001, 0, 0, "autodetect start" },
  40. { 0x0002, MSP_CARRIER(4.5), MSP_CARRIER(4.72), "4.5/4.72 M Dual FM-Stereo" },
  41. { 0x0003, MSP_CARRIER(5.5), MSP_CARRIER(5.7421875), "5.5/5.74 B/G Dual FM-Stereo" },
  42. { 0x0004, MSP_CARRIER(6.5), MSP_CARRIER(6.2578125), "6.5/6.25 D/K1 Dual FM-Stereo" },
  43. { 0x0005, MSP_CARRIER(6.5), MSP_CARRIER(6.7421875), "6.5/6.74 D/K2 Dual FM-Stereo" },
  44. { 0x0006, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 D/K FM-Mono (HDEV3)" },
  45. { 0x0007, MSP_CARRIER(6.5), MSP_CARRIER(5.7421875), "6.5/5.74 D/K3 Dual FM-Stereo" },
  46. { 0x0008, MSP_CARRIER(5.5), MSP_CARRIER(5.85), "5.5/5.85 B/G NICAM FM" },
  47. { 0x0009, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 L NICAM AM" },
  48. { 0x000a, MSP_CARRIER(6.0), MSP_CARRIER(6.55), "6.0/6.55 I NICAM FM" },
  49. { 0x000b, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM" },
  50. { 0x000c, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM (HDEV2)" },
  51. { 0x000d, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM (HDEV3)" },
  52. { 0x0020, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Stereo" },
  53. { 0x0021, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Mono + SAP" },
  54. { 0x0030, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M EIA-J Japan Stereo" },
  55. { 0x0040, MSP_CARRIER(10.7), MSP_CARRIER(10.7), "10.7 FM-Stereo Radio" },
  56. { 0x0050, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 SAT-Mono" },
  57. { 0x0051, MSP_CARRIER(7.02), MSP_CARRIER(7.20), "7.02/7.20 SAT-Stereo" },
  58. { 0x0060, MSP_CARRIER(7.2), MSP_CARRIER(7.2), "7.2 SAT ADR" },
  59. { -1, 0, 0, NULL }, /* EOF */
  60. };
  61. static struct msp3400c_init_data_dem {
  62. int fir1[6];
  63. int fir2[6];
  64. int cdo1;
  65. int cdo2;
  66. int ad_cv;
  67. int mode_reg;
  68. int dsp_src;
  69. int dsp_matrix;
  70. } msp3400c_init_data[] = {
  71. { /* AM (for carrier detect / msp3400) */
  72. {75, 19, 36, 35, 39, 40},
  73. {75, 19, 36, 35, 39, 40},
  74. MSP_CARRIER(5.5), MSP_CARRIER(5.5),
  75. 0x00d0, 0x0500, 0x0020, 0x3000
  76. },{ /* AM (for carrier detect / msp3410) */
  77. {-1, -1, -8, 2, 59, 126},
  78. {-1, -1, -8, 2, 59, 126},
  79. MSP_CARRIER(5.5), MSP_CARRIER(5.5),
  80. 0x00d0, 0x0100, 0x0020, 0x3000
  81. },{ /* FM Radio */
  82. {-8, -8, 4, 6, 78, 107},
  83. {-8, -8, 4, 6, 78, 107},
  84. MSP_CARRIER(10.7), MSP_CARRIER(10.7),
  85. 0x00d0, 0x0480, 0x0020, 0x3000
  86. },{ /* Terrestial FM-mono + FM-stereo */
  87. {3, 18, 27, 48, 66, 72},
  88. {3, 18, 27, 48, 66, 72},
  89. MSP_CARRIER(5.5), MSP_CARRIER(5.5),
  90. 0x00d0, 0x0480, 0x0030, 0x3000
  91. },{ /* Sat FM-mono */
  92. { 1, 9, 14, 24, 33, 37},
  93. { 3, 18, 27, 48, 66, 72},
  94. MSP_CARRIER(6.5), MSP_CARRIER(6.5),
  95. 0x00c6, 0x0480, 0x0000, 0x3000
  96. },{ /* NICAM/FM -- B/G (5.5/5.85), D/K (6.5/5.85) */
  97. {-2, -8, -10, 10, 50, 86},
  98. {3, 18, 27, 48, 66, 72},
  99. MSP_CARRIER(5.5), MSP_CARRIER(5.5),
  100. 0x00d0, 0x0040, 0x0120, 0x3000
  101. },{ /* NICAM/FM -- I (6.0/6.552) */
  102. {2, 4, -6, -4, 40, 94},
  103. {3, 18, 27, 48, 66, 72},
  104. MSP_CARRIER(6.0), MSP_CARRIER(6.0),
  105. 0x00d0, 0x0040, 0x0120, 0x3000
  106. },{ /* NICAM/AM -- L (6.5/5.85) */
  107. {-2, -8, -10, 10, 50, 86},
  108. {-4, -12, -9, 23, 79, 126},
  109. MSP_CARRIER(6.5), MSP_CARRIER(6.5),
  110. 0x00c6, 0x0140, 0x0120, 0x7c00
  111. },
  112. };
  113. struct msp3400c_carrier_detect {
  114. int cdo;
  115. char *name;
  116. };
  117. static struct msp3400c_carrier_detect msp3400c_carrier_detect_main[] = {
  118. /* main carrier */
  119. { MSP_CARRIER(4.5), "4.5 NTSC" },
  120. { MSP_CARRIER(5.5), "5.5 PAL B/G" },
  121. { MSP_CARRIER(6.0), "6.0 PAL I" },
  122. { MSP_CARRIER(6.5), "6.5 PAL D/K + SAT + SECAM" }
  123. };
  124. static struct msp3400c_carrier_detect msp3400c_carrier_detect_55[] = {
  125. /* PAL B/G */
  126. { MSP_CARRIER(5.7421875), "5.742 PAL B/G FM-stereo" },
  127. { MSP_CARRIER(5.85), "5.85 PAL B/G NICAM" }
  128. };
  129. static struct msp3400c_carrier_detect msp3400c_carrier_detect_65[] = {
  130. /* PAL SAT / SECAM */
  131. { MSP_CARRIER(5.85), "5.85 PAL D/K + SECAM NICAM" },
  132. { MSP_CARRIER(6.2578125), "6.25 PAL D/K1 FM-stereo" },
  133. { MSP_CARRIER(6.7421875), "6.74 PAL D/K2 FM-stereo" },
  134. { MSP_CARRIER(7.02), "7.02 PAL SAT FM-stereo s/b" },
  135. { MSP_CARRIER(7.20), "7.20 PAL SAT FM-stereo s" },
  136. { MSP_CARRIER(7.38), "7.38 PAL SAT FM-stereo b" },
  137. };
  138. /* ------------------------------------------------------------------------ */
  139. const char *msp_standard_std_name(int std)
  140. {
  141. int i;
  142. for (i = 0; msp_stdlist[i].name != NULL; i++)
  143. if (msp_stdlist[i].retval == std)
  144. return msp_stdlist[i].name;
  145. return "unknown";
  146. }
  147. static void msp_set_source(struct i2c_client *client, u16 src)
  148. {
  149. struct msp_state *state = i2c_get_clientdata(client);
  150. if (msp_dolby) {
  151. msp_write_dsp(client, 0x0008, 0x0520); /* I2S1 */
  152. msp_write_dsp(client, 0x0009, 0x0620); /* I2S2 */
  153. } else {
  154. msp_write_dsp(client, 0x0008, src);
  155. msp_write_dsp(client, 0x0009, src);
  156. }
  157. msp_write_dsp(client, 0x000a, src);
  158. msp_write_dsp(client, 0x000b, src);
  159. msp_write_dsp(client, 0x000c, src);
  160. if (state->has_scart2_out)
  161. msp_write_dsp(client, 0x0041, src);
  162. }
  163. void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2)
  164. {
  165. msp_write_dem(client, 0x0093, cdo1 & 0xfff);
  166. msp_write_dem(client, 0x009b, cdo1 >> 12);
  167. msp_write_dem(client, 0x00a3, cdo2 & 0xfff);
  168. msp_write_dem(client, 0x00ab, cdo2 >> 12);
  169. msp_write_dem(client, 0x0056, 0); /* LOAD_REG_1/2 */
  170. }
  171. void msp3400c_set_mode(struct i2c_client *client, int mode)
  172. {
  173. struct msp_state *state = i2c_get_clientdata(client);
  174. struct msp3400c_init_data_dem *data = &msp3400c_init_data[mode];
  175. int tuner = (state->routing.input >> 3) & 1;
  176. int i;
  177. v4l_dbg(1, msp_debug, client, "set_mode: %d\n", mode);
  178. state->mode = mode;
  179. state->rxsubchans = V4L2_TUNER_SUB_MONO;
  180. msp_write_dem(client, 0x00bb, data->ad_cv | (tuner ? 0x100 : 0));
  181. for (i = 5; i >= 0; i--) /* fir 1 */
  182. msp_write_dem(client, 0x0001, data->fir1[i]);
  183. msp_write_dem(client, 0x0005, 0x0004); /* fir 2 */
  184. msp_write_dem(client, 0x0005, 0x0040);
  185. msp_write_dem(client, 0x0005, 0x0000);
  186. for (i = 5; i >= 0; i--)
  187. msp_write_dem(client, 0x0005, data->fir2[i]);
  188. msp_write_dem(client, 0x0083, data->mode_reg);
  189. msp3400c_set_carrier(client, data->cdo1, data->cdo2);
  190. msp_set_source(client, data->dsp_src);
  191. /* set prescales */
  192. /* volume prescale for SCART (AM mono input) */
  193. msp_write_dsp(client, 0x000d, 0x1900);
  194. msp_write_dsp(client, 0x000e, data->dsp_matrix);
  195. if (state->has_nicam) /* nicam prescale */
  196. msp_write_dsp(client, 0x0010, 0x5a00);
  197. }
  198. /* Set audio mode. Note that the pre-'G' models do not support BTSC+SAP,
  199. nor do they support stereo BTSC. */
  200. static void msp3400c_set_audmode(struct i2c_client *client)
  201. {
  202. static char *strmode[] = { "mono", "stereo", "lang2", "lang1", "lang1+lang2" };
  203. struct msp_state *state = i2c_get_clientdata(client);
  204. char *modestr = (state->audmode >= 0 && state->audmode < 5) ?
  205. strmode[state->audmode] : "unknown";
  206. int src = 0; /* channel source: FM/AM, nicam or SCART */
  207. int audmode = state->audmode;
  208. if (state->opmode == OPMODE_AUTOSELECT) {
  209. /* this method would break everything, let's make sure
  210. * it's never called
  211. */
  212. v4l_dbg(1, msp_debug, client,
  213. "set_audmode called with mode=%d instead of set_source (ignored)\n",
  214. state->audmode);
  215. return;
  216. }
  217. /* Note: for the C and D revs no NTSC stereo + SAP is possible as
  218. the hardware does not support SAP. So the rxsubchans combination
  219. of STEREO | LANG2 does not occur. */
  220. if (state->mode != MSP_MODE_EXTERN) {
  221. /* switch to mono if only mono is available */
  222. if (state->rxsubchans == V4L2_TUNER_SUB_MONO)
  223. audmode = V4L2_TUNER_MODE_MONO;
  224. /* if bilingual */
  225. else if (state->rxsubchans & V4L2_TUNER_SUB_LANG2) {
  226. /* and mono or stereo, then fallback to lang1 */
  227. if (audmode == V4L2_TUNER_MODE_MONO ||
  228. audmode == V4L2_TUNER_MODE_STEREO)
  229. audmode = V4L2_TUNER_MODE_LANG1;
  230. }
  231. /* if stereo, and audmode is not mono, then switch to stereo */
  232. else if (audmode != V4L2_TUNER_MODE_MONO)
  233. audmode = V4L2_TUNER_MODE_STEREO;
  234. }
  235. /* switch demodulator */
  236. switch (state->mode) {
  237. case MSP_MODE_FM_TERRA:
  238. v4l_dbg(1, msp_debug, client, "FM set_audmode: %s\n", modestr);
  239. switch (audmode) {
  240. case V4L2_TUNER_MODE_STEREO:
  241. msp_write_dsp(client, 0x000e, 0x3001);
  242. break;
  243. case V4L2_TUNER_MODE_MONO:
  244. case V4L2_TUNER_MODE_LANG1:
  245. case V4L2_TUNER_MODE_LANG2:
  246. case V4L2_TUNER_MODE_LANG1_LANG2:
  247. msp_write_dsp(client, 0x000e, 0x3000);
  248. break;
  249. }
  250. break;
  251. case MSP_MODE_FM_SAT:
  252. v4l_dbg(1, msp_debug, client, "SAT set_audmode: %s\n", modestr);
  253. switch (audmode) {
  254. case V4L2_TUNER_MODE_MONO:
  255. msp3400c_set_carrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
  256. break;
  257. case V4L2_TUNER_MODE_STEREO:
  258. case V4L2_TUNER_MODE_LANG1_LANG2:
  259. msp3400c_set_carrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02));
  260. break;
  261. case V4L2_TUNER_MODE_LANG1:
  262. msp3400c_set_carrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02));
  263. break;
  264. case V4L2_TUNER_MODE_LANG2:
  265. msp3400c_set_carrier(client, MSP_CARRIER(7.38), MSP_CARRIER(7.02));
  266. break;
  267. }
  268. break;
  269. case MSP_MODE_FM_NICAM1:
  270. case MSP_MODE_FM_NICAM2:
  271. case MSP_MODE_AM_NICAM:
  272. v4l_dbg(1, msp_debug, client, "NICAM set_audmode: %s\n",modestr);
  273. if (state->nicam_on)
  274. src = 0x0100; /* NICAM */
  275. break;
  276. case MSP_MODE_BTSC:
  277. v4l_dbg(1, msp_debug, client, "BTSC set_audmode: %s\n",modestr);
  278. break;
  279. case MSP_MODE_EXTERN:
  280. v4l_dbg(1, msp_debug, client, "extern set_audmode: %s\n",modestr);
  281. src = 0x0200; /* SCART */
  282. break;
  283. case MSP_MODE_FM_RADIO:
  284. v4l_dbg(1, msp_debug, client, "FM-Radio set_audmode: %s\n",modestr);
  285. break;
  286. default:
  287. v4l_dbg(1, msp_debug, client, "mono set_audmode\n");
  288. return;
  289. }
  290. /* switch audio */
  291. v4l_dbg(1, msp_debug, client, "set audmode %d\n", audmode);
  292. switch (audmode) {
  293. case V4L2_TUNER_MODE_STEREO:
  294. case V4L2_TUNER_MODE_LANG1_LANG2:
  295. src |= 0x0020;
  296. break;
  297. case V4L2_TUNER_MODE_MONO:
  298. if (state->mode == MSP_MODE_AM_NICAM) {
  299. v4l_dbg(1, msp_debug, client, "switching to AM mono\n");
  300. /* AM mono decoding is handled by tuner, not MSP chip */
  301. /* SCART switching control register */
  302. msp_set_scart(client, SCART_MONO, 0);
  303. src = 0x0200;
  304. break;
  305. }
  306. if (state->rxsubchans & V4L2_TUNER_SUB_STEREO)
  307. src = 0x0030;
  308. break;
  309. case V4L2_TUNER_MODE_LANG1:
  310. break;
  311. case V4L2_TUNER_MODE_LANG2:
  312. src |= 0x0010;
  313. break;
  314. }
  315. v4l_dbg(1, msp_debug, client, "set_audmode final source/matrix = 0x%x\n", src);
  316. msp_set_source(client, src);
  317. }
  318. static void msp3400c_print_mode(struct i2c_client *client)
  319. {
  320. struct msp_state *state = i2c_get_clientdata(client);
  321. if (state->main == state->second) {
  322. v4l_dbg(1, msp_debug, client, "mono sound carrier: %d.%03d MHz\n",
  323. state->main / 910000, (state->main / 910) % 1000);
  324. } else {
  325. v4l_dbg(1, msp_debug, client, "main sound carrier: %d.%03d MHz\n",
  326. state->main / 910000, (state->main / 910) % 1000);
  327. }
  328. if (state->mode == MSP_MODE_FM_NICAM1 || state->mode == MSP_MODE_FM_NICAM2)
  329. v4l_dbg(1, msp_debug, client, "NICAM/FM carrier : %d.%03d MHz\n",
  330. state->second / 910000, (state->second/910) % 1000);
  331. if (state->mode == MSP_MODE_AM_NICAM)
  332. v4l_dbg(1, msp_debug, client, "NICAM/AM carrier : %d.%03d MHz\n",
  333. state->second / 910000, (state->second / 910) % 1000);
  334. if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) {
  335. v4l_dbg(1, msp_debug, client, "FM-stereo carrier : %d.%03d MHz\n",
  336. state->second / 910000, (state->second / 910) % 1000);
  337. }
  338. }
  339. /* ----------------------------------------------------------------------- */
  340. static int msp3400c_detect_stereo(struct i2c_client *client)
  341. {
  342. struct msp_state *state = i2c_get_clientdata(client);
  343. int val;
  344. int rxsubchans = state->rxsubchans;
  345. int newnicam = state->nicam_on;
  346. int update = 0;
  347. switch (state->mode) {
  348. case MSP_MODE_FM_TERRA:
  349. val = msp_read_dsp(client, 0x18);
  350. if (val > 32767)
  351. val -= 65536;
  352. v4l_dbg(2, msp_debug, client, "stereo detect register: %d\n", val);
  353. if (val > 8192) {
  354. rxsubchans = V4L2_TUNER_SUB_STEREO;
  355. } else if (val < -4096) {
  356. rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
  357. } else {
  358. rxsubchans = V4L2_TUNER_SUB_MONO;
  359. }
  360. newnicam = 0;
  361. break;
  362. case MSP_MODE_FM_NICAM1:
  363. case MSP_MODE_FM_NICAM2:
  364. case MSP_MODE_AM_NICAM:
  365. val = msp_read_dem(client, 0x23);
  366. v4l_dbg(2, msp_debug, client, "nicam sync=%d, mode=%d\n",
  367. val & 1, (val & 0x1e) >> 1);
  368. if (val & 1) {
  369. /* nicam synced */
  370. switch ((val & 0x1e) >> 1) {
  371. case 0:
  372. case 8:
  373. rxsubchans = V4L2_TUNER_SUB_STEREO;
  374. break;
  375. case 1:
  376. case 9:
  377. rxsubchans = V4L2_TUNER_SUB_MONO;
  378. break;
  379. case 2:
  380. case 10:
  381. rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
  382. break;
  383. default:
  384. rxsubchans = V4L2_TUNER_SUB_MONO;
  385. break;
  386. }
  387. newnicam = 1;
  388. } else {
  389. newnicam = 0;
  390. rxsubchans = V4L2_TUNER_SUB_MONO;
  391. }
  392. break;
  393. }
  394. if (rxsubchans != state->rxsubchans) {
  395. update = 1;
  396. v4l_dbg(1, msp_debug, client, "watch: rxsubchans %02x => %02x\n",
  397. state->rxsubchans, rxsubchans);
  398. state->rxsubchans = rxsubchans;
  399. }
  400. if (newnicam != state->nicam_on) {
  401. update = 1;
  402. v4l_dbg(1, msp_debug, client, "watch: nicam %d => %d\n",
  403. state->nicam_on, newnicam);
  404. state->nicam_on = newnicam;
  405. }
  406. return update;
  407. }
  408. /*
  409. * A kernel thread for msp3400 control -- we don't want to block the
  410. * in the ioctl while doing the sound carrier & stereo detect
  411. */
  412. /* stereo/multilang monitoring */
  413. static void watch_stereo(struct i2c_client *client)
  414. {
  415. struct msp_state *state = i2c_get_clientdata(client);
  416. if (msp_detect_stereo(client)) {
  417. msp_set_audmode(client);
  418. }
  419. if (msp_once)
  420. state->watch_stereo = 0;
  421. }
  422. int msp3400c_thread(void *data)
  423. {
  424. struct i2c_client *client = data;
  425. struct msp_state *state = i2c_get_clientdata(client);
  426. struct msp3400c_carrier_detect *cd;
  427. int count, max1, max2, val1, val2, val, this;
  428. v4l_dbg(1, msp_debug, client, "msp3400 daemon started\n");
  429. for (;;) {
  430. v4l_dbg(2, msp_debug, client, "msp3400 thread: sleep\n");
  431. msp_sleep(state, -1);
  432. v4l_dbg(2, msp_debug, client, "msp3400 thread: wakeup\n");
  433. restart:
  434. v4l_dbg(2, msp_debug, client, "thread: restart scan\n");
  435. state->restart = 0;
  436. if (kthread_should_stop())
  437. break;
  438. if (state->radio || MSP_MODE_EXTERN == state->mode) {
  439. /* no carrier scan, just unmute */
  440. v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
  441. state->scan_in_progress = 0;
  442. state->rxsubchans = V4L2_TUNER_SUB_STEREO;
  443. msp_set_audio(client);
  444. continue;
  445. }
  446. /* mute audio */
  447. state->scan_in_progress = 1;
  448. msp_set_audio(client);
  449. msp3400c_set_mode(client, MSP_MODE_AM_DETECT);
  450. val1 = val2 = 0;
  451. max1 = max2 = -1;
  452. state->watch_stereo = 0;
  453. state->nicam_on = 0;
  454. /* wait for tuner to settle down after a channel change */
  455. if (msp_sleep(state, 200))
  456. goto restart;
  457. /* carrier detect pass #1 -- main carrier */
  458. cd = msp3400c_carrier_detect_main;
  459. count = ARRAY_SIZE(msp3400c_carrier_detect_main);
  460. if (msp_amsound && (state->v4l2_std & V4L2_STD_SECAM)) {
  461. /* autodetect doesn't work well with AM ... */
  462. max1 = 3;
  463. count = 0;
  464. v4l_dbg(1, msp_debug, client, "AM sound override\n");
  465. }
  466. for (this = 0; this < count; this++) {
  467. msp3400c_set_carrier(client, cd[this].cdo, cd[this].cdo);
  468. if (msp_sleep(state,100))
  469. goto restart;
  470. val = msp_read_dsp(client, 0x1b);
  471. if (val > 32767)
  472. val -= 65536;
  473. if (val1 < val)
  474. val1 = val, max1 = this;
  475. v4l_dbg(1, msp_debug, client, "carrier1 val: %5d / %s\n", val,cd[this].name);
  476. }
  477. /* carrier detect pass #2 -- second (stereo) carrier */
  478. switch (max1) {
  479. case 1: /* 5.5 */
  480. cd = msp3400c_carrier_detect_55;
  481. count = ARRAY_SIZE(msp3400c_carrier_detect_55);
  482. break;
  483. case 3: /* 6.5 */
  484. cd = msp3400c_carrier_detect_65;
  485. count = ARRAY_SIZE(msp3400c_carrier_detect_65);
  486. break;
  487. case 0: /* 4.5 */
  488. case 2: /* 6.0 */
  489. default:
  490. cd = NULL;
  491. count = 0;
  492. break;
  493. }
  494. if (msp_amsound && (state->v4l2_std & V4L2_STD_SECAM)) {
  495. /* autodetect doesn't work well with AM ... */
  496. cd = NULL;
  497. count = 0;
  498. max2 = 0;
  499. }
  500. for (this = 0; this < count; this++) {
  501. msp3400c_set_carrier(client, cd[this].cdo, cd[this].cdo);
  502. if (msp_sleep(state,100))
  503. goto restart;
  504. val = msp_read_dsp(client, 0x1b);
  505. if (val > 32767)
  506. val -= 65536;
  507. if (val2 < val)
  508. val2 = val, max2 = this;
  509. v4l_dbg(1, msp_debug, client, "carrier2 val: %5d / %s\n", val,cd[this].name);
  510. }
  511. /* program the msp3400 according to the results */
  512. state->main = msp3400c_carrier_detect_main[max1].cdo;
  513. switch (max1) {
  514. case 1: /* 5.5 */
  515. if (max2 == 0) {
  516. /* B/G FM-stereo */
  517. state->second = msp3400c_carrier_detect_55[max2].cdo;
  518. msp3400c_set_mode(client, MSP_MODE_FM_TERRA);
  519. state->watch_stereo = 1;
  520. } else if (max2 == 1 && state->has_nicam) {
  521. /* B/G NICAM */
  522. state->second = msp3400c_carrier_detect_55[max2].cdo;
  523. msp3400c_set_mode(client, MSP_MODE_FM_NICAM1);
  524. state->nicam_on = 1;
  525. state->watch_stereo = 1;
  526. } else {
  527. goto no_second;
  528. }
  529. break;
  530. case 2: /* 6.0 */
  531. /* PAL I NICAM */
  532. state->second = MSP_CARRIER(6.552);
  533. msp3400c_set_mode(client, MSP_MODE_FM_NICAM2);
  534. state->nicam_on = 1;
  535. state->watch_stereo = 1;
  536. break;
  537. case 3: /* 6.5 */
  538. if (max2 == 1 || max2 == 2) {
  539. /* D/K FM-stereo */
  540. state->second = msp3400c_carrier_detect_65[max2].cdo;
  541. msp3400c_set_mode(client, MSP_MODE_FM_TERRA);
  542. state->watch_stereo = 1;
  543. } else if (max2 == 0 && (state->v4l2_std & V4L2_STD_SECAM)) {
  544. /* L NICAM or AM-mono */
  545. state->second = msp3400c_carrier_detect_65[max2].cdo;
  546. msp3400c_set_mode(client, MSP_MODE_AM_NICAM);
  547. state->watch_stereo = 1;
  548. } else if (max2 == 0 && state->has_nicam) {
  549. /* D/K NICAM */
  550. state->second = msp3400c_carrier_detect_65[max2].cdo;
  551. msp3400c_set_mode(client, MSP_MODE_FM_NICAM1);
  552. state->nicam_on = 1;
  553. state->watch_stereo = 1;
  554. } else {
  555. goto no_second;
  556. }
  557. break;
  558. case 0: /* 4.5 */
  559. default:
  560. no_second:
  561. state->second = msp3400c_carrier_detect_main[max1].cdo;
  562. msp3400c_set_mode(client, MSP_MODE_FM_TERRA);
  563. break;
  564. }
  565. msp3400c_set_carrier(client, state->second, state->main);
  566. /* unmute */
  567. state->scan_in_progress = 0;
  568. msp3400c_set_audmode(client);
  569. msp_set_audio(client);
  570. if (msp_debug)
  571. msp3400c_print_mode(client);
  572. /* monitor tv audio mode, the first time don't wait
  573. so long to get a quick stereo/bilingual result */
  574. count = 3;
  575. while (state->watch_stereo) {
  576. if (msp_sleep(state, count ? 1000 : 5000))
  577. goto restart;
  578. if (count) count--;
  579. watch_stereo(client);
  580. }
  581. }
  582. v4l_dbg(1, msp_debug, client, "thread: exit\n");
  583. return 0;
  584. }
  585. int msp3410d_thread(void *data)
  586. {
  587. struct i2c_client *client = data;
  588. struct msp_state *state = i2c_get_clientdata(client);
  589. int val, i, std, count;
  590. v4l_dbg(1, msp_debug, client, "msp3410 daemon started\n");
  591. for (;;) {
  592. v4l_dbg(2, msp_debug, client, "msp3410 thread: sleep\n");
  593. msp_sleep(state,-1);
  594. v4l_dbg(2, msp_debug, client, "msp3410 thread: wakeup\n");
  595. restart:
  596. v4l_dbg(2, msp_debug, client, "thread: restart scan\n");
  597. state->restart = 0;
  598. if (kthread_should_stop())
  599. break;
  600. if (state->mode == MSP_MODE_EXTERN) {
  601. /* no carrier scan needed, just unmute */
  602. v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
  603. state->scan_in_progress = 0;
  604. msp_set_audio(client);
  605. continue;
  606. }
  607. /* mute audio */
  608. state->scan_in_progress = 1;
  609. msp_set_audio(client);
  610. /* start autodetect. Note: autodetect is not supported for
  611. NTSC-M and radio, hence we force the standard in those cases. */
  612. if (state->radio)
  613. std = 0x40;
  614. else
  615. std = (state->v4l2_std & V4L2_STD_NTSC) ? 0x20 : 1;
  616. state->watch_stereo = 0;
  617. state->nicam_on = 0;
  618. /* wait for tuner to settle down after a channel change */
  619. if (msp_sleep(state, 200))
  620. goto restart;
  621. if (msp_debug)
  622. v4l_dbg(2, msp_debug, client, "setting standard: %s (0x%04x)\n",
  623. msp_standard_std_name(std), std);
  624. if (std != 1) {
  625. /* programmed some specific mode */
  626. val = std;
  627. } else {
  628. /* triggered autodetect */
  629. msp_write_dem(client, 0x20, std);
  630. for (;;) {
  631. if (msp_sleep(state, 100))
  632. goto restart;
  633. /* check results */
  634. val = msp_read_dem(client, 0x7e);
  635. if (val < 0x07ff)
  636. break;
  637. v4l_dbg(2, msp_debug, client, "detection still in progress\n");
  638. }
  639. }
  640. for (i = 0; msp_stdlist[i].name != NULL; i++)
  641. if (msp_stdlist[i].retval == val)
  642. break;
  643. v4l_dbg(1, msp_debug, client, "current standard: %s (0x%04x)\n",
  644. msp_standard_std_name(val), val);
  645. state->main = msp_stdlist[i].main;
  646. state->second = msp_stdlist[i].second;
  647. state->std = val;
  648. state->rxsubchans = V4L2_TUNER_SUB_MONO;
  649. if (msp_amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) &&
  650. (val != 0x0009)) {
  651. /* autodetection has failed, let backup */
  652. v4l_dbg(1, msp_debug, client, "autodetection failed,"
  653. " switching to backup standard: %s (0x%04x)\n",
  654. msp_stdlist[8].name ? msp_stdlist[8].name : "unknown",val);
  655. state->std = val = 0x0009;
  656. msp_write_dem(client, 0x20, val);
  657. }
  658. /* set stereo */
  659. switch (val) {
  660. case 0x0008: /* B/G NICAM */
  661. case 0x000a: /* I NICAM */
  662. case 0x000b: /* D/K NICAM */
  663. if (val == 0x000a)
  664. state->mode = MSP_MODE_FM_NICAM2;
  665. else
  666. state->mode = MSP_MODE_FM_NICAM1;
  667. /* just turn on stereo */
  668. state->nicam_on = 1;
  669. state->watch_stereo = 1;
  670. break;
  671. case 0x0009:
  672. state->mode = MSP_MODE_AM_NICAM;
  673. state->nicam_on = 1;
  674. state->watch_stereo = 1;
  675. break;
  676. case 0x0020: /* BTSC */
  677. /* The pre-'G' models only have BTSC-mono */
  678. state->mode = MSP_MODE_BTSC;
  679. break;
  680. case 0x0040: /* FM radio */
  681. state->mode = MSP_MODE_FM_RADIO;
  682. state->rxsubchans = V4L2_TUNER_SUB_STEREO;
  683. /* not needed in theory if we have radio, but
  684. short programming enables carrier mute */
  685. msp3400c_set_mode(client, MSP_MODE_FM_RADIO);
  686. msp3400c_set_carrier(client, MSP_CARRIER(10.7),
  687. MSP_CARRIER(10.7));
  688. break;
  689. case 0x0002:
  690. case 0x0003:
  691. case 0x0004:
  692. case 0x0005:
  693. state->mode = MSP_MODE_FM_TERRA;
  694. state->watch_stereo = 1;
  695. break;
  696. }
  697. /* set various prescales */
  698. msp_write_dsp(client, 0x0d, 0x1900); /* scart */
  699. msp_write_dsp(client, 0x0e, 0x3000); /* FM */
  700. if (state->has_nicam)
  701. msp_write_dsp(client, 0x10, 0x5a00); /* nicam */
  702. if (state->has_i2s_conf)
  703. msp_write_dem(client, 0x40, state->i2s_mode);
  704. /* unmute */
  705. msp3400c_set_audmode(client);
  706. state->scan_in_progress = 0;
  707. msp_set_audio(client);
  708. /* monitor tv audio mode, the first time don't wait
  709. so long to get a quick stereo/bilingual result */
  710. count = 3;
  711. while (state->watch_stereo) {
  712. if (msp_sleep(state, count ? 1000 : 5000))
  713. goto restart;
  714. if (count) count--;
  715. watch_stereo(client);
  716. }
  717. }
  718. v4l_dbg(1, msp_debug, client, "thread: exit\n");
  719. return 0;
  720. }
  721. /* ----------------------------------------------------------------------- */
  722. /* msp34xxG + (autoselect no-thread)
  723. * this one uses both automatic standard detection and automatic sound
  724. * select which are available in the newer G versions
  725. * struct msp: only norm, acb and source are really used in this mode
  726. */
  727. static int msp34xxg_modus(struct i2c_client *client)
  728. {
  729. struct msp_state *state = i2c_get_clientdata(client);
  730. if (state->radio) {
  731. v4l_dbg(1, msp_debug, client, "selected radio modus\n");
  732. return 0x0001;
  733. }
  734. if (state->v4l2_std & V4L2_STD_PAL) {
  735. v4l_dbg(1, msp_debug, client, "selected PAL modus\n");
  736. return 0x7001;
  737. }
  738. if (state->v4l2_std == V4L2_STD_NTSC_M_JP) {
  739. v4l_dbg(1, msp_debug, client, "selected M (EIA-J) modus\n");
  740. return 0x4001;
  741. }
  742. if (state->v4l2_std == V4L2_STD_NTSC_M_KR) {
  743. v4l_dbg(1, msp_debug, client, "selected M (A2) modus\n");
  744. return 0x0001;
  745. }
  746. if (state->v4l2_std & V4L2_STD_MN) {
  747. v4l_dbg(1, msp_debug, client, "selected M (BTSC) modus\n");
  748. return 0x2001;
  749. }
  750. if (state->v4l2_std & V4L2_STD_SECAM) {
  751. v4l_dbg(1, msp_debug, client, "selected SECAM modus\n");
  752. return 0x6001;
  753. }
  754. return 0x0001;
  755. }
  756. static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
  757. {
  758. struct msp_state *state = i2c_get_clientdata(client);
  759. int source, matrix;
  760. switch (state->audmode) {
  761. case V4L2_TUNER_MODE_MONO:
  762. source = 0; /* mono only */
  763. matrix = 0x30;
  764. break;
  765. case V4L2_TUNER_MODE_LANG2:
  766. source = 4; /* stereo or B */
  767. matrix = 0x10;
  768. break;
  769. case V4L2_TUNER_MODE_LANG1_LANG2:
  770. source = 1; /* stereo or A|B */
  771. matrix = 0x20;
  772. break;
  773. case V4L2_TUNER_MODE_STEREO:
  774. case V4L2_TUNER_MODE_LANG1:
  775. default:
  776. source = 3; /* stereo or A */
  777. matrix = 0x00;
  778. break;
  779. }
  780. if (in == MSP_DSP_IN_TUNER)
  781. source = (source << 8) | 0x20;
  782. /* the msp34x2g puts the MAIN_AVC, MAIN and AUX sources in 12, 13, 14
  783. instead of 11, 12, 13. So we add one for that msp version. */
  784. else if (in >= MSP_DSP_IN_MAIN_AVC && state->has_dolby_pro_logic)
  785. source = ((in + 1) << 8) | matrix;
  786. else
  787. source = (in << 8) | matrix;
  788. v4l_dbg(1, msp_debug, client, "set source to %d (0x%x) for output %02x\n",
  789. in, source, reg);
  790. msp_write_dsp(client, reg, source);
  791. }
  792. static void msp34xxg_set_sources(struct i2c_client *client)
  793. {
  794. struct msp_state *state = i2c_get_clientdata(client);
  795. u32 in = state->routing.input;
  796. msp34xxg_set_source(client, 0x0008, (in >> 4) & 0xf);
  797. /* quasi-peak detector is set to same input as the loudspeaker (MAIN) */
  798. msp34xxg_set_source(client, 0x000c, (in >> 4) & 0xf);
  799. msp34xxg_set_source(client, 0x0009, (in >> 8) & 0xf);
  800. msp34xxg_set_source(client, 0x000a, (in >> 12) & 0xf);
  801. if (state->has_scart2_out)
  802. msp34xxg_set_source(client, 0x0041, (in >> 16) & 0xf);
  803. msp34xxg_set_source(client, 0x000b, (in >> 20) & 0xf);
  804. }
  805. /* (re-)initialize the msp34xxg */
  806. static void msp34xxg_reset(struct i2c_client *client)
  807. {
  808. struct msp_state *state = i2c_get_clientdata(client);
  809. int tuner = (state->routing.input >> 3) & 1;
  810. int modus;
  811. /* initialize std to 1 (autodetect) to signal that no standard is
  812. selected yet. */
  813. state->std = 1;
  814. msp_reset(client);
  815. if (state->has_i2s_conf)
  816. msp_write_dem(client, 0x40, state->i2s_mode);
  817. /* step-by-step initialisation, as described in the manual */
  818. modus = msp34xxg_modus(client);
  819. modus |= tuner ? 0x100 : 0;
  820. msp_write_dem(client, 0x30, modus);
  821. /* write the dsps that may have an influence on
  822. standard/audio autodetection right now */
  823. msp34xxg_set_sources(client);
  824. msp_write_dsp(client, 0x0d, 0x1900); /* scart */
  825. msp_write_dsp(client, 0x0e, 0x3000); /* FM */
  826. if (state->has_nicam)
  827. msp_write_dsp(client, 0x10, 0x5a00); /* nicam */
  828. /* set identification threshold. Personally, I
  829. * I set it to a higher value than the default
  830. * of 0x190 to ignore noisy stereo signals.
  831. * this needs tuning. (recommended range 0x00a0-0x03c0)
  832. * 0x7f0 = forced mono mode
  833. *
  834. * a2 threshold for stereo/bilingual.
  835. * Note: this register is part of the Manual/Compatibility mode.
  836. * It is supported by all 'G'-family chips.
  837. */
  838. msp_write_dem(client, 0x22, msp_stereo_thresh);
  839. }
  840. int msp34xxg_thread(void *data)
  841. {
  842. struct i2c_client *client = data;
  843. struct msp_state *state = i2c_get_clientdata(client);
  844. int val, i;
  845. v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n");
  846. for (;;) {
  847. v4l_dbg(2, msp_debug, client, "msp34xxg thread: sleep\n");
  848. msp_sleep(state, -1);
  849. v4l_dbg(2, msp_debug, client, "msp34xxg thread: wakeup\n");
  850. restart:
  851. v4l_dbg(1, msp_debug, client, "thread: restart scan\n");
  852. state->restart = 0;
  853. if (kthread_should_stop())
  854. break;
  855. if (state->mode == MSP_MODE_EXTERN) {
  856. /* no carrier scan needed, just unmute */
  857. v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
  858. state->scan_in_progress = 0;
  859. msp_set_audio(client);
  860. continue;
  861. }
  862. /* setup the chip*/
  863. msp34xxg_reset(client);
  864. state->std = state->radio ? 0x40 :
  865. (state->force_btsc && msp_standard == 1) ? 32 : msp_standard;
  866. msp_write_dem(client, 0x20, state->std);
  867. /* start autodetect */
  868. if (state->std != 1)
  869. goto unmute;
  870. /* watch autodetect */
  871. v4l_dbg(1, msp_debug, client, "started autodetect, waiting for result\n");
  872. for (i = 0; i < 10; i++) {
  873. if (msp_sleep(state, 100))
  874. goto restart;
  875. /* check results */
  876. val = msp_read_dem(client, 0x7e);
  877. if (val < 0x07ff) {
  878. state->std = val;
  879. break;
  880. }
  881. v4l_dbg(2, msp_debug, client, "detection still in progress\n");
  882. }
  883. if (state->std == 1) {
  884. v4l_dbg(1, msp_debug, client, "detection still in progress after 10 tries. giving up.\n");
  885. continue;
  886. }
  887. unmute:
  888. v4l_dbg(1, msp_debug, client, "detected standard: %s (0x%04x)\n",
  889. msp_standard_std_name(state->std), state->std);
  890. if (state->std == 9) {
  891. /* AM NICAM mode */
  892. msp_write_dsp(client, 0x0e, 0x7c00);
  893. }
  894. /* unmute: dispatch sound to scart output, set scart volume */
  895. msp_set_audio(client);
  896. /* restore ACB */
  897. if (msp_write_dsp(client, 0x13, state->acb))
  898. return -1;
  899. /* the periodic stereo/SAP check is only relevant for
  900. the 0x20 standard (BTSC) */
  901. if (state->std != 0x20)
  902. continue;
  903. state->watch_stereo = 1;
  904. /* monitor tv audio mode, the first time don't wait
  905. in order to get a quick stereo/SAP update */
  906. watch_stereo(client);
  907. while (state->watch_stereo) {
  908. watch_stereo(client);
  909. if (msp_sleep(state, 5000))
  910. goto restart;
  911. }
  912. }
  913. v4l_dbg(1, msp_debug, client, "thread: exit\n");
  914. return 0;
  915. }
  916. static int msp34xxg_detect_stereo(struct i2c_client *client)
  917. {
  918. struct msp_state *state = i2c_get_clientdata(client);
  919. int status = msp_read_dem(client, 0x0200);
  920. int is_bilingual = status & 0x100;
  921. int is_stereo = status & 0x40;
  922. int oldrx = state->rxsubchans;
  923. state->rxsubchans = 0;
  924. if (is_stereo)
  925. state->rxsubchans = V4L2_TUNER_SUB_STEREO;
  926. else
  927. state->rxsubchans = V4L2_TUNER_SUB_MONO;
  928. if (is_bilingual) {
  929. if (state->std == 0x20)
  930. state->rxsubchans |= V4L2_TUNER_SUB_SAP;
  931. else
  932. state->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
  933. }
  934. v4l_dbg(1, msp_debug, client, "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n",
  935. status, is_stereo, is_bilingual, state->rxsubchans);
  936. return (oldrx != state->rxsubchans);
  937. }
  938. static void msp34xxg_set_audmode(struct i2c_client *client)
  939. {
  940. struct msp_state *state = i2c_get_clientdata(client);
  941. if (state->std == 0x20) {
  942. if ((state->rxsubchans & V4L2_TUNER_SUB_SAP) &&
  943. (state->audmode == V4L2_TUNER_MODE_LANG1_LANG2 ||
  944. state->audmode == V4L2_TUNER_MODE_LANG2)) {
  945. msp_write_dem(client, 0x20, 0x21);
  946. } else {
  947. msp_write_dem(client, 0x20, 0x20);
  948. }
  949. }
  950. msp34xxg_set_sources(client);
  951. }
  952. void msp_set_audmode(struct i2c_client *client)
  953. {
  954. struct msp_state *state = i2c_get_clientdata(client);
  955. switch (state->opmode) {
  956. case OPMODE_MANUAL:
  957. case OPMODE_AUTODETECT:
  958. msp3400c_set_audmode(client);
  959. break;
  960. case OPMODE_AUTOSELECT:
  961. msp34xxg_set_audmode(client);
  962. break;
  963. }
  964. }
  965. int msp_detect_stereo(struct i2c_client *client)
  966. {
  967. struct msp_state *state = i2c_get_clientdata(client);
  968. switch (state->opmode) {
  969. case OPMODE_MANUAL:
  970. case OPMODE_AUTODETECT:
  971. return msp3400c_detect_stereo(client);
  972. case OPMODE_AUTOSELECT:
  973. return msp34xxg_detect_stereo(client);
  974. }
  975. return 0;
  976. }