dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Rob Clark <robdclark@chromium.org>,
	Philip Chen <philipchen@chromium.org>,
	Jitao Shi <jitao.shi@mediatek.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Jonas Karlman <jonas@kwiboo.se>,
	Robert Foss <robert.foss@linaro.org>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Douglas Anderson <dianders@chromium.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Andrzej Hajda <a.hajda@samsung.com>,
	dri-devel@lists.freedesktop.org,
	Enric Balletbo i Serra <enric.balletbo@collabora.com>
Subject: Re: [PATCH v1 2/9] drm: add drm specific media-bus-format header file
Date: Tue, 8 Feb 2022 02:40:29 +0200	[thread overview]
Message-ID: <YgG7/eb6ymR/1U70@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220206154405.1243333-3-sam@ravnborg.org>

Hi Sam,

Thank you for the patch.

On Sun, Feb 06, 2022 at 04:43:58PM +0100, Sam Ravnborg wrote:
> For now the header file includes a single method to retreive the bpc

s/retreive/retrieve/

> from the bus format.
> The supported MEDIA_BUS_* codes are the ones used for the current panels
> in DRM. The list can be extended as there are a need for more formats.
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  include/drm/media-bus-format.h | 53 ++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
>  create mode 100644 include/drm/media-bus-format.h
> 
> diff --git a/include/drm/media-bus-format.h b/include/drm/media-bus-format.h
> new file mode 100644
> index 000000000000..d4d18f19a70f
> --- /dev/null
> +++ b/include/drm/media-bus-format.h
> @@ -0,0 +1,53 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2022 Sam Ravnborg
> + */
> +
> +#ifndef __LINUX_DRM_MEDIA_BUS_FORMAT
> +#define __LINUX_DRM_MEDIA_BUS_FORMAT
> +
> +#include <linux/bug.h>
> +#include <linux/media-bus-format.h>
> +#include <linux/types.h>
> +
> +/**
> + * media_bus_format_to_bpc - The bits per color channel for the bus_format
> + *
> + * Based on the supplied bus_format return the maximum number of bits
> + * per color channel.
> + *
> + * RETURNS
> + * The number of bits per color channel, or -EINVAL if the bus_format
> + * is unknown.
> + */
> +static inline int media_bus_format_to_bpc(u32 bus_format)
> +{
> +	switch (bus_format) {
> +	/* DPI */
> +	case MEDIA_BUS_FMT_RGB565_1X16:
> +	case MEDIA_BUS_FMT_RGB666_1X18:
> +		return 6;
> +
> +	/* DPI */
> +	case MEDIA_BUS_FMT_RGB888_1X24:
> +	case MEDIA_BUS_FMT_RGB888_3X8:
> +	case MEDIA_BUS_FMT_RGB888_3X8_DELTA:
> +	case MEDIA_BUS_FMT_Y8_1X8:
> +		return 8;
> +
> +     	/* LVDS */

Wrong indentation.

> +	case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
> +		return 6;
> +
> +     	/* LVDS */
> +	case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
> +	case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
> +		return 8;
> +
> +	default:
> +		WARN(1, "Unknown MEDIA_BUS format %d\n", bus_format);
> +		return -EINVAL;
> +	}
> +}

This seems a bit big for an inline function.

If we add more helper functions, it will result in lots of switch...case
statements. Could we use the same approach as in drm_fourcc.h with a
format info structure ?

> +
> +#endif

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2022-02-08  0:40 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-06 15:43 [PATCH v1 0/9] drm/bridge: ps8640 and ti-sn65dsi86 updates Sam Ravnborg
2022-02-06 15:43 ` [PATCH v1 1/9] drm/bridge: add DRM_BRIDGE_STATE_OPS macro Sam Ravnborg
2022-02-07 22:19   ` Doug Anderson
2022-02-08  0:30   ` Laurent Pinchart
2022-02-12 21:15     ` Sam Ravnborg
2022-02-06 15:43 ` [PATCH v1 2/9] drm: add drm specific media-bus-format header file Sam Ravnborg
2022-02-07 22:21   ` Doug Anderson
2022-02-08  0:40   ` Laurent Pinchart [this message]
2022-02-06 15:43 ` [PATCH v1 3/9] drm: add drm_atomic_helper_bridge_dsi_input_bus_fmt Sam Ravnborg
2022-02-07 22:32   ` Doug Anderson
2022-02-08  0:44     ` Laurent Pinchart
2022-02-08 19:06       ` Sam Ravnborg
2022-02-06 15:44 ` [PATCH v1 4/9] drm/bridge: ti-sn65dsi86: Use atomic variants of drm_bridge_funcs Sam Ravnborg
2022-02-07 22:33   ` Doug Anderson
2022-02-08  0:46   ` Laurent Pinchart
2022-02-06 15:44 ` [PATCH v1 5/9] drm/bridge: ti-sn65dsi86: Fetch bpc via drm_bridge_state Sam Ravnborg
2022-02-07 22:34   ` Doug Anderson
2022-02-08 19:08     ` Sam Ravnborg
2022-02-06 15:44 ` [PATCH v1 6/9] drm/bridge: ti-sn65dsi86: Add NO_CONNECTOR support Sam Ravnborg
2022-02-07 22:34   ` Doug Anderson
2022-02-08  1:01     ` Laurent Pinchart
2022-02-08 19:12     ` Sam Ravnborg
2022-03-09 16:52   ` Kieran Bingham
2022-02-06 15:44 ` [PATCH v1 7/9] drm/bridge: ps8640: Use atomic variants of drm_bridge_funcs Sam Ravnborg
2022-02-06 15:44 ` [PATCH v1 8/9] drm/bridge: ps8640: plug atomic_get_input_bus_fmts Sam Ravnborg
2022-02-06 15:44 ` [PATCH v1 9/9] drm/bridge: Drop unused drm_bridge_chain functions Sam Ravnborg
2022-02-08  0:52   ` Laurent Pinchart
2022-02-06 19:09 ` [PATCH v1 0/9] drm/bridge: ps8640 and ti-sn65dsi86 updates Sam Ravnborg
2022-06-22 10:07   ` Kieran Bingham
2022-06-22 16:45     ` Sam Ravnborg

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=YgG7/eb6ymR/1U70@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=enric.balletbo@collabora.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jitao.shi@mediatek.com \
    --cc=jonas@kwiboo.se \
    --cc=narmstrong@baylibre.com \
    --cc=philipchen@chromium.org \
    --cc=robdclark@chromium.org \
    --cc=robert.foss@linaro.org \
    --cc=sam@ravnborg.org \
    --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