UPSTREAM: drm/i915/skl+: consider max supported plane pixel rate while scaling

A display resolution is only supported if it meets all the restrictions
below for Maximum Pipe Pixel Rate.

The display resolution must fit within the maximum pixel rate output
from the pipe. Make sure that the display pipe is able to feed pixels at
a rate required to support the desired resolution.
For each enabled plane on the pipe {
    If plane scaling enabled {
	Horizontal down scale amount = Maximum[1, plane horizontal size /
		    scaler horizontal window size]
	Vertical down scale amount = Maximum[1, plane vertical size /
		    scaler vertical window size]
	Plane down scale amount = Horizontal down scale amount *
		    Vertical down scale amount
	Plane Ratio = 1 / Plane down scale amount
    }
    Else {
	Plane Ratio = 1
    }
    If plane source pixel format is 64 bits per pixel {
	Plane Ratio = Plane Ratio * 8/9
    }
}

Pipe Ratio = Minimum Plane Ratio of all enabled planes on the pipe

If pipe scaling is enabled {
    Horizontal down scale amount = Maximum[1, pipe horizontal source size /
		scaler horizontal window size]
    Vertical down scale amount = Maximum[1, pipe vertical source size /
		scaler vertical window size]
    Note: The progressive fetch - interlace display mode is equivalent to a
		2.0 vertical down scale
    Pipe down scale amount = Horizontal down scale amount *
		Vertical down scale amount
    Pipe Ratio = Pipe Ratio / Pipe down scale amount
}

Pipe maximum pixel rate = CDCLK frequency * Pipe Ratio

In this patch our calculation is based on pipe downscale amount
(plane max downscale amount * pipe downscale amount) instead of Pipe
Ratio. So,
max supported crtc clock with given scaling = CDCLK / pipe downscale.
Flip will fail if,
current crtc clock > max supported crct clock with given scaling.

Changes since V1:
 - separate out fixed_16_16 wrapper API definition
Changes since V2:
 - Fix buggy crtc !active condition (Maarten)
 - use intel_wm_plane_visible wrapper as per Maarten's suggestion
Changes since V3:
 - Change failure return from ERANGE to EINVAL
Changes since V4:
 - Rebase based on previous patch changes
Changes since V5:
 - return EINVAL instead of continue (Maarten)
Changes since V6:
 - Improve commit message
 - Address review comment
Changes since V7:
 - use !enable instead of !active
 - rename config variable for consistency (Maarten)

Signed-off-by: Mahesh Kumar <mahesh1.kumar@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170526151546.25025-4-mahesh1.kumar@intel.com
(cherry picked from commit 73b0ca8ec76d593d8ebb9d3a5e4021da852310e7)
from drm-intel-next-2017-06-19
Signed-off-by: Tarun <tarun.vyas@intel.com>

BUG=chromium:746068
TEST=With a 4K capable Youtube video with no UI(annotations, subtitles
turned off, which results into a switch to plane OVL), _no_ zoom in happens
with higher resolutions i.e 1080p, 1440p and 2160p.
TEST=With a 4K capable Youtube video running in Ultra HD (2160p) and no
UI (plane OVL), a switch to full screen mode doesn't results into any visual
artifacts.
TEST=No regressions in KBL/APL/BYT

Change-Id: I5e0da3439318e7bcb0bbcf017f7b01d4633cc326
Reviewed-on: https://chromium-review.googlesource.com/588605
Commit-Ready: Tarun Vyas <tarun.vyas@intel.com>
Tested-by: Dongseong Hwang <dongseong.hwang@intel.com>
Tested-by: Daniele Castagna <dcastagna@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Casey G Bowman <casey.g.bowman@intel.com>
Reviewed-by: Dongseong Hwang <dongseong.hwang@intel.com>
Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
(cherry picked from commit ee7645a9c5429025a1ce9bf7d5bcf5cc37b198db)
Reviewed-on: https://chromium-review.googlesource.com/601162
Commit-Queue: Kristian H. Kristensen <hoegsberg@chromium.org>
3 files changed