[PATCH] libv4l1: move VIDIOCGVBIFMT and VIDIOCSVBIFMT into libv4l1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Huzaifa Sidhpurwala <huzaifas@xxxxxxxxxx>

move VIDIOCGVBIFMT and VIDIOCSVBIFMT into libv4l1

Signed-of-by: Huzaifa Sidhpurwala <huzaifas@xxxxxxxxxx>
---
 lib/libv4l1/libv4l1.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)

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 */
-- 
1.6.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux