示例#1
0
int src_v4l2_set_controls(src_t *src)
{
	src_v4l2_t *s = (src_v4l2_t *) src->state;
	struct v4l2_queryctrl queryctrl;
	int c;
	
	memset(&queryctrl, 0, sizeof(queryctrl));
	
	if(src->list & SRC_LIST_CONTROLS)
	{
		HEAD("%-25s %-15s %s", "Available Controls", "Current Value", "Range");
		MSG("%-25s %-15s %s",  "------------------", "-------------", "-----");
		
		/* Display normal controls. */
		for(c = V4L2_CID_BASE; c < V4L2_CID_LASTP1; c++)
		{
			queryctrl.id = c;
			
			if(ioctl(s->fd, VIDIOC_QUERYCTRL, &queryctrl)) continue;
			src_v4l2_show_control(src, &queryctrl);
		}
		
		/* Display device-specific controls. */
		for(c = V4L2_CID_PRIVATE_BASE; ; c++)
		{
			queryctrl.id = c;
			
			if(ioctl(s->fd, VIDIOC_QUERYCTRL, &queryctrl)) break;
			src_v4l2_show_control(src, &queryctrl);
		}
	}
	
	/* Scan normal controls. */
	for(c = V4L2_CID_BASE; c < V4L2_CID_LASTP1; c++)
	{
		queryctrl.id = c;
		
		if(ioctl(s->fd, VIDIOC_QUERYCTRL, &queryctrl)) continue;
		src_v4l2_set_control(src, &queryctrl);
	}
	
	/* Scan device-specific controls. */
	for(c = V4L2_CID_PRIVATE_BASE; ; c++)
	{
		queryctrl.id = c;
		
		if(ioctl(s->fd, VIDIOC_QUERYCTRL, &queryctrl)) break;
		src_v4l2_set_control(src, &queryctrl);
	}
	
	return(0);
}
示例#2
0
int src_v4l2_set_controls(src_t *src)
{
	src_v4l2_t *s = (src_v4l2_t *) src->state;
	struct v4l2_queryctrl queryctrl;
    struct v4l2_control control;
	int c, rc;
	
	memset(&queryctrl, 0, sizeof(queryctrl));
#if 1	
	if(src->list & SRC_LIST_CONTROLS)
	{
		HEAD("%-25s %-15s %s", "Available Controls", "Current Value", "Range");
		MSG("%-25s %-15s %s",  "------------------", "-------------", "-----");
		
		/* Display all controls */
		queryctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
		while (0 == ioctl(s->fd, VIDIOC_QUERYCTRL, &queryctrl))
		{
			src_v4l2_show_control(src, &queryctrl);
			queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
		}
	}
	
	/* Set all controls */
	queryctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
	while (0 == ioctl(s->fd, VIDIOC_QUERYCTRL, &queryctrl))
	{
		src_v4l2_set_control(src, &queryctrl);
		queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
	}
#endif    
    rc = 0;
    if (src->exposure != 0xf0000000) {
        memset(&control, 0, sizeof(control));
        control.id = V4L2_CID_EXPOSURE;
        rc = ioctl(s->fd, VIDIOC_G_CTRL, &control);
        fprintf(stderr, "rc: %d - get value: %d\n", rc, control.value);
        control.value = src->exposure;
		rc = ioctl(s->fd, VIDIOC_S_CTRL, &control);
        fprintf(stderr, "rc: %d - set src->exposure: %d\n", rc, src->exposure);
    }
    
    if (src->hflip != 0xf0000000) {
        memset(&control, 0, sizeof(control));
        control.id = V4L2_CID_HFLIP;
        rc = ioctl(s->fd, VIDIOC_G_CTRL, &control);
        fprintf(stderr, "rc: %d - get value: %d\n", rc, control.value);
        control.value = src->hflip;
		rc = ioctl(s->fd, VIDIOC_S_CTRL, &control);
        fprintf(stderr, "rc: %d - set value: %d\n", rc, control.value);
    }
    if (src->vflip != 0xf0000000) {
        memset(&control, 0, sizeof(control));
        control.id = V4L2_CID_VFLIP;
        rc = ioctl(s->fd, VIDIOC_G_CTRL, &control);
        fprintf(stderr, "rc: %d - value: %d\n", rc, control.value);
        control.value = src->vflip;
		rc = ioctl(s->fd, VIDIOC_S_CTRL, &control);
        fprintf(stderr, "rc: %d - set value: %d\n", rc, control.value);
    }
	return(rc);
}