📄 unichrome.h
字号:
//// 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#ifndef DXR3PLAYER_UNICHROME_UNICHROME_H#define DXR3PLAYER_UNICHROME_UNICHROME_H//------------------------------------------------------------------------------#include "IO.h"#include "FIFO.h"#include "MPEGDecoder.h"#include "Mode.h"#include "PhysicalWindow.h"#include "sched/Thread.h"#include "types.h"//------------------------------------------------------------------------------namespace unichrome {//------------------------------------------------------------------------------class TVEncoder;class MemoryBlock;//------------------------------------------------------------------------------/** * The main class for the driver. * * The card's memory is laid out as follows: * * - the primary frame buffer of size FBSIZE, where FBSIZE is * (width*height*depth), where depth is usually for (32 bits) * - the secondary frame buffer of size FBSIZE * * if HQV is enabled: * - the primary V1 buffer of size VBSIZE, where VBSIZE is * (2 * width * height) for an aspect ratio of 4:3 * (2 * width * width) for an aspect ratio of 16:9 * - the secondary V1 buffer of size VBSIZE * - the SPU buffer of size SPUSIZE, where SPUSIZE is * (width * height) for an aspect ratio of 4:3 * (width * width) for an aspect ratio of 16:9 * * - the 4 MPEG buffers, each of size MPGSIZE, where MPGSIZE is * (VBSIZE/2) * 3/2 (each pixel occupies 1.5 bytes, 1 for * the luminance, 0.5 for the chroma) * */class Unichrome{public: /** * The structure describing CRT settings for some mode. */ struct CRTSettings { /** * Total number of pixels. */ size_t total; /** * Addressabble region. */ size_t addressable; /** * Start of blanking. */ size_t blankStart; /** * End of blanking. */ size_t blankEnd; /** * Start of synchronization */ size_t synchStart; /** * End of synchronization */ size_t synchEnd; };private: /** * Thread performing the frame flipping through the helper device driver. */ class FlipperThread : public sched::Thread { public: /** * Create the flipper thread, if the helper device can be *opened. */ static FlipperThread* create(); private: /** * The file descriptor for the helper device driver. */ int uchelperFD; /** * The field number to flip at or the last flip was performed * for. This is the "logical" field number, i.e. the one * without field compensation. */ size_t fieldNumber; /** * The field compensation. This will be added to flipField to * yield the "real" field to flip at. The two are handled * separately so that we could return the "logical" field * number for callers. */ ssize_t fieldCompensation; /** * The buffer offset to flip into view. */ size_t bufferOffset; /** * The time of the last flip. */ millis_t flipTime; private: /** * Construct the thread. */ FlipperThread(int uchelperFD); public: /** * Start the flipping. */ void startFlip(size_t fieldNo, ssize_t compensation, size_t offset); /** * Wait until the flipping started last time is finished. */ millis_t finishFlip(size_t& fieldNo); private: /** * Perform the operation requested. */ virtual void perform(); };public: /** * Check if the command regulator is busy. */ static bool isCommandRegulatorBusy(IO& io); /** * Wait for the 2D command regulator. * * @return if the waiting could be completed without having been interrupted */ static bool waitCommandRegulator(IO& io); /** * Check if the graphics engine is busy. */ static bool isGraphicsEngineBusy(IO& io); /** * Wait for the graphics engine to become idle. * * @return if the waiting could be completed without having been interrupted */ static bool waitGraphicsEngine(IO& io);private: /** * Wait until the given function returns false. * * @return if the waiting could be completed without having been interrupted */ static bool wait(IO& io, bool (*checkFn)(IO& io), const char* name, size_t busyCycles, size_t sleepCycles, millis_t sleepLength); /** * The I/O handler. */ IO io; /** * The last memory block allocated from this board. */ MemoryBlock* lastMemoryBlock; /** * The command FIFO */ FIFO fifo; /** * Our TV encoder. */ TVEncoder* tvEncoder; /** * The flipper thread. */ FlipperThread* flipperThread; /** * The current mode. */ Mode currentMode; /** * The index of the current mode info. */ size_t currentModeIndex; /** * The MPEG decoder. */ MPEGDecoder mpegDecoder; /** * Indicate if HQV is in use. */ bool useHQV; /** * The offsets of the V1 buffers (only in case of HQV). */ size_t v1BufferOffsets[2]; /** * The number of the V1 buffer to be displayed next (only for HQV). */ size_t nextV1Buffer; /** * Indicate if the result of a V1 flip has not been queried yet * (only for HQV). */ bool v1FlipPending; /** * Offset of the SPU buffer. */ size_t spuOffset; /** * The width of the SPU buffer. */ size_t spuWidth; /** * The height of the SPU buffer. */ size_t spuHeight; /** * The states of some interesting registers. */ struct { /** * The background colour/source colour key * (Register::BGCOLOR and Register::SRCCOLORKEY) */ uint32_t bgColor; /** * The keycontrol (Register::KEYCONTROL); */ uint32_t keyControl; /** * The source base offset (Register::SRCBASE) */ uint32_t sourceBase; /** * The destination base offset (Register::DSTBASE) */ uint32_t destinationBase; /** * The source and destination pitch (Register::PITCH) */ uint32_t pitch; } state; /** * The frame buffer window. */ PhysicalWindow frameBufferWindow;public: /** * Construct the driver. */ Unichrome(); /** * Destroy the driver. */ ~Unichrome(); /** * Get the size of the card's memory. */ size_t getMemorySize(); /** * Get the window to the frame buffer. */ Window& getFrameBufferWindow(); /** * Allocate a memory block of the given size. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -