mirror of
https://github.com/espressif/esp32-camera.git
synced 2025-08-06 16:40:19 +08:00
Experimental: Enable EDMA for JPEG when XCLK is 16MHz
This commit is contained in:
@ -132,7 +132,7 @@ static camera_config_t camera_config = {
|
||||
.pin_href = CAM_PIN_HREF,
|
||||
.pin_pclk = CAM_PIN_PCLK,
|
||||
|
||||
.xclk_freq_hz = 20000000,
|
||||
.xclk_freq_hz = 20000000,//EXPERIMENTAL: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode
|
||||
.ledc_timer = LEDC_TIMER_0,
|
||||
.ledc_channel = LEDC_CHANNEL_0,
|
||||
|
||||
|
@ -315,7 +315,7 @@ esp_err_t cam_config(const camera_config_t *config, framesize_t frame_size, uint
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
cam_obj->psram_mode = false;
|
||||
#else
|
||||
cam_obj->psram_mode = !cam_obj->jpeg_mode && (config->xclk_freq_hz == 16000000);
|
||||
cam_obj->psram_mode = (config->xclk_freq_hz == 16000000);
|
||||
#endif
|
||||
cam_obj->frame_cnt = config->fb_count;
|
||||
cam_obj->width = resolution[frame_size].width;
|
||||
|
@ -104,7 +104,7 @@ typedef struct {
|
||||
int pin_href; /*!< GPIO pin for camera HREF line */
|
||||
int pin_pclk; /*!< GPIO pin for camera PCLK line */
|
||||
|
||||
int xclk_freq_hz; /*!< Frequency of XCLK signal, in Hz. Either 20KHz or 10KHz for OV2640 double FPS (Experimental) */
|
||||
int xclk_freq_hz; /*!< Frequency of XCLK signal, in Hz. EXPERIMENTAL: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode */
|
||||
|
||||
ledc_timer_t ledc_timer; /*!< LEDC timer to be used for generating XCLK */
|
||||
ledc_channel_t ledc_channel; /*!< LEDC channel to be used for generating XCLK */
|
||||
|
@ -165,6 +165,9 @@ static int set_window(sensor_t *sensor, ov2640_sensor_mode_t mode, int offset_x,
|
||||
if(mode == OV2640_MODE_UXGA) {
|
||||
c.pclk_div = 12;
|
||||
}
|
||||
// if (sensor->xclk_freq_hz == 16000000) {
|
||||
// c.pclk_div = c.pclk_div / 2;
|
||||
// }
|
||||
} else {
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
c.clk_2x = 0;
|
||||
|
@ -355,7 +355,7 @@ static int set_framesize(sensor_t *sensor, framesize_t framesize)
|
||||
}
|
||||
|
||||
if (sensor->pixformat == PIXFORMAT_JPEG) {
|
||||
if (framesize == FRAMESIZE_QXGA) {
|
||||
if (framesize == FRAMESIZE_QXGA || sensor->xclk_freq_hz == 16000000) {
|
||||
//40MHz SYSCLK and 10MHz PCLK
|
||||
ret = set_pll(sensor, false, 24, 1, 3, false, 0, true, 8);
|
||||
} else {
|
||||
@ -363,7 +363,7 @@ static int set_framesize(sensor_t *sensor, framesize_t framesize)
|
||||
ret = set_pll(sensor, false, 30, 1, 3, false, 0, true, 10);
|
||||
}
|
||||
} else {
|
||||
//tuned for 16MHz XCLK
|
||||
//tuned for 16MHz XCLK and 8MHz PCLK
|
||||
if (framesize > FRAMESIZE_HVGA) {
|
||||
//8MHz SYSCLK and 8MHz PCLK (4.44 FPS)
|
||||
ret = set_pll(sensor, false, 4, 1, 0, false, 2, true, 2);
|
||||
|
@ -433,7 +433,7 @@ static int set_framesize(sensor_t *sensor, framesize_t framesize)
|
||||
if (sensor->pixformat == PIXFORMAT_JPEG) {
|
||||
//10MHz PCLK
|
||||
uint8_t sys_mul = 200;
|
||||
if(framesize < FRAMESIZE_QVGA){
|
||||
if(framesize < FRAMESIZE_QVGA || sensor->xclk_freq_hz == 16000000){
|
||||
sys_mul = 160;
|
||||
} else if(framesize < FRAMESIZE_XGA){
|
||||
sys_mul = 180;
|
||||
|
@ -246,7 +246,7 @@ void ll_cam_do_vsync(cam_obj_t *cam)
|
||||
|
||||
uint8_t ll_cam_get_dma_align(cam_obj_t *cam)
|
||||
{
|
||||
return 16 << I2S0.lc_conf.ext_mem_bk_size;
|
||||
return 64;//16 << I2S0.lc_conf.ext_mem_bk_size;
|
||||
}
|
||||
|
||||
static void ll_cam_calc_rgb_dma(cam_obj_t *cam){
|
||||
@ -328,10 +328,17 @@ void ll_cam_dma_sizes(cam_obj_t *cam)
|
||||
{
|
||||
cam->dma_bytes_per_item = 1;
|
||||
if (cam->jpeg_mode) {
|
||||
cam->dma_half_buffer_cnt = 16;
|
||||
cam->dma_buffer_size = cam->dma_half_buffer_cnt * 1024;
|
||||
cam->dma_half_buffer_size = cam->dma_buffer_size / cam->dma_half_buffer_cnt;
|
||||
cam->dma_node_buffer_size = cam->dma_half_buffer_size;
|
||||
if (cam->psram_mode) {
|
||||
cam->dma_buffer_size = cam->recv_size;
|
||||
cam->dma_half_buffer_size = 1024;
|
||||
cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size;
|
||||
cam->dma_node_buffer_size = cam->dma_half_buffer_size;
|
||||
} else {
|
||||
cam->dma_half_buffer_cnt = 16;
|
||||
cam->dma_buffer_size = cam->dma_half_buffer_cnt * 1024;
|
||||
cam->dma_half_buffer_size = cam->dma_buffer_size / cam->dma_half_buffer_cnt;
|
||||
cam->dma_node_buffer_size = cam->dma_half_buffer_size;
|
||||
}
|
||||
} else {
|
||||
ll_cam_calc_rgb_dma(cam);
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ void ll_cam_do_vsync(cam_obj_t *cam)
|
||||
|
||||
uint8_t ll_cam_get_dma_align(cam_obj_t *cam)
|
||||
{
|
||||
return 16 << GDMA.in[cam->dma_num].conf1.in_ext_mem_bk_size;
|
||||
return 64;//16 << GDMA.in[cam->dma_num].conf1.in_ext_mem_bk_size;
|
||||
}
|
||||
|
||||
static void ll_cam_calc_rgb_dma(cam_obj_t *cam){
|
||||
@ -345,10 +345,17 @@ void ll_cam_dma_sizes(cam_obj_t *cam)
|
||||
{
|
||||
cam->dma_bytes_per_item = 1;
|
||||
if (cam->jpeg_mode) {
|
||||
cam->dma_half_buffer_cnt = 16;
|
||||
cam->dma_buffer_size = cam->dma_half_buffer_cnt * 1024;
|
||||
cam->dma_half_buffer_size = cam->dma_buffer_size / cam->dma_half_buffer_cnt;
|
||||
cam->dma_node_buffer_size = cam->dma_half_buffer_size;
|
||||
if (cam->psram_mode) {
|
||||
cam->dma_buffer_size = cam->recv_size;
|
||||
cam->dma_half_buffer_size = 1024;
|
||||
cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size;
|
||||
cam->dma_node_buffer_size = cam->dma_half_buffer_size;
|
||||
} else {
|
||||
cam->dma_half_buffer_cnt = 16;
|
||||
cam->dma_buffer_size = cam->dma_half_buffer_cnt * 1024;
|
||||
cam->dma_half_buffer_size = cam->dma_buffer_size / cam->dma_half_buffer_cnt;
|
||||
cam->dma_node_buffer_size = cam->dma_half_buffer_size;
|
||||
}
|
||||
} else {
|
||||
ll_cam_calc_rgb_dma(cam);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ static esp_err_t init_camera(uint32_t xclk_freq_hz, pixformat_t pixel_format, ui
|
||||
.pin_href = CAM_PIN_HREF,
|
||||
.pin_pclk = CAM_PIN_PCLK,
|
||||
|
||||
//XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
|
||||
//EXPERIMENTAL: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode
|
||||
.xclk_freq_hz = xclk_freq_hz,
|
||||
.ledc_timer = LEDC_TIMER_0,
|
||||
.ledc_channel = LEDC_CHANNEL_0,
|
||||
|
Reference in New Issue
Block a user