From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: Re: [PATCH 03/15] drm/dsi: Add mipi_dsi_set_maximum_return_packet_size() helper Date: Tue, 14 Oct 2014 11:05:40 +0200 Message-ID: <20141014090539.GB18993@ulmo> References: <1413195395-3355-1-git-send-email-thierry.reding@gmail.com> <1413195395-3355-3-git-send-email-thierry.reding@gmail.com> <543BDD57.9090407@samsung.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1009896201==" Return-path: Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by gabe.freedesktop.org (Postfix) with ESMTP id CE73989BF3 for ; Tue, 14 Oct 2014 02:05:42 -0700 (PDT) Received: by mail-wi0-f180.google.com with SMTP id em10so9528772wid.13 for ; Tue, 14 Oct 2014 02:05:42 -0700 (PDT) In-Reply-To: <543BDD57.9090407@samsung.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Andrzej Hajda Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1009896201== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="24zk1gE8NUlDmwG9" Content-Disposition: inline --24zk1gE8NUlDmwG9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Oct 13, 2014 at 04:10:31PM +0200, Andrzej Hajda wrote: > On 10/13/2014 12:16 PM, Thierry Reding wrote: > > From: YoungJun Cho > >=20 > > This function can be used to set the maximum return packet size for a > > MIPI DSI peripheral. > >=20 > > 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(+) > >=20 > > 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); > > =20 > > +/* > > + * mipi_dsi_set_maximum_return_packet_size() - specify the maximum siz= e of the > > + * the payload in a long packet transmitted from the peripheral bac= k 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 *ds= i, > > + u16 value) > > +{ > > + u8 tx[2] =3D { value & 0xff, value >> 8 }; > > + struct mipi_dsi_msg msg; > > + ssize_t err; > > + > > + memset(&msg, 0, sizeof(msg)); > > + msg.channel =3D dsi->channel; > > + msg.type =3D MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE; > > + msg.tx_len =3D sizeof(tx); > > + msg.tx_buf =3D tx; >=20 >=20 > An alternative (without tx variable) could be: >=20 > __cpu_to_le16s(&value); > msg.tx_len =3D sizeof(value); > msg.tx_buf =3D &value; >=20 > But it is just pico-optimization. >=20 >=20 > > + > > + err =3D dsi->host->ops->transfer(dsi->host, &msg); >=20 > I guess the sequence: > if (dsi->mode_flags & MIPI_DSI_MODE_LPM) > msg.flags =3D MIPI_DSI_MSG_USE_LPM; >=20 > should be before this callback. >=20 > 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; >=20 > if (dsi->mode_flags & MIPI_DSI_MODE_LPM) > msg.flags =3D MIPI_DSI_MSG_USE_LPM; >=20 >=20 > return ops->transfer(dsi->host, msg); > } Good idea. It'd be slightly better if we could check for valid ops earlier, but I don't think it's really worth it. I'll add a helper that performs these common checks and rebase the other patches on top of it. Thierry --24zk1gE8NUlDmwG9 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJUPOdjAAoJEN0jrNd/PrOh6GYP/RN854E2fG3VwkFz3H+W6kZe YDMBaEAMUQXHsh0kcdWM4FVHoyGFvDoeFRpDUkxiXcRLSYZ4EZrLwQXUBGrCcdqn 25lqFmbVtoo+BBqv90wEdLYDHo0NyVwp8tiby6oGiHe8ba2ogrsNAdrbERxZLgho K7VPPpYenTpKQLLLu4At9QBtX3kKwtbRs63yxQPYhnG+6BVAZuxlgVO5D1CoK0r/ 2PgJoIHpKphasarPxhFsWEDct/zofB3m5dqOXZeHfzvad/SWHSiM5nQAt6Gjgixs 3ixddkMWN/oIJwuDEsZePhj+awlx9p1BJX9ll1dpUKQWPGYbwp/kBTvIcUa1A45f ST3ZaoH4T6fncviSmGIqeXKbRQTVrva1n/f4vx9y0e+GpP+l5yPYIguRakYdsVYV 97rhf4HbQqAsk2OGEhQEL2JlJYv3PzONdXAQv+ZXNw/pf0OP9aFcQvCV9hnskQk9 68eOzg1KAatG8g++HhuqGCCPQdEAc7lP4U+Xn2A8U2e7NIpFJLdMLb5xCtxJhV2c HpnRHoyucGYl56OdKihj8kLvMzcwULEkL94b+dbaprnJAJR5YKvw0ul8XIR0qWTp gCXR14Yyl0FFCMpYLjWe8UI84/ecRjgtEYOeAjIr6uJMTjoXM9tgfp4u/s469SIJ ZJ7BgudRMm625eVz2tmg =nM/7 -----END PGP SIGNATURE----- --24zk1gE8NUlDmwG9-- --===============1009896201== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1009896201==--