Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp42129pxb; Fri, 15 Jan 2021 07:13:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxsTAQUoULXlutqux5U3j/2ubDYHvOFP6NWm2xlELNbyJuGwKUn7f4qiY0ass8Dp31H8g9e X-Received: by 2002:a05:6402:1914:: with SMTP id e20mr6273829edz.89.1610723623437; Fri, 15 Jan 2021 07:13:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610723623; cv=none; d=google.com; s=arc-20160816; b=aP/P3ZUINxrqpkeKqSUQWNmTEu5VfEFMzSqWndcAB+QoGRN7U4tcTC2thnxGBEWv7S DJ6320SpI9PhihnUPIUY90myYT2D7mqLNqJB27ht++9/vjxxONjaWibwKOKvpG2xAK0k tNKx9V3vDufQmq1i6NWs/fJwv4MiVRvAEfuEo0xWUflyPLOj91pKbNNg2KK2f0TOTuoT eNwS2yVaIcYeJJQ6XEc9cgjxNEl0YkkI41qA9dOnnOcc2iGgQWYxTzzNVe9RNJoygYFc 4+IoLyLiq/L479jpP5RG5lBX/T1yOr0fKh4MlZlqTeJEXCet3cxVYJt5HB97mUf0nJFH RPkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=DRIeDoOgUkLikV7wSCIOTC7A+bSaY1iECZ2gcrgi2cY=; b=tWq39+dOfQ/nhSKJoXRoEI38LSASbxckjVywv0MzQzF1NBsWZAxVdPzm/Oca6Ue0hv p616HBq3C/R4+PixWziwzifil+5ueH5adsNS7clhrJemTdDlraAggJomZRppB/t3vyW+ gJdvg6MVr1/HGFJHELgUjIRxj5DDd5v4DBs4WbCNPt8pcl54oB7Gng3PcLPNHjiPQk01 E2kIPEoAvgPQI+oogawBsHmAgZpXAAXnIUtoN8zjyRT6wr1spGoBeKKtiTUnpSIL9ddp HZTpwD7yp/lBRbF+kh9KTSNtFk3jh8Wz5gnUoep+TB9ks2D6E1j2u2aPiit1I4GKmGmS Fo3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si2328385edd.105.2021.01.15.07.13.17; Fri, 15 Jan 2021 07:13:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732400AbhAOPLy (ORCPT + 99 others); Fri, 15 Jan 2021 10:11:54 -0500 Received: from mga12.intel.com ([192.55.52.136]:38601 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728878AbhAOPLx (ORCPT ); Fri, 15 Jan 2021 10:11:53 -0500 IronPort-SDR: h7FgO+b0laePwwlVj1d4ENZe1TOV+4iDyOvGU1V9DaNpoYf6WPYQIHZusylZPEvENtPuY2yle8 NMH/awEVBPjg== X-IronPort-AV: E=McAfee;i="6000,8403,9864"; a="157739688" X-IronPort-AV: E=Sophos;i="5.79,349,1602572400"; d="scan'208";a="157739688" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 07:11:12 -0800 IronPort-SDR: qvFDr4gis4W2L8H3+grQyof86sZPJVgFEH/lzW5XVSoHgll869oG6tg6xJNYbqaPDja4+RTyb8 7EZNMuJWjwQw== X-IronPort-AV: E=Sophos;i="5.79,349,1602572400"; d="scan'208";a="465611249" Received: from bmkierna-mobl3.ger.corp.intel.com (HELO localhost) ([10.213.221.58]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 07:11:07 -0800 From: Jani Nikula To: Lyude Paul , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Arnd Bergmann , Anshuman Gupta , Pankaj Bharadiya , David Airlie , Lucas De Marchi , open list , Chris Wilson , Hans de Goede , Uma Shankar , Sean Paul , Rodrigo Vivi , Dave Airlie Subject: Re: [PATCH v7 1/5] drm/i915: Pass port to intel_panel_bl_funcs.get() In-Reply-To: <8735z2pazc.fsf@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20210114221709.2261452-1-lyude@redhat.com> <20210114221709.2261452-2-lyude@redhat.com> <8735z2pazc.fsf@intel.com> Date: Fri, 15 Jan 2021 17:11:04 +0200 Message-ID: <87wnwensl3.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Jan 2021, Jani Nikula wrote: > On Thu, 14 Jan 2021, Lyude Paul wrote: >> In the next commit where we split PWM related backlight functions from >> higher-level backlight functions, we'll want to be able to retrieve the >> backlight level for the current display panel from the >> intel_panel_bl_funcs->setup() function using pwm_funcs->get(). Since >> intel_panel_bl_funcs->setup() is called before we've fully read in the >> current hardware state into our atomic state, we can't grab atomic >> modesetting locks safely anyway in intel_panel_bl_funcs->setup(), and some >> PWM backlight functions (vlv_get_backlight() in particular) require knowing >> the currently used pipe we need to be able to discern the current display >> pipe through other means. Luckily, we're already passing the current >> display pipe to intel_panel_bl_funcs->setup() so all we have to do in order >> to achieve this is pass down that parameter to intel_panel_bl_funcs->get(). >> >> So, fix this by accepting an additional pipe parameter in >> intel_panel_bl_funcs->get(), and leave figuring out the current display >> pipe up to the caller. >> >> Signed-off-by: Lyude Paul > > Much neater than anything I suggested! > > Reviewed-by: Jani Nikula And pushed this one to drm-intel-next, thanks for the patch. BR, Jani. > >> --- >> .../drm/i915/display/intel_display_types.h | 2 +- >> .../drm/i915/display/intel_dp_aux_backlight.c | 4 +- >> .../i915/display/intel_dsi_dcs_backlight.c | 2 +- >> drivers/gpu/drm/i915/display/intel_panel.c | 40 ++++++++----------- >> 4 files changed, 21 insertions(+), 27 deletions(-) >> >> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h >> index 585bb1edea04..b1f4ec144207 100644 >> --- a/drivers/gpu/drm/i915/display/intel_display_types.h >> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h >> @@ -228,7 +228,7 @@ struct intel_encoder { >> struct intel_panel_bl_funcs { >> /* Connector and platform specific backlight functions */ >> int (*setup)(struct intel_connector *connector, enum pipe pipe); >> - u32 (*get)(struct intel_connector *connector); >> + u32 (*get)(struct intel_connector *connector, enum pipe pipe); >> void (*set)(const struct drm_connector_state *conn_state, u32 level); >> void (*disable)(const struct drm_connector_state *conn_state, u32 level); >> void (*enable)(const struct intel_crtc_state *crtc_state, >> diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c >> index 9775f33d1aac..de764dae1e66 100644 >> --- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c >> +++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c >> @@ -128,7 +128,7 @@ static bool intel_dp_aux_vesa_backlight_dpcd_mode(struct intel_connector *connec >> * Read the current backlight value from DPCD register(s) based >> * on if 8-bit(MSB) or 16-bit(MSB and LSB) values are supported >> */ >> -static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector) >> +static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector, enum pipe unused) >> { >> struct intel_dp *intel_dp = intel_attached_dp(connector); >> struct drm_i915_private *i915 = dp_to_i915(intel_dp); >> @@ -381,7 +381,7 @@ static int intel_dp_aux_vesa_setup_backlight(struct intel_connector *connector, >> return -ENODEV; >> >> panel->backlight.min = 0; >> - panel->backlight.level = intel_dp_aux_vesa_get_backlight(connector); >> + panel->backlight.level = intel_dp_aux_vesa_get_backlight(connector, pipe); >> panel->backlight.enabled = intel_dp_aux_vesa_backlight_dpcd_mode(connector) && >> panel->backlight.level != 0; >> >> diff --git a/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c b/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c >> index 88628764956d..584c14c4cbd0 100644 >> --- a/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c >> +++ b/drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c >> @@ -43,7 +43,7 @@ >> >> #define PANEL_PWM_MAX_VALUE 0xFF >> >> -static u32 dcs_get_backlight(struct intel_connector *connector) >> +static u32 dcs_get_backlight(struct intel_connector *connector, enum pipe unused) >> { >> struct intel_encoder *encoder = intel_attached_encoder(connector); >> struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); >> diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c >> index 7a4239d1c241..7587aaefc7a0 100644 >> --- a/drivers/gpu/drm/i915/display/intel_panel.c >> +++ b/drivers/gpu/drm/i915/display/intel_panel.c >> @@ -530,21 +530,21 @@ static u32 intel_panel_compute_brightness(struct intel_connector *connector, >> return val; >> } >> >> -static u32 lpt_get_backlight(struct intel_connector *connector) >> +static u32 lpt_get_backlight(struct intel_connector *connector, enum pipe unused) >> { >> struct drm_i915_private *dev_priv = to_i915(connector->base.dev); >> >> return intel_de_read(dev_priv, BLC_PWM_PCH_CTL2) & BACKLIGHT_DUTY_CYCLE_MASK; >> } >> >> -static u32 pch_get_backlight(struct intel_connector *connector) >> +static u32 pch_get_backlight(struct intel_connector *connector, enum pipe unused) >> { >> struct drm_i915_private *dev_priv = to_i915(connector->base.dev); >> >> return intel_de_read(dev_priv, BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK; >> } >> >> -static u32 i9xx_get_backlight(struct intel_connector *connector) >> +static u32 i9xx_get_backlight(struct intel_connector *connector, enum pipe unused) >> { >> struct drm_i915_private *dev_priv = to_i915(connector->base.dev); >> struct intel_panel *panel = &connector->panel; >> @@ -564,23 +564,17 @@ static u32 i9xx_get_backlight(struct intel_connector *connector) >> return val; >> } >> >> -static u32 _vlv_get_backlight(struct drm_i915_private *dev_priv, enum pipe pipe) >> +static u32 vlv_get_backlight(struct intel_connector *connector, enum pipe pipe) >> { >> + struct drm_i915_private *dev_priv = to_i915(connector->base.dev); >> + >> if (drm_WARN_ON(&dev_priv->drm, pipe != PIPE_A && pipe != PIPE_B)) >> return 0; >> >> return intel_de_read(dev_priv, VLV_BLC_PWM_CTL(pipe)) & BACKLIGHT_DUTY_CYCLE_MASK; >> } >> >> -static u32 vlv_get_backlight(struct intel_connector *connector) >> -{ >> - struct drm_i915_private *dev_priv = to_i915(connector->base.dev); >> - enum pipe pipe = intel_connector_get_pipe(connector); >> - >> - return _vlv_get_backlight(dev_priv, pipe); >> -} >> - >> -static u32 bxt_get_backlight(struct intel_connector *connector) >> +static u32 bxt_get_backlight(struct intel_connector *connector, enum pipe unused) >> { >> struct drm_i915_private *dev_priv = to_i915(connector->base.dev); >> struct intel_panel *panel = &connector->panel; >> @@ -589,7 +583,7 @@ static u32 bxt_get_backlight(struct intel_connector *connector) >> BXT_BLC_PWM_DUTY(panel->backlight.controller)); >> } >> >> -static u32 ext_pwm_get_backlight(struct intel_connector *connector) >> +static u32 ext_pwm_get_backlight(struct intel_connector *connector, enum pipe unused) >> { >> struct intel_panel *panel = &connector->panel; >> struct pwm_state state; >> @@ -1233,7 +1227,7 @@ static u32 intel_panel_get_backlight(struct intel_connector *connector) >> mutex_lock(&dev_priv->backlight_lock); >> >> if (panel->backlight.enabled) { >> - val = panel->backlight.funcs->get(connector); >> + val = panel->backlight.funcs->get(connector, intel_connector_get_pipe(connector)); >> val = intel_panel_compute_brightness(connector, val); >> } >> >> @@ -1646,9 +1640,9 @@ static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus >> !(pch_ctl1 & BLM_PCH_OVERRIDE_ENABLE) && >> (cpu_ctl2 & BLM_PWM_ENABLE); >> if (cpu_mode) >> - val = pch_get_backlight(connector); >> + val = pch_get_backlight(connector, unused); >> else >> - val = lpt_get_backlight(connector); >> + val = lpt_get_backlight(connector, unused); >> >> if (cpu_mode) { >> drm_dbg_kms(&dev_priv->drm, >> @@ -1690,7 +1684,7 @@ static int pch_setup_backlight(struct intel_connector *connector, enum pipe unus >> >> panel->backlight.min = get_backlight_min_vbt(connector); >> >> - val = pch_get_backlight(connector); >> + val = pch_get_backlight(connector, unused); >> val = intel_panel_compute_brightness(connector, val); >> panel->backlight.level = clamp(val, panel->backlight.min, >> panel->backlight.max); >> @@ -1731,7 +1725,7 @@ static int i9xx_setup_backlight(struct intel_connector *connector, enum pipe unu >> >> panel->backlight.min = get_backlight_min_vbt(connector); >> >> - val = i9xx_get_backlight(connector); >> + val = i9xx_get_backlight(connector, unused); >> val = intel_panel_compute_brightness(connector, val); >> panel->backlight.level = clamp(val, panel->backlight.min, >> panel->backlight.max); >> @@ -1765,7 +1759,7 @@ static int i965_setup_backlight(struct intel_connector *connector, enum pipe unu >> >> panel->backlight.min = get_backlight_min_vbt(connector); >> >> - val = i9xx_get_backlight(connector); >> + val = i9xx_get_backlight(connector, unused); >> val = intel_panel_compute_brightness(connector, val); >> panel->backlight.level = clamp(val, panel->backlight.min, >> panel->backlight.max); >> @@ -1798,7 +1792,7 @@ static int vlv_setup_backlight(struct intel_connector *connector, enum pipe pipe >> >> panel->backlight.min = get_backlight_min_vbt(connector); >> >> - val = _vlv_get_backlight(dev_priv, pipe); >> + val = vlv_get_backlight(connector, pipe); >> val = intel_panel_compute_brightness(connector, val); >> panel->backlight.level = clamp(val, panel->backlight.min, >> panel->backlight.max); >> @@ -1840,7 +1834,7 @@ bxt_setup_backlight(struct intel_connector *connector, enum pipe unused) >> >> panel->backlight.min = get_backlight_min_vbt(connector); >> >> - val = bxt_get_backlight(connector); >> + val = bxt_get_backlight(connector, unused); >> val = intel_panel_compute_brightness(connector, val); >> panel->backlight.level = clamp(val, panel->backlight.min, >> panel->backlight.max); >> @@ -1880,7 +1874,7 @@ cnp_setup_backlight(struct intel_connector *connector, enum pipe unused) >> >> panel->backlight.min = get_backlight_min_vbt(connector); >> >> - val = bxt_get_backlight(connector); >> + val = bxt_get_backlight(connector, unused); >> val = intel_panel_compute_brightness(connector, val); >> panel->backlight.level = clamp(val, panel->backlight.min, >> panel->backlight.max); -- Jani Nikula, Intel Open Source Graphics Center