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