Skip to content

Commit 339cbd2

Browse files
colbybanburyfacchinm
authored andcommitted
add OV7675 support for additional resolutions
1 parent 3066862 commit 339cbd2

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ GRAYSCALE LITERAL 1
5353
VGA LITERAL1
5454
CIF LITERAL1
5555
QVGA LITERAL1
56+
QQVGA LITERAL1
5657
QCIF LITERAL1

src/utility/ov7670.c

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,24 @@ static struct regval_list ov7670_qqvga_regs[] = {
832832

833833
};
834834

835+
/*
836+
* To center the QQVGA window on the OV7675 the REG_VSTART value was increased
837+
*/
838+
static struct regval_list ov7675_qqvga_regs[] = {
839+
{ REG_COM3, COM3_DCWEN },
840+
{ REG_COM14, 0x1a},
841+
{ 0x72, 0x22 }, // downsample by 4
842+
{ 0x73, 0xf2 }, // divide by 4
843+
{ REG_HSTART, 0x16 },
844+
{ REG_HSTOP, 0x04 },
845+
{ REG_HREF, 0xa4 },
846+
{ REG_VSTART, 0x22 }, //Different from OV7670
847+
{ REG_VSTOP, 0x7a },
848+
{ REG_VREF, 0x0a },
849+
{ 0xff, 0xff }, /* END MARKER */
850+
851+
};
852+
835853
static struct ov7670_win_size ov7670_win_sizes[] = {
836854
/* VGA */
837855
{
@@ -893,9 +911,8 @@ static struct ov7670_win_size ov7670_win_sizes[] = {
893911

894912
static struct ov7670_win_size ov7675_win_sizes[] = {
895913
/*
896-
* Currently, only VGA is supported. Theoretically it could be possible
897-
* to support CIF, QVGA and QCIF too. Taking values for ov7670 as a
898-
* base and tweak them empirically could be required.
914+
* Values copied from ov7670_win_sizes and verified to work.
915+
* The QCIF and QQVGA values were changed to center the cropped window.
899916
*/
900917
{
901918
.width = VGA_WIDTH,
@@ -906,6 +923,50 @@ static struct ov7670_win_size ov7675_win_sizes[] = {
906923
.vstart = 14, /* Empirically determined */
907924
.vstop = 494,
908925
.regs = NULL,
926+
},
927+
/* CIF */
928+
{
929+
.width = CIF_WIDTH,
930+
.height = CIF_HEIGHT,
931+
.com7_bit = COM7_FMT_CIF,
932+
.hstart = 170, /* Copied from ov7670 and verified*/
933+
.hstop = 90,
934+
.vstart = 14,
935+
.vstop = 494,
936+
.regs = NULL,
937+
},
938+
/* QVGA */
939+
{
940+
.width = QVGA_WIDTH,
941+
.height = QVGA_HEIGHT,
942+
.com7_bit = COM7_FMT_QVGA,
943+
.hstart = 168, /* Copied from ov7670 and verified*/
944+
.hstop = 24,
945+
.vstart = 12,
946+
.vstop = 492,
947+
.regs = NULL,
948+
},
949+
/* QCIF */
950+
{
951+
.width = QCIF_WIDTH,
952+
.height = QCIF_HEIGHT,
953+
.com7_bit = COM7_FMT_VGA, /* see comment above */
954+
.hstart = 250, /* Empirically determined and different from ov7670*/
955+
.hstop = 24,
956+
.vstart = 120,
957+
.vstop = 180,
958+
.regs = ov7670_qcif_regs,
959+
},
960+
/* QQVGA */
961+
{
962+
.width = QQVGA_WIDTH,
963+
.height = QQVGA_HEIGHT,
964+
.com7_bit = COM7_FMT_VGA, /* see comment above */
965+
.hstart = 0x16, /* Empirically determined and different from ov7670*/
966+
.hstop = 0x04,
967+
.vstart = 0x22, /* These values seem to be overridden by the regs */
968+
.vstop = 0x7a,
969+
.regs = ov7675_qqvga_regs,/* changed to better center on OV7675 */
909970
}
910971
};
911972

0 commit comments

Comments
 (0)