diff mbox

libv4l1: move VIDIOCGVBIFMT and VIDIOCSVBIFMT into libv4l1

Message ID 1275906191-26135-1-git-send-email-huzaifas@redhat.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Huzaifa Sidhpurwala June 7, 2010, 10:23 a.m. UTC
None
diff mbox

Patch

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index 263d564..6d6caa6 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -1143,6 +1143,71 @@  int v4l1_ioctl(int fd, unsigned long int request, ...)
 
 	}
 
+	case VIDIOCSVBIFMT: {
+		struct vbi_format *fmt = arg;
+		struct v4l2_format fmt2;
+
+		if (VIDEO_PALETTE_RAW != fmt->sample_format) {
+			result = -EINVAL;
+			break;
+		}
+
+		fmt2.type = V4L2_BUF_TYPE_VBI_CAPTURE;
+		fmt2.fmt.vbi.samples_per_line = fmt->samples_per_line;
+		fmt2.fmt.vbi.sampling_rate    = fmt->sampling_rate;
+		fmt2.fmt.vbi.sample_format    = V4L2_PIX_FMT_GREY;
+		fmt2.fmt.vbi.start[0]         = fmt->start[0];
+		fmt2.fmt.vbi.count[0]         = fmt->count[0];
+		fmt2.fmt.vbi.start[1]         = fmt->start[1];
+		fmt2.fmt.vbi.count[1]         = fmt->count[1];
+		fmt2.fmt.vbi.flags            = fmt->flags;
+
+		result  = v4l2_ioctl(fd, VIDIOC_TRY_FMT, fmt2);
+		if (result < 0)
+			break;
+
+		if (fmt2.fmt.vbi.samples_per_line != fmt->samples_per_line ||
+		fmt2.fmt.vbi.sampling_rate    != fmt->sampling_rate    ||
+		fmt2.fmt.vbi.sample_format    != V4L2_PIX_FMT_GREY     ||
+		fmt2.fmt.vbi.start[0]         != fmt->start[0]         ||
+		fmt2.fmt.vbi.count[0]         != fmt->count[0]         ||
+		fmt2.fmt.vbi.start[1]         != fmt->start[1]         ||
+		fmt2.fmt.vbi.count[1]         != fmt->count[1]         ||
+		fmt2.fmt.vbi.flags            != fmt->flags) {
+			result = -EINVAL;
+			break;
+		}
+		result = v4l2_ioctl(fd, VIDIOC_S_FMT, fmt2);
+
+	}
+
+	case VIDIOCGVBIFMT: {
+		struct vbi_format *fmt = arg;
+		struct v4l2_format fmt2 = { 0, };
+
+		fmt2.type = V4L2_BUF_TYPE_VBI_CAPTURE;
+		result = v4l2_ioctl(fd, VIDIOC_G_FMT, &fmt2);
+
+		if (result < 0)
+			break;
+
+		if (fmt2.fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) {
+			result = -EINVAL;
+			break;
+		}
+
+		fmt->samples_per_line = fmt2.fmt.vbi.samples_per_line;
+		fmt->sampling_rate    = fmt2.fmt.vbi.sampling_rate;
+		fmt->sample_format    = VIDEO_PALETTE_RAW;
+		fmt->start[0]         = fmt2.fmt.vbi.start[0];
+		fmt->count[0]         = fmt2.fmt.vbi.count[0];
+		fmt->start[1]         = fmt2.fmt.vbi.start[1];
+		fmt->count[1]         = fmt2.fmt.vbi.count[1];
+		fmt->flags            = fmt2.fmt.vbi.flags & 0x03;
+
+		break;
+	}
+
 	default:
 		/* Pass through libv4l2 for applications which are using v4l2 through
 		   libv4l1 (this can happen with the v4l1compat.so wrapper preloaded */