From 689ca98561d1d3cd2a42ee336b111e7a6c799026 Mon Sep 17 00:00:00 2001 From: TwolDE Date: Mon, 20 Jan 2025 08:38:18 +0100 Subject: [PATCH 01/17] [configure.ac] - re add MACHINEBUILD macro --- configure.ac | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 7ec00f2fc1..6266b25cc6 100644 --- a/configure.ac +++ b/configure.ac @@ -58,11 +58,12 @@ AC_ARG_WITH(boxtype, AC_SUBST(BOXTYPE) AC_DEFINE_UNQUOTED(BOXTYPE,"$BOXTYPE",[box type]) -AM_CONDITIONAL(AZBOX, test `echo "$BOXTYPE" | cut -b 1-5` == "azbox") -AM_CONDITIONAL(CUBE, test `echo "$BOXTYPE" | cut -b 1-4` == "cube") -AM_CONDITIONAL(DAGS, test `echo "$BOXTYPE" | cut -b 1-4` == "dags") -AM_CONDITIONAL(DREAMBOX, test `echo "$BOXTYPE" | cut -b 1-2` == "dm") -AM_CONDITIONAL(EBOX, test `echo "$BOXTYPE" | cut -b 1-4` == "ebox") +AC_ARG_WITH(machinebuild, + [ --with-machinebuild=NAME machine build [[none,atemeo5200,atemeo6000...]]], + [MACHINEBUILD="$withval"],[MACHINEBUILD="atemeo5200"]) +AC_SUBST(MACHINEBUILD) +AC_DEFINE_UNQUOTED(MACHINEBUILD,"$MACHINEBUILD",[machine build]) + AM_CONDITIONAL(GIGABLUE, test `echo "$BOXTYPE" | cut -b 1-2` == "gb") AM_CONDITIONAL(INI, test `echo "$BOXTYPE" | cut -b 1-3` == "ini") AM_CONDITIONAL(IXUSS, test `echo "$BOXTYPE" | cut -b 1-4` == "ixus") From cc77209b1bbc2dcb6ce69a0389e3dbe437a7f27d Mon Sep 17 00:00:00 2001 From: jbleyel Date: Tue, 26 Dec 2023 11:50:21 +0100 Subject: [PATCH 02/17] [Hardwaredb] * move device table to c --- configure.ac | 35 +++++++ include/Makefile.am | 3 +- include/hardwaredb.h | 197 +++++++++++++++++++++++++++++++++++++ lib/python/enigma_python.i | 13 +++ 4 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 include/hardwaredb.h diff --git a/configure.ac b/configure.ac index 6266b25cc6..4a3680d12f 100644 --- a/configure.ac +++ b/configure.ac @@ -64,6 +64,11 @@ AC_ARG_WITH(machinebuild, AC_SUBST(MACHINEBUILD) AC_DEFINE_UNQUOTED(MACHINEBUILD,"$MACHINEBUILD",[machine build]) +AM_CONDITIONAL(AZBOX, test `echo "$BOXTYPE" | cut -b 1-5` == "azbox") +AM_CONDITIONAL(CUBE, test `echo "$BOXTYPE" | cut -b 1-4` == "cube") +AM_CONDITIONAL(DAGS, test `echo "$BOXTYPE" | cut -b 1-4` == "dags") +AM_CONDITIONAL(DREAMBOX, test `echo "$BOXTYPE" | cut -b 1-2` == "dm") +AM_CONDITIONAL(EBOX, test `echo "$BOXTYPE" | cut -b 1-4` == "ebox") AM_CONDITIONAL(GIGABLUE, test `echo "$BOXTYPE" | cut -b 1-2` == "gb") AM_CONDITIONAL(INI, test `echo "$BOXTYPE" | cut -b 1-3` == "ini") AM_CONDITIONAL(IXUSS, test `echo "$BOXTYPE" | cut -b 1-4` == "ixus") @@ -165,6 +170,36 @@ AM_CONDITIONAL(XC7358CI, test "$BOXTYPE" == xc7358ci) AM_CONDITIONAL(XC7362, test "$BOXTYPE" == xc7362) AM_CONDITIONAL(XP1000, test "$BOXTYPE" == xp1000) +AS_IF([test "$BOXTYPE" == "dm900"],[AC_DEFINE(HWDM900, 1,[dm900])]) +AS_IF([test "$BOXTYPE" == "dm920"],[AC_DEFINE(HWDM920, 1,[dm920])]) +AS_IF([test "$BOXTYPE" == "vusolo4k"],[AC_DEFINE(HWVUSOLO4K, 1,[vusolo4k])]) +AS_IF([test "$BOXTYPE" == "vuultimo4k"],[AC_DEFINE(HWULTIMO4K, 1,[vuultimo4k])]) +AS_IF([test "$BOXTYPE" == "vuduo4k"],[AC_DEFINE(HWDUO4K, 1,[vuduo4k])]) +AS_IF([test "$BOXTYPE" == "vuduo4kse"],[AC_DEFINE(HWDUO4KSE, 1,[vuduo4kse])]) +AS_IF([test "$BOXTYPE" == "vuduo2"],[AC_DEFINE(HWDUO2, 1,[vuduo2])]) +AS_IF([test "$BOXTYPE" == "vuuno4kse"],[AC_DEFINE(HWUNO4KSE, 1,[vuuno4kse])]) +AS_IF([test "$BOXTYPE" == "h7"],[AC_DEFINE(HWH7, 1,[h7])]) +AS_IF([test "$BOXTYPE" == "h17"],[AC_DEFINE(HWH17, 1,[h17])]) +AS_IF([test "$BOXTYPE" == "pulse4k"],[AC_DEFINE(HWPULSE4K, 1,[pulse4k])]) +AS_IF([test "$BOXTYPE" == "pulse4kmini"],[AC_DEFINE(HWPULSE4KMINI, 1,[pulse4kmini])]) +AS_IF([test "$MACHINEBUILD" == "gbue4k"],[AC_DEFINE(HWGBUE4K, 1,[gbue4k])]) +AS_IF([test "$MACHINEBUILD" == "gbtrio4k"],[AC_DEFINE(HWGBTRIO4K, 1,[gbtrio4k])]) +AS_IF([test "$MACHINEBUILD" == "gbtrio4kpro"],[AC_DEFINE(HWGBTRIO4KPRO, 1,[gbtrio4kpro])]) +AS_IF([test "$MACHINEBUILD" == "gbquad4kpro"],[AC_DEFINE(HWGBQUAD4KPRO, 1,[gbquad4kpro])]) +AS_IF([test "$MACHINEBUILD" == "beyonwizt2"],[AC_DEFINE(HWBEYONWIZT2, 1,[beyonwizt2])]) +AS_IF([test "$MACHINEBUILD" == "gbquad4k"],[AC_DEFINE(HWGBQUAD4K, 1,[gbquad4k])]) +AS_IF([test "$BOXTYPE" == "u5"],[AC_DEFINE(HWU5, 1,[u5])]) +AS_IF([test "$BOXTYPE" == "hd51"],[AC_DEFINE(HWHD51, 1,[hd51])]) +AS_IF([test "$BOXTYPE" == "hd61"],[AC_DEFINE(HWHD61, 1,[hd61])]) +AS_IF([test "$BOXTYPE" == "sfx6008"],[AC_DEFINE(HWSFX6008, 1,[sfx6008])]) +AS_IF([test "$BOXTYPE" == "osnino"],[AC_DEFINE(HWOSNINO, 1,[osnino])]) +AS_IF([test "$BOXTYPE" == "h10"],[AC_DEFINE(HWH10, 1,[h10])]) +AS_IF([test "$BOXTYPE" == "multiboxpro"],[AC_DEFINE(HWMULTIBOXPRO, 1,[multiboxpro])]) +AS_IF([test "$BOXTYPE" == "sf8008"],[AC_DEFINE(HWSF8008, 1,[sf8008])]) +AS_IF([test "$BOXTYPE" == "et7x00"],[AC_DEFINE(HWET7X00, 1,[et7x00])]) +AS_IF([test "$BOXTYPE" == "h9combo"],[AC_DEFINE(HWH9COMBO, 1,[h9combo])]) +AS_IF([test "$BOXTYPE" == "h9"],[AC_DEFINE(HWH9, 1,[h9])]) + AC_ARG_WITH(accelerationthreshold, AS_HELP_STRING([--with-accelerationthreshold=n], [use acceleration threshold of n bytes]), [[with_accelerationthreshold=$withval]], diff --git a/include/Makefile.am b/include/Makefile.am index 24adb96739..6a4efea403 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,4 +2,5 @@ pkginclude_HEADERS = \ connection.h \ libsig_comp.h \ nanosvg.h \ - nanosvgrast.h + nanosvgrast.h \ + hardwaredb.h diff --git a/include/hardwaredb.h b/include/hardwaredb.h new file mode 100644 index 0000000000..c327fd9025 --- /dev/null +++ b/include/hardwaredb.h @@ -0,0 +1,197 @@ +/* +Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License + +Copyright (c) 2023-2025 OpenATV, jbleyel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +1. Non-Commercial Use: You may not use the Software or any derivative works + for commercial purposes without obtaining explicit permission from the + copyright holder. +2. Share Alike: If you distribute or publicly perform the Software or any + derivative works, you must do so under the same license terms, and you + must make the source code of any derivative works available to the + public. +3. Attribution: You must give appropriate credit to the original author(s) + of the Software by including a prominent notice in your derivative works. +THE SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, +ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more details about the CC BY-NC-SA 4.0 License, please visit: +https://creativecommons.org/licenses/by-nc-sa/4.0/ +*/ + +#ifndef __hardwaredb_h +#define __hardwaredb_h +#include +#include + +static std::unordered_map HardwareDB{ + +#ifdef HWDM900 + {"/devices/platform/brcmstb-ahci.0/ata1/", "SATA"}, + {"/devices/rdb.4/f03e0000.sdhci/mmc_host/mmc0/", "eMMC"}, + {"/devices/rdb.4/f03e0200.sdhci/mmc_host/mmc1/", "SD"}, + {"/devices/rdb.4/f0470600.ohci_v2/usb6/6-0:1.0", "Front panel USB"}, + {"/devices/rdb.4/f0470300.ehci_v2/usb3/3-0:1.0", "Front panel USB"}, + {"/devices/rdb.4/f0471000.xhci_v2/usb2/2-0:1.0", "Front panel USB"}, + {"/devices/rdb.4/f0470300.ehci_v2/usb3/3-1/3-1:1.0", "Front panel USB"}, + {"/devices/rdb.4/f0470400.ohci_v2/usb5/5-0:1.0", "Rear USB"}, + {"/devices/rdb.4/f0470500.ehci_v2/usb4/4-0:1.0", "Rear USB"}, + {"/devices/rdb.4/f0470500.ehci_v2/usb4/4-1/4-1:1.0", "Rear USB"}, + {"/devices/rdb.4/f0471000.xhci_v2/usb2/2-0:1.0", "Rear USB"} +#elif HWDM920 + {"/devices/platform/brcmstb-ahci.0/ata1/", "SATA"}, + {"/devices/rdb.4/f03e0000.sdhci/mmc_host/mmc0/", "eMMC"}, + {"/devices/rdb.4/f03e0200.sdhci/mmc_host/mmc1/", "SD"}, + {"/devices/rdb.4/f0470600.ohci_v2/usb6/6-0:1.0/port1/", "Front USB"}, + {"/devices/rdb.4/f0470300.ehci_v2/usb3/3-0:1.0/port1/", "Front USB"}, + {"/devices/rdb.4/f0471000.xhci_v2/usb2/2-0:1.0/port1/", "Front USB"}, + {"/devices/rdb.4/f0470400.ohci_v2/usb5/5-0:1.0/port1/", "Rear USB"}, + {"/devices/rdb.4/f0470500.ehci_v2/usb4/4-0:1.0/port1/", "Rear USB"}, + {"/devices/rdb.4/f0471000.xhci_v2/usb2/2-0:1.0/port2/", "Rear USB"} +#elif HWVUSOLO4K + {"/devices/platform/strict-ahci.0/ata1/", "SATA"}, + {"/devices/f0490600.ohci/usb10/", "Front USB"}, + {"/devices/f0480400.ohci/usb7/", "Rear USB 3.0 lower"}, + {"/devices/f0480600.ohci/usb8/", "Rear USB 3.0 upper"} +#elif HWUNO4KSE + {"/devices/platform/rdb/f045a000.sata/ata1/", "SATA"}, + {"/devices/platform/rdb/f0470300.ehci_v2/usb3/3-1/3-1", "Rear USB 3.0 lower"}, + {"/devices/platform/rdb/f0471000.xhci_v2/usb2/2-1/2-1", "Rear USB 3.0 lower"}, + {"/devices/platform/rdb/f0470500.ehci_v2/usb4/4-1/4-1", "Rear USB 3.0 upper"}, + {"/devices/platform/rdb/f0471000.xhci_v2/usb2/2-2/2-2", "Rear USB 3.0 upper"} +#elif HWDUO2 // CHECKED + {"/devices/platform/strict-ahci.0/ata1/", "eSATA"}, + {"/devices/platform/ehci-brcm.2/usb3/", "Front USB"}, + {"/devices/platform/ehci-brcm.0/usb1/", "Rear USB lower"}, + {"/devices/platform/ehci-brcm.1/usb2/", "Rear USB upper"} +#elif HWDUO4K + {"/devices/platform/rdb/8b0a000.sata/", "SATA"}, + {"/devices/platform/rdb/8b39000.xhci_v2/usb1/", "Front USB"}, + {"/devices/platform/rdb/8b39000.xhci_v2/usb2/2-2/", "Rear USB 3.0 upper"}, + {"/devices/platform/rdb/8b39000.xhci_v2/usb2/2-1/", "Rear USB 3.0 lower"} +#elif HWDUO4KSE + {"/devices/platform/rdb/f045a000.sata/", "SATA"}, + {"/devices/platform/rdb/f0480500.ehci_v2/usb6/", "Front USB"}, + {"/devices/platform/rdb/f0471000.xhci_v2/usb2/2-2/", "Rear USB 3.0 upper"}, + {"/devices/platform/rdb/f0471000.xhci_v2/usb2/2-1/", "Rear USB 3.0 lower"} +#elif HWVUULTIMO4K + {"/devices/platform/brcmstb-ahci.0/ata1", "SATA"}, + {"/devices/rdb.3/f0470300.ehci_v2/usb3/", "Rear USB 3.0 lower"}, + {"/devices/rdb.3/f0470500.ehci_v2/usb4/", "Rear USB 3.0 upper"}, + {"/devices/rdb.3/f0480600.ohci_v2/usb10/", "Front USB"} +#elif HWH7 + {"/devices/platform/rdb/f045a000.sata/ata1/", "SATA"}, + {"/devices/platform/f0470500.ehci/usb2/", "Rear USB 3.0"}, + {"/devices/platform/f0470300.ehci/usb1/1-1/1-1.2/", "Rear USB lower"}, + {"/devices/platform/f0470300.ehci/usb1/1-1/1-1.1/", "Rear USB upper"} +#elif HWH17 // CHECKED + {"/devices/platform/f0470300.ehci/usb1/", "Front USB"}, + {"/devices/platform/f0471000.xhci/usb6/", "Rear USB"}, + {"/devices/platform/f0471000.ohci/usb4/", "Rear USB"}, + {"/devices/platform/f0470500.ehci/usb2/", "Rear USB"} +#elif HWPULSE4K + {"/devices/platform/soc/f9900000.hiahci/ata1/host0/target0:0:0/0:0:0:0", "SATA"}, + {"/devices/platform/soc/f98a0000.xhci/usb3/", "Front USB"}, + {"/devices/platform/soc/f9890000.ehci/usb1/", "Rear USB"} +#elif HWPULSE4KMINI // CHECKED + {"/devices/platform/soc/f9820000.himciv200.SD/mmc_host/mmc1/", "microSD"}, + {"/devices/platform/soc/f9890000.ehci/usb1/", "Rear upper USB"}, + {"/devices/platform/soc/f98a0000.xhci/usb4/", "Rear lower USB"}, + {"/devices/platform/soc/f98a0000.xhci/usb3/", "Rear lower USB"} +#elif HWGBTRIO4K // CHECKED + {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1.3/1-1.3:1.0", "Rear right microSD"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1.2/1-1.2:1.0", "Rear right USB"}, + {"/devices/platform/soc/f98a0000.xhci/usb3/3-1/3-1:1.0", "Rear left USB 3.0"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-2/1-2:1.0", "Front panel USB"} +#elif HWGBTRIO4KPRO // CHECKED + {"/devices/platform/soc/f9890000.ehci/usb1/1-2/1-2", "microSD"}, + {"/devices/platform/soc/f98a0000.xhci/usb4/4-1/4-1", "Rear USB left"}, + {"/devices/platform/soc/f98a0000.xhci/usb3/3-1/3-1", "Rear USB left"}, + {"/devices/platform/soc/f9880000.ohci/usb2/2-1/2-1", "Rear USB right"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1", "Rear USB right"} +#elif HWGBUE4K + {"/devices/platform/rdb/f045a000.sata/ata2/", "SATA"}, + {"/devices/platform/rdb/f0470300.ehci_v2/usb3/3-1/3-1.1/3-1.1:", "Front panel USB"}, + {"/devices/platform/rdb/f0470500.ehci_v2/usb4/", "Rear USB 3.0"}, + {"/devices/platform/rdb/f0470300.ehci_v2/usb3/3-1/3-1.2/3-1.2:", "Rear upper USB"}, + {"/devices/platform/rdb/f0470300.ehci_v2/usb3/3-1/3-1.3/3-1.3:", "Rear lower USB"} +#elif HWGBQUAD4K + {"/devices/platform/rdb/f045a000.sata/", "SATA"}, + {"/devices/platform/rdb/f0470500.ehci_v2/usb4/4-1/4-1.4/4-1.4:1.0", "Rear middle USB 3.0 left"}, + {"/devices/platform/rdb/f0471000.xhci_v2/usb2/2-2/2-2.3/2-2.3:1.0", "Rear middle USB 3.0 right"}, + {"/devices/platform/rdb/f0470500.ehci_v2/usb4/4-1/4-1.2/4-1.2:1.0", "Rear right lower USB"}, + {"/devices/platform/rdb/f0470500.ehci_v2/usb4/4-1/4-1.1/4-1.1:1.0", "Rear right upper USB"}, + {"/devices/platform/rdb/f0470300.ehci_v2/usb3/3-1/3-1:1.0", "Front panel, USB"} +#elif HWGBQUAD4KPRO // CHECKED + {"/devices/platform/rdb/f045a000.sata/", "SATA"}, + {"/devices/platform/rdb/f03e0000.sdhci/mmc_host/", "SD"}, + {"/devices/platform/rdb/f0470500.ehci_v2/usb4/4-1/4-1.1", "Front USB"}, + {"/devices/platform/rdb/f0471000.xhci_v2/usb2/2-2/2-2.1", "Front USB"}, + {"/devices/platform/rdb/f0470500.ehci_v2/usb4/4-1/4-1.4", "Rear USB right"}, + {"/devices/platform/rdb/f0471000.xhci_v2/usb2/2-2/2-2.4", "Rear USB right"}, + {"/devices/platform/rdb/f0470300.ehci_v2/usb3/3-1/3-1", "Rear USB 3.0, left"}, + {"/devices/platform/rdb/f0471000.xhci_v2/usb2/2-1/2-1", "Rear USB 3.0, left"}, + {"/devices/platform/rdb/f0470500.ehci_v2/usb4/4-1/4-1.3", "Rear USB-C"}, + {"/devices/platform/rdb/f0471000.xhci_v2/usb2/2-2/2-2.3", "Rear USB-C"} +#elif HWHD51 // CHECKED + {"/devices/platform/rdb/f045a000.sata/ata1/", "SATA"}, + {"/devices/platform/f0470300.ehci/usb1/1-1/1-1.2", "Front USB"}, + {"/devices/platform/f0470300.ehci/usb1/1-1/1-1.3", "Rear USB left"}, + {"/devices/platform/f0471000.xhci/usb6/6-2/6-2", "Rear USB right"}, + {"/devices/platform/f0470500.ehci/usb2/2-1/2-1", "Rear USB right"} +#elif HWHD61 // CHECKED + {"/devices/platform/soc/f9820000.himciv200.SD/mmc_host/mmc1", "Front panel, microSD"}, + {"/devices/platform/soc/f98a0000.xhci/usb3/3-1/3-1", "Front panel USB"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1", "Rear USB"}, + {"/devices/platform/soc/f9900000.hiahci/ata1/", "SATA"} +#elif HWSFX6008 // CHECKED + {"/devices/platform/soc/f98a0000.xhci/usb3/3-1/3-1", "Left USB"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-1", "Rear USB"} +#elif HWOSNINO // CHECKED + {"/devices/platform/ehci-brcm.0/usb1/1-2", "Front USB right"}, + {"/devices/platform/ehci-brcm.0/usb1/1-1", "Rear USB right"} +#elif HWMULTIBOXPRO // CHECKED + {"/devices/platform/soc/f98a0000.xhci/usb3", "Rear USB left"}, + {"/devices/platform/soc/f9890000.ehci/usb1", "Rear USB right"}, + {"/devices/platform/soc/f9820000.himciv200.SD/mmc_host/mmc1", "microSD"} +#elif HWU5 // eg. Dinobot4k + {"/devices/platform/soc/f98a0000.xhci/usb3/", "Rear USB"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-2/1-2.3/", "Rear USB Left"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-2/1-2.4/", "Front Left USB"} +#elif HWSF8008 + {"/devices/platform/soc/f98a0000.xhci/usb4/4-1/4-1", "Right USB"}, + {"/devices/platform/soc/f98a0000.xhci/usb4/3-1/3-1", "Right USB"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1.2", "Rear USB"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1.3", "Rear microSD"} +#elif HWET7X00 // CHECKED + {"/devices/platform/ehci-brcm.0/usb1/1-1/1-1:1.0", "Rear USB"}, + {"/devices/platform/ehci-brcm.0/usb1/1-2/1-2:1.0", "Front panel USB"} +#elif HWH9COMBO // CHECKED + {"/devices/platform/soc/f9820000.himciv200.SD/mmc_host/mmc1/mmc1:0007", "Rear microSD"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1:1.0", "Rear USB"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-2/1-2.4/1-2.4:1.0", "Front panel USB"} +#elif HWH9 // CHECKED + {"/devices/platform/soc/f9820000.himciv200.SD/mmc_host/mmc0/mmc0:0007", "Rear microSD"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1:1.0", "Rear USB"} +#elif HWH10 // CHECKED + {"/devices/platform/soc/f9890000.ehci/usb1/1-1", "Rear USB left"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-2", "Rear USB right"}, + {"/devices/platform/soc/f9900000.hiahci/ata1/", "SATA"} +#else + +#endif + +}; + +#endif diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index fc9f3e90ea..35e15235c1 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -115,6 +115,7 @@ is usually caused by not marking PSignals as immutable. #include #include #include +#include %} %feature("ref") iObject "$this->AddRef(); /* eDebug(\"AddRef (%s:%d)!\", __FILE__, __LINE__); */ " @@ -453,6 +454,18 @@ PyObject *getFontFaces() } %} +PyObject *getDeviceDB(); +%{ +PyObject *getDeviceDB() +{ + ePyObject result = PyDict_New(); + for (const auto & [ key, value ] : HardwareDB) { + PutToDict(result, key.c_str(), value.c_str()); + } + return result; +} +%} + /************** temp *****************/ /* need a better place for this, i agree. */ From 0037ea06d39be3ba256e791ee0cb08dba1eab59c Mon Sep 17 00:00:00 2001 From: TwolDE Date: Mon, 20 Jan 2025 10:52:26 +0100 Subject: [PATCH 03/17] [Harddisk] - add device port routine --- lib/python/Components/Harddisk.py | 35 +++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 5680c96284..cc9293b808 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -5,7 +5,7 @@ from re import sub from time import sleep, time -from enigma import eTimer +from enigma import getDeviceDB, eTimer from Components.Console import Console from Components.SystemInfo import SystemInfo, BoxInfo import Components.Task @@ -200,14 +200,27 @@ def bus(self): if self.internal: busName = _("Internal") if self.rotational == 0: - busName = "%s%s" % (busName, " (SSD)") + busName = f"{busName}{' (SSD)'}" else: - busName = "%s%s" % (busName, " (HDD)") + busName = f"{busName}{' (HDD)'}" else: - busName = _("External") - busName = "%s (%s)" % (busName, self.busType) + busName = self.port() + if not busName: + busName = _("External") + busName = f"{busName} ({self.busType})" return busName + def port(self): + print(f"[Harddisk][port] physicalDevice:{self.phys_path}") + print(f"[Harddisk][port] list(getDeviceDB().items() {list(getDeviceDB().items())}") + portDescription = "" + for physdevprefix, pdescription in list(getDeviceDB().items()): + print(f"[Harddisk][port] physdevprefix:{physdevprefix} pdescription:{pdescription}") + if self.phys_path.replace("/sys", "").startswith(physdevprefix): + portDescription = pdescription + print(f"[Harddisk][bus] portDescription:{portDescription}") + return portDescription + def diskSize(self): # output in MB dev = self.findMount() @@ -241,14 +254,14 @@ def model(self): vendor = readFile(ospath.join(self.phys_path, "vendor")) model = readFile(ospath.join(self.phys_path, "model")) if vendor or model and vendor != model: - data = "%s (%s)" % (vendor, model) + data = f"{vendor} ({model})" elif self.device.startswith("mmcblk"): data = readFile(self.sysfsPath("device/name")) else: msg = " Device not hdX or sdX or mmcX." if data is None: - print("[Harddisk] Error: Failed to get model!%s:" % msg) - return "Unknown" + print("[Harddisk][model] Error: Failed to get model! msg:", msg) + return "Unknown model" return data def free(self, dev=None): @@ -965,12 +978,12 @@ def HDDCount(self): def HDDList(self): list = [] for hd in self.hdd: - hdd = "%s - %s" % (hd.model(), hd.bus()) + print(f"[Harddsk][HDDList] {hd.model()} {hd.bus()} /dev/{hd.device}.") + hdd = f"{hd.bus()} {hd.model()} /dev/{hd.device}" cap = hd.capacity() if cap != "": - hdd += " (%s)" % cap + hdd += f" {cap}" list.append((hdd, hd)) - # print("[Harddisk] HDDlist = %s." % list) return list def getCD(self): From 3bed495dcbb34fcfc076f14500e8b0e466972eba Mon Sep 17 00:00:00 2001 From: TwolDE Date: Mon, 20 Jan 2025 10:56:50 +0100 Subject: [PATCH 04/17] [Harddisk] use format --- lib/python/Components/Harddisk.py | 238 ++++++++++++++++-------------- 1 file changed, 125 insertions(+), 113 deletions(-) diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index cc9293b808..3abca85916 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -12,7 +12,7 @@ from Tools.CList import CList from Tools.Directories import fileReadLines, fileReadLine, fileWriteLines -# DEBUG: REMINDER: This comment needs to be expanded for the benefit of readers. +# : REMINDER: This comment needs to be expanded for the benefit of readers. # Removable if 1 --> With motor # Internal if 1 --> SATA disk # Rotational if 0 --> SSD or MMC, 1 --> HDD @@ -76,11 +76,11 @@ def readFile(filename): def runCommand(command): - print("[Harddisk] Command: '%s'." % command) + print(f"[Harddisk][runCommand]: '{command}'.") exitStatus = ossystem(command) exitStatus = exitStatus >> 8 if exitStatus: - print("[Harddisk] Error: Command '%s' returned error code %d!" % (command, exitStatus)) + print(f"[Harddisk][runCommand] '{command}' returned error code {exitStatus}!") return exitStatus @@ -127,7 +127,7 @@ def addInstallTask(job, package): task = Components.Task.LoggingTask(job, _("Update packages...")) task.setTool("opkg") task.args.append("update") - task = Components.Task.LoggingTask(job, _("Install '%s'") % package) + task = Components.Task.LoggingTask(job, _(f"Install '{package}'")) task.setTool("opkg") task.args.append("install") task.args.append(package) @@ -167,17 +167,16 @@ def __init__(self, device, removable=False, model=None): self.dev_path = ospath.join("/dev", self.device) self.disk_path = self.dev_path self.sdmmc = "MMC" in self.busType - # print("[Harddisk] self.sdmmc1", self.sdmmc) if (self.internal or not removable) and not self.sdmmc: msg = " (Start Idle)" self.startIdle() else: msg = "" - print("[Harddisk] Device '%s' (%s - %s) -> '%s' -> '%s'%s." % (self.device, self.bus(), self.model(), self.dev_path, self.disk_path, msg)) + print(f"[Harddisk][Init] Device '{self.device}' ({self.bus()} - {self.model()}) -> '{self.dev_path}' -> '{self.disk_path}'{msg}.") def __str__(self): - return "Harddisk(device=%s, devPath=%s, diskPath=%s, physPath=%s, internal=%s, rotational=%s, removable=%s)" % (self.device, self.dev_path, self.disk_path, self.phys_path, self.internal, self.rotational, self.removable) + return f"Harddisk(device={self.device}, devPath={self.dev_path}, diskPath={self.disk_path}, physPath={self.phys_path}, internal={self.internal}, rotational={self.rotational}, removable={self.removable})" def __lt__(self, ob): return self.device < ob.device @@ -187,9 +186,9 @@ def sysfsPath(self, filename): def partitionPath(self, n): if self.dev_path.startswith("/dev/mmcblk"): - return "%sp%s" % (self.dev_path, n) + return f"{self.dev_path}p{n}" else: - return "%s%s" % (self.dev_path, n) + return f"{self.dev_path}{n}" def stop(self): if self.timer: @@ -227,10 +226,10 @@ def diskSize(self): if dev: try: stat = statvfs(dev) - print("[Harddisk] [diskSize]: stat.f_blocks: %s stat.f_bsize: %s" % (stat.f_blocks, stat.f_bsize)) + # print(f"[Harddisk][diskSize]: stat.f_blocks: {stat.f_blocks} stat.f_bsize: {stat.f_bsize}") cap = int((stat.f_blocks * stat.f_bsize) / 1000 / 1000) except (IOError, OSError) as err: - print("[Harddisk] Error: Failed to get disk size for '%s':" % dev, err) + print(f"[Harddisk][diskSize] Error: Failed to get disk size for '{dev}':", err) cap = 0 else: data = readFile(self.sysfsPath("size")) @@ -267,26 +266,26 @@ def model(self): def free(self, dev=None): if dev is None: dev = self.findMount() - print("[Harddisk][free]dev:", dev) + # print("[Harddisk][free]dev:", dev) if dev: try: stat = statvfs(dev) return (stat.f_bfree / 1000) * (stat.f_bsize / 1000) except (IOError, OSError) as err: - print("[Harddisk] Error: Failed to get free space for '%s' %s:" % dev, err) + print(f"[Harddisk][free] Error: Failed to get free space for '{dev}' :", err) return -1 def totalFree(self): # output in MB mediapath = [] freetot = 0 - print("[Harddisk][totalFree]self.dev_path:", self.dev_path) + # print("[Harddisk][totalFree]self.dev_path:", self.dev_path) for parts in getProcMounts(): if ospath.realpath(parts[0]).startswith(self.dev_path): mediapath.append(parts[1]) - print("[Harddisk][totalFree]mediapath:", mediapath) + # print("[Harddisk][totalFree]mediapath:", mediapath) for mpath in mediapath: - print("[Harddisk][totalFree]mpath:", mpath) + # print("[Harddisk][totalFree]mpath:", mpath) if mpath == "/" and SystemInfo["HasKexecMultiboot"]: continue free = self.free(mpath) @@ -312,7 +311,7 @@ def mountDevice(self): if ospath.realpath(parts[0]).startswith(self.dev_path): self.mount_device = parts[0] self.mount_path = parts[1] - print("[Harddisk][mountDevice]device, path", parts[0], " ", parts[1]) + # print("[Harddisk][mountDevice]device, path", parts[0], " ", parts[1]) return parts[1] return None @@ -330,7 +329,7 @@ def unmount(self): dev = self.mountDevice() if dev is None: return 0 # Not mounted, return OK. - return runCommand("umount %s" % dev) + return runCommand(f"umount {dev}") def createPartition(self): return runCommand("printf \"8,\n;0,0\n;0,0\n;0,0\ny\n\" | sfdisk -f -uS %s" % self.disk_path) @@ -338,21 +337,26 @@ def createPartition(self): def mount(self): if self.mount_device is None: # Try mounting through fstab first. dev = self.partitionPath("1") + print("[Harddisk][mount] mounting1:in fstab", dev) else: dev = self.mount_device # If previously mounted, use the same spot. + print("[Harddisk][mount] mounting2: not in fstab", dev) try: with open("/etc/fstab", "r") as fd: for line in fd.readlines(): parts = line.strip().split(" ") fspath = ospath.realpath(parts[0]) if fspath == dev: - return runCommand("mount -t auto %s" % fspath) + print("[Harddisk] mounting3:dev, fspath", dev, " ", fspath) + exitCode = runCommand(f"mount -t auto {fspath}") + return exitCode >> 8 except (IOError, OSError): return -1 + print("[Harddisk][mount] mounting4: not in fstab", dev) exitCode = -1 # Device is not in fstab. - exitCode = runCommand("hdparm -z %s" % self.disk_path) # We can let udev do the job, re-read the partition table. + exitCode = runCommand(f"hdparm -z {self.disk_path}") # We can let udev do the job, re-read the partition table. sleep(3) # Give udev some time to make the mount, which it will do asynchronously. - return exitCode + return exitCode >> 8 def killPartitionTable(self): zero = 512 * b"\0" @@ -361,7 +365,7 @@ def killPartitionTable(self): for i in range(9): # Delete first 9 sectors, which will likely kill the first partition too. fd.write(zero) except (IOError, OSError) as err: - print("[Harddisk] Error: Failed to wipe partition table on '%s':" % self.dev_path, err) + print(f"[Harddisk][killPartitionTable] Error: Failed to wipe partition table on '{self.dev_path}':", err) def killPartition(self, n): zero = 512 * b"\0" @@ -371,13 +375,13 @@ def killPartition(self, n): for i in range(3): fd.write(zero) except (IOError, OSError) as err: - print("[Harddisk] Error: Failed to wipe partition on '%s':" % partition, err) + print(f"[Harddisk][killPartition] Error: Failed to wipe partition on '{partition}':", err) def createInitializeJob(self): - print("[Harddisk] Initializing storage device...") + print("[Harddisk][createInitializeJob] Initializing storage device...") job = Components.Task.Job(_("Initializing storage device...")) size = self.diskSize() - print("[Harddisk] Disk size: %s MB." % size) + print(f"[Harddisk][createInitializeJob] Disk size: {size} MB.") task = UnmountTask(job, self) task = Components.Task.PythonTask(job, _("Removing partition table.")) task.work = self.killPartitionTable @@ -402,7 +406,7 @@ def createInitializeJob(self): task.check = lambda: ospath.exists(self.partitionPath("1")) task.weighting = 1 task = UnmountTask(job, self) - print("[Harddisk] Creating filesystem.") + print("[Harddisk][createInitializeJob] Creating filesystem.") task = MkfsTask(job, _("Creating filesystem.")) big_o_options = ["dir_index"] task.setTool("mkfs.ext4") @@ -417,15 +421,15 @@ def createInitializeJob(self): task.args += ["-F", "-F", "-m0", "-O ^metadata_csum", "-O", ",".join(big_o_options), self.partitionPath("1")] task = MountTask(job, self) task.weighting = 3 - print("[Harddisk] Mounting storage device.") - task = Components.Task.ConditionTask(job, _("Waiting for mount."), timeoutCount=20) + print("[Harddisk][createInitializeJob] Mounting storage device.") + task = Components.Task.ConditionTask(job, _("Waiting for mount"), timeoutCount=30) task.check = self.mountDevice task.weighting = 1 - print("[Harddisk] Initialization complete.") + print("[Harddisk][createInitializeJob] Initialization complete.") return job def createCheckJob(self): - print("[Harddisk] Checking filesystem...") + print("[Harddisk][createCheckJob] Checking filesystem...") job = Components.Task.Job(_("Checking filesystem...")) if self.findMount(): task = UnmountTask(job, self) # Create unmount task if it was not mounted. @@ -437,9 +441,9 @@ def createCheckJob(self): partType = parts[2] if partType not in ("ext3", "ext4", "vfat", "nfs"): partType = "ext4" - print("[Harddisk] Filesystem type is '%s'." % partType) + print(f"[Harddisk][createCheckJob] Filesystem type is '{partType}'.") task = Components.Task.LoggingTask(job, _("Checking disk.")) # "fsck" - task.setTool("fsck.%s" % partType) + task.setTool(f"fsck.{partType}") task.args.append("-f") task.args.append("-p") task.args.append(dev) @@ -448,7 +452,7 @@ def createCheckJob(self): task = Components.Task.ConditionTask(job, _("Waiting for mount.")) task.check = self.mountDevice task.weighting = 1 - print("[Harddisk] Check complete.") + print("[Harddisk][createCheckJob] Check complete.") return job def getDeviceDir(self): @@ -491,7 +495,7 @@ def readStats(self): filename = ospath.join("/sys/block", self.device, "stat") data = readFile(filename) if data is None: - print("[Harddisk] Error: Failed to read '%s' stats!" % filename) + print(f"[Harddisk][readStats] Error: Failed to read '{filename}' stats!") return -1, -1 data = data.split() return int(data[0]), int(data[4]) # Return read I/O's, write I/O's. @@ -499,11 +503,11 @@ def readStats(self): def startIdle(self): # Disable HDD standby timer. if self.internal: - runCommand("hdparm -S0 %s" % self.disk_path) + runCommand(f"hdparm -S0 {self.disk_path}") else: - exitCode = runCommand("sdparm --set=SCT=0 %s" % self.disk_path) + exitCode = runCommand(f"sdparm --set=SCT=0 {self.disk_path}") if exitCode: - runCommand("hdparm -S0 %s" % self.disk_path) + runCommand(f"hdparm -S0 {self.disk_path}") self.timer = eTimer() self.timer.callback.append(self.runIdle) self.idle_running = True @@ -526,11 +530,11 @@ def runIdle(self): def setSleep(self): if self.internal: - runCommand("hdparm -y %s" % self.disk_path) + runCommand(f"hdparm -y {self.disk_path}") else: - exitCode = runCommand("sdparm --flexible --readonly --command=stop %s" % self.disk_path) + exitCode = runCommand(f"sdparm --flexible --readonly --command=stop {self.disk_path}") if exitCode: - runCommand("hdparm -y %s" % self.disk_path) + runCommand(f"hdparm -y {self.disk_path}") def setIdleTime(self, idle): self.max_idle_time = idle @@ -549,7 +553,7 @@ def deviceState(self, device): return (False, "ERROR") match = None for bus in hotplugBuses: - if "/%s" % bus in self.phys_path: + if f"/{bus}" in self.phys_path: match = bus break @@ -557,10 +561,10 @@ def deviceState(self, device): match = None if match: - # print("[Harddisk] DEBUG: Device is removable. (device='%s', match='%s')" % (device, match)) + # print(f"[Harddisk][deviceState] Device is removable. (device='{device}', match='[match}')") return (False, match.upper()) else: - # print("[Harddisk] DEBUG: Device is not removable. (device='%s', No bus)" % (device)) + # print(f"[Harddisk][deviceState] Device is not removable. (device='{device}, No bus)") return (True, "ATA") @@ -574,13 +578,13 @@ def __init__(self, mountpoint, device=None, description="", force_mounted=False) self.is_hotplug = force_mounted # So far; this might change. def __str__(self): - return "Partition(mountpoint = %s, description = %s, device = %s)" % (self.mountpoint, self.description, self.device) + return f"Partition(mountpoint = {self.mountpoint}, description = {self.description}, device = {self.device})" def stat(self): if self.mountpoint: return statvfs(self.mountpoint) else: - raise OSError("Device '%s' is not mounted!" % self.device) + raise OSError(f"Device '{self.device}' is not mounted!") def free(self): try: @@ -620,7 +624,7 @@ def filesystem(self, mounts=None): mounts = getProcMounts() for fields in mounts: if self.mountpoint.endswith(ossep) and not self.mountpoint == ossep: - if "%s%s" % (fields[1], ossep) == self.mountpoint: + if f"{fields[1]}{ossep}" == self.mountpoint: return fields[2] else: if fields[1] == self.mountpoint: @@ -718,9 +722,9 @@ def parseDeviceData(inputData): callback() def enumerateBlockDevices(self): - print("[Harddisk] Enumerating block devices...") + print("[Harddisk][enumerateBlockDevices] Enumerating block devices...") self.partitions.append(Partition(mountpoint="/", description=("Internal flash"))) # Add the root device. - # print("[Harddisk] DEBUG: Partition(mountpoint=%s, description=%s)" % ("/", _("Internal flash"))) + # print(f"[Harddisk][enumerateBlockDevices] : Partition(mountpoint={'/'}, description={_("Internal flash")})") try: rootDev = stat("/").st_dev rootMajor = major(rootDev) @@ -728,96 +732,100 @@ def enumerateBlockDevices(self): except (IOError, OSError): rootMajor = None # rootMinor = None - # print("[Harddisk] DEBUG: rootMajor = '%s', rootMinor = '%s'" % (rootMajor, rootMinor)) + # print(f"[Harddisk][enumerateBlockDevices] rootMajor = '{rootMajor}', rootMinor = '{rootMinor}'") + # print(f"[Harddisk][enumerateBlockDevices] Box model:{BoxInfo.getItem('model')}") boxModel = BoxInfo.getItem("model") for device in sorted(listdir("/sys/block")): try: physicalDevice = ospath.realpath(ospath.join("/sys/block", device, "device")) except (IOError, OSError) as err: - print("[Harddisk] Error: Couldn't determine physicalDevice for device '%s':" % device, err) + print(f"[Harddisk][enumerateBlockDevices] Error: Couldn't determine physicalDevice for device '{device}':", err) continue devicePath = ospath.join("/sys/block/", device) data = readFile(ospath.join(devicePath, "dev")) # This is the device's major and minor device numbers. + # print(f"[Harddisk][enumerateBlockDevices] boxModel:{boxModel} device:{device} data:{data}") if data is None: - print("[Harddisk] Error: Device '%s' (%s) does not appear to have valid device numbers!" % (device, physicalDevice)) + print(f"[Harddisk][enumerateBlockDevices] Error: Device '{device}' ({physicalDevice}) does not appear to have valid device numbers!") continue devMajor = int(data.split(":")[0]) devMinor = int(data.split(":")[1]) + # print(f"[Harddisk][enumerateBlockDevices] devMajor:{devMajor} for device '{device,}' blacklisted:{blacklistedDisks}") if devMajor in blacklistedDisks: - # print("[Harddisk] DEBUG: Major device number '%s' for device '%s' (%s) is blacklisted." % (devMajor, device, physicalDevice)) + # print(f"[Harddisk][enumerateBlockDevices] Major device number '{devMajor}' for device '{device,}' ({physicalDevice}) is blacklisted.") continue - print(f"[Harddisk] DEBUG: boxModel:{boxModel} device:{device} devMajor = '{devMajor}', devMinor = '{devMinor}'") + # print(f"[Harddisk][enumerateBlockDevices] boxModel:{boxModel} device:{device} devMajor = '{devMajor}', devMinor = '{devMinor}'") if devMajor == 179 and boxModel in ("dm900", "dm920"): if devMinor != 0: continue else: if devMajor == 179 and not SystemInfo["HasSDnomount"]: # Lets handle Zgemma SD card mounts - uses SystemInfo to determine SDcard status - # print(f"[Harddisk] DEBUG: Major device number '{devMajor,}' for device '{device}' ({physicalDevice}) doesn't have 'HasSDnomount' set.") + # print(f"[Harddisk][enumerateBlockDevices] Major device number '{devMajor,}' for device '{device}' ({physicalDevice}) doesn't have 'HasSDnomount' set.") continue if devMajor == 179 and devMajor == rootMajor and not SystemInfo["HasSDnomount"][0]: - # print(f"[Harddisk] DEBUG: Major device number '{devMajor} for device '{device} ({physicalDevice}) is the root disk.") + # print(f"[Harddisk][enumerateBlockDevices] Major device number '{devMajor} for device '{device} ({physicalDevice}) is the root disk.") continue if SystemInfo["HasSDnomount"] and device.startswith(f"{SystemInfo['HasSDnomount'][1]}") and SystemInfo["HasSDnomount"][0]: - # print("f[Harddisk] DEBUG: Major device number '{devMajor} for device '{device}' ({physicalDevice}) starts with 'mmcblk0' and has 'HasSDnomount' set.") + # print("f[Harddisk][enumerateBlockDevices] Major device number '{devMajor} for device '{device}' ({physicalDevice}) starts with 'mmcblk0' and has 'HasSDnomount' set.") continue description = self.getUserfriendlyDeviceName(device, physicalDevice) isCdrom = devMajor in opticalDisks or device.startswith("sr") if isCdrom: self.cd = ospath.join("/dev", device) if device.startswith("sr") else devicePath self.partitions.append(Partition(mountpoint=self.getMountpoint(device), description=description, force_mounted=True, device=device)) - # print("[Harddisk] DEBUG: Partition(mountpoint=%s, description=%s, force_mounted=True, device=%s)" % (self.getMountpoint(device), description, device)) - # print("[Harddisk] Found optical disk '%s' (%s)." % (device, physicalDevice)) + # print(f"[Harddisk][enumerateBlockDevices] Partition(mountpoint={self.getMountpoint(device)}, description={description}, force_mounted=True, device={device})") + # print(f"[Harddisk][enumerateBlockDevices] Found optical disk '{device}' ({physicalDevice}).") data = readFile(ospath.join(devicePath, "removable")) removable = False if data is None else bool(int(data)) # if removable: - # # print("[Harddisk] DEBUG: Device '%s' (%s) has removable media." % (device, physicalDevice)) + # # print(f"[Harddisk][enumerateBlockDevices] Device '{device}' ({physicalDevice}) has removable media.") try: open(ospath.join("/dev", device), "r").close() - mediumFound = True # noqa: F841 Check for medium set for debug. + # mediumFound = True # Check for medium. except (IOError, OSError) as err: if err.errno in (123, 159): # ENOMEDIUM - No medium found. (123 = Common Linux, 159 = MIPS Linux) - mediumFound = False # noqa: F841 set for Debug + print("[Harddisk][enumerateBlockDevices] Error: No medium found", err) + # mediumFound = False else: - print("[Harddisk] Error: Device '%s' (%s) media availability test failed:" % (device, physicalDevice), err) + print(f"[Harddisk][enumerateBlockDevices] Error: Device '{device}' ({physicalDevice}) media availability test failed:", err) continue # if mediumFound: - # print("[Harddisk] DEBUG: Device '%s' (%s) has media." % (device, physicalDevice)) - # print("[Harddisk] DEBUG: device = '%s', physicalDevice = '%s', devMajor = '%s', description = '%s'" % (device, physicalDevice, devMajor, description)) + # print(f"[Harddisk][enumerateBlockDevices] Device '{device}' ({physicalDevice}) has media.") + # print(f"[Harddisk][enumerateBlockDevices] device = '{device}, physicalDevice = '{physicalDevice}', devMajor = '{devMajor}', description = '{description}'") if not isCdrom and ospath.exists(devicePath): partitions = [partition for partition in sorted(listdir(devicePath)) if partition.startswith(device)] # Add HDD check for partitions. if len(partitions) == 0: # Add HDD check for HDD with no partitions (unformatted). - print("[Harddisk]1 Found storage device '%s' (Removable=%s) NoPartitions = %s." % (device, removable, len(partitions))) + print(f"[Harddisk][enumerateBlockDevices]1 Found storage device '{device} (Removable={removable}) NoPartitions = {len(partitions)}.") self.hdd.append(Harddisk(device, removable)) SystemInfo["Harddisk"] = True else: if SystemInfo["HasHiSi"] and devMajor == 8 and len(partitions) >= 4: partitions = [] if len(partitions) > 6 else partitions[4:] - print("[Harddisk] len partitions = %s, device = %s" % (len(partitions), device)) + print(f"[Harddisk][enumerateBlockDevices] len partitions = {len(partitions)}, device = {device}") if len(partitions) != 0: if removable: SystemInfo["HasUsbhdd"][device] = len(partitions) - print("[Harddisk]2 Found storage device '%s' (Removable=%s) NoPartitions = %s." % (device, removable, len(partitions))) # [Harddisk] Found storage device 'sdb' (Removable=True) NoPartitions = 1. - print("[Harddisk]1 SystemInfo['HasUsbhdd']= %s" % SystemInfo["HasUsbhdd"]) + print(f"[Harddisk][enumerateBlockDevices]2 Found storage device '{device}' (Removable={removable}) Number of Partitions = {len(partitions)}.") # [Harddisk][enumerateBlockDevices] Found storage device 'sdb' (Removable=True) NoPartitions = 1. + print(f"[Harddisk][enumerateBlockDevices]1 SystemInfo['HasUsbhdd']= {SystemInfo['HasUsbhdd']}") self.hdd.append(Harddisk(device, removable)) SystemInfo["Harddisk"] = True # self.partitions.append(Partition(mountpoint = self.getMountpoint(device), description = description, force_mounted, device = device)) - # print("[Harddisk] DEBUG: Partition(mountpoint=%s, description=%s, force_mounted=True, device=%s)" % (self.getMountpoint(device), description, device)) + # print(f"[Harddisk][enumerateBlockDevices] Partition(mountpoint={self.getMountpoint(device)}, description={description}, force_mounted=True, device={device}") for partition in partitions: if devMajor == 179 and boxModel in ("dm900", "dm920") and partition != "mmcblk0p3": continue description = self.getUserfriendlyDeviceName(partition, physicalDevice) - print("[Harddisk] Found partition '%s', description='%s', device='%s'." % (partition, description, physicalDevice)) + print(f"[Harddisk][enumerateBlockDevices] Found partition '{partition}', description='{description}', device='{physicalDevice}'.") # part = Partition(mountpoint=self.getMountpoint(partition), description=description, force_mounted=True, device=partition) part = Partition(mountpoint=self.getMountpoint(partition, skiproot=True), description=description, force_mounted=True, device=partition) self.partitions.append(part) - # print("[Harddisk] DEBUG: Partition(mountpoint = %s, description = %s, force_mounted = True, device = %s)" % (self.getMountpoint(partition), description, partition)) + # print(f"[Harddisk][enumerateBlockDevices] Partition(mountpoint = {self.getMountpoint(partition)}, description = {description}, force_mounted = True, device = {partition})") self.on_partition_list_change("add", part) - # print("[Harddisk] DEBUG: on_partition_list_change('add', Partition(mountpoint = %s, description = %s, force_mounted = True, device = %s))" % (self.getMountpoint(partition), description, partition)) + # print(f"[Harddisk][enumerateBlockDevices] on_partition_list_change('add', Partition(mountpoint = {self.getMountpoint(partition)}, description = {description}, force_mounted = True, device = {partition}))") self.hdd.sort() - print("[Harddisk] Enumerating block devices complete.") + print("[Harddisk][enumerateBlockDevices] Enumerating block devices complete.") def enumerateNetworkMounts(self): - print("[Harddisk] Enumerating network mounts...") + print("[Harddisk][enumerateNetworkMounts] Enumerating network mounts...") for entry in sorted(listdir("/media")): mountEntry = ospath.join("/media", entry) if not ospath.isdir(mountEntry): @@ -825,32 +833,33 @@ def enumerateNetworkMounts(self): try: # protect against drive being removed unexpectedly mounts = listdir(mountEntry) except IOError as err: - print("[Harddisk] drive not accessible", err) + print("[Harddisk][enumerateNetworkMounts] drive not accessible", err) continue if len(mounts) > 0: for mount in mounts: mountDir = ospath.join(mountEntry, mount, "") - # print("[Harddisk] enumerateNetworkMountsNew DEBUG: mountDir = '%s', isMount = '%s'" % (mountDir, ospath.ismount(mountDir))) + # print(f"[Harddisk][enumerateNetworkMounts] enumerateNetworkMountsNew mountDir = '{mountDir}', isMount = '{ospath.ismount(mountDir)}'") if ospath.ismount(mountDir) and mountDir not in [partition.mountpoint for partition in self.partitions]: - print("[Harddisk] Found network mount (%s) '%s' -> '%s'." % (entry, mount, mountDir)) + print(f"[Harddisk][enumerateNetworkMounts] Found network mount ({entry}) '{mount}' -> '{mountDir}'.") self.partitions.append(Partition(mountpoint=mountDir, description=mount)) - # print("[Harddisk] DEBUG: Partition(mountpoint = %s, description = %s)" % (mountDir, mount)) + # print(f"[Harddisk][enumerateNetworkMounts] Partition(mountpoint = {mountDir}, description = {mount})") elif "/media/net" in mountEntry and ospath.exists(mountDir) and mountDir not in [partition.mountpoint for partition in self.partitions]: - print("[Harddisk] Found network mount (%s) '%s' -> '%s'." % (entry, mount, mountDir)) + print(f"[Harddisk][enumerateNetworkMounts] Found network mount ({entry}) '{mount}' -> '{mountDir}'.") self.partitions.append(Partition(mountpoint=mountDir, description=mount)) if ospath.ismount("/media/hdd") and "/media/hdd/" not in [partition.mountpoint for partition in self.partitions]: - print("[Harddisk] new Network Mount being used as HDD replacement -> /media/hdd/") + print("[Harddisk][enumerateNetworkMounts] new Network Mount being used as HDD replacement -> /media/hdd/") self.partitions.append(Partition(mountpoint="/media/hdd/", description="/media/hdd")) - print("[Harddisk] Enumerating network mounts complete.") + print("[Harddisk][enumerateNetworkMounts] Enumerating network mounts complete.") def getUserfriendlyDeviceName(self, device, physicalDevice): + print(f"[Harddisk][getUserfriendlyDeviceName] device:{device} physicalDevice:{physicalDevice}") dev, part = self.splitDeviceName(device) description = readFile(ospath.join(physicalDevice, "model")) if description is None: description = readFile(ospath.join(physicalDevice, "name")) if description is None: - # print("[Harddisk] Error: Couldn't read harddisk model on '%s' ('%s')!" % (device, physicalDevice)) - description = _("Device %s") % dev + # print(f"[Harddisk][getUserfriendlyDeviceName] Error: Couldn't read harddisk model on '{device}' ('{physicalDevice}')!") + description = _(f"Device {dev}") if part: # and part != 1: # Not wholedisk and not partition 1. description = "%s %s" % (description, _("(Partition %d)") % part) return description @@ -868,7 +877,7 @@ def splitDeviceName(self, devName): elif devName[:2] != "sr": # this works for: sr0 (which is in fact dev="sr0", part="") device = pdevice # This works for other devices in the form: sdaX, hdaX, or any device that has a numeric suffix. partition = int(devName[deviceLen:]) if deviceLen < devNameLen else 0 - print(f"[Harddisk] splitDeviceName DEBUG: devName = '{devName}', device = '{device}', partition = '{partition}'") + print(f"[Harddisk][splitDeviceName] devName = '{devName}', device = '{device}', partition = '{partition}'") return device, partition def getAutofsMountpoint(self, device): @@ -897,20 +906,20 @@ def addHotplugPartition(self, device, physDevice=None, model=None): HDDin = error = removable = isCdrom = blacklisted = False mediumFound = True hddDev, part = self.splitDeviceName(device) - devicePath = "/sys/block/%s" % hddDev + devicePath = f"/sys/block/{hddDev}" try: physicalDevice = ospath.realpath(ospath.join("/sys/block", hddDev, "device")) except (IOError, OSError): - print("[Harddisk] Error: Couldn't determine physical device for device '%s'!" % hddDev) + print(f"[Harddsk][addHotplugPartition] Error: Couldn't determine physical device for device '{hddDev}'!") physicalDevice = hddDev description = self.getUserfriendlyDeviceName(device, physicalDevice) - # print("[Harddisk] DEBUG: Hotplug description = '%s', devicePath = '%s', hddDev = '%s'." % (description, devicePath, hddDev)) + # print(f"[Harddsk][addHotplugPartition] : Hotplug description = '{description}', devicePath = '{devicePath}, hddDev = '{hddDev}'.") data = readFile(ospath.join(devicePath, "dev")) # This is the device's major and minor device numbers. if data is not None: devMajor = int(data.split(":")[0]) isCdrom = devMajor in opticalDisks or device.startswith("sr") if isCdrom: - print("[Harddisk] Found optical disk '%s' (%s)." % (device, physicalDevice)) + print(f"[Harddsk][addHotplugPartition] Found optical disk '{device}' ({physicalDevice}).") self.cd = ospath.join("/dev", device) if device.startswith("sr") else devicePath part = Partition(mountpoint=self.getMountpoint(hddDev), description=description, force_mounted=True, device=hddDev) self.partitions.append(part) @@ -920,7 +929,7 @@ def addHotplugPartition(self, device, physDevice=None, model=None): data = readFile(ospath.join(devicePath, "removable")) removable = False if data is None else bool(int(data)) for hdd in self.hdd: # Perhaps the disk has not been removed, so don't add it again. - # print("[Harddisk] DEBUG hddDev in hddlist. (hdd = '%s', hdd.device = '%s', hddDev = '%s')" % (hdd, hdd.device, hddDev)) + # print(f"[Harddsk][addHotplugPartition] hddDev in hddlist. (hdd = '{hdd], hdd.device = '{hdd.device}', hddDev = '{hddDev}')") if hdd.device == hddDev: HDDin = True break @@ -929,23 +938,23 @@ def addHotplugPartition(self, device, physDevice=None, model=None): partitions = partitions[4:] if HDDin is False and len(partitions) != 0: SystemInfo["HasUsbhdd"][device] = len(partitions) - print("[Harddisk]2 SystemInfo['HasUsbhdd']= %s" % SystemInfo["HasUsbhdd"]) + print(f"[Harddsk][addHotplugPartition]2 HasUsbhdd:{SystemInfo['HasUsbhdd']} device:{device} partitions:{len(partitions)}") self.hdd.append(Harddisk(hddDev, removable)) - # print("[Harddisk] DEBUG: Add hotplug HDD device in hddlist. (device = '%s', hdd.device = '%s', hddDev = '%s')" % (device, hdd.device, hddDev)) + # print(f"[Harddsk][addHotplugPartition] : Add hotplug HDD device in hddlist. (device = '{device}', hdd.device = '{hdd.device}', hddDev = '{hddDev}')") self.hdd.sort() SystemInfo["Harddisk"] = True # self.partitions.append(Partition(mountpoint = self.getMountpoint(hddDev), description = description, force_mounted = True, device = hddDev)) - # print("[Harddisk] DEBUG add hddDev: Partition(mountpoint=%s, description=%s, force_mounted=True, hddDev=%s)" % (self.getMountpoint(device), description, hddDev)) + # print(f"[Harddsk][addHotplugPartition] add hddDev: Partition(mountpoint={self.getMountpoint(device)}, description={description,}, force_mounted=True, hddDev={hddDev})") for partition in partitions: description = self.getUserfriendlyDeviceName(partition, physicalDevice) - print("[Harddisk] Found partition '%s', description = '%s', device = '%s'." % (partition, description, physicalDevice)) + print(f"[Harddsk][addHotplugPartition] Found partition '{partition}', description = '{description}', device = '{physicalDevice}'.") part = Partition(mountpoint=self.getMountpoint(partition), description=description, force_mounted=True, device=partition) # add in partition - # print("[Harddisk] DEBUG add partition: Part(mountpoint = %s, description = %s, force_mounted = True, device = %s)" % (self.getMountpoint(partition), description, partition)) + # print(f"[Harddsk][addHotplugPartition] add partition: Part(mountpoint = {self.getMountpoint(partition)}, description = {description}, force_mounted = True, device = {partition})") self.partitions.append(part) if part.mountpoint: # Plugins won't expect unmounted devices. self.on_partition_list_change("add", part) - # print("[Harddisk] DEBUG: on_partition_list_change('add', Partition(mountpoint = %s, description = %s, force_mounted = True, device = %s))" % (self.getMountpoint(partition), description, partition)) - # print("[Harddisk] Hotplug connection complete.") + # print(f"[Harddsk][addHotplugPartition] : on_partition_list_change('add', Partition(mountpoint = {self.getMountpoint(partition)} description = {description}, force_mounted = True, device = {partition})") + # print("[Harddsk][addHotplugPartition] Hotplug connection complete.") return error, blacklisted, removable, isCdrom, self.partitions, mediumFound # Return for hotplug legacy code. def removeHotplugPartition(self, device): @@ -956,21 +965,21 @@ def removeHotplugPartition(self, device): if partition.device is None: continue pDevice = partition.device - # print("[Harddisk] DEBUG: Partition is in self.partitions. (partition.device = '%s', device = '%s')" % (pDevice, device)) + # print("f[Harddsk][removeHotplugPartition] : Partition is in self.partitions. (partition.device = '{pDevice}, device = '{device}')") if pDevice.startswith(hddDev): # This is the disk's partition for which we are looking. - print("[Harddisk] Unmounting partition '%s'." % device) + print(f"[Harddsk][removeHotplugPartition] Unmounting partition '{device}'.") self.partitions.remove(partition) # Remove partition. if partition.mountpoint: # Plugins won't expect unmounted devices. self.on_partition_list_change("remove", partition) for hdd in self.hdd: if hdd.device == hddDev: # This is the storage device for which we are looking. - print("[Harddisk] Removing storage device '%s'." % hddDev) - # print("[Harddisk] DEBUG: Storage device is in self.hdd. (hdd.device = '%s', device = '%s', hddDev = '%s')" % (hdd.device, device, hddDev)) + print(f"[Harddsk][removeHotplugPartition] Removing storage device '{hddDev}.") + # print(f"[Harddsk][removeHotplugPartition] : Storage device is in self.hdd. (hdd.device = '{hdd.device}', device = '{device}', hddDev = '{hddDev}')") hdd.stop() # Stop the disk. self.hdd.remove(hdd) # Remove the disk. break SystemInfo["Harddisk"] = len(self.hdd) > 0 - print("[Harddisk] Hotplug disconnection complete.") + print("[Harddsk][removeHotplugPartition] Hotplug disconnection complete.") def HDDCount(self): return len(self.hdd) @@ -1022,7 +1031,7 @@ def setDVDSpeed(self, device, speed=0): with open(device, "wb") as fd: ioctl(fd.fileno(), int(0x5322), speed) except (IOError, OSError) as err: - print("[Harddisk] Error: Failed to set '%s' speed to '%s':" % (device, speed), err) + print(f"[Harddsk][setDVDSpeed] Error: Failed to set '{device}' speed to '{speed}':", err) class UnmountTask(Components.Task.LoggingTask): @@ -1036,8 +1045,8 @@ def prepare(self): print("[Harddisk] UnMountTask - prepare") try: dev = self.hdd.disk_path.split(ossep)[-1] - print("[Harddisk] [UnMountTask - prepare]", dev) - open("/dev/nomount.%s" % dev, "wb").close() + # print("[Harddisk] [UnMountTask - prepare]", dev) + open(f"/dev/nomount.{dev}", "wb").close() except (IOError, OSError) as err: print("[Harddisk] UnmountTask - Error: Failed to create /dev/nomount file:", err) self.setTool("umount") @@ -1056,7 +1065,7 @@ def afterRun(self): try: rmdir(path) except (IOError, OSError) as err: - print("[Harddisk] UnmountTask - Error: Failed to remove path '%s':" % path, err) + print(f"[Harddisk] UnmountTask - Error: Failed to remove path '{path}':", err) class MountTask(Components.Task.LoggingTask): @@ -1065,32 +1074,35 @@ def __init__(self, job, hdd): self.hdd = hdd def prepare(self): - print("[Harddisk] MountTask - prepare") + print("[Harddisk][ MountTask][prepare] - prepare") try: dev = self.hdd.disk_path.split(ossep)[-1] - unlink("/dev/nomount.%s" % dev) + unlink(f"/dev/nomount.{dev}") except (IOError, OSError) as err: - print("[Harddisk] MountTask - Error: Failed to remove '/dev/nomount' file:", err) + print("[Harddisk][MountTask][prepare] - Error: Failed to remove '/dev/nomount' file:", err) if self.hdd.mount_device is None: dev = self.hdd.partitionPath("1") # Try mounting through fstab first. + print("[Harddisk][MountTask][prepare] mounting1:in fstab", dev) else: dev = self.hdd.mount_device # If previously mounted, use the same spot. + print("[Harddisk][MountTask][prepare] mounting2: not in fstab", dev) try: with open("/etc/fstab", "r") as fd: for line in fd.readlines(): parts = line.strip().split(" ") fspath = ospath.realpath(parts[0]) - if ospath.realpath(fspath) == dev: - self.setCmdline("mount -t auto %s" % fspath) + print("[Harddisk][MountTask][prepare] mounting3:dev, fspath", dev, " ", fspath) + if fspath == dev: + self.setCmdline(f"mount -t auto {fspath}") self.postconditions.append(Components.Task.ReturncodePostcondition()) return except (IOError, OSError) as err: - print("[Harddisk] MountTask - Error: Failed to read '/etc/fstab' file:", err) + print("[Harddisk][prepa MountTask - Error: Failed to read '/etc/fstab' file:", err) # Device is not in fstab. # We can let udev do the job, re-read the partition table. # Sorry for the sleep 2 hack... - print("[Harddisk] MountTask - let udev complete the job") - self.setCmdline("sleep 2; hdparm -z %s" % self.hdd.disk_path) + print("[Harddisk][MountTask][prepare] - let udev complete the job") + self.setCmdline(f"sleep 2; hdparm -z {self.hdd.disk_path}") self.postconditions.append(Components.Task.ReturncodePostcondition()) From 895f7a010f23eab776cd8ef33ef05591531b8879 Mon Sep 17 00:00:00 2001 From: TwolDE Date: Mon, 20 Jan 2025 10:58:47 +0100 Subject: [PATCH 05/17] [Hotplug] add device port information --- lib/python/Plugins/SystemPlugins/Hotplug/plugin.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py b/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py index 924e0da5be..ddf7bfda9b 100644 --- a/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py @@ -5,7 +5,7 @@ from twisted.internet import reactor from twisted.internet.protocol import Factory, Protocol -from enigma import eTimer +from enigma import getDeviceDB, eTimer from Session import SessionObject from Components.Console import Console @@ -166,7 +166,12 @@ def processAddDevice(self): self.newCount += 1 if notFound: - text = f"{_("A new storage device has been connected:")}\n{ID_MODEL} - ({bytesToHumanReadable(ID_PART_ENTRY_SIZE * 512)})\n" + description = "" + for physdevprefix, pdescription in list(getDeviceDB().items()): + if DEVPATH.startswith(physdevprefix): + description = f"\n{pdescription}" + + text = f"{_("A new storage device has been connected:")}\n{ID_MODEL} - ({bytesToHumanReadable(ID_PART_ENTRY_SIZE * 512)})\n{description}" def newDeviceCallback(answer): if answer: @@ -241,7 +246,7 @@ def processHotplugData(self, eventData): mode = eventData.get("mode") print("[Hotplug] DEBUG: ", eventData) action = eventData.get("ACTION") - if mode == 1: + if mode == 1 and eventData.get("MODE", "") != "CD": if action == "add": self.addTimer.stop() ID_TYPE = eventData.get("ID_TYPE") From 2d1d96bb3ff3d852550a72764661e7442a160e0d Mon Sep 17 00:00:00 2001 From: TwolDE Date: Mon, 20 Jan 2025 11:00:25 +0100 Subject: [PATCH 06/17] [About] - slight change for Device port information --- lib/python/Screens/About.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/python/Screens/About.py b/lib/python/Screens/About.py index 40de2a0a57..5b34b590bf 100644 --- a/lib/python/Screens/About.py +++ b/lib/python/Screens/About.py @@ -285,8 +285,8 @@ def populate2(self): hdd = self.hddlist[count][1] hddp = self.hddlist[count][0] if "ATA" in hddp: - hddp = hddp.replace("ATA", "") - hddp = hddp.replace("Internal", "ATA Bus ") + hddp = hddp.replace("ATA", "", 2) + hddp = hddp.replace("SATA", "SATA Internal Bus ").replace("(", "").replace(")", "") free = hdd.Totalfree() if free >= 1: free *= 1000000 # convert MB to bytes From 70d1d8a001faf90ad54a4bc8d9ea8cab1354f763 Mon Sep 17 00:00:00 2001 From: TwolDE Date: Mon, 20 Jan 2025 11:01:49 +0100 Subject: [PATCH 07/17] [MountManager] - add device port information --- .../Plugins/SystemPlugins/ViX/MountManager.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/python/Plugins/SystemPlugins/ViX/MountManager.py b/lib/python/Plugins/SystemPlugins/ViX/MountManager.py index dc5ac5fb72..c5dd91edeb 100644 --- a/lib/python/Plugins/SystemPlugins/ViX/MountManager.py +++ b/lib/python/Plugins/SystemPlugins/ViX/MountManager.py @@ -2,7 +2,7 @@ from os import mkdir, path, rename, statvfs, system import re -from enigma import eTimer +from enigma import getDeviceDB, eTimer from Components.ActionMap import ActionMap from Components.Label import Label @@ -93,12 +93,22 @@ def buildPartitionInfo(partition, partitionList): # print("[MountManager] physicalDevice: %s" % physicalDevice) # print("[MountManager] Type: %s" % SystemInfo["MountManager"]) + print(f"[MountManager][port] physicalDevice:{physicalDevice}") + print(f"[MountManager][port] list(getDeviceDB().items() {list(getDeviceDB().items())}") + portDescription = "" + for physdevprefix, pdescription in list(getDeviceDB().items()): + print(f"[MountManager][port] physdevprefix:{physdevprefix} pdescription:{pdescription}") + if physicalDevice.replace("/sys", "").startswith(physdevprefix): + portDescription = pdescription + print(f"[MountManager] portDescription:{portDescription}") + description = readFile(path.join(physicalDevice, "model")) if description is None: description = readFile(path.join(physicalDevice, "name")) if description is None: description = _("Device %s") % partition - description = str(description).replace("\n", "") + print(f"[MountManager] description:{description}") + description = portDescription + " " + str(description).replace("\n", "") hotplugBuses = ("usb", "mmc", "ata") busTranslate = ("usb", "sd", "hdd") @@ -109,7 +119,9 @@ def buildPartitionInfo(partition, partitionList): break # print("[MountManager1]bus: %s count : %s" % (bus, count)) pngType = busTranslate[count] - name = _("%s: " % pngType.upper()) + name = "" + if not portDescription: + name = _("%s: " % pngType.upper()) name += description if path.exists(resolveFilename(SCOPE_CURRENT_SKIN, "vixcore/dev_%s.png" % pngType)): From 2e2f66d35733765fe33e6251a4aeff659e60fbb6 Mon Sep 17 00:00:00 2001 From: Dimitar Tsenev Date: Mon, 20 Jan 2025 11:31:41 +0200 Subject: [PATCH 08/17] [Added] Flush of gstreamer buffer on switch to not DVB subtitles [Fixed] Wrong subtitles track numbering for text/pango subtitles --- lib/python/Screens/AudioSelection.py | 1 - lib/service/servicemp3.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/python/Screens/AudioSelection.py b/lib/python/Screens/AudioSelection.py index 19a91ed60a..3d07a699e7 100644 --- a/lib/python/Screens/AudioSelection.py +++ b/lib/python/Screens/AudioSelection.py @@ -380,7 +380,6 @@ def __call__(self, *args, **kwargs): description = types[x[2]] except Exception: description = _("unknown") + ": %s" % x[2] - number = str(int(number) + 1) streams.append((x, "", number, description, language, selected, selectionpng if selected == "X" else None)) idx += 1 conflist.append(getConfigListEntry(_("To audio selection"), self.settings.menupage)) diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 48bc947176..3d8ae60088 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -2884,6 +2884,24 @@ RESULT eServiceMP3::enableSubtitles(iSubtitleUser *user, struct SubtitleTrack &t setCacheEntry(false, track.pid - 1); g_object_set (G_OBJECT (m_gst_playbin), "current-text", m_currentSubtitleStream, NULL); + if (track.type != stDVB) + { + bool validposition = false; + pts_t ppos = 0; + if (getPlayPosition(ppos) >= 0) + { + validposition = true; + ppos -= 100; + if (ppos < 0) + ppos = 0; + } + if (validposition) + { + /* flush */ + seekTo(ppos); + } + } + m_subtitle_widget = user; eDebug ("[eServiceMP3] switched to subtitle stream %i", m_currentSubtitleStream); @@ -2986,6 +3004,13 @@ RESULT eServiceMP3::getSubtitleList(std::vector &subtitlel case stUnknown: case stVOB: case stPGS: + struct SubtitleTrack track = {}; + track.type = 1; + track.pid = stream_idx; + track.page_number = int(type); + track.magazine_number = 0; + track.language_code = IterSubtitleStream->language_code; + subtitlelist.push_back(track); break; case stDVB: { From 128d6084871a5569e5f5b4254e0648f9722f5986 Mon Sep 17 00:00:00 2001 From: Dimitar Tsenev Date: Mon, 20 Jan 2025 12:38:12 +0200 Subject: [PATCH 09/17] [Fixed] Build --- lib/service/servicemp3.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 3d8ae60088..bc1f943bda 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -3004,13 +3004,6 @@ RESULT eServiceMP3::getSubtitleList(std::vector &subtitlel case stUnknown: case stVOB: case stPGS: - struct SubtitleTrack track = {}; - track.type = 1; - track.pid = stream_idx; - track.page_number = int(type); - track.magazine_number = 0; - track.language_code = IterSubtitleStream->language_code; - subtitlelist.push_back(track); break; case stDVB: { From 43a4d583757579728d58c71005895918c1d1866c Mon Sep 17 00:00:00 2001 From: TwolDE Date: Mon, 20 Jan 2025 16:43:36 +0100 Subject: [PATCH 10/17] [HardwareDB] - update dm920 --- include/hardwaredb.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/hardwaredb.h b/include/hardwaredb.h index c327fd9025..999901ea86 100644 --- a/include/hardwaredb.h +++ b/include/hardwaredb.h @@ -56,8 +56,10 @@ static std::unordered_map HardwareDB{ {"/devices/rdb.4/f0470600.ohci_v2/usb6/6-0:1.0/port1/", "Front USB"}, {"/devices/rdb.4/f0470300.ehci_v2/usb3/3-0:1.0/port1/", "Front USB"}, {"/devices/rdb.4/f0471000.xhci_v2/usb2/2-0:1.0/port1/", "Front USB"}, + {"/devices/rdb.4/f0470300.ehci_v2/usb3/3-1/3-1:1.0", "Front panel USB"}, {"/devices/rdb.4/f0470400.ohci_v2/usb5/5-0:1.0/port1/", "Rear USB"}, {"/devices/rdb.4/f0470500.ehci_v2/usb4/4-0:1.0/port1/", "Rear USB"}, + {"/devices/rdb.4/f0470500.ehci_v2/usb4/4-1/4-1:1.0", "Rear USB"}, {"/devices/rdb.4/f0471000.xhci_v2/usb2/2-0:1.0/port2/", "Rear USB"} #elif HWVUSOLO4K {"/devices/platform/strict-ahci.0/ata1/", "SATA"}, From fd86e0729c831e00dae39db9b866d206e141eb48 Mon Sep 17 00:00:00 2001 From: TwolDE Date: Tue, 21 Jan 2025 11:47:18 +0100 Subject: [PATCH 11/17] [Hardisk] - add mmcblk0p3 dream as Data --- lib/python/Components/Harddisk.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 3abca85916..1859a97a5c 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -680,7 +680,7 @@ def parseDeviceData(inputData): mounts = getProcMounts() devmounts = [x[0] for x in mounts] mounts = [x[1] for x in mounts if x[1].startswith("/media/")] - possibleMountPoints = [f"/media/{x}" for x in ("usb8", "usb7", "usb6", "usb5", "usb4", "usb3", "usb2", "usb", "hdd") if f"/media/{x}" not in mounts] + possibleMountPoints = [f"/media/{x}" for x in ("usb8", "usb7", "usb6", "usb5", "usb4", "usb3", "usb2", "usb", "hdd", "data") if f"/media/{x}" not in mounts] for device in devices: if device["DEVNAME"] not in devmounts or "/media/hdd" in possibleMountPoints: @@ -814,9 +814,11 @@ def enumerateBlockDevices(self): if devMajor == 179 and boxModel in ("dm900", "dm920") and partition != "mmcblk0p3": continue description = self.getUserfriendlyDeviceName(partition, physicalDevice) - print(f"[Harddisk][enumerateBlockDevices] Found partition '{partition}', description='{description}', device='{physicalDevice}'.") - # part = Partition(mountpoint=self.getMountpoint(partition), description=description, force_mounted=True, device=partition) - part = Partition(mountpoint=self.getMountpoint(partition, skiproot=True), description=description, force_mounted=True, device=partition) + print(f"[Harddisk][enumerateBlockDevices]### Found partition '{partition}', description='{description}', device='{physicalDevice}' mountpoint='{self.getMountpoint(partition)}.") + if boxModel in ("dm900", "dm920") and partition == "mmcblk0p3" and self.getMountpoint(partition) == None: + part = Partition(mountpoint="/media/data/", description=description, force_mounted=True, device=partition) + else: + part = Partition(mountpoint=self.getMountpoint(partition, skiproot=True), description=description, force_mounted=True, device=partition) self.partitions.append(part) # print(f"[Harddisk][enumerateBlockDevices] Partition(mountpoint = {self.getMountpoint(partition)}, description = {description}, force_mounted = True, device = {partition})") self.on_partition_list_change("add", part) From ca3e116e7e4d9e1f182f0156f253fa8dbf94c705 Mon Sep 17 00:00:00 2001 From: TwolDE Date: Tue, 21 Jan 2025 11:49:50 +0100 Subject: [PATCH 12/17] [hardwareDB] - add sf8008m --- configure.ac | 1 + include/hardwaredb.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index 4a3680d12f..ee4f5643b5 100644 --- a/configure.ac +++ b/configure.ac @@ -195,6 +195,7 @@ AS_IF([test "$BOXTYPE" == "sfx6008"],[AC_DEFINE(HWSFX6008, 1,[sfx6008])]) AS_IF([test "$BOXTYPE" == "osnino"],[AC_DEFINE(HWOSNINO, 1,[osnino])]) AS_IF([test "$BOXTYPE" == "h10"],[AC_DEFINE(HWH10, 1,[h10])]) AS_IF([test "$BOXTYPE" == "multiboxpro"],[AC_DEFINE(HWMULTIBOXPRO, 1,[multiboxpro])]) +AS_IF([test "$MACHINEBUILD" == "sf8008m"],[AC_DEFINE(HWSF8008M, 1,[sf8008m])]) AS_IF([test "$BOXTYPE" == "sf8008"],[AC_DEFINE(HWSF8008, 1,[sf8008])]) AS_IF([test "$BOXTYPE" == "et7x00"],[AC_DEFINE(HWET7X00, 1,[et7x00])]) AS_IF([test "$BOXTYPE" == "h9combo"],[AC_DEFINE(HWH9COMBO, 1,[h9combo])]) diff --git a/include/hardwaredb.h b/include/hardwaredb.h index 999901ea86..f5e4a3ad25 100644 --- a/include/hardwaredb.h +++ b/include/hardwaredb.h @@ -176,6 +176,9 @@ static std::unordered_map HardwareDB{ {"/devices/platform/soc/f98a0000.xhci/usb4/3-1/3-1", "Right USB"}, {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1.2", "Rear USB"}, {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1.3", "Rear microSD"} +#elif HWSF8008M + {"/devices/platform/soc/f98a0000.xhci/usb3/3-1/3-1:1.0", "Right side - left USB 3.0"}, + {"/devices/platform/soc/f9890000.ehci/usb1/1-1/1-1:1.0", "Right side - right USB"} #elif HWET7X00 // CHECKED {"/devices/platform/ehci-brcm.0/usb1/1-1/1-1:1.0", "Rear USB"}, {"/devices/platform/ehci-brcm.0/usb1/1-2/1-2:1.0", "Front panel USB"} From 5737a9114f5d77248660a8cf5fb1761a7f7622cc Mon Sep 17 00:00:00 2001 From: openvix-bot Date: Tue, 21 Jan 2025 10:50:44 +0000 Subject: [PATCH 13/17] PEP8 double aggressive W291 ~ W293 and W391 --- lib/python/Components/Harddisk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 1859a97a5c..f66459f007 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -816,7 +816,7 @@ def enumerateBlockDevices(self): description = self.getUserfriendlyDeviceName(partition, physicalDevice) print(f"[Harddisk][enumerateBlockDevices]### Found partition '{partition}', description='{description}', device='{physicalDevice}' mountpoint='{self.getMountpoint(partition)}.") if boxModel in ("dm900", "dm920") and partition == "mmcblk0p3" and self.getMountpoint(partition) == None: - part = Partition(mountpoint="/media/data/", description=description, force_mounted=True, device=partition) + part = Partition(mountpoint="/media/data/", description=description, force_mounted=True, device=partition) else: part = Partition(mountpoint=self.getMountpoint(partition, skiproot=True), description=description, force_mounted=True, device=partition) self.partitions.append(part) From 7f666d9c4b42405687cb6b4cc1893be3ef326051 Mon Sep 17 00:00:00 2001 From: TwolDE Date: Tue, 21 Jan 2025 14:26:07 +0100 Subject: [PATCH 14/17] Revert "PEP8 double aggressive W291 ~ W293 and W391" This reverts commit 5737a9114f5d77248660a8cf5fb1761a7f7622cc. --- lib/python/Components/Harddisk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index f66459f007..1859a97a5c 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -816,7 +816,7 @@ def enumerateBlockDevices(self): description = self.getUserfriendlyDeviceName(partition, physicalDevice) print(f"[Harddisk][enumerateBlockDevices]### Found partition '{partition}', description='{description}', device='{physicalDevice}' mountpoint='{self.getMountpoint(partition)}.") if boxModel in ("dm900", "dm920") and partition == "mmcblk0p3" and self.getMountpoint(partition) == None: - part = Partition(mountpoint="/media/data/", description=description, force_mounted=True, device=partition) + part = Partition(mountpoint="/media/data/", description=description, force_mounted=True, device=partition) else: part = Partition(mountpoint=self.getMountpoint(partition, skiproot=True), description=description, force_mounted=True, device=partition) self.partitions.append(part) From 58e76165a96301a4ba6d6a397b9df446b999aca2 Mon Sep 17 00:00:00 2001 From: TwolDE Date: Tue, 21 Jan 2025 14:26:49 +0100 Subject: [PATCH 15/17] Revert "[Hardisk] - add mmcblk0p3 dream as Data" This reverts commit fd86e0729c831e00dae39db9b866d206e141eb48. --- lib/python/Components/Harddisk.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 1859a97a5c..3abca85916 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -680,7 +680,7 @@ def parseDeviceData(inputData): mounts = getProcMounts() devmounts = [x[0] for x in mounts] mounts = [x[1] for x in mounts if x[1].startswith("/media/")] - possibleMountPoints = [f"/media/{x}" for x in ("usb8", "usb7", "usb6", "usb5", "usb4", "usb3", "usb2", "usb", "hdd", "data") if f"/media/{x}" not in mounts] + possibleMountPoints = [f"/media/{x}" for x in ("usb8", "usb7", "usb6", "usb5", "usb4", "usb3", "usb2", "usb", "hdd") if f"/media/{x}" not in mounts] for device in devices: if device["DEVNAME"] not in devmounts or "/media/hdd" in possibleMountPoints: @@ -814,11 +814,9 @@ def enumerateBlockDevices(self): if devMajor == 179 and boxModel in ("dm900", "dm920") and partition != "mmcblk0p3": continue description = self.getUserfriendlyDeviceName(partition, physicalDevice) - print(f"[Harddisk][enumerateBlockDevices]### Found partition '{partition}', description='{description}', device='{physicalDevice}' mountpoint='{self.getMountpoint(partition)}.") - if boxModel in ("dm900", "dm920") and partition == "mmcblk0p3" and self.getMountpoint(partition) == None: - part = Partition(mountpoint="/media/data/", description=description, force_mounted=True, device=partition) - else: - part = Partition(mountpoint=self.getMountpoint(partition, skiproot=True), description=description, force_mounted=True, device=partition) + print(f"[Harddisk][enumerateBlockDevices] Found partition '{partition}', description='{description}', device='{physicalDevice}'.") + # part = Partition(mountpoint=self.getMountpoint(partition), description=description, force_mounted=True, device=partition) + part = Partition(mountpoint=self.getMountpoint(partition, skiproot=True), description=description, force_mounted=True, device=partition) self.partitions.append(part) # print(f"[Harddisk][enumerateBlockDevices] Partition(mountpoint = {self.getMountpoint(partition)}, description = {description}, force_mounted = True, device = {partition})") self.on_partition_list_change("add", part) From 92fe32eb4a36d64741c2503e3fac9f99213d8008 Mon Sep 17 00:00:00 2001 From: TwolDE Date: Wed, 22 Jan 2025 09:19:33 +0100 Subject: [PATCH 16/17] [Harddisk] mount DM recovery partition at 1st boot --- lib/python/Components/Harddisk.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 3abca85916..73b9b7c01b 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -680,7 +680,7 @@ def parseDeviceData(inputData): mounts = getProcMounts() devmounts = [x[0] for x in mounts] mounts = [x[1] for x in mounts if x[1].startswith("/media/")] - possibleMountPoints = [f"/media/{x}" for x in ("usb8", "usb7", "usb6", "usb5", "usb4", "usb3", "usb2", "usb", "hdd") if f"/media/{x}" not in mounts] + possibleMountPoints = [f"/media/{x}" for x in ("usb8", "usb7", "usb6", "usb5", "usb4", "usb3", "usb2", "usb", "data", "hdd") if f"/media/{x}" not in mounts] for device in devices: if device["DEVNAME"] not in devmounts or "/media/hdd" in possibleMountPoints: @@ -814,9 +814,18 @@ def enumerateBlockDevices(self): if devMajor == 179 and boxModel in ("dm900", "dm920") and partition != "mmcblk0p3": continue description = self.getUserfriendlyDeviceName(partition, physicalDevice) - print(f"[Harddisk][enumerateBlockDevices] Found partition '{partition}', description='{description}', device='{physicalDevice}'.") - # part = Partition(mountpoint=self.getMountpoint(partition), description=description, force_mounted=True, device=partition) - part = Partition(mountpoint=self.getMountpoint(partition, skiproot=True), description=description, force_mounted=True, device=partition) + print(f"[Harddisk][enumerateBlockDevices]### Found partition '{partition}', description='{description}', device='{physicalDevice}' mountpoint='{self.getMountpoint(partition)}.") + if boxModel in ("dm900", "dm920") and partition == "mmcblk0p3" and self.getMountpoint(partition) == None: + mountpoint = "/media/data/" + newFstab = fileReadLines("/etc/fstab") + newFstab.append("/dev/mmcblk0p3 /media/data ext4 rw, relatime,data=ordered 0 0") + fileWriteLines("/etc/fstab", newFstab) + if not ospath.exists(mountpoint): + mkdir(mountpoint, 0o755) + self.console.ePopen("/bin/mount -a") + part = Partition(mountpoint, description=description, force_mounted=True, device=partition) + else: + part = Partition(mountpoint=self.getMountpoint(partition, skiproot=True), description=description, force_mounted=True, device=partition) self.partitions.append(part) # print(f"[Harddisk][enumerateBlockDevices] Partition(mountpoint = {self.getMountpoint(partition)}, description = {description}, force_mounted = True, device = {partition})") self.on_partition_list_change("add", part) From f853954c92938b4827f4cc213e8cb6cfaface92e Mon Sep 17 00:00:00 2001 From: ims Date: Sun, 12 Jan 2025 12:35:17 +0100 Subject: [PATCH 17/17] DVB subtites - fixed background transparency --- lib/dvb/subtitle.cpp | 2 +- lib/python/Components/UsageConfig.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/dvb/subtitle.cpp b/lib/dvb/subtitle.cpp index 9a5044893a..568669f359 100644 --- a/lib/dvb/subtitle.cpp +++ b/lib/dvb/subtitle.cpp @@ -1087,7 +1087,7 @@ void eDVBSubtitleParser::subtitle_redraw(int page_id) palette[i].g = MAX(MIN(((298 * y - 55 * cb - 137 * cr) / 256), 255), 0); palette[i].b = MAX(MIN(((298 * y + 543 * cb) / 256), 255), 0); } - if (bcktrans) + if (bcktrans >= 0) { if (palette[i].r || palette[i].g || palette[i].b) palette[i].a = (entries[i].T) & 0xFF; diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py index 14c3dcf7b5..22ad84497d 100644 --- a/lib/python/Components/UsageConfig.py +++ b/lib/python/Components/UsageConfig.py @@ -1033,7 +1033,8 @@ def setZapmode(el): config.subtitles.dvb_subtitles_original_position = ConfigSelection(default="0", choices=[("0", _("Original")), ("1", _("Fixed")), ("2", _("Relative"))]) config.subtitles.dvb_subtitles_centered = ConfigYesNo(default=False) config.subtitles.subtitle_bad_timing_delay = ConfigSelection(default="0", choices=subtitle_delay_choicelist) - config.subtitles.dvb_subtitles_backtrans = ConfigSelection(default="0", choices=[ + config.subtitles.dvb_subtitles_backtrans = ConfigSelection(default="-1", choices=[ + ("-1", _("Original")), ("0", _("No transparency")), ("25", "10%"), ("50", "20%"),