linux查询video设备类型
想查询 dev/video的类型,找不到命令,闲的蛋疼留个模版
用的时候把video列表写进solve前的 dev_list即可
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <fcntl.h> /* low-level i/o */ #include <unistd.h> #include <errno.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/time.h> #include <sys/mman.h> #include <sys/ioctl.h> #include <asm/types.h> #include <linux/videodev2.h> int device_open(char *dev_name) { struct stat st; if (-1 == stat(dev_name, &st)) { fprintf(stderr, "Cannot identify '%s': %d, %s\n", dev_name, errno, strerror(errno)); // exit(EXIT_FAILURE); } if (!S_ISCHR(st.st_mode)) { fprintf(stderr, "%s is no device\n", dev_name); // exit(EXIT_FAILURE); } int fd = open(dev_name, O_RDWR /* required */ | O_NONBLOCK, 0); if (-1 == fd) { fprintf(stderr, "Cannot open '%s': %d, %s\n", dev_name, errno, strerror(errno)); // exit(EXIT_FAILURE); } printf("%s %d : Open %s successfully. fd = %d\n", __func__, __LINE__, dev_name, fd); return fd; } int device_close(int fd) { if (-1 == close(fd)) { printf("\tdevice close failed.\n"); // exit(EXIT_FAILURE); } else { printf("%s %d : devices close successfully\n", __func__, __LINE__); } return 0; } int device_query(char *dev_name, int fd) { struct v4l2_capability cap; memset(&cap, 0, sizeof(cap)); if (-1 == ioctl(fd, VIDIOC_QUERYCAP, &cap)) // query v4l2-devices's capability { if (EINVAL == errno) { fprintf(stderr, "%s is no V4L2 device\n", dev_name); // exit(EXIT_FAILURE); } else { return 0; printf("\tvideo ioctl_querycap failed.\n"); // exit(EXIT_FAILURE); } } else//\tdevice name : %s\n dev_name, { printf("\n\tdriver name : %s\n\tcard name : %s\n\tbus info : %s\n\tdriver version : %u.%u.%u\n\n", cap.driver, cap.card, cap.bus_info,(cap.version >> 16) & 0XFF, (cap.version >> 8) & 0XFF, cap.version & 0XFF); } return 0; } int dev_num = 27; char dev_list[100][20] = { "/dev/video6", "/dev/video7", "/dev/video11", "/dev/video12", "/dev/video13", // 00 - 04 "/dev/video14", "/dev/video15", "/dev/video16", "/dev/video17", "/dev/video18", // 05 - 09 "/dev/video19", "/dev/video23", "/dev/video24", "/dev/video25", "/dev/video26", // 10 - 14 "/dev/video27", "/dev/video28", "/dev/video29", "/dev/video30", "/dev/video31", // 15 - 19 "/dev/video32", "/dev/video33", "/dev/video34", "/dev/video36", "/dev/video37", // 20 - 24 "/dev/video38", "/dev/video50" }; int solve() { int i = 0; int dev_start = 0; int dev_end = dev_num; for( i = dev_start; i < dev_end; ++i) { int fd = device_open(dev_list[i]); device_query(dev_list[i], fd); device_close(fd); } return 0; } int main() { printf("\nstart game\n"); solve(); printf("\nquit game\n"); return 0; }
附 rp5410 video info
/* start game device name :video6 driver name : MFC card name : decoder bus info : driver version : 1.0.0 device name :video7 driver name : MFC card name : encoder bus info : driver version : 1.0.0 device name :video11 driver name : s5p-jpeg card name : s5p-jpeg bus info : driver version : 1.0.0 device name :video12 driver name : s5p-jpeg card name : s5p-jpeg bus info : driver version : 1.0.0 device name :video13 driver name : exynos5-jpeg-hx card name : exynos5-jpeg-hx bus info : driver version : 1.0.0 device name :video14 driver name : exynos5-jpeg-hx card name : exynos5-jpeg-hx bus info : driver version : 1.0.0 device name :video16 driver name : s5p-mixer card name : mxr0_graph0 bus info : 0 driver version : 0.1.0 device name :video17 driver name : s5p-mixer card name : mxr0_graph1 bus info : 1 driver version : 0.1.0 device name :video18 driver name : s5p-mixer card name : mxr1_graph2 bus info : 2 driver version : 0.1.0 device name :video19 driver name : s5p-mixer card name : mxr1_graph3 bus info : 3 driver version : 0.1.0 device name :video23 driver name : exynos-gsc card name : exynos-gsc bus info : driver version : 3.4.5 device name :video24 driver name : exynos-gsc card name : exynos-gsc bus info : driver version : 3.4.5 device name :video26 driver name : exynos-gsc card name : exynos-gsc bus info : driver version : 3.4.5 device name :video27 driver name : exynos-gsc card name : exynos-gsc bus info : driver version : 3.4.5 device name :video29 driver name : exynos-gsc card name : exynos-gsc bus info : driver version : 3.4.5 device name :video30 driver name : exynos-gsc card name : exynos-gsc bus info : driver version : 3.4.5 device name :video32 driver name : exynos-gsc card name : exynos-gsc bus info : driver version : 3.4.5 device name :video33 driver name : exynos-gsc card name : exynos-gsc bus info : driver version : 3.4.5 device name :video50 driver name : exynos5-scaler card name : exynos5-scaler bus info : driver version : 3.4.5 quit game */
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。