cx25840-core.c 31 KB

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