cx18-av-core.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105
  1. /*
  2. * cx18 ADEC audio functions
  3. *
  4. * Derived from cx25840-core.c
  5. *
  6. * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
  7. * Copyright (C) 2008 Andy Walls <awalls@radix.net>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  22. * 02110-1301, USA.
  23. */
  24. #include "cx18-driver.h"
  25. #include "cx18-io.h"
  26. int cx18_av_write(struct cx18 *cx, u16 addr, u8 value)
  27. {
  28. u32 reg = 0xc40000 + (addr & ~3);
  29. u32 mask = 0xff;
  30. int shift = (addr & 3) * 8;
  31. u32 x = cx18_read_reg(cx, reg);
  32. x = (x & ~(mask << shift)) | ((u32)value << shift);
  33. cx18_write_reg(cx, x, reg);
  34. return 0;
  35. }
  36. int cx18_av_write_expect(struct cx18 *cx, u16 addr, u8 value, u8 eval, u8 mask)
  37. {
  38. u32 reg = 0xc40000 + (addr & ~3);
  39. int shift = (addr & 3) * 8;
  40. u32 x = cx18_read_reg(cx, reg);
  41. x = (x & ~((u32)0xff << shift)) | ((u32)value << shift);
  42. cx18_write_reg_expect(cx, x, reg,
  43. ((u32)eval << shift), ((u32)mask << shift));
  44. return 0;
  45. }
  46. int cx18_av_write4(struct cx18 *cx, u16 addr, u32 value)
  47. {
  48. cx18_write_reg(cx, value, 0xc40000 + addr);
  49. return 0;
  50. }
  51. int
  52. cx18_av_write4_expect(struct cx18 *cx, u16 addr, u32 value, u32 eval, u32 mask)
  53. {
  54. cx18_write_reg_expect(cx, value, 0xc40000 + addr, eval, mask);
  55. return 0;
  56. }
  57. int cx18_av_write4_noretry(struct cx18 *cx, u16 addr, u32 value)
  58. {
  59. cx18_write_reg_noretry(cx, value, 0xc40000 + addr);
  60. return 0;
  61. }
  62. u8 cx18_av_read(struct cx18 *cx, u16 addr)
  63. {
  64. u32 x = cx18_read_reg(cx, 0xc40000 + (addr & ~3));
  65. int shift = (addr & 3) * 8;
  66. return (x >> shift) & 0xff;
  67. }
  68. u32 cx18_av_read4(struct cx18 *cx, u16 addr)
  69. {
  70. return cx18_read_reg(cx, 0xc40000 + addr);
  71. }
  72. int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned and_mask,
  73. u8 or_value)
  74. {
  75. return cx18_av_write(cx, addr,
  76. (cx18_av_read(cx, addr) & and_mask) |
  77. or_value);
  78. }
  79. int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 and_mask,
  80. u32 or_value)
  81. {
  82. return cx18_av_write4(cx, addr,
  83. (cx18_av_read4(cx, addr) & and_mask) |
  84. or_value);
  85. }
  86. /* ----------------------------------------------------------------------- */
  87. static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input,
  88. enum cx18_av_audio_input aud_input);
  89. static void log_audio_status(struct cx18 *cx);
  90. static void log_video_status(struct cx18 *cx);
  91. /* ----------------------------------------------------------------------- */
  92. static void cx18_av_initialize(struct cx18 *cx)
  93. {
  94. struct cx18_av_state *state = &cx->av_state;
  95. u32 v;
  96. cx18_av_loadfw(cx);
  97. /* Stop 8051 code execution */
  98. cx18_av_write4_expect(cx, CXADEC_DL_CTL, 0x03000000,
  99. 0x03000000, 0x13000000);
  100. /* initallize the PLL by toggling sleep bit */
  101. v = cx18_av_read4(cx, CXADEC_HOST_REG1);
  102. /* enable sleep mode - register appears to be read only... */
  103. cx18_av_write4_expect(cx, CXADEC_HOST_REG1, v | 1, v, 0xfffe);
  104. /* disable sleep mode */
  105. cx18_av_write4_expect(cx, CXADEC_HOST_REG1, v & 0xfffe,
  106. v & 0xfffe, 0xffff);
  107. /* initialize DLLs */
  108. v = cx18_av_read4(cx, CXADEC_DLL1_DIAG_CTRL) & 0xE1FFFEFF;
  109. /* disable FLD */
  110. cx18_av_write4(cx, CXADEC_DLL1_DIAG_CTRL, v);
  111. /* enable FLD */
  112. cx18_av_write4(cx, CXADEC_DLL1_DIAG_CTRL, v | 0x10000100);
  113. v = cx18_av_read4(cx, CXADEC_DLL2_DIAG_CTRL) & 0xE1FFFEFF;
  114. /* disable FLD */
  115. cx18_av_write4(cx, CXADEC_DLL2_DIAG_CTRL, v);
  116. /* enable FLD */
  117. cx18_av_write4(cx, CXADEC_DLL2_DIAG_CTRL, v | 0x06000100);
  118. /* set analog bias currents. Set Vreg to 1.20V. */
  119. cx18_av_write4(cx, CXADEC_AFE_DIAG_CTRL1, 0x000A1802);
  120. v = cx18_av_read4(cx, CXADEC_AFE_DIAG_CTRL3) | 1;
  121. /* enable TUNE_FIL_RST */
  122. cx18_av_write4_expect(cx, CXADEC_AFE_DIAG_CTRL3, v, v, 0x03009F0F);
  123. /* disable TUNE_FIL_RST */
  124. cx18_av_write4_expect(cx, CXADEC_AFE_DIAG_CTRL3,
  125. v & 0xFFFFFFFE, v & 0xFFFFFFFE, 0x03009F0F);
  126. /* enable 656 output */
  127. cx18_av_and_or4(cx, CXADEC_PIN_CTRL1, ~0, 0x040C00);
  128. /* video output drive strength */
  129. cx18_av_and_or4(cx, CXADEC_PIN_CTRL2, ~0, 0x2);
  130. /* reset video */
  131. cx18_av_write4(cx, CXADEC_SOFT_RST_CTRL, 0x8000);
  132. cx18_av_write4(cx, CXADEC_SOFT_RST_CTRL, 0);
  133. /* set video to auto-detect */
  134. /* Clear bits 11-12 to enable slow locking mode. Set autodetect mode */
  135. /* set the comb notch = 1 */
  136. cx18_av_and_or4(cx, CXADEC_MODE_CTRL, 0xFFF7E7F0, 0x02040800);
  137. /* Enable wtw_en in CRUSH_CTRL (Set bit 22) */
  138. /* Enable maj_sel in CRUSH_CTRL (Set bit 20) */
  139. cx18_av_and_or4(cx, CXADEC_CRUSH_CTRL, ~0, 0x00500000);
  140. /* Set VGA_TRACK_RANGE to 0x20 */
  141. cx18_av_and_or4(cx, CXADEC_DFE_CTRL2, 0xFFFF00FF, 0x00002000);
  142. /* Enable VBI capture */
  143. cx18_av_write4(cx, CXADEC_OUT_CTRL1, 0x4010253F);
  144. /* cx18_av_write4(cx, CXADEC_OUT_CTRL1, 0x4010253E); */
  145. /* Set the video input.
  146. The setting in MODE_CTRL gets lost when we do the above setup */
  147. /* EncSetSignalStd(dwDevNum, pEnc->dwSigStd); */
  148. /* EncSetVideoInput(dwDevNum, pEnc->VidIndSelection); */
  149. v = cx18_av_read4(cx, CXADEC_AFE_CTRL);
  150. v &= 0xFFFBFFFF; /* turn OFF bit 18 for droop_comp_ch1 */
  151. v &= 0xFFFF7FFF; /* turn OFF bit 9 for clamp_sel_ch1 */
  152. v &= 0xFFFFFFFE; /* turn OFF bit 0 for 12db_ch1 */
  153. /* v |= 0x00000001;*/ /* turn ON bit 0 for 12db_ch1 */
  154. cx18_av_write4(cx, CXADEC_AFE_CTRL, v);
  155. /* if(dwEnable && dw3DCombAvailable) { */
  156. /* CxDevWrReg(CXADEC_SRC_COMB_CFG, 0x7728021F); */
  157. /* } else { */
  158. /* CxDevWrReg(CXADEC_SRC_COMB_CFG, 0x6628021F); */
  159. /* } */
  160. cx18_av_write4(cx, CXADEC_SRC_COMB_CFG, 0x6628021F);
  161. state->default_volume = 228 - cx18_av_read(cx, 0x8d4);
  162. state->default_volume = ((state->default_volume / 2) + 23) << 9;
  163. }
  164. /* ----------------------------------------------------------------------- */
  165. void cx18_av_std_setup(struct cx18 *cx)
  166. {
  167. struct cx18_av_state *state = &cx->av_state;
  168. v4l2_std_id std = state->std;
  169. int hblank, hactive, burst, vblank, vactive, sc;
  170. int vblank656, src_decimation;
  171. int luma_lpf, uv_lpf, comb;
  172. u32 pll_int, pll_frac, pll_post;
  173. /* datasheet startup, step 8d */
  174. if (std & ~V4L2_STD_NTSC)
  175. cx18_av_write(cx, 0x49f, 0x11);
  176. else
  177. cx18_av_write(cx, 0x49f, 0x14);
  178. if (std & V4L2_STD_625_50) {
  179. hblank = 132;
  180. hactive = 720;
  181. burst = 93;
  182. vblank = 36;
  183. vactive = 580;
  184. vblank656 = 40;
  185. src_decimation = 0x21f;
  186. luma_lpf = 2;
  187. if (std & V4L2_STD_PAL) {
  188. uv_lpf = 1;
  189. comb = 0x20;
  190. sc = 688739;
  191. } else if (std == V4L2_STD_PAL_Nc) {
  192. uv_lpf = 1;
  193. comb = 0x20;
  194. sc = 556453;
  195. } else { /* SECAM */
  196. uv_lpf = 0;
  197. comb = 0;
  198. sc = 672351;
  199. }
  200. } else {
  201. hactive = 720;
  202. hblank = 122;
  203. vactive = 487;
  204. luma_lpf = 1;
  205. uv_lpf = 1;
  206. vblank = 26;
  207. vblank656 = 26;
  208. src_decimation = 0x21f;
  209. if (std == V4L2_STD_PAL_60) {
  210. burst = 0x5b;
  211. luma_lpf = 2;
  212. comb = 0x20;
  213. sc = 688739;
  214. } else if (std == V4L2_STD_PAL_M) {
  215. burst = 0x61;
  216. comb = 0x20;
  217. sc = 555452;
  218. } else {
  219. burst = 0x5b;
  220. comb = 0x66;
  221. sc = 556063;
  222. }
  223. }
  224. /* DEBUG: Displays configured PLL frequency */
  225. pll_int = cx18_av_read(cx, 0x108);
  226. pll_frac = cx18_av_read4(cx, 0x10c) & 0x1ffffff;
  227. pll_post = cx18_av_read(cx, 0x109);
  228. CX18_DEBUG_INFO("PLL regs = int: %u, frac: %u, post: %u\n",
  229. pll_int, pll_frac, pll_post);
  230. if (pll_post) {
  231. int fin, fsc, pll;
  232. pll = (28636360L * ((((u64)pll_int) << 25) + pll_frac)) >> 25;
  233. pll /= pll_post;
  234. CX18_DEBUG_INFO("PLL = %d.%06d MHz\n",
  235. pll / 1000000, pll % 1000000);
  236. CX18_DEBUG_INFO("PLL/8 = %d.%06d MHz\n",
  237. pll / 8000000, (pll / 8) % 1000000);
  238. fin = ((u64)src_decimation * pll) >> 12;
  239. CX18_DEBUG_INFO("ADC Sampling freq = %d.%06d MHz\n",
  240. fin / 1000000, fin % 1000000);
  241. fsc = (((u64)sc) * pll) >> 24L;
  242. CX18_DEBUG_INFO("Chroma sub-carrier freq = %d.%06d MHz\n",
  243. fsc / 1000000, fsc % 1000000);
  244. CX18_DEBUG_INFO("hblank %i, hactive %i, "
  245. "vblank %i , vactive %i, vblank656 %i, src_dec %i,"
  246. "burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x,"
  247. " sc 0x%06x\n",
  248. hblank, hactive, vblank, vactive, vblank656,
  249. src_decimation, burst, luma_lpf, uv_lpf, comb, sc);
  250. }
  251. /* Sets horizontal blanking delay and active lines */
  252. cx18_av_write(cx, 0x470, hblank);
  253. cx18_av_write(cx, 0x471, 0xff & (((hblank >> 8) & 0x3) |
  254. (hactive << 4)));
  255. cx18_av_write(cx, 0x472, hactive >> 4);
  256. /* Sets burst gate delay */
  257. cx18_av_write(cx, 0x473, burst);
  258. /* Sets vertical blanking delay and active duration */
  259. cx18_av_write(cx, 0x474, vblank);
  260. cx18_av_write(cx, 0x475, 0xff & (((vblank >> 8) & 0x3) |
  261. (vactive << 4)));
  262. cx18_av_write(cx, 0x476, vactive >> 4);
  263. cx18_av_write(cx, 0x477, vblank656);
  264. /* Sets src decimation rate */
  265. cx18_av_write(cx, 0x478, 0xff & src_decimation);
  266. cx18_av_write(cx, 0x479, 0xff & (src_decimation >> 8));
  267. /* Sets Luma and UV Low pass filters */
  268. cx18_av_write(cx, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30));
  269. /* Enables comb filters */
  270. cx18_av_write(cx, 0x47b, comb);
  271. /* Sets SC Step*/
  272. cx18_av_write(cx, 0x47c, sc);
  273. cx18_av_write(cx, 0x47d, 0xff & sc >> 8);
  274. cx18_av_write(cx, 0x47e, 0xff & sc >> 16);
  275. /* Sets VBI parameters */
  276. if (std & V4L2_STD_625_50) {
  277. cx18_av_write(cx, 0x47f, 0x01);
  278. state->vbi_line_offset = 5;
  279. } else {
  280. cx18_av_write(cx, 0x47f, 0x00);
  281. state->vbi_line_offset = 8;
  282. }
  283. }
  284. /* ----------------------------------------------------------------------- */
  285. static void input_change(struct cx18 *cx)
  286. {
  287. struct cx18_av_state *state = &cx->av_state;
  288. v4l2_std_id std = state->std;
  289. u8 v;
  290. /* Follow step 8c and 8d of section 3.16 in the cx18_av datasheet */
  291. cx18_av_write(cx, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11);
  292. cx18_av_and_or(cx, 0x401, ~0x60, 0);
  293. cx18_av_and_or(cx, 0x401, ~0x60, 0x60);
  294. if (std & V4L2_STD_525_60) {
  295. if (std == V4L2_STD_NTSC_M_JP) {
  296. /* Japan uses EIAJ audio standard */
  297. cx18_av_write_expect(cx, 0x808, 0xf7, 0xf7, 0xff);
  298. cx18_av_write_expect(cx, 0x80b, 0x02, 0x02, 0x3f);
  299. } else if (std == V4L2_STD_NTSC_M_KR) {
  300. /* South Korea uses A2 audio standard */
  301. cx18_av_write_expect(cx, 0x808, 0xf8, 0xf8, 0xff);
  302. cx18_av_write_expect(cx, 0x80b, 0x03, 0x03, 0x3f);
  303. } else {
  304. /* Others use the BTSC audio standard */
  305. cx18_av_write_expect(cx, 0x808, 0xf6, 0xf6, 0xff);
  306. cx18_av_write_expect(cx, 0x80b, 0x01, 0x01, 0x3f);
  307. }
  308. } else if (std & V4L2_STD_PAL) {
  309. /* Follow tuner change procedure for PAL */
  310. cx18_av_write_expect(cx, 0x808, 0xff, 0xff, 0xff);
  311. cx18_av_write_expect(cx, 0x80b, 0x03, 0x03, 0x3f);
  312. } else if (std & V4L2_STD_SECAM) {
  313. /* Select autodetect for SECAM */
  314. cx18_av_write_expect(cx, 0x808, 0xff, 0xff, 0xff);
  315. cx18_av_write_expect(cx, 0x80b, 0x03, 0x03, 0x3f);
  316. }
  317. v = cx18_av_read(cx, 0x803);
  318. if (v & 0x10) {
  319. /* restart audio decoder microcontroller */
  320. v &= ~0x10;
  321. cx18_av_write_expect(cx, 0x803, v, v, 0x1f);
  322. v |= 0x10;
  323. cx18_av_write_expect(cx, 0x803, v, v, 0x1f);
  324. }
  325. }
  326. static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input,
  327. enum cx18_av_audio_input aud_input)
  328. {
  329. struct cx18_av_state *state = &cx->av_state;
  330. u8 is_composite = (vid_input >= CX18_AV_COMPOSITE1 &&
  331. vid_input <= CX18_AV_COMPOSITE8);
  332. u8 reg;
  333. u8 v;
  334. CX18_DEBUG_INFO("decoder set video input %d, audio input %d\n",
  335. vid_input, aud_input);
  336. if (is_composite) {
  337. reg = 0xf0 + (vid_input - CX18_AV_COMPOSITE1);
  338. } else {
  339. int luma = vid_input & 0xf0;
  340. int chroma = vid_input & 0xf00;
  341. if ((vid_input & ~0xff0) ||
  342. luma < CX18_AV_SVIDEO_LUMA1 ||
  343. luma > CX18_AV_SVIDEO_LUMA8 ||
  344. chroma < CX18_AV_SVIDEO_CHROMA4 ||
  345. chroma > CX18_AV_SVIDEO_CHROMA8) {
  346. CX18_ERR("0x%04x is not a valid video input!\n",
  347. vid_input);
  348. return -EINVAL;
  349. }
  350. reg = 0xf0 + ((luma - CX18_AV_SVIDEO_LUMA1) >> 4);
  351. if (chroma >= CX18_AV_SVIDEO_CHROMA7) {
  352. reg &= 0x3f;
  353. reg |= (chroma - CX18_AV_SVIDEO_CHROMA7) >> 2;
  354. } else {
  355. reg &= 0xcf;
  356. reg |= (chroma - CX18_AV_SVIDEO_CHROMA4) >> 4;
  357. }
  358. }
  359. switch (aud_input) {
  360. case CX18_AV_AUDIO_SERIAL1:
  361. case CX18_AV_AUDIO_SERIAL2:
  362. /* do nothing, use serial audio input */
  363. break;
  364. case CX18_AV_AUDIO4: reg &= ~0x30; break;
  365. case CX18_AV_AUDIO5: reg &= ~0x30; reg |= 0x10; break;
  366. case CX18_AV_AUDIO6: reg &= ~0x30; reg |= 0x20; break;
  367. case CX18_AV_AUDIO7: reg &= ~0xc0; break;
  368. case CX18_AV_AUDIO8: reg &= ~0xc0; reg |= 0x40; break;
  369. default:
  370. CX18_ERR("0x%04x is not a valid audio input!\n", aud_input);
  371. return -EINVAL;
  372. }
  373. cx18_av_write_expect(cx, 0x103, reg, reg, 0xf7);
  374. /* Set INPUT_MODE to Composite (0) or S-Video (1) */
  375. cx18_av_and_or(cx, 0x401, ~0x6, is_composite ? 0 : 0x02);
  376. /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */
  377. v = cx18_av_read(cx, 0x102);
  378. if (reg & 0x80)
  379. v &= ~0x2;
  380. else
  381. v |= 0x2;
  382. /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */
  383. if ((reg & 0xc0) != 0xc0 && (reg & 0x30) != 0x30)
  384. v |= 0x4;
  385. else
  386. v &= ~0x4;
  387. cx18_av_write_expect(cx, 0x102, v, v, 0x17);
  388. /*cx18_av_and_or4(cx, 0x104, ~0x001b4180, 0x00004180);*/
  389. state->vid_input = vid_input;
  390. state->aud_input = aud_input;
  391. cx18_av_audio_set_path(cx);
  392. input_change(cx);
  393. return 0;
  394. }
  395. /* ----------------------------------------------------------------------- */
  396. static int set_v4lstd(struct cx18 *cx)
  397. {
  398. struct cx18_av_state *state = &cx->av_state;
  399. u8 fmt = 0; /* zero is autodetect */
  400. u8 pal_m = 0;
  401. /* First tests should be against specific std */
  402. if (state->std == V4L2_STD_NTSC_M_JP) {
  403. fmt = 0x2;
  404. } else if (state->std == V4L2_STD_NTSC_443) {
  405. fmt = 0x3;
  406. } else if (state->std == V4L2_STD_PAL_M) {
  407. pal_m = 1;
  408. fmt = 0x5;
  409. } else if (state->std == V4L2_STD_PAL_N) {
  410. fmt = 0x6;
  411. } else if (state->std == V4L2_STD_PAL_Nc) {
  412. fmt = 0x7;
  413. } else if (state->std == V4L2_STD_PAL_60) {
  414. fmt = 0x8;
  415. } else {
  416. /* Then, test against generic ones */
  417. if (state->std & V4L2_STD_NTSC)
  418. fmt = 0x1;
  419. else if (state->std & V4L2_STD_PAL)
  420. fmt = 0x4;
  421. else if (state->std & V4L2_STD_SECAM)
  422. fmt = 0xc;
  423. }
  424. CX18_DEBUG_INFO("changing video std to fmt %i\n", fmt);
  425. /* Follow step 9 of section 3.16 in the cx18_av datasheet.
  426. Without this PAL may display a vertical ghosting effect.
  427. This happens for example with the Yuan MPC622. */
  428. if (fmt >= 4 && fmt < 8) {
  429. /* Set format to NTSC-M */
  430. cx18_av_and_or(cx, 0x400, ~0xf, 1);
  431. /* Turn off LCOMB */
  432. cx18_av_and_or(cx, 0x47b, ~6, 0);
  433. }
  434. cx18_av_and_or(cx, 0x400, ~0x2f, fmt | 0x20);
  435. cx18_av_and_or(cx, 0x403, ~0x3, pal_m);
  436. cx18_av_std_setup(cx);
  437. input_change(cx);
  438. return 0;
  439. }
  440. /* ----------------------------------------------------------------------- */
  441. static int set_v4lctrl(struct cx18 *cx, struct v4l2_control *ctrl)
  442. {
  443. switch (ctrl->id) {
  444. case V4L2_CID_BRIGHTNESS:
  445. if (ctrl->value < 0 || ctrl->value > 255) {
  446. CX18_ERR("invalid brightness setting %d\n",
  447. ctrl->value);
  448. return -ERANGE;
  449. }
  450. cx18_av_write(cx, 0x414, ctrl->value - 128);
  451. break;
  452. case V4L2_CID_CONTRAST:
  453. if (ctrl->value < 0 || ctrl->value > 127) {
  454. CX18_ERR("invalid contrast setting %d\n",
  455. ctrl->value);
  456. return -ERANGE;
  457. }
  458. cx18_av_write(cx, 0x415, ctrl->value << 1);
  459. break;
  460. case V4L2_CID_SATURATION:
  461. if (ctrl->value < 0 || ctrl->value > 127) {
  462. CX18_ERR("invalid saturation setting %d\n",
  463. ctrl->value);
  464. return -ERANGE;
  465. }
  466. cx18_av_write(cx, 0x420, ctrl->value << 1);
  467. cx18_av_write(cx, 0x421, ctrl->value << 1);
  468. break;
  469. case V4L2_CID_HUE:
  470. if (ctrl->value < -128 || ctrl->value > 127) {
  471. CX18_ERR("invalid hue setting %d\n", ctrl->value);
  472. return -ERANGE;
  473. }
  474. cx18_av_write(cx, 0x422, ctrl->value);
  475. break;
  476. case V4L2_CID_AUDIO_VOLUME:
  477. case V4L2_CID_AUDIO_BASS:
  478. case V4L2_CID_AUDIO_TREBLE:
  479. case V4L2_CID_AUDIO_BALANCE:
  480. case V4L2_CID_AUDIO_MUTE:
  481. return cx18_av_audio(cx, VIDIOC_S_CTRL, ctrl);
  482. default:
  483. return -EINVAL;
  484. }
  485. return 0;
  486. }
  487. static int get_v4lctrl(struct cx18 *cx, struct v4l2_control *ctrl)
  488. {
  489. switch (ctrl->id) {
  490. case V4L2_CID_BRIGHTNESS:
  491. ctrl->value = (s8)cx18_av_read(cx, 0x414) + 128;
  492. break;
  493. case V4L2_CID_CONTRAST:
  494. ctrl->value = cx18_av_read(cx, 0x415) >> 1;
  495. break;
  496. case V4L2_CID_SATURATION:
  497. ctrl->value = cx18_av_read(cx, 0x420) >> 1;
  498. break;
  499. case V4L2_CID_HUE:
  500. ctrl->value = (s8)cx18_av_read(cx, 0x422);
  501. break;
  502. case V4L2_CID_AUDIO_VOLUME:
  503. case V4L2_CID_AUDIO_BASS:
  504. case V4L2_CID_AUDIO_TREBLE:
  505. case V4L2_CID_AUDIO_BALANCE:
  506. case V4L2_CID_AUDIO_MUTE:
  507. return cx18_av_audio(cx, VIDIOC_G_CTRL, ctrl);
  508. default:
  509. return -EINVAL;
  510. }
  511. return 0;
  512. }
  513. /* ----------------------------------------------------------------------- */
  514. static int get_v4lfmt(struct cx18 *cx, struct v4l2_format *fmt)
  515. {
  516. switch (fmt->type) {
  517. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  518. return cx18_av_vbi(cx, VIDIOC_G_FMT, fmt);
  519. default:
  520. return -EINVAL;
  521. }
  522. return 0;
  523. }
  524. static int set_v4lfmt(struct cx18 *cx, struct v4l2_format *fmt)
  525. {
  526. struct cx18_av_state *state = &cx->av_state;
  527. struct v4l2_pix_format *pix;
  528. int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
  529. int is_50Hz = !(state->std & V4L2_STD_525_60);
  530. switch (fmt->type) {
  531. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  532. pix = &(fmt->fmt.pix);
  533. Vsrc = (cx18_av_read(cx, 0x476) & 0x3f) << 4;
  534. Vsrc |= (cx18_av_read(cx, 0x475) & 0xf0) >> 4;
  535. Hsrc = (cx18_av_read(cx, 0x472) & 0x3f) << 4;
  536. Hsrc |= (cx18_av_read(cx, 0x471) & 0xf0) >> 4;
  537. Vlines = pix->height + (is_50Hz ? 4 : 7);
  538. if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) ||
  539. (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) {
  540. CX18_ERR("%dx%d is not a valid size!\n",
  541. pix->width, pix->height);
  542. return -ERANGE;
  543. }
  544. HSC = (Hsrc * (1 << 20)) / pix->width - (1 << 20);
  545. VSC = (1 << 16) - (Vsrc * (1 << 9) / Vlines - (1 << 9));
  546. VSC &= 0x1fff;
  547. if (pix->width >= 385)
  548. filter = 0;
  549. else if (pix->width > 192)
  550. filter = 1;
  551. else if (pix->width > 96)
  552. filter = 2;
  553. else
  554. filter = 3;
  555. CX18_DEBUG_INFO("decoder set size %dx%d -> scale %ux%u\n",
  556. pix->width, pix->height, HSC, VSC);
  557. /* HSCALE=HSC */
  558. cx18_av_write(cx, 0x418, HSC & 0xff);
  559. cx18_av_write(cx, 0x419, (HSC >> 8) & 0xff);
  560. cx18_av_write(cx, 0x41a, HSC >> 16);
  561. /* VSCALE=VSC */
  562. cx18_av_write(cx, 0x41c, VSC & 0xff);
  563. cx18_av_write(cx, 0x41d, VSC >> 8);
  564. /* VS_INTRLACE=1 VFILT=filter */
  565. cx18_av_write(cx, 0x41e, 0x8 | filter);
  566. break;
  567. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  568. return cx18_av_vbi(cx, VIDIOC_S_FMT, fmt);
  569. case V4L2_BUF_TYPE_VBI_CAPTURE:
  570. return cx18_av_vbi(cx, VIDIOC_S_FMT, fmt);
  571. default:
  572. return -EINVAL;
  573. }
  574. return 0;
  575. }
  576. /* ----------------------------------------------------------------------- */
  577. static int valid_av_cmd(unsigned int cmd)
  578. {
  579. switch (cmd) {
  580. /* All commands supported by cx18_av_cmd() */
  581. case VIDIOC_INT_DECODE_VBI_LINE:
  582. case VIDIOC_INT_AUDIO_CLOCK_FREQ:
  583. case VIDIOC_STREAMON:
  584. case VIDIOC_STREAMOFF:
  585. case VIDIOC_LOG_STATUS:
  586. case VIDIOC_G_CTRL:
  587. case VIDIOC_S_CTRL:
  588. case VIDIOC_QUERYCTRL:
  589. case VIDIOC_G_STD:
  590. case VIDIOC_S_STD:
  591. case AUDC_SET_RADIO:
  592. case VIDIOC_INT_G_VIDEO_ROUTING:
  593. case VIDIOC_INT_S_VIDEO_ROUTING:
  594. case VIDIOC_INT_G_AUDIO_ROUTING:
  595. case VIDIOC_INT_S_AUDIO_ROUTING:
  596. case VIDIOC_S_FREQUENCY:
  597. case VIDIOC_G_TUNER:
  598. case VIDIOC_S_TUNER:
  599. case VIDIOC_G_FMT:
  600. case VIDIOC_S_FMT:
  601. case VIDIOC_INT_RESET:
  602. return 1;
  603. default:
  604. return 0;
  605. }
  606. return 0;
  607. }
  608. int cx18_av_cmd(struct cx18 *cx, unsigned int cmd, void *arg)
  609. {
  610. struct cx18_av_state *state = &cx->av_state;
  611. struct v4l2_tuner *vt = arg;
  612. struct v4l2_routing *route = arg;
  613. if (!state->is_initialized && valid_av_cmd(cmd)) {
  614. CX18_DEBUG_INFO("cmd %08x triggered fw load\n", cmd);
  615. /* initialize on first use */
  616. state->is_initialized = 1;
  617. cx18_av_initialize(cx);
  618. }
  619. switch (cmd) {
  620. case VIDIOC_INT_DECODE_VBI_LINE:
  621. return cx18_av_vbi(cx, cmd, arg);
  622. case VIDIOC_INT_AUDIO_CLOCK_FREQ:
  623. return cx18_av_audio(cx, cmd, arg);
  624. case VIDIOC_STREAMON:
  625. CX18_DEBUG_INFO("enable output\n");
  626. cx18_av_write(cx, 0x115, 0x8c);
  627. cx18_av_write(cx, 0x116, 0x07);
  628. break;
  629. case VIDIOC_STREAMOFF:
  630. CX18_DEBUG_INFO("disable output\n");
  631. cx18_av_write(cx, 0x115, 0x00);
  632. cx18_av_write(cx, 0x116, 0x00);
  633. break;
  634. case VIDIOC_LOG_STATUS:
  635. log_video_status(cx);
  636. log_audio_status(cx);
  637. break;
  638. case VIDIOC_G_CTRL:
  639. return get_v4lctrl(cx, (struct v4l2_control *)arg);
  640. case VIDIOC_S_CTRL:
  641. return set_v4lctrl(cx, (struct v4l2_control *)arg);
  642. case VIDIOC_QUERYCTRL:
  643. {
  644. struct v4l2_queryctrl *qc = arg;
  645. switch (qc->id) {
  646. case V4L2_CID_BRIGHTNESS:
  647. case V4L2_CID_CONTRAST:
  648. case V4L2_CID_SATURATION:
  649. case V4L2_CID_HUE:
  650. return v4l2_ctrl_query_fill_std(qc);
  651. default:
  652. break;
  653. }
  654. switch (qc->id) {
  655. case V4L2_CID_AUDIO_VOLUME:
  656. return v4l2_ctrl_query_fill(qc, 0, 65535,
  657. 65535 / 100, state->default_volume);
  658. case V4L2_CID_AUDIO_MUTE:
  659. case V4L2_CID_AUDIO_BALANCE:
  660. case V4L2_CID_AUDIO_BASS:
  661. case V4L2_CID_AUDIO_TREBLE:
  662. return v4l2_ctrl_query_fill_std(qc);
  663. default:
  664. return -EINVAL;
  665. }
  666. return -EINVAL;
  667. }
  668. case VIDIOC_G_STD:
  669. *(v4l2_std_id *)arg = state->std;
  670. break;
  671. case VIDIOC_S_STD:
  672. if (state->radio == 0 && state->std == *(v4l2_std_id *)arg)
  673. return 0;
  674. state->radio = 0;
  675. state->std = *(v4l2_std_id *)arg;
  676. return set_v4lstd(cx);
  677. case AUDC_SET_RADIO:
  678. state->radio = 1;
  679. break;
  680. case VIDIOC_INT_G_VIDEO_ROUTING:
  681. route->input = state->vid_input;
  682. route->output = 0;
  683. break;
  684. case VIDIOC_INT_S_VIDEO_ROUTING:
  685. return set_input(cx, route->input, state->aud_input);
  686. case VIDIOC_INT_G_AUDIO_ROUTING:
  687. route->input = state->aud_input;
  688. route->output = 0;
  689. break;
  690. case VIDIOC_INT_S_AUDIO_ROUTING:
  691. return set_input(cx, state->vid_input, route->input);
  692. case VIDIOC_S_FREQUENCY:
  693. input_change(cx);
  694. break;
  695. case VIDIOC_G_TUNER:
  696. {
  697. u8 vpres = cx18_av_read(cx, 0x40e) & 0x20;
  698. u8 mode;
  699. int val = 0;
  700. if (state->radio)
  701. break;
  702. vt->signal = vpres ? 0xffff : 0x0;
  703. vt->capability |=
  704. V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 |
  705. V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
  706. mode = cx18_av_read(cx, 0x804);
  707. /* get rxsubchans and audmode */
  708. if ((mode & 0xf) == 1)
  709. val |= V4L2_TUNER_SUB_STEREO;
  710. else
  711. val |= V4L2_TUNER_SUB_MONO;
  712. if (mode == 2 || mode == 4)
  713. val = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
  714. if (mode & 0x10)
  715. val |= V4L2_TUNER_SUB_SAP;
  716. vt->rxsubchans = val;
  717. vt->audmode = state->audmode;
  718. break;
  719. }
  720. case VIDIOC_S_TUNER:
  721. {
  722. u8 v;
  723. if (state->radio)
  724. break;
  725. v = cx18_av_read(cx, 0x809);
  726. v &= ~0xf;
  727. switch (vt->audmode) {
  728. case V4L2_TUNER_MODE_MONO:
  729. /* mono -> mono
  730. stereo -> mono
  731. bilingual -> lang1 */
  732. break;
  733. case V4L2_TUNER_MODE_STEREO:
  734. case V4L2_TUNER_MODE_LANG1:
  735. /* mono -> mono
  736. stereo -> stereo
  737. bilingual -> lang1 */
  738. v |= 0x4;
  739. break;
  740. case V4L2_TUNER_MODE_LANG1_LANG2:
  741. /* mono -> mono
  742. stereo -> stereo
  743. bilingual -> lang1/lang2 */
  744. v |= 0x7;
  745. break;
  746. case V4L2_TUNER_MODE_LANG2:
  747. /* mono -> mono
  748. stereo -> stereo
  749. bilingual -> lang2 */
  750. v |= 0x1;
  751. break;
  752. default:
  753. return -EINVAL;
  754. }
  755. cx18_av_write_expect(cx, 0x809, v, v, 0xff);
  756. state->audmode = vt->audmode;
  757. break;
  758. }
  759. case VIDIOC_G_FMT:
  760. return get_v4lfmt(cx, (struct v4l2_format *)arg);
  761. case VIDIOC_S_FMT:
  762. return set_v4lfmt(cx, (struct v4l2_format *)arg);
  763. case VIDIOC_INT_RESET:
  764. cx18_av_initialize(cx);
  765. break;
  766. default:
  767. return -EINVAL;
  768. }
  769. return 0;
  770. }
  771. /* ----------------------------------------------------------------------- */
  772. /* ----------------------------------------------------------------------- */
  773. static void log_video_status(struct cx18 *cx)
  774. {
  775. static const char *const fmt_strs[] = {
  776. "0x0",
  777. "NTSC-M", "NTSC-J", "NTSC-4.43",
  778. "PAL-BDGHI", "PAL-M", "PAL-N", "PAL-Nc", "PAL-60",
  779. "0x9", "0xA", "0xB",
  780. "SECAM",
  781. "0xD", "0xE", "0xF"
  782. };
  783. struct cx18_av_state *state = &cx->av_state;
  784. u8 vidfmt_sel = cx18_av_read(cx, 0x400) & 0xf;
  785. u8 gen_stat1 = cx18_av_read(cx, 0x40d);
  786. u8 gen_stat2 = cx18_av_read(cx, 0x40e);
  787. int vid_input = state->vid_input;
  788. CX18_INFO("Video signal: %spresent\n",
  789. (gen_stat2 & 0x20) ? "" : "not ");
  790. CX18_INFO("Detected format: %s\n",
  791. fmt_strs[gen_stat1 & 0xf]);
  792. CX18_INFO("Specified standard: %s\n",
  793. vidfmt_sel ? fmt_strs[vidfmt_sel] : "automatic detection");
  794. if (vid_input >= CX18_AV_COMPOSITE1 &&
  795. vid_input <= CX18_AV_COMPOSITE8) {
  796. CX18_INFO("Specified video input: Composite %d\n",
  797. vid_input - CX18_AV_COMPOSITE1 + 1);
  798. } else {
  799. CX18_INFO("Specified video input: S-Video (Luma In%d, Chroma In%d)\n",
  800. (vid_input & 0xf0) >> 4, (vid_input & 0xf00) >> 8);
  801. }
  802. CX18_INFO("Specified audioclock freq: %d Hz\n", state->audclk_freq);
  803. }
  804. /* ----------------------------------------------------------------------- */
  805. static void log_audio_status(struct cx18 *cx)
  806. {
  807. struct cx18_av_state *state = &cx->av_state;
  808. u8 download_ctl = cx18_av_read(cx, 0x803);
  809. u8 mod_det_stat0 = cx18_av_read(cx, 0x804);
  810. u8 mod_det_stat1 = cx18_av_read(cx, 0x805);
  811. u8 audio_config = cx18_av_read(cx, 0x808);
  812. u8 pref_mode = cx18_av_read(cx, 0x809);
  813. u8 afc0 = cx18_av_read(cx, 0x80b);
  814. u8 mute_ctl = cx18_av_read(cx, 0x8d3);
  815. int aud_input = state->aud_input;
  816. char *p;
  817. switch (mod_det_stat0) {
  818. case 0x00: p = "mono"; break;
  819. case 0x01: p = "stereo"; break;
  820. case 0x02: p = "dual"; break;
  821. case 0x04: p = "tri"; break;
  822. case 0x10: p = "mono with SAP"; break;
  823. case 0x11: p = "stereo with SAP"; break;
  824. case 0x12: p = "dual with SAP"; break;
  825. case 0x14: p = "tri with SAP"; break;
  826. case 0xfe: p = "forced mode"; break;
  827. default: p = "not defined"; break;
  828. }
  829. CX18_INFO("Detected audio mode: %s\n", p);
  830. switch (mod_det_stat1) {
  831. case 0x00: p = "not defined"; break;
  832. case 0x01: p = "EIAJ"; break;
  833. case 0x02: p = "A2-M"; break;
  834. case 0x03: p = "A2-BG"; break;
  835. case 0x04: p = "A2-DK1"; break;
  836. case 0x05: p = "A2-DK2"; break;
  837. case 0x06: p = "A2-DK3"; break;
  838. case 0x07: p = "A1 (6.0 MHz FM Mono)"; break;
  839. case 0x08: p = "AM-L"; break;
  840. case 0x09: p = "NICAM-BG"; break;
  841. case 0x0a: p = "NICAM-DK"; break;
  842. case 0x0b: p = "NICAM-I"; break;
  843. case 0x0c: p = "NICAM-L"; break;
  844. case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break;
  845. case 0x0e: p = "IF FM Radio"; break;
  846. case 0x0f: p = "BTSC"; break;
  847. case 0x10: p = "detected chrominance"; break;
  848. case 0xfd: p = "unknown audio standard"; break;
  849. case 0xfe: p = "forced audio standard"; break;
  850. case 0xff: p = "no detected audio standard"; break;
  851. default: p = "not defined"; break;
  852. }
  853. CX18_INFO("Detected audio standard: %s\n", p);
  854. CX18_INFO("Audio muted: %s\n",
  855. (mute_ctl & 0x2) ? "yes" : "no");
  856. CX18_INFO("Audio microcontroller: %s\n",
  857. (download_ctl & 0x10) ? "running" : "stopped");
  858. switch (audio_config >> 4) {
  859. case 0x00: p = "undefined"; break;
  860. case 0x01: p = "BTSC"; break;
  861. case 0x02: p = "EIAJ"; break;
  862. case 0x03: p = "A2-M"; break;
  863. case 0x04: p = "A2-BG"; break;
  864. case 0x05: p = "A2-DK1"; break;
  865. case 0x06: p = "A2-DK2"; break;
  866. case 0x07: p = "A2-DK3"; break;
  867. case 0x08: p = "A1 (6.0 MHz FM Mono)"; break;
  868. case 0x09: p = "AM-L"; break;
  869. case 0x0a: p = "NICAM-BG"; break;
  870. case 0x0b: p = "NICAM-DK"; break;
  871. case 0x0c: p = "NICAM-I"; break;
  872. case 0x0d: p = "NICAM-L"; break;
  873. case 0x0e: p = "FM radio"; break;
  874. case 0x0f: p = "automatic detection"; break;
  875. default: p = "undefined"; break;
  876. }
  877. CX18_INFO("Configured audio standard: %s\n", p);
  878. if ((audio_config >> 4) < 0xF) {
  879. switch (audio_config & 0xF) {
  880. case 0x00: p = "MONO1 (LANGUAGE A/Mono L+R channel for BTSC, EIAJ, A2)"; break;
  881. case 0x01: p = "MONO2 (LANGUAGE B)"; break;
  882. case 0x02: p = "MONO3 (STEREO forced MONO)"; break;
  883. case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break;
  884. case 0x04: p = "STEREO"; break;
  885. case 0x05: p = "DUAL1 (AC)"; break;
  886. case 0x06: p = "DUAL2 (BC)"; break;
  887. case 0x07: p = "DUAL3 (AB)"; break;
  888. default: p = "undefined";
  889. }
  890. CX18_INFO("Configured audio mode: %s\n", p);
  891. } else {
  892. switch (audio_config & 0xF) {
  893. case 0x00: p = "BG"; break;
  894. case 0x01: p = "DK1"; break;
  895. case 0x02: p = "DK2"; break;
  896. case 0x03: p = "DK3"; break;
  897. case 0x04: p = "I"; break;
  898. case 0x05: p = "L"; break;
  899. case 0x06: p = "BTSC"; break;
  900. case 0x07: p = "EIAJ"; break;
  901. case 0x08: p = "A2-M"; break;
  902. case 0x09: p = "FM Radio (4.5 MHz)"; break;
  903. case 0x0a: p = "FM Radio (5.5 MHz)"; break;
  904. case 0x0b: p = "S-Video"; break;
  905. case 0x0f: p = "automatic standard and mode detection"; break;
  906. default: p = "undefined"; break;
  907. }
  908. CX18_INFO("Configured audio system: %s\n", p);
  909. }
  910. if (aud_input)
  911. CX18_INFO("Specified audio input: Tuner (In%d)\n",
  912. aud_input);
  913. else
  914. CX18_INFO("Specified audio input: External\n");
  915. switch (pref_mode & 0xf) {
  916. case 0: p = "mono/language A"; break;
  917. case 1: p = "language B"; break;
  918. case 2: p = "language C"; break;
  919. case 3: p = "analog fallback"; break;
  920. case 4: p = "stereo"; break;
  921. case 5: p = "language AC"; break;
  922. case 6: p = "language BC"; break;
  923. case 7: p = "language AB"; break;
  924. default: p = "undefined"; break;
  925. }
  926. CX18_INFO("Preferred audio mode: %s\n", p);
  927. if ((audio_config & 0xf) == 0xf) {
  928. switch ((afc0 >> 3) & 0x1) {
  929. case 0: p = "system DK"; break;
  930. case 1: p = "system L"; break;
  931. }
  932. CX18_INFO("Selected 65 MHz format: %s\n", p);
  933. switch (afc0 & 0x7) {
  934. case 0: p = "Chroma"; break;
  935. case 1: p = "BTSC"; break;
  936. case 2: p = "EIAJ"; break;
  937. case 3: p = "A2-M"; break;
  938. case 4: p = "autodetect"; break;
  939. default: p = "undefined"; break;
  940. }
  941. CX18_INFO("Selected 45 MHz format: %s\n", p);
  942. }
  943. }