Files
recycled-ni-libstb-hal/libspark/hardware_caps.c
Stefan Seyfried d9c22d3808 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
2012-09-15 11:49:51 +02:00

77 lines
1.5 KiB
C

/*
* 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;
}