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