cx25840-core.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156
  1. /* cx25840 - Conexant CX25840 audio/video decoder driver
  2. *
  3. * Copyright (C) 2004 Ulf Eklund
  4. *
  5. * Based on the saa7115 driver and on the first verison of Chris Kennedy's
  6. * cx25840 driver.
  7. *
  8. * Changes by Tyler Trafford <tatrafford@comcast.net>
  9. * - cleanup/rewrite for V4L2 API (2005)
  10. *
  11. * VBI support by Hans Verkuil <hverkuil@xs4all.nl>.
  12. *
  13. * NTSC sliced VBI support by Christopher Neufeld <television@cneufeld.ca>
  14. * with additional fixes by Hans Verkuil <hverkuil@xs4all.nl>.
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License
  18. * as published by the Free Software Foundation; either version 2
  19. * of the License, or (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  29. */
  30. #include <linux/kernel.h>
  31. #include <linux/module.h>
  32. #include <linux/slab.h>
  33. #include <linux/videodev2.h>
  34. #include <linux/i2c.h>
  35. #include <media/v4l2-common.h>
  36. #include <media/v4l2-chip-ident.h>
  37. #include <media/cx25840.h>
  38. #include "cx25840-core.h"
  39. MODULE_DESCRIPTION("Conexant CX25840 audio/video decoder driver");
  40. MODULE_AUTHOR("Ulf Eklund, Chris Kennedy, Hans Verkuil, Tyler Trafford");
  41. MODULE_LICENSE("GPL");
  42. static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };
  43. int cx25840_debug;
  44. module_param_named(debug,cx25840_debug, int, 0644);
  45. MODULE_PARM_DESC(debug, "Debugging messages [0=Off (default) 1=On]");
  46. I2C_CLIENT_INSMOD;
  47. /* ----------------------------------------------------------------------- */
  48. int cx25840_write(struct i2c_client *client, u16 addr, u8 value)
  49. {
  50. u8 buffer[3];
  51. buffer[0] = addr >> 8;
  52. buffer[1] = addr & 0xff;
  53. buffer[2] = value;
  54. return i2c_master_send(client, buffer, 3);
  55. }
  56. int cx25840_write4(struct i2c_client *client, u16 addr, u32 value)
  57. {
  58. u8 buffer[6];
  59. buffer[0] = addr >> 8;
  60. buffer[1] = addr & 0xff;
  61. buffer[2] = value >> 24;
  62. buffer[3] = (value >> 16) & 0xff;
  63. buffer[4] = (value >> 8) & 0xff;
  64. buffer[5] = value & 0xff;
  65. return i2c_master_send(client, buffer, 6);
  66. }
  67. u8 cx25840_read(struct i2c_client * client, u16 addr)
  68. {
  69. u8 buffer[2];
  70. buffer[0] = addr >> 8;
  71. buffer[1] = addr & 0xff;
  72. if (i2c_master_send(client, buffer, 2) < 2)
  73. return 0;
  74. if (i2c_master_recv(client, buffer, 1) < 1)
  75. return 0;
  76. return buffer[0];
  77. }
  78. u32 cx25840_read4(struct i2c_client * client, u16 addr)
  79. {
  80. u8 buffer[4];
  81. buffer[0] = addr >> 8;
  82. buffer[1] = addr & 0xff;
  83. if (i2c_master_send(client, buffer, 2) < 2)
  84. return 0;
  85. if (i2c_master_recv(client, buffer, 4) < 4)
  86. return 0;
  87. return (buffer[3] << 24) | (buffer[2] << 16) |
  88. (buffer[1] << 8) | buffer[0];
  89. }
  90. int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned and_mask,
  91. u8 or_value)
  92. {
  93. return cx25840_write(client, addr,
  94. (cx25840_read(client, addr) & and_mask) |
  95. or_value);
  96. }
  97. /* ----------------------------------------------------------------------- */
  98. static int set_input(struct i2c_client *client, enum cx25840_video_input vid_input,
  99. enum cx25840_audio_input aud_input);
  100. static void log_audio_status(struct i2c_client *client);
  101. static void log_video_status(struct i2c_client *client);
  102. /* ----------------------------------------------------------------------- */
  103. static void init_dll1(struct i2c_client *client)
  104. {
  105. /* This is the Hauppauge sequence used to
  106. * initialize the Delay Lock Loop 1 (ADC DLL). */
  107. cx25840_write(client, 0x159, 0x23);
  108. cx25840_write(client, 0x15a, 0x87);
  109. cx25840_write(client, 0x15b, 0x06);
  110. cx25840_write(client, 0x159, 0xe1);
  111. cx25840_write(client, 0x15a, 0x86);
  112. cx25840_write(client, 0x159, 0xe0);
  113. cx25840_write(client, 0x159, 0xe1);
  114. cx25840_write(client, 0x15b, 0x10);
  115. }
  116. static void init_dll2(struct i2c_client *client)
  117. {
  118. /* This is the Hauppauge sequence used to
  119. * initialize the Delay Lock Loop 2 (ADC DLL). */
  120. cx25840_write(client, 0x15d, 0xe3);
  121. cx25840_write(client, 0x15e, 0x86);
  122. cx25840_write(client, 0x15f, 0x06);
  123. cx25840_write(client, 0x15d, 0xe1);
  124. cx25840_write(client, 0x15d, 0xe0);
  125. cx25840_write(client, 0x15d, 0xe1);
  126. }
  127. static void cx25836_initialize(struct i2c_client *client)
  128. {
  129. /* reset configuration is described on page 3-77 of the CX25836 datasheet */
  130. /* 2. */
  131. cx25840_and_or(client, 0x000, ~0x01, 0x01);
  132. cx25840_and_or(client, 0x000, ~0x01, 0x00);
  133. /* 3a. */
  134. cx25840_and_or(client, 0x15a, ~0x70, 0x00);
  135. /* 3b. */
  136. cx25840_and_or(client, 0x15b, ~0x1e, 0x06);
  137. /* 3c. */
  138. cx25840_and_or(client, 0x159, ~0x02, 0x02);
  139. /* 3d. */
  140. /* There should be a 10-us delay here, but since the
  141. i2c bus already has a 10-us delay we don't need to do
  142. anything */
  143. /* 3e. */
  144. cx25840_and_or(client, 0x159, ~0x02, 0x00);
  145. /* 3f. */
  146. cx25840_and_or(client, 0x159, ~0xc0, 0xc0);
  147. /* 3g. */
  148. cx25840_and_or(client, 0x159, ~0x01, 0x00);
  149. cx25840_and_or(client, 0x159, ~0x01, 0x01);
  150. /* 3h. */
  151. cx25840_and_or(client, 0x15b, ~0x1e, 0x10);
  152. }
  153. static void cx25840_initialize(struct i2c_client *client, int loadfw)
  154. {
  155. struct cx25840_state *state = i2c_get_clientdata(client);
  156. /* datasheet startup in numbered steps, refer to page 3-77 */
  157. /* 2. */
  158. cx25840_and_or(client, 0x803, ~0x10, 0x00);
  159. /* The default of this register should be 4, but I get 0 instead.
  160. * Set this register to 4 manually. */
  161. cx25840_write(client, 0x000, 0x04);
  162. /* 3. */
  163. init_dll1(client);
  164. init_dll2(client);
  165. cx25840_write(client, 0x136, 0x0a);
  166. /* 4. */
  167. cx25840_write(client, 0x13c, 0x01);
  168. cx25840_write(client, 0x13c, 0x00);
  169. /* 5. */
  170. if (loadfw)
  171. cx25840_loadfw(client);
  172. /* 6. */
  173. cx25840_write(client, 0x115, 0x8c);
  174. cx25840_write(client, 0x116, 0x07);
  175. cx25840_write(client, 0x118, 0x02);
  176. /* 7. */
  177. cx25840_write(client, 0x4a5, 0x80);
  178. cx25840_write(client, 0x4a5, 0x00);
  179. cx25840_write(client, 0x402, 0x00);
  180. /* 8. */
  181. cx25840_and_or(client, 0x401, ~0x18, 0);
  182. cx25840_and_or(client, 0x4a2, ~0x10, 0x10);
  183. /* steps 8c and 8d are done in change_input() */
  184. /* 10. */
  185. cx25840_write(client, 0x8d3, 0x1f);
  186. cx25840_write(client, 0x8e3, 0x03);
  187. cx25840_vbi_setup(client);
  188. /* trial and error says these are needed to get audio */
  189. cx25840_write(client, 0x914, 0xa0);
  190. cx25840_write(client, 0x918, 0xa0);
  191. cx25840_write(client, 0x919, 0x01);
  192. /* stereo prefered */
  193. cx25840_write(client, 0x809, 0x04);
  194. /* AC97 shift */
  195. cx25840_write(client, 0x8cf, 0x0f);
  196. /* (re)set input */
  197. set_input(client, state->vid_input, state->aud_input);
  198. /* start microcontroller */
  199. cx25840_and_or(client, 0x803, ~0x10, 0x10);
  200. }
  201. /* ----------------------------------------------------------------------- */
  202. static void input_change(struct i2c_client *client)
  203. {
  204. struct cx25840_state *state = i2c_get_clientdata(client);
  205. v4l2_std_id std = cx25840_get_v4lstd(client);
  206. /* Follow step 8c and 8d of section 3.16 in the cx25840 datasheet */
  207. if (std & V4L2_STD_SECAM) {
  208. cx25840_write(client, 0x402, 0);
  209. }
  210. else {
  211. cx25840_write(client, 0x402, 0x04);
  212. cx25840_write(client, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11);
  213. }
  214. cx25840_and_or(client, 0x401, ~0x60, 0);
  215. cx25840_and_or(client, 0x401, ~0x60, 0x60);
  216. if (std & V4L2_STD_525_60) {
  217. /* Certain Hauppauge PVR150 models have a hardware bug
  218. that causes audio to drop out. For these models the
  219. audio standard must be set explicitly.
  220. To be precise: it affects cards with tuner models
  221. 85, 99 and 112 (model numbers from tveeprom). */
  222. int hw_fix = state->pvr150_workaround;
  223. if (std == V4L2_STD_NTSC_M_JP) {
  224. /* Japan uses EIAJ audio standard */
  225. cx25840_write(client, 0x808, hw_fix ? 0x2f : 0xf7);
  226. } else if (std == V4L2_STD_NTSC_M_KR) {
  227. /* South Korea uses A2 audio standard */
  228. cx25840_write(client, 0x808, hw_fix ? 0x3f : 0xf8);
  229. } else {
  230. /* Others use the BTSC audio standard */
  231. cx25840_write(client, 0x808, hw_fix ? 0x1f : 0xf6);
  232. }
  233. cx25840_write(client, 0x80b, 0x00);
  234. } else if (std & V4L2_STD_PAL) {
  235. /* Follow tuner change procedure for PAL */
  236. cx25840_write(client, 0x808, 0xff);
  237. cx25840_write(client, 0x80b, 0x10);
  238. } else if (std & V4L2_STD_SECAM) {
  239. /* Select autodetect for SECAM */
  240. cx25840_write(client, 0x808, 0xff);
  241. cx25840_write(client, 0x80b, 0x10);
  242. }
  243. if (cx25840_read(client, 0x803) & 0x10) {
  244. /* restart audio decoder microcontroller */
  245. cx25840_and_or(client, 0x803, ~0x10, 0x00);
  246. cx25840_and_or(client, 0x803, ~0x10, 0x10);
  247. }
  248. }
  249. static int set_input(struct i2c_client *client, enum cx25840_video_input vid_input,
  250. enum cx25840_audio_input aud_input)
  251. {
  252. struct cx25840_state *state = i2c_get_clientdata(client);
  253. u8 is_composite = (vid_input >= CX25840_COMPOSITE1 &&
  254. vid_input <= CX25840_COMPOSITE8);
  255. u8 reg;
  256. v4l_dbg(1, cx25840_debug, client, "decoder set video input %d, audio input %d\n",
  257. vid_input, aud_input);
  258. if (is_composite) {
  259. reg = 0xf0 + (vid_input - CX25840_COMPOSITE1);
  260. } else {
  261. int luma = vid_input & 0xf0;
  262. int chroma = vid_input & 0xf00;
  263. if ((vid_input & ~0xff0) ||
  264. luma < CX25840_SVIDEO_LUMA1 || luma > CX25840_SVIDEO_LUMA4 ||
  265. chroma < CX25840_SVIDEO_CHROMA4 || chroma > CX25840_SVIDEO_CHROMA8) {
  266. v4l_err(client, "0x%04x is not a valid video input!\n", vid_input);
  267. return -EINVAL;
  268. }
  269. reg = 0xf0 + ((luma - CX25840_SVIDEO_LUMA1) >> 4);
  270. if (chroma >= CX25840_SVIDEO_CHROMA7) {
  271. reg &= 0x3f;
  272. reg |= (chroma - CX25840_SVIDEO_CHROMA7) >> 2;
  273. } else {
  274. reg &= 0xcf;
  275. reg |= (chroma - CX25840_SVIDEO_CHROMA4) >> 4;
  276. }
  277. }
  278. switch (aud_input) {
  279. case CX25840_AUDIO_SERIAL:
  280. /* do nothing, use serial audio input */
  281. break;
  282. case CX25840_AUDIO4: reg &= ~0x30; break;
  283. case CX25840_AUDIO5: reg &= ~0x30; reg |= 0x10; break;
  284. case CX25840_AUDIO6: reg &= ~0x30; reg |= 0x20; break;
  285. case CX25840_AUDIO7: reg &= ~0xc0; break;
  286. case CX25840_AUDIO8: reg &= ~0xc0; reg |= 0x40; break;
  287. default:
  288. v4l_err(client, "0x%04x is not a valid audio input!\n", aud_input);
  289. return -EINVAL;
  290. }
  291. cx25840_write(client, 0x103, reg);
  292. /* Set INPUT_MODE to Composite (0) or S-Video (1) */
  293. cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02);
  294. /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */
  295. cx25840_and_or(client, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0);
  296. /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */
  297. if ((reg & 0xc0) != 0xc0 && (reg & 0x30) != 0x30)
  298. cx25840_and_or(client, 0x102, ~0x4, 4);
  299. else
  300. cx25840_and_or(client, 0x102, ~0x4, 0);
  301. state->vid_input = vid_input;
  302. state->aud_input = aud_input;
  303. if (!state->is_cx25836) {
  304. cx25840_audio_set_path(client);
  305. input_change(client);
  306. }
  307. return 0;
  308. }
  309. /* ----------------------------------------------------------------------- */
  310. static int set_v4lstd(struct i2c_client *client, v4l2_std_id std)
  311. {
  312. u8 fmt=0; /* zero is autodetect */
  313. /* First tests should be against specific std */
  314. if (std == V4L2_STD_NTSC_M_JP) {
  315. fmt=0x2;
  316. } else if (std == V4L2_STD_NTSC_443) {
  317. fmt=0x3;
  318. } else if (std == V4L2_STD_PAL_M) {
  319. fmt=0x5;
  320. } else if (std == V4L2_STD_PAL_N) {
  321. fmt=0x6;
  322. } else if (std == V4L2_STD_PAL_Nc) {
  323. fmt=0x7;
  324. } else if (std == V4L2_STD_PAL_60) {
  325. fmt=0x8;
  326. } else {
  327. /* Then, test against generic ones */
  328. if (std & V4L2_STD_NTSC) {
  329. fmt=0x1;
  330. } else if (std & V4L2_STD_PAL) {
  331. fmt=0x4;
  332. } else if (std & V4L2_STD_SECAM) {
  333. fmt=0xc;
  334. }
  335. }
  336. v4l_dbg(1, cx25840_debug, client, "changing video std to fmt %i\n",fmt);
  337. /* Follow step 9 of section 3.16 in the cx25840 datasheet.
  338. Without this PAL may display a vertical ghosting effect.
  339. This happens for example with the Yuan MPC622. */
  340. if (fmt >= 4 && fmt < 8) {
  341. /* Set format to NTSC-M */
  342. cx25840_and_or(client, 0x400, ~0xf, 1);
  343. /* Turn off LCOMB */
  344. cx25840_and_or(client, 0x47b, ~6, 0);
  345. }
  346. cx25840_and_or(client, 0x400, ~0xf, fmt);
  347. cx25840_vbi_setup(client);
  348. return 0;
  349. }
  350. v4l2_std_id cx25840_get_v4lstd(struct i2c_client * client)
  351. {
  352. struct cx25840_state *state = i2c_get_clientdata(client);
  353. /* check VID_FMT_SEL first */
  354. u8 fmt = cx25840_read(client, 0x400) & 0xf;
  355. if (!fmt) {
  356. /* check AFD_FMT_STAT if set to autodetect */
  357. fmt = cx25840_read(client, 0x40d) & 0xf;
  358. }
  359. switch (fmt) {
  360. case 0x1:
  361. {
  362. /* if the audio std is A2-M, then this is the South Korean
  363. NTSC standard */
  364. if (!state->is_cx25836 && cx25840_read(client, 0x805) == 2)
  365. return V4L2_STD_NTSC_M_KR;
  366. return V4L2_STD_NTSC_M;
  367. }
  368. case 0x2: return V4L2_STD_NTSC_M_JP;
  369. case 0x3: return V4L2_STD_NTSC_443;
  370. case 0x4: return V4L2_STD_PAL;
  371. case 0x5: return V4L2_STD_PAL_M;
  372. case 0x6: return V4L2_STD_PAL_N;
  373. case 0x7: return V4L2_STD_PAL_Nc;
  374. case 0x8: return V4L2_STD_PAL_60;
  375. case 0xc: return V4L2_STD_SECAM;
  376. default: return V4L2_STD_UNKNOWN;
  377. }
  378. }
  379. /* ----------------------------------------------------------------------- */
  380. static int set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
  381. {
  382. struct cx25840_state *state = i2c_get_clientdata(client);
  383. switch (ctrl->id) {
  384. case CX25840_CID_ENABLE_PVR150_WORKAROUND:
  385. state->pvr150_workaround = ctrl->value;
  386. set_input(client, state->vid_input, state->aud_input);
  387. break;
  388. case V4L2_CID_BRIGHTNESS:
  389. if (ctrl->value < 0 || ctrl->value > 255) {
  390. v4l_err(client, "invalid brightness setting %d\n",
  391. ctrl->value);
  392. return -ERANGE;
  393. }
  394. cx25840_write(client, 0x414, ctrl->value - 128);
  395. break;
  396. case V4L2_CID_CONTRAST:
  397. if (ctrl->value < 0 || ctrl->value > 127) {
  398. v4l_err(client, "invalid contrast setting %d\n",
  399. ctrl->value);
  400. return -ERANGE;
  401. }
  402. cx25840_write(client, 0x415, ctrl->value << 1);
  403. break;
  404. case V4L2_CID_SATURATION:
  405. if (ctrl->value < 0 || ctrl->value > 127) {
  406. v4l_err(client, "invalid saturation setting %d\n",
  407. ctrl->value);
  408. return -ERANGE;
  409. }
  410. cx25840_write(client, 0x420, ctrl->value << 1);
  411. cx25840_write(client, 0x421, ctrl->value << 1);
  412. break;
  413. case V4L2_CID_HUE:
  414. if (ctrl->value < -127 || ctrl->value > 127) {
  415. v4l_err(client, "invalid hue setting %d\n", ctrl->value);
  416. return -ERANGE;
  417. }
  418. cx25840_write(client, 0x422, ctrl->value);
  419. break;
  420. case V4L2_CID_AUDIO_VOLUME:
  421. case V4L2_CID_AUDIO_BASS:
  422. case V4L2_CID_AUDIO_TREBLE:
  423. case V4L2_CID_AUDIO_BALANCE:
  424. case V4L2_CID_AUDIO_MUTE:
  425. if (state->is_cx25836)
  426. return -EINVAL;
  427. return cx25840_audio(client, VIDIOC_S_CTRL, ctrl);
  428. default:
  429. return -EINVAL;
  430. }
  431. return 0;
  432. }
  433. static int get_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
  434. {
  435. struct cx25840_state *state = i2c_get_clientdata(client);
  436. switch (ctrl->id) {
  437. case CX25840_CID_ENABLE_PVR150_WORKAROUND:
  438. ctrl->value = state->pvr150_workaround;
  439. break;
  440. case V4L2_CID_BRIGHTNESS:
  441. ctrl->value = (s8)cx25840_read(client, 0x414) + 128;
  442. break;
  443. case V4L2_CID_CONTRAST:
  444. ctrl->value = cx25840_read(client, 0x415) >> 1;
  445. break;
  446. case V4L2_CID_SATURATION:
  447. ctrl->value = cx25840_read(client, 0x420) >> 1;
  448. break;
  449. case V4L2_CID_HUE:
  450. ctrl->value = (s8)cx25840_read(client, 0x422);
  451. break;
  452. case V4L2_CID_AUDIO_VOLUME:
  453. case V4L2_CID_AUDIO_BASS:
  454. case V4L2_CID_AUDIO_TREBLE:
  455. case V4L2_CID_AUDIO_BALANCE:
  456. case V4L2_CID_AUDIO_MUTE:
  457. if (state->is_cx25836)
  458. return -EINVAL;
  459. return cx25840_audio(client, VIDIOC_G_CTRL, ctrl);
  460. default:
  461. return -EINVAL;
  462. }
  463. return 0;
  464. }
  465. /* ----------------------------------------------------------------------- */
  466. static int get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
  467. {
  468. switch (fmt->type) {
  469. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  470. return cx25840_vbi(client, VIDIOC_G_FMT, fmt);
  471. default:
  472. return -EINVAL;
  473. }
  474. return 0;
  475. }
  476. static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
  477. {
  478. struct v4l2_pix_format *pix;
  479. int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
  480. int is_50Hz = !(cx25840_get_v4lstd(client) & V4L2_STD_525_60);
  481. switch (fmt->type) {
  482. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  483. pix = &(fmt->fmt.pix);
  484. Vsrc = (cx25840_read(client, 0x476) & 0x3f) << 4;
  485. Vsrc |= (cx25840_read(client, 0x475) & 0xf0) >> 4;
  486. Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4;
  487. Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4;
  488. Vlines = pix->height + (is_50Hz ? 4 : 7);
  489. if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) ||
  490. (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) {
  491. v4l_err(client, "%dx%d is not a valid size!\n",
  492. pix->width, pix->height);
  493. return -ERANGE;
  494. }
  495. HSC = (Hsrc * (1 << 20)) / pix->width - (1 << 20);
  496. VSC = (1 << 16) - (Vsrc * (1 << 9) / Vlines - (1 << 9));
  497. VSC &= 0x1fff;
  498. if (pix->width >= 385)
  499. filter = 0;
  500. else if (pix->width > 192)
  501. filter = 1;
  502. else if (pix->width > 96)
  503. filter = 2;
  504. else
  505. filter = 3;
  506. v4l_dbg(1, cx25840_debug, client, "decoder set size %dx%d -> scale %ux%u\n",
  507. pix->width, pix->height, HSC, VSC);
  508. /* HSCALE=HSC */
  509. cx25840_write(client, 0x418, HSC & 0xff);
  510. cx25840_write(client, 0x419, (HSC >> 8) & 0xff);
  511. cx25840_write(client, 0x41a, HSC >> 16);
  512. /* VSCALE=VSC */
  513. cx25840_write(client, 0x41c, VSC & 0xff);
  514. cx25840_write(client, 0x41d, VSC >> 8);
  515. /* VS_INTRLACE=1 VFILT=filter */
  516. cx25840_write(client, 0x41e, 0x8 | filter);
  517. break;
  518. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  519. return cx25840_vbi(client, VIDIOC_S_FMT, fmt);
  520. case V4L2_BUF_TYPE_VBI_CAPTURE:
  521. return cx25840_vbi(client, VIDIOC_S_FMT, fmt);
  522. default:
  523. return -EINVAL;
  524. }
  525. return 0;
  526. }
  527. /* ----------------------------------------------------------------------- */
  528. static int cx25840_command(struct i2c_client *client, unsigned int cmd,
  529. void *arg)
  530. {
  531. struct cx25840_state *state = i2c_get_clientdata(client);
  532. struct v4l2_tuner *vt = arg;
  533. struct v4l2_routing *route = arg;
  534. switch (cmd) {
  535. #ifdef CONFIG_VIDEO_ADV_DEBUG
  536. /* ioctls to allow direct access to the
  537. * cx25840 registers for testing */
  538. case VIDIOC_DBG_G_REGISTER:
  539. case VIDIOC_DBG_S_REGISTER:
  540. {
  541. struct v4l2_register *reg = arg;
  542. if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip))
  543. return -EINVAL;
  544. if (!capable(CAP_SYS_ADMIN))
  545. return -EPERM;
  546. if (cmd == VIDIOC_DBG_G_REGISTER)
  547. reg->val = cx25840_read(client, reg->reg & 0x0fff);
  548. else
  549. cx25840_write(client, reg->reg & 0x0fff, reg->val & 0xff);
  550. break;
  551. }
  552. #endif
  553. case VIDIOC_INT_DECODE_VBI_LINE:
  554. return cx25840_vbi(client, cmd, arg);
  555. case VIDIOC_INT_AUDIO_CLOCK_FREQ:
  556. return cx25840_audio(client, cmd, arg);
  557. case VIDIOC_STREAMON:
  558. v4l_dbg(1, cx25840_debug, client, "enable output\n");
  559. cx25840_write(client, 0x115, state->is_cx25836 ? 0x0c : 0x8c);
  560. cx25840_write(client, 0x116, state->is_cx25836 ? 0x04 : 0x07);
  561. break;
  562. case VIDIOC_STREAMOFF:
  563. v4l_dbg(1, cx25840_debug, client, "disable output\n");
  564. cx25840_write(client, 0x115, 0x00);
  565. cx25840_write(client, 0x116, 0x00);
  566. break;
  567. case VIDIOC_LOG_STATUS:
  568. log_video_status(client);
  569. if (!state->is_cx25836)
  570. log_audio_status(client);
  571. break;
  572. case VIDIOC_G_CTRL:
  573. return get_v4lctrl(client, (struct v4l2_control *)arg);
  574. case VIDIOC_S_CTRL:
  575. return set_v4lctrl(client, (struct v4l2_control *)arg);
  576. case VIDIOC_QUERYCTRL:
  577. {
  578. struct v4l2_queryctrl *qc = arg;
  579. switch (qc->id) {
  580. case V4L2_CID_BRIGHTNESS:
  581. case V4L2_CID_CONTRAST:
  582. case V4L2_CID_SATURATION:
  583. case V4L2_CID_HUE:
  584. return v4l2_ctrl_query_fill_std(qc);
  585. default:
  586. break;
  587. }
  588. if (state->is_cx25836)
  589. return -EINVAL;
  590. switch (qc->id) {
  591. case V4L2_CID_AUDIO_VOLUME:
  592. case V4L2_CID_AUDIO_MUTE:
  593. case V4L2_CID_AUDIO_BALANCE:
  594. case V4L2_CID_AUDIO_BASS:
  595. case V4L2_CID_AUDIO_TREBLE:
  596. return v4l2_ctrl_query_fill_std(qc);
  597. default:
  598. return -EINVAL;
  599. }
  600. return -EINVAL;
  601. }
  602. case VIDIOC_G_STD:
  603. *(v4l2_std_id *)arg = cx25840_get_v4lstd(client);
  604. break;
  605. case VIDIOC_S_STD:
  606. state->radio = 0;
  607. return set_v4lstd(client, *(v4l2_std_id *)arg);
  608. case AUDC_SET_RADIO:
  609. state->radio = 1;
  610. break;
  611. case VIDIOC_INT_G_VIDEO_ROUTING:
  612. route->input = state->vid_input;
  613. route->output = 0;
  614. break;
  615. case VIDIOC_INT_S_VIDEO_ROUTING:
  616. return set_input(client, route->input, state->aud_input);
  617. case VIDIOC_INT_G_AUDIO_ROUTING:
  618. if (state->is_cx25836)
  619. return -EINVAL;
  620. route->input = state->aud_input;
  621. route->output = 0;
  622. break;
  623. case VIDIOC_INT_S_AUDIO_ROUTING:
  624. if (state->is_cx25836)
  625. return -EINVAL;
  626. return set_input(client, state->vid_input, route->input);
  627. case VIDIOC_S_FREQUENCY:
  628. if (!state->is_cx25836) {
  629. input_change(client);
  630. }
  631. break;
  632. case VIDIOC_G_TUNER:
  633. {
  634. u8 vpres = cx25840_read(client, 0x40e) & 0x20;
  635. u8 mode;
  636. int val = 0;
  637. if (state->radio)
  638. break;
  639. vt->signal = vpres ? 0xffff : 0x0;
  640. if (state->is_cx25836)
  641. break;
  642. vt->capability |=
  643. V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 |
  644. V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
  645. mode = cx25840_read(client, 0x804);
  646. /* get rxsubchans and audmode */
  647. if ((mode & 0xf) == 1)
  648. val |= V4L2_TUNER_SUB_STEREO;
  649. else
  650. val |= V4L2_TUNER_SUB_MONO;
  651. if (mode == 2 || mode == 4)
  652. val = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
  653. if (mode & 0x10)
  654. val |= V4L2_TUNER_SUB_SAP;
  655. vt->rxsubchans = val;
  656. vt->audmode = state->audmode;
  657. break;
  658. }
  659. case VIDIOC_S_TUNER:
  660. if (state->radio || state->is_cx25836)
  661. break;
  662. switch (vt->audmode) {
  663. case V4L2_TUNER_MODE_MONO:
  664. /* mono -> mono
  665. stereo -> mono
  666. bilingual -> lang1 */
  667. cx25840_and_or(client, 0x809, ~0xf, 0x00);
  668. break;
  669. case V4L2_TUNER_MODE_STEREO:
  670. case V4L2_TUNER_MODE_LANG1:
  671. /* mono -> mono
  672. stereo -> stereo
  673. bilingual -> lang1 */
  674. cx25840_and_or(client, 0x809, ~0xf, 0x04);
  675. break;
  676. case V4L2_TUNER_MODE_LANG1_LANG2:
  677. /* mono -> mono
  678. stereo -> stereo
  679. bilingual -> lang1/lang2 */
  680. cx25840_and_or(client, 0x809, ~0xf, 0x07);
  681. break;
  682. case V4L2_TUNER_MODE_LANG2:
  683. /* mono -> mono
  684. stereo -> stereo
  685. bilingual -> lang2 */
  686. cx25840_and_or(client, 0x809, ~0xf, 0x01);
  687. break;
  688. default:
  689. return -EINVAL;
  690. }
  691. state->audmode = vt->audmode;
  692. break;
  693. case VIDIOC_G_FMT:
  694. return get_v4lfmt(client, (struct v4l2_format *)arg);
  695. case VIDIOC_S_FMT:
  696. return set_v4lfmt(client, (struct v4l2_format *)arg);
  697. case VIDIOC_INT_RESET:
  698. if (state->is_cx25836)
  699. cx25836_initialize(client);
  700. else
  701. cx25840_initialize(client, 0);
  702. break;
  703. case VIDIOC_G_CHIP_IDENT:
  704. return v4l2_chip_ident_i2c_client(client, arg, state->id, state->rev);
  705. default:
  706. return -EINVAL;
  707. }
  708. return 0;
  709. }
  710. /* ----------------------------------------------------------------------- */
  711. static struct i2c_driver i2c_driver_cx25840;
  712. static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
  713. int kind)
  714. {
  715. struct i2c_client *client;
  716. struct cx25840_state *state;
  717. u32 id;
  718. u16 device_id;
  719. /* Check if the adapter supports the needed features
  720. * Not until kernel version 2.6.11 did the bit-algo
  721. * correctly report that it would do an I2C-level xfer */
  722. if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
  723. return 0;
  724. state = kzalloc(sizeof(struct cx25840_state), GFP_KERNEL);
  725. if (state == 0)
  726. return -ENOMEM;
  727. client = &state->c;
  728. client->addr = address;
  729. client->adapter = adapter;
  730. client->driver = &i2c_driver_cx25840;
  731. snprintf(client->name, sizeof(client->name) - 1, "cx25840");
  732. v4l_dbg(1, cx25840_debug, client, "detecting cx25840 client on address 0x%x\n", address << 1);
  733. device_id = cx25840_read(client, 0x101) << 8;
  734. device_id |= cx25840_read(client, 0x100);
  735. /* The high byte of the device ID should be
  736. * 0x83 for the cx2583x and 0x84 for the cx2584x */
  737. if ((device_id & 0xff00) == 0x8300) {
  738. id = V4L2_IDENT_CX25836 + ((device_id >> 4) & 0xf) - 6;
  739. state->is_cx25836 = 1;
  740. }
  741. else if ((device_id & 0xff00) == 0x8400) {
  742. id = V4L2_IDENT_CX25840 + ((device_id >> 4) & 0xf);
  743. state->is_cx25836 = 0;
  744. }
  745. else {
  746. v4l_dbg(1, cx25840_debug, client, "cx25840 not found\n");
  747. kfree(state);
  748. return 0;
  749. }
  750. /* Note: revision '(device_id & 0x0f) == 2' was never built. The
  751. marking skips from 0x1 == 22 to 0x3 == 23. */
  752. v4l_info(client, "cx25%3x-2%x found @ 0x%x (%s)\n",
  753. (device_id & 0xfff0) >> 4,
  754. (device_id & 0x0f) < 3 ? (device_id & 0x0f) + 1 : (device_id & 0x0f),
  755. address << 1, adapter->name);
  756. i2c_set_clientdata(client, state);
  757. state->vid_input = CX25840_COMPOSITE7;
  758. state->aud_input = CX25840_AUDIO8;
  759. state->audclk_freq = 48000;
  760. state->pvr150_workaround = 0;
  761. state->audmode = V4L2_TUNER_MODE_LANG1;
  762. state->vbi_line_offset = 8;
  763. state->id = id;
  764. state->rev = device_id;
  765. i2c_attach_client(client);
  766. if (state->is_cx25836)
  767. cx25836_initialize(client);
  768. else
  769. cx25840_initialize(client, 1);
  770. return 0;
  771. }
  772. static int cx25840_attach_adapter(struct i2c_adapter *adapter)
  773. {
  774. if (adapter->class & I2C_CLASS_TV_ANALOG)
  775. return i2c_probe(adapter, &addr_data, &cx25840_detect_client);
  776. return 0;
  777. }
  778. static int cx25840_detach_client(struct i2c_client *client)
  779. {
  780. struct cx25840_state *state = i2c_get_clientdata(client);
  781. int err;
  782. err = i2c_detach_client(client);
  783. if (err) {
  784. return err;
  785. }
  786. kfree(state);
  787. return 0;
  788. }
  789. /* ----------------------------------------------------------------------- */
  790. static struct i2c_driver i2c_driver_cx25840 = {
  791. .driver = {
  792. .name = "cx25840",
  793. },
  794. .id = I2C_DRIVERID_CX25840,
  795. .attach_adapter = cx25840_attach_adapter,
  796. .detach_client = cx25840_detach_client,
  797. .command = cx25840_command,
  798. };
  799. static int __init m__init(void)
  800. {
  801. return i2c_add_driver(&i2c_driver_cx25840);
  802. }
  803. static void __exit m__exit(void)
  804. {
  805. i2c_del_driver(&i2c_driver_cx25840);
  806. }
  807. module_init(m__init);
  808. module_exit(m__exit);
  809. /* ----------------------------------------------------------------------- */
  810. static void log_video_status(struct i2c_client *client)
  811. {
  812. static const char *const fmt_strs[] = {
  813. "0x0",
  814. "NTSC-M", "NTSC-J", "NTSC-4.43",
  815. "PAL-BDGHI", "PAL-M", "PAL-N", "PAL-Nc", "PAL-60",
  816. "0x9", "0xA", "0xB",
  817. "SECAM",
  818. "0xD", "0xE", "0xF"
  819. };
  820. struct cx25840_state *state = i2c_get_clientdata(client);
  821. u8 vidfmt_sel = cx25840_read(client, 0x400) & 0xf;
  822. u8 gen_stat1 = cx25840_read(client, 0x40d);
  823. u8 gen_stat2 = cx25840_read(client, 0x40e);
  824. int vid_input = state->vid_input;
  825. v4l_info(client, "Video signal: %spresent\n",
  826. (gen_stat2 & 0x20) ? "" : "not ");
  827. v4l_info(client, "Detected format: %s\n",
  828. fmt_strs[gen_stat1 & 0xf]);
  829. v4l_info(client, "Specified standard: %s\n",
  830. vidfmt_sel ? fmt_strs[vidfmt_sel] : "automatic detection");
  831. if (vid_input >= CX25840_COMPOSITE1 &&
  832. vid_input <= CX25840_COMPOSITE8) {
  833. v4l_info(client, "Specified video input: Composite %d\n",
  834. vid_input - CX25840_COMPOSITE1 + 1);
  835. } else {
  836. v4l_info(client, "Specified video input: S-Video (Luma In%d, Chroma In%d)\n",
  837. (vid_input & 0xf0) >> 4, (vid_input & 0xf00) >> 8);
  838. }
  839. v4l_info(client, "Specified audioclock freq: %d Hz\n", state->audclk_freq);
  840. }
  841. /* ----------------------------------------------------------------------- */
  842. static void log_audio_status(struct i2c_client *client)
  843. {
  844. struct cx25840_state *state = i2c_get_clientdata(client);
  845. u8 download_ctl = cx25840_read(client, 0x803);
  846. u8 mod_det_stat0 = cx25840_read(client, 0x804);
  847. u8 mod_det_stat1 = cx25840_read(client, 0x805);
  848. u8 audio_config = cx25840_read(client, 0x808);
  849. u8 pref_mode = cx25840_read(client, 0x809);
  850. u8 afc0 = cx25840_read(client, 0x80b);
  851. u8 mute_ctl = cx25840_read(client, 0x8d3);
  852. int aud_input = state->aud_input;
  853. char *p;
  854. switch (mod_det_stat0) {
  855. case 0x00: p = "mono"; break;
  856. case 0x01: p = "stereo"; break;
  857. case 0x02: p = "dual"; break;
  858. case 0x04: p = "tri"; break;
  859. case 0x10: p = "mono with SAP"; break;
  860. case 0x11: p = "stereo with SAP"; break;
  861. case 0x12: p = "dual with SAP"; break;
  862. case 0x14: p = "tri with SAP"; break;
  863. case 0xfe: p = "forced mode"; break;
  864. default: p = "not defined";
  865. }
  866. v4l_info(client, "Detected audio mode: %s\n", p);
  867. switch (mod_det_stat1) {
  868. case 0x00: p = "not defined"; break;
  869. case 0x01: p = "EIAJ"; break;
  870. case 0x02: p = "A2-M"; break;
  871. case 0x03: p = "A2-BG"; break;
  872. case 0x04: p = "A2-DK1"; break;
  873. case 0x05: p = "A2-DK2"; break;
  874. case 0x06: p = "A2-DK3"; break;
  875. case 0x07: p = "A1 (6.0 MHz FM Mono)"; break;
  876. case 0x08: p = "AM-L"; break;
  877. case 0x09: p = "NICAM-BG"; break;
  878. case 0x0a: p = "NICAM-DK"; break;
  879. case 0x0b: p = "NICAM-I"; break;
  880. case 0x0c: p = "NICAM-L"; break;
  881. case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break;
  882. case 0x0e: p = "IF FM Radio"; break;
  883. case 0x0f: p = "BTSC"; break;
  884. case 0x10: p = "high-deviation FM"; break;
  885. case 0x11: p = "very high-deviation FM"; break;
  886. case 0xfd: p = "unknown audio standard"; break;
  887. case 0xfe: p = "forced audio standard"; break;
  888. case 0xff: p = "no detected audio standard"; break;
  889. default: p = "not defined";
  890. }
  891. v4l_info(client, "Detected audio standard: %s\n", p);
  892. v4l_info(client, "Audio muted: %s\n",
  893. (mute_ctl & 0x2) ? "yes" : "no");
  894. v4l_info(client, "Audio microcontroller: %s\n",
  895. (download_ctl & 0x10) ? "running" : "stopped");
  896. switch (audio_config >> 4) {
  897. case 0x00: p = "undefined"; break;
  898. case 0x01: p = "BTSC"; break;
  899. case 0x02: p = "EIAJ"; break;
  900. case 0x03: p = "A2-M"; break;
  901. case 0x04: p = "A2-BG"; break;
  902. case 0x05: p = "A2-DK1"; break;
  903. case 0x06: p = "A2-DK2"; break;
  904. case 0x07: p = "A2-DK3"; break;
  905. case 0x08: p = "A1 (6.0 MHz FM Mono)"; break;
  906. case 0x09: p = "AM-L"; break;
  907. case 0x0a: p = "NICAM-BG"; break;
  908. case 0x0b: p = "NICAM-DK"; break;
  909. case 0x0c: p = "NICAM-I"; break;
  910. case 0x0d: p = "NICAM-L"; break;
  911. case 0x0e: p = "FM radio"; break;
  912. case 0x0f: p = "automatic detection"; break;
  913. default: p = "undefined";
  914. }
  915. v4l_info(client, "Configured audio standard: %s\n", p);
  916. if ((audio_config >> 4) < 0xF) {
  917. switch (audio_config & 0xF) {
  918. case 0x00: p = "MONO1 (LANGUAGE A/Mono L+R channel for BTSC, EIAJ, A2)"; break;
  919. case 0x01: p = "MONO2 (LANGUAGE B)"; break;
  920. case 0x02: p = "MONO3 (STEREO forced MONO)"; break;
  921. case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break;
  922. case 0x04: p = "STEREO"; break;
  923. case 0x05: p = "DUAL1 (AB)"; break;
  924. case 0x06: p = "DUAL2 (AC) (FM)"; break;
  925. case 0x07: p = "DUAL3 (BC) (FM)"; break;
  926. case 0x08: p = "DUAL4 (AC) (AM)"; break;
  927. case 0x09: p = "DUAL5 (BC) (AM)"; break;
  928. case 0x0a: p = "SAP"; break;
  929. default: p = "undefined";
  930. }
  931. v4l_info(client, "Configured audio mode: %s\n", p);
  932. } else {
  933. switch (audio_config & 0xF) {
  934. case 0x00: p = "BG"; break;
  935. case 0x01: p = "DK1"; break;
  936. case 0x02: p = "DK2"; break;
  937. case 0x03: p = "DK3"; break;
  938. case 0x04: p = "I"; break;
  939. case 0x05: p = "L"; break;
  940. case 0x06: p = "BTSC"; break;
  941. case 0x07: p = "EIAJ"; break;
  942. case 0x08: p = "A2-M"; break;
  943. case 0x09: p = "FM Radio"; break;
  944. case 0x0f: p = "automatic standard and mode detection"; break;
  945. default: p = "undefined";
  946. }
  947. v4l_info(client, "Configured audio system: %s\n", p);
  948. }
  949. if (aud_input) {
  950. v4l_info(client, "Specified audio input: Tuner (In%d)\n", aud_input);
  951. } else {
  952. v4l_info(client, "Specified audio input: External\n");
  953. }
  954. switch (pref_mode & 0xf) {
  955. case 0: p = "mono/language A"; break;
  956. case 1: p = "language B"; break;
  957. case 2: p = "language C"; break;
  958. case 3: p = "analog fallback"; break;
  959. case 4: p = "stereo"; break;
  960. case 5: p = "language AC"; break;
  961. case 6: p = "language BC"; break;
  962. case 7: p = "language AB"; break;
  963. default: p = "undefined";
  964. }
  965. v4l_info(client, "Preferred audio mode: %s\n", p);
  966. if ((audio_config & 0xf) == 0xf) {
  967. switch ((afc0 >> 3) & 0x3) {
  968. case 0: p = "system DK"; break;
  969. case 1: p = "system L"; break;
  970. case 2: p = "autodetect"; break;
  971. default: p = "undefined";
  972. }
  973. v4l_info(client, "Selected 65 MHz format: %s\n", p);
  974. switch (afc0 & 0x7) {
  975. case 0: p = "chroma"; break;
  976. case 1: p = "BTSC"; break;
  977. case 2: p = "EIAJ"; break;
  978. case 3: p = "A2-M"; break;
  979. case 4: p = "autodetect"; break;
  980. default: p = "undefined";
  981. }
  982. v4l_info(client, "Selected 45 MHz format: %s\n", p);
  983. }
  984. }