| 1 |
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ |
| 2 |
/* |
| 3 |
* V4L2 C++ helper header providing wrappers to simplify access to the various |
| 4 |
* v4l2 functions. |
| 5 |
* |
| 6 |
* Copyright 2014-2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef _CV4L_HELPERS_H_ |
| 10 |
#define _CV4L_HELPERS_H_ |
| 11 |
|
| 12 |
#include <limits.h> |
| 13 |
#include <v4l-helpers.h> |
| 14 |
|
| 15 |
#define cv4l_ioctl(cmd, arg) v4l_named_ioctl(g_v4l_fd(), #cmd, cmd, arg) |
| 16 |
|
| 17 |
class cv4l_fd : v4l_fd { |
| 18 |
public: |
| 19 |
cv4l_fd() |
| 20 |
{ |
| 21 |
v4l_fd_init(this); |
| 22 |
} |
| 23 |
cv4l_fd(cv4l_fd *fd) |
| 24 |
{ |
| 25 |
*this = *fd; |
| 26 |
} |
| 27 |
cv4l_fd &operator= (const cv4l_fd &_fd) |
| 28 |
{ |
| 29 |
memcpy(this, &_fd, sizeof(_fd)); |
| 30 |
if (_fd.fd >= 0) |
| 31 |
fd = dup(_fd.fd); |
| 32 |
return *this; |
| 33 |
} |
| 34 |
|
| 35 |
bool is_subdev() const { return v4l_fd_is_subdev(this); } |
| 36 |
bool is_media() const { return v4l_fd_is_media(this); } |
| 37 |
bool is_v4l2() const { return v4l_fd_is_v4l2(this); } |
| 38 |
__u32 g_type() const { return type; } |
| 39 |
void s_type(__u32 type) { v4l_s_type(this, type); } |
| 40 |
__u32 g_selection_type() const { return v4l_g_selection_type(this); } |
| 41 |
__u32 g_caps() const { return caps; } |
| 42 |
int g_fd() const { return fd; } |
| 43 |
v4l_fd *g_v4l_fd() { return this; } |
| 44 |
bool g_direct() const { return v4l_fd_g_direct(this); } |
| 45 |
void s_direct(bool direct) { v4l_fd_s_direct(this, direct); } |
| 46 |
unsigned int g_trace() const { return v4l_fd_g_trace(this); } |
| 47 |
void s_trace(unsigned int trace) { v4l_fd_s_trace(this, trace); } |
| 48 |
|
| 49 |
int open(const char *devname, bool non_blocking = false) { return v4l_open(this, devname, non_blocking); } |
| 50 |
int s_fd(int fd, const char *devname, bool direct) { return v4l_s_fd(this, fd, devname, direct); } |
| 51 |
int subdev_open(const char *devname, bool non_blocking = false) { return v4l_subdev_open(this, devname, non_blocking); } |
| 52 |
int subdev_s_fd(int fd, const char *devname) { return v4l_subdev_s_fd(this, fd, devname); } |
| 53 |
int media_open(const char *devname, bool non_blocking = false) { return v4l_media_open(this, devname, non_blocking); } |
| 54 |
int media_s_fd(int fd, const char *devname) { return v4l_media_s_fd(this, fd, devname); } |
| 55 |
int close() { return v4l_close(this); } |
| 56 |
int reopen(bool non_blocking = false) { return v4l_reopen(this, non_blocking); } |
| 57 |
ssize_t read(void *buffer, size_t n) { return v4l_read(this, buffer, n); } |
| 58 |
ssize_t write(const void *buffer, size_t n) { return v4l_write(this, buffer, n); } |
| 59 |
void *mmap(size_t length, off_t offset) { return v4l_mmap(this, length, offset); } |
| 60 |
int munmap(void *start, size_t length) { return v4l_munmap(this, start, length); } |
| 61 |
|
| 62 |
bool has_vid_cap() const { return v4l_has_vid_cap(this); } |
| 63 |
bool has_vid_out() const { return v4l_has_vid_out(this); } |
| 64 |
bool has_vid_m2m() const { return v4l_has_vid_m2m(this); } |
| 65 |
bool has_vid_mplane() const { return v4l_has_vid_mplane(this); } |
| 66 |
bool has_overlay_cap() const { return v4l_has_overlay_cap(this); } |
| 67 |
bool has_overlay_out() const { return v4l_has_overlay_out(this); } |
| 68 |
bool has_raw_vbi_cap() const { return v4l_has_raw_vbi_cap(this); } |
| 69 |
bool has_sliced_vbi_cap() const { return v4l_has_sliced_vbi_cap(this); } |
| 70 |
bool has_vbi_cap() const { return v4l_has_vbi_cap(this); } |
| 71 |
bool has_raw_vbi_out() const { return v4l_has_raw_vbi_out(this); } |
| 72 |
bool has_sliced_vbi_out() const { return v4l_has_sliced_vbi_out(this); } |
| 73 |
bool has_vbi_out() const { return v4l_has_vbi_out(this); } |
| 74 |
bool has_vbi() const { return v4l_has_vbi(this); } |
| 75 |
bool has_radio_rx() const { return v4l_has_radio_rx(this); } |
| 76 |
bool has_radio_tx() const { return v4l_has_radio_tx(this); } |
| 77 |
bool has_rds_cap() const { return v4l_has_rds_cap(this); } |
| 78 |
bool has_rds_out() const { return v4l_has_rds_out(this); } |
| 79 |
bool has_sdr_cap() const { return v4l_has_sdr_cap(this); } |
| 80 |
bool has_sdr_out() const { return v4l_has_sdr_out(this); } |
| 81 |
bool has_touch() const { return v4l_has_touch(this); } |
| 82 |
bool has_meta_cap() const { return v4l_has_meta_cap(this); } |
| 83 |
bool has_meta_out() const { return v4l_has_meta_out(this); } |
| 84 |
bool has_hwseek() const { return v4l_has_hwseek(this); } |
| 85 |
bool has_rw() const { return v4l_has_rw(this); } |
| 86 |
bool has_streaming() const { return v4l_has_streaming(this); } |
| 87 |
bool has_ext_pix_format() const { return v4l_has_ext_pix_format(this); } |
| 88 |
bool has_streams() const { return have_streams; } |
| 89 |
bool has_ival_uses_which() const { return ival_uses_which; } |
| 90 |
|
| 91 |
int querycap(v4l2_capability &cap, bool force = false) |
| 92 |
{ |
| 93 |
if (force) |
| 94 |
return cv4l_ioctl(VIDIOC_QUERYCAP, &cap); |
| 95 |
cap = this->cap; |
| 96 |
return 0; |
| 97 |
} |
| 98 |
|
| 99 |
int queryctrl(v4l2_queryctrl &qc) |
| 100 |
{ |
| 101 |
return cv4l_ioctl(VIDIOC_QUERYCTRL, &qc); |
| 102 |
} |
| 103 |
|
| 104 |
int querymenu(v4l2_querymenu &qm) |
| 105 |
{ |
| 106 |
return cv4l_ioctl(VIDIOC_QUERYMENU, &qm); |
| 107 |
} |
| 108 |
|
| 109 |
int query_ext_ctrl(v4l2_query_ext_ctrl &qec, bool next_ctrl = false, bool next_compound = false) |
| 110 |
{ |
| 111 |
return v4l_query_ext_ctrl(this, &qec, next_ctrl, next_compound); |
| 112 |
} |
| 113 |
|
| 114 |
int g_ctrl(v4l2_control &ctrl) |
| 115 |
{ |
| 116 |
return cv4l_ioctl(VIDIOC_G_CTRL, &ctrl); |
| 117 |
} |
| 118 |
|
| 119 |
int s_ctrl(v4l2_control &ctrl) |
| 120 |
{ |
| 121 |
return cv4l_ioctl(VIDIOC_S_CTRL, &ctrl); |
| 122 |
} |
| 123 |
|
| 124 |
int g_ext_ctrls(v4l2_ext_controls &ec) |
| 125 |
{ |
| 126 |
return v4l_g_ext_ctrls(this, &ec); |
| 127 |
} |
| 128 |
|
| 129 |
int try_ext_ctrls(v4l2_ext_controls &ec) |
| 130 |
{ |
| 131 |
return v4l_try_ext_ctrls(this, &ec); |
| 132 |
} |
| 133 |
|
| 134 |
int s_ext_ctrls(v4l2_ext_controls &ec) |
| 135 |
{ |
| 136 |
return v4l_s_ext_ctrls(this, &ec); |
| 137 |
} |
| 138 |
|
| 139 |
int g_fmt(v4l2_format &fmt, unsigned type = 0) |
| 140 |
{ |
| 141 |
return v4l_g_fmt(this, &fmt, type); |
| 142 |
} |
| 143 |
|
| 144 |
int try_fmt(v4l2_format &fmt, bool zero_bpl = true) |
| 145 |
{ |
| 146 |
return v4l_try_fmt(this, &fmt, zero_bpl); |
| 147 |
} |
| 148 |
|
| 149 |
int s_fmt(v4l2_format &fmt, bool zero_bpl = true) |
| 150 |
{ |
| 151 |
return v4l_s_fmt(this, &fmt, zero_bpl); |
| 152 |
} |
| 153 |
|
| 154 |
int g_selection(v4l2_selection &sel) |
| 155 |
{ |
| 156 |
return v4l_g_selection(this, &sel); |
| 157 |
} |
| 158 |
|
| 159 |
int s_selection(v4l2_selection &sel) |
| 160 |
{ |
| 161 |
return v4l_s_selection(this, &sel); |
| 162 |
} |
| 163 |
|
| 164 |
int g_frame_selection(v4l2_selection &sel, __u32 field) |
| 165 |
{ |
| 166 |
return v4l_g_frame_selection(this, &sel, field); |
| 167 |
} |
| 168 |
|
| 169 |
int s_frame_selection(v4l2_selection &sel, __u32 field) |
| 170 |
{ |
| 171 |
return v4l_s_frame_selection(this, &sel, field); |
| 172 |
} |
| 173 |
|
| 174 |
int g_tuner(v4l2_tuner &tuner, unsigned index = 0) |
| 175 |
{ |
| 176 |
memset(&tuner, 0, sizeof(tuner)); |
| 177 |
tuner.index = index; |
| 178 |
int ret = cv4l_ioctl(VIDIOC_G_TUNER, &tuner); |
| 179 |
if (ret == 0 && tuner.rangehigh > INT_MAX) |
| 180 |
tuner.rangehigh = INT_MAX; |
| 181 |
return ret; |
| 182 |
} |
| 183 |
|
| 184 |
int s_tuner(v4l2_tuner &tuner) |
| 185 |
{ |
| 186 |
return cv4l_ioctl(VIDIOC_S_TUNER, &tuner); |
| 187 |
} |
| 188 |
|
| 189 |
int g_modulator(v4l2_modulator &modulator, unsigned index = 0) |
| 190 |
{ |
| 191 |
memset(&modulator, 0, sizeof(modulator)); |
| 192 |
modulator.index = index; |
| 193 |
return cv4l_ioctl(VIDIOC_G_MODULATOR, &modulator); |
| 194 |
} |
| 195 |
|
| 196 |
int s_modulator(v4l2_modulator &modulator) |
| 197 |
{ |
| 198 |
return cv4l_ioctl(VIDIOC_S_MODULATOR, &modulator); |
| 199 |
} |
| 200 |
|
| 201 |
int enum_input(v4l2_input &in, bool init = false, int index = 0) |
| 202 |
{ |
| 203 |
if (init) { |
| 204 |
memset(&in, 0, sizeof(in)); |
| 205 |
in.index = index; |
| 206 |
} else { |
| 207 |
in.index++; |
| 208 |
} |
| 209 |
return cv4l_ioctl(VIDIOC_ENUMINPUT, &in); |
| 210 |
} |
| 211 |
|
| 212 |
int enum_output(v4l2_output &out, bool init = false, int index = 0) |
| 213 |
{ |
| 214 |
if (init) { |
| 215 |
memset(&out, 0, sizeof(out)); |
| 216 |
out.index = index; |
| 217 |
} else { |
| 218 |
out.index++; |
| 219 |
} |
| 220 |
return cv4l_ioctl(VIDIOC_ENUMOUTPUT, &out); |
| 221 |
} |
| 222 |
|
| 223 |
int enum_audio(v4l2_audio &audio, bool init = false, int index = 0) |
| 224 |
{ |
| 225 |
if (init) { |
| 226 |
memset(&audio, 0, sizeof(audio)); |
| 227 |
audio.index = index; |
| 228 |
} else { |
| 229 |
audio.index++; |
| 230 |
} |
| 231 |
return cv4l_ioctl(VIDIOC_ENUMAUDIO, &audio); |
| 232 |
} |
| 233 |
|
| 234 |
int enum_audout(v4l2_audioout &audout, bool init = false, int index = 0) |
| 235 |
{ |
| 236 |
if (init) { |
| 237 |
memset(&audout, 0, sizeof(audout)); |
| 238 |
audout.index = index; |
| 239 |
} else { |
| 240 |
audout.index++; |
| 241 |
} |
| 242 |
return cv4l_ioctl(VIDIOC_ENUMAUDOUT, &audout); |
| 243 |
} |
| 244 |
|
| 245 |
bool has_crop() |
| 246 |
{ |
| 247 |
v4l2_selection sel; |
| 248 |
|
| 249 |
memset(&sel, 0, sizeof(sel)); |
| 250 |
sel.type = g_selection_type(); |
| 251 |
sel.target = V4L2_SEL_TGT_CROP; |
| 252 |
return g_selection(sel) != ENOTTY; |
| 253 |
} |
| 254 |
|
| 255 |
bool has_compose() |
| 256 |
{ |
| 257 |
v4l2_selection sel; |
| 258 |
|
| 259 |
memset(&sel, 0, sizeof(sel)); |
| 260 |
sel.type = g_selection_type(); |
| 261 |
sel.target = V4L2_SEL_TGT_COMPOSE; |
| 262 |
return g_selection(sel) != ENOTTY; |
| 263 |
} |
| 264 |
|
| 265 |
bool cur_io_has_crop() |
| 266 |
{ |
| 267 |
v4l2_selection sel; |
| 268 |
|
| 269 |
memset(&sel, 0, sizeof(sel)); |
| 270 |
sel.type = g_selection_type(); |
| 271 |
sel.target = V4L2_SEL_TGT_CROP; |
| 272 |
return g_selection(sel) == 0; |
| 273 |
} |
| 274 |
|
| 275 |
bool cur_io_has_compose() |
| 276 |
{ |
| 277 |
v4l2_selection sel; |
| 278 |
|
| 279 |
memset(&sel, 0, sizeof(sel)); |
| 280 |
sel.type = g_selection_type(); |
| 281 |
sel.target = V4L2_SEL_TGT_COMPOSE; |
| 282 |
return g_selection(sel) == 0; |
| 283 |
} |
| 284 |
|
| 285 |
int subscribe_event(v4l2_event_subscription &sub) |
| 286 |
{ |
| 287 |
return cv4l_ioctl(VIDIOC_SUBSCRIBE_EVENT, &sub); |
| 288 |
} |
| 289 |
|
| 290 |
int unsubscribe_event(v4l2_event_subscription &sub) |
| 291 |
{ |
| 292 |
return cv4l_ioctl(VIDIOC_UNSUBSCRIBE_EVENT, &sub); |
| 293 |
} |
| 294 |
|
| 295 |
int dqevent(v4l2_event &ev) |
| 296 |
{ |
| 297 |
return cv4l_ioctl(VIDIOC_DQEVENT, &ev); |
| 298 |
} |
| 299 |
|
| 300 |
int g_input(__u32 &input) |
| 301 |
{ |
| 302 |
return cv4l_ioctl(VIDIOC_G_INPUT, &input); |
| 303 |
} |
| 304 |
|
| 305 |
int s_input(__u32 input) |
| 306 |
{ |
| 307 |
return cv4l_ioctl(VIDIOC_S_INPUT, &input); |
| 308 |
} |
| 309 |
|
| 310 |
int g_output(__u32 &output) |
| 311 |
{ |
| 312 |
return cv4l_ioctl(VIDIOC_G_OUTPUT, &output); |
| 313 |
} |
| 314 |
|
| 315 |
int s_output(__u32 output) |
| 316 |
{ |
| 317 |
return cv4l_ioctl(VIDIOC_S_OUTPUT, &output); |
| 318 |
} |
| 319 |
|
| 320 |
int g_audio(v4l2_audio &audio) |
| 321 |
{ |
| 322 |
memset(&audio, 0, sizeof(audio)); |
| 323 |
return cv4l_ioctl(VIDIOC_G_AUDIO, &audio); |
| 324 |
} |
| 325 |
|
| 326 |
int s_audio(__u32 input) |
| 327 |
{ |
| 328 |
v4l2_audio audio; |
| 329 |
|
| 330 |
memset(&audio, 0, sizeof(audio)); |
| 331 |
audio.index = input; |
| 332 |
return cv4l_ioctl(VIDIOC_S_AUDIO, &audio); |
| 333 |
} |
| 334 |
|
| 335 |
int g_audout(v4l2_audioout &audout) |
| 336 |
{ |
| 337 |
memset(&audout, 0, sizeof(audout)); |
| 338 |
return cv4l_ioctl(VIDIOC_G_AUDOUT, &audout); |
| 339 |
} |
| 340 |
|
| 341 |
int s_audout(__u32 output) |
| 342 |
{ |
| 343 |
v4l2_audioout audout; |
| 344 |
|
| 345 |
memset(&audout, 0, sizeof(audout)); |
| 346 |
audout.index = output; |
| 347 |
return cv4l_ioctl(VIDIOC_S_AUDOUT, &audout); |
| 348 |
} |
| 349 |
|
| 350 |
int g_std(v4l2_std_id &std) |
| 351 |
{ |
| 352 |
return cv4l_ioctl(VIDIOC_G_STD, &std); |
| 353 |
} |
| 354 |
|
| 355 |
int s_std(v4l2_std_id std) |
| 356 |
{ |
| 357 |
return cv4l_ioctl(VIDIOC_S_STD, &std); |
| 358 |
} |
| 359 |
|
| 360 |
int query_std(v4l2_std_id &std) |
| 361 |
{ |
| 362 |
return cv4l_ioctl(VIDIOC_QUERYSTD, &std); |
| 363 |
} |
| 364 |
|
| 365 |
int dv_timings_cap(v4l2_dv_timings_cap &cap) |
| 366 |
{ |
| 367 |
cap.pad = 0; |
| 368 |
memset(cap.reserved, 0, sizeof(cap.reserved)); |
| 369 |
return cv4l_ioctl(VIDIOC_DV_TIMINGS_CAP, &cap); |
| 370 |
} |
| 371 |
|
| 372 |
int g_dv_timings(v4l2_dv_timings &timings) |
| 373 |
{ |
| 374 |
return cv4l_ioctl(VIDIOC_G_DV_TIMINGS, &timings); |
| 375 |
} |
| 376 |
|
| 377 |
int s_dv_timings(v4l2_dv_timings &timings) |
| 378 |
{ |
| 379 |
if (timings.type == V4L2_DV_BT_656_1120) |
| 380 |
memset(timings.bt.reserved, 0, |
| 381 |
sizeof(timings.bt.reserved)); |
| 382 |
return cv4l_ioctl(VIDIOC_S_DV_TIMINGS, &timings); |
| 383 |
} |
| 384 |
|
| 385 |
int query_dv_timings(v4l2_dv_timings &timings) |
| 386 |
{ |
| 387 |
return cv4l_ioctl(VIDIOC_QUERY_DV_TIMINGS, &timings); |
| 388 |
} |
| 389 |
|
| 390 |
int g_frequency(v4l2_frequency &freq, unsigned index = 0) |
| 391 |
{ |
| 392 |
memset(&freq, 0, sizeof(freq)); |
| 393 |
freq.tuner = index; |
| 394 |
freq.type = V4L2_TUNER_ANALOG_TV; |
| 395 |
return cv4l_ioctl(VIDIOC_G_FREQUENCY, &freq); |
| 396 |
} |
| 397 |
|
| 398 |
int s_frequency(v4l2_frequency &freq) |
| 399 |
{ |
| 400 |
return cv4l_ioctl(VIDIOC_S_FREQUENCY, &freq); |
| 401 |
} |
| 402 |
|
| 403 |
int g_priority(__u32 &prio) |
| 404 |
{ |
| 405 |
return cv4l_ioctl(VIDIOC_G_PRIORITY, &prio); |
| 406 |
} |
| 407 |
|
| 408 |
int s_priority(__u32 prio = V4L2_PRIORITY_DEFAULT) |
| 409 |
{ |
| 410 |
return cv4l_ioctl(VIDIOC_S_PRIORITY, &prio); |
| 411 |
} |
| 412 |
|
| 413 |
int streamon(__u32 type = 0) |
| 414 |
{ |
| 415 |
if (type == 0) |
| 416 |
type = g_type(); |
| 417 |
return cv4l_ioctl(VIDIOC_STREAMON, &type); |
| 418 |
} |
| 419 |
|
| 420 |
int streamoff(__u32 type = 0) |
| 421 |
{ |
| 422 |
if (type == 0) |
| 423 |
type = g_type(); |
| 424 |
return cv4l_ioctl(VIDIOC_STREAMOFF, &type); |
| 425 |
} |
| 426 |
|
| 427 |
int querybuf(v4l_buffer &buf) |
| 428 |
{ |
| 429 |
return v4l_buffer_querybuf(this, &buf, |
| 430 |
v4l_buffer_g_index(&buf)); |
| 431 |
} |
| 432 |
|
| 433 |
int querybuf(v4l_buffer &buf, unsigned index) |
| 434 |
{ |
| 435 |
return v4l_buffer_querybuf(this, &buf, index); |
| 436 |
} |
| 437 |
|
| 438 |
int dqbuf(v4l_buffer &buf) |
| 439 |
{ |
| 440 |
return v4l_buffer_dqbuf(this, &buf); |
| 441 |
} |
| 442 |
|
| 443 |
int qbuf(v4l_buffer &buf) |
| 444 |
{ |
| 445 |
return v4l_buffer_qbuf(this, &buf); |
| 446 |
} |
| 447 |
|
| 448 |
int prepare_buf(v4l_buffer &buf) |
| 449 |
{ |
| 450 |
return v4l_buffer_prepare_buf(this, &buf); |
| 451 |
} |
| 452 |
|
| 453 |
int enum_std(v4l2_standard &std, bool init = false, int index = 0) |
| 454 |
{ |
| 455 |
if (init) { |
| 456 |
memset(&std, 0, sizeof(std)); |
| 457 |
std.index = index; |
| 458 |
} else { |
| 459 |
std.index++; |
| 460 |
} |
| 461 |
return cv4l_ioctl(VIDIOC_ENUMSTD, &std); |
| 462 |
} |
| 463 |
|
| 464 |
int enum_freq_bands(v4l2_frequency_band &band, unsigned tuner, bool init = false, int index = 0) |
| 465 |
{ |
| 466 |
if (init) { |
| 467 |
memset(&band, 0, sizeof(band)); |
| 468 |
band.index = index; |
| 469 |
} else { |
| 470 |
band.index++; |
| 471 |
} |
| 472 |
band.tuner = tuner; |
| 473 |
if (has_radio_tx() || has_radio_rx()) |
| 474 |
band.type = V4L2_TUNER_RADIO; |
| 475 |
else |
| 476 |
band.type = V4L2_TUNER_ANALOG_TV; |
| 477 |
return cv4l_ioctl(VIDIOC_ENUM_FREQ_BANDS, &band); |
| 478 |
} |
| 479 |
|
| 480 |
int enum_dv_timings(v4l2_enum_dv_timings &timings, bool init = false, int index = 0) |
| 481 |
{ |
| 482 |
if (init) { |
| 483 |
memset(&timings, 0, sizeof(timings)); |
| 484 |
timings.index = index; |
| 485 |
} else { |
| 486 |
timings.index++; |
| 487 |
} |
| 488 |
return cv4l_ioctl(VIDIOC_ENUM_DV_TIMINGS, &timings); |
| 489 |
} |
| 490 |
|
| 491 |
int enum_fmt(v4l2_fmtdesc &fmt, bool init = false, int index = 0, unsigned type = 0, __u32 mbus_code = 0, bool enum_all = false) |
| 492 |
{ |
| 493 |
if (init) { |
| 494 |
memset(&fmt, 0, sizeof(fmt)); |
| 495 |
fmt.type = type ? type : g_type(); |
| 496 |
fmt.index = index; |
| 497 |
fmt.mbus_code = mbus_code; |
| 498 |
} else { |
| 499 |
fmt.index++; |
| 500 |
} |
| 501 |
if (enum_all) |
| 502 |
fmt.index |= V4L2_FMTDESC_FLAG_ENUM_ALL; |
| 503 |
|
| 504 |
return cv4l_ioctl(VIDIOC_ENUM_FMT, &fmt); |
| 505 |
} |
| 506 |
|
| 507 |
int enum_framesizes(v4l2_frmsizeenum &frm, __u32 init_pixfmt = 0, int index = 0) |
| 508 |
{ |
| 509 |
if (init_pixfmt) { |
| 510 |
memset(&frm, 0, sizeof(frm)); |
| 511 |
frm.pixel_format = init_pixfmt; |
| 512 |
frm.index = index; |
| 513 |
} else { |
| 514 |
frm.index++; |
| 515 |
} |
| 516 |
return cv4l_ioctl(VIDIOC_ENUM_FRAMESIZES, &frm); |
| 517 |
} |
| 518 |
|
| 519 |
int enum_frameintervals(v4l2_frmivalenum &frm, __u32 init_pixfmt = 0, __u32 w = 0, __u32 h = 0, int index = 0) |
| 520 |
{ |
| 521 |
if (init_pixfmt) { |
| 522 |
memset(&frm, 0, sizeof(frm)); |
| 523 |
frm.pixel_format = init_pixfmt; |
| 524 |
frm.width = w; |
| 525 |
frm.height = h; |
| 526 |
frm.index = index; |
| 527 |
} else { |
| 528 |
frm.index++; |
| 529 |
} |
| 530 |
return cv4l_ioctl(VIDIOC_ENUM_FRAMEINTERVALS, &frm); |
| 531 |
} |
| 532 |
|
| 533 |
int set_interval(v4l2_fract interval, unsigned type = 0) |
| 534 |
{ |
| 535 |
v4l2_streamparm parm; |
| 536 |
|
| 537 |
parm.type = type ? type : g_type(); |
| 538 |
memset(parm.parm.capture.reserved, 0, sizeof(parm.parm.capture.reserved)); |
| 539 |
if (cv4l_ioctl(VIDIOC_G_PARM, &parm) || |
| 540 |
!(parm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME)) |
| 541 |
return -1; |
| 542 |
|
| 543 |
parm.parm.capture.timeperframe = interval; |
| 544 |
|
| 545 |
return cv4l_ioctl(VIDIOC_S_PARM, &parm); |
| 546 |
} |
| 547 |
|
| 548 |
int get_interval(v4l2_fract &interval, unsigned type = 0) |
| 549 |
{ |
| 550 |
v4l2_streamparm parm; |
| 551 |
|
| 552 |
parm.type = type ? type : g_type(); |
| 553 |
memset(parm.parm.capture.reserved, 0, sizeof(parm.parm.capture.reserved)); |
| 554 |
if (cv4l_ioctl(VIDIOC_G_PARM, &parm) == 0 && |
| 555 |
(parm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME)) { |
| 556 |
interval = parm.parm.capture.timeperframe; |
| 557 |
return 0; |
| 558 |
} |
| 559 |
|
| 560 |
return -1; |
| 561 |
} |
| 562 |
|
| 563 |
int g_fbuf(v4l2_framebuffer &fbuf) |
| 564 |
{ |
| 565 |
return cv4l_ioctl(VIDIOC_G_FBUF, &fbuf); |
| 566 |
} |
| 567 |
|
| 568 |
int s_fbuf(v4l2_framebuffer &fbuf) |
| 569 |
{ |
| 570 |
fbuf.fmt.priv = 0; |
| 571 |
return cv4l_ioctl(VIDIOC_S_FBUF, &fbuf); |
| 572 |
} |
| 573 |
|
| 574 |
int overlay(bool enable) |
| 575 |
{ |
| 576 |
int ena = enable; |
| 577 |
|
| 578 |
return cv4l_ioctl(VIDIOC_OVERLAY, &ena); |
| 579 |
} |
| 580 |
|
| 581 |
int g_jpegcomp(v4l2_jpegcompression &jpeg) |
| 582 |
{ |
| 583 |
return cv4l_ioctl(VIDIOC_G_JPEGCOMP, &jpeg); |
| 584 |
} |
| 585 |
|
| 586 |
int s_jpegcomp(v4l2_jpegcompression &jpeg) |
| 587 |
{ |
| 588 |
return cv4l_ioctl(VIDIOC_S_JPEGCOMP, &jpeg); |
| 589 |
} |
| 590 |
|
| 591 |
int g_edid(v4l2_edid &edid) |
| 592 |
{ |
| 593 |
memset(edid.reserved, 0, sizeof(edid.reserved)); |
| 594 |
return cv4l_ioctl(VIDIOC_G_EDID, &edid); |
| 595 |
} |
| 596 |
|
| 597 |
int s_edid(v4l2_edid &edid) |
| 598 |
{ |
| 599 |
memset(edid.reserved, 0, sizeof(edid.reserved)); |
| 600 |
return cv4l_ioctl(VIDIOC_S_EDID, &edid); |
| 601 |
} |
| 602 |
|
| 603 |
int g_sliced_vbi_cap(v4l2_sliced_vbi_cap &cap) |
| 604 |
{ |
| 605 |
memset(cap.reserved, 0, sizeof(cap.reserved)); |
| 606 |
return cv4l_ioctl(VIDIOC_G_SLICED_VBI_CAP, &cap); |
| 607 |
} |
| 608 |
|
| 609 |
int g_enc_index(v4l2_enc_idx &enc_idx) |
| 610 |
{ |
| 611 |
return cv4l_ioctl(VIDIOC_G_ENC_INDEX, &enc_idx); |
| 612 |
} |
| 613 |
|
| 614 |
int s_hw_freq_seek(v4l2_hw_freq_seek &seek) |
| 615 |
{ |
| 616 |
memset(seek.reserved, 0, sizeof(seek.reserved)); |
| 617 |
return cv4l_ioctl(VIDIOC_S_HW_FREQ_SEEK, &seek); |
| 618 |
} |
| 619 |
|
| 620 |
int log_status() |
| 621 |
{ |
| 622 |
return cv4l_ioctl(VIDIOC_LOG_STATUS, NULL); |
| 623 |
} |
| 624 |
|
| 625 |
int encoder_cmd(v4l2_encoder_cmd &cmd) |
| 626 |
{ |
| 627 |
memset(&cmd.raw, 0, sizeof(cmd.raw)); |
| 628 |
return cv4l_ioctl(VIDIOC_ENCODER_CMD, &cmd); |
| 629 |
} |
| 630 |
|
| 631 |
int try_encoder_cmd(v4l2_encoder_cmd &cmd) |
| 632 |
{ |
| 633 |
memset(&cmd.raw, 0, sizeof(cmd.raw)); |
| 634 |
return cv4l_ioctl(VIDIOC_TRY_ENCODER_CMD, &cmd); |
| 635 |
} |
| 636 |
|
| 637 |
int decoder_cmd(v4l2_decoder_cmd &cmd) |
| 638 |
{ |
| 639 |
return cv4l_ioctl(VIDIOC_DECODER_CMD, &cmd); |
| 640 |
} |
| 641 |
|
| 642 |
int try_decoder_cmd(v4l2_decoder_cmd &cmd) |
| 643 |
{ |
| 644 |
return cv4l_ioctl(VIDIOC_TRY_DECODER_CMD, &cmd); |
| 645 |
} |
| 646 |
|
| 647 |
v4l2_fract g_pixel_aspect(unsigned &width, unsigned &height, unsigned type = 0) |
| 648 |
{ |
| 649 |
v4l2_cropcap ratio; |
| 650 |
v4l2_dv_timings timings; |
| 651 |
v4l2_std_id std; |
| 652 |
static const v4l2_fract square = { 1, 1 }; |
| 653 |
static const v4l2_fract hz50 = { 11, 12 }; |
| 654 |
static const v4l2_fract hz60 = { 11, 10 }; |
| 655 |
|
| 656 |
ratio.type = type ? type : g_selection_type(); |
| 657 |
if (cv4l_ioctl(VIDIOC_CROPCAP, &ratio) == 0) { |
| 658 |
width = ratio.defrect.width; |
| 659 |
height = ratio.defrect.height; |
| 660 |
if (ratio.pixelaspect.numerator && ratio.pixelaspect.denominator) |
| 661 |
return ratio.pixelaspect; |
| 662 |
} |
| 663 |
|
| 664 |
width = 720; |
| 665 |
height = 480; |
| 666 |
if (!g_std(std)) { |
| 667 |
if (std & V4L2_STD_525_60) |
| 668 |
return hz60; |
| 669 |
if (std & V4L2_STD_625_50) { |
| 670 |
height = 576; |
| 671 |
return hz50; |
| 672 |
} |
| 673 |
} |
| 674 |
|
| 675 |
if (!g_dv_timings(timings)) { |
| 676 |
width = timings.bt.width; |
| 677 |
height = timings.bt.height; |
| 678 |
if (width == 720 && height == 480) |
| 679 |
return hz60; |
| 680 |
if (width == 720 && height == 576) { |
| 681 |
height = 576; |
| 682 |
return hz50; |
| 683 |
} |
| 684 |
return square; |
| 685 |
} |
| 686 |
width = 0; |
| 687 |
height = 0; |
| 688 |
return square; |
| 689 |
} |
| 690 |
}; |
| 691 |
|
| 692 |
class cv4l_fmt : public v4l2_format { |
| 693 |
public: |
| 694 |
cv4l_fmt(unsigned _type = 0) |
| 695 |
{ |
| 696 |
v4l_format_init(this, _type); |
| 697 |
} |
| 698 |
cv4l_fmt(const v4l2_format &_fmt) |
| 699 |
{ |
| 700 |
memcpy(this, &_fmt, sizeof(_fmt)); |
| 701 |
} |
| 702 |
|
| 703 |
__u32 g_type() { return type; } |
| 704 |
void s_type(unsigned type) { v4l_format_init(this, type); } |
| 705 |
__u32 g_width() const { return v4l_format_g_width(this); } |
| 706 |
void s_width(__u32 width) { v4l_format_s_width(this, width); } |
| 707 |
__u32 g_height() const { return v4l_format_g_height(this); } |
| 708 |
void s_height(__u32 height) { v4l_format_s_height(this, height); } |
| 709 |
__u32 g_frame_height() const { return v4l_format_g_frame_height(this); } |
| 710 |
void s_frame_height(__u32 height) { v4l_format_s_frame_height(this, height); } |
| 711 |
__u32 g_pixelformat() const { return v4l_format_g_pixelformat(this); } |
| 712 |
void s_pixelformat(__u32 pixelformat) { v4l_format_s_pixelformat(this, pixelformat); } |
| 713 |
unsigned g_colorspace() const { return v4l_format_g_colorspace(this); } |
| 714 |
void s_colorspace(unsigned colorspace) { v4l_format_s_colorspace(this, colorspace); } |
| 715 |
unsigned g_xfer_func() const { return v4l_format_g_xfer_func(this); } |
| 716 |
void s_xfer_func(unsigned xfer_func) { v4l_format_s_xfer_func(this, xfer_func); } |
| 717 |
unsigned g_ycbcr_enc() const { return v4l_format_g_ycbcr_enc(this); } |
| 718 |
unsigned g_hsv_enc() const { return v4l_format_g_hsv_enc(this); } |
| 719 |
void s_ycbcr_enc(unsigned ycbcr_enc) { v4l_format_s_ycbcr_enc(this, ycbcr_enc); } |
| 720 |
unsigned g_quantization() const { return v4l_format_g_quantization(this); } |
| 721 |
void s_quantization(unsigned quantization) { v4l_format_s_quantization(this, quantization); } |
| 722 |
unsigned g_flags() const { return v4l_format_g_flags(this); } |
| 723 |
void s_flags(unsigned flags) { v4l_format_s_flags(this, flags); } |
| 724 |
__u8 g_num_planes() const { return v4l_format_g_num_planes(this); } |
| 725 |
void s_num_planes(__u8 num_planes) { v4l_format_s_num_planes(this, num_planes); } |
| 726 |
__u32 g_bytesperline(unsigned plane = 0) const { return v4l_format_g_bytesperline(this, plane); } |
| 727 |
void s_bytesperline(__u32 bytesperline, unsigned plane = 0) { v4l_format_s_bytesperline(this, plane, bytesperline); } |
| 728 |
__u32 g_sizeimage(unsigned plane = 0) const { return v4l_format_g_sizeimage(this, plane); } |
| 729 |
void s_sizeimage(__u32 sizeimage, unsigned plane = 0) { v4l_format_s_sizeimage(this, plane, sizeimage); } |
| 730 |
unsigned g_field() const { return v4l_format_g_field(this); } |
| 731 |
void s_field(unsigned field) { v4l_format_s_field(this, field); } |
| 732 |
unsigned g_first_field(v4l2_std_id std) const { return v4l_format_g_first_field(this, std); } |
| 733 |
unsigned g_flds_per_frm() const { return v4l_format_g_flds_per_frm(this); } |
| 734 |
}; |
| 735 |
|
| 736 |
class cv4l_buffer; |
| 737 |
|
| 738 |
class cv4l_queue : v4l_queue { |
| 739 |
friend class cv4l_buffer; |
| 740 |
public: |
| 741 |
cv4l_queue(unsigned type = V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 742 |
unsigned memory = V4L2_MEMORY_MMAP) |
| 743 |
{ |
| 744 |
v4l_queue_init(this, type, memory); |
| 745 |
} |
| 746 |
~cv4l_queue() { v4l_queue_free_bufs_info(this); } |
| 747 |
void init(unsigned type, unsigned memory) |
| 748 |
{ |
| 749 |
v4l_queue_init(this, type, memory); |
| 750 |
} |
| 751 |
unsigned g_type() const { return v4l_queue_g_type(this); } |
| 752 |
unsigned g_memory() const { return v4l_queue_g_memory(this); } |
| 753 |
unsigned g_buffers() const { return v4l_queue_g_buffers(this); } |
| 754 |
unsigned g_max_num_buffers() const { return v4l_queue_g_max_num_buffers(this); } |
| 755 |
unsigned g_num_planes() const { return v4l_queue_g_num_planes(this); } |
| 756 |
unsigned g_capabilities() const { return v4l_queue_g_capabilities(this); } |
| 757 |
unsigned g_length(unsigned plane) const { return v4l_queue_g_length(this, plane); } |
| 758 |
unsigned g_mem_offset(unsigned index, unsigned plane) const { return v4l_queue_g_mem_offset(this, index, plane); } |
| 759 |
void *g_mmapping(unsigned index, unsigned plane) const { return v4l_queue_g_mmapping(this, index, plane); } |
| 760 |
void s_mmapping(unsigned index, unsigned plane, void *m) { v4l_queue_s_mmapping(this, index, plane, m); } |
| 761 |
void *g_userptr(unsigned index, unsigned plane) const { return v4l_queue_g_userptr(this, index, plane); } |
| 762 |
void s_userptr(unsigned index, unsigned plane, void *m) { v4l_queue_s_userptr(this, index, plane, m); } |
| 763 |
void *g_dataptr(unsigned index, unsigned plane) const { return v4l_queue_g_dataptr(this, index, plane); } |
| 764 |
int g_fd(unsigned index, unsigned plane) const { return v4l_queue_g_fd(this, index, plane); } |
| 765 |
void s_fd(unsigned index, unsigned plane, int fd) { v4l_queue_s_fd(this, index, plane, fd); } |
| 766 |
|
| 767 |
int reqbufs(cv4l_fd *fd, unsigned count = 0, unsigned int flags = 0) |
| 768 |
{ |
| 769 |
return v4l_queue_reqbufs(fd->g_v4l_fd(), this, count, flags); |
| 770 |
} |
| 771 |
int remove_bufs(cv4l_fd *fd, unsigned index = 0, unsigned count = 0) |
| 772 |
{ |
| 773 |
return v4l_queue_remove_bufs(fd->g_v4l_fd(), this, index, count); |
| 774 |
} |
| 775 |
bool has_create_bufs(cv4l_fd *fd) const |
| 776 |
{ |
| 777 |
return v4l_queue_has_create_bufs(fd->g_v4l_fd(), this); |
| 778 |
} |
| 779 |
int create_bufs(cv4l_fd *fd, unsigned count, const v4l2_format *fmt = NULL, unsigned int flags = 0) |
| 780 |
{ |
| 781 |
return v4l_queue_create_bufs(fd->g_v4l_fd(), this, count, fmt, flags); |
| 782 |
} |
| 783 |
int mmap_bufs(cv4l_fd *fd, unsigned from = 0) |
| 784 |
{ |
| 785 |
return v4l_queue_mmap_bufs(fd->g_v4l_fd(), this, from); |
| 786 |
} |
| 787 |
int munmap_bufs(cv4l_fd *fd, unsigned from = 0) |
| 788 |
{ |
| 789 |
return v4l_queue_munmap_bufs(fd->g_v4l_fd(), this, from); |
| 790 |
} |
| 791 |
int alloc_bufs(cv4l_fd *fd, unsigned from = 0) |
| 792 |
{ |
| 793 |
return v4l_queue_alloc_bufs(fd->g_v4l_fd(), this, from); |
| 794 |
} |
| 795 |
int free_bufs(unsigned from = 0) |
| 796 |
{ |
| 797 |
return v4l_queue_free_bufs(this, from); |
| 798 |
} |
| 799 |
int obtain_bufs(cv4l_fd *fd, unsigned from = 0) |
| 800 |
{ |
| 801 |
return v4l_queue_obtain_bufs(fd->g_v4l_fd(), this, from); |
| 802 |
} |
| 803 |
int release_bufs(cv4l_fd *fd, unsigned from = 0) |
| 804 |
{ |
| 805 |
return v4l_queue_release_bufs(fd->g_v4l_fd(), this, from); |
| 806 |
} |
| 807 |
bool has_expbuf(cv4l_fd *fd) |
| 808 |
{ |
| 809 |
return v4l_queue_has_expbuf(fd->g_v4l_fd()); |
| 810 |
} |
| 811 |
int export_bufs(cv4l_fd *fd, unsigned exp_type) |
| 812 |
{ |
| 813 |
return v4l_queue_export_bufs(fd->g_v4l_fd(), this, exp_type); |
| 814 |
} |
| 815 |
void close_exported_fds() |
| 816 |
{ |
| 817 |
v4l_queue_close_exported_fds(this); |
| 818 |
} |
| 819 |
void free(cv4l_fd *fd) |
| 820 |
{ |
| 821 |
v4l_queue_free(fd->g_v4l_fd(), this); |
| 822 |
} |
| 823 |
void buffer_init(v4l_buffer &buf, unsigned index) const |
| 824 |
{ |
| 825 |
v4l_queue_buffer_init(this, &buf, index); |
| 826 |
} |
| 827 |
void buffer_update(v4l_buffer &buf, unsigned index) const |
| 828 |
{ |
| 829 |
v4l_queue_buffer_update(this, &buf, index); |
| 830 |
} |
| 831 |
int queue_all(cv4l_fd *fd); |
| 832 |
}; |
| 833 |
|
| 834 |
class cv4l_buffer : public v4l_buffer { |
| 835 |
public: |
| 836 |
cv4l_buffer(unsigned type = 0, unsigned memory = 0, unsigned index = 0) |
| 837 |
{ |
| 838 |
init(type, memory, index); |
| 839 |
} |
| 840 |
cv4l_buffer(const cv4l_queue &q, unsigned index = 0) |
| 841 |
{ |
| 842 |
init(q, index); |
| 843 |
} |
| 844 |
cv4l_buffer(const cv4l_buffer &b) |
| 845 |
{ |
| 846 |
init(b); |
| 847 |
} |
| 848 |
cv4l_buffer operator= (const cv4l_buffer &b) |
| 849 |
{ |
| 850 |
v4l_buffer *dst = this; |
| 851 |
const v4l_buffer *src = &b; |
| 852 |
memcpy(dst, src, sizeof(*src)); |
| 853 |
return *this; |
| 854 |
} |
| 855 |
virtual ~cv4l_buffer() {} |
| 856 |
|
| 857 |
void init(unsigned type = 0, unsigned memory = 0, unsigned index = 0) |
| 858 |
{ |
| 859 |
v4l_buffer_init(this, type, memory, index); |
| 860 |
} |
| 861 |
void init(const cv4l_queue &q, unsigned index = 0) |
| 862 |
{ |
| 863 |
q.buffer_init(*this, index); |
| 864 |
} |
| 865 |
void init(const cv4l_buffer &b) |
| 866 |
{ |
| 867 |
memcpy((v4l2_buffer *)this, (v4l2_buffer *)&b, sizeof(b)); |
| 868 |
if (v4l_type_is_planar(g_type())) |
| 869 |
buf.m.planes = planes; |
| 870 |
} |
| 871 |
void update(const cv4l_queue &q, unsigned index = 0) |
| 872 |
{ |
| 873 |
q.buffer_update(*this, index); |
| 874 |
} |
| 875 |
|
| 876 |
__u32 g_index() const { return v4l_buffer_g_index(this); } |
| 877 |
void s_index(unsigned index) { v4l_buffer_s_index(this, index); } |
| 878 |
__s32 g_request_fd() const { return v4l_buffer_g_request_fd(this); } |
| 879 |
void s_request_fd(__s32 request_fd) { v4l_buffer_s_request_fd(this, request_fd); } |
| 880 |
unsigned g_type() const { return v4l_buffer_g_type(this); } |
| 881 |
unsigned g_memory() const { return v4l_buffer_g_memory(this); } |
| 882 |
__u32 g_flags() const { return v4l_buffer_g_flags(this); } |
| 883 |
void s_flags(__u32 flags) { v4l_buffer_s_flags(this, flags); } |
| 884 |
void or_flags(__u32 flags) { v4l_buffer_or_flags(this, flags); } |
| 885 |
unsigned g_field() const { return v4l_buffer_g_field(this); } |
| 886 |
void s_field(unsigned field) { v4l_buffer_s_field(this, field); } |
| 887 |
|
| 888 |
unsigned g_num_planes() const { return v4l_buffer_g_num_planes(this); } |
| 889 |
__u32 g_mem_offset(unsigned plane = 0) const { return v4l_buffer_g_mem_offset(this, plane); } |
| 890 |
void *g_userptr(unsigned plane = 0) const { return v4l_buffer_g_userptr(this, plane); } |
| 891 |
void s_userptr(void *userptr, unsigned plane = 0) { v4l_buffer_s_userptr(this, plane, userptr); } |
| 892 |
int g_fd(unsigned plane = 0) const { return v4l_buffer_g_fd(this, plane); } |
| 893 |
void s_fd(int fd, unsigned plane = 0) { v4l_buffer_s_fd(this, plane, fd); } |
| 894 |
__u32 g_bytesused(unsigned plane = 0) const { return v4l_buffer_g_bytesused(this, plane); } |
| 895 |
void s_bytesused(__u32 bytesused, unsigned plane = 0) { v4l_buffer_s_bytesused(this, plane, bytesused); } |
| 896 |
__u32 g_data_offset(unsigned plane = 0) const { return v4l_buffer_g_data_offset(this, plane); } |
| 897 |
void s_data_offset(__u32 data_offset, unsigned plane = 0) { v4l_buffer_s_data_offset(this, plane, data_offset); } |
| 898 |
__u32 g_length(unsigned plane = 0) const { return v4l_buffer_g_length(this, plane); } |
| 899 |
void s_length(unsigned length, unsigned plane = 0) { return v4l_buffer_s_length(this, plane, length); } |
| 900 |
|
| 901 |
__u32 g_sequence() const { return v4l_buffer_g_sequence(this); } |
| 902 |
__u32 g_timestamp_type() const { return v4l_buffer_g_timestamp_type(this); } |
| 903 |
__u32 g_timestamp_src() const { return v4l_buffer_g_timestamp_src(this); } |
| 904 |
void s_timestamp_src(__u32 src) { v4l_buffer_s_timestamp_src(this, src); } |
| 905 |
bool ts_is_copy() const { return v4l_buffer_is_copy(this); } |
| 906 |
const timeval &g_timestamp() const { return *v4l_buffer_g_timestamp(this); } |
| 907 |
__u64 g_timestamp_ns() const { return v4l2_timeval_to_ns(v4l_buffer_g_timestamp(this)); } |
| 908 |
void s_timestamp(const timeval &tv) { v4l_buffer_s_timestamp(this, &tv); } |
| 909 |
void s_timestamp_ts(const timespec &ts) { v4l_buffer_s_timestamp_ts(this, &ts); } |
| 910 |
void s_timestamp_clock() { v4l_buffer_s_timestamp_clock(this); } |
| 911 |
const v4l2_timecode &g_timecode() const { return *v4l_buffer_g_timecode(this); } |
| 912 |
void s_timecode(const v4l2_timecode &tc) { v4l_buffer_s_timecode(this, &tc); } |
| 913 |
}; |
| 914 |
|
| 915 |
inline int cv4l_queue::queue_all(cv4l_fd *fd) |
| 916 |
{ |
| 917 |
cv4l_buffer buf; |
| 918 |
|
| 919 |
for (unsigned i = 0; i < g_buffers(); i++) { |
| 920 |
buf.init(*this, i); |
| 921 |
int ret = fd->qbuf(buf); |
| 922 |
if (ret) |
| 923 |
return ret; |
| 924 |
} |
| 925 |
return 0; |
| 926 |
} |
| 927 |
|
| 928 |
#endif |