ddbridge.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * ddbridge.h: Digital Devices PCIe bridge driver
  3. *
  4. * Copyright (C) 2010-2011 Digital Devices GmbH
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 only, as published by the Free Software Foundation.
  9. *
  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. * GNU General Public License for more details.
  15. *
  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., 51 Franklin Street, Fifth Floor, Boston, MA
  20. * 02110-1301, USA
  21. * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
  22. */
  23. #ifndef _DDBRIDGE_H_
  24. #define _DDBRIDGE_H_
  25. #include <linux/types.h>
  26. #include <linux/sched.h>
  27. #include <linux/interrupt.h>
  28. #include <linux/i2c.h>
  29. #include <linux/mutex.h>
  30. #include <asm/dma.h>
  31. #include <linux/dvb/frontend.h>
  32. #include <linux/dvb/ca.h>
  33. #include <linux/socket.h>
  34. #include "dmxdev.h"
  35. #include "dvbdev.h"
  36. #include "dvb_demux.h"
  37. #include "dvb_frontend.h"
  38. #include "dvb_ringbuffer.h"
  39. #include "dvb_ca_en50221.h"
  40. #include "dvb_net.h"
  41. #include "cxd2099.h"
  42. #define DDB_MAX_I2C 4
  43. #define DDB_MAX_PORT 4
  44. #define DDB_MAX_INPUT 8
  45. #define DDB_MAX_OUTPUT 4
  46. struct ddb_info {
  47. int type;
  48. #define DDB_NONE 0
  49. #define DDB_OCTOPUS 1
  50. char *name;
  51. int port_num;
  52. u32 port_type[DDB_MAX_PORT];
  53. };
  54. /* DMA_SIZE MUST be divisible by 188 and 128 !!! */
  55. #define INPUT_DMA_MAX_BUFS 32 /* hardware table limit */
  56. #define INPUT_DMA_BUFS 8
  57. #define INPUT_DMA_SIZE (128*47*21)
  58. #define OUTPUT_DMA_MAX_BUFS 32
  59. #define OUTPUT_DMA_BUFS 8
  60. #define OUTPUT_DMA_SIZE (128*47*21)
  61. struct ddb;
  62. struct ddb_port;
  63. struct ddb_input {
  64. struct ddb_port *port;
  65. u32 nr;
  66. int attached;
  67. dma_addr_t pbuf[INPUT_DMA_MAX_BUFS];
  68. u8 *vbuf[INPUT_DMA_MAX_BUFS];
  69. u32 dma_buf_num;
  70. u32 dma_buf_size;
  71. struct tasklet_struct tasklet;
  72. spinlock_t lock;
  73. wait_queue_head_t wq;
  74. int running;
  75. u32 stat;
  76. u32 cbuf;
  77. u32 coff;
  78. struct dvb_adapter adap;
  79. struct dvb_device *dev;
  80. struct dvb_frontend *fe;
  81. struct dvb_frontend *fe2;
  82. struct dmxdev dmxdev;
  83. struct dvb_demux demux;
  84. struct dvb_net dvbnet;
  85. struct dmx_frontend hw_frontend;
  86. struct dmx_frontend mem_frontend;
  87. int users;
  88. int (*gate_ctrl)(struct dvb_frontend *, int);
  89. };
  90. struct ddb_output {
  91. struct ddb_port *port;
  92. u32 nr;
  93. dma_addr_t pbuf[OUTPUT_DMA_MAX_BUFS];
  94. u8 *vbuf[OUTPUT_DMA_MAX_BUFS];
  95. u32 dma_buf_num;
  96. u32 dma_buf_size;
  97. struct tasklet_struct tasklet;
  98. spinlock_t lock;
  99. wait_queue_head_t wq;
  100. int running;
  101. u32 stat;
  102. u32 cbuf;
  103. u32 coff;
  104. struct dvb_adapter adap;
  105. struct dvb_device *dev;
  106. };
  107. struct ddb_i2c {
  108. struct ddb *dev;
  109. u32 nr;
  110. struct i2c_adapter adap;
  111. struct i2c_adapter adap2;
  112. u32 regs;
  113. u32 rbuf;
  114. u32 wbuf;
  115. int done;
  116. wait_queue_head_t wq;
  117. };
  118. struct ddb_port {
  119. struct ddb *dev;
  120. u32 nr;
  121. struct ddb_i2c *i2c;
  122. struct mutex i2c_gate_lock;
  123. u32 class;
  124. #define DDB_PORT_NONE 0
  125. #define DDB_PORT_CI 1
  126. #define DDB_PORT_TUNER 2
  127. u32 type;
  128. #define DDB_TUNER_NONE 0
  129. #define DDB_TUNER_DVBS_ST 1
  130. #define DDB_TUNER_DVBS_ST_AA 2
  131. #define DDB_TUNER_DVBCT_TR 16
  132. #define DDB_TUNER_DVBCT_ST 17
  133. u32 adr;
  134. struct ddb_input *input[2];
  135. struct ddb_output *output;
  136. struct dvb_ca_en50221 *en;
  137. };
  138. struct ddb {
  139. struct pci_dev *pdev;
  140. unsigned char __iomem *regs;
  141. struct ddb_port port[DDB_MAX_PORT];
  142. struct ddb_i2c i2c[DDB_MAX_I2C];
  143. struct ddb_input input[DDB_MAX_INPUT];
  144. struct ddb_output output[DDB_MAX_OUTPUT];
  145. struct device *ddb_dev;
  146. int nr;
  147. u8 iobuf[1028];
  148. struct ddb_info *info;
  149. int msi;
  150. };
  151. /****************************************************************************/
  152. #define ddbwritel(_val, _adr) writel((_val), \
  153. dev->regs+(_adr))
  154. #define ddbreadl(_adr) readl(dev->regs+(_adr))
  155. #define ddbcpyto(_adr, _src, _count) memcpy_toio(dev->regs+(_adr), (_src), (_count))
  156. #define ddbcpyfrom(_dst, _adr, _count) memcpy_fromio((_dst), dev->regs+(_adr), (_count))
  157. /****************************************************************************/
  158. #endif