Hi,
this patch adds Diseqc support to the part of dvbstream specific for
NEWSTRUCT (alongside the support for the previous drivers).
To select the diseqc position (between 1 and 4) use the parameter -D:
dvbstream -D 2 -f 12480 -s 27500 -p V -o 8192
selects Sat1 on diseqc position 2.
I took the code from szap, and it works for me both with NEW and
0.9.4 drivers.
Thanks for your help,
Nico
diff -Naur dvbstream/dvbstream.c dvbstream-newstruct/dvbstream.c
--- dvbstream/dvbstream.c 2002-10-13 20:44:09.000000000 +0200
+++ dvbstream-newstruct/dvbstream.c 2003-02-01 09:43:42.000000000 +0100
@@ -497,10 +497,19 @@
pol='H';
}
}
- } else if (strcmp(argv[i],"-s")==0) {
+ }
+ else if (strcmp(argv[i],"-s")==0) {
i++;
srate=atoi(argv[i])*1000UL;
- } else if (strcmp(argv[i],"-o")==0) {
+ }
+ else if (strcmp(argv[i],"-D")==0)
+ {
+ i++;
+ diseqc=atoi(argv[i]);
+ if(diseqc < 0 || diseqc > 4)
+ diseqc = 0;
+ }
+ else if (strcmp(argv[i],"-o")==0) {
to_stdout = 1;
} else if (strcmp(argv[i],"-n")==0) {
i++;
diff -Naur dvbstream/Makefile dvbstream-newstruct/Makefile
--- dvbstream/Makefile 2002-10-13 20:39:53.000000000 +0200
+++ dvbstream-newstruct/Makefile 2003-02-02 18:02:13.000000000 +0100
@@ -5,14 +5,14 @@
NEWSTRUCT=1
CC=gcc
-CFLAGS = -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE
+CFLAGS = -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+-D_LARGEFILE64_SOURCE
OBJS=dvbstream dumprtp ts_filter rtpfeed rtp.o
ifdef NEWSTRUCT
CFLAGS += -DNEWSTRUCT
- INCS=-I ../DVB/include
+ INCS=-I ../dvb-kernel/linux/include
else
- INCS=-I ../DVB/ost/include
+ INCS=-I /usr/src/linux-2.4.18/include/
endif
ifdef UK
diff -Naur dvbstream/tune.c dvbstream-newstruct/tune.c
--- dvbstream/tune.c 2003-01-16 08:51:41.000000000 +0100
+++ dvbstream-newstruct/tune.c 2003-02-08 17:07:15.000000000 +0100
@@ -243,6 +243,53 @@
}
return 0;
}
+
+
+struct diseqc_cmd {
+ struct dvb_diseqc_master_cmd cmd;
+ uint32_t wait;
+};
+
+void diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd,
+ fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
+{
+ ioctl(fd, FE_SET_TONE, SEC_TONE_OFF);
+ ioctl(fd, FE_SET_VOLTAGE, v);
+ usleep(15 * 1000);
+ ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd->cmd);
+ usleep(cmd->wait * 1000);
+ usleep(15 * 1000);
+ ioctl(fd, FE_DISEQC_SEND_BURST, b);
+ usleep(15 * 1000);
+ ioctl(fd, FE_SET_TONE, t);
+}
+
+
+
+
+/* digital satellite equipment control,
+ * specification is available from http://www.eutelsat.com/
+ */
+static int head_diseqc(int secfd, int sat_no, int pol, int hi_lo)
+{
+ struct diseqc_cmd cmd =
+ { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 };
+
+ /* param: high nibble: reset bits, low nibble set bits,
+ * bits are: option, position, polarizaion, band
+ */
+ cmd.cmd.msg[3] =
+ 0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (pol ? 0 : 2));
+
+ diseqc_send_msg(secfd, pol ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18,
+ &cmd, hi_lo ? SEC_TONE_ON : SEC_TONE_OFF,
+ (sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A);
+
+ return 1;
+}
+
+
+
#else
int check_status(int fd_frontend,FrontendParameters* feparams,int tone) {
int i,res;
@@ -484,7 +531,21 @@
#endif
#ifdef NEWSTRUCT
- #warning DISEQC is unimplemented for NEWSTRUCT
+ //#warning DISEQC is unimplemented for NEWSTRUCT
+ if(diseqc > 0)
+ {
+ int ipol = (pol == 'V' ? 1 : 0);
+ int hiband = (freq >= SLOF);
+
+ if(head_diseqc(fd_frontend, diseqc-1, ipol, hiband))
+ {
+ fprintf(stderr, "DISEQC SETTING SUCCEDED\n");
+ }
+ else
+ {
+ fprintf(stderr, "DISEQC SETTING FAILED\n");
+ }
+ }
#else
if (diseqc > 0) {
struct secCommand scmd;
diff -Naur dvbstream/tune.h dvbstream-newstruct/tune.h
--- dvbstream/tune.h 2002-10-13 20:46:03.000000000 +0200
+++ dvbstream-newstruct/tune.h 2003-01-31 00:07:37.000000000 +0100
@@ -7,7 +7,7 @@
// The following defines make the "OLDSTRUCT" driver more compatible with NEWSTRUCT.
- #include <ost/frontend.h>
+#include <ost/frontend.h>
#define fe_status_t FrontendStatus
#define fe_spectral_inversion_t SpectralInversion
@@ -20,6 +20,7 @@
#define dmx_pes_filter_params dmxPesFilterParams
#define dmx_sct_filter_params dmxSctFilterParams
#define dmx_pes_type_t dmxPesType_t
+
#endif
#include "dvb_defaults.h"