mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
drm/panel: simple: handle small delay durations more precisely
Since msleep is based on jiffies the panel could take longer than expected. So use msleep for values greater than 20 msec otherwise usleep_range. Change-Id: Ib03c6e381b44a31dd57aeaaa3a88a459578de313 Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
This commit is contained in:
@@ -137,6 +137,14 @@ enum MCU_IOCTL {
|
||||
MCU_SETBYPASS,
|
||||
};
|
||||
|
||||
static void panel_simple_sleep(unsigned int msec)
|
||||
{
|
||||
if (msec > 20)
|
||||
msleep(msec);
|
||||
else
|
||||
usleep_range(msec * 1000, (msec + 1) * 1000);
|
||||
}
|
||||
|
||||
static inline int get_panel_cmd_type(const char *s)
|
||||
{
|
||||
if (!s)
|
||||
@@ -172,7 +180,7 @@ static int panel_simple_parse_cmds(struct device *dev,
|
||||
const u8 *data, int blen,
|
||||
struct panel_cmds *pcmds)
|
||||
{
|
||||
int len;
|
||||
unsigned int len;
|
||||
char *buf, *bp;
|
||||
struct cmd_ctrl_hdr *dchdr;
|
||||
int i, cnt;
|
||||
@@ -282,7 +290,7 @@ static int panel_simple_mcu_send_cmds(struct panel_simple *panel,
|
||||
rockchip_drm_crtc_send_mcu_cmd(panel->base.drm, panel->np_crtc,
|
||||
cmd->dchdr.dtype, value);
|
||||
if (cmd->dchdr.wait)
|
||||
msleep(cmd->dchdr.wait);
|
||||
panel_simple_sleep(cmd->dchdr.wait);
|
||||
}
|
||||
rockchip_drm_crtc_send_mcu_cmd(panel->base.drm,
|
||||
panel->np_crtc, MCU_SETBYPASS, 0);
|
||||
@@ -309,7 +317,7 @@ static int panel_simple_spi_send_cmds(struct panel_simple *panel,
|
||||
panel_simple_spi_write_cmd(panel, cmd->dchdr.dtype, value);
|
||||
|
||||
if (cmd->dchdr.wait)
|
||||
msleep(cmd->dchdr.wait);
|
||||
panel_simple_sleep(cmd->dchdr.wait);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -351,7 +359,7 @@ static int panel_simple_dsi_send_cmds(struct panel_simple *panel,
|
||||
err);
|
||||
|
||||
if (cmd->dchdr.wait)
|
||||
msleep(cmd->dchdr.wait);
|
||||
panel_simple_sleep(cmd->dchdr.wait);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -569,7 +577,7 @@ static int panel_simple_disable(struct drm_panel *panel)
|
||||
}
|
||||
|
||||
if (p->desc && p->desc->delay.disable)
|
||||
msleep(p->desc->delay.disable);
|
||||
panel_simple_sleep(p->desc->delay.disable);
|
||||
|
||||
if (p->cmd_type == CMD_TYPE_MCU) {
|
||||
err = panel_simple_mcu_send_cmds(p, p->off_cmds);
|
||||
@@ -607,7 +615,7 @@ static int panel_simple_unprepare(struct drm_panel *panel)
|
||||
panel_simple_regulator_disable(panel);
|
||||
|
||||
if (p->desc && p->desc->delay.unprepare)
|
||||
msleep(p->desc->delay.unprepare);
|
||||
panel_simple_sleep(p->desc->delay.unprepare);
|
||||
|
||||
p->prepared = false;
|
||||
|
||||
@@ -632,19 +640,19 @@ static int panel_simple_prepare(struct drm_panel *panel)
|
||||
gpiod_direction_output(p->enable_gpio, 1);
|
||||
|
||||
if (p->desc && p->desc->delay.prepare)
|
||||
msleep(p->desc->delay.prepare);
|
||||
panel_simple_sleep(p->desc->delay.prepare);
|
||||
|
||||
if (p->reset_gpio)
|
||||
gpiod_direction_output(p->reset_gpio, 1);
|
||||
|
||||
if (p->desc && p->desc->delay.reset)
|
||||
msleep(p->desc->delay.reset);
|
||||
panel_simple_sleep(p->desc->delay.reset);
|
||||
|
||||
if (p->reset_gpio)
|
||||
gpiod_direction_output(p->reset_gpio, 0);
|
||||
|
||||
if (p->desc && p->desc->delay.init)
|
||||
msleep(p->desc->delay.init);
|
||||
panel_simple_sleep(p->desc->delay.init);
|
||||
|
||||
if (p->on_cmds) {
|
||||
if (p->dsi)
|
||||
@@ -674,7 +682,7 @@ static int panel_simple_enable(struct drm_panel *panel)
|
||||
dev_err(p->dev, "failed to send mcu on cmds\n");
|
||||
}
|
||||
if (p->desc && p->desc->delay.enable)
|
||||
msleep(p->desc->delay.enable);
|
||||
panel_simple_sleep(p->desc->delay.enable);
|
||||
|
||||
if (p->backlight) {
|
||||
p->backlight->props.power = FB_BLANK_UNBLANK;
|
||||
|
||||
Reference in New Issue
Block a user