The patch number 10312 was added via Mauro Carvalho Chehab <mche...@redhat.com>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <linux-me...@vger.kernel.org>

------

From: Mauro Carvalho Chehab  <mche...@redhat.com>
Retrieves info for all v4l2 devices on /dev


Signed-off-by: Mauro Carvalho Chehab <mche...@redhat.com>


---

 v4l2-apps/util/v4l2_sysfs_path.c |   52 +++++++++++++++++++++++++------
 1 file changed, 42 insertions(+), 10 deletions(-)

diff -r c96c6e9eeb08 -r 92603e53d49e v4l2-apps/util/v4l2_sysfs_path.c
--- a/v4l2-apps/util/v4l2_sysfs_path.c  Tue Jan 27 21:56:31 2009 -0200
+++ b/v4l2-apps/util/v4l2_sysfs_path.c  Tue Jan 27 22:16:53 2009 -0200
@@ -16,20 +16,19 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-
-
 #include "../lib/v4l2_driver.h"
 #include <sysfs/libsysfs.h>
 #include <errno.h>
 #include <malloc.h>
 #include <stdio.h>
 #include <string.h>
+#include <dirent.h>
 
 #define USB_ID "usb-"
 #define PCI_ID "PCI:"
 #define PCIe_ID "PCIe:"
 
-char *obtain_bus_sysfs_path(const char *bus_info)
+char *obtain_bus_sysfs_path(char *bus_info)
 {
        struct sysfs_device *pcictl = NULL;
        struct sysfs_bus *bus = NULL;
@@ -136,24 +135,57 @@ err:
        return NULL;
 }
 
-int main(void)
+void get_sysfs(char *fname)
 {
        struct v4l2_driver drv;
        char *path;
-
-       if (v4l2_open("/dev/video0", 0, &drv) < 0) {
-               perror("open /dev/video0");
-               return -1;
+       if (v4l2_open(fname, 0, &drv) < 0) {
+               perror(fname);
+               return;
        }
 
-       printf("bus info = %s\n", drv.cap.bus_info);
+       printf("device     = %s\n", fname);
+       printf("bus info   = %s\n", drv.cap.bus_info);
        path = obtain_bus_sysfs_path((char *)drv.cap.bus_info);
        if (path) {
-               printf("sysfs path = %s\n", path);
+               printf("sysfs path = %s\n\n", path);
                free(path);
        }
 
        v4l2_close(&drv);
+}
 
+void read_dir(char *dirname)
+{
+       DIR             *dir;
+       struct dirent   *entry;
+       const char      *vid = "video";
+       const char      *rad = "radio";
+       char            *p, name[512];
+
+       dir = opendir(dirname);
+       if (!dir)
+               return;
+
+       strcpy(name, dirname);
+       strcat(name, "/");
+       p = name + strlen(name);
+
+       entry = readdir(dir);
+       while (entry) {
+               if (!strncmp(entry->d_name, vid, strlen(vid)) ||
+                   !strncmp(entry->d_name, rad, strlen(rad))) {
+                       strcpy(p, entry->d_name);
+
+                       get_sysfs(name);
+               }
+               entry = readdir(dir);
+       }
+       closedir(dir);
+}
+
+int main(void)
+{
+       read_dir("/dev");
        return 0;
 }


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/92603e53d49e52dd7e5ec8020f1b7ce6b5a0f4b0

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to