From: Jani Nikula <jani.nikula@intel.com>
To: "Jouni Högander" <jouni.hogander@intel.com>,
intel-gfx@lists.freedesktop.org
Cc: ville.syrjala@linux.intel.com,
"Jouni Högander" <jouni.hogander@intel.com>
Subject: Re: [PATCH v3 1/2] drm/i915/display: Add mechanism to use sink model when applying quirk
Date: Mon, 02 Sep 2024 11:31:32 +0300 [thread overview]
Message-ID: <87cylmv4m3.fsf@intel.com> (raw)
In-Reply-To: <20240902064241.1020965-2-jouni.hogander@intel.com>
On Mon, 02 Sep 2024, Jouni Högander <jouni.hogander@intel.com> wrote:
> Currently there is no way to apply quirk on device only if certain panel
> model is installed. This patch implements such mechanism by adding new
> quirk type intel_dpcd_quirk which contains also sink_oui and sink_device_id
> fields and using also them to figure out if applying quirk is needed.
>
> New intel_init_dpcd_quirks is added and called after drm_dp_read_desc with
> proper sink device identity read from dpcdc.
>
> v3:
> - !mem_is_zero fixed to mem_is_zero
> v2:
> - instead of using struct intel_quirk add new struct intel_dpcd_quirk
>
> Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> .../drm/i915/display/intel_display_types.h | 4 ++
> drivers/gpu/drm/i915/display/intel_dp.c | 4 ++
> drivers/gpu/drm/i915/display/intel_quirks.c | 51 +++++++++++++++++++
> drivers/gpu/drm/i915/display/intel_quirks.h | 5 ++
> 4 files changed, 64 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> index 868ff8976ed93..ba1617bcea9f5 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -1907,6 +1907,10 @@ struct intel_dp {
> } alpm_parameters;
>
> u8 alpm_dpcd;
> +
> + struct {
> + unsigned long mask;
> + } quirks;
> };
>
> enum lspcon_vendor {
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 789c2f78826d0..98ed39413a7de 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -84,6 +84,7 @@
> #include "intel_pch_display.h"
> #include "intel_pps.h"
> #include "intel_psr.h"
> +#include "intel_quirks.h"
> #include "intel_tc.h"
> #include "intel_vdsc.h"
> #include "intel_vrr.h"
> @@ -4053,6 +4054,7 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp, struct intel_connector *connector
>
> drm_dp_read_desc(&intel_dp->aux, &intel_dp->desc,
> drm_dp_is_branch(intel_dp->dpcd));
> + intel_init_dpcd_quirks(intel_dp, &intel_dp->desc.ident);
>
> /*
> * Read the eDP display control registers.
> @@ -4165,6 +4167,8 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp)
> drm_dp_read_desc(&intel_dp->aux, &intel_dp->desc,
> drm_dp_is_branch(intel_dp->dpcd));
>
> + intel_init_dpcd_quirks(intel_dp, &intel_dp->desc.ident);
> +
> intel_dp_update_sink_caps(intel_dp);
> }
>
> diff --git a/drivers/gpu/drm/i915/display/intel_quirks.c b/drivers/gpu/drm/i915/display/intel_quirks.c
> index 14d5fefc9c5b2..bce1f67c918bb 100644
> --- a/drivers/gpu/drm/i915/display/intel_quirks.c
> +++ b/drivers/gpu/drm/i915/display/intel_quirks.c
> @@ -14,6 +14,11 @@ static void intel_set_quirk(struct intel_display *display, enum intel_quirk_id q
> display->quirks.mask |= BIT(quirk);
> }
>
> +static void intel_set_dpcd_quirk(struct intel_dp *intel_dp, enum intel_quirk_id quirk)
> +{
> + intel_dp->quirks.mask |= BIT(quirk);
> +}
> +
> /*
> * Some machines (Lenovo U160) do not work with SSC on LVDS for some reason
> */
> @@ -72,6 +77,21 @@ struct intel_quirk {
> void (*hook)(struct intel_display *display);
> };
>
> +struct intel_dpcd_quirk {
> + int device;
> + int subsystem_vendor;
> + int subsystem_device;
> + u8 sink_oui[3];
> + u8 sink_device_id[6];
> + void (*hook)(struct intel_dp *intel_dp);
> +};
> +
> +#define SINK_OUI(first, second, third) { (first), (second), (third) }
> +#define SINK_DEVICE_ID(first, second, third, fourth, fifth, sixth) \
> + { (first), (second), (third), (fourth), (fifth), (sixth) }
> +
> +#define SINK_DEVICE_ID_ANY SINK_DEVICE_ID(0, 0, 0, 0, 0, 0)
> +
> /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
> struct intel_dmi_quirk {
> void (*hook)(struct intel_display *display);
> @@ -203,6 +223,9 @@ static struct intel_quirk intel_quirks[] = {
> { 0x0f31, 0x103c, 0x220f, quirk_invert_brightness },
> };
>
> +static struct intel_dpcd_quirk intel_dpcd_quirks[] = {
> +};
> +
> void intel_init_quirks(struct intel_display *display)
> {
> struct pci_dev *d = to_pci_dev(display->drm->dev);
> @@ -224,7 +247,35 @@ void intel_init_quirks(struct intel_display *display)
> }
> }
>
> +void intel_init_dpcd_quirks(struct intel_dp *intel_dp,
> + const struct drm_dp_dpcd_ident *ident)
> +{
> + struct intel_display *display = to_intel_display(intel_dp);
> + struct pci_dev *d = to_pci_dev(display->drm->dev);
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(intel_dpcd_quirks); i++) {
> + struct intel_dpcd_quirk *q = &intel_dpcd_quirks[i];
> +
> + if (d->device == q->device &&
> + (d->subsystem_vendor == q->subsystem_vendor ||
> + q->subsystem_vendor == PCI_ANY_ID) &&
> + (d->subsystem_device == q->subsystem_device ||
> + q->subsystem_device == PCI_ANY_ID) &&
> + !memcmp(q->sink_oui, ident->oui, sizeof(ident->oui)) &&
> + (!memcmp(q->sink_device_id, ident->device_id,
> + sizeof(ident->device_id)) ||
> + mem_is_zero(q->sink_device_id, sizeof(q->sink_device_id))))
> + q->hook(intel_dp);
> + }
> +}
> +
> bool intel_has_quirk(struct intel_display *display, enum intel_quirk_id quirk)
> {
> return display->quirks.mask & BIT(quirk);
> }
> +
> +bool intel_has_dpcd_quirk(struct intel_dp *intel_dp, enum intel_quirk_id quirk)
> +{
> + return intel_dp->quirks.mask & BIT(quirk);
> +}
> diff --git a/drivers/gpu/drm/i915/display/intel_quirks.h b/drivers/gpu/drm/i915/display/intel_quirks.h
> index 151c8f4ae5760..c8db50b9ab74d 100644
> --- a/drivers/gpu/drm/i915/display/intel_quirks.h
> +++ b/drivers/gpu/drm/i915/display/intel_quirks.h
> @@ -9,6 +9,8 @@
> #include <linux/types.h>
>
> struct intel_display;
> +struct intel_dp;
> +struct drm_dp_dpcd_ident;
>
> enum intel_quirk_id {
> QUIRK_BACKLIGHT_PRESENT,
> @@ -20,6 +22,9 @@ enum intel_quirk_id {
> };
>
> void intel_init_quirks(struct intel_display *display);
> +void intel_init_dpcd_quirks(struct intel_dp *intel_dp,
> + const struct drm_dp_dpcd_ident *ident);
> bool intel_has_quirk(struct intel_display *display, enum intel_quirk_id quirk);
> +bool intel_has_dpcd_quirk(struct intel_dp *intel_dp, enum intel_quirk_id quirk);
>
> #endif /* __INTEL_QUIRKS_H__ */
--
Jani Nikula, Intel
next prev parent reply other threads:[~2024-09-02 8:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 6:42 [PATCH v3 0/2] Increase fastwake sync pulse count as a quirk Jouni Högander
2024-09-02 6:42 ` [PATCH v3 1/2] drm/i915/display: Add mechanism to use sink model when applying quirk Jouni Högander
2024-09-02 8:31 ` Jani Nikula [this message]
2024-09-02 6:42 ` [PATCH v3 2/2] drm/i915/display: Increase Fast Wake Sync length as a quirk Jouni Högander
2024-09-02 8:33 ` Jani Nikula
2024-09-03 5:07 ` Hogander, Jouni
2024-09-02 7:30 ` ✗ Fi.CI.SPARSE: warning for Increase fastwake sync pulse count as a quirk (rev3) Patchwork
2024-09-02 7:49 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-09-02 10:28 ` ✓ Fi.CI.BAT: success " Patchwork
2024-09-02 14:32 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-09-02 17:04 ` Hogander, Jouni
2024-09-09 3:37 ` ✓ Fi.CI.IGT: success " 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=87cylmv4m3.fsf@intel.com \
--to=jani.nikula@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jouni.hogander@intel.com \
--cc=ville.syrjala@linux.intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox