ddbridge.h 4.7 KB

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