From f7bcb3dd642409ff8c222e3007a13c731223af0a Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Sat, 29 Sep 2012 14:44:48 +0400 Subject: [PATCH 01/12] zapit/src/zapit.cpp: add missing initial volume set --- src/zapit/src/zapit.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index 6215f1772..19b574d35 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -2042,6 +2042,8 @@ bool CZapit::Start(Z_start_arg *ZapStart_arg) audioDecoder = new cAudio(audioDemux->getBuffer(), videoDecoder->GetTVEnc(), NULL /*videoDecoder->GetTVEncSD()*/); videoDecoder->SetAudioHandle(audioDecoder->GetHandle()); + /* set initial volume with 100% */ + SetVolumePercent(100); #ifdef USE_VBI videoDecoder->OpenVBI(1); #endif From 410b19aaf3ecff2fba571939c213506122c3f86f Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Sat, 29 Sep 2012 14:45:57 +0400 Subject: [PATCH 02/12] locals: add locales for start wizard initial settings --- data/locale/english.locale | 2 ++ src/system/locals.h | 2 ++ src/system/locals_intern.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/data/locale/english.locale b/data/locale/english.locale index 1d5307a08..d9d25012b 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1799,6 +1799,8 @@ videomenu.videoformat_149 14:9 videomenu.videoformat_169 16:9 videomenu.videoformat_43 4:3 videomenu.videomode Digital video mode +wizard.initial_settings Initial settings found +wizard.install_settings Do you want to install channels for Astra 19.2°E ? wizard.welcome_head Welcome to the Setup Wizard wizard.welcome_text Next steps will guide you through initial installation of the device.\nImportant: Your CoolStream set-top box can be conveniently controlled\nwith the web interface for timer management or live TV on the Web browser.\nDo not make it accessible to untrusted networks!\nDo you want to continue? word.from from diff --git a/src/system/locals.h b/src/system/locals.h index 113bf9cc9..857ffefc8 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1826,6 +1826,8 @@ typedef enum LOCALE_VIDEOMENU_VIDEOFORMAT_169, LOCALE_VIDEOMENU_VIDEOFORMAT_43, LOCALE_VIDEOMENU_VIDEOMODE, + LOCALE_WIZARD_INITIAL_SETTINGS, + LOCALE_WIZARD_INSTALL_SETTINGS, LOCALE_WIZARD_WELCOME_HEAD, LOCALE_WIZARD_WELCOME_TEXT, LOCALE_WORD_FROM, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 15b277c1a..7f13792bb 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1826,6 +1826,8 @@ const char * locale_real_names[] = "videomenu.videoformat_169", "videomenu.videoformat_43", "videomenu.videomode", + "wizard.initial_settings", + "wizard.install_settings", "wizard.welcome_head", "wizard.welcome_text", "word.from", From 4c41541f20fc2f521c6ffb68e6a5fa51f3d613f4 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Sat, 29 Sep 2012 14:46:43 +0400 Subject: [PATCH 03/12] gui/start_wizard.cpp: copy initial zapit settings from /var/tuxbox/config/initial/ if found --- src/gui/start_wizard.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gui/start_wizard.cpp b/src/gui/start_wizard.cpp index 79b7168d3..29a4ef9fe 100644 --- a/src/gui/start_wizard.cpp +++ b/src/gui/start_wizard.cpp @@ -46,6 +46,8 @@ #include "osd_setup.h" #include "osdlang_setup.h" #include "scan_setup.h" +#include +#include #include @@ -103,6 +105,17 @@ int CStartUpWizard::exec(CMenuTarget* parent, const string & /*actionKey*/) res = CScanSetup::getInstance()->exec(NULL, ""); CScanSetup::getInstance()->setWizardMode(CScanSetup::SCAN_SETUP_MODE_WIZARD_NO); } + bool init_settings = file_exists("/var/tuxbox/config/initial/"); + if(init_settings && (res != menu_return::RETURN_EXIT_ALL)) + { + if (ShowMsgUTF(LOCALE_WIZARD_INITIAL_SETTINGS, g_Locale->getText(LOCALE_WIZARD_INSTALL_SETTINGS), + CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) { + system("/bin/cp /var/tuxbox/config/initial/* /var/tuxbox/config/zapit/"); + CFEManager::getInstance()->loadSettings(); + CFEManager::getInstance()->saveSettings(); + CZapit::getInstance()->PrepareChannels(); + } + } } From a9950f10eb2c7873d0b63f81f4041c68d71a14dc Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 10 Oct 2012 18:33:11 +0400 Subject: [PATCH 04/12] zapit/src/scannit.cpp: fix satellite descriptor satellite position --- src/zapit/src/scannit.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/zapit/src/scannit.cpp b/src/zapit/src/scannit.cpp index 762960867..756750c84 100644 --- a/src/zapit/src/scannit.cpp +++ b/src/zapit/src/scannit.cpp @@ -293,12 +293,17 @@ bool CNit::ParseSatelliteDescriptor(SatelliteDeliverySystemDescriptor * sd, Tran newSat += ((sd->getOrbitalPosition() >> 8) & 0xF) * 100; newSat += ((sd->getOrbitalPosition() >> 4) & 0xF) * 10; newSat += ((sd->getOrbitalPosition()) & 0xF); - if (newSat && (!sd->getWestEastFlag())) + + if (newSat > 1800) newSat = 3600 - newSat; + if (!sd->getWestEastFlag()) + newSat = -newSat; + if (abs(newSat - satellitePosition) < 5) + newSat = satellitePosition; if(satellitePosition != newSat) { - printf("NIT: different satellite position: our %d nit %d\n", - satellitePosition, sd->getOrbitalPosition()); + printf("NIT: different satellite position: our %d nit %d (%X)\n", + satellitePosition, newSat, sd->getOrbitalPosition()); return false; } @@ -320,7 +325,7 @@ bool CNit::ParseSatelliteDescriptor(SatelliteDeliverySystemDescriptor * sd, Tran break; default: #ifdef DEBUG_NIT - printf("NIT: undefined modulation system %08x\n", modulation_system; + printf("NIT: undefined modulation system %08x\n", modulation_system); #endif feparams.delsys = SYS_UNDEFINED; break; From 296aee816c326e01b1490398791a1847a8a9bfbd Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 10 Oct 2012 18:34:19 +0400 Subject: [PATCH 05/12] zapit/src/zapit.cpp: change signal lock monitor (disabled at the moment) --- src/zapit/src/zapit.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index 19b574d35..907232ea0 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -2134,10 +2134,6 @@ static bool zapit_parse_command(CBasicMessage::Header &rmsg, int connfd) void CZapit::run() { -#if 0 - time_t stime = time(0); - time_t curtime; -#endif printf("[zapit] starting... tid %ld\n", syscall(__NR_gettid)); abort_zapit = 0; @@ -2186,14 +2182,15 @@ void CZapit::run() /* yuck, don't waste that much cpu time :) */ usleep(0); #if 0 - if(!standby && !CServiceScan::getInstance()->Scanning() &¤t_channel) { - curtime = time(0); + static time_t stime = time(0); + if(!standby && !CServiceScan::getInstance()->Scanning() && current_channel) { + time_t curtime = time(0); + //FIXME check if sig_delay needed */ if(sig_delay && (curtime - stime) > sig_delay) { stime = curtime; - uint16_t sig = live_fe->getSignalStrength(); - //if(sig < 8000) - if(sig < 28000) { - printf("[monitor] signal %d, trying to re-tune...\n", sig); + fe_status_t status = live_fe->getStatus(); + printf("[zapit] frontend status %d\n", status); + if (status != FE_HAS_LOCK) { live_fe->retuneChannel(); } } From 7a8097907c870fe1aa87ea923315898ddefdefff Mon Sep 17 00:00:00 2001 From: satbaby Date: Thu, 11 Oct 2012 14:10:01 +0200 Subject: [PATCH 06/12] nfs.cpp:Update mount icon after mounting, ported from tuxbox cvs --- src/gui/nfs.cpp | 18 +++++++++++++----- src/gui/nfs.h | 4 +++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 79122a775..9f20e0a1a 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -149,10 +149,17 @@ int CNFSMountGui::exec( CMenuTarget* parent, const std::string & actionKey ) else if(actionKey.substr(0,7)=="domount") { int nr=atoi(actionKey.substr(7,1).c_str()); - CFSMounter::mount(g_settings.network_nfs_ip[nr].c_str(), g_settings.network_nfs_dir[nr], + CFSMounter::MountRes mres = CFSMounter::mount( + g_settings.network_nfs_ip[nr].c_str(), g_settings.network_nfs_dir[nr], g_settings.network_nfs_local_dir[nr], (CFSMounter::FSType) g_settings.network_nfs_type[nr], g_settings.network_nfs_username[nr], g_settings.network_nfs_password[nr], g_settings.network_nfs_mount_options1[nr], g_settings.network_nfs_mount_options2[nr]); + + if (mres == CFSMounter::MRES_OK || mres == CFSMounter::MRES_FS_ALREADY_MOUNTED) + mountMenuEntry[nr]->iconName = NEUTRINO_ICON_MOUNTED; + else + mountMenuEntry[nr]->iconName = NEUTRINO_ICON_NOT_MOUNTED; + // TODO show msg in case of error returnval = menu_return::RETURN_EXIT; } @@ -176,15 +183,16 @@ int CNFSMountGui::menu() { sprintf(s2,"mountentry%d",i); sprintf(ISO_8859_1_entry[i],ZapitTools::UTF8_to_Latin1(m_entry[i]).c_str()); - CMenuForwarderNonLocalized *forwarder = new CMenuForwarderNonLocalized(ISO_8859_1_entry[i], true, NULL, this, s2); + mountMenuEntry[i] = new CMenuForwarderNonLocalized("", true, ISO_8859_1_entry[i], this, s2); + if (CFSMounter::isMounted(g_settings.network_nfs_local_dir[i])) { - forwarder->iconName = NEUTRINO_ICON_MOUNTED; + mountMenuEntry[i]->iconName = NEUTRINO_ICON_MOUNTED; } else { - forwarder->iconName = NEUTRINO_ICON_NOT_MOUNTED; + mountMenuEntry[i]->iconName = NEUTRINO_ICON_NOT_MOUNTED; } - mountMenuW.addItem(forwarder); + mountMenuW.addItem(mountMenuEntry[i]); } int ret=mountMenuW.exec(this,""); return ret; diff --git a/src/gui/nfs.h b/src/gui/nfs.h index ad5e77063..46d4469ae 100644 --- a/src/gui/nfs.h +++ b/src/gui/nfs.h @@ -46,7 +46,9 @@ class CNFSMountGui : public CMenuTarget int menuEntry(int nr); char m_entry[NETWORK_NFS_NR_OF_ENTRIES][200]; - char ISO_8859_1_entry[NETWORK_NFS_NR_OF_ENTRIES][200]; + char ISO_8859_1_entry[NETWORK_NFS_NR_OF_ENTRIES][200]; + + CMenuForwarderNonLocalized* mountMenuEntry[NETWORK_NFS_NR_OF_ENTRIES]; CFSMounter::FS_Support m_nfs_sup; CFSMounter::FS_Support m_cifs_sup; From 4c1552ead923271cad1426692cc221d07c53bbc4 Mon Sep 17 00:00:00 2001 From: satbaby Date: Thu, 11 Oct 2012 12:09:11 +0200 Subject: [PATCH 07/12] nfs.cpp:Show OK buttons on menu forwarders, ported from tuxbox cvs Signed-off-by: satbaby --- src/gui/nfs.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 9f20e0a1a..eacc03661 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -264,7 +264,8 @@ int CNFSMountGui::menuEntry(int nr) CMenuForwarder *password_fwd = new CMenuForwarder(LOCALE_NFS_PASSWORD, (*type==CFSMounter::CIFS || CFSMounter::LUFS), NULL, &passInput); CMACInput macInput(LOCALE_RECORDINGMENU_SERVER_MAC, g_settings.network_nfs_mac[nr], LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); CMenuForwarder * macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs_mac[nr], &macInput); - + CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, true, NULL, this, cmd); + mountnow_fwd->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); CNFSMountGuiNotifier notifier(username_fwd, password_fwd, type); mountMenuEntryW.addItem(new CMenuOptionChooser(LOCALE_NFS_TYPE, type, NFS_TYPE_OPTIONS, NFS_TYPE_OPTION_COUNT, typeEnabled, ¬ifier)); @@ -277,7 +278,7 @@ int CNFSMountGui::menuEntry(int nr) mountMenuEntryW.addItem(username_fwd); mountMenuEntryW.addItem(password_fwd); mountMenuEntryW.addItem(macInput_fwd); - mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_MOUNTNOW, true, NULL , this , cmd )); + mountMenuEntryW.addItem(mountnow_fwd); int ret = mountMenuEntryW.exec(this,""); return ret; @@ -341,8 +342,10 @@ int CNFSSmallMenu::exec( CMenuTarget* parent, const std::string & actionKey ) CMenuWidget sm_menu(LOCALE_NFSMENU_HEAD, NEUTRINO_ICON_NETWORK, width); CNFSMountGui mountGui; CNFSUmountGui umountGui; + CMenuForwarder *remount_fwd = new CMenuForwarder(LOCALE_NFS_REMOUNT, true, NULL, this, "remount"); + remount_fwd->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); sm_menu.addIntroItems(); - sm_menu.addItem(new CMenuForwarder(LOCALE_NFS_REMOUNT, true, NULL, this, "remount")); + sm_menu.addItem(remount_fwd); sm_menu.addItem(new CMenuForwarder(LOCALE_NFS_MOUNT , true, NULL, & mountGui)); sm_menu.addItem(new CMenuForwarder(LOCALE_NFS_UMOUNT, true, NULL, &umountGui)); return sm_menu.exec(parent, actionKey); From 7b06b3fd3888143a2b878af5e141e0383a955807 Mon Sep 17 00:00:00 2001 From: satbaby Date: Thu, 11 Oct 2012 14:11:05 +0200 Subject: [PATCH 08/12] Neutrino: rework COnOffNotifier and use it if possible, ported from tuxbox cvs --- src/gui/miscsettings_menu.cpp | 6 ++++-- src/gui/miscsettings_menu.h | 2 +- src/gui/moviebrowser.cpp | 3 ++- src/gui/nfs.cpp | 34 ++++------------------------- src/gui/osd_setup.h | 11 ---------- src/system/setting_helpers.cpp | 39 +++++++++------------------------- src/system/setting_helpers.h | 20 ++++++----------- 7 files changed, 28 insertions(+), 87 deletions(-) diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index bc05e028c..409d0ddd4 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -281,8 +281,10 @@ void CMiscMenue::showMiscSettingsMenuEnergy(CMenuWidget *ms_energy) CStringInput * miscSettings_shutdown_count = new CStringInput(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, g_settings.shutdown_count, 3, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT1, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT2, "0123456789 "); CMenuForwarder *m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, !g_settings.shutdown_real, g_settings.shutdown_count, miscSettings_shutdown_count); m2->setHint("", LOCALE_MENU_HINT_SHUTDOWN_COUNT); - - miscNotifier = new CMiscNotifier( m1, m2 ); + + miscNotifier = new COnOffNotifier(1); + miscNotifier->addItem(m1); + miscNotifier->addItem(m2); CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_MISCSETTINGS_SHUTDOWN_REAL, &g_settings.shutdown_real, OPTIONS_OFF1_ON0_OPTIONS, OPTIONS_OFF1_ON0_OPTION_COUNT, true, miscNotifier); mc->setHint("", LOCALE_MENU_HINT_SHUTDOWN_REAL); diff --git a/src/gui/miscsettings_menu.h b/src/gui/miscsettings_menu.h index 84e4e72b5..b05d0c68a 100644 --- a/src/gui/miscsettings_menu.h +++ b/src/gui/miscsettings_menu.h @@ -40,7 +40,7 @@ class CMiscMenue : public CMenuTarget private: CFanControlNotifier *fanNotifier; CSectionsdConfigNotifier* sectionsdConfigNotifier; - CMiscNotifier* miscNotifier; + COnOffNotifier* miscNotifier; int width; diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index b7fa267e8..b651122ee 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -2977,7 +2977,8 @@ bool CMovieBrowser::showMenu(MI_MOVIE_INFO* /*movie_info*/) { dirInput[i] = new CFileChooser(&m_settings.storageDir[i]); forwarder[i] = new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, m_settings.storageDirUsed[i], m_settings.storageDir[i], dirInput[i]); - notifier[i] = new COnOffNotifier(forwarder[i]); + notifier[i] = new COnOffNotifier(); + notifier[i]->addItem(forwarder[i]); chooser[i] = new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_DIR , &m_settings.storageDirUsed[i] , MESSAGEBOX_YES_NO_OPTIONS, MESSAGEBOX_YES_NO_OPTIONS_COUNT, true,notifier[i]); optionsMenuDir.addItem(chooser[i] ); optionsMenuDir.addItem(forwarder[i] ); diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index eacc03661..2916475f7 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -51,37 +51,9 @@ #include #include #include - +#include #include -class CNFSMountGuiNotifier : public CChangeObserver -{ -private: - CMenuForwarder *m_opt1,*m_opt2, *m_user, *m_pass; - int *m_type; -public: - CNFSMountGuiNotifier( CMenuForwarder* a3, CMenuForwarder* a4 , int* type) - { - m_user = a3; - m_pass = a4; - m_type = type; - } - bool changeNotify(const neutrino_locale_t /*OptionName*/, void *) - { - if(*m_type == (int)CFSMounter::NFS) - { - m_user->setActive (false); - m_pass->setActive (false); - } - else - { - m_user->setActive (true); - m_pass->setActive (true); - } - return true; - } -}; - CNFSMountGui::CNFSMountGui() { // FIXME #warning move probing from exec() to fsmounter @@ -266,7 +238,9 @@ int CNFSMountGui::menuEntry(int nr) CMenuForwarder * macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs_mac[nr], &macInput); CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, true, NULL, this, cmd); mountnow_fwd->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); - CNFSMountGuiNotifier notifier(username_fwd, password_fwd, type); + COnOffNotifier notifier(CFSMounter::NFS); + notifier.addItem(username_fwd); + notifier.addItem(password_fwd); mountMenuEntryW.addItem(new CMenuOptionChooser(LOCALE_NFS_TYPE, type, NFS_TYPE_OPTIONS, NFS_TYPE_OPTION_COUNT, typeEnabled, ¬ifier)); mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_IP , true, g_settings.network_nfs_ip[nr], &ipInput )); diff --git a/src/gui/osd_setup.h b/src/gui/osd_setup.h index 99db7df0f..e62f6f793 100644 --- a/src/gui/osd_setup.h +++ b/src/gui/osd_setup.h @@ -90,15 +90,4 @@ class COsdSetup : public CMenuTarget, public CChangeObserver int showContextChanlistMenu(); }; - -class COsdSetupChannelLogoNotifier : public CChangeObserver -{ - private: - CMenuForwarder* toDisable1; - CMenuOptionChooser* toDisable2; - public: - COsdSetupChannelLogoNotifier( CMenuForwarder*, CMenuOptionChooser* ); - bool changeNotify(const neutrino_locale_t, void * Data); -}; - #endif diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index 677b696f9..b93cbb0d1 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -88,43 +88,24 @@ extern cDemux *pcrDemux; extern "C" int pinghost( const char *hostname ); -// gui/moviebrowser.cpp -COnOffNotifier::COnOffNotifier( CMenuItem* a1,CMenuItem* a2,CMenuItem* a3,CMenuItem* a4,CMenuItem* a5) +COnOffNotifier::COnOffNotifier(int OffValue) { - number = 0; - if(a1 != NULL){ toDisable[0] =a1;number++;}; - if(a2 != NULL){ toDisable[1] =a2;number++;}; - if(a3 != NULL){ toDisable[2] =a3;number++;}; - if(a4 != NULL){ toDisable[3] =a4;number++;}; - if(a5 != NULL){ toDisable[4] =a5;number++;}; + offValue = OffValue; } bool COnOffNotifier::changeNotify(const neutrino_locale_t, void *Data) { - if(*(int*)(Data) == 0) - { - for (int i=0; isetActive(false); - } - else - { - for (int i=0; isetActive(true); - } - return false; + bool active = (*(int*)(Data) != offValue); + + for (std::vector::iterator it = toDisable.begin(); it != toDisable.end(); it++) + (*it)->setActive(active); + + return false; } -//used in gui/miscsettings_menu.cpp -CMiscNotifier::CMiscNotifier( CMenuItem* i1, CMenuItem* i2) +void COnOffNotifier::addItem(CMenuItem* menuItem) { - toDisable[0]=i1; - toDisable[1]=i2; -} -bool CMiscNotifier::changeNotify(const neutrino_locale_t, void *) -{ - toDisable[0]->setActive(!g_settings.shutdown_real); - toDisable[1]->setActive(!g_settings.shutdown_real); - return false; + toDisable.push_back(menuItem); } bool CSectionsdConfigNotifier::changeNotify(const neutrino_locale_t, void *) diff --git a/src/system/setting_helpers.h b/src/system/setting_helpers.h index a8eda16bc..22d0b27c9 100644 --- a/src/system/setting_helpers.h +++ b/src/system/setting_helpers.h @@ -55,22 +55,16 @@ class CGenericMenuActivate }; class COnOffNotifier : public CChangeObserver -{ - private: - int number; - CMenuItem* toDisable[5]; - public: - COnOffNotifier (CMenuItem* a1,CMenuItem* a2 = NULL,CMenuItem* a3 = NULL,CMenuItem* a4 = NULL,CMenuItem* a5 = NULL); - bool changeNotify(const neutrino_locale_t, void *Data); -}; - -class CMiscNotifier : public CChangeObserver { private: - CMenuItem* toDisable[2]; + int offValue; + std::vector toDisable; + public: - CMiscNotifier( CMenuItem*, CMenuItem* ); - bool changeNotify(const neutrino_locale_t, void *); + COnOffNotifier(int OffValue = 0); + bool changeNotify(const neutrino_locale_t, void *Data); + + void addItem(CMenuItem* menuItem); }; class CSectionsdConfigNotifier : public CChangeObserver From 9526434754c98ece1d736a07bca80f4f1c5f6b57 Mon Sep 17 00:00:00 2001 From: satbaby Date: Thu, 11 Oct 2012 14:16:49 +0200 Subject: [PATCH 09/12] nfs.cpp:NFSMountGui: disable username and password properly, ported from tuxbox cvs --- src/gui/nfs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 2916475f7..eb2d47d25 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -231,9 +231,9 @@ int CNFSMountGui::menuEntry(int nr) CStringInputSMS options2Input(LOCALE_NFS_MOUNT_OPTIONS, options2, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_=.,:|!?/ "); CMenuForwarder *options2_fwd = new CMenuForwarder(LOCALE_NFS_MOUNT_OPTIONS, true, options2, &options2Input); CStringInputSMS userInput(LOCALE_NFS_USERNAME, username, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_.,:|!?/ "); - CMenuForwarder *username_fwd = new CMenuForwarder(LOCALE_NFS_USERNAME, (*type==CFSMounter::CIFS || CFSMounter::LUFS), username, &userInput); + CMenuForwarder *username_fwd = new CMenuForwarder(LOCALE_NFS_USERNAME, (*type != (int)CFSMounter::NFS), username, &userInput); CStringInputSMS passInput(LOCALE_NFS_PASSWORD, password, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_.,:|!?/ "); - CMenuForwarder *password_fwd = new CMenuForwarder(LOCALE_NFS_PASSWORD, (*type==CFSMounter::CIFS || CFSMounter::LUFS), NULL, &passInput); + CMenuForwarder *password_fwd = new CMenuForwarder(LOCALE_NFS_PASSWORD, (*type != (int)CFSMounter::NFS), NULL, &passInput); CMACInput macInput(LOCALE_RECORDINGMENU_SERVER_MAC, g_settings.network_nfs_mac[nr], LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); CMenuForwarder * macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs_mac[nr], &macInput); CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, true, NULL, this, cmd); From 5983d36b141989d5b9fe1c2b238afbeeb78198da Mon Sep 17 00:00:00 2001 From: satbaby Date: Thu, 11 Oct 2012 14:59:52 +0200 Subject: [PATCH 10/12] nfs.cpp: disable mount option if mountpoint is mounted --- src/gui/nfs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index eb2d47d25..3117fba73 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -236,7 +236,7 @@ int CNFSMountGui::menuEntry(int nr) CMenuForwarder *password_fwd = new CMenuForwarder(LOCALE_NFS_PASSWORD, (*type != (int)CFSMounter::NFS), NULL, &passInput); CMACInput macInput(LOCALE_RECORDINGMENU_SERVER_MAC, g_settings.network_nfs_mac[nr], LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); CMenuForwarder * macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs_mac[nr], &macInput); - CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, true, NULL, this, cmd); + CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, !(CFSMounter::isMounted(g_settings.network_nfs_local_dir[nr])), NULL, this, cmd); mountnow_fwd->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); COnOffNotifier notifier(CFSMounter::NFS); notifier.addItem(username_fwd); From 21ffa39a457f2b9ff2e0ab6a6af1975ca793f721 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 11 Oct 2012 18:38:35 +0400 Subject: [PATCH 11/12] zapit/src/frontend.cpp: cleanup unused; remove redundant data members; dont set anything on first Open(), add Init() for this - will be called from femanager; dont init diseqc if no diseqc type set; dont send diseqc commands if no input is set; increase wait after voltage change; set voltage before diseqc commands --- src/zapit/include/zapit/frontend_c.h | 25 +-- src/zapit/src/frontend.cpp | 293 ++++++++------------------- 2 files changed, 95 insertions(+), 223 deletions(-) diff --git a/src/zapit/include/zapit/frontend_c.h b/src/zapit/include/zapit/frontend_c.h index 492028124..43cce1eb0 100644 --- a/src/zapit/include/zapit/frontend_c.h +++ b/src/zapit/include/zapit/frontend_c.h @@ -25,6 +25,7 @@ #define __zapit_frontend_h__ #include +#include #include #include #include @@ -78,8 +79,6 @@ static inline fe_rolloff_t dvbs_get_rolloff(fe_delivery_system_t delsys) return ROLLOFF_35; } -#define MAX_LNBS 64 /* due to Diseqc 1.1 (2003-01-10 rasc) */ - class CFEManager; class CFrontend @@ -87,12 +86,12 @@ class CFrontend private: /* frontend filedescriptor */ int fd; + + OpenThreads::Mutex mutex; /* use count for locking purposes */ int usecount; /* current adapter where this frontend is on */ int adapter; - /* current frontend instance */ - //static CFrontend *currentFe; bool locked; /* tuning finished flag */ bool tuned; @@ -100,7 +99,6 @@ class CFrontend struct dvb_frontend_info info; /* current 22kHz tone mode */ fe_sec_tone_mode_t currentToneMode; - int currentDiseqc; fe_sec_voltage_t currentVoltage; /* current satellite position */ int32_t currentSatellitePosition; @@ -117,7 +115,6 @@ class CFrontend int repeatUsals; int feTimeout; - int diseqc; uint8_t uncommitedInput; /* lnb offsets */ int32_t lnbOffsetLow; @@ -125,15 +122,12 @@ class CFrontend int32_t lnbSwitch; /* current Transponderdata */ TP_params currentTransponder; - FrontendParameters curfe; bool slave; int fenumber; bool standby; bool buildProperties(const FrontendParameters*, struct dtv_properties &); - uint32_t getDiseqcReply(const int timeout_ms) const; FrontendParameters getFrontend(void) const; - void secResetOverload(void); void secSetTone(const fe_sec_tone_mode_t mode, const uint32_t ms); void secSetVoltage(const fe_sec_voltage_t voltage, const uint32_t ms); void sendDiseqcCommand(const struct dvb_diseqc_master_cmd *cmd, const uint32_t ms); @@ -146,12 +140,13 @@ class CFrontend void sendToneBurst(const fe_sec_mini_cmd_t burst, const uint32_t ms); int setFrontend(const FrontendParameters *feparams, bool nowait = false); void setSec(const uint8_t sat_no, const uint8_t pol, const bool high_band); - void set12V(bool enable); void reset(void); /* Private constructor */ CFrontend(int Number = 0, int Adapter = 0); + bool Open(bool init = false); + void Close(void); + void Init(void); - //static CFrontend *getInstance(int Number = 0, int Adapter = 0); friend class CFEManager; public: ~CFrontend(void); @@ -160,7 +155,7 @@ class CFrontend uint8_t getDiseqcPosition(void) const { return currentTransponder.diseqc; } uint8_t getDiseqcRepeats(void) const { return config.diseqcRepeats; } diseqc_t getDiseqcType(void) const { return (diseqc_t) config.diseqcType; } - uint32_t getFrequency(void) const { return curfe.dvb_feparams.frequency; } + uint32_t getFrequency(void) const { return currentTransponder.feparams.dvb_feparams.frequency; } bool getHighBand() { return (int) getFrequency() >= lnbSwitch; } static fe_modulation_t getModulation(const uint8_t modulation); uint8_t getPolarization(void) const; @@ -177,7 +172,7 @@ class CFrontend int32_t getRotorSatellitePosition() { return rotorSatellitePosition; } void setDiseqcRepeats(const uint8_t repeats) { config.diseqcRepeats = repeats; } - void setDiseqcType(const diseqc_t type); + void setDiseqcType(const diseqc_t type, bool force = false); void setTimeout(int timeout) { feTimeout = timeout; }; void configUsals(double Latitude, double Longitude, int LaDirection, int LoDirection, bool _repeatUsals) { @@ -197,7 +192,6 @@ class CFrontend int setParameters(TP_params *TP, bool nowait = 0); int tuneFrequency (FrontendParameters * feparams, uint8_t polarization, bool nowait = false); const TP_params* getParameters(void) const { return ¤tTransponder; }; - struct dvb_frontend_event* setParametersResponse(TP_params *TP); void setCurrentSatellitePosition(int32_t satellitePosition) {currentSatellitePosition = satellitePosition; } void setRotorSatellitePosition(int32_t satellitePosition) {rotorSatellitePosition = satellitePosition; } @@ -206,7 +200,6 @@ class CFrontend void gotoXX(t_satellite_position pos); bool tuneChannel(CZapitChannel *channel, bool nvod); bool retuneChannel(void); - bool retuneTP(bool nowait = true); fe_code_rate_t getCFEC (); transponder_id_t getTsidOnid() { return currentTransponder.TP_id; } @@ -218,8 +211,6 @@ class CFrontend void setTsidOnid(transponder_id_t newid) { currentTransponder.TP_id = newid; } uint32_t getRate (); - bool Open(); - void Close(); void Lock(); void Unlock(); diff --git a/src/zapit/src/frontend.cpp b/src/zapit/src/frontend.cpp index 159f1895f..6b9088957 100644 --- a/src/zapit/src/frontend.cpp +++ b/src/zapit/src/frontend.cpp @@ -137,19 +137,6 @@ typedef enum dvb_fec { #define TIME_STEP 200 #define TIMEOUT_MAX_MS (feTimeout*100) /*********************************************************************************************************/ -#if 0 -// Global fe instance -CFrontend *CFrontend::currentFe = NULL; - -CFrontend *CFrontend::getInstance(int Number, int Adapter) -{ - if (!currentFe) { - currentFe = new CFrontend(Number, Adapter); - currentFe->Open(); - } - return currentFe; -} -#endif CFrontend::CFrontend(int Number, int Adapter) { printf("[fe%d] New frontend on adapter %d\n", Number, Adapter); @@ -161,15 +148,10 @@ CFrontend::CFrontend(int Number, int Adapter) locked = false; usecount = 0; - - memset(&curfe, 0, sizeof(curfe)); - curfe.dvb_feparams.u.qpsk.fec_inner = FEC_3_4; - curfe.dvb_feparams.u.qam.fec_inner = FEC_3_4; - curfe.dvb_feparams.u.qam.modulation = QAM_64; - tuned = false; uncommitedInput = 255; - diseqc = 255; + + memset(¤tTransponder, 0, sizeof(currentTransponder)); currentTransponder.polarization = 1; currentTransponder.feparams.dvb_feparams.frequency = 0; currentTransponder.TP_id = 0; @@ -183,28 +165,22 @@ CFrontend::CFrontend(int Number, int Adapter) config.motorRotationSpeed = 0; //in 0.1 degrees per second feTimeout = 40; - // to allow Open() switch it off - currentVoltage = SEC_VOLTAGE_OFF; //SEC_VOLTAGE_13; + currentVoltage = SEC_VOLTAGE_OFF; currentToneMode = SEC_TONE_ON; } CFrontend::~CFrontend(void) { printf("[fe%d] close frontend fd %d\n", fenumber, fd); - if(fd >= 0) { + if(fd >= 0) Close(); - close(fd); - } - //currentFe = NULL; } -bool CFrontend::Open(void) +bool CFrontend::Open(bool init) { if(!standby) return false; - printf("[fe%d] open frontend\n", fenumber); - char filename[128]; snprintf(filename, sizeof(filename), "/dev/dvb/adapter%d/frontend%d", adapter, fenumber); printf("[fe%d] open %s\n", fenumber, filename); @@ -219,14 +195,9 @@ bool CFrontend::Open(void) } //FIXME info.type = FE_QAM; - //currentVoltage = SEC_VOLTAGE_OFF; - //secSetVoltage(SEC_VOLTAGE_OFF, 15); - secSetVoltage(SEC_VOLTAGE_13, 15); - secSetTone(SEC_TONE_OFF, 15); - diseqc_t diseqcType = (diseqc_t) config.diseqcType; - config.diseqcType = NO_DISEQC; - setDiseqcType(diseqcType); + if (init) + Init(); currentTransponder.TP_id = 0; @@ -235,6 +206,15 @@ bool CFrontend::Open(void) return true; } +void CFrontend::Init(void) +{ + mutex.lock(); + secSetVoltage(SEC_VOLTAGE_13, 100); + secSetTone(SEC_TONE_OFF, 15); + setDiseqcType((diseqc_t) config.diseqcType, true); + mutex.unlock(); +} + void CFrontend::Close(void) { if(standby) @@ -261,16 +241,10 @@ void CFrontend::setMasterSlave(bool _slave) if(_slave) { secSetVoltage(SEC_VOLTAGE_OFF, 0); secSetTone(SEC_TONE_OFF, 15); - } - slave = _slave; - if(!slave) { - secSetVoltage(SEC_VOLTAGE_13, 0); -#if 1 - diseqc_t diseqcType = (diseqc_t) config.diseqcType; - config.diseqcType = NO_DISEQC; - setDiseqcType(diseqcType); -#endif } + slave = _slave; + if(!slave) + Init(); } void CFrontend::reset(void) @@ -293,11 +267,10 @@ void CFrontend::Unlock() fe_code_rate_t CFrontend::getCFEC() { - if (info.type == FE_QPSK) { - return curfe.dvb_feparams.u.qpsk.fec_inner; - } else { - return curfe.dvb_feparams.u.qam.fec_inner; - } + if (info.type == FE_QPSK) + return currentTransponder.feparams.dvb_feparams.u.qpsk.fec_inner; + else + return currentTransponder.feparams.dvb_feparams.u.qam.fec_inner; } fe_code_rate_t CFrontend::getCodeRate(const uint8_t fec_inner, int system) @@ -380,25 +353,19 @@ uint8_t CFrontend::getPolarization(void) const uint32_t CFrontend::getRate() { - if (info.type == FE_QPSK) { - return curfe.dvb_feparams.u.qpsk.symbol_rate; - } else { - return curfe.dvb_feparams.u.qam.symbol_rate; - } + if (info.type == FE_QPSK) + return currentTransponder.feparams.dvb_feparams.u.qpsk.symbol_rate; + else + return currentTransponder.feparams.dvb_feparams.u.qam.symbol_rate; } fe_status_t CFrontend::getStatus(void) const { -#if 1 // FIXME FE_READ_STATUS works ? struct dvb_frontend_event event; fop(ioctl, FE_READ_STATUS, &event.status); - //printf("CFrontend::getStatus: %x\n", event.status); return (fe_status_t) (event.status & FE_HAS_LOCK); -#else - fe_status_t status = (fe_status_t) tuned; - return status; -#endif } + #if 0 //never used FrontendParameters CFrontend::getFrontend(void) const @@ -406,6 +373,7 @@ FrontendParameters CFrontend::getFrontend(void) const return currentTransponder.feparams; } #endif + uint32_t CFrontend::getBitErrorRate(void) const { uint32_t ber = 0; @@ -452,12 +420,9 @@ struct dvb_frontend_event CFrontend::getEvent(void) memset(&event, 0, sizeof(struct dvb_frontend_event)); - //printf("[fe%d] getEvent: max timeout: %d\n", fenumber, TIMEOUT_MAX_MS); FE_TIMER_START(); - //while (msec <= TIMEOUT_MAX_MS ) { while ((int) timer_msec < TIMEOUT_MAX_MS) { - //int ret = poll(&pfd, 1, TIME_STEP); int ret = poll(&pfd, 1, TIMEOUT_MAX_MS - timer_msec); if (ret < 0) { perror("CFrontend::getEvent poll"); @@ -472,7 +437,6 @@ struct dvb_frontend_event CFrontend::getEvent(void) FE_TIMER_STOP("poll has event after"); memset(&event, 0, sizeof(struct dvb_frontend_event)); - //fop(ioctl, FE_READ_STATUS, &event.status); ret = ioctl(fd, FE_GET_EVENT, &event); if (ret < 0) { perror("CFrontend::getEvent ioctl"); @@ -746,7 +710,7 @@ bool CFrontend::buildProperties(const FrontendParameters *feparams, struct dtv_p return true; } -int CFrontend::setFrontend(const FrontendParameters *feparams, bool /*nowait*/) +int CFrontend::setFrontend(const FrontendParameters *feparams, bool nowait) { struct dtv_property cmdargs[FE_COMMON_PROPS + FE_DVBS2_PROPS]; // WARNING: increase when needed more space struct dtv_properties cmdseq; @@ -756,7 +720,6 @@ int CFrontend::setFrontend(const FrontendParameters *feparams, bool /*nowait*/) tuned = false; - //printf("[fe%d] DEMOD: FEC %s system %s modulation %s pilot %s\n", fenumber, f, s, m, pilot == PILOT_ON ? "on" : "off"); struct dvb_frontend_event ev; { // Erase previous events @@ -767,7 +730,6 @@ int CFrontend::setFrontend(const FrontendParameters *feparams, bool /*nowait*/) } } - //printf("[fe%d] DEMOD: FEC %s system %s modulation %s pilot %s, freq %d\n", fenumber, f, s, m, pilot == PILOT_ON ? "on" : "off", p->props[FREQUENCY].u.data); if (!buildProperties(feparams, cmdseq)) return 0; @@ -780,6 +742,8 @@ int CFrontend::setFrontend(const FrontendParameters *feparams, bool /*nowait*/) } FE_TIMER_STOP("FE_SET_PROPERTY took"); } + if (nowait) + return 0; { FE_TIMER_INIT(); FE_TIMER_START(); @@ -832,12 +796,6 @@ void CFrontend::secSetVoltage(const fe_sec_voltage_t voltage, const uint32_t ms) return; printf("[fe%d] voltage %s\n", fenumber, voltage == SEC_VOLTAGE_OFF ? "OFF" : voltage == SEC_VOLTAGE_13 ? "13" : "18"); - //printf("[fe%d] voltage %s high %d\n", fenumber, voltage == SEC_VOLTAGE_OFF ? "OFF" : voltage == SEC_VOLTAGE_13 ? "13" : "18", config.highVoltage); - //int val = config.highVoltage; - //fop(ioctl, FE_ENABLE_HIGH_LNB_VOLTAGE, val); - - //FE_TIMER_INIT(); - //FE_TIMER_START(); if (config.uni_scr >= 0) { /* see my comment in secSetTone... */ currentVoltage = voltage; /* need to know polarization for unicable */ @@ -847,34 +805,23 @@ void CFrontend::secSetVoltage(const fe_sec_voltage_t voltage, const uint32_t ms) if (fop(ioctl, FE_SET_VOLTAGE, voltage) == 0) { currentVoltage = voltage; - //FE_TIMER_STOP("[frontend] FE_SET_VOLTAGE took"); - usleep(1000 * ms); // FIXME : is needed ? + usleep(1000 * ms); } } -#if 0 -//never used -void CFrontend::secResetOverload(void) -{ -} -#endif + void CFrontend::sendDiseqcCommand(const struct dvb_diseqc_master_cmd *cmd, const uint32_t ms) { + if (slave || info.type != FE_QPSK) + return; + printf("[fe%d] Diseqc cmd: ", fenumber); for (int i = 0; i < cmd->msg_len; i++) printf("0x%X ", cmd->msg[i]); printf("\n"); - if (slave || info.type != FE_QPSK) - return; if (fop(ioctl, FE_DISEQC_SEND_MASTER_CMD, cmd) == 0) usleep(1000 * ms); } -#if 0 -//never used -uint32_t CFrontend::getDiseqcReply(const int /*timeout_ms*/) const -{ - return 0; -} -#endif + void CFrontend::sendToneBurst(const fe_sec_mini_cmd_t burst, const uint32_t ms) { if (slave || info.type != FE_QPSK) @@ -883,7 +830,7 @@ void CFrontend::sendToneBurst(const fe_sec_mini_cmd_t burst, const uint32_t ms) usleep(1000 * ms); } -void CFrontend::setDiseqcType(const diseqc_t newDiseqcType) +void CFrontend::setDiseqcType(const diseqc_t newDiseqcType, bool force) { switch (newDiseqcType) { case NO_DISEQC: @@ -923,19 +870,13 @@ void CFrontend::setDiseqcType(const diseqc_t newDiseqcType) return; } -#if 0 - if (!slave && (config.diseqcType <= MINI_DISEQC) - && (newDiseqcType > MINI_DISEQC)) { + if (force || ((config.diseqcType <= MINI_DISEQC) + && (newDiseqcType > MINI_DISEQC))) { + secSetTone(SEC_TONE_OFF, 15); sendDiseqcPowerOn(); sendDiseqcReset(); + secSetTone(SEC_TONE_ON, 20); } -#else - - if (config.diseqcType != newDiseqcType) { - sendDiseqcPowerOn(); - sendDiseqcReset(); - } -#endif config.diseqcType = newDiseqcType; } @@ -966,8 +907,8 @@ void CFrontend::sendMotorCommand(uint8_t cmdtype, uint8_t address, uint8_t comma cmd.msg_len = 3 + num_parameters; //secSetVoltage(config.highVoltage ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13, 15); - secSetVoltage(SEC_VOLTAGE_13, 15); secSetTone(SEC_TONE_OFF, 15); + secSetVoltage(SEC_VOLTAGE_13, 100); for(i = 0; i <= repeat; i++) sendDiseqcCommand(&cmd, 50); @@ -985,12 +926,12 @@ void CFrontend::positionMotor(uint8_t motorPosition) }; if (motorPosition != 0) { - secSetVoltage(config.highVoltage ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13, 15); secSetTone(SEC_TONE_OFF, 25); + secSetVoltage(config.highVoltage ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13, 15); cmd.msg[3] = motorPosition; for (int i = 0; i <= repeatUsals; ++i) - sendDiseqcCommand(&cmd, 50); + sendDiseqcCommand(&cmd, 50); printf("[fe%d] motor positioning command sent.\n", fenumber); } @@ -999,12 +940,10 @@ void CFrontend::positionMotor(uint8_t motorPosition) bool CFrontend::setInput(CZapitChannel * channel, bool nvod) { transponder_list_t::iterator tpI; - //transponder_id_t ct = channel->getTransponderId(); transponder_id_t ct = nvod ? (channel->getTransponderId() & 0xFFFFFFFFULL) : channel->getTransponderId(); transponder_id_t current_id = nvod ? (currentTransponder.TP_id & 0xFFFFFFFFULL) : currentTransponder.TP_id; //printf("CFrontend::setInput tuned %d nvod %d current_id %llx new %llx\n\n", tuned, nvod, current_id, ct); - //if (tuned && (ct == currentTransponder.TP_id)) if (tuned && (ct == current_id)) return false; @@ -1022,6 +961,7 @@ bool CFrontend::setInput(CZapitChannel * channel, bool nvod) } currentTransponder.TP_id = tpI->first; + currentTransponder.polarization = tpI->second.polarization; currentSatellitePosition = channel->getSatellitePosition(); setInput(channel->getSatellitePosition(), tpI->second.feparams.dvb_feparams.frequency, tpI->second.polarization); @@ -1032,11 +972,7 @@ void CFrontend::setInput(t_satellite_position satellitePosition, uint32_t freque { sat_iterator_t sit = satellites.find(satellitePosition); -#if 0 - printf("[fe%d] setInput: SatellitePosition %d -> %d\n", fenumber, currentSatellitePosition, satellitePosition); - if (currentSatellitePosition != satellitePosition) -#endif - setLnbOffsets(sit->second.lnbOffsetLow, sit->second.lnbOffsetHigh, sit->second.lnbSwitch); + setLnbOffsets(sit->second.lnbOffsetLow, sit->second.lnbOffsetHigh, sit->second.lnbSwitch); if (config.diseqcType != DISEQC_ADVANCED) { setDiseqc(sit->second.diseqc, polarization, frequency); return; @@ -1047,7 +983,7 @@ void CFrontend::setInput(t_satellite_position satellitePosition, uint32_t freque sendUncommittedSwitchesCommand(sit->second.uncommited); } else { if (sendUncommittedSwitchesCommand(sit->second.uncommited)) - diseqc = -1; + currentTransponder.diseqc = -1; setDiseqcSimple(sit->second.commited, polarization, frequency); } } @@ -1092,49 +1028,42 @@ uint32_t CFrontend::sendEN50494TuningCommand(const uint32_t frequency, const int bool CFrontend::tuneChannel(CZapitChannel * /*channel*/, bool /*nvod*/) { -//printf("tuneChannel: tpid %llx\n", currentTransponder.TP_id); transponder_list_t::iterator transponder = transponders.find(currentTransponder.TP_id); if (transponder == transponders.end()) return false; return tuneFrequency(&transponder->second.feparams, transponder->second.polarization, false); } -#if 0 -//never used -bool CFrontend::retuneTP(bool nowait) -{ - /* used in pip only atm */ - tuneFrequency(&curfe, currentTransponder.polarization, nowait); - return 0; -} bool CFrontend::retuneChannel(void) { - setFrontend(¤tTransponder.feparams); - return 0; + mutex.lock(); + setInput(currentSatellitePosition, currentTransponder.feparams.dvb_feparams.frequency, currentTransponder.polarization); + transponder_list_t::iterator transponder = transponders.find(currentTransponder.TP_id); + if (transponder == transponders.end()) + return false; + mutex.unlock(); + return tuneFrequency(&transponder->second.feparams, transponder->second.polarization, true); } -#endif + int CFrontend::tuneFrequency(FrontendParameters * feparams, uint8_t polarization, bool nowait) { TP_params TP; - //printf("[fe%d] tune to frequency %d pol %s srate %d\n", fenumber, feparams->dvb_feparams.frequency, polarization ? "Vertical/Right" : "Horizontal/Left", feparams->dvb_feparams.u.qpsk.symbol_rate); - memmove(&curfe, feparams, sizeof(struct dvb_frontend_parameters)); + memmove(¤tTransponder.feparams, feparams, sizeof(struct dvb_frontend_parameters)); memmove(&TP.feparams, feparams, sizeof(struct dvb_frontend_parameters)); TP.polarization = polarization; return setParameters(&TP, nowait); } -int CFrontend::setParameters(TP_params *TP, bool /*nowait*/) +int CFrontend::setParameters(TP_params *TP, bool nowait) { int freq_offset = 0, freq; - TP_params currTP; - FrontendParameters *feparams; + FrontendParameters feparams; /* Copy the data for local use */ - currTP = *TP; - feparams = &currTP.feparams; - freq = (int) feparams->dvb_feparams.frequency; + memcpy(&feparams, &TP->feparams, sizeof(feparams)); + freq = (int) feparams.dvb_feparams.frequency; char * f, *s, *m; if (info.type == FE_QPSK) { @@ -1148,49 +1077,18 @@ int CFrontend::setParameters(TP_params *TP, bool /*nowait*/) freq_offset = lnbOffsetHigh; } - feparams->dvb_feparams.frequency = abs(freq - freq_offset); + feparams.dvb_feparams.frequency = abs(freq - freq_offset); setSec(TP->diseqc, TP->polarization, high_band); - getDelSys(feparams->dvb_feparams.u.qpsk.fec_inner, dvbs_get_modulation(feparams->dvb_feparams.u.qpsk.fec_inner), f, s, m); + getDelSys(feparams.dvb_feparams.u.qpsk.fec_inner, dvbs_get_modulation(feparams.dvb_feparams.u.qpsk.fec_inner), f, s, m); } else if (info.type == FE_QAM) { if (freq < 1000*1000) - feparams->dvb_feparams.frequency = freq * 1000; - getDelSys(feparams->dvb_feparams.u.qam.fec_inner,feparams->dvb_feparams.u.qam.modulation, f, s, m); -#if 0 - switch (TP->feparams.dvb_feparams.inversion) { - case INVERSION_OFF: - TP->feparams.dvb_feparams.inversion = INVERSION_ON; - break; - case INVERSION_ON: - default: - TP->feparams.dvb_feparams.inversion = INVERSION_OFF; - break; - } -#endif + feparams.dvb_feparams.frequency = freq * 1000; + getDelSys(feparams.dvb_feparams.u.qam.fec_inner, feparams.dvb_feparams.u.qam.modulation, f, s, m); } - //printf("[fe%d] tuner to frequency %d (offset %d timeout %d)\n", fenumber, feparams->dvb_feparams.frequency, freq_offset, TIMEOUT_MAX_MS); - //printf("[fe%d] tune to frequency %d (tuner %d offset %d timeout %d)\n", fenumber, freq, feparams->dvb_feparams.frequency, freq_offset, TIMEOUT_MAX_MS); printf("[fe%d] tune to %d %s %s %s %s srate %d (tuner %d offset %d timeout %d)\n", fenumber, freq, s, m, f, - TP->polarization & 1 ? "V/R" : "H/L", feparams->dvb_feparams.u.qpsk.symbol_rate, feparams->dvb_feparams.frequency, freq_offset, TIMEOUT_MAX_MS); - setFrontend(feparams); - -#if 0 - if (tuned) { - ret = diff(event.parameters.frequency, TP->feparams.dvb_feparams.frequency); - /* if everything went ok, then it is a good idea to copy the real - * frontend parameters, so we can update the service list, if it differs. - * TODO: set a flag to indicate a change in the service list */ - memmove(¤tTransponder.feparams, &event.parameters, sizeof(struct dvb_frontend_parameters)); - } -#endif - -#if 0 - /* add the frequency offset to the frontend parameters again - * because they are used for the channel list and were given - * to this method as a pointer */ - if (info.type == FE_QPSK) - TP->feparams.dvb_feparams.frequency += freq_offset; -#endif + TP->polarization & 1 ? "V/R" : "H/L", feparams.dvb_feparams.u.qpsk.symbol_rate, feparams.dvb_feparams.frequency, freq_offset, TIMEOUT_MAX_MS); + setFrontend(&feparams, nowait); return tuned; } @@ -1216,7 +1114,6 @@ bool CFrontend::sendUncommittedSwitchesCommand(int input) /* off = low band, on - hi band , vertical 13v, horizontal 18v */ bool CFrontend::setDiseqcSimple(int sat_no, const uint8_t pol, const uint32_t frequency) { - //for monoblock fe_sec_voltage_t v = (pol & 1) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18; //fe_sec_mini_cmd_t b = (sat_no & 1) ? SEC_MINI_B : SEC_MINI_A; bool high_band = ((int)frequency >= lnbSwitch); @@ -1225,20 +1122,15 @@ bool CFrontend::setDiseqcSimple(int sat_no, const uint8_t pol, const uint32_t fr {0xe0, 0x10, 0x38, 0x00, 0x00, 0x00}, 4 }; - INFO("[fe%d] diseqc input %d -> %d", fenumber, diseqc, sat_no); + INFO("[fe%d] diseqc input %d -> %d", fenumber, currentTransponder.diseqc, sat_no); currentTransponder.diseqc = sat_no; if (slave) return true; - if ((sat_no >= 0) && (diseqc != sat_no)) { - diseqc = sat_no; - printf("[fe%d] diseqc no. %d\n", fenumber, sat_no); - + if ((sat_no >= 0) /* && (diseqc != sat_no)*/) { cmd.msg[3] = 0xf0 | (((sat_no * 4) & 0x0f) | (high_band ? 1 : 0) | ((pol & 1) ? 0 : 2)); - //for monoblock - needed ?? - secSetVoltage(v, 15); - //secSetVoltage(SEC_VOLTAGE_13, 15);//FIXME for test secSetTone(SEC_TONE_OFF, 20); + secSetVoltage(v, 100); sendDiseqcCommand(&cmd, 100); return true; @@ -1259,21 +1151,23 @@ void CFrontend::setDiseqc(int sat_no, const uint8_t pol, const uint32_t frequenc uint8_t loop; bool high_band = ((int)frequency >= lnbSwitch); struct dvb_diseqc_master_cmd cmd = { {0xE0, 0x10, 0x38, 0xF0, 0x00, 0x00}, 4 }; - //fe_sec_voltage_t polarity = (pol & 1) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18; - //fe_sec_tone_mode_t tone = high_band ? SEC_TONE_ON : SEC_TONE_OFF;//seems needed? fe_sec_mini_cmd_t b = (sat_no & 1) ? SEC_MINI_B : SEC_MINI_A; int delay = 0; - printf("[fe%d] diseqc input %d -> %d\n", fenumber, diseqc, sat_no); + if ((config.diseqcType == NO_DISEQC) || sat_no < 0) + return; + + printf("[fe%d] diseqc input %d -> %d\n", fenumber, currentTransponder.diseqc, sat_no); + currentTransponder.diseqc = sat_no; if (slave) return; - //secSetVoltage(polarity, 15); /* first of all set the "polarization" */ - //secSetTone(tone, 1); /* set the "band" */ - - //secSetVoltage(SEC_VOLTAGE_13, 15);//FIXME for test secSetTone(SEC_TONE_OFF, 20); - +#if 1 + fe_sec_voltage_t v = (pol & 1) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18; + secSetVoltage(v, 100); +#endif + sendDiseqcReset(); for (loop = 0; loop <= config.diseqcRepeats; loop++) { //usleep(50*1000); /* sleep at least 50 milli seconds */ @@ -1316,13 +1210,6 @@ void CFrontend::setDiseqc(int sat_no, const uint8_t pol, const uint32_t frequenc if (config.diseqcType == SMATV_REMOTE_TUNING) sendDiseqcSmatvRemoteTuningCommand(frequency); - -#if 0 // setSec do this, when tune called - if (high_band) - secSetTone(SEC_TONE_ON, 20); -#endif - //secSetTone(tone, 20); - currentTransponder.diseqc = sat_no; } void CFrontend::setSec(const uint8_t /*sat_no*/, const uint8_t pol, const bool high_band) @@ -1330,33 +1217,29 @@ void CFrontend::setSec(const uint8_t /*sat_no*/, const uint8_t pol, const bool h fe_sec_voltage_t v = (pol & 1) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18; fe_sec_tone_mode_t t = high_band ? SEC_TONE_ON : SEC_TONE_OFF; - secSetVoltage(v, 15); + currentTransponder.polarization = pol; secSetTone(t, 15); - currentTransponder.polarization = pol;// & 1; + secSetVoltage(v, 100); } void CFrontend::sendDiseqcPowerOn(void) { // FIXME power on can take a while. Should be wait // more time here ? 15 ms enough for some switches ? -#if 1 printf("[fe%d] diseqc power on\n", fenumber); sendDiseqcZeroByteCommand(0xe0, 0x10, 0x03); -#else - struct dvb_diseqc_master_cmd cmd = { - {0xE0, 0x10, 0x03, 0x00, 0x00, 0x00}, 3 - }; - sendDiseqcCommand(&cmd, 100); -#endif } void CFrontend::sendDiseqcReset(void) { printf("[fe%d] diseqc reset\n", fenumber); +#if 0 /* Reset && Clear Reset */ sendDiseqcZeroByteCommand(0xe0, 0x10, 0x00); sendDiseqcZeroByteCommand(0xe0, 0x10, 0x01); - //sendDiseqcZeroByteCommand(0xe0, 0x00, 0x00); // enigma +#else + sendDiseqcZeroByteCommand(0xe0, 0x00, 0x00); // enigma +#endif } void CFrontend::sendDiseqcStandby(void) @@ -1402,7 +1285,6 @@ int CFrontend::driveToSatellitePosition(t_satellite_position satellitePosition, //if(config.diseqcType == DISEQC_ADVANCED) //FIXME testing { - //printf("[fe%d] SatellitePosition %d -> %d\n", fenumber, rotorSatellitePosition, satellitePosition); bool moved = false; sat_iterator_t sit = satellites.find(satellitePosition); @@ -1417,7 +1299,6 @@ int CFrontend::driveToSatellitePosition(t_satellite_position satellitePosition, if (sit != satellites.end()) old_position = sit->second.motor_position; - //printf("[fe%d] motorPosition %d -> %d usals %s\n", fenumber, old_position, new_position, use_usals ? "on" : "off"); printf("[fe%d] sat pos %d -> %d motor pos %d -> %d usals %s\n", fenumber, rotorSatellitePosition, satellitePosition, old_position, new_position, use_usals ? "on" : "off"); if (rotorSatellitePosition == satellitePosition) From 4758457e49f3902b0f097905433e6b5673d8efe5 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 11 Oct 2012 18:41:59 +0400 Subject: [PATCH 12/12] zapit/src/femanager.cpp: change frontend init: dont call setDiseqcType direct, setMode will call Init() or setMasterSlave(); force Init() on frontend re-open (leaving standby) --- src/zapit/src/femanager.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/zapit/src/femanager.cpp b/src/zapit/src/femanager.cpp index 26e669fc1..cabfe7127 100644 --- a/src/zapit/src/femanager.cpp +++ b/src/zapit/src/femanager.cpp @@ -170,8 +170,7 @@ bool CFEManager::loadSettings() frontend_config_t & fe_config = fe->getConfig(); INFO("load config for fe%d", fe->fenumber); - //fe_config.diseqcType = (diseqc_t) getConfigValue(fe, "diseqcType", NO_DISEQC); - diseqc_t diseqcType = (diseqc_t) getConfigValue(fe, "diseqcType", NO_DISEQC); + fe_config.diseqcType = (diseqc_t) getConfigValue(fe, "diseqcType", NO_DISEQC); fe_config.diseqcRepeats = getConfigValue(fe, "diseqcRepeats", 0); fe_config.motorRotationSpeed = getConfigValue(fe, "motorRotationSpeed", 18); fe_config.highVoltage = getConfigValue(fe, "highVoltage", 0); @@ -181,7 +180,10 @@ bool CFEManager::loadSettings() fe->setRotorSatellitePosition(getConfigValue(fe, "lastSatellitePosition", 0)); //fe->setDiseqcType((diseqc_t) fe_config.diseqcType); +#if 0 + diseqc_t diseqcType = (diseqc_t) getConfigValue(fe, "diseqcType", NO_DISEQC); fe->setDiseqcType(diseqcType); +#endif char cfg_key[81]; sprintf(cfg_key, "fe%d_satellites", fe->fenumber); @@ -265,27 +267,29 @@ void CFEManager::saveSettings(bool write) void CFEManager::setMode(fe_mode_t newmode, bool initial) { - if(newmode == mode) + if(!initial && (newmode == mode)) return; - if(femap.size() == 1) { - mode = FE_MODE_SINGLE; - return; - } mode = newmode; - bool setslave = (mode == FE_MODE_LOOP); + if(femap.size() == 1) + mode = FE_MODE_SINGLE; + + bool setslave = (mode == FE_MODE_LOOP) || (mode == FE_MODE_SINGLE); for(fe_map_iterator_t it = femap.begin(); it != femap.end(); it++) { + CFrontend * fe = it->second; if(it != femap.begin()) { - CFrontend * fe = it->second; INFO("Frontend %d as slave: %s", fe->fenumber, setslave ? "yes" : "no"); fe->setMasterSlave(setslave); - } + } else + fe->Init(); } +#if 0 if(setslave && !initial) { CFrontend * fe = getFE(0); fe->Close(); - fe->Open(); + fe->Open(true); } +#endif } void CFEManager::Open() @@ -293,7 +297,7 @@ void CFEManager::Open() for(fe_map_iterator_t it = femap.begin(); it != femap.end(); it++) { CFrontend * fe = it->second; if(!fe->Locked()) - fe->Open(); + fe->Open(true); } }