diff --git a/azbox/dmx.cpp b/azbox/dmx.cpp index 099901a..1fe5561 100644 --- a/azbox/dmx.cpp +++ b/azbox/dmx.cpp @@ -1,3 +1,24 @@ +/* + * cDemux implementation for azbox receivers (tested on azbox me and minime) + * + * derived from libtriple/dmx_td.cpp + * + * (C) 2010-2013 Stefan Seyfried + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "config.h" #include #include @@ -141,14 +162,6 @@ void cDemux::Close(void) return; } - for (std::vector::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i) - { - lt_debug("%s stopping and closing demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid); - if (ioctl((*i).fd, DMX_STOP) < 0) - perror("DEMUX_STOP"); - if (close((*i).fd) < 0) - perror("close"); - } pesfds.clear(); ioctl(fd, DMX_STOP); close(fd); @@ -174,13 +187,6 @@ bool cDemux::Start(bool) lt_info("%s #%d: not open!\n", __FUNCTION__, num); return false; } - - for (std::vector::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i) - { - lt_debug("%s starting demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid); - if (ioctl((*i).fd, DMX_START) < 0) - perror("DMX_START"); - } ioctl(fd, DMX_START); return true; } @@ -193,12 +199,6 @@ bool cDemux::Stop(void) lt_info("%s #%d: not open!\n", __FUNCTION__, num); return false; } - for (std::vector::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i) - { - lt_debug("%s stopping demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid); - if (ioctl((*i).fd, DMX_STOP) < 0) - perror("DMX_STOP"); - } ioctl(fd, DMX_STOP); return true; } @@ -277,13 +277,12 @@ bool cDemux::sectionFilter(unsigned short pid, const unsigned char * const filte const unsigned char * const mask, int len, int timeout, const unsigned char * const negmask) { - int length = len; memset(&s_flt, 0, sizeof(s_flt)); if (len > DMX_FILTER_SIZE) { lt_info("%s #%d: len too long: %d, DMX_FILTER_SIZE %d\n", __func__, num, len, DMX_FILTER_SIZE); - length = DMX_FILTER_SIZE; + len = DMX_FILTER_SIZE; } s_flt.pid = pid; s_flt.timeout = timeout; @@ -454,7 +453,6 @@ bool cDemux::addPid(unsigned short Pid) lt_debug("%s: pid 0x%04hx\n", __func__, Pid); pes_pids pfd; int ret; - struct dmx_pes_filter_params p; if (dmx_type != DMX_TP_CHANNEL) { lt_info("%s pes_type %s not implemented yet! pid=%hx\n", __FUNCTION__, DMX_T[dmx_type], Pid); @@ -462,6 +460,9 @@ bool cDemux::addPid(unsigned short Pid) } if (fd == -1) lt_info("%s bucketfd not yet opened? pid=%hx\n", __FUNCTION__, Pid); + pfd.fd = fd; /* dummy */ + pfd.pid = Pid; + pesfds.push_back(pfd); ret = (ioctl(fd, DMX_ADD_PID, &Pid)); if (ret < 0) lt_info("%s: DMX_ADD_PID (%m)\n", __func__); @@ -478,11 +479,9 @@ void cDemux::removePid(unsigned short Pid) for (std::vector::iterator i = pesfds.begin(); i != pesfds.end(); ++i) { if ((*i).pid == Pid) { - lt_debug("removePid: removing demux fd %d pid 0x%04x\n", (*i).fd, Pid); - if (ioctl((*i).fd, DMX_STOP) < 0) - perror("DMX_STOP"); - if (close((*i).fd) < 0) - perror("close"); + lt_debug("removePid: removing demux fd %d pid 0x%04x\n", fd, Pid); + if (ioctl(fd, DMX_REMOVE_PID, Pid) < 0) + lt_info("%s: (DMX_REMOVE_PID, 0x%04hx): %m\n", __func__, Pid); pesfds.erase(i); return; /* TODO: what if the same PID is there multiple times */ } @@ -515,3 +514,9 @@ bool cDemux::SetSource(int unit, int source) lt_info_c("%s(%d, %d): not implemented yet\n", __func__, unit, source); return true; } + +int cDemux::GetSource(int unit) +{ + lt_info_c("%s(%d): not implemented yet\n", __func__, unit); + return 0; +} diff --git a/azbox/dmx_lib.h b/azbox/dmx_lib.h index ffd293e..ed38048 100644 --- a/azbox/dmx_lib.h +++ b/azbox/dmx_lib.h @@ -55,6 +55,7 @@ class cDemux void getSTC(int64_t * STC); int getUnit(void); static bool SetSource(int unit, int source); + static int GetSource(int unit); // TD only functions int getFD(void) { return fd; }; /* needed by cPlayback class */ void removePid(unsigned short Pid); /* needed by cRecord class */ diff --git a/generic-pc/dmx.cpp b/generic-pc/dmx.cpp index 7a61a90..91525fd 100644 --- a/generic-pc/dmx.cpp +++ b/generic-pc/dmx.cpp @@ -1,3 +1,25 @@ +/* + * cDemux implementation for generic dvbapi + * + * derived from libtriple/dmx_td.cpp + * + * (C) 2010-2013 Stefan Seyfried + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + #include "config.h" #include #include @@ -124,15 +146,6 @@ void cDemux::Close(void) lt_info("%s #%d: not open!\n", __FUNCTION__, num); return; } - - for (std::vector::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i) - { - lt_debug("%s stopping and closing demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid); - if (ioctl((*i).fd, DMX_STOP) < 0) - perror("DEMUX_STOP"); - if (close((*i).fd) < 0) - perror("close"); - } pesfds.clear(); ioctl(fd, DMX_STOP); close(fd); @@ -158,13 +171,6 @@ bool cDemux::Start(bool) lt_info("%s #%d: not open!\n", __FUNCTION__, num); return false; } - - for (std::vector::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i) - { - lt_debug("%s starting demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid); - if (ioctl((*i).fd, DMX_START) < 0) - perror("DMX_START"); - } ioctl(fd, DMX_START); return true; } @@ -177,12 +183,6 @@ bool cDemux::Stop(void) lt_info("%s #%d: not open!\n", __FUNCTION__, num); return false; } - for (std::vector::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i) - { - lt_debug("%s stopping demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid); - if (ioctl((*i).fd, DMX_STOP) < 0) - perror("DMX_STOP"); - } ioctl(fd, DMX_STOP); return true; } @@ -247,13 +247,12 @@ bool cDemux::sectionFilter(unsigned short pid, const unsigned char * const filte const unsigned char * const mask, int len, int timeout, const unsigned char * const negmask) { - int length = len; memset(&s_flt, 0, sizeof(s_flt)); if (len > DMX_FILTER_SIZE) { lt_info("%s #%d: len too long: %d, DMX_FILTER_SIZE %d\n", __func__, num, len, DMX_FILTER_SIZE); - length = DMX_FILTER_SIZE; + len = DMX_FILTER_SIZE; } s_flt.pid = pid; s_flt.timeout = timeout; @@ -422,7 +421,6 @@ bool cDemux::addPid(unsigned short Pid) lt_debug("%s: pid 0x%04hx\n", __func__, Pid); pes_pids pfd; int ret; - struct dmx_pes_filter_params p; if (dmx_type != DMX_TP_CHANNEL) { lt_info("%s pes_type %s not implemented yet! pid=%hx\n", __FUNCTION__, DMX_T[dmx_type], Pid); @@ -430,6 +428,9 @@ bool cDemux::addPid(unsigned short Pid) } if (fd == -1) lt_info("%s bucketfd not yet opened? pid=%hx\n", __FUNCTION__, Pid); + pfd.fd = fd; /* dummy */ + pfd.pid = Pid; + pesfds.push_back(pfd); ret = (ioctl(fd, DMX_ADD_PID, &Pid)); if (ret < 0) lt_info("%s: DMX_ADD_PID (%m)\n", __func__); @@ -446,11 +447,9 @@ void cDemux::removePid(unsigned short Pid) for (std::vector::iterator i = pesfds.begin(); i != pesfds.end(); ++i) { if ((*i).pid == Pid) { - lt_debug("removePid: removing demux fd %d pid 0x%04x\n", (*i).fd, Pid); - if (ioctl((*i).fd, DMX_STOP) < 0) - perror("DMX_STOP"); - if (close((*i).fd) < 0) - perror("close"); + lt_debug("removePid: removing demux fd %d pid 0x%04x\n", fd, Pid); + if (ioctl(fd, DMX_REMOVE_PID, Pid) < 0) + lt_info("%s: (DMX_REMOVE_PID, 0x%04hx): %m\n", __func__, Pid); pesfds.erase(i); return; /* TODO: what if the same PID is there multiple times */ } @@ -478,3 +477,9 @@ bool cDemux::SetSource(int unit, int source) lt_info_c("%s(%d, %d): not implemented yet\n", __func__, unit, source); return true; } + +int cDemux::GetSource(int unit) +{ + lt_info_c("%s(%d): not implemented yet\n", __func__, unit); + return 0; +} diff --git a/generic-pc/dmx_lib.h b/generic-pc/dmx_lib.h index ffd293e..ed38048 100644 --- a/generic-pc/dmx_lib.h +++ b/generic-pc/dmx_lib.h @@ -55,6 +55,7 @@ class cDemux void getSTC(int64_t * STC); int getUnit(void); static bool SetSource(int unit, int source); + static int GetSource(int unit); // TD only functions int getFD(void) { return fd; }; /* needed by cPlayback class */ void removePid(unsigned short Pid); /* needed by cRecord class */ diff --git a/libspark/dmx.cpp b/libspark/dmx.cpp index edc96d3..1523d19 100644 --- a/libspark/dmx.cpp +++ b/libspark/dmx.cpp @@ -1,15 +1,23 @@ /* * cDemux implementation for SH4 receivers (tested on fulan spark and - * fulan spark7162 hardware + * fulan spark7162 hardware) * * derived from libtriple/dmx_td.cpp * - * (C) 2010-2012 Stefan Seyfried + * (C) 2010-2013 Stefan Seyfried * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ /* @@ -227,14 +235,6 @@ void cDemux::Close(void) return; } - for (std::vector::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i) - { - lt_debug("%s stopping and closing demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid); - if (ioctl((*i).fd, DMX_STOP) < 0) - perror("DEMUX_STOP"); - if (close((*i).fd) < 0) - perror("close"); - } pesfds.clear(); ioctl(fd, DMX_STOP); close(fd); @@ -259,16 +259,7 @@ bool cDemux::Start(bool) lt_info("%s #%d: not open!\n", __FUNCTION__, num); return false; } - -#ifndef MARTII - for (std::vector::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i) - { - lt_debug("%s starting demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid); - if (ioctl((*i).fd, DMX_START) < 0) - perror("DMX_START"); - } ioctl(fd, DMX_START); -#endif return true; } @@ -279,12 +270,6 @@ bool cDemux::Stop(void) lt_info("%s #%d: not open!\n", __FUNCTION__, num); return false; } - for (std::vector::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i) - { - lt_debug("%s stopping demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid); - if (ioctl((*i).fd, DMX_STOP) < 0) - perror("DMX_STOP"); - } ioctl(fd, DMX_STOP); return true; } @@ -368,9 +353,6 @@ bool cDemux::sectionFilter(unsigned short pid, const unsigned char * const filte const unsigned char * const mask, int len, int timeout, const unsigned char * const negmask) { -#ifndef MARTII - int length = len; -#endif memset(&s_flt, 0, sizeof(s_flt)); _open(); @@ -378,11 +360,7 @@ bool cDemux::sectionFilter(unsigned short pid, const unsigned char * const filte if (len > DMX_FILTER_SIZE) { lt_info("%s #%d: len too long: %d, DMX_FILTER_SIZE %d\n", __func__, num, len, DMX_FILTER_SIZE); -#ifdef MARTII len = DMX_FILTER_SIZE; -#else - length = DMX_FILTER_SIZE; -#endif } s_flt.pid = pid; s_flt.timeout = timeout; @@ -554,13 +532,8 @@ void *cDemux::getChannel() bool cDemux::addPid(unsigned short Pid) { lt_debug("%s: pid 0x%04hx\n", __func__, Pid); -#ifndef MARTII pes_pids pfd; -#endif int ret; -#ifndef MARTII - struct dmx_pes_filter_params p; -#endif if (dmx_type != DMX_TP_CHANNEL) { lt_info("%s pes_type %s not implemented yet! pid=%hx\n", __FUNCTION__, DMX_T[dmx_type], Pid); @@ -569,39 +542,9 @@ bool cDemux::addPid(unsigned short Pid) _open(); if (fd == -1) lt_info("%s bucketfd not yet opened? pid=%hx\n", __FUNCTION__, Pid); -#if 0 - pfd.fd = open(devname[num], O_RDWR); - if (pfd.fd < 0) - { - lt_info("%s #%d Pid = %hx open failed (%m)\n", __FUNCTION__, num, Pid); - return false; - } - fcntl(pfd.fd, F_SETFD, FD_CLOEXEC); - lt_debug("%s #%d Pid = %hx pfd = %d\n", __FUNCTION__, num, Pid, pfd.fd); - - p.pid = Pid; - p.input = DMX_IN_FRONTEND; - p.pes_type = DMX_PES_OTHER; - p.output = DMX_OUT_TS_TAP; - p.flags = 0; - - ret = ioctl(pfd.fd, DMX_SET_BUFFER_SIZE, 0x10000); // 64k - if (ret == -1) - perror("DMX_SET_BUFFER_SIZE"); - else - { - ret = ioctl(pfd.fd, DMX_SET_PES_FILTER, &p); - if (ret == -1) - perror("DEMUX_FILTER_PES_SET"); - } + pfd.fd = fd; /* dummy */ pfd.pid = Pid; - if (ret != -1) - /* success! */ - pesfds.push_back(pfd); - else - /* error! */ - close(pfd.fd); -#endif + pesfds.push_back(pfd); ret = (ioctl(fd, DMX_ADD_PID, &Pid)); if (ret < 0) lt_info("%s: DMX_ADD_PID (%m)\n", __func__); @@ -618,11 +561,9 @@ void cDemux::removePid(unsigned short Pid) for (std::vector::iterator i = pesfds.begin(); i != pesfds.end(); ++i) { if ((*i).pid == Pid) { - lt_debug("removePid: removing demux fd %d pid 0x%04x\n", (*i).fd, Pid); - if (ioctl((*i).fd, DMX_STOP) < 0) - perror("DMX_STOP"); - if (close((*i).fd) < 0) - perror("close"); + lt_debug("removePid: removing demux fd %d pid 0x%04x\n", fd, Pid); + if (ioctl(fd, DMX_REMOVE_PID, Pid) < 0) + lt_info("%s: (DMX_REMOVE_PID, 0x%04hx): %m\n", __func__, Pid); pesfds.erase(i); return; /* TODO: what if the same PID is there multiple times */ } @@ -663,3 +604,13 @@ bool cDemux::SetSource(int unit, int source) dmx_source[unit] = source; return true; } + +int cDemux::GetSource(int unit) +{ + if (unit >= NUM_DEMUX || unit < 0) { + lt_info_c("%s: unit (%d) out of range, NUM_DEMUX %d\n", __func__, unit, NUM_DEMUX); + return -1; + } + lt_info_c("%s(%d) => %d\n", __func__, unit, dmx_source[unit]); + return dmx_source[unit]; +} diff --git a/libspark/dmx_lib.h b/libspark/dmx_lib.h index 99ac526..e85dc3c 100644 --- a/libspark/dmx_lib.h +++ b/libspark/dmx_lib.h @@ -57,6 +57,7 @@ class cDemux void getSTC(int64_t * STC); int getUnit(void); static bool SetSource(int unit, int source); + static int GetSource(int unit); // TD only functions int getFD(void) { return fd; }; /* needed by cPlayback class */ void removePid(unsigned short Pid); /* needed by cRecord class */ diff --git a/libspark/hardware_caps.c b/libspark/hardware_caps.c index 5849b52..9c70bc3 100644 --- a/libspark/hardware_caps.c +++ b/libspark/hardware_caps.c @@ -53,12 +53,10 @@ hw_caps_t *get_hwcaps(void) if (p && sscanf(p, "STB_ID=%x:%x:%x:", &h0, &h1, &h2) == 3) { int sys_id = (h0 << 16) | (h1 << 8) | h2; switch (sys_id) { -#ifdef MARTII case 0x090003: tmp = "Truman Premier 1+"; caps.has_SCART = 1; break; -#endif case 0x090007: tmp = "GoldenMedia GM990"; caps.has_SCART = 1; @@ -74,7 +72,6 @@ hw_caps_t *get_hwcaps(void) tmp = "GalaxyInnovations S8120"; caps.has_SCART = 1; break; -#ifdef MARTII case 0x09000d: tmp = "Dynavision Spark"; caps.has_SCART = 1; @@ -103,12 +100,10 @@ hw_caps_t *get_hwcaps(void) tmp = "Truman Top Box 2"; caps.has_SCART = 1; break; -#endif case 0x0c0007: tmp = "GoldenMedia Triplex"; caps.has_SCART = 1; break; -#ifdef MARTII case 0x0c000a: tmp = "Amiko Alien 2"; caps.has_SCART = 1; @@ -141,7 +136,6 @@ hw_caps_t *get_hwcaps(void) tmp = "Icecrypt S3700 CHD"; caps.has_SCART = 1; break; -#endif default: tmp = p; } diff --git a/libspark/video.cpp b/libspark/video.cpp index 6ca5f16..25340d1 100644 --- a/libspark/video.cpp +++ b/libspark/video.cpp @@ -1,10 +1,10 @@ /* * (C) 2002-2003 Andreas Oberritter - * (C) 2010-2011 Stefan Seyfried + * (C) 2010-2013 Stefan Seyfried * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or + * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -13,8 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA + * along with this program. If not, see . */ #include @@ -499,9 +498,6 @@ int cVideo::getBlank(void) size_t n = 0; ssize_t r; char *line = NULL; -#ifndef MARTII - char *p; -#endif /* hack: the "mailbox" irq is not increasing if * no audio or video is decoded... */ FILE *f = fopen("/proc/interrupts", "r"); diff --git a/libtriple/dmx_td.cpp b/libtriple/dmx_td.cpp index 3c4b1e1..f3549f6 100644 --- a/libtriple/dmx_td.cpp +++ b/libtriple/dmx_td.cpp @@ -1,3 +1,22 @@ +/* + * cDemux implementation for the Tripledragon dbs3000 receiver + * + * (C) 2010-2013 Stefan Seyfried + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include #include #include @@ -349,12 +368,12 @@ bool cDemux::sectionFilter(unsigned short pid, const unsigned char * const filte s_flt.filter[0] = filter[0]; s_flt.mask[0] = mask[0]; s_flt.timeout = timeout; - memcpy(&s_flt.filter[3], &filter[1], len - 1); - memcpy(&s_flt.mask[3], &mask[1], len - 1); + memcpy(&s_flt.filter[3], &filter[1], length - 1); + memcpy(&s_flt.mask[3], &mask[1], length - 1); if (negmask != NULL) { s_flt.positive[0] = negmask[0]; - memcpy(&s_flt.positive[3], &negmask[1], len - 1); + memcpy(&s_flt.positive[3], &negmask[1], length - 1); } s_flt.flags = XPDF_IMMEDIATE_START; diff --git a/libtriple/dmx_td.h b/libtriple/dmx_td.h index 4b35ece..e657592 100644 --- a/libtriple/dmx_td.h +++ b/libtriple/dmx_td.h @@ -63,6 +63,7 @@ class cDemux int getUnit(void); /* tripledragon is unlikely to get a second tuner, so stub it out right here */ static bool SetSource(int /*unit*/, int /*source*/) { return true; }; + static int GetSource(int /*unit*/) { return 0; }; // TD only functions int getFD(void) { return fd; }; /* needed by cPlayback class */ void removePid(unsigned short Pid); /* needed by cRecord class */ diff --git a/tools/spark_fp.c b/tools/spark_fp.c index 8f2a27b..b991539 100644 --- a/tools/spark_fp.c +++ b/tools/spark_fp.c @@ -44,8 +44,6 @@ void usage() #ifdef MARTII printf("\t-w