gst-libs/gst/tuner/tunerchannel.h: - add a freq_multiplicator field to make the conve...
authorStéphane Loeuillet <gstreamer@leroutier.net>
Mon, 31 May 2004 14:16:54 +0000 (14:16 +0000)
committerStéphane Loeuillet <gstreamer@leroutier.net>
Mon, 31 May 2004 14:16:54 +0000 (14:16 +0000)
Original commit message from CVS:
* gst-libs/gst/tuner/tunerchannel.h:
- add a freq_multiplicator field to make the conversion
between internal frequency unit and Hz
* sys/v4l/gstv4lelement.c:
* sys/v4l2/gstv4l2element.c:
- change default video device to /dev/video0
* sys/v4l/v4l_calls.c:
* sys/v4l2/v4l2_calls.c:
- we only expose frequency to the user in Hz instead of
bastard v4lX unit (either 62.5kHz or 62.5Hz)

ChangeLog
gst-libs/gst/tuner/tunerchannel.h
sys/v4l2/gstv4l2element.c
sys/v4l2/v4l2_calls.c

index ffde603..6ba4b85 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-05-31  Stephane Loeuillet  <stephane.loeuillet@tiscali.fr>
+
+       * gst-libs/gst/tuner/tunerchannel.h:
+         - add a freq_multiplicator field to make the conversion
+           between internal frequency unit and Hz
+       * sys/v4l/gstv4lelement.c:
+       * sys/v4l2/gstv4l2element.c:
+         - change default video device to /dev/video0
+       * sys/v4l/v4l_calls.c:
+       * sys/v4l2/v4l2_calls.c:
+         - we only expose frequency to the user in Hz instead of
+           bastard v4lX unit (either 62.5kHz or 62.5Hz)
+
 2004-05-31  Jan Schmidt  <thaytan@mad.scientist.com>
        * ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
          Initialise b_o_s and e_o_s variables
index ee5654d..b38dc27 100644 (file)
@@ -43,7 +43,7 @@ typedef enum {
   GST_TUNER_CHANNEL_INPUT     = (1<<0),
   GST_TUNER_CHANNEL_OUTPUT    = (1<<1),
   GST_TUNER_CHANNEL_FREQUENCY = (1<<2),
-  GST_TUNER_CHANNEL_AUDIO     = (1<<3),
+  GST_TUNER_CHANNEL_AUDIO     = (1<<3)
 } GstTunerChannelFlags;
 
 #define GST_TUNER_CHANNEL_HAS_FLAG(channel, flag) \
@@ -54,6 +54,7 @@ typedef struct _GstTunerChannel {
 
   gchar               *label;
   GstTunerChannelFlags flags;
+  gfloat               freq_multiplicator;
   gulong               min_frequency,
                       max_frequency;
   gint                 min_signal,
index 1595e87..4b7c618 100644 (file)
@@ -383,7 +383,7 @@ gst_v4l2element_class_init (GstV4l2ElementClass * klass)
           "input/output to switch to", NULL, G_PARAM_READWRITE));
   g_object_class_install_property (gobject_class, ARG_FREQUENCY,
       g_param_spec_ulong ("frequency", "frequency",
-          "frequency to tune to", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
+          "frequency to tune to (in Hz)", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
 
   /* signals */
   gst_v4l2element_signals[SIGNAL_OPEN] =
@@ -411,7 +411,7 @@ gst_v4l2element_init (GstV4l2Element * v4l2element)
   /* some default values */
   v4l2element->video_fd = -1;
   v4l2element->buffer = NULL;
-  v4l2element->device = g_strdup ("/dev/video");
+  v4l2element->device = g_strdup ("/dev/video0");
   v4l2element->display = g_strdup (g_getenv ("DISPLAY"));
 
   v4l2element->channels = NULL;
index 92de8a4..7b32ad7 100644 (file)
@@ -123,8 +123,10 @@ gst_v4l2_fill_lists (GstV4l2Element * v4l2element)
           g_object_unref (G_OBJECT (channel));
           return FALSE;
         }
-        channel->min_frequency = vtun.rangelow;
-        channel->max_frequency = vtun.rangehigh;
+        channel->freq_multiplicator =
+            62.5 * ((vtun.capability & V4L2_TUNER_CAP_LOW) ? 1 : 1000);
+        channel->min_frequency = vtun.rangelow * channel->freq_multiplicator;
+        channel->max_frequency = vtun.rangehigh * channel->freq_multiplicator;
         channel->min_signal = 0;
         channel->max_signal = 0xffff;
       }
@@ -620,10 +622,13 @@ gst_v4l2_get_frequency (GstV4l2Element * v4l2element,
     gint tunernum, gulong * frequency)
 {
   struct v4l2_frequency freq;
+  GstTunerChannel *channel;
 
   DEBUG ("getting current tuner frequency");
   GST_V4L2_CHECK_OPEN (v4l2element);
 
+  channel = gst_tuner_get_channel (GST_TUNER (v4l2element));
+
   freq.tuner = tunernum;
   if (ioctl (v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq) < 0) {
     GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
@@ -632,7 +637,7 @@ gst_v4l2_get_frequency (GstV4l2Element * v4l2element,
     return FALSE;
   }
 
-  *frequency = freq.frequency;
+  *frequency = freq.frequency * channel->freq_multiplicator;
 
   return TRUE;
 }
@@ -649,15 +654,18 @@ gst_v4l2_set_frequency (GstV4l2Element * v4l2element,
     gint tunernum, gulong frequency)
 {
   struct v4l2_frequency freq;
+  GstTunerChannel *channel;
 
   DEBUG ("setting current tuner frequency to %lu", frequency);
   GST_V4L2_CHECK_OPEN (v4l2element);
   GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
 
+  channel = gst_tuner_get_channel (GST_TUNER (v4l2element));
+
   freq.tuner = tunernum;
   /* fill in type - ignore error */
   ioctl (v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq);
-  freq.frequency = frequency;
+  freq.frequency = frequency / channel->freq_multiplicator;
 
   if (ioctl (v4l2element->video_fd, VIDIOC_S_FREQUENCY, &freq) < 0) {
     GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),