-
Notifications
You must be signed in to change notification settings - Fork 6
/
i2s-dma-psram-4.4.8.patch
49 lines (48 loc) · 2.5 KB
/
i2s-dma-psram-4.4.8.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
diff --git a/components/driver/i2s.c b/components/driver/i2s.c
index 224967474e..2426b302fb 100644
--- a/components/driver/i2s.c
+++ b/components/driver/i2s.c
@@ -70,6 +70,8 @@ typedef struct {
volatile int rw_pos;
volatile void *curr_ptr;
SemaphoreHandle_t mux;
+ void* queue_mem;
+ StaticQueue_t queue_obj;
xQueueHandle queue;
lldesc_t **desc;
} i2s_dma_t;
@@ -822,6 +824,7 @@ static esp_err_t i2s_destroy_dma_object(i2s_port_t i2s_num, i2s_dma_t **dma)
vSemaphoreDelete((*dma)->mux);
/* Delete DMA queue */
vQueueDelete((*dma)->queue);
+ free((*dma)->queue_mem);
/* Free DMA structure */
free(*dma);
*dma = NULL;
@@ -848,7 +851,7 @@ static esp_err_t i2s_create_dma_object(i2s_port_t i2s_num, i2s_dma_t **dma)
ESP_RETURN_ON_FALSE((*dma == NULL), ESP_ERR_INVALID_ARG, TAG, "DMA object has been created");
uint32_t buf_cnt = p_i2s[i2s_num]->dma_buf_count;
/* Allocate new DMA structure */
- *dma = (i2s_dma_t *) malloc(sizeof(i2s_dma_t));
+ *dma = (i2s_dma_t *) heap_caps_malloc(sizeof(i2s_dma_t), (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT));
ESP_RETURN_ON_FALSE(*dma, ESP_ERR_NO_MEM, TAG, "DMA object allocate failed");
/* Allocate DMA buffer poiter */
(*dma)->buf = (char **)heap_caps_calloc(buf_cnt, sizeof(char *), MALLOC_CAP_DMA);
@@ -861,7 +864,8 @@ static esp_err_t i2s_create_dma_object(i2s_port_t i2s_num, i2s_dma_t **dma)
goto err;
}
/* Create queue and mutex */
- (*dma)->queue = xQueueCreate(buf_cnt - 1, sizeof(char *));
+ void* queue_mem = (*dma)->queue_mem = heap_caps_malloc((buf_cnt - 1) * sizeof(char *), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
+ (*dma)->queue = xQueueCreateStatic(buf_cnt - 1, sizeof(char *), (uint8_t*)queue_mem, &(*dma)->queue_obj);
if (!(*dma)->queue) {
goto err;
}
@@ -1961,7 +1965,7 @@ esp_err_t i2s_driver_install(i2s_port_t i2s_num, const i2s_config_t *i2s_config,
ESP_RETURN_ON_FALSE((i2s_config->dma_buf_len >= 8 && i2s_config->dma_buf_len <= 1024), ESP_ERR_INVALID_ARG, TAG, "I2S buffer length at most 1024 and more than 8");
/* Step 2: Allocate driver object and register to platform */
- i2s_obj_t *pre_alloc_i2s_obj = calloc(1, sizeof(i2s_obj_t));
+ i2s_obj_t *pre_alloc_i2s_obj = heap_caps_calloc(1, sizeof(i2s_obj_t), (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT));
ESP_RETURN_ON_FALSE(pre_alloc_i2s_obj, ESP_ERR_NO_MEM, TAG, "no mem for I2S driver");
ret = i2s_priv_register_object(pre_alloc_i2s_obj, i2s_num);
if (ret != ESP_OK) {