saa6752hs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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/videodev.h>
  13. #include <linux/init.h>
  14. #include <linux/crc32.h>
  15. #include <media/id.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. };
  53. enum saa6752hs_command {
  54. SAA6752HS_COMMAND_RESET = 0,
  55. SAA6752HS_COMMAND_STOP = 1,
  56. SAA6752HS_COMMAND_START = 2,
  57. SAA6752HS_COMMAND_PAUSE = 3,
  58. SAA6752HS_COMMAND_RECONFIGURE = 4,
  59. SAA6752HS_COMMAND_SLEEP = 5,
  60. SAA6752HS_COMMAND_RECONFIGURE_FORCE = 6,
  61. SAA6752HS_COMMAND_MAX
  62. };
  63. /* ---------------------------------------------------------------------- */
  64. static u8 PAT[] = {
  65. 0xc2, // i2c register
  66. 0x00, // table number for encoder
  67. 0x47, // sync
  68. 0x40, 0x00, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0)
  69. 0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0)
  70. 0x00, // PSI pointer to start of table
  71. 0x00, // tid(0)
  72. 0xb0, 0x0d, // section_syntax_indicator(1), section_length(13)
  73. 0x00, 0x01, // transport_stream_id(1)
  74. 0xc1, // version_number(0), current_next_indicator(1)
  75. 0x00, 0x00, // section_number(0), last_section_number(0)
  76. 0x00, 0x01, // program_number(1)
  77. 0xe0, 0x00, // PMT PID
  78. 0x00, 0x00, 0x00, 0x00 // CRC32
  79. };
  80. static u8 PMT[] = {
  81. 0xc2, // i2c register
  82. 0x01, // table number for encoder
  83. 0x47, // sync
  84. 0x40, 0x00, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid
  85. 0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0)
  86. 0x00, // PSI pointer to start of table
  87. 0x02, // tid(2)
  88. 0xb0, 0x17, // section_syntax_indicator(1), section_length(23)
  89. 0x00, 0x01, // program_number(1)
  90. 0xc1, // version_number(0), current_next_indicator(1)
  91. 0x00, 0x00, // section_number(0), last_section_number(0)
  92. 0xe0, 0x00, // PCR_PID
  93. 0xf0, 0x00, // program_info_length(0)
  94. 0x02, 0xe0, 0x00, 0xf0, 0x00, // video stream type(2), pid
  95. 0x04, 0xe0, 0x00, 0xf0, 0x00, // audio stream type(4), pid
  96. 0x00, 0x00, 0x00, 0x00 // CRC32
  97. };
  98. static struct v4l2_mpeg_compression param_defaults =
  99. {
  100. .st_type = V4L2_MPEG_TS_2,
  101. .st_bitrate = {
  102. .mode = V4L2_BITRATE_CBR,
  103. .target = 7000,
  104. },
  105. .ts_pid_pmt = 16,
  106. .ts_pid_video = 260,
  107. .ts_pid_audio = 256,
  108. .ts_pid_pcr = 259,
  109. .vi_type = V4L2_MPEG_VI_2,
  110. .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3,
  111. .vi_bitrate = {
  112. .mode = V4L2_BITRATE_VBR,
  113. .target = 4000,
  114. .max = 6000,
  115. },
  116. .au_type = V4L2_MPEG_AU_2_II,
  117. .au_bitrate = {
  118. .mode = V4L2_BITRATE_CBR,
  119. .target = 256,
  120. },
  121. #if 0
  122. /* FIXME: size? via S_FMT? */
  123. .video_format = MPEG_VIDEO_FORMAT_D1,
  124. #endif
  125. };
  126. /* ---------------------------------------------------------------------- */
  127. static int saa6752hs_chip_command(struct i2c_client* client,
  128. enum saa6752hs_command command)
  129. {
  130. unsigned char buf[3];
  131. unsigned long timeout;
  132. int status = 0;
  133. // execute the command
  134. switch(command) {
  135. case SAA6752HS_COMMAND_RESET:
  136. buf[0] = 0x00;
  137. break;
  138. case SAA6752HS_COMMAND_STOP:
  139. buf[0] = 0x03;
  140. break;
  141. case SAA6752HS_COMMAND_START:
  142. buf[0] = 0x02;
  143. break;
  144. case SAA6752HS_COMMAND_PAUSE:
  145. buf[0] = 0x04;
  146. break;
  147. case SAA6752HS_COMMAND_RECONFIGURE:
  148. buf[0] = 0x05;
  149. break;
  150. case SAA6752HS_COMMAND_SLEEP:
  151. buf[0] = 0x06;
  152. break;
  153. case SAA6752HS_COMMAND_RECONFIGURE_FORCE:
  154. buf[0] = 0x07;
  155. break;
  156. default:
  157. return -EINVAL;
  158. }
  159. // set it and wait for it to be so
  160. i2c_master_send(client, buf, 1);
  161. timeout = jiffies + HZ * 3;
  162. for (;;) {
  163. // get the current status
  164. buf[0] = 0x10;
  165. i2c_master_send(client, buf, 1);
  166. i2c_master_recv(client, buf, 1);
  167. if (!(buf[0] & 0x20))
  168. break;
  169. if (time_after(jiffies,timeout)) {
  170. status = -ETIMEDOUT;
  171. break;
  172. }
  173. // wait a bit
  174. msleep(10);
  175. }
  176. // delay a bit to let encoder settle
  177. msleep(50);
  178. // done
  179. return status;
  180. }
  181. static int saa6752hs_set_bitrate(struct i2c_client* client,
  182. struct v4l2_mpeg_compression* params)
  183. {
  184. u8 buf[3];
  185. // set the bitrate mode
  186. buf[0] = 0x71;
  187. buf[1] = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ? 0 : 1;
  188. i2c_master_send(client, buf, 2);
  189. // set the video bitrate
  190. if (params->vi_bitrate.mode == V4L2_BITRATE_VBR) {
  191. // set the target bitrate
  192. buf[0] = 0x80;
  193. buf[1] = params->vi_bitrate.target >> 8;
  194. buf[2] = params->vi_bitrate.target & 0xff;
  195. i2c_master_send(client, buf, 3);
  196. // set the max bitrate
  197. buf[0] = 0x81;
  198. buf[1] = params->vi_bitrate.max >> 8;
  199. buf[2] = params->vi_bitrate.max & 0xff;
  200. i2c_master_send(client, buf, 3);
  201. } else {
  202. // set the target bitrate (no max bitrate for CBR)
  203. buf[0] = 0x81;
  204. buf[1] = params->vi_bitrate.target >> 8;
  205. buf[2] = params->vi_bitrate.target & 0xff;
  206. i2c_master_send(client, buf, 3);
  207. }
  208. // set the audio bitrate
  209. buf[0] = 0x94;
  210. buf[1] = (256 == params->au_bitrate.target) ? 0 : 1;
  211. i2c_master_send(client, buf, 2);
  212. // set the total bitrate
  213. buf[0] = 0xb1;
  214. buf[1] = params->st_bitrate.target >> 8;
  215. buf[2] = params->st_bitrate.target & 0xff;
  216. i2c_master_send(client, buf, 3);
  217. // return success
  218. return 0;
  219. }
  220. static void saa6752hs_set_subsampling(struct i2c_client* client,
  221. struct v4l2_format* f)
  222. {
  223. struct saa6752hs_state *h = i2c_get_clientdata(client);
  224. int dist_352, dist_480, dist_720;
  225. /*
  226. FIXME: translate and round width/height into EMPRESS
  227. subsample type:
  228. type | PAL | NTSC
  229. ---------------------------
  230. SIF | 352x288 | 352x240
  231. 1/2 D1 | 352x576 | 352x480
  232. 2/3 D1 | 480x576 | 480x480
  233. D1 | 720x576 | 720x480
  234. */
  235. dist_352 = abs(f->fmt.pix.width - 352);
  236. dist_480 = abs(f->fmt.pix.width - 480);
  237. dist_720 = abs(f->fmt.pix.width - 720);
  238. if (dist_720 < dist_480) {
  239. f->fmt.pix.width = 720;
  240. f->fmt.pix.height = 576;
  241. h->video_format = SAA6752HS_VF_D1;
  242. }
  243. else if (dist_480 < dist_352) {
  244. f->fmt.pix.width = 480;
  245. f->fmt.pix.height = 576;
  246. h->video_format = SAA6752HS_VF_2_3_D1;
  247. }
  248. else {
  249. f->fmt.pix.width = 352;
  250. if (abs(f->fmt.pix.height - 576) <
  251. abs(f->fmt.pix.height - 288)) {
  252. f->fmt.pix.height = 576;
  253. h->video_format = SAA6752HS_VF_1_2_D1;
  254. }
  255. else {
  256. f->fmt.pix.height = 288;
  257. h->video_format = SAA6752HS_VF_SIF;
  258. }
  259. }
  260. }
  261. static void saa6752hs_set_params(struct i2c_client* client,
  262. struct v4l2_mpeg_compression* params)
  263. {
  264. struct saa6752hs_state *h = i2c_get_clientdata(client);
  265. /* check PIDs */
  266. if (params->ts_pid_pmt <= MPEG_PID_MAX)
  267. h->params.ts_pid_pmt = params->ts_pid_pmt;
  268. if (params->ts_pid_pcr <= MPEG_PID_MAX)
  269. h->params.ts_pid_pcr = params->ts_pid_pcr;
  270. if (params->ts_pid_video <= MPEG_PID_MAX)
  271. h->params.ts_pid_video = params->ts_pid_video;
  272. if (params->ts_pid_audio <= MPEG_PID_MAX)
  273. h->params.ts_pid_audio = params->ts_pid_audio;
  274. /* check bitrate parameters */
  275. if ((params->vi_bitrate.mode == V4L2_BITRATE_CBR) ||
  276. (params->vi_bitrate.mode == V4L2_BITRATE_VBR))
  277. h->params.vi_bitrate.mode = params->vi_bitrate.mode;
  278. if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
  279. h->params.st_bitrate.target = params->st_bitrate.target;
  280. if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
  281. h->params.vi_bitrate.target = params->vi_bitrate.target;
  282. if (params->vi_bitrate.mode == V4L2_BITRATE_VBR)
  283. h->params.vi_bitrate.max = params->vi_bitrate.max;
  284. if (params->au_bitrate.mode != V4L2_BITRATE_NONE)
  285. h->params.au_bitrate.target = params->au_bitrate.target;
  286. /* aspect ratio */
  287. if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3 ||
  288. params->vi_aspect_ratio == V4L2_MPEG_ASPECT_16_9)
  289. h->params.vi_aspect_ratio = params->vi_aspect_ratio;
  290. /* range checks */
  291. if (h->params.st_bitrate.target > MPEG_TOTAL_TARGET_BITRATE_MAX)
  292. h->params.st_bitrate.target = MPEG_TOTAL_TARGET_BITRATE_MAX;
  293. if (h->params.vi_bitrate.target > MPEG_VIDEO_TARGET_BITRATE_MAX)
  294. h->params.vi_bitrate.target = MPEG_VIDEO_TARGET_BITRATE_MAX;
  295. if (h->params.vi_bitrate.max > MPEG_VIDEO_MAX_BITRATE_MAX)
  296. h->params.vi_bitrate.max = MPEG_VIDEO_MAX_BITRATE_MAX;
  297. if (h->params.au_bitrate.target <= 256)
  298. h->params.au_bitrate.target = 256;
  299. else
  300. h->params.au_bitrate.target = 384;
  301. }
  302. static int saa6752hs_init(struct i2c_client* client)
  303. {
  304. unsigned char buf[9], buf2[4];
  305. struct saa6752hs_state *h;
  306. u32 crc;
  307. unsigned char localPAT[256];
  308. unsigned char localPMT[256];
  309. h = i2c_get_clientdata(client);
  310. // Set video format - must be done first as it resets other settings
  311. buf[0] = 0x41;
  312. buf[1] = h->video_format;
  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 success
  416. return 0;
  417. }
  418. static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
  419. {
  420. struct saa6752hs_state *h;
  421. printk("saa6752hs: chip found @ 0x%x\n", addr<<1);
  422. if (NULL == (h = kmalloc(sizeof(*h), GFP_KERNEL)))
  423. return -ENOMEM;
  424. memset(h,0,sizeof(*h));
  425. h->client = client_template;
  426. h->params = param_defaults;
  427. h->client.adapter = adap;
  428. h->client.addr = addr;
  429. i2c_set_clientdata(&h->client, h);
  430. i2c_attach_client(&h->client);
  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. default:
  483. /* nothing */
  484. break;
  485. }
  486. return err;
  487. }
  488. /* ----------------------------------------------------------------------- */
  489. static struct i2c_driver driver = {
  490. .owner = THIS_MODULE,
  491. .name = "i2c saa6752hs MPEG encoder",
  492. .id = I2C_DRIVERID_SAA6752HS,
  493. .flags = I2C_DF_NOTIFY,
  494. .attach_adapter = saa6752hs_probe,
  495. .detach_client = saa6752hs_detach,
  496. .command = saa6752hs_command,
  497. };
  498. static struct i2c_client client_template =
  499. {
  500. I2C_DEVNAME("saa6752hs"),
  501. .flags = I2C_CLIENT_ALLOW_USE,
  502. .driver = &driver,
  503. };
  504. static int __init saa6752hs_init_module(void)
  505. {
  506. return i2c_add_driver(&driver);
  507. }
  508. static void __exit saa6752hs_cleanup_module(void)
  509. {
  510. i2c_del_driver(&driver);
  511. }
  512. module_init(saa6752hs_init_module);
  513. module_exit(saa6752hs_cleanup_module);
  514. /*
  515. * Overrides for Emacs so that we follow Linus's tabbing style.
  516. * ---------------------------------------------------------------------------
  517. * Local variables:
  518. * c-basic-offset: 8
  519. * End:
  520. */