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


Origin commit data
------------------
Branch: master
Commit: 8a6f1dea9d
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2012-09-15 (Sat, 15 Sep 2012)



------------------
This commit was generated by Migit
This commit is contained in:
Stefan Seyfried
2012-09-15 11:49:51 +02:00
parent 0ed8fd60c3
commit d9c22d3808
9 changed files with 208 additions and 0 deletions

View File

@@ -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 \

View File

@@ -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 \

50
azbox/hardware_caps.c Normal file
View File

@@ -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 <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <hardware_caps.h>
static int initialized = 0;
static hw_caps_t caps;
hw_caps_t *get_hwcaps(void)
{
if (initialized)
return &caps;
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 &caps;
}

1
common/hardware_caps.h Symbolic link
View File

@@ -0,0 +1 @@
../include/hardware_caps.h

45
include/hardware_caps.h Normal file
View File

@@ -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

View File

@@ -9,6 +9,7 @@ AM_LDFLAGS = -lpthread
libspark_a_SOURCES = \
irmp.c \
hardware_caps.c \
lirmp_input.cpp \
dmx.cpp \
video.cpp \

76
libspark/hardware_caps.c Normal file
View File

@@ -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 <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <hardware_caps.h>
static int initialized = 0;
static hw_caps_t caps;
hw_caps_t *get_hwcaps(void)
{
if (initialized)
return &caps;
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 &caps;
}

View File

@@ -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 \

30
libtriple/hardware_caps.c Normal file
View File

@@ -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 &caps;
}