From 3fe82e4e2aba2d557d51dd9a5294e5f453838ded Mon Sep 17 00:00:00 2001
From: Jean-Paul Saman <jpsaman@videolan.org>
Date: Fri, 19 Sep 2003 13:09:57 +0000
Subject: [PATCH] Frequency et al is really specified in KHz and not in Hz. I
 got an order of magnitude wrong. The same mistake is in the old satellite
 plugin's and user interface for specifying the frequency. It is specified in
 MHz instead of the KHz it should be.

---
 modules/access/dvb/access.c | 11 ++++++-----
 modules/access/dvb/dvb.c    | 21 +++++++++++----------
 modules/access/dvb/dvb.h    |  2 +-
 modules/access/dvb/qpsk.c   | 16 ++++++++--------
 4 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/modules/access/dvb/access.c b/modules/access/dvb/access.c
index 476d14745a69..5682120347dd 100644
--- a/modules/access/dvb/access.c
+++ b/modules/access/dvb/access.c
@@ -121,7 +121,7 @@ int E_(Open) ( vlc_object_t *p_this )
     u_lnb_lof2 = config_GetInt( p_input, "lnb-lof2" );
     u_lnb_slof = config_GetInt( p_input, "lnb-slof" );
 
-    /*Get modulation parametters*/
+    /*Get modulation parameters*/
     i_bandwidth = config_GetInt( p_input, "bandwidth");
     i_code_rate_HP = config_GetInt(p_input, "code-rate-hp");
     i_code_rate_LP = config_GetInt(p_input, "code-rate-lp");
@@ -162,7 +162,7 @@ int E_(Open) ( vlc_object_t *p_this )
         else if (strncmp( p_input->psz_access, "terrestrial",11) ==0)
             frontend_info.type = FE_OFDM;
 
-        frontend_info.frequency_max =   12999000;
+        frontend_info.frequency_max =   12999000; /* KHz */
         frontend_info.frequency_min =    9750000;
         frontend_info.symbol_rate_max = 30000000;
         frontend_info.symbol_rate_min =  1000000;
@@ -416,7 +416,7 @@ int E_(Open) ( vlc_object_t *p_this )
     {
         /* DVB-S: satellite and budget cards (nova) */
         case FE_QPSK:
-            fep.frequency = u_freq;
+            fep.frequency = u_freq; /* KHz */
             fep.inversion = dvb_DecodeInversion(p_input, (int) b_polarisation);
             fep.u.qpsk.symbol_rate = u_srate;
             fep.u.qpsk.fec_inner = dvb_DecodeFEC(p_input, i_fec); 
@@ -425,7 +425,7 @@ int E_(Open) ( vlc_object_t *p_this )
             
         /* DVB-C */
         case FE_QAM:
-            fep.frequency = u_freq;
+            fep.frequency = u_freq; /* KHz */
             fep.inversion = dvb_DecodeInversion(p_input, (int) b_polarisation);
             fep.u.qam.symbol_rate = u_srate;
             fep.u.qam.fec_inner = dvb_DecodeFEC(p_input, i_fec); 
@@ -435,7 +435,7 @@ int E_(Open) ( vlc_object_t *p_this )
 
         /* DVB-T */
         case FE_OFDM:
-            fep.frequency = u_freq;
+            fep.frequency = u_freq; /* KHz */
             fep.inversion = dvb_DecodeInversion(p_input, (int) b_polarisation);
             fep.u.ofdm.bandwidth = dvb_DecodeBandwidth(p_input, i_bandwidth);
             fep.u.ofdm.code_rate_HP = dvb_DecodeFEC(p_input, i_code_rate_HP); 
@@ -520,6 +520,7 @@ int E_(Open) ( vlc_object_t *p_this )
 
     msg_Dbg( p_input, "setting filter on PAT" );
 
+    /* Set Filter on PAT packet */
     if ( ioctl_SetDMXFilter(p_input, 0, &i_fd, 21, u_adapter, u_device ) < 0 )
     {
 #   ifdef HAVE_ERRNO_H
diff --git a/modules/access/dvb/dvb.c b/modules/access/dvb/dvb.c
index 7c96bf2800dc..84adf9e0592e 100644
--- a/modules/access/dvb/dvb.c
+++ b/modules/access/dvb/dvb.c
@@ -294,9 +294,9 @@ int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters
                        unsigned int u_lnb_lof1, unsigned int u_lnb_lof2, unsigned int u_lnb_slof,
                        unsigned int u_adapter, unsigned int u_device  )
 {
-    int front;
     int ret;
     int i;
+    int front;
     int hiband;
     char frontend[] = FRONTEND;
     int i_len;
@@ -310,7 +310,7 @@ int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters
     
     /* Open the frontend device */
     msg_Dbg(p_input, "Opening frontend %s", frontend);
-    if((front = open(frontend,O_RDWR)) < 0)
+    if(( front = open(frontend,O_RDWR)) < 0)
     {
 #   ifdef HAVE_ERRNO_H
         msg_Err(p_input, "failed to open frontend (%s)", strerror(errno));
@@ -375,7 +375,8 @@ int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters
         usleep( 500000 );
     }
 
-    /* Close front end device */
+    /* Fixme: Return this instead of closing it.
+       Close front end device */
     close(front);
     return ret;
 }
@@ -473,7 +474,7 @@ int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int * pi_fd , int i_
     }
 
     msg_Dbg(p_input, "Opening demux device %s", dmx);
