Skip to content

Conversation

@seokhun-eom24
Copy link
Contributor

Add condition check to prevent multiple LCD power on/off operations.

Copy link
Member

@pcs1265 pcs1265 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

*
****************************************************************************/

static int lcd_power_on(FAR struct mipi_lcd_dev_s *priv)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of this PR, why do off and on APIs have different return type?

*
****************************************************************************/

static int lcd_power_on(FAR struct mipi_lcd_dev_s *priv)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Regardless of this PR, why do off and on APIs have different return type?
  2. Don't you need to verify the priv for null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Change the return type of both lcd_power_off and lcd_power_on to int, as power operations can fail when send_cmd or check_lcd_vendor_send_init_cmd fail.

  2. Verify priv is not null by adding DEBUGASSERT to all functions to validate non-null arguments in the new commit.

@seokhun-eom24 seokhun-eom24 force-pushed the 251021-add-boundary-lcdonoff branch from 08fef23 to a106064 Compare October 27, 2025 06:02
@abhinav-s235
Copy link
Contributor

LGTM

@seokhun-eom24 seokhun-eom24 force-pushed the 251021-add-boundary-lcdonoff branch from a106064 to 071cbba Compare October 27, 2025 09:02
DEBUGASSERT(priv);
if (priv->lcdonoff == LCD_OFF) {
lcddbg("ERROR: LCD already powered off\n");
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's void return type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved.

send_cmd(priv, display_off_cmd);
/* The power off must operate only when LCD is ON */
if (send_cmd(priv, display_off_cmd) != OK) {
lcddbg("ERROR: LCD power off failed\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here there should be return

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved.

@seokhun-eom24 seokhun-eom24 force-pushed the 251021-add-boundary-lcdonoff branch from 071cbba to adad52c Compare October 30, 2025 11:17
lcm_setting_table_t display_off_cmd = {0x28, 0, {0x00}};
send_cmd(priv, display_off_cmd);
/* The power off must operate only when LCD is ON */
if (send_cmd(priv, display_off_cmd) != OK) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int ret = send_cmd(priv, display_off_cmd);
if (ret != OK) {
	lcddbg("ERROR: LCD power off failed ret : %d\n", ret);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out.
I modified to log so that errno can be logged.

return ERROR;
}

priv->lcdonoff = LCD_OFF;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor, but usually change operation and then change state is more stable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a very minor issue, but I think it would be better to fix it.
Thank you.

if (priv->lcdonoff == LCD_ON) {
lcddbg("ERROR: LCD already powered on\n");
return ERROR;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after this, priv->lcdonoff need to be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, we're setting priv->lcdonoff = LCD_ON when switching mipi video mode and render buffer data timing.
But this distributed state management has a risk, so I refactored it in #7018.

/* The power off must operate only when LCD is ON */
if (send_cmd(priv, display_off_cmd) != OK) {
lcddbg("ERROR: LCD power off failed\n");
return ERROR;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will finally calls bsp function, and perhaps return value is one of value in errno.h
so you should return one of errno, not ERROR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified to return errno from send_cmd.

lcddbg("Powering down the LCD\n");
priv->config->backlight(power);
lcd_power_off(priv);
if (lcd_power_off(priv) != OK) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above comments. debug message include result & type of error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it.

@seokhun-eom24 seokhun-eom24 force-pushed the 251021-add-boundary-lcdonoff branch 2 times, most recently from cf84f73 to 810e56c Compare October 31, 2025 04:56
Add condition check to prevent multiple LCD power on/off operations.

Signed-off-by: seokhun-eom <seokhun.eom@samsung.com>
Add DEBUGASSERT checks for device pointers and validate other pointer parameters.
This null checks for function that can be called by drivers.

Signed-off-by: seokhun-eom <seokhun.eom@samsung.com>
@seokhun-eom24 seokhun-eom24 force-pushed the 251021-add-boundary-lcdonoff branch from 810e56c to 79f1b5a Compare December 22, 2025 12:09
@sunghan-chang sunghan-chang merged commit 58ea648 into Samsung:master Dec 26, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants