Camera

From FriendlyELEC WiKi
Jump to: navigation, search

查看中文

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