commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r5190 - gnuradio/branches/developers/nldudok1/general-


From: nldudok1
Subject: [Commit-gnuradio] r5190 - gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src
Date: Sun, 29 Apr 2007 10:07:37 -0600 (MDT)

Author: nldudok1
Date: 2007-04-29 10:07:36 -0600 (Sun, 29 Apr 2007)
New Revision: 5190

Modified:
   gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc.i
   
gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc_source.cc
   gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc_source.h
Log:
initual tuning support

Modified: gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc.i
===================================================================
--- gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc.i      
2007-04-29 01:26:12 UTC (rev 5189)
+++ gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc.i      
2007-04-29 16:07:36 UTC (rev 5190)
@@ -53,5 +53,10 @@
                     double frame_avg_alpha,
                    const std::string dev) throw (std::runtime_error);
  public:
+  bool set_freq (double target_freq, double *p_actual_freq);
+  bool set_freq (double target_freq);
+  bool get_freq (double *p_actual_freq);
+  double freq();
+  int get_tuner ();
   ~cxadc_source ();
 };

Modified: 
gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc_source.cc
===================================================================
--- 
gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc_source.cc  
    2007-04-29 01:26:12 UTC (rev 5189)
+++ 
gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc_source.cc  
    2007-04-29 16:07:36 UTC (rev 5190)
@@ -43,7 +43,10 @@
 #include <stdexcept>
 #include <algorithm>
 //include <gri_add_const_ss.h>
+#include <asm/types.h>          /* for videodev2.h */
 
+#include <linux/videodev2.h>
+
 //32 Mbytes VBI DMA BUFF
 #define VBI_DMA_BUFF_SIZE (1024*1024*32) 
 //corresponds to 8192 DMA pages of 4k bytes
@@ -199,6 +202,9 @@
   //set_output_multiple (2 * (1L << 20) / sizeof (short));
   //set_output_multiple (CXADC_PAGE_SIZE * (1L << 8) / sizeof(unsigned char));
   set_output_multiple (CXADC_PAGE_SIZE * (1L << 2) / sizeof(unsigned char));
+  double actual_freq;
+  get_freq(&actual_freq);
+  printf("current tuned rf freq=%f\n",actual_freq);
   return;
 
  bail:
@@ -295,9 +301,125 @@
 }
 
 
+/*!
+ * \brief get tuner
+ *
+ * \returns true if sucessful.
+ */
+int
+cxadc_source::get_tuner ()
+{
+  struct v4l2_tuner tuner;
+  double tune_step_high=62.5e3;
+  double tune_step_low =62.5;
+  double tune_step=tune_step_high;//TODO implement tune_step_high/low switching
+  memset (&(tuner), 0, sizeof (tuner));
+  int result=0;
+  tuner.index=0;
+  int the_tuner=-1;
+  //do
+  {
+    result=ioctl(d_device_fd, VIDIOC_G_TUNER, &tuner);
+    if (result >=0)//!=-EINVAL)//!=EINVAL)
+    {
+       printf("tuner.index %i\n",tuner.index);
+       printf("tuner.name %s\n",tuner.name);
+       printf("tuner.type %i\n",tuner.type);
+       printf("tuner.capability %i\n",tuner.capability);
+       printf("tuner.rangelow %i\n",tuner.rangelow);
+       printf("tuner.rangehigh %i\n",tuner.rangehigh);
+       printf("tuner.rxsubchans %i\n",tuner.rxsubchans);
+       printf("tuner.audmode %i\n",tuner.audmode);
+       printf("tuner.signal %i\n",tuner.signal);    
+       printf("\n");    
+       the_tuner=tuner.index;
+    }
+    printf("index %i result=%i\n\n",tuner.index,result);
+    tuner.index++;
+  } //MDVH while (result >=0 );//!=-EINVAL);
+  
+  return the_tuner;
+}
 
