Commit 42fd20ed authored by Kevin Strasser's avatar Kevin Strasser Committed by Maarten Lankhorst

drm/i915: Refactor icl_is_hdr_plane

Change the api in order to enable callers that can't supply a valid
intel_plane pointer, as would be the case prior to calling
drm_universal_plane_init.

v4:
- Rename variables and move a declaration (Ville)

v6:
- Rebase and fix merge conflict

Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: default avatarKevin Strasser <kevin.strasser@intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: default avatarAdam Jackson <ajax@redhat.com>
Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1552437513-22648-3-git-send-email-kevin.strasser@intel.com
parent 88ab9c76
...@@ -234,10 +234,11 @@ static void intel_atomic_setup_scaler(struct intel_crtc_scaler_state *scaler_sta ...@@ -234,10 +234,11 @@ static void intel_atomic_setup_scaler(struct intel_crtc_scaler_state *scaler_sta
if (plane_state && plane_state->base.fb && if (plane_state && plane_state->base.fb &&
plane_state->base.fb->format->is_yuv && plane_state->base.fb->format->is_yuv &&
plane_state->base.fb->format->num_planes > 1) { plane_state->base.fb->format->num_planes > 1) {
struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
if (IS_GEN(dev_priv, 9) && if (IS_GEN(dev_priv, 9) &&
!IS_GEMINILAKE(dev_priv)) { !IS_GEMINILAKE(dev_priv)) {
mode = SKL_PS_SCALER_MODE_NV12; mode = SKL_PS_SCALER_MODE_NV12;
} else if (icl_is_hdr_plane(to_intel_plane(plane_state->base.plane))) { } else if (icl_is_hdr_plane(dev_priv, plane->id)) {
/* /*
* On gen11+'s HDR planes we only use the scaler for * On gen11+'s HDR planes we only use the scaler for
* scaling. They have a dedicated chroma upsampler, so * scaling. They have a dedicated chroma upsampler, so
......
...@@ -3808,6 +3808,8 @@ u32 glk_plane_color_ctl_crtc(const struct intel_crtc_state *crtc_state) ...@@ -3808,6 +3808,8 @@ u32 glk_plane_color_ctl_crtc(const struct intel_crtc_state *crtc_state)
u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state, u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
const struct intel_plane_state *plane_state) const struct intel_plane_state *plane_state)
{ {
struct drm_i915_private *dev_priv =
to_i915(plane_state->base.plane->dev);
const struct drm_framebuffer *fb = plane_state->base.fb; const struct drm_framebuffer *fb = plane_state->base.fb;
struct intel_plane *plane = to_intel_plane(plane_state->base.plane); struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
u32 plane_color_ctl = 0; u32 plane_color_ctl = 0;
...@@ -3815,7 +3817,7 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state, ...@@ -3815,7 +3817,7 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
plane_color_ctl |= PLANE_COLOR_PLANE_GAMMA_DISABLE; plane_color_ctl |= PLANE_COLOR_PLANE_GAMMA_DISABLE;
plane_color_ctl |= glk_plane_color_ctl_alpha(plane_state); plane_color_ctl |= glk_plane_color_ctl_alpha(plane_state);
if (fb->format->is_yuv && !icl_is_hdr_plane(plane)) { if (fb->format->is_yuv && !icl_is_hdr_plane(dev_priv, plane->id)) {
if (plane_state->base.color_encoding == DRM_COLOR_YCBCR_BT709) if (plane_state->base.color_encoding == DRM_COLOR_YCBCR_BT709)
plane_color_ctl |= PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709; plane_color_ctl |= PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709;
else else
...@@ -5141,13 +5143,14 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state, ...@@ -5141,13 +5143,14 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
{ {
struct intel_plane *intel_plane = struct intel_plane *intel_plane =
to_intel_plane(plane_state->base.plane); to_intel_plane(plane_state->base.plane);
struct drm_i915_private *dev_priv = to_i915(intel_plane->base.dev);
struct drm_framebuffer *fb = plane_state->base.fb; struct drm_framebuffer *fb = plane_state->base.fb;
int ret; int ret;
bool force_detach = !fb || !plane_state->base.visible; bool force_detach = !fb || !plane_state->base.visible;
bool need_scaler = false; bool need_scaler = false;
/* Pre-gen11 and SDR planes always need a scaler for planar formats. */ /* Pre-gen11 and SDR planes always need a scaler for planar formats. */
if (!icl_is_hdr_plane(intel_plane) && if (!icl_is_hdr_plane(dev_priv, intel_plane->id) &&
fb && is_planar_yuv_format(fb->format->format)) fb && is_planar_yuv_format(fb->format->format))
need_scaler = true; need_scaler = true;
......
...@@ -2325,12 +2325,13 @@ static inline bool icl_is_nv12_y_plane(enum plane_id id) ...@@ -2325,12 +2325,13 @@ static inline bool icl_is_nv12_y_plane(enum plane_id id)
return false; return false;
} }
static inline bool icl_is_hdr_plane(struct intel_plane *plane) static inline bool icl_is_hdr_plane(struct drm_i915_private *dev_priv,
enum plane_id plane_id)
{ {
if (INTEL_GEN(to_i915(plane->base.dev)) < 11) if (INTEL_GEN(dev_priv) < 11)
return false; return false;
return plane->id < PLANE_SPRITE2; return plane_id < PLANE_SPRITE2;
} }
/* intel_tv.c */ /* intel_tv.c */
......
...@@ -349,7 +349,7 @@ skl_program_scaler(struct intel_plane *plane, ...@@ -349,7 +349,7 @@ skl_program_scaler(struct intel_plane *plane,
/* TODO: handle sub-pixel coordinates */ /* TODO: handle sub-pixel coordinates */
if (is_planar_yuv_format(plane_state->base.fb->format->format) && if (is_planar_yuv_format(plane_state->base.fb->format->format) &&
!icl_is_hdr_plane(plane)) { !icl_is_hdr_plane(dev_priv, plane->id)) {
y_hphase = skl_scaler_calc_phase(1, hscale, false); y_hphase = skl_scaler_calc_phase(1, hscale, false);
y_vphase = skl_scaler_calc_phase(1, vscale, false); y_vphase = skl_scaler_calc_phase(1, vscale, false);
...@@ -531,7 +531,7 @@ skl_program_plane(struct intel_plane *plane, ...@@ -531,7 +531,7 @@ skl_program_plane(struct intel_plane *plane,
I915_WRITE_FW(PLANE_AUX_DIST(pipe, plane_id), I915_WRITE_FW(PLANE_AUX_DIST(pipe, plane_id),
(plane_state->color_plane[1].offset - surf_addr) | aux_stride); (plane_state->color_plane[1].offset - surf_addr) | aux_stride);
if (icl_is_hdr_plane(plane)) { if (icl_is_hdr_plane(dev_priv, plane_id)) {
u32 cus_ctl = 0; u32 cus_ctl = 0;
if (linked) { if (linked) {
...@@ -555,7 +555,7 @@ skl_program_plane(struct intel_plane *plane, ...@@ -555,7 +555,7 @@ skl_program_plane(struct intel_plane *plane,
if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
I915_WRITE_FW(PLANE_COLOR_CTL(pipe, plane_id), plane_color_ctl); I915_WRITE_FW(PLANE_COLOR_CTL(pipe, plane_id), plane_color_ctl);
if (fb->format->is_yuv && icl_is_hdr_plane(plane)) if (fb->format->is_yuv && icl_is_hdr_plane(dev_priv, plane_id))
icl_program_input_csc(plane, crtc_state, plane_state); icl_program_input_csc(plane, crtc_state, plane_state);
skl_write_plane_wm(plane, crtc_state); skl_write_plane_wm(plane, crtc_state);
......
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