Embedded System/Video4Linux2

[V4L2] Querying Capabilities

임베지수 2017. 4. 2. 14:43

 

 

 

IOCTL

For using V4L2, learn about ioctl. What's ioctl? ioctl is abbreviation of Input/Output Control. In computing, ioctl is a system call for device-specific input/output operations and other operations which is can not be expressed by regular system calls.

 

* ioctl definition *

/* Perform the I/O control operation specified by REQUEST on FD.
    One argument may follow; its presence and type depend on REQUEST.
    Return Value depend on REQUEST. Usually -1 indicates error. */


 int ioctl(int __fd, unsigned long int __request, ...) __THROW;

 

 

Querying Capabilities

All V4L2 devices support the VIDIOC_QUERYCAP ioctl. It is identify kernel devices compatible with this specification and to obtain information about driver and hardware capabilities. The ioctl takes a pointer to a struct v4l2_capability which is filled by the driver. When the driver is not compatible with the specification the ioctl returns an EINVAL error code.

 

 

* v4l2_capability definition *

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  reversed[4];
};

 

 

Example Code

 

int fd, ret;
struct v4l2_capability capa;

fd=open("/dev/video0", O_RDWR);

if(fd<0)
{
	printf("Failed to open device\n");
	return -1;
}

ret=ioctl(fd, VIDIOC_QUERYCAP, &capa);

if(ret<0)
{
	printf("Failed to get from capabilities\n");
	return -1;
}

printf("------------------------------------");
printf("  Name : %s\n", capa.card);
printf("  Driver : %s\n", capa.driver);
printf("  Bus_info : %s\n", capa.bus_info);
printf("  Version : %d\n", capa.version);
printf("------------------------------------");

close(fd);

 

This is my webcam information.

 

 

 

 

'Embedded System > Video4Linux2' 카테고리의 다른 글

[V4L2] 이진화, 선 긋기  (5) 2017.04.02
[V4L2] Memory Mapping  (0) 2017.04.02
[V4L2] Data Formats  (3) 2017.04.02
[V4L2] Opening and Closing Devices  (0) 2017.04.02
V4L2 API를 이용하여 영상획득 성공!!  (0) 2017.04.02