Annotation of margi2/cardbase.h, revision 1.15

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