[PATCH] Print Vendor and Product Id of probed devices



Hi,
As you might know if you did recently follow cheese bugzilla, many
changes went in webcam drivers with 2.6.27 kernel series.
Most of decoding stuff which was done at kernel level has been moved
into the userspace library libv4l. There's been some regression too so
many webcam devices which did work previously stopped working and
users started complaining about cheese being broken.
I believe there will be some other bug report like those so this patch
prints more informations (product id and vendor id) about detected
device to help bug triaging. Furthermore, the first question I usually
ask to reporters is "what webcam do you have? which driver does it
use?". This patch should avoid that putting the useful data directly
into cheese log.

I'm sending it here because I wrote it quickly but I'd like to commit
it in the gnome-2-24 stable branch before tomorrow (2.24.2 tarballs
due), so I'd like to have a review from the other developers.

Thanks,

Filippo Argiolas
From 2aaa7bb2c581329e57b3d67614e4df06ab40b7ec Mon Sep 17 00:00:00 2001
From: Filippo Argiolas <filippo argiolas gmail com>
Date: Wed, 19 Nov 2008 18:23:33 +0100
Subject: [PATCH] Print Vendor and Product Id while probing devices.
 Provide some more device informations for easier bug triaging.

---
 src/cheese-webcam.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/src/cheese-webcam.c b/src/cheese-webcam.c
index c3e6bee..2637ded 100644
--- a/src/cheese-webcam.c
+++ b/src/cheese-webcam.c
@@ -256,6 +256,8 @@ cheese_webcam_get_video_devices_from_hal (CheeseWebcam *webcam)
 
   priv->num_webcam_devices = 0;
 
+  g_print ("Probing devices with HAL...\n");
+
   dbus_error_init (&error);
   hal_ctx = libhal_ctx_new ();
   if (hal_ctx == NULL)
@@ -299,9 +301,45 @@ cheese_webcam_get_video_devices_from_hal (CheeseWebcam *webcam)
   for (i = 0; i < num_udis; i++)
   {
     char                   *device;
+    char                   *parent_udi = NULL;
+    char                   *subsystem = NULL;
     char                   *gstreamer_src, *product_name;
     struct v4l2_capability  v2cap;
     struct video_capability v1cap;
+    gint vendor_id = 0;
+    gint product_id = 0;
+    gchar *property_name = NULL;
+
+    parent_udi = libhal_device_get_property_string (hal_ctx, udis[i], "info.parent", &error);
+    if (dbus_error_is_set (&error))
+    {
+      g_warning ("error getting parent for %s: %s: %s\n", udis[i], error.name, error.message);
+      dbus_error_free (&error);
+    }
+
+    if (parent_udi != NULL) {
+      subsystem = libhal_device_get_property_string (hal_ctx, parent_udi, "info.subsystem", NULL);
+      if (subsystem == NULL) continue;
+      property_name = g_strjoin (".", subsystem, "vendor_id", NULL);
+      vendor_id = libhal_device_get_property_int (hal_ctx, parent_udi, property_name , &error);
+      if (dbus_error_is_set (&error)) {
+        g_warning ("error getting vendor id: %s: %s\n", error.name, error.message);
+        dbus_error_free (&error);
+      }
+      g_free (property_name);
+
+      property_name = g_strjoin (".", subsystem, "product_id", NULL);
+      product_id = libhal_device_get_property_int (hal_ctx, parent_udi, property_name, &error);
+      if (dbus_error_is_set (&error)) {
+        g_warning ("error getting product id: %s: %s\n", error.name, error.message);
+        dbus_error_free (&error);
+      }
+      g_free (property_name);
+      libhal_free_string (subsystem);
+      libhal_free_string (parent_udi);
+    }
+
+    g_print ("Found device %04x:%04x, getting capabilities...\n", vendor_id, product_id);
 
     device = libhal_device_get_property_string (hal_ctx, udis[i], "video4linux.device", &error);
     if (dbus_error_is_set (&error))
@@ -348,8 +386,8 @@ cheese_webcam_get_video_devices_from_hal (CheeseWebcam *webcam)
       guint cap = v2cap.capabilities;
       g_print ("Detected v4l2 device: %s\n", v2cap.card);
       g_print ("Driver: %s, version: %d\n", v2cap.driver, v2cap.version);
-      g_print ("Bus info: %s\n", v2cap.bus_info);
-      g_print ("Capabilities: 0x%08X\n", v2cap.capabilities);
+      /* g_print ("Bus info: %s\n", v2cap.bus_info); */ /* Doesn't seem anything useful */
+     g_print ("Capabilities: 0x%08X\n", v2cap.capabilities);
       if (!(cap & V4L2_CAP_VIDEO_CAPTURE))
       {
         g_print ("Device %s seems to not have the capture capability, (radio tuner?)\n"
@@ -362,6 +400,8 @@ cheese_webcam_get_video_devices_from_hal (CheeseWebcam *webcam)
       product_name  = (char *) v2cap.card;
     }
 
+    g_print ("\n");
+
     priv->webcam_devices[priv->num_webcam_devices].hal_udi           = g_strdup (udis[i]);
     priv->webcam_devices[priv->num_webcam_devices].video_device      = g_strdup (device);
     priv->webcam_devices[priv->num_webcam_devices].gstreamer_src     = g_strdup (gstreamer_src);
@@ -653,8 +693,7 @@ cheese_webcam_get_webcam_device_data (CheeseWebcam       *webcam,
         if (name == NULL)
           name = "Unknown";
 
-        g_print ("Detected webcam: %s\n", name);
-        g_print ("device: %s\n", webcam_device->video_device);
+        g_print ("Device: %s (%s)\n", name, webcam_device->video_device);
         pad  = gst_element_get_pad (src, "src");
         caps = gst_pad_get_caps (pad);
         gst_object_unref (pad);
@@ -700,9 +739,12 @@ cheese_webcam_detect_webcam_devices (CheeseWebcam *webcam)
   int i;
 
   cheese_webcam_get_video_devices_from_hal (webcam);
+
+  g_print ("Probing supported video formats...\n");
   for (i = 0; i < priv->num_webcam_devices; i++)
   {
     cheese_webcam_get_webcam_device_data (webcam, &(priv->webcam_devices[i]));
+    g_print ("\n");
   }
 
   if (priv->num_webcam_devices == 0)
-- 
1.5.4.3



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