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