Hi list,
Asking myself if I want to build kernels and drivers for 4 different PCs
or try my luck with an old DVB API patch for vdr-1.5.14, I've chosen the
latter. The attached patch implements fallback for VDR in case no
multiproto DVB driver headers are available.
I'm not really sure what I've been doing here, as I don't know the DVB
API well enough, but at least my vdr-1.5.14 is running on old DVB
drivers again. The patch is a bit hackish, and could probably be
implemented a bit more cleanly, but its a starting point.
Cheers,
Udo
diff -Naur vdr-1.5.14-orig/channels.c vdr-1.5.14/channels.c
--- vdr-1.5.14-orig/channels.c 2008-01-27 14:59:53.000000000 +0100
+++ vdr-1.5.14/channels.c 2008-01-27 21:03:04.000000000 +0100
@@ -11,6 +11,7 @@
#include <linux/dvb/frontend.h>
#include <ctype.h>
#include "device.h"
+#include "dvb_api_emulate.h"
#include "epg.h"
#include "timers.h"
diff -Naur vdr-1.5.14-orig/dvb_api_emulate.h vdr-1.5.14/dvb_api_emulate.h
--- vdr-1.5.14-orig/dvb_api_emulate.h 1970-01-01 01:00:00.000000000 +0100
+++ vdr-1.5.14/dvb_api_emulate.h 2008-01-27 21:03:04.000000000 +0100
@@ -0,0 +1,106 @@
+/*
+ * dvb_api_emulate.h: The DVB device interface
+ *
+ * See the main source file 'vdr.c' for copyright information and
+ * how to reach the author.
+ *
+ * $Id: $
+ */
+
+#ifndef __DVB_API_EMULATE_H
+#define __DVB_API_EMULATE_H
+
+
+#if DVB_API_VERSION != 3 || DVB_API_VERSION_MINOR != 3
+
+#define DVB_API_EMULATE
+
+enum dvbfe_delsys {
+ DVBFE_DELSYS_DVBS = (1 << 0),
+ DVBFE_DELSYS_DSS = (1 << 1),
+ DVBFE_DELSYS_DVBS2 = (1 << 2),
+ DVBFE_DELSYS_DVBC = (1 << 3),
+ DVBFE_DELSYS_DVBT = (1 << 4),
+ DVBFE_DELSYS_DVBH = (1 << 5),
+ DVBFE_DELSYS_ATSC = (1 << 6),
+ DVBFE_DELSYS_DUMMY = (1 << 31)
+};
+enum dvbfe_hierarchy {
+ DVBFE_HIERARCHY_OFF = (1 << 0),
+ DVBFE_HIERARCHY_ON = (1 << 1),
+ DVBFE_HIERARCHY_AUTO = (1 << 2)
+};
+enum dvbfe_alpha {
+ DVBFE_ALPHA_1 = (1 << 0),
+ DVBFE_ALPHA_2 = (1 << 1),
+ DVBFE_ALPHA_4 = (1 << 2)
+};
+enum dvbfe_stream_priority {
+ DVBFE_STREAM_PRIORITY_HP = (0 << 0),
+ DVBFE_STREAM_PRIORITY_LP = (1 << 0)
+};
+enum dvbfe_rolloff {
+ DVBFE_ROLLOFF_35 = 0,
+ DVBFE_ROLLOFF_25 = 1,
+ DVBFE_ROLLOFF_20 = 2,
+ DVBFE_ROLLOFF_UNKNOWN = 3
+};
+
+#define DVBFE_SET_PARAMS FE_SET_FRONTEND
+#define DVBFE_INVERSION_OFF INVERSION_OFF
+#define DVBFE_INVERSION_ON INVERSION_ON
+#define DVBFE_INVERSION_AUTO INVERSION_AUTO
+#define DVBFE_BANDWIDTH_5_MHZ BANDWIDTH_AUTO
+#define DVBFE_BANDWIDTH_6_MHZ BANDWIDTH_6_MHZ
+#define DVBFE_BANDWIDTH_7_MHZ BANDWIDTH_7_MHZ
+#define DVBFE_BANDWIDTH_8_MHZ BANDWIDTH_8_MHZ
+#define DVBFE_BANDWIDTH_AUTO BANDWIDTH_AUTO
+#define DVBFE_FEC_NONE FEC_NONE
+#define DVBFE_FEC_1_2 FEC_1_2
+#define DVBFE_FEC_1_3 FEC_AUTO
+#define DVBFE_FEC_1_4 FEC_AUTO
+#define DVBFE_FEC_2_3 FEC_2_3
+#define DVBFE_FEC_2_5 FEC_AUTO
+#define DVBFE_FEC_3_4 FEC_3_4
+#define DVBFE_FEC_3_5 FEC_AUTO
+#define DVBFE_FEC_4_5 FEC_4_5
+#define DVBFE_FEC_5_6 FEC_5_6
+#define DVBFE_FEC_6_7 FEC_6_7
+#define DVBFE_FEC_7_8 FEC_7_8
+#define DVBFE_FEC_8_9 FEC_8_9
+#define DVBFE_FEC_9_10 FEC_AUTO
+#define DVBFE_FEC_AUTO FEC_AUTO
+#define DVBFE_MOD_NONE QAM_AUTO
+#define DVBFE_MOD_QAM4 QAM_AUTO
+#define DVBFE_MOD_QAM16 QAM_16
+#define DVBFE_MOD_QAM32 QAM_32
+#define DVBFE_MOD_QAM64 QAM_64
+#define DVBFE_MOD_QAM128 QAM_128
+#define DVBFE_MOD_QAM256 QAM_256
+#define DVBFE_MOD_QAM512 QAM_AUTO
+#define DVBFE_MOD_QAM1024 QAM_AUTO
+#define DVBFE_MOD_BPSK QAM_AUTO
+#define DVBFE_MOD_QPSK QPSK
+#define DVBFE_MOD_OQPSK QAM_AUTO
+#define DVBFE_MOD_8PSK QAM_AUTO
+#define DVBFE_MOD_16APSK QAM_AUTO
+#define DVBFE_MOD_32APSK QAM_AUTO
+#define DVBFE_MOD_OFDM QAM_AUTO
+#define DVBFE_MOD_COFDM QAM_AUTO
+#define DVBFE_MOD_VSB8 QAM_AUTO
+#define DVBFE_MOD_VSB16 QAM_AUTO
+#define DVBFE_MOD_QAMAUTO QAM_AUTO
+#define DVBFE_MOD_AUTO QAM_AUTO
+#define DVBFE_TRANSMISSION_MODE_2K TRANSMISSION_MODE_2K
+#define DVBFE_TRANSMISSION_MODE_4K TRANSMISSION_MODE_AUTO
+#define DVBFE_TRANSMISSION_MODE_8K TRANSMISSION_MODE_8K
+#define DVBFE_TRANSMISSION_MODE_AUTO TRANSMISSION_MODE_AUTO
+#define DVBFE_GUARD_INTERVAL_1_4 GUARD_INTERVAL_1_4
+#define DVBFE_GUARD_INTERVAL_1_8 GUARD_INTERVAL_1_8
+#define DVBFE_GUARD_INTERVAL_1_16 GUARD_INTERVAL_1_16
+#define DVBFE_GUARD_INTERVAL_1_32 GUARD_INTERVAL_1_32
+#define DVBFE_GUARD_INTERVAL_AUTO GUARD_INTERVAL_AUTO
+
+#endif // if DVB_API_VERSION != 3 || DVB_API_VERSION_MINOR != 3
+
+#endif // ifndef __DVB_API_EMULATE_H
diff -Naur vdr-1.5.14-orig/dvbdevice.c vdr-1.5.14/dvbdevice.c
--- vdr-1.5.14-orig/dvbdevice.c 2008-01-27 15:35:54.000000000 +0100
+++ vdr-1.5.14/dvbdevice.c 2008-01-27 21:03:04.000000000 +0100
@@ -192,7 +192,11 @@
bool cDvbTuner::SetFrontend(void)
{
+#ifdef DVB_API_EMULATE
+ dvb_frontend_parameters Frontend;
+#else
dvbfe_params Frontend;
+#endif
memset(&Frontend, 0, sizeof(Frontend));
if (frontendType & (DVBFE_DELSYS_DVBS | DVBFE_DELSYS_DVBS2)) {
@@ -249,6 +253,12 @@
}
frequency = abs(frequency); // Allow for C-band, where the frequency is less than the LOF
+#ifdef DVB_API_EMULATE
+ Frontend.frequency = frequency * 1000UL;
+ Frontend.inversion = fe_spectral_inversion_t(channel.Inversion());
+ Frontend.u.qpsk.symbol_rate = channel.Srate() * 1000UL;
+ Frontend.u.qpsk.fec_inner = fe_code_rate_t(channel.CoderateH());
+#else
Frontend.delivery = dvbfe_delsys(channel.System());
Frontend.frequency = frequency * 1000UL;
Frontend.inversion = fe_spectral_inversion_t(channel.Inversion());
@@ -264,14 +274,23 @@
Frontend.delsys.dvbs2.rolloff = dvbfe_rolloff(channel.RollOff());
}
- tuneTimeout = DVBS_TUNE_TIMEOUT;
- lockTimeout = DVBS_LOCK_TIMEOUT;
-
dvbfe_info feinfo;
feinfo.delivery = Frontend.delivery;
CHECK(ioctl(fd_frontend, DVBFE_GET_INFO, &feinfo)); //switch system
+#endif
+
+ tuneTimeout = DVBS_TUNE_TIMEOUT;
+ lockTimeout = DVBS_LOCK_TIMEOUT;
}
else if (frontendType & DVBFE_DELSYS_DVBC) {
+
+#ifdef DVB_API_EMULATE
+ Frontend.frequency = FrequencyToHz(channel.Frequency());
+ Frontend.inversion = fe_spectral_inversion_t(channel.Inversion());
+ Frontend.u.qam.symbol_rate = channel.Srate() * 1000UL;
+ Frontend.u.qam.fec_inner = fe_code_rate_t(channel.CoderateH());
+ Frontend.u.qam.modulation = fe_modulation_t(channel.Modulation());
+#else
Frontend.delivery = DVBFE_DELSYS_DVBC;
Frontend.frequency = FrequencyToHz(channel.Frequency());
Frontend.inversion = fe_spectral_inversion_t(channel.Inversion());
@@ -279,14 +298,26 @@
Frontend.delsys.dvbc.fec = dvbfe_fec(channel.CoderateH());
Frontend.delsys.dvbc.modulation = dvbfe_modulation(channel.Modulation());
- tuneTimeout = DVBC_TUNE_TIMEOUT;
- lockTimeout = DVBC_LOCK_TIMEOUT;
-
dvbfe_info feinfo;
feinfo.delivery = Frontend.delivery;
CHECK(ioctl(fd_frontend, DVBFE_GET_INFO, &feinfo)); //switch system
+#endif
+
+ tuneTimeout = DVBC_TUNE_TIMEOUT;
+ lockTimeout = DVBC_LOCK_TIMEOUT;
}
else if (frontendType & DVBFE_DELSYS_DVBT) {
+#ifdef DVB_API_EMULATE
+ Frontend.frequency = FrequencyToHz(channel.Frequency());
+ Frontend.inversion = fe_spectral_inversion_t(channel.Inversion());
+ Frontend.u.ofdm.bandwidth = fe_bandwidth_t(channel.Bandwidth());
+ Frontend.u.ofdm.code_rate_HP = fe_code_rate_t(channel.CoderateH());
+ Frontend.u.ofdm.code_rate_LP = fe_code_rate_t(channel.CoderateL());
+ Frontend.u.ofdm.constellation = fe_modulation_t(channel.Modulation());
+ Frontend.u.ofdm.transmission_mode = fe_transmit_mode_t(channel.Transmission());
+ Frontend.u.ofdm.guard_interval = fe_guard_interval_t(channel.Guard());
+ Frontend.u.ofdm.hierarchy_information = fe_hierarchy_t(channel.Hierarchy());
+#else
Frontend.delivery = DVBFE_DELSYS_DVBT;
Frontend.frequency = FrequencyToHz(channel.Frequency());
Frontend.inversion = fe_spectral_inversion_t(channel.Inversion());
@@ -300,12 +331,13 @@
Frontend.delsys.dvbt.alpha = dvbfe_alpha(channel.Alpha());
Frontend.delsys.dvbt.priority = dvbfe_stream_priority(channel.Priority());
- tuneTimeout = DVBT_TUNE_TIMEOUT;
- lockTimeout = DVBT_LOCK_TIMEOUT;
-
dvbfe_info feinfo;
feinfo.delivery = Frontend.delivery;
CHECK(ioctl(fd_frontend, DVBFE_GET_INFO, &feinfo)); //switch system
+#endif
+
+ tuneTimeout = DVBT_TUNE_TIMEOUT;
+ lockTimeout = DVBT_LOCK_TIMEOUT;
}
else {
esyslog("ERROR: attempt to set channel with unknown DVB frontend type");
@@ -460,6 +492,30 @@
// We only check the devices that must be present - the others will be checked before accessing them://XXX
if (fd_frontend >= 0) {
+#ifdef DVB_API_EMULATE
+ dvb_frontend_info feinfo;
+ if (ioctl(fd_frontend, FE_GET_INFO, &feinfo) >= 0) {
+ switch (feinfo.type) {
+ case FE_QPSK:
+ frontendType = DVBFE_DELSYS_DVBS;
+ break;
+ case FE_QAM:
+ frontendType = DVBFE_DELSYS_DVBC;
+ break;
+ case FE_OFDM:
+ frontendType = DVBFE_DELSYS_DVBT;
+ break;
+ case FE_ATSC:
+ frontendType = DVBFE_DELSYS_DUMMY;
+ break;
+ }
+ if (frontendType != DVBFE_DELSYS_DUMMY)
+ dvbTuner = new cDvbTuner(fd_frontend, CardIndex(), frontendType);
+ }
+ else
+ LOG_ERROR;
+ }
+#else
if (ioctl(fd_frontend, DVBFE_GET_DELSYS, &frontendType) >= 0) {
const char **DeliverySystem = DeliverySystems;
cString ds;
@@ -481,6 +537,7 @@
else
LOG_ERROR;
}
+#endif
else
esyslog("ERROR: can't open DVB device %d", n);
diff -Naur vdr-1.5.14-orig/dvbdevice.h vdr-1.5.14/dvbdevice.h
--- vdr-1.5.14-orig/dvbdevice.h 2008-01-27 11:21:02.000000000 +0100
+++ vdr-1.5.14/dvbdevice.h 2008-01-27 21:03:04.000000000 +0100
@@ -14,9 +14,10 @@
#include <linux/dvb/version.h>
#include "device.h"
#include "dvbspu.h"
+#include "dvb_api_emulate.h"
-#if DVB_API_VERSION != 3 || DVB_API_VERSION_MINOR != 3
-#error VDR requires Linux DVB driver API version 3.3!
+#if DVB_API_VERSION != 3
+#error VDR requires Linux DVB driver API version 3!
#endif
#define MAXDVBDEVICES 8
diff -Naur vdr-1.5.14-orig/nit.c vdr-1.5.14/nit.c
--- vdr-1.5.14-orig/nit.c 2008-01-26 16:08:01.000000000 +0100
+++ vdr-1.5.14/nit.c 2008-01-27 21:03:04.000000000 +0100
@@ -10,6 +10,7 @@
#include "nit.h"
#include <linux/dvb/frontend.h>
#include "channels.h"
+#include "dvb_api_emulate.h"
#include "eitscan.h"
#include "libsi/section.h"
#include "libsi/descriptor.h"