au0828.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Driver for the Auvitek AU0828 USB bridge
  3. *
  4. * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com>
  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. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <linux/usb.h>
  22. #include <linux/i2c.h>
  23. #include <linux/i2c-algo-bit.h>
  24. #include <media/tveeprom.h>
  25. /* DVB */
  26. #include "demux.h"
  27. #include "dmxdev.h"
  28. #include "dvb_demux.h"
  29. #include "dvb_frontend.h"
  30. #include "dvb_net.h"
  31. #include "dvbdev.h"
  32. #include "au0828-reg.h"
  33. #include "au0828-cards.h"
  34. #define DRIVER_NAME "au0828"
  35. #define URB_COUNT 16
  36. #define URB_BUFSIZE (0xe522)
  37. struct au0828_board {
  38. char *name;
  39. };
  40. struct au0828_dvb {
  41. struct mutex lock;
  42. struct dvb_adapter adapter;
  43. struct dvb_frontend *frontend;
  44. struct dvb_demux demux;
  45. struct dmxdev dmxdev;
  46. struct dmx_frontend fe_hw;
  47. struct dmx_frontend fe_mem;
  48. struct dvb_net net;
  49. int feeding;
  50. };
  51. struct au0828_dev {
  52. struct mutex mutex;
  53. struct usb_device *usbdev;
  54. int board;
  55. u8 ctrlmsg[64];
  56. /* I2C */
  57. struct i2c_adapter i2c_adap;
  58. struct i2c_algo_bit_data i2c_algo;
  59. struct i2c_client i2c_client;
  60. u32 i2c_rc;
  61. /* Digital */
  62. struct au0828_dvb dvb;
  63. /* USB / URB Related */
  64. int urb_streaming;
  65. struct urb *urbs[URB_COUNT];
  66. };
  67. struct au0828_buff {
  68. struct au0828_dev *dev;
  69. struct urb *purb;
  70. struct list_head buff_list;
  71. };
  72. /* ----------------------------------------------------------- */
  73. #define au0828_read(dev, reg) au0828_readreg(dev, reg)
  74. #define au0828_write(dev, reg, value) au0828_writereg(dev, reg, value)
  75. #define au0828_andor(dev, reg, mask, value) \
  76. au0828_writereg(dev, reg, \
  77. (au0828_readreg(dev, reg) & ~(mask)) | ((value) & (mask)))
  78. #define au0828_set(dev, reg, bit) au0828_andor(dev, (reg), (bit), (bit))
  79. #define au0828_clear(dev, reg, bit) au0828_andor(dev, (reg), (bit), 0)
  80. /* ----------------------------------------------------------- */
  81. /* au0828-core.c */
  82. extern u32 au0828_read(struct au0828_dev *dev, u16 reg);
  83. extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val);
  84. extern int au0828_debug;
  85. /* ----------------------------------------------------------- */
  86. /* au0828-cards.c */
  87. extern struct au0828_board au0828_boards[];
  88. extern struct usb_device_id au0828_usb_id_table[];
  89. extern void au0828_gpio_setup(struct au0828_dev *dev);
  90. extern int au0828_tuner_callback(void *priv, int command, int arg);
  91. extern void au0828_card_setup(struct au0828_dev *dev);
  92. /* ----------------------------------------------------------- */
  93. /* au0828-i2c.c */
  94. extern int au0828_i2c_register(struct au0828_dev *dev);
  95. extern int au0828_i2c_unregister(struct au0828_dev *dev);
  96. extern void au0828_call_i2c_clients(struct au0828_dev *dev,
  97. unsigned int cmd, void *arg);
  98. /* ----------------------------------------------------------- */
  99. /* au0828-dvb.c */
  100. extern int au0828_dvb_register(struct au0828_dev *dev);
  101. extern void au0828_dvb_unregister(struct au0828_dev *dev);
  102. #define dprintk(level, fmt, arg...)\
  103. do { if (au0828_debug & level)\
  104. printk(KERN_DEBUG DRIVER_NAME "/0: " fmt, ## arg);\
  105. } while (0)