au0828-core.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. /*
  2. * Driver for the Auvitek USB bridge
  3. *
  4. * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. *
  15. * GNU General Public License for more details.
  16. */
  17. #include "au0828.h"
  18. #include "au8522.h"
  19. #include <linux/module.h>
  20. #include <linux/slab.h>
  21. #include <linux/videodev2.h>
  22. #include <media/v4l2-common.h>
  23. #include <linux/mutex.h>
  24. /* Due to enum tuner_pad_index */
  25. #include <media/tuner.h>
  26. /*
  27. * 1 = General debug messages
  28. * 2 = USB handling
  29. * 4 = I2C related
  30. * 8 = Bridge related
  31. * 16 = IR related
  32. */
  33. int au0828_debug;
  34. module_param_named(debug, au0828_debug, int, 0644);
  35. MODULE_PARM_DESC(debug,
  36. "set debug bitmask: 1=general, 2=USB, 4=I2C, 8=bridge, 16=IR");
  37. static unsigned int disable_usb_speed_check;
  38. module_param(disable_usb_speed_check, int, 0444);
  39. MODULE_PARM_DESC(disable_usb_speed_check,
  40. "override min bandwidth requirement of 480M bps");
  41. #define _AU0828_BULKPIPE 0x03
  42. #define _BULKPIPESIZE 0xffff
  43. static int send_control_msg(struct au0828_dev *dev, u16 request, u32 value,
  44. u16 index);
  45. static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value,
  46. u16 index, unsigned char *cp, u16 size);
  47. /* USB Direction */
  48. #define CMD_REQUEST_IN 0x00
  49. #define CMD_REQUEST_OUT 0x01
  50. u32 au0828_readreg(struct au0828_dev *dev, u16 reg)
  51. {
  52. u8 result = 0;
  53. recv_control_msg(dev, CMD_REQUEST_IN, 0, reg, &result, 1);
  54. dprintk(8, "%s(0x%04x) = 0x%02x\n", __func__, reg, result);
  55. return result;
  56. }
  57. u32 au0828_writereg(struct au0828_dev *dev, u16 reg, u32 val)
  58. {
  59. dprintk(8, "%s(0x%04x, 0x%02x)\n", __func__, reg, val);
  60. return send_control_msg(dev, CMD_REQUEST_OUT, val, reg);
  61. }
  62. static int send_control_msg(struct au0828_dev *dev, u16 request, u32 value,
  63. u16 index)
  64. {
  65. int status = -ENODEV;
  66. if (dev->usbdev) {
  67. /* cp must be memory that has been allocated by kmalloc */
  68. status = usb_control_msg(dev->usbdev,
  69. usb_sndctrlpipe(dev->usbdev, 0),
  70. request,
  71. USB_DIR_OUT | USB_TYPE_VENDOR |
  72. USB_RECIP_DEVICE,
  73. value, index, NULL, 0, 1000);
  74. status = min(status, 0);
  75. if (status < 0) {
  76. pr_err("%s() Failed sending control message, error %d.\n",
  77. __func__, status);
  78. }
  79. }
  80. return status;
  81. }
  82. static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value,
  83. u16 index, unsigned char *cp, u16 size)
  84. {
  85. int status = -ENODEV;
  86. mutex_lock(&dev->mutex);
  87. if (dev->usbdev) {
  88. status = usb_control_msg(dev->usbdev,
  89. usb_rcvctrlpipe(dev->usbdev, 0),
  90. request,
  91. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  92. value, index,
  93. dev->ctrlmsg, size, 1000);
  94. status = min(status, 0);
  95. if (status < 0) {
  96. pr_err("%s() Failed receiving control message, error %d.\n",
  97. __func__, status);
  98. }
  99. /* the host controller requires heap allocated memory, which
  100. is why we didn't just pass "cp" into usb_control_msg */
  101. memcpy(cp, dev->ctrlmsg, size);
  102. }
  103. mutex_unlock(&dev->mutex);
  104. return status;
  105. }
  106. #ifdef CONFIG_MEDIA_CONTROLLER
  107. static void au0828_media_graph_notify(struct media_entity *new,
  108. void *notify_data);
  109. #endif
  110. static void au0828_unregister_media_device(struct au0828_dev *dev)
  111. {
  112. #ifdef CONFIG_MEDIA_CONTROLLER
  113. struct media_device *mdev = dev->media_dev;
  114. struct media_entity_notify *notify, *nextp;
  115. if (!mdev || !media_devnode_is_registered(mdev->devnode))
  116. return;
  117. /* Remove au0828 entity_notify callbacks */
  118. list_for_each_entry_safe(notify, nextp, &mdev->entity_notify, list) {
  119. if (notify->notify != au0828_media_graph_notify)
  120. continue;
  121. media_device_unregister_entity_notify(mdev, notify);
  122. }
  123. /* clear enable_source, disable_source */
  124. mutex_lock(&mdev->graph_mutex);
  125. dev->media_dev->source_priv = NULL;
  126. dev->media_dev->enable_source = NULL;
  127. dev->media_dev->disable_source = NULL;
  128. mutex_unlock(&mdev->graph_mutex);
  129. media_device_unregister(dev->media_dev);
  130. media_device_cleanup(dev->media_dev);
  131. kfree(dev->media_dev);
  132. dev->media_dev = NULL;
  133. #endif
  134. }
  135. void au0828_usb_release(struct au0828_dev *dev)
  136. {
  137. au0828_unregister_media_device(dev);
  138. /* I2C */
  139. au0828_i2c_unregister(dev);
  140. kfree(dev);
  141. }
  142. static void au0828_usb_disconnect(struct usb_interface *interface)
  143. {
  144. struct au0828_dev *dev = usb_get_intfdata(interface);
  145. dprintk(1, "%s()\n", __func__);
  146. /* there is a small window after disconnect, before
  147. dev->usbdev is NULL, for poll (e.g: IR) try to access
  148. the device and fill the dmesg with error messages.
  149. Set the status so poll routines can check and avoid
  150. access after disconnect.
  151. */
  152. set_bit(DEV_DISCONNECTED, &dev->dev_state);
  153. au0828_rc_unregister(dev);
  154. /* Digital TV */
  155. au0828_dvb_unregister(dev);
  156. usb_set_intfdata(interface, NULL);
  157. mutex_lock(&dev->mutex);
  158. dev->usbdev = NULL;
  159. mutex_unlock(&dev->mutex);
  160. if (au0828_analog_unregister(dev)) {
  161. /*
  162. * No need to call au0828_usb_release() if V4L2 is enabled,
  163. * as this is already called via au0828_usb_v4l2_release()
  164. */
  165. return;
  166. }
  167. au0828_usb_release(dev);
  168. }
  169. static int au0828_media_device_init(struct au0828_dev *dev,
  170. struct usb_device *udev)
  171. {
  172. #ifdef CONFIG_MEDIA_CONTROLLER
  173. struct media_device *mdev;
  174. mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
  175. if (!mdev)
  176. return -ENOMEM;
  177. /* check if media device is already initialized */
  178. if (!mdev->dev)
  179. media_device_usb_init(mdev, udev, udev->product);
  180. dev->media_dev = mdev;
  181. #endif
  182. return 0;
  183. }
  184. #ifdef CONFIG_MEDIA_CONTROLLER
  185. static void au0828_media_graph_notify(struct media_entity *new,
  186. void *notify_data)
  187. {
  188. struct au0828_dev *dev = (struct au0828_dev *) notify_data;
  189. int ret;
  190. struct media_entity *entity, *mixer = NULL, *decoder = NULL;
  191. if (!new) {
  192. /*
  193. * Called during au0828 probe time to connect
  194. * entites that were created prior to registering
  195. * the notify handler. Find mixer and decoder.
  196. */
  197. media_device_for_each_entity(entity, dev->media_dev) {
  198. if (entity->function == MEDIA_ENT_F_AUDIO_MIXER)
  199. mixer = entity;
  200. else if (entity->function == MEDIA_ENT_F_ATV_DECODER)
  201. decoder = entity;
  202. }
  203. goto create_link;
  204. }
  205. switch (new->function) {
  206. case MEDIA_ENT_F_AUDIO_MIXER:
  207. mixer = new;
  208. if (dev->decoder)
  209. decoder = dev->decoder;
  210. break;
  211. case MEDIA_ENT_F_ATV_DECODER:
  212. /* In case, Mixer is added first, find mixer and create link */
  213. media_device_for_each_entity(entity, dev->media_dev) {
  214. if (entity->function == MEDIA_ENT_F_AUDIO_MIXER)
  215. mixer = entity;
  216. }
  217. decoder = new;
  218. break;
  219. default:
  220. break;
  221. }
  222. create_link:
  223. if (decoder && mixer) {
  224. ret = media_create_pad_link(decoder,
  225. DEMOD_PAD_AUDIO_OUT,
  226. mixer, 0,
  227. MEDIA_LNK_FL_ENABLED);
  228. if (ret)
  229. dev_err(&dev->usbdev->dev,
  230. "Mixer Pad Link Create Error: %d\n", ret);
  231. }
  232. }
  233. /* Callers should hold graph_mutex */
  234. static int au0828_enable_source(struct media_entity *entity,
  235. struct media_pipeline *pipe)
  236. {
  237. struct media_entity *source, *find_source;
  238. struct media_entity *sink;
  239. struct media_link *link, *found_link = NULL;
  240. int ret = 0;
  241. struct media_device *mdev = entity->graph_obj.mdev;
  242. struct au0828_dev *dev;
  243. if (!mdev)
  244. return -ENODEV;
  245. dev = mdev->source_priv;
  246. /*
  247. * For Audio and V4L2 entity, find the link to which decoder
  248. * is the sink. Look for an active link between decoder and
  249. * source (tuner/s-video/Composite), if one exists, nothing
  250. * to do. If not, look for any active links between source
  251. * and any other entity. If one exists, source is busy. If
  252. * source is free, setup link and start pipeline from source.
  253. * For DVB FE entity, the source for the link is the tuner.
  254. * Check if tuner is available and setup link and start
  255. * pipeline.
  256. */
  257. if (entity->function == MEDIA_ENT_F_DTV_DEMOD) {
  258. sink = entity;
  259. find_source = dev->tuner;
  260. } else {
  261. /* Analog isn't configured or register failed */
  262. if (!dev->decoder) {
  263. ret = -ENODEV;
  264. goto end;
  265. }
  266. sink = dev->decoder;
  267. /*
  268. * Default input is tuner and default input_type
  269. * is AU0828_VMUX_TELEVISION.
  270. * FIXME:
  271. * There is a problem when s_input is called to
  272. * change the default input. s_input will try to
  273. * enable_source before attempting to change the
  274. * input on the device, and will end up enabling
  275. * default source which is tuner.
  276. *
  277. * Additional logic is necessary in au0828
  278. * to detect that the input has changed and
  279. * enable the right source.
  280. */
  281. if (dev->input_type == AU0828_VMUX_TELEVISION)
  282. find_source = dev->tuner;
  283. else if (dev->input_type == AU0828_VMUX_SVIDEO ||
  284. dev->input_type == AU0828_VMUX_COMPOSITE)
  285. find_source = &dev->input_ent[dev->input_type];
  286. else {
  287. /* unknown input - let user select input */
  288. ret = 0;
  289. goto end;
  290. }
  291. }
  292. /* Is an active link between sink and source */
  293. if (dev->active_link) {
  294. /*
  295. * If DVB is using the tuner and calling entity is
  296. * audio/video, the following check will be false,
  297. * since sink is different. Result is Busy.
  298. */
  299. if (dev->active_link->sink->entity == sink &&
  300. dev->active_link->source->entity == find_source) {
  301. /*
  302. * Either ALSA or Video own tuner. sink is
  303. * the same for both. Prevent Video stepping
  304. * on ALSA when ALSA owns the source.
  305. */
  306. if (dev->active_link_owner != entity &&
  307. dev->active_link_owner->function ==
  308. MEDIA_ENT_F_AUDIO_CAPTURE) {
  309. pr_debug("ALSA has the tuner\n");
  310. ret = -EBUSY;
  311. goto end;
  312. }
  313. ret = 0;
  314. goto end;
  315. } else {
  316. ret = -EBUSY;
  317. goto end;
  318. }
  319. }
  320. list_for_each_entry(link, &sink->links, list) {
  321. /* Check sink, and source */
  322. if (link->sink->entity == sink &&
  323. link->source->entity == find_source) {
  324. found_link = link;
  325. break;
  326. }
  327. }
  328. if (!found_link) {
  329. ret = -ENODEV;
  330. goto end;
  331. }
  332. /* activate link between source and sink and start pipeline */
  333. source = found_link->source->entity;
  334. ret = __media_entity_setup_link(found_link, MEDIA_LNK_FL_ENABLED);
  335. if (ret) {
  336. pr_err("Activate tuner link %s->%s. Error %d\n",
  337. source->name, sink->name, ret);
  338. goto end;
  339. }
  340. ret = __media_pipeline_start(entity, pipe);
  341. if (ret) {
  342. pr_err("Start Pipeline: %s->%s Error %d\n",
  343. source->name, entity->name, ret);
  344. ret = __media_entity_setup_link(found_link, 0);
  345. pr_err("Deactivate link Error %d\n", ret);
  346. goto end;
  347. }
  348. /*
  349. * save active link and active link owner to avoid audio
  350. * deactivating video owned link from disable_source and
  351. * vice versa
  352. */
  353. dev->active_link = found_link;
  354. dev->active_link_owner = entity;
  355. dev->active_source = source;
  356. dev->active_sink = sink;
  357. pr_debug("Enabled Source: %s->%s->%s Ret %d\n",
  358. dev->active_source->name, dev->active_sink->name,
  359. dev->active_link_owner->name, ret);
  360. end:
  361. pr_debug("au0828_enable_source() end %s %d %d\n",
  362. entity->name, entity->function, ret);
  363. return ret;
  364. }
  365. /* Callers should hold graph_mutex */
  366. static void au0828_disable_source(struct media_entity *entity)
  367. {
  368. int ret = 0;
  369. struct media_device *mdev = entity->graph_obj.mdev;
  370. struct au0828_dev *dev;
  371. if (!mdev)
  372. return;
  373. dev = mdev->source_priv;
  374. if (!dev->active_link)
  375. return;
  376. /* link is active - stop pipeline from source (tuner) */
  377. if (dev->active_link->sink->entity == dev->active_sink &&
  378. dev->active_link->source->entity == dev->active_source) {
  379. /*
  380. * prevent video from deactivating link when audio
  381. * has active pipeline
  382. */
  383. if (dev->active_link_owner != entity)
  384. return;
  385. __media_pipeline_stop(entity);
  386. ret = __media_entity_setup_link(dev->active_link, 0);
  387. if (ret)
  388. pr_err("Deactivate link Error %d\n", ret);
  389. pr_debug("Disabled Source: %s->%s->%s Ret %d\n",
  390. dev->active_source->name, dev->active_sink->name,
  391. dev->active_link_owner->name, ret);
  392. dev->active_link = NULL;
  393. dev->active_link_owner = NULL;
  394. dev->active_source = NULL;
  395. dev->active_sink = NULL;
  396. }
  397. }
  398. #endif
  399. static int au0828_media_device_register(struct au0828_dev *dev,
  400. struct usb_device *udev)
  401. {
  402. #ifdef CONFIG_MEDIA_CONTROLLER
  403. int ret;
  404. struct media_entity *entity, *demod = NULL;
  405. struct media_link *link;
  406. if (!dev->media_dev)
  407. return 0;
  408. if (!media_devnode_is_registered(dev->media_dev->devnode)) {
  409. /* register media device */
  410. ret = media_device_register(dev->media_dev);
  411. if (ret) {
  412. dev_err(&udev->dev,
  413. "Media Device Register Error: %d\n", ret);
  414. return ret;
  415. }
  416. } else {
  417. /*
  418. * Call au0828_media_graph_notify() to connect
  419. * audio graph to our graph. In this case, audio
  420. * driver registered the device and there is no
  421. * entity_notify to be called when new entities
  422. * are added. Invoke it now.
  423. */
  424. au0828_media_graph_notify(NULL, (void *) dev);
  425. }
  426. /*
  427. * Find tuner, decoder and demod.
  428. *
  429. * The tuner and decoder should be cached, as they'll be used by
  430. * au0828_enable_source.
  431. *
  432. * It also needs to disable the link between tuner and
  433. * decoder/demod, to avoid disable step when tuner is requested
  434. * by video or audio. Note that this step can't be done until dvb
  435. * graph is created during dvb register.
  436. */
  437. media_device_for_each_entity(entity, dev->media_dev) {
  438. switch (entity->function) {
  439. case MEDIA_ENT_F_TUNER:
  440. dev->tuner = entity;
  441. break;
  442. case MEDIA_ENT_F_ATV_DECODER:
  443. dev->decoder = entity;
  444. break;
  445. case MEDIA_ENT_F_DTV_DEMOD:
  446. demod = entity;
  447. break;
  448. }
  449. }
  450. /* Disable link between tuner->demod and/or tuner->decoder */
  451. if (dev->tuner) {
  452. list_for_each_entry(link, &dev->tuner->links, list) {
  453. if (demod && link->sink->entity == demod)
  454. media_entity_setup_link(link, 0);
  455. if (dev->decoder && link->sink->entity == dev->decoder)
  456. media_entity_setup_link(link, 0);
  457. }
  458. }
  459. /* register entity_notify callback */
  460. dev->entity_notify.notify_data = (void *) dev;
  461. dev->entity_notify.notify = (void *) au0828_media_graph_notify;
  462. ret = media_device_register_entity_notify(dev->media_dev,
  463. &dev->entity_notify);
  464. if (ret) {
  465. dev_err(&udev->dev,
  466. "Media Device register entity_notify Error: %d\n",
  467. ret);
  468. return ret;
  469. }
  470. /* set enable_source */
  471. mutex_lock(&dev->media_dev->graph_mutex);
  472. dev->media_dev->source_priv = (void *) dev;
  473. dev->media_dev->enable_source = au0828_enable_source;
  474. dev->media_dev->disable_source = au0828_disable_source;
  475. mutex_unlock(&dev->media_dev->graph_mutex);
  476. #endif
  477. return 0;
  478. }
  479. static int au0828_usb_probe(struct usb_interface *interface,
  480. const struct usb_device_id *id)
  481. {
  482. int ifnum;
  483. int retval = 0;
  484. struct au0828_dev *dev;
  485. struct usb_device *usbdev = interface_to_usbdev(interface);
  486. ifnum = interface->altsetting->desc.bInterfaceNumber;
  487. if (ifnum != 0)
  488. return -ENODEV;
  489. dprintk(1, "%s() vendor id 0x%x device id 0x%x ifnum:%d\n", __func__,
  490. le16_to_cpu(usbdev->descriptor.idVendor),
  491. le16_to_cpu(usbdev->descriptor.idProduct),
  492. ifnum);
  493. /*
  494. * Make sure we have 480 Mbps of bandwidth, otherwise things like
  495. * video stream wouldn't likely work, since 12 Mbps is generally
  496. * not enough even for most Digital TV streams.
  497. */
  498. if (usbdev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {
  499. pr_err("au0828: Device initialization failed.\n");
  500. pr_err("au0828: Device must be connected to a high-speed USB 2.0 port.\n");
  501. return -ENODEV;
  502. }
  503. dev = kzalloc(sizeof(*dev), GFP_KERNEL);
  504. if (dev == NULL) {
  505. pr_err("%s() Unable to allocate memory\n", __func__);
  506. return -ENOMEM;
  507. }
  508. mutex_init(&dev->lock);
  509. mutex_lock(&dev->lock);
  510. mutex_init(&dev->mutex);
  511. mutex_init(&dev->dvb.lock);
  512. dev->usbdev = usbdev;
  513. dev->boardnr = id->driver_info;
  514. dev->board = au0828_boards[dev->boardnr];
  515. /* Initialize the media controller */
  516. retval = au0828_media_device_init(dev, usbdev);
  517. if (retval) {
  518. pr_err("%s() au0828_media_device_init failed\n",
  519. __func__);
  520. mutex_unlock(&dev->lock);
  521. kfree(dev);
  522. return retval;
  523. }
  524. retval = au0828_v4l2_device_register(interface, dev);
  525. if (retval) {
  526. au0828_usb_v4l2_media_release(dev);
  527. mutex_unlock(&dev->lock);
  528. kfree(dev);
  529. return retval;
  530. }
  531. /* Power Up the bridge */
  532. au0828_write(dev, REG_600, 1 << 4);
  533. /* Bring up the GPIO's and supporting devices */
  534. au0828_gpio_setup(dev);
  535. /* I2C */
  536. au0828_i2c_register(dev);
  537. /* Setup */
  538. au0828_card_setup(dev);
  539. /*
  540. * Store the pointer to the au0828_dev so it can be accessed in
  541. * au0828_usb_disconnect
  542. */
  543. usb_set_intfdata(interface, dev);
  544. /* Analog TV */
  545. retval = au0828_analog_register(dev, interface);
  546. if (retval) {
  547. pr_err("%s() au0828_analog_register failed to register on V4L2\n",
  548. __func__);
  549. mutex_unlock(&dev->lock);
  550. goto done;
  551. }
  552. /* Digital TV */
  553. retval = au0828_dvb_register(dev);
  554. if (retval)
  555. pr_err("%s() au0828_dvb_register failed\n",
  556. __func__);
  557. /* Remote controller */
  558. au0828_rc_register(dev);
  559. pr_info("Registered device AU0828 [%s]\n",
  560. dev->board.name == NULL ? "Unset" : dev->board.name);
  561. mutex_unlock(&dev->lock);
  562. retval = au0828_media_device_register(dev, usbdev);
  563. done:
  564. if (retval < 0)
  565. au0828_usb_disconnect(interface);
  566. return retval;
  567. }
  568. static int au0828_suspend(struct usb_interface *interface,
  569. pm_message_t message)
  570. {
  571. struct au0828_dev *dev = usb_get_intfdata(interface);
  572. if (!dev)
  573. return 0;
  574. pr_info("Suspend\n");
  575. au0828_rc_suspend(dev);
  576. au0828_v4l2_suspend(dev);
  577. au0828_dvb_suspend(dev);
  578. /* FIXME: should suspend also ATV/DTV */
  579. return 0;
  580. }
  581. static int au0828_resume(struct usb_interface *interface)
  582. {
  583. struct au0828_dev *dev = usb_get_intfdata(interface);
  584. if (!dev)
  585. return 0;
  586. pr_info("Resume\n");
  587. /* Power Up the bridge */
  588. au0828_write(dev, REG_600, 1 << 4);
  589. /* Bring up the GPIO's and supporting devices */
  590. au0828_gpio_setup(dev);
  591. au0828_rc_resume(dev);
  592. au0828_v4l2_resume(dev);
  593. au0828_dvb_resume(dev);
  594. /* FIXME: should resume also ATV/DTV */
  595. return 0;
  596. }
  597. static struct usb_driver au0828_usb_driver = {
  598. .name = KBUILD_MODNAME,
  599. .probe = au0828_usb_probe,
  600. .disconnect = au0828_usb_disconnect,
  601. .id_table = au0828_usb_id_table,
  602. .suspend = au0828_suspend,
  603. .resume = au0828_resume,
  604. .reset_resume = au0828_resume,
  605. };
  606. static int __init au0828_init(void)
  607. {
  608. int ret;
  609. if (au0828_debug & 1)
  610. pr_info("%s() Debugging is enabled\n", __func__);
  611. if (au0828_debug & 2)
  612. pr_info("%s() USB Debugging is enabled\n", __func__);
  613. if (au0828_debug & 4)
  614. pr_info("%s() I2C Debugging is enabled\n", __func__);
  615. if (au0828_debug & 8)
  616. pr_info("%s() Bridge Debugging is enabled\n",
  617. __func__);
  618. if (au0828_debug & 16)
  619. pr_info("%s() IR Debugging is enabled\n",
  620. __func__);
  621. pr_info("au0828 driver loaded\n");
  622. ret = usb_register(&au0828_usb_driver);
  623. if (ret)
  624. pr_err("usb_register failed, error = %d\n", ret);
  625. return ret;
  626. }
  627. static void __exit au0828_exit(void)
  628. {
  629. usb_deregister(&au0828_usb_driver);
  630. }
  631. module_init(au0828_init);
  632. module_exit(au0828_exit);
  633. MODULE_DESCRIPTION("Driver for Auvitek AU0828 based products");
  634. MODULE_AUTHOR("Steven Toth <stoth@linuxtv.org>");
  635. MODULE_LICENSE("GPL");
  636. MODULE_VERSION("0.0.3");