mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
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:
76
libspark/hardware_caps.c
Normal file
76
libspark/hardware_caps.c
Normal 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 ∩︀
|
||||
|
||||
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 ∩︀
|
||||
}
|
Reference in New Issue
Block a user