mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: noralf@tronnes.org, Jessica Zhang <quic_jesszhan@quicinc.com>,
	Sam Ravnborg <sam@ravnborg.org>, David Airlie <airlied@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Kamlesh Gurudasani <kamlesh.gurudasani@gmail.com>,
	Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Subject: Re: [PATCH v2 5/5] drm/tiny: panel-mipi-dbi: Support the pixel format property
Date: Tue, 21 May 2024 10:04:39 +0200	[thread overview]
Message-ID: <c08f679c-7063-4e61-a1f3-8a16459d9c04@linaro.org> (raw)
In-Reply-To: <20240512-panel-mipi-dbi-rgb666-v2-5-49dd266328a0@tronnes.org>

On 12/05/2024 17:25, Noralf Trønnes via B4 Relay wrote:
> From: Noralf Trønnes <noralf@tronnes.org>
> 
> Add support for these pixel format property values:
> - r5g6b5, RGB565
> - b6x2g6x2r6x2, BGR666
> 
> BGR666 is presented to userspace as RGB888. The 2 LSB in each color
> are discarded by the controller. The pixel is sent on the wire using
> 8 bits per word (little endian) so the controller sees it as BGR.
> 
> RGB565 is the default if the property is not present.
> 
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> ---
>   drivers/gpu/drm/tiny/panel-mipi-dbi.c | 55 ++++++++++++++++++++++++++++++++++-
>   1 file changed, 54 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tiny/panel-mipi-dbi.c b/drivers/gpu/drm/tiny/panel-mipi-dbi.c
> index f80a141fcf36..f3aa2abce314 100644
> --- a/drivers/gpu/drm/tiny/panel-mipi-dbi.c
> +++ b/drivers/gpu/drm/tiny/panel-mipi-dbi.c
> @@ -26,6 +26,49 @@
>   
>   #include <video/mipi_display.h>
>   
> +struct panel_mipi_dbi_format {
> +	const char *name;
> +	u32 fourcc;
> +	unsigned int bpp;
> +};
> +
> +static const struct panel_mipi_dbi_format panel_mipi_dbi_formats[] = {
> +	{ "r5g6b5", DRM_FORMAT_RGB565, 16 },
> +	{ "b6x2g6x2r6x2", DRM_FORMAT_RGB888, 24 },
> +};
> +
> +static int panel_mipi_dbi_get_format(struct device *dev, u32 *formats, unsigned int *bpp)
> +{
> +	const char *format_name;
> +	unsigned int i;
> +	int ret;
> +
> +	formats[1] = DRM_FORMAT_XRGB8888;
> +
> +	ret = device_property_read_string(dev, "format", &format_name);
> +	if (ret) {
> +		/* Old Device Trees don't have this property */
> +		formats[0] = DRM_FORMAT_RGB565;
> +		*bpp = 16;
> +		return 0;
> +	}
> +
> +	for (i = 0; i < ARRAY_SIZE(panel_mipi_dbi_formats); i++) {
> +		const struct panel_mipi_dbi_format *format = &panel_mipi_dbi_formats[i];
> +
> +		if (strcmp(format_name, format->name))
> +			continue;
> +
> +		formats[0] = format->fourcc;
> +		*bpp = format->bpp;
> +		return 0;
> +	}
> +
> +	dev_err(dev, "Pixel format is not supported: '%s'\n", format_name);
> +
> +	return -EINVAL;
> +}
> +
>   static const u8 panel_mipi_dbi_magic[15] = { 'M', 'I', 'P', 'I', ' ', 'D', 'B', 'I',
>   					     0, 0, 0, 0, 0, 0, 0 };
>   
> @@ -276,6 +319,9 @@ static int panel_mipi_dbi_spi_probe(struct spi_device *spi)
>   	struct drm_device *drm;
>   	struct mipi_dbi *dbi;
>   	struct gpio_desc *dc;
> +	unsigned int bpp;
> +	size_t buf_size;
> +	u32 formats[2];
>   	int ret;
>   
>   	dbidev = devm_drm_dev_alloc(dev, &panel_mipi_dbi_driver, struct mipi_dbi_dev, drm);
> @@ -323,7 +369,14 @@ static int panel_mipi_dbi_spi_probe(struct spi_device *spi)
>   	if (IS_ERR(dbidev->driver_private))
>   		return PTR_ERR(dbidev->driver_private);
>   
> -	ret = mipi_dbi_dev_init(dbidev, &panel_mipi_dbi_pipe_funcs, &mode, 0);
> +	ret = panel_mipi_dbi_get_format(dev, formats, &bpp);
> +	if (ret)
> +		return ret;
> +
> +	buf_size = DIV_ROUND_UP(mode.hdisplay * mode.vdisplay * bpp, 8);
> +	ret = mipi_dbi_dev_init_with_formats(dbidev, &panel_mipi_dbi_pipe_funcs,
> +					     formats, ARRAY_SIZE(formats),
> +					     &mode, 0, buf_size);
>   	if (ret)
>   		return ret;
>   
> 

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

      reply	other threads:[~2024-05-21  8:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-12 15:25 [PATCH v2 0/5] drm/tiny: panel-mipi-dbi: Support 18 bits per color RGB666 Noralf Trønnes via B4 Relay
2024-05-12 15:25 ` [PATCH v2 1/5] dt-bindings: display: panel: mipi-dbi-spi: Add a pixel format property Noralf Trønnes via B4 Relay
2024-05-20 15:57   ` Rob Herring (Arm)
2024-05-12 15:25 ` [PATCH v2 2/5] drm/mipi-dbi: Remove mipi_dbi_machine_little_endian() Noralf Trønnes via B4 Relay
2024-05-12 15:25 ` [PATCH v2 3/5] drm/mipi-dbi: Make bits per word configurable for pixel transfers Noralf Trønnes via B4 Relay
2024-05-12 15:25 ` [PATCH v2 4/5] drm/mipi-dbi: Add support for DRM_FORMAT_RGB888 Noralf Trønnes via B4 Relay
2024-05-12 15:25 ` [PATCH v2 5/5] drm/tiny: panel-mipi-dbi: Support the pixel format property Noralf Trønnes via B4 Relay
2024-05-21  8:04   ` Neil Armstrong [this message]

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=c08f679c-7063-4e61-a1f3-8a16459d9c04@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=airlied@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kamlesh.gurudasani@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    --cc=quic_jesszhan@quicinc.com \
    --cc=robh@kernel.org \
    --cc=sam@ravnborg.org \
    --cc=tommaso.merciai@amarulasolutions.com \
    --cc=tzimmermann@suse.de \
    /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®