1494N/A/*
1494N/A * Copyright (c) 2011, 2013 Intel Corporation
1494N/A *
1494N/A * Permission is hereby granted, free of charge, to any person obtaining a
1494N/A * copy of this software and associated documentation files (the "Software"),
1494N/A * to deal in the Software without restriction, including without limitation
1494N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1494N/A * and/or sell copies of the Software, and to permit persons to whom the
1494N/A * Software is furnished to do so, subject to the following conditions:
1494N/A *
1494N/A * The above copyright notice and this permission notice (including the next
1494N/A * paragraph) shall be included in all copies or substantial portions of the
1494N/A * Software.
1494N/A *
1494N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1494N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1494N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1494N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1494N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1494N/A * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1494N/A * SOFTWARE.
1494N/A *
1494N/A * Authors:
1494N/A * Jesse Barnes <jbarnes@virtuousgeek.org>
1494N/A *
1494N/A * New plane/sprite handling.
1494N/A *
1494N/A * The older chips had a separate interface for programming plane related
1494N/A * registers; newer ones are much simpler and we can use the new DRM plane
1494N/A * support.
1494N/A */
1494N/A#include "drmP.h"
1494N/A#include "drm_crtc.h"
1494N/A#include "drm_fourcc.h"
1494N/A#include "drm_rect.h"
1494N/A#include "intel_drv.h"
1494N/A#include "i915_drm.h"
1494N/A#include "i915_drv.h"
1494N/A
1494N/Astatic void
1494N/Avlv_update_plane(struct drm_plane *dplane, struct drm_framebuffer *fb,
1494N/A struct drm_i915_gem_object *obj, int crtc_x, int crtc_y,
1494N/A unsigned int crtc_w, unsigned int crtc_h,
1494N/A int x, int y,
1494N/A uint32_t src_w, uint32_t src_h)
1494N/A{
1494N/A struct drm_device *dev = dplane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane = to_intel_plane(dplane);
1494N/A int pipe = intel_plane->pipe;
1494N/A int plane = intel_plane->plane;
1494N/A u32 sprctl;
1494N/A unsigned long sprsurf_offset, linear_offset;
1494N/A int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
1494N/A
1494N/A sprctl = I915_READ(SPCNTR(pipe, plane));
1494N/A
1494N/A /* Mask out pixel format bits in case we change it */
1494N/A sprctl &= ~SP_PIXFORMAT_MASK;
1494N/A sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
1494N/A sprctl &= ~SP_TILED;
1494N/A
1494N/A switch (fb->pixel_format) {
1494N/A case DRM_FORMAT_YUYV:
1494N/A sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YUYV;
1494N/A break;
1494N/A case DRM_FORMAT_YVYU:
1494N/A sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YVYU;
1494N/A break;
1494N/A case DRM_FORMAT_UYVY:
1494N/A sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_UYVY;
1494N/A break;
1494N/A case DRM_FORMAT_VYUY:
1494N/A sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_VYUY;
1494N/A break;
1494N/A case DRM_FORMAT_RGB565:
1494N/A sprctl |= SP_FORMAT_BGR565;
1494N/A break;
1494N/A case DRM_FORMAT_XRGB8888:
1494N/A sprctl |= SP_FORMAT_BGRX8888;
1494N/A break;
1494N/A case DRM_FORMAT_ARGB8888:
1494N/A sprctl |= SP_FORMAT_BGRA8888;
1494N/A break;
1494N/A case DRM_FORMAT_XBGR2101010:
1494N/A sprctl |= SP_FORMAT_RGBX1010102;
1494N/A break;
1494N/A case DRM_FORMAT_ABGR2101010:
1494N/A sprctl |= SP_FORMAT_RGBA1010102;
1494N/A break;
1494N/A case DRM_FORMAT_XBGR8888:
1494N/A sprctl |= SP_FORMAT_RGBX8888;
1494N/A break;
1494N/A case DRM_FORMAT_ABGR8888:
1494N/A sprctl |= SP_FORMAT_RGBA8888;
1494N/A break;
1494N/A default:
1494N/A /*
1494N/A * If we get here one of the upper layers failed to filter
1494N/A * out the unsupported plane formats
1494N/A */
1494N/A BUG();
1494N/A break;
1494N/A }
1494N/A
1494N/A if (obj->tiling_mode != I915_TILING_NONE)
1494N/A sprctl |= SP_TILED;
1494N/A
1494N/A sprctl |= SP_ENABLE;
1494N/A
1494N/A /* Sizes are 0 based */
1494N/A src_w--;
1494N/A src_h--;
1494N/A crtc_w--;
1494N/A crtc_h--;
1494N/A
1494N/A intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size, true);
1494N/A
1494N/A I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]);
1494N/A I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x);
1494N/A
1494N/A linear_offset = y * fb->pitches[0] + x * pixel_size;
1494N/A sprsurf_offset = intel_gen4_compute_page_offset(&x, &y,
1494N/A obj->tiling_mode,
1494N/A pixel_size,
1494N/A fb->pitches[0]);
1494N/A linear_offset -= sprsurf_offset;
1494N/A
1494N/A if (obj->tiling_mode != I915_TILING_NONE)
1494N/A I915_WRITE(SPTILEOFF(pipe, plane), (y << 16) | x);
1494N/A else
1494N/A I915_WRITE(SPLINOFF(pipe, plane), linear_offset);
1494N/A
1494N/A I915_WRITE(SPSIZE(pipe, plane), (crtc_h << 16) | crtc_w);
1494N/A I915_WRITE(SPCNTR(pipe, plane), sprctl);
1494N/A I915_MODIFY_DISPBASE(SPSURF(pipe, plane), obj->gtt_offset +
1494N/A sprsurf_offset);
1494N/A POSTING_READ(SPSURF(pipe, plane));
1494N/A}
1494N/A
1494N/Astatic void
1494N/Avlv_disable_plane(struct drm_plane *dplane)
1494N/A{
1494N/A struct drm_device *dev = dplane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane = to_intel_plane(dplane);
1494N/A int pipe = intel_plane->pipe;
1494N/A int plane = intel_plane->plane;
1494N/A
1494N/A I915_WRITE(SPCNTR(pipe, plane), I915_READ(SPCNTR(pipe, plane)) &
1494N/A ~SP_ENABLE);
1494N/A /* Activate double buffered register update */
1494N/A I915_MODIFY_DISPBASE(SPSURF(pipe, plane), 0);
1494N/A POSTING_READ(SPSURF(pipe, plane));
1494N/A}
1494N/A
1494N/Astatic int
1494N/Avlv_update_colorkey(struct drm_plane *dplane,
1494N/A struct drm_intel_sprite_colorkey *key)
1494N/A{
1494N/A struct drm_device *dev = dplane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane = to_intel_plane(dplane);
1494N/A int pipe = intel_plane->pipe;
1494N/A int plane = intel_plane->plane;
1494N/A u32 sprctl;
1494N/A
1494N/A if (key->flags & I915_SET_COLORKEY_DESTINATION)
1494N/A return -EINVAL;
1494N/A
1494N/A I915_WRITE(SPKEYMINVAL(pipe, plane), key->min_value);
1494N/A I915_WRITE(SPKEYMAXVAL(pipe, plane), key->max_value);
1494N/A I915_WRITE(SPKEYMSK(pipe, plane), key->channel_mask);
1494N/A
1494N/A sprctl = I915_READ(SPCNTR(pipe, plane));
1494N/A sprctl &= ~SP_SOURCE_KEY;
1494N/A if (key->flags & I915_SET_COLORKEY_SOURCE)
1494N/A sprctl |= SP_SOURCE_KEY;
1494N/A I915_WRITE(SPCNTR(pipe, plane), sprctl);
1494N/A
1494N/A POSTING_READ(SPKEYMSK(pipe, plane));
1494N/A
1494N/A return 0;
1494N/A}
1494N/A
1494N/Astatic void
1494N/Avlv_get_colorkey(struct drm_plane *dplane,
1494N/A struct drm_intel_sprite_colorkey *key)
1494N/A{
1494N/A struct drm_device *dev = dplane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane = to_intel_plane(dplane);
1494N/A int pipe = intel_plane->pipe;
1494N/A int plane = intel_plane->plane;
1494N/A u32 sprctl;
1494N/A
1494N/A key->min_value = I915_READ(SPKEYMINVAL(pipe, plane));
1494N/A key->max_value = I915_READ(SPKEYMAXVAL(pipe, plane));
1494N/A key->channel_mask = I915_READ(SPKEYMSK(pipe, plane));
1494N/A
1494N/A sprctl = I915_READ(SPCNTR(pipe, plane));
1494N/A if (sprctl & SP_SOURCE_KEY)
1494N/A key->flags = I915_SET_COLORKEY_SOURCE;
1494N/A else
1494N/A key->flags = I915_SET_COLORKEY_NONE;
1494N/A}
1494N/A
1494N/Astatic void
1494N/Aivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
1494N/A struct drm_i915_gem_object *obj, int crtc_x, int crtc_y,
1494N/A unsigned int crtc_w, unsigned int crtc_h,
1494N/A int x, int y,
1494N/A uint32_t src_w, uint32_t src_h)
1494N/A{
1494N/A struct drm_device *dev = plane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane = to_intel_plane(plane);
1494N/A int pipe = intel_plane->pipe;
1494N/A u32 sprctl, sprscale = 0;
1494N/A unsigned long sprsurf_offset, linear_offset;
1494N/A int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
1494N/A bool scaling_was_enabled = (bool)dev_priv->sprite_scaling_enabled;
1494N/A
1494N/A sprctl = I915_READ(SPRCTL(pipe));
1494N/A
1494N/A /* Mask out pixel format bits in case we change it */
1494N/A sprctl &= ~SPRITE_PIXFORMAT_MASK;
1494N/A sprctl &= ~SPRITE_RGB_ORDER_RGBX;
1494N/A sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK;
1494N/A sprctl &= ~SPRITE_TILED;
1494N/A
1494N/A switch (fb->pixel_format) {
1494N/A case DRM_FORMAT_XBGR8888:
1494N/A sprctl |= SPRITE_FORMAT_RGBX888 | SPRITE_RGB_ORDER_RGBX;
1494N/A break;
1494N/A case DRM_FORMAT_XRGB8888:
1494N/A sprctl |= SPRITE_FORMAT_RGBX888;
1494N/A break;
1494N/A case DRM_FORMAT_YUYV:
1494N/A sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YUYV;
1494N/A break;
1494N/A case DRM_FORMAT_YVYU:
1494N/A sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YVYU;
1494N/A break;
1494N/A case DRM_FORMAT_UYVY:
1494N/A sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_UYVY;
1494N/A break;
1494N/A case DRM_FORMAT_VYUY:
1494N/A sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_VYUY;
1494N/A break;
1494N/A default:
1494N/A BUG();
1494N/A }
1494N/A
1494N/A if (obj->tiling_mode != I915_TILING_NONE)
1494N/A sprctl |= SPRITE_TILED;
1494N/A
1494N/A /* must disable */
1494N/A sprctl |= SPRITE_TRICKLE_FEED_DISABLE;
1494N/A sprctl |= SPRITE_ENABLE;
1494N/A
1494N/A if (IS_HASWELL(dev))
1494N/A sprctl |= SPRITE_PIPE_CSC_ENABLE;
1494N/A
1494N/A /* Sizes are 0 based */
1494N/A src_w--;
1494N/A src_h--;
1494N/A crtc_w--;
1494N/A crtc_h--;
1494N/A
1494N/A intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size, true);
1494N/A
1494N/A /*
1494N/A * IVB workaround: must disable low power watermarks for at least
1494N/A * one frame before enabling scaling. LP watermarks can be re-enabled
1494N/A * when scaling is disabled.
1494N/A */
1494N/A if (crtc_w != src_w || crtc_h != src_h) {
1494N/A dev_priv->sprite_scaling_enabled |= 1 << pipe;
1494N/A
1494N/A if (!scaling_was_enabled) {
1494N/A intel_update_watermarks(dev);
1494N/A intel_wait_for_vblank(dev, pipe);
1494N/A }
1494N/A sprscale = SPRITE_SCALE_ENABLE | (src_w << 16) | src_h;
1494N/A } else
1494N/A dev_priv->sprite_scaling_enabled &= ~(1 << pipe);
1494N/A
1494N/A I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]);
1494N/A I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x);
1494N/A
1494N/A linear_offset = y * fb->pitches[0] + x * pixel_size;
1494N/A sprsurf_offset =
1494N/A intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode,
1494N/A pixel_size, fb->pitches[0]);
1494N/A linear_offset -= sprsurf_offset;
1494N/A
1494N/A /* HSW consolidates SPRTILEOFF and SPRLINOFF into a single SPROFFSET
1494N/A * register */
1494N/A if (IS_HASWELL(dev))
1494N/A I915_WRITE(SPROFFSET(pipe), (y << 16) | x);
1494N/A else if (obj->tiling_mode != I915_TILING_NONE)
1494N/A I915_WRITE(SPRTILEOFF(pipe), (y << 16) | x);
1494N/A else
1494N/A I915_WRITE(SPRLINOFF(pipe), linear_offset);
1494N/A
1494N/A I915_WRITE(SPRSIZE(pipe), (crtc_h << 16) | crtc_w);
1494N/A if (intel_plane->can_scale)
1494N/A I915_WRITE(SPRSCALE(pipe), sprscale);
1494N/A I915_WRITE(SPRCTL(pipe), sprctl);
1494N/A I915_MODIFY_DISPBASE(SPRSURF(pipe), obj->gtt_offset + sprsurf_offset);
1494N/A POSTING_READ(SPRSURF(pipe));
1494N/A
1494N/A /* potentially re-enable LP watermarks */
1494N/A if (scaling_was_enabled && !dev_priv->sprite_scaling_enabled)
1494N/A intel_update_watermarks(dev);
1494N/A}
1494N/A
1494N/Astatic void
1494N/Aivb_disable_plane(struct drm_plane *plane)
1494N/A{
1494N/A struct drm_device *dev = plane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane = to_intel_plane(plane);
1494N/A int pipe = intel_plane->pipe;
1494N/A bool scaling_was_enabled = (bool)dev_priv->sprite_scaling_enabled;
1494N/A
1494N/A I915_WRITE(SPRCTL(pipe), I915_READ(SPRCTL(pipe)) & ~SPRITE_ENABLE);
1494N/A /* Can't leave the scaler enabled... */
1494N/A if (intel_plane->can_scale)
1494N/A I915_WRITE(SPRSCALE(pipe), 0);
1494N/A /* Activate double buffered register update */
1494N/A I915_MODIFY_DISPBASE(SPRSURF(pipe), 0);
1494N/A POSTING_READ(SPRSURF(pipe));
1494N/A
1494N/A dev_priv->sprite_scaling_enabled &= ~(1 << pipe);
1494N/A
1494N/A intel_update_sprite_watermarks(dev, pipe, 0, 0, false);
1494N/A
1494N/A /* potentially re-enable LP watermarks */
1494N/A if (scaling_was_enabled && !dev_priv->sprite_scaling_enabled)
1494N/A intel_update_watermarks(dev);
1494N/A}
1494N/A
1494N/Astatic int
1494N/Aivb_update_colorkey(struct drm_plane *plane,
1494N/A struct drm_intel_sprite_colorkey *key)
1494N/A{
1494N/A struct drm_device *dev = plane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane;
1494N/A u32 sprctl;
1494N/A int ret = 0;
1494N/A
1494N/A intel_plane = to_intel_plane(plane);
1494N/A
1494N/A I915_WRITE(SPRKEYVAL(intel_plane->pipe), key->min_value);
1494N/A I915_WRITE(SPRKEYMAX(intel_plane->pipe), key->max_value);
1494N/A I915_WRITE(SPRKEYMSK(intel_plane->pipe), key->channel_mask);
1494N/A
1494N/A sprctl = I915_READ(SPRCTL(intel_plane->pipe));
1494N/A sprctl &= ~(SPRITE_SOURCE_KEY | SPRITE_DEST_KEY);
1494N/A if (key->flags & I915_SET_COLORKEY_DESTINATION)
1494N/A sprctl |= SPRITE_DEST_KEY;
1494N/A else if (key->flags & I915_SET_COLORKEY_SOURCE)
1494N/A sprctl |= SPRITE_SOURCE_KEY;
1494N/A I915_WRITE(SPRCTL(intel_plane->pipe), sprctl);
1494N/A
1494N/A POSTING_READ(SPRKEYMSK(intel_plane->pipe));
1494N/A
1494N/A return ret;
1494N/A}
1494N/A
1494N/Astatic void
1494N/Aivb_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key)
1494N/A{
1494N/A struct drm_device *dev = plane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane;
1494N/A u32 sprctl;
1494N/A
1494N/A intel_plane = to_intel_plane(plane);
1494N/A
1494N/A key->min_value = I915_READ(SPRKEYVAL(intel_plane->pipe));
1494N/A key->max_value = I915_READ(SPRKEYMAX(intel_plane->pipe));
1494N/A key->channel_mask = I915_READ(SPRKEYMSK(intel_plane->pipe));
1494N/A key->flags = 0;
1494N/A
1494N/A sprctl = I915_READ(SPRCTL(intel_plane->pipe));
1494N/A
1494N/A if (sprctl & SPRITE_DEST_KEY)
1494N/A key->flags = I915_SET_COLORKEY_DESTINATION;
1494N/A else if (sprctl & SPRITE_SOURCE_KEY)
1494N/A key->flags = I915_SET_COLORKEY_SOURCE;
1494N/A else
1494N/A key->flags = I915_SET_COLORKEY_NONE;
1494N/A}
1494N/A
1494N/Astatic void
1494N/Ailk_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
1494N/A struct drm_i915_gem_object *obj, int crtc_x, int crtc_y,
1494N/A unsigned int crtc_w, unsigned int crtc_h,
1494N/A int x, int y,
1494N/A uint32_t src_w, uint32_t src_h)
1494N/A{
1494N/A struct drm_device *dev = plane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane = to_intel_plane(plane);
1494N/A int pipe = intel_plane->pipe;
1494N/A unsigned long dvssurf_offset, linear_offset;
1494N/A u32 dvscntr, dvsscale;
1494N/A int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
1494N/A
1494N/A dvscntr = I915_READ(DVSCNTR(pipe));
1494N/A
1494N/A /* Mask out pixel format bits in case we change it */
1494N/A dvscntr &= ~DVS_PIXFORMAT_MASK;
1494N/A dvscntr &= ~DVS_RGB_ORDER_XBGR;
1494N/A dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK;
1494N/A dvscntr &= ~DVS_TILED;
1494N/A
1494N/A switch (fb->pixel_format) {
1494N/A case DRM_FORMAT_XBGR8888:
1494N/A dvscntr |= DVS_FORMAT_RGBX888 | DVS_RGB_ORDER_XBGR;
1494N/A break;
1494N/A case DRM_FORMAT_XRGB8888:
1494N/A dvscntr |= DVS_FORMAT_RGBX888;
1494N/A break;
1494N/A case DRM_FORMAT_YUYV:
1494N/A dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YUYV;
1494N/A break;
1494N/A case DRM_FORMAT_YVYU:
1494N/A dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YVYU;
1494N/A break;
1494N/A case DRM_FORMAT_UYVY:
1494N/A dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_UYVY;
1494N/A break;
1494N/A case DRM_FORMAT_VYUY:
1494N/A dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_VYUY;
1494N/A break;
1494N/A default:
1494N/A BUG();
1494N/A }
1494N/A
1494N/A if (obj->tiling_mode != I915_TILING_NONE)
1494N/A dvscntr |= DVS_TILED;
1494N/A
1494N/A if (IS_GEN6(dev))
1494N/A dvscntr |= DVS_TRICKLE_FEED_DISABLE; /* must disable */
1494N/A dvscntr |= DVS_ENABLE;
1494N/A
1494N/A /* Sizes are 0 based */
1494N/A src_w--;
1494N/A src_h--;
1494N/A crtc_w--;
1494N/A crtc_h--;
1494N/A
1494N/A intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size, true);
1494N/A
1494N/A dvsscale = 0;
1494N/A if (IS_GEN5(dev) || crtc_w != src_w || crtc_h != src_h)
1494N/A dvsscale = DVS_SCALE_ENABLE | (src_w << 16) | src_h;
1494N/A
1494N/A I915_WRITE(DVSSTRIDE(pipe), fb->pitches[0]);
1494N/A I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x);
1494N/A linear_offset = y * fb->pitches[0] + x * pixel_size;
1494N/A dvssurf_offset =
1494N/A intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode,
1494N/A pixel_size, fb->pitches[0]);
1494N/A linear_offset -= dvssurf_offset;
1494N/A
1494N/A if (obj->tiling_mode != I915_TILING_NONE)
1494N/A I915_WRITE(DVSTILEOFF(pipe), (y << 16) | x);
1494N/A else
1494N/A I915_WRITE(DVSLINOFF(pipe), linear_offset);
1494N/A
1494N/A I915_WRITE(DVSSIZE(pipe), (crtc_h << 16) | crtc_w);
1494N/A I915_WRITE(DVSSCALE(pipe), dvsscale);
1494N/A I915_WRITE(DVSCNTR(pipe), dvscntr);
1494N/A I915_MODIFY_DISPBASE(DVSSURF(pipe), obj->gtt_offset + dvssurf_offset);
1494N/A POSTING_READ(DVSSURF(pipe));
1494N/A}
1494N/A
1494N/Astatic void
1494N/Ailk_disable_plane(struct drm_plane *plane)
1494N/A{
1494N/A struct drm_device *dev = plane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane = to_intel_plane(plane);
1494N/A int pipe = intel_plane->pipe;
1494N/A
1494N/A I915_WRITE(DVSCNTR(pipe), I915_READ(DVSCNTR(pipe)) & ~DVS_ENABLE);
1494N/A /* Disable the scaler */
1494N/A I915_WRITE(DVSSCALE(pipe), 0);
1494N/A /* Flush double buffered register updates */
1494N/A I915_MODIFY_DISPBASE(DVSSURF(pipe), 0);
1494N/A POSTING_READ(DVSSURF(pipe));
1494N/A}
1494N/A
1494N/Astatic void
1494N/Aintel_enable_primary(struct drm_crtc *crtc)
1494N/A{
1494N/A struct drm_device *dev = crtc->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1494N/A int reg = DSPCNTR(intel_crtc->plane);
1494N/A
1494N/A if (!intel_crtc->primary_disabled)
1494N/A return;
1494N/A
1494N/A intel_crtc->primary_disabled = false;
1494N/A intel_update_fbc(dev);
1494N/A
1494N/A I915_WRITE(reg, I915_READ(reg) | DISPLAY_PLANE_ENABLE);
1494N/A}
1494N/A
1494N/Astatic void
1494N/Aintel_disable_primary(struct drm_crtc *crtc)
1494N/A{
1494N/A struct drm_device *dev = crtc->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1494N/A int reg = DSPCNTR(intel_crtc->plane);
1494N/A
1494N/A if (intel_crtc->primary_disabled)
1494N/A return;
1494N/A
1494N/A I915_WRITE(reg, I915_READ(reg) & ~DISPLAY_PLANE_ENABLE);
1494N/A
1494N/A intel_crtc->primary_disabled = true;
1494N/A intel_update_fbc(dev);
1494N/A}
1494N/A
1494N/Astatic int
1494N/Ailk_update_colorkey(struct drm_plane *plane,
1494N/A struct drm_intel_sprite_colorkey *key)
1494N/A{
1494N/A struct drm_device *dev = plane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane;
1494N/A u32 dvscntr;
1494N/A int ret = 0;
1494N/A
1494N/A intel_plane = to_intel_plane(plane);
1494N/A
1494N/A I915_WRITE(DVSKEYVAL(intel_plane->pipe), key->min_value);
1494N/A I915_WRITE(DVSKEYMAX(intel_plane->pipe), key->max_value);
1494N/A I915_WRITE(DVSKEYMSK(intel_plane->pipe), key->channel_mask);
1494N/A
1494N/A dvscntr = I915_READ(DVSCNTR(intel_plane->pipe));
1494N/A dvscntr &= ~(DVS_SOURCE_KEY | DVS_DEST_KEY);
1494N/A if (key->flags & I915_SET_COLORKEY_DESTINATION)
1494N/A dvscntr |= DVS_DEST_KEY;
1494N/A else if (key->flags & I915_SET_COLORKEY_SOURCE)
1494N/A dvscntr |= DVS_SOURCE_KEY;
1494N/A I915_WRITE(DVSCNTR(intel_plane->pipe), dvscntr);
1494N/A
1494N/A POSTING_READ(DVSKEYMSK(intel_plane->pipe));
1494N/A
1494N/A return ret;
1494N/A}
1494N/A
1494N/Astatic void
1494N/Ailk_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key)
1494N/A{
1494N/A struct drm_device *dev = plane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_plane *intel_plane;
1494N/A u32 dvscntr;
1494N/A
1494N/A intel_plane = to_intel_plane(plane);
1494N/A
1494N/A key->min_value = I915_READ(DVSKEYVAL(intel_plane->pipe));
1494N/A key->max_value = I915_READ(DVSKEYMAX(intel_plane->pipe));
1494N/A key->channel_mask = I915_READ(DVSKEYMSK(intel_plane->pipe));
1494N/A key->flags = 0;
1494N/A
1494N/A dvscntr = I915_READ(DVSCNTR(intel_plane->pipe));
1494N/A
1494N/A if (dvscntr & DVS_DEST_KEY)
1494N/A key->flags = I915_SET_COLORKEY_DESTINATION;
1494N/A else if (dvscntr & DVS_SOURCE_KEY)
1494N/A key->flags = I915_SET_COLORKEY_SOURCE;
1494N/A else
1494N/A key->flags = I915_SET_COLORKEY_NONE;
1494N/A}
1494N/A
1494N/Astatic bool
1494N/Aformat_is_yuv(uint32_t format)
1494N/A{
1494N/A switch (format) {
1494N/A case DRM_FORMAT_YUYV:
1494N/A case DRM_FORMAT_UYVY:
1494N/A case DRM_FORMAT_VYUY:
1494N/A case DRM_FORMAT_YVYU:
1494N/A return true;
1494N/A default:
1494N/A return false;
1494N/A }
1494N/A}
1494N/A
1494N/Astatic int
1494N/Aintel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
1494N/A struct drm_framebuffer *fb, int crtc_x, int crtc_y,
1494N/A unsigned int crtc_w, unsigned int crtc_h,
1494N/A uint32_t src_x, uint32_t src_y,
1494N/A uint32_t src_w, uint32_t src_h)
1494N/A{
1494N/A struct drm_device *dev = plane->dev;
1494N/A struct drm_i915_private *dev_priv = dev->dev_private;
1494N/A struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1494N/A struct intel_plane *intel_plane = to_intel_plane(plane);
1494N/A struct intel_framebuffer *intel_fb;
1494N/A struct drm_i915_gem_object *obj, *old_obj;
1494N/A int pipe = intel_plane->pipe;
1494N/A enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv,
1494N/A pipe);
1494N/A int ret = 0;
1494N/A bool disable_primary = false;
1494N/A bool visible;
1494N/A int hscale, vscale;
1494N/A int max_scale, min_scale;
1494N/A int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
1494N/A struct drm_rect src = {
1494N/A /* sample coordinates in 16.16 fixed point */
1494N/A .x1 = src_x,
1494N/A .x2 = src_x + src_w,
1494N/A .y1 = src_y,
1494N/A .y2 = src_y + src_h,
1494N/A };
1494N/A struct drm_rect dst = {
1494N/A /* integer pixels */
1494N/A .x1 = crtc_x,
1494N/A .x2 = crtc_x + crtc_w,
1494N/A .y1 = crtc_y,
1494N/A .y2 = crtc_y + crtc_h,
1494N/A };
1494N/A const struct drm_rect clip = {
1494N/A .x2 = crtc->mode.hdisplay,
1494N/A .y2 = crtc->mode.vdisplay,
1494N/A };
1494N/A
1494N/A intel_fb = to_intel_framebuffer(fb);
1494N/A obj = intel_fb->obj;
1494N/A
1494N/A old_obj = intel_plane->obj;
1494N/A
1494N/A intel_plane->crtc_x = crtc_x;
1494N/A intel_plane->crtc_y = crtc_y;
1494N/A intel_plane->crtc_w = crtc_w;
1494N/A intel_plane->crtc_h = crtc_h;
1494N/A intel_plane->src_x = src_x;
1494N/A intel_plane->src_y = src_y;
1494N/A intel_plane->src_w = src_w;
1494N/A intel_plane->src_h = src_h;
1494N/A
1494N/A /* Pipe must be running... */
1494N/A if (!(I915_READ(PIPECONF(cpu_transcoder)) & PIPECONF_ENABLE)) {
1494N/A DRM_DEBUG_KMS("Pipe disabled\n");
1494N/A return -EINVAL;
1494N/A }
1494N/A
1494N/A /* Don't modify another pipe's plane */
1494N/A if (intel_plane->pipe != intel_crtc->pipe) {
1494N/A DRM_DEBUG_KMS("Wrong plane <-> crtc mapping\n");
1494N/A return -EINVAL;
1494N/A }
1494N/A
1494N/A /* FIXME check all gen limits */
1494N/A if (fb->width < 3 || fb->height < 3 || fb->pitches[0] > 16384) {
1494N/A DRM_DEBUG_KMS("Unsuitable framebuffer for plane\n");
1494N/A return -EINVAL;
1494N/A }
1494N/A
1494N/A /* Sprite planes can be linear or x-tiled surfaces */
1494N/A switch (obj->tiling_mode) {
1494N/A case I915_TILING_NONE:
1494N/A case I915_TILING_X:
1494N/A break;
1494N/A default:
1494N/A DRM_DEBUG_KMS("Unsupported tiling mode\n");
1494N/A return -EINVAL;
1494N/A }
1494N/A
1494N/A /*
1494N/A * FIXME the following code does a bunch of fuzzy adjustments to the
1494N/A * coordinates and sizes. We probably need some way to decide whether
1494N/A * more strict checking should be done instead.
1494N/A */
1494N/A max_scale = intel_plane->max_downscale << 16;
1494N/A min_scale = intel_plane->can_scale ? 1 : (1 << 16);
1494N/A
1494N/A hscale = drm_rect_calc_hscale_relaxed(&src, &dst, min_scale, max_scale);
1494N/A BUG_ON(hscale < 0);
1494N/A
1494N/A vscale = drm_rect_calc_vscale_relaxed(&src, &dst, min_scale, max_scale);
1494N/A BUG_ON(vscale < 0);
1494N/A
1494N/A visible = drm_rect_clip_scaled(&src, &dst, &clip, hscale, vscale);
1494N/A
1494N/A crtc_x = dst.x1;
1494N/A crtc_y = dst.y1;
1494N/A crtc_w = drm_rect_width(&dst);
1494N/A crtc_h = drm_rect_height(&dst);
1494N/A
1494N/A if (visible) {
1494N/A /* check again in case clipping clamped the results */
1494N/A hscale = drm_rect_calc_hscale(&src, &dst, min_scale, max_scale);
1494N/A if (hscale < 0) {
1494N/A DRM_DEBUG_KMS("Horizontal scaling factor out of limits\n");
1494N/A drm_rect_debug_print(&src, true);
1494N/A drm_rect_debug_print(&dst, false);
1494N/A
1494N/A return hscale;
1494N/A }
1494N/A
1494N/A vscale = drm_rect_calc_vscale(&src, &dst, min_scale, max_scale);
1494N/A if (vscale < 0) {
1494N/A DRM_DEBUG_KMS("Vertical scaling factor out of limits\n");
1494N/A drm_rect_debug_print(&src, true);
1494N/A drm_rect_debug_print(&dst, false);
1494N/A
1494N/A return vscale;
1494N/A }
1494N/A
1494N/A /* Make the source viewport size an exact multiple of the scaling factors. */
1494N/A drm_rect_adjust_size(&src,
1494N/A drm_rect_width(&dst) * hscale - drm_rect_width(&src),
1494N/A drm_rect_height(&dst) * vscale - drm_rect_height(&src));
1494N/A
1494N/A /* sanity check to make sure the src viewport wasn't enlarged */
1494N/A WARN_ON(src.x1 < (int) src_x ||
1494N/A src.y1 < (int) src_y ||
1494N/A src.x2 > (int) (src_x + src_w) ||
1494N/A src.y2 > (int) (src_y + src_h));
1494N/A
1494N/A /*
1494N/A * Hardware doesn't handle subpixel coordinates.
1494N/A * Adjust to (macro)pixel boundary, but be careful not to
1494N/A * increase the source viewport size, because that could
1494N/A * push the downscaling factor out of bounds.
1494N/A */
1494N/A src_x = src.x1 >> 16;
1494N/A src_w = drm_rect_width(&src) >> 16;
1494N/A src_y = src.y1 >> 16;
1494N/A src_h = drm_rect_height(&src) >> 16;
1494N/A
1494N/A if (format_is_yuv(fb->pixel_format)) {
1494N/A src_x &= ~1;
1494N/A src_w &= ~1;
1494N/A
1494N/A /*
1494N/A * Must keep src and dst the
1494N/A * same if we can't scale.
1494N/A */
1494N/A if (!intel_plane->can_scale)
1494N/A crtc_w &= ~1;
1494N/A
1494N/A if (crtc_w == 0)
1494N/A visible = false;
1494N/A }
1494N/A }
1494N/A
1494N/A /* Check size restrictions when scaling */
1494N/A if (visible && (src_w != crtc_w || src_h != crtc_h)) {
1494N/A unsigned int width_bytes;
1494N/A
1494N/A WARN_ON(!intel_plane->can_scale);
1494N/A
1494N/A /* FIXME interlacing min height is 6 */
1494N/A
1494N/A if (crtc_w < 3 || crtc_h < 3)
1494N/A visible = false;
1494N/A
1494N/A if (src_w < 3 || src_h < 3)
1494N/A visible = false;
1494N/A
1494N/A width_bytes = ((src_x * pixel_size) & 63) + src_w * pixel_size;
1494N/A
1494N/A if (src_w > 2048 || src_h > 2048 ||
1494N/A width_bytes > 4096 || fb->pitches[0] > 4096) {
1494N/A DRM_DEBUG_KMS("Source dimensions exceed hardware limits\n");
1494N/A return -EINVAL;
1494N/A }
1494N/A }
1494N/A
1494N/A dst.x1 = crtc_x;
1494N/A dst.x2 = crtc_x + crtc_w;
1494N/A dst.y1 = crtc_y;
1494N/A dst.y2 = crtc_y + crtc_h;
1494N/A
1494N/A /*
1494N/A * If the sprite is completely covering the primary plane,
1494N/A * we can disable the primary and save power.
1494N/A */
1494N/A disable_primary = drm_rect_equals(&dst, &clip);
1494N/A WARN_ON(disable_primary && !visible);
1494N/A
1494N/A mutex_lock(&dev->struct_mutex);
1494N/A
1494N/A /* Note that this will apply the VT-d workaround for scanouts,
1494N/A * which is more restrictive than required for sprites. (The
1494N/A * primary plane requires 256KiB alignment with 64 PTE padding,
1494N/A * the sprite planes only require 128KiB alignment and 32 PTE padding.
1494N/A */
1494N/A ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
1494N/A if (ret)
1494N/A goto out_unlock;
1494N/A
1494N/A intel_plane->obj = obj;
1494N/A
1494N/A /*
1494N/A * Be sure to re-enable the primary before the sprite is no longer
1494N/A * covering it fully.
1494N/A */
1494N/A if (!disable_primary)
1494N/A intel_enable_primary(crtc);
1494N/A
1494N/A if (visible)
1494N/A intel_plane->update_plane(plane, fb, obj,
1494N/A crtc_x, crtc_y, crtc_w, crtc_h,
1494N/A src_x, src_y, src_w, src_h);
1494N/A else
1494N/A intel_plane->disable_plane(plane);
1494N/A
1494N/A if (disable_primary)
1494N/A intel_disable_primary(crtc);
1494N/A
1494N/A /* Unpin old obj after new one is active to avoid ugliness */
1494N/A if (old_obj) {
1494N/A /*
1494N/A * It's fairly common to simply update the position of
1494N/A * an existing object. In that case, we don't need to
1494N/A * wait for vblank to avoid ugliness, we only need to
1494N/A * do the pin & ref bookkeeping.
1494N/A */
1494N/A if (old_obj != obj) {
1494N/A mutex_unlock(&dev->struct_mutex);
1494N/A intel_wait_for_vblank(dev, to_intel_crtc(crtc)->pipe);
1494N/A mutex_lock(&dev->struct_mutex);
1494N/A }
1494N/A intel_unpin_fb_obj(old_obj);
1494N/A }
1494N/A
1494N/Aout_unlock:
1494N/A mutex_unlock(&dev->struct_mutex);
1494N/A return ret;
1494N/A}
1494N/A
1494N/Astatic int
1494N/Aintel_disable_plane(struct drm_plane *plane)
1494N/A{
1494N/A struct drm_device *dev = plane->dev;
1494N/A struct intel_plane *intel_plane = to_intel_plane(plane);
1494N/A int ret = 0;
1494N/A
1494N/A if (plane->crtc)
1494N/A intel_enable_primary(plane->crtc);
1494N/A intel_plane->disable_plane(plane);
1494N/A
1494N/A if (!intel_plane->obj)
1494N/A goto out;
1494N/A
1494N/A intel_wait_for_vblank(dev, intel_plane->pipe);
1494N/A
1494N/A mutex_lock(&dev->struct_mutex);
1494N/A intel_unpin_fb_obj(intel_plane->obj);
1494N/A intel_plane->obj = NULL;
1494N/A mutex_unlock(&dev->struct_mutex);
1494N/Aout:
1494N/A
1494N/A return ret;
1494N/A}
1494N/A
1494N/Astatic void intel_destroy_plane(struct drm_plane *plane)
1494N/A{
1494N/A struct intel_plane *intel_plane = to_intel_plane(plane);
1494N/A intel_disable_plane(plane);
1494N/A drm_plane_cleanup(plane);
1494N/A kfree(intel_plane, sizeof(struct intel_plane));
1494N/A}
1494N/A
1494N/Aint intel_sprite_set_colorkey(DRM_IOCTL_ARGS)
1494N/A{
1494N/A struct drm_intel_sprite_colorkey *set = data;
1494N/A struct drm_mode_object *obj;
1494N/A struct drm_plane *plane;
1494N/A struct intel_plane *intel_plane;
1494N/A int ret = 0;
1494N/A
1494N/A if (!drm_core_check_feature(dev, DRIVER_MODESET))
1494N/A return -ENODEV;
1494N/A
1494N/A /* Make sure we don't try to enable both src & dest simultaneously */
1494N/A if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE))
1494N/A return -EINVAL;
1494N/A
1494N/A drm_modeset_lock_all(dev);
1494N/A
1494N/A obj = drm_mode_object_find(dev, set->plane_id, DRM_MODE_OBJECT_PLANE);
1494N/A if (!obj) {
1494N/A ret = -EINVAL;
1494N/A goto out_unlock;
1494N/A }
1494N/A
1494N/A plane = obj_to_plane(obj);
1494N/A intel_plane = to_intel_plane(plane);
1494N/A ret = intel_plane->update_colorkey(plane, set);
1494N/A
1494N/Aout_unlock:
1494N/A drm_modeset_unlock_all(dev);
1494N/A return ret;
1494N/A}
1494N/A
1494N/Aint intel_sprite_get_colorkey(DRM_IOCTL_ARGS)
1494N/A{
1494N/A struct drm_intel_sprite_colorkey *get = data;
1494N/A struct drm_mode_object *obj;
1494N/A struct drm_plane *plane;
1494N/A struct intel_plane *intel_plane;
1494N/A int ret = 0;
1494N/A
1494N/A if (!drm_core_check_feature(dev, DRIVER_MODESET))
1494N/A return -ENODEV;
1494N/A
1494N/A drm_modeset_lock_all(dev);
1494N/A obj = drm_mode_object_find(dev, get->plane_id, DRM_MODE_OBJECT_PLANE);
1494N/A if (!obj) {
1494N/A ret = -EINVAL;
1494N/A goto out_unlock;
1494N/A }
1494N/A
1494N/A plane = obj_to_plane(obj);
1494N/A intel_plane = to_intel_plane(plane);
1494N/A intel_plane->get_colorkey(plane, get);
1494N/A
1494N/Aout_unlock:
1494N/A drm_modeset_unlock_all(dev);
1494N/A return ret;
1494N/A}
1494N/A
1494N/Avoid intel_plane_restore(struct drm_plane *plane)
1494N/A{
1494N/A struct intel_plane *intel_plane = to_intel_plane(plane);
1494N/A
1494N/A if (!plane->crtc || !plane->fb)
1494N/A return;
1494N/A
1494N/A intel_update_plane(plane, plane->crtc, plane->fb,
1494N/A intel_plane->crtc_x, intel_plane->crtc_y,
1494N/A intel_plane->crtc_w, intel_plane->crtc_h,
1494N/A intel_plane->src_x, intel_plane->src_y,
1494N/A intel_plane->src_w, intel_plane->src_h);
1494N/A}
1494N/A
1494N/Avoid intel_plane_disable(struct drm_plane *plane)
1494N/A{
1494N/A if (!plane->crtc || !plane->fb)
1494N/A return;
1494N/A
1494N/A intel_disable_plane(plane);
1494N/A}
1494N/A
1494N/Astatic const struct drm_plane_funcs intel_plane_funcs = {
1494N/A .update_plane = intel_update_plane,
1494N/A .disable_plane = intel_disable_plane,
1494N/A .destroy = intel_destroy_plane,
1494N/A};
1494N/A
1494N/Astatic uint32_t ilk_plane_formats[] = {
1494N/A DRM_FORMAT_XRGB8888,
1494N/A DRM_FORMAT_YUYV,
1494N/A DRM_FORMAT_YVYU,
1494N/A DRM_FORMAT_UYVY,
1494N/A DRM_FORMAT_VYUY,
1494N/A};
1494N/A
1494N/Astatic uint32_t snb_plane_formats[] = {
1494N/A DRM_FORMAT_XBGR8888,
1494N/A DRM_FORMAT_XRGB8888,
1494N/A DRM_FORMAT_YUYV,
1494N/A DRM_FORMAT_YVYU,
1494N/A DRM_FORMAT_UYVY,
1494N/A DRM_FORMAT_VYUY,
1494N/A};
1494N/A
1494N/Astatic uint32_t vlv_plane_formats[] = {
1494N/A DRM_FORMAT_RGB565,
1494N/A DRM_FORMAT_ABGR8888,
1494N/A DRM_FORMAT_ARGB8888,
1494N/A DRM_FORMAT_XBGR8888,
1494N/A DRM_FORMAT_XRGB8888,
1494N/A DRM_FORMAT_XBGR2101010,
1494N/A DRM_FORMAT_ABGR2101010,
1494N/A DRM_FORMAT_YUYV,
1494N/A DRM_FORMAT_YVYU,
1494N/A DRM_FORMAT_UYVY,
1494N/A DRM_FORMAT_VYUY,
1494N/A};
1494N/A
1494N/Aint
1494N/Aintel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
1494N/A{
1494N/A struct intel_plane *intel_plane;
1494N/A unsigned long possible_crtcs;
1494N/A const uint32_t *plane_formats;
1494N/A int num_plane_formats;
1494N/A int ret;
1494N/A
1494N/A if (INTEL_INFO(dev)->gen < 5)
1494N/A return -ENODEV;
1494N/A
1494N/A intel_plane = kzalloc(sizeof(struct intel_plane), GFP_KERNEL);
1494N/A if (!intel_plane)
1494N/A return -ENOMEM;
1494N/A
1494N/A switch (INTEL_INFO(dev)->gen) {
1494N/A case 5:
1494N/A case 6:
1494N/A intel_plane->can_scale = true;
1494N/A intel_plane->max_downscale = 16;
1494N/A intel_plane->update_plane = ilk_update_plane;
1494N/A intel_plane->disable_plane = ilk_disable_plane;
1494N/A intel_plane->update_colorkey = ilk_update_colorkey;
1494N/A intel_plane->get_colorkey = ilk_get_colorkey;
1494N/A
1494N/A if (IS_GEN6(dev)) {
1494N/A plane_formats = snb_plane_formats;
1494N/A num_plane_formats = ARRAY_SIZE(snb_plane_formats);
1494N/A } else {
1494N/A plane_formats = ilk_plane_formats;
1494N/A num_plane_formats = ARRAY_SIZE(ilk_plane_formats);
1494N/A }
1494N/A break;
1494N/A
1494N/A case 7:
1494N/A if (IS_IVYBRIDGE(dev)) {
1494N/A intel_plane->can_scale = true;
1494N/A intel_plane->max_downscale = 2;
1494N/A } else {
1494N/A intel_plane->can_scale = false;
1494N/A intel_plane->max_downscale = 1;
1494N/A }
1494N/A
1494N/A if (IS_VALLEYVIEW(dev)) {
1494N/A intel_plane->update_plane = vlv_update_plane;
1494N/A intel_plane->disable_plane = vlv_disable_plane;
1494N/A intel_plane->update_colorkey = vlv_update_colorkey;
1494N/A intel_plane->get_colorkey = vlv_get_colorkey;
1494N/A
1494N/A plane_formats = vlv_plane_formats;
1494N/A num_plane_formats = ARRAY_SIZE(vlv_plane_formats);
1494N/A } else {
1494N/A intel_plane->update_plane = ivb_update_plane;
1494N/A intel_plane->disable_plane = ivb_disable_plane;
1494N/A intel_plane->update_colorkey = ivb_update_colorkey;
1494N/A intel_plane->get_colorkey = ivb_get_colorkey;
1494N/A
1494N/A plane_formats = snb_plane_formats;
1494N/A num_plane_formats = ARRAY_SIZE(snb_plane_formats);
1494N/A }
1494N/A break;
1494N/A
1494N/A default:
1494N/A kfree(intel_plane, sizeof(struct intel_plane));
1494N/A return -ENODEV;
1494N/A }
1494N/A
1494N/A intel_plane->pipe = pipe;
1494N/A intel_plane->plane = plane;
1494N/A possible_crtcs = (1 << pipe);
1494N/A ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
1494N/A &intel_plane_funcs,
1494N/A plane_formats, num_plane_formats,
1494N/A false);
1494N/A if (ret)
1494N/A kfree(intel_plane, sizeof(struct intel_plane));
1494N/A
1494N/A return ret;
1494N/A}
1494N/A