[linux-dvb] AC3 support for szap with firmware 0x2622

Dr. Werner Fink werner at suse.de
Wed Dec 7 17:26:11 CET 2005


Hi,

just a few changes to the current szap found in the CVS of
linuxtv.org to support TV channels with AC3 audio channels.

--------------------------* snip *--------------------------------
--- util/szap/szap.c
+++ util/szap/szap.c	2005-12-06 16:29:57.000000000 +0100
@@ -46,6 +46,7 @@
 
 #include <linux/dvb/frontend.h>
 #include <linux/dvb/dmx.h>
+#include <linux/dvb/audio.h>
 #include "lnb.h"
 
 #ifndef TRUE
@@ -65,6 +66,7 @@
 
 #define FRONTENDDEVICE "/dev/dvb/adapter%d/frontend%d"
 #define DEMUXDEVICE "/dev/dvb/adapter%d/demux%d"
+#define AUDIODEVICE "/dev/dvb/adapter%d/audio%d"
 
 static struct lnb_types_st lnb_type;
 
@@ -80,6 +82,7 @@
     "     -f number : use given frontend (default 0)\n"
     "     -d number : use given demux (default 0)\n"
     "     -c file   : read channels list from 'file'\n"
+    "     -b        : enable Audio Bypass (default no)\n"
     "     -x        : exit after tuning\n"
     "     -r        : set up /dev/dvb/adapterX/dvr0 for TS recording\n"
     "     -l lnb-type (DVB-S Only) (use -l help to print types) or \n"
