saa6752hs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/sched.h>
  4. #include <linux/string.h>
  5. #include <linux/timer.h>
  6. #include <linux/delay.h>
  7. #include <linux/errno.h>
  8. #include <linux/slab.h>
  9. #include <linux/poll.h>
  10. #include <linux/i2c.h>
  11. #include <linux/types.h>
  12. #include <linux/videodev2.h>
  13. #include <media/v4l2-common.h>
  14. #include <linux/init.h>
  15. #include <linux/crc32.h>
  16. #define MPEG_VIDEO_TARGET_BITRATE_MAX 27000
  17. #define MPEG_VIDEO_MAX_BITRATE_MAX 27000
  18. #define MPEG_TOTAL_TARGET_BITRATE_MAX 27000
  19. #define MPEG_PID_MAX ((1 << 14) - 1)
  20. /* Addresses to scan */
  21. static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END};
  22. I2C_CLIENT_INSMOD;
  23. MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder");
  24. MODULE_AUTHOR("Andrew de Quincey");
  25. MODULE_LICENSE("GPL");
  26. static struct i2c_driver driver;
  27. static struct i2c_client client_template;
  28. enum saa6752hs_videoformat {
  29. SAA6752HS_VF_D1 = 0, /* standard D1 video format: 720x576 */
  30. SAA6752HS_VF_2_3_D1 = 1,/* 2/3D1 video format: 480x576 */
  31. SAA6752HS_VF_1_2_D1 = 2,/* 1/2D1 video format: 352x576 */
  32. SAA6752HS_VF_SIF = 3, /* SIF video format: 352x288 */
  33. SAA6752HS_VF_UNKNOWN,
  34. };
  35. static const struct v4l2_format v4l2_format_table[] =
  36. {
  37. [SAA6752HS_VF_D1] =
  38. { .fmt = { .pix = { .width = 720, .height = 576 }}},
  39. [SAA6752HS_VF_2_3_D1] =
  40. { .fmt = { .pix = { .width = 480, .height = 576 }}},
  41. [SAA6752HS_VF_1_2_D1] =
  42. { .fmt = { .pix = { .width = 352, .height = 576 }}},
  43. [SAA6752HS_VF_SIF] =
  44. { .fmt = { .pix = { .width = 352, .height = 288 }}},
  45. [SAA6752HS_VF_UNKNOWN] =
  46. { .fmt = { .pix = { .width = 0, .height = 0}}},
  47. };
  48. struct saa6752hs_state {
  49. struct i2c_client client;
  50. struct v4l2_mpeg_compression params;
  51. enum saa6752hs_videoformat video_format;
  52. v4l2_std_id standard;
  53. };
  54. enum saa6752hs_command {
  55. SAA6752HS_COMMAND_RESET = 0,
  56. SAA6752HS_COMMAND_STOP = 1,
  57. SAA6752HS_COMMAND_START = 2,
  58. SAA6752HS_COMMAND_PAUSE = 3,
  59. SAA6752HS_COMMAND_RECONFIGURE = 4,
  60. SAA6752HS_COMMAND_SLEEP = 5,
  61. SAA6752HS_COMMAND_RECONFIGURE_FORCE = 6,
  62. SAA6752HS_COMMAND_MAX
  63. };
  64. /* ---------------------------------------------------------------------- */
  65. static u8 PAT[] = {
  66. 0xc2, /* i2c register */
  67. 0x00, /* table number for encoder */
  68. 0x47, /* sync */
  69. 0x40, 0x00, /* transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0) */
  70. 0x10, /* transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) */
  71. 0x00, /* PSI pointer to start of table */
  72. 0x00, /* tid(0) */
  73. 0xb0, 0x0d, /* section_syntax_indicator(1), section_length(13) */
  74. 0x00, 0x01, /* transport_stream_id(1) */
  75. 0xc1, /* version_number(0), current_next_indicator(1) */
  76. 0x00, 0x00, /* section_number(0), last_section_number(0) */
  77. 0x00, 0x01, /* program_number(1) */
  78. 0xe0, 0x00, /* PMT PID */
  79. 0x00, 0x00, 0x00, 0x00 /* CRC32 */
  80. };
  81. static u8 PMT[] = {
  82. 0xc2, /* i2c register */
  83. 0x01, /* table number for encoder */
  84. 0x47, /* sync */
  85. 0x40, 0x00, /* transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid */
  86. 0x10, /* transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) */
  87. 0x00, /* PSI pointer to start of table */
  88. 0x02, /* tid(2) */
  89. 0xb0, 0x17, /* section_syntax_indicator(1), section_length(23) */
  90. 0x00, 0x01, /* program_number(1) */
  91. 0xc1, /* version_number(0), current_next_indicator(1) */
  92. 0x00, 0x00, /* section_number(0), last_section_number(0) */
  93. 0xe0, 0x00, /* PCR_PID */
  94. 0xf0, 0x00, /* program_info_length(0) */
  95. 0x02, 0xe0, 0x00, 0xf0, 0x00, /* video stream type(2), pid */
  96. 0x04, 0xe0, 0x00, 0xf0, 0x00, /* audio stream type(4), pid */
  97. 0x00, 0x00, 0x00, 0x00 /* CRC32 */
  98. };
  99. static struct v4l2_mpeg_compression param_defaults =
  100. {
  101. .st_type = V4L2_MPEG_TS_2,
  102. .st_bitrate = {
  103. .mode = V4L2_BITRATE_CBR,
  104. .target = 7000,
  105. },
  106. .ts_pid_pmt = 16,
  107. .ts_pid_video = 260,
  108. .ts_pid_audio = 256,
  109. .ts_pid_pcr = 259,
  110. .vi_type = V4L2_MPEG_VI_2,
  111. .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3,
  112. .vi_bitrate = {
  113. .mode = V4L2_BITRATE_VBR,
  114. .target = 4000,
  115. .max = 6000,
  116. },
  117. .au_type = V4L2_MPEG_AU_2_II,
  118. .au_bitrate = {
  119. .mode = V4L2_BITRATE_CBR,
  120. .target = 256,
  121. },
  122. };
  123. /* ---------------------------------------------------------------------- */
  124. static int saa6752hs_chip_command(struct i2c_client* client,
  125. enum saa6752hs_command command)
  126. {
  127. unsigned char buf[3];
  128. unsigned long timeout;
  129. int status = 0;
  130. /* execute the command */
  131. switch(command) {
  132. case SAA6752HS_COMMAND_RESET:
  133. buf[0] = 0x00;
  134. break;
  135. case SAA6752HS_COMMAND_STOP:
  136. buf[0] = 0x03;
  137. break;
  138. case SAA6752HS_COMMAND_START:
  139. buf[0] = 0x02;
  140. break;
  141. case SAA6752HS_COMMAND_PAUSE:
  142. buf[0] = 0x04;
  143. break;
  144. case SAA6752HS_COMMAND_RECONFIGURE:
  145. buf[0] = 0x05;
  146. break;
  147. case SAA6752HS_COMMAND_SLEEP:
  148. buf[0] = 0x06;
  149. break;
  150. case SAA6752HS_COMMAND_RECONFIGURE_FORCE:
  151. buf[0] = 0x07;
  152. break;
  153. default:
  154. return -EINVAL;
  155. }
  156. /* set it and wait for it to be so */
  157. i2c_master_send(client, buf, 1);
  158. timeout = jiffies + HZ * 3;
  159. for (;;) {
  160. /* get the current status */
  161. buf[0] = 0x10;
  162. i2c_master_send(client, buf, 1);
  163. i2c_master_recv(client, buf, 1);
  164. if (!(buf[0] & 0x20))
  165. break;
  166. if (time_after(jiffies,timeout)) {
  167. status = -ETIMEDOUT;
  168. break;
  169. }
  170. msleep(10);
  171. }
  172. /* delay a bit to let encoder settle */
  173. msleep(50);
  174. return status;
  175. }
  176. static int saa6752hs_set_bitrate(struct i2c_client* client,
  177. struct v4l2_mpeg_compression* params)
  178. {
  179. u8 buf[3];
  180. /* set the bitrate mode */
  181. buf[0] = 0x71;
  182. buf[1] = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ? 0 : 1;
  183. i2c_master_send(client, buf, 2);
  184. /* set the video bitrate */
  185. if (params->vi_bitrate.mode == V4L2_BITRATE_VBR) {
  186. /* set the target bitrate */
  187. buf[0] = 0x80;
  188. buf[1] = params->vi_bitrate.target >> 8;
  189. buf[2] = params->vi_bitrate.target & 0xff;
  190. i2c_master_send(client, buf, 3);
  191. /* set the max bitrate */
  192. buf[0] = 0x81;
  193. buf[1] = params->vi_bitrate.max >> 8;
  194. buf[2] = params->vi_bitrate.max & 0xff;
  195. i2c_master_send(client, buf, 3);
  196. } else {
  197. /* set the target bitrate (no max bitrate for CBR) */
  198. buf[0] = 0x81;
  199. buf[1] = params->vi_bitrate.target >> 8;
  200. buf[2] = params->vi_bitrate.target & 0xff;
  201. i2c_master_send(client, buf, 3);
  202. }
  203. /* set the audio bitrate */
  204. buf[0] = 0x94;
  205. buf[1] = (256 == params->au_bitrate.target) ? 0 : 1;
  206. i2c_master_send(client, buf, 2);
  207. /* set the total bitrate */
  208. buf[0] = 0xb1;
  209. buf[1] = params->st_bitrate.target >> 8;
  210. buf[2] = params->st_bitrate.target & 0xff;
  211. i2c_master_send(client, buf, 3);
  212. return 0;
  213. }
  214. static void saa6752hs_set_subsampling(struct i2c_client* client,
  215. struct v4l2_format* f)
  216. {
  217. struct saa6752hs_state *h = i2c_get_clientdata(client);
  218. int dist_352, dist_480, dist_720;
  219. /*
  220. FIXME: translate and round width/height into EMPRESS
  221. subsample type:
  222. type | PAL | NTSC
  223. ---------------------------
  224. SIF | 352x288 | 352x240
  225. 1/2 D1 | 352x576 | 352x480
  226. 2/3 D1 | 480x576 | 480x480
  227. D1 | 720x576 | 720x480
  228. */
  229. dist_352 = abs(f->fmt.pix.width - 352);
  230. dist_480 = abs(f->fmt.pix.width - 480);
  231. dist_720 = abs(f->fmt.pix.width - 720);
  232. if (dist_720 < dist_480) {
  233. f->fmt.pix.width = 720;
  234. f->fmt.pix.height = 576;
  235. h->video_format = SAA6752HS_VF_D1;
  236. }
  237. else if (dist_480 < dist_352) {
  238. f->fmt.pix.width = 480;
  239. f->fmt.pix.height = 576;
  240. h->video_format = SAA6752HS_VF_2_3_D1;
  241. }
  242. else {
  243. f->fmt.pix.width = 352;
  244. if (abs(f->fmt.pix.height - 576) <
  245. abs(f->fmt.pix.height - 288)) {
  246. f->fmt.pix.height = 576;
  247. h->video_format = SAA6752HS_VF_1_2_D1;
  248. }
  249. else {
  250. f->fmt.pix.height = 288;
  251. h->video_format = SAA6752HS_VF_SIF;
  252. }
  253. }
  254. }
  255. static void saa6752hs_set_params(struct i2c_client* client,
  256. struct v4l2_mpeg_compression* params)
  257. {
  258. struct saa6752hs_state *h = i2c_get_clientdata(client);
  259. /* check PIDs */
  260. if (params->ts_pid_pmt <= MPEG_PID_MAX)
  261. h->params.ts_pid_pmt = params->ts_pid_pmt;
  262. if (params->ts_pid_pcr <= MPEG_PID_MAX)
  263. h->params.ts_pid_pcr = params->ts_pid_pcr;
  264. if (params->ts_pid_video <= MPEG_PID_MAX)
  265. h->params.ts_pid_video = params->ts_pid_video;
  266. if (params->ts_pid_audio <= MPEG_PID_MAX)
  267. h->params.ts_pid_audio = params->ts_pid_audio;
  268. /* check bitrate parameters */
  269. if ((params->vi_bitrate.mode == V4L2_BITRATE_CBR) ||
  270. (params->vi_bitrate.mode == V4L2_BITRATE_VBR))
  271. h->params.vi_bitrate.mode = params->vi_bitrate.mode;
  272. if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
  273. h->params.st_bitrate.target = params->st_bitrate.target;
  274. if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
  275. h->params.vi_bitrate.target = params->vi_bitrate.target;
  276. if (params->vi_bitrate.mode == V4L2_BITRATE_VBR)
  277. h->params.vi_bitrate.max = params->vi_bitrate.max;
  278. if (params->au_bitrate.mode != V4L2_BITRATE_NONE)
  279. h->params.au_bitrate.target = params->au_bitrate.target;
  280. /* aspect ratio */
  281. if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3 ||
  282. params->vi_aspect_ratio == V4L2_MPEG_ASPECT_16_9)
  283. h->params.vi_aspect_ratio = params->vi_aspect_ratio;
  284. /* range checks */
  285. if (h->params.st_bitrate.target > MPEG_TOTAL_TARGET_BITRATE_MAX)
  286. h->params.st_bitrate.target = MPEG_TOTAL_TARGET_BITRATE_MAX;
  287. if (h->params.vi_bitrate.target > MPEG_VIDEO_TARGET_BITRATE_MAX)
  288. h->params.vi_bitrate.target = MPEG_VIDEO_TARGET_BITRATE_MAX;
  289. if (h->params.vi_bitrate.max > MPEG_VIDEO_MAX_BITRATE_MAX)
  290. h->params.vi_bitrate.max = MPEG_VIDEO_MAX_BITRATE_MAX;
  291. if (h->params.au_bitrate.target <= 256)
  292. h->params.au_bitrate.target = 256;
  293. else
  294. h->params.au_bitrate.target = 384;
  295. }
  296. static int saa6752hs_init(struct i2c_client* client)
  297. {
  298. unsigned char buf[9], buf2[4];
  299. struct saa6752hs_state *h;
  300. u32 crc;
  301. unsigned char localPAT[256];
  302. unsigned char localPMT[256];
  303. h = i2c_get_clientdata(client);
  304. /* Set video format - must be done first as it resets other settings */
  305. buf[0] = 0x41;
  306. buf[1] = h->video_format;
  307. i2c_master_send(client, buf, 2);
  308. /* Set number of lines in input signal */
  309. buf[0] = 0x40;
  310. buf[1] = 0x00;
  311. if (h->standard & V4L2_STD_525_60)
  312. buf[1] = 0x01;
  313. i2c_master_send(client, buf, 2);
  314. /* set bitrate */
  315. saa6752hs_set_bitrate(client, &h->params);
  316. /* Set GOP structure {3, 13} */
  317. buf[0] = 0x72;
  318. buf[1] = 0x03;
  319. buf[2] = 0x0D;
  320. i2c_master_send(client,buf,3);
  321. /* Set minimum Q-scale {4} */
  322. buf[0] = 0x82;
  323. buf[1] = 0x04;
  324. i2c_master_send(client,buf,2);
  325. /* Set maximum Q-scale {12} */
  326. buf[0] = 0x83;
  327. buf[1] = 0x0C;
  328. i2c_master_send(client,buf,2);
  329. /* Set Output Protocol */
  330. buf[0] = 0xD0;
  331. buf[1] = 0x81;
  332. i2c_master_send(client,buf,2);
  333. /* Set video output stream format {TS} */
  334. buf[0] = 0xB0;
  335. buf[1] = 0x05;
  336. i2c_master_send(client,buf,2);
  337. /* compute PAT */
  338. memcpy(localPAT, PAT, sizeof(PAT));
  339. localPAT[17] = 0xe0 | ((h->params.ts_pid_pmt >> 8) & 0x0f);
  340. localPAT[18] = h->params.ts_pid_pmt & 0xff;
  341. crc = crc32_be(~0, &localPAT[7], sizeof(PAT) - 7 - 4);
  342. localPAT[sizeof(PAT) - 4] = (crc >> 24) & 0xFF;
  343. localPAT[sizeof(PAT) - 3] = (crc >> 16) & 0xFF;
  344. localPAT[sizeof(PAT) - 2] = (crc >> 8) & 0xFF;
  345. localPAT[sizeof(PAT) - 1] = crc & 0xFF;
  346. /* compute PMT */
  347. memcpy(localPMT, PMT, sizeof(PMT));
  348. localPMT[3] = 0x40 | ((h->params.ts_pid_pmt >> 8) & 0x0f);
  349. localPMT[4] = h->params.ts_pid_pmt & 0xff;
  350. localPMT[15] = 0xE0 | ((h->params.ts_pid_pcr >> 8) & 0x0F);
  351. localPMT[16] = h->params.ts_pid_pcr & 0xFF;
  352. localPMT[20] = 0xE0 | ((h->params.ts_pid_video >> 8) & 0x0F);
  353. localPMT[21] = h->params.ts_pid_video & 0xFF;
  354. localPMT[25] = 0xE0 | ((h->params.ts_pid_audio >> 8) & 0x0F);
  355. localPMT[26] = h->params.ts_pid_audio & 0xFF;
  356. crc = crc32_be(~0, &localPMT[7], sizeof(PMT) - 7 - 4);
  357. localPMT[sizeof(PMT) - 4] = (crc >> 24) & 0xFF;
  358. localPMT[sizeof(PMT) - 3] = (crc >> 16) & 0xFF;
  359. localPMT[sizeof(PMT) - 2] = (crc >> 8) & 0xFF;
  360. localPMT[sizeof(PMT) - 1] = crc & 0xFF;
  361. /* Set Audio PID */
  362. buf[0] = 0xC1;
  363. buf[1] = (h->params.ts_pid_audio >> 8) & 0xFF;
  364. buf[2] = h->params.ts_pid_audio & 0xFF;
  365. i2c_master_send(client,buf,3);
  366. /* Set Video PID */
  367. buf[0] = 0xC0;
  368. buf[1] = (h->params.ts_pid_video >> 8) & 0xFF;
  369. buf[2] = h->params.ts_pid_video & 0xFF;
  370. i2c_master_send(client,buf,3);
  371. /* Set PCR PID */
  372. buf[0] = 0xC4;
  373. buf[1] = (h->params.ts_pid_pcr >> 8) & 0xFF;
  374. buf[2] = h->params.ts_pid_pcr & 0xFF;
  375. i2c_master_send(client,buf,3);
  376. /* Send SI tables */
  377. i2c_master_send(client,localPAT,sizeof(PAT));
  378. i2c_master_send(client,localPMT,sizeof(PMT));
  379. /* mute then unmute audio. This removes buzzing artefacts */
  380. buf[0] = 0xa4;
  381. buf[1] = 1;
  382. i2c_master_send(client, buf, 2);
  383. buf[1] = 0;
  384. i2c_master_send(client, buf, 2);
  385. /* start it going */
  386. saa6752hs_chip_command(client, SAA6752HS_COMMAND_START);
  387. /* readout current state */
  388. buf[0] = 0xE1;
  389. buf[1] = 0xA7;
  390. buf[2] = 0xFE;
  391. buf[3] = 0x82;
  392. buf[4] = 0xB0;
  393. i2c_master_send(client, buf, 5);
  394. i2c_master_recv(client, buf2, 4);
  395. /* change aspect ratio */
  396. buf[0] = 0xE0;
  397. buf[1] = 0xA7;
  398. buf[2] = 0xFE;
  399. buf[3] = 0x82;
  400. buf[4] = 0xB0;
  401. buf[5] = buf2[0];
  402. switch(h->params.vi_aspect_ratio) {
  403. case V4L2_MPEG_ASPECT_16_9:
  404. buf[6] = buf2[1] | 0x40;
  405. break;
  406. case V4L2_MPEG_ASPECT_4_3:
  407. default:
  408. buf[6] = buf2[1] & 0xBF;
  409. break;
  410. break;
  411. }
  412. buf[7] = buf2[2];
  413. buf[8] = buf2[3];
  414. i2c_master_send(client, buf, 9);
  415. return 0;
  416. }
  417. static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
  418. {
  419. struct saa6752hs_state *h;
  420. if (NULL == (h = kzalloc(sizeof(*h), GFP_KERNEL)))
  421. return -ENOMEM;
  422. h->client = client_template;
  423. h->params = param_defaults;
  424. h->client.adapter = adap;
  425. h->client.addr = addr;
  426. /* Assume 625 input lines */
  427. h->standard = 0;
  428. i2c_set_clientdata(&h->client, h);
  429. i2c_attach_client(&h->client);
  430. v4l_info(&h->client,"saa6752hs: chip found @ 0x%x\n", addr<<1);
  431. return 0;
  432. }
  433. static int saa6752hs_probe(struct i2c_adapter *adap)
  434. {
  435. if (adap->class & I2C_CLASS_TV_ANALOG)
  436. return i2c_probe(adap, &addr_data, saa6752hs_attach);
  437. return 0;
  438. }
  439. static int saa6752hs_detach(struct i2c_client *client)
  440. {
  441. struct saa6752hs_state *h;
  442. h = i2c_get_clientdata(client);
  443. i2c_detach_client(client);
  444. kfree(h);
  445. return 0;
  446. }
  447. static int
  448. saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
  449. {
  450. struct saa6752hs_state *h = i2c_get_clientdata(client);
  451. struct v4l2_mpeg_compression *params = arg;
  452. int err = 0;
  453. switch (cmd) {
  454. case VIDIOC_S_MPEGCOMP:
  455. if (NULL == params) {
  456. /* apply settings and start encoder */
  457. saa6752hs_init(client);
  458. break;
  459. }
  460. saa6752hs_set_params(client, params);
  461. /* fall through */
  462. case VIDIOC_G_MPEGCOMP:
  463. *params = h->params;
  464. break;
  465. case VIDIOC_G_FMT:
  466. {
  467. struct v4l2_format *f = arg;
  468. if (h->video_format == SAA6752HS_VF_UNKNOWN)
  469. h->video_format = SAA6752HS_VF_D1;
  470. f->fmt.pix.width =
  471. v4l2_format_table[h->video_format].fmt.pix.width;
  472. f->fmt.pix.height =
  473. v4l2_format_table[h->video_format].fmt.pix.height;
  474. break ;
  475. }
  476. case VIDIOC_S_FMT:
  477. {
  478. struct v4l2_format *f = arg;
  479. saa6752hs_set_subsampling(client, f);
  480. break;
  481. }
  482. case VIDIOC_S_STD:
  483. h->standard = *((v4l2_std_id *) arg);
  484. break;
  485. default:
  486. /* nothing */
  487. break;
  488. }
  489. return err;
  490. }
  491. /* ----------------------------------------------------------------------- */
  492. static struct i2c_driver driver = {
  493. .driver = {
  494. .name = "saa6752hs",
  495. },
  496. .id = I2C_DRIVERID_SAA6752HS,
  497. .attach_adapter = saa6752hs_probe,
  498. .detach_client = saa6752hs_detach,
  499. .command = saa6752hs_command,
  500. };
  501. static struct i2c_client client_template =
  502. {
  503. .name = "saa6752hs",
  504. .driver = &driver,
  505. };
  506. static int __init saa6752hs_init_module(void)
  507. {
  508. return i2c_add_driver(&driver);
  509. }
  510. static void __exit saa6752hs_cleanup_module(void)
  511. {
  512. i2c_del_driver(&driver);
  513. }
  514. module_init(saa6752hs_init_module);
  515. module_exit(saa6752hs_cleanup_module);
  516. /*
  517. * Overrides for Emacs so that we follow Linus's tabbing style.
  518. * ---------------------------------------------------------------------------
  519. * Local variables:
  520. * c-basic-offset: 8
  521. * End:
  522. */