Annotation of margi2/cardbase.h, revision 1.11

1.1       cvs         1: /* 
                      2:     cardbase.h
                      3: 
                      4:     Copyright (C) Christian Wolff for convergence integrated media.
                      5: 
                      6:     This program is free software; you can redistribute it and/or modify
                      7:     it under the terms of the GNU General Public License as published by
                      8:     the Free Software Foundation; either version 2 of the License, or
                      9:     (at your option) any later version.
                     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:     You should have received a copy of the GNU General Public License
                     17:     along with this program; if not, write to the Free Software
                     18:     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                     19: */
                     20: 
                     21: #ifndef CARDBASE_H
                     22: #define CARDBASE_H
                     23: 
                     24: // all the internal structs
                     25: 
                     26: #include <pcmcia/config.h>
                     27: #include <pcmcia/k_compat.h>
                     28: #include "ringbuffy.h"
                     29: 
                     30: #include <linux/kernel.h>
                     31: #include <linux/config.h>
                     32: 
                     33: #include <linux/malloc.h>
                     34: #include <linux/vmalloc.h>
                     35: #include <linux/mm.h>
                     36: #include <linux/delay.h>
                     37: #include <linux/poll.h>
                     38: #include <linux/fs.h>
                     39: #include <linux/interrupt.h>
                     40: #include <asm/io.h>
                     41: #include <asm/byteorder.h>
                     42: 
1.10      mocm       43: #ifdef DVB
1.6       mocm       44: #include "dvbdev.h"
                     45: #ifdef __DVB_PACK__
                     46: #include <ost/video.h>
                     47: #include <ost/audio.h>
                     48: #include <ost/demux.h>
                     49: #include <ost/dmx.h>
                     50: #include <ost/sec.h>
                     51: #include <ost/frontend.h>
                     52: #include <ost/ca.h>
1.11    ! mocm       53: #include <ost/osd.h>
1.6       mocm       54: #else
                     55: #include <linux/ost/video.h>
                     56: #include <linux/ost/audio.h>
                     57: #include <linux/ost/demux.h>
                     58: #include <linux/ost/dmx.h>
                     59: #include <linux/ost/sec.h>
                     60: #include <linux/ost/frontend.h>
                     61: #include <linux/ost/ca.h>
1.11    ! mocm       62: #include <linux/ost/osd.h>
1.6       mocm       63: #endif
                     64: 
                     65: #include "dvb_demux.h"
                     66: #include "dmxdev.h"
1.10      mocm       67: #include "dvb_formats.h"
                     68: #endif
1.1       cvs        69: // List of pci cards in the system
                     70: 
                     71: #include "cvdvtypes.h"
                     72: 
1.3       rjkm       73: #define DVERSION             "0.5.0"
1.1       cvs        74: #define SHORTDEVNAME        "ConvDVD"
                     75: #define MEDDEVNAME          "convergence DVD"
                     76: #define LONGDEVNAME         "convergence DVD Video Decoder"
                     77: #define LOGNAME             "convdvd"
1.6       mocm       78: #define NBBUF 8
                     79: 
                     80: 
                     81: #define VID_PAN_SCAN_PREF       0x01    /* Pan and Scan Display preferred */
                     82: #define VID_VERT_COMP_PREF      0x02    /* Vertical compression display preferred */
                     83: #define VID_VC_AND_PS_PREF      0x03    /* PanScan and vertical Compression if allowed */
                     84: #define VID_CENTRE_CUT_PREF     0x05    /* PanScan with zero vector */
                     85: 
