mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	Douglas Anderson <dianders@chromium.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	Jessica Zhang <quic_jesszhan@quicinc.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Caleb Connolly <caleb.connolly@linaro.org>,
	Marijn Suijten <marijn.suijten@somainline.org>,
	Vinod Koul <vkoul@kernel.org>
Cc: Cong Yang <yangcong5@huaqin.corp-partner.google.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/7] drm/mipi-dsi: wrap more functions for streamline handling
Date: Fri, 17 May 2024 21:32:58 +0200	[thread overview]
Message-ID: <63ebc7ab-b7b4-4814-95b1-d45fc9818184@linaro.org> (raw)
In-Reply-To: <20240512-dsi-panels-upd-api-v2-2-e31ca14d102e@linaro.org>

On 12/05/2024 01:00, Dmitry Baryshkov wrote:
> Follow the pattern of mipi_dsi_dcs_*_multi() and wrap several existing
> MIPI DSI functions to use the context for processing. This simplifies
> and streamlines driver code to use simpler code pattern.
> 
> Note, msleep function is also wrapped in this way as it is frequently
> called inbetween other mipi_dsi_dcs_*() functions.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>   drivers/gpu/drm/drm_mipi_dsi.c | 210 +++++++++++++++++++++++++++++++++++++++++
>   include/drm/drm_mipi_dsi.h     |  21 +++++
>   2 files changed, 231 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index d2957cb692d3..8721edd06c06 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -1429,6 +1429,216 @@ int mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device *dsi,
>   }
>   EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness_large);
>   
> +/**
> + * mipi_dsi_picture_parameter_set_multi() - transmit the DSC PPS to the peripheral
> + * @ctx: Context for multiple DSI transactions
> + * @pps: VESA DSC 1.1 Picture Parameter Set
> + *
> + * Like mipi_dsi_picture_parameter_set() but deals with errors in a way that
> + * makes it convenient to make several calls in a row.
> + */
> +void mipi_dsi_picture_parameter_set_multi(struct mipi_dsi_multi_context *ctx,
> +				   const struct drm_dsc_picture_parameter_set *pps)
> +{
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	struct device *dev = &dsi->dev;
> +	ssize_t ret;
> +
> +	if (ctx->accum_err)
> +		return;
> +
> +	ret = mipi_dsi_picture_parameter_set(dsi, pps);
> +	if (ret < 0) {
> +		ctx->accum_err = ret;
> +		dev_err(dev, "sending PPS failed: %d\n",
> +			ctx->accum_err);
> +	}
> +}
> +EXPORT_SYMBOL(mipi_dsi_picture_parameter_set_multi);
> +
> +/**
> + * mipi_dsi_compression_mode_ext_multi() - enable/disable DSC on the peripheral
> + * @ctx: Context for multiple DSI transactions
> + * @enable: Whether to enable or disable the DSC
> + * @algo: Selected compression algorithm
> + * @pps_selector: Select PPS from the table of pre-stored or uploaded PPS entries
> + *
> + * Like mipi_dsi_compression_mode_ext() but deals with errors in a way that
> + * makes it convenient to make several calls in a row.
> + */
> +void mipi_dsi_compression_mode_ext_multi(struct mipi_dsi_multi_context *ctx,
> +					 bool enable,
> +					 enum mipi_dsi_compression_algo algo,
> +					 unsigned int pps_selector)
> +{
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	struct device *dev = &dsi->dev;
> +	ssize_t ret;
> +
> +	if (ctx->accum_err)
> +		return;
> +
> +	ret = mipi_dsi_compression_mode_ext(dsi, enable, algo, pps_selector);
> +	if (ret < 0) {
> +		ctx->accum_err = ret;
> +		dev_err(dev, "sending COMPRESSION_MODE failed: %d\n",
> +			ctx->accum_err);
> +	}
> +}
> +EXPORT_SYMBOL(mipi_dsi_compression_mode_ext_multi);
> +
> +/**
> + * mipi_dsi_dcs_nop_multi() - send DCS NOP packet
> + * @ctx: Context for multiple DSI transactions
> + *
> + * Like mipi_dsi_dcs_nop() but deals with errors in a way that
> + * makes it convenient to make several calls in a row.
> + */
> +void mipi_dsi_dcs_nop_multi(struct mipi_dsi_multi_context *ctx)
> +{
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	struct device *dev = &dsi->dev;
> +	ssize_t ret;
> +
> +	if (ctx->accum_err)
> +		return;
> +
> +	ret = mipi_dsi_dcs_nop(dsi);
> +	if (ret < 0) {
> +		ctx->accum_err = ret;
> +		dev_err(dev, "sending DCS NOP failed: %d\n",
> +			ctx->accum_err);
> +	}
> +}
> +EXPORT_SYMBOL(mipi_dsi_dcs_nop_multi);
> +
> +/**
> + * mipi_dsi_dcs_enter_sleep_mode_multi() - send DCS ENTER_SLEEP_MODE  packet
> + * @ctx: Context for multiple DSI transactions
> + *
> + * Like mipi_dsi_dcs_enter_sleep_mode() but deals with errors in a way that
> + * makes it convenient to make several calls in a row.
> + */
> +void mipi_dsi_dcs_enter_sleep_mode_multi(struct mipi_dsi_multi_context *ctx)
> +{
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	struct device *dev = &dsi->dev;
> +	ssize_t ret;
> +
> +	if (ctx->accum_err)
> +		return;
> +
> +	ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
> +	if (ret < 0) {
> +		ctx->accum_err = ret;
> +		dev_err(dev, "sending DCS ENTER_SLEEP_MODE failed: %d\n",
> +			ctx->accum_err);
> +	}
> +}
> +EXPORT_SYMBOL(mipi_dsi_dcs_enter_sleep_mode_multi);
> +
> +/**
> + * mipi_dsi_dcs_exit_sleep_mode_multi() - send DCS EXIT_SLEEP_MODE packet
> + * @ctx: Context for multiple DSI transactions
> + *
> + * Like mipi_dsi_dcs_exit_sleep_mode() but deals with errors in a way that
> + * makes it convenient to make several calls in a row.
> + */
> +void mipi_dsi_dcs_exit_sleep_mode_multi(struct mipi_dsi_multi_context *ctx)
> +{
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	struct device *dev = &dsi->dev;
> +	ssize_t ret;
> +
> +	if (ctx->accum_err)
> +		return;
> +
> +	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
> +	if (ret < 0) {
> +		ctx->accum_err = ret;
> +		dev_err(dev, "sending DCS EXIT_SLEEP_MODE failed: %d\n",
> +			ctx->accum_err);
> +	}
> +}
> +EXPORT_SYMBOL(mipi_dsi_dcs_exit_sleep_mode_multi);
> +
> +/**
> + * mipi_dsi_dcs_set_display_off_multi() - send DCS SET_DISPLAY_OFF packet
> + * @ctx: Context for multiple DSI transactions
> + *
> + * Like mipi_dsi_dcs_set_display_off() but deals with errors in a way that
> + * makes it convenient to make several calls in a row.
> + */
> +void mipi_dsi_dcs_set_display_off_multi(struct mipi_dsi_multi_context *ctx)
> +{
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	struct device *dev = &dsi->dev;
> +	ssize_t ret;
> +
> +	if (ctx->accum_err)
> +		return;
> +
> +	ret = mipi_dsi_dcs_set_display_off(dsi);
> +	if (ret < 0) {
> +		ctx->accum_err = ret;
> +		dev_err(dev, "sending DCS SET_DISPLAY_OFF failed: %d\n",
> +			ctx->accum_err);
> +	}
> +}
> +EXPORT_SYMBOL(mipi_dsi_dcs_set_display_off_multi);
> +
> +/**
> + * mipi_dsi_dcs_set_display_on_multi() - send DCS SET_DISPLAY_ON packet
> + * @ctx: Context for multiple DSI transactions
> + *
> + * Like mipi_dsi_dcs_set_display_on() but deals with errors in a way that
> + * makes it convenient to make several calls in a row.
> + */
> +void mipi_dsi_dcs_set_display_on_multi(struct mipi_dsi_multi_context *ctx)
> +{
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	struct device *dev = &dsi->dev;
> +	ssize_t ret;
> +
> +	if (ctx->accum_err)
> +		return;
> +
> +	ret = mipi_dsi_dcs_set_display_on(dsi);
> +	if (ret < 0) {
> +		ctx->accum_err = ret;
> +		dev_err(dev, "sending DCS SET_DISPLAY_ON failed: %d\n",
> +			ctx->accum_err);
> +	}
> +}
> +EXPORT_SYMBOL(mipi_dsi_dcs_set_display_on_multi);
> +
> +/**
> + * mipi_dsi_dcs_set_tear_on_multi() - send DCS SET_TEAR_ON packet
> + * @ctx: Context for multiple DSI transactions
> + * @mode: the Tearing Effect Output Line mode
> + *
> + * Like mipi_dsi_dcs_set_tear_on() but deals with errors in a way that
> + * makes it convenient to make several calls in a row.
> + */
> +void mipi_dsi_dcs_set_tear_on_multi(struct mipi_dsi_multi_context *ctx,
> +				    enum mipi_dsi_dcs_tear_mode mode)
> +{
> +	struct mipi_dsi_device *dsi = ctx->dsi;
> +	struct device *dev = &dsi->dev;
> +	ssize_t ret;
> +
> +	if (ctx->accum_err)
> +		return;
> +
> +	ret = mipi_dsi_dcs_set_tear_on(dsi, mode);
> +	if (ret < 0) {
> +		ctx->accum_err = ret;
> +		dev_err(dev, "sending DCS SET_TEAR_ON failed: %d\n",
> +			ctx->accum_err);
> +	}
> +}
> +EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on_multi);
> +
>   static int mipi_dsi_drv_probe(struct device *dev)
>   {
>   	struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
> diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
> index 5e9cad541bd6..bd5a0b6d0711 100644
> --- a/include/drm/drm_mipi_dsi.h
> +++ b/include/drm/drm_mipi_dsi.h
> @@ -275,6 +275,13 @@ int mipi_dsi_compression_mode_ext(struct mipi_dsi_device *dsi, bool enable,
>   int mipi_dsi_picture_parameter_set(struct mipi_dsi_device *dsi,
>   				   const struct drm_dsc_picture_parameter_set *pps);
>   
> +void mipi_dsi_compression_mode_ext_multi(struct mipi_dsi_multi_context *ctx,
> +					 bool enable,
> +					 enum mipi_dsi_compression_algo algo,
> +					 unsigned int pps_selector);
> +void mipi_dsi_picture_parameter_set_multi(struct mipi_dsi_multi_context *ctx,
> +					  const struct drm_dsc_picture_parameter_set *pps);
> +
>   ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload,
>   			       size_t size);
>   int mipi_dsi_generic_write_chatty(struct mipi_dsi_device *dsi,
> @@ -284,6 +291,12 @@ void mipi_dsi_generic_write_multi(struct mipi_dsi_multi_context *ctx,
>   ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params,
>   			      size_t num_params, void *data, size_t size);
>   
> +#define mipi_dsi_msleep(ctx, delay)	\
> +	do {				\
> +		if (!ctx.accum_err)	\
> +			msleep(delay);	\
> +	} while (0)
> +
>   /**
>    * enum mipi_dsi_dcs_tear_mode - Tearing Effect Output Line mode
>    * @MIPI_DSI_DCS_TEAR_MODE_VBLANK: the TE output line consists of V-Blanking
> @@ -338,6 +351,14 @@ int mipi_dsi_dcs_set_display_brightness_large(struct mipi_dsi_device *dsi,
>   int mipi_dsi_dcs_get_display_brightness_large(struct mipi_dsi_device *dsi,
>   					     u16 *brightness);
>   
> +void mipi_dsi_dcs_nop_multi(struct mipi_dsi_multi_context *ctx);
> +void mipi_dsi_dcs_enter_sleep_mode_multi(struct mipi_dsi_multi_context *ctx);
> +void mipi_dsi_dcs_exit_sleep_mode_multi(struct mipi_dsi_multi_context *ctx);
> +void mipi_dsi_dcs_set_display_off_multi(struct mipi_dsi_multi_context *ctx);
> +void mipi_dsi_dcs_set_display_on_multi(struct mipi_dsi_multi_context *ctx);
> +void mipi_dsi_dcs_set_tear_on_multi(struct mipi_dsi_multi_context *ctx,
> +				    enum mipi_dsi_dcs_tear_mode mode);
> +
>   /**
>    * mipi_dsi_generic_write_seq - transmit data using a generic write packet
>    *
> 

The mipi_dsi_msleep() seems a little bit over-enginerred for me, but it serves
the purpose so:

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil

  parent reply	other threads:[~2024-05-17 19:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-11 23:00 [PATCH v2 0/7] drm/mipi-dsi: simplify MIPI DSI init/cleanup even more Dmitry Baryshkov
2024-05-11 23:00 ` [PATCH v2 1/7] drm/panel: lg-sw43408: add missing error handling Dmitry Baryshkov
2024-05-11 23:00 ` [PATCH v2 2/7] drm/mipi-dsi: wrap more functions for streamline handling Dmitry Baryshkov
2024-05-13 16:49   ` Doug Anderson
2024-05-17 19:32   ` Neil Armstrong [this message]
2024-05-11 23:00 ` [PATCH v2 3/7] drm/panel: boe-tv101wum-nl6: use wrapped MIPI DCS functions Dmitry Baryshkov
2024-05-11 23:00 ` [PATCH v2 4/7] drm/panel: ilitek-ili9882t: " Dmitry Baryshkov
2024-05-11 23:00 ` [PATCH v2 5/7] drm/panel: innolux-p079zca: use mipi_dsi_dcs_nop_multi() Dmitry Baryshkov
2024-05-11 23:00 ` [PATCH v2 6/7] drm/panel: novatek-nt36672e: use wrapped MIPI DCS functions Dmitry Baryshkov
2024-05-11 23:00 ` [PATCH v2 7/7] drm/panel: lg-sw43408: use new streamlined MIPI DSI API Dmitry Baryshkov
2024-05-17 19:39 ` [PATCH v2 0/7] drm/mipi-dsi: simplify MIPI DSI init/cleanup even more Neil Armstrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=63ebc7ab-b7b4-4814-95b1-d45fc9818184@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=airlied@gmail.com \
    --cc=caleb.connolly@linaro.org \
    --cc=daniel@ffwll.ch \
    --cc=dianders@chromium.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=marijn.suijten@somainline.org \
    --cc=mripard@kernel.org \
    --cc=quic_jesszhan@quicinc.com \
    --cc=sam@ravnborg.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tzimmermann@suse.de \
    --cc=vkoul@kernel.org \
    --cc=yangcong5@huaqin.corp-partner.google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®