Skip to content

Commit df21193

Browse files
committed
fix(mipi_dsi): only wait ready for enabled data lane
1 parent e486f3b commit df21193

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

components/esp_lcd/dsi/esp_lcd_mipi_dsi_bus.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ esp_err_t esp_lcd_new_dsi_bus(const esp_lcd_dsi_bus_config_t *bus_config, esp_lc
2121
{
2222
esp_err_t ret = ESP_OK;
2323
ESP_RETURN_ON_FALSE(bus_config && ret_bus, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
24+
ESP_RETURN_ON_FALSE(bus_config->num_data_lanes <= MIPI_DSI_LL_MAX_DATA_LANES,
25+
ESP_ERR_INVALID_ARG, TAG, "invalid number of data lanes %d", bus_config->num_data_lanes);
2426
ESP_RETURN_ON_FALSE(bus_config->lane_bit_rate_mbps >= MIPI_DSI_LL_MIN_PHY_MBPS &&
2527
bus_config->lane_bit_rate_mbps <= MIPI_DSI_LL_MAX_PHY_MBPS, ESP_ERR_INVALID_ARG, TAG,
2628
"invalid lane bit rate %"PRIu32, bus_config->lane_bit_rate_mbps);
@@ -64,11 +66,16 @@ esp_err_t esp_lcd_new_dsi_bus(const esp_lcd_dsi_bus_config_t *bus_config, esp_lc
6466
esp_pm_lock_acquire(dsi_bus->pm_lock);
6567
#endif
6668

69+
// if the number of data lanes is not assigned, fallback to the maximum number of data lanes
70+
int num_data_lanes = bus_config->num_data_lanes;
71+
if (num_data_lanes == 0) {
72+
num_data_lanes = MIPI_DSI_LL_MAX_DATA_LANES;
73+
}
6774
// initialize HAL context
6875
mipi_dsi_hal_config_t hal_config = {
6976
.bus_id = bus_id,
7077
.lane_bit_rate_mbps = bus_config->lane_bit_rate_mbps,
71-
.num_data_lanes = bus_config->num_data_lanes,
78+
.num_data_lanes = num_data_lanes,
7279
};
7380
mipi_dsi_hal_init(&dsi_bus->hal, &hal_config);
7481
mipi_dsi_hal_context_t *hal = &dsi_bus->hal;
@@ -84,7 +91,7 @@ esp_err_t esp_lcd_new_dsi_bus(const esp_lcd_dsi_bus_config_t *bus_config, esp_lc
8491
while (!mipi_dsi_phy_ll_is_pll_locked(hal->host)) {
8592
vTaskDelay(pdMS_TO_TICKS(1));
8693
}
87-
while (!mipi_dsi_phy_ll_are_lanes_stopped(hal->host)) {
94+
while (!mipi_dsi_phy_ll_are_lanes_stopped(hal->host, num_data_lanes)) {
8895
vTaskDelay(pdMS_TO_TICKS(1));
8996
}
9097

components/esp_lcd/dsi/include/esp_lcd_mipi_dsi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern "C" {
2121
*/
2222
typedef struct {
2323
int bus_id; /*!< Select which DSI controller, index from 0 */
24-
uint8_t num_data_lanes; /*!< Number of data lanes */
24+
uint8_t num_data_lanes; /*!< Number of data lanes, if set to 0, the driver will fallback to use maximum number of lanes */
2525
mipi_dsi_phy_clock_source_t phy_clk_src; /*!< MIPI DSI PHY clock source */
2626
uint32_t lane_bit_rate_mbps; /*!< Lane bit rate in Mbps */
2727
} esp_lcd_dsi_bus_config_t;

components/hal/esp32p4/include/hal/mipi_dsi_ll.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
#include "hal/mipi_dsi_brg_ll.h"
1515
#include "hal/mipi_dsi_phy_ll.h"
1616

17-
#define MIPI_DSI_LL_NUM_BUS 1 // 1 MIPI DSI bus
17+
#define MIPI_DSI_LL_NUM_BUS 1 // support only 1 MIPI DSI bus
18+
#define MIPI_DSI_LL_MAX_DATA_LANES 2 // support up to 2 data lanes
1819

1920
#ifdef __cplusplus
2021
extern "C" {

components/hal/esp32p4/include/hal/mipi_dsi_phy_ll.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,19 @@ static inline bool mipi_dsi_phy_ll_is_pll_locked(dsi_host_dev_t *dev)
8181
* @brief Check if the all active lanes are in the stop state
8282
*
8383
* @param dev Pointer to the DSI Host controller register base address
84+
* @param num_data_lanes Number of data lanes
8485
* @return True if the lanes are all in stop state, False otherwise
8586
*/
86-
static inline bool mipi_dsi_phy_ll_are_lanes_stopped(dsi_host_dev_t *dev)
87+
static inline bool mipi_dsi_phy_ll_are_lanes_stopped(dsi_host_dev_t *dev, uint8_t num_data_lanes)
8788
{
8889
uint32_t status = dev->phy_status.val;
89-
const uint32_t mask = 1 << 2 | 1 << 4 | 1 << 7;
90+
uint32_t mask = 1 << 2;
91+
if (num_data_lanes > 0) {
92+
mask |= 1 << 4;
93+
}
94+
if (num_data_lanes > 1) {
95+
mask |= 1 << 7;
96+
}
9097
return (status & mask) == mask;
9198
}
9299

0 commit comments

Comments
 (0)