drm/omap: dsi: avoid sending bta sync all the time in writes
Subsystems (3)
PATCH v5 1/1 drm/omap: dsi: avoid sending bta sync all the time in writes
Some chips need configuration commands to be sent first, before they can send data. TC358762 for example needs PPI_LPTXTIMECNT configured and PPI_STARTPPI set to 1 to be able to transmit anything. To be able to configure such chips, do not send bta sync during writes if no acks are requested. Instead just wait for the packet to be sent to avoid FIFO overflows. There might be more to do about acks, but there seem to be virtually no users of that flag.
This came to light when fiddling with the Epson Moverio BT-200 display which consists of 2 TC358762 bridges with SPI funneled through to the unknown display chip. With that patch the bridge can be accessed, Reading back registers works, when the above-mentioned registers are set.
In Command-Mode update, there was a nop sent, apparently the most relevant part was the bta sync to actually force low power mode.
Video mode panel at OMAP4 (BT-200) and video mode at OMAP5 was tested.
---
Changes in v5:
- send bta sync on VC_CMD again
Changes in v4:
- wait on completition on all packets (was limited to long packets only, because I had the wrong impression that there is no confirmation on these)
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- Link to v2: https://patch.msgid.link/[email protected]
- fix things mentioned by claude here:
https://lore.gitlab.freedesktop.org/drm-ai-reviews/[email protected]/
- fix typos
- register ISR before sending packet
- check for RX_FIFO_NOT_EMPTY also in for short packets
Changes in v2:
- fix commandmode update, need bta sync there
- do not wait on short packets
- Link to v1: https://patch.msgid.link/[email protected]
--- drivers/gpu/drm/omapdrm/dss/dsi.c | 53 ++++++++++++++----------------- 1 file changed, 24 insertions(+), 29 deletions(-)
drivers/gpu/drm/omapdrm/dss/dsi.c +24 -29
@@ -2194,28 +2194,38 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel)static int dsi_vc_write_common (struct omap_dss_device *dssdev,int vc,const struct mipi_dsi_msg *msg) { +DECLARE_COMPLETION_ONSTACK (completion);struct dsi_data *dsi =to_dsi_data (dssdev);int r; +/* wait for IRQ for packet transmission confirmation */ + r =dsi_register_isr_vc (dsi, vc, dsi_completion_handler, + &completion,DSI_VC_IRQ_PACKET_SENT ); +if (r) +return r; +if (mipi_dsi_packet_format_is_short (msg->type)) r =dsi_vc_send_short (dsi, vc, msg);else r =dsi_vc_send_long (dsi, vc, msg); -if (r <0 ) +if ((!r) &&wait_for_completion_timeout (&completion, +msecs_to_jiffies (500 )) ==0 ) + r = -EIO ; + +dsi_unregister_isr_vc (dsi, vc, dsi_completion_handler, + &completion,DSI_VC_IRQ_PACKET_SENT ); +if (r)return r; -/* -* TODO: we do not always have to do the BTA sync, for example -* we can improve performance by setting the update window -* information without sending BTA sync between the commands. -* In that case we can return early. -*/ +/* TODO: find out if more needs to be done for MIPI_DSI_MSG_REQ_ACK */ - r =dsi_vc_send_bta_sync (dssdev, vc); -if (r) { -DSSERR ("bta sync failed\n" ); -return r; +if (msg->flags &MIPI_DSI_MSG_REQ_ACK ) { + r =dsi_vc_send_bta_sync (dssdev, vc); +if (r) { +DSSERR ("bta sync failed\n" ); +return r; + } }/* RX_FIFO_NOT_EMPTY */
@@ -3233,21 +3243,6 @@ static int _dsi_update(struct dsi_data *dsi)return 0 ; } -static int _dsi_send_nop (struct dsi_data *dsi,int vc,int channel) -{ -const u8 payload[] = {MIPI_DCS_NOP }; -const struct mipi_dsi_msg msg = { - .channel = channel, - .type =MIPI_DSI_DCS_SHORT_WRITE , - .tx_len =1 , - .tx_buf = payload, - }; - -WARN_ON (!dsi_bus_is_locked (dsi)); - -return _omap_dsi_host_transfer (dsi, vc, &msg); -} -static int dsi_update_channel (struct omap_dss_device *dssdev,int vc) {struct dsi_data *dsi =to_dsi_data (dssdev);
@@ -3268,13 +3263,13 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)DSSDBG ("dsi_update_channel: %d" , vc);/* -* Send NOP between the frames. If we don't send something here, the +* Transition to LP here. If we don't send something here, the * updates stop working. This is probably related to DSI spec stating * that the DSI host should transition to LP at least once per frame. */ - r =_dsi_send_nop (dsi,VC_CMD , dsi->dsidev->channel); + r =dsi_vc_send_bta_sync (dssdev,VC_CMD );if (r <0 ) { -DSSWARN ("failed to send nop between frames: %d\n" , r); +DSSWARN ("failed to send bta sync between frames: %d\n" , r); goto err; }
Signature · 1 line
2.47.3
Tomi Valkeinen
maintainerHi,
Quoted 89 lines · Andreas Kemnade
Some chips need configuration commands to be sent first, before they can send data. TC358762 for example needs
PPI_LPTXTIMECNTconfigured andPPI_STARTPPIset to 1 to be able to transmit anything. To be able to configure such chips, do not send bta sync during writes if no acks are requested. Instead just wait for the packet to be sent to avoid FIFO overflows. There might be more to do about acks, but there seem to be virtually no users of that flag.This came to light when fiddling with the Epson Moverio BT-200 display which consists of 2 TC358762 bridges with SPI funneled through to the unknown display chip. With that patch the bridge can be accessed, Reading back registers works, when the above-mentioned registers are set.
In Command-Mode update, there was a nop sent, apparently the most relevant part was the bta sync to actually force low power mode.
Video mode panel at OMAP4 (BT-200) and video mode at OMAP5 was tested.
Fixes e70965386353e ("drm/omap: dsi: simplify write function")Signed-off-by Andreas Kemnade <[email protected]>---
Changes in v5:
- send bta sync onVC_CMDagainChanges in v4:
- wait on completition on all packets (was limited to long packets only, because I had the wrong impression that there is no confirmation on these)
- Link to v3: https://patch.msgid.link/[email protected]Changes in v3:
- Link to v2: https://patch.msgid.link/[email protected]
- fix things mentioned by claude here:
https://lore.gitlab.freedesktop.org/drm-ai-reviews/[email protected]/
- fix typos
- register ISR before sending packet
- check forRX_FIFO_NOT_EMPTYalso in for short packetsChanges in v2:
- fix commandmode update, need bta sync there
- do not wait on short packets
- Link to v1: https://patch.msgid.link/[email protected]--- drivers/gpu/drm/omapdrm/dss/dsi.c | 53 ++++++++++++++----------------- 1 file changed, 24 insertions(+), 29 deletions(-)drivers/gpu/drm/omapdrm/dss/dsi.c +15
-8@@ -2194,28 +2194,38 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel)static int dsi_vc_write_common (struct omap_dss_device *dssdev,int vc,const struct mipi_dsi_msg *msg) { +DECLARE_COMPLETION_ONSTACK (completion);struct dsi_data *dsi =to_dsi_data (dssdev);int r; +/* wait for IRQ for packet transmission confirmation */ + r =dsi_register_isr_vc (dsi, vc, dsi_completion_handler, + &completion,DSI_VC_IRQ_PACKET_SENT ); +if (r) +return r; +if (mipi_dsi_packet_format_is_short (msg->type)) r =dsi_vc_send_short (dsi, vc, msg);else r =dsi_vc_send_long (dsi, vc, msg); -if (r <0 ) +if ((!r) &&wait_for_completion_timeout (&completion, +msecs_to_jiffies (500 )) ==0 ) + r = -EIO ; + +dsi_unregister_isr_vc (dsi, vc, dsi_completion_handler, + &completion,DSI_VC_IRQ_PACKET_SENT ); +if (r)return r; -/* -* TODO: we do not always have to do the BTA sync, for example -* we can improve performance by setting the update window -* information without sending BTA sync between the commands. -* In that case we can return early. -*/ +/* TODO: find out if more needs to be done for MIPI_DSI_MSG_REQ_ACK */ - r =dsi_vc_send_bta_sync (dssdev, vc);
drivers/gpu/drm/omapdrm/dss/dsi.c static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel) · line 2229
Quoted 10 lines
drivers/gpu/drm/omapdrm/dss/dsi.c +6
-3-if (r) { -DSSERR ("bta sync failed\n" ); -return r; +if (msg->flags &MIPI_DSI_MSG_REQ_ACK ) { + r =dsi_vc_send_bta_sync (dssdev, vc); +if (r) { +DSSERR ("bta sync failed\n" ); +return r; + } }
The dsi_vc_send_bta_sync() function does dsi_get_errors(), which we now don't always do here. I think that might cause any errors to be left there, which would trigger error handling on next read or write-with-bta.
_omap_dsi_host_transfer forward declaration can now be remove.
I don't have HW to test this, but other than the above, it looks reasonable. Although I have to say, based on my past experience, it's also very easy to break a use case =).
Tomi
Quoted 23 lines · Tomi Valkeinen
Quoted 8 lines
drivers/gpu/drm/omapdrm/dss/dsi.c +1
-7-/* -* TODO: we do not always have to do the BTA sync, for example -* we can improve performance by setting the update window -* information without sending BTA sync between the commands. -* In that case we can return early. -*/ +/* TODO: find out if more needs to be done for MIPI_DSI_MSG_REQ_ACK */ - r =dsi_vc_send_bta_sync (dssdev, vc);drivers/gpu/drm/omapdrm/dss/dsi.c static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel) · line 2229
Quoted 10 lines
drivers/gpu/drm/omapdrm/dss/dsi.c +6
-3-if (r) { -DSSERR ("bta sync failed\n" ); -return r; +if (msg->flags &MIPI_DSI_MSG_REQ_ACK ) { + r =dsi_vc_send_bta_sync (dssdev, vc); +if (r) { +DSSERR ("bta sync failed\n" ); +return r; + } }The
dsi_vc_send_bta_sync()function doesdsi_get_errors(), which we now don't always do here. I think that might cause any errors to be left there, which would trigger error handling on next read or write-with-bta.
Quoted 1 line
_omap_dsi_host_transferforward declaration can now be remove.
I will produce a v6, when I have the possibility to test again, probably on Monday.
Quoted 5 lines
I don't have HW to test this, but other than the above, it looks reasonable. Although I have to say, based on my past experience, it's also very easy to break a use case =).
Probably these usecases should use MIPI_DSI_MSG_REQ_ACK.
Regards,
Andreas