[Intel-gfx] [PATCH v5 1/2] drm/i915/opregion: add support for mailbox #5 EDID

2021-12-29 Thread Anisse Astier
The ACPI OpRegion Mailbox #5 ASLE extension may contain an EDID to be
used for the embedded display. Add support for using it via by adding
the EDID to the list of available modes on the connector, and use it for
eDP when available.

If a panel's EDID is broken, there may be an override EDID set in the
ACPI OpRegion mailbox #5. Use it if available.

Fixes the GPD Win Max display.

Based on original patch series by: Jani Nikula 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/

Changes:
 - EDID is copied and validated with drm_edid_is_valid
 - EDID is now only used as a fallback.
 - squashed the two patches

Cc: Jani Nikula 
Cc: Uma Shankar 
Cc: Ville Syrjälä 
Co-developed-by: Jani Nikula 
Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/i915/display/intel_dp.c   |  8 +++
 drivers/gpu/drm/i915/display/intel_opregion.c | 55 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h | 10 
 3 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index b5e2508db1cf..d6d8c9922feb 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -4974,6 +4974,14 @@ static bool intel_edp_init_connector(struct intel_dp 
*intel_dp,
 
mutex_lock(&dev->mode_config.mutex);
edid = drm_get_edid(connector, &intel_dp->aux.ddc);
+   if (!edid) {
+   /* Fallback to EDID from ACPI OpRegion, if any */
+   edid = intel_opregion_get_edid(intel_connector);
+   if (edid)
+   drm_dbg_kms(&dev_priv->drm,
+   "[CONNECTOR:%d:%s] Using OpRegion EDID\n",
+   connector->base.id, connector->name);
+   }
if (edid) {
if (drm_add_edid_modes(connector, edid)) {
drm_connector_update_edid_property(connector, edid);
diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c 
b/drivers/gpu/drm/i915/display/intel_opregion.c
index 0065111593a6..985790a66a4d 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.c
+++ b/drivers/gpu/drm/i915/display/intel_opregion.c
@@ -195,6 +195,8 @@ struct opregion_asle_ext {
 #define ASLE_IUER_WINDOWS_BTN  (1 << 1)
 #define ASLE_IUER_POWER_BTN(1 << 0)
 
+#define ASLE_PHED_EDID_VALID_MASK  0x3
+
 /* Software System Control Interrupt (SWSCI) */
 #define SWSCI_SCIC_INDICATOR   (1 << 0)
 #define SWSCI_SCIC_MAIN_FUNCTION_SHIFT 1
@@ -908,8 +910,10 @@ int intel_opregion_setup(struct drm_i915_private *dev_priv)
opregion->asle->ardy = ASLE_ARDY_NOT_READY;
}
 
-   if (mboxes & MBOX_ASLE_EXT)
+   if (mboxes & MBOX_ASLE_EXT) {
drm_dbg(&dev_priv->drm, "ASLE extension supported\n");
+   opregion->asle_ext = base + OPREGION_ASLE_EXT_OFFSET;
+   }
 
if (intel_load_vbt_firmware(dev_priv) == 0)
goto out;
@@ -1036,6 +1040,54 @@ intel_opregion_get_panel_type(struct drm_i915_private 
*dev_priv)
return ret - 1;
 }
 
+/**
+ * intel_opregion_get_edid - Fetch EDID from ACPI OpRegion mailbox #5
+ * @intel_connector: eDP connector
+ *
+ * This reads the ACPI Opregion mailbox #5 to extract the EDID that is passed
+ * to it.
+ *
+ * Returns:
+ * The EDID in the OpRegion, or NULL if there is none or it's invalid.
+ *
+ */
+struct edid *intel_opregion_get_edid(struct intel_connector *intel_connector)
+{
+   struct drm_connector *connector = &intel_connector->base;
+   struct drm_i915_private *i915 = to_i915(connector->dev);
+   struct intel_opregion *opregion = &i915->opregion;
+   const void *in_edid;
+   const struct edid *edid;
+   struct edid *new_edid;
+   int len;
+
+   if (!opregion->asle_ext)
+   return NULL;
+
+   in_edid = opregion->asle_ext->bddc;
+
+   /* Validity corresponds to number of 128-byte blocks */
+   len = (opregion->asle_ext->phed & ASLE_PHED_EDID_VALID_MASK) * 128;
+   if (!len || !memchr_inv(in_edid, 0, len))
+   return NULL;
+
+   edid = in_edid;
+
+   if (len < EDID_LENGTH * (1 + edid->extensions)) {
+   drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox 
#5): too short\n");
+   return NULL;
+   }
+   new_edid = drm_edid_duplicate(edid);
+   if (!new_edid)
+   return NULL;
+   if (!drm_edid_is_valid(new_edid)) {
+   kfree(new_edid);
+   drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox 
#5)\n");
+   return NULL;
+   }
+   return new_edid;
+}
+
 void intel_opregion_register(struct drm_i915_private *i915)
 {
struct intel_opregion 

[Intel-gfx] [PATCH v5 2/2] drm: Add orientation quirk for GPD Win Max

2021-12-29 Thread Anisse Astier
Panel is 800x1280, but mounted on a laptop form factor, sideways.

Signed-off-by: Anisse Astier 
Reviewed-by: Hans de Goede 
---
 drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c 
b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index 042bb80383c9..3dc383b1e2ba 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -174,6 +174,12 @@ static const struct dmi_system_id orientation_data[] = {
  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MicroPC"),
},
.driver_data = (void *)&lcd720x1280_rightside_up,
+   }, {/* GPD Win Max */
+   .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "GPD"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G1619-01"),
+   },
+   .driver_data = (void *)&lcd800x1280_rightside_up,
}, {/*
 * GPD Pocket, note that the the DMI data is less generic then
 * it seems, devices with a board-vendor of "AMI Corporation"
-- 
2.33.1



[Intel-gfx] [PATCH v5 0/2] GPD Win Max display fixes

2021-12-29 Thread Anisse Astier
This patch series is for making the GPD Win Max display usable with
Linux.

The GPD Win Max is a small laptop, and its eDP panel does not send an
EDID over DPCD; the EDID is instead available in the intel opregion, in
mailbox #5 [1]

The second patch is just to fix the orientation of the panel.

Changes since v1:
 - rebased on drm-tip
 - squashed patch 1 & 2
 - picked up Reviewed-by from Hans de Goede (thanks for the review)

Changes since v2:
 - rebased on drm-tip
 - updated commit message

When v2 was initially sent [3] Ville Syrjälä suggested that it might be
a good idea to use the ACPI _DDC method instead to get the EDID, to
cover a wider range of hardware. Unfortunately, it doesn't seem
available on GPD Win Max, so I think this work should be done
independently, and this patch series considered separately.

Change since v3:
 - edits following Jani's review:
- The EDID from the opregion is now only used as a fallback: if we
  cannot get any edid from the edp connector, then we attempt to get
  it from the opregion. This works for the GPD Win Max.
- all other remarks should have been taken into account
 - rebased on drm-tip
 - added Co-developed-by
 - reordered signed-off-by and reviewed-by in second patch (thanks
   Maarten!)

Changes since v4:
 - checkpatch.pl fixes
 - rebased on drm-tip
 - Note: patch #1 is incomplete, still missing Jani's signed-off-by


[1]: https://gitlab.freedesktop.org/drm/intel/-/issues/3454
[2]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/
[3]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20210531204642.4907-2-ani...@astier.eu/


Anisse Astier (2):
  drm/i915/opregion: add support for mailbox #5 EDID
  drm: Add orientation quirk for GPD Win Max

 .../gpu/drm/drm_panel_orientation_quirks.c|  6 ++
 drivers/gpu/drm/i915/display/intel_dp.c   |  7 +++
 drivers/gpu/drm/i915/display/intel_opregion.c | 55 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h | 10 
 4 files changed, 77 insertions(+), 1 deletion(-)

-- 
2.31.1



[Intel-gfx] [PATCH v4 RESEND 2/2] drm: Add orientation quirk for GPD Win Max

2021-12-09 Thread Anisse Astier
Panel is 800x1280, but mounted on a laptop form factor, sideways.

Signed-off-by: Anisse Astier 
Reviewed-by: Hans de Goede 
---
 drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c 
b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index 042bb80383c9..3dc383b1e2ba 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -174,6 +174,12 @@ static const struct dmi_system_id orientation_data[] = {
  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MicroPC"),
},
.driver_data = (void *)&lcd720x1280_rightside_up,
+   }, {/* GPD Win Max */
+   .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "GPD"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G1619-01"),
+   },
+   .driver_data = (void *)&lcd800x1280_rightside_up,
}, {/*
 * GPD Pocket, note that the the DMI data is less generic then
 * it seems, devices with a board-vendor of "AMI Corporation"
-- 
2.31.1



[Intel-gfx] [PATCH v4 RESEND 1/2] drm/i915/opregion: add support for mailbox #5 EDID

2021-12-09 Thread Anisse Astier
The ACPI OpRegion Mailbox #5 ASLE extension may contain an EDID to be
used for the embedded display. Add support for using it via by adding
the EDID to the list of available modes on the connector, and use it for
eDP when available.

If a panel's EDID is broken, there may be an override EDID set in the
ACPI OpRegion mailbox #5. Use it if available.

Fixes the GPD Win Max display.

Based on original patch series by: Jani Nikula 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/

Changes:
 - EDID is copied and validated with drm_edid_is_valid
 - EDID is now only used as a fallback.
 - squashed the two patches

Cc: Jani Nikula 
Cc: Uma Shankar 
Cc: Ville Syrjälä 
Co-developed-by: Jani Nikula 
Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/i915/display/intel_dp.c   |  8 +++
 drivers/gpu/drm/i915/display/intel_opregion.c | 55 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h | 10 
 3 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index 0a424bf69396..a3c64125405e 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -4962,6 +4962,14 @@ static bool intel_edp_init_connector(struct intel_dp 
*intel_dp,
 
mutex_lock(&dev->mode_config.mutex);
edid = drm_get_edid(connector, &intel_dp->aux.ddc);
+   if (!edid) {
+   /* Fallback to EDID from ACPI OpRegion, if any */
+   edid = intel_opregion_get_edid(intel_connector);
+   if (edid)
+   drm_dbg_kms(&dev_priv->drm,
+   "[CONNECTOR:%d:%s] Using OpRegion EDID\n",
+   connector->base.id, connector->name);
+   }
if (edid) {
if (drm_add_edid_modes(connector, edid)) {
drm_connector_update_edid_property(connector, edid);
diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c 
b/drivers/gpu/drm/i915/display/intel_opregion.c
index 0065111593a6..985790a66a4d 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.c
+++ b/drivers/gpu/drm/i915/display/intel_opregion.c
@@ -195,6 +195,8 @@ struct opregion_asle_ext {
 #define ASLE_IUER_WINDOWS_BTN  (1 << 1)
 #define ASLE_IUER_POWER_BTN(1 << 0)
 
+#define ASLE_PHED_EDID_VALID_MASK  0x3
+
 /* Software System Control Interrupt (SWSCI) */
 #define SWSCI_SCIC_INDICATOR   (1 << 0)
 #define SWSCI_SCIC_MAIN_FUNCTION_SHIFT 1
@@ -908,8 +910,10 @@ int intel_opregion_setup(struct drm_i915_private *dev_priv)
opregion->asle->ardy = ASLE_ARDY_NOT_READY;
}
 
-   if (mboxes & MBOX_ASLE_EXT)
+   if (mboxes & MBOX_ASLE_EXT) {
drm_dbg(&dev_priv->drm, "ASLE extension supported\n");
+   opregion->asle_ext = base + OPREGION_ASLE_EXT_OFFSET;
+   }
 
if (intel_load_vbt_firmware(dev_priv) == 0)
goto out;
@@ -1036,6 +1040,54 @@ intel_opregion_get_panel_type(struct drm_i915_private 
*dev_priv)
return ret - 1;
 }
 
+/**
+ * intel_opregion_get_edid - Fetch EDID from ACPI OpRegion mailbox #5
+ * @intel_connector: eDP connector
+ *
+ * This reads the ACPI Opregion mailbox #5 to extract the EDID that is passed
+ * to it.
+ *
+ * Returns:
+ * The EDID in the OpRegion, or NULL if there is none or it's invalid.
+ *
+ */
+struct edid *intel_opregion_get_edid(struct intel_connector *intel_connector)
+{
+   struct drm_connector *connector = &intel_connector->base;
+   struct drm_i915_private *i915 = to_i915(connector->dev);
+   struct intel_opregion *opregion = &i915->opregion;
+   const void *in_edid;
+   const struct edid *edid;
+   struct edid *new_edid;
+   int len;
+
+   if (!opregion->asle_ext)
+   return NULL;
+
+   in_edid = opregion->asle_ext->bddc;
+
+   /* Validity corresponds to number of 128-byte blocks */
+   len = (opregion->asle_ext->phed & ASLE_PHED_EDID_VALID_MASK) * 128;
+   if (!len || !memchr_inv(in_edid, 0, len))
+   return NULL;
+
+   edid = in_edid;
+
+   if (len < EDID_LENGTH * (1 + edid->extensions)) {
+   drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox 
#5): too short\n");
+   return NULL;
+   }
+   new_edid = drm_edid_duplicate(edid);
+   if (!new_edid)
+   return NULL;
+   if (!drm_edid_is_valid(new_edid)) {
+   kfree(new_edid);
+   drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox 
#5)\n");
+   return NULL;
+   }
+   return new_edid;
+}
+
 void intel_opregion_register(struct drm_i915_private *i915)
 {
struct intel_opregion 

[Intel-gfx] [PATCH v4 RESEND 0/2] GPD Win Max display fixes

2021-12-09 Thread Anisse Astier
This patch series is for making the GPD Win Max display usable with
Linux.

The GPD Win Max is a small laptop, and its eDP panel does not send an
EDID over DPCD; the EDID is instead available in the intel opregion, in
mailbox #5 [1]

The second patch is just to fix the orientation of the panel.

Changes since v1:
 - rebased on drm-tip
 - squashed patch 1 & 2
 - picked up Reviewed-by from Hans de Goede (thanks for the review)

Changes since v2:
 - rebased on drm-tip
 - updated commit message

When v2 was initially sent [3] Ville Syrjälä suggested that it might be
a good idea to use the ACPI _DDC method instead to get the EDID, to
cover a wider range of hardware. Unfortunately, it doesn't seem
available on GPD Win Max, so I think this work should be done
independently, and this patch series considered separately.

Change since v3:
 - edits following Jani's review:
- The EDID from the opregion is now only used as a fallback: if we
  cannot get any edid from the edp connector, then we attempt to get
  it from the opregion. This works for the GPD Win Max.
- all other remarks should have been taken into account
 - rebased on drm-tip
 - added Co-developed-by
 - reordered signed-off-by and reviewed-by in second patch (thanks
   Maarten!)


[1]: https://gitlab.freedesktop.org/drm/intel/-/issues/3454
[2]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/
[3]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20210531204642.4907-2-ani...@astier.eu/


Anisse Astier (2):
  drm/i915/opregion: add support for mailbox #5 EDID
  drm: Add orientation quirk for GPD Win Max

 .../gpu/drm/drm_panel_orientation_quirks.c|  6 ++
 drivers/gpu/drm/i915/display/intel_dp.c   |  7 +++
 drivers/gpu/drm/i915/display/intel_opregion.c | 55 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h | 10 
 4 files changed, 77 insertions(+), 1 deletion(-)

-- 
2.31.1



[Intel-gfx] [PATCH v4 2/2] drm: Add orientation quirk for GPD Win Max

2021-09-05 Thread Anisse Astier
Panel is 800x1280, but mounted on a laptop form factor, sideways.

Signed-off-by: Anisse Astier 
Reviewed-by: Hans de Goede 
---
 drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c 
b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index 4e965b0f5502..643b55f9a9d1 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -160,6 +160,12 @@ static const struct dmi_system_id orientation_data[] = {
  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MicroPC"),
},
.driver_data = (void *)&lcd720x1280_rightside_up,
+   }, {/* GPD Win Max */
+   .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "GPD"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G1619-01"),
+   },
+   .driver_data = (void *)&lcd800x1280_rightside_up,
}, {/*
 * GPD Pocket, note that the the DMI data is less generic then
 * it seems, devices with a board-vendor of "AMI Corporation"
-- 
2.31.1



[Intel-gfx] [PATCH v4 1/2] drm/i915/opregion: add support for mailbox #5 EDID

2021-09-05 Thread Anisse Astier
The ACPI OpRegion Mailbox #5 ASLE extension may contain an EDID to be
used for the embedded display. Add support for using it via by adding
the EDID to the list of available modes on the connector, and use it for
eDP when available.

If a panel's EDID is broken, there may be an override EDID set in the
ACPI OpRegion mailbox #5. Use it if available.

Fixes the GPD Win Max display.

Based on original patch series by: Jani Nikula 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/

Changes:
 - EDID is copied and validated with drm_edid_is_valid
 - EDID is now only used as a fallback.
 - squashed the two patches

Cc: Jani Nikula 
Cc: Uma Shankar 
Cc: Ville Syrjälä 
Co-developed-by: Jani Nikula 
Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/i915/display/intel_dp.c   |  8 +++
 drivers/gpu/drm/i915/display/intel_opregion.c | 55 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h | 10 
 3 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index d28bd8c4a8a5..836a98d9e5c3 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -4820,6 +4820,14 @@ static bool intel_edp_init_connector(struct intel_dp 
*intel_dp,
 
mutex_lock(&dev->mode_config.mutex);
edid = drm_get_edid(connector, &intel_dp->aux.ddc);
+   if (!edid) {
+   /* Fallback to EDID from ACPI OpRegion, if any */
+   edid = intel_opregion_get_edid(intel_connector);
+   if (edid)
+   drm_dbg_kms(&dev_priv->drm,
+   "[CONNECTOR:%d:%s] Using OpRegion EDID\n",
+   connector->base.id, connector->name);
+   }
if (edid) {
if (drm_add_edid_modes(connector, edid)) {
drm_connector_update_edid_property(connector, edid);
diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c 
b/drivers/gpu/drm/i915/display/intel_opregion.c
index 0065111593a6..985790a66a4d 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.c
+++ b/drivers/gpu/drm/i915/display/intel_opregion.c
@@ -195,6 +195,8 @@ struct opregion_asle_ext {
 #define ASLE_IUER_WINDOWS_BTN  (1 << 1)
 #define ASLE_IUER_POWER_BTN(1 << 0)
 
+#define ASLE_PHED_EDID_VALID_MASK  0x3
+
 /* Software System Control Interrupt (SWSCI) */
 #define SWSCI_SCIC_INDICATOR   (1 << 0)
 #define SWSCI_SCIC_MAIN_FUNCTION_SHIFT 1
@@ -908,8 +910,10 @@ int intel_opregion_setup(struct drm_i915_private *dev_priv)
opregion->asle->ardy = ASLE_ARDY_NOT_READY;
}
 
-   if (mboxes & MBOX_ASLE_EXT)
+   if (mboxes & MBOX_ASLE_EXT) {
drm_dbg(&dev_priv->drm, "ASLE extension supported\n");
+   opregion->asle_ext = base + OPREGION_ASLE_EXT_OFFSET;
+   }
 
if (intel_load_vbt_firmware(dev_priv) == 0)
goto out;
@@ -1036,6 +1040,54 @@ intel_opregion_get_panel_type(struct drm_i915_private 
*dev_priv)
return ret - 1;
 }
 
+/**
+ * intel_opregion_get_edid - Fetch EDID from ACPI OpRegion mailbox #5
+ * @intel_connector: eDP connector
+ *
+ * This reads the ACPI Opregion mailbox #5 to extract the EDID that is passed
+ * to it.
+ *
+ * Returns:
+ * The EDID in the OpRegion, or NULL if there is none or it's invalid.
+ *
+ */
+struct edid *intel_opregion_get_edid(struct intel_connector *intel_connector)
+{
+   struct drm_connector *connector = &intel_connector->base;
+   struct drm_i915_private *i915 = to_i915(connector->dev);
+   struct intel_opregion *opregion = &i915->opregion;
+   const void *in_edid;
+   const struct edid *edid;
+   struct edid *new_edid;
+   int len;
+
+   if (!opregion->asle_ext)
+   return NULL;
+
+   in_edid = opregion->asle_ext->bddc;
+
+   /* Validity corresponds to number of 128-byte blocks */
+   len = (opregion->asle_ext->phed & ASLE_PHED_EDID_VALID_MASK) * 128;
+   if (!len || !memchr_inv(in_edid, 0, len))
+   return NULL;
+
+   edid = in_edid;
+
+   if (len < EDID_LENGTH * (1 + edid->extensions)) {
+   drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox 
#5): too short\n");
+   return NULL;
+   }
+   new_edid = drm_edid_duplicate(edid);
+   if (!new_edid)
+   return NULL;
+   if (!drm_edid_is_valid(new_edid)) {
+   kfree(new_edid);
+   drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox 
#5)\n");
+   return NULL;
+   }
+   return new_edid;
+}
+
 void intel_opregion_register(struct drm_i915_private *i915)
 {
struct intel_opregion 

[Intel-gfx] [PATCH v4 0/2] GPD Win Max display fixes

2021-09-05 Thread Anisse Astier
This patch series is for making the GPD Win Max display usable with
Linux.

The GPD Win Max is a small laptop, and its eDP panel does not send an
EDID over DPCD; the EDID is instead available in the intel opregion, in
mailbox #5 [1]

The second patch is just to fix the orientation of the panel.

Changes since v1:
 - rebased on drm-tip
 - squashed patch 1 & 2
 - picked up Reviewed-by from Hans de Goede (thanks for the review)

Changes since v2:
 - rebased on drm-tip
 - updated commit message

When v2 was initially sent [3] Ville Syrjälä suggested that it might be
a good idea to use the ACPI _DDC method instead to get the EDID, to
cover a wider range of hardware. Unfortunately, it doesn't seem
available on GPD Win Max, so I think this work should be done
independently, and this patch series considered separately.

Change since v3:
 - edits following Jani's review:
- The EDID from the opregion is now only used as a fallback: if we
  cannot get any edid from the edp connector, then we attempt to get
  it from the opregion. This works for the GPD Win Max.
- all other remarks should have been taken into account
 - rebased on drm-tip
 - added Co-developed-by
 - reordered signed-off-by and reviewed-by in second patch (thanks
   Maarten!)

[1]: https://gitlab.freedesktop.org/drm/intel/-/issues/3454
[2]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/
[3]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20210531204642.4907-2-ani...@astier.eu/


Anisse Astier (2):
  drm/i915/opregion: add support for mailbox #5 EDID
  drm: Add orientation quirk for GPD Win Max

 .../gpu/drm/drm_panel_orientation_quirks.c|  6 ++
 drivers/gpu/drm/i915/display/intel_dp.c   |  7 +++
 drivers/gpu/drm/i915/display/intel_opregion.c | 55 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h | 10 
 4 files changed, 77 insertions(+), 1 deletion(-)

-- 
2.31.1



Re: [Intel-gfx] [PATCH v3 1/2] drm/i915/opregion: add support for mailbox #5 EDID

2021-09-01 Thread Anisse Astier
Hi,

On Tue, Aug 31, 2021 at 11:30 AM Jani Nikula  wrote:
>
> On Tue, 17 Aug 2021, Anisse Astier  wrote:
> > The ACPI OpRegion Mailbox #5 ASLE extension may contain an EDID to be
> > used for the embedded display. Add support for using it via by adding
> > the EDID to the list of available modes on the connector, and use it for
> > eDP when available.
> >
> > If a panel's EDID is broken, there may be an override EDID set in the
> > ACPI OpRegion mailbox #5. Use it if available.
> >
> > Fixes the GPD Win Max laptop display, which seems to only use this
> > mechanism to provide a proper EDID for its eDP screen. It would have
> > been better to provide the EDID through the ACPI _DDC method instead, to
> > have a more generic solution, but it seems the designers of this system
> > did not consider it, and shipped the firmware without it.
>
> The question is whether the opregion EDID should be used for override or
> fallback. The patch at hand is kind of neither, it just unconditionally
> adds the modes from the opregion EDID to the connector. For your
> display, they apparently end up also being the only mode(s), with one of
> them being used as the fixed mode. (Otherwise the orientation quirk
> wouldn't work.)

Yes, I agree it should be a fallback, at least for this hardware.

>
> What does drm_get_edid() return for you? Maybe we should do something
> like this instead:
>
> mutex_lock(&dev->mode_config.mutex);
> edid = drm_get_edid(connector, &intel_dp->aux.ddc);
> +   if (!edid)
> +   edid = intel_opregion_get_edid(intel_connector);
> if (edid) {
> if (drm_add_edid_modes(connector, edid)) {
> drm_connector_update_edid_property(connector, edid);

Yes, I just tried this, it works well since drm_get_edid() does not
return an EDID.

>
> This way we'll actually use all the other bits in the EDID, not just the
> modes. And if it needs to become override rather than fallback, the
> solution is:
>
> mutex_lock(&dev->mode_config.mutex);
> -   edid = drm_get_edid(connector, &intel_dp->aux.ddc);
> +   edid = intel_opregion_get_edid(intel_connector);
> +   if (!edid)
> +   edid = drm_get_edid(connector, &intel_dp->aux.ddc);
> if (edid) {
> if (drm_add_edid_modes(connector, edid)) {
> drm_connector_update_edid_property(connector, edid);
>
> In any case, I think it's just plain wrong to use both the display and
> opregion EDIDs at the same time. It's probably all around safer to start
> with fallback.

It will be in the next iteration.

>
> Please find some further comments inline.
>
> > Based on original patch series by: Jani Nikula 
> > https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/
> >
> > Changes since Jani Nikula's series:
> >  - EDID is copied and validated with drm_edid_is_valid
> >  - Mode is now added via drm_add_edid_modes instead of using override
> >mechanism
> >  - squashed the two patches
> >
> > Cc: Jani Nikula 
> > Cc: Uma Shankar 
> > Cc: Ville Syrjälä 
> > Signed-off-by: Anisse Astier 
> > ---
> >  drivers/gpu/drm/i915/display/intel_dp.c   |  3 +
> >  drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
> >  drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
> >  3 files changed, 79 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
> > b/drivers/gpu/drm/i915/display/intel_dp.c
> > index 75d4ebc66941..f9254c0df1a2 100644
> > --- a/drivers/gpu/drm/i915/display/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> > @@ -5183,6 +5183,9 @@ static bool intel_edp_init_connector(struct intel_dp 
> > *intel_dp,
> >   goto out_vdd_off;
> >   }
> >
> > + /* Set up override EDID, if any, from ACPI OpRegion */
> > + intel_opregion_edid_probe(intel_connector);
> > +
> >   mutex_lock(&dev->mode_config.mutex);
> >   edid = drm_get_edid(connector, &intel_dp->aux.ddc);
> >   if (edid) {
> > diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c 
> > b/drivers/gpu/drm/i915/display/intel_opregion.c
> > index 3855fba70980..b1b87ed758ba 100644
> > --- a/drivers/gpu/drm/i915/display/intel_opregion.c
> > +++ b/drivers/gpu/drm/i915/display/intel_opregion.c
> > @@ -196,6 +196,8 @@ struct opregion_asle_ext {
> >  #define ASLE_IUER_WINDOWS_BTN(1 << 1)
> >

Re: [Intel-gfx] [PATCH v3 0/2] GPD Win Max display fixes

2021-08-31 Thread Anisse Astier
On Tue, Aug 31, 2021 at 11:33 AM Jani Nikula  wrote:
>
> On Tue, 17 Aug 2021, Anisse Astier  wrote:
> > This patch series is for making the GPD Win Max display usable with
> > Linux.
> >
> > The GPD Win Max is a small laptop, and its eDP panel does not send an
> > EDID over DPCD; the EDID is instead available in the intel opregion, in
> > mailbox #5 [1]
> >
> > The first patch is based on Jani's patch series [2] adding support for
> > the opregion, with changes. I've changed authorship, but I'd be glad to
> > revert it
>
> If you don't mind, please just add:
>
> Co-developed-by: Jani Nikula 

I don't mind at all, I think you should be first author for this
series, I just didn't feel like giving you the blame for the bugs
after this many modifications, without asking first. Will be in next
iteration.

Anisse


>
>
> Thanks,
> Jani.
>
> >
> > The second patch is just to fix the orientation of the panel.
> >
> > Changes since v1:
> >  - rebased on drm-tip
> >  - squashed patch 1 & 2
> >  - picked up Reviewed-by from Hans de Goede (thanks for the review)
> >
> > Changes since v2:
> >  - rebased on drm-tip
> >  - updated commit message
> >
> > When v2 was initially sent [3] Ville Syrjälä suggested that it might be
> > a good idea to use the ACPI _DDC method instead to get the EDID, to
> > cover a wider range of hardware. Unfortunately, it doesn't seem
> > available on GPD Win Max, so I think this work should be done
> > independently, and this patch series considered separately.
> >
> > [1]: https://gitlab.freedesktop.org/drm/intel/-/issues/3454
> > [2]: 
> > https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/
> > [3]: 
> > https://patchwork.kernel.org/project/intel-gfx/patch/20210531204642.4907-2-ani...@astier.eu/
> >
> >
> > Anisse Astier (2):
> >   drm/i915/opregion: add support for mailbox #5 EDID
> >   drm: Add orientation quirk for GPD Win Max
> >
> >  .../gpu/drm/drm_panel_orientation_quirks.c|  6 ++
> >  drivers/gpu/drm/i915/display/intel_dp.c   |  3 +
> >  drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
> >  drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
> >  4 files changed, 85 insertions(+), 1 deletion(-)
>
> --
> Jani Nikula, Intel Open Source Graphics Center


Re: [Intel-gfx] [PATCH v3 0/2] GPD Win Max display fixes

2021-08-30 Thread Anisse Astier
Hi,

On Tue, Aug 17, 2021 at 10:43 PM Anisse Astier  wrote:
>
> This patch series is for making the GPD Win Max display usable with
> Linux.
>
> The GPD Win Max is a small laptop, and its eDP panel does not send an
> EDID over DPCD; the EDID is instead available in the intel opregion, in
> mailbox #5 [1]
>
> The first patch is based on Jani's patch series [2] adding support for
> the opregion, with changes. I've changed authorship, but I'd be glad to
> revert it
>
> The second patch is just to fix the orientation of the panel.
>
> Changes since v1:
>  - rebased on drm-tip
>  - squashed patch 1 & 2
>  - picked up Reviewed-by from Hans de Goede (thanks for the review)
>
> Changes since v2:
>  - rebased on drm-tip
>  - updated commit message
>
> When v2 was initially sent [3] Ville Syrjälä suggested that it might be
> a good idea to use the ACPI _DDC method instead to get the EDID, to
> cover a wider range of hardware. Unfortunately, it doesn't seem
> available on GPD Win Max, so I think this work should be done
> independently, and this patch series considered separately.
>
> [1]: https://gitlab.freedesktop.org/drm/intel/-/issues/3454
> [2]: 
> https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/
> [3]: 
> https://patchwork.kernel.org/project/intel-gfx/patch/20210531204642.4907-2-ani...@astier.eu/
>
>
> Anisse Astier (2):
>   drm/i915/opregion: add support for mailbox #5 EDID
>   drm: Add orientation quirk for GPD Win Max
>
>  .../gpu/drm/drm_panel_orientation_quirks.c|  6 ++
>  drivers/gpu/drm/i915/display/intel_dp.c   |  3 +
>  drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
>  drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
>  4 files changed, 85 insertions(+), 1 deletion(-)

Would it be possible to have this series reviewed ?

Kind regards,

Anisse


[Intel-gfx] [PATCH v3 2/2] drm: Add orientation quirk for GPD Win Max

2021-08-17 Thread Anisse Astier
Panel is 800x1280, but mounted on a laptop form factor, sideways.

Reviewed-by: Hans de Goede 
Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c 
b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index 4e965b0f5502..643b55f9a9d1 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -160,6 +160,12 @@ static const struct dmi_system_id orientation_data[] = {
  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MicroPC"),
},
.driver_data = (void *)&lcd720x1280_rightside_up,
+   }, {/* GPD Win Max */
+   .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "GPD"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G1619-01"),
+   },
+   .driver_data = (void *)&lcd800x1280_rightside_up,
}, {/*
 * GPD Pocket, note that the the DMI data is less generic then
 * it seems, devices with a board-vendor of "AMI Corporation"
-- 
2.31.1



[Intel-gfx] [PATCH v3 1/2] drm/i915/opregion: add support for mailbox #5 EDID

2021-08-17 Thread Anisse Astier
The ACPI OpRegion Mailbox #5 ASLE extension may contain an EDID to be
used for the embedded display. Add support for using it via by adding
the EDID to the list of available modes on the connector, and use it for
eDP when available.

If a panel's EDID is broken, there may be an override EDID set in the
ACPI OpRegion mailbox #5. Use it if available.

Fixes the GPD Win Max laptop display, which seems to only use this
mechanism to provide a proper EDID for its eDP screen. It would have
been better to provide the EDID through the ACPI _DDC method instead, to
have a more generic solution, but it seems the designers of this system
did not consider it, and shipped the firmware without it.

Based on original patch series by: Jani Nikula 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/

Changes since Jani Nikula's series:
 - EDID is copied and validated with drm_edid_is_valid
 - Mode is now added via drm_add_edid_modes instead of using override
   mechanism
 - squashed the two patches

Cc: Jani Nikula 
Cc: Uma Shankar 
Cc: Ville Syrjälä 
Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/i915/display/intel_dp.c   |  3 +
 drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
 3 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index 75d4ebc66941..f9254c0df1a2 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -5183,6 +5183,9 @@ static bool intel_edp_init_connector(struct intel_dp 
*intel_dp,
goto out_vdd_off;
}
 
+   /* Set up override EDID, if any, from ACPI OpRegion */
+   intel_opregion_edid_probe(intel_connector);
+
mutex_lock(&dev->mode_config.mutex);
edid = drm_get_edid(connector, &intel_dp->aux.ddc);
if (edid) {
diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c 
b/drivers/gpu/drm/i915/display/intel_opregion.c
index 3855fba70980..b1b87ed758ba 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.c
+++ b/drivers/gpu/drm/i915/display/intel_opregion.c
@@ -196,6 +196,8 @@ struct opregion_asle_ext {
 #define ASLE_IUER_WINDOWS_BTN  (1 << 1)
 #define ASLE_IUER_POWER_BTN(1 << 0)
 
+#define ASLE_PHED_EDID_VALID_MASK  0x3
+
 /* Software System Control Interrupt (SWSCI) */
 #define SWSCI_SCIC_INDICATOR   (1 << 0)
 #define SWSCI_SCIC_MAIN_FUNCTION_SHIFT 1
@@ -909,8 +911,10 @@ int intel_opregion_setup(struct drm_i915_private *dev_priv)
opregion->asle->ardy = ASLE_ARDY_NOT_READY;
}
 
-   if (mboxes & MBOX_ASLE_EXT)
+   if (mboxes & MBOX_ASLE_EXT) {
drm_dbg(&dev_priv->drm, "ASLE extension supported\n");
+   opregion->asle_ext = base + OPREGION_ASLE_EXT_OFFSET;
+   }
 
if (intel_load_vbt_firmware(dev_priv) == 0)
goto out;
@@ -1037,6 +1041,68 @@ intel_opregion_get_panel_type(struct drm_i915_private 
*dev_priv)
return ret - 1;
 }
 
+/**
+ * intel_opregion_edid_probe - Add EDID from ACPI OpRegion mailbox #5
+ * @intel_connector: eDP connector
+ *
+ * This reads the ACPI Opregion mailbox #5 to extract the EDID that is passed
+ * to it.
+ *
+ * Will take a lock on the DRM mode_config to add the EDID; make sure it isn't
+ * called with lock taken.
+ *
+ */
+void intel_opregion_edid_probe(struct intel_connector *intel_connector)
+{
+   struct drm_connector *connector = &intel_connector->base;
+   struct drm_i915_private *i915 = to_i915(connector->dev);
+   struct intel_opregion *opregion = &i915->opregion;
+   const void *in_edid;
+   const struct edid *edid;
+   struct edid *new_edid;
+   int len, ret, num;
+
+   if (!opregion->asle_ext || connector->override_edid)
+   return;
+
+   in_edid = opregion->asle_ext->bddc;
+
+   /* Validity corresponds to number of 128-byte blocks */
+   len = (opregion->asle_ext->phed & ASLE_PHED_EDID_VALID_MASK) * 128;
+   if (!len || !memchr_inv(in_edid, 0, len))
+   return;
+
+   edid = in_edid;
+
+   if (len < EDID_LENGTH * (1 + edid->extensions)) {
+   drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox 
#5)\n");
+   return;
+   }
+   new_edid = drm_edid_duplicate(edid);
+   if (!new_edid) {
+   drm_err(&i915->drm, "Cannot duplicate EDID\n");
+   return;
+   }
+   if (!drm_edid_is_valid(new_edid)) {
+   kfree(new_edid);
+   drm_dbg_kms(&i915->drm, "Cannot validate EDID in ACPI OpRegion 
(Mailbox #5)\n");
+   return;
+   }
+
+   ret = drm_connector_update_

[Intel-gfx] [PATCH v3 0/2] GPD Win Max display fixes

2021-08-17 Thread Anisse Astier
This patch series is for making the GPD Win Max display usable with
Linux.

The GPD Win Max is a small laptop, and its eDP panel does not send an
EDID over DPCD; the EDID is instead available in the intel opregion, in
mailbox #5 [1]

The first patch is based on Jani's patch series [2] adding support for
the opregion, with changes. I've changed authorship, but I'd be glad to
revert it

The second patch is just to fix the orientation of the panel.

Changes since v1:
 - rebased on drm-tip
 - squashed patch 1 & 2
 - picked up Reviewed-by from Hans de Goede (thanks for the review)

Changes since v2:
 - rebased on drm-tip
 - updated commit message

When v2 was initially sent [3] Ville Syrjälä suggested that it might be
a good idea to use the ACPI _DDC method instead to get the EDID, to
cover a wider range of hardware. Unfortunately, it doesn't seem
available on GPD Win Max, so I think this work should be done
independently, and this patch series considered separately.

[1]: https://gitlab.freedesktop.org/drm/intel/-/issues/3454
[2]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/
[3]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20210531204642.4907-2-ani...@astier.eu/


Anisse Astier (2):
  drm/i915/opregion: add support for mailbox #5 EDID
  drm: Add orientation quirk for GPD Win Max

 .../gpu/drm/drm_panel_orientation_quirks.c|  6 ++
 drivers/gpu/drm/i915/display/intel_dp.c   |  3 +
 drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
 4 files changed, 85 insertions(+), 1 deletion(-)

-- 
2.31.1



[Intel-gfx] [PATCH RESEND 1/2] drm/i915/opregion: add support for mailbox #5 EDID

2021-07-07 Thread Anisse Astier
The ACPI OpRegion Mailbox #5 ASLE extension may contain an EDID to be
used for the embedded display. Add support for using it via by adding
the EDID to the list of available modes on the connector, and use it for
eDP when available.

If a panel's EDID is broken, there may be an override EDID set in the
ACPI OpRegion mailbox #5. Use it if available.

Fixes the GPD Win Max display.

Based on original patch series by: Jani Nikula 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/

Changes:
 - EDID is copied and validated with drm_edid_is_valid
 - Mode is now added via drm_add_edid_modes instead of using override
   mechanism
 - squashed the two patches

Cc: Jani Nikula 
Cc: Uma Shankar 
Cc: Ville Syrjälä 
Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/i915/display/intel_dp.c   |  3 +
 drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
 3 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index 5b52beaddada..2eaad1c9dcee 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -5188,6 +5188,9 @@ static bool intel_edp_init_connector(struct intel_dp 
*intel_dp,
goto out_vdd_off;
}
 
+   /* Set up override EDID, if any, from ACPI OpRegion */
+   intel_opregion_edid_probe(intel_connector);
+
mutex_lock(&dev->mode_config.mutex);
edid = drm_get_edid(connector, &intel_dp->aux.ddc);
if (edid) {
diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c 
b/drivers/gpu/drm/i915/display/intel_opregion.c
index dfd724e506b5..ef8d38f041eb 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.c
+++ b/drivers/gpu/drm/i915/display/intel_opregion.c
@@ -196,6 +196,8 @@ struct opregion_asle_ext {
 #define ASLE_IUER_WINDOWS_BTN  (1 << 1)
 #define ASLE_IUER_POWER_BTN(1 << 0)
 
+#define ASLE_PHED_EDID_VALID_MASK  0x3
+
 /* Software System Control Interrupt (SWSCI) */
 #define SWSCI_SCIC_INDICATOR   (1 << 0)
 #define SWSCI_SCIC_MAIN_FUNCTION_SHIFT 1
@@ -909,8 +911,10 @@ int intel_opregion_setup(struct drm_i915_private *dev_priv)
opregion->asle->ardy = ASLE_ARDY_NOT_READY;
}
 
-   if (mboxes & MBOX_ASLE_EXT)
+   if (mboxes & MBOX_ASLE_EXT) {
drm_dbg(&dev_priv->drm, "ASLE extension supported\n");
+   opregion->asle_ext = base + OPREGION_ASLE_EXT_OFFSET;
+   }
 
if (intel_load_vbt_firmware(dev_priv) == 0)
goto out;
@@ -1037,6 +1041,68 @@ intel_opregion_get_panel_type(struct drm_i915_private 
*dev_priv)
return ret - 1;
 }
 
+/**
+ * intel_opregion_edid_probe - Add EDID from ACPI OpRegion mailbox #5
+ * @intel_connector: eDP connector
+ *
+ * This reads the ACPI Opregion mailbox #5 to extract the EDID that is passed
+ * to it.
+ *
+ * Will take a lock on the DRM mode_config to add the EDID; make sure it isn't
+ * called with lock taken.
+ *
+ */
+void intel_opregion_edid_probe(struct intel_connector *intel_connector)
+{
+   struct drm_connector *connector = &intel_connector->base;
+   struct drm_i915_private *i915 = to_i915(connector->dev);
+   struct intel_opregion *opregion = &i915->opregion;
+   const void *in_edid;
+   const struct edid *edid;
+   struct edid *new_edid;
+   int len, ret, num;
+
+   if (!opregion->asle_ext || connector->override_edid)
+   return;
+
+   in_edid = opregion->asle_ext->bddc;
+
+   /* Validity corresponds to number of 128-byte blocks */
+   len = (opregion->asle_ext->phed & ASLE_PHED_EDID_VALID_MASK) * 128;
+   if (!len || !memchr_inv(in_edid, 0, len))
+   return;
+
+   edid = in_edid;
+
+   if (len < EDID_LENGTH * (1 + edid->extensions)) {
+   drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox 
#5)\n");
+   return;
+   }
+   new_edid = drm_edid_duplicate(edid);
+   if (!new_edid) {
+   drm_err(&i915->drm, "Cannot duplicate EDID\n");
+   return;
+   }
+   if (!drm_edid_is_valid(new_edid)) {
+   kfree(new_edid);
+   drm_dbg_kms(&i915->drm, "Cannot validate EDID in ACPI OpRegion 
(Mailbox #5)\n");
+   return;
+   }
+
+   ret = drm_connector_update_edid_property(connector, new_edid);
+   if (ret) {
+   kfree(new_edid);
+   return;
+   }
+
+   mutex_lock(&connector->dev->mode_config.mutex);
+   num = drm_add_edid_modes(connector, new_edid);
+   mutex_unlock(&connector->dev->mode_config.mutex);
+
+   drm_dbg_kms(&i915->

[Intel-gfx] [PATCH RESEND 2/2] drm: Add orientation quirk for GPD Win Max

2021-07-07 Thread Anisse Astier
Panel is 800x1280, but mounted on a laptop form factor, sideways.

Reviewed-by: Hans de Goede 
Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c 
b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index f6bdec7fa925..3c3f4ed89173 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -148,6 +148,12 @@ static const struct dmi_system_id orientation_data[] = {
  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MicroPC"),
},
.driver_data = (void *)&lcd720x1280_rightside_up,
+   }, {/* GPD Win Max */
+   .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "GPD"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G1619-01"),
+   },
+   .driver_data = (void *)&lcd800x1280_rightside_up,
}, {/*
 * GPD Pocket, note that the the DMI data is less generic then
 * it seems, devices with a board-vendor of "AMI Corporation"
-- 
2.31.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH RESEND v2 0/2] GPD Win Max display fixes

2021-07-07 Thread Anisse Astier
This patch series is for making the GPD Win Max display usable with
Linux.

The GPD Win Max is a small laptop, and its eDP panel does not send an
EDID over DPCD; the EDID is instead available in the intel opregion, in
mailbox #5 [1]

The first patch is based on Jani's patch series [2] adding support for
the opregion, with changes. I've changed authorship, but I'd be glad to
revert it

The second patch is just to fix the orientation of the panel.


Changes since v1:
 - rebased on drm-tip
 - squashed patch 1 & 2
 - picked up Reviewed-by from Hans de Goede (thanks for the review)

When v2 was initially sent [3] Ville Syrjälä suggested that it might be
a good idea to use the ACPI _DDC method instead to get the EDID, to
cover a wider range of hardware. Unfortunately, it doesn't seem
available on GPD Win Max, so I think this work should be done
independently, and this patch series considered separately.

[1]: https://gitlab.freedesktop.org/drm/intel/-/issues/3454
[2]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/
[3]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20210531204642.4907-2-ani...@astier.eu/


Anisse Astier (2):
  drm/i915/opregion: add support for mailbox #5 EDID
  drm: Add orientation quirk for GPD Win Max

 .../gpu/drm/drm_panel_orientation_quirks.c|  6 ++
 drivers/gpu/drm/i915/display/intel_dp.c   |  3 +
 drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
 4 files changed, 85 insertions(+), 1 deletion(-)

-- 
2.31.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v2 1/2] drm/i915/opregion: add support for mailbox #5 EDID

2021-07-07 Thread Anisse Astier
Le Wed, Jul 07, 2021 at 02:57:47PM -0500, Daniel Dadap a écrit :
> On 6/1/21 5:43 PM, Anisse Astier wrote:
> > 
> > Le Tue, Jun 01, 2021 at 06:50:24PM +0300, Ville Syrj?l? a ?crit :
> > > On Mon, May 31, 2021 at 10:46:41PM +0200, Anisse Astier wrote:
> > > > The ACPI OpRegion Mailbox #5 ASLE extension may contain an EDID to be
> > > > used for the embedded display. Add support for using it via by adding
> > > > the EDID to the list of available modes on the connector, and use it for
> > > > eDP when available.
> > > > 
> > > > If a panel's EDID is broken, there may be an override EDID set in the
> > > > ACPI OpRegion mailbox #5. Use it if available.
> > > Looks like Windows uses the ACPI _DDC method instead. We should probably
> > > do the same, just in case some crazy machine stores the EDID somewhere
> > > else.
> > Thanks, I wouldn't have thought of this. It seems Daniel Dadap did a
> > patch series to do just that, in a generic way:
> > https://lore.kernel.org/amd-gfx/20200727205357.27839-1-dda...@nvidia.com/
> > 
> > I've tried patch 1 & 2, and after a fix[1] was able to call the _DDC method
> > on most devices, but without any EDID being returned.
> > 
> > I looked at the disassembled ACPI tables[2], and could not find any
> > device with the _DDC method. Are you sure it's the only method the
> > Windows driver uses to get the EDID ?
> 
> 
> _DDC only works on devices that actually implement it, and the vast majority
> of devices don't, because the display just provides an EDID normally. AIUI,
> usually a device will implement _DDC either because an embedded panel has no
> ROM of its own to deliver an EDID, or to allow the EDID to be read by either
> GPU on a system with a muxed display, regardless of which GPU happens to
> have the DDC lines (in TMDS) or DP AUX routed to it at the moment. (To my
> knowledge, nobody actually muxes DP AUX independently from the main link,
> but there were some older pre-DP designs where DDC could be muxed
> independently.)
> 
> I'm not sure whether the comment about Windows using _DDC was meant for this
> device in particular, or just more generally, since DDC is part of the ACPI
> spec and some Windows GPU drivers *do* use it, where available. If it was
> meant for a particular device, then it's possible that the ACPI tables
> advertise different methods depending on e.g. _OSI. If you haven't already
> tried doing so, it might be worth overriding _OSI to spoof Windows, to see
> if _DDC gets advertised.

I think it's already the default Linux behaviour according to
https://www.kernel.org/doc/html/latest/firmware-guide/acpi/osi.html

I added a few specific Windows versions (2007 - 2020), but did not see
any difference.


> 
> I'm not sure how you were able to call _DDC without an EDID being returned
> as described above, if there was no _DDC method in the ACPI tables; I would
> expect that attempting to call _DDC would fail to locate a suitable method
> and do_acpi_ddc would return NULL.

I wasn't, I just tried calling the method on all devices (removing the
_DOD id check), but obviously it failed because it did not exist.

> 
> 
> > Regards,
> > 
> > Anisse
> > 
> > [1] _DOD ids should only use 16 lower bits, see table here:
> > https://uefi.org/specs/ACPI/6.4/Apx_B_Video_Extensions/display-specific-methods.html#dod-enumerate-all-devices-attached-to-the-display-adapter
> 
> 
> Thanks; I don't see a version of your modified patch here, was the fix just
> to mask the _DOD IDs against 0x?

Yes, nothing fancy:

-   if (adr == dod_entries[i]) {
+   if (adr == (dod_entries[i] & 0x) ) {


Regards,

Anisse
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v2 1/2] drm/i915/opregion: add support for mailbox #5 EDID

2021-06-01 Thread Anisse Astier
Le Tue, Jun 01, 2021 at 06:50:24PM +0300, Ville Syrj?l? a ?crit :
> On Mon, May 31, 2021 at 10:46:41PM +0200, Anisse Astier wrote:
> > The ACPI OpRegion Mailbox #5 ASLE extension may contain an EDID to be
> > used for the embedded display. Add support for using it via by adding
> > the EDID to the list of available modes on the connector, and use it for
> > eDP when available.
> > 
> > If a panel's EDID is broken, there may be an override EDID set in the
> > ACPI OpRegion mailbox #5. Use it if available.
> 
> Looks like Windows uses the ACPI _DDC method instead. We should probably
> do the same, just in case some crazy machine stores the EDID somewhere
> else.

Thanks, I wouldn't have thought of this. It seems Daniel Dadap did a
patch series to do just that, in a generic way:
https://lore.kernel.org/amd-gfx/20200727205357.27839-1-dda...@nvidia.com/

I've tried patch 1 & 2, and after a fix[1] was able to call the _DDC method
on most devices, but without any EDID being returned.

I looked at the disassembled ACPI tables[2], and could not find any
device with the _DDC method. Are you sure it's the only method the
Windows driver uses to get the EDID ?

Regards,

Anisse

[1] _DOD ids should only use 16 lower bits, see table here:
https://uefi.org/specs/ACPI/6.4/Apx_B_Video_Extensions/display-specific-methods.html#dod-enumerate-all-devices-attached-to-the-display-adapter
[2] acpidump: https://gitlab.freedesktop.org/drm/intel/-/issues/3454#note_913970

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v2 2/2] drm: Add orientation quirk for GPD Win Max

2021-05-31 Thread Anisse Astier
Panel is 800x1280, but mounted on a laptop form factor, sideways.

Reviewed-by: Hans de Goede 
Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c 
b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index f6bdec7fa925..3c3f4ed89173 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -148,6 +148,12 @@ static const struct dmi_system_id orientation_data[] = {
  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MicroPC"),
},
.driver_data = (void *)&lcd720x1280_rightside_up,
+   }, {/* GPD Win Max */
+   .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "GPD"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G1619-01"),
+   },
+   .driver_data = (void *)&lcd800x1280_rightside_up,
}, {/*
 * GPD Pocket, note that the the DMI data is less generic then
 * it seems, devices with a board-vendor of "AMI Corporation"
-- 
2.31.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v2 1/2] drm/i915/opregion: add support for mailbox #5 EDID

2021-05-31 Thread Anisse Astier
The ACPI OpRegion Mailbox #5 ASLE extension may contain an EDID to be
used for the embedded display. Add support for using it via by adding
the EDID to the list of available modes on the connector, and use it for
eDP when available.

If a panel's EDID is broken, there may be an override EDID set in the
ACPI OpRegion mailbox #5. Use it if available.

Fixes the GPD Win Max display.

Based on original patch series by: Jani Nikula 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/

Changes:
 - EDID is copied and validated with drm_edid_is_valid
 - Mode is now added via drm_add_edid_modes instead of using override
   mechanism
 - squashed the two patches

Cc: Jani Nikula 
Cc: Uma Shankar 
Cc: Ville Syrjälä 
Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/i915/display/intel_dp.c   |  3 +
 drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
 3 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index 5c983044..43fb485c0e02 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -5191,6 +5191,9 @@ static bool intel_edp_init_connector(struct intel_dp 
*intel_dp,
goto out_vdd_off;
}
 
+   /* Set up override EDID, if any, from ACPI OpRegion */
+   intel_opregion_edid_probe(intel_connector);
+
mutex_lock(&dev->mode_config.mutex);
edid = drm_get_edid(connector, &intel_dp->aux.ddc);
if (edid) {
diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c 
b/drivers/gpu/drm/i915/display/intel_opregion.c
index dfd724e506b5..ef8d38f041eb 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.c
+++ b/drivers/gpu/drm/i915/display/intel_opregion.c
@@ -196,6 +196,8 @@ struct opregion_asle_ext {
 #define ASLE_IUER_WINDOWS_BTN  (1 << 1)
 #define ASLE_IUER_POWER_BTN(1 << 0)
 
+#define ASLE_PHED_EDID_VALID_MASK  0x3
+
 /* Software System Control Interrupt (SWSCI) */
 #define SWSCI_SCIC_INDICATOR   (1 << 0)
 #define SWSCI_SCIC_MAIN_FUNCTION_SHIFT 1
@@ -909,8 +911,10 @@ int intel_opregion_setup(struct drm_i915_private *dev_priv)
opregion->asle->ardy = ASLE_ARDY_NOT_READY;
}
 
-   if (mboxes & MBOX_ASLE_EXT)
+   if (mboxes & MBOX_ASLE_EXT) {
drm_dbg(&dev_priv->drm, "ASLE extension supported\n");
+   opregion->asle_ext = base + OPREGION_ASLE_EXT_OFFSET;
+   }
 
if (intel_load_vbt_firmware(dev_priv) == 0)
goto out;
@@ -1037,6 +1041,68 @@ intel_opregion_get_panel_type(struct drm_i915_private 
*dev_priv)
return ret - 1;
 }
 
+/**
+ * intel_opregion_edid_probe - Add EDID from ACPI OpRegion mailbox #5
+ * @intel_connector: eDP connector
+ *
+ * This reads the ACPI Opregion mailbox #5 to extract the EDID that is passed
+ * to it.
+ *
+ * Will take a lock on the DRM mode_config to add the EDID; make sure it isn't
+ * called with lock taken.
+ *
+ */
+void intel_opregion_edid_probe(struct intel_connector *intel_connector)
+{
+   struct drm_connector *connector = &intel_connector->base;
+   struct drm_i915_private *i915 = to_i915(connector->dev);
+   struct intel_opregion *opregion = &i915->opregion;
+   const void *in_edid;
+   const struct edid *edid;
+   struct edid *new_edid;
+   int len, ret, num;
+
+   if (!opregion->asle_ext || connector->override_edid)
+   return;
+
+   in_edid = opregion->asle_ext->bddc;
+
+   /* Validity corresponds to number of 128-byte blocks */
+   len = (opregion->asle_ext->phed & ASLE_PHED_EDID_VALID_MASK) * 128;
+   if (!len || !memchr_inv(in_edid, 0, len))
+   return;
+
+   edid = in_edid;
+
+   if (len < EDID_LENGTH * (1 + edid->extensions)) {
+   drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox 
#5)\n");
+   return;
+   }
+   new_edid = drm_edid_duplicate(edid);
+   if (!new_edid) {
+   drm_err(&i915->drm, "Cannot duplicate EDID\n");
+   return;
+   }
+   if (!drm_edid_is_valid(new_edid)) {
+   kfree(new_edid);
+   drm_dbg_kms(&i915->drm, "Cannot validate EDID in ACPI OpRegion 
(Mailbox #5)\n");
+   return;
+   }
+
+   ret = drm_connector_update_edid_property(connector, new_edid);
+   if (ret) {
+   kfree(new_edid);
+   return;
+   }
+
+   mutex_lock(&connector->dev->mode_config.mutex);
+   num = drm_add_edid_modes(connector, new_edid);
+   mutex_unlock(&connector->dev->mode_config.mutex);
+
+   drm_dbg_kms(&i915->

[Intel-gfx] [PATCH v2 0/2] GPD Win Max display fixes

2021-05-31 Thread Anisse Astier
This patch series is for making the GPD Win Max display usable with
Linux.

The GPD Win Max is a small laptop, and its eDP panel does not send an
EDID over DPCD; the EDID is instead available in the intel opregion, in
mailbox #5 [1]

The first patch is based on Jani's patch series [2] adding support for
the opregion, with changes. I've changed authorship, but I'd be glad to
revert it

The second patch is just to fix the orientation of the panel.

Changes since v1:
 - rebased on drm-tip
 - squashed patch 1 & 2
 - picked up Reviewed-by from Hans de Goede (thanks for the review)


[1]: https://gitlab.freedesktop.org/drm/intel/-/issues/3454
[2]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/

Anisse Astier (2):
  drm/i915/opregion: add support for mailbox #5 EDID
  drm: Add orientation quirk for GPD Win Max

 .../gpu/drm/drm_panel_orientation_quirks.c|  6 ++
 drivers/gpu/drm/i915/display/intel_dp.c   |  3 +
 drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
 4 files changed, 85 insertions(+), 1 deletion(-)

-- 
2.31.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 2/3] drm/i915/dp: use opregion mailbox #5 EDID for eDP, if available

2021-05-24 Thread Anisse Astier
From: Jani Nikula 

If a panel's EDID is broken, there may be an override EDID set in the
ACPI OpRegion mailbox #5. Use it if available.

Fixes the GPD Win Max display.

Cc: Uma Shankar 
Signed-off-by: Jani Nikula 
Signed-off-by: Anisse Astier 

[Anisse changes: function name]
---
 drivers/gpu/drm/i915/display/intel_dp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index 5c983044..43fb485c0e02 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -5191,6 +5191,9 @@ static bool intel_edp_init_connector(struct intel_dp 
*intel_dp,
goto out_vdd_off;
}
 
+   /* Set up override EDID, if any, from ACPI OpRegion */
+   intel_opregion_edid_probe(intel_connector);
+
mutex_lock(&dev->mode_config.mutex);
edid = drm_get_edid(connector, &intel_dp->aux.ddc);
if (edid) {
-- 
2.31.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 0/3] GPD Win Max display fixes

2021-05-24 Thread Anisse Astier
This patch series is for making the GPD Win Max display usable with
Linux.

The GPD Win Max is a small laptop, and its eDP panel does not send an
EDID over DPCD; the EDID is instead available in the intel opregion, in
mailbox #5 [1]

The first two patches are based on Jani's patch series [2] adding
support for the opregion, with minimal changes. I've change authorship
for the first, but we can revert it.

The third patch is just to fix the orientation of the panel. For some
reason it does not work at boot when an external display is plugged, but
I doubt this is specific to this hardware.


[1]: https://gitlab.freedesktop.org/drm/intel/-/issues/3454
[2]: 
https://patchwork.kernel.org/project/intel-gfx/patch/20200828061941.17051-1-jani.nik...@intel.com/

Anisse Astier (2):
  drm/i915/opregion: add support for mailbox #5 EDID
  drm: Add orientation quirk for GPD Win Max

Jani Nikula (1):
  drm/i915/dp: use opregion mailbox #5 EDID for eDP, if available

 .../gpu/drm/drm_panel_orientation_quirks.c|  6 ++
 drivers/gpu/drm/i915/display/intel_dp.c   |  3 +
 drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
 4 files changed, 85 insertions(+), 1 deletion(-)

-- 
2.31.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 3/3] drm: Add orientation quirk for GPD Win Max

2021-05-24 Thread Anisse Astier
Panel is 800x1280, but mounted on a laptop form factor, sideways.

Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c 
b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index f6bdec7fa925..3c3f4ed89173 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -148,6 +148,12 @@ static const struct dmi_system_id orientation_data[] = {
  DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MicroPC"),
},
.driver_data = (void *)&lcd720x1280_rightside_up,
+   }, {/* GPD Win Max */
+   .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "GPD"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "G1619-01"),
+   },
+   .driver_data = (void *)&lcd800x1280_rightside_up,
}, {/*
 * GPD Pocket, note that the the DMI data is less generic then
 * it seems, devices with a board-vendor of "AMI Corporation"
-- 
2.31.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 1/3] drm/i915/opregion: add support for mailbox #5 EDID

2021-05-24 Thread Anisse Astier
The ACPI OpRegion Mailbox #5 ASLE extension may contain an EDID to be
used for the embedded display. Add support for using it via by adding
the EDID to the list of available modes on the connector.

Based on original patch by: Jani Nikula 

Changes:
 - EDID is copied and validated with drm_edid_is_valid
 - Mode is now added via drm_add_edid_modes instead of using override
   mechanism

Cc: Jani Nikula 
Cc: Uma Shankar 
Cc: Ville Syrjälä 
Signed-off-by: Anisse Astier 
---
 drivers/gpu/drm/i915/display/intel_opregion.c | 69 ++-
 drivers/gpu/drm/i915/display/intel_opregion.h |  8 +++
 2 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c 
b/drivers/gpu/drm/i915/display/intel_opregion.c
index dfd724e506b5..ef8d38f041eb 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.c
+++ b/drivers/gpu/drm/i915/display/intel_opregion.c
@@ -196,6 +196,8 @@ struct opregion_asle_ext {
 #define ASLE_IUER_WINDOWS_BTN  (1 << 1)
 #define ASLE_IUER_POWER_BTN(1 << 0)
 
+#define ASLE_PHED_EDID_VALID_MASK  0x3
+
 /* Software System Control Interrupt (SWSCI) */
 #define SWSCI_SCIC_INDICATOR   (1 << 0)
 #define SWSCI_SCIC_MAIN_FUNCTION_SHIFT 1
@@ -909,8 +911,10 @@ int intel_opregion_setup(struct drm_i915_private *dev_priv)
opregion->asle->ardy = ASLE_ARDY_NOT_READY;
}
 
-   if (mboxes & MBOX_ASLE_EXT)
+   if (mboxes & MBOX_ASLE_EXT) {
drm_dbg(&dev_priv->drm, "ASLE extension supported\n");
+   opregion->asle_ext = base + OPREGION_ASLE_EXT_OFFSET;
+   }
 
if (intel_load_vbt_firmware(dev_priv) == 0)
goto out;
@@ -1037,6 +1041,68 @@ intel_opregion_get_panel_type(struct drm_i915_private 
*dev_priv)
return ret - 1;
 }
 
+/**
+ * intel_opregion_edid_probe - Add EDID from ACPI OpRegion mailbox #5
+ * @intel_connector: eDP connector
+ *
+ * This reads the ACPI Opregion mailbox #5 to extract the EDID that is passed
+ * to it.
+ *
+ * Will take a lock on the DRM mode_config to add the EDID; make sure it isn't
+ * called with lock taken.
+ *
+ */
+void intel_opregion_edid_probe(struct intel_connector *intel_connector)
+{
+   struct drm_connector *connector = &intel_connector->base;
+   struct drm_i915_private *i915 = to_i915(connector->dev);
+   struct intel_opregion *opregion = &i915->opregion;
+   const void *in_edid;
+   const struct edid *edid;
+   struct edid *new_edid;
+   int len, ret, num;
+
+   if (!opregion->asle_ext || connector->override_edid)
+   return;
+
+   in_edid = opregion->asle_ext->bddc;
+
+   /* Validity corresponds to number of 128-byte blocks */
+   len = (opregion->asle_ext->phed & ASLE_PHED_EDID_VALID_MASK) * 128;
+   if (!len || !memchr_inv(in_edid, 0, len))
+   return;
+
+   edid = in_edid;
+
+   if (len < EDID_LENGTH * (1 + edid->extensions)) {
+   drm_dbg_kms(&i915->drm, "Invalid EDID in ACPI OpRegion (Mailbox 
#5)\n");
+   return;
+   }
+   new_edid = drm_edid_duplicate(edid);
+   if (!new_edid) {
+   drm_err(&i915->drm, "Cannot duplicate EDID\n");
+   return;
+   }
+   if (!drm_edid_is_valid(new_edid)) {
+   kfree(new_edid);
+   drm_dbg_kms(&i915->drm, "Cannot validate EDID in ACPI OpRegion 
(Mailbox #5)\n");
+   return;
+   }
+
+   ret = drm_connector_update_edid_property(connector, new_edid);
+   if (ret) {
+   kfree(new_edid);
+   return;
+   }
+
+   mutex_lock(&connector->dev->mode_config.mutex);
+   num = drm_add_edid_modes(connector, new_edid);
+   mutex_unlock(&connector->dev->mode_config.mutex);
+
+   drm_dbg_kms(&i915->drm, "Using OpRegion EDID for [CONNECTOR:%d:%s], 
added %d mode(s)\n",
+   connector->base.id, connector->name, num);
+}
+
 void intel_opregion_register(struct drm_i915_private *i915)
 {
struct intel_opregion *opregion = &i915->opregion;
@@ -1127,6 +1193,7 @@ void intel_opregion_unregister(struct drm_i915_private 
*i915)
opregion->acpi = NULL;
opregion->swsci = NULL;
opregion->asle = NULL;
+   opregion->asle_ext = NULL;
opregion->vbt = NULL;
opregion->lid_state = NULL;
 }
diff --git a/drivers/gpu/drm/i915/display/intel_opregion.h 
b/drivers/gpu/drm/i915/display/intel_opregion.h
index 4aa68ffbd30e..c1ecfcbb6f55 100644
--- a/drivers/gpu/drm/i915/display/intel_opregion.h
+++ b/drivers/gpu/drm/i915/display/intel_opregion.h
@@ -29,12 +29,14 @@
 #include 
 
 struct drm_i915_private;
+struct intel_connector;
 struct intel_encoder;
 
 struct opregion_header;
 struct opregion_acpi