ddbridge.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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/dvb/video.h>
  34. #include <linux/dvb/audio.h>
  35. #include <linux/socket.h>
  36. #include "dmxdev.h"
  37. #include "dvbdev.h"
  38. #include "dvb_demux.h"
  39. #include "dvb_frontend.h"
  40. #include "dvb_ringbuffer.h"
  41. #include "dvb_ca_en50221.h"
  42. #include "dvb_net.h"
  43. #include "cxd2099.h"
  44. #define DDB_MAX_I2C 4
  45. #define DDB_MAX_PORT 4
  46. #define DDB_MAX_INPUT 8
  47. #define DDB_MAX_OUTPUT 4
  48. struct ddb_info {
  49. int type;
  50. #define DDB_NONE 0
  51. #define DDB_OCTOPUS 1
  52. char *name;
  53. int port_num;
  54. u32 port_type[DDB_MAX_PORT];
  55. };
  56. /* DMA_SIZE MUST be divisible by 188 and 128 !!! */
  57. #define INPUT_DMA_MAX_BUFS 32 /* hardware table limit */
  58. #define INPUT_DMA_BUFS 8
  59. #define INPUT_DMA_SIZE (128*47*21)
  60. #define OUTPUT_DMA_MAX_BUFS 32
  61. #define OUTPUT_DMA_BUFS 8
  62. #define OUTPUT_DMA_SIZE (128*47*21)
  63. struct ddb;
  64. struct ddb_port;
  65. struct ddb_input {
  66. struct ddb_port *port;
  67. u32 nr;
  68. int attached;
  69. dma_addr_t pbuf[INPUT_DMA_MAX_BUFS];
  70. u8 *vbuf[INPUT_DMA_MAX_BUFS];
  71. u32 dma_buf_num;
  72. u32 dma_buf_size;
  73. struct tasklet_struct tasklet;
  74. spinlock_t lock;
  75. wait_queue_head_t wq;
  76. int running;
  77. u32 stat;
  78. u32 cbuf;
  79. u32 coff;
  80. struct dvb_adapter adap;
  81. struct dvb_device *dev;
  82. struct dvb_frontend *fe;
  83. struct dvb_frontend *fe2;
  84. struct dmxdev dmxdev;
  85. struct dvb_demux demux;
  86. struct dvb_net dvbnet;
  87. struct dmx_frontend hw_frontend;
  88. struct dmx_frontend mem_frontend;
  89. int users;
  90. int (*gate_ctrl)(struct dvb_frontend *, int);
  91. };
  92. struct ddb_output {
  93. struct ddb_port *port;
  94. u32 nr;
  95. dma_addr_t pbuf[OUTPUT_DMA_MAX_BUFS];
  96. u8 *vbuf[OUTPUT_DMA_MAX_BUFS];
  97. u32 dma_buf_num;
  98. u32 dma_buf_size;
  99. struct tasklet_struct tasklet;
  100. spinlock_t lock;
  101. wait_queue_head_t wq;
  102. int running;
  103. u32 stat;
  104. u32 cbuf;
  105. u32 coff;
  106. struct dvb_adapter adap;
  107. struct dvb_device *dev;
  108. };
  109. struct ddb_i2c {
  110. struct ddb *dev;
  111. u32 nr;
  112. struct i2c_adapter adap;
  113. struct i2c_adapter adap2;
  114. u32 regs;
  115. u32 rbuf;
  116. u32 wbuf;
  117. int done;
  118. wait_queue_head_t wq;
  119. };
  120. struct ddb_port {
  121. struct ddb *dev;
  122. u32 nr;
  123. struct ddb_i2c *i2c;
  124. struct mutex i2c_gate_lock;
  125. u32 class;
  126. #define DDB_PORT_NONE 0
  127. #define DDB_PORT_CI 1
  128. #define DDB_PORT_TUNER 2
  129. u32 type;
  130. #define DDB_TUNER_NONE 0
  131. #define DDB_TUNER_DVBS_ST 1
  132. #define DDB_TUNER_DVBS_ST_AA 2
  133. #define DDB_TUNER_DVBCT_TR 16
  134. #define DDB_TUNER_DVBCT_ST 17
  135. u32 adr;
  136. struct ddb_input *input[2];
  137. struct ddb_output *output;
  138. struct dvb_ca_en50221 *en;
  139. };
  140. struct ddb {
  141. struct pci_dev *pdev;
  142. unsigned char *regs;
  143. struct ddb_port port[DDB_MAX_PORT];
  144. struct ddb_i2c i2c[DDB_MAX_I2C];
  145. struct ddb_input input[DDB_MAX_INPUT];
  146. struct ddb_output output[DDB_MAX_OUTPUT];
  147. struct device *ddb_dev;
  148. int nr;
  149. u8 iobuf[1028];
  150. struct ddb_info *info;
  151. int msi;
  152. };
  153. /****************************************************************************/
  154. #define ddbwritel(_val, _adr) writel((_val), \
  155. (char *) (dev->regs+(_adr)))
  156. #define ddbreadl(_adr) readl((char *) (dev->regs+(_adr)))
  157. #define ddbcpyto(_adr, _src, _count) memcpy_toio((char *) \
  158. (dev->regs+(_adr)), (_src), (_count))
  159. #define ddbcpyfrom(_dst, _adr, _count) memcpy_fromio((_dst), (char *) \
  160. (dev->regs+(_adr)), (_count))
  161. /****************************************************************************/
  162. #endif