[英]difference between v4l2_ioctl and ioctl
I am currently investigating how we can use v4l2 devices from python, and found that python has a binding for ioctl ( https://docs.python.org/3/library/fcntl.html ).
我在 C 中做了一些實現,但我很難理解 ioctl 是否與 v4l2_ioctl 相同?
他們似乎采用完全相同的 arguments,在官方示例中,我看到兩者都包裹在 function 中,使用方式相同:
static void xioctl(int fh, int request, void *arg)
{
int r;
do {
r = v4l2_ioctl(fh, request, arg);
} while (r == -1 && ((errno == EINTR) || (errno == EAGAIN)));
if (r == -1) {
fprintf(stderr, "error %d, %s\\n", errno, strerror(errno));
exit(EXIT_FAILURE);
}
}
對於普通的 ioctl:
static int xioctl(int fh, int request, void *arg)
{
int r;
do {
r = ioctl(fh, request, arg);
} while (-1 == r && EINTR == errno);
return r;
}
我查看了 linux 存儲庫,但無法弄清楚兩者之間的確切區別。
我可以互換使用 ioctl 和 v4l2_ioctl 嗎?
如果是這樣,為什么兩者都存在?
如果不是,與 v4l2_ioctl 相比,ioctl 的局限性是什么?
我可以互換使用 ioctl 和 v4l2_ioctl 嗎?
不。
如果是這樣,為什么兩者都存在?
ioctl
的存在是為了在設備上執行一些特殊操作。
v4l2_ioctl
是 libv4l2 的一個包裝器,用於簡化libv4l2
設備上的操作。
從自述文件:
libv4l2
這提供了 v4l2_open、v4l2_ioctl 等功能,可用於快速使 v4l2 應用程序與具有奇怪格式的 v4l2 設備一起工作。 libv4l2 主要將調用直接傳遞給 v4l2 驅動程序。 當應用程序使用不支持的格式執行 TRY_FMT / S_FMT 時,libv4l2 將進入中間並模擬格式(如果應用程序想知道硬件真正可以執行哪些格式,它應該使用 ENUM_FMT,而不是隨機嘗試一堆 S_FMT) . 有關 v4l2_ 函數的更多詳細信息,請參見 libv4l2.h。
在 libv4l 項目中找到的源代碼是最終的代碼文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.