All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 01/14] drm: Centralize format information
Date: Thu, 15 Sep 2016 09:22:54 +0300	[thread overview]
Message-ID: <1ef50c0f-dc06-0a62-8728-82ee601eec34@ti.com> (raw)
In-Reply-To: <1622000.t01kXMM4V9@avalon>


[-- Attachment #1.1.1: Type: text/plain, Size: 4712 bytes --]

On 15/09/16 01:22, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the review.
> 
> On Wednesday 14 Sep 2016 14:49:26 Tomi Valkeinen wrote:
>> On 08/09/16 17:44, Laurent Pinchart wrote:
>>> Various pieces of information about DRM formats (number of planes, color
>>> depth, chroma subsampling, ...) are scattered across different helper
>>> functions in the DRM core. Callers of those functions often need to
>>> access more than a single parameter of the format, leading to
>>> inefficiencies due to multiple lookups.
>>>
>>> Centralize all format information in a data structure and create a
>>> function to look up information based on the format 4CC.
>>>
>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> ---
>>>
>>>  Documentation/gpu/drm-kms.rst |  3 ++
>>>  drivers/gpu/drm/drm_fourcc.c  | 84 ++++++++++++++++++++++++++++++++++++++
>>>  include/drm/drm_fourcc.h      | 19 ++++++++++
>>>  3 files changed, 106 insertions(+)
> 
> [snip]
> 
>>> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
>>> index 29c56b4331e0..6b91bd8a510d 100644
>>> --- a/drivers/gpu/drm/drm_fourcc.c
>>> +++ b/drivers/gpu/drm/drm_fourcc.c
>>> @@ -103,6 +103,90 @@ char *drm_get_format_name(uint32_t format)
>>>  EXPORT_SYMBOL(drm_get_format_name);
>>>  
>>>  /**
>>> + * drm_format_info - query information for a given format
>>> + * @format: pixel format (DRM_FORMAT_*)
>>> + *
>>> + * Returns:
>>> + * The instance of struct drm_format_info that describes the pixel
>>> format, or
>>> + * NULL if the format is unsupported.
>>> + */
>>> +const struct drm_format_info *drm_format_info(u32 format)
>>> +{
>>> +	static const struct drm_format_info formats[] = {
>>> +		{ .format = DRM_FORMAT_C8,		.depth = 8, 
>>> .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
>>> +		{ .format = DRM_FORMAT_RGB332,		.depth = 8, 
>>> .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
>>> +		{ .format = DRM_FORMAT_BGR233,		.depth = 8,
>>> .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
>>> +		{ .format = DRM_FORMAT_XRGB4444,	.depth = 12,
>>> .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
>>> +		{ .format = DRM_FORMAT_XBGR4444,	.depth = 12,
>>> .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
>>> +		{ .format = DRM_FORMAT_RGBX4444,	.depth = 12,
>>> .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
>>> +		{ .format = DRM_FORMAT_BGRX4444,	.depth = 12,
>>> .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
>>> +		{ .format = DRM_FORMAT_ARGB4444,	.depth = 12,
>>> .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
>>> +		{ .format = DRM_FORMAT_ABGR4444,	.depth = 12,
>>> .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
>>> +		{ .format = DRM_FORMAT_RGBA4444,	.depth = 12,
>>> .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
>>> +		{ .format = DRM_FORMAT_BGRA4444,	.depth = 12,
>>> .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
>>
>> Aren't these 16 bit deep modes? 4+4+4+4 = 16.
> 
> No, the depth value is the number of colour bits, excluding the alpha bits. 
> This is used to implement the fbdev compatibility code, as fbdev (unlike kms) 
> makes use of that information.
> 
> The total number of bits per pixel is not stored in the table as it can be 
> computed by cpp[0]*8 + (cpp[1]+cpp[2])*8/hsub/vsub. For RGB formats, which are 
> the only formats supported by the existing drm_fb_get_bpp_depth() function, 
> this simplifies to just cpp[0] * 8.

Ok. Then the ARGB8888 & co. formats have depth wrong. I presumed those
were right as they're the "normal" ones =).

I'm not sure if it's worth the hassle, but if the depth is only for
fbdev compat code, maybe a separate format->depth table in fbdev code
(for the formats fbdev supports) would make this cleaner and avoid any
future mistakes with new drm drivers.

>>> diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
>>> index 30c30fa87ee8..4e79d6159856 100644
>>> --- a/include/drm/drm_fourcc.h
>>> +++ b/include/drm/drm_fourcc.h
>>> @@ -25,6 +25,25 @@
>>>  #include <linux/types.h>
>>>  #include <uapi/drm/drm_fourcc.h>
>>>
>>> +/**
>>> + * struct drm_format_info - information about a DRM format
>>> + * @format: 4CC format identifier (DRM_FORMAT_*)
>>> + * @depth: color depth (number of bits per pixel excluding padding bits)
>>
>> Depth is zero for yuv formats. Maybe that should be made clear here.
> 
> How about
> 
> "color depth (number of bits per pixel excluding padding and alpha bits), 
> valid for RGB formats only" ?

Yes, that makes it clear.

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2016-09-15  6:23 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08 14:44 [PATCH v4 00/14] Centralize format information Laurent Pinchart
2016-09-08 14:44 ` [PATCH v4 01/14] drm: " Laurent Pinchart
2016-09-14 11:49   ` Tomi Valkeinen
2016-09-14 22:22     ` Laurent Pinchart
2016-09-15  6:22       ` Tomi Valkeinen [this message]
2016-09-15 16:12         ` Eric Engestrom
2016-09-15 23:30           ` Laurent Pinchart
2016-09-16  9:44             ` Tomi Valkeinen
2016-09-16  9:59               ` Laurent Pinchart
2016-09-18 10:17   ` [PATCH v4.1 " Laurent Pinchart
2016-09-21  7:23     ` Daniel Vetter
2016-09-21 11:21       ` Laurent Pinchart
2016-09-21 12:43         ` Daniel Vetter
2016-09-21 13:40     ` Eric Engestrom
2016-09-22  6:37       ` Daniel Vetter
2016-09-08 14:44 ` [PATCH v4 02/14] drm: Implement the drm_format_*() helpers as drm_format_info() wrappers Laurent Pinchart
2016-09-14 11:56   ` Tomi Valkeinen
2016-09-21  7:34   ` Daniel Vetter
2016-09-21 11:29     ` Laurent Pinchart
2016-09-08 14:44 ` [PATCH v4 03/14] drm: Use drm_format_info() in DRM core code Laurent Pinchart
2016-09-14 13:23   ` Tomi Valkeinen
2016-09-14 22:31     ` Laurent Pinchart
2016-09-21  7:26       ` Daniel Vetter
2016-09-08 14:44 ` [PATCH v4 04/14] drm: WARN when calling drm_format_info() for an unsupported format Laurent Pinchart
2016-09-15  9:33   ` Tomi Valkeinen
2016-09-08 14:44 ` [PATCH v4 05/14] drm: sti: Replace drm_fb_get_bpp_depth() with drm_format_plane_cpp() Laurent Pinchart
2016-09-09 12:08   ` Vincent ABRIOU
2016-09-08 14:44 ` [PATCH v4 06/14] drm: hdlcd: " Laurent Pinchart
2016-09-08 14:44 ` [PATCH v4 07/14] drm: tilcdc: " Laurent Pinchart
2016-09-15  9:36   ` Tomi Valkeinen
2016-09-15  9:49     ` Jyri Sarha
2016-09-15 21:40       ` [PATCH v4.1 " Laurent Pinchart
2016-09-08 14:44 ` [PATCH v4 08/14] drm: cirrus: " Laurent Pinchart
2016-09-21  7:36   ` Daniel Vetter
2016-09-08 14:44 ` [PATCH v4 09/14] drm: gma500: Replace drm_fb_get_bpp_depth() with drm_format_info() Laurent Pinchart
2016-09-21  7:35   ` Daniel Vetter
2016-09-08 14:44 ` [PATCH v4 10/14] drm: amdgpu: Replace drm_fb_get_bpp_depth() with drm_format_plane_cpp() Laurent Pinchart
2016-09-21  7:51   ` Daniel Vetter
2016-09-21 12:39     ` Laurent Pinchart
2016-09-21 12:46       ` Daniel Vetter
2016-09-21 13:59         ` Laurent Pinchart
2016-09-22  5:31           ` Daniel Vetter
2016-09-22  6:33             ` Laurent Pinchart
2016-09-08 14:44 ` [PATCH v4 11/14] drm: radeon: " Laurent Pinchart
2016-09-21  7:52   ` Daniel Vetter
2016-09-08 14:44 ` [PATCH v4 12/14] drm: vmwgfx: Replace drm_fb_get_bpp_depth() with drm_format_info() Laurent Pinchart
2016-09-21  7:31   ` Daniel Vetter
2016-09-23 12:40     ` Laurent Pinchart
2016-09-23 12:48       ` Daniel Vetter
2016-09-08 14:44 ` [PATCH v4 13/14] drm/arm: mali-dp: Replace drm_fb_get_bpp_depth() with drm_format_plane_cpp() Laurent Pinchart
2016-09-21  7:53   ` Daniel Vetter
2016-09-08 14:44 ` [PATCH v4 14/14] drm: Don't export the drm_fb_get_bpp_depth() function Laurent Pinchart
2016-09-15  9:41   ` Tomi Valkeinen

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=1ef50c0f-dc06-0a62-8728-82ee601eec34@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.