Commit fc3413a9 authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Tomi Valkeinen

drm/omap: panel-dsi-cm: convert to transfer API

This converts the panel-dsi-cm driver to use the transfer
API instead of specific functions, so that the specific
functions can be unexported and squashed into the generic
transfer function.
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201215104657.802264-7-tomi.valkeinen@ti.com
parent 9e8d3b92
...@@ -140,45 +140,61 @@ static void hw_guard_wait(struct panel_drv_data *ddata) ...@@ -140,45 +140,61 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data) static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
{ {
struct omap_dss_device *src = ddata->src; struct omap_dss_device *src = ddata->src;
int r; const struct mipi_dsi_msg msg = {
u8 buf[1]; .channel = ddata->channel,
.type = MIPI_DSI_DCS_READ,
r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd, buf, 1); .tx_len = 1,
.tx_buf = &dcs_cmd,
if (r < 0) .rx_len = 1,
return r; .rx_buf = data
};
*data = buf[0];
return 0; return src->ops->dsi.transfer(src, &msg);
} }
static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd) static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
{ {
struct omap_dss_device *src = ddata->src; struct omap_dss_device *src = ddata->src;
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
.type = MIPI_DSI_DCS_SHORT_WRITE,
.tx_buf = &dcs_cmd,
.tx_len = 1,
};
return src->ops->dsi.dcs_write(src, ddata->channel, &dcs_cmd, 1); return src->ops->dsi.transfer(src, &msg);
} }
static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param) static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param)
{ {
struct omap_dss_device *src = ddata->src; struct omap_dss_device *src = ddata->src;
u8 buf[2] = { dcs_cmd, param }; const u8 buf[] = { dcs_cmd, param };
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
.type = MIPI_DSI_DCS_SHORT_WRITE_PARAM,
.tx_buf = &buf,
.tx_len = 2,
};
return src->ops->dsi.dcs_write(src, ddata->channel, buf, 2); return src->ops->dsi.transfer(src, &msg);
} }
static int dsicm_sleep_in(struct panel_drv_data *ddata) static int dsicm_sleep_in(struct panel_drv_data *ddata)
{ {
struct omap_dss_device *src = ddata->src; struct omap_dss_device *src = ddata->src;
u8 cmd;
int r; int r;
const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
.type = MIPI_DSI_DCS_SHORT_WRITE,
.tx_buf = &cmd,
.tx_len = 1,
};
hw_guard_wait(ddata); hw_guard_wait(ddata);
cmd = MIPI_DCS_ENTER_SLEEP_MODE; r = src->ops->dsi.transfer(src, &msg);
r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, &cmd, 1);
if (r) if (r)
return r; return r;
...@@ -233,28 +249,43 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata, ...@@ -233,28 +249,43 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata,
u16 y1 = y; u16 y1 = y;
u16 y2 = y + h - 1; u16 y2 = y + h - 1;
u8 buf[5]; const u8 paramX[] = {
buf[0] = MIPI_DCS_SET_COLUMN_ADDRESS; MIPI_DCS_SET_COLUMN_ADDRESS,
buf[1] = (x1 >> 8) & 0xff; (x1 >> 8) & 0xff,
buf[2] = (x1 >> 0) & 0xff; (x1 >> 0) & 0xff,
buf[3] = (x2 >> 8) & 0xff; (x2 >> 8) & 0xff,
buf[4] = (x2 >> 0) & 0xff; (x2 >> 0) & 0xff,
};
r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf)); const struct mipi_dsi_msg msgX = {
if (r) .channel = ddata->channel,
return r; .type = MIPI_DSI_GENERIC_LONG_WRITE,
.tx_buf = paramX,
.tx_len = 5,
};
const u8 paramY[] = {
MIPI_DCS_SET_PAGE_ADDRESS,
(y1 >> 8) & 0xff,
(y1 >> 0) & 0xff,
(y2 >> 8) & 0xff,
(y2 >> 0) & 0xff,
};
buf[0] = MIPI_DCS_SET_PAGE_ADDRESS; const struct mipi_dsi_msg msgY = {
buf[1] = (y1 >> 8) & 0xff; .channel = ddata->channel,
buf[2] = (y1 >> 0) & 0xff; .type = MIPI_DSI_GENERIC_LONG_WRITE,
buf[3] = (y2 >> 8) & 0xff; .tx_buf = paramY,
buf[4] = (y2 >> 0) & 0xff; .tx_len = 5,
};
r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf)); r = src->ops->dsi.transfer(src, &msgX);
if (r) if (r)
return r; return r;
src->ops->dsi.bta_sync(src, ddata->channel); r = src->ops->dsi.transfer(src, &msgY);
if (r)
return r;
return r; return r;
} }
...@@ -991,6 +1022,27 @@ static int dsicm_get_te(struct omap_dss_device *dssdev) ...@@ -991,6 +1022,27 @@ static int dsicm_get_te(struct omap_dss_device *dssdev)
return r; return r;
} }
static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev,
u16 size)
{
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *src = ddata->src;
const u8 buf[] = {
size & 0xff,
size >> 8 & 0xff,
};
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
.type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE,
.tx_buf = buf,
.tx_len = 2,
};
return src->ops->dsi.transfer(src, &msg);
}
static int dsicm_memory_read(struct omap_dss_device *dssdev, static int dsicm_memory_read(struct omap_dss_device *dssdev,
void *buf, size_t size, void *buf, size_t size,
u16 x, u16 y, u16 w, u16 h) u16 x, u16 y, u16 w, u16 h)
...@@ -1031,17 +1083,23 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev, ...@@ -1031,17 +1083,23 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
dsicm_set_update_window(ddata, x, y, w, h); dsicm_set_update_window(ddata, x, y, w, h);
r = src->ops->dsi.set_max_rx_packet_size(src, ddata->channel, plen); r = dsicm_set_max_rx_packet_size(dssdev, plen);
if (r) if (r)
goto err2; goto err2;
while (buf_used < size) { while (buf_used < size) {
u8 dcs_cmd = first ? 0x2e : 0x3e; u8 dcs_cmd = first ? 0x2e : 0x3e;
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
.type = MIPI_DSI_DCS_READ,
.tx_buf = &dcs_cmd,
.tx_len = 1,
.rx_buf = buf + buf_used,
.rx_len = size - buf_used,
};
first = 0; first = 0;
r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd, r = src->ops->dsi.transfer(src, &msg);
buf + buf_used, size - buf_used);
if (r < 0) { if (r < 0) {
dev_err(dssdev->dev, "read error\n"); dev_err(dssdev->dev, "read error\n");
goto err3; goto err3;
...@@ -1065,7 +1123,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev, ...@@ -1065,7 +1123,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
r = buf_used; r = buf_used;
err3: err3:
src->ops->dsi.set_max_rx_packet_size(src, ddata->channel, 1); dsicm_set_max_rx_packet_size(dssdev, 1);
err2: err2:
src->ops->dsi.bus_unlock(src); src->ops->dsi.bus_unlock(src);
err1: err1:
......
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