<div dir="ltr"><div>FYI:  The latest version of the CCS modifier patches for mesa are now reviewed:<br><br><a href="https://patchwork.freedesktop.org/series/27213/">https://patchwork.freedesktop.org/series/27213/</a><br><br></div>I'll be landing the prep-work patches soon.  The final couple of patches are just waiting on the I915_FORMAT_MOD_Y_TILED_CCS in drm_fourcc.h to land in the kernel.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 9, 2017 at 11:53 PM, Vidya Srinivas <span dir="ltr"><<a href="mailto:vidya.srinivas@intel.com" target="_blank">vidya.srinivas@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Ville Syrjälä <<a href="mailto:ville.syrjala@linux.intel.com">ville.syrjala@linux.intel.com</a><wbr>><br>
<br>
SKL+ display engine can scan out certain kinds of compressed surfaces<br>
produced by the render engine. This involved telling the display engine<br>
the location of the color control surfae (CCS) which describes which<br>
parts of the main surface are compressed and which are not. The location<br>
of CCS is provided by userspace as just another plane with its own offset.<br>
<br>
By providing our own format information for the CCS formats, we should<br>
be able to make framebuffer_check() do the right thing for the CCS<br>
surface as well.<br>
<br>
Note that we'll return the same format info for both Y and Yf tiled<br>
format as that's what happens with the non-CCS Y vs. Yf as well. If<br>
desired, we could potentially return a unique pointer for each<br>
pixel_format+tiling+ccs combination, in which case we immediately be<br>
able to tell if any of that stuff changed by just comparing the<br>
pointers. But that does sound a bit wasteful space wise.<br>
<br>
v2: Drop the 'dev' argument from the hook<br>
        v3: Include the description of the CCS surface layout<br>
v4: Pretend CCS tiles are regular 128 byte wide Y tiles (Jason)<br>
<br>
Cc: Daniel Vetter <<a href="mailto:daniel@ffwll.ch">daniel@ffwll.ch</a>><br>
Cc: Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>><br>
Cc: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
Reviewed-by: Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>> (v3)<br>
Signed-off-by: Ville Syrjä <<a href="mailto:ville.syrjala@linux.intel.com">ville.syrjala@linux.intel.com</a><wbr>><br>
---<br>
 drivers/gpu/drm/drm_fourcc.c         |  2 +-<br>
 drivers/gpu/drm/i915/intel_<wbr>display.c | 37 ++++++++++++++++++++++++++++++<wbr>++++++<br>
 include/drm/drm_mode_config.h        |  3 ++-<br>
 include/uapi/drm/drm_fourcc.h        |  3 +++<br>
 4 files changed, 43 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c<br>
index 9c0152d..50da618 100644<br>
--- a/drivers/gpu/drm/drm_fourcc.c<br>
+++ b/drivers/gpu/drm/drm_fourcc.c<br>
@@ -222,7 +222,7 @@ const struct drm_format_info *drm_format_info(u32 format)<br>
        const struct drm_format_info *info = NULL;<br>
<br>
        if (dev->mode_config.funcs->get_<wbr>format_info)<br>
-               info = dev->mode_config.funcs->get_<wbr>format_info(mode_cmd);<br>
+               info = dev->mode_config.funcs->get_<wbr>format_info(dev, mode_cmd);<br>
<br>
        if (!info)<br>
                info = drm_format_info(mode_cmd-><wbr>pixel_format);<br>
diff --git a/drivers/gpu/drm/i915/intel_<wbr>display.c b/drivers/gpu/drm/i915/intel_<wbr>display.c<br>
index 2144adc..9fb2f37 100644<br>
--- a/drivers/gpu/drm/i915/intel_<wbr>display.c<br>
+++ b/drivers/gpu/drm/i915/intel_<wbr>display.c<br>
@@ -2433,6 +2433,42 @@ static unsigned int intel_fb_modifier_to_tiling(<wbr>uint64_t fb_modifier)<br>
        }<br>
 }<br>
<br>
+static const struct drm_format_info ccs_formats[] = {<br>
+       { .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },<br>
+       { .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },<br>
+       { .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },<br>
+       { .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2, .cpp = { 4, 1, }, .hsub = 16, .vsub = 8, },<br>
+};<br>
+<br>
+static const struct drm_format_info *<br>
+lookup_format_info(const struct drm_format_info formats[],<br>
+                  int num_formats, u32 format)<br>
+{<br>
+       int i;<br>
+<br>
+       for (i = 0; i < num_formats; i++) {<br>
+               if (formats[i].format == format)<br>
+                       return &formats[i];<br>
+       }<br>
+<br>
+       return NULL;<br>
+}<br>
+<br>
+static const struct drm_format_info *<br>
+intel_get_format_info(struct drm_device *dev,<br>
+                     const struct drm_mode_fb_cmd2 *cmd)<br>
+{<br>
+       switch (cmd->modifier[0]) {<br>
+       case I915_FORMAT_MOD_Y_TILED_CCS:<br>
+       case I915_FORMAT_MOD_Yf_TILED_CCS:<br>
+               return lookup_format_info(ccs_<wbr>formats,<br>
+                                         ARRAY_SIZE(ccs_formats),<br>
+                                         cmd->pixel_format);<br>
+       default:<br>
+               return NULL;<br>
+       }<br>
+}<br>
+<br>
 static int<br>
 intel_fill_fb_info(struct drm_i915_private *dev_priv,<br>
                   struct drm_framebuffer *fb)<br>
@@ -14622,6 +14658,7 @@ static void intel_atomic_state_free(struct drm_atomic_state *state)<br>
<br>
 static const struct drm_mode_config_funcs intel_mode_funcs = {<br>
        .fb_create = intel_user_framebuffer_create,<br>
+       .get_format_info = intel_get_format_info,<br>
        .output_poll_changed = intel_fbdev_output_poll_<wbr>changed,<br>
        .atomic_check = intel_atomic_check,<br>
        .atomic_commit = intel_atomic_commit,<br>
diff --git a/include/drm/drm_mode_config.<wbr>h b/include/drm/drm_mode_config.<wbr>h<br>
index 4298171..f0d3d38 100644<br>
--- a/include/drm/drm_mode_config.<wbr>h<br>
+++ b/include/drm/drm_mode_config.<wbr>h<br>
@@ -81,7 +81,8 @@ struct drm_mode_config_funcs {<br>
         * The format information specific to the given fb metadata, or<br>
         * NULL if none is found.<br>
         */<br>
-       const struct drm_format_info *(*get_format_info)(const struct drm_mode_fb_cmd2 *mode_cmd);<br>
+       const struct drm_format_info *(*get_format_info)(struct drm_device *dev,<br>
+               const struct drm_mode_fb_cmd2 *mode_cmd);<br>
<br>
        /**<br>
         * @output_poll_changed:<br>
diff --git a/include/uapi/drm/drm_fourcc.<wbr>h b/include/uapi/drm/drm_fourcc.<wbr>h<br>
index 7586c46..ee59109 100644<br>
--- a/include/uapi/drm/drm_fourcc.<wbr>h<br>
+++ b/include/uapi/drm/drm_fourcc.<wbr>h<br>
@@ -252,6 +252,9 @@<br>
  */<br>
 #define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3)<br>
<br>
+#define I915_FORMAT_MOD_Y_TILED_CCS    fourcc_mod_code(INTEL, 4)<br>
+#define I915_FORMAT_MOD_Yf_TILED_CCS   fourcc_mod_code(INTEL, 5)<br>
+<br>
 /*<br>
  * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks<br>
  *<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
</font></span></blockquote></div><br></div>