Chinaunix首页 | 论坛 | 博客
  • 博客访问: 387785
  • 博文数量: 214
  • 博客积分: 770
  • 博客等级: 军士长
  • 技术积分: 1969
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-08 01:22
文章分类

全部博文(214)

文章存档

2013年(110)

2012年(104)

我的朋友

分类:

2012-11-16 22:01:34

Andrew Huang 转载请注明作者及网址


一.设备性能查询

在V4L第二步,对用ioctl来查询设备属性和配置,

这里我们用VIDIOC_QUERYCAP来进设备属性查询操作,这是一个v4l2设备必须实现的操作


这里使用 
   ret = ioctl(fd, VIDIOC_QUERYCAP, &cap);
这里查询的结果保存在数据结构
  struct v4l2_capability cap;当中,它有如下定义

struct v4l2_capability {
    __u8    driver[16];    /* i.e. "bttv" */
    __u8    card[32];    /* i.e. "Hauppauge WinTV" */
    __u8    bus_info[32];    /* "PCI:" + pci_name(pci_dev) */
    __u32 version; /* should use KERNEL_VERSION() */
    __u32    capabilities;    /* Device capabilities */
    __u32    reserved[4];
};



另外硬件视频数据输入的参数,可以用VIDIOC_ENUMINPUT来做多次查询.
struct v4l2_input input;
  int ret;
  memset(&input, 0, sizeof(input));//initialize i.index=0;

  PRINT_V4L("inputs\n");
  
  while(ret=ioctl(fd, VIDIOC_ENUMINPUT, &input)>=0)
  {
   }

其中使用v4l2_input 数据结构定义如下

/*
 *    V I D E O I N P U T S
 */

struct v4l2_input {
    __u32     index;        /* Which input */
    __u8     name[32];        /* Label */
    __u32     type;        /* Type of input */
    __u32     audioset;        /* Associated audios (bitfield) */
    __u32 tuner; /* Associated tuner */
    v4l2_std_id std;
    __u32     status;
    __u32     reserved[4];
};



2.视频格式查询
 
在 v4l2中,有两种查询视频格式的方法,一个遍历所有视频格式的, 一次查询出一种格式的,使用ioctl VIDIOC_ENUM_FMT
 
  1. struct v4l2_fmtdesc fmtdesc;
  2.    int i=0;
  3.    memset(&fmtdesc, 0, sizeof(fmtdesc));

  4.    for(i=0;;i++)
  5.        {     
  6.      fmtdesc.index = i;
  7.       fmtdesc.type = type;
  8.     
  9.      if(-1== ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc))
  10.         break;
  11.     }

 
另外是一次性查询所有格式用,VIDIOC_G_FMT

 
  1. struct v4l2_format format;
  2.     memset(&format,0,sizeof(format));
  3.     format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  4.          if (-1 == ioctl(fd,VIDIOC_G_FMT,&format))
  5.          {
  6.              perror("VIDIOC_G_FMT(VIDEO_CAPTURE)");
  7.              return -1;
  8.          }

