📄 decoder.c
字号:
if (card->intdecodestatus) { // now running //DecoderSetVideoPanic(card, 1, 3); // video panic at 3 pictures card->showvideo = 1; } else { // now stopped if (card->closing) { card->closing = 0; CloseCard(card); } } } if (intr[1] & 0x10) { // Begin Active Video if (card->highlight_valid) { for (i = 0; i < 10; i++) DecoderWriteByte(card, 0x1C0 + i, card->highlight[i]); card->highlight_valid = 0; } } if (intr[1] & 0x08) { // SPU Start Code Detected MDEBUG(0, ": Int - SPU Start Code Detected\n"); } if (intr[1] & 0x04) { // SCR compare audio MDEBUG(0, ": Int - SCR compare audio\n"); DecoderDelByte(card, 0x013, 0x01); AudioStart(card); } if (intr[2] & 0x20) { // DSI PES data ready DecoderReadNavipack(card); } if (intr[2] & 0x06) { // Audio / Video PES data ready ReadPESHeaders(card); } if (intr[3] & 0x40) { // CSS card->css.status = DecoderReadByte(card, 0x0B0); if (card->css.status&0x01) card->css.ChallengeReady = 1; // challenge ready if (card->css.status&0x02) card->css.ResponseReady = 1; // response ready if (card->css.status&0x04) card->css.DiskKey = 1; // Disk key ready if (card->css.status&0x08) card->css.Error = 1; // Disk key error if (card->css.status&0x10) card->css.TitleKey = 1; // Title key ready if (card->css.status&0x20) card->css.TitleKeyDiff = 1; // Title key error } if (intr[3] & 0x30) { // Audio/Video ES channel buffer underflow MDEBUG(1,": Int - ES channel buffer underflow\n"); if (card->closing) { card->closing = 0; CloseCard(card); } } if (intr[4] & 0x10 ) { // SPU decode error MDEBUG(1,": Int - SPU decode error: (1CA)=0x%02X\n", DecoderReadByte(card, 0x1CA)); DecoderDelByte(card, 0x1A0, 0x01); // SPU decode stop DecoderSetByte(card, 0x1A0, 0x01); // SPU decode start } // Audio / Video Syncronisation if (card->videosync && !card->videoskip && !card->videodelay) { SCR_base = DecoderReadSCR(card, 0x009); SCR_compareV = DecoderReadSCR(card, 0x00D); if (intr[1] & 0x02) { // picture start code detected DecoderMaskByte(card, 0x011, 0x03, 0x01); // Set SCR compare/capture mode to capture DecoderSetByte(card, 0x11, 0x04); // Set "capture on picture start" if (intr[1] & 0x01) { // audio sync code detected DecoderSetByte(card, 0x11, 0x08); // Set "capture on audio sync code" } VideoAddr = DecoderReadRWAddr(card,0x080); if (PTSGetPTS(&card->VideoPTSStore, VideoAddr, &PTS)) { card->oldVPTS = card->VPTS; card->VPTS = PTS; card->VSCR = ((long)SCR_compareV - (long)PTS) / 2;// card->VideoTime = ISRTime; } } else if (intr[1] & 0x01) { // audio sync code detected DecoderMaskByte(card, 0x011, 0x03, 0x01); // Set SCR compare/capture mode to capture DecoderSetByte(card, 0x11, 0x08); // Set "capture on audio sync code" AudioAddr = DecoderReadRWAddr(card,0x083); if (PTSGetPTS(&card->AudioPTSStore, AudioAddr, &PTS)) { card->oldAPTS = card->APTS; card->APTS = PTS; card->ASCR = ((long)SCR_compareV - (long)PTS) / 2; } else { card->ASCR = 0x7FFFFFFF; } if (card->VSCR != 0x7FFFFFFF) { if (card->ASCR != 0x7FFFFFFF) { DeltaSyncTime = ISRTime - card->SyncTime; card->SyncTime = ISRTime; // Calculate Audio and Video SCR difference Offset = (card->ASCR - card->VSCR - (10 * 736)) / 736; // if the APTS and SCR are off update SCR to keep SubPic synced if ((SCR_compareV > card->APTS) || ((card->APTS - SCR_compareV) > 10000)) { Offset = 0; SetSCR(card, card->APTS); } // if more than 3 frames away if ((Offset > 3) || (Offset < -3)) { if (Offset > 0 ) { card->videodelay = 0; if (Offset < 100) { if (Offset < 10) { card->videodelay = 1; } else { card->videodelay = Offset / 2; if (card->videodelay > 20) { card->videodelay = 20; } } MDEBUG(0,": <<< Pausing %d\n", card->videodelay); } else { } } else { card->videoskip = 0; if (Offset > -100) { if (Offset < -10) { card->videoskip = 10; } else { card->videoskip = 3; } MDEBUG(0, ": >>> FForward %d\n", card->videoskip); } } } else { } card->VSCR = 0x7FFFFFFF; } } } } } DecoderWriteByte(card, 0x006, 0x01); // Clear Interrupt Pin}// Enable the IRQ Masksvoid L64021InstallIntr(struct cvdv_cards *card) { u8 data; data=0; data |= 0x80; // new field data |= 0x40; // audio sync recovery data |= 0x20; // SPU SCR compare // data |= 0x10; // SDRAM Transfer Done // data |= 0x08; // Sequence End Code Detect data |= 0x04; // First Slice Start Code data |= 0x02; // Aux/User Data Fifo data |= 0x01; // decode status DecoderWriteByte(card, 0x000, (~data) & 0xFF); data = 0; // data |= 0x80; // SCR compare // data |= 0x40; // SCR Overflow // data |= 0x20; // Begin Vertical Blank data |= 0x10; // Begin Active Video data |= 0x08; // SPU Start Code Detected data |= 0x04; // SCR compare audio data |= 0x02; // picture start code detected data |= 0x01; // audio sync code detected DecoderWriteByte(card, 0x001, (~data) & 0xFF); data = 0; // data |= 0x80; // DTS video event // data |= 0x40; // DTS audio event data |= 0x20; // DSI PES data ready // data |= 0x10; // Seq end code in video channel data |= 0x08; // SPU PES data ready data |= 0x04; // Video PES data ready data |= 0x02; // Audio PES data ready // data |= 0x01; // Pack data ready DecoderWriteByte(card, 0x002, (~data) & 0xFF); data = 0; // data |= 0x80; // Reserved data |= 0x40; // CSS data |= 0x20; // Video ES channel buffer underflow data |= 0x10; // Audio ES channel buffer underflow // data |= 0x08; // Data Dump channel PES data ready data |= 0x04; // SPU channel buffer overflow //data |= 0x02; // Video ES channel buffer overflow //data |= 0x01; // Audio ES channel buffer overflow DecoderWriteByte(card, 0x003, (~data) & 0xFF); data = 0;// data |= 0x80; // S/PDIF channel buffer underflow // data |= 0x40; // packet error // data |= 0x20; // reserved data |= 0x10; // SPU decode error// data |= 0x08; // Audio Sync error// data |= 0x04; // Audio CRC or illegal bit error// data |= 0x02; // context error// data |= 0x01; // VLC or Run length error DecoderWriteByte(card, 0x004, (~data) & 0xFF); card->IntInstalled = 1;}int L64021RemoveIntr(struct cvdv_cards *card) { // Disable the IRQ Masks DecoderWriteByte(card, 0x000, 0xFF); // No ints DecoderWriteByte(card, 0x001, 0xFF); // No ints DecoderWriteByte(card, 0x002, 0xFF); // No ints DecoderWriteByte(card, 0x003, 0xFF); // No ints DecoderWriteByte(card, 0x004, 0xFF); // No ints card->IntInstalled = 0; return 0;}int L64021Reset(struct cvdv_cards *card) { L64021RemoveIntr(card); // Stop interrupts // Reset MDEBUG(1, ": L64021 Software reset...\n"); //DecoderSetByte(card, 0x007, 0x20); // reset on DecoderMaskByte(card, 0x007, 0xE2, 0xE2); // reset on while (!(DecoderReadByte(card, 0x007) & 0x02)) ; // wait until reset is done //DecoderDelByte(card, 0x007, 0x20); // reset off DecoderMaskByte(card, 0x007, 0xE2, 0xC2); // reset off MDEBUG(1, ": L64021 Software reset done.\n"); DecoderStopChannel(card); DecoderStopDecode(card); DecoderStreamReset(card); DecoderSetupReset(card); printk(KERN_INFO LOGNAME ": L64021 Rev. 0x%02X reset successfully.\n", DecoderReadByte(card, 0x0F5)); return 0;}int L64021Setup(struct cvdv_cards *card) { MDEBUG(1, ": -- L64021Setup\n"); DecoderWriteByte(card, 0x0C1, 0x88); // switch (card->videomode) { case NTSC: // NTSC M, N. America, Taiwan, Japan DecoderMaskByte(card, 0x122, 0x03, 0x01); // Television Standard: NTSC /* Default values: DecoderWriteByte(card, 0x116, 90); // Main Reads per Line DecoderWriteByte(card, 0x11A, 4); // Vline Count Init DecoderWriteByte(card, 0x11C, 0x13); // Pixel State Reset Value / BT.656 Mode / Sync Active Low DecoderWriteByte(card, 0x129, 23); // Start- and End Row DecoderWriteByte(card, 0x12A, 262 & 0xFF); DecoderWriteByte(card, 0x12B, (262>>4)&0x70); DecoderWriteByte(card, 0x12C, 244 & 0xFF); // Start- and End Column DecoderWriteByte(card, 0x12D, 1683 & 0xFF); DecoderWriteByte(card, 0x12E, ((1683>>4)&0x70)|((244>>8)&0x07)); DecoderWriteByte(card, 0x132, 240 & 0xFF); // SAV Column DecoderWriteByte(card, 0x133, 1684 & 0xFF); // EAV Column DecoderWriteByte(card, 0x134, ((1684>>4)&0x70)|((240>>8)&0x07)); DecoderWriteByte(card, 0x12F, (21&0x1F)|((262>>3)&0x20)|(1<<6)|((265>>1)&0x80)); // VCode Zero... DecoderWriteByte(card, 0x130, 262&0xFF); // ... and VCode Even DecoderWriteByte(card, 0x131, 265&0xFF); // ... and FCode */ break; case PAL: // PAL-B, D, G, H, I, Europe, Asia DecoderMaskByte(card, 0x122, 0x03, 0x02); // Television Standard: PAL /* Default values: DecoderWriteByte(card, 0x116, 90); // Main Reads per Line DecoderWriteByte(card, 0x11A, 1); // Vline Count Init DecoderWriteByte(card, 0x11C, 0x13); // Pixel State Reset Value / BT.656 Mode / Sync Active Low DecoderWriteByte(card, 0x129, 23); // Start- and End Row DecoderWriteByte(card, 0x12A, 310 & 0xFF); DecoderWriteByte(card, 0x12B, (310>>4)&0x70); DecoderWriteByte(card, 0x12C, 264 & 0xFF); // Start- and End Column DecoderWriteByte(card, 0x12D, 1703 & 0xFF); DecoderWriteByte(card, 0x12E, ((1703>>4)&0x70)|((264>>8)&0x07)); DecoderWriteByte(card, 0x132, 260 & 0xFF); // SAV Column DecoderWriteByte(card, 0x133, 1704 & 0xFF); // EAV Column DecoderWriteByte(card, 0x134, ((1704>>4)&0x70)|((260>>8)&0x07)); DecoderWriteByte(card, 0x12F, (21&0x1F)|((310>>3)&0x20)|(0<<6)|((312>>1)&0x80)); // VCode Zero... DecoderWriteByte(card, 0x130, 310&0xFF); // ... and VCode Even DecoderWriteByte(card, 0x131, 312&0xFF); // ... and FCode */ break; case PAL60: // PAL 60Hz case NTSC60: // NTSC 60Hz, USA HDTV case PALM: // PAL-M normal, Brazil case PALM60: // PAL-M HDTV, Brazil case PALN: // PAL-N, Uruguay, Paraguay case PALNc: // PAL-Nc, Argentinia default: // TODO: set mode according to other standards DecoderMaskByte(card, 0x122, 0x03, 0x00); // Television Standard: User programmed DecoderWriteByte(card, 0x116, 90); // Main Reads per Line DecoderWriteByte(card, 0x11A, 1); // Vline Count Init DecoderWriteByte(card, 0x11C, 0x13); // Pixel State Reset Value / BT.656 Mode / Sync Active Low DecoderWriteByte(card, 0x129, 23); // Start- and End Row DecoderWriteByte(card, 0x12A, 310 & 0xFF); DecoderWriteByte(card, 0x12B, (310>>4)&0x70); DecoderWriteByte(card, 0x12C, 264 & 0xFF); // Start- and End Column DecoderWriteByte(card, 0x12D, 1703 & 0xFF); DecoderWriteByte(card, 0x12E, ((1703>>4)&0x70)|((264>>8)&0x07)); DecoderWriteByte(card, 0x132, 260 & 0xFF); // SAV Column DecoderWriteByte(card, 0x133, 1704 & 0xFF); // EAV Column DecoderWriteByte(card, 0x134, ((1704>>4)&0x70)|((260>>8)&0x07)); DecoderWriteByte(card, 0x12F, (21&0x1F)|((310>>3)&0x20)|(0<<6)|((312>>1)&0x80)); // VCode Zero... DecoderWriteByte(card, 0x130, 310&0xFF); // ... and VCode Even DecoderWriteByte(card, 0x131, 312&0xFF); // ... and FCode break; } DecoderWriteByte(card, 0x045, 0x00); // disable compares and panic mode DecoderWriteByte(card, 0x094, 0x00); // disable TOS Detect DecoderMaskByte(card, 0x109, 0x30, 0x00); // Display Override off, don't change OSD, Background DecoderWriteByte(card, 0x112, 0x00); // Disable Horizontal 2:1 Filter DecoderWriteByte(card, 0x113, 0x14); // FreezeMode 1 / 3:2 Pulldown / Repeat First Field / Top Field First DecoderWriteByte(card, 0x114, ( 5 <<3)|( 0 <<1)|( 0 <<2)|( 1 <<7)); // VideoMode/FilterEnable/FilterAB/FieldSyncEnable DecoderWriteByte(card, 0x115, 0); // Horizontal Filter Scale DecoderWriteByte(card, 0x117, 0x80); // Automatic Field Inversion Correction// DecoderWriteByte(card, 0x117, 0x00); // no Automatic Field Inversion Correction DecoderWriteByte(card, 0x118, 0); // Horizontal Pan and Scan Word Offset (signed) DecoderWriteByte(card, 0x119, 0); // Vertical Pan and Scan Line Offset DecoderWriteByte(card, 0x11B, 0x00); // Override Picture Width// if (0) { // letterbox// DecoderWriteByte(card, 0x114, (DecoderReadByte(card, 0x114) & ~0x78) | 0x40); // mode 8// DecoderWriteByte(card, 0x129, 0x35);// DecoderWriteByte(card, 0x12A, 0xE7);// DecoderWriteByte(card, 0x114, DecoderReadByte(card, 0x114) & ~0x77); // ???// } else {// if (0) { // MPEG-1// DecoderWriteByte(card, 0x114, (DecoderReadByte(card, 0x114) & ~0x78) | 0x10); // mode 2// } else { // MPEG-2// DecoderWriteByte(card, 0x114, (DecoderReadByte(card, 0x114) & ~0x78) | 0x28); // mode 5// }// } L64021InstallIntr(card); // Set the interrupt masks, again return 0;}int L64021Init(struct cvdv_cards *card) {MDEBUG(1, ": -- L64021Init\n"); L64021Reset(card); L64021Setup(card); VideoSetBackground(card, 1, 0, 0, 0); // black DecoderWriteByte(card, 0x135, 0x01); // Enable Video Out, Disable SPU Mix DecoderWriteByte(card,0x11C,0x13); // Pixel State Reset Value / BT.656 Mode / Sync Active Low L64021InstallIntr(card); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -