From: Daniel Vetter <daniel@ffwll.ch>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 01/15] drm: Move format-related helpers to drm_fourcc.c
Date: Thu, 9 Jun 2016 10:36:18 +0200 [thread overview]
Message-ID: <20160609083618.GL3363@phenom.ffwll.local> (raw)
In-Reply-To: <1465428739-26529-2-git-send-email-laurent.pinchart@ideasonboard.com>
On Thu, Jun 09, 2016 at 02:32:05AM +0300, Laurent Pinchart wrote:
> The drm_crtc.c file is a mess, making the ABI documentation confusing
> since all functions are in the same bag. Split the format-related
> helpers to a new drm_fourcc.c file.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> Documentation/DocBook/gpu.tmpl | 5 +
> drivers/gpu/drm/Makefile | 2 +-
> drivers/gpu/drm/drm_crtc.c | 289 -------------------------------------
> drivers/gpu/drm/drm_fourcc.c | 320 +++++++++++++++++++++++++++++++++++++++++
> include/drm/drmP.h | 1 +
> include/drm/drm_crtc.h | 9 --
> include/drm/drm_fourcc.h | 37 +++++
> 7 files changed, 364 insertions(+), 299 deletions(-)
> create mode 100644 drivers/gpu/drm/drm_fourcc.c
> create mode 100644 include/drm/drm_fourcc.h
>
> diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl
> index 7586bf75f62e..d32363cb1ff1 100644
> --- a/Documentation/DocBook/gpu.tmpl
> +++ b/Documentation/DocBook/gpu.tmpl
> @@ -1656,6 +1656,11 @@ void intel_crt_init(struct drm_device *dev)
> !Edrivers/gpu/drm/drm_rect.c
> </sect2>
> <sect2>
> + <title>Formats Utilities Reference</title>
> +!Iinclude/drm/drm_fourcc.h
> +!Edrivers/gpu/drm/drm_fourcc.c
Not sure this is correct in the helper section of KMS. drm_fourcc is part
of the uabi, including all the metadata definitions. Please move one
section up, and resend just this patch so I can merge it (to avoid
needless conflicts and rebase pain).
-Daniel
> + </sect2>
> + <sect2>
> <title>Flip-work Helper Reference</title>
> !Pinclude/drm/drm_flip_work.h flip utils
> !Iinclude/drm/drm_flip_work.h
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index be43afb08c69..aa24af35c068 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -8,7 +8,7 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \
> drm_lock.o drm_memory.o drm_drv.o drm_vm.o \
> drm_scatter.o drm_pci.o \
> drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \
> - drm_crtc.o drm_modes.o drm_edid.o \
> + drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \
> drm_info.o drm_debugfs.o drm_encoder_slave.o \
> drm_trace_points.o drm_global.o drm_prime.o \
> drm_rect.o drm_vma_manager.o drm_flip_work.o \
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 0e3cc66aa8b7..e5369529af06 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -239,37 +239,6 @@ const char *drm_get_subpixel_order_name(enum subpixel_order order)
> }
> EXPORT_SYMBOL(drm_get_subpixel_order_name);
>
> -static char printable_char(int c)
> -{
> - return isascii(c) && isprint(c) ? c : '?';
> -}
> -
> -/**
> - * drm_get_format_name - return a string for drm fourcc format
> - * @format: format to compute name of
> - *
> - * Note that the buffer used by this function is globally shared and owned by
> - * the function itself.
> - *
> - * FIXME: This isn't really multithreading safe.
> - */
> -const char *drm_get_format_name(uint32_t format)
> -{
> - static char buf[32];
> -
> - snprintf(buf, sizeof(buf),
> - "%c%c%c%c %s-endian (0x%08x)",
> - printable_char(format & 0xff),
> - printable_char((format >> 8) & 0xff),
> - printable_char((format >> 16) & 0xff),
> - printable_char((format >> 24) & 0x7f),
> - format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
> - format);
> -
> - return buf;
> -}
> -EXPORT_SYMBOL(drm_get_format_name);
> -
> /*
> * Internal function to assign a slot in the object idr and optionally
> * register the object into the idr.
> @@ -5544,264 +5513,6 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
> }
>
> /**
> - * drm_fb_get_bpp_depth - get the bpp/depth values for format
> - * @format: pixel format (DRM_FORMAT_*)
> - * @depth: storage for the depth value
> - * @bpp: storage for the bpp value
> - *
> - * This only supports RGB formats here for compat with code that doesn't use
> - * pixel formats directly yet.
> - */
> -void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
> - int *bpp)
> -{
> - switch (format) {
> - case DRM_FORMAT_C8:
> - case DRM_FORMAT_RGB332:
> - case DRM_FORMAT_BGR233:
> - *depth = 8;
> - *bpp = 8;
> - break;
> - case DRM_FORMAT_XRGB1555:
> - case DRM_FORMAT_XBGR1555:
> - case DRM_FORMAT_RGBX5551:
> - case DRM_FORMAT_BGRX5551:
> - case DRM_FORMAT_ARGB1555:
> - case DRM_FORMAT_ABGR1555:
> - case DRM_FORMAT_RGBA5551:
> - case DRM_FORMAT_BGRA5551:
> - *depth = 15;
> - *bpp = 16;
> - break;
> - case DRM_FORMAT_RGB565:
> - case DRM_FORMAT_BGR565:
> - *depth = 16;
> - *bpp = 16;
> - break;
> - case DRM_FORMAT_RGB888:
> - case DRM_FORMAT_BGR888:
> - *depth = 24;
> - *bpp = 24;
> - break;
> - case DRM_FORMAT_XRGB8888:
> - case DRM_FORMAT_XBGR8888:
> - case DRM_FORMAT_RGBX8888:
> - case DRM_FORMAT_BGRX8888:
> - *depth = 24;
> - *bpp = 32;
> - break;
> - case DRM_FORMAT_XRGB2101010:
> - case DRM_FORMAT_XBGR2101010:
> - case DRM_FORMAT_RGBX1010102:
> - case DRM_FORMAT_BGRX1010102:
> - case DRM_FORMAT_ARGB2101010:
> - case DRM_FORMAT_ABGR2101010:
> - case DRM_FORMAT_RGBA1010102:
> - case DRM_FORMAT_BGRA1010102:
> - *depth = 30;
> - *bpp = 32;
> - break;
> - case DRM_FORMAT_ARGB8888:
> - case DRM_FORMAT_ABGR8888:
> - case DRM_FORMAT_RGBA8888:
> - case DRM_FORMAT_BGRA8888:
> - *depth = 32;
> - *bpp = 32;
> - break;
> - default:
> - DRM_DEBUG_KMS("unsupported pixel format %s\n",
> - drm_get_format_name(format));
> - *depth = 0;
> - *bpp = 0;
> - break;
> - }
> -}
> -EXPORT_SYMBOL(drm_fb_get_bpp_depth);
> -
> -/**
> - * drm_format_num_planes - get the number of planes for format
> - * @format: pixel format (DRM_FORMAT_*)
> - *
> - * Returns:
> - * The number of planes used by the specified pixel format.
> - */
> -int drm_format_num_planes(uint32_t format)
> -{
> - switch (format) {
> - case DRM_FORMAT_YUV410:
> - case DRM_FORMAT_YVU410:
> - case DRM_FORMAT_YUV411:
> - case DRM_FORMAT_YVU411:
> - case DRM_FORMAT_YUV420:
> - case DRM_FORMAT_YVU420:
> - case DRM_FORMAT_YUV422:
> - case DRM_FORMAT_YVU422:
> - case DRM_FORMAT_YUV444:
> - case DRM_FORMAT_YVU444:
> - return 3;
> - case DRM_FORMAT_NV12:
> - case DRM_FORMAT_NV21:
> - case DRM_FORMAT_NV16:
> - case DRM_FORMAT_NV61:
> - case DRM_FORMAT_NV24:
> - case DRM_FORMAT_NV42:
> - return 2;
> - default:
> - return 1;
> - }
> -}
> -EXPORT_SYMBOL(drm_format_num_planes);
> -
> -/**
> - * drm_format_plane_cpp - determine the bytes per pixel value
> - * @format: pixel format (DRM_FORMAT_*)
> - * @plane: plane index
> - *
> - * Returns:
> - * The bytes per pixel value for the specified plane.
> - */
> -int drm_format_plane_cpp(uint32_t format, int plane)
> -{
> - unsigned int depth;
> - int bpp;
> -
> - if (plane >= drm_format_num_planes(format))
> - return 0;
> -
> - switch (format) {
> - case DRM_FORMAT_YUYV:
> - case DRM_FORMAT_YVYU:
> - case DRM_FORMAT_UYVY:
> - case DRM_FORMAT_VYUY:
> - return 2;
> - case DRM_FORMAT_NV12:
> - case DRM_FORMAT_NV21:
> - case DRM_FORMAT_NV16:
> - case DRM_FORMAT_NV61:
> - case DRM_FORMAT_NV24:
> - case DRM_FORMAT_NV42:
> - return plane ? 2 : 1;
> - case DRM_FORMAT_YUV410:
> - case DRM_FORMAT_YVU410:
> - case DRM_FORMAT_YUV411:
> - case DRM_FORMAT_YVU411:
> - case DRM_FORMAT_YUV420:
> - case DRM_FORMAT_YVU420:
> - case DRM_FORMAT_YUV422:
> - case DRM_FORMAT_YVU422:
> - case DRM_FORMAT_YUV444:
> - case DRM_FORMAT_YVU444:
> - return 1;
> - default:
> - drm_fb_get_bpp_depth(format, &depth, &bpp);
> - return bpp >> 3;
> - }
> -}
> -EXPORT_SYMBOL(drm_format_plane_cpp);
> -
> -/**
> - * drm_format_horz_chroma_subsampling - get the horizontal chroma subsampling factor
> - * @format: pixel format (DRM_FORMAT_*)
> - *
> - * Returns:
> - * The horizontal chroma subsampling factor for the
> - * specified pixel format.
> - */
> -int drm_format_horz_chroma_subsampling(uint32_t format)
> -{
> - switch (format) {
> - case DRM_FORMAT_YUV411:
> - case DRM_FORMAT_YVU411:
> - case DRM_FORMAT_YUV410:
> - case DRM_FORMAT_YVU410:
> - return 4;
> - case DRM_FORMAT_YUYV:
> - case DRM_FORMAT_YVYU:
> - case DRM_FORMAT_UYVY:
> - case DRM_FORMAT_VYUY:
> - case DRM_FORMAT_NV12:
> - case DRM_FORMAT_NV21:
> - case DRM_FORMAT_NV16:
> - case DRM_FORMAT_NV61:
> - case DRM_FORMAT_YUV422:
> - case DRM_FORMAT_YVU422:
> - case DRM_FORMAT_YUV420:
> - case DRM_FORMAT_YVU420:
> - return 2;
> - default:
> - return 1;
> - }
> -}
> -EXPORT_SYMBOL(drm_format_horz_chroma_subsampling);
> -
> -/**
> - * drm_format_vert_chroma_subsampling - get the vertical chroma subsampling factor
> - * @format: pixel format (DRM_FORMAT_*)
> - *
> - * Returns:
> - * The vertical chroma subsampling factor for the
> - * specified pixel format.
> - */
> -int drm_format_vert_chroma_subsampling(uint32_t format)
> -{
> - switch (format) {
> - case DRM_FORMAT_YUV410:
> - case DRM_FORMAT_YVU410:
> - return 4;
> - case DRM_FORMAT_YUV420:
> - case DRM_FORMAT_YVU420:
> - case DRM_FORMAT_NV12:
> - case DRM_FORMAT_NV21:
> - return 2;
> - default:
> - return 1;
> - }
> -}
> -EXPORT_SYMBOL(drm_format_vert_chroma_subsampling);
> -
> -/**
> - * drm_format_plane_width - width of the plane given the first plane
> - * @width: width of the first plane
> - * @format: pixel format
> - * @plane: plane index
> - *
> - * Returns:
> - * The width of @plane, given that the width of the first plane is @width.
> - */
> -int drm_format_plane_width(int width, uint32_t format, int plane)
> -{
> - if (plane >= drm_format_num_planes(format))
> - return 0;
> -
> - if (plane == 0)
> - return width;
> -
> - return width / drm_format_horz_chroma_subsampling(format);
> -}
> -EXPORT_SYMBOL(drm_format_plane_width);
> -
> -/**
> - * drm_format_plane_height - height of the plane given the first plane
> - * @height: height of the first plane
> - * @format: pixel format
> - * @plane: plane index
> - *
> - * Returns:
> - * The height of @plane, given that the height of the first plane is @height.
> - */
> -int drm_format_plane_height(int height, uint32_t format, int plane)
> -{
> - if (plane >= drm_format_num_planes(format))
> - return 0;
> -
> - if (plane == 0)
> - return height;
> -
> - return height / drm_format_vert_chroma_subsampling(format);
> -}
> -EXPORT_SYMBOL(drm_format_plane_height);
> -
> -/**
> * drm_rotation_simplify() - Try to simplify the rotation
> * @rotation: Rotation to be simplified
> * @supported_rotations: Supported rotations
> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> new file mode 100644
> index 000000000000..0645c85d5f95
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_fourcc.c
> @@ -0,0 +1,320 @@
> +/*
> + * Copyright (c) 2016 Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> + *
> + * DRM core format related functions
> + *
> + * Permission to use, copy, modify, distribute, and sell this software and its
> + * documentation for any purpose is hereby granted without fee, provided that
> + * the above copyright notice appear in all copies and that both that copyright
> + * notice and this permission notice appear in supporting documentation, and
> + * that the name of the copyright holders not be used in advertising or
> + * publicity pertaining to distribution of the software without specific,
> + * written prior permission. The copyright holders make no representations
> + * about the suitability of this software for any purpose. It is provided "as
> + * is" without express or implied warranty.
> + *
> + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
> + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
> + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
> + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
> + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
> + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
> + * OF THIS SOFTWARE.
> + */
> +
> +#include <linux/bug.h>
> +#include <linux/ctype.h>
> +#include <linux/export.h>
> +#include <linux/kernel.h>
> +
> +#include <drm/drmP.h>
> +#include <drm/drm_fourcc.h>
> +
> +static char printable_char(int c)
> +{
> + return isascii(c) && isprint(c) ? c : '?';
> +}
> +
> +/**
> + * drm_get_format_name - return a string for drm fourcc format
> + * @format: format to compute name of
> + *
> + * Note that the buffer used by this function is globally shared and owned by
> + * the function itself.
> + *
> + * FIXME: This isn't really multithreading safe.
> + */
> +const char *drm_get_format_name(uint32_t format)
> +{
> + static char buf[32];
> +
> + snprintf(buf, sizeof(buf),
> + "%c%c%c%c %s-endian (0x%08x)",
> + printable_char(format & 0xff),
> + printable_char((format >> 8) & 0xff),
> + printable_char((format >> 16) & 0xff),
> + printable_char((format >> 24) & 0x7f),
> + format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
> + format);
> +
> + return buf;
> +}
> +EXPORT_SYMBOL(drm_get_format_name);
> +
> +/**
> + * drm_fb_get_bpp_depth - get the bpp/depth values for format
> + * @format: pixel format (DRM_FORMAT_*)
> + * @depth: storage for the depth value
> + * @bpp: storage for the bpp value
> + *
> + * This only supports RGB formats here for compat with code that doesn't use
> + * pixel formats directly yet.
> + */
> +void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
> + int *bpp)
> +{
> + switch (format) {
> + case DRM_FORMAT_C8:
> + case DRM_FORMAT_RGB332:
> + case DRM_FORMAT_BGR233:
> + *depth = 8;
> + *bpp = 8;
> + break;
> + case DRM_FORMAT_XRGB1555:
> + case DRM_FORMAT_XBGR1555:
> + case DRM_FORMAT_RGBX5551:
> + case DRM_FORMAT_BGRX5551:
> + case DRM_FORMAT_ARGB1555:
> + case DRM_FORMAT_ABGR1555:
> + case DRM_FORMAT_RGBA5551:
> + case DRM_FORMAT_BGRA5551:
> + *depth = 15;
> + *bpp = 16;
> + break;
> + case DRM_FORMAT_RGB565:
> + case DRM_FORMAT_BGR565:
> + *depth = 16;
> + *bpp = 16;
> + break;
> + case DRM_FORMAT_RGB888:
> + case DRM_FORMAT_BGR888:
> + *depth = 24;
> + *bpp = 24;
> + break;
> + case DRM_FORMAT_XRGB8888:
> + case DRM_FORMAT_XBGR8888:
> + case DRM_FORMAT_RGBX8888:
> + case DRM_FORMAT_BGRX8888:
> + *depth = 24;
> + *bpp = 32;
> + break;
> + case DRM_FORMAT_XRGB2101010:
> + case DRM_FORMAT_XBGR2101010:
> + case DRM_FORMAT_RGBX1010102:
> + case DRM_FORMAT_BGRX1010102:
> + case DRM_FORMAT_ARGB2101010:
> + case DRM_FORMAT_ABGR2101010:
> + case DRM_FORMAT_RGBA1010102:
> + case DRM_FORMAT_BGRA1010102:
> + *depth = 30;
> + *bpp = 32;
> + break;
> + case DRM_FORMAT_ARGB8888:
> + case DRM_FORMAT_ABGR8888:
> + case DRM_FORMAT_RGBA8888:
> + case DRM_FORMAT_BGRA8888:
> + *depth = 32;
> + *bpp = 32;
> + break;
> + default:
> + DRM_DEBUG_KMS("unsupported pixel format %s\n",
> + drm_get_format_name(format));
> + *depth = 0;
> + *bpp = 0;
> + break;
> + }
> +}
> +EXPORT_SYMBOL(drm_fb_get_bpp_depth);
> +
> +/**
> + * drm_format_num_planes - get the number of planes for format
> + * @format: pixel format (DRM_FORMAT_*)
> + *
> + * Returns:
> + * The number of planes used by the specified pixel format.
> + */
> +int drm_format_num_planes(uint32_t format)
> +{
> + switch (format) {
> + case DRM_FORMAT_YUV410:
> + case DRM_FORMAT_YVU410:
> + case DRM_FORMAT_YUV411:
> + case DRM_FORMAT_YVU411:
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_YVU420:
> + case DRM_FORMAT_YUV422:
> + case DRM_FORMAT_YVU422:
> + case DRM_FORMAT_YUV444:
> + case DRM_FORMAT_YVU444:
> + return 3;
> + case DRM_FORMAT_NV12:
> + case DRM_FORMAT_NV21:
> + case DRM_FORMAT_NV16:
> + case DRM_FORMAT_NV61:
> + case DRM_FORMAT_NV24:
> + case DRM_FORMAT_NV42:
> + return 2;
> + default:
> + return 1;
> + }
> +}
> +EXPORT_SYMBOL(drm_format_num_planes);
> +
> +/**
> + * drm_format_plane_cpp - determine the bytes per pixel value
> + * @format: pixel format (DRM_FORMAT_*)
> + * @plane: plane index
> + *
> + * Returns:
> + * The bytes per pixel value for the specified plane.
> + */
> +int drm_format_plane_cpp(uint32_t format, int plane)
> +{
> + unsigned int depth;
> + int bpp;
> +
> + if (plane >= drm_format_num_planes(format))
> + return 0;
> +
> + switch (format) {
> + case DRM_FORMAT_YUYV:
> + case DRM_FORMAT_YVYU:
> + case DRM_FORMAT_UYVY:
> + case DRM_FORMAT_VYUY:
> + return 2;
> + case DRM_FORMAT_NV12:
> + case DRM_FORMAT_NV21:
> + case DRM_FORMAT_NV16:
> + case DRM_FORMAT_NV61:
> + case DRM_FORMAT_NV24:
> + case DRM_FORMAT_NV42:
> + return plane ? 2 : 1;
> + case DRM_FORMAT_YUV410:
> + case DRM_FORMAT_YVU410:
> + case DRM_FORMAT_YUV411:
> + case DRM_FORMAT_YVU411:
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_YVU420:
> + case DRM_FORMAT_YUV422:
> + case DRM_FORMAT_YVU422:
> + case DRM_FORMAT_YUV444:
> + case DRM_FORMAT_YVU444:
> + return 1;
> + default:
> + drm_fb_get_bpp_depth(format, &depth, &bpp);
> + return bpp >> 3;
> + }
> +}
> +EXPORT_SYMBOL(drm_format_plane_cpp);
> +
> +/**
> + * drm_format_horz_chroma_subsampling - get the horizontal chroma subsampling factor
> + * @format: pixel format (DRM_FORMAT_*)
> + *
> + * Returns:
> + * The horizontal chroma subsampling factor for the
> + * specified pixel format.
> + */
> +int drm_format_horz_chroma_subsampling(uint32_t format)
> +{
> + switch (format) {
> + case DRM_FORMAT_YUV411:
> + case DRM_FORMAT_YVU411:
> + case DRM_FORMAT_YUV410:
> + case DRM_FORMAT_YVU410:
> + return 4;
> + case DRM_FORMAT_YUYV:
> + case DRM_FORMAT_YVYU:
> + case DRM_FORMAT_UYVY:
> + case DRM_FORMAT_VYUY:
> + case DRM_FORMAT_NV12:
> + case DRM_FORMAT_NV21:
> + case DRM_FORMAT_NV16:
> + case DRM_FORMAT_NV61:
> + case DRM_FORMAT_YUV422:
> + case DRM_FORMAT_YVU422:
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_YVU420:
> + return 2;
> + default:
> + return 1;
> + }
> +}
> +EXPORT_SYMBOL(drm_format_horz_chroma_subsampling);
> +
> +/**
> + * drm_format_vert_chroma_subsampling - get the vertical chroma subsampling factor
> + * @format: pixel format (DRM_FORMAT_*)
> + *
> + * Returns:
> + * The vertical chroma subsampling factor for the
> + * specified pixel format.
> + */
> +int drm_format_vert_chroma_subsampling(uint32_t format)
> +{
> + switch (format) {
> + case DRM_FORMAT_YUV410:
> + case DRM_FORMAT_YVU410:
> + return 4;
> + case DRM_FORMAT_YUV420:
> + case DRM_FORMAT_YVU420:
> + case DRM_FORMAT_NV12:
> + case DRM_FORMAT_NV21:
> + return 2;
> + default:
> + return 1;
> + }
> +}
> +EXPORT_SYMBOL(drm_format_vert_chroma_subsampling);
> +
> +/**
> + * drm_format_plane_width - width of the plane given the first plane
> + * @width: width of the first plane
> + * @format: pixel format
> + * @plane: plane index
> + *
> + * Returns:
> + * The width of @plane, given that the width of the first plane is @width.
> + */
> +int drm_format_plane_width(int width, uint32_t format, int plane)
> +{
> + if (plane >= drm_format_num_planes(format))
> + return 0;
> +
> + if (plane == 0)
> + return width;
> +
> + return width / drm_format_horz_chroma_subsampling(format);
> +}
> +EXPORT_SYMBOL(drm_format_plane_width);
> +
> +/**
> + * drm_format_plane_height - height of the plane given the first plane
> + * @height: height of the first plane
> + * @format: pixel format
> + * @plane: plane index
> + *
> + * Returns:
> + * The height of @plane, given that the height of the first plane is @height.
> + */
> +int drm_format_plane_height(int height, uint32_t format, int plane)
> +{
> + if (plane >= drm_format_num_planes(format))
> + return 0;
> +
> + if (plane == 0)
> + return height;
> +
> + return height / drm_format_vert_chroma_subsampling(format);
> +}
> +EXPORT_SYMBOL(drm_format_plane_height);
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 84f1a8eefbdb..c8879057084e 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -66,6 +66,7 @@
>
> #include <drm/drm_agpsupport.h>
> #include <drm/drm_crtc.h>
> +#include <drm/drm_fourcc.h>
> #include <drm/drm_global.h>
> #include <drm/drm_hashtab.h>
> #include <drm/drm_mem_util.h>
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index d1559cd04e3d..1b80c0268d8f 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -2540,15 +2540,6 @@ extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
> extern int drm_mode_atomic_ioctl(struct drm_device *dev,
> void *data, struct drm_file *file_priv);
>
> -extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
> - int *bpp);
> -extern int drm_format_num_planes(uint32_t format);
> -extern int drm_format_plane_cpp(uint32_t format, int plane);
> -extern int drm_format_horz_chroma_subsampling(uint32_t format);
> -extern int drm_format_vert_chroma_subsampling(uint32_t format);
> -extern int drm_format_plane_width(int width, uint32_t format, int plane);
> -extern int drm_format_plane_height(int height, uint32_t format, int plane);
> -extern const char *drm_get_format_name(uint32_t format);
> extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
> unsigned int supported_rotations);
> extern unsigned int drm_rotation_simplify(unsigned int rotation,
> diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> new file mode 100644
> index 000000000000..7f90a396cf2b
> --- /dev/null
> +++ b/include/drm/drm_fourcc.h
> @@ -0,0 +1,37 @@
> +/*
> + * Copyright (c) 2016 Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> + *
> + * Permission to use, copy, modify, distribute, and sell this software and its
> + * documentation for any purpose is hereby granted without fee, provided that
> + * the above copyright notice appear in all copies and that both that copyright
> + * notice and this permission notice appear in supporting documentation, and
> + * that the name of the copyright holders not be used in advertising or
> + * publicity pertaining to distribution of the software without specific,
> + * written prior permission. The copyright holders make no representations
> + * about the suitability of this software for any purpose. It is provided "as
> + * is" without express or implied warranty.
> + *
> + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
> + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
> + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
> + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
> + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
> + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
> + * OF THIS SOFTWARE.
> + */
> +#ifndef __DRM_FOURCC_H__
> +#define __DRM_FOURCC_H__
> +
> +#include <linux/types.h>
> +#include <uapi/drm/drm_fourcc.h>
> +
> +void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth, int *bpp);
> +int drm_format_num_planes(uint32_t format);
> +int drm_format_plane_cpp(uint32_t format, int plane);
> +int drm_format_horz_chroma_subsampling(uint32_t format);
> +int drm_format_vert_chroma_subsampling(uint32_t format);
> +int drm_format_plane_width(int width, uint32_t format, int plane);
> +int drm_format_plane_height(int height, uint32_t format, int plane);
> +const char *drm_get_format_name(uint32_t format);
> +
> +#endif /* __DRM_FOURCC_H__ */
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
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-09 8:36 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 23:32 [PATCH v3 00/15] Centralize format information Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 01/15] drm: Move format-related helpers to drm_fourcc.c Laurent Pinchart
2016-06-09 8:36 ` Daniel Vetter [this message]
2016-06-09 9:54 ` [PATCH v3.1 " Laurent Pinchart
2016-06-09 10:03 ` Daniel Vetter
2016-06-08 23:32 ` [PATCH v3 02/15] drm: Centralize format information Laurent Pinchart
2016-06-09 8:52 ` Daniel Vetter
2016-06-09 12:23 ` Ville Syrjälä
2016-06-09 12:40 ` Daniel Vetter
2016-06-09 13:05 ` Ville Syrjälä
2016-06-09 13:29 ` Daniel Vetter
2016-06-09 14:13 ` Ville Syrjälä
2016-09-08 13:49 ` Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 03/15] drm: Implement the drm_format_*() helpers as drm_format_info() wrappers Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 04/15] drm: Use drm_format_info() in DRM core code Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 05/15] drm: WARN when calling drm_format_info() for an unsupported format Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 06/15] drm: msm: Replace drm_fb_get_bpp_depth() with drm_format_plane_cpp() Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 07/15] drm: sti: " Laurent Pinchart
2016-06-09 7:52 ` Vincent ABRIOU
2016-06-09 9:17 ` Laurent Pinchart
2016-06-09 12:10 ` Vincent ABRIOU
2016-06-08 23:32 ` [PATCH v3 08/15] drm: hdlcd: " Laurent Pinchart
2016-06-09 9:01 ` Liviu Dudau
2016-07-25 11:10 ` Liviu Dudau
2016-09-08 14:45 ` Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 09/15] drm: tilcdc: " Laurent Pinchart
2016-06-10 11:51 ` Tomi Valkeinen
2016-06-10 12:05 ` Ville Syrjälä
2016-06-10 12:08 ` Tomi Valkeinen
2016-06-10 12:23 ` Ville Syrjälä
2016-06-10 12:26 ` Tomi Valkeinen
2016-06-10 12:29 ` Ville Syrjälä
2016-06-10 12:48 ` Tomi Valkeinen
2016-06-10 13:08 ` Tomi Valkeinen
2016-06-10 13:16 ` Jyri Sarha
2016-06-10 13:25 ` Ville Syrjälä
2016-06-10 14:21 ` Daniel Vetter
2016-06-10 12:07 ` Laurent Pinchart
2016-06-10 12:08 ` [PATCH v3.1 " Laurent Pinchart
2016-06-10 12:21 ` Tomi Valkeinen
2016-06-08 23:32 ` [PATCH v3 10/15] drm: cirrus: " Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 11/15] drm: gma500: Replace drm_fb_get_bpp_depth() with drm_format_info() Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 12/15] drm: amdgpu: Replace drm_fb_get_bpp_depth() with drm_format_plane_cpp() Laurent Pinchart
2016-06-09 1:42 ` Michel Dänzer
2016-06-09 9:18 ` Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 13/15] drm: radeon: " Laurent Pinchart
2016-06-08 23:32 ` [PATCH v3 14/15] drm: vmwgfx: Replace drm_fb_get_bpp_depth() with drm_format_info() Laurent Pinchart
2016-06-27 17:51 ` Sinclair Yeh
2016-06-08 23:32 ` [PATCH v3 15/15] drm: Don't export the drm_fb_get_bpp_depth() function Laurent Pinchart
-- strict thread matches above, loose matches on Subject: below --
2016-06-08 23:30 [PATCH v3 00/15] Centralize format information Laurent Pinchart
2016-06-08 23:30 ` [PATCH v3 01/15] drm: Move format-related helpers to drm_fourcc.c 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=20160609083618.GL3363@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=tomi.valkeinen@ti.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.