diff options
Diffstat (limited to 'v4l2-apps')
-rw-r--r-- | v4l2-apps/Makefile | 3 | ||||
-rw-r--r-- | v4l2-apps/libv4l/COPYING.LIB (renamed from v4l2-apps/lib/COPYING.LIB) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/ChangeLog (renamed from v4l2-apps/lib/libv4l/ChangeLog) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/Makefile (renamed from v4l2-apps/lib/libv4l/Makefile) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/README (renamed from v4l2-apps/lib/libv4l/README) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/README.multi-threading (renamed from v4l2-apps/lib/libv4l/README.multi-threading) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/TODO (renamed from v4l2-apps/lib/libv4l/TODO) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/include/libv4l1.h (renamed from v4l2-apps/lib/libv4l/include/libv4l1.h) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/include/libv4l2.h (renamed from v4l2-apps/lib/libv4l/include/libv4l2.h) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/include/libv4lconvert.h (renamed from v4l2-apps/lib/libv4l/include/libv4lconvert.h) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l1/Makefile (renamed from v4l2-apps/lib/libv4l/libv4l1/Makefile) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l1/libv4l1-priv.h (renamed from v4l2-apps/lib/libv4l/libv4l1/libv4l1-priv.h) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l1/libv4l1.c (renamed from v4l2-apps/lib/libv4l/libv4l1/libv4l1.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l1/log.c (renamed from v4l2-apps/lib/libv4l/libv4l1/log.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l1/v4l1compat.c (renamed from v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l2/Makefile (renamed from v4l2-apps/lib/libv4l/libv4l2/Makefile) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l2/libv4l2-priv.h (renamed from v4l2-apps/lib/libv4l/libv4l2/libv4l2-priv.h) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l2/libv4l2.c (renamed from v4l2-apps/lib/libv4l/libv4l2/libv4l2.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l2/log.c (renamed from v4l2-apps/lib/libv4l/libv4l2/log.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4l2/v4l2convert.c (renamed from v4l2-apps/lib/libv4l/libv4l2/v4l2convert.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/Makefile (renamed from v4l2-apps/lib/libv4l/libv4lconvert/Makefile) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/bayer.c (renamed from v4l2-apps/lib/libv4l/libv4lconvert/bayer.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/flip.c (renamed from v4l2-apps/lib/libv4l/libv4lconvert/flip.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/jidctflt.c (renamed from v4l2-apps/lib/libv4l/libv4lconvert/jidctflt.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/libv4lconvert-priv.h (renamed from v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c (renamed from v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/pac207.c (renamed from v4l2-apps/lib/libv4l/libv4lconvert/pac207.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/rgbyuv.c (renamed from v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/sn9c10x.c (renamed from v4l2-apps/lib/libv4l/libv4lconvert/sn9c10x.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/spca501.c (renamed from v4l2-apps/lib/libv4l/libv4lconvert/spca501.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/spca561-decompress.c (renamed from v4l2-apps/lib/libv4l/libv4lconvert/spca561-decompress.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/tinyjpeg-internal.h (renamed from v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg-internal.h) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/tinyjpeg.c (renamed from v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l/libv4lconvert/tinyjpeg.h (renamed from v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.h) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l2util/COPYING.LIB (renamed from v4l2-apps/lib/libv4l/COPYING.LIB) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l2util/Makefile (renamed from v4l2-apps/lib/Makefile) | 6 | ||||
-rw-r--r-- | v4l2-apps/libv4l2util/TODO (renamed from v4l2-apps/lib/TODO) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l2util/frequencies.c (renamed from v4l2-apps/lib/frequencies.c) | 2 | ||||
-rw-r--r-- | v4l2-apps/libv4l2util/libv4l2util.h (renamed from v4l2-apps/lib/v4l2.h) | 4 | ||||
-rw-r--r-- | v4l2-apps/libv4l2util/v4l2_driver.c (renamed from v4l2-apps/lib/v4l2_driver.c) | 0 | ||||
-rw-r--r-- | v4l2-apps/libv4l2util/v4l2_driver.h (renamed from v4l2-apps/lib/v4l2_driver.h) | 0 | ||||
-rw-r--r-- | v4l2-apps/test/Makefile | 9 | ||||
-rw-r--r-- | v4l2-apps/test/capture-example.c (renamed from v4l2-apps/test/capture_example.c) | 10 | ||||
-rw-r--r-- | v4l2-apps/test/driver-test.c | 2 | ||||
-rw-r--r-- | v4l2-apps/test/ioctl-test.c | 2 | ||||
-rw-r--r-- | v4l2-apps/test/stress-buffer.c | 140 | ||||
-rw-r--r-- | v4l2-apps/util/Makefile | 10 | ||||
-rwxr-xr-x | v4l2-apps/util/parse-sniffusb2.pl | 84 | ||||
-rw-r--r-- | v4l2-apps/util/qv4l2/ctrl-tab.cpp | 2 | ||||
-rw-r--r-- | v4l2-apps/util/qv4l2/general-tab.cpp | 2 | ||||
-rw-r--r-- | v4l2-apps/util/qv4l2/qv4l2.cpp | 2 | ||||
-rw-r--r-- | v4l2-apps/util/qv4l2/qv4l2.pro | 4 | ||||
-rw-r--r-- | v4l2-apps/util/v4l2-ctl.cpp | 123 | ||||
-rw-r--r-- | v4l2-apps/util/v4l2-sysfs-path.c | 191 |
54 files changed, 565 insertions, 31 deletions
diff --git a/v4l2-apps/Makefile b/v4l2-apps/Makefile index 2bba8fcd4..86b5bc267 100644 --- a/v4l2-apps/Makefile +++ b/v4l2-apps/Makefile @@ -5,7 +5,8 @@ all:: prepare-includes all clean install:: - $(MAKE) -C lib $@ + $(MAKE) -C libv4l $@ + $(MAKE) -C libv4l2util $@ $(MAKE) -C util $@ $(MAKE) -C test $@ diff --git a/v4l2-apps/lib/COPYING.LIB b/v4l2-apps/libv4l/COPYING.LIB index 1dd325d2b..1dd325d2b 100644 --- a/v4l2-apps/lib/COPYING.LIB +++ b/v4l2-apps/libv4l/COPYING.LIB diff --git a/v4l2-apps/lib/libv4l/ChangeLog b/v4l2-apps/libv4l/ChangeLog index dd53eced9..dd53eced9 100644 --- a/v4l2-apps/lib/libv4l/ChangeLog +++ b/v4l2-apps/libv4l/ChangeLog diff --git a/v4l2-apps/lib/libv4l/Makefile b/v4l2-apps/libv4l/Makefile index 4c99c3167..4c99c3167 100644 --- a/v4l2-apps/lib/libv4l/Makefile +++ b/v4l2-apps/libv4l/Makefile diff --git a/v4l2-apps/lib/libv4l/README b/v4l2-apps/libv4l/README index 3a2059224..3a2059224 100644 --- a/v4l2-apps/lib/libv4l/README +++ b/v4l2-apps/libv4l/README diff --git a/v4l2-apps/lib/libv4l/README.multi-threading b/v4l2-apps/libv4l/README.multi-threading index 93b393c8c..93b393c8c 100644 --- a/v4l2-apps/lib/libv4l/README.multi-threading +++ b/v4l2-apps/libv4l/README.multi-threading diff --git a/v4l2-apps/lib/libv4l/TODO b/v4l2-apps/libv4l/TODO index f3f9ff527..f3f9ff527 100644 --- a/v4l2-apps/lib/libv4l/TODO +++ b/v4l2-apps/libv4l/TODO diff --git a/v4l2-apps/lib/libv4l/include/libv4l1.h b/v4l2-apps/libv4l/include/libv4l1.h index c878cc198..c878cc198 100644 --- a/v4l2-apps/lib/libv4l/include/libv4l1.h +++ b/v4l2-apps/libv4l/include/libv4l1.h diff --git a/v4l2-apps/lib/libv4l/include/libv4l2.h b/v4l2-apps/libv4l/include/libv4l2.h index b05b57cb6..b05b57cb6 100644 --- a/v4l2-apps/lib/libv4l/include/libv4l2.h +++ b/v4l2-apps/libv4l/include/libv4l2.h diff --git a/v4l2-apps/lib/libv4l/include/libv4lconvert.h b/v4l2-apps/libv4l/include/libv4lconvert.h index 626c43473..626c43473 100644 --- a/v4l2-apps/lib/libv4l/include/libv4lconvert.h +++ b/v4l2-apps/libv4l/include/libv4lconvert.h diff --git a/v4l2-apps/lib/libv4l/libv4l1/Makefile b/v4l2-apps/libv4l/libv4l1/Makefile index 27848477e..27848477e 100644 --- a/v4l2-apps/lib/libv4l/libv4l1/Makefile +++ b/v4l2-apps/libv4l/libv4l1/Makefile diff --git a/v4l2-apps/lib/libv4l/libv4l1/libv4l1-priv.h b/v4l2-apps/libv4l/libv4l1/libv4l1-priv.h index 651599255..651599255 100644 --- a/v4l2-apps/lib/libv4l/libv4l1/libv4l1-priv.h +++ b/v4l2-apps/libv4l/libv4l1/libv4l1-priv.h diff --git a/v4l2-apps/lib/libv4l/libv4l1/libv4l1.c b/v4l2-apps/libv4l/libv4l1/libv4l1.c index 797c8768a..797c8768a 100644 --- a/v4l2-apps/lib/libv4l/libv4l1/libv4l1.c +++ b/v4l2-apps/libv4l/libv4l1/libv4l1.c diff --git a/v4l2-apps/lib/libv4l/libv4l1/log.c b/v4l2-apps/libv4l/libv4l1/log.c index 9ff0cea46..9ff0cea46 100644 --- a/v4l2-apps/lib/libv4l/libv4l1/log.c +++ b/v4l2-apps/libv4l/libv4l1/log.c diff --git a/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c b/v4l2-apps/libv4l/libv4l1/v4l1compat.c index e4293d2f9..e4293d2f9 100644 --- a/v4l2-apps/lib/libv4l/libv4l1/v4l1compat.c +++ b/v4l2-apps/libv4l/libv4l1/v4l1compat.c diff --git a/v4l2-apps/lib/libv4l/libv4l2/Makefile b/v4l2-apps/libv4l/libv4l2/Makefile index 648d27c0c..648d27c0c 100644 --- a/v4l2-apps/lib/libv4l/libv4l2/Makefile +++ b/v4l2-apps/libv4l/libv4l2/Makefile diff --git a/v4l2-apps/lib/libv4l/libv4l2/libv4l2-priv.h b/v4l2-apps/libv4l/libv4l2/libv4l2-priv.h index 8724832e1..8724832e1 100644 --- a/v4l2-apps/lib/libv4l/libv4l2/libv4l2-priv.h +++ b/v4l2-apps/libv4l/libv4l2/libv4l2-priv.h diff --git a/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c index b4a10afac..b4a10afac 100644 --- a/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c diff --git a/v4l2-apps/lib/libv4l/libv4l2/log.c b/v4l2-apps/libv4l/libv4l2/log.c index 6237d55ec..6237d55ec 100644 --- a/v4l2-apps/lib/libv4l/libv4l2/log.c +++ b/v4l2-apps/libv4l/libv4l2/log.c diff --git a/v4l2-apps/lib/libv4l/libv4l2/v4l2convert.c b/v4l2-apps/libv4l/libv4l2/v4l2convert.c index 307a03ce5..307a03ce5 100644 --- a/v4l2-apps/lib/libv4l/libv4l2/v4l2convert.c +++ b/v4l2-apps/libv4l/libv4l2/v4l2convert.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/Makefile b/v4l2-apps/libv4l/libv4lconvert/Makefile index 641d19d6e..641d19d6e 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/Makefile +++ b/v4l2-apps/libv4l/libv4lconvert/Makefile diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c b/v4l2-apps/libv4l/libv4lconvert/bayer.c index ca7bb486f..ca7bb486f 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c +++ b/v4l2-apps/libv4l/libv4lconvert/bayer.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/flip.c b/v4l2-apps/libv4l/libv4lconvert/flip.c index cd3468a89..cd3468a89 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/flip.c +++ b/v4l2-apps/libv4l/libv4lconvert/flip.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/jidctflt.c b/v4l2-apps/libv4l/libv4lconvert/jidctflt.c index 532abc7ea..532abc7ea 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/jidctflt.c +++ b/v4l2-apps/libv4l/libv4lconvert/jidctflt.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert-priv.h index 0c4eff6ce..0c4eff6ce 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h +++ b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert-priv.h diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c index 93bc67c7e..93bc67c7e 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c +++ b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/pac207.c b/v4l2-apps/libv4l/libv4lconvert/pac207.c index 97ef4ebc0..97ef4ebc0 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/pac207.c +++ b/v4l2-apps/libv4l/libv4lconvert/pac207.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c b/v4l2-apps/libv4l/libv4lconvert/rgbyuv.c index 0f26b227a..0f26b227a 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c +++ b/v4l2-apps/libv4l/libv4lconvert/rgbyuv.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/sn9c10x.c b/v4l2-apps/libv4l/libv4lconvert/sn9c10x.c index 4ea526d49..4ea526d49 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/sn9c10x.c +++ b/v4l2-apps/libv4l/libv4lconvert/sn9c10x.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c b/v4l2-apps/libv4l/libv4lconvert/spca501.c index 9157629e3..9157629e3 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c +++ b/v4l2-apps/libv4l/libv4lconvert/spca501.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/spca561-decompress.c b/v4l2-apps/libv4l/libv4lconvert/spca561-decompress.c index 01eed4ec5..01eed4ec5 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/spca561-decompress.c +++ b/v4l2-apps/libv4l/libv4lconvert/spca561-decompress.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg-internal.h b/v4l2-apps/libv4l/libv4lconvert/tinyjpeg-internal.h index 26844c28a..26844c28a 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg-internal.h +++ b/v4l2-apps/libv4l/libv4lconvert/tinyjpeg-internal.h diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c b/v4l2-apps/libv4l/libv4lconvert/tinyjpeg.c index fc9efbeb2..fc9efbeb2 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.c +++ b/v4l2-apps/libv4l/libv4lconvert/tinyjpeg.c diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.h b/v4l2-apps/libv4l/libv4lconvert/tinyjpeg.h index b0096f0de..b0096f0de 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/tinyjpeg.h +++ b/v4l2-apps/libv4l/libv4lconvert/tinyjpeg.h diff --git a/v4l2-apps/lib/libv4l/COPYING.LIB b/v4l2-apps/libv4l2util/COPYING.LIB index 1dd325d2b..1dd325d2b 100644 --- a/v4l2-apps/lib/libv4l/COPYING.LIB +++ b/v4l2-apps/libv4l2util/COPYING.LIB diff --git a/v4l2-apps/lib/Makefile b/v4l2-apps/libv4l2util/Makefile index 8443039b4..f3f413071 100644 --- a/v4l2-apps/lib/Makefile +++ b/v4l2-apps/libv4l2util/Makefile @@ -2,12 +2,12 @@ CPPFLAGS += -I../include -I.. -includes = v4l2.h +includes = libv4l2util.h objects = frequencies.o v4l2_driver.o -sharedlib = libv4l2.so -staticlib = libv4l2.a +sharedlib = libv4l2util.so +staticlib = libv4l2util.a ifeq ($(prefix),) prefix = /usr diff --git a/v4l2-apps/lib/TODO b/v4l2-apps/libv4l2util/TODO index 456a916ce..456a916ce 100644 --- a/v4l2-apps/lib/TODO +++ b/v4l2-apps/libv4l2util/TODO diff --git a/v4l2-apps/lib/frequencies.c b/v4l2-apps/libv4l2util/frequencies.c index 64379d2b0..df8d47dba 100644 --- a/v4l2-apps/lib/frequencies.c +++ b/v4l2-apps/libv4l2util/frequencies.c @@ -22,7 +22,7 @@ #include <stdlib.h> #include <linux/videodev2.h> -#include "v4l2.h" +#include "libv4l2util.h" /* This source was originally written by Nathan Laredo <laredo@gnu.org>. He kindly gave permission to release this source under the LGPL diff --git a/v4l2-apps/lib/v4l2.h b/v4l2-apps/libv4l2util/libv4l2util.h index 172688853..fde7cdc75 100644 --- a/v4l2-apps/lib/v4l2.h +++ b/v4l2-apps/libv4l2util/libv4l2util.h @@ -15,8 +15,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef _V4L2_H_ -#define _V4L2_H_ +#ifndef _V4L2UTIL_H_ +#define _V4L2UTIL_H_ /* --------------------------------------------------------------------- */ diff --git a/v4l2-apps/lib/v4l2_driver.c b/v4l2-apps/libv4l2util/v4l2_driver.c index 94f826968..94f826968 100644 --- a/v4l2-apps/lib/v4l2_driver.c +++ b/v4l2-apps/libv4l2util/v4l2_driver.c diff --git a/v4l2-apps/lib/v4l2_driver.h b/v4l2-apps/libv4l2util/v4l2_driver.h index b5d5dd22d..b5d5dd22d 100644 --- a/v4l2-apps/lib/v4l2_driver.h +++ b/v4l2-apps/libv4l2util/v4l2_driver.h diff --git a/v4l2-apps/test/Makefile b/v4l2-apps/test/Makefile index faafed14d..d118b9210 100644 --- a/v4l2-apps/test/Makefile +++ b/v4l2-apps/test/Makefile @@ -9,7 +9,8 @@ binaries = ioctl-test \ v4lgrab \ driver-test \ pixfmt-test \ - capture_example + stress-buffer \ + capture-example .PHONY: all clean install @@ -20,10 +21,10 @@ clean:: install: -../lib/libv4l2.a: ../lib/v4l2_driver.c ../lib/frequencies.c - make -C ../lib libv4l2.a +../libv4l2util/libv4l2util.a: ../libv4l2util/v4l2_driver.c ../libv4l2util/frequencies.c + make -C ../libv4l2util libv4l2util.a -driver-test: driver-test.o ../lib/libv4l2.a +driver-test: driver-test.o ../libv4l2util/libv4l2util.a pixfmt-test: pixfmt-test.o $(CC) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ -lX11 diff --git a/v4l2-apps/test/capture_example.c b/v4l2-apps/test/capture-example.c index 0cd129885..9d5b0d6ce 100644 --- a/v4l2-apps/test/capture_example.c +++ b/v4l2-apps/test/capture-example.c @@ -23,17 +23,15 @@ #include <sys/mman.h> #include <sys/ioctl.h> -#include <asm/types.h> /* for videodev2.h */ - #include <linux/videodev2.h> #define CLEAR(x) memset(&(x), 0, sizeof(x)) -typedef enum { +enum io_method { IO_METHOD_READ, IO_METHOD_MMAP, IO_METHOD_USERPTR, -} io_method; +}; struct buffer { void *start; @@ -41,7 +39,7 @@ struct buffer { }; static char *dev_name; -static io_method io = IO_METHOD_MMAP; +static enum io_method io = IO_METHOD_MMAP; static int fd = -1; struct buffer *buffers; static unsigned int n_buffers; @@ -570,7 +568,7 @@ static void usage(FILE *fp, int argc, char **argv) "-f | --format Force format to 640x480 YUYV\n" "-c | --count Number of frames to grab [%i]\n" "", - argv[0],dev_name,frame_count ); + argv[0], dev_name, frame_count); } static const char short_options[] = "d:hmruofc:"; diff --git a/v4l2-apps/test/driver-test.c b/v4l2-apps/test/driver-test.c index e4c16ed54..1f722e198 100644 --- a/v4l2-apps/test/driver-test.c +++ b/v4l2-apps/test/driver-test.c @@ -14,7 +14,7 @@ GNU General Public License for more details. */ -#include "../lib/v4l2_driver.h" +#include "../libv4l2util/v4l2_driver.h" #include <stdio.h> #include <string.h> #include <unistd.h> diff --git a/v4l2-apps/test/ioctl-test.c b/v4l2-apps/test/ioctl-test.c index f9ac1cad5..883282106 100644 --- a/v4l2-apps/test/ioctl-test.c +++ b/v4l2-apps/test/ioctl-test.c @@ -90,7 +90,6 @@ union v4l_parms { struct v4l2_encoder_cmd p_v4l2_encoder_cmd; struct v4l2_dbg_register p_v4l2_dbg_register; struct v4l2_dbg_chip_ident p_v4l2_dbg_chip_ident; - struct v4l2_chip_ident_old p_v4l2_chip_ident_old; struct v4l2_hw_freq_seek p_v4l2_hw_freq_seek; }; @@ -197,7 +196,6 @@ static const struct { ioc(VIDIOC_DBG_S_REGISTER), /* struct v4l2_register */ ioc(VIDIOC_DBG_G_REGISTER), /* struct v4l2_register */ ioc(VIDIOC_DBG_G_CHIP_IDENT), /* struct v4l2_dbg_chip_ident */ - ioc(VIDIOC_G_CHIP_IDENT_OLD), /* struct v4l2_chip_ident_old */ ioc(VIDIOC_S_HW_FREQ_SEEK), /* struct v4l2_hw_freq_seek */ #ifdef __OLD_VIDIOC_ ioc(VIDIOC_OVERLAY_OLD), /* int */ diff --git a/v4l2-apps/test/stress-buffer.c b/v4l2-apps/test/stress-buffer.c new file mode 100644 index 000000000..60410c70c --- /dev/null +++ b/v4l2-apps/test/stress-buffer.c @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2009 Douglas Schilling Landgraf <dougsland@redhat.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * stress-buffer tool makes infinite calls using read() for + * any device specified by the command argument. + * + * The size of buffer shall be a random number from 0 up to 1000. + * + * Also is automatically created a file called: stats-M-D-Y-h-m-s.txt + * in current directory with data executed. + * + * The stress test is performed by several read() calls, + * and it helped to identify real issues like: + * + * - memory leaks + * - specific crashs that are rare and hard to reproduce + * + * To compile: + * gcc -o stress-buffer stress-buffer.c -Wall + * + * To execute: + * ./stress-buffer /dev/device_for_test + * + * Example: + * ./stress-buffer /dev/video0 + */ + +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdio.h> +#include <sys/ioctl.h> +#include <stdlib.h> +#include <time.h> +#include <string.h> +#include <errno.h> + +int main(int argc, char **argv) +{ + char buffer[1000]; + char fname[30]; + int fd, ret, magic_buffer_size, cnt = 0; + time_t t1, t2; + double dif; + time_t current; + struct tm *timep; + + FILE *fd_file; + + if (argc != 2) { + printf("Usage: %s /dev/device_to_test\n", argv[0]); + return -1; + } + + current = time(NULL); + timep = localtime(¤t); + + memset(fname, 0, sizeof(fname)); + + snprintf(fname, sizeof(fname), "stats-%.2d-%.2d-%.2d-%.2d-%.2d-%.2d.txt", + timep->tm_mon+1, timep->tm_mday, timep->tm_year + 1900, + timep->tm_hour, timep->tm_min, timep->tm_sec); + + fd_file = fopen(fname, "a+"); + if (!fd_file) { + perror("error opening file"); + return -1; + } + + srand(time(NULL)); + + while (1) { + + if (time(&t1) < 0) { + perror("time_t t1"); + fclose(fd_file); + return -1; + } + + fd = open(argv[1], O_RDONLY); + if (fd < 0) { + perror("error opening device"); + fclose(fd_file); + return -1; + } + + /* Random number 0 - 1000 */ + magic_buffer_size = rand() % sizeof(buffer); + + memset(buffer, 0, sizeof(buffer)); + + ret = access(fname, W_OK); + if (ret < 0) { + close(fd); + perror("Error"); + return -1; + } + + ret = read(fd, buffer, magic_buffer_size); + if (ret < 0) { + fprintf(fd_file, "[%s] error reading buffer - [%s]\n", + argv[1], strerror(errno)); + fflush(fd_file); + perror("error reading buffer from device"); + return -1; + } + + if (time(&t2) < 0) { + perror("time_t t2"); + fclose(fd_file); + return -1; + } + + dif = difftime(t2, t1); + + printf("Seconds: [%d] - Test Number: [%d] - Read [%d] bytes\n", + (int)dif, cnt, ret); + + fprintf(fd_file, "Seconds: [%.2f] - Test number: [%d] - Read [%d] bytes\n", + dif, cnt, ret); + + fflush(fd_file); + + cnt++; + + close(fd); + + } + return 0; +} diff --git a/v4l2-apps/util/Makefile b/v4l2-apps/util/Makefile index b80de190b..6f9d1071a 100644 --- a/v4l2-apps/util/Makefile +++ b/v4l2-apps/util/Makefile @@ -7,7 +7,7 @@ endif CPPFLAGS += -I../include -D_GNU_SOURCE LDFLAGS += -lm -binaries = v4l2-ctl v4l2-dbg v4l2-compliance ivtv-ctl cx18-ctl +binaries = v4l2-ctl v4l2-dbg v4l2-compliance ivtv-ctl cx18-ctl v4l2-sysfs-path ifeq ($(prefix),) prefix = /usr @@ -34,6 +34,14 @@ v4l2-dbg: v4l2-dbg.o v4l2-chipids.o v4l2-dbg.o: v4l2-dbg.h v4l2-dbg-bttv.h v4l2-dbg-em28xx.h v4l2-dbg-saa7134.h +v4l2-sysfs-path.o: v4l2-sysfs-path.c ../libv4l2util/v4l2_driver.h + +v4l2-sysfs-path: v4l2-sysfs-path.o ../libv4l2util/libv4l2util.a + $(CC) $^ -o $@ -lsysfs + +../libv4l2util/libv4l2util.a: + $(MAKE) -C ../libv4l2util libv4l2util.a + install: mkdir -p $(prefix)/bin cp $(binaries) $(prefix)/bin diff --git a/v4l2-apps/util/parse-sniffusb2.pl b/v4l2-apps/util/parse-sniffusb2.pl new file mode 100755 index 000000000..34406b0ea --- /dev/null +++ b/v4l2-apps/util/parse-sniffusb2.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl +# +# Author: Franklin Meng <fmeng2002@yahoo.com> +# Parser for USB snoops captured from SniffUSB 2.0. +# + +use strict; +use warnings; +use Data::Dumper; + +foreach my $curfile (@ARGV) { + parsefile($curfile); + #we can only process 1 file + exit; +} + +sub parsefile { + my $curfile = shift; + my $SetupPacket =''; + my $preS = ''; + my $TransferBuffer =''; + my $preT = ''; + my $Direction =''; + my $preD = ''; + my @tmpsplit; + my $t=0; + my $s=0; + + open(FD, $curfile) || die("Error: $!\n"); + + while(<FD>) { + chomp; + if($t==1 && /^\s+\d{8}/) { +# print $_ . "\n"; + @tmpsplit = split(/\:\s/,$_); + $TransferBuffer = $TransferBuffer . $tmpsplit[1] . " "; + } elsif($s==1 && /^\s+\d{8}/) { +# print $_ . "\n"; + @tmpsplit = split(/\:\s/,$_); + $SetupPacket = $SetupPacket . $tmpsplit[1] ; + } else { + $t=0; + $s=0; + } + if(/[<>]{3}/){ + #print out last packet if valid + if($SetupPacket) { + if($preT) { + print "$SetupPacket $preD $preT\n"; + + } else { + print "$SetupPacket $Direction $TransferBuffer\n"; + } + } +# print "$SetupPacket $Direction $TransferBuffer\n"; + #clear variables + $preT = $TransferBuffer; + $TransferBuffer = ''; + $preS = $SetupPacket; + $SetupPacket = ''; + $preD = $Direction; + $t = 0; + $s = 0; + # get direction + @tmpsplit = split(/\s+/, $_); + $Direction = $tmpsplit[2]; +# print $_ . "\n"; + } elsif(/TransferBufferMDL/) { + $t = 1 + } elsif(/SetupPacket/) { + $s = 1; + } + } + #print last packet +# print "$SetupPacket $Direction $TransferBuffer\n"; + if($SetupPacket) { + if($preT) { + print "$SetupPacket $preD $preT\n"; + } else { + print "$SetupPacket $Direction $TransferBuffer\n"; + } + } +} + diff --git a/v4l2-apps/util/qv4l2/ctrl-tab.cpp b/v4l2-apps/util/qv4l2/ctrl-tab.cpp index c7d1a275c..6f436b494 100644 --- a/v4l2-apps/util/qv4l2/ctrl-tab.cpp +++ b/v4l2-apps/util/qv4l2/ctrl-tab.cpp @@ -1,6 +1,6 @@ #include "qv4l2.h" -#include "v4l2.h" +#include "libv4l2util.h" #include <qstatusbar.h> #include <qlineedit.h> diff --git a/v4l2-apps/util/qv4l2/general-tab.cpp b/v4l2-apps/util/qv4l2/general-tab.cpp index 3b9ad2e5b..78656cf10 100644 --- a/v4l2-apps/util/qv4l2/general-tab.cpp +++ b/v4l2-apps/util/qv4l2/general-tab.cpp @@ -20,7 +20,7 @@ #include "qv4l2.h" #include "general-tab.h" -#include "v4l2.h" +#include "libv4l2util.h" #include <qlabel.h> #include <qspinbox.h> diff --git a/v4l2-apps/util/qv4l2/qv4l2.cpp b/v4l2-apps/util/qv4l2/qv4l2.cpp index d144723d9..764fbd172 100644 --- a/v4l2-apps/util/qv4l2/qv4l2.cpp +++ b/v4l2-apps/util/qv4l2/qv4l2.cpp @@ -1,7 +1,7 @@ #include "qv4l2.h" #include "general-tab.h" -#include "v4l2.h" +#include "libv4l2util.h" #include <qimage.h> #include <qpixmap.h> diff --git a/v4l2-apps/util/qv4l2/qv4l2.pro b/v4l2-apps/util/qv4l2/qv4l2.pro index 5e0b7555d..96adb7260 100644 --- a/v4l2-apps/util/qv4l2/qv4l2.pro +++ b/v4l2-apps/util/qv4l2/qv4l2.pro @@ -3,10 +3,10 @@ ###################################################################### TEMPLATE = app -INCLUDEPATH += . ../../include ../../lib +INCLUDEPATH += . ../../include ../../libv4l2util CONFIG += debug # Input HEADERS += qv4l2.h general-tab.h SOURCES += qv4l2.cpp general-tab.cpp ctrl-tab.cpp -LIBS += -lv4l2 -L../../lib +LIBS += -lv4l2util -L../../libv4l2util diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index 7d5988571..dec9edd61 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -129,6 +129,8 @@ enum Option { OptGetOverlayCropCap, OptGetOutputOverlayCropCap, OptOverlay, + OptGetJpegComp, + OptSetJpegComp, OptListDevices, OptLast = 256 }; @@ -256,6 +258,8 @@ static struct option long_options[] = { {"get-cropcap-output-overlay", no_argument, 0, OptGetOutputOverlayCropCap}, {"get-crop-output-overlay", no_argument, 0, OptGetOutputOverlayCrop}, {"set-crop-output-overlay", required_argument, 0, OptSetOutputOverlayCrop}, + {"get-jpeg-comp", no_argument, 0, OptGetJpegComp}, + {"set-jpeg-comp", required_argument, 0, OptSetJpegComp}, {"overlay", required_argument, 0, OptOverlay}, {"list-devices", no_argument, 0, OptListDevices}, {0, 0, 0, 0} @@ -380,6 +384,16 @@ static void usage(void) " query the video output overlay crop window [VIDIOC_G_CROP]\n" " --set-crop-output-overlay=top=<x>,left=<y>,width=<w>,height=<h>\n" " set the video output overlay crop window [VIDIOC_S_CROP]\n" + " --get-jpeg-comp query the JPEG compression [VIDIOC_G_JPEGCOMP]\n" + " --set-jpeg-comp=quality=<q>,markers=<markers>,comment=<c>,app<n>=<a>\n" + " set the JPEG compression [VIDIOC_S_JPEGCOMP]\n" + " <n> is the app segment: 0-9 or a-f, <a> is the actual string.\n" + " <markers> is a colon separated list of:\n" + " dht: Define Huffman Tables\n" + " dqt: Define Quantization Tables\n" + " dri: Define Restart Interval\n" + " --set-audio-output=<num>\n" + " set the audio output to <num> [VIDIOC_S_AUDOUT]\n" " --get-audio-input query the audio input [VIDIOC_G_AUDIO]\n" " --set-audio-input=<num>\n" " set the audio input to <num> [VIDIOC_S_AUDIO]\n" @@ -576,11 +590,12 @@ static void print_qctrl(int fd, struct v4l2_queryctrl *queryctrl, } if (queryctrl->flags) { const flag_def def[] = { - { V4L2_CTRL_FLAG_GRABBED, "grabbed" }, - { V4L2_CTRL_FLAG_READ_ONLY, "readonly" }, - { V4L2_CTRL_FLAG_UPDATE, "update" }, - { V4L2_CTRL_FLAG_INACTIVE, "inactive" }, - { V4L2_CTRL_FLAG_SLIDER, "slider" }, + { V4L2_CTRL_FLAG_GRABBED, "grabbed" }, + { V4L2_CTRL_FLAG_READ_ONLY, "read-only" }, + { V4L2_CTRL_FLAG_UPDATE, "update" }, + { V4L2_CTRL_FLAG_INACTIVE, "inactive" }, + { V4L2_CTRL_FLAG_SLIDER, "slider" }, + { V4L2_CTRL_FLAG_WRITE_ONLY, "write-only" }, { 0, NULL } }; printf(" flags=%s", flags2s(queryctrl->flags, def).c_str()); @@ -750,6 +765,35 @@ static void printfbuf(const struct v4l2_framebuffer &fb) } } +static std::string markers2s(unsigned markers) +{ + std::string s; + + if (markers & V4L2_JPEG_MARKER_DHT) + s += "\t\tDefine Huffman Tables\n"; + if (markers & V4L2_JPEG_MARKER_DQT) + s += "\t\tDefine Quantization Tables\n"; + if (markers & V4L2_JPEG_MARKER_DRI) + s += "\t\tDefine Restart Interval\n"; + if (markers & V4L2_JPEG_MARKER_COM) + s += "\t\tDefine Comment\n"; + if (markers & V4L2_JPEG_MARKER_APP) + s += "\t\tDefine APP segment\n"; + return s; +} + +static void printjpegcomp(const struct v4l2_jpegcompression &jc) +{ + printf("JPEG compression:\n"); + printf("\tQuality: %d\n", jc.quality); + if (jc.COM_len) + printf("\tComment: '%s'\n", jc.COM_data); + if (jc.APP_len) + printf("\tAPP%x : '%s'\n", jc.APPn, jc.APP_data); + printf("\tMarkers: 0x%08lx\n", jc.jpeg_markers); + printf("%s", markers2s(jc.jpeg_markers).c_str()); +} + static void printcrop(const struct v4l2_crop &crop) { printf("Crop: Left %d, Top %d, Width %d, Height %d\n", @@ -1337,6 +1381,7 @@ int main(int argc, char **argv) struct v4l2_rect vcrop_overlay; /* crop rect */ struct v4l2_rect vcrop_out_overlay; /* crop rect */ struct v4l2_framebuffer fbuf; /* fbuf */ + struct v4l2_jpegcompression jpegcomp; /* jpeg compression */ int input; /* set_input/get_input */ int output; /* set_output/get_output */ v4l2_std_id std; /* get_std/set_std */ @@ -1371,6 +1416,7 @@ int main(int argc, char **argv) memset(&vf, 0, sizeof(vf)); memset(&vs, 0, sizeof(vs)); memset(&fbuf, 0, sizeof(fbuf)); + memset(&jpegcomp, 0, sizeof(jpegcomp)); if (argc == 1) { usage(); @@ -1700,6 +1746,62 @@ int main(int argc, char **argv) } break; } + case OptSetJpegComp: + { + subs = optarg; + while (*subs != '\0') { + static const char *const subopts[] = { + "app0", "app1", "app2", "app3", + "app4", "app5", "app6", "app7", + "app8", "app9", "appa", "appb", + "appc", "appd", "appe", "appf", + "quality", + "markers", + "comment", + NULL + }; + int len; + int opt = parse_subopt(&subs, subopts, &value); + + switch (opt) { + case 16: + jpegcomp.quality = strtol(value, 0L, 0); + break; + case 17: + if (strstr(value, "dht")) + jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DHT; + if (strstr(value, "dqt")) + jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DQT; + if (strstr(value, "dri")) + jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DRI; + break; + case 18: + len = strlen(value); + if (len > sizeof(jpegcomp.COM_data) - 1) + len = sizeof(jpegcomp.COM_data) - 1; + jpegcomp.COM_len = len; + memcpy(jpegcomp.COM_data, value, len); + jpegcomp.COM_data[len] = '\0'; + break; + default: + if (opt < 0 || opt > 15) + break; + len = strlen(value); + if (len > sizeof(jpegcomp.APP_data) - 1) + len = sizeof(jpegcomp.APP_data) - 1; + if (jpegcomp.APP_len) { + fprintf(stderr, "Only one APP segment can be set\n"); + break; + } + jpegcomp.APP_len = len; + memcpy(jpegcomp.APP_data, value, len); + jpegcomp.APP_data[len] = '\0'; + jpegcomp.APPn = opt; + break; + } + } + break; + } case OptListDevices: list_devices(); break; @@ -1768,6 +1870,7 @@ int main(int argc, char **argv) options[OptGetFBuf] = 1; options[OptGetCropCap] = 1; options[OptGetOutputCropCap] = 1; + options[OptGetJpegComp] = 1; options[OptSilent] = 1; } @@ -1987,6 +2090,10 @@ set_vid_fmt_error: } } + if (options[OptSetJpegComp]) { + doioctl(fd, VIDIOC_S_JPEGCOMP, &jpegcomp, "VIDIOC_S_JPEGCOMP"); + } + if (options[OptOverlay]) { doioctl(fd, VIDIOC_OVERLAY, &overlay, "VIDIOC_OVERLAY"); } @@ -2110,6 +2217,12 @@ set_vid_fmt_error: printfbuf(fb); } + if (options[OptGetJpegComp]) { + struct v4l2_jpegcompression jc; + if (doioctl(fd, VIDIOC_G_JPEGCOMP, &jc, "VIDIOC_G_JPEGCOMP") == 0) + printjpegcomp(jc); + } + if (options[OptGetCropCap]) { struct v4l2_cropcap cropcap; diff --git a/v4l2-apps/util/v4l2-sysfs-path.c b/v4l2-apps/util/v4l2-sysfs-path.c new file mode 100644 index 000000000..e3f3e63e8 --- /dev/null +++ b/v4l2-apps/util/v4l2-sysfs-path.c @@ -0,0 +1,191 @@ +/* + Copyright (C) 2009 Mauro Carvalho Chehab <mchehab@redhat.com> + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation version 2 of the License. + + The sysfs logic were adapted from a C++/Boost snippet code sent by + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "../libv4l2util/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(char *bus_info) +{ + struct sysfs_device *pcictl = NULL; + struct sysfs_bus *bus = NULL; + struct sysfs_device *busdev = NULL; + struct dlist *busdevs = NULL; + struct sysfs_device *pdev = NULL; + char *tmp = NULL, *busname, *buspath; + int pci; + + if (!strncmp(bus_info, USB_ID, strlen(USB_ID))) { + bus_info += strlen(USB_ID); + pci = 0; + } else if (!strncmp(bus_info, PCI_ID, strlen(PCI_ID))) { + bus_info += strlen(PCI_ID); + pci = 1; + } else if (!strncmp(bus_info, PCIe_ID, strlen(PCIe_ID))) { + bus_info += strlen(PCIe_ID); + pci = 1; + } else + return NULL; + + busname = strtok(bus_info, "-"); + if (!busname) + return NULL; + + buspath = strtok(NULL, "-"); + if (!buspath && !pci) + return NULL; + + /* open bus host controller */ + pcictl = sysfs_open_device("pci", busname); + if (!pcictl) + goto err; + + /* We have all we need for PCI devices */ + if (pci) { + char *name; + + asprintf(&name, "%s", pcictl->path); + return name; + } + + /* find matching usb bus */ + bus = sysfs_open_bus("usb"); + if (!bus) + goto err; + + busdevs = sysfs_get_bus_devices(bus); + if (!busdevs) + goto err; + + dlist_for_each_data(busdevs, busdev, struct sysfs_device) { + /* compare pathes of bus host controller and + parent of enumerated bus devices */ + + pdev = sysfs_get_device_parent(busdev); + if (!pdev) + continue; + + if (!strcmp(pcictl->path, pdev->path)) + break; + } + + if (!pdev) + goto err; + + sysfs_close_device(pcictl); + pcictl = NULL; + + /* assemble bus device path */ + if (busdev) { + struct sysfs_attribute *busnumattr; + unsigned int busnum; + char *name; + + busnumattr = sysfs_get_device_attr(busdev, "busnum"); + if (!busnumattr) + goto err; + + tmp = malloc(busnumattr->len + 1); + strncpy(tmp, busnumattr->value, busnumattr->len); + tmp[busnumattr->len] = '\0'; + + if (sscanf(tmp, "%u", &busnum) != 1) + goto err; + + asprintf(&name, "%s/%d-%s", busdev->path, + busnum, buspath); + + free(tmp); + sysfs_close_bus(bus); + + return name; + } + +err: + if (tmp) + free(tmp); + if (bus) + sysfs_close_bus(bus); + if (pcictl) + sysfs_close_device(pcictl); + + return NULL; +} + +void get_sysfs(char *fname) +{ + struct v4l2_driver drv; + char *path; + if (v4l2_open(fname, 0, &drv) < 0) { + perror(fname); + return; + } + + 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\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; +} |