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