From 61befe510e1c090736031088c1d177c52b262b18 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 23 Oct 2009 12:02:00 +0200 Subject: [PATCH] libv4l: Add support for STV0680 raw bayer data Priority: normal Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- lib/ChangeLog | 3 ++- lib/libv4lconvert/Makefile | 1 + lib/libv4lconvert/libv4lconvert-priv.h | 7 ++++++ lib/libv4lconvert/libv4lconvert.c | 7 ++++++ lib/libv4lconvert/stv0680.c | 41 ++++++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 lib/libv4lconvert/stv0680.c diff --git a/lib/ChangeLog b/lib/ChangeLog index edeac95..1357365 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -3,7 +3,8 @@ libv4l-0.6.3 * Add more laptop models to the upside down devices table * Improved mr97310a decompression * Add support for decompressing yuv420 planar JPEG (one component per SOS, - 3 SOS per frame) + 3 SOS per frame), this is needed for w9968cf based cams +* Add support for STV0680 raw bayer data libv4l-0.6.2 ------------ diff --git a/lib/libv4lconvert/Makefile b/lib/libv4lconvert/Makefile index 5cdccd5..839cbd5 100644 --- a/lib/libv4lconvert/Makefile +++ b/lib/libv4lconvert/Makefile @@ -15,6 +15,7 @@ endif CONVERT_OBJS = libv4lconvert.o tinyjpeg.o sn9c10x.o sn9c20x.o pac207.o \ mr97310a.o flip.o crop.o jidctflt.o spca561-decompress.o \ rgbyuv.o sn9c2028-decomp.o spca501.o sq905c.o bayer.o hm12.o \ + stv0680.o \ control/libv4lcontrol.o processing/libv4lprocessing.o \ processing/whitebalance.o processing/autogain.o \ processing/gamma.o helper.o diff --git a/lib/libv4lconvert/libv4lconvert-priv.h b/lib/libv4lconvert/libv4lconvert-priv.h index f16d05d..d16f500 100644 --- a/lib/libv4lconvert/libv4lconvert-priv.h +++ b/lib/libv4lconvert/libv4lconvert-priv.h @@ -96,6 +96,10 @@ #define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */ #endif +#ifndef V4L2_PIX_FMT_STV0680 +#define V4L2_PIX_FMT_STV0680 v4l2_fourcc('S', '6', '8', '0') +#endif + #ifndef V4L2_FMT_FLAG_EMULATED #define V4L2_FMT_FLAG_EMULATED 0x0002 #endif @@ -233,6 +237,9 @@ void v4lconvert_decode_sn9c2028(const unsigned char *src, unsigned char *dst, void v4lconvert_decode_sq905c(const unsigned char *src, unsigned char *dst, int width, int height); +void v4lconvert_decode_stv0680(const unsigned char *src, unsigned char *dst, + int width, int height); + void v4lconvert_bayer_to_rgb24(const unsigned char *bayer, unsigned char *rgb, int width, int height, unsigned int pixfmt); diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c index 9bceb1a..38da959 100644 --- a/lib/libv4lconvert/libv4lconvert.c +++ b/lib/libv4lconvert/libv4lconvert.c @@ -52,6 +52,7 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] = { { V4L2_PIX_FMT_SGBRG8, V4LCONVERT_NEEDS_CONVERSION }, { V4L2_PIX_FMT_SGRBG8, V4LCONVERT_NEEDS_CONVERSION }, { V4L2_PIX_FMT_SRGGB8, V4LCONVERT_NEEDS_CONVERSION }, + { V4L2_PIX_FMT_STV0680, V4LCONVERT_NEEDS_CONVERSION }, { V4L2_PIX_FMT_SPCA501, V4LCONVERT_NEEDS_CONVERSION }, { V4L2_PIX_FMT_SPCA505, V4LCONVERT_NEEDS_CONVERSION }, { V4L2_PIX_FMT_SPCA508, V4LCONVERT_NEEDS_CONVERSION }, @@ -500,6 +501,7 @@ static int v4lconvert_processing_needs_double_conversion( case V4L2_PIX_FMT_SGBRG8: case V4L2_PIX_FMT_SGRBG8: case V4L2_PIX_FMT_SRGGB8: + case V4L2_PIX_FMT_STV0680: return 0; } switch (dest_pix_fmt) { @@ -731,6 +733,7 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, case V4L2_PIX_FMT_MR97310A: case V4L2_PIX_FMT_SN9C2028: case V4L2_PIX_FMT_SQ905C: + case V4L2_PIX_FMT_STV0680: /* Not compressed but needs some shuffling */ { unsigned char *tmpbuf; struct v4l2_format tmpfmt = *fmt; @@ -770,6 +773,10 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, v4lconvert_decode_sq905c(src, tmpbuf, width, height); tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SRGGB8; break; + case V4L2_PIX_FMT_STV0680: + v4lconvert_decode_stv0680(src, tmpbuf, width, height); + tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SRGGB8; + break; } /* Do processing on the tmp buffer, because doing it on bayer data is cheaper, and bayer == rgb and our dest_fmt may be yuv */ diff --git a/lib/libv4lconvert/stv0680.c b/lib/libv4lconvert/stv0680.c new file mode 100644 index 0000000..024a212 --- /dev/null +++ b/lib/libv4lconvert/stv0680.c @@ -0,0 +1,41 @@ +/* + * stv0680.c + * + * Copyright (c) 2009 Hans de Goede + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "libv4lconvert-priv.h" + +/* The stv0640 first sends all the red/green pixels for a line (so 1/2 width) + and then all the green/blue pixels in that line, shuffle this to a regular + RGGB bayer pattern. */ +void v4lconvert_decode_stv0680(const unsigned char *src, unsigned char *dst, + int width, int height) +{ + int x, y; + const unsigned char *src1 = src; + const unsigned char *src2 = src + width / 2; + + for (y = 0; y < height; y++) { + for (x = 0; x < width / 2; x++) { + *dst++ = *src1++; + *dst++ = *src2++; + } + src1 += width / 2; + src2 += width / 2; + } +} -- 2.7.4