disp: msm: dsi: maintain validated dsi msg flags

This change fixes the usecase where dsi msg flags validated only
during command transfer. This fix maintains the flags between
transfer and trigger calls. It also adds a new async override
flag to be used to bypass validate function.

Change-Id: Ie12acd3d7b01099bba65ca37cec61091408b81c5
Signed-off-by: Nilaan Gunabalachandran <ngunabal@codeaurora.org>
Signed-off-by: Satya Rama Aditya Pinapala <psraditya30@codeaurora.org>
This commit is contained in:
Nilaan Gunabalachandran
2020-03-19 15:17:41 -04:00
committed by Satya Rama Aditya Pinapala
parent a1143d12be
commit 41f52e3987
4 changed files with 40 additions and 32 deletions

View File

@@ -18,6 +18,7 @@
#include "dsi_clk.h" #include "dsi_clk.h"
#include "dsi_pwr.h" #include "dsi_pwr.h"
#include "dsi_catalog.h" #include "dsi_catalog.h"
#include "dsi_panel.h"
#include "sde_dbg.h" #include "sde_dbg.h"
@@ -1251,9 +1252,9 @@ static void dsi_kickoff_msg_tx(struct dsi_ctrl *dsi_ctrl,
} }
} }
static u32 dsi_ctrl_validate_msg_flags(struct dsi_ctrl *dsi_ctrl, static void dsi_ctrl_validate_msg_flags(struct dsi_ctrl *dsi_ctrl,
const struct mipi_dsi_msg *msg, const struct mipi_dsi_msg *msg,
u32 flags) u32 *flags)
{ {
/* /*
* ASYNC command wait mode is not supported for * ASYNC command wait mode is not supported for
@@ -1263,20 +1264,20 @@ static u32 dsi_ctrl_validate_msg_flags(struct dsi_ctrl *dsi_ctrl,
* - whenever an explicit wait time is specificed for the command * - whenever an explicit wait time is specificed for the command
* since the wait time cannot be guaranteed in async mode * since the wait time cannot be guaranteed in async mode
* - video mode panels * - video mode panels
* If async override is set, skip async flag reset
*/ */
if ((flags & DSI_CTRL_CMD_FIFO_STORE) || if (((*flags & DSI_CTRL_CMD_FIFO_STORE) ||
flags & DSI_CTRL_CMD_READ || *flags & DSI_CTRL_CMD_READ ||
flags & DSI_CTRL_CMD_NON_EMBEDDED_MODE || *flags & DSI_CTRL_CMD_NON_EMBEDDED_MODE ||
msg->wait_ms || msg->wait_ms ||
(dsi_ctrl->host_config.panel_mode == DSI_OP_VIDEO_MODE)) (dsi_ctrl->host_config.panel_mode == DSI_OP_VIDEO_MODE)) &&
flags &= ~DSI_CTRL_CMD_ASYNC_WAIT; !(msg->flags & MIPI_DSI_MSG_ASYNC_OVERRIDE))
*flags &= ~DSI_CTRL_CMD_ASYNC_WAIT;
return flags;
} }
static int dsi_message_tx(struct dsi_ctrl *dsi_ctrl, static int dsi_message_tx(struct dsi_ctrl *dsi_ctrl,
const struct mipi_dsi_msg *msg, const struct mipi_dsi_msg *msg,
u32 flags) u32 *flags)
{ {
int rc = 0; int rc = 0;
struct mipi_dsi_packet packet; struct mipi_dsi_packet packet;
@@ -1288,10 +1289,10 @@ static int dsi_message_tx(struct dsi_ctrl *dsi_ctrl,
u8 *cmdbuf; u8 *cmdbuf;
/* Select the tx mode to transfer the command */ /* Select the tx mode to transfer the command */
dsi_message_setup_tx_mode(dsi_ctrl, msg->tx_len, &flags); dsi_message_setup_tx_mode(dsi_ctrl, msg->tx_len, flags);
/* Validate the mode before sending the command */ /* Validate the mode before sending the command */
rc = dsi_message_validate_tx_mode(dsi_ctrl, msg->tx_len, &flags); rc = dsi_message_validate_tx_mode(dsi_ctrl, msg->tx_len, flags);
if (rc) { if (rc) {
DSI_CTRL_ERR(dsi_ctrl, DSI_CTRL_ERR(dsi_ctrl,
"Cmd tx validation failed, cannot transfer cmd\n"); "Cmd tx validation failed, cannot transfer cmd\n");
@@ -1299,16 +1300,16 @@ static int dsi_message_tx(struct dsi_ctrl *dsi_ctrl,
goto error; goto error;
} }
flags = dsi_ctrl_validate_msg_flags(dsi_ctrl, msg, flags); dsi_ctrl_validate_msg_flags(dsi_ctrl, msg, flags);
if (dsi_ctrl->dma_wait_queued) if (dsi_ctrl->dma_wait_queued)
dsi_ctrl_flush_cmd_dma_queue(dsi_ctrl); dsi_ctrl_flush_cmd_dma_queue(dsi_ctrl);
if (flags & DSI_CTRL_CMD_NON_EMBEDDED_MODE) { if (*flags & DSI_CTRL_CMD_NON_EMBEDDED_MODE) {
cmd_mem.offset = dsi_ctrl->cmd_buffer_iova; cmd_mem.offset = dsi_ctrl->cmd_buffer_iova;
cmd_mem.en_broadcast = (flags & DSI_CTRL_CMD_BROADCAST) ? cmd_mem.en_broadcast = (*flags & DSI_CTRL_CMD_BROADCAST) ?
true : false; true : false;
cmd_mem.is_master = (flags & DSI_CTRL_CMD_BROADCAST_MASTER) ? cmd_mem.is_master = (*flags & DSI_CTRL_CMD_BROADCAST_MASTER) ?
true : false; true : false;
cmd_mem.use_lpm = (msg->flags & MIPI_DSI_MSG_USE_LPM) ? cmd_mem.use_lpm = (msg->flags & MIPI_DSI_MSG_USE_LPM) ?
true : false; true : false;
@@ -1343,12 +1344,12 @@ static int dsi_message_tx(struct dsi_ctrl *dsi_ctrl,
if ((msg->flags & MIPI_DSI_MSG_LASTCOMMAND)) if ((msg->flags & MIPI_DSI_MSG_LASTCOMMAND))
buffer[3] |= BIT(7);//set the last cmd bit in header. buffer[3] |= BIT(7);//set the last cmd bit in header.
if (flags & DSI_CTRL_CMD_FETCH_MEMORY) { if (*flags & DSI_CTRL_CMD_FETCH_MEMORY) {
/* Embedded mode config is selected */ /* Embedded mode config is selected */
cmd_mem.offset = dsi_ctrl->cmd_buffer_iova; cmd_mem.offset = dsi_ctrl->cmd_buffer_iova;
cmd_mem.en_broadcast = (flags & DSI_CTRL_CMD_BROADCAST) ? cmd_mem.en_broadcast = (*flags & DSI_CTRL_CMD_BROADCAST) ?
true : false; true : false;
cmd_mem.is_master = (flags & DSI_CTRL_CMD_BROADCAST_MASTER) ? cmd_mem.is_master = (*flags & DSI_CTRL_CMD_BROADCAST_MASTER) ?
true : false; true : false;
cmd_mem.use_lpm = (msg->flags & MIPI_DSI_MSG_USE_LPM) ? cmd_mem.use_lpm = (msg->flags & MIPI_DSI_MSG_USE_LPM) ?
true : false; true : false;
@@ -1368,19 +1369,19 @@ static int dsi_message_tx(struct dsi_ctrl *dsi_ctrl,
dsi_ctrl->cmd_len = 0; dsi_ctrl->cmd_len = 0;
} }
} else if (flags & DSI_CTRL_CMD_FIFO_STORE) { } else if (*flags & DSI_CTRL_CMD_FIFO_STORE) {
cmd.command = (u32 *)buffer; cmd.command = (u32 *)buffer;
cmd.size = length; cmd.size = length;
cmd.en_broadcast = (flags & DSI_CTRL_CMD_BROADCAST) ? cmd.en_broadcast = (*flags & DSI_CTRL_CMD_BROADCAST) ?
true : false; true : false;
cmd.is_master = (flags & DSI_CTRL_CMD_BROADCAST_MASTER) ? cmd.is_master = (*flags & DSI_CTRL_CMD_BROADCAST_MASTER) ?
true : false; true : false;
cmd.use_lpm = (msg->flags & MIPI_DSI_MSG_USE_LPM) ? cmd.use_lpm = (msg->flags & MIPI_DSI_MSG_USE_LPM) ?
true : false; true : false;
} }
kickoff: kickoff:
dsi_kickoff_msg_tx(dsi_ctrl, msg, &cmd, &cmd_mem, flags); dsi_kickoff_msg_tx(dsi_ctrl, msg, &cmd, &cmd_mem, *flags);
error: error:
if (buffer) if (buffer)
devm_kfree(&dsi_ctrl->pdev->dev, buffer); devm_kfree(&dsi_ctrl->pdev->dev, buffer);
@@ -1408,7 +1409,7 @@ static int dsi_set_max_return_size(struct dsi_ctrl *dsi_ctrl,
dflags &= ~BIT(3); dflags &= ~BIT(3);
msg.flags = dflags; msg.flags = dflags;
rc = dsi_message_tx(dsi_ctrl, &msg, flags); rc = dsi_message_tx(dsi_ctrl, &msg, &flags);
if (rc) if (rc)
DSI_CTRL_ERR(dsi_ctrl, "failed to send max return size packet, rc=%d\n", DSI_CTRL_ERR(dsi_ctrl, "failed to send max return size packet, rc=%d\n",
rc); rc);
@@ -1470,7 +1471,7 @@ static int dsi_parse_long_read_resp(const struct mipi_dsi_msg *msg,
static int dsi_message_rx(struct dsi_ctrl *dsi_ctrl, static int dsi_message_rx(struct dsi_ctrl *dsi_ctrl,
const struct mipi_dsi_msg *msg, const struct mipi_dsi_msg *msg,
u32 flags) u32 *flags)
{ {
int rc = 0; int rc = 0;
u32 rd_pkt_size, total_read_len, hw_read_cnt; u32 rd_pkt_size, total_read_len, hw_read_cnt;
@@ -3071,7 +3072,7 @@ int dsi_ctrl_validate_timing(struct dsi_ctrl *dsi_ctrl,
*/ */
int dsi_ctrl_cmd_transfer(struct dsi_ctrl *dsi_ctrl, int dsi_ctrl_cmd_transfer(struct dsi_ctrl *dsi_ctrl,
const struct mipi_dsi_msg *msg, const struct mipi_dsi_msg *msg,
u32 flags) u32 *flags)
{ {
int rc = 0; int rc = 0;
@@ -3089,7 +3090,7 @@ int dsi_ctrl_cmd_transfer(struct dsi_ctrl *dsi_ctrl,
goto error; goto error;
} }
if (flags & DSI_CTRL_CMD_READ) { if (*flags & DSI_CTRL_CMD_READ) {
rc = dsi_message_rx(dsi_ctrl, msg, flags); rc = dsi_message_rx(dsi_ctrl, msg, flags);
if (rc <= 0) if (rc <= 0)
DSI_CTRL_ERR(dsi_ctrl, "read message failed read length, rc=%d\n", DSI_CTRL_ERR(dsi_ctrl, "read message failed read length, rc=%d\n",

View File

@@ -554,7 +554,7 @@ int dsi_ctrl_set_tpg_state(struct dsi_ctrl *dsi_ctrl, bool on);
*/ */
int dsi_ctrl_cmd_transfer(struct dsi_ctrl *dsi_ctrl, int dsi_ctrl_cmd_transfer(struct dsi_ctrl *dsi_ctrl,
const struct mipi_dsi_msg *msg, const struct mipi_dsi_msg *msg,
u32 flags); u32 *flags);
/** /**
* dsi_ctrl_cmd_tx_trigger() - Trigger a deferred command. * dsi_ctrl_cmd_tx_trigger() - Trigger a deferred command.

View File

@@ -677,7 +677,7 @@ static int dsi_display_read_status(struct dsi_display_ctrl *ctrl,
cmds[i].msg.flags |= MIPI_DSI_MSG_USE_LPM; cmds[i].msg.flags |= MIPI_DSI_MSG_USE_LPM;
cmds[i].msg.rx_buf = config->status_buf; cmds[i].msg.rx_buf = config->status_buf;
cmds[i].msg.rx_len = config->status_cmds_rlen[i]; cmds[i].msg.rx_len = config->status_cmds_rlen[i];
rc = dsi_ctrl_cmd_transfer(ctrl->ctrl, &cmds[i].msg, flags); rc = dsi_ctrl_cmd_transfer(ctrl->ctrl, &cmds[i].msg, &flags);
if (rc <= 0) { if (rc <= 0) {
DSI_ERR("rx cmd transfer failed rc=%d\n", rc); DSI_ERR("rx cmd transfer failed rc=%d\n", rc);
return rc; return rc;
@@ -2733,7 +2733,7 @@ static int dsi_display_broadcast_cmd(struct dsi_display *display,
* 2. Trigger commands * 2. Trigger commands
*/ */
m_ctrl = &display->ctrl[display->cmd_master_idx]; m_ctrl = &display->ctrl[display->cmd_master_idx];
rc = dsi_ctrl_cmd_transfer(m_ctrl->ctrl, msg, m_flags); rc = dsi_ctrl_cmd_transfer(m_ctrl->ctrl, msg, &m_flags);
if (rc) { if (rc) {
DSI_ERR("[%s] cmd transfer failed on master,rc=%d\n", DSI_ERR("[%s] cmd transfer failed on master,rc=%d\n",
display->name, rc); display->name, rc);
@@ -2745,7 +2745,7 @@ static int dsi_display_broadcast_cmd(struct dsi_display *display,
if (ctrl == m_ctrl) if (ctrl == m_ctrl)
continue; continue;
rc = dsi_ctrl_cmd_transfer(ctrl->ctrl, msg, flags); rc = dsi_ctrl_cmd_transfer(ctrl->ctrl, msg, &flags);
if (rc) { if (rc) {
DSI_ERR("[%s] cmd transfer failed, rc=%d\n", DSI_ERR("[%s] cmd transfer failed, rc=%d\n",
display->name, rc); display->name, rc);
@@ -2887,7 +2887,7 @@ static ssize_t dsi_host_transfer(struct mipi_dsi_host *host,
cmd_flags |= DSI_CTRL_CMD_ASYNC_WAIT; cmd_flags |= DSI_CTRL_CMD_ASYNC_WAIT;
rc = dsi_ctrl_cmd_transfer(display->ctrl[ctrl_idx].ctrl, msg, rc = dsi_ctrl_cmd_transfer(display->ctrl[ctrl_idx].ctrl, msg,
cmd_flags); &cmd_flags);
if (rc) { if (rc) {
DSI_ERR("[%s] cmd transfer failed, rc=%d\n", DSI_ERR("[%s] cmd transfer failed, rc=%d\n",
display->name, rc); display->name, rc);

View File

@@ -29,6 +29,13 @@
#define DSI_CMD_PPS_HDR_SIZE 7 #define DSI_CMD_PPS_HDR_SIZE 7
#define DSI_MODE_MAX 32 #define DSI_MODE_MAX 32
/*
* Defining custom dsi msg flag,
* continued from drm_mipi_dsi.h
* Override to use async transfer
*/
#define MIPI_DSI_MSG_ASYNC_OVERRIDE BIT(4)
enum dsi_panel_rotation { enum dsi_panel_rotation {
DSI_PANEL_ROTATE_NONE = 0, DSI_PANEL_ROTATE_NONE = 0,
DSI_PANEL_ROTATE_HV_FLIP, DSI_PANEL_ROTATE_HV_FLIP,