Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp59382pxb; Fri, 15 Jan 2021 05:51:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPVCeuFm4xQjNFFEqpVE6BcElIuBGnTgXUFrFx5EEoVX7takKIGPUKKAESBCt58MkABlNV X-Received: by 2002:a17:906:279a:: with SMTP id j26mr8860600ejc.203.1610718696436; Fri, 15 Jan 2021 05:51:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610718696; cv=none; d=google.com; s=arc-20160816; b=Su1NXuHV1swB9nSY727qQ/3l9fzq9b57hRLcDcpT+xYYlyMx9oJEGGORUaExnZF+P6 3RTiIWiTzIhg2TMhcvtfJb7HWae1UPe4WOfipAvOsULldNmhWIu1Z0w9oEY4EITPeCYh KaIbngax4mbomCXioyGSV7wFQwLE5Auh6kiegntl16fU6ujHCdTSjx2HGXQXxUSXAZEJ lUI6tO5bGf0uWolh7ZWBhWSXj5PEleKPo72memDzBijsUFWLcSnA/FrNvOVP392yRekI r0Fd8C+RJLWmAfqTobybDXbRMhonNYfVyVxSZm/Q8xFmSRGmaPjfOp69GgBUuiaSkP9U mI2A== 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=y10iMSzAVLEf2YqmF2Tel+iWf70CMa4IQbYumr/vdGM=; b=bfHVeWOLVtiRBRxl7GqEQsv8MjJ3ixTDSzm1FQaFfYzUZZgXVsnXS7mxm1eteBWeOq AvLn4mjYiAtE3BqsrM8qWcYB6zJxIDY7Li+UJQa8o2DjqLn4D6SS6jTvNxcsbD0pxwvR r2l+zEa8wqHBBll/hhwF9K0AqNp3x57ASZqqrdcY4jInc6n5/mirSXsJCXVvzrFfA/Xc BAOzdQnlRjD054NQMJkEmCZWKdLnkO5TNovMUYxPfqAR032QslIGdfr87oielANIES0E 6yNiElpCh5kKneXl4LpeJlTvSlLTdb4klQWoeQeIO7VsOzN96oBpvdKLJ9ksHOavduvO cSdg== 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 dv23si3843797ejb.408.2021.01.15.05.51.12; Fri, 15 Jan 2021 05:51:36 -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 S1732299AbhAONtO (ORCPT + 99 others); Fri, 15 Jan 2021 08:49:14 -0500 Received: from mga04.intel.com ([192.55.52.120]:39849 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726381AbhAONtO (ORCPT ); Fri, 15 Jan 2021 08:49:14 -0500 IronPort-SDR: CaeBc8eqK62tybvnZIsxnHkf5MSObIalfDoNIGUSkgqiPtSEIpHGDcWGzg8aOay2L9ZVHOqg8b El8uFfWrYlZw== X-IronPort-AV: E=McAfee;i="6000,8403,9864"; a="175968434" X-IronPort-AV: E=Sophos;i="5.79,349,1602572400"; d="scan'208";a="175968434" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 05:48:32 -0800 IronPort-SDR: zOIWh6gHEjPDYHR8fMNQFv1tUPOo/S/TDp1mcZCkkr1sPLx4eqhLT6FA3s0N7o7JW9VOa+MU8r rk1ft05pTxFg== X-IronPort-AV: E=Sophos;i="5.79,349,1602572400"; d="scan'208";a="354310399" Received: from bmkierna-mobl3.ger.corp.intel.com (HELO localhost) ([10.213.221.58]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 05:48:26 -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: <20210114221709.2261452-2-lyude@redhat.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> Date: Fri, 15 Jan 2021 15:48:23 +0200 Message-ID: <8735z2pazc.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > .../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