]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/gpu/drm/i915/intel_sprite.c
drm/i915: Reject rotation for some hdr formats
[linux.git] / drivers / gpu / drm / i915 / intel_sprite.c
index 53174d5795741947b609d9c269ba03ed29e675a0..65de7387bf1b0cebc42ed545414184c3c235a09b 100644 (file)
@@ -269,7 +269,8 @@ int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state)
 {
        const struct drm_framebuffer *fb = plane_state->base.fb;
        struct drm_rect *src = &plane_state->base.src;
-       u32 src_x, src_y, src_w, src_h;
+       u32 src_x, src_y, src_w, src_h, hsub, vsub;
+       bool rotated = drm_rotation_90_or_270(plane_state->base.rotation);
 
        /*
         * Hardware doesn't handle subpixel coordinates.
@@ -287,18 +288,26 @@ int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state)
        src->y1 = src_y << 16;
        src->y2 = (src_y + src_h) << 16;
 
-       if (fb->format->is_yuv &&
-           (src_x & 1 || src_w & 1)) {
-               DRM_DEBUG_KMS("src x/w (%u, %u) must be a multiple of 2 for YUV planes\n",
-                             src_x, src_w);
+       if (!fb->format->is_yuv)
+               return 0;
+
+       /* YUV specific checks */
+       if (!rotated) {
+               hsub = fb->format->hsub;
+               vsub = fb->format->vsub;
+       } else {
+               hsub = vsub = max(fb->format->hsub, fb->format->vsub);
+       }
+
+       if (src_x % hsub || src_w % hsub) {
+               DRM_DEBUG_KMS("src x/w (%u, %u) must be a multiple of %u for %sYUV planes\n",
+                             src_x, src_w, hsub, rotated ? "rotated " : "");
                return -EINVAL;
        }
 
-       if (fb->format->is_yuv &&
-           fb->format->num_planes > 1 &&
-           (src_y & 1 || src_h & 1)) {
-               DRM_DEBUG_KMS("src y/h (%u, %u) must be a multiple of 2 for planar YUV planes\n",
-                             src_y, src_h);
+       if (src_y % vsub || src_h % vsub) {
+               DRM_DEBUG_KMS("src y/h (%u, %u) must be a multiple of %u for %sYUV planes\n",
+                             src_y, src_h, vsub, rotated ? "rotated " : "");
                return -EINVAL;
        }
 
@@ -622,6 +631,9 @@ skl_disable_plane(struct intel_plane *plane,
 
        spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
 
+       if (icl_is_hdr_plane(dev_priv, plane_id))
+               I915_WRITE_FW(PLANE_CUS_CTL(pipe, plane_id), 0);
+
        skl_write_plane_wm(plane, crtc_state);
 
        I915_WRITE_FW(PLANE_CTL(pipe, plane_id), 0);
@@ -754,7 +766,12 @@ vlv_update_clrc(const struct intel_plane_state *plane_state)
 
 static u32 vlv_sprite_ctl_crtc(const struct intel_crtc_state *crtc_state)
 {
-       return SP_GAMMA_ENABLE;
+       u32 sprctl = 0;
+
+       if (crtc_state->gamma_enable)
+               sprctl |= SP_GAMMA_ENABLE;
+
+       return sprctl;
 }
 
 static u32 vlv_sprite_ctl(const struct intel_crtc_state *crtc_state,
@@ -929,12 +946,12 @@ vlv_plane_get_hw_state(struct intel_plane *plane,
 
 static u32 ivb_sprite_ctl_crtc(const struct intel_crtc_state *crtc_state)
 {
-       struct drm_i915_private *dev_priv = to_i915(crtc_state->base.crtc->dev);
        u32 sprctl = 0;
 
-       sprctl |= SPRITE_GAMMA_ENABLE;
+       if (crtc_state->gamma_enable)
+               sprctl |= SPRITE_GAMMA_ENABLE;
 
-       if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
+       if (crtc_state->csc_enable)
                sprctl |= SPRITE_PIPE_CSC_ENABLE;
 
        return sprctl;
@@ -1120,7 +1137,15 @@ g4x_sprite_max_stride(struct intel_plane *plane,
 
 static u32 g4x_sprite_ctl_crtc(const struct intel_crtc_state *crtc_state)
 {
-       return DVS_GAMMA_ENABLE;
+       u32 dvscntr = 0;
+
+       if (crtc_state->gamma_enable)
+               dvscntr |= DVS_GAMMA_ENABLE;
+
+       if (crtc_state->csc_enable)
+               dvscntr |= DVS_PIPE_CSC_ENABLE;
+
+       return dvscntr;
 }
 
 static u32 g4x_sprite_ctl(const struct intel_crtc_state *crtc_state,
@@ -1506,6 +1531,11 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state,
                case DRM_FORMAT_XBGR16161616F:
                case DRM_FORMAT_ARGB16161616F:
                case DRM_FORMAT_ABGR16161616F:
+               case DRM_FORMAT_Y210:
+               case DRM_FORMAT_Y212:
+               case DRM_FORMAT_Y216:
+               case DRM_FORMAT_XVYU12_16161616:
+               case DRM_FORMAT_XVYU16161616:
                        DRM_DEBUG_KMS("Unsupported pixel format %s for 90/270!\n",
                                      drm_get_format_name(fb->format->format,
                                                          &format_name));
@@ -1805,7 +1835,7 @@ static const u32 skl_plane_formats[] = {
        DRM_FORMAT_VYUY,
 };
 
-static const uint32_t icl_plane_formats[] = {
+static const u32 icl_plane_formats[] = {
        DRM_FORMAT_C8,
        DRM_FORMAT_RGB565,
        DRM_FORMAT_XRGB8888,
@@ -1826,7 +1856,7 @@ static const uint32_t icl_plane_formats[] = {
        DRM_FORMAT_XVYU16161616,
 };
 
-static const uint32_t icl_hdr_plane_formats[] = {
+static const u32 icl_hdr_plane_formats[] = {
        DRM_FORMAT_C8,
        DRM_FORMAT_RGB565,
        DRM_FORMAT_XRGB8888,
@@ -1867,7 +1897,7 @@ static const u32 skl_planar_formats[] = {
        DRM_FORMAT_NV12,
 };
 
-static const uint32_t glk_planar_formats[] = {
+static const u32 glk_planar_formats[] = {
        DRM_FORMAT_C8,
        DRM_FORMAT_RGB565,
        DRM_FORMAT_XRGB8888,
@@ -1886,7 +1916,7 @@ static const uint32_t glk_planar_formats[] = {
        DRM_FORMAT_P016,
 };
 
-static const uint32_t icl_planar_formats[] = {
+static const u32 icl_planar_formats[] = {
        DRM_FORMAT_C8,
        DRM_FORMAT_RGB565,
        DRM_FORMAT_XRGB8888,
@@ -1911,7 +1941,7 @@ static const uint32_t icl_planar_formats[] = {
        DRM_FORMAT_XVYU16161616,
 };
 
-static const uint32_t icl_hdr_planar_formats[] = {
+static const u32 icl_hdr_planar_formats[] = {
        DRM_FORMAT_C8,
        DRM_FORMAT_RGB565,
        DRM_FORMAT_XRGB8888,
@@ -2082,12 +2112,7 @@ static bool skl_plane_format_mod_supported(struct drm_plane *_plane,
        case DRM_FORMAT_P010:
        case DRM_FORMAT_P012:
        case DRM_FORMAT_P016:
-       case DRM_FORMAT_Y210:
-       case DRM_FORMAT_Y212:
-       case DRM_FORMAT_Y216:
        case DRM_FORMAT_XVYU2101010:
-       case DRM_FORMAT_XVYU12_16161616:
-       case DRM_FORMAT_XVYU16161616:
                if (modifier == I915_FORMAT_MOD_Yf_TILED)
                        return true;
                /* fall through */
@@ -2096,6 +2121,11 @@ static bool skl_plane_format_mod_supported(struct drm_plane *_plane,
        case DRM_FORMAT_ABGR16161616F:
        case DRM_FORMAT_XRGB16161616F:
        case DRM_FORMAT_ARGB16161616F:
+       case DRM_FORMAT_Y210:
+       case DRM_FORMAT_Y212:
+       case DRM_FORMAT_Y216:
+       case DRM_FORMAT_XVYU12_16161616:
+       case DRM_FORMAT_XVYU16161616:
                if (modifier == DRM_FORMAT_MOD_LINEAR ||
                    modifier == I915_FORMAT_MOD_X_TILED ||
                    modifier == I915_FORMAT_MOD_Y_TILED)