add libduckbox

This commit is contained in:
max10
2014-04-27 01:52:05 +02:00
parent fcf4785716
commit 4dc1171253
73 changed files with 4050 additions and 2030 deletions

26
libduckbox/Makefile.am Normal file
View File

@@ -0,0 +1,26 @@
noinst_LTLIBRARIES = libduckbox.la
AM_CPPFLAGS = -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
AM_CPPFLAGS += \
-I$(top_srcdir)/common \
-I$(top_srcdir)/include \
-I$(top_srcdir)/libeplayer3/include
AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing
AM_LDFLAGS = -lpthread -lasound -lass -lrt \
@AVFORMAT_LIBS@ \
@AVUTIL_LIBS@ \
@AVCODEC_LIBS@ \
@SWRESAMPLE_LIBS@
libduckbox_la_SOURCES = \
hardware_caps.c \
dmx.cpp \
video.cpp \
audio.cpp \
audio_mixer.cpp \
init.cpp \
playback_libeplayer3.cpp \
pwrmngr.cpp \
record.cpp

1
libduckbox/audio.cpp Symbolic link
View File

@@ -0,0 +1 @@
../libspark/audio.cpp

1
libduckbox/audio_lib.h Symbolic link
View File

@@ -0,0 +1 @@
../libspark/audio_lib.h

1
libduckbox/audio_mixer.cpp Symbolic link
View File

@@ -0,0 +1 @@
../libspark/audio_mixer.cpp

1
libduckbox/audio_mixer.h Symbolic link
View File

@@ -0,0 +1 @@
../libspark/audio_mixer.h

30
libduckbox/cs_api.h Normal file
View File

@@ -0,0 +1,30 @@
/* compatibility header for tripledragon. I'm lazy, so I just left it
as "cs_api.h" so that I don't need too many ifdefs in the code */
#ifndef __CS_API_H_
#define __CS_API_H_
#include "init_lib.h"
typedef void (*cs_messenger) (unsigned int msg, unsigned int data);
inline void cs_api_init()
{
init_td_api();
};
inline void cs_api_exit()
{
shutdown_td_api();
};
#define cs_malloc_uncached malloc
#define cs_free_uncached free
// Callback function helpers
void cs_register_messenger(cs_messenger messenger);
static inline void cs_deregister_messenger(void) { return; };
/* compat... HD1 seems to be version 6. everything newer ist > 6... */
static inline unsigned int cs_get_revision(void) { return 1; };
extern int cnxt_debug;
#endif //__CS_API_H_

1
libduckbox/dmx.cpp Symbolic link
View File

@@ -0,0 +1 @@
../libspark/dmx.cpp

1
libduckbox/dmx_cs.h Symbolic link
View File

@@ -0,0 +1 @@
../libspark/dmx_cs.h

1
libduckbox/dmx_lib.h Symbolic link
View File

@@ -0,0 +1 @@
../libspark/dmx_lib.h

158
libduckbox/hardware_caps.c Normal file
View File

@@ -0,0 +1,158 @@
/*
* 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;
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;
if (!strncmp(buf, "atevio7500", 10)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 1;
caps.has_fan = 0;
caps.has_CI = 2;
}
else if (!strncmp(buf, "ufs912", 6)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 1;
caps.has_fan = 0;
caps.has_CI = 2;
}
else if (!strncmp(buf, "ufs913", 6)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 1;
caps.has_fan = 0;
caps.has_CI = 2;
}
else if (!strncmp(buf, "ufs922", 6)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 0;
caps.has_fan = 1;
caps.has_CI = 2;
}
else if (!strncmp(buf, "ufs910", 6)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 0;
caps.has_fan = 0;
caps.has_CI = 2;
}
else if (!strncmp(buf, "hdbox", 5)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 0;
caps.has_fan = 0;
caps.has_CI = 2;
}
else if (!strncmp(buf, "octagon1008", 11)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 0;
caps.has_fan = 0;
caps.has_CI = 2;
}
else if (!strncmp(buf, "cuberevo", 8)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 0;
caps.has_fan = 0;
caps.has_CI = 2;
}
else if (!strncmp(buf, "cuberevo-mini2", 14)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 0;
caps.has_fan = 0;
caps.has_CI = 2;
}
else if (!strncmp(buf, "cuberevo-2000hd", 15)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 0;
caps.has_fan = 0;
caps.has_CI = 0;
}
else if (!strncmp(buf, "tf7700", 6)) {
strcpy(caps.boxvendor, "DUCKBOX");
strcpy(caps.boxname, buf);
caps.can_shutdown = 1;
caps.has_HDMI = 1;
caps.has_SCART = 1;
caps.can_cec = 0;
caps.has_fan = 0;
caps.has_CI = 2;
}
else {
strcpy(caps.boxvendor, "unknown");
strcpy(caps.boxname, "unknown model");
}
}
else
strcpy(caps.boxname, "(unknown model)");
return &caps;
}

55
libduckbox/init.cpp Normal file
View File

@@ -0,0 +1,55 @@
#include <stdio.h>
#include "init_lib.h"
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <linux/dvb/dmx.h>
#include "pwrmngr.h"
#include "lt_debug.h"
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_INIT, NULL, args)
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_INIT, NULL, args)
static bool initialized = false;
void init_td_api()
{
if (!initialized)
lt_debug_init();
lt_info("%s begin, initialized=%d, debug=0x%02x\n", __FUNCTION__, (int)initialized, debuglevel);
if (!initialized)
{
/* this is a strange hack: the drivers seem to only work correctly after
* demux0 has been used once. After that, we can use demux1,2,... */
struct dmx_pes_filter_params p;
int dmx = open("/dev/dvb/adapter0/demux0", O_RDWR|O_CLOEXEC);
if (dmx < 0)
lt_info("%s: ERROR open /dev/dvb/adapter0/demux0 (%m)\n", __func__);
else
{
memset(&p, 0, sizeof(p));
p.output = DMX_OUT_DECODER;
p.input = DMX_IN_FRONTEND;
p.flags = DMX_IMMEDIATE_START;
p.pes_type = DMX_PES_VIDEO;
ioctl(dmx, DMX_SET_PES_FILTER, &p);
ioctl(dmx, DMX_STOP);
close(dmx);
}
}
initialized = true;
lt_info("%s end\n", __FUNCTION__);
}
void shutdown_td_api()
{
lt_info("%s, initialized = %d\n", __FUNCTION__, (int)initialized);
initialized = false;
}

1
libduckbox/init_cs.h Symbolic link
View File

@@ -0,0 +1 @@
../libspark/init_cs.h

1
libduckbox/init_lib.h Symbolic link
View File

@@ -0,0 +1 @@
../libspark/init_lib.h

View File

@@ -0,0 +1 @@
../libspark/playback_libeplayer3.cpp

View File

@@ -0,0 +1 @@
../libspark/playback_libeplayer3.h

1
libduckbox/pwrmngr.cpp Symbolic link
View File

@@ -0,0 +1 @@
../libspark/pwrmngr.cpp

1
libduckbox/pwrmngr.h Symbolic link
View File

@@ -0,0 +1 @@
../libspark/pwrmngr.h

1
libduckbox/record.cpp Symbolic link
View File

@@ -0,0 +1 @@
../libspark/record.cpp

1
libduckbox/record_lib.h Symbolic link
View File

@@ -0,0 +1 @@
../libspark/record_lib.h

1
libduckbox/video.cpp Symbolic link
View File

@@ -0,0 +1 @@
../libspark/video.cpp

1
libduckbox/video_lib.h Symbolic link
View File

@@ -0,0 +1 @@
../libspark/video_lib.h