From d257f0701d55e76ea55321ad3ae9a6fb5866792c Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 26 Mar 2006 17:03:18 +0000 Subject: [PATCH] Portability --- Makefile | 7 ++-- main.cc | 6 ++- mtd.cc | 88 --------------------------------------- mtd.h | 46 +++------------------ mtdmvp.cc | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ mtdmvp.h | 78 +++++++++++++++++++++++++++++++++++ mtdwin.cc | 50 +++++++++++++++++++++++ mtdwin.h | 41 +++++++++++++++++++ 8 files changed, 303 insertions(+), 133 deletions(-) create mode 100644 mtdmvp.cc create mode 100644 mtdmvp.h create mode 100644 mtdwin.cc create mode 100644 mtdwin.h diff --git a/Makefile b/Makefile index a731f69..eef9158 100644 --- a/Makefile +++ b/Makefile @@ -25,11 +25,12 @@ OBJECTS1 = main.o command.o log.o tcp.o dsock.o thread.o timers.o i18n.o OBJECTS2 = remote.o led.o mtd.o video.o audio.o osd.o surface.o \ remotemvp.o remotewin.o \ - audiomvp.o audiowin.o \ + ledmvp.o ledwin.o \ + mtdmvp.o mtdwin.o \ videomvp.o videowin.o \ + audiomvp.o audiowin.o \ osdmvp.o osdwin.o \ - surfacemvp.o surfacewin.o \ - ledmvp.o ledwin.o + surfacemvp.o surfacewin.o OBJECTS = $(OBJECTS1) $(OBJECTS2) diff --git a/main.cc b/main.cc index e9024a6..53c629b 100644 --- a/main.cc +++ b/main.cc @@ -27,19 +27,20 @@ #include "defines.h" #include "log.h" -#include "mtd.h" #include "timers.h" #include "vdr.h" #include "viewman.h" #include "command.h" #ifdef WIN32 + #include "mtdwin.h" #include "remotewin.h" #include "ledwin.h" #include "osdwin.h" #include "audiowin.h" #include "videowin.h" #else + #include "mtdmvp.h" #include "remotemvp.h" #include "ledmvp.h" #include "osdmvp.h" @@ -72,16 +73,17 @@ int main(int argc, char** argv) // Init global vars ------------------------------------------------------------------------------------------------ logger = new Log(); - mtd = new Mtd(); timers = new Timers(); vdr = new VDR(); #ifdef WIN32 + mtd = new MtdWin(); remote = new RemoteWin(); led = new LedWin(); osd = new OsdWin(); audio = new AudioWin(); video = new VideoWin(); #else + mtd = new MtdMVP(); remote = new RemoteMVP(); led = new LedMVP(); osd = new OsdMVP(); diff --git a/mtd.cc b/mtd.cc index 100097e..f4434df 100644 --- a/mtd.cc +++ b/mtd.cc @@ -26,7 +26,6 @@ Mtd::Mtd() { if (instance) return; instance = this; - initted = 0; } Mtd::~Mtd() @@ -38,90 +37,3 @@ Mtd* Mtd::getInstance() { return instance; } - -int Mtd::init(char* device) -{ - if (initted) return 0; - initted = 1; - - int fd; - - if ((fd = open(device, O_RDONLY)) < 0) - { - initted = 0; - return 0; - } - - if (read(fd, data, 8192) < 8192) - { - initted = 0; - return 0; - } - - close(fd); - - logit(); - - return 1; -} - -int Mtd::shutdown() -{ - if (!initted) return 0; - initted = 0; - return 1; -} - -short Mtd::getPALorNTSC() -{ - return data[2119]; -} - -short Mtd::getAspect() -{ - return data[2125]; -} - -short Mtd::getFlicker() -{ - return data[2124]; -} - -short Mtd::getBootLogoOutput() -{ - return data[2116]; -} - -short Mtd::getBootLogoDisplayVideoLeft() -{ - return data[2120]; -} - -short Mtd::getBootLogoDisplayVideoUpper() -{ - return data[2121]; -} - -short Mtd::getBootLogoDisplayVideoWidth() -{ - return data[2122]; -} - -short Mtd::getBootLogoDisplayVideoHeight() -{ - return data[2123]; -} - -void Mtd::logit() -{ - Log* logger = Log::getInstance(); - - logger->log("MTD", Log::DEBUG, "Mode: %i", getPALorNTSC()); - logger->log("MTD", Log::DEBUG, "Aspect: %i", getAspect()); - logger->log("MTD", Log::DEBUG, "Flicker: %i", getFlicker()); - logger->log("MTD", Log::DEBUG, "Bootlogo output: %i", getBootLogoOutput()); - logger->log("MTD", Log::DEBUG, "Bootlogo display video left: %i", getBootLogoDisplayVideoLeft()); - logger->log("MTD", Log::DEBUG, "Bootlogo display video upper: %i", getBootLogoDisplayVideoUpper()); - logger->log("MTD", Log::DEBUG, "Bootlogo display video width: %i", getBootLogoDisplayVideoWidth()); - logger->log("MTD", Log::DEBUG, "Bootlogo display video height: %i", getBootLogoDisplayVideoHeight()); -} diff --git a/mtd.h b/mtd.h index aca0b9f..0ab7749 100644 --- a/mtd.h +++ b/mtd.h @@ -18,59 +18,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// Information for this class taken from the mvpmc project - thanks - -/* - discussion on short positions: - http://www.shspvr.com/smf/index.php?topic=3765.30 - -It says: -1 = NTSC/composite -2 = PAL/Scart -3 = PAL/Composite - -But with PAL/Scart/RGB I get a value of 1 - -So, am assuming: -0 = NTSC / composite -1 = PAL / scart rgb -2 = PAL / scart composite -*/ - #ifndef MTD_H #define MTD_H -#include -#include - -#include "log.h" +#include class Mtd { public: Mtd(); - ~Mtd(); + virtual ~Mtd(); static Mtd* getInstance(); - int init(char* device); - int shutdown(); + virtual int init(char* device)=0; + virtual int shutdown()=0; - short getPALorNTSC(); - short getAspect(); - short getFlicker(); - short getBootLogoOutput(); - short getBootLogoDisplayVideoLeft(); - short getBootLogoDisplayVideoUpper(); - short getBootLogoDisplayVideoWidth(); - short getBootLogoDisplayVideoHeight(); + virtual short getPALorNTSC()=0; - void logit(); - - private: + protected: static Mtd* instance; - int initted; - - short data[4096]; }; #endif diff --git a/mtdmvp.cc b/mtdmvp.cc new file mode 100644 index 0000000..c801710 --- /dev/null +++ b/mtdmvp.cc @@ -0,0 +1,120 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "mtdmvp.h" + +MtdMVP::MtdMVP() +{ + if (instance) return; + initted = 0; +} + +MtdMVP::~MtdMVP() +{ +} + +int MtdMVP::init(char* device) +{ + if (initted) return 0; + initted = 1; + + int fd; + + if ((fd = open(device, O_RDONLY)) < 0) + { + initted = 0; + return 0; + } + + if (read(fd, data, 8192) < 8192) + { + initted = 0; + return 0; + } + + close(fd); + + //logit(); + + return 1; +} + +int MtdMVP::shutdown() +{ + if (!initted) return 0; + initted = 0; + return 1; +} + +short MtdMVP::getPALorNTSC() +{ + return data[2119]; +} + +/* +short MtdMVP::getAspect() +{ + return data[2125]; +} + +short MtdMVP::getFlicker() +{ + return data[2124]; +} + +short MtdMVP::getBootLogoOutput() +{ + return data[2116]; +} + +short MtdMVP::getBootLogoDisplayVideoLeft() +{ + return data[2120]; +} + +short MtdMVP::getBootLogoDisplayVideoUpper() +{ + return data[2121]; +} + +short MtdMVP::getBootLogoDisplayVideoWidth() +{ + return data[2122]; +} + +short MtdMVP::getBootLogoDisplayVideoHeight() +{ + return data[2123]; +} + +void MtdMVP::logit() +{ + Log* logger = Log::getInstance(); + + logger->log("MTD", Log::DEBUG, "Mode: %i", getPALorNTSC()); + logger->log("MTD", Log::DEBUG, "Aspect: %i", getAspect()); + logger->log("MTD", Log::DEBUG, "Flicker: %i", getFlicker()); + logger->log("MTD", Log::DEBUG, "Bootlogo output: %i", getBootLogoOutput()); + logger->log("MTD", Log::DEBUG, "Bootlogo display video left: %i", getBootLogoDisplayVideoLeft()); + logger->log("MTD", Log::DEBUG, "Bootlogo display video upper: %i", getBootLogoDisplayVideoUpper()); + logger->log("MTD", Log::DEBUG, "Bootlogo display video width: %i", getBootLogoDisplayVideoWidth()); + logger->log("MTD", Log::DEBUG, "Bootlogo display video height: %i", getBootLogoDisplayVideoHeight()); +} +*/ diff --git a/mtdmvp.h b/mtdmvp.h new file mode 100644 index 0000000..8b110d3 --- /dev/null +++ b/mtdmvp.h @@ -0,0 +1,78 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +// Information for this class taken from the mvpmc project - thanks + +/* + discussion on short positions: + http://www.shspvr.com/smf/index.php?topic=3765.30 + +It says: +1 = NTSC/composite +2 = PAL/Scart +3 = PAL/Composite + +But with PAL/Scart/RGB I get a value of 1 + +So, am assuming: +0 = NTSC / composite +1 = PAL / scart rgb +2 = PAL / scart composite +*/ + +#ifndef MTDMVP_H +#define MTDMVP_H + +#include +#include + +#include "log.h" +#include "mtd.h" + +class MtdMVP : public Mtd +{ + public: + MtdMVP(); + ~MtdMVP(); + + int init(char* device); + int shutdown(); + + short getPALorNTSC(); + + /* + short getAspect(); + short getFlicker(); + short getBootLogoOutput(); + short getBootLogoDisplayVideoLeft(); + short getBootLogoDisplayVideoUpper(); + short getBootLogoDisplayVideoWidth(); + short getBootLogoDisplayVideoHeight(); + + void logit(); + */ + + private: + int initted; + + short data[4096]; +}; + +#endif diff --git a/mtdwin.cc b/mtdwin.cc new file mode 100644 index 0000000..0c7e338 --- /dev/null +++ b/mtdwin.cc @@ -0,0 +1,50 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "mtdwin.h" + +MtdWin::MtdWin() +{ + if (instance) return; + initted = 0; +} + +MtdWin::~MtdWin() +{ +} + +int MtdWin::init(char* device) +{ + if (initted) return 0; + initted = 1; + return 1; +} + +int MtdWin::shutdown() +{ + if (!initted) return 0; + initted = 0; + return 1; +} + +short MtdWin::getPALorNTSC() +{ + return 0; +} diff --git a/mtdwin.h b/mtdwin.h new file mode 100644 index 0000000..4a6086e --- /dev/null +++ b/mtdwin.h @@ -0,0 +1,41 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef MTDWIN_H +#define MTDWIN_H + +#include "mtd.h" + +class MtdWin : public Mtd +{ + public: + MtdWin(); + ~MtdWin(); + + int init(char* device); + int shutdown(); + + short getPALorNTSC(); + + private: + int initted; +}; + +#endif -- 2.39.5