1.1       cvs        86: 
                     87: // Character device definitions
                     88: // char dev name
                     89: #define CVDV_PROCNAME     "msc"        // Media Stream Consumer
                     90: // got to get another number
                     91: #define CVDV_MAJOR        200  // 0=dynamic assignment
                     92: 
                     93: // Author definitions
                     94: #define NAME                "Christian Wolff"
                     95: #define EMAIL               "scarabaeus@convergence.de"
                     96: #define COMPANY             "convergence integrated media GmbH"
                     97: #define AUTHOR              NAME " <" EMAIL "> " COMPANY
                     98: 
                     99: #define MAXDEV            1    // maximum number of cards, distance between minor devices
                    100: 
                    101: #define MINORNUM          (256/MAXDEV) // number of minor devices
                    102: 
                    103: #define NAVISIZE 1024          // size of one navi block
                    104: #define NAVIBUFFERSIZE NAVISIZE*10     // size of ten navi blocks
                    105: 
                    106: #define BLANK 0xFFFFFFFF
                    107: 
                    108: #define FIFO_MASK 1023
                    109: 
                    110: #define CCIR601Lines(system) (((system==NTSC) || (system==NTSC60) || (system==PALM) || (system==PALM60) || (system==PAL60))?525:625)
                    111: 
                    112: // default video mode
                    113: #define VIDEO_MODE PAL
                    114: //#define VIDEO_MODE NTSC
                    115: 
                    116: struct DRAMBlock {
                    117:        u32 start;              // start address of the block; (21 bit word address, 64 bit aligned)
                    118:        u32 length;             // length of the block (in 16 bit words)
                    119:        struct DRAMBlock *next; // chain link
                    120: };
                    121: 
                    122: struct CSS {
                    123:        u8 status;              // interrupt status from Register 0x0B0
                    124:        int ChallengeReady;     // 1 if challenge data valid
                    125:        u8 challenge[10];       // challenge data
                    126:        int ResponseReady;      // 1 if response data valid
                    127:        u8 response[5];         // response data
                    128:        int DiskKey;            // 1 if disk key extraction complete
                    129:        int TitleKey;           // 1 if title key decryption complete
                    130:        int Error;              // 1 if authentication or disc key extraction
                    131:        int TitleKeyDiff;       // 1 if title key different from previous
                    132: };
                    133: 
                    134: struct GOPHeader {
                    135:        int valid;              // 1: struct contains valid data
                    136:        int timecode;
                    137:        int closedgop;
                    138:        int brokenlink;
                    139: };
                    140: 
                    141: struct SequenceHeader {
                    142:        int valid;              // 1: struct contains valid data
                    143:        int hsize;
                    144:        int vsize;
                    145:        int aspectratio;
                    146:        int frameratecode;
                    147:        int bitrate;
                    148:        int vbvbuffersize;
                    149:        int constrained;
                    150: };
                    151: 
                    152: struct SequenceExtension {
                    153:        int valid;              // 1: struct contains valid data
                    154:        int profilelevel;
                    155:        int progressive;
                    156:        int chroma;
                    157:        int hsizeext;
                    158:        int vsizeext;
                    159:        int bitrateext;
                    160:        int vbvbuffersizeext;
                    161:        int lowdelay;
                    162:        int frextn;
                    163:        int frextd;
                    164: };
                    165: 
                    166: struct AudioMPEG {
                    167:        int present;            // true: MPEG audio stream present
                    168:        int MPEG2;              // 0:MPEG1 Audio
                    169:        int layer;              // 1..3 (I..III)
                    170:        int bitrate;            // 0=free, 32-448 kbps
                    171:        int samplefreq;         // 32,44,48 (44 eq. 44.1)
                    172:        int mode;               // 0=stereo 1=joint-stereo 2=dualchannel 3=single channel (just right channel)
                    173:        int modeext;            // Layer I&II: intensity stereo subbands  Layer III: bit 0=intensity stereo, bit 1=ms-stereo
                    174:        int copyright;          // true=copyrighted material
                    175:        int original;           // 0=copy true=original
                    176:        int emphasis;           // 0=no emph. 1=50/15usec 3=CCITT J.17
                    177: };
                    178: 
                    179: struct AudioAC3 {
                    180:        int present;            // 1: AC3 audio stream present
                    181:        int acmod;              // parameters from the AC3 documentation
                    182:        int bsmod;
                    183:        int dialnorm;
                    184:        int dialnorm2;
                    185:        int surmixlev;
                    186:        int mixlevel;
                    187:        int cmixlev;
                    188:        int mixlevel2;
                    189:        int fscod;
                    190:        int lfeon;
                    191:        int bsid;
                    192:        int dsurmod;
                    193:        int frmsizecod;
                    194:        int langcod;
                    195:        int langcod2;
                    196:        int timecod;
                    197:        int roomtyp;
                    198:        int timecod2;
                    199:        int roomtyp2;
                    200: };
                    201: 
                    202: struct AudioPCM {
                    203:        int present;            // 1: PCM audio stream present
                    204:        int audio_frm_num;
                    205:        int num_of_audio_ch;
                    206:        int Fs;
                    207:        int quantization;
                    208:        int emphasis;
                    209:        int mute_bit;
                    210: };
                    211: 
                    212: struct AudioParam {
                    213:        int valid;
                    214:        struct AudioMPEG mpeg;
                    215:        struct AudioAC3 ac3;
                    216:        struct AudioPCM pcm;
                    217: };
                    218: 
                    219: struct OSDPicture {            // all u32 pointers are 21 bit word addresses 
                    220:        int open;               // are the buffers initialized?
                    221:        int width;              // frame width
                    222:        int height;             // frame height
                    223:        int bpp;                // bit per pixel
                    224:        int evenfirst;          // first line is in even field
                    225:        int aspectratio;        // pixel aspect ratio: 11/aspectratio
                    226:        int oddheight;          // height of the odd field
                    227:        u32 oddmem;             // DRAM address of allocated memory
                    228:        u32 odddata;            // data (=header) pointer
                    229:        u32 oddpalette;         // pointer to palette inside data
                    230:        u32 oddbitmap;          // pointer to bitmap inside data
                    231:        u32 oddterm;            // pointer to termination header
                    232:        int evenheight;         // height of the even field
                    233:        u32 evenmem;            // DRAM address of allocated memory
                    234:        u32 evendata;           // data (=header) pointer
                    235:        u32 evenpalette;        // pointer to palette inside data
                    236:        u32 evenbitmap;         // pointer to bitmap inside data
                    237:        u32 eventerm;           // pointer to termination header
                    238: };
                    239: 
                    240: struct StreamInfo {
                    241:        int valid;              // 1: struct contains valid data
                    242:        int MPEG2;              // 0: MPEG1/ISO11172  1: MPEG2/ISO13818
                    243:        int hsize;              // overall hsize (hsize&hsizeext)
                    244:        int vsize;              // overall vsize (vsize&vsizeext)
                    245:        int bitrate;            // overall bitrate (bitrate&bitrateext)
                    246:        int vbvbuffersize;      // overall...
                    247:        struct GOPHeader gop;
                    248:        struct SequenceHeader sh;
                    249:        struct SequenceExtension se;
                    250:        struct AudioParam audio;
                    251: };
                    252: 
                    253: struct StreamSetup {           // user selected parameters for the stream playback
                    254:        stream_type streamtype; // what is the type of our input stream?
                    255:        audio_type audioselect; // 0=auto/unknown 1=MPEG 2=LPCM 3=AC3
                    256:        int videoID;            // stream ID of the video ES, -1 for any
                    257:        int audioID;            // stream ID of the audio ES, -1 for any
                    258:        int audioIDext;         // stream ID of the audio extension ES, -1 for none
                    259:        int SPDIFmode;          // 0:MPEG/AC3 data on digital S/PDIF out 1:IEC956 data on digital S/PDIF out
                    260: };
                    261: 
1.4       rjkm      262: #define MAX_PTS 256
1.1       cvs       263: 
                    264: typedef struct PTSRecord {
                    265:        int begin;
                    266:        int end;
                    267:        int size;
                    268:        u32 LastAddr;
                    269:        u32 AddrB[MAX_PTS];
                    270:        u32 AddrE[MAX_PTS];
                    271:        u32 PTS[MAX_PTS];
                    272: } PTSStorage;
                    273: 
1.7       mocm      274: #define DVB_DEVS_MAX 9
1.6       mocm      275: 
                    276: typedef struct dvb_devs_s {
                    277:         int num;  
                    278:         int tab[DVB_DEVS_MAX];
                    279:         int max_users[DVB_DEVS_MAX];
                    280:         int max_writers[DVB_DEVS_MAX];
                    281: } dvb_devs_t;
                    282: 
1.1       cvs       283: struct cvdv_cards {
1.10      mocm      284: #ifdef DVB
1.6       mocm      285:        struct dvb_device       dvb_dev;
1.10      mocm      286:        dvb_demux_t             demux;
                    287: #endif
1.1       cvs       288:        struct cvdv_cards *next;
                    289:        void *margi;
                    290:        struct bus_operations *bus;
                    291:        u_char scl;
                    292:        u_char sda;
                    293:        int i2c_addr;
                    294:        u32 VideoESSize;                
                    295:        u32 AudioESSize;                
                    296:        u32 VideoPESSize;               
                    297:        u32 DataDumpSize;               
                    298:        u32 AudioPESSize;               
                    299:        u32 NaviBankSize;               
                    300:        int currentAThread;
                    301:        int currentBThread;
                    302:        int currentType;
                    303:        u32 lengthB[NBBUF];
                    304:        u32 posB[NBBUF];
                    305:        u32 lengthA[NBBUF];
                    306:        u32 posA[NBBUF];
                    307:        ringbuffy rbuf;
                    308:        int use_ring;
                    309: 
1.8       mocm      310:        int nonblock;
1.1       cvs       311:        //  struct video_device   video;
                    312:        u8 *addr;
                    313:        unsigned int size;
                    314:        unsigned int minor;
                    315:        struct DRAMBlock *DRAMFirstBlock;
                    316:        u32 DRAMSize;
                    317:        struct OSDPicture OSD;
                    318:        int DMAABusy;           // Is the DMA A currently in use?
                    319:        int DMABBusy;           // Is the DMA B currently in use?
                    320:        int IntInstalled;       // is the card interrupt routine installed?
                    321:        int ChannelBuffersAllocated;    // Are the channel buffers for the decoder allocated?
                    322:        u32 VideoES;            // 21 bit word address of the allocated channel
                    323:        u32 AudioES;            // 21 bit word address of the allocated channel
                    324:        u32 VideoPES;           // 21 bit word address of the allocated channel
                    325:        u32 DataDump;           // 21 bit word address of the allocated channel
                    326:        u32 AudioPES;           // 21 bit word address of the allocated channel
                    327:        u32 NaviBank;           // 21 bit word address of the allocated channel
                    328:        int FrameBuffersAllocated;      // Are the frame buffers for the decoder allocated?
                    329:        u32 FrameStoreLuma1;    // 21 bit word address of the allocated frame
                    330:        u32 FrameStoreChroma1;  // 21 bit word address of the allocated frame
                    331:        u32 FrameStoreLuma2;    // 21 bit word address of the allocated frame
                    332:        u32 FrameStoreChroma2;  // 21 bit word address of the allocated frame
                    333:        u32 FrameStoreLumaB;    // 21 bit word address of the allocated frame
                    334:        u32 FrameStoreChromaB;  // 21 bit word address of the allocated frame
                    335:        int DecoderOpen;        // Is the Decoder initialized?
                    336:        u16 AuxFifo[FIFO_MASK + 1];     // Auxiliary Fifo Data
                    337:        int AuxFifoHead;        // Auxiliary Fifo Position
                    338:        int AuxFifoTail;        // Auxiliary Fifo Position
                    339:        u16 DataFifo[FIFO_MASK + 1];    // Data Fifo Data
                    340:        int DataFifoHead;       // Data Fifo Position
                    341:        int DataFifoTail;       // Data Fifo Position
                    342:        int FifoALast;          // last used thread of FIFO A
                    343:        int FifoBLast;          // last used thread of FIFO B
                    344:        videosystem videomode;  // current video output mode, PAL or NTSC
                    345:        struct StreamInfo stream;       // header information of the current stream
                    346:        struct StreamSetup setup;       // should be filled bevor sending data, but default is OK
                    347:        int AuxFifoExt;         // used by Aux FIFO parser
                    348:        int AuxFifoLayer;       //  "   "   "   "     "
                    349:        int AudioInitialized;   // Is the Audio set up?
                    350:        int AudioOldMode;       // remainder of the previous mode while trickmodes, or -1
1.6       mocm      351:        int open;       // is the 64017 initialized and the video out active?
1.1       cvs       352:        int closing;            // 1 if char device closed, but DMA still running
                    353:        int startingV;          // 1 if card is waiting for the Video ES buffer to fill up, to start the decoder
                    354:        int startingA;          // 1 if card is waiting for the Audio ES buffer to fill up, to start the decoder
                    355:        int startingDVDV;       // 1 if card is waiting for the Video ES buffer to fill up, to start the decoder
                    356:        int startingDVDA;       // 1 if card is waiting for the Audio ES buffer to fill up, to start the decoder
                    357:        int channelrun;         // 1 if channel has been started by the host
                    358:        u8 *channelA;           // Buffer for channel A
                    359:        int channelAthread;     // currently filled thread
                    360:        int channelApos;        // write position in buffer
                    361:        u8 *channelB;           // Buffer for channel B
                    362:        int channelBthread;     // currently filled thread
                    363:        int channelBpos;        // write position in buffer
                    364:        int fields;             // counter of video fields, debugging only
                    365:        struct CSS css;         // CSS data
                    366:        u32 NaviPackAddress;    // Read address of the Navi Pack Buffer
                    367:        wait_queue_head_t wqA;
                    368:        wait_queue_head_t wqB;
                    369:        int threadAthreads;
                    370:        u8 *threadA[NBBUF];
                    371:        u32 threadAsize;
                    372:        int threadBthreads;
                    373:        u8 *threadB[NBBUF];
                    374:        u32 threadBsize;
                    375:        u8 bt864reg[128];       // Bt864/865 register mirror
                    376:        u8 navibuffer[NAVIBUFFERSIZE];
                    377:        int navihead;
                    378:        int navitail;
                    379:        int intdecodestatus;
                    380:        int showvideo;
                    381:        int videodelay;
1.8       mocm      382:        int videodelay_last;
                    383:        int videoskip;
1.11    ! mocm      384:        int videoskip_last;
1.1       cvs       385:        int videosync;
1.8       mocm      386:        int videoslow;
                    387:        int videoslow_last;
1.11    ! mocm      388:        int videoffwd;
        !           389:        int videoffwd_last;
1.1       cvs       390:        PTSStorage VideoPTSStore;
                    391:        PTSStorage AudioPTSStore;
                    392:        u32 LastAddr;
                    393:        u32 VPTS;
                    394:        u32 oldVPTS;
                    395:        long VSCR;
                    396:        u32 APTS;
                    397:        u32 oldAPTS;
                    398:        long ASCR;
                    399:        long SyncTime;
                    400:        int paused;
                    401:        u16 lastvattr;
                    402:        u16 lastaattr;
                    403:        u8 reg07B;              // mirrors of write-only register
                    404:        u8 reg08F;
                    405:        u8 reg090;
                    406:        u8 reg091;
                    407:        u8 reg092;
                    408:        u8 reg093;
                    409:        u8 highlight[10];       // content of registers 1C0 thru 1C0, to be written after next BAV int.
                    410:        int highlight_valid;    // if 1
                    411:        int do_flush;           // if 1, send flush packet after last transfer done
1.6       mocm      412:        int hasZV;
                    413: #ifdef NOINT
                    414:        struct timer_list timer;
                    415:        spinlock_t timelock;
                    416: #endif
1.10      mocm      417: 
                    418: #ifdef DVB
1.6       mocm      419:         dvb_devs_t *dvb_devs;
                    420:         int users[DVB_DEVS_MAX];
                    421:         int writers[DVB_DEVS_MAX];
                    422: 
                    423:         dmxdev_t                dmxdev;
                    424:         boolean                 video_blank;
                    425:         struct videoStatus      videostate;
                    426:         struct audioStatus      audiostate;
1.10      mocm      427:        int                     dvb_registered;
                    428:        char                    demux_id[16];
                    429:        dmx_frontend_t          mem_frontend;
                    430:        p2p                     tsa;
                    431:        p2p                     tsv;
                    432: #endif
1.1       cvs       433: };
                    434: 
                    435: extern u8 FlushPacket[32];
                    436: 
                    437: extern struct cvdv_cards *first_card;
                    438: extern struct cvdv_cards *minorlist[MAXDEV];
                    439: 
                    440: void DecoderStreamReset(struct cvdv_cards *card);
                    441: 
                    442: void DecoderSetupReset(struct cvdv_cards *card);
                    443: 
                    444: void DecoderCSSReset(struct cvdv_cards *card);
                    445: 
                    446: void card_init(struct cvdv_cards *card, unsigned int minor);
                    447: 
                    448: #endif                         /* CARDBASE_H */

LinuxTV legacy CVS <linuxtv.org/cvs>