Skip to content

Commit 2f2acfa

Browse files
committed
Merge branch 'feat/rgb_lcd_gdma_link_v5.3' into 'release/v5.3'
refactor rgb_lcd driver to use gdma_link driver (v5.3) See merge request espressif/esp-idf!34265
2 parents f7c4b63 + 2fa45a9 commit 2f2acfa

File tree

7 files changed

+229
-181
lines changed

7 files changed

+229
-181
lines changed

components/esp_hw_support/dma/gdma_link.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,20 @@ uintptr_t gdma_link_get_head_addr(gdma_link_list_handle_t list)
227227
return (uintptr_t)(list->items);
228228
}
229229

230+
esp_err_t gdma_link_concat(gdma_link_list_handle_t first_link, int first_link_item_index, gdma_link_list_handle_t second_link, int second_link_item_index)
231+
{
232+
ESP_RETURN_ON_FALSE(first_link && second_link, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
233+
gdma_link_list_item_t *lli_nc = NULL;
234+
lli_nc = (gdma_link_list_item_t *)(first_link->items_nc + (first_link->num_items + first_link_item_index) % first_link->num_items * first_link->item_size);
235+
lli_nc->next = (gdma_link_list_item_t *)(second_link->items + (second_link->num_items + second_link_item_index) % second_link->num_items * second_link->item_size);
236+
return ESP_OK;
237+
}
238+
230239
esp_err_t gdma_link_set_owner(gdma_link_list_handle_t list, int item_index, gdma_lli_owner_t owner)
231240
{
232241
ESP_RETURN_ON_FALSE_ISR(list, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
233242
ESP_RETURN_ON_FALSE_ISR(item_index < list->num_items, ESP_ERR_INVALID_ARG, TAG, "invalid item index");
234-
gdma_link_list_item_t *lli = (gdma_link_list_item_t *)(list->items_nc + item_index * list->item_size);
243+
gdma_link_list_item_t *lli = (gdma_link_list_item_t *)(list->items_nc + (list->num_items + item_index) % list->num_items * list->item_size);
235244
lli->dw0.owner = owner;
236245
return ESP_OK;
237246
}
@@ -240,7 +249,7 @@ esp_err_t gdma_link_get_owner(gdma_link_list_handle_t list, int item_index, gdma
240249
{
241250
ESP_RETURN_ON_FALSE_ISR(list && owner, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
242251
ESP_RETURN_ON_FALSE_ISR(item_index < list->num_items, ESP_ERR_INVALID_ARG, TAG, "invalid item index");
243-
gdma_link_list_item_t *lli = (gdma_link_list_item_t *)(list->items_nc + item_index * list->item_size);
252+
gdma_link_list_item_t *lli = (gdma_link_list_item_t *)(list->items_nc + (list->num_items + item_index) % list->num_items * list->item_size);
244253
*owner = lli->dw0.owner;
245254
return ESP_OK;
246255
}

components/esp_hw_support/dma/include/esp_private/gdma_link.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ typedef struct {
7171
uint32_t mark_final: 1; /*!< Whether to terminate the DMA link list at this item.
7272
Note, DMA engine will stop at this item and trigger an interrupt.
7373
If `mark_final` is not set, this list item will point to the next item, and
74-
wrap around to the head item if it's the one in the list. */
74+
wrap around to the head item if it's the last one in the list. */
7575
} flags; //!< Flags for buffer mount configurations
7676
} gdma_buffer_mount_config_t;
7777

@@ -105,6 +105,27 @@ esp_err_t gdma_link_mount_buffers(gdma_link_list_handle_t list, uint32_t start_i
105105
*/
106106
uintptr_t gdma_link_get_head_addr(gdma_link_list_handle_t list);
107107

108+
/**
109+
* @brief Concatenate two link lists as follows:
110+
*
111+
* Link A: A1 --> A2 --> A3 --> A4
112+
* | item_index
113+
* +-----+
114+
* |
115+
* v item_index
116+
* Link B: B1 --> B2 --> B3 --> B4
117+
*
118+
* @param[in] first_link First link list handle, allocated by `gdma_new_link_list`
119+
* @param[in] first_link_item_index Index of the item in the first link list (-1 means the last item)
120+
* @param[in] second_link Second link list handle, allocated by `gdma_new_link_list`
121+
* @param[in] second_link_item_index Index of the item in the second link list (-1 means the last item)
122+
* @return
123+
* - ESP_OK: Concatenate the link lists successfully
124+
* - ESP_ERR_INVALID_ARG: Concatenate the link lists failed because of invalid argument
125+
* - ESP_FAIL: Concatenate the link lists failed because of other error
126+
*/
127+
esp_err_t gdma_link_concat(gdma_link_list_handle_t first_link, int first_link_item_index, gdma_link_list_handle_t second_link, int second_link_item_index);
128+
108129
/**
109130
* @brief GDMA link list item owner
110131
*/
@@ -117,7 +138,7 @@ typedef enum {
117138
* @brief Set the ownership for a DMA link list item
118139
*
119140
* @param[in] list Link list handle, allocated by `gdma_new_link_list`
120-
* @param[in] item_index Index of the link list item
141+
* @param[in] item_index Index of the link list item (-1 means the last item)
121142
* @param[in] owner Ownership
122143
* @return
123144
* - ESP_OK: Set the ownership successfully
@@ -130,7 +151,7 @@ esp_err_t gdma_link_set_owner(gdma_link_list_handle_t list, int item_index, gdma
130151
* @brief Get the ownership of a DMA link list item
131152
*
132153
* @param[in] list Link list handle, allocated by `gdma_new_link_list`
133-
* @param[in] item_index Index of the link list item
154+
* @param[in] item_index Index of the link list item (-1 means the last item)
134155
* @param[out] owner Ownership
135156
* @return
136157
* - ESP_OK: Get the ownership successfully

components/esp_lcd/linker.lf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ entries:
44
if LCD_RGB_ISR_IRAM_SAFE = y:
55
gdma: gdma_reset (noflash)
66
gdma: gdma_start (noflash)
7+
gdma_link: gdma_link_get_head_addr (noflash)
78

89
[mapping:esp_lcd_hal]
910
archive: libhal.a

components/esp_lcd/priv_include/esp_lcd_common.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -60,15 +60,6 @@ int lcd_com_register_device(lcd_com_device_type_t device_type, void *device_obj)
6060
void lcd_com_remove_device(lcd_com_device_type_t device_type, int member_id);
6161
#endif // SOC_LCDCAM_SUPPORTED
6262

63-
/**
64-
* @brief Mount data to DMA descriptors
65-
*
66-
* @param desc_head Point to the head of DMA descriptor chain
67-
* @param buffer Data buffer
68-
* @param len Size of the data buffer, in bytes
69-
*/
70-
void lcd_com_mount_dma_data(dma_descriptor_t *desc_head, const void *buffer, size_t len);
71-
7263
/**
7364
* @brief Reverse the bytes in the buffer
7465
*

0 commit comments

Comments
 (0)