All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Allen Ballway <ballway@chromium.org>
Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915/quirk: Add quirk for devices with incorrect PWM frequency
Date: Thu, 9 Nov 2023 10:05:31 -0800	[thread overview]
Message-ID: <ZU0fa6fvT4ZWTNXr@google.com> (raw)
In-Reply-To: <20231017175728.1.Ibc6408a8ff1f334974104c5bcc25f2f35a57f36e@changeid>

Hi Allen,

On Tue, Oct 17, 2023 at 06:01:39PM +0000, Allen Ballway wrote:
> Cyernet T10C has a bad default PWM frequency causing the display to
> strobe when the brightness is less than 100%. Create a new quirk to use
> the value from the BIOS rather than the default register value.
> 
> Signed-off-by: Allen Ballway <ballway@chromium.org>
> 
> ---
> 
>  .../gpu/drm/i915/display/intel_backlight.c    |  3 ++-
>  drivers/gpu/drm/i915/display/intel_quirks.c   | 26 +++++++++++++++++++
>  drivers/gpu/drm/i915/display/intel_quirks.h   |  1 +
>  3 files changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c
> index 2e8f17c045222..c4dcfece9deca 100644
> --- a/drivers/gpu/drm/i915/display/intel_backlight.c
> +++ b/drivers/gpu/drm/i915/display/intel_backlight.c
> @@ -1388,7 +1388,8 @@ static int vlv_setup_backlight(struct intel_connector *connector, enum pipe pipe
>  	ctl = intel_de_read(i915, VLV_BLC_PWM_CTL(pipe));
>  	panel->backlight.pwm_level_max = ctl >> 16;
> 
> -	if (!panel->backlight.pwm_level_max)
> +	if (!panel->backlight.pwm_level_max ||
> +	    intel_has_quirk(i915, QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY))
>  		panel->backlight.pwm_level_max = get_backlight_max_vbt(connector);

I think it would be better if we did:

	if (!intel_has_quirk(i915, QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY)) {
		ctl = intel_de_read(i915, VLV_BLC_PWM_CTL(pipe));
		panel->backlight.pwm_level_max = ctl >> 16;
	} else {
		panel->backlight.pwm_level_max = 0;
	}

	if (!panel->backlight.pwm_level_max)
		panel->backlight.pwm_level_max = get_backlight_max_vbt(connector);

The "else" branch can potentially be omitted if we know that backlight
member is initialized to 0 (I suspect it is).

> 
>  	if (!panel->backlight.pwm_level_max)
> diff --git a/drivers/gpu/drm/i915/display/intel_quirks.c b/drivers/gpu/drm/i915/display/intel_quirks.c
> index a280448df771a..ff6cb499428ce 100644
> --- a/drivers/gpu/drm/i915/display/intel_quirks.c
> +++ b/drivers/gpu/drm/i915/display/intel_quirks.c
> @@ -65,6 +65,12 @@ static void quirk_no_pps_backlight_power_hook(struct drm_i915_private *i915)
>  	drm_info(&i915->drm, "Applying no pps backlight power quirk\n");
>  }
> 
> +static void quirk_ignore_default_pwm_frequency(struct drm_i915_private *i915)
> +{
> +	intel_set_quirk(i915, QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY);
> +	drm_info(&i915->drm, "Applying ignore default pwm frequency quirk");
> +}
> +
>  struct intel_quirk {
>  	int device;
>  	int subsystem_vendor;
> @@ -90,6 +96,12 @@ static int intel_dmi_no_pps_backlight(const struct dmi_system_id *id)
>  	return 1;
>  }
> 
> +static int intel_dmi_ignore_default_pwm_frequency(const struct dmi_system_id *id)
> +{
> +	DRM_INFO("Default PWM frequency is incorrect and is overridden on %s\n", id->ident);
> +	return 1;
> +}
> +
>  static const struct intel_dmi_quirk intel_dmi_quirks[] = {
>  	{
>  		.dmi_id_list = &(const struct dmi_system_id[]) {
> @@ -136,6 +148,20 @@ static const struct intel_dmi_quirk intel_dmi_quirks[] = {
>  		},
>  		.hook = quirk_no_pps_backlight_power_hook,
>  	},
> +	{
> +		.dmi_id_list = &(const struct dmi_system_id[]) {
> +			{
> +				.callback = intel_dmi_ignore_default_pwm_frequency,
> +				.ident = "Cybernet T10C Tablet",
> +				.matches = {DMI_EXACT_MATCH(DMI_BOARD_VENDOR,
> +							    "Cybernet Manufacturing Inc."),
> +					    DMI_EXACT_MATCH(DMI_BOARD_NAME, "T10C Tablet"),
> +				},
> +			},
> +			{ }
> +		},
> +		.hook = quirk_ignore_default_pwm_frequency,
> +	},
>  };
> 
>  static struct intel_quirk intel_quirks[] = {
> diff --git a/drivers/gpu/drm/i915/display/intel_quirks.h b/drivers/gpu/drm/i915/display/intel_quirks.h
> index 10a4d163149fd..70589505e5a0e 100644
> --- a/drivers/gpu/drm/i915/display/intel_quirks.h
> +++ b/drivers/gpu/drm/i915/display/intel_quirks.h
> @@ -17,6 +17,7 @@ enum intel_quirk_id {
>  	QUIRK_INVERT_BRIGHTNESS,
>  	QUIRK_LVDS_SSC_DISABLE,
>  	QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK,
> +	QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY

You want a trailing comma here.

>  };
> 
>  void intel_init_quirks(struct drm_i915_private *i915);
> --
> 2.42.0.655.g421f12c284-goog
> 

Thanks.

-- 
Dmitry

WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Allen Ballway <ballway@chromium.org>
Cc: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915/quirk: Add quirk for devices with incorrect PWM frequency
Date: Thu, 9 Nov 2023 10:05:31 -0800	[thread overview]
Message-ID: <ZU0fa6fvT4ZWTNXr@google.com> (raw)
In-Reply-To: <20231017175728.1.Ibc6408a8ff1f334974104c5bcc25f2f35a57f36e@changeid>

Hi Allen,

On Tue, Oct 17, 2023 at 06:01:39PM +0000, Allen Ballway wrote:
> Cyernet T10C has a bad default PWM frequency causing the display to
> strobe when the brightness is less than 100%. Create a new quirk to use
> the value from the BIOS rather than the default register value.
> 
> Signed-off-by: Allen Ballway <ballway@chromium.org>
> 
> ---
> 
>  .../gpu/drm/i915/display/intel_backlight.c    |  3 ++-
>  drivers/gpu/drm/i915/display/intel_quirks.c   | 26 +++++++++++++++++++
>  drivers/gpu/drm/i915/display/intel_quirks.h   |  1 +
>  3 files changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c
> index 2e8f17c045222..c4dcfece9deca 100644
> --- a/drivers/gpu/drm/i915/display/intel_backlight.c
> +++ b/drivers/gpu/drm/i915/display/intel_backlight.c
> @@ -1388,7 +1388,8 @@ static int vlv_setup_backlight(struct intel_connector *connector, enum pipe pipe
>  	ctl = intel_de_read(i915, VLV_BLC_PWM_CTL(pipe));
>  	panel->backlight.pwm_level_max = ctl >> 16;
> 
> -	if (!panel->backlight.pwm_level_max)
> +	if (!panel->backlight.pwm_level_max ||
> +	    intel_has_quirk(i915, QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY))
>  		panel->backlight.pwm_level_max = get_backlight_max_vbt(connector);

I think it would be better if we did:

	if (!intel_has_quirk(i915, QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY)) {
		ctl = intel_de_read(i915, VLV_BLC_PWM_CTL(pipe));
		panel->backlight.pwm_level_max = ctl >> 16;
	} else {
		panel->backlight.pwm_level_max = 0;
	}

	if (!panel->backlight.pwm_level_max)
		panel->backlight.pwm_level_max = get_backlight_max_vbt(connector);

The "else" branch can potentially be omitted if we know that backlight
member is initialized to 0 (I suspect it is).

> 
>  	if (!panel->backlight.pwm_level_max)
> diff --git a/drivers/gpu/drm/i915/display/intel_quirks.c b/drivers/gpu/drm/i915/display/intel_quirks.c
> index a280448df771a..ff6cb499428ce 100644
> --- a/drivers/gpu/drm/i915/display/intel_quirks.c
> +++ b/drivers/gpu/drm/i915/display/intel_quirks.c
> @@ -65,6 +65,12 @@ static void quirk_no_pps_backlight_power_hook(struct drm_i915_private *i915)
>  	drm_info(&i915->drm, "Applying no pps backlight power quirk\n");
>  }
> 
> +static void quirk_ignore_default_pwm_frequency(struct drm_i915_private *i915)
> +{
> +	intel_set_quirk(i915, QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY);
> +	drm_info(&i915->drm, "Applying ignore default pwm frequency quirk");
> +}
> +
>  struct intel_quirk {
>  	int device;
>  	int subsystem_vendor;
> @@ -90,6 +96,12 @@ static int intel_dmi_no_pps_backlight(const struct dmi_system_id *id)
>  	return 1;
>  }
> 
> +static int intel_dmi_ignore_default_pwm_frequency(const struct dmi_system_id *id)
> +{
> +	DRM_INFO("Default PWM frequency is incorrect and is overridden on %s\n", id->ident);
> +	return 1;
> +}
> +
>  static const struct intel_dmi_quirk intel_dmi_quirks[] = {
>  	{
>  		.dmi_id_list = &(const struct dmi_system_id[]) {
> @@ -136,6 +148,20 @@ static const struct intel_dmi_quirk intel_dmi_quirks[] = {
>  		},
>  		.hook = quirk_no_pps_backlight_power_hook,
>  	},
> +	{
> +		.dmi_id_list = &(const struct dmi_system_id[]) {
> +			{
> +				.callback = intel_dmi_ignore_default_pwm_frequency,
> +				.ident = "Cybernet T10C Tablet",
> +				.matches = {DMI_EXACT_MATCH(DMI_BOARD_VENDOR,
> +							    "Cybernet Manufacturing Inc."),
> +					    DMI_EXACT_MATCH(DMI_BOARD_NAME, "T10C Tablet"),
> +				},
> +			},
> +			{ }
> +		},
> +		.hook = quirk_ignore_default_pwm_frequency,
> +	},
>  };
> 
>  static struct intel_quirk intel_quirks[] = {
> diff --git a/drivers/gpu/drm/i915/display/intel_quirks.h b/drivers/gpu/drm/i915/display/intel_quirks.h
> index 10a4d163149fd..70589505e5a0e 100644
> --- a/drivers/gpu/drm/i915/display/intel_quirks.h
> +++ b/drivers/gpu/drm/i915/display/intel_quirks.h
> @@ -17,6 +17,7 @@ enum intel_quirk_id {
>  	QUIRK_INVERT_BRIGHTNESS,
>  	QUIRK_LVDS_SSC_DISABLE,
>  	QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK,
> +	QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY

You want a trailing comma here.

>  };
> 
>  void intel_init_quirks(struct drm_i915_private *i915);
> --
> 2.42.0.655.g421f12c284-goog
> 

Thanks.

-- 
Dmitry

  parent reply	other threads:[~2023-11-09 18:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17 18:01 [Intel-gfx] [PATCH] drm/i915/quirk: Add quirk for devices with incorrect PWM frequency Allen Ballway
2023-10-17 18:01 ` Allen Ballway
2023-10-17 18:01 ` Allen Ballway
2023-10-17 18:46 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2023-10-18  0:32 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2023-11-09 18:05 ` Dmitry Torokhov [this message]
2023-11-09 18:05   ` [Intel-gfx] [PATCH] " Dmitry Torokhov
2023-11-10 19:13   ` [Intel-gfx] [PATCH v2] " Allen Ballway
2023-11-10 19:13     ` Allen Ballway
2023-11-10 19:13     ` Allen Ballway
2023-11-10 22:01 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/quirk: Add quirk for devices with incorrect PWM frequency (rev2) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZU0fa6fvT4ZWTNXr@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=ballway@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.