Difference between revisions of "Camera"
From FriendlyELEC WiKi
(updated by API) |
(updated by API) |
||
Line 1: | Line 1: | ||
− | == | + | [[Camera/zh|查看中文]] |
+ | ==Query camera device file name== | ||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
#include <stdio.h> | #include <stdio.h> | ||
Line 38: | Line 39: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | == | + | ==RK3399: Device tree location of the camera== |
DTS 是 arm64/boot/dts/rockchip/ 下的 | DTS 是 arm64/boot/dts/rockchip/ 下的 | ||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> |
Latest revision as of 07:17, 9 September 2021
1 Query camera device file name
#include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/videodev.h> int is_camera(const char* filename){ FILE* f = fopen( filename, "r" ); if (f == NULL) { return 0; } char buff[256] = {0}; int ret = 0; if (fread(buff, 1, 255, f) <= 0) { fclose(f); return 0; } fclose( f ); if (strstr(buff, "Camera") == NULL || strstr(buff, "UVC") == NULL) { return 1; } return 0; } int main() { int i; char filename[255]; for (i=0; i<20; i++) { sprintf(filename, "/sys/class/video4linux/video%d/name", i); if (is_camera(filename) == 1) { printf("/dev/video%d is a camera.\n", i); break; } } }
2 RK3399: Device tree location of the camera
DTS 是 arm64/boot/dts/rockchip/ 下的
rk3399-nanopi4-cifisp.dtsi rk3399-nanopi4-common.dtsi rk3399-nanopi4-rev00.dts rk3399-nanopi4-rev01.dts rk3399-nanopi4-rev04.dts