diff mbox

libv4l1: Move VIDIOCSFBUF into libv4l1

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

Commit Message

Huzaifa Sidhpurwala June 1, 2010, 9:37 a.m. UTC
None
diff mbox

Patch

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index ac3c2d9..877508c 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -847,6 +847,38 @@  int v4l1_ioctl(int fd, unsigned long int request, ...)
 				(buffer->width * buffer->depth + 7) & 7;
 			buffer->bytesperline >>= 3;
 		}
+		break;
+	}
+
+	case VIDIOCSFBUF: {
+		struct video_buffer *buffer = arg;
+		struct v4l2_framebuffer fbuf = { 0, };
+
+		fbuf.base = buffer->base;
+		fbuf.fmt.height = buffer->height;
+		fbuf.fmt.width = buffer->width;
+
+		switch (buffer->depth) {
+		case 8:
+			fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB332;
+			break;
+		case 15:
+			fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB555;
+			break;
+		case 16:
+			fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB565;
+			break;
+		case 24:
+			fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR24;
+			break;
+		case 32:
+			fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR32;
+			break;
+		}
+
+		fbuf.fmt.bytesperline = buffer->bytesperline;
+		result = v4l2_ioctl(fd, VIDIOC_G_FBUF, buffer);
+		break;
 	}
 
 	default: