Re: [vdr] [PATCH] DVB API wrapper patch v0.2 for VDR-1.5.14

2008-02-04 Thread Udo Richter

For people who encounter this bug on recent kernels:

dvb_api_wrapper.c:189: error: '__invalid_size_argument_for_IOC' cannot 
appear in a constant-expression


This is caused by an obscure kernel compile check that is supposed to do 
macro parameter checking for ioctl constants, but also prevents using 
these constants in switch statements.


(Basically, it complains that an expression like this is not allowed:
case (true ? 1234 : some_var):
The glory details are in /usr/include/asm-generic/ioctl.h)


The attached (additional, because I'm lazy) patch works around this.

Cheers,

Udo

--- dvb_api_wrapper.c.orig  2008-02-04 21:12:33.0 +0100
+++ dvb_api_wrapper.c   2008-02-04 21:10:30.0 +0100
@@ -185,18 +185,16 @@
 }
 
 int DVBFE_ioctl(int d, int request, void *data) {
-  switch (request) {
-case DVBFE_SET_PARAMS:
- return ioctl_DVBFE_SET_PARAMS(d, (dvbfe_params*)data);
-case DVBFE_GET_DELSYS:
- return ioctl_DVBFE_GET_DELSYS(d, (dvbfe_delsys*)data);
-case DVBFE_GET_INFO:
- return ioctl_DVBFE_GET_INFO(d, (dvbfe_info*)data);
-case DVBFE_GET_PARAMS:
-case DVBFE_GET_EVENT:
- errno = EINVAL;
- return -1;
-  }
+  if (request == (int)DVBFE_SET_PARAMS)
+ return ioctl_DVBFE_SET_PARAMS(d, (dvbfe_params*)data);
+  if (request == (int)DVBFE_GET_DELSYS)
+ return ioctl_DVBFE_GET_DELSYS(d, (dvbfe_delsys*)data);
+  if (request == (int)DVBFE_GET_INFO)
+ return ioctl_DVBFE_GET_INFO(d, (dvbfe_info*)data);
+  if (request == (int)DVBFE_GET_PARAMS || request == (int)DVBFE_GET_EVENT) {
+ errno = EINVAL;
+ return -1;
+ }
   return ioctl(d, request, data);
 }
 
___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


[vdr] [PATCH] DVB API wrapper patch v0.2 for VDR-1.5.14

2008-02-03 Thread Udo Richter

Hi list,


Based on the original DVB API patch of last week, I've done a cleaner 
rewrite of the patch. This time, the changes to the VDR sources are 
limited to a few #includes and replacements of ioctl calls by the new 
DVBFE_ioctl wrapper call. All the magic goes into this API wrapper, that 
translates multiproto calls into DVB 3.0 API calls.


There's also more control on the behavior. Adding DEFINES += 
-DDVB_MULTIPROTO_WRAPPER=1 to Make.config will enforce the API 
translation even if the multiproto API is present, setting it =0 will 
disable API translation, requiring the multiproto API to be present. By 
default, the present API is automatically detected, and the wrapper is 
enabled accordingly.


The patch currently doesn't translate the whole API, just the parts that 
are used by VDR. But if required, the missing parts can surely be 
integrated.



Cheers,

Udo
diff -Nu vdr-1.5.14/channels.c vdr-1.5.14-wrapper/channels.c
--- vdr-1.5.14/channels.c   2008-01-27 14:59:53.0 +0100
+++ vdr-1.5.14-wrapper/channels.c   2008-02-02 23:37:38.0 +0100
@@ -11,6 +11,7 @@
 #include linux/dvb/frontend.h
 #include ctype.h
 #include device.h
+#include dvb_api_wrapper.h
 #include epg.h
 #include timers.h
 
