diff options
| author | Xiaoming Zhou <zhoux@codeaurora.org> | 2013-11-18 18:08:29 -0500 |
|---|---|---|
| committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-23 20:23:52 -0700 |
| commit | a88ea517865708eff94615e2926ae66cd2520beb (patch) | |
| tree | b0e2b204dcb0e30b2cad581657d792e9a2350d5d | |
| parent | c99508ee32b4b0077d8be9df1c594d0309c7f52d (diff) | |
msm: mdss: use the dsi panel API for sending init commands
The dsi panel driver implements the dsi command send
and receive functions. However, on 8x10, it was using
its own version. This change is to use the functions
defined in the panel driver.
Change-Id: I4dcec67fecb51f02b65ee7818ccbe7729f3e6831
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
| -rw-r--r-- | drivers/video/fbdev/msm/dsi_host_v2.c | 106 | ||||
| -rw-r--r-- | drivers/video/fbdev/msm/dsi_v2.c | 51 | ||||
| -rw-r--r-- | drivers/video/fbdev/msm/dsi_v2.h | 13 |
3 files changed, 81 insertions, 89 deletions
diff --git a/drivers/video/fbdev/msm/dsi_host_v2.c b/drivers/video/fbdev/msm/dsi_host_v2.c index b87e736b6ba7..191b87c15136 100644 --- a/drivers/video/fbdev/msm/dsi_host_v2.c +++ b/drivers/video/fbdev/msm/dsi_host_v2.c @@ -432,24 +432,6 @@ void msm_dsi_op_mode_config(int mode, struct mdss_panel_data *pdata) wmb(); } -int msm_dsi_cmd_reg_tx(u32 data) -{ - unsigned char *ctrl_base = dsi_host_private->dsi_base; - - MIPI_OUTP(ctrl_base + DSI_TRIG_CTRL, 0x04);/* sw trigger */ - MIPI_OUTP(ctrl_base + DSI_CTRL, 0x135); - wmb(); - - MIPI_OUTP(ctrl_base + DSI_COMMAND_MODE_DMA_CTRL, data); - wmb(); - MIPI_OUTP(ctrl_base + DSI_CMD_MODE_DMA_SW_TRIGGER, 0x01); - wmb(); - - udelay(300); /*per spec*/ - - return 0; -} - int msm_dsi_cmd_dma_tx(struct dsi_buf *tp) { int len, rc; @@ -521,11 +503,12 @@ int msm_dsi_cmd_dma_rx(struct dsi_buf *rp, int rlen) return 0; } -int msm_dsi_cmds_tx(struct mdss_panel_data *pdata, - struct dsi_buf *tp, struct dsi_cmd_desc *cmds, int cnt) +int msm_dsi_cmds_tx(struct mdss_dsi_ctrl_pdata *ctrl, + struct dsi_cmd_desc *cmds, int cnt) { + struct dsi_buf *tp; struct dsi_cmd_desc *cm; - u32 dsi_ctrl, ctrl; + u32 dsi_ctrl, data; int i, video_mode, rc = 0; unsigned char *ctrl_base = dsi_host_private->dsi_base; @@ -537,12 +520,13 @@ int msm_dsi_cmds_tx(struct mdss_panel_data *pdata, dsi_ctrl = MIPI_INP(ctrl_base + DSI_CTRL); video_mode = dsi_ctrl & 0x02; /* VIDEO_MODE_EN */ if (video_mode) { - ctrl = dsi_ctrl | 0x04; /* CMD_MODE_EN */ - MIPI_OUTP(ctrl_base + DSI_CTRL, ctrl); + data = dsi_ctrl | 0x04; /* CMD_MODE_EN */ + MIPI_OUTP(ctrl_base + DSI_CTRL, data); } msm_dsi_enable_irq(); + tp = &ctrl->tx_buf; cm = cmds; for (i = 0; i < cnt; i++) { mdss_dsi_buf_init(tp); @@ -589,15 +573,16 @@ static struct dsi_cmd_desc pkt_size_cmd[] = { * * ov_mutex need to be acquired before call this function. */ -int msm_dsi_cmds_rx(struct mdss_panel_data *pdata, - struct dsi_buf *tp, struct dsi_buf *rp, +int msm_dsi_cmds_rx(struct mdss_dsi_ctrl_pdata *ctrl, struct dsi_cmd_desc *cmds, int rlen) { + struct dsi_buf *tp, *rp; int cnt, len, diff, pkt_size, rc = 0; char cmd; unsigned char *ctrl_base = dsi_host_private->dsi_base; u32 dsi_ctrl, data; int video_mode; + struct mdss_panel_data *pdata = &ctrl->panel_data; /* turn on cmd mode for video mode */ dsi_ctrl = MIPI_INP(ctrl_base + DSI_CTRL); @@ -634,6 +619,9 @@ int msm_dsi_cmds_rx(struct mdss_panel_data *pdata, msm_dsi_enable_irq(); + tp = &ctrl->tx_buf; + rp = &ctrl->rx_buf; + if (!pdata->panel_info.mipi.no_max_pkt_size) { /* packet size need to be set at every read */ pkt_size = len; @@ -731,6 +719,54 @@ msm_dsi_cmds_rx_err: return rp->len; } +void msm_dsi_cmdlist_tx(struct mdss_dsi_ctrl_pdata *ctrl, + struct dcs_cmd_req *req) +{ + int ret; + + ret = msm_dsi_cmds_tx(ctrl, req->cmds, req->cmds_cnt); + + if (req->cb) + req->cb(ret); +} + +void msm_dsi_cmdlist_rx(struct mdss_dsi_ctrl_pdata *ctrl, + struct dcs_cmd_req *req) +{ + struct dsi_buf *rp; + int len = 0; + + if (req->rbuf) { + rp = &ctrl->rx_buf; + len = msm_dsi_cmds_rx(ctrl, req->cmds, req->rlen); + memcpy(req->rbuf, rp->data, rp->len); + } else { + pr_err("%s: No rx buffer provided\n", __func__); + } + + if (req->cb) + req->cb(len); +} +void msm_dsi_cmdlist_commit(struct mdss_dsi_ctrl_pdata *ctrl, int from_mdp) +{ + struct dcs_cmd_req *req; + + mutex_lock(&ctrl->cmd_mutex); + req = mdss_dsi_cmdlist_get(ctrl); + + if (!req) { + mutex_unlock(&ctrl->cmd_mutex); + return; + } + + if (req->flags & CMD_REQ_RX) + msm_dsi_cmdlist_rx(ctrl, req); + else + msm_dsi_cmdlist_tx(ctrl, req); + + mutex_unlock(&ctrl->cmd_mutex); +} + static int msm_dsi_cal_clk_rate(struct mdss_panel_data *pdata, u32 *bitclk_rate, u32 *dsiclk_rate, @@ -1106,6 +1142,22 @@ static int msm_dsi_clk_ctrl(struct mdss_panel_data *pdata, int enable) return 0; } +void msm_dsi_ctrl_init(struct mdss_dsi_ctrl_pdata *ctrl) +{ + init_completion(&ctrl->dma_comp); + init_completion(&ctrl->mdp_comp); + init_completion(&ctrl->video_comp); + spin_lock_init(&ctrl->irq_lock); + spin_lock_init(&ctrl->mdp_lock); + mutex_init(&ctrl->mutex); + mutex_init(&ctrl->cmd_mutex); + complete(&ctrl->mdp_comp); + dsi_buf_alloc(&ctrl->tx_buf, SZ_4K); + dsi_buf_alloc(&ctrl->rx_buf, SZ_4K); + ctrl->cmdlist_commit = msm_dsi_cmdlist_commit; + ctrl->panel_mode = ctrl->panel_data.panel_info.mipi.mode; +} + static int msm_dsi_probe(struct platform_device *pdev) { struct dsi_interface intf; @@ -1226,14 +1278,14 @@ static int msm_dsi_probe(struct platform_device *pdev) intf.cont_on = msm_dsi_cont_on; intf.clk_ctrl = msm_dsi_clk_ctrl; intf.op_mode_config = msm_dsi_op_mode_config; - intf.tx = msm_dsi_cmds_tx; - intf.rx = msm_dsi_cmds_rx; intf.index = 0; intf.private = NULL; dsi_register_interface(&intf); msm_dsi_debug_init(); + msm_dsi_ctrl_init(ctrl_pdata); + rc = dsi_panel_device_register_v2(pdev, ctrl_pdata); if (rc) { pr_err("%s: dsi panel dev reg failed\n", __func__); diff --git a/drivers/video/fbdev/msm/dsi_v2.c b/drivers/video/fbdev/msm/dsi_v2.c index c4a8a7a35978..3967568dec1b 100644 --- a/drivers/video/fbdev/msm/dsi_v2.c +++ b/drivers/video/fbdev/msm/dsi_v2.c @@ -21,7 +21,6 @@ #include "dsi_v2.h" static struct dsi_interface dsi_intf; -static struct dsi_buf dsi_panel_tx_buf; static int dsi_off(struct mdss_panel_data *pdata) { @@ -67,21 +66,13 @@ static int dsi_panel_handler(struct mdss_panel_data *pdata, int enable) if (enable) { dsi_ctrl_gpio_request(ctrl_pdata); mdss_dsi_panel_reset(pdata, 1); - - rc = dsi_cmds_tx_v2(pdata, &dsi_panel_tx_buf, - ctrl_pdata->on_cmds.cmds, - ctrl_pdata->on_cmds.cmd_cnt); - + rc = ctrl_pdata->on(pdata); if (rc) pr_err("dsi_panel_handler panel on failed %d\n", rc); } else { if (dsi_intf.op_mode_config) dsi_intf.op_mode_config(DSI_CMD_MODE, pdata); - - dsi_cmds_tx_v2(pdata, &dsi_panel_tx_buf, - ctrl_pdata->off_cmds.cmds, - ctrl_pdata->off_cmds.cmd_cnt); - + rc = ctrl_pdata->off(pdata); mdss_dsi_panel_reset(pdata, 0); dsi_ctrl_gpio_free(ctrl_pdata); } @@ -593,19 +584,12 @@ int dsi_panel_device_register_v2(struct platform_device *dev, ctrl_pdata->panel_data.event_handler = dsi_event_handler; - rc = dsi_buf_alloc(&dsi_panel_tx_buf, - ALIGN(DSI_BUF_SIZE, - SZ_4K)); - if (rc) - return rc; - /* * register in mdp driver */ rc = mdss_register_panel(dev, &(ctrl_pdata->panel_data)); if (rc) { dev_err(&dev->dev, "unable to register MIPI DSI panel\n"); - kfree(dsi_panel_tx_buf.start); return rc; } @@ -618,37 +602,6 @@ void dsi_register_interface(struct dsi_interface *intf) dsi_intf = *intf; } -int dsi_cmds_tx_v2(struct mdss_panel_data *pdata, - struct dsi_buf *tp, struct dsi_cmd_desc *cmds, - int cnt) -{ - int rc = 0; - - if (!dsi_intf.tx) - return -EINVAL; - - rc = dsi_intf.tx(pdata, tp, cmds, cnt); - return rc; -} - -int dsi_cmds_rx_v2(struct mdss_panel_data *pdata, - struct dsi_buf *tp, struct dsi_buf *rp, - struct dsi_cmd_desc *cmds, int rlen) -{ - int rc = 0; - - if (pdata == NULL) { - pr_err("%s: Invalid input data\n", __func__); - return -EINVAL; - } - - if (!dsi_intf.rx) - return -EINVAL; - - rc = dsi_intf.rx(pdata, tp, rp, cmds, rlen); - return rc; -} - int dsi_buf_alloc(struct dsi_buf *dp, int size) { dp->start = kmalloc(size, GFP_KERNEL); diff --git a/drivers/video/fbdev/msm/dsi_v2.h b/drivers/video/fbdev/msm/dsi_v2.h index 36239a8d1091..b8c91da57576 100644 --- a/drivers/video/fbdev/msm/dsi_v2.h +++ b/drivers/video/fbdev/msm/dsi_v2.h @@ -29,11 +29,6 @@ struct dsi_interface { int (*cont_on)(struct mdss_panel_data *pdata); int (*clk_ctrl)(struct mdss_panel_data *pdata, int enable); void (*op_mode_config)(int mode, struct mdss_panel_data *pdata); - int (*tx)(struct mdss_panel_data *pdata, - struct dsi_buf *tp, struct dsi_cmd_desc *cmds, int cnt); - int (*rx)(struct mdss_panel_data *pdata, - struct dsi_buf *tp, struct dsi_buf *rp, - struct dsi_cmd_desc *cmds, int len); int index; void *private; }; @@ -43,14 +38,6 @@ int dsi_panel_device_register_v2(struct platform_device *pdev, void dsi_register_interface(struct dsi_interface *intf); -int dsi_cmds_rx_v2(struct mdss_panel_data *pdata, - struct dsi_buf *tp, struct dsi_buf *rp, - struct dsi_cmd_desc *cmds, int len); - -int dsi_cmds_tx_v2(struct mdss_panel_data *pdata, - struct dsi_buf *tp, struct dsi_cmd_desc *cmds, - int cnt); - int dsi_buf_alloc(struct dsi_buf *dp, int size); void dsi_set_tx_power_mode(int mode); |