-    if ((*pi_fd = open(dmx, O_RDWR|O_NONBLOCK))  < 0)
+    if (( (*pi_fd) = open(dmx, O_RDWR|O_NONBLOCK))  < 0)
     {
 #   ifdef HAVE_ERRNO_H
         msg_Err(p_input, "ioctl_SetDMXFilter: opening device failed (%s)", strerror(errno));
@@ -600,21 +601,21 @@ int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int * pi_fd , int i_
 /*****************************************************************************
  * ioctl_UnsetDMXFilter : removes a filter
  *****************************************************************************/
-int ioctl_UnsetDMXFilter(input_thread_t * p_input, int demux)
+int ioctl_UnsetDMXFilter(input_thread_t * p_input, int pi_fd)
 {
     int ret;
     
-    if ((ret=ioctl(demux, DMX_STOP))<0)
+    if ((ret=ioctl( pi_fd, DMX_STOP))<0)
     {
 #   ifdef HAVE_ERRNO_H
-        msg_Err(p_input, "ioctl DMX_STOP failed for demux %d (%d) %s", demux, ret, strerror(errno));
+        msg_Err(p_input, "ioctl DMX_STOP failed for demux %d (%d) %s", pi_fd, ret, strerror(errno));
 #   else
-        msg_Err(p_input, "ioctl DMX_STOP failed for demux %d (%d)", demux, ret);
+        msg_Err(p_input, "ioctl DMX_STOP failed for demux %d (%d)", pi_fd, ret);
 #   endif
         return -1;
     }
-    msg_Dbg( p_input, "ioctl_UnsetDMXFilter closing demux %d", demux);
-    close(demux);
+    msg_Dbg( p_input, "ioctl_UnsetDMXFilter closing demux %d", pi_fd);
+    close(pi_fd);
     return 0;
 }
 
diff --git a/modules/access/dvb/dvb.h b/modules/access/dvb/dvb.h
index dbe7c68fa430..b420df6e6f74 100644
--- a/modules/access/dvb/dvb.h
+++ b/modules/access/dvb/dvb.h
@@ -37,7 +37,7 @@ int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters
                        unsigned int u_lnb_lof1, unsigned int u_lnb_lof2, unsigned int u_lnb_slof,
                        unsigned int u_adapter, unsigned int u_device );
 int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int *pi_fd, int i_type, unsigned int u_adapter, unsigned int u_device );
-int ioctl_UnsetDMXFilter(input_thread_t * p_input, int );
+int ioctl_UnsetDMXFilter(input_thread_t * p_input, int pi_fd);
 int ioctl_InfoFrontend(input_thread_t * p_input, struct dvb_frontend_info *info, unsigned int u_adapter, unsigned int u_device );
 
 /*****************************************************************************
diff --git a/modules/access/dvb/qpsk.c b/modules/access/dvb/qpsk.c
index 929fc286dbff..4618a73c706e 100644
--- a/modules/access/dvb/qpsk.c
+++ b/modules/access/dvb/qpsk.c
@@ -42,12 +42,12 @@ void E_(Close)   ( vlc_object_t * );
 
 /* Satellite options */
 #define ADAPTER_TEXT N_("adapter card to tune")
-#define ADAPTER_LONGTEXT N_("adapter cards have a device file named /dev/dvb/adapter[n] with n>=0")
+#define ADAPTER_LONGTEXT N_("adapter cards have a device file in directory named /dev/dvb/adapter[n] with n>=0")
 
 #define DEVICE_TEXT N_("device nummer to use on adapter")
 #define DEVICE_LONGTEXT ""
 
-#define FREQ_TEXT N_("satellite default transponder frequency in Hz")
+#define FREQ_TEXT N_("satellite default transponder frequency in KHz")
 #define FREQ_LONGTEXT ""
 
 #define POL_TEXT N_("satellite default transponder polarization")
@@ -56,19 +56,19 @@ void E_(Close)   ( vlc_object_t * );
 #define FEC_TEXT N_("satellite default transponder FEC")
 #define FEC_LONGTEXT N_("FEC=Forward Error Correction mode")
 
-#define SRATE_TEXT N_("satellite default transponder symbol rate in Hz")
+#define SRATE_TEXT N_("satellite default transponder symbol rate in KHz")
 #define SRATE_LONGTEXT ""
 
 #define DISEQC_TEXT N_("use diseqc with antenna")
 #define DISEQC_LONGTEXT ""
 
-#define LNB_LOF1_TEXT N_("antenna lnb_lof1 (Hz)")
+#define LNB_LOF1_TEXT N_("antenna lnb_lof1 (KHz)")
 #define LNB_LOF1_LONGTEXT ""
 
-#define LNB_LOF2_TEXT N_("antenna lnb_lof2 (Hz)")
+#define LNB_LOF2_TEXT N_("antenna lnb_lof2 (KHz)")
 #define LNB_LOF2_LONGTEXT ""
 
-#define LNB_SLOF_TEXT N_("antenna lnb_slof (Hz)")
+#define LNB_SLOF_TEXT N_("antenna lnb_slof (KHz)")
 #define LNB_SLOF_LONGTEXT ""
 
 #define PROBE_TEXT	N_("probe the dvb card for capabilities (default disabled)")
@@ -98,6 +98,8 @@ void E_(Close)   ( vlc_object_t * );
 #define HIERARCHY_LONGTEXT ""
 
 vlc_module_begin();
+    set_description( _("DVB input module with v4l2 support") );
+    set_capability( "access", 0 );
     add_category_hint( N_("Input"), NULL, VLC_FALSE );
         add_integer( "adapter", 0, NULL, ADAPTER_TEXT, ADAPTER_LONGTEXT, VLC_FALSE );
         add_integer( "device", 0, NULL, DEVICE_TEXT, DEVICE_LONGTEXT, VLC_FALSE );
@@ -117,8 +119,6 @@ vlc_module_begin();
         add_integer( "guard", 0, NULL, GUARD_TEXT, GUARD_LONGTEXT, VLC_TRUE );
         add_integer( "transmission", 0, NULL, TRANSMISSION_TEXT, TRANSMISSION_LONGTEXT, VLC_TRUE );
         add_integer( "hierarchy", 0, NULL, HIERARCHY_TEXT, HIERARCHY_LONGTEXT, VLC_TRUE );
-    set_description( _("DVB input module with v4l2 support") );
-    set_capability( "access", 0 );
     add_shortcut( "qpsk" );
     add_shortcut( "cable" );
     add_shortcut( "terrestrial" );
-- 
GitLab