@@ -292,10 +295,10 @@
 int zap_to(unsigned int adapter, unsigned int frontend, unsigned int demux,
       unsigned int sat_no, unsigned int freq, unsigned int pol,
       unsigned int sr, unsigned int vpid, unsigned int apid, int sid,
-      int dvr, int rec_psi)
+      int dvr, int rec_psi, int bypass)
 {
-   char fedev[128], dmxdev[128];
-   static int fefd, videofd, audiofd, patfd, pmtfd;
+   char fedev[128], dmxdev[128], auddev[128];
+   static int fefd, dmxfd, audiofd, patfd, pmtfd;
    int pmtpid;
    uint32_t ifreq;
    int hiband, result;
@@ -304,6 +307,7 @@
    if (!fefd) {
       snprintf(fedev, sizeof(fedev), FRONTENDDEVICE, adapter, frontend);
       snprintf(dmxdev, sizeof(dmxdev), DEMUXDEVICE, adapter, demux);
+      snprintf(auddev, sizeof(auddev), AUDIODEVICE, adapter, demux);
       printf("using '%s' and '%s'\n", fedev, dmxdev);
 
       if ((fefd = open(fedev, O_RDWR | O_NONBLOCK)) < 0) {
@@ -325,15 +329,15 @@
 	 return FALSE;
       }
 
-      if ((videofd = open(dmxdev, O_RDWR)) < 0) {
+      if ((dmxfd = open(dmxdev, O_RDWR)) < 0) {
 	 perror("opening video demux failed");
 	 close(fefd);
 	 return FALSE;
       }
 
-      if ((audiofd = open(dmxdev, O_RDWR)) < 0) {
+      if ((audiofd = open(auddev, O_RDWR)) < 0) {
 	 perror("opening audio demux failed");
-	 close(videofd);
+	 close(dmxfd);
 	 close(fefd);
 	 return FALSE;
       }
@@ -342,7 +346,7 @@
          if ((patfd = open(dmxdev, O_RDWR)) < 0) {
 	    perror("opening audio demux failed");
 	    close(audiofd);
-	    close(videofd);
+	    close(dmxfd);
 	    close(fefd);
 	    return FALSE;
          }
@@ -351,7 +355,7 @@
 	    perror("opening audio demux failed");
 	    close(patfd);
 	    close(audiofd);
-	    close(videofd);
+	    close(dmxfd);
 	    close(fefd);
 	    return FALSE;
          }
@@ -375,8 +379,9 @@
 
    if (diseqc(fefd, sat_no, pol, hiband))
       if (do_tune(fefd, ifreq, sr))
-	 if (set_demux(videofd, vpid, DMX_PES_VIDEO, dvr))
-	    if (set_demux(audiofd, apid, DMX_PES_AUDIO, dvr)) {
+	 if (set_demux(dmxfd, vpid, DMX_PES_VIDEO, dvr))
+	    (void)ioctl(audiofd, AUDIO_SET_BYPASS_MODE, bypass);
+	    if (set_demux(dmxfd, apid, DMX_PES_AUDIO, dvr)) {
 	       if (rec_psi) {
 	          pmtpid = get_pmt_pid(dmxdev, sid);
 		  if (pmtpid < 0) {
@@ -400,7 +405,7 @@
       close(patfd);
       close(pmtfd);
       close(audiofd);
-      close(videofd);
+      close(dmxfd);
       close(fefd);
    }
 
@@ -411,7 +416,8 @@
 static int read_channels(const char *filename, int list_channels,
 			 uint32_t chan_no, const char *chan_name,
 			 unsigned int adapter, unsigned int frontend,
-			 unsigned int demux, int dvr, int rec_psi)
+			 unsigned int demux, int dvr, int rec_psi,
+			 int bypass)
 {
    FILE *cfp;
    char buf[4096];
@@ -504,6 +510,18 @@
 	 if (!(field = strsep(&tmp, ":")))
 	    goto syntax_err;
 
+	 p = strchr(field, ';');
+
+	 if (p) {
+	    *p = '\0';
+	    p++;
+	    if (bypass) {
+	       if (!p || !*p)
+		  goto syntax_err;
+	       field = p;
+	    }
+	 }
+
 	 apid = strtoul(field, NULL, 0);
 	 if (!apid)
             apid = 0x1fff;
@@ -519,8 +537,8 @@
 
 	 fclose(cfp);
 
-	 ret = zap_to(adapter, frontend, demux,
-		      sat_no, freq * 1000, pol, sr, vpid, apid, sid, dvr, rec_psi);
+	 ret = zap_to(adapter, frontend, demux, sat_no, freq * 1000,
+		      pol, sr, vpid, apid, sid, dvr, rec_psi, bypass);
 	 if (interactive)
 	    goto again;
 
@@ -584,16 +602,20 @@
    unsigned int chan_no = 0;
    const char *chan_name = NULL;
    unsigned int adapter = 0, frontend = 0, demux = 0, dvr = 0, rec_psi = 0;
+   int bypass = 0;
    int opt, copt = 0;
 
    lnb_type = *lnb_enum(0);
-   while ((opt = getopt(argc, argv, "hqrpn:a:f:d:c:l:xi")) != -1) {
+   while ((opt = getopt(argc, argv, "hqrpn:a:f:d:c:l:xib")) != -1) {
       switch (opt)
       {
 	 case '?':
 	 case 'h':
 	 default:
 	    bad_usage(argv[0], 0);
+	 case 'b':
+	    bypass = 1;
+	    break;
 	 case 'q':
 	    list_channels = 1;
 	    break;
@@ -669,7 +691,7 @@
       dvr=1;
 
    if (!read_channels(chanfile, list_channels, chan_no, chan_name,
-	    adapter, frontend, demux, dvr, rec_psi))
+	    adapter, frontend, demux, dvr, rec_psi, bypass))
       return TRUE;
 
    return FALSE;
--- util/szap/channels-conf/dvb-s/Astra-19.2E
+++ util/szap/channels-conf/dvb-s/Astra-19.2E	2005-12-06 16:16:21.000000000 +0100
@@ -1,6 +1,6 @@
 Das Erste:11837:h:0:27500:101:102:28106
-ZDF:11954:h:0:27500:110:120:28006
-3sat:11954:h:0:27500:210:220:28007
+ZDF:11954:h:0:27500:110:120;125:28006
+3sat:11954:h:0:27500:210:220;225:28007
 EinsMuXx:12110:h:0:27500:301:302:28203
 EinsFestival:12110:h:0:27500:201:202:28202
 EinsExtra:12110:h:0:27500:101:102:28201
@@ -22,8 +22,8 @@
 Phoenix:11837:h:0:27500:901:902:28114
 DW-tv:10786:v:0:21997:305:306:9005
 RTL Television:12188:h:0:27500:163:104:12003
-SAT.1:12480:v:0:27500:1791:1792:46
-ProSieben:12480:v:0:27500:255:256:898
+SAT.1:12480:v:0:27500:1791:1792;1795:46
+ProSieben:12480:v:0:27500:255:256;257:898
 RTL2:12188:h:0:27500:166:128:12020
 Super RTL:12188:h:0:27500:165:120:12040
 KABEL1:12480:v:0:27500:511:512:899
--------------------------* snap *--------------------------------

Just to be able to test the new feature of the firmware 0x2622
without using VDR.


       Werner

-- 
AC3 loop through sound card http://bitstreamout.sourceforge.net/
Howto http://www.vdr-portal.de/board/thread.php?threadid=1958
------------------------------------------------------------------
 "Having a smoking section in a restaurant is like having
         a  peeing section in a swimming pool." -- Edward Burr



More information about the linux-dvb mailing list