From patchwork Mon Apr 1 17:30:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Shankar, Uma" X-Patchwork-Id: 10880325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 99B4D184E for ; Mon, 1 Apr 2019 17:04:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A13127F92 for ; Mon, 1 Apr 2019 17:04:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EA6128477; Mon, 1 Apr 2019 17:04:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DDB152839C for ; Mon, 1 Apr 2019 17:04:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E9DA06E23C; Mon, 1 Apr 2019 17:04:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id E9E5D6E140; Mon, 1 Apr 2019 17:04:46 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 10:04:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,297,1549958400"; d="scan'208";a="147074009" Received: from linuxpresi1-desktop.iind.intel.com ([10.223.74.121]) by orsmga002.jf.intel.com with ESMTP; 01 Apr 2019 10:04:42 -0700 From: Uma Shankar To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [v2 2/7] drm/i915: Define color lut range structure Date: Mon, 1 Apr 2019 23:00:06 +0530 Message-Id: <1554139811-13280-3-git-send-email-uma.shankar@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1554139811-13280-1-git-send-email-uma.shankar@intel.com> References: <1554139811-13280-1-git-send-email-uma.shankar@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcastagna@chromium.org, emil.l.velikov@gmail.com, Uma Shankar , seanpaul@chromium.org, ville.syrjala@intel.com, maarten.lankhorst@intel.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Ville Syrjälä This defines the color lut ranges for 10bit and multi segmented gamma range for ICL. Signed-off-by: Ville Syrjälä Signed-off-by: Uma Shankar --- drivers/gpu/drm/i915/intel_color.c | 301 ++++++++++++++++++++++++++++++++++++- 1 file changed, 297 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_color.c b/drivers/gpu/drm/i915/intel_color.c index f2907cf..84d93ec 100644 --- a/drivers/gpu/drm/i915/intel_color.c +++ b/drivers/gpu/drm/i915/intel_color.c @@ -1083,9 +1083,279 @@ static int icl_color_check(struct intel_crtc_state *crtc_state) return 0; } +enum { + I9XX_LUT_SIZE_8BIT = 256, + I9XX_LUT_SIZE_10BIT = 129, + + ILK_LUT_SIZE_10BIT = 1024, + ILK_LUT_SIZE_12BIT = 513, + + IVB_LUT_SIZE_SPLIT = 512, + + CHV_LUT_SIZE_CGM_DEGAMMA = 65, + CHV_LUT_SIZE_CGM_GAMMA = 257, +}; + +#define I9XX_GAMMA_8 \ + { \ + .flags = DRM_MODE_LUT_GAMMA, \ + .count = 256, \ + .input_bpc = 8, .output_bpc = 8, \ + .start = 0, .end = (1 << 8) - 1, \ + .min = 0, .max = (1 << 8) - 1, \ + } + +static const struct drm_color_lut_range i9xx_gamma_8[] = { + I9XX_GAMMA_8, +}; + +static const struct drm_color_lut_range i9xx_gamma_10_slope[] = { + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_NON_DECREASING), + .count = 129, + .input_bpc = 10, .output_bpc = 10, + .start = 0, .end = 1 << 10, + .min = 0, .max = (1 << 10) - 1, + }, +}; + +#define I965_GAMMA_10 \ + { \ + .flags = (DRM_MODE_LUT_GAMMA | \ + DRM_MODE_LUT_INTERPOLATE | \ + DRM_MODE_LUT_NON_DECREASING), \ + .count = 128, \ + .input_bpc = 10, .output_bpc = 16, \ + .start = 0, .end = (1 << 10) - (1 << 10) / 128, \ + .min = 0, .max = (1 << 16) - 1, \ + }, \ + /* PIPEGCMAX */ \ + { \ + .flags = (DRM_MODE_LUT_GAMMA | \ + DRM_MODE_LUT_INTERPOLATE | \ + DRM_MODE_LUT_REUSE_LAST | \ + DRM_MODE_LUT_NON_DECREASING), \ + .count = 1, \ + .input_bpc = 10, .output_bpc = 16, \ + .start = (1 << 10) - (1 << 10) / 128, .end = 1 << 10, \ + .min = 0, .max = 1 << 16, \ + } + +static const struct drm_color_lut_range i965_gamma_10[] = { + I965_GAMMA_10, +}; + +static const struct drm_color_lut_range ilk_gamma_degamma_8[] = { + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_DEGAMMA), + .count = 256, + .input_bpc = 8, .output_bpc = 8, + .start = 0, .end = (1 << 8) - 1, + .min = 0, .max = (1 << 8) - 1, + }, +}; + +static const struct drm_color_lut_range ilk_gamma_degamma_10[] = { + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_DEGAMMA), + .count = 1024, + .input_bpc = 10, .output_bpc = 10, + .start = 0, .end = (1 << 10) - 1, + .min = 0, .max = (1 << 10) - 1, + }, +}; + +static const struct drm_color_lut_range ilk_gamma_degamma_12p4[] = { + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_DEGAMMA | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_NON_DECREASING), + .count = 512, + .input_bpc = 12, .output_bpc = 16, + .start = 0, .end = (1 << 12) - (1 << 12) / 512, + .min = 0, .max = (1 << 16) - 1, + }, + /* PIPEGCMAX */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_DEGAMMA | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_REUSE_LAST | + DRM_MODE_LUT_NON_DECREASING), + .count = 1, + .input_bpc = 10, .output_bpc = 16, + .start = (1 << 12) - (1 << 12) / 512, .end = 1 << 12, + .min = 0, .max = 1 << 16, + }, +}; + +static const struct drm_color_lut_range glk_gamma_10[] = { + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE), + .count = 1024, + .input_bpc = 10, .output_bpc = 10, + .start = 0, .end = (1 << 10) - 1, + .min = 0, .max = (1 << 10) - 1, + }, + /* PAL_EXT_GC_MAX */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_REUSE_LAST | + DRM_MODE_LUT_NON_DECREASING), + .count = 1, + .input_bpc = 10, .output_bpc = 16, + .start = 1 << 10, .end = 3 << 10, + .min = 0, .max = (8 << 16) - 1, + }, + /* PAL_EXT2_GC_MAX */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_REUSE_LAST | + DRM_MODE_LUT_NON_DECREASING), + .count = 1, + .input_bpc = 10, .output_bpc = 16, + .start = 3 << 12, .end = 7 << 12, + .min = 0, .max = (8 << 16) - 1, + }, +}; + +/* FIXME input bpc? */ +static const struct drm_color_lut_range glk_gamma_12p4[] = { + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_NON_DECREASING), + .count = 512, + .input_bpc = 16, .output_bpc = 16, + .start = 0, .end = (1 << 16) - (1 << 16) / 512, + .min = 0, .max = (1 << 16) - 1, + }, + /* PAL_GC_MAX */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_REUSE_LAST | + DRM_MODE_LUT_NON_DECREASING), + .count = 1, + .input_bpc = 16, .output_bpc = 16, + .start = (1 << 16) - (1 << 16) / 512, .end = 1 << 16, + .min = 0, .max = 1 << 16, + }, + /* PAL_EXT_GC_MAX */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_REUSE_LAST | + DRM_MODE_LUT_NON_DECREASING), + .count = 1, + .input_bpc = 16, .output_bpc = 16, + .start = 1 << 16, .end = 3 << 16, + .min = 0, .max = (8 << 16) - 1, + }, + /* PAL_EXT2_GC_MAX */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_REUSE_LAST | + DRM_MODE_LUT_NON_DECREASING), + .count = 1, + .input_bpc = 16, .output_bpc = 16, + .start = 3 << 16, .end = 7 << 16, + .min = 0, .max = (8 << 16) - 1, + }, +}; + + /* FIXME input bpc? */ +static const struct drm_color_lut_range icl_multi_seg_gamma[] = { + /* segment 1 aka. super fine segment */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_NON_DECREASING), + .count = 9, + .input_bpc = 24, .output_bpc = 16, + .start = 0, .end = (1 << 24) / (128 * 256), + .min = 0, .max = (1 << 16) - 1, + }, + /* segment 2 aka. fine segment */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_NON_DECREASING), + .count = 257, + .input_bpc = 24, .output_bpc = 16, + .start = 0, .end = (1 << 24) / 128, + .min = 0, .max = (1 << 16) - 1, + }, + /* segment 3 aka. coarse segment */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_NON_DECREASING), + .count = 257, + .input_bpc = 24, .output_bpc = 16, + .start = 0, .end = (1 << 24) - (1 << 24) / 256, + .min = 0, .max = (1 << 16) - 1, + }, + /* segment 3 aka. coarse segment / PAL_GC_MAX */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_REUSE_LAST | + DRM_MODE_LUT_NON_DECREASING), + .count = 1, + .input_bpc = 24, .output_bpc = 16, + .start = (1 << 24) - (1 << 24) / 256, .end = 1 << 24, + .min = 0, .max = 1 << 16, + }, + /* PAL_EXT_GC_MAX */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_REUSE_LAST | + DRM_MODE_LUT_NON_DECREASING), + .count = 1, + .input_bpc = 24, .output_bpc = 16, + .start = 1 << 24, .end = 3 << 24, + .min = 0, .max = (8 << 16) - 1, + }, + /* PAL_EXT2_GC_MAX */ + { + .flags = (DRM_MODE_LUT_GAMMA | + DRM_MODE_LUT_REFLECT_NEGATIVE | + DRM_MODE_LUT_INTERPOLATE | + DRM_MODE_LUT_REUSE_LAST | + DRM_MODE_LUT_NON_DECREASING), + .count = 1, + .input_bpc = 24, .output_bpc = 16, + .start = 3 << 24, .end = 7 << 24, + .min = 0, .max = (8 << 16) - 1, + }, +}; + void intel_color_init(struct intel_crtc *crtc) { struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); + int degamma_lut_size, gamma_lut_size; drm_mode_crtc_set_gamma_size(&crtc->base, 256); @@ -1100,14 +1370,37 @@ void intel_color_init(struct intel_crtc *crtc) dev_priv->display.load_luts = i9xx_load_luts; } } else { - if (INTEL_GEN(dev_priv) >= 11) + if (INTEL_GEN(dev_priv) >= 11) { dev_priv->display.color_check = icl_color_check; - else if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) + + /* don't advertize the >= 1.0 entries */ + degamma_lut_size = 0; + gamma_lut_size = ILK_LUT_SIZE_10BIT; + + drm_color_add_gamma_mode_range(&dev_priv->drm, + "8bit gamma", + i9xx_gamma_8, + sizeof(i9xx_gamma_8)); + drm_color_add_gamma_mode_range(&dev_priv->drm, + "10bit gamma", + glk_gamma_10, + sizeof(glk_gamma_10)); + drm_color_add_gamma_mode_range(&dev_priv->drm, + "interpolated gamma", + glk_gamma_12p4, + sizeof(glk_gamma_12p4)); + drm_color_add_gamma_mode_range(&dev_priv->drm, + "multi-segmented gamma", + icl_multi_seg_gamma, + sizeof(icl_multi_seg_gamma)); + } else if (INTEL_GEN(dev_priv) >= 10 || + IS_GEMINILAKE(dev_priv)) { dev_priv->display.color_check = glk_color_check; - else if (INTEL_GEN(dev_priv) >= 8) + } else if (INTEL_GEN(dev_priv) >= 8) { dev_priv->display.color_check = bdw_color_check; - else + } else { dev_priv->display.color_check = ilk_color_check; + } if (INTEL_GEN(dev_priv) >= 9) dev_priv->display.color_commit = skl_color_commit;