linux/drivers/media/pci/ddbridge/ddbridge.h
<<
>>
Prefs
   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#define DDB_MAX_LINK    4
  47#define DDB_LINK_SHIFT 28
  48
  49#define DDB_LINK_TAG(_x) (_x << DDB_LINK_SHIFT)
  50
  51#define DDB_XO2_TYPE_NONE       0
  52#define DDB_XO2_TYPE_DUOFLEX    1
  53#define DDB_XO2_TYPE_CI         2
  54
  55struct ddb_info {
  56        int   type;
  57#define DDB_NONE                0
  58#define DDB_OCTOPUS             1
  59#define DDB_OCTOPUS_MAX_CT      6
  60        char *name;
  61        int   port_num;
  62        u32   port_type[DDB_MAX_PORT];
  63        u32   board_control;
  64        u32   board_control_2;
  65        u8    ts_quirks;
  66#define TS_QUIRK_SERIAL   1
  67#define TS_QUIRK_REVERSED 2
  68#define TS_QUIRK_ALT_OSC  8
  69};
  70
  71/* DMA_SIZE MUST be divisible by 188 and 128 !!! */
  72
  73#define INPUT_DMA_MAX_BUFS 32      /* hardware table limit */
  74#define INPUT_DMA_BUFS 8
  75#define INPUT_DMA_SIZE (128*47*21)
  76
  77#define OUTPUT_DMA_MAX_BUFS 32
  78#define OUTPUT_DMA_BUFS 8
  79#define OUTPUT_DMA_SIZE (128*47*21)
  80
  81struct ddb;
  82struct ddb_port;
  83
  84struct ddb_input {
  85        struct ddb_port       *port;
  86        u32                    nr;
  87        int                    attached;
  88
  89        dma_addr_t             pbuf[INPUT_DMA_MAX_BUFS];
  90        u8                    *vbuf[INPUT_DMA_MAX_BUFS];
  91        u32                    dma_buf_num;
  92        u32                    dma_buf_size;
  93
  94        struct tasklet_struct  tasklet;
  95        spinlock_t             lock;
  96        wait_queue_head_t      wq;
  97        int                    running;
  98        u32                    stat;
  99        u32                    cbuf;
 100        u32                    coff;
 101
 102        struct dvb_adapter     adap;
 103        struct dvb_device     *dev;
 104        struct i2c_client     *i2c_client[1];
 105        struct dvb_frontend   *fe;
 106        struct dvb_frontend   *fe2;
 107        struct dmxdev          dmxdev;
 108        struct dvb_demux       demux;
 109        struct dvb_net         dvbnet;
 110        struct dmx_frontend    hw_frontend;
 111        struct dmx_frontend    mem_frontend;
 112        int                    users;
 113        int (*gate_ctrl)(struct dvb_frontend *, int);
 114};
 115
 116struct ddb_output {
 117        struct ddb_port       *port;
 118        u32                    nr;
 119        dma_addr_t             pbuf[OUTPUT_DMA_MAX_BUFS];
 120        u8                    *vbuf[OUTPUT_DMA_MAX_BUFS];
 121        u32                    dma_buf_num;
 122        u32                    dma_buf_size;
 123        struct tasklet_struct  tasklet;
 124        spinlock_t             lock;
 125        wait_queue_head_t      wq;
 126        int                    running;
 127        u32                    stat;
 128        u32                    cbuf;
 129        u32                    coff;
 130
 131        struct dvb_adapter     adap;
 132        struct dvb_device     *dev;
 133};
 134
 135struct ddb_i2c {
 136        struct ddb            *dev;
 137        u32                    nr;
 138        struct i2c_adapter     adap;
 139        struct i2c_adapter     adap2;
 140        u32                    regs;
 141        u32                    rbuf;
 142        u32                    wbuf;
 143        int                    done;
 144        wait_queue_head_t      wq;
 145};
 146
 147struct ddb_port {
 148        struct ddb            *dev;
 149        u32                    nr;
 150        struct ddb_i2c        *i2c;
 151        struct mutex           i2c_gate_lock;
 152        u32                    class;
 153#define DDB_PORT_NONE           0
 154#define DDB_PORT_CI             1
 155#define DDB_PORT_TUNER          2
 156        u32                    type;
 157#define DDB_TUNER_NONE                  0
 158#define DDB_TUNER_DVBS_ST               1
 159#define DDB_TUNER_DVBS_ST_AA            2
 160#define DDB_TUNER_DVBCT2_SONY_P         7
 161#define DDB_TUNER_DVBC2T2_SONY_P        8
 162#define DDB_TUNER_ISDBT_SONY_P          9
 163#define DDB_TUNER_DVBC2T2I_SONY_P       15
 164#define DDB_TUNER_DVBCT_TR              16
 165#define DDB_TUNER_DVBCT_ST              17
 166#define DDB_TUNER_XO2_DVBS_STV0910      32
 167#define DDB_TUNER_XO2_DVBCT2_SONY       33
 168#define DDB_TUNER_XO2_ISDBT_SONY        34
 169#define DDB_TUNER_XO2_DVBC2T2_SONY      35
 170#define DDB_TUNER_XO2_ATSC_ST           36
 171#define DDB_TUNER_XO2_DVBC2T2I_SONY     37
 172
 173        u32                    adr;
 174
 175        struct ddb_input      *input[2];
 176        struct ddb_output     *output;
 177        struct dvb_ca_en50221 *en;
 178};
 179
 180struct ddb {
 181        struct pci_dev        *pdev;
 182        unsigned char __iomem *regs;
 183        struct ddb_port        port[DDB_MAX_PORT];
 184        struct ddb_i2c         i2c[DDB_MAX_I2C];
 185        struct ddb_input       input[DDB_MAX_INPUT];
 186        struct ddb_output      output[DDB_MAX_OUTPUT];
 187
 188        struct device         *ddb_dev;
 189        int                    nr;
 190        u8                     iobuf[1028];
 191
 192        struct ddb_info       *info;
 193        int                    msi;
 194};
 195
 196/****************************************************************************/
 197
 198#define ddbwritel(_val, _adr)        writel((_val), \
 199                                     dev->regs+(_adr))
 200#define ddbreadl(_adr)               readl(dev->regs+(_adr))
 201#define ddbcpyto(_adr, _src, _count) memcpy_toio(dev->regs+(_adr), (_src), (_count))
 202#define ddbcpyfrom(_dst, _adr, _count) memcpy_fromio((_dst), dev->regs+(_adr), (_count))
 203
 204/****************************************************************************/
 205
 206#endif
 207