📄 probe.c
字号:
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <sys/ioctl.h>#include <linux/videodev.h>#include "pwc-ioctl.h"int main() { const char *dev = "/dev/video0"; int fd = open(dev, O_RDONLY); if (fd < 0) { perror("open"); return -1; } int compression; if (ioctl(fd, VIDIOCPWCGCQUAL, &compression) < 0) { perror("ioctl VIDIOCPWCGCQUAL"); return -1; } printf("compression=%d (", compression); switch (compression) { case 0: printf("no)\n"); break; case 1: printf("less)\n"); break; case 2: printf("middle)\n"); break; case 3: printf("high)\n"); } int agc; if (ioctl(fd, VIDIOCPWCGAGC, &agc) < 0) { perror("ioctl VIDIOCPWCGAGC"); return -1; } printf("agc=%d (", agc); if (agc < 0) printf("auto)\n"); else printf("fixed)\n"); struct pwc_whitebalance wb; if (ioctl(fd, VIDIOCPWCGAWB, &wb) < 0) { perror("ioctl VIDIOCPWCGAWB"); return -1; } printf("white balance="); switch (wb.mode) { case PWC_WB_AUTO: printf("auto, red=%d, blue=%d\n", wb.read_red, wb.read_blue); break; case PWC_WB_MANUAL: printf("manual, red=%d, blue=%d\n", wb.manual_red, wb.manual_blue); break; case PWC_WB_INDOOR: printf("indoor\n"); break; case PWC_WB_OUTDOOR: printf("outdoor\n"); break; case PWC_WB_FL: printf("fl\n"); } struct pwc_wb_speed wbs; if (ioctl(fd, VIDIOCPWCGAWBSPEED, &wbs) < 0) { perror("ioctl VIDIOCPWCGAWBSPEED"); return -1; } printf("white balance speed=%d, delay=%d\n", wbs.control_speed, wbs.control_delay); /* VIDIOCPWCGLED */ int contour; if (ioctl(fd, VIDIOCPWCGCONTOUR, &contour) < 0) { perror("ioctl VIDIOCPWCGCONTOUR"); return -1; } printf("contour=%d\n", contour); int bl; if (ioctl(fd, VIDIOCPWCGBACKLIGHT, &bl) < 0) { perror("ioctl VIDIOCPWCGBACKLIGHT"); return -1; } printf("backlight compensation mode=%d (", bl); if (bl) printf("on)\n"); else printf("off)\n"); int af; if (ioctl(fd, VIDIOCPWCGFLICKER, &af) < 0) { perror("ioctl VIDIOCPWCGFLICKER "); return -1; } printf("anti-flicker=%d (", af); if (af) printf("on)\n"); else printf("off)\n"); int noise; if (ioctl(fd, VIDIOCPWCGDYNNOISE, &noise) < 0) { perror("ioctl VIDIOCPWCGDYNNOISE"); return -1; } printf("dynamic noise reduction=%d (", noise); switch (noise) { case 0: printf("none)\n"); break; case 1: printf("less)\n"); break; case 2: printf("middle)\n"); break; case 3: printf("high)\n"); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -