Skip to content

Commit fe1091c

Browse files
committed
fix(lcd): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled
1 parent 5599fd4 commit fe1091c

File tree

6 files changed

+46
-2
lines changed

6 files changed

+46
-2
lines changed

components/esp_lcd/dsi/esp_lcd_mipi_dsi_bus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ esp_err_t esp_lcd_del_dsi_bus(esp_lcd_dsi_bus_handle_t bus)
143143
DSI_RCC_ATOMIC() {
144144
mipi_dsi_ll_enable_bus_clock(bus_id, false);
145145
}
146+
#if CONFIG_PM_ENABLE
146147
if (bus->pm_lock) {
147148
esp_pm_lock_release(bus->pm_lock);
148149
esp_pm_lock_delete(bus->pm_lock);
149150
}
151+
#endif
150152
free(bus);
151153
return ESP_OK;
152154
}

components/esp_lcd/dsi/esp_lcd_panel_dpi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ struct esp_lcd_dpi_panel_t {
4747
dw_gdma_link_list_handle_t link_lists[DPI_PANEL_MAX_FB_NUM]; // DMA link list
4848
esp_async_fbcpy_handle_t fbcpy_handle; // Use DMA2D to do frame buffer copy
4949
SemaphoreHandle_t draw_sem; // A semaphore used to synchronize the draw operations when DMA2D is used
50+
#if CONFIG_PM_ENABLE
5051
esp_pm_lock_handle_t pm_lock; // Power management lock
52+
#endif
5153
esp_lcd_dpi_panel_color_trans_done_cb_t on_color_trans_done; // Callback invoked when color data transfer has finished
5254
esp_lcd_dpi_panel_refresh_done_cb_t on_refresh_done; // Callback invoked when one refresh operation finished (kinda like a vsync end)
5355
void *user_ctx; // User context for the callback
@@ -375,10 +377,12 @@ static esp_err_t dpi_panel_del(esp_lcd_panel_t *panel)
375377
if (dpi_panel->draw_sem) {
376378
vSemaphoreDeleteWithCaps(dpi_panel->draw_sem);
377379
}
380+
#if CONFIG_PM_ENABLE
378381
if (dpi_panel->pm_lock) {
379382
esp_pm_lock_release(dpi_panel->pm_lock);
380383
esp_pm_lock_delete(dpi_panel->pm_lock);
381384
}
385+
#endif
382386
free(dpi_panel);
383387
return ESP_OK;
384388
}

components/esp_lcd/dsi/mipi_dsi_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ extern "C" {
3939
typedef struct esp_lcd_dsi_bus_t {
4040
int bus_id;
4141
mipi_dsi_hal_context_t hal;
42+
#if CONFIG_PM_ENABLE
4243
esp_pm_lock_handle_t pm_lock;
44+
#endif
4345
} esp_lcd_dsi_bus_t;
4446

4547
#ifdef __cplusplus

components/esp_lcd/i80/esp_lcd_panel_io_i2s.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -71,7 +71,9 @@ struct esp_lcd_i80_bus_t {
7171
int dc_gpio_num; // GPIO used for DC line
7272
int wr_gpio_num; // GPIO used for WR line
7373
intr_handle_t intr; // LCD peripheral interrupt handle
74+
#if CONFIG_PM_ENABLE
7475
esp_pm_lock_handle_t pm_lock; // lock APB frequency when necessary
76+
#endif
7577
size_t max_transfer_bytes; // Maximum number of bytes that can be transferred in one transaction
7678
gdma_link_list_handle_t dma_link; // DMA link list handle
7779
uint8_t *format_buffer;// The driver allocates an internal buffer for DMA to do data format transformer
@@ -235,9 +237,11 @@ esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lc
235237
if (bus->format_buffer) {
236238
free(bus->format_buffer);
237239
}
240+
#if CONFIG_PM_ENABLE
238241
if (bus->pm_lock) {
239242
esp_pm_lock_delete(bus->pm_lock);
240243
}
244+
#endif
241245
free(bus);
242246
}
243247
return ret;
@@ -251,9 +255,11 @@ esp_err_t esp_lcd_del_i80_bus(esp_lcd_i80_bus_handle_t bus)
251255
int bus_id = bus->bus_id;
252256
i2s_platform_release_occupation(I2S_CTLR_HP, bus_id);
253257
esp_intr_free(bus->intr);
258+
#if CONFIG_PM_ENABLE
254259
if (bus->pm_lock) {
255260
esp_pm_lock_delete(bus->pm_lock);
256261
}
262+
#endif
257263
free(bus->format_buffer);
258264
gdma_del_link_list(bus->dma_link);
259265
free(bus);
@@ -550,10 +556,12 @@ static esp_err_t panel_io_i80_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, cons
550556
// delay a while, wait for DMA data being feed to I2S FIFO
551557
// in fact, this is only needed when LCD pixel clock is set too high
552558
esp_rom_delay_us(1);
559+
#if CONFIG_PM_ENABLE
553560
// increase the pm lock reference count before starting a new transaction
554561
if (bus->pm_lock) {
555562
esp_pm_lock_acquire(bus->pm_lock);
556563
}
564+
#endif
557565
i2s_ll_tx_start(bus->hal.dev);
558566
// polling the trans done event
559567
while (!(i2s_ll_get_intr_status(bus->hal.dev) & I2S_LL_EVENT_TX_EOF)) {}
@@ -574,10 +582,12 @@ static esp_err_t panel_io_i80_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, cons
574582
// polling the trans done event, but don't clear the event status
575583
while (!(i2s_ll_get_intr_status(bus->hal.dev) & I2S_LL_EVENT_TX_EOF)) {}
576584
}
585+
#if CONFIG_PM_ENABLE
577586
// decrease pm lock reference count
578587
if (bus->pm_lock) {
579588
esp_pm_lock_release(bus->pm_lock);
580589
}
590+
#endif
581591
bus->cur_trans = NULL;
582592
return ESP_OK;
583593
}
@@ -624,17 +634,21 @@ static esp_err_t panel_io_i80_tx_color(esp_lcd_panel_io_t *io, int lcd_cmd, cons
624634
i2s_ll_tx_reset(bus->hal.dev); // reset TX engine first
625635
i2s_ll_start_out_link(bus->hal.dev);
626636
esp_rom_delay_us(1);
637+
#if CONFIG_PM_ENABLE
627638
// increase the pm lock reference count before starting a new transaction
628639
if (bus->pm_lock) {
629640
esp_pm_lock_acquire(bus->pm_lock);
630641
}
642+
#endif
631643
i2s_ll_tx_start(bus->hal.dev);
632644
// polling the trans done event
633645
while (!(i2s_ll_get_intr_status(bus->hal.dev) & I2S_LL_EVENT_TX_EOF)) {}
646+
#if CONFIG_PM_ENABLE
634647
// decrease pm lock reference count
635648
if (bus->pm_lock) {
636649
esp_pm_lock_release(bus->pm_lock);
637650
}
651+
#endif
638652
bus->cur_trans = NULL;
639653

640654
// sending LCD color data to queue
@@ -770,10 +784,12 @@ static IRAM_ATTR void i2s_lcd_default_isr_handler(void *args)
770784
// process finished transaction
771785
if (trans_desc) {
772786
assert(trans_desc->i80_device == cur_device && "transaction device mismatch");
787+
#if CONFIG_PM_ENABLE
773788
// decrease pm lock reference count
774789
if (bus->pm_lock) {
775790
esp_pm_lock_release(bus->pm_lock);
776791
}
792+
#endif
777793
// device callback
778794
if (trans_desc->trans_done_cb) {
779795
if (trans_desc->trans_done_cb(&cur_device->base, NULL, trans_desc->user_ctx)) {
@@ -824,10 +840,12 @@ static IRAM_ATTR void i2s_lcd_default_isr_handler(void *args)
824840
i2s_ll_tx_reset(bus->hal.dev); // reset TX engine first
825841
i2s_ll_start_out_link(bus->hal.dev);
826842
esp_rom_delay_us(1);
843+
#if CONFIG_PM_ENABLE
827844
// increase the pm lock reference count before starting a new transaction
828845
if (bus->pm_lock) {
829846
esp_pm_lock_acquire(bus->pm_lock);
830847
}
848+
#endif
831849
i2s_ll_tx_start(bus->hal.dev);
832850
break; // exit for-each loop
833851
}

components/esp_lcd/i80/esp_lcd_panel_io_i80.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -84,7 +84,9 @@ struct esp_lcd_i80_bus_t {
8484
lcd_hal_context_t hal; // Hal object
8585
size_t bus_width; // Number of data lines
8686
intr_handle_t intr; // LCD peripheral interrupt handle
87+
#if CONFIG_PM_ENABLE
8788
esp_pm_lock_handle_t pm_lock; // Power management lock
89+
#endif
8890
uint8_t *format_buffer; // The driver allocates an internal buffer for DMA to do data format transformer
8991
uint8_t *format_buffer_nc; // Non-cacheable version of format buffer
9092
size_t resolution_hz; // LCD_CLK resolution, determined by selected clock source
@@ -251,9 +253,11 @@ esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lc
251253
if (bus->format_buffer) {
252254
free(bus->format_buffer);
253255
}
256+
#if CONFIG_PM_ENABLE
254257
if (bus->pm_lock) {
255258
esp_pm_lock_delete(bus->pm_lock);
256259
}
260+
#endif
257261
free(bus);
258262
}
259263
return ret;
@@ -275,9 +279,11 @@ esp_err_t esp_lcd_del_i80_bus(esp_lcd_i80_bus_handle_t bus)
275279
gdma_del_channel(bus->dma_chan);
276280
esp_intr_free(bus->intr);
277281
free(bus->format_buffer);
282+
#if CONFIG_PM_ENABLE
278283
if (bus->pm_lock) {
279284
esp_pm_lock_delete(bus->pm_lock);
280285
}
286+
#endif
281287
gdma_del_link_list(bus->dma_link);
282288
free(bus);
283289
ESP_LOGD(TAG, "del i80 bus(%d)", bus_id);
@@ -497,17 +503,21 @@ static esp_err_t panel_io_i80_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, cons
497503
}
498504
};
499505
gdma_link_mount_buffers(bus->dma_link, 0, &mount_config, 1, NULL);
506+
#if CONFIG_PM_ENABLE
500507
// increase the pm lock reference count before starting a new transaction
501508
if (bus->pm_lock) {
502509
esp_pm_lock_acquire(bus->pm_lock);
503510
}
511+
#endif
504512
lcd_start_transaction(bus, trans_desc);
505513
// polling the trans done event, but don't clear the event status
506514
while (!(lcd_ll_get_interrupt_status(bus->hal.dev) & LCD_LL_EVENT_TRANS_DONE)) {}
515+
#if CONFIG_PM_ENABLE
507516
// decrease pm lock reference count
508517
if (bus->pm_lock) {
509518
esp_pm_lock_release(bus->pm_lock);
510519
}
520+
#endif
511521
return ESP_OK;
512522
}
513523

