Commit 20689765 authored by Trung Hieu Le's avatar Trung Hieu Le Committed by Carles Cufi
Browse files

drivers: display: elcdif: Modify interrupt enablement



The elcdif interrupt is enabled in the write function and disabled in
the IRQ handler for each new frame update. Disabling the interrupt when
no new frame needs to be sent gives the CPU the possibility to enter
low-power mode. However, when the application's frame rate
matches the LCD refresh rate, this adds additional latency.

This commit provides a config to choose between following options:
- Toggle the CUR_FRAME_DONE_IRQ_EN in the write function and in IRQ
handler for each new frame when the power mangement is a concern.
- Activate the CUR_FRAME_DONE_IRQ_EN once at the init function when
low latency is required.

Signed-off-by: default avatarTrung Hieu Le <trunghieu.le@nxp.com>
parent 024bd41e
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -53,6 +53,18 @@ config MCUX_ELCDIF_PXP
	  display_write is called with a framebuffer equal in size to the
	  display.

config MCUX_ELCDIF_LP
	bool "ELCDIF low power"
	help
	  This option, when enabled, will enable CUR_FRAME_DONE_IRQ at the display
	  write function and disable it at the interruption handler for each new frame.
	  Disabling the interrupt when no new frame needs to be sent gives the CPU the
	  possibility to enter low-power mode, thus saving energy.
	  This option, when disabled, CUR_FRAME_DONE_IRQ will be enabled only
	  once at initialization. This option should be disabled when the application's
	  frame rate is close to the display's refresh rate to avoid introducing
	  additional latency caused by frequently enabling and disabling CUR_FRAME_DONE_IRQ.

if MCUX_ELCDIF_PXP

choice MCUX_ELCDIF_PXP_ROTATE_DIRECTION
+12 −6
Original line number Diff line number Diff line
@@ -203,8 +203,10 @@ static int mcux_elcdif_write(const struct device *dev, const uint16_t x, const u
	/* Update index of active framebuffer */
	dev_data->next_idx = (dev_data->next_idx + 1) % CONFIG_MCUX_ELCDIF_FB_NUM;
#endif
	/* Enable frame buffer completion interrupt */

	if (IS_ENABLED(CONFIG_MCUX_ELCDIF_LP)) {
		ELCDIF_EnableInterrupts(config->base, kELCDIF_CurFrameDoneInterruptEnable);
	}
	/* Wait for frame send to complete */
	k_sem_take(&dev_data->sem, K_FOREVER);
	return ret;
@@ -297,10 +299,11 @@ static void mcux_elcdif_isr(const struct device *dev)
	status = ELCDIF_GetInterruptStatus(config->base);
	ELCDIF_ClearInterruptStatus(config->base, status);
	if (config->base->CUR_BUF == ((uint32_t)dev_data->active_fb)) {
		/* Disable frame completion interrupt, post to
		 * sem to notify that frame send is complete.
		 */
		if (IS_ENABLED(CONFIG_MCUX_ELCDIF_LP)) {
			/* Disable frame completion interrupt if Low power mode is activated*/
			ELCDIF_DisableInterrupts(config->base, kELCDIF_CurFrameDoneInterruptEnable);
		}
		/* Post to sem to notify that frame display is complete.*/
		k_sem_give(&dev_data->sem);
	}
}
@@ -338,6 +341,9 @@ static int mcux_elcdif_init(const struct device *dev)
	dev_data->active_fb = dev_data->fb[0];

	ELCDIF_RgbModeInit(config->base, &dev_data->rgb_mode);
	if (!IS_ENABLED(CONFIG_MCUX_ELCDIF_LP)) {
		ELCDIF_EnableInterrupts(config->base, kELCDIF_CurFrameDoneInterruptEnable);
	}
	ELCDIF_RgbModeStart(config->base);

	return 0;