diff -Nu vdr-1.5.14/dvb_api_wrapper.c vdr-1.5.14-wrapper/dvb_api_wrapper.c
--- vdr-1.5.14/dvb_api_wrapper.c1970-01-01 01:00:00.0 +0100
+++ vdr-1.5.14-wrapper/dvb_api_wrapper.c2008-02-02 23:57:09.0 
+0100
@@ -0,0 +1,203 @@
+/*
+ * dvb_api_wrapper.c:
+ * Wrapper to translate Multiproto DVB API to DVB 3.0 API calls
+ *
+ * See the main source file 'vdr.c' for copyright information and
+ * how to reach the author.
+ *
+ * $Id: $
+ */
+
+#include dvb_api_wrapper.h
+#include string.h
+#include errno.h
+#include sys/ioctl.h
+
+#ifdef DVB_MULTIPROTO_WRAPPER
+
+static bool TranslateCodeRate(fe_code_rate oldfec, dvbfe_fec fec) {
+  switch (fec) {
+case DVBFE_FEC_NONE: oldfec = FEC_NONE; return true;
+case DVBFE_FEC_1_2:  oldfec = FEC_1_2;  return true;
+case DVBFE_FEC_2_3:  oldfec = FEC_2_3;  return true;
+case DVBFE_FEC_3_4:  oldfec = FEC_3_4;  return true;
+case DVBFE_FEC_4_5:  oldfec = FEC_4_5;  return true;
+case DVBFE_FEC_5_6:  oldfec = FEC_5_6;  return true;
+case DVBFE_FEC_6_7:  oldfec = FEC_6_7;  return true;
+case DVBFE_FEC_7_8:  oldfec = FEC_7_8;  return true;
+case DVBFE_FEC_8_9:  oldfec = FEC_8_9;  return true;
+case DVBFE_FEC_AUTO: oldfec = FEC_AUTO; return true;
+default: return false;
+}
+}
+
+static bool TranslateModulation(fe_modulation oldmod, dvbfe_modulation mod) {
+  switch (mod) {
+case DVBFE_MOD_QPSK:oldmod = QPSK; return true;
+case DVBFE_MOD_QAM16:   oldmod = QAM_16;   return true;
+case DVBFE_MOD_QAM32:   oldmod = QAM_32;   return true;
+case DVBFE_MOD_QAM64:   oldmod = QAM_64;   return true;
+case DVBFE_MOD_QAM128:  oldmod = QAM_128;  return true;
+case DVBFE_MOD_QAM256:  oldmod = QAM_256;  return true;
+case DVBFE_MOD_QAMAUTO: oldmod = QAM_AUTO; return true;
+default: return false;
+  }
+}
+
+static bool TranslateBandwidth(fe_bandwidth_t oldbw, dvbfe_bandwidth 
bandwidth) {
+  switch (bandwidth) {
+case DVBFE_BANDWIDTH_8_MHZ: oldbw = BANDWIDTH_8_MHZ; return true;
+case DVBFE_BANDWIDTH_7_MHZ: oldbw = BANDWIDTH_7_MHZ; return true;
+case DVBFE_BANDWIDTH_6_MHZ: oldbw = BANDWIDTH_6_MHZ; return true;
+case DVBFE_BANDWIDTH_AUTO:  oldbw = BANDWIDTH_AUTO;  return true;
+default: return false;
+  }
+}
+
+static bool TranslateTransmission(fe_transmit_mode_t oldtrans, 
dvbfe_transmission_mode trans) {
+  switch (trans) {
+case DVBFE_TRANSMISSION_MODE_2K:   oldtrans = TRANSMISSION_MODE_2K;   
return true;
+case DVBFE_TRANSMISSION_MODE_8K:   oldtrans = TRANSMISSION_MODE_8K;   
return true;
+case DVBFE_TRANSMISSION_MODE_AUTO: oldtrans = TRANSMISSION_MODE_AUTO; 
return true;
+default: return false;
+  }
+}
+
+static bool TranslateGuard(fe_guard_interval_t oldguard, dvbfe_guard_interval 
guard) {
+  switch (guard) {
+case DVBFE_GUARD_INTERVAL_1_32: oldguard = GUARD_INTERVAL_1_32; return 
true;
+case DVBFE_GUARD_INTERVAL_1_16: oldguard = GUARD_INTERVAL_1_16; return 
true;
+case DVBFE_GUARD_INTERVAL_1_8:  oldguard = GUARD_INTERVAL_1_8;  return 
true;
+case DVBFE_GUARD_INTERVAL_1_4:  oldguard = GUARD_INTERVAL_1_4;  return 
true;
+case DVBFE_GUARD_INTERVAL_AUTO: oldguard = GUARD_INTERVAL_AUTO; return 
true;
+default: return false;
+  }
+}
+
+static bool TranslateHierarchy(fe_hierarchy_t oldhier, dvbfe_hierarchy 
hierarchy, dvbfe_alpha alpha) {
+  switch (hierarchy) {
+case DVBFE_HIERARCHY_OFF:  oldhier = HIERARCHY_NONE; return true;
+case DVBFE_HIERARCHY_AUTO: oldhier = HIERARCHY_AUTO; return true;
+case DVBFE_HIERARCHY_ON:
+ switch (alpha) {
+   case DVBFE_ALPHA_1: oldhier = HIERARCHY_1; return true;
+   case DVBFE_ALPHA_2: oldhier = HIERARCHY_2; return true;
+   case