public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: ville.syrjala@linux.intel.com
Cc: intel-gfx@lists.freedesktop.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/9] drm: Add mode_config .get_format_info() hook
Date: Wed, 4 Jan 2017 19:15:34 -0800	[thread overview]
Message-ID: <20170105031533.GA15476@mail.bwidawsk.net> (raw)
In-Reply-To: <20170104184232.23048-2-ville.syrjala@linux.intel.com>

On 17-01-04 20:42:24, Ville Syrjälä wrote:
>From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
>Allow drivers to return a custom drm_format_info structure for special
>fb layouts. We'll use this for the compression control surface in i915.
>
>v2: Fix drm_get_format_info() kernel doc (Laurent)
>    Don't pass 'dev' to the new hook (Laurent)
>
>Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>Cc: Ben Widawsky <ben@bwidawsk.net>
>Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>---
> drivers/gpu/drm/drm_fb_cma_helper.c  |  2 +-
> drivers/gpu/drm/drm_fourcc.c         | 25 +++++++++++++++++++++++++
> drivers/gpu/drm/drm_framebuffer.c    |  9 +++++++--
> drivers/gpu/drm/drm_modeset_helper.c |  2 +-
> include/drm/drm_fourcc.h             |  6 ++++++
> include/drm/drm_mode_config.h        | 14 ++++++++++++++
> 6 files changed, 54 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
>index 20a4011f790d..de3c9fe116fc 100644
>--- a/drivers/gpu/drm/drm_fb_cma_helper.c
>+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
>@@ -177,7 +177,7 @@ struct drm_framebuffer *drm_fb_cma_create_with_funcs(struct drm_device *dev,
> 	int ret;
> 	int i;
>
>-	info = drm_format_info(mode_cmd->pixel_format);
>+	info = drm_get_format_info(dev, mode_cmd);
> 	if (!info)
> 		return ERR_PTR(-EINVAL);
>
>diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
>index 90d2cc8da8eb..f9b6445e846a 100644
>--- a/drivers/gpu/drm/drm_fourcc.c
>+++ b/drivers/gpu/drm/drm_fourcc.c
>@@ -199,6 +199,31 @@ const struct drm_format_info *drm_format_info(u32 format)
> EXPORT_SYMBOL(drm_format_info);
>
> /**
>+ * drm_get_format_info - query information for a given framebuffer configuration
>+ * @dev: DRM device
>+ * @mode_cmd: metadata from the userspace fb creation request
>+ *
>+ * 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_get_format_info(struct drm_device *dev,
>+		    const struct drm_mode_fb_cmd2 *mode_cmd)
>+{
>+	const struct drm_format_info *info = NULL;
>+
>+	if (dev->mode_config.funcs->get_format_info)
>+		info = dev->mode_config.funcs->get_format_info(mode_cmd);
>+
>+	if (!info)
>+		info = drm_format_info(mode_cmd->pixel_format);
>+
>+	return info;
>+}
>+EXPORT_SYMBOL(drm_get_format_info);
>+
>+/**
>  * drm_format_num_planes - get the number of planes for format
>  * @format: pixel format (DRM_FORMAT_*)
>  *
>diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
>index 588ccc3a2218..e276fcdc3a62 100644
>--- a/drivers/gpu/drm/drm_framebuffer.c
>+++ b/drivers/gpu/drm/drm_framebuffer.c
>@@ -126,11 +126,13 @@ int drm_mode_addfb(struct drm_device *dev,
> 	return 0;
> }
>
>-static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
>+static int framebuffer_check(struct drm_device *dev,
>+			     const struct drm_mode_fb_cmd2 *r)
> {
> 	const struct drm_format_info *info;
> 	int i;
>
>+	/* check if the format is supported at all */
> 	info = __drm_format_info(r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN);
> 	if (!info) {
> 		struct drm_format_name_buf format_name;
>@@ -140,6 +142,9 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
> 		return -EINVAL;
> 	}
>
>+	/* now let the driver pick its own format info */
>+	info = drm_get_format_info(dev, r);
>+
> 	if (r->width == 0 || r->width % info->hsub) {
> 		DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
> 		return -EINVAL;
>@@ -263,7 +268,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
> 		return ERR_PTR(-EINVAL);
> 	}
>
>-	ret = framebuffer_check(r);
>+	ret = framebuffer_check(dev, r);
> 	if (ret)
> 		return ERR_PTR(ret);
>
>diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
>index cc44a9a4b004..2b33825f2f93 100644
>--- a/drivers/gpu/drm/drm_modeset_helper.c
>+++ b/drivers/gpu/drm/drm_modeset_helper.c
>@@ -78,7 +78,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
> 	int i;
>
> 	fb->dev = dev;
>-	fb->format = drm_format_info(mode_cmd->pixel_format);
>+	fb->format = drm_get_format_info(dev, mode_cmd);
> 	fb->width = mode_cmd->width;
> 	fb->height = mode_cmd->height;
> 	for (i = 0; i < 4; i++) {
>diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
>index fcc08da850c8..6942e84b6edd 100644
>--- a/include/drm/drm_fourcc.h
>+++ b/include/drm/drm_fourcc.h
>@@ -25,6 +25,9 @@
> #include <linux/types.h>
> #include <uapi/drm/drm_fourcc.h>
>
>+struct drm_device;
>+struct drm_mode_fb_cmd2;
>+
> /**
>  * struct drm_format_info - information about a DRM format
>  * @format: 4CC format identifier (DRM_FORMAT_*)
>@@ -55,6 +58,9 @@ struct drm_format_name_buf {
>
> const struct drm_format_info *__drm_format_info(u32 format);
> const struct drm_format_info *drm_format_info(u32 format);
>+const struct drm_format_info *
>+drm_get_format_info(struct drm_device *dev,
>+		    const struct drm_mode_fb_cmd2 *mode_cmd);
> uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
> int drm_format_num_planes(uint32_t format);
> int drm_format_plane_cpp(uint32_t format, int plane);
>diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
>index 17942c0f32a8..b5c2eb825965 100644
>--- a/include/drm/drm_mode_config.h
>+++ b/include/drm/drm_mode_config.h
>@@ -34,6 +34,7 @@ struct drm_file;
> struct drm_device;
> struct drm_atomic_state;
> struct drm_mode_fb_cmd2;
>+struct drm_format_info;
>
> /**
>  * struct drm_mode_config_funcs - basic driver provided mode setting functions
>@@ -70,6 +71,19 @@ struct drm_mode_config_funcs {
> 					     const struct drm_mode_fb_cmd2 *mode_cmd);
>
> 	/**
>+	 * @get_format_info:
>+	 *
>+	 * Allows a driver to return custom format information for special
>+	 * fb layouts (eg. ones with auxiliary compresssion control planes).

compression

>+	 *
>+	 * RETURNS:
>+	 *
>+	 * The format information specific to the given fb metadata, or
>+	 * NULL if none is found.
>+	 */
>+	const struct drm_format_info *(*get_format_info)(const struct drm_mode_fb_cmd2 *mode_cmd);
>+
>+	/**
> 	 * @output_poll_changed:
> 	 *
> 	 * Callback used by helpers to inform the driver of output configuration

Looks like msm and omap could use this too, and then if you allowed mode_cmd
to be NULL, you could potentially deprecate drm_format_info. Just a thought.

LGTM:
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>

>-- 
>2.10.2
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-01-05  3:15 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-04 18:42 [PATCH 0/9] drm/i915: SKL+ render decompression support ville.syrjala
2017-01-04 18:42 ` [PATCH 1/9] drm: Add mode_config .get_format_info() hook ville.syrjala
2017-01-05  3:15   ` Ben Widawsky [this message]
2017-01-05  8:48     ` Daniel Vetter
2017-01-04 18:42 ` [PATCH 2/9] drm/i915: Plumb drm_framebuffer into more places ville.syrjala
2017-02-02 13:30   ` [Intel-gfx] " Imre Deak
2017-01-04 18:42 ` [PATCH 3/9] drm/i915: Move nv12 chroma plane handling into intel_surf_alignment() ville.syrjala
2017-02-02 13:34   ` Imre Deak
2017-01-04 18:42 ` [PATCH 4/9] drm/i915: Avoid div-by-zero when computing aux_stride w/o an aux plane ville.syrjala
2017-02-02 13:38   ` Imre Deak
2017-01-04 18:42 ` [PATCH 5/9] drm/i915: Fix Yf tile width ville.syrjala
2017-02-02 15:07   ` Imre Deak
2017-01-04 18:42 ` [PATCH 6/9] drm/i915: Pass the correct plane index to _intel_compute_tile_offset() ville.syrjala
2017-02-02 16:10   ` Imre Deak
2017-01-04 18:42 ` [PATCH 7/9] drm/i915: Use DRM_DEBUG_KMS() for framebuffer failure debug messages ville.syrjala
2017-02-02 16:19   ` Imre Deak
2017-01-04 18:42 ` [PATCH 8/9] drm/i915: Implement .get_format_info() hook for CCS ville.syrjala
2017-01-05 16:24   ` Tvrtko Ursulin
2017-01-05 17:40     ` Ben Widawsky
2017-02-26 22:41   ` Chad Versace
2017-02-27 15:13     ` [Intel-gfx] " Ville Syrjälä
2017-02-28  5:36       ` Ben Widawsky
2017-01-04 18:42 ` [PATCH 9/9] drm/i915: Add render decompression support ville.syrjala
2017-01-04 19:14   ` Paulo Zanoni
2017-01-05 15:12     ` Ville Syrjälä
2017-01-05  4:25   ` Ben Widawsky
2017-01-05 15:11     ` Ville Syrjälä
2017-01-05 15:14   ` [PATCH v2 " ville.syrjala
2017-01-09 19:20     ` Jason Ekstrand
2017-01-10 17:04       ` Ville Syrjälä
2017-01-11 21:49         ` Jason Ekstrand
2017-01-11 22:29           ` Jason Ekstrand
2017-02-07 15:37     ` Imre Deak
2017-02-13 17:13       ` Ville Syrjälä
2017-02-28 20:18     ` Jason Ekstrand
2017-02-28 21:00       ` Ben Widawsky
2017-02-28 23:20       ` Ben Widawsky
2017-03-01 10:51         ` Ville Syrjälä
2017-03-01 17:50           ` Ben Widawsky
2017-03-01 18:00             ` Ville Syrjälä
2017-01-04 19:45 ` ✓ Fi.CI.BAT: success for drm/i915: SKL+ " Patchwork
2017-01-05 15:54 ` ✗ Fi.CI.BAT: failure for drm/i915: SKL+ render decompression support (rev2) Patchwork
2017-01-06 23:41 ` [PATCH 0/9] drm/i915: SKL+ render decompression support Ben Widawsky
2017-01-10 19:23 ` ✓ Fi.CI.BAT: success for drm/i915: SKL+ render decompression support (rev2) Patchwork

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=20170105031533.GA15476@mail.bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.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