2.具体代码
 

  1. /*
  2.  * Author: Andrew Huang <bluedrum@163.com>
  3.  * query v4l2 device capabilities
  4.  * date: 2010/06/16
  5.  */
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <errno.h>

  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <fcntl.h>

  12. #include <linux/videodev2.h>

  13. #define PRINT_V4L printf

  14. #define PRINT_IOCTL_CMD(cmd) printf(" %15s = (0x%x)\n",#cmd,cmd)
  15. #define PRINT_IOCTL_CMD2(cmd,n) printf(" %-20s(%d) = (0x%x)\n",#cmd,n,cmd)

  16. #define PRINT_V4L_MEMBER(m) printf(" %-20s:",#m);
  17. #define PRINT_V4L_STRING(m) printf(" %-20s:\"%s\"\n",#m,m)
  18. #define PRINT_V4L_INT(m) printf(" %-20s:%d\n",#m,m)
  19. #define PRINT_V4L_INTX(m) printf(" %-20s:0x%x\n",#m,m)

  20. /* 显示enum 值的之一*/
  21. #define TEST_V4L_FLAG0(m,f) printf("%s",((m & f)==f)?#f:"")

  22. /* 显示一个组合值的所有内容 */
  23. #define PRINT_V4L_FLAGS(m) printf(" %-20s:0x%x [",#m,m) /* 组合值开始*/
  24. #define TEST_V4L_FLAG(m,f) printf("%s",((m & f)==f)?#f",":"") /* 组合值中间值,可以有多个*/
  25. #define PRINT_V4L_FLAGS2(m) printf("]\n") /* 组合值结束*/


  26. #define PRINT_INT(e) printf("%s=%d\n",#e,e)




  27. int v4l2_query_video_cap(int fd)
  28. {
  29.  int ret;
  30. struct v4l2_capability cap;
  31. ret = ioctl(fd, VIDIOC_QUERYCAP, &cap);
  32. if(ret < 0)
  33.     {
  34.      printf("get vidieo capability error,error code: %d \n", errno);
  35.      return ret;
  36.     }
  37.     PRINT_V4L("general info\n");
  38.     PRINT_IOCTL_CMD(VIDIOC_QUERYCAP);

  39.     PRINT_V4L_STRING(cap.driver);
  40.     PRINT_V4L_STRING(cap.card);
  41.     PRINT_V4L_STRING(cap.bus_info);
  42.     PRINT_V4L_MEMBER(cap.version);printf("%u.%u.%u\n",(cap.version>>16)&0XFF, (cap.version>>8)&0XFF,cap.version&0xFF);
  43.     
  44.     PRINT_V4L_FLAGS(cap.capabilities);    
  45.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_VIDEO_CAPTURE);
  46.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_VIDEO_OUTPUT);
  47.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_VIDEO_OVERLAY);
  48.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_VBI_CAPTURE);
  49.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_VBI_OUTPUT);
  50.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_SLICED_VBI_CAPTURE);
  51.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_SLICED_VBI_OUTPUT);
  52.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_RDS_CAPTURE);
  53.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_VIDEO_OUTPUT_OVERLAY);
  54.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_HW_FREQ_SEEK);
  55.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_TUNER);
  56.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_AUDIO);
  57.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_RADIO);
  58.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_READWRITE);
  59.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_ASYNCIO);
  60.     TEST_V4L_FLAG(cap.capabilities,V4L2_CAP_STREAMING);

  61.     PRINT_V4L_FLAGS2(cap.capabilities);
  62.    return 0;

  63. }

  64. static void _show_capture_type(enum v4l2_buf_type type)
  65. {
  66.        TEST_V4L_FLAG(type,V4L2_BUF_TYPE_VIDEO_CAPTURE);
  67.         TEST_V4L_FLAG(type,V4L2_BUF_TYPE_VIDEO_OUTPUT);
  68.         TEST_V4L_FLAG(type,V4L2_BUF_TYPE_VIDEO_OVERLAY);
  69.         TEST_V4L_FLAG(type,V4L2_BUF_TYPE_VBI_CAPTURE);
  70.         TEST_V4L_FLAG(type,V4L2_BUF_TYPE_VBI_OUTPUT);
  71.         TEST_V4L_FLAG(type,V4L2_BUF_TYPE_SLICED_VBI_CAPTURE);
  72.         TEST_V4L_FLAG(type,V4L2_BUF_TYPE_SLICED_VBI_OUTPUT);
  73.         TEST_V4L_FLAG(type,V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY);
  74.         TEST_V4L_FLAG(type,V4L2_BUF_TYPE_PRIVATE);    
  75. }


  76. //void show_video_std(v4l2_std_id std)
  77. void show_video_std(v4l2_std_id std)
  78. {
  79. // printf("%s:std=%x\n",__FUNCTION__,std);
  80.   TEST_V4L_FLAG(std,V4L2_STD_PAL_B);
  81.     TEST_V4L_FLAG(std,V4L2_STD_PAL_B1);
  82.     TEST_V4L_FLAG(std,V4L2_STD_PAL_G);
  83.     TEST_V4L_FLAG(std,V4L2_STD_PAL_H);
  84.     TEST_V4L_FLAG(std,V4L2_STD_PAL_I);
  85.     TEST_V4L_FLAG(std,V4L2_STD_PAL_D);
  86.     TEST_V4L_FLAG(std,V4L2_STD_PAL_D1);
  87.     TEST_V4L_FLAG(std,V4L2_STD_PAL_M);
  88.     TEST_V4L_FLAG(std,V4L2_STD_PAL_N);
  89.     TEST_V4L_FLAG(std,V4L2_STD_PAL_Nc);
  90.     TEST_V4L_FLAG(std,V4L2_STD_PAL_60);
  91.     TEST_V4L_FLAG(std,V4L2_STD_NTSC_M);
  92.     TEST_V4L_FLAG(std,V4L2_STD_NTSC_M_JP);
  93.     TEST_V4L_FLAG(std,V4L2_STD_NTSC_443);
  94.     TEST_V4L_FLAG(std,V4L2_STD_NTSC_M_KR);
  95.     TEST_V4L_FLAG(std,V4L2_STD_SECAM_B);
  96.     TEST_V4L_FLAG(std,V4L2_STD_SECAM_D);
  97.     TEST_V4L_FLAG(std,V4L2_STD_SECAM_G);
  98.     TEST_V4L_FLAG(std,V4L2_STD_SECAM_H);
  99.     TEST_V4L_FLAG(std,V4L2_STD_SECAM_K);
  100.     TEST_V4L_FLAG(std,V4L2_STD_SECAM_K1);
  101.     TEST_V4L_FLAG(std,V4L2_STD_SECAM_L);
  102.     TEST_V4L_FLAG(std,V4L2_STD_SECAM_LC);
  103.     TEST_V4L_FLAG(std,V4L2_STD_ATSC_8_VSB);
  104.     TEST_V4L_FLAG(std,V4L2_STD_ATSC_16_VSB);
  105. }



  106. int v4l2_enum_video_input(int fd)
  107. {
  108.   struct v4l2_input input;
  109.   int ret;
  110.   memset(&input, 0, sizeof(input));//initialize i.index=0;

  111.   PRINT_V4L("inputs\n");
  112.   
  113.   while(ret=ioctl(fd, VIDIOC_ENUMINPUT, &input)>=0)
  114.   {
  115.     PRINT_IOCTL_CMD2(VIDIOC_ENUMINPUT,input.index);
  116.     PRINT_V4L_INT(input.index);
  117.     PRINT_V4L_STRING(input.name);
  118.     
  119.     PRINT_V4L_MEMBER(input.type);
  120.     TEST_V4L_FLAG0(input.type,V4L2_INPUT_TYPE_TUNER);
  121.     TEST_V4L_FLAG0(input.type,V4L2_INPUT_TYPE_CAMERA);
  122.     PRINT_V4L("\n");

  123.     PRINT_V4L_INT(input.audioset);    
  124.     PRINT_V4L_INT(input.tuner);



  125.     PRINT_V4L_FLAGS(input.std);
  126.     
  127.     show_video_std(input.std);
  128.     PRINT_V4L_FLAGS2(input.std);
  129.     
  130.     
  131.    //printf("input i.name:%s; i.index :%d i.type = %s\n",i.name, i.index, i.type);
  132.    input.index++;
  133.   }

  134.   return ret;
  135. }

  136. static void _show_pixel_format(unsigned int pixelformat )
  137. {
  138.     if(pixelformat == 0)
  139.         {
  140.          printf("unknow pixelformat %d\n",pixelformat);
  141.          return ;
  142.         }
  143.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_RGB332);
  144.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_RGB444);
  145.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_RGB555);
  146.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_RGB565);
  147.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_RGB555X);
  148.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_RGB565X);
  149.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_BGR24);
  150.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_RGB24);
  151.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_BGR32);
  152.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_RGB32);
  153.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_GREY);
  154.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_Y16);
  155.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_PAL8);
  156.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YVU410);
  157.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YVU420);
  158.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YUYV);
  159.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_UYVY);
  160.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YUV422P);
  161.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YUV411P);
  162.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_Y41P);
  163.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YUV444);
  164.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YUV555);
  165.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YUV565);
  166.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YUV32);
  167.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_NV12);
  168.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_NV21);
  169.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YUV410);
  170.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YUV420);
  171.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YYUV);
  172.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_HI240);
  173.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_HM12);
  174.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_SBGGR8);
  175.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_SGBRG8);
  176.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_SGRBG10);
  177.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_SGRBG10DPCM8);
  178.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_SBGGR16);
  179.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_MJPEG);
  180.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_JPEG);
  181.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_DV);
  182.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_MPEG);
  183.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_WNVA);
  184.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_SN9C10X);
  185.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_PWC1);
  186.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_PWC2);
  187.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_ET61X251);
  188.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_SPCA501);
  189.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_SPCA505);
  190.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_SPCA508);
  191.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_SPCA561);
  192.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_PAC207);
  193.         TEST_V4L_FLAG(pixelformat,V4L2_PIX_FMT_YVYU);    
  194. }

  195. int v4l2_enum_video_format(int fd,enum v4l2_buf_type type,char * title)
  196. {
  197.    struct v4l2_fmtdesc fmtdesc;
  198.    int i=0;
  199.    memset(&fmtdesc, 0, sizeof(fmtdesc));
  200.    


  201.    PRINT_V4L("%s\n",title);

  202.    for(i=0;;i++)
  203.        {
  204.        
  205.      fmtdesc.index = i;
  206.       fmtdesc.type = type;
  207.     
  208.      if(-1== ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc))
  209.         break;
  210.    
  211.        
  212.               
  213.         PRINT_IOCTL_CMD(VIDIOC_ENUM_FMT);
  214.         PRINT_V4L_INT(fmtdesc.index);
  215.         
  216.         PRINT_V4L_FLAGS(fmtdesc.type);
  217.         _show_capture_type(fmtdesc.type);
  218.         PRINT_V4L_FLAGS2(fmtdesc.type);

  219.         PRINT_V4L_INT(fmtdesc.flags);
  220.         PRINT_V4L_STRING(fmtdesc.description);


  221.         PRINT_V4L_FLAGS(fmtdesc.pixelformat);
  222.         _show_pixel_format(fmtdesc.pixelformat);    
  223.         PRINT_V4L_FLAGS2(fmtdesc.pixelformat);

  224.         

  225.         
  226.      
  227.        
  228.        }
  229.   return i;
  230.   
  231. }

  232. #define v4l2_enum_foramt(fd,type) v4l2_enum_video_format(fd,type,#type)
  233. #define v4l2_enum_video_capture(fd) v4l2_enum_foramt(fd,V4L2_BUF_TYPE_VIDEO_CAPTURE)
  234. #define v4l2_enum_video_overlay(fd) v4l2_enum_foramt(fd,V4L2_BUF_TYPE_VIDEO_OVERLAY)
  235. #define v4l2_enum_video_vbi_capture(fd) v4l2_enum_foramt(fd,V4L2_CAP_VBI_CAPTURE)



  236. void _show_v4l2_field(unsigned v4l2_filed)
  237. {
  238.       PRINT_V4L_MEMBER(v4l2_filed);
  239.       TEST_V4L_FLAG0(v4l2_filed,V4L2_FIELD_ANY);
  240.      TEST_V4L_FLAG0(v4l2_filed,V4L2_FIELD_NONE);
  241.      TEST_V4L_FLAG0(v4l2_filed,V4L2_FIELD_TOP);
  242.      TEST_V4L_FLAG0(v4l2_filed,V4L2_FIELD_BOTTOM);
  243.      TEST_V4L_FLAG0(v4l2_filed,V4L2_FIELD_INTERLACED);
  244.      TEST_V4L_FLAG0(v4l2_filed,V4L2_FIELD_SEQ_TB);
  245.      TEST_V4L_FLAG0(v4l2_filed,V4L2_FIELD_SEQ_BT);
  246.      TEST_V4L_FLAG0(v4l2_filed,V4L2_FIELD_ALTERNATE);
  247.      TEST_V4L_FLAG0(v4l2_filed,V4L2_FIELD_INTERLACED_TB);
  248.      TEST_V4L_FLAG0(v4l2_filed,V4L2_FIELD_INTERLACED_BT);
  249.      PRINT_V4L("\n");
  250. }

  251. int v4l2_get_capture_format(int fd)
  252. {
  253.     struct v4l2_format format;
  254.     memset(&format,0,sizeof(format));
  255.     format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  256.          if (-1 == ioctl(fd,VIDIOC_G_FMT,&format))
  257.          {
  258.              perror("VIDIOC_G_FMT(VIDEO_CAPTURE)");
  259.              return -1;
  260.          }

  261.      PRINT_IOCTL_CMD(VIDIOC_G_FMT);
  262.      PRINT_V4L_FLAGS(format.type);
  263.      _show_capture_type(format.type);
  264.      PRINT_V4L_FLAGS2(format.type);


  265.     
  266.      PRINT_V4L_INT(format.fmt.pix.width);
  267.      PRINT_V4L_INT(format.fmt.pix.height);
  268.      _show_pixel_format(format.fmt.pix.pixelformat);
  269.     
  270.      PRINT_V4L_INT(format.fmt.pix.bytesperline);
  271.      PRINT_V4L_INT(format.fmt.pix.sizeimage);

  272.     

  273.      _show_v4l2_field(format.fmt.pix.field);

  274.     

  275.     return 0;        
  276. }

  277. int main(int argc,char * argv[])
  278. {
  279.    char dev_name[64] = "/dev/video0";
  280.    int cam_fd =-1;

  281.    if(argc>1)
  282.        {
  283.         strncpy(dev_name,argv[1],sizeof(dev_name)-1);
  284.        }

  285.    printf("open device %s\n",dev_name);
  286.     cam_fd = open(dev_name,O_RDWR|O_NONBLOCK);

  287.     if(cam_fd == -1)
  288.         {
  289.          printf("open failure \n");
  290.          return -1;
  291.         }


  292.     printf("### v4l2 device info [%s] ###\n",dev_name);

  293.     
  294.    v4l2_query_video_cap(cam_fd);
  295.    v4l2_enum_video_input(cam_fd);

  296.   v4l2_enum_video_capture(cam_fd);
  297.    

  298.    v4l2_get_capture_format(cam_fd);
  299.     close(cam_fd);

  300.    return 0;
  301.     
  302. }

