aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ov7670.c
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2007-03-25 10:38:21 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-04-27 14:45:07 -0400
commit585553ecedabf434e5cdc59d05bf64596ceab7bc (patch)
treec78b3bdf64908c72808cf033c8aab582bac003d2 /drivers/media/video/ov7670.c
parent77d5140fe78ca628bfc9d2567c35457481f9c63d (diff)
V4L/DVB (5469): Add raw bayer support to the ov7670 driver
Add raw bayer support to the ov7670 driver Signed-off-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/ov7670.c')
-rw-r--r--drivers/media/video/ov7670.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c
index 639fc2367832..03bc369a9e49 100644
--- a/drivers/media/video/ov7670.c
+++ b/drivers/media/video/ov7670.c
@@ -165,6 +165,10 @@ MODULE_LICENSE("GPL");
165 165
166#define REG_GFIX 0x69 /* Fix gain control */ 166#define REG_GFIX 0x69 /* Fix gain control */
167 167
168#define REG_REG76 0x76 /* OV's name */
169#define R76_BLKPCOR 0x80 /* Black pixel correction enable */
170#define R76_WHTPCOR 0x40 /* White pixel correction enable */
171
168#define REG_RGB444 0x8c /* RGB 444 control */ 172#define REG_RGB444 0x8c /* RGB 444 control */
169#define R444_ENABLE 0x02 /* Turn on RGB444, overrides 5x5 */ 173#define R444_ENABLE 0x02 /* Turn on RGB444, overrides 5x5 */
170#define R444_RGBX 0x01 /* Empty nibble at end */ 174#define R444_RGBX 0x01 /* Empty nibble at end */
@@ -383,6 +387,13 @@ static struct regval_list ov7670_fmt_rgb444[] = {
383 { 0xff, 0xff }, 387 { 0xff, 0xff },
384}; 388};
385 389
390static struct regval_list ov7670_fmt_raw[] = {
391 { REG_COM7, COM7_BAYER },
392 { REG_COM13, 0x08 }, /* No gamma, magic rsvd bit */
393 { REG_COM16, 0x3d }, /* Edge enhancement, denoise */
394 { REG_REG76, 0xe1 }, /* Pix correction, magic rsvd */
395 { 0xff, 0xff },
396};
386 397
387 398
388 399
@@ -486,32 +497,39 @@ static struct ov7670_format_struct {
486 __u32 pixelformat; 497 __u32 pixelformat;
487 struct regval_list *regs; 498 struct regval_list *regs;
488 int cmatrix[CMATRIX_LEN]; 499 int cmatrix[CMATRIX_LEN];
500 int bpp; /* Bytes per pixel */
489} ov7670_formats[] = { 501} ov7670_formats[] = {
490 { 502 {
491 .desc = "YUYV 4:2:2", 503 .desc = "YUYV 4:2:2",
492 .pixelformat = V4L2_PIX_FMT_YUYV, 504 .pixelformat = V4L2_PIX_FMT_YUYV,
493 .regs = ov7670_fmt_yuv422, 505 .regs = ov7670_fmt_yuv422,
494 .cmatrix = { 128, -128, 0, -34, -94, 128 }, 506 .cmatrix = { 128, -128, 0, -34, -94, 128 },
507 .bpp = 2,
495 }, 508 },
496 { 509 {
497 .desc = "RGB 444", 510 .desc = "RGB 444",
498 .pixelformat = V4L2_PIX_FMT_RGB444, 511 .pixelformat = V4L2_PIX_FMT_RGB444,
499 .regs = ov7670_fmt_rgb444, 512 .regs = ov7670_fmt_rgb444,
500 .cmatrix = { 179, -179, 0, -61, -176, 228 }, 513 .cmatrix = { 179, -179, 0, -61, -176, 228 },
514 .bpp = 2,
501 }, 515 },
502 { 516 {
503 .desc = "RGB 565", 517 .desc = "RGB 565",
504 .pixelformat = V4L2_PIX_FMT_RGB565, 518 .pixelformat = V4L2_PIX_FMT_RGB565,
505 .regs = ov7670_fmt_rgb565, 519 .regs = ov7670_fmt_rgb565,
506 .cmatrix = { 179, -179, 0, -61, -176, 228 }, 520 .cmatrix = { 179, -179, 0, -61, -176, 228 },
521 .bpp = 2,
522 },
523 {
524 .desc = "Raw RGB Bayer",
525 .pixelformat = V4L2_PIX_FMT_SBGGR8,
526 .regs = ov7670_fmt_raw,
527 .cmatrix = { 0, 0, 0, 0, 0, 0 },
528 .bpp = 1
507 }, 529 },
508}; 530};
509#define N_OV7670_FMTS (sizeof(ov7670_formats)/sizeof(ov7670_formats[0])) 531#define N_OV7670_FMTS ARRAY_SIZE(ov7670_formats)
510 532
511/*
512 * All formats we support are 2 bytes/pixel.
513 */
514#define BYTES_PER_PIXEL 2
515 533
516/* 534/*
517 * Then there is the issue of window sizes. Try to capture the info here. 535 * 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 */ 706 */
689 pix->width = wsize->width; 707 pix->width = wsize->width;
690 pix->height = wsize->height; 708 pix->height = wsize->height;
691 pix->bytesperline = pix->width*BYTES_PER_PIXEL; 709 pix->bytesperline = pix->width*ov7670_formats[index].bpp;
692 pix->sizeimage = pix->height*pix->bytesperline; 710 pix->sizeimage = pix->height*pix->bytesperline;
693 return 0; 711 return 0;
694} 712}