Updating prebuilts and/or headers

f751b481c4a9203345cdbb6459d0f2882f7cdbd9 - include/libv4lconvert.h
6feb5b2b8c99c99712dd1ea7fe9ab674d58bf86b - include/libv4l1.h
f2b73fa5ab10ea7038e58bd9a4461d8e16316249 - include/libv4l1-videodev.h
bc44111fd6b2f0374a9fc67b1b23666c5c498b2c - include/libv4l2rds.h
94434b9692371b7d5f54ddef2141d22d90079ce9 - include/libv4l-plugin.h
c84a9a115a21d1fd20da0f6ca3df7b46dd23cd2a - include/config.h
1edc439e6c0fc98513fa4a69557eb6221d043be0 - include/libv4l2.h
2f55ba765c689500401111747bb381b5aca77b30 - include/libdvbv5/desc_ca.h
4c412880f0c49cd00cb16e56eed082c4744211a5 - include/libdvbv5/countries.h
c1212a9308d96730de547648d3cda2fc144d0e29 - include/libdvbv5/desc_atsc_service_location.h
4fe7def34ff640fc5e327b3596298169fdfe2f1c - include/libdvbv5/mpeg_ts.h
ef979f3276cc3cad6e947865a42643fbba860c69 - include/libdvbv5/mgt.h
ac87e3306569dae329809f27ef227c5d50f0b60e - include/libdvbv5/desc_event_short.h
98365b48442b9e3abb58101983b5da8c14f78289 - include/libdvbv5/dvb-v5-std.h
9a2b20076d6728b5799096e4149e33a73119e1ef - include/libdvbv5/desc_sat.h
c8b4fc511833f0993fa740a529e1f61e0f5a216f - include/libdvbv5/mpeg_es.h
44ab16a8d4eae09690c71a6301927c1da55dda6d - include/libdvbv5/descriptors.h
9d523ee179af955a687662996050ee3cfaacf2ab - include/libdvbv5/crc32.h
c18291ff9009bfe71a2c7c6f0fce75331dc95e30 - include/libdvbv5/sdt.h
02168c58e3c772f116f075085579ac4a8422e819 - include/libdvbv5/desc_terrestrial_delivery.h
bdf514383ca0afe981cf4fd6af86440db2dc6667 - include/libdvbv5/pat.h
22c83d133e5c1d2648efb3028e0d89c970d0aad4 - include/libdvbv5/desc_partial_reception.h
96db22ef84892a36d5df3cffa0b30d5bad01939c - include/libdvbv5/desc_logical_channel.h
73b7b0cf684de0e8a4eae49a8521f81b411d7b72 - include/libdvbv5/desc_ts_info.h
7fb0966c6a1ccdf1a8844aed4a94d4ae1d02fcd7 - include/libdvbv5/dvb-fe.h
6e6fd4c61c1f61006c63214cbe4868d49428ddb9 - include/libdvbv5/mpeg_pes.h
efa3a711499f68ae370d49d98dc1963bf6bafcd8 - include/libdvbv5/desc_extension.h
d562371bb8a3b961c4d63a0f5618453bdff4bcd3 - include/libdvbv5/dvb-log.h
b72b6d1ffcdd81e3e631c7c20bb30e5c287dc7ff - include/libdvbv5/vct.h
92d4c28148d0b537c8afc289e1a76de68435cba0 - include/libdvbv5/dvb-scan.h
6bd2ed0beaf6aa4838e239198564fd8e1d20a3a1 - include/libdvbv5/desc_t2_delivery.h
ad13bfa0b1642fc72cca387e62bc193974c8d5ee - include/libdvbv5/atsc_header.h
450fab787e61210c0c5f527df92c31c90b44a113 - include/libdvbv5/desc_service.h
9b5cfad4a5f41cbf886507da6e79b07314827b32 - include/libdvbv5/desc_language.h
e81b7f75c11f175cf365fc7fb535e80828f10e24 - include/libdvbv5/dvb-file.h
30e9a7240938943de2725f2b335b19ad320179a5 - include/libdvbv5/header.h
188fc2cbec97288787a7f66554a4b6288224f980 - include/libdvbv5/desc_isdbt_delivery.h
7645dda247bcd45628afbb74ec2707a47050992e - include/libdvbv5/nit.h
1ba874a7cad36ff31e4af3bfb37b98c05063d6b2 - include/libdvbv5/desc_event_extended.h
146f4f53fc49c66b59905249c0142efffd72fc54 - include/libdvbv5/desc_network_name.h
5b4a5e7fb30a7f28118be012837e73a7151d2619 - include/libdvbv5/cat.h
d7a096d51e3050c8f52e0e2111d88b71a5313da1 - include/libdvbv5/dvb-demux.h
40a06b5375dbc0de88a15d26cc6c1e9a505119bc - include/libdvbv5/eit.h
7544b5fb8f621a9c637c40d8f7a2a71f6ab4bd63 - include/libdvbv5/desc_hierarchy.h
2560f18846a535a2c02e1ae449511e731f11c011 - include/libdvbv5/desc_ca_identifier.h
100c02ce3bc364ddff895c75f4fb1f928a748d2d - include/libdvbv5/desc_cable_delivery.h
7a6093b13354d054cac78ea118a96e813cac3395 - include/libdvbv5/atsc_eit.h
cabecc6d7c9fdf1c437273bd6a746bf83c156f72 - include/libdvbv5/desc_frequency_list.h
b867a2e7941d718aa64b2f6a1402322b616cb2da - include/libdvbv5/pmt.h
fb8d640da36b6a156cbe0ef12dc25468de89a2a1 - include/libdvbv5/dvb-sat.h
5e2dfc1d9a71805389e9a7932812695d0309050c - include/libdvbv5/dvb-frontend.h
5430e46abb1ac7039ed0309ca338237533ff29c9 - libv4lconvert/sn9c20x.c
f4d73412805f12fa08dd79a43798a7f8d7acece9 - libv4lconvert/pac207.c
3c49d99b9753208a9c1c2a9c738a1e7ad291ca22 - libv4lconvert/jpeg_memsrcdest.h
ddd39b2fe0e2a86a6c64031ccc0d36edfd9b0f1a - libv4lconvert/sn9c10x.c
463725aa4dd3fecaf89c0b8bbf4747f8f7577935 - libv4lconvert/jpeg.c
fa751ff0f78845f3b4591396710df3b165bc8d11 - libv4lconvert/mr97310a.c
3e8e6c1fb85e3c4b58c4e9b2b0a223ddc793edcb - libv4lconvert/libv4lconvert.pc.in
b2c19c2eac71d39d3fb883cdc159a69c2afa8fd6 - libv4lconvert/ov511-decomp.c
f08c902ecd48c2739956606b502fc0b8e4007703 - libv4lconvert/crop.c
1949e23fe99ccd0a05dcd084848f6d38b0af7ab6 - libv4lconvert/hm12.c
1d9c446cd8a232da87bd79acebc93e018ec72499 - libv4lconvert/jidctflt.c
8b7644ac3d5c4161cfb6dcc2a34013f4c379c665 - libv4lconvert/libv4lconvert.export
22fd03618c218ae14ba59a5aab5f30b0acd2b6ea - libv4lconvert/Makefile
ff7444c48a8da88f8a466cfb138e30e585828cb3 - libv4lconvert/jl2005bcd.c
033894511bd7e8a374a52486889658faa17918c4 - libv4lconvert/flip.c
25130d299463897a09e8b9adf72389dac2e89fa4 - libv4lconvert/tinyjpeg-internal.h
cc3f3e94a21795990610e63887c30528bde7b42e - libv4lconvert/bayer.c
1f1d1e05443c4b824cd697c0ce5efa9ea1277964 - libv4lconvert/ov518-decomp.c
3271d74d02e2f33c16e3e50aeb1268eb9c440782 - libv4lconvert/rgbyuv.c
725c9b8d0bfadba566cf200921e602961cb12705 - libv4lconvert/spca561-decompress.c
84c9c3812d4b5f237c8cd616d37fc1161a212acc - libv4lconvert/se401.c
b694b6348e035b3da880824c2c2768145c9b5199 - libv4lconvert/jpeg_memsrcdest.c
66dd7958319442bd52ba40ede28fbfe31bb4e074 - libv4lconvert/cpia1.c
6ad4947dca51a7e67e056561cdb445d6c354d23c - libv4lconvert/libv4lconvert.c
cc8982bb6f753249181c715fe6430ffefc78c23b - libv4lconvert/stv0680.c
72953a5a3a56b0188d35f49246356b9c8c35756c - libv4lconvert/helper.c
db3c69c666e451c5d4ef6d1b5a3117f4b128baa4 - libv4lconvert/libv4lconvert-priv.h
803c4d0b9364050eda163452b8792e62e221ab6d - libv4lconvert/tinyjpeg.h
fb3344cfa8df97688332ee4fd3b17968437e8ad5 - libv4lconvert/helper-funcs.h
60e29f95ea52df4407d771330897813cdb38340f - libv4lconvert/libv4lsyscall-priv.h
fbbffd8182b4fe2e85289b6e784f70cba7ea7b1d - libv4lconvert/sq905c.c
4eff5c1a5e0b99ce4d6e9aa63645d9628467fdc3 - libv4lconvert/sn9c2028-decomp.c
22a502c238e48f4b939c81de41feccfc7c366766 - libv4lconvert/Makefile.dGPU
d6c1aba89bbcb6fef46a6f22b7ea01025435c44d - libv4lconvert/Makefile.am
be9e3bf3d7d1086b6eed0c1bf2f574c2b1737c00 - libv4lconvert/tinyjpeg.c
f061a4e0e45ca8e0dbab630dd477e19a6c915fda - libv4lconvert/spca501.c
07f8e7c84abfbbe76d49d8bfd1f4eae6ea39a90b - libv4lconvert/jpgl.c
1e08fb01a598d71e3fc69656c4f2291f7dc13105 - libv4lconvert/control/libv4lcontrol.h
70f4992835e964b2698473971904375333e3659b - libv4lconvert/control/libv4lcontrol-priv.h
19a7fd04cdeba61172f281806d030472dee79fcd - libv4lconvert/control/libv4lcontrol.c
0390d660eb130f0e580832bcf8ad5069010d2696 - libv4lconvert/processing/libv4lprocessing.h
7da402829dbff238ca6ac829c037a85476185db6 - libv4lconvert/processing/autogain.c
a54c2cb0439e606af01d0b4f02704f411819d98c - libv4lconvert/processing/libv4lprocessing.c
dae9c69b7f019d7d4494cd56e2cf757e8510824a - libv4lconvert/processing/whitebalance.c
33ab91b54108e8c24cbb80c5c335d96391d440b2 - libv4lconvert/processing/libv4lprocessing-priv.h
ebf12bcf99f35fb9c400b04a1439e68598268249 - libv4lconvert/processing/gamma.c
d1f2b6f016cfb90c616d848418feb915e3737fa7 - libv4l2/libv4l2.c
752cb342c44989a8c172e3280e220a6fa2ec86b5 - libv4l2/Makefile
7fa618184ff89737d13164be0b79e227d81f398c - libv4l2/log.c
9d456d1772885d900865a8958c0291e13d509de5 - libv4l2/v4l2convert.c
cbcee4426c19c168c6f49d04af3a0b2e30c0b681 - libv4l2/libv4l2.pc.in
766aaca553b0166eb736557e44ad42b69464aa53 - libv4l2/libv4l2.export
2542aabb7fbff4b1a09faaadec6006c4410a6d10 - libv4l2/libv4l2-priv.h
4ba98a607592ed0b8327b387af354544c65c9b67 - libv4l2/v4l2-plugin-android.c
ffecae84262f548deac1da0fa51f1aba6b6f96a0 - libv4l2/Makefile.dGPU
8e335567bf404eeb3d180dd384309f687f2ab944 - libv4l2/Makefile.am
e6516370c43e4869e05a540d2e4ef584ac64890a - libv4l2/v4l2-plugin.c

