1 /* 2 # (C) 2008 Hans de Goede <hdegoede@redhat.com> 3 4 # This program is free software; you can redistribute it and/or modify 5 # it under the terms of the GNU Lesser General Public License as published by 6 # the Free Software Foundation; either version 2.1 of the License, or 7 # (at your option) any later version. 8 # 9 # This program is distributed in the hope that it will be useful, 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # GNU Lesser General Public License for more details. 13 # 14 # You should have received a copy of the GNU Lesser General Public License 15 # along with this program; if not, write to the Free Software 16 # Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA 17 */ 18 19 #ifndef __LIBV4L1_H 20 #define __LIBV4L1_H 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif /* __cplusplus */ 25 26 #include <stdio.h> 27 #include <stdint.h> 28 #include <unistd.h> 29 #include <libv4l1-videodev.h> 30 31 #if HAVE_VISIBILITY 32 #define LIBV4L_PUBLIC __attribute__ ((visibility("default"))) 33 #else 34 #define LIBV4L_PUBLIC 35 #endif 36 37 /* Point this to a FILE opened for writing when you want to log error and 38 status messages to a file, when NULL errors will get send to stderr */ 39 LIBV4L_PUBLIC extern FILE *v4l1_log_file; 40 41 /* Just like your regular open/close/etc, except that when opening a v4l2 42 capture only device, full v4l1 emulation is done including emulating the 43 often not implemented in v4l2 drivers CGMBUF ioctl and v4l1 style mmap call 44 in userspace. 45 46 Format conversion is done if necessary when capturing. That is if you 47 (try to) set a capture format which is not supported by the cam, but is 48 supported by libv4lconvert then SPICT will succeed and on SYNC / read the 49 data will be converted for you and returned in the request format. 50 51 Note that currently libv4l1 depends on the kernel v4l1 compatibility layer 52 for: 1) Devices which are not capture only, 2) Emulation of many basic 53 v4l1 ioctl's which require no driver specific handling. 54 55 Note that no functionality is added to v4l1 devices, so if for example an 56 obscure v4l1 device is opened which only supports some weird capture format 57 then libv4l1 will not be of any help (in this case it would be best to get 58 the driver converted to v4l2, as v4l2 has been designed to include weird 59 capture formats, like hw specific bayer compression methods). 60 */ 61 62 LIBV4L_PUBLIC int v4l1_open(const char *file, int oflag, ...); 63 LIBV4L_PUBLIC int v4l1_close(int fd); 64 LIBV4L_PUBLIC int v4l1_dup(int fd); 65 LIBV4L_PUBLIC int v4l1_ioctl(int fd, unsigned long int request, ...); 66 LIBV4L_PUBLIC ssize_t v4l1_read(int fd, void *buffer, size_t n); 67 LIBV4L_PUBLIC void *v4l1_mmap(void *start, size_t length, int prot, int flags, 68 int fd, int64_t offset); 69 LIBV4L_PUBLIC int v4l1_munmap(void *_start, size_t length); 70 71 #ifdef __cplusplus 72 } 73 #endif /* __cplusplus */ 74 75 #endif 76