@@ -752,10 +762,12 @@ IRAM_ATTR static void i80_lcd_default_isr_handler(void *args)
752762
// process finished transaction
753763
if (trans_desc) {
754764
assert(trans_desc->i80_device == cur_device && "transaction device mismatch");
765+
#if CONFIG_PM_ENABLE
755766
// decrease pm lock reference count
756767
if (bus->pm_lock) {
757768
esp_pm_lock_release(bus->pm_lock);
758769
}
770+
#endif
759771
// device callback
760772
if (trans_desc->trans_done_cb) {
761773
if (trans_desc->trans_done_cb(&cur_device->base, NULL, trans_desc->user_ctx)) {
@@ -802,10 +814,12 @@ IRAM_ATTR static void i80_lcd_default_isr_handler(void *args)
802814
gdma_link_mount_buffers(bus->dma_link, 0, &mount_config, 1, NULL);
803815
// enable interrupt again, because the new transaction can trigger new trans done event
804816
esp_intr_enable(bus->intr);
817+
#if CONFIG_PM_ENABLE
805818
// increase the pm lock reference count before starting a new transaction
806819
if (bus->pm_lock) {
807820
esp_pm_lock_acquire(bus->pm_lock);
808821
}
822+
#endif
809823
lcd_start_transaction(bus, trans_desc);
810824
break; // exit for-each loop
811825
}

components/esp_lcd/rgb/esp_lcd_panel_rgb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ struct esp_rgb_panel_t {
104104
size_t dma_burst_size; // DMA transfer burst size
105105
int disp_gpio_num; // Display control GPIO, which is used to perform action like "disp_off"
106106
intr_handle_t intr; // LCD peripheral interrupt handle
107+
#if CONFIG_PM_ENABLE
107108
esp_pm_lock_handle_t pm_lock; // Power management lock
109+
#endif
108110
size_t num_dma_nodes; // Number of DMA descriptors that used to carry the frame buffer
109111
gdma_channel_handle_t dma_chan; // DMA channel handle
110112
gdma_link_list_handle_t dma_fb_links[RGB_LCD_PANEL_MAX_FB_NUM]; // DMA link lists for multiple frame buffers
@@ -235,10 +237,12 @@ static esp_err_t lcd_rgb_panel_destroy(esp_rgb_panel_t *rgb_panel)
235237
if (rgb_panel->intr) {
236238
esp_intr_free(rgb_panel->intr);
237239
}
240+
#if CONFIG_PM_ENABLE
238241
if (rgb_panel->pm_lock) {
239242
esp_pm_lock_release(rgb_panel->pm_lock);
240243
esp_pm_lock_delete(rgb_panel->pm_lock);
241244
}
245+
#endif
242246
free(rgb_panel);
243247
return ESP_OK;
244248
}

0 commit comments

Comments
 (0)