]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/i915: Add 180 degree sprite rotation support
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 5 Aug 2014 05:56:52 +0000 (11:26 +0530)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 8 Aug 2014 15:43:51 +0000 (17:43 +0200)
The sprite planes (in fact all display planes starting from gen4)
support 180 degree rotation. Add the relevant low level bits to the
sprite code to make use of that feature.

The upper layers are not yet plugged in.

v2: HSW handles the rotated buffer offset automagically

v3: BDW also handles the rotated buffer offset automagically

Testcase: igt/kms_rotation_crc
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
Reviewed-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_sprite.c

index 7f9a81087ebcbdaf9bb9a92f39531b0067de03f5..5ebac620bbcd32c14c6e1e0686667bfd527ea6dd 100644 (file)
@@ -4218,6 +4218,7 @@ enum punit_power_well {
 #define   DVS_YUV_ORDER_UYVY   (1<<16)
 #define   DVS_YUV_ORDER_YVYU   (2<<16)
 #define   DVS_YUV_ORDER_VYUY   (3<<16)
+#define   DVS_ROTATE_180       (1<<15)
 #define   DVS_DEST_KEY         (1<<2)
 #define   DVS_TRICKLE_FEED_DISABLE (1<<14)
 #define   DVS_TILED            (1<<10)
@@ -4288,6 +4289,7 @@ enum punit_power_well {
 #define   SPRITE_YUV_ORDER_UYVY                (1<<16)
 #define   SPRITE_YUV_ORDER_YVYU                (2<<16)
 #define   SPRITE_YUV_ORDER_VYUY                (3<<16)
+#define   SPRITE_ROTATE_180            (1<<15)
 #define   SPRITE_TRICKLE_FEED_DISABLE  (1<<14)
 #define   SPRITE_INT_GAMMA_ENABLE      (1<<13)
 #define   SPRITE_TILED                 (1<<10)
@@ -4361,6 +4363,7 @@ enum punit_power_well {
 #define   SP_YUV_ORDER_UYVY            (1<<16)
 #define   SP_YUV_ORDER_YVYU            (2<<16)
 #define   SP_YUV_ORDER_VYUY            (3<<16)
+#define   SP_ROTATE_180                        (1<<15)
 #define   SP_TILED                     (1<<10)
 #define _SPALINOFF             (VLV_DISPLAY_BASE + 0x72184)
 #define _SPASTRIDE             (VLV_DISPLAY_BASE + 0x72188)
index 3198de3007be8a77446ba7657c8d9129f6331457..b63df4416301cdd93a3ebb37b672302210a9a5ac 100644 (file)
@@ -448,6 +448,7 @@ struct intel_plane {
        unsigned int crtc_w, crtc_h;
        uint32_t src_x, src_y;
        uint32_t src_w, src_h;
+       unsigned int rotation;
 
        /* Since we need to change the watermarks before/after
         * enabling/disabling the planes, we need to store the parameters here
index d34a5696ffb616560c7f963bc54ee69a94dffa5f..f4d10c4b2781e3818f2e729d0ee4f525bfc14e15 100644 (file)
@@ -164,6 +164,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
        sprctl &= ~SP_PIXFORMAT_MASK;
        sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
        sprctl &= ~SP_TILED;
+       sprctl &= ~SP_ROTATE_180;
 
        switch (fb->pixel_format) {
        case DRM_FORMAT_YUYV:
@@ -236,6 +237,14 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
                                                        fb->pitches[0]);
        linear_offset -= sprsurf_offset;
 
+       if (intel_plane->rotation == BIT(DRM_ROTATE_180)) {
+               sprctl |= SP_ROTATE_180;
+
+               x += src_w;
+               y += src_h;
+               linear_offset += src_h * fb->pitches[0] + src_w * pixel_size;
+       }
+
        atomic_update = intel_pipe_update_start(intel_crtc, &start_vbl_count);
 
        intel_update_primary_plane(intel_crtc);
@@ -365,6 +374,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
        sprctl &= ~SPRITE_RGB_ORDER_RGBX;
        sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK;
        sprctl &= ~SPRITE_TILED;
+       sprctl &= ~SPRITE_ROTATE_180;
 
        switch (fb->pixel_format) {
        case DRM_FORMAT_XBGR8888:
@@ -427,6 +437,18 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
                                               pixel_size, fb->pitches[0]);
        linear_offset -= sprsurf_offset;
 
+       if (intel_plane->rotation == BIT(DRM_ROTATE_180)) {
+               sprctl |= SPRITE_ROTATE_180;
+
+               /* HSW and BDW does this automagically in hardware */
+               if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) {
+                       x += src_w;
+                       y += src_h;
+                       linear_offset += src_h * fb->pitches[0] +
+                               src_w * pixel_size;
+               }
+       }
+
        atomic_update = intel_pipe_update_start(intel_crtc, &start_vbl_count);
 
        intel_update_primary_plane(intel_crtc);
@@ -572,6 +594,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
        dvscntr &= ~DVS_RGB_ORDER_XBGR;
        dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK;
        dvscntr &= ~DVS_TILED;
+       dvscntr &= ~DVS_ROTATE_180;
 
        switch (fb->pixel_format) {
        case DRM_FORMAT_XBGR8888:
@@ -629,6 +652,14 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
                                               pixel_size, fb->pitches[0]);
        linear_offset -= dvssurf_offset;
 
+       if (intel_plane->rotation == BIT(DRM_ROTATE_180)) {
+               dvscntr |= DVS_ROTATE_180;
+
+               x += src_w;
+               y += src_h;
+               linear_offset += src_h * fb->pitches[0] + src_w * pixel_size;
+       }
+
        atomic_update = intel_pipe_update_start(intel_crtc, &start_vbl_count);
 
        intel_update_primary_plane(intel_crtc);
@@ -896,6 +927,9 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
        max_scale = intel_plane->max_downscale << 16;
        min_scale = intel_plane->can_scale ? 1 : (1 << 16);
 
+       drm_rect_rotate(&src, fb->width << 16, fb->height << 16,
+                       intel_plane->rotation);
+
        hscale = drm_rect_calc_hscale_relaxed(&src, &dst, min_scale, max_scale);
        BUG_ON(hscale < 0);
 
@@ -934,6 +968,9 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
                                     drm_rect_width(&dst) * hscale - drm_rect_width(&src),
                                     drm_rect_height(&dst) * vscale - drm_rect_height(&src));
 
+               drm_rect_rotate_inv(&src, fb->width << 16, fb->height << 16,
+                                   intel_plane->rotation);
+
                /* sanity check to make sure the src viewport wasn't enlarged */
                WARN_ON(src.x1 < (int) src_x ||
                        src.y1 < (int) src_y ||
@@ -1311,6 +1348,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 
        intel_plane->pipe = pipe;
        intel_plane->plane = plane;
+       intel_plane->rotation = BIT(DRM_ROTATE_0);
        possible_crtcs = (1 << pipe);
        ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
                             &intel_plane_funcs,