-
Notifications
You must be signed in to change notification settings - Fork 619
os/drivers/lcd: Prevent multiple LCD power on/off operations #7010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os/drivers/lcd: Prevent multiple LCD power on/off operations #7010
Conversation
pcs1265
left a comment
There was a problem hiding this 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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
- Don't you need to verify the priv for null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Change the return type of both
lcd_power_offandlcd_power_ontoint, as power operations can fail whensend_cmdorcheck_lcd_vendor_send_init_cmdfail. -
Verify
privis not null by addingDEBUGASSERTto all functions to validate non-null arguments in the new commit.
08fef23 to
a106064
Compare
|
LGTM |
a106064 to
071cbba
Compare
os/drivers/lcd/mipi_lcd.c
Outdated
| DEBUGASSERT(priv); | ||
| if (priv->lcdonoff == LCD_OFF) { | ||
| lcddbg("ERROR: LCD already powered off\n"); | ||
| return; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved.
os/drivers/lcd/mipi_lcd.c
Outdated
| 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"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved.
071cbba to
adad52c
Compare
os/drivers/lcd/mipi_lcd.c
Outdated
| 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) { |
There was a problem hiding this comment.
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);
}
There was a problem hiding this comment.
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.
os/drivers/lcd/mipi_lcd.c
Outdated
| return ERROR; | ||
| } | ||
|
|
||
| priv->lcdonoff = LCD_OFF; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
os/drivers/lcd/mipi_lcd.c
Outdated
| /* 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
os/drivers/lcd/mipi_lcd.c
Outdated
| lcddbg("Powering down the LCD\n"); | ||
| priv->config->backlight(power); | ||
| lcd_power_off(priv); | ||
| if (lcd_power_off(priv) != OK) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it.
cf84f73 to
810e56c
Compare
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>
810e56c to
79f1b5a
Compare
Add condition check to prevent multiple LCD power on/off operations.