Camera mirror control

Jonathan Corbet corbet at lwn.net
Tue Dec 19 23:02:51 EST 2006


>From the current discussion, I gather that reasonable people differ on
the right setting for the horizontal flip (mirror) option on the
camera.  The following primitive little program will let you mess with
it at runtime.  Run without arguments, it will print the current flip
setting; give it 0 or 1 to change it.  Proper UI and error checking left
as an exercise for the reader.

jon

/* shflip.c */
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <linux/types.h>
#include <sys/ioctl.h>
#include <linux/videodev.h>
#include <fcntl.h>


main(int argc, char *argv[])
{
	int fd = open("/dev/video", O_RDWR);
	int ret;
	struct v4l2_control ctrl;

	memset(&ctrl, 0, sizeof(ctrl));
	ctrl.id = V4L2_CID_HFLIP;
	ret = ioctl(fd, VIDIOC_G_CTRL, &ctrl);
	printf("Get H flip, ret %d value %d\n", ret, ctrl.value);
	if (argc > 1) {
		ctrl.value = atoi(argv[1]);
		ret = ioctl(fd, VIDIOC_S_CTRL, &ctrl);
		printf("Set to %d, ret %d\n", ctrl.value, ret);
	}
}



More information about the Devel mailing list