linux/drivers/media/pci/ttpci/av7110.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2#ifndef _AV7110_H_
   3#define _AV7110_H_
   4
   5#include <linux/interrupt.h>
   6#include <linux/socket.h>
   7#include <linux/netdevice.h>
   8#include <linux/i2c.h>
   9#include <linux/input.h>
  10#include <linux/time.h>
  11
  12#include <linux/dvb/video.h>
  13#include <linux/dvb/audio.h>
  14#include <linux/dvb/dmx.h>
  15#include <linux/dvb/ca.h>
  16#include <linux/dvb/osd.h>
  17#include <linux/dvb/net.h>
  18#include <linux/mutex.h>
  19
  20#include <media/dvbdev.h>
  21#include <media/demux.h>
  22#include <media/dvb_demux.h>
  23#include <media/dmxdev.h>
  24#include "dvb_filter.h"
  25#include <media/dvb_net.h>
  26#include <media/dvb_ringbuffer.h>
  27#include <media/dvb_frontend.h>
  28#include "ves1820.h"
  29#include "ves1x93.h"
  30#include "stv0299.h"
  31#include "tda8083.h"
  32#include "sp8870.h"
  33#include "stv0297.h"
  34#include "l64781.h"
  35
  36#include <media/drv-intf/saa7146_vv.h>
  37
  38
  39#define ANALOG_TUNER_VES1820 1
  40#define ANALOG_TUNER_STV0297 2
  41
  42extern int av7110_debug;
  43
  44#define dprintk(level, fmt, arg...) do {                                \
  45        if (level & av7110_debug)                                       \
  46                printk(KERN_DEBUG KBUILD_MODNAME ": %s(): " fmt,        \
  47                       __func__, ##arg);                                \
  48} while (0)
  49
  50#define MAXFILT 32
  51
  52enum {AV_PES_STREAM, PS_STREAM, TS_STREAM, PES_STREAM};
  53
  54enum av7110_video_mode {
  55        AV7110_VIDEO_MODE_PAL   = 0,
  56        AV7110_VIDEO_MODE_NTSC  = 1
  57};
  58
  59struct av7110_p2t {
  60        u8                pes[TS_SIZE];
  61        u8                counter;
  62        long int          pos;
  63        int               frags;
  64        struct dvb_demux_feed *feed;
  65};
  66
  67/* video MPEG decoder events: */
  68/* (code copied from dvb_frontend.c, should maybe be factored out...) */
  69#define MAX_VIDEO_EVENT 8
  70struct dvb_video_events {
  71        struct video_event        events[MAX_VIDEO_EVENT];
  72        int                       eventw;
  73        int                       eventr;
  74        int                       overflow;
  75        wait_queue_head_t         wait_queue;
  76        spinlock_t                lock;
  77};
  78
  79
  80struct av7110;
  81
  82/* infrared remote control */
  83struct infrared {
  84        u16     key_map[256];
  85        struct input_dev        *input_dev;
  86        char                    input_phys[32];
  87        struct timer_list       keyup_timer;
  88        struct tasklet_struct   ir_tasklet;
  89        void                    (*ir_handler)(struct av7110 *av7110, u32 ircom);
  90        u32                     ir_command;
  91        u32                     ir_config;
  92        u32                     device_mask;
  93        u8                      protocol;
  94        u8                      inversion;
  95        u16                     last_key;
  96        u16                     last_toggle;
  97        bool                    keypressed;
  98};
  99
 100
 101/* place to store all the necessary device information */
 102struct av7110 {
 103
 104        /* devices */
 105
 106        struct dvb_device       dvb_dev;
 107        struct dvb_net          dvb_net;
 108
 109        struct video_device     v4l_dev;
 110        struct video_device     vbi_dev;
 111
 112        struct saa7146_dev      *dev;
 113
 114        struct i2c_adapter      i2c_adap;
 115
 116        char                    *card_name;
 117
 118        /* support for analog module of dvb-c */
 119        int                     analog_tuner_flags;
 120        int                     current_input;
 121        u32                     current_freq;
 122
 123        struct tasklet_struct   debi_tasklet;
 124        struct tasklet_struct   gpio_tasklet;
 125
 126        int adac_type;         /* audio DAC type */
 127#define DVB_ADAC_TI       0
 128#define DVB_ADAC_CRYSTAL  1
 129#define DVB_ADAC_MSP34x0  2
 130#define DVB_ADAC_MSP34x5  3
 131#define DVB_ADAC_NONE    -1
 132
 133
 134        /* buffers */
 135
 136        void                   *iobuf;   /* memory for all buffers */
 137        struct dvb_ringbuffer   avout;   /* buffer for video or A/V mux */
 138#define AVOUTLEN (128*1024)
 139        struct dvb_ringbuffer   aout;    /* buffer for audio */
 140#define AOUTLEN (64*1024)
 141        void                   *bmpbuf;
 142#define BMPLEN (8*32768+1024)
 143
 144        /* bitmap buffers and states */
 145
 146        int                     bmpp;
 147        int                     bmplen;
 148        volatile int            bmp_state;
 149#define BMP_NONE     0
 150#define BMP_LOADING  1
 151#define BMP_LOADED   2
 152        wait_queue_head_t       bmpq;
 153
 154
 155        /* DEBI and polled command interface */
 156
 157        spinlock_t              debilock;
 158        struct mutex            dcomlock;
 159        volatile int            debitype;
 160        volatile int            debilen;
 161
 162
 163        /* Recording and playback flags */
 164
 165        int                     rec_mode;
 166        int                     playing;
 167#define RP_NONE  0
 168#define RP_VIDEO 1
 169#define RP_AUDIO 2
 170#define RP_AV    3
 171
 172
 173        /* OSD */
 174
 175        int                     osdwin;      /* currently active window */
 176        u16                     osdbpp[8];
 177        struct mutex            osd_mutex;
 178
 179        /* CA */
 180
 181        struct ca_slot_info     ci_slot[2];
 182
 183        enum av7110_video_mode  vidmode;
 184        struct dmxdev           dmxdev;
 185        struct dvb_demux        demux;
 186
 187        struct dmx_frontend     hw_frontend;
 188        struct dmx_frontend     mem_frontend;
 189
 190        /* for budget mode demux1 */
 191        struct dmxdev           dmxdev1;
 192        struct dvb_demux        demux1;
 193        struct dvb_net          dvb_net1;
 194        spinlock_t              feedlock1;
 195        int                     feeding1;
 196        u32                     ttbp;
 197        unsigned char           *grabbing;
 198        struct saa7146_pgtable  pt;
 199        struct tasklet_struct   vpe_tasklet;
 200        bool                    full_ts;
 201
 202        int                     fe_synced;
 203        struct mutex            pid_mutex;
 204
 205        int                     video_blank;
 206        struct video_status     videostate;
 207        u16                     display_panscan;
 208        int                     display_ar;
 209        int                     trickmode;
 210#define TRICK_NONE   0
 211#define TRICK_FAST   1
 212#define TRICK_SLOW   2
 213#define TRICK_FREEZE 3
 214        struct audio_status     audiostate;
 215
 216        struct dvb_demux_filter *handle2filter[32];
 217        struct av7110_p2t        p2t_filter[MAXFILT];
 218        struct dvb_filter_pes2ts p2t[2];
 219        struct ipack             ipack[2];
 220        u8                      *kbuf[2];
 221
 222        int sinfo;
 223        int feeding;
 224
 225        int arm_errors;
 226        int registered;
 227
 228
 229        /* AV711X */
 230
 231        u32                 arm_fw;
 232        u32                 arm_rtsl;
 233        u32                 arm_vid;
 234        u32                 arm_app;
 235        u32                 avtype;
 236        int                 arm_ready;
 237        struct task_struct *arm_thread;
 238        wait_queue_head_t   arm_wait;
 239        u16                 arm_loops;
 240
 241        void               *debi_virt;
 242        dma_addr_t          debi_bus;
 243
 244        u16                 pids[DMX_PES_OTHER];
 245
 246        struct dvb_ringbuffer    ci_rbuffer;
 247        struct dvb_ringbuffer    ci_wbuffer;
 248
 249        struct audio_mixer      mixer;
 250
 251        struct dvb_adapter       dvb_adapter;
 252        struct dvb_device        *video_dev;
 253        struct dvb_device        *audio_dev;
 254        struct dvb_device        *ca_dev;
 255        struct dvb_device        *osd_dev;
 256
 257        struct dvb_video_events  video_events;
 258        video_size_t             video_size;
 259
 260        u16                     wssMode;
 261        u16                     wssData;
 262
 263        struct infrared         ir;
 264
 265        /* firmware stuff */
 266        unsigned char *bin_fw;
 267        unsigned long size_fw;
 268
 269        unsigned char *bin_dpram;
 270        unsigned long size_dpram;
 271
 272        unsigned char *bin_root;
 273        unsigned long size_root;
 274
 275        struct dvb_frontend* fe;
 276        enum fe_status fe_status;
 277
 278        struct mutex ioctl_mutex;
 279
 280        /* crash recovery */
 281        void                            (*recover)(struct av7110* av7110);
 282        enum fe_sec_voltage             saved_voltage;
 283        enum fe_sec_tone_mode           saved_tone;
 284        struct dvb_diseqc_master_cmd    saved_master_cmd;
 285        enum fe_sec_mini_cmd            saved_minicmd;
 286
 287        int (*fe_init)(struct dvb_frontend* fe);
 288        int (*fe_read_status)(struct dvb_frontend *fe, enum fe_status *status);
 289        int (*fe_diseqc_reset_overload)(struct dvb_frontend *fe);
 290        int (*fe_diseqc_send_master_cmd)(struct dvb_frontend *fe,
 291                                         struct dvb_diseqc_master_cmd *cmd);
 292        int (*fe_diseqc_send_burst)(struct dvb_frontend *fe,
 293                                    enum fe_sec_mini_cmd minicmd);
 294        int (*fe_set_tone)(struct dvb_frontend *fe,
 295                           enum fe_sec_tone_mode tone);
 296        int (*fe_set_voltage)(struct dvb_frontend *fe,
 297                              enum fe_sec_voltage voltage);
 298        int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend *fe,
 299                                                  unsigned long cmd);
 300        int (*fe_set_frontend)(struct dvb_frontend *fe);
 301};
 302
 303
 304extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
 305                       u16 subpid, u16 pcrpid);
 306
 307extern int av7110_check_ir_config(struct av7110 *av7110, int force);
 308extern int av7110_ir_init(struct av7110 *av7110);
 309extern void av7110_ir_exit(struct av7110 *av7110);
 310
 311/* msp3400 i2c subaddresses */
 312#define MSP_WR_DEM 0x10
 313#define MSP_RD_DEM 0x11
 314#define MSP_WR_DSP 0x12
 315#define MSP_RD_DSP 0x13
 316
 317extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val);
 318extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg);
 319extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val);
 320
 321
 322extern int av7110_init_analog_module(struct av7110 *av7110);
 323extern int av7110_init_v4l(struct av7110 *av7110);
 324extern int av7110_exit_v4l(struct av7110 *av7110);
 325
 326#endif /* _AV7110_H_ */
 327