saa6752hs.c 16 KB

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