mirror of
https://github.com/espressif/esp32-camera.git
synced 2025-05-17 15:19:45 +08:00
fix: add SC031GS VGA framesize support (#581)
This commit is contained in:
@ -78,10 +78,13 @@ struct sc031gs_regval {
|
||||
uint8_t val;
|
||||
};
|
||||
|
||||
// 200*200, xclk=10M, fps=120fps
|
||||
static const struct sc031gs_regval sc031gs_default_init_regs[] = {
|
||||
{0x0103, 0x01}, // soft reset.
|
||||
static const struct sc031gs_regval sc031gs_reset_regs[] = {
|
||||
{0x0103, 0x01}, // soft reset.
|
||||
{REG_DELAY, 10}, // delay.
|
||||
};
|
||||
|
||||
// 200*200, xclk=10M, fps=120fps
|
||||
static const struct sc031gs_regval sc031gs_200x200_init_regs[] = {
|
||||
{0x0100, 0x00},
|
||||
{0x36e9, 0x80},
|
||||
{0x36f9, 0x80},
|
||||
@ -200,3 +203,114 @@ static const struct sc031gs_regval sc031gs_default_init_regs[] = {
|
||||
{0x3317, 0x0e},
|
||||
{REG_NULL, 0x00},
|
||||
};
|
||||
|
||||
// 640*480, xclk=20M, fps=50fps, xclk=10M, fps=25fps
|
||||
static const struct sc031gs_regval sc031gs_640x480_50fps_init_regs[] = {
|
||||
{0x0100, 0x00},
|
||||
{0x36e9, 0x80},
|
||||
{0x36f9, 0x80},
|
||||
{0x300f, 0x0f},
|
||||
{0x3018, 0x1f},
|
||||
{0x3019, 0xff},
|
||||
{0x301c, 0xb4},
|
||||
{0x301f, 0x6c},
|
||||
{0x3028, 0x82},
|
||||
{0x3200, 0x00},
|
||||
{0x3201, 0x00},
|
||||
{0x3202, 0x00},
|
||||
{0x3203, 0x08},
|
||||
{0x3204, 0x02},
|
||||
{0x3205, 0x8f},
|
||||
{0x3206, 0x01},
|
||||
{0x3207, 0xf7},
|
||||
{SC031GS_OUTPUT_WINDOW_WIDTH_H_REG, 0x02},
|
||||
{SC031GS_OUTPUT_WINDOW_WIDTH_L_REG, 0x80},
|
||||
{SC031GS_OUTPUT_WINDOW_HIGH_H_REG, 0x01},
|
||||
{SC031GS_OUTPUT_WINDOW_HIGH_L_REG, 0xe0},
|
||||
{0x320c, 0x03},
|
||||
{0x320d, 0x6e},
|
||||
{0x320e, 0x04},
|
||||
{0x320f, 0x72},
|
||||
{SC031GS_OUTPUT_WINDOW_START_Y_H_REG, 0x00},
|
||||
{SC031GS_OUTPUT_WINDOW_START_Y_L_REG, 0x08},
|
||||
{SC031GS_OUTPUT_WINDOW_START_X_H_REG, 0x00},
|
||||
{SC031GS_OUTPUT_WINDOW_START_X_L_REG, 0x08},
|
||||
{0x3220, 0x10},
|
||||
{0x3223, 0x50},
|
||||
{0x3250, 0xf0},
|
||||
{0x3251, 0x02},
|
||||
{0x3252, 0x03},
|
||||
{0x3253, 0xb0},
|
||||
{0x3254, 0x02},
|
||||
{0x3255, 0x07},
|
||||
{0x3304, 0x48},
|
||||
{0x3306, 0x38},
|
||||
{0x3309, 0x68},
|
||||
{0x330b, 0xe0},
|
||||
{0x330c, 0x18},
|
||||
{0x330f, 0x20},
|
||||
{0x3310, 0x10},
|
||||
{0x3314, 0x6d},
|
||||
{0x3315, 0x38},
|
||||
{0x3316, 0x68},
|
||||
{0x3317, 0x0f},
|
||||
{0x3329, 0x5c},
|
||||
{0x332d, 0x5c},
|
||||
{0x332f, 0x60},
|
||||
{0x3335, 0x64},
|
||||
{0x3344, 0x64},
|
||||
{0x335b, 0x80},
|
||||
{0x335f, 0x80},
|
||||
{0x3366, 0x06},
|
||||
{0x3385, 0x31},
|
||||
{0x3387, 0x51},
|
||||
{0x3389, 0x01},
|
||||
{0x33b1, 0x03},
|
||||
{0x33b2, 0x06},
|
||||
{0x3621, 0xa4},
|
||||
{0x3622, 0x05},
|
||||
{0x3624, 0x47},
|
||||
{0x3631, 0x48},
|
||||
{0x3633, 0x52},
|
||||
{0x3635, 0x18},
|
||||
{0x3636, 0x25},
|
||||
{0x3637, 0x89},
|
||||
{0x3638, 0x0f},
|
||||
{0x3639, 0x08},
|
||||
{0x363a, 0x00},
|
||||
{0x363b, 0x48},
|
||||
{0x363c, 0x06},
|
||||
{0x363e, 0xf8},
|
||||
{0x3640, 0x00},
|
||||
{0x3641, 0x01},
|
||||
{0x36ea, 0x36},
|
||||
{0x36eb, 0x1a},
|
||||
{0x36ec, 0x0a},
|
||||
{0x36ed, 0x23},
|
||||
{0x36fa, 0x36},
|
||||
{0x36fb, 0x10},
|
||||
{0x36fc, 0x01},
|
||||
{0x36fd, 0x03},
|
||||
{0x3908, 0x91},
|
||||
{0x3d08, 0x01},
|
||||
{0x3e01, 0x14},
|
||||
{0x3e02, 0x80},
|
||||
{0x3e06, 0x0c},
|
||||
{0x3f04, 0x03},
|
||||
{0x3f05, 0x4e},
|
||||
{0x4500, 0x59},
|
||||
{0x4501, 0xc4},
|
||||
{0x4809, 0x01},
|
||||
{0x4837, 0x1b},
|
||||
{0x5011, 0x00},
|
||||
{0x36e9, 0x20},
|
||||
{0x36f9, 0x24},
|
||||
{0x0100, 0x01}, // must write 0x0100 with 0x01, must delay no less then 7ms
|
||||
//delay 10ms
|
||||
{REG_DELAY, 0X0a},
|
||||
{0x4418, 0x08},
|
||||
{0x4419, 0x80},
|
||||
{0x363d, 0x10},
|
||||
{0x3630, 0x48},
|
||||
{REG_NULL, 0x00},
|
||||
};
|
@ -204,7 +204,7 @@ static int set_aec_value(sensor_t *sensor, int value)
|
||||
|
||||
static int reset(sensor_t *sensor)
|
||||
{
|
||||
int ret = write_regs(sensor->slv_addr, sc031gs_default_init_regs);
|
||||
int ret = write_regs(sensor->slv_addr, sc031gs_reset_regs);
|
||||
if (ret) {
|
||||
ESP_LOGE(TAG, "reset fail");
|
||||
}
|
||||
@ -217,17 +217,11 @@ static int set_output_window(sensor_t *sensor, int offset_x, int offset_y, int w
|
||||
{
|
||||
int ret = 0;
|
||||
//sc:H_start={0x3212[1:0],0x3213},H_length={0x3208[1:0],0x3209},
|
||||
// printf("%d, %d, %d, %d\r\n", ((offset_x>>8) & 0x03), offset_x & 0xff, ((w>>8) & 0x03), w & 0xff);
|
||||
|
||||
WRITE_REG_OR_RETURN(SC031GS_OUTPUT_WINDOW_START_X_H_REG, 0x0); // For now, we use x_start is 0x04
|
||||
WRITE_REG_OR_RETURN(SC031GS_OUTPUT_WINDOW_START_X_L_REG, 0x04);
|
||||
WRITE_REG_OR_RETURN(SC031GS_OUTPUT_WINDOW_WIDTH_H_REG, ((w>>8) & 0x03));
|
||||
WRITE_REG_OR_RETURN(SC031GS_OUTPUT_WINDOW_WIDTH_L_REG, w & 0xff);
|
||||
|
||||
//sc:V_start={0x3210[1:0],0x3211},V_length={0x320a[1:0],0x320b},
|
||||
// printf("%d, %d, %d, %d\r\n", ((offset_y>>8) & 0x03), offset_y & 0xff, ((h>>8) & 0x03), h & 0xff);
|
||||
WRITE_REG_OR_RETURN(SC031GS_OUTPUT_WINDOW_START_Y_H_REG, 0x0); // For now, we use y_start is 0x08
|
||||
WRITE_REG_OR_RETURN(SC031GS_OUTPUT_WINDOW_START_Y_L_REG, 0x08);
|
||||
WRITE_REG_OR_RETURN(SC031GS_OUTPUT_WINDOW_HIGH_H_REG, ((h>>8) & 0x03));
|
||||
WRITE_REG_OR_RETURN(SC031GS_OUTPUT_WINDOW_HIGH_L_REG, h & 0xff);
|
||||
|
||||
@ -240,17 +234,21 @@ static int set_framesize(sensor_t *sensor, framesize_t framesize)
|
||||
{
|
||||
uint16_t w = resolution[framesize].width;
|
||||
uint16_t h = resolution[framesize].height;
|
||||
if(w > SC031GS_MAX_FRAME_WIDTH || h > SC031GS_MAX_FRAME_HIGH) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if(w != 200 || h != 200) {
|
||||
ESP_LOGE(TAG, "Only support 200*200 for now, contact us if you want to use other resolutions");
|
||||
struct sc031gs_regval const *framesize_regs = sc031gs_200x200_init_regs;
|
||||
if(framesize > FRAMESIZE_VGA) {
|
||||
goto err;
|
||||
} else if(framesize > FRAMESIZE_QVGA) {
|
||||
framesize_regs = sc031gs_640x480_50fps_init_regs;
|
||||
}
|
||||
|
||||
uint16_t offset_x = (640-w) /2 + 4;
|
||||
uint16_t offset_y = (480-h) /2 + 4;
|
||||
|
||||
int ret = write_regs(sensor->slv_addr, framesize_regs);
|
||||
if (ret) {
|
||||
ESP_LOGE(TAG, "reset fail");
|
||||
}
|
||||
|
||||
if(set_output_window(sensor, offset_x, offset_y, w, h)) {
|
||||
goto err;
|
||||
|
Reference in New Issue
Block a user