Change-Id: Ie5623d7d9a7af2fb05dcb8167e9830c3ef710cbe
This commit is contained in:
svcmobrel-release
2024-02-26 22:27:03 -08:00
parent e003da6fcd
commit b29ee1e5b4
111 changed files with 30910 additions and 0 deletions

61
libv4l2/Makefile Normal file
View File

@@ -0,0 +1,61 @@
###############################################################################
#
# Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.
#
###############################################################################
SO_NAME := libnvv4l2.so
SRCS := libv4l2.c log.c v4l2convert.c v4l2-plugin.c
INCLUDES += -I./ -I../include
OBJS := $(SRCS:.c=.o)
CFLAGS := -fPIC
MACHINE = $(shell uname -m)
ifeq ($(MACHINE),x86_64)
CFLAGS += -DLIBV4L2_PLUGIN_DIR_PATH_X86
DEST_DIR ?= /opt/nvidia/deepstream/deepstream-4.0/lib/
SYM_LINK_DIR = $(DEST_DIR)
else
DEST_DIR ?= /usr/lib/$(MACHINE)-linux-gnu/tegra
SYM_LINK_DIR = $(shell realpath $(DEST_DIR)/..)
endif
LDFLAGS := -L$(DEST_DIR) -Wl,-soname,libv4l2.so.0
LIBS := -lv4lconvert -ldl
all: $(SO_NAME)
%.o: %.c
$(CC) -c $< $(CFLAGS) $(INCLUDES) -o $@
$(SO_NAME): $(OBJS)
$(CC) -shared -o $(SO_NAME) $(OBJS) $(LIBS) $(LDFLAGS)
.PHONY: install
install: $(SO_NAME)
cp -vp $(SO_NAME) $(DEST_DIR)
if [ "$(MACHINE)" = "aarch64" ]; then \
ln -sf tegra/$(SO_NAME) $(SYM_LINK_DIR)/libv4l2.so.0.0.999999 ; \
else \
ln -sf $(SO_NAME) $(SYM_LINK_DIR)/libv4l2.so.0.0.999999 ; \
fi
ln -sf libv4l2.so.0.0.999999 \
$(SYM_LINK_DIR)/libv4l2.so
ln -sf libv4l2.so.0.0.999999 \
${SYM_LINK_DIR}/libv4l2.so.0
.PHONY: clean
clean:
rm -rf $(OBJS) $(SO_NAME)

28
libv4l2/Makefile.am Normal file
View File

@@ -0,0 +1,28 @@
if WITH_LIBV4L
lib_LTLIBRARIES = libv4l2.la
include_HEADERS = ../include/libv4l2.h ../include/libv4l-plugin.h
pkgconfig_DATA = libv4l2.pc
LIBV4L2_VERSION = -version-info 0
if WITH_V4L_WRAPPERS
libv4l2priv_LTLIBRARIES = v4l2convert.la
install-exec-hook:
$(MKDIR_P) $(DESTDIR)/$(libdir)
(cd $(DESTDIR)/$(libdir) && rm -f v4l2convert.so && $(LN_S) $(libv4l2subdir)/v4l2convert.so v4l2convert.so)
endif
else
noinst_LTLIBRARIES = libv4l2.la
endif
libv4l2_la_SOURCES = libv4l2.c v4l2-plugin.c log.c libv4l2-priv.h
libv4l2_la_CPPFLAGS = $(CFLAG_VISIBILITY) $(ENFORCE_LIBV4L_STATIC)
libv4l2_la_LDFLAGS = $(LIBV4L2_VERSION) -lpthread $(DLOPEN_LIBS) $(ENFORCE_LIBV4L_STATIC)
libv4l2_la_LIBADD = ../libv4lconvert/libv4lconvert.la
v4l2convert_la_SOURCES = v4l2convert.c
v4l2convert_la_LIBADD = libv4l2.la
v4l2convert_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
v4l2convert_la_LIBTOOLFLAGS = --tag=disable-static
EXTRA_DIST = Android.mk v4l2-plugin-android.c

36
libv4l2/Makefile.dGPU Normal file
View File

@@ -0,0 +1,36 @@
###############################################################################
#
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.
#
###############################################################################
CC:=gcc
TARGET_NAME:= libnvv4l2.so
SRCS := libv4l2.c log.c v4l2convert.c v4l2-plugin.c
INC_PATHS := ./ ../include ../../include
CFLAGS := -fPIC
CFLAGS += -DLIBV4L2_PLUGIN_DIR_PATH_X86
IGNORE_DS_PACKAGE_NAMING:=1
LDFLAGS:= -shared
LIBS:= -lv4lconvert -ldl -Wl,-soname,libv4l2.so.0
#IS_V4L2_LIB:=1
PACKAGE_BINARY_IN_DS:=1
BUILD_DIR:=../../../../deepstream/sdk/build/libs/libv4l/
include ../../../../deepstream/sdk/Rules.mk
install::
ln -sf $(INSTALL_DIR)/$(TARGET_NAME) /usr/lib/x86_64-linux-gnu/libv4l2.so.0.0.99999
ldconfig

118
libv4l2/libv4l2-priv.h Normal file
View File

@@ -0,0 +1,118 @@
/*
# (C) 2008 Hans de Goede <hdegoede@redhat.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License, version 2.1,
# as published by the Free Software Foundation.
#
# 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*/
#ifndef __LIBV4L2_PRIV_H
#define __LIBV4L2_PRIV_H
#include <stdio.h>
#include <pthread.h>
#include <libv4lconvert.h> /* includes videodev2.h for us */
#include "../libv4lconvert/libv4lsyscall-priv.h"
#define V4L2_MAX_DEVICES 1024
/* Warning when making this larger the frame_queued and frame_mapped members of
the v4l2_dev_info struct can no longer be a bitfield, so the code needs to
be adjusted! */
#define V4L2_MAX_NO_FRAMES 32
#define V4L2_DEFAULT_NREADBUFFERS 4
#define V4L2_IGNORE_FIRST_FRAME_ERRORS 3
#define V4L2_DEFAULT_FPS 30
#define V4L2_LOG_ERR(...) \
do { \
if (v4l2_log_file) { \
fprintf(v4l2_log_file, "libv4l2: error " __VA_ARGS__); \
fflush(v4l2_log_file); \
} else \
fprintf(stderr, "libv4l2: error " __VA_ARGS__); \
} while (0)
#define V4L2_PERROR(format, ...) \
do { \
if (errno == ENODEV) { \
devices[index].gone = 1;\
break; \
} \
V4L2_LOG_ERR(format ": %s\n", ##__VA_ARGS__, strerror(errno)); \
} while (0)
#define V4L2_LOG_WARN(...) \
do { \
if (v4l2_log_file) { \
fprintf(v4l2_log_file, "libv4l2: warning " __VA_ARGS__); \
fflush(v4l2_log_file); \
} else \
fprintf(stderr, "libv4l2: warning " __VA_ARGS__); \
} while (0)
#define V4L2_LOG(...) \
do { \
if (v4l2_log_file) { \
fprintf(v4l2_log_file, "libv4l2: " __VA_ARGS__); \
fflush(v4l2_log_file); \
} \
} while (0)
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
struct v4l2_dev_info {
int fd;
int flags;
int open_count;
int gone; /* Set to 1 when a device is detached (ENODEV encountered) */
long page_size;
/* actual format of the cam */
struct v4l2_format src_fmt;
/* fmt as seen by the application (iow after conversion) */
struct v4l2_format dest_fmt;
pthread_mutex_t stream_lock;
unsigned int no_frames;
unsigned int nreadbuffers;
int fps;
int first_frame;
struct v4lconvert_data *convert;
unsigned char *convert_mmap_buf;
size_t convert_mmap_buf_size;
size_t convert_mmap_frame_size;
/* Frame bookkeeping is only done when in read or mmap-conversion mode */
unsigned char *frame_pointers[V4L2_MAX_NO_FRAMES];
int frame_sizes[V4L2_MAX_NO_FRAMES];
int frame_queued; /* 1 status bit per frame */
int frame_info_generation;
/* mapping tracking of our fake (converting mmap) frame buffers */
unsigned char frame_map_count[V4L2_MAX_NO_FRAMES];
/* buffer when doing conversion and using read() for read() */
int readbuf_size;
unsigned char *readbuf;
/* plugin info */
void *plugin_library;
void *dev_ops_priv;
const struct libv4l_dev_ops *dev_ops;
};
/* From v4l2-plugin.c */
void v4l2_plugin_init(int fd, void **plugin_lib_ret, void **plugin_priv_ret,
const struct libv4l_dev_ops **dev_ops_ret);
void v4l2_plugin_cleanup(void *plugin_lib, void *plugin_priv,
const struct libv4l_dev_ops *dev_ops);
/* From log.c */
extern const char *v4l2_ioctls[];
void v4l2_log_ioctl(unsigned long int request, void *arg, int result);
#endif

1781
libv4l2/libv4l2.c Normal file
View File

File diff suppressed because it is too large Load Diff

13
libv4l2/libv4l2.export Normal file
View File

@@ -0,0 +1,13 @@
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
v4l2_close
v4l2_dup
v4l2_fd_open
v4l2_get_control
v4l2_ioctl
v4l2_log_file
v4l2_mmap
v4l2_munmap
v4l2_open
v4l2_read
v4l2_set_control
v4l2_write

12
libv4l2/libv4l2.pc.in Normal file
View File

@@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
includedir=@includedir@
libdir=@libdir@
Name: libv4l2
Description: v4l2 device access library
Version: @PACKAGE_VERSION@
Requires.private: libv4lconvert
Libs: -L${libdir} -lv4l2
Libs.private: -lpthread
Cflags: -I${includedir}

259
libv4l2/log.c Normal file
View File

@@ -0,0 +1,259 @@
/*
# (C) 2008 Elmar Kleijn <elmar_kleijn@hotmail.com>
# (C) 2008 Sjoerd Piepenbrink <need4weed@gmail.com>
# (C) 2008 Hans de Goede <hdegoede@redhat.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License, version 2.1,
# as published by the Free Software Foundation.
#
# 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*/
#ifdef ANDROID
#include <android-config.h>
#else
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../libv4lconvert/libv4lsyscall-priv.h"
#include <linux/videodev2.h>
#include "libv4l2.h"
#include "libv4l2-priv.h"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
FILE *v4l2_log_file = NULL;
const char *v4l2_ioctls[] = {
/* start v4l2 ioctls */
[_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP",
[_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED",
[_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
[_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
[_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
[_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
[_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
[_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
[_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF",
[_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY",
[_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF",
[_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF",
[_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON",
[_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF",
[_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM",
[_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM",
[_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD",
[_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD",
[_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD",
[_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT",
[_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL",
[_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL",
[_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER",
[_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER",
[_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO",
[_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO",
[_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL",
[_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU",
[_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT",
[_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT",
[_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT",
[_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT",
[_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT",
[_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT",
[_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT",
[_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR",
[_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR",
[_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY",
[_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY",
[_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP",
[_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP",
[_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP",
[_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP",
[_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP",
[_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD",
[_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT",
[_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO",
[_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT",
[_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY",
[_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY",
[_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
[_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS",
[_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS",
[_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS",
[_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS",
[_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES",
[_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS",
[_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX",
[_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
[_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",
[_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
[_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
[_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK",
[_IOC_NR(VIDIOC_S_DV_TIMINGS)] = "VIDIOC_S_DV_TIMINGS",
[_IOC_NR(VIDIOC_G_DV_TIMINGS)] = "VIDIOC_G_DV_TIMINGS",
[_IOC_NR(VIDIOC_DQEVENT)] = "VIDIOC_DQEVENT",
[_IOC_NR(VIDIOC_SUBSCRIBE_EVENT)] = "VIDIOC_SUBSCRIBE_EVENT",
[_IOC_NR(VIDIOC_UNSUBSCRIBE_EVENT)] = "VIDIOC_UNSUBSCRIBE_EVENT",
[_IOC_NR(VIDIOC_CREATE_BUFS)] = "VIDIOC_CREATE_BUFS",
[_IOC_NR(VIDIOC_PREPARE_BUF)] = "VIDIOC_PREPARE_BUF",
[_IOC_NR(VIDIOC_G_SELECTION)] = "VIDIOC_G_SELECTION",
[_IOC_NR(VIDIOC_S_SELECTION)] = "VIDIOC_S_SELECTION",
[_IOC_NR(VIDIOC_DECODER_CMD)] = "VIDIOC_DECODER_CMD",
[_IOC_NR(VIDIOC_TRY_DECODER_CMD)] = "VIDIOC_TRY_DECODER_CMD",
[_IOC_NR(VIDIOC_ENUM_DV_TIMINGS)] = "VIDIOC_ENUM_DV_TIMINGS",
[_IOC_NR(VIDIOC_QUERY_DV_TIMINGS)] = "VIDIOC_QUERY_DV_TIMINGS",
[_IOC_NR(VIDIOC_DV_TIMINGS_CAP)] = "VIDIOC_DV_TIMINGS_CAP",
[_IOC_NR(VIDIOC_ENUM_FREQ_BANDS)] = "VIDIOC_ENUM_FREQ_BANDS",
[_IOC_NR(VIDIOC_DBG_G_CHIP_INFO)] = "VIDIOC_DBG_G_CHIP_INFO",
};
void v4l2_log_ioctl(unsigned long int request, void *arg, int result)
{
const char *ioctl_str;
char buf[40];
int saved_errno = errno;
if (!v4l2_log_file)
return;
if (_IOC_TYPE(request) == 'V' && _IOC_NR(request) < ARRAY_SIZE(v4l2_ioctls))
ioctl_str = v4l2_ioctls[_IOC_NR(request)];
else {
snprintf(buf, sizeof(buf), "unknown request: %c %d",
(int)_IOC_TYPE(request), (int)_IOC_NR(request));
ioctl_str = buf;
}
fprintf(v4l2_log_file, "request == %s\n", ioctl_str);
switch (request) {
case VIDIOC_ENUM_FMT: {
struct v4l2_fmtdesc *fmt = arg;
fprintf(v4l2_log_file, " index: %u, description: %s\n",
fmt->index, (result < 0) ? "" : (const char *)fmt->description);
break;
}
case VIDIOC_G_FMT:
case VIDIOC_S_FMT:
case VIDIOC_TRY_FMT: {
struct v4l2_format *fmt = arg;
int pixfmt = fmt->fmt.pix.pixelformat;
if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
fprintf(v4l2_log_file, " pixelformat: %c%c%c%c %ux%u\n",
pixfmt & 0xff,
(pixfmt >> 8) & 0xff,
(pixfmt >> 16) & 0xff,
pixfmt >> 24,
fmt->fmt.pix.width,
fmt->fmt.pix.height);
fprintf(v4l2_log_file, " field: %d bytesperline: %d imagesize: %d\n",
(int)fmt->fmt.pix.field, (int)fmt->fmt.pix.bytesperline,
(int)fmt->fmt.pix.sizeimage);
fprintf(v4l2_log_file, " colorspace: %d, priv: %x\n",
(int)fmt->fmt.pix.colorspace, (int)fmt->fmt.pix.priv);
} else {
fprintf(v4l2_log_file, " type: %d\n", (int)fmt->type);
}
break;
}
case VIDIOC_REQBUFS: {
struct v4l2_requestbuffers *req = arg;
fprintf(v4l2_log_file, " count: %u type: %d memory: %d\n",
req->count, (int)req->type, (int)req->memory);
break;
}
case VIDIOC_DQBUF: {
struct v4l2_buffer *buf = arg;
fprintf(v4l2_log_file, " timestamp %ld.%06ld\n",
(long)buf->timestamp.tv_sec,
(long)buf->timestamp.tv_usec);
break;
}
case VIDIOC_ENUM_FRAMESIZES: {
struct v4l2_frmsizeenum *frmsize = arg;
int pixfmt = frmsize->pixel_format;
fprintf(v4l2_log_file, " index: %u pixelformat: %c%c%c%c\n",
frmsize->index,
pixfmt & 0xff,
(pixfmt >> 8) & 0xff,
(pixfmt >> 16) & 0xff,
pixfmt >> 24);
switch (frmsize->type) {
case V4L2_FRMSIZE_TYPE_DISCRETE:
fprintf(v4l2_log_file, " %ux%u\n", frmsize->discrete.width,
frmsize->discrete.height);
break;
case V4L2_FRMSIZE_TYPE_CONTINUOUS:
case V4L2_FRMSIZE_TYPE_STEPWISE:
fprintf(v4l2_log_file, " %ux%u -> %ux%u\n",
frmsize->stepwise.min_width, frmsize->stepwise.min_height,
frmsize->stepwise.max_width, frmsize->stepwise.max_height);
break;
}
break;
}
case VIDIOC_ENUM_FRAMEINTERVALS: {
struct v4l2_frmivalenum *frmival = arg;
int pixfmt = frmival->pixel_format;
fprintf(v4l2_log_file, " index: %u pixelformat: %c%c%c%c %ux%u:\n",
frmival->index,
pixfmt & 0xff,
(pixfmt >> 8) & 0xff,
(pixfmt >> 16) & 0xff,
pixfmt >> 24,
frmival->width,
frmival->height);
switch (frmival->type) {
case V4L2_FRMIVAL_TYPE_DISCRETE:
fprintf(v4l2_log_file, " %u/%u\n", frmival->discrete.numerator,
frmival->discrete.denominator);
break;
case V4L2_FRMIVAL_TYPE_CONTINUOUS:
case V4L2_FRMIVAL_TYPE_STEPWISE:
fprintf(v4l2_log_file, " %u/%u -> %u/%u\n",
frmival->stepwise.min.numerator,
frmival->stepwise.min.denominator,
frmival->stepwise.max.numerator,
frmival->stepwise.max.denominator);
break;
}
break;
}
case VIDIOC_G_PARM:
case VIDIOC_S_PARM: {
struct v4l2_streamparm *parm = arg;
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
break;
if (parm->parm.capture.capability & V4L2_CAP_TIMEPERFRAME)
fprintf(v4l2_log_file, "timeperframe: %u/%u\n",
parm->parm.capture.timeperframe.numerator,
parm->parm.capture.timeperframe.denominator);
break;
}
}
if (result < 0)
fprintf(v4l2_log_file, "result == %d (%s)\n", result, strerror(saved_errno));
else
fprintf(v4l2_log_file, "result == %d\n", result);
fflush(v4l2_log_file);
}

View File

@@ -0,0 +1,151 @@
/*
* Copyright (C) 2010 Nokia Corporation <multimedia@maemo.org>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1,
* as published by the Free Software Foundation.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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
*/
#ifdef ANDROID
#include <android-config.h>
#else
#include <config.h>
#endif
#include <stdarg.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include "libv4l2.h"
#include "libv4l2-priv.h"
#include "libv4l-plugin.h"
/* libv4l plugin support:
it is provided by functions v4l2_plugin_[open,close,etc].
When open() is called libv4l dlopens files in /usr/lib[64]/libv4l/plugins
1 at a time and call open callback passing through the applications
parameters unmodified.
If a plugin is relevant for the specified device node, it can indicate so
by returning a value other then -1 (the actual file descriptor).
As soon as a plugin returns another value then -1 plugin loading stops and
information about it (fd and corresponding library handle) is stored. For
each function v4l2_[ioctl,read,close,etc] is called corresponding
v4l2_plugin_* function which looks if there is loaded plugin for that file
and call it's callbacks.
v4l2_plugin_* function indicates by it's first argument if plugin was used,
and if it was not then v4l2_* functions proceed with their usual behavior.
*/
/* list of plugin search paths */
static const char *g_plugin_search_paths[] = {
"/system/lib/libv4l/plugins",
"/vendor/lib/libv4l/plugins",
NULL /* list terminator */
};
void v4l2_plugin_init(int fd, void **plugin_lib_ret, void **plugin_priv_ret,
const struct libv4l_dev_ops **dev_ops_ret)
{
char *error;
void *plugin_library = NULL;
const struct libv4l_dev_ops *libv4l2_plugin = NULL;
DIR *plugin_dir = NULL;
struct dirent *entry;
char *suffix = NULL;
int length, i;
char filename[256];
/* initialize output params */
*dev_ops_ret = v4lconvert_get_default_dev_ops();
*plugin_lib_ret = NULL;
*plugin_priv_ret = NULL;
/* read the plugin directory for "*.so" files */
for (i = 0; g_plugin_search_paths[i] != NULL; i++) {
plugin_dir = opendir(g_plugin_search_paths[i]);
if (plugin_dir == NULL) {
V4L2_LOG_ERR("PLUGIN: opening plugin directory (%s) failed\n",
g_plugin_search_paths[i]);
continue;
}
while ((entry = readdir(plugin_dir))) {
/* get last 3 letter suffix from the filename */
length = strlen(entry->d_name);
if (length > 3)
suffix = entry->d_name + (length - 3);
if (!suffix || strcmp(suffix, ".so")) {
suffix = NULL; /* reset for next iteration */
continue;
}
/* load library and get desired symbol */
sprintf(filename, "%s/%s", g_plugin_search_paths[i], entry->d_name);
V4L2_LOG("PLUGIN: dlopen(%s);\n", filename);
plugin_library = dlopen(filename, RTLD_LAZY);
if (!plugin_library)
continue;
dlerror(); /* Clear any existing error */
libv4l2_plugin = (struct libv4l_dev_ops *)
dlsym(plugin_library, "libv4l2_plugin");
error = dlerror();
if (error != NULL) {
V4L2_LOG_ERR("PLUGIN: dlsym failed: %s\n", error);
dlclose(plugin_library);
continue;
}
if (!libv4l2_plugin->init ||
!libv4l2_plugin->close ||
!libv4l2_plugin->ioctl) {
V4L2_LOG("PLUGIN: does not have all mandatory ops\n");
dlclose(plugin_library);
continue;
}
*plugin_priv_ret = libv4l2_plugin->init(fd);
if (!*plugin_priv_ret) {
V4L2_LOG("PLUGIN: plugin open() returned NULL\n");
dlclose(plugin_library);
continue;
}
/* exit loop when a suitable plugin is found */
*plugin_lib_ret = plugin_library;
*dev_ops_ret = libv4l2_plugin;
break;
}
closedir(plugin_dir);
/* exit loop when a suitable plugin is found */
if (*plugin_lib_ret && *plugin_priv_ret && *dev_ops_ret)
break;
}
}
void v4l2_plugin_cleanup(void *plugin_lib, void *plugin_priv,
const struct libv4l_dev_ops *dev_ops)
{
if (plugin_lib) {
dev_ops->close(plugin_priv);
dlclose(plugin_lib);
}
}

120
libv4l2/v4l2-plugin.c Normal file
View File

@@ -0,0 +1,120 @@
/*
* Copyright (C) 2010 Nokia Corporation <multimedia@maemo.org>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1,
* as published by the Free Software Foundation.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 <config.h>
#include <stdarg.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <glob.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "libv4l2.h"
#include "libv4l2-priv.h"
#include "libv4l-plugin.h"
/* libv4l plugin support:
it is provided by functions v4l2_plugin_[open,close,etc].
When open() is called libv4l dlopens files in /usr/lib[64]/libv4l/plugins
1 at a time and call open callback passing through the applications
parameters unmodified.
If a plugin is relevant for the specified device node, it can indicate so
by returning a value other then -1 (the actual file descriptor).
As soon as a plugin returns another value then -1 plugin loading stops and
information about it (fd and corresponding library handle) is stored. For
each function v4l2_[ioctl,read,close,etc] is called corresponding
v4l2_plugin_* function which looks if there is loaded plugin for that file
and call it's callbacks.
v4l2_plugin_* function indicates by it's first argument if plugin was used,
and if it was not then v4l2_* functions proceed with their usual behavior.
*/
#define PLUGINS_PATTERN LIBV4L2_PLUGIN_DIR "/*.so"
void v4l2_plugin_init(int fd, void **plugin_lib_ret, void **plugin_priv_ret,
const struct libv4l_dev_ops **dev_ops_ret)
{
char *error;
int glob_ret;
uint32_t i;
void *plugin_library = NULL;
const struct libv4l_dev_ops *libv4l2_plugin = NULL;
glob_t globbuf;
*dev_ops_ret = v4lconvert_get_default_dev_ops();
*plugin_lib_ret = NULL;
*plugin_priv_ret = NULL;
glob_ret = glob(PLUGINS_PATTERN, 0, NULL, &globbuf);
if (glob_ret == GLOB_NOSPACE)
return;
if (glob_ret == GLOB_ABORTED || glob_ret == GLOB_NOMATCH)
goto leave;
for (i = 0; i < globbuf.gl_pathc; i++) {
V4L2_LOG("PLUGIN: dlopen(%s);\n", globbuf.gl_pathv[i]);
plugin_library = dlopen(globbuf.gl_pathv[i], RTLD_LAZY);
if (!plugin_library)
continue;
dlerror(); /* Clear any existing error */
libv4l2_plugin = (struct libv4l_dev_ops *)
dlsym(plugin_library, "libv4l2_plugin");
error = dlerror();
if (error != NULL) {
V4L2_LOG_ERR("PLUGIN: dlsym failed: %s\n", error);
dlclose(plugin_library);
continue;
}
if (!libv4l2_plugin->init ||
!libv4l2_plugin->close ||
!libv4l2_plugin->ioctl) {
V4L2_LOG("PLUGIN: does not have all mandatory ops\n");
dlclose(plugin_library);
continue;
}
*plugin_priv_ret = libv4l2_plugin->init(fd);
if (!*plugin_priv_ret) {
V4L2_LOG("PLUGIN: plugin open() returned NULL\n");
dlclose(plugin_library);
continue;
}
*plugin_lib_ret = plugin_library;
*dev_ops_ret = libv4l2_plugin;
break;
}
leave:
globfree(&globbuf);
}
void v4l2_plugin_cleanup(void *plugin_lib, void *plugin_priv,
const struct libv4l_dev_ops *dev_ops)
{
if (plugin_lib) {
dev_ops->close(plugin_priv);
dlclose(plugin_lib);
}
}

167
libv4l2/v4l2convert.c Normal file
View File

@@ -0,0 +1,167 @@
/*
# open/close/ioctl/mmap/munmap library call wrapper doing format conversion
# for v4l2 applications which want to be able to simply capture bgr24 / yuv420
# from v4l2 devices with more exotic frame formats.
# (C) 2008 Hans de Goede <hdegoede@redhat.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License, version 2.1,
# as published by the Free Software Foundation.
#
# 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*/
/* prevent GCC 4.7 inlining error */
#undef _FORTIFY_SOURCE
#define _LARGEFILE64_SOURCE 1
#ifdef ANDROID
#include <android-config.h>
#else
#include <config.h>
#endif
#include <stdarg.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <linux/videodev2.h>
#include <libv4l2.h>
#include "../libv4lconvert/libv4lsyscall-priv.h"
/* Check that open/read/mmap is not a define */
#if defined open || defined read || defined mmap
#error open/read/mmap is a prepocessor macro !!
#endif
#if HAVE_VISIBILITY
#define LIBV4L_PUBLIC __attribute__ ((visibility("default")))
#else
#define LIBV4L_PUBLIC
#endif
LIBV4L_PUBLIC int open(const char *file, int oflag, ...)
{
int fd;
int v4l_device = 0;
/* check if we're opening a video4linux2 device */
if (!strncmp(file, "/dev/video", 10) || !strncmp(file, "/dev/v4l/", 9)) {
/* Some apps open the device read-only, but we need rw rights as the
buffers *MUST* be mapped rw */
oflag = (oflag & ~O_ACCMODE) | O_RDWR;
v4l_device = 1;
}
/* original open code */
if (oflag & O_CREAT) {
va_list ap;
mode_t mode;
va_start(ap, oflag);
mode = va_arg(ap, PROMOTED_MODE_T);
fd = SYS_OPEN(file, oflag, mode);
va_end(ap);
} else {
fd = SYS_OPEN(file, oflag, 0);
}
/* end of original open code */
if (fd == -1 || !v4l_device)
return fd;
/* Try to Register with libv4l2 (in case of failure pass the fd to the
application as is) */
v4l2_fd_open(fd, 0);
return fd;
}
#if defined(linux) && defined(__GLIBC__)
LIBV4L_PUBLIC int open64(const char *file, int oflag, ...)
{
int fd;
/* original open code */
if (oflag & O_CREAT) {
va_list ap;
mode_t mode;
va_start(ap, oflag);
mode = va_arg(ap, PROMOTED_MODE_T);
fd = open(file, oflag | O_LARGEFILE, mode);
va_end(ap);
} else {
fd = open(file, oflag | O_LARGEFILE);
}
/* end of original open code */
return fd;
}
#endif
#ifndef ANDROID
LIBV4L_PUBLIC int close(int fd)
{
return v4l2_close(fd);
}
LIBV4L_PUBLIC int dup(int fd)
{
return v4l2_dup(fd);
}
#ifdef HAVE_POSIX_IOCTL
LIBV4L_PUBLIC int ioctl(int fd, int request, ...)
#else
LIBV4L_PUBLIC int ioctl(int fd, unsigned long int request, ...)
#endif
{
void *arg;
va_list ap;
va_start(ap, request);
arg = va_arg(ap, void *);
va_end(ap);
return v4l2_ioctl(fd, request, arg);
}
LIBV4L_PUBLIC ssize_t read(int fd, void *buffer, size_t n)
{
return v4l2_read(fd, buffer, n);
}
LIBV4L_PUBLIC void *mmap(void *start, size_t length, int prot, int flags, int fd,
off_t offset)
{
return v4l2_mmap(start, length, prot, flags, fd, offset);
}
#if defined(linux) && defined(__GLIBC__)
LIBV4L_PUBLIC void *mmap64(void *start, size_t length, int prot, int flags, int fd,
off64_t offset)
{
return v4l2_mmap(start, length, prot, flags, fd, offset);
}
#endif
LIBV4L_PUBLIC int munmap(void *start, size_t length)
{
return v4l2_munmap(start, length);
}
#endif