au0828.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. /* DVB */
  25. #include "demux.h"
  26. #include "dmxdev.h"
  27. #include "dvb_demux.h"
  28. #include "dvb_frontend.h"
  29. #include "dvb_net.h"
  30. #include "dvbdev.h"
  31. #include "au0828-reg.h"
  32. #include "au0828-cards.h"
  33. #define DRIVER_NAME "au0828"
  34. #define URB_COUNT 16
  35. //#define URB_BUFSIZE (312 * 188)
  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,(au0828_readreg(dev,reg)&~(mask))|((value)&(mask)))
  77. #define au0828_set(dev,reg,bit) au0828_andor(dev,(reg),(bit),(bit))
  78. #define au0828_clear(dev,reg,bit) au0828_andor(dev,(reg),(bit),0)
  79. /* ----------------------------------------------------------- */
  80. /* au0828-core.c */
  81. extern u32 au0828_read(struct au0828_dev *dev, u16 reg);
  82. extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val);
  83. /* ----------------------------------------------------------- */
  84. /* au0828-cards.c */
  85. extern struct au0828_board au0828_boards[];
  86. extern struct usb_device_id au0828_usb_id_table[];
  87. extern const unsigned int au0828_bcount;
  88. extern void au0828_gpio_setup(struct au0828_dev *dev);
  89. extern int au0828_tuner_callback(void *priv, int command, int arg);
  90. /* ----------------------------------------------------------- */
  91. /* au0828-i2c.c */
  92. extern int au0828_i2c_register(struct au0828_dev *dev);
  93. extern int au0828_i2c_unregister(struct au0828_dev *dev);
  94. extern void au0828_call_i2c_clients(struct au0828_dev *dev,
  95. unsigned int cmd, void *arg);
  96. /* ----------------------------------------------------------- */
  97. /* au0828-dvb.c */
  98. extern int au0828_dvb_register(struct au0828_dev *dev);
  99. extern void au0828_dvb_unregister(struct au0828_dev *dev);