saa6752hs.c 16 KB

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