Commit 38f24f21 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Fix plane YCbCr->RGB conversion for GLK

On GLK the plane CSC controls moved into the COLOR_CTL register.
Update the code to progam the YCbCr->RGB CSC mode correctly when
faced with an YCbCr framebuffer.

The spec is rather confusing as it calls the mode "YUV601 to RGB709".
I'm going to assume that just means it's going to use the YCbCr->RGB
matrix as specified in BT.601 and doesn't actually change the gamut.

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Russell King - ARM Linux <linux@armlinux.org.uk>
Cc: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Shashank Sharma <shashank.sharma@intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180214192327.3250-6-ville.syrjala@linux.intel.comReviewed-by: default avatarImre Deak <imre.deak@intel.com>
parent 5deae919
...@@ -6436,6 +6436,11 @@ enum { ...@@ -6436,6 +6436,11 @@ enum {
#define _PLANE_COLOR_CTL_3_A 0x703CC /* GLK+ */ #define _PLANE_COLOR_CTL_3_A 0x703CC /* GLK+ */
#define PLANE_COLOR_PIPE_GAMMA_ENABLE (1 << 30) #define PLANE_COLOR_PIPE_GAMMA_ENABLE (1 << 30)
#define PLANE_COLOR_PIPE_CSC_ENABLE (1 << 23) #define PLANE_COLOR_PIPE_CSC_ENABLE (1 << 23)
#define PLANE_COLOR_CSC_MODE_BYPASS (0 << 17)
#define PLANE_COLOR_CSC_MODE_YUV601_TO_RGB709 (1 << 17)
#define PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709 (2 << 17)
#define PLANE_COLOR_CSC_MODE_YUV2020_TO_RGB2020 (3 << 17)
#define PLANE_COLOR_CSC_MODE_RGB709_TO_RGB2020 (4 << 17)
#define PLANE_COLOR_PLANE_GAMMA_DISABLE (1 << 13) #define PLANE_COLOR_PLANE_GAMMA_DISABLE (1 << 13)
#define PLANE_COLOR_ALPHA_MASK (0x3 << 4) #define PLANE_COLOR_ALPHA_MASK (0x3 << 4)
#define PLANE_COLOR_ALPHA_DISABLE (0 << 4) #define PLANE_COLOR_ALPHA_DISABLE (0 << 4)
......
...@@ -3565,6 +3565,9 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state, ...@@ -3565,6 +3565,9 @@ 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(fb->format->format); plane_color_ctl |= glk_plane_color_ctl_alpha(fb->format->format);
if (intel_format_is_yuv(fb->format->format))
plane_color_ctl |= PLANE_COLOR_CSC_MODE_YUV601_TO_RGB709;
return plane_color_ctl; return plane_color_ctl;
} }
......
...@@ -1589,6 +1589,7 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state, ...@@ -1589,6 +1589,7 @@ 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);
u32 skl_plane_ctl(const struct intel_crtc_state *crtc_state, u32 skl_plane_ctl(const struct intel_crtc_state *crtc_state,
const struct intel_plane_state *plane_state); const struct intel_plane_state *plane_state);
u32 glk_color_ctl(const struct intel_plane_state *plane_state);
u32 skl_plane_stride(const struct drm_framebuffer *fb, int plane, u32 skl_plane_stride(const struct drm_framebuffer *fb, int plane,
unsigned int rotation); unsigned int rotation);
int skl_check_plane_surface(const struct intel_crtc_state *crtc_state, int skl_check_plane_surface(const struct intel_crtc_state *crtc_state,
...@@ -2014,6 +2015,7 @@ bool intel_sdvo_init(struct drm_i915_private *dev_priv, ...@@ -2014,6 +2015,7 @@ bool intel_sdvo_init(struct drm_i915_private *dev_priv,
/* intel_sprite.c */ /* intel_sprite.c */
bool intel_format_is_yuv(u32 format);
int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode, int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
int usecs); int usecs);
struct intel_plane *intel_sprite_plane_create(struct drm_i915_private *dev_priv, struct intel_plane *intel_sprite_plane_create(struct drm_i915_private *dev_priv,
......
...@@ -41,8 +41,7 @@ ...@@ -41,8 +41,7 @@
#include <drm/i915_drm.h> #include <drm/i915_drm.h>
#include "i915_drv.h" #include "i915_drv.h"
static bool bool intel_format_is_yuv(u32 format)
format_is_yuv(uint32_t format)
{ {
switch (format) { switch (format) {
case DRM_FORMAT_YUYV: case DRM_FORMAT_YUYV:
...@@ -266,6 +265,7 @@ skl_update_plane(struct intel_plane *plane, ...@@ -266,6 +265,7 @@ skl_update_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), I915_WRITE_FW(PLANE_COLOR_CTL(pipe, plane_id),
plane_state->color_ctl); plane_state->color_ctl);
if (key->flags) { if (key->flags) {
I915_WRITE_FW(PLANE_KEYVAL(pipe, plane_id), key->min_value); I915_WRITE_FW(PLANE_KEYVAL(pipe, plane_id), key->min_value);
I915_WRITE_FW(PLANE_KEYMAX(pipe, plane_id), key->max_value); I915_WRITE_FW(PLANE_KEYMAX(pipe, plane_id), key->max_value);
...@@ -354,7 +354,7 @@ chv_update_csc(const struct intel_plane_state *plane_state) ...@@ -354,7 +354,7 @@ chv_update_csc(const struct intel_plane_state *plane_state)
enum plane_id plane_id = plane->id; enum plane_id plane_id = plane->id;
/* Seems RGB data bypasses the CSC always */ /* Seems RGB data bypasses the CSC always */
if (!format_is_yuv(fb->format->format)) if (!intel_format_is_yuv(fb->format->format))
return; return;
/* /*
...@@ -399,7 +399,7 @@ vlv_update_clrc(const struct intel_plane_state *plane_state) ...@@ -399,7 +399,7 @@ vlv_update_clrc(const struct intel_plane_state *plane_state)
enum plane_id plane_id = plane->id; enum plane_id plane_id = plane->id;
int contrast, brightness, sh_scale, sh_sin, sh_cos; int contrast, brightness, sh_scale, sh_sin, sh_cos;
if (format_is_yuv(fb->format->format)) { if (intel_format_is_yuv(fb->format->format)) {
/* /*
* Expand limited range to full range: * Expand limited range to full range:
* Contrast is applied first and is used to expand Y range. * Contrast is applied first and is used to expand Y range.
...@@ -1024,7 +1024,7 @@ intel_check_sprite_plane(struct intel_plane *plane, ...@@ -1024,7 +1024,7 @@ intel_check_sprite_plane(struct intel_plane *plane,
src_y = src->y1 >> 16; src_y = src->y1 >> 16;
src_h = drm_rect_height(src) >> 16; src_h = drm_rect_height(src) >> 16;
if (format_is_yuv(fb->format->format)) { if (intel_format_is_yuv(fb->format->format)) {
src_x &= ~1; src_x &= ~1;
src_w &= ~1; src_w &= ~1;
......
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