mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
refactor(esp_common): centralize ALIGN_UP/ALIGN_DOWN into esp_macros.h
Remove ~50 duplicate local definitions of ALIGN_UP/ALIGN_DOWN/ALIGN_UP_BY/ ALIGN_DOWN_BY across the codebase and replace them with canonical ESP_ALIGN_UP/ESP_ALIGN_DOWN from esp_macros.h.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "hal/color_hal.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_cache.h"
|
||||
#include "esp_macros.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/esp_cache_private.h"
|
||||
#include "esp_private/gpio.h"
|
||||
@@ -45,8 +46,6 @@
|
||||
#define CAM_DVP_DATA_SIG_NUM 0 /*!< Default value */
|
||||
#endif
|
||||
|
||||
#define ALIGN_UP_BY(num, align) ((align) == 0 ? (num) : (((num) + ((align) - 1)) & ~((align) - 1)))
|
||||
|
||||
#define DVP_CAM_CONFIG_INPUT_PIN(pin, sig, inv) \
|
||||
{ \
|
||||
if (pin != GPIO_NUM_NC) { \
|
||||
@@ -230,7 +229,7 @@ static uint32_t IRAM_ATTR esp_cam_ctlr_dvp_get_recved_size(esp_cam_ctlr_dvp_cam_
|
||||
uint32_t recv_buffer_size;
|
||||
|
||||
if (ctlr->pic_format_jpeg) {
|
||||
recv_buffer_size = ALIGN_UP_BY(MIN(dma_recv_size, ctlr->fb_size_in_bytes), 64);
|
||||
recv_buffer_size = ESP_ALIGN_UP(MIN(dma_recv_size, ctlr->fb_size_in_bytes), 64);
|
||||
} else {
|
||||
recv_buffer_size = ctlr->fb_size_in_bytes;
|
||||
}
|
||||
@@ -861,7 +860,9 @@ esp_err_t esp_cam_new_dvp_ctlr(const esp_cam_ctlr_dvp_config_t *config, esp_cam_
|
||||
ESP_GOTO_ON_ERROR(s_dvp_claim_ctlr(config->ctlr_id, ctlr), fail1, TAG, "no available DVP controller");
|
||||
|
||||
ESP_LOGD(TAG, "alignment: 0x%x\n", alignment_size);
|
||||
fb_size_in_bytes = ALIGN_UP_BY(fb_size_in_bytes, alignment_size);
|
||||
if (alignment_size) {
|
||||
fb_size_in_bytes = ESP_ALIGN_UP(fb_size_in_bytes, alignment_size);
|
||||
}
|
||||
if (!config->bk_buffer_dis) {
|
||||
ctlr->backup_buffer = heap_caps_aligned_alloc(alignment_size, fb_size_in_bytes, DVP_CAM_BK_BUFFER_ALLOC_CAPS);
|
||||
ESP_GOTO_ON_FALSE(ctlr->backup_buffer, ESP_ERR_NO_MEM, fail2, TAG, "no mem for DVP backup buffer");
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#include "esp_private/esp_cache_private.h"
|
||||
#include "esp_cam_ctlr_dvp_dma.h"
|
||||
#include "esp_memory_utils.h"
|
||||
|
||||
#define ALIGN_UP_BY(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
|
||||
#include "esp_macros.h"
|
||||
|
||||
#if defined(SOC_GDMA_TRIG_PERIPH_CAM0_BUS) && (SOC_GDMA_TRIG_PERIPH_CAM0_BUS == SOC_GDMA_BUS_AHB)
|
||||
#define DVP_GDMA_NEW_CHANNEL gdma_new_ahb_channel
|
||||
@@ -113,7 +112,7 @@ esp_err_t esp_cam_ctlr_dvp_dma_init(esp_cam_ctlr_dvp_dma_t *dma, uint32_t burst_
|
||||
}
|
||||
dma->size = size;
|
||||
alignment_size = (alignment_size == 0) ? 1 : alignment_size;
|
||||
dma->desc_size = ALIGN_UP_BY(dma->desc_count * sizeof(esp_cam_ctlr_dvp_dma_desc_t), alignment_size);
|
||||
dma->desc_size = ESP_ALIGN_UP(dma->desc_count * sizeof(esp_cam_ctlr_dvp_dma_desc_t), alignment_size);
|
||||
|
||||
ESP_LOGD(TAG, "alignment_size: %d, dma->desc_count: %d, dma->desc_size: %d", alignment_size, dma->desc_count, dma->desc_size);
|
||||
dma->desc = heap_caps_aligned_alloc(alignment_size, dma->desc_size, DVP_GDMA_DESC_ALLOC_CAPS);
|
||||
|
||||
Reference in New Issue
Block a user