4.测试样例:
   
  1. [root@FriendlyARM 3]# ./test_v4l2 /dev/video0
  2. open device /dev/video0
  3. ### v4l2 device info [/dev/video0] ###
  4. general info
  5. VIDIOC_QUERYCAP = (0x80685600)
  6. cap.driver :"Samsung FIMC Dris3c-fimc0"
  7. cap.card :"s3c-fimc0"
  8. cap.bus_info :"FIMC AHB-bus"
  9. cap.version :0.0.0
  10. cap.capabilities :0x4000005 [V4L2_CAP_VIDEO_CAPTURE,V4L2_CAP_VIDEO_OVERLAY,V4L2_CAP_STREAMING,]
  11. inputs
  12. VIDIOC_ENUMINPUT (0) = (0xc050561a)
  13. input.index :0
  14. input.name :"External Camera Input"
  15. input.type :V4L2_INPUT_TYPE_CAMERA
  16. input.audioset :1
  17. input.tuner :0
  18. input.std :0x1007 [V4L2_STD_PAL_B,V4L2_STD_PAL_B1,V4L2_STD_PAL_G,V4L2_STD_NTSC_M,]
  19. VIDIOC_ENUMINPUT (1) = (0xc050561a)
  20. input.index :1
  21. input.name :"Memory Input"
  22. input.type :V4L2_INPUT_TYPE_CAMERA
  23. input.audioset :2
  24. input.tuner :0
  25. input.std :0x1007 [V4L2_STD_PAL_B,V4L2_STD_PAL_B1,V4L2_STD_PAL_G,V4L2_STD_NTSC_M,]
  26. VIDIOC_G_FMT = (0xc0cc5604)
  27. format.type :0x1 [V4L2_BUF_TYPE_VIDEO_CAPTURE,]
  28. format.fmt.pix.width:0
  29. format.fmt.pix.height:0
  30. unknow pixelformat 0
  31. format.fmt.pix.bytesperline:0
  32. format.fmt.pix.sizeimage:0
  33. v4l2_filed :V4L2_FIELD_ANY
  34. [root@FriendlyARM 3]#
  35. ----------------------------------------------------------------------------------------------------------------

  36. [root@FriendlyARM 3]# ./test_v4l2 /dev/video1
  37. open device /dev/video1
  38. ### v4l2 device info [/dev/video1] ###
  39. general info
  40. VIDIOC_QUERYCAP = (0x80685600)
  41. cap.driver :"Samsung FIMC Dris3c-fimc1"
  42. cap.card :"s3c-fimc1"
  43. cap.bus_info :"FIMC AHB-bus"
  44. cap.version :0.0.0
  45. cap.capabilities :0x4000005 [V4L2_CAP_VIDEO_CAPTURE,V4L2_CAP_VIDEO_OVERLAY,V4L2_CAP_STREAMING,]
  46. inputs
  47. VIDIOC_ENUMINPUT (0) = (0xc050561a)
  48. input.index :0
  49. input.name :"External Camera Input"
  50. input.type :V4L2_INPUT_TYPE_CAMERA
  51. input.audioset :1
  52. input.tuner :0
  53. input.std :0x1007 [V4L2_STD_PAL_B,V4L2_STD_PAL_B1,V4L2_STD_PAL_G,V4L2_STD_NTSC_M,]
  54. VIDIOC_ENUMINPUT (1) = (0xc050561a)
  55. input.index :1
  56. input.name :"Memory Input"
  57. input.type :V4L2_INPUT_TYPE_CAMERA
  58. input.audioset :2
  59. input.tuner :0
  60. input.std :0x1007 [V4L2_STD_PAL_B,V4L2_STD_PAL_B1,V4L2_STD_PAL_G,V4L2_STD_NTSC_M,]
  61. VIDIOC_G_FMT = (0xc0cc5604)
  62. format.type :0x1 [V4L2_BUF_TYPE_VIDEO_CAPTURE,]
  63. format.fmt.pix.width:0
  64. format.fmt.pix.height:0
  65. unknow pixelformat 0
  66. format.fmt.pix.bytesperline:0
  67. format.fmt.pix.sizeimage:0
  68. v4l2_filed :V4L2_FIELD_ANY
  69. [root@FriendlyARM 3]#


  70. --------------------------------------------------------------------------------------------------------------------------

  71. [root@FriendlyARM 3]# ./test_v4l2 /dev/video2
  72. open device /dev/video2
  73. ### v4l2 device info [/dev/video2] ###
  74. general info
  75. VIDIOC_QUERYCAP = (0x80685600)
  76. cap.driver :"zc3xx"
  77. cap.card :"PC Camera"
  78. cap.bus_info :"s3c24xx"
  79. cap.version :2.3.0
  80. cap.capabilities :0x5000001 [V4L2_CAP_VIDEO_CAPTURE,V4L2_CAP_READWRITE,V4L2_CAP_STREAMING,]
  81. inputs
  82. VIDIOC_ENUMINPUT (0) = (0xc050561a)
  83. input.index :0
  84. input.name :"zc3xx"
  85. input.type :V4L2_INPUT_TYPE_CAMERA
  86. input.audioset :0
  87. input.tuner :0
  88. input.std :0x0 []
  89. VIDIOC_G_FMT = (0xc0cc5604)
  90. format.type :0x1 [V4L2_BUF_TYPE_VIDEO_CAPTURE,]
  91. format.fmt.pix.width:640
  92. format.fmt.pix.height:480
  93. V4L2_PIX_FMT_JPEG, format.fmt.pix.bytesperline:640
  94. format.fmt.pix.sizeimage:115790
  95. v4l2_filed :V4L2_FIELD_ANYV4L2_FIELD_NONE
  96. [root@FriendlyARM 3]#
  
更复杂的ioctl里,借鉴了开源项目xrawtv中的v4l_info.c一节,具体代码参见
阅读(925) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~