+/*!
+ * \brief select RF frequency to be tuned to output frequency.
+ * \p target_freq is the requested frequency in Hz, \p actual_freq
+ * is set to the actual frequency tuned.  It takes about 100 ms
+ * for the PLL to settle.
+ *
+ * \returns true if sucessful.
+ */
+bool
+cxadc_source::set_freq (double target_freq, double *p_actual_freq)
+{
+  struct v4l2_frequency v4l2_freq;
+  double tune_step_high=62.5e3;
+  double tune_step_low =62.5;
+  double tune_step=tune_step_high;//TODO implement tune_step_high/low switching
+  memset (&(v4l2_freq), 0, sizeof (v4l2_freq));
+  v4l2_freq.tuner = get_tuner ();
+  v4l2_freq.type  = V4L2_TUNER_ANALOG_TV;
+  v4l2_freq.frequency = (int)((double)target_freq/tune_step);
+  if (ioctl(d_device_fd, VIDIOC_S_FREQUENCY, &v4l2_freq) < 0) {
+    printf("gr-cxadc: ioctl VIDIOC_S_FREQUENCY failed: %s\n", strerror(errno));
+    get_freq(p_actual_freq);
+    return false;
+  }
+  return get_freq(p_actual_freq);
+}
 
+/*!
+ * \brief select RF frequency to be tuned to output frequency.
+ * \p target_freq is the requested frequency in Hz, 
+ * It takes about 100 ms for the PLL to settle.
+ *
+ * \returns true if sucessful.
+ */
+bool
+cxadc_source::set_freq (double target_freq)
+{
+  double actual_freq;
+  return set_freq (target_freq, &actual_freq);
+} 
 
+/*!
+ * \brief get tuned RF frequency.
+ * \p actual_freq is set to the actual frequency tuned in Hz. 
+ *
+ * \returns true if sucessful.
+ */
+bool
+cxadc_source::get_freq (double *p_actual_freq)
+{
+  struct v4l2_frequency v4l2_freq;
+  double tune_step_high=62.5e3;
+  double tune_step_low =62.5;
+  double tune_step=tune_step_high;//TODO implement tune_step_high/low switching
+  memset (&(v4l2_freq), 0, sizeof (v4l2_freq));
+  v4l2_freq.tuner = get_tuner ();
+  v4l2_freq.type  = V4L2_TUNER_ANALOG_TV;
+  if (ioctl(d_device_fd, VIDIOC_G_FREQUENCY, &v4l2_freq) < 0) {
+    printf("gr-cxadc: ioctl VIDIOC_G_FREQUENCY failed: %s\n", strerror(errno));
+    *p_actual_freq=-1.0;
+    return false;
+  }
+  *p_actual_freq=(double)v4l2_freq.frequency*tune_step;
+  return true;
+}
+
+/*!
+ * \brief get tuned RF frequency.
+ *
+ * \returns tuned RF frequency in Hz.
+ */
+double
+cxadc_source::freq()
+{
+  double actual_freq;
+  get_freq (&actual_freq);
+  return actual_freq;
+}
+
 int
 cxadc_source::work (int noutput_items,
                     gr_vector_const_void_star &input_items,

Modified: 
gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc_source.h
===================================================================
--- 
gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc_source.h   
    2007-04-29 01:26:12 UTC (rev 5189)
+++ 
gnuradio/branches/developers/nldudok1/general-wip/gr-cxadc/src/cxadc_source.h   
    2007-04-29 16:07:36 UTC (rev 5190)
@@ -68,8 +68,45 @@
   int work (int noutput_items,
            gr_vector_const_void_star &input_items,
            gr_vector_void_star &output_items);
+/*!
+ * \brief select RF frequency to be tuned to output frequency.
+ * \p target_freq is the requested frequency in Hz, \p actual_freq
+ * is set to the actual frequency tuned.  It takes about 100 ms
+ * for the PLL to settle.
+ *
+ * \returns true if sucessful.
+ */
+  bool set_freq (double target_freq, double *p_actual_freq);
+/*!
+ * \brief select RF frequency to be tuned to output frequency.
+ * \p target_freq is the requested frequency in Hz, 
+ * It takes about 100 ms for the PLL to settle.
+ *
+ * \returns true if sucessful.
+ */
+  bool set_freq (double target_freq);
 
+/*!
+ * \brief get tuned RF frequency.
+ * \p actual_freq is set to the actual frequency tuned in Hz. 
+ *
+ * \returns true if sucessful.
+ */
+  bool get_freq (double *p_actual_freq);
 
+/*!
+ * \brief get tuned RF frequency.
+ *
+ * \returns tuned RF frequency in Hz.
+ */
+  double freq();
+/*!
+ * \brief get tuner
+ *
+ * \returns true if sucessful.
+ */
+int get_tuner ();
+
  private:
   void cxadc_uchar_to_ss (short *dst, const unsigned char *src,
                                   unsigned int nshorts);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]