From 5fd2dd4835fab0ca4ed1a0cda381e17ee2901f35 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 18 Sep 2005 20:02:36 +0000 Subject: [PATCH] New widescreen mode --- command.cc | 85 ++++++++++++++++++++----------- command.h | 1 + demuxer.cc | 6 +-- demuxer.h | 3 +- video.cc | 72 ++++++++++++++++----------- video.h | 15 +++--- voptions.cc | 124 +++++++++++++++++++++------------------------- voptions.h | 2 +- vrecordinglist.cc | 13 +++-- 9 files changed, 179 insertions(+), 142 deletions(-) diff --git a/command.cc b/command.cc index 5455c9a..16cb7b1 100644 --- a/command.cc +++ b/command.cc @@ -99,20 +99,20 @@ void Command::run() viewman->removeView(v); // Wallpaper - VWallpaper* w = new VWallpaper(); + wallpaper = new VWallpaper(); if (screenSize == Video::PAL) { logger->log("Command", Log::DEBUG, "PAL wallpaper selected"); - w->init("/wallpaperPAL.jpg"); + wallpaper->init("/wallpaperPAL.jpg"); } else { logger->log("Command", Log::DEBUG, "NTSC wallpaper selected"); - w->init("/wallpaperNTSC.jpg"); + wallpaper->init("/wallpaperNTSC.jpg"); } - w->draw(); - w->show(); - viewman->add(w); + wallpaper->draw(); + wallpaper->show(); + viewman->add(wallpaper); VConnect* vconnect = new VConnect(); viewman->add(vconnect); @@ -230,11 +230,12 @@ void Command::doStandby() } else { + Video::getInstance()->signalOff(); viewman->removeAll(); + wallpaper->show(); VDR::getInstance()->configSave("General", "Last Power State", "Off"); VDR::getInstance()->disconnect(); - Video::getInstance()->signalOff(); Led::getInstance()->off(); isStandby = 1; } @@ -267,27 +268,29 @@ void Command::doJustConnected(VConnect* vconnect) VDR* vdr = VDR::getInstance(); + char* config; // Power off if first boot and config says so if (firstBoot) { firstBoot = 0; - char* powerAfterBoot = vdr->configLoad("General", "Power After Boot"); + config = vdr->configLoad("General", "Power After Boot"); - if (powerAfterBoot) + if (config) { - if (!strcasecmp(powerAfterBoot, "On")) + if (!strcasecmp(config, "On")) { logger->log("Command", Log::INFO, "Config says Power After Boot = On"); } - else if (!strcasecmp(powerAfterBoot, "Off")) + else if (!strcasecmp(config, "Off")) { logger->log("Command", Log::INFO, "Config says Power After Boot = Off"); doStandby(); + delete[] config; return; // quit here } - else if (!strcasecmp(powerAfterBoot, "Last state")) + else if (!strcasecmp(config, "Last state")) { char* lastPowerState = vdr->configLoad("General", "Last Power State"); if (lastPowerState) @@ -300,6 +303,7 @@ void Command::doJustConnected(VConnect* vconnect) { logger->log("Command", Log::INFO, "Config says Last Power State = Off"); doStandby(); + delete[] config; return; // quit here } else @@ -316,6 +320,7 @@ void Command::doJustConnected(VConnect* vconnect) { logger->log("Command", Log::INFO, "Config/Power After Boot not understood"); } + delete[] config; } else { @@ -326,20 +331,21 @@ void Command::doJustConnected(VConnect* vconnect) // Go S-Video if config says so - char* svideo = vdr->configLoad("TV", "S-Video"); + config = vdr->configLoad("TV", "S-Video"); - if (svideo) + if (config) { - if (!strcasecmp(svideo, "Yes")) + if (!strcasecmp(config, "Yes")) { - logger->log("Command", Log::INFO, "Switching to S-Video as S-Video=%s", svideo); + logger->log("Command", Log::INFO, "Switching to S-Video as S-Video=%s", config); video->setConnection(Video::SVIDEO); } else { - logger->log("Command", Log::INFO, "Leaving video output as S-Video=%s", svideo); + logger->log("Command", Log::INFO, "Leaving video output as S-Video=%s", config); video->setConnection(Video::COMPOSITERGB); } + delete[] config; } else { @@ -348,11 +354,11 @@ void Command::doJustConnected(VConnect* vconnect) // Set remote type - char* remoteType = vdr->configLoad("General", "Remote type"); + config = vdr->configLoad("General", "Remote type"); - if (remoteType) + if (config) { - if (!strcasecmp(remoteType, "New")) + if (!strcasecmp(config, "New")) { logger->log("Command", Log::INFO, "Switching to New remote type"); remote->setRemoteType(Remote::NEWREMOTE); @@ -362,6 +368,7 @@ void Command::doJustConnected(VConnect* vconnect) logger->log("Command", Log::INFO, "Switching to Old remote type"); remote->setRemoteType(Remote::OLDREMOTE); } + delete[] config; } else { @@ -369,17 +376,12 @@ void Command::doJustConnected(VConnect* vconnect) remote->setRemoteType(Remote::OLDREMOTE); } - // Save power state = on - - vdr->configSave("General", "Last Power State", "On"); - // Get TV aspect ratio - char* aspect = vdr->configLoad("TV", "Aspect"); - - if (aspect) + config = vdr->configLoad("TV", "Aspect"); + if (config) { - if (!strcasecmp(aspect, "16:9")) + if (!strcasecmp(config, "16:9")) { logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9"); video->setTVsize(Video::ASPECT16X9); @@ -389,6 +391,7 @@ void Command::doJustConnected(VConnect* vconnect) logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3"); video->setTVsize(Video::ASPECT4X3); } + delete[] config; } else { @@ -396,8 +399,34 @@ void Command::doJustConnected(VConnect* vconnect) video->setTVsize(Video::ASPECT4X3); } + config = vdr->configLoad("TV", "Widemode"); + if (config) + { + if (!strcasecmp(config, "Letterbox")) + { + logger->log("Command", Log::INFO, "Setting letterbox mode"); + video->setMode(Video::LETTERBOX); + } + else + { + logger->log("Command", Log::INFO, "Setting chop-sides mode"); + video->setMode(Video::NORMAL); + } + delete[] config; + } + else + { + logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode"); + video->setMode(Video::NORMAL); + } + // config done + // Save power state = on + + vdr->configSave("General", "Last Power State", "On"); + + viewman->removeView(vi); VWelcome* vw = new VWelcome(); diff --git a/command.h b/command.h index a63dc46..8e357b1 100644 --- a/command.h +++ b/command.h @@ -81,6 +81,7 @@ class Command : public MessageQueue Log* logger; ViewMan* viewman; Remote* remote; + VWallpaper* wallpaper; void processMessage(Message* m); }; diff --git a/demuxer.cc b/demuxer.cc index 8a2fbf9..afd7eec 100644 --- a/demuxer.cc +++ b/demuxer.cc @@ -47,11 +47,11 @@ int Demuxer::init(Callback* tcallback) { if (!initted) { - if ( !videostream.init(demuxMemory) || - !audiostream.init(demuxMemory) || + if ( !videostream.init(demuxMemoryV) || + !audiostream.init(demuxMemoryA) || !(local_frame = (UCHAR *) malloc(0x10000))) { - printf("failed to initialize demuxer\n"); + // printf("failed to initialize demuxer\n"); shutdown(); return 0; } diff --git a/demuxer.h b/demuxer.h index c4bcfcb..96fcdac 100644 --- a/demuxer.h +++ b/demuxer.h @@ -86,7 +86,8 @@ class Demuxer void parse_video_details(UCHAR* buf, int len); UCHAR* local_frame; - static const int demuxMemory = 2097152; + static const int demuxMemoryV = 2097152; + static const int demuxMemoryA = 524288; static const int Demuxer::FrameRates[9]; enum FRAMETYPE diff --git a/video.cc b/video.cc index acb2161..ba073d8 100644 --- a/video.cc +++ b/video.cc @@ -66,11 +66,23 @@ int Video::init(UCHAR tformat) setTVsize(ASPECT4X3); + if (format == PAL) setLetterboxBorder("38"); + else setLetterboxBorder("31"); + stop(); + return 1; } +void Video::setLetterboxBorder(char* border) +{ + FILE* fdlbox = fopen("/proc/lbox_border", "w"); + if (!fdlbox) return; + fputs(border, fdlbox); + fclose(fdlbox); +} + int Video::setTVsize(UCHAR ttvsize) { tvsize = ttvsize; @@ -86,6 +98,9 @@ int Video::setTVsize(UCHAR ttvsize) // Set this again to the same as the tv screen size if (!setAspectRatio(tvsize)) { shutdown(); return 0; } + // mode == LETTERBOX is invalid if the TV is widescreen + if (tvsize == ASPECT16X9) setMode(NORMAL); + return 1; } @@ -157,7 +172,6 @@ int Video::setAspectRatio(UCHAR taspectRatio) aspectRatio = taspectRatio; if (ioctl(fdVideo, AV_SET_VID_RATIO, aspectRatio) != 0) return 0; -// if (!setMode(mode)) return 0; return 1; } @@ -165,37 +179,16 @@ int Video::setMode(UCHAR tmode) { if (!initted) return 0; + if ((tmode == LETTERBOX) && (tvsize == ASPECT16X9)) return 0; // invalid mode + if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH) && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0; mode = tmode; if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0; - -// int a = ioctl(fdVideo, AV_SET_VID_MODE, mode); -// printf("Mode requested: %i, result: %i\n", mode, a); - return 1; } -#ifdef DEV -int Video::test() -{ - return 0; - -// ULLONG stc = 0; -// return ioctl(fdVideo, AV_SET_VID_STC, &stc); -/* - // reset(); - return 1; -*/ -} - -int Video::test2() -{ - return 0; -} -#endif - int Video::signalOff() { if (ioctl(fdVideo, AV_SET_VID_DENC, 0) != 0) return 0; @@ -221,10 +214,16 @@ int Video::setPosition(int x, int y) { if (!initted) return 0; +// vid_pos_regs_t pos_d; +// pos_d.x = x; +// pos_d.y = y; + vid_pos_regs_t pos_d; - pos_d.x = x; - pos_d.y = y; + memset(&pos_d, 0, sizeof(pos_d)); + + pos_d.dest.y = y; + pos_d.dest.x = x; /* typedef struct { int w; @@ -361,9 +360,26 @@ UINT Video::getScreenHeight() return screenHeight; } -/* UCHAR Video::getTVsize() { - return ; + return tvsize; } + +#ifdef DEV +int Video::test() +{ + return 0; + +// ULLONG stc = 0; +// return ioctl(fdVideo, AV_SET_VID_STC, &stc); +/* + // reset(); + return 1; */ +} + +int Video::test2() +{ + return 0; +} +#endif diff --git a/video.h b/video.h index bf69200..f1d2180 100644 --- a/video.h +++ b/video.h @@ -30,6 +30,7 @@ #include #include #include +#include #include "defines.h" #include "stb.h" @@ -63,9 +64,9 @@ class Video Actual Source Aspect Aspect IOCTL Mode IOCTL MODE A MODE B 4:3 4:3 NORMAL fullframe43 fullframe43 - 4:3 16:9 NORMAL fullframe43 fullframe43 + 4:3 16:9 NORMAL fullframe43 fullframe43 -- invalid? 4:3 4:3 LETTERBOX fullframe43 fullframe43 - 4:3 16:9 LETTERBOX fullframe43 fullframe43 + 4:3 16:9 LETTERBOX fullframe43 fullframe43 -- invalid? 16:9 4:3 NORMAL chop sides fullframe169 16:9 16:9 NORMAL chop sides fullframe169 16:9 4:3 LETTERBOX letterbox letterbox @@ -75,6 +76,7 @@ class Video 1. There are two chip modes - accessible by reopening the fd 2. The video chip knows the aspect ratio purely from the incoming MPEG + 3. MODE A is for 4:3 TVs, MODE B is for 16:9 TVs To switch to MODE A, set the aspect ioctl to 4:3 and reopen the FD. To switch to MODE B, set the aspect ioctl to 16:9 and reopen the FD. @@ -89,10 +91,9 @@ class Video int setFormat(UCHAR format); int setConnection(UCHAR connection); int setAspectRatio(UCHAR aspectRatio); // This one does the pin 8 scart widescreen switching -// UCHAR getAspectRatio(); - int setTVsize(UCHAR size); - int setDefaultAspect(); int setMode(UCHAR mode); + int setTVsize(UCHAR size); // Is the TV a widescreen? + int setDefaultAspect(); int setSource(); int setPosition(int x, int y); int sync(); @@ -106,21 +107,23 @@ class Video int blank(); int signalOn(); int signalOff(); + int attachFrameBuffer(); // What does this do? #ifdef DEV int test(); int test2(); #endif - int attachFrameBuffer(); // What does this do? int getFD(); UCHAR getFormat(); UINT getScreenWidth(); UINT getScreenHeight(); + UCHAR getTVsize(); private: int checkSCART(); + void setLetterboxBorder(char* border); static Video* instance; int initted; diff --git a/voptions.cc b/voptions.cc index f451e12..dc3bc28 100644 --- a/voptions.cc +++ b/voptions.cc @@ -60,98 +60,71 @@ VOptions::VOptions() optionBox[3].setSurface(surface); optionBox[3].setSurfaceOffset(330, 135); optionBox[3].setDimensions(150, fontHeight); - optionBox[3].addOption("On"); - optionBox[3].addOption("Off"); - optionBox[3].addOption("Last state"); + optionBox[3].addOption("Chop sides"); + optionBox[3].addOption("Letterbox"); optionBox[4].setSurface(surface); optionBox[4].setSurfaceOffset(330, 165); optionBox[4].setDimensions(150, fontHeight); - optionBox[4].addOption("All"); - optionBox[4].addOption("FTA only"); + optionBox[4].addOption("On"); + optionBox[4].addOption("Off"); + optionBox[4].addOption("Last state"); + + optionBox[5].setSurface(surface); + optionBox[5].setSurfaceOffset(330, 195); + optionBox[5].setDimensions(150, fontHeight); + optionBox[5].addOption("All"); + optionBox[5].addOption("FTA only"); char* config; vdr = VDR::getInstance(); config = vdr->configLoad("General", "Remote type"); - if (!config) - { + if (!config || strcasecmp(config, "New")) optionBox[0].setSelected("Old"); - } - else if (!strcasecmp(config, "New")) - { - optionBox[0].setSelected("New"); - } else - { - optionBox[0].setSelected("Old"); - } - + optionBox[0].setSelected("New"); + if (config) delete[] config; config = vdr->configLoad("TV", "S-Video"); - if (!config) - { + if (!config || strcasecmp(config, "Yes")) optionBox[1].setSelected("RGB+composite"); - } - else if (!strcasecmp(config, "Yes")) - { - optionBox[1].setSelected("S-Video"); - } else - { - optionBox[1].setSelected("RGB+composite"); - } + optionBox[1].setSelected("S-Video"); + if (config) delete[] config; config = vdr->configLoad("TV", "Aspect"); - if (!config) - { + if (!config || strcasecmp(config, "16:9")) optionBox[2].setSelected("4:3"); - } - else if (!strcasecmp(config, "16:9")) - { + else optionBox[2].setSelected("16:9"); - } + if (config) delete[] config; + + config = vdr->configLoad("TV", "Widemode"); + if (!config || strcasecmp(config, "Letterbox")) + optionBox[3].setSelected("Chop sides"); else - { - optionBox[2].setSelected("4:3"); - } + optionBox[3].setSelected("Letterbox"); + if (config) delete[] config; config = vdr->configLoad("General", "Power After Boot"); if (!config) - { - optionBox[3].setSelected("On"); - } - else if (!strcasecmp(config, "On")) // just for completeness - { - optionBox[3].setSelected("On"); - } + optionBox[4].setSelected("On"); else if (!strcasecmp(config, "Off")) - { - optionBox[3].setSelected("Off"); - } + optionBox[4].setSelected("Off"); else if (!strcasecmp(config, "Last state")) - { - optionBox[3].setSelected("Last state"); - } + optionBox[4].setSelected("Last state"); else - { - optionBox[3].setSelected("On"); - } + optionBox[4].setSelected("On"); + if (config) delete[] config; config = vdr->configLoad("General", "Channels"); - if (!config) - { - optionBox[4].setSelected("All"); - } - else if (!strcasecmp(config, "FTA only")) - { - optionBox[4].setSelected("FTA only"); - } + if (!config || strcasecmp(config, "FTA only")) + optionBox[5].setSelected("All"); else - { - optionBox[4].setSelected("All"); - } + optionBox[5].setSelected("FTA only"); + if (config) delete[] config; selectedOption = 0; optionBox[0].setActive(1); @@ -171,8 +144,9 @@ void VOptions::draw() drawText("Remote control type", 10, 45, Colour::LIGHTTEXT); drawText("TV connection type", 10, 75, Colour::LIGHTTEXT); drawText("TV aspect ratio", 10, 105, Colour::LIGHTTEXT); - drawText("Power state after bootup", 10, 135, Colour::LIGHTTEXT); - drawText("Display channels", 10, 165, Colour::LIGHTTEXT); + drawText("16:9 on 4:3 display mode", 10, 135, Colour::LIGHTTEXT); + drawText("Power state after bootup", 10, 165, Colour::LIGHTTEXT); + drawText("Display channels", 10, 195, Colour::LIGHTTEXT); drawText("Press back to exit, <, > or [ok] to change", 10, 220, Colour::LIGHTTEXT); @@ -273,10 +247,13 @@ void VOptions::doSave() char* aspect = optionBox[2].getSelected(); vdr->configSave("TV", "Aspect", aspect); - char* powerState = optionBox[3].getSelected(); + char* widemode = optionBox[3].getSelected(); + vdr->configSave("TV", "Widemode", widemode); + + char* powerState = optionBox[4].getSelected(); vdr->configSave("General", "Power After Boot", powerState); - char* channels = optionBox[4].getSelected(); + char* channels = optionBox[5].getSelected(); vdr->configSave("General", "Channels", channels); // Apply changes @@ -295,12 +272,23 @@ void VOptions::doSave() if (!strcmp(aspect, "16:9")) { - Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox"); + Log::getInstance()->log("Options", Log::DEBUG, "Setting widescreen"); video->setTVsize(Video::ASPECT16X9); } else { - Log::getInstance()->log("Options", Log::DEBUG, "Setting normal"); + Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 screen"); video->setTVsize(Video::ASPECT4X3); } + + if (!strcmp(widemode, "Letterbox")) + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox"); + video->setMode(Video::LETTERBOX); + } + else + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides"); + video->setMode(Video::NORMAL); + } } diff --git a/voptions.h b/voptions.h index b0d8a34..8237af1 100644 --- a/voptions.h +++ b/voptions.h @@ -42,7 +42,7 @@ class VOptions : public View private: void doSave(); - const static UINT numOptions = 5; + const static UINT numOptions = 6; UINT selectedOption; WOptionBox optionBox[numOptions]; VDR* vdr; diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 9ecbf89..4a072b3 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -92,8 +92,8 @@ void VRecordingList::drawData() dir = *i; if (dir->getNumRecordings() == 0) { - recDir->dirList.erase(i); delete dir; + recDir->dirList.erase(i); break; } } @@ -232,21 +232,20 @@ void VRecordingList::doDeleteSelected() saveTop = sl.getTopOption(); Log::getInstance()->log("VRecordingList", Log::DEBUG, "FOUND: %i %s %s", toDelete->index, toDelete->getProgName(), toDelete->fileName); + VDR* vdr = VDR::getInstance(); + vdr->deleteRecording(toDelete->fileName); + + delete toDelete; + for(RecordingList::iterator i = recDir->recList.begin(); i != recDir->recList.end(); i++) { if (*i == toDelete) { recDir->recList.erase(i); - Log::getInstance()->log("VRecordingList", Log::DEBUG, "Removed from vector: %s %s", toDelete->getProgName(), toDelete->fileName); break; } } - VDR* vdr = VDR::getInstance(); - vdr->deleteRecording(toDelete->fileName); - - delete toDelete; - sl.clear(); setDir(recDir); sl.hintSetCurrent(saveIndex); -- 2.39.5