Commit 81cc7e51 authored by Julien STEPHAN's avatar Julien STEPHAN Committed by Chun-Kuang Hu

drm/mediatek: Allow commands to be sent during video mode

Mipi dsi panel drivers can use mipi_dsi_dcs_{set,get}_display_brightness()
to request backlight changes.

This can be done during panel initialization (dsi is in command mode)
or afterwards (dsi is in Video Mode).

When the DSI is in Video Mode, all commands are rejected.

Detect current DSI mode in mtk_dsi_host_transfer() and switch modes
temporarily to allow commands to be sent.
Signed-off-by: default avatarJulien STEPHAN <jstephan@baylibre.com>
Signed-off-by: default avatarMattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarChun-Kuang Hu <chunkuang.hu@kernel.org>
parent e7dcfe64
...@@ -891,24 +891,33 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host, ...@@ -891,24 +891,33 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
u8 read_data[16]; u8 read_data[16];
void *src_addr; void *src_addr;
u8 irq_flag = CMD_DONE_INT_FLAG; u8 irq_flag = CMD_DONE_INT_FLAG;
u32 dsi_mode;
int ret;
if (readl(dsi->regs + DSI_MODE_CTRL) & MODE) { dsi_mode = readl(dsi->regs + DSI_MODE_CTRL);
DRM_ERROR("dsi engine is not command mode\n"); if (dsi_mode & MODE) {
return -EINVAL; mtk_dsi_stop(dsi);
ret = mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500);
if (ret)
goto restore_dsi_mode;
} }
if (MTK_DSI_HOST_IS_READ(msg->type)) if (MTK_DSI_HOST_IS_READ(msg->type))
irq_flag |= LPRX_RD_RDY_INT_FLAG; irq_flag |= LPRX_RD_RDY_INT_FLAG;
if (mtk_dsi_host_send_cmd(dsi, msg, irq_flag) < 0) ret = mtk_dsi_host_send_cmd(dsi, msg, irq_flag);
return -ETIME; if (ret)
goto restore_dsi_mode;
if (!MTK_DSI_HOST_IS_READ(msg->type)) if (!MTK_DSI_HOST_IS_READ(msg->type)) {
return 0; recv_cnt = 0;
goto restore_dsi_mode;
}
if (!msg->rx_buf) { if (!msg->rx_buf) {
DRM_ERROR("dsi receive buffer size may be NULL\n"); DRM_ERROR("dsi receive buffer size may be NULL\n");
return -EINVAL; ret = -EINVAL;
goto restore_dsi_mode;
} }
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
...@@ -933,7 +942,13 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host, ...@@ -933,7 +942,13 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n", DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n",
recv_cnt, *((u8 *)(msg->tx_buf))); recv_cnt, *((u8 *)(msg->tx_buf)));
return recv_cnt; restore_dsi_mode:
if (dsi_mode & MODE) {
mtk_dsi_set_mode(dsi);
mtk_dsi_start(dsi);
}
return ret < 0 ? ret : recv_cnt;
} }
static const struct mipi_dsi_host_ops mtk_dsi_ops = { static const struct mipi_dsi_host_ops mtk_dsi_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment