From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/4] drm: Centralize format information
Date: Tue, 07 Jun 2016 16:24:01 +0300 [thread overview]
Message-ID: <5771754.tDPS7Scd8F@avalon> (raw)
In-Reply-To: <20160607132017.GG4329@intel.com>
Hi Ville,
On Tuesday 07 Jun 2016 16:20:17 Ville Syrjälä wrote:
> On Tue, Jun 07, 2016 at 02:33:11AM +0300, 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>
> > ---
> >
> > drivers/gpu/drm/drm_crtc.c | 83 +++++++++++++++++++++++++++++++++++++++++
> > include/drm/drm_crtc.h | 21 ++++++++++++
> > 2 files changed, 104 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index 0e3cc66aa8b7..74b0c6dd80cd 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -5544,6 +5544,89 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device
> > *dev,>
> > }
> >
> > /**
> >
> > + * drm_format_info - 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[] = {
> > + { DRM_FORMAT_C8, 8, 8, 1, { 1 }, 1, 1 },
>
> Named initializers please.
Do we really want to expand every entry to 7 lines ? I can do so, but it won't
look pretty.
> > + { DRM_FORMAT_RGB332, 8, 8, 1, { 1 }, 1, 1 },
> > + { DRM_FORMAT_BGR233, 8, 8, 1, { 1 }, 1, 1 },
> > + { DRM_FORMAT_XRGB4444, 12, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_XBGR4444, 12, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_RGBX4444, 12, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_BGRX4444, 12, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_ARGB4444, 12, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_ABGR4444, 12, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_RGBA4444, 12, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_BGRA4444, 12, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_XRGB1555, 15, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_XBGR1555, 15, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_RGBX5551, 15, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_BGRX5551, 15, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_ARGB1555, 15, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_ABGR1555, 15, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_RGBA5551, 15, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_BGRA5551, 15, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_RGB565, 16, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_BGR565, 16, 16, 1, { 2 }, 1, 1 },
> > + { DRM_FORMAT_RGB888, 24, 24, 1, { 3 }, 1, 1 },
> > + { DRM_FORMAT_BGR888, 24, 24, 1, { 3 }, 1, 1 },
> > + { DRM_FORMAT_XRGB8888, 24, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_XBGR8888, 24, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_RGBX8888, 24, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_BGRX8888, 24, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_XRGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_XBGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_RGBX1010102, 30, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_BGRX1010102, 30, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_ARGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_ABGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_RGBA1010102, 30, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_BGRA1010102, 30, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_ARGB8888, 32, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_ABGR8888, 32, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_RGBA8888, 32, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_BGRA8888, 32, 32, 1, { 4 }, 1, 1 },
> > + { DRM_FORMAT_YUV410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> > + { DRM_FORMAT_YVU410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> > + { DRM_FORMAT_YUV411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> > + { DRM_FORMAT_YVU411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> > + { DRM_FORMAT_YUV420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> > + { DRM_FORMAT_YVU420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> > + { DRM_FORMAT_YUV422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> > + { DRM_FORMAT_YVU422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> > + { DRM_FORMAT_YUV444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> > + { DRM_FORMAT_YVU444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> > + { DRM_FORMAT_NV12, 0, 0, 2, { 1, 2 }, 2, 2 },
> > + { DRM_FORMAT_NV21, 0, 0, 2, { 1, 2 }, 2, 2 },
> > + { DRM_FORMAT_NV16, 0, 0, 2, { 1, 2 }, 2, 1 },
> > + { DRM_FORMAT_NV61, 0, 0, 2, { 1, 2 }, 2, 1 },
> > + { DRM_FORMAT_NV24, 0, 0, 2, { 1, 2 }, 1, 1 },
> > + { DRM_FORMAT_NV42, 0, 0, 2, { 1, 2 }, 1, 1 },
> > + { DRM_FORMAT_YUYV, 0, 0, 1, { 2 }, 2, 1 },
> > + { DRM_FORMAT_YVYU, 0, 0, 1, { 2 }, 2, 1 },
> > + { DRM_FORMAT_UYVY, 0, 0, 1, { 2 }, 2, 1 },
> > + { DRM_FORMAT_VYUY, 0, 0, 1, { 2 }, 2, 1 },
> > + { DRM_FORMAT_AYUV, 0, 0, 1, { 4 }, 1, 1 },
> > + };
> > +
> > + unsigned int i;
> > +
> > + for (i = 0; i < ARRAY_SIZE(formats); ++i) {
> > + if (formats[i].format == format)
> > + return &formats[i];
> > + }
> > +
> > + return NULL;
> > +}
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-06-07 13:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 23:33 [PATCH 0/4] Centralize format information Laurent Pinchart
2016-06-06 23:33 ` [PATCH 1/4] drm: " Laurent Pinchart
2016-06-07 9:18 ` Tomi Valkeinen
2016-06-07 11:48 ` Laurent Pinchart
2016-06-07 9:25 ` Tomi Valkeinen
2016-06-07 12:05 ` Laurent Pinchart
2016-06-07 13:20 ` Ville Syrjälä
2016-06-07 13:24 ` Laurent Pinchart [this message]
2016-06-06 23:33 ` [PATCH 2/4] drm: Remove unused drm_format_plane_(width|height) helpers Laurent Pinchart
2016-06-07 13:19 ` Ville Syrjälä
2016-06-07 13:23 ` Laurent Pinchart
2016-06-06 23:33 ` [PATCH 3/4] drm: Implement the drm_format_*() helpers as drm_format_info() wrappers Laurent Pinchart
2016-06-06 23:33 ` [PATCH 4/4] drm: Use drm_format_info() in DRM core code Laurent Pinchart
2016-06-07 13:27 ` [PATCH 0/4] Centralize format information Daniel Vetter
2016-06-07 13:33 ` Laurent Pinchart
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=5771754.tDPS7Scd8F@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=tomi.valkeinen@ti.com \
--cc=ville.syrjala@linux.intel.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