From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrzej Hajda Subject: Re: [PATCH 03/15] drm/dsi: Add mipi_dsi_set_maximum_return_packet_size() helper Date: Mon, 13 Oct 2014 16:10:31 +0200 Message-ID: <543BDD57.9090407@samsung.com> References: <1413195395-3355-1-git-send-email-thierry.reding@gmail.com> <1413195395-3355-3-git-send-email-thierry.reding@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by gabe.freedesktop.org (Postfix) with ESMTP id 156F189DA5 for ; Mon, 13 Oct 2014 07:10:36 -0700 (PDT) Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NDD001WKZIFFM20@mailout1.w1.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 13 Oct 2014 15:13:27 +0100 (BST) In-reply-to: <1413195395-3355-3-git-send-email-thierry.reding@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Thierry Reding , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On 10/13/2014 12:16 PM, Thierry Reding wrote: > From: YoungJun Cho > > This function can be used to set the maximum return packet size for a > MIPI DSI peripheral. > > Signed-off-by: YoungJun Cho > [treding: endianess, kerneldoc, return value] > Signed-off-by: Thierry Reding > --- > drivers/gpu/drm/drm_mipi_dsi.c | 30 ++++++++++++++++++++++++++++++ > include/drm/drm_mipi_dsi.h | 2 ++ > 2 files changed, 32 insertions(+) > > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c > index 1702ffd07986..27fc6dac5e4a 100644 > --- a/drivers/gpu/drm/drm_mipi_dsi.c > +++ b/drivers/gpu/drm/drm_mipi_dsi.c > @@ -198,6 +198,36 @@ int mipi_dsi_detach(struct mipi_dsi_device *dsi) > } > EXPORT_SYMBOL(mipi_dsi_detach); > > +/* > + * mipi_dsi_set_maximum_return_packet_size() - specify the maximum size of the > + * the payload in a long packet transmitted from the peripheral back to the > + * host processor > + * @dsi: DSI peripheral device > + * @value: the maximum size of the payload > + * > + * Return: 0 on success or a negative error code on failure. > + */ > +int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi, > + u16 value) > +{ > + u8 tx[2] = { value & 0xff, value >> 8 }; > + struct mipi_dsi_msg msg; > + ssize_t err; > + > + memset(&msg, 0, sizeof(msg)); > + msg.channel = dsi->channel; > + msg.type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE; > + msg.tx_len = sizeof(tx); > + msg.tx_buf = tx; An alternative (without tx variable) could be: __cpu_to_le16s(&value); msg.tx_len = sizeof(value); msg.tx_buf = &value; But it is just pico-optimization. > + > + err = dsi->host->ops->transfer(dsi->host, &msg); I guess the sequence: if (dsi->mode_flags & MIPI_DSI_MODE_LPM) msg.flags = MIPI_DSI_MSG_USE_LPM; should be before this callback. The same should be in all other helpers calling ops->transfer, so I guess it may be good to move it all to separate function, for example sth like: ... dsi_transfer(dsi, msg) { if (!ops || !ops->transfer) return -NOSYS; if (dsi->mode_flags & MIPI_DSI_MODE_LPM) msg.flags = MIPI_DSI_MSG_USE_LPM; return ops->transfer(dsi->host, msg); } Regards Andrzej > + if (err < 0) > + return err; > + > + return 0; > +} > +EXPORT_SYMBOL(mipi_dsi_set_maximum_return_packet_size); > + > /** > * mipi_dsi_dcs_write_buffer() - transmit a DCS command with payload > * @dsi: DSI peripheral device > diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h > index 836cc2b677d0..ef50b5d0de57 100644 > --- a/include/drm/drm_mipi_dsi.h > +++ b/include/drm/drm_mipi_dsi.h > @@ -132,6 +132,8 @@ static inline struct mipi_dsi_device *to_mipi_dsi_device(struct device *dev) > > int mipi_dsi_attach(struct mipi_dsi_device *dsi); > int mipi_dsi_detach(struct mipi_dsi_device *dsi); > +int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi, > + u16 value); > ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi, > const void *data, size_t len); > ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd, >