From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomi Valkeinen Subject: Re: [PATCH 1/4] drm: Centralize format information Date: Tue, 7 Jun 2016 12:25:08 +0300 Message-ID: <575692F4.2020800@ti.com> References: <1465255994-317-1-git-send-email-laurent.pinchart@ideasonboard.com> <1465255994-317-2-git-send-email-laurent.pinchart@ideasonboard.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0624076584==" Return-path: Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by gabe.freedesktop.org (Postfix) with ESMTPS id E453B6E6E8 for ; Tue, 7 Jun 2016 09:25:14 +0000 (UTC) In-Reply-To: <1465255994-317-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 --===============0624076584== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ctf4B44tmI9lF0O9bDAuO6NRoBOFR9h8l" --ctf4B44tmI9lF0O9bDAuO6NRoBOFR9h8l Content-Type: multipart/mixed; boundary="4MmUt4j0RiiHB5hliErWBILTpHTTnGUDv" From: Tomi Valkeinen To: Laurent Pinchart , dri-devel@lists.freedesktop.org Cc: Daniel Vetter Message-ID: <575692F4.2020800@ti.com> Subject: Re: [PATCH 1/4] drm: Centralize format information References: <1465255994-317-1-git-send-email-laurent.pinchart@ideasonboard.com> <1465255994-317-2-git-send-email-laurent.pinchart@ideasonboard.com> In-Reply-To: <1465255994-317-2-git-send-email-laurent.pinchart@ideasonboard.com> --4MmUt4j0RiiHB5hliErWBILTpHTTnGUDv Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/06/16 02:33, 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 > --- > drivers/gpu/drm/drm_crtc.c | 83 ++++++++++++++++++++++++++++++++++++++= ++++++++ > include/drm/drm_crtc.h | 21 ++++++++++++ > 2 files changed, 104 insertions(+) >=20 > 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_devic= e *dev, > } > =20 > /** > + * 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 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 { > + { DRM_FORMAT_C8, 8, 8, 1, { 1 }, 1, 1 }, > + { 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 =3D 0; i < ARRAY_SIZE(formats); ++i) { > + if (formats[i].format =3D=3D format) > + return &formats[i]; > + } > + > + return NULL; After looking at the third patch, I wonder if it would make sense to give a warning here if the format was not found. In the third patch many of the helpers will quietly return a valid value for unknown modes. Which is what they do at the moment too, but is there ever a valid reason to do that without something being wrong? Tomi --4MmUt4j0RiiHB5hliErWBILTpHTTnGUDv-- --ctf4B44tmI9lF0O9bDAuO6NRoBOFR9h8l 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 iQIcBAEBCAAGBQJXVpL0AAoJEPo9qoy8lh71OHsQAKWOPVyf1puwm214iMR4LpAt y18GIkyIE36ZvLSe3O2SUfhF0QF5tj30hKABpcd12mEiG27kLock50Tc3gISvdwo MA1l0oMKHsg4IpW7lPG9XLc9hODDMSCwjWwyk2vsWsMuE/3ozaPf2Df5Kv85D4HW GhHUM4KOz8vjHRRiqFOCckzAoTyO7ONMnNcg+NruUhWGFNTzsdFmoieDxXYphgaI /pqq9RQbXc4LQN6YSc0NzEypDWfL5OpofwlZAAFhACP81Ns7pFRAe4WYIg69xsgK snFmqvv85yIQ1Lu3UZqMfHRz0tygdZAATMCoZOo+UIt4w+F6Zn2x2n3+iwF34e4G g/Jp0HJOj5UUR6MsqIH8/W9NGPnwdzChhgMCd8qmSFZ1oOf423i2A77J6ZubZ+68 SKg3GR06ruaAC1LquCqtxqgYZueuYXoyKmYmvoLrk+NeovE7O+lE3J+d95LH25BB xQ41AH+E9Ozgo0yHDF5V0EbuA2WaKF6QPjFIFLMPKvb6fQwsAk8BvdQBEsyLaCDM HEOJE+MFoiZMVSq9uv6ViWr6WRVp/7x4HyxuYR3lx1Gn1VzxZPgn4IrUSvYsRIb6 MMUAyGnxZrqzDTOvgTwyCfeF9kzunyX9/uOeGdL+21/g+BY2QhZ7KuOGk/QuzpEK 8kCyyzm8cLuOa9CBDg5k =U4sU -----END PGP SIGNATURE----- --ctf4B44tmI9lF0O9bDAuO6NRoBOFR9h8l-- --===============0624076584== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0624076584==--