Skip to content

Commit 81cc7e5

Browse files
justephChun-Kuang Hu
authored andcommitted
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: Julien STEPHAN <jstephan@baylibre.com> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
1 parent e7dcfe6 commit 81cc7e5

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

drivers/gpu/drm/mediatek/mtk_dsi.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -891,24 +891,33 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
891891
u8 read_data[16];
892892
void *src_addr;
893893
u8 irq_flag = CMD_DONE_INT_FLAG;
894+
u32 dsi_mode;
895+
int ret;
894896

895-
if (readl(dsi->regs + DSI_MODE_CTRL) & MODE) {
896-
DRM_ERROR("dsi engine is not command mode\n");
897-
return -EINVAL;
897+
dsi_mode = readl(dsi->regs + DSI_MODE_CTRL);
898+
if (dsi_mode & MODE) {
899+
mtk_dsi_stop(dsi);
900+
ret = mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500);
901+
if (ret)
902+
goto restore_dsi_mode;
898903
}
899904

900905
if (MTK_DSI_HOST_IS_READ(msg->type))
901906
irq_flag |= LPRX_RD_RDY_INT_FLAG;
902907

903-
if (mtk_dsi_host_send_cmd(dsi, msg, irq_flag) < 0)
904-
return -ETIME;
908+
ret = mtk_dsi_host_send_cmd(dsi, msg, irq_flag);
909+
if (ret)
910+
goto restore_dsi_mode;
905911

906-
if (!MTK_DSI_HOST_IS_READ(msg->type))
907-
return 0;
912+
if (!MTK_DSI_HOST_IS_READ(msg->type)) {
913+
recv_cnt = 0;
914+
goto restore_dsi_mode;
915+
}
908916

909917
if (!msg->rx_buf) {
910918
DRM_ERROR("dsi receive buffer size may be NULL\n");
911-
return -EINVAL;
919+
ret = -EINVAL;
920+
goto restore_dsi_mode;
912921
}
913922

914923
for (i = 0; i < 16; i++)
@@ -933,7 +942,13 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,
933942
DRM_INFO("dsi get %d byte data from the panel address(0x%x)\n",
934943
recv_cnt, *((u8 *)(msg->tx_buf)));
935944

936-
return recv_cnt;
945+
restore_dsi_mode:
946+
if (dsi_mode & MODE) {
947+
mtk_dsi_set_mode(dsi);
948+
mtk_dsi_start(dsi);
949+
}
950+
951+
return ret < 0 ? ret : recv_cnt;
937952
}
938953

939954
static const struct mipi_dsi_host_ops mtk_dsi_ops = {

0 commit comments

Comments
 (0)