⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fifo.cc

📁 Linux下比较早的基于命令行的DVD播放器
💻 CC
字号:
//// Copyright (c) 2004 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card, but now handles other// hardware as well. These files contain a (mostly) user-space driver // for the Unichrome board found on Via's EPIA motherboards.//// The information for implementing this driver has been gathered// from the following sources://// - The DirectFB Unichrome driver//   Copyright (c) 2003 Andreas Robinson, All rights reserved.//// - Andreas Robinson's MPEG-2 decoder for the Unichrome board.//   Copyright (c) 2003 Andreas Robinson, All rights reserved.//// - Via's Unichrome Framebuffer driver//   Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.//   Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA//------------------------------------------------------------------------------#include "FIFO.h"#include "IO.h"#include "Register.h"#include "Constant.h"#include "Unichrome.h"#include "sched/Scheduler.h"#include <cassert>//------------------------------------------------------------------------------using unichrome::FIFO;using sched::Scheduler;//------------------------------------------------------------------------------FIFO::FIFO(IO& io) :    io(io),    buffer(new uint32_t[FIFO_SIZE]),    nextIndex(0),    numUsed(0){}//------------------------------------------------------------------------------FIFO::~FIFO(){    delete[] buffer;}//------------------------------------------------------------------------------void FIFO::flush(){    pad();    if (!waitCommandRegulator()) return;    bool check2DCommand = false;    for(size_t index = 0; index<nextIndex; ) {        uint32_t command = buffer[index++];        if (command==Constant::CMD_HEADER2) {            size_t subCommand = buffer[index++];            check2DCommand = subCommand!=Constant::CMD_SUB_ADDR0;            io.reg(Register::TRANSET) = subCommand;        } else if (check2DCommand &&                    (command&Constant::MASK_HEADER1)==Constant::CMD_HEADER1)         {            size_t address = (command & Constant::MASK_ADDRESS)<<2;            io.reg(address) = buffer[index++];        } else if ((command&Constant::MASK_FIRE)==Constant::CMD_FIRE) {            io.reg(Register::TRANSPACE) = command;            if (index<nextIndex &&                 (buffer[index]&Constant::MASK_FIRE)==Constant::CMD_FIRE)             {                ++index;            }            if (index<nextIndex &&                 (buffer[index]&Constant::MASK_B)==Constant::CMD_B)             {                check2DCommand = true;            }        } else {            io.reg(Register::TRANSPACE) = command;        }    }    nextIndex = 0;    numUsed = 0;}//------------------------------------------------------------------------------void FIFO::prepare(size_t numWords){    size_t newUsed = nextIndex + numWords;    if ((newUsed+8)>FIFO_SIZE) {        flush();        newUsed = nextIndex + numWords;    }    if (newUsed>numUsed) numUsed = newUsed;}//------------------------------------------------------------------------------void FIFO::add(size_t command){    assert(nextIndex<FIFO_SIZE);    buffer[nextIndex++] = command;    if (nextIndex>numUsed) numUsed = nextIndex;}//------------------------------------------------------------------------------void FIFO::addHeader(uint32_t param){    add(Constant::CMD_HEADER2);    add(param);}//------------------------------------------------------------------------------void FIFO::add2D(size_t reg, uint32_t data){    add( (reg>>2) | Constant::CMD_HEADER1 );    add(data);}//------------------------------------------------------------------------------void FIFO::pad(){    size_t remainder = nextIndex & 0x7;    if (remainder<2) return;    size_t padSize = 8-remainder;    if (padSize<=2) padSize += 8;        add(Constant::CMD_HEADER2);    add(Constant::CMD_PARATYPE_NOTTEX);    for(size_t i = 2; i<padSize; ++i) {        add(Constant::CMD_DUMMY);    }}//------------------------------------------------------------------------------bool FIFO::waitCommandRegulator(){    return Unichrome::waitCommandRegulator(io);}//------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -