31
31
* ------------------------------------------
32
32
* begin : written in 2008 by Matthias Schneider
33
33
* copyright : (c) 2008 by Matthias Schneider
34
* description : Used to detect the names and supported V4L
35
* interfaces of a new video4linux device (this
34
* description : Used to detect the names and supported V4L
35
* interfaces of a new video4linux device (this
36
36
* should really be in HALd itself.
40
#include <fcntl.h> // for open()
41
#include <unistd.h> // for read(), write(), close()
40
#include <fcntl.h> // for open()
41
#include <unistd.h> // for read(), write(), close()
42
42
#include <sys/ioctl.h> // for ioctl()
43
43
#include <stdlib.h> // for free(), malloc()
44
44
#include <string.h> // for strlen()
46
48
#include <linux/videodev.h>
50
#include <linux/videodev2.h>
51
#include <libv4l1-videodev.h>
48
54
int v4l_get_device_names (const char* device, char** v4l1_name, char** v4l2_name) {
50
56
unsigned ret = 0; // Device not valid
55
61
if((fp = open(device, O_RDONLY)) == 0) {
56
62
return -1; // Unable to open device
59
65
struct video_capability v4l1_caps;
60
66
if (ioctl(fp, VIDIOCGCAP, &v4l1_caps) >= 0 && (v4l1_caps.type & VID_TYPE_CAPTURE) != 0) {