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