diff options
author | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2018-11-14 06:49:23 -0500 |
---|---|---|
committer | Joonas Lahtinen <joonas.lahtinen@linux.intel.com> | 2018-11-15 06:56:14 -0500 |
commit | 2a2777990a342b05f611e78822fc4fa2d9789ade (patch) | |
tree | f37037e56ed6a818ed58424318adf92ed164f3da | |
parent | a22612301ae61d78a7c0c82dc556931a35db0e91 (diff) |
drm/i915: Move programming plane scaler to its own function.
This cleans the code up slightly, and will make other changes easier.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180920102711.4184-8-maarten.lankhorst@linux.intel.com
(cherry picked from commit ab5c60bf76755d24ae8de5c1c6ac594934656ace)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
-rw-r--r-- | drivers/gpu/drm/i915/intel_sprite.c | 90 |
1 files changed, 52 insertions, 38 deletions
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 5fd2f7bf3927..873adcc20109 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c | |||
@@ -302,13 +302,63 @@ skl_plane_max_stride(struct intel_plane *plane, | |||
302 | return min(8192 * cpp, 32768); | 302 | return min(8192 * cpp, 32768); |
303 | } | 303 | } |
304 | 304 | ||
305 | static void | ||
306 | skl_program_scaler(struct drm_i915_private *dev_priv, | ||
307 | struct intel_plane *plane, | ||
308 | const struct intel_crtc_state *crtc_state, | ||
309 | const struct intel_plane_state *plane_state) | ||
310 | { | ||
311 | enum plane_id plane_id = plane->id; | ||
312 | enum pipe pipe = plane->pipe; | ||
313 | int scaler_id = plane_state->scaler_id; | ||
314 | const struct intel_scaler *scaler = | ||
315 | &crtc_state->scaler_state.scalers[scaler_id]; | ||
316 | int crtc_x = plane_state->base.dst.x1; | ||
317 | int crtc_y = plane_state->base.dst.y1; | ||
318 | uint32_t crtc_w = drm_rect_width(&plane_state->base.dst); | ||
319 | uint32_t crtc_h = drm_rect_height(&plane_state->base.dst); | ||
320 | u16 y_hphase, uv_rgb_hphase; | ||
321 | u16 y_vphase, uv_rgb_vphase; | ||
322 | |||
323 | /* Sizes are 0 based */ | ||
324 | crtc_w--; | ||
325 | crtc_h--; | ||
326 | |||
327 | /* TODO: handle sub-pixel coordinates */ | ||
328 | if (plane_state->base.fb->format->format == DRM_FORMAT_NV12) { | ||
329 | y_hphase = skl_scaler_calc_phase(1, false); | ||
330 | y_vphase = skl_scaler_calc_phase(1, false); | ||
331 | |||
332 | /* MPEG2 chroma siting convention */ | ||
333 | uv_rgb_hphase = skl_scaler_calc_phase(2, true); | ||
334 | uv_rgb_vphase = skl_scaler_calc_phase(2, false); | ||
335 | } else { | ||
336 | /* not used */ | ||
337 | y_hphase = 0; | ||
338 | y_vphase = 0; | ||
339 | |||
340 | uv_rgb_hphase = skl_scaler_calc_phase(1, false); | ||
341 | uv_rgb_vphase = skl_scaler_calc_phase(1, false); | ||
342 | } | ||
343 | |||
344 | I915_WRITE_FW(SKL_PS_CTRL(pipe, scaler_id), | ||
345 | PS_SCALER_EN | PS_PLANE_SEL(plane_id) | scaler->mode); | ||
346 | I915_WRITE_FW(SKL_PS_PWR_GATE(pipe, scaler_id), 0); | ||
347 | I915_WRITE_FW(SKL_PS_VPHASE(pipe, scaler_id), | ||
348 | PS_Y_PHASE(y_vphase) | PS_UV_RGB_PHASE(uv_rgb_vphase)); | ||
349 | I915_WRITE_FW(SKL_PS_HPHASE(pipe, scaler_id), | ||
350 | PS_Y_PHASE(y_hphase) | PS_UV_RGB_PHASE(uv_rgb_hphase)); | ||
351 | I915_WRITE_FW(SKL_PS_WIN_POS(pipe, scaler_id), (crtc_x << 16) | crtc_y); | ||
352 | I915_WRITE_FW(SKL_PS_WIN_SZ(pipe, scaler_id), | ||
353 | ((crtc_w + 1) << 16)|(crtc_h + 1)); | ||
354 | } | ||
355 | |||
305 | void | 356 | void |
306 | skl_update_plane(struct intel_plane *plane, | 357 | skl_update_plane(struct intel_plane *plane, |
307 | const struct intel_crtc_state *crtc_state, | 358 | const struct intel_crtc_state *crtc_state, |
308 | const struct intel_plane_state *plane_state) | 359 | const struct intel_plane_state *plane_state) |
309 | { | 360 | { |
310 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); | 361 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
311 | const struct drm_framebuffer *fb = plane_state->base.fb; | ||
312 | enum plane_id plane_id = plane->id; | 362 | enum plane_id plane_id = plane->id; |
313 | enum pipe pipe = plane->pipe; | 363 | enum pipe pipe = plane->pipe; |
314 | u32 plane_ctl = plane_state->ctl; | 364 | u32 plane_ctl = plane_state->ctl; |
@@ -318,8 +368,6 @@ skl_update_plane(struct intel_plane *plane, | |||
318 | u32 aux_stride = skl_plane_stride(plane_state, 1); | 368 | u32 aux_stride = skl_plane_stride(plane_state, 1); |
319 | int crtc_x = plane_state->base.dst.x1; | 369 | int crtc_x = plane_state->base.dst.x1; |
320 | int crtc_y = plane_state->base.dst.y1; | 370 | int crtc_y = plane_state->base.dst.y1; |
321 | uint32_t crtc_w = drm_rect_width(&plane_state->base.dst); | ||
322 | uint32_t crtc_h = drm_rect_height(&plane_state->base.dst); | ||
323 | uint32_t x = plane_state->color_plane[0].x; | 371 | uint32_t x = plane_state->color_plane[0].x; |
324 | uint32_t y = plane_state->color_plane[0].y; | 372 | uint32_t y = plane_state->color_plane[0].y; |
325 | uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16; | 373 | uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16; |
@@ -329,8 +377,6 @@ skl_update_plane(struct intel_plane *plane, | |||
329 | /* Sizes are 0 based */ | 377 | /* Sizes are 0 based */ |
330 | src_w--; | 378 | src_w--; |
331 | src_h--; | 379 | src_h--; |
332 | crtc_w--; | ||
333 | crtc_h--; | ||
334 | 380 | ||
335 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); | 381 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
336 | 382 | ||
@@ -355,39 +401,7 @@ skl_update_plane(struct intel_plane *plane, | |||
355 | 401 | ||
356 | /* program plane scaler */ | 402 | /* program plane scaler */ |
357 | if (plane_state->scaler_id >= 0) { | 403 | if (plane_state->scaler_id >= 0) { |
358 | int scaler_id = plane_state->scaler_id; | 404 | skl_program_scaler(dev_priv, plane, crtc_state, plane_state); |
359 | const struct intel_scaler *scaler = | ||
360 | &crtc_state->scaler_state.scalers[scaler_id]; | ||
361 | u16 y_hphase, uv_rgb_hphase; | ||
362 | u16 y_vphase, uv_rgb_vphase; | ||
363 | |||
364 | /* TODO: handle sub-pixel coordinates */ | ||
365 | if (fb->format->format == DRM_FORMAT_NV12) { | ||
366 | y_hphase = skl_scaler_calc_phase(1, false); | ||
367 | y_vphase = skl_scaler_calc_phase(1, false); | ||
368 | |||
369 | /* MPEG2 chroma siting convention */ | ||
370 | uv_rgb_hphase = skl_scaler_calc_phase(2, true); | ||
371 | uv_rgb_vphase = skl_scaler_calc_phase(2, false); | ||
372 | } else { | ||
373 | /* not used */ | ||
374 | y_hphase = 0; | ||
375 | y_vphase = 0; | ||
376 | |||
377 | uv_rgb_hphase = skl_scaler_calc_phase(1, false); | ||
378 | uv_rgb_vphase = skl_scaler_calc_phase(1, false); | ||
379 | } | ||
380 | |||
381 | I915_WRITE_FW(SKL_PS_CTRL(pipe, scaler_id), | ||
382 | PS_SCALER_EN | PS_PLANE_SEL(plane_id) | scaler->mode); | ||
383 | I915_WRITE_FW(SKL_PS_PWR_GATE(pipe, scaler_id), 0); | ||
384 | I915_WRITE_FW(SKL_PS_VPHASE(pipe, scaler_id), | ||
385 | PS_Y_PHASE(y_vphase) | PS_UV_RGB_PHASE(uv_rgb_vphase)); | ||
386 | I915_WRITE_FW(SKL_PS_HPHASE(pipe, scaler_id), | ||
387 | PS_Y_PHASE(y_hphase) | PS_UV_RGB_PHASE(uv_rgb_hphase)); | ||
388 | I915_WRITE_FW(SKL_PS_WIN_POS(pipe, scaler_id), (crtc_x << 16) | crtc_y); | ||
389 | I915_WRITE_FW(SKL_PS_WIN_SZ(pipe, scaler_id), | ||
390 | ((crtc_w + 1) << 16)|(crtc_h + 1)); | ||
391 | 405 | ||
392 | I915_WRITE_FW(PLANE_POS(pipe, plane_id), 0); | 406 | I915_WRITE_FW(PLANE_POS(pipe, plane_id), 0); |
393 | } else { | 407 | } else { |