<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 4, 2014 at 4:27 AM, Damien Lespiau <span dir="ltr"><<a href="mailto:damien.lespiau@intel.com" target="_blank">damien.lespiau@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">SKL Uses the same hardware for all planes now, so called "universal"<br>
planes. Ie both the primary planes and sprite planes share the same<br>
logic. This patch implements the drm_plane vfuncs for "sprites" ie<br>
planes that aren't the primary plane.<br>
<br>
v2: Couple of fixes:<br>
  - Actually enabled the planes and fix the plane number<br>
<br>
Signed-off-by: Damien Lespiau <<a href="mailto:damien.lespiau@intel.com">damien.lespiau@intel.com</a>><br>
---<br>
 drivers/gpu/drm/i915/i915_reg.h     |  31 +++++-<br>
 drivers/gpu/drm/i915/intel_sprite.c | 206 +++++++++++++++++++++++++++++++++++-<br>
 2 files changed, 235 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h<br>
index c293dab..0159f2d 100644<br>
--- a/drivers/gpu/drm/i915/i915_reg.h<br>
+++ b/drivers/gpu/drm/i915/i915_reg.h<br>
@@ -4513,7 +4513,9 @@ enum punit_power_well {<br>
 #define   PLANE_CTL_FORMAT_INDEXED             ( 12 << 24)<br>
 #define   PLANE_CTL_FORMAT_RGB_565             ( 14 << 24)<br>
 #define   PLANE_CTL_PIPE_CSC_ENABLE            (1 << 23)<br>
-#define   PLANE_CTL_KEY_ENABLE                 (1 << 22)<br>
+#define   PLANE_CTL_KEY_ENABLE_MASK            (0x3 << 21)<br>
+#define   PLANE_CTL_KEY_ENABLE_SOURCE          (  1 << 21)<br>
+#define   PLANE_CTL_KEY_ENABLE_DESTINATION     (  2 << 21)<br></blockquote><div><br></div><div>Oh ignore my comments on patch 12/89 regarding these bits! ;)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 #define   PLANE_CTL_ORDER_BGRX                 (0 << 20)<br>
 #define   PLANE_CTL_ORDER_RGBX                 (1 << 20)<br>
 #define   PLANE_CTL_YUV422_ORDER_MASK          (0x3 << 16)<br>
@@ -4548,6 +4550,12 @@ enum punit_power_well {<br>
 #define _PLANE_OFFSET_1_A                      0x701a4<br>
 #define _PLANE_OFFSET_2_A                      0x702a4<br>
 #define _PLANE_OFFSET_3_A                      0x703a4<br>
+#define _PLANE_KEYVAL_1_A                      0x70194<br>
+#define _PLANE_KEYVAL_2_A                      0x70294<br>
+#define _PLANE_KEYMSK_1_A                      0x70198<br>
+#define _PLANE_KEYMSK_2_A                      0x70298<br>
+#define _PLANE_KEYMAX_1_A                      0x701a0<br>
+#define _PLANE_KEYMAX_2_A                      0x702a0<br>
<br>
 #define _PLANE_CTL_1_B                         0x71180<br>
 #define _PLANE_CTL_2_B                         0x71280<br>
@@ -4604,6 +4612,27 @@ enum punit_power_well {<br>
 #define PLANE_OFFSET(pipe, plane)      \<br>
        _PLANE(plane, _PLANE_OFFSET_1(pipe), _PLANE_OFFSET_2(pipe))<br>
<br>
+#define _PLANE_KEYVAL_1_B                      0x71194<br>
+#define _PLANE_KEYVAL_2_B                      0x71294<br>
+#define _PLANE_KEYVAL_1(pipe) _PIPE(pipe, _PLANE_KEYVAL_1_A, _PLANE_KEYVAL_1_B)<br>
+#define _PLANE_KEYVAL_2(pipe) _PIPE(pipe, _PLANE_KEYVAL_2_A, _PLANE_KEYVAL_2_B)<br>
+#define PLANE_KEYVAL(pipe, plane)      \<br>
+       _PLANE(plane, _PLANE_KEYVAL_1(pipe), _PLANE_KEYVAL_2(pipe))<br>
+<br>
+#define _PLANE_KEYMSK_1_B                      0x71198<br>
+#define _PLANE_KEYMSK_2_B                      0x71298<br>
+#define _PLANE_KEYMSK_1(pipe) _PIPE(pipe, _PLANE_KEYMSK_1_A, _PLANE_KEYMSK_1_B)<br>
+#define _PLANE_KEYMSK_2(pipe) _PIPE(pipe, _PLANE_KEYMSK_2_A, _PLANE_KEYMSK_2_B)<br>
+#define PLANE_KEYMSK(pipe, plane)      \<br>
+       _PLANE(plane, _PLANE_KEYMSK_1(pipe), _PLANE_KEYMSK_2(pipe))<br>
+<br>
+#define _PLANE_KEYMAX_1_B                      0x711a0<br>
+#define _PLANE_KEYMAX_2_B                      0x712a0<br>
+#define _PLANE_KEYMAX_1(pipe) _PIPE(pipe, _PLANE_KEYMAX_1_A, _PLANE_KEYMAX_1_B)<br>
+#define _PLANE_KEYMAX_2(pipe) _PIPE(pipe, _PLANE_KEYMAX_2_A, _PLANE_KEYMAX_2_B)<br>
+#define PLANE_KEYMAX(pipe, plane)      \<br>
+       _PLANE(plane, _PLANE_KEYMAX_1(pipe), _PLANE_KEYMAX_2(pipe))<br>
+<br>
 /* VBIOS regs */<br>
 #define VGACNTRL               0x71400<br>
 # define VGA_DISP_DISABLE                      (1 << 31)<br>
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c<br>
index 07a74ef..57e7190 100644<br>
--- a/drivers/gpu/drm/i915/intel_sprite.c<br>
+++ b/drivers/gpu/drm/i915/intel_sprite.c<br>
@@ -139,6 +139,184 @@ static void intel_update_primary_plane(struct intel_crtc *crtc)<br>
 }<br>
<br>
 static void<br>
+skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,<br>
+                struct drm_framebuffer *fb,<br>
+                struct drm_i915_gem_object *obj, int crtc_x, int crtc_y,<br>
+                unsigned int crtc_w, unsigned int crtc_h,<br>
+                uint32_t x, uint32_t y,<br>
+                uint32_t src_w, uint32_t src_h)<br>
+{<br>
+       struct drm_device *dev = drm_plane->dev;<br>
+       struct drm_i915_private *dev_priv = dev->dev_private;<br>
+       struct intel_plane *intel_plane = to_intel_plane(drm_plane);<br>
+       const int pipe = intel_plane->pipe;<br>
+       const int plane = intel_plane->plane + 1;</blockquote><div><br></div><div>A comment above to remind skl doesn't have the primary would be good. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       u32 plane_ctl, stride;<br>
+       int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);<br>
+<br>
+       plane_ctl = I915_READ(PLANE_CTL(pipe, plane));<br>
+<br>
+       /* Mask out pixel format bits in case we change it */<br>
+       plane_ctl &= ~PLANE_CTL_FORMAT_MASK;<br>
+       plane_ctl &= ~PLANE_CTL_ORDER_RGBX;<br>
+       plane_ctl &= ~PLANE_CTL_YUV422_ORDER_MASK;<br>
+       plane_ctl &= ~PLANE_CTL_TILED_MASK;<br>
+       plane_ctl &= ~PLANE_CTL_ALPHA_MASK;<br>
+<br>
+       /* Trickle feed has to be enabled */<br>
+       plane_ctl &= ~PLANE_CTL_TRICKLE_FEED_DISABLE;<br>
+<br>
+       switch (fb->pixel_format) {<br>
+       case DRM_FORMAT_RGB565:<br>
+               plane_ctl |= PLANE_CTL_FORMAT_RGB_565;<br>
+               break;<br>
+       case DRM_FORMAT_XBGR8888:<br>
+               plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888 | PLANE_CTL_ORDER_RGBX;<br>
+               break;<br>
+       case DRM_FORMAT_XRGB8888:<br>
+               plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888;<br>
+               break;<br>
+       /*<br>
+        * XXX: For ARBG/ABGR formats we default to expecting scanout buffers<br>
+        * to be already pre-multiplied. We need to add a knob (or a different<br>
+        * DRM_FORMAT) for user-space to configure that.<br>
+        */<br>
+       case DRM_FORMAT_ABGR8888:<br>
+               plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888 |<br>
+                            PLANE_CTL_ORDER_RGBX |<br>
+                            PLANE_CTL_ALPHA_SW_PREMULTIPLY;<br>
+               break;<br>
+       case DRM_FORMAT_ARGB8888:<br>
+               plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888 |<br>
+                            PLANE_CTL_ALPHA_SW_PREMULTIPLY;<br>
+               break;<br>
+       case DRM_FORMAT_YUYV:<br>
+               plane_ctl |= PLANE_CTL_FORMAT_YUV422 | PLANE_CTL_YUV422_YUYV;<br>
+               break;<br>
+       case DRM_FORMAT_YVYU:<br>
+               plane_ctl |= PLANE_CTL_FORMAT_YUV422 | PLANE_CTL_YUV422_YVYU;<br>
+               break;<br>
+       case DRM_FORMAT_UYVY:<br>
+               plane_ctl |= PLANE_CTL_FORMAT_YUV422 | PLANE_CTL_YUV422_UYVY;<br>
+               break;<br>
+       case DRM_FORMAT_VYUY:<br>
+               plane_ctl |= PLANE_CTL_FORMAT_YUV422 | PLANE_CTL_YUV422_VYUY;<br>
+               break;<br>
+       default:<br>
+               BUG();<br>
+       }<br>
+<br>
+       switch (obj->tiling_mode) {<br>
+       case I915_TILING_NONE:<br>
+               stride = fb->pitches[0] >> 6;<br>
+               break;<br>
+       case I915_TILING_X:<br>
+               plane_ctl |= PLANE_CTL_TILED_X;<br>
+               stride = fb->pitches[0] >> 9;<br>
+               break;<br>
+       default:<br>
+               BUG();<br>
+       }<br>
+<br>
+       plane_ctl |= PLANE_CTL_ENABLE;<br>
+       plane_ctl |= PLANE_CTL_PIPE_CSC_ENABLE;<br>
+<br>
+       intel_update_sprite_watermarks(drm_plane, crtc, src_w, src_h,<br>
+                                      pixel_size, true,<br>
+                                      src_w != crtc_w || src_h != crtc_h);<br>
+<br>
+       /* Sizes are 0 based */<br>
+       src_w--;<br>
+       src_h--;<br>
+       crtc_w--;<br>
+       crtc_h--;<br>
+<br>
+       I915_WRITE(PLANE_OFFSET(pipe, plane), (y << 16) | x);<br>
+       I915_WRITE(PLANE_STRIDE(pipe, plane), stride);<br>
+       I915_WRITE(PLANE_POS(pipe, plane), (crtc_y << 16) | crtc_x);<br>
+       I915_WRITE(PLANE_SIZE(pipe, plane), (crtc_h << 16) | crtc_w);<br>
+       I915_WRITE(PLANE_CTL(pipe, plane), plane_ctl);<br>
+       I915_WRITE(PLANE_SURF(pipe, plane), i915_gem_obj_ggtt_offset(obj));<br>
+       POSTING_READ(PLANE_SURF(pipe, plane));<br>
+}<br>
+<br>
+static void<br>
+skl_disable_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc)<br>
+{<br>
+       struct drm_device *dev = drm_plane->dev;<br>
+       struct drm_i915_private *dev_priv = dev->dev_private;<br>
+       struct intel_plane *intel_plane = to_intel_plane(drm_plane);<br>
+       const int pipe = intel_plane->pipe;<br>
+       const int plane = intel_plane->plane + 1;<br>
+<br>
+       I915_WRITE(PLANE_CTL(pipe, plane),<br>
+                  I915_READ(PLANE_CTL(pipe, plane)) & ~PLANE_CTL_ENABLE);<br>
+<br>
+       /* Activate double buffered register update */<br>
+       I915_WRITE(PLANE_CTL(pipe, plane), 0);<br>
+       POSTING_READ(PLANE_CTL(pipe, plane));<br>
+<br>
+       intel_update_sprite_watermarks(drm_plane, crtc, 0, 0, 0, false, false);<br>
+}<br>
+<br>
+static int<br>
+skl_update_colorkey(struct drm_plane *drm_plane,<br>
+                   struct drm_intel_sprite_colorkey *key)<br>
+{<br>
+       struct drm_device *dev = drm_plane->dev;<br>
+       struct drm_i915_private *dev_priv = dev->dev_private;<br>
+       struct intel_plane *intel_plane = to_intel_plane(drm_plane);<br>
+       const int pipe = intel_plane->pipe;<br>
+       const int plane = intel_plane->plane;<br>
+       u32 plane_ctl;<br>
+<br>
+       I915_WRITE(PLANE_KEYVAL(pipe, plane), key->min_value);<br>
+       I915_WRITE(PLANE_KEYMAX(pipe, plane), key->max_value);<br>
+       I915_WRITE(PLANE_KEYMSK(pipe, plane), key->channel_mask);<br>
+<br>
+       plane_ctl = I915_READ(PLANE_CTL(pipe, plane));<br>
+       plane_ctl &= ~PLANE_CTL_KEY_ENABLE_MASK;<br>
+       if (key->flags & I915_SET_COLORKEY_DESTINATION)<br>
+               plane_ctl |= PLANE_CTL_KEY_ENABLE_DESTINATION;<br>
+       else if (key->flags & I915_SET_COLORKEY_SOURCE)<br>
+               plane_ctl |= PLANE_CTL_KEY_ENABLE_SOURCE;<br>
+       I915_WRITE(PLANE_CTL(pipe, plane), plane_ctl);<br>
+<br>
+       POSTING_READ(PLANE_CTL(pipe, plane));<br>
+<br>
+       return 0;<br>
+}<br>
+<br>
+static void<br>
+skl_get_colorkey(struct drm_plane *drm_plane,<br>
+                struct drm_intel_sprite_colorkey *key)<br>
+{<br>
+       struct drm_device *dev = drm_plane->dev;<br>
+       struct drm_i915_private *dev_priv = dev->dev_private;<br>
+       struct intel_plane *intel_plane = to_intel_plane(drm_plane);<br>
+       const int pipe = intel_plane->pipe;<br>
+       const int plane = intel_plane->plane;<br>
+       u32 plane_ctl;<br>
+<br>
+       key->min_value = I915_READ(PLANE_KEYVAL(pipe, plane));<br>
+       key->max_value = I915_READ(PLANE_KEYMAX(pipe, plane));<br>
+       key->channel_mask = I915_READ(PLANE_KEYMSK(pipe, plane));<br>
+<br>
+       plane_ctl = I915_READ(PLANE_CTL(pipe, plane));<br>
+<br>
+       switch (plane_ctl & PLANE_CTL_KEY_ENABLE_MASK) {<br>
+       case PLANE_CTL_KEY_ENABLE_DESTINATION:<br>
+               key->flags = I915_SET_COLORKEY_DESTINATION;<br>
+               break;<br>
+       case PLANE_CTL_KEY_ENABLE_SOURCE:<br>
+               key->flags = I915_SET_COLORKEY_SOURCE;<br>
+               break;<br>
+       default:<br>
+               key->flags = I915_SET_COLORKEY_NONE;<br>
+       }<br>
+}<br>
+<br>
+static void<br>
 vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,<br>
                 struct drm_framebuffer *fb,<br>
                 struct drm_i915_gem_object *obj, int crtc_x, int crtc_y,<br>
@@ -1305,6 +1483,18 @@ static uint32_t vlv_plane_formats[] = {<br>
        DRM_FORMAT_VYUY,<br>
 };<br>
<br>
+static uint32_t skl_plane_formats[] = {<br>
+       DRM_FORMAT_RGB565,<br>
+       DRM_FORMAT_ABGR8888,<br>
+       DRM_FORMAT_ARGB8888,<br>
+       DRM_FORMAT_XBGR8888,<br>
+       DRM_FORMAT_XRGB8888,<br>
+       DRM_FORMAT_YUYV,<br>
+       DRM_FORMAT_YVYU,<br>
+       DRM_FORMAT_UYVY,<br>
+       DRM_FORMAT_VYUY,<br>
+};<br>
+<br>
 int<br>
 intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)<br>
 {<br>
@@ -1368,7 +1558,21 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)<br>
                        num_plane_formats = ARRAY_SIZE(snb_plane_formats);<br>
                }<br>
                break;<br>
-<br>
+       case 9:<br>
+               /*<br>
+                * FIXME: Skylake planes can be scaled (with some restrictions),<br>
+                * but this is for another time.<br>
+                */<br>
+               intel_plane->can_scale = false;<br>
+               intel_plane->max_downscale = 1;<br>
+               intel_plane->update_plane = skl_update_plane;<br>
+               intel_plane->disable_plane = skl_disable_plane;<br>
+               intel_plane->update_colorkey = skl_update_colorkey;<br>
+               intel_plane->get_colorkey = skl_get_colorkey;<br>
+<br>
+               plane_formats = skl_plane_formats;<br>
+               num_plane_formats = ARRAY_SIZE(skl_plane_formats);<br>
+               break;<br>
        default:<br>
                kfree(intel_plane);<br>
                return -ENODEV;<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.1<br>
<br>
_______________________________________________<br>
Intel-gfx mailing list<br>
<a href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/intel-gfx" target="_blank">http://lists.freedesktop.org/mailman/listinfo/intel-gfx</a><br>
</font></span></blockquote></div><br><br>Reviewed-by: Rodrigo Vivi <<a href="mailto:rodrigo.vivi@intel.com">rodrigo.vivi@intel.com</a>><br clear="all"><div><br></div>-- <br><div>Rodrigo Vivi</div><div>Blog: <a href="http://blog.vivi.eng.br" target="_blank">http://blog.vivi.eng.br</a></div><div> </div>
</div></div>