hvaib...@ti.com wrote:
From: Vaibhav Hiremathhvaib...@ti.com
Features Supported -
1. Provides V4L2 user interface for the video pipelines of DSS
2. Basic streaming working on LCD, DVI and TV.
3. Works on latest DSS2 library from Tomi
4. Support for various pixel formats like YUV, UYVY, RGB32, RGB24,
RGB565
5. Supports Alpha blending.
6. Supports Color keying both source and destination.
7. Supports rotation.
8. Supports cropping.
9. Supports Background color setting.
10. Allocated buffers to only needed size
Signed-off-by: Vaibhav Hiremathhvaib...@ti.com
snip
diff --git a/drivers/media/video/omap/omap_voutlib.c
b/drivers/media/video/omap/omap_voutlib.c
new file mode 100644
index 000..05c0e17
--- /dev/null
+++ b/drivers/media/video/omap/omap_voutlib.c
@@ -0,0 +1,258 @@
+/*
+ * omap_voutlib.c
+ *
+ * Copyright (C) 2005-2010 Texas Instruments.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed as is without any warranty of any
+ * kind, whether express or implied.
+ *
+ * Based on the OMAP2 camera driver
+ * Video-for-Linux (Version 2) camera capture driver for
+ * the OMAP24xx camera controller.
+ *
+ * Author: Andy Lowe (sou...@mvista.com)
+ *
+ * Copyright (C) 2004 MontaVista Software, Inc.
+ * Copyright (C) 2010 Texas Instruments.
+ *
+ */
+
+#includelinux/module.h
+#includelinux/errno.h
+#includelinux/kernel.h
+#includelinux/types.h
+#includelinux/videodev2.h
+
+MODULE_AUTHOR(Texas Instruments);
+MODULE_DESCRIPTION(OMAP Video library);
+MODULE_LICENSE(GPL);
+
+/* Return the default overlay cropping rectangle in crop given the image
+ * size in pix and the video display size in fbuf. The default
+ * cropping rectangle is the largest rectangle no larger than the capture size
+ * that will fit on the display. The default cropping rectangle is centered in
+ * the image. All dimensions and offsets are rounded down to even numbers.
+ */
+void omap_vout_default_crop(struct v4l2_pix_format *pix,
+ struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop)
+{
+ crop-width = (pix-width fbuf-fmt.width) ?
+ pix-width : fbuf-fmt.width;
+ crop-height = (pix-height fbuf-fmt.height) ?
+ pix-height : fbuf-fmt.height;
+ crop-width= ~1;
+ crop-height= ~1;
+ crop-left = ((pix-width - crop-width) 1) ~1;
+ crop-top = ((pix-height - crop-height) 1) ~1;
+}
+EXPORT_SYMBOL_GPL(omap_vout_default_crop);
+
+/* Given a new render window in new_win, adjust the window to the
+ * nearest supported configuration. The adjusted window parameters are
+ * returned in new_win.
+ * Returns zero if succesful, or -EINVAL if the requested window is
+ * impossible and cannot reasonably be adjusted.
+ */
+int omap_vout_try_window(struct v4l2_framebuffer *fbuf,
+ struct v4l2_window *new_win)
+{
+ struct v4l2_rect try_win;
+
+ /* make a working copy of the new_win rectangle */
+ try_win = new_win-w;
+
+ /* adjust the preview window so it fits on the display by clipping any
+* offscreen areas
+*/
+ if (try_win.left 0) {
+ try_win.width += try_win.left;
+ try_win.left = 0;
+ }
+ if (try_win.top 0) {
+ try_win.height += try_win.top;
+ try_win.top = 0;
+ }
+ try_win.width = (try_win.width fbuf-fmt.width) ?
+ try_win.width : fbuf-fmt.width;
+ try_win.height = (try_win.height fbuf-fmt.height) ?
+ try_win.height : fbuf-fmt.height;
+ if (try_win.left + try_win.width fbuf-fmt.width)
+ try_win.width = fbuf-fmt.width - try_win.left;
+ if (try_win.top + try_win.height fbuf-fmt.height)
+ try_win.height = fbuf-fmt.height - try_win.top;
+ try_win.width= ~1;
+ try_win.height= ~1;
+
+ if (try_win.width= 0 || try_win.height= 0)
+ return -EINVAL;
+
+ /* We now have a valid preview window, so go with it */
+ new_win-w = try_win;
+ new_win-field = V4L2_FIELD_ANY;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(omap_vout_try_window);
+
+/* Given a new render window in new_win, adjust the window to the
+ * nearest supported configuration. The image cropping window in crop
+ * will also be adjusted if necessary. Preference is given to keeping the
+ * the window as close to the requested configuration as possible. If
+ * successful, new_win, vout-win, and crop are updated.
+ * Returns zero if succesful, or -EINVAL if the requested preview window is
+ * impossible and cannot reasonably be adjusted.
+ */
+int omap_vout_new_window(struct v4l2_rect *crop,
+ struct v4l2_window *win, struct v4l2_framebuffer *fbuf,
+ struct v4l2_window *new_win)
+{
+ int err;
+
+ err = omap_vout_try_window(fbuf, new_win);
+ if