1
/* v4l2-api: low-level wrapper around v4l2 devices
3
* Copyright (C) 2009 Hans Verkuil <hverkuil@xs4all.nl>
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
#include <linux/videodev2.h>
25
#include <libv4lconvert.h>
33
m_device(old.m_device),
34
m_useWrapper(old.m_useWrapper),
35
m_capability(old.m_capability)
38
bool open(const QString &device, bool useWrapper = true);
40
int read(unsigned char *p, int size);
41
int ioctl(unsigned cmd, void *arg);
42
bool ioctl(const QString &descr, unsigned cmd, void *arg);
43
void *mmap(size_t length, __off64_t offset);
44
int munmap(void *_start, size_t length);
46
inline int fd() const { return m_fd; }
47
inline bool useWrapper() const { return m_useWrapper; }
48
inline __u32 caps() const { return m_capability.capabilities; }
49
inline const QString &device() const { return m_device; }
50
static QString pixfmt2s(unsigned pixelformat);
52
virtual void error(const QString &text);
54
bool querycap(v4l2_capability &cap);
55
bool queryctrl(v4l2_queryctrl &qc);
56
bool querymenu(v4l2_querymenu &qm);
57
bool g_tuner(v4l2_tuner &tuner);
58
bool g_input(int &input);
59
bool s_input(int input);
60
bool g_output(int &output);
61
bool s_output(int output);
62
bool g_audio(v4l2_audio &audio);
63
bool s_audio(int input);
64
bool g_audout(v4l2_audioout &audout);
65
bool s_audout(int output);
66
bool s_std(v4l2_std_id std);
67
bool g_std(v4l2_std_id &std);
68
bool g_frequency(v4l2_frequency &freq);
69
bool s_frequency(v4l2_frequency &freq);
70
bool s_frequency(int freq);
71
bool g_fmt_cap(v4l2_format &fmt);
72
bool g_fmt_out(v4l2_format &fmt);
73
bool try_fmt(v4l2_format &fmt);
74
bool s_fmt(v4l2_format &fmt);
75
bool enum_input(v4l2_input &in, bool init = false);
76
bool enum_output(v4l2_output &out, bool init = false);
77
bool enum_audio(v4l2_audio &audio, bool init = false);
78
bool enum_audout(v4l2_audioout &audout, bool init = false);
79
bool enum_std(v4l2_standard &std, bool init = false, int index = 0);
80
bool enum_fmt_cap(v4l2_fmtdesc &std, bool init = false, int index = 0);
81
bool enum_fmt_out(v4l2_fmtdesc &std, bool init = false, int index = 0);
82
bool enum_framesizes(v4l2_frmsizeenum &frm, __u32 init_pixfmt = 0, int index = 0);
83
bool enum_frameintervals(v4l2_frmivalenum &frm, __u32 init_pixfmt = 0, __u32 w = 0, __u32 h = 0, int index = 0);
85
bool reqbufs_mmap_cap(v4l2_requestbuffers &reqbuf, int count = 0);
86
bool reqbufs_user_cap(v4l2_requestbuffers &reqbuf, int count = 0);
87
bool dqbuf_mmap_cap(v4l2_buffer &buf);
88
bool dqbuf_user_cap(v4l2_buffer &buf);
89
bool qbuf(v4l2_buffer &buf);
90
bool qbuf_mmap_cap(int index);
91
bool qbuf_user_cap(int index, void *ptr, int length);
95
bool reqbufs_mmap_out(v4l2_requestbuffers &reqbuf, int count = 0);
96
bool reqbufs_user_out(v4l2_requestbuffers &reqbuf);
97
bool dqbuf_mmap_out(v4l2_buffer &buf);
98
bool dqbuf_user_out(v4l2_buffer &buf);
99
bool qbuf_mmap_out(int index, int bytesused);
100
bool qbuf_user_out(void *ptr, int length);
102
bool streamoff_out();
105
void clear() { error(QString()); }
110
bool m_useWrapper; // true if using the libv4l2 wrappers
111
v4l2_capability m_capability;