Commit 2fde1391 authored by Maarten Lankhorst's avatar Maarten Lankhorst

drm/i915: Use passed plane state for sprite planes, v4.

Don't use plane->state directly, use the pointer from commit_plane.

Changes since v1:
- Fix uses of plane->state->rotation and color key to use the passed state too.
- Only pass crtc_state and plane_state to update_plane.
Changes since v2:
- Rebased.
Changes since v3:
- Small whitespace changes and only assign 1 variable per line.
- Constify plane_state and crtc_state. (vsyrjala)
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1452164052-21752-2-git-send-email-maarten.lankhorst@linux.intel.comReviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
parent 396e33ae
...@@ -681,16 +681,12 @@ struct intel_plane { ...@@ -681,16 +681,12 @@ struct intel_plane {
/* /*
* NOTE: Do not place new plane state fields here (e.g., when adding * NOTE: Do not place new plane state fields here (e.g., when adding
* new plane properties). New runtime state should now be placed in * new plane properties). New runtime state should now be placed in
* the intel_plane_state structure and accessed via drm_plane->state. * the intel_plane_state structure and accessed via plane_state.
*/ */
void (*update_plane)(struct drm_plane *plane, void (*update_plane)(struct drm_plane *plane,
struct drm_crtc *crtc, const struct intel_crtc_state *crtc_state,
struct drm_framebuffer *fb, const struct intel_plane_state *plane_state);
int crtc_x, int crtc_y,
unsigned int crtc_w, unsigned int crtc_h,
uint32_t x, uint32_t y,
uint32_t src_w, uint32_t src_h);
void (*disable_plane)(struct drm_plane *plane, void (*disable_plane)(struct drm_plane *plane,
struct drm_crtc *crtc); struct drm_crtc *crtc);
int (*check_plane)(struct drm_plane *plane, int (*check_plane)(struct drm_plane *plane,
......
...@@ -178,28 +178,33 @@ void intel_pipe_update_end(struct intel_crtc *crtc) ...@@ -178,28 +178,33 @@ void intel_pipe_update_end(struct intel_crtc *crtc)
} }
static void static void
skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc, skl_update_plane(struct drm_plane *drm_plane,
struct drm_framebuffer *fb, const struct intel_crtc_state *crtc_state,
int crtc_x, int crtc_y, const struct intel_plane_state *plane_state)
unsigned int crtc_w, unsigned int crtc_h,
uint32_t x, uint32_t y,
uint32_t src_w, uint32_t src_h)
{ {
struct drm_device *dev = drm_plane->dev; struct drm_device *dev = drm_plane->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_plane *intel_plane = to_intel_plane(drm_plane); struct intel_plane *intel_plane = to_intel_plane(drm_plane);
struct drm_framebuffer *fb = plane_state->base.fb;
struct drm_i915_gem_object *obj = intel_fb_obj(fb); struct drm_i915_gem_object *obj = intel_fb_obj(fb);
const int pipe = intel_plane->pipe; const int pipe = intel_plane->pipe;
const int plane = intel_plane->plane + 1; const int plane = intel_plane->plane + 1;
u32 plane_ctl, stride_div, stride; u32 plane_ctl, stride_div, stride;
const struct drm_intel_sprite_colorkey *key = const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
&to_intel_plane_state(drm_plane->state)->ckey;
u32 surf_addr; u32 surf_addr;
u32 tile_height, plane_offset, plane_size; u32 tile_height, plane_offset, plane_size;
unsigned int rotation; unsigned int rotation;
int x_offset, y_offset; int x_offset, y_offset;
struct intel_crtc_state *crtc_state = to_intel_crtc(crtc)->config; int crtc_x = plane_state->dst.x1;
int scaler_id; int crtc_y = plane_state->dst.y1;
uint32_t crtc_w = drm_rect_width(&plane_state->dst);
uint32_t crtc_h = drm_rect_height(&plane_state->dst);
uint32_t x = plane_state->src.x1 >> 16;
uint32_t y = plane_state->src.y1 >> 16;
uint32_t src_w = drm_rect_width(&plane_state->src) >> 16;
uint32_t src_h = drm_rect_height(&plane_state->src) >> 16;
const struct intel_scaler *scaler =
&crtc_state->scaler_state.scalers[plane_state->scaler_id];
plane_ctl = PLANE_CTL_ENABLE | plane_ctl = PLANE_CTL_ENABLE |
PLANE_CTL_PIPE_GAMMA_ENABLE | PLANE_CTL_PIPE_GAMMA_ENABLE |
...@@ -208,14 +213,12 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc, ...@@ -208,14 +213,12 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
plane_ctl |= skl_plane_ctl_format(fb->pixel_format); plane_ctl |= skl_plane_ctl_format(fb->pixel_format);
plane_ctl |= skl_plane_ctl_tiling(fb->modifier[0]); plane_ctl |= skl_plane_ctl_tiling(fb->modifier[0]);
rotation = drm_plane->state->rotation; rotation = plane_state->base.rotation;
plane_ctl |= skl_plane_ctl_rotation(rotation); plane_ctl |= skl_plane_ctl_rotation(rotation);
stride_div = intel_fb_stride_alignment(dev, fb->modifier[0], stride_div = intel_fb_stride_alignment(dev, fb->modifier[0],
fb->pixel_format); fb->pixel_format);
scaler_id = to_intel_plane_state(drm_plane->state)->scaler_id;
/* Sizes are 0 based */ /* Sizes are 0 based */
src_w--; src_w--;
src_h--; src_h--;
...@@ -256,13 +259,13 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc, ...@@ -256,13 +259,13 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
I915_WRITE(PLANE_SIZE(pipe, plane), plane_size); I915_WRITE(PLANE_SIZE(pipe, plane), plane_size);
/* program plane scaler */ /* program plane scaler */
if (scaler_id >= 0) { if (plane_state->scaler_id >= 0) {
uint32_t ps_ctrl = 0; uint32_t ps_ctrl = 0;
int scaler_id = plane_state->scaler_id;
DRM_DEBUG_KMS("plane = %d PS_PLANE_SEL(plane) = 0x%x\n", plane, DRM_DEBUG_KMS("plane = %d PS_PLANE_SEL(plane) = 0x%x\n", plane,
PS_PLANE_SEL(plane)); PS_PLANE_SEL(plane));
ps_ctrl = PS_SCALER_EN | PS_PLANE_SEL(plane) | ps_ctrl = PS_SCALER_EN | PS_PLANE_SEL(plane) | scaler->mode;
crtc_state->scaler_state.scalers[scaler_id].mode;
I915_WRITE(SKL_PS_CTRL(pipe, scaler_id), ps_ctrl); I915_WRITE(SKL_PS_CTRL(pipe, scaler_id), ps_ctrl);
I915_WRITE(SKL_PS_PWR_GATE(pipe, scaler_id), 0); I915_WRITE(SKL_PS_PWR_GATE(pipe, scaler_id), 0);
I915_WRITE(SKL_PS_WIN_POS(pipe, scaler_id), (crtc_x << 16) | crtc_y); I915_WRITE(SKL_PS_WIN_POS(pipe, scaler_id), (crtc_x << 16) | crtc_y);
...@@ -334,24 +337,29 @@ chv_update_csc(struct intel_plane *intel_plane, uint32_t format) ...@@ -334,24 +337,29 @@ chv_update_csc(struct intel_plane *intel_plane, uint32_t format)
} }
static void static void
vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, vlv_update_plane(struct drm_plane *dplane,
struct drm_framebuffer *fb, const struct intel_crtc_state *crtc_state,
int crtc_x, int crtc_y, const struct intel_plane_state *plane_state)
unsigned int crtc_w, unsigned int crtc_h,
uint32_t x, uint32_t y,
uint32_t src_w, uint32_t src_h)
{ {
struct drm_device *dev = dplane->dev; struct drm_device *dev = dplane->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_plane *intel_plane = to_intel_plane(dplane); struct intel_plane *intel_plane = to_intel_plane(dplane);
struct drm_framebuffer *fb = plane_state->base.fb;
struct drm_i915_gem_object *obj = intel_fb_obj(fb); struct drm_i915_gem_object *obj = intel_fb_obj(fb);
int pipe = intel_plane->pipe; int pipe = intel_plane->pipe;
int plane = intel_plane->plane; int plane = intel_plane->plane;
u32 sprctl; u32 sprctl;
unsigned long sprsurf_offset, linear_offset; unsigned long sprsurf_offset, linear_offset;
int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
const struct drm_intel_sprite_colorkey *key = const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
&to_intel_plane_state(dplane->state)->ckey; int crtc_x = plane_state->dst.x1;
int crtc_y = plane_state->dst.y1;
uint32_t crtc_w = drm_rect_width(&plane_state->dst);
uint32_t crtc_h = drm_rect_height(&plane_state->dst);
uint32_t x = plane_state->src.x1 >> 16;
uint32_t y = plane_state->src.y1 >> 16;
uint32_t src_w = drm_rect_width(&plane_state->src) >> 16;
uint32_t src_h = drm_rect_height(&plane_state->src) >> 16;
sprctl = SP_ENABLE; sprctl = SP_ENABLE;
...@@ -421,7 +429,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, ...@@ -421,7 +429,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
fb->pitches[0]); fb->pitches[0]);
linear_offset -= sprsurf_offset; linear_offset -= sprsurf_offset;
if (dplane->state->rotation == BIT(DRM_ROTATE_180)) { if (plane_state->base.rotation == BIT(DRM_ROTATE_180)) {
sprctl |= SP_ROTATE_180; sprctl |= SP_ROTATE_180;
x += src_w; x += src_w;
...@@ -474,23 +482,28 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc) ...@@ -474,23 +482,28 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)
} }
static void static void
ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ivb_update_plane(struct drm_plane *plane,
struct drm_framebuffer *fb, const struct intel_crtc_state *crtc_state,
int crtc_x, int crtc_y, const struct intel_plane_state *plane_state)
unsigned int crtc_w, unsigned int crtc_h,
uint32_t x, uint32_t y,
uint32_t src_w, uint32_t src_h)
{ {
struct drm_device *dev = plane->dev; struct drm_device *dev = plane->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_plane *intel_plane = to_intel_plane(plane); struct intel_plane *intel_plane = to_intel_plane(plane);
struct drm_framebuffer *fb = plane_state->base.fb;
struct drm_i915_gem_object *obj = intel_fb_obj(fb); struct drm_i915_gem_object *obj = intel_fb_obj(fb);
enum pipe pipe = intel_plane->pipe; enum pipe pipe = intel_plane->pipe;
u32 sprctl, sprscale = 0; u32 sprctl, sprscale = 0;
unsigned long sprsurf_offset, linear_offset; unsigned long sprsurf_offset, linear_offset;
int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
const struct drm_intel_sprite_colorkey *key = const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
&to_intel_plane_state(plane->state)->ckey; int crtc_x = plane_state->dst.x1;
int crtc_y = plane_state->dst.y1;
uint32_t crtc_w = drm_rect_width(&plane_state->dst);
uint32_t crtc_h = drm_rect_height(&plane_state->dst);
uint32_t x = plane_state->src.x1 >> 16;
uint32_t y = plane_state->src.y1 >> 16;
uint32_t src_w = drm_rect_width(&plane_state->src) >> 16;
uint32_t src_h = drm_rect_height(&plane_state->src) >> 16;
sprctl = SPRITE_ENABLE; sprctl = SPRITE_ENABLE;
...@@ -550,7 +563,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -550,7 +563,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
pixel_size, fb->pitches[0]); pixel_size, fb->pitches[0]);
linear_offset -= sprsurf_offset; linear_offset -= sprsurf_offset;
if (plane->state->rotation == BIT(DRM_ROTATE_180)) { if (plane_state->base.rotation == BIT(DRM_ROTATE_180)) {
sprctl |= SPRITE_ROTATE_180; sprctl |= SPRITE_ROTATE_180;
/* HSW and BDW does this automagically in hardware */ /* HSW and BDW does this automagically in hardware */
...@@ -612,23 +625,28 @@ ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc) ...@@ -612,23 +625,28 @@ ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)
} }
static void static void
ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ilk_update_plane(struct drm_plane *plane,
struct drm_framebuffer *fb, const struct intel_crtc_state *crtc_state,
int crtc_x, int crtc_y, const struct intel_plane_state *plane_state)
unsigned int crtc_w, unsigned int crtc_h,
uint32_t x, uint32_t y,
uint32_t src_w, uint32_t src_h)
{ {
struct drm_device *dev = plane->dev; struct drm_device *dev = plane->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_plane *intel_plane = to_intel_plane(plane); struct intel_plane *intel_plane = to_intel_plane(plane);
struct drm_framebuffer *fb = plane_state->base.fb;
struct drm_i915_gem_object *obj = intel_fb_obj(fb); struct drm_i915_gem_object *obj = intel_fb_obj(fb);
int pipe = intel_plane->pipe; int pipe = intel_plane->pipe;
unsigned long dvssurf_offset, linear_offset; unsigned long dvssurf_offset, linear_offset;
u32 dvscntr, dvsscale; u32 dvscntr, dvsscale;
int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
const struct drm_intel_sprite_colorkey *key = const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
&to_intel_plane_state(plane->state)->ckey; int crtc_x = plane_state->dst.x1;
int crtc_y = plane_state->dst.y1;
uint32_t crtc_w = drm_rect_width(&plane_state->dst);
uint32_t crtc_h = drm_rect_height(&plane_state->dst);
uint32_t x = plane_state->src.x1 >> 16;
uint32_t y = plane_state->src.y1 >> 16;
uint32_t src_w = drm_rect_width(&plane_state->src) >> 16;
uint32_t src_h = drm_rect_height(&plane_state->src) >> 16;
dvscntr = DVS_ENABLE; dvscntr = DVS_ENABLE;
...@@ -684,7 +702,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -684,7 +702,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
pixel_size, fb->pitches[0]); pixel_size, fb->pitches[0]);
linear_offset -= dvssurf_offset; linear_offset -= dvssurf_offset;
if (plane->state->rotation == BIT(DRM_ROTATE_180)) { if (plane_state->base.rotation == BIT(DRM_ROTATE_180)) {
dvscntr |= DVS_ROTATE_180; dvscntr |= DVS_ROTATE_180;
x += src_w; x += src_w;
...@@ -917,23 +935,17 @@ static void ...@@ -917,23 +935,17 @@ static void
intel_commit_sprite_plane(struct drm_plane *plane, intel_commit_sprite_plane(struct drm_plane *plane,
struct intel_plane_state *state) struct intel_plane_state *state)
{ {
struct drm_crtc *crtc = state->base.crtc;
struct intel_plane *intel_plane = to_intel_plane(plane); struct intel_plane *intel_plane = to_intel_plane(plane);
struct drm_framebuffer *fb = state->base.fb;
crtc = crtc ? crtc : plane->crtc;
if (state->visible) { if (state->visible) {
intel_plane->update_plane(plane, crtc, fb, struct intel_crtc_state *crtc_state =
state->dst.x1, state->dst.y1, to_intel_crtc(state->base.crtc)->config;
drm_rect_width(&state->dst),
drm_rect_height(&state->dst), intel_plane->update_plane(plane, crtc_state, state);
state->src.x1 >> 16,
state->src.y1 >> 16,
drm_rect_width(&state->src) >> 16,
drm_rect_height(&state->src) >> 16);
} else { } else {
intel_plane->disable_plane(plane, crtc); struct drm_crtc *crtc = state->base.crtc;
intel_plane->disable_plane(plane, crtc ?: plane->crtc);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment