From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomi Valkeinen Subject: Re: [PATCH v4 01/14] drm: Centralize format information Date: Wed, 14 Sep 2016 14:49:26 +0300 Message-ID: <9a7a728d-6983-4d5b-53e4-96291c31f2a0@ti.com> References: <1473345868-25453-1-git-send-email-laurent.pinchart@ideasonboard.com> <1473345868-25453-2-git-send-email-laurent.pinchart@ideasonboard.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1532535101==" Return-path: Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE1306E136 for ; Wed, 14 Sep 2016 11:49:35 +0000 (UTC) In-Reply-To: <1473345868-25453-2-git-send-email-laurent.pinchart@ideasonboard.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Laurent Pinchart , dri-devel@lists.freedesktop.org Cc: Daniel Vetter List-Id: dri-devel@lists.freedesktop.org --===============1532535101== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="aXb4tttPS4QAOvP6s88BpHwlQSCv3FHs2" --aXb4tttPS4QAOvP6s88BpHwlQSCv3FHs2 Content-Type: multipart/mixed; boundary="JVIE9UNfphhpFrcUSxOsjCxVxHtp5E5TE"; protected-headers="v1" From: Tomi Valkeinen To: Laurent Pinchart , dri-devel@lists.freedesktop.org Cc: Daniel Vetter Message-ID: <9a7a728d-6983-4d5b-53e4-96291c31f2a0@ti.com> Subject: Re: [PATCH v4 01/14] drm: Centralize format information References: <1473345868-25453-1-git-send-email-laurent.pinchart@ideasonboard.com> <1473345868-25453-2-git-send-email-laurent.pinchart@ideasonboard.com> In-Reply-To: <1473345868-25453-2-git-send-email-laurent.pinchart@ideasonboard.com> --JVIE9UNfphhpFrcUSxOsjCxVxHtp5E5TE Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/09/16 17:44, Laurent Pinchart wrote: > Various pieces of information about DRM formats (number of planes, colo= r > 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. >=20 > Centralize all format information in a data structure and create a > function to look up information based on the format 4CC. >=20 > Signed-off-by: Laurent Pinchart > --- > Documentation/gpu/drm-kms.rst | 3 ++ > drivers/gpu/drm/drm_fourcc.c | 84 +++++++++++++++++++++++++++++++++++= ++++++++ > include/drm/drm_fourcc.h | 19 ++++++++++ > 3 files changed, 106 insertions(+) >=20 > diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.= rst > index f9a991bb87d4..85c4c49f4436 100644 > --- a/Documentation/gpu/drm-kms.rst > +++ b/Documentation/gpu/drm-kms.rst > @@ -63,6 +63,9 @@ Frame Buffer Functions Reference > DRM Format Handling > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =20 > +.. kernel-doc:: include/drm/drm_fourcc.h > + :internal: > + > .. kernel-doc:: drivers/gpu/drm/drm_fourcc.c > :export: > =20 > 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); > =20 > /** > + * 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 for= mat, or > + * NULL if the format is unsupported. > + */ > +const struct drm_format_info *drm_format_info(u32 format) > +{ > + static const struct drm_format_info formats[] =3D { > + { .format =3D DRM_FORMAT_C8, .depth =3D 8, .num_planes =3D 1, .cpp= =3D { 1, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_RGB332, .depth =3D 8, .num_planes =3D 1, = =2Ecpp =3D { 1, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGR233, .depth =3D 8, .num_planes =3D 1, = =2Ecpp =3D { 1, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_XRGB4444, .depth =3D 12, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_XBGR4444, .depth =3D 12, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_RGBX4444, .depth =3D 12, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGRX4444, .depth =3D 12, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_ARGB4444, .depth =3D 12, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_ABGR4444, .depth =3D 12, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_RGBA4444, .depth =3D 12, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGRA4444, .depth =3D 12, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, Aren't these 16 bit deep modes? 4+4+4+4 =3D 16. > + { .format =3D DRM_FORMAT_XRGB1555, .depth =3D 15, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_XBGR1555, .depth =3D 15, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_RGBX5551, .depth =3D 15, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGRX5551, .depth =3D 15, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_ARGB1555, .depth =3D 15, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_ABGR1555, .depth =3D 15, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_RGBA5551, .depth =3D 15, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGRA5551, .depth =3D 15, .num_planes =3D 1,= .cpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, Aren't these 16 bit deep modes? 5+5+5+1 =3D 16. > + { .format =3D DRM_FORMAT_RGB565, .depth =3D 16, .num_planes =3D 1, = =2Ecpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGR565, .depth =3D 16, .num_planes =3D 1, = =2Ecpp =3D { 2, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_RGB888, .depth =3D 24, .num_planes =3D 1, = =2Ecpp =3D { 3, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGR888, .depth =3D 24, .num_planes =3D 1, = =2Ecpp =3D { 3, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_XRGB8888, .depth =3D 24, .num_planes =3D 1,= .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_XBGR8888, .depth =3D 24, .num_planes =3D 1,= .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_RGBX8888, .depth =3D 24, .num_planes =3D 1,= .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGRX8888, .depth =3D 24, .num_planes =3D 1,= .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_XRGB2101010, .depth =3D 30, .num_planes =3D= 1, .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_XBGR2101010, .depth =3D 30, .num_planes =3D= 1, .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_RGBX1010102, .depth =3D 30, .num_planes =3D= 1, .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGRX1010102, .depth =3D 30, .num_planes =3D= 1, .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_ARGB2101010, .depth =3D 30, .num_planes =3D= 1, .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_ABGR2101010, .depth =3D 30, .num_planes =3D= 1, .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_RGBA1010102, .depth =3D 30, .num_planes =3D= 1, .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGRA1010102, .depth =3D 30, .num_planes =3D= 1, .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, Aren't these 32 bit deep modes? 10+10+10+2 =3D 32. > + { .format =3D DRM_FORMAT_ARGB8888, .depth =3D 32, .num_planes =3D 1,= .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_ABGR8888, .depth =3D 32, .num_planes =3D 1,= .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_RGBA8888, .depth =3D 32, .num_planes =3D 1,= .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_BGRA8888, .depth =3D 32, .num_planes =3D 1,= .cpp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_YUV410, .depth =3D 0, .num_planes =3D 3, = =2Ecpp =3D { 1, 1, 1 }, .hsub =3D 4, .vsub =3D 4 }, > + { .format =3D DRM_FORMAT_YVU410, .depth =3D 0, .num_planes =3D 3, = =2Ecpp =3D { 1, 1, 1 }, .hsub =3D 4, .vsub =3D 4 }, > + { .format =3D DRM_FORMAT_YUV411, .depth =3D 0, .num_planes =3D 3, = =2Ecpp =3D { 1, 1, 1 }, .hsub =3D 4, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_YVU411, .depth =3D 0, .num_planes =3D 3, = =2Ecpp =3D { 1, 1, 1 }, .hsub =3D 4, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_YUV420, .depth =3D 0, .num_planes =3D 3, = =2Ecpp =3D { 1, 1, 1 }, .hsub =3D 2, .vsub =3D 2 }, > + { .format =3D DRM_FORMAT_YVU420, .depth =3D 0, .num_planes =3D 3, = =2Ecpp =3D { 1, 1, 1 }, .hsub =3D 2, .vsub =3D 2 }, > + { .format =3D DRM_FORMAT_YUV422, .depth =3D 0, .num_planes =3D 3, = =2Ecpp =3D { 1, 1, 1 }, .hsub =3D 2, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_YVU422, .depth =3D 0, .num_planes =3D 3, = =2Ecpp =3D { 1, 1, 1 }, .hsub =3D 2, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_YUV444, .depth =3D 0, .num_planes =3D 3, = =2Ecpp =3D { 1, 1, 1 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_YVU444, .depth =3D 0, .num_planes =3D 3, = =2Ecpp =3D { 1, 1, 1 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_NV12, .depth =3D 0, .num_planes =3D 2, .c= pp =3D { 1, 2, 0 }, .hsub =3D 2, .vsub =3D 2 }, > + { .format =3D DRM_FORMAT_NV21, .depth =3D 0, .num_planes =3D 2, .c= pp =3D { 1, 2, 0 }, .hsub =3D 2, .vsub =3D 2 }, > + { .format =3D DRM_FORMAT_NV16, .depth =3D 0, .num_planes =3D 2, .c= pp =3D { 1, 2, 0 }, .hsub =3D 2, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_NV61, .depth =3D 0, .num_planes =3D 2, .c= pp =3D { 1, 2, 0 }, .hsub =3D 2, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_NV24, .depth =3D 0, .num_planes =3D 2, .c= pp =3D { 1, 2, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_NV42, .depth =3D 0, .num_planes =3D 2, .c= pp =3D { 1, 2, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_YUYV, .depth =3D 0, .num_planes =3D 1, .c= pp =3D { 2, 0, 0 }, .hsub =3D 2, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_YVYU, .depth =3D 0, .num_planes =3D 1, .c= pp =3D { 2, 0, 0 }, .hsub =3D 2, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_UYVY, .depth =3D 0, .num_planes =3D 1, .c= pp =3D { 2, 0, 0 }, .hsub =3D 2, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_VYUY, .depth =3D 0, .num_planes =3D 1, .c= pp =3D { 2, 0, 0 }, .hsub =3D 2, .vsub =3D 1 }, > + { .format =3D DRM_FORMAT_AYUV, .depth =3D 0, .num_planes =3D 1, .c= pp =3D { 4, 0, 0 }, .hsub =3D 1, .vsub =3D 1 }, > + }; > + > + unsigned int i; > + > + for (i =3D 0; i < ARRAY_SIZE(formats); ++i) { > + if (formats[i].format =3D=3D format) > + return &formats[i]; > + } > + > + return NULL; > +} > +EXPORT_SYMBOL(drm_format_info); > + > +/** > * drm_fb_get_bpp_depth - get the bpp/depth values for format > * @format: pixel format (DRM_FORMAT_*) > * @depth: storage for the depth value > 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 > #include > =20 > +/** > + * 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 bit= s) Depth is zero for yuv formats. Maybe that should be made clear here. Tomi --JVIE9UNfphhpFrcUSxOsjCxVxHtp5E5TE-- --aXb4tttPS4QAOvP6s88BpHwlQSCv3FHs2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJX2TlGAAoJEPo9qoy8lh71TBoQAKrEj3x5FDJj5KVfF4wBTp07 0/WULi/3jR+NPRUfC96VBpOv+/yy7MeDGiHZvBQh3gQh6HYdDOMPDGwP1uHCwH6R JkLRh/BWKWtLmdMS7kbbtmmlEI7QD4jo15ru/13QwpOZ60cbrypvk6ya8U3CJo2O wup86K2hUOeTO0ZeWsBsqcjxxOOdZ/fjWcgm7ufZY0dROniuAntRp+kL9y9K8n1W akycHyejxMuGwdC+uLPbmaPIEyylddH0oOW+h7Wcn3WenjLbUD7ULNawwL8NDwnt zXqCHd/Jdymf69pZg0tYEAqHICIR7tZI0b3BU2hU0Cc19bn8BI6/VlNLsshiIhoT V2aUlc3BVGmRHfZ+3nXACJc7xi0bLEitzCwS1vG0OXtxZemuBFVt/CcSnnY46RFp wagOsdPBZC7CJv0fmZss27KFavLod552I9R4AAmPocdpgOEiSw7wUA0hoHQNpBwL UltI31rzJJd4MinrHQ+/mb7NJaXlMW/RRVqbHcXkRK3YGaVLYMYKsCeoMQOtDghz ZRko2oSCY/iLtmGJcSlKpwNnvPp/NWJ5omWIJSxz+pvLNbVlOlSSYw5oFjJhjgE0 de/QJBRQd9C335tuBdZE5jRFz66xWJXExr5cem+v/MEIATX+ahgXWDrd8veQLPu/ IZkaamQRziPCFNpDAsBr =GjVi -----END PGP SIGNATURE----- --aXb4tttPS4QAOvP6s88BpHwlQSCv3FHs2-- --===============1532535101== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1532535101==--