Commit 585553ec authored by Jonathan Corbet's avatar Jonathan Corbet Committed by Mauro Carvalho Chehab

V4L/DVB (5469): Add raw bayer support to the ov7670 driver

Add raw bayer support to the ov7670 driver
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 77d5140f
...@@ -165,6 +165,10 @@ MODULE_LICENSE("GPL"); ...@@ -165,6 +165,10 @@ MODULE_LICENSE("GPL");
#define REG_GFIX 0x69 /* Fix gain control */ #define REG_GFIX 0x69 /* Fix gain control */
#define REG_REG76 0x76 /* OV's name */
#define R76_BLKPCOR 0x80 /* Black pixel correction enable */
#define R76_WHTPCOR 0x40 /* White pixel correction enable */
#define REG_RGB444 0x8c /* RGB 444 control */ #define REG_RGB444 0x8c /* RGB 444 control */
#define R444_ENABLE 0x02 /* Turn on RGB444, overrides 5x5 */ #define R444_ENABLE 0x02 /* Turn on RGB444, overrides 5x5 */
#define R444_RGBX 0x01 /* Empty nibble at end */ #define R444_RGBX 0x01 /* Empty nibble at end */
...@@ -383,6 +387,13 @@ static struct regval_list ov7670_fmt_rgb444[] = { ...@@ -383,6 +387,13 @@ static struct regval_list ov7670_fmt_rgb444[] = {
{ 0xff, 0xff }, { 0xff, 0xff },
}; };
static struct regval_list ov7670_fmt_raw[] = {
{ REG_COM7, COM7_BAYER },
{ REG_COM13, 0x08 }, /* No gamma, magic rsvd bit */
{ REG_COM16, 0x3d }, /* Edge enhancement, denoise */
{ REG_REG76, 0xe1 }, /* Pix correction, magic rsvd */
{ 0xff, 0xff },
};
...@@ -486,32 +497,39 @@ static struct ov7670_format_struct { ...@@ -486,32 +497,39 @@ static struct ov7670_format_struct {
__u32 pixelformat; __u32 pixelformat;
struct regval_list *regs; struct regval_list *regs;
int cmatrix[CMATRIX_LEN]; int cmatrix[CMATRIX_LEN];
int bpp; /* Bytes per pixel */
} ov7670_formats[] = { } ov7670_formats[] = {
{ {
.desc = "YUYV 4:2:2", .desc = "YUYV 4:2:2",
.pixelformat = V4L2_PIX_FMT_YUYV, .pixelformat = V4L2_PIX_FMT_YUYV,
.regs = ov7670_fmt_yuv422, .regs = ov7670_fmt_yuv422,
.cmatrix = { 128, -128, 0, -34, -94, 128 }, .cmatrix = { 128, -128, 0, -34, -94, 128 },
.bpp = 2,
}, },
{ {
.desc = "RGB 444", .desc = "RGB 444",
.pixelformat = V4L2_PIX_FMT_RGB444, .pixelformat = V4L2_PIX_FMT_RGB444,
.regs = ov7670_fmt_rgb444, .regs = ov7670_fmt_rgb444,
.cmatrix = { 179, -179, 0, -61, -176, 228 }, .cmatrix = { 179, -179, 0, -61, -176, 228 },
.bpp = 2,
}, },
{ {
.desc = "RGB 565", .desc = "RGB 565",
.pixelformat = V4L2_PIX_FMT_RGB565, .pixelformat = V4L2_PIX_FMT_RGB565,
.regs = ov7670_fmt_rgb565, .regs = ov7670_fmt_rgb565,
.cmatrix = { 179, -179, 0, -61, -176, 228 }, .cmatrix = { 179, -179, 0, -61, -176, 228 },
.bpp = 2,
},
{
.desc = "Raw RGB Bayer",
.pixelformat = V4L2_PIX_FMT_SBGGR8,
.regs = ov7670_fmt_raw,
.cmatrix = { 0, 0, 0, 0, 0, 0 },
.bpp = 1
}, },
}; };
#define N_OV7670_FMTS (sizeof(ov7670_formats)/sizeof(ov7670_formats[0])) #define N_OV7670_FMTS ARRAY_SIZE(ov7670_formats)
/*
* All formats we support are 2 bytes/pixel.
*/
#define BYTES_PER_PIXEL 2
/* /*
* Then there is the issue of window sizes. Try to capture the info here. * Then there is the issue of window sizes. Try to capture the info here.
...@@ -688,7 +706,7 @@ static int ov7670_try_fmt(struct i2c_client *c, struct v4l2_format *fmt, ...@@ -688,7 +706,7 @@ static int ov7670_try_fmt(struct i2c_client *c, struct v4l2_format *fmt,
*/ */
pix->width = wsize->width; pix->width = wsize->width;
pix->height = wsize->height; pix->height = wsize->height;
pix->bytesperline = pix->width*BYTES_PER_PIXEL; pix->bytesperline = pix->width*ov7670_formats[index].bpp;
pix->sizeimage = pix->height*pix->bytesperline; pix->sizeimage = pix->height*pix->bytesperline;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment