mirror of
https://github.com/espressif/esp32-camera.git
synced 2025-07-03 07:30:15 +08:00
Fix SPIRAM checks and allow conversion APIs to be built for all platforms (#397)
Signed-off-by: Vikram <vikram.dattu@espressif.com>
This commit is contained in:
@ -1,5 +1,24 @@
|
|||||||
|
# set conversion sources
|
||||||
|
set(COMPONENT_SRCS
|
||||||
|
conversions/yuv.c
|
||||||
|
conversions/to_jpg.cpp
|
||||||
|
conversions/to_bmp.c
|
||||||
|
conversions/jpge.cpp
|
||||||
|
conversions/esp_jpg_decode.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set(COMPONENT_PRIV_INCLUDEDIRS
|
||||||
|
conversions/private_include
|
||||||
|
)
|
||||||
|
|
||||||
|
set(COMPONENT_ADD_INCLUDEDIRS
|
||||||
|
driver/include
|
||||||
|
conversions/include
|
||||||
|
)
|
||||||
|
|
||||||
|
# set driver sources only for supported platforms
|
||||||
if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3")
|
if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3")
|
||||||
set(COMPONENT_SRCS
|
list(APPEND COMPONENT_SRCS
|
||||||
driver/esp_camera.c
|
driver/esp_camera.c
|
||||||
driver/cam_hal.c
|
driver/cam_hal.c
|
||||||
driver/sccb.c
|
driver/sccb.c
|
||||||
@ -16,22 +35,11 @@ if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET ST
|
|||||||
sensors/bf3005.c
|
sensors/bf3005.c
|
||||||
sensors/bf20a6.c
|
sensors/bf20a6.c
|
||||||
sensors/sc030iot.c
|
sensors/sc030iot.c
|
||||||
conversions/yuv.c
|
|
||||||
conversions/to_jpg.cpp
|
|
||||||
conversions/to_bmp.c
|
|
||||||
conversions/jpge.cpp
|
|
||||||
conversions/esp_jpg_decode.c
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS
|
list(APPEND COMPONENT_PRIV_INCLUDEDIRS
|
||||||
driver/include
|
|
||||||
conversions/include
|
|
||||||
)
|
|
||||||
|
|
||||||
set(COMPONENT_PRIV_INCLUDEDIRS
|
|
||||||
driver/private_include
|
driver/private_include
|
||||||
sensors/private_include
|
sensors/private_include
|
||||||
conversions/private_include
|
|
||||||
target/private_include
|
target/private_include
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -70,5 +78,6 @@ if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET ST
|
|||||||
message(WARNING "ESP-IDF version detected: '${idf_version}'.")
|
message(WARNING "ESP-IDF version detected: '${idf_version}'.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
register_component()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
register_component()
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
#include "tjpgd.h"
|
#include "tjpgd.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||||
#include "esp32s3/rom/tjpgd.h"
|
#include "esp32s3/rom/tjpgd.h"
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||||
|
#include "esp32c3/rom/tjpgd.h"
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32H2
|
||||||
|
#include "esp32h2/rom/tjpgd.h"
|
||||||
#else
|
#else
|
||||||
#error Target CONFIG_IDF_TARGET is not supported
|
#error Target CONFIG_IDF_TARGET is not supported
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,7 +29,12 @@ namespace jpge {
|
|||||||
if(b){
|
if(b){
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
// check if SPIRAM is enabled and allocate on SPIRAM if allocatable
|
||||||
|
#if (CONFIG_SPIRAM_SUPPORT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC))
|
||||||
return heap_caps_malloc(nSize, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
return heap_caps_malloc(nSize, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
static inline void jpge_free(void *p) { free(p); }
|
static inline void jpge_free(void *p) { free(p); }
|
||||||
|
|
||||||
|
@ -21,19 +21,6 @@
|
|||||||
#include "esp_jpg_decode.h"
|
#include "esp_jpg_decode.h"
|
||||||
|
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
|
|
||||||
#include "esp32/spiram.h"
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
|
||||||
#include "esp32s2/spiram.h"
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
|
||||||
#include "esp32s3/spiram.h"
|
|
||||||
#else
|
|
||||||
#error Target CONFIG_IDF_TARGET is not supported
|
|
||||||
#endif
|
|
||||||
#else // ESP32 Before IDF 4.0
|
|
||||||
#include "esp_spiram.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
|
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
|
||||||
#include "esp32-hal-log.h"
|
#include "esp32-hal-log.h"
|
||||||
@ -72,7 +59,12 @@ typedef struct {
|
|||||||
|
|
||||||
static void *_malloc(size_t size)
|
static void *_malloc(size_t size)
|
||||||
{
|
{
|
||||||
|
// check if SPIRAM is enabled and allocate on SPIRAM if allocatable
|
||||||
|
#if (CONFIG_SPIRAM_SUPPORT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC))
|
||||||
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||||
|
#endif
|
||||||
|
// try allocating in internal memory
|
||||||
|
return malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
//output buffer and image width
|
//output buffer and image width
|
||||||
|
@ -21,21 +21,6 @@
|
|||||||
#include "jpge.h"
|
#include "jpge.h"
|
||||||
#include "yuv.h"
|
#include "yuv.h"
|
||||||
|
|
||||||
#include "esp_system.h"
|
|
||||||
#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
|
|
||||||
#include "esp32/spiram.h"
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
|
||||||
#include "esp32s2/spiram.h"
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
|
||||||
#include "esp32s3/spiram.h"
|
|
||||||
#else
|
|
||||||
#error Target CONFIG_IDF_TARGET is not supported
|
|
||||||
#endif
|
|
||||||
#else // ESP32 Before IDF 4.0
|
|
||||||
#include "esp_spiram.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
|
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
|
||||||
#include "esp32-hal-log.h"
|
#include "esp32-hal-log.h"
|
||||||
#define TAG ""
|
#define TAG ""
|
||||||
@ -50,7 +35,12 @@ static void *_malloc(size_t size)
|
|||||||
if(res) {
|
if(res) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if SPIRAM is enabled and is allocatable
|
||||||
|
#if (CONFIG_SPIRAM_SUPPORT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC))
|
||||||
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IRAM_ATTR void convert_line_format(uint8_t * src, pixformat_t format, uint8_t * dst, size_t width, size_t in_channels, size_t line)
|
static IRAM_ATTR void convert_line_format(uint8_t * src, pixformat_t format, uint8_t * dst, size_t width, size_t in_channels, size_t line)
|
||||||
|
Reference in New Issue
Block a user