From 8a6f1dea9dc9335d7c1f7b10047f1300b52f82a1 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 15 Sep 2012 11:49:51 +0200 Subject: [PATCH 1/2] add hardware_caps header First version of a "hardware capabilites information" struct. This is intended to help clean up the mess in the neutrino GUI. Surely needs some more work and ongoing changes --- Makefile.am | 3 ++ azbox/Makefile.am | 1 + azbox/hardware_caps.c | 50 ++++++++++++++++++++++++++ common/hardware_caps.h | 1 + include/hardware_caps.h | 45 +++++++++++++++++++++++ libspark/Makefile.am | 1 + libspark/hardware_caps.c | 76 +++++++++++++++++++++++++++++++++++++++ libtriple/Makefile.am | 1 + libtriple/hardware_caps.c | 30 ++++++++++++++++ 9 files changed, 208 insertions(+) create mode 100644 azbox/hardware_caps.c create mode 120000 common/hardware_caps.h create mode 100644 include/hardware_caps.h create mode 100644 libspark/hardware_caps.c create mode 100644 libtriple/hardware_caps.c diff --git a/Makefile.am b/Makefile.am index 0a9c765..a016297 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,6 +24,7 @@ SUBDIRS += libtriple libstb_hal_a_LIBADD += \ libtriple/audio_td.o \ libtriple/dmx_td.o \ + libtriple/hardware_caps.o \ libtriple/init_td.o \ libtriple/lt_dfbinput.o \ libtriple/playback_td.o \ @@ -36,6 +37,7 @@ SUBDIRS += azbox libstb_hal_a_LIBADD += \ azbox/audio.o \ azbox/dmx.o \ + azbox/hardware_caps.o \ azbox/init.o \ azbox/playback.o \ azbox/pwrmngr.o \ @@ -47,6 +49,7 @@ SUBDIRS += libspark libeplayer3 libstb_hal_a_LIBADD += \ libspark/audio.o \ libspark/dmx.o \ + libspark/hardware_caps.o \ libspark/init.o \ libspark/irmp.o \ libspark/lirmp_input.o \ diff --git a/azbox/Makefile.am b/azbox/Makefile.am index 95cdc70..f234200 100644 --- a/azbox/Makefile.am +++ b/azbox/Makefile.am @@ -8,6 +8,7 @@ AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing AM_LDFLAGS = -lpthread libdummy_a_SOURCES = \ + hardware_caps.c \ dmx.cpp \ video.cpp \ audio.cpp \ diff --git a/azbox/hardware_caps.c b/azbox/hardware_caps.c new file mode 100644 index 0000000..6489378 --- /dev/null +++ b/azbox/hardware_caps.c @@ -0,0 +1,50 @@ +/* + * determine the capabilities of the hardware. + * part of libstb-hal + * + * (C) 2010-2012 Stefan Seyfried + * + * License: GPL v2 or later + */ + +#include +#include +#include +#include +#include +#include +#include + +static int initialized = 0; +static hw_caps_t caps; + +hw_caps_t *get_hwcaps(void) +{ + if (initialized) + return ∩︀ + + memset(&caps, 0, sizeof(hw_caps_t)); + + initialized = 1; + caps.can_shutdown = 1; + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.has_HDMI = 1; + caps.display_xres = 8; + strcpy(caps.boxvendor, "AZBox"); + const char *tmp; + char buf[64]; + int len = -1; + int fd = open("/proc/stb/info/model", O_RDONLY); + if (fd != -1) { + len = read(fd, buf, sizeof(buf) - 1); + close(fd); + } + if (len > 0) { + buf[len] = 0; + strcpy(caps.boxname, buf); + } + else + strcpy(caps.boxname, "(unknown model)"); + + return ∩︀ +} diff --git a/common/hardware_caps.h b/common/hardware_caps.h new file mode 120000 index 0000000..3bb479b --- /dev/null +++ b/common/hardware_caps.h @@ -0,0 +1 @@ +../include/hardware_caps.h \ No newline at end of file diff --git a/include/hardware_caps.h b/include/hardware_caps.h new file mode 100644 index 0000000..5966056 --- /dev/null +++ b/include/hardware_caps.h @@ -0,0 +1,45 @@ +/* + * determine the capabilities of the hardware. + * part of libstb-hal + * + * (C) 2010-2012 Stefan Seyfried + * + * License: GPL v2 or later + */ +#ifndef __HARDWARE_CAPS_H__ +#define __HARDWARE_CAPS_H__ + +#ifdef __cplusplus +extern "C" { +#endif +typedef enum +{ + HW_DISPLAY_NONE, + HW_DISPLAY_LED_NUM, /* simple 7 segment LED display */ + HW_DISPLAY_LINE_TEXT, /* 1 line text display */ + HW_DISPLAY_GFX +} display_type_t; + + +typedef struct hw_caps +{ + int has_fan; + int has_HDMI; + int has_SCART; + int has_SCART_input; + int has_YUV_cinch; + int can_shutdown; + int can_cec; + display_type_t display_type; + int display_xres; /* x resolution or chars per line */ + int display_yres; + char boxvendor[64]; + char boxname[64]; +} hw_caps_t; + +hw_caps_t *get_hwcaps(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libspark/Makefile.am b/libspark/Makefile.am index dc74f60..f35318e 100644 --- a/libspark/Makefile.am +++ b/libspark/Makefile.am @@ -9,6 +9,7 @@ AM_LDFLAGS = -lpthread libspark_a_SOURCES = \ irmp.c \ + hardware_caps.c \ lirmp_input.cpp \ dmx.cpp \ video.cpp \ diff --git a/libspark/hardware_caps.c b/libspark/hardware_caps.c new file mode 100644 index 0000000..c872658 --- /dev/null +++ b/libspark/hardware_caps.c @@ -0,0 +1,76 @@ +/* + * determine the capabilities of the hardware. + * part of libstb-hal + * + * (C) 2010-2012 Stefan Seyfried + * + * License: GPL v2 or later + */ + +#include +#include +#include +#include +#include +#include +#include + +static int initialized = 0; +static hw_caps_t caps; + +hw_caps_t *get_hwcaps(void) +{ + if (initialized) + return ∩︀ + + memset(&caps, 0, sizeof(hw_caps_t)); + + initialized = 1; + caps.can_shutdown = 1; + caps.display_type = HW_DISPLAY_LED_NUM; + caps.has_HDMI = 1; + caps.display_xres = 4; + strcpy(caps.boxvendor, "SPARK"); + const char *tmp; + char buf[1024]; + int len = -1; + int fd = open("/proc/cmdline", O_RDONLY); + if (fd != -1) { + len = read(fd, buf, sizeof(buf) - 1); + close(fd); + } + if (len > 0) { + buf[len] = 0; + char *p = strstr(buf, "STB_ID="); + int h0, h1, h2; + if (p && sscanf(p, "STB_ID=%x:%x:%x:", &h0, &h1, &h2) == 3) { + int sys_id = (h0 << 16) | (h1 << 8) | h2; + switch (sys_id) { + case 0x090007: + tmp = "GoldenMedia GM990"; + caps.has_SCART = 1; + break; + case 0x090008: + tmp = "Edision Pingulux"; + break; + case 0x09000a: + tmp = "Amiko Alien SDH8900"; + caps.has_SCART = 1; + break; + case 0x09000b: + tmp = "GalaxyInnovations S8120"; + caps.has_SCART = 1; + break; + case 0x0c0007: + tmp = "GoldenMedia Triplex"; + caps.has_SCART = 1; + break; + default: + tmp = p; + } + } else + tmp = "(NO STB_ID FOUND)"; + strcpy(caps.boxname, tmp); + } + return ∩︀ +} diff --git a/libtriple/Makefile.am b/libtriple/Makefile.am index a14b131..6ef7656 100644 --- a/libtriple/Makefile.am +++ b/libtriple/Makefile.am @@ -7,6 +7,7 @@ noinst_LIBRARIES = libtriple.a AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing libtriple_a_SOURCES = \ + hardware_caps.c \ lt_dfbinput.cpp \ dmx_td.cpp \ video_td.cpp \ diff --git a/libtriple/hardware_caps.c b/libtriple/hardware_caps.c new file mode 100644 index 0000000..facb1b1 --- /dev/null +++ b/libtriple/hardware_caps.c @@ -0,0 +1,30 @@ +/* + * determine the capabilities of the hardware. + * part of libstb-hal + * + * (C) 2010-2012 Stefan Seyfried + * + * License: GPL v2 or later + */ + +#include "hardware_caps.h" + +static hw_caps_t caps = { + .has_fan = 0, + .has_SCART = 1, + .has_SCART_input = 1, + .has_HDMI = 0, + .has_YUV_cinch = 0, + .can_shutdown = 0, + .can_cec = 0, + .display_type = HW_DISPLAY_GFX, + .display_xres = 128, + .display_yres = 64, + .boxvendor = "Armas", + .boxname = "TripleDragon" +}; + +hw_caps_t *get_hwcaps(void) +{ + return ∩︀ +} From f0a9b76ef1a97b9b9180727c5d8bb73c62f56e35 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 16 Sep 2012 22:53:35 +0200 Subject: [PATCH 2/2] spark: improve hardware_caps detection --- libspark/hardware_caps.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libspark/hardware_caps.c b/libspark/hardware_caps.c index c872658..dda67aa 100644 --- a/libspark/hardware_caps.c +++ b/libspark/hardware_caps.c @@ -13,8 +13,12 @@ #include #include #include +#include +#include + #include +#define FP_DEV "/dev/vfd" static int initialized = 0; static hw_caps_t caps; @@ -33,7 +37,7 @@ hw_caps_t *get_hwcaps(void) strcpy(caps.boxvendor, "SPARK"); const char *tmp; char buf[1024]; - int len = -1; + int len = -1, ret, val; int fd = open("/proc/cmdline", O_RDONLY); if (fd != -1) { len = read(fd, buf, sizeof(buf) - 1); @@ -72,5 +76,16 @@ hw_caps_t *get_hwcaps(void) tmp = "(NO STB_ID FOUND)"; strcpy(caps.boxname, tmp); } + fd = open (FP_DEV, O_RDWR); + if (fd != -1) { + ret = ioctl(fd, VFDGETVERSION, &val); + if (ret < 0) + fprintf(stderr, "[hardware_caps] %s: VFDGETVERSION %m\n", __func__); + else if (val == 1) { /* VFD, others not yet seen in the wild */ + caps.display_type = HW_DISPLAY_LINE_TEXT; + caps.display_xres = 8; + } + close(fd); + } return ∩︀ }