From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Jani Nikula <jani.nikula@intel.com>
Subject: [Intel-gfx] [PATCH v3 13/18] drm/i915/bios: Refactor panel_type code
Date: Tue, 26 Apr 2022 22:32:17 +0300 [thread overview]
Message-ID: <20220426193222.3422-14-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20220426193222.3422-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Make the panel type code a bit more abstract along the
lines of the source of the panel type. For the moment
we have three classes: OpRegion, VBT, fallback.
Well introduce another one shortly.
We can now also print out all the different panel types,
and indicate which one we ultimately selected. Could help
with debugging.
v2: Add .get_panel_type() vfunc (Jani)
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/i915/display/intel_bios.c | 66 ++++++++++++++++++-----
1 file changed, 53 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index c68e4d987b81..e4ab637517ba 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -595,6 +595,11 @@ get_lfp_data_tail(const struct bdb_lvds_lfp_data *data,
return NULL;
}
+static int opregion_get_panel_type(struct drm_i915_private *i915)
+{
+ return intel_opregion_get_panel_type(i915);
+}
+
static int vbt_get_panel_type(struct drm_i915_private *i915)
{
const struct bdb_lvds_options *lvds_options;
@@ -612,25 +617,60 @@ static int vbt_get_panel_type(struct drm_i915_private *i915)
return lvds_options->panel_type;
}
+static int fallback_get_panel_type(struct drm_i915_private *i915)
+{
+ return 0;
+}
+
+enum panel_type {
+ PANEL_TYPE_OPREGION,
+ PANEL_TYPE_VBT,
+ PANEL_TYPE_FALLBACK,
+};
+
static int get_panel_type(struct drm_i915_private *i915)
{
- int ret;
+ struct {
+ const char *name;
+ int (*get_panel_type)(struct drm_i915_private *i915);
+ int panel_type;
+ } panel_types[] = {
+ [PANEL_TYPE_OPREGION] = {
+ .name = "OpRegion",
+ .get_panel_type = opregion_get_panel_type,
+ },
+ [PANEL_TYPE_VBT] = {
+ .name = "VBT",
+ .get_panel_type = vbt_get_panel_type,
+ },
+ [PANEL_TYPE_FALLBACK] = {
+ .name = "fallback",
+ .get_panel_type = fallback_get_panel_type,
+ },
+ };
+ int i;
- ret = intel_opregion_get_panel_type(i915);
- if (ret >= 0) {
- drm_WARN_ON(&i915->drm, ret > 0xf);
- drm_dbg_kms(&i915->drm, "Panel type: %d (OpRegion)\n", ret);
- return ret;
- }
+ for (i = 0; i < ARRAY_SIZE(panel_types); i++) {
+ panel_types[i].panel_type = panel_types[i].get_panel_type(i915);
+
+ drm_WARN_ON(&i915->drm, panel_types[i].panel_type > 0xf);
- ret = vbt_get_panel_type(i915);
- if (ret >= 0) {
- drm_WARN_ON(&i915->drm, ret > 0xf);
- drm_dbg_kms(&i915->drm, "Panel type: %d (VBT)\n", ret);
- return ret;
+ if (panel_types[i].panel_type >= 0)
+ drm_dbg_kms(&i915->drm, "Panel type (%s): %d\n",
+ panel_types[i].name, panel_types[i].panel_type);
}
- return 0; /* fallback */
+ if (panel_types[PANEL_TYPE_OPREGION].panel_type >= 0)
+ i = PANEL_TYPE_OPREGION;
+ else if (panel_types[PANEL_TYPE_VBT].panel_type >= 0)
+ i = PANEL_TYPE_VBT;
+ else
+ i = PANEL_TYPE_FALLBACK;
+
+ drm_dbg_kms(&i915->drm, "Selected panel type (%s): %d\n",
+ panel_types[i].name, panel_types[i].panel_type);
+
+ return panel_types[i].panel_type;
}
/* Parse general panel options */
--
2.35.1
next prev parent reply other threads:[~2022-04-26 19:33 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-26 19:32 [Intel-gfx] [PATCH v3 00/18] drm/i915/bios: Rework BDB block handling and PNPID->panel_type matching Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 01/18] drm/i915/bios: Reorder panel DTD parsing Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 02/18] drm/i915/bios: Generate LFP data table pointers if the VBT lacks them Ville Syrjala
2022-05-03 10:55 ` Jani Nikula
2022-05-03 17:29 ` Ville Syrjälä
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 03/18] drm/i915/bios: Get access to the tail end of the LFP data block Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 04/18] drm/i915/bios: Document the mess around the LFP data tables Ville Syrjala
2022-05-03 10:56 ` Jani Nikula
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 05/18] drm/i915/bios: Assume panel_type==0 if the VBT has bogus data Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 06/18] drm/i915/bios: Split parse_driver_features() into two parts Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 07/18] drm/i915/bios: Split VBT parsing to global vs. panel specific parts Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 08/18] drm/i915/bios: Don't parse some panel specific data multiple times Ville Syrjala
2022-05-03 11:08 ` Jani Nikula
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 09/18] drm/i915/pps: Split PPS init+sanitize in two Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 10/18] drm/i915/pps: Reinit PPS delays after VBT has been fully parsed Ville Syrjala
2022-05-03 11:46 ` Jani Nikula
2022-05-03 17:05 ` Ville Syrjälä
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 11/18] drm/i915/bios: Do panel specific VBT parsing later Ville Syrjala
2022-05-03 11:07 ` Jani Nikula
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 12/18] drm/i915/bios: Extract get_panel_type() Ville Syrjala
2022-04-26 19:32 ` Ville Syrjala [this message]
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 14/18] drm/i915/bios: Determine panel type via PNPID match Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 15/18] drm/i915/bios: Parse the seamless DRRS min refresh rate Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 16/18] drm/i915: Respect VBT " Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 17/18] drm/edid: Extract drm_edid_decode_mfg_id() Ville Syrjala
2022-04-26 19:32 ` [Intel-gfx] [PATCH v3 18/18] drm/i915/bios: Dump PNPID and panel name Ville Syrjala
2022-04-26 20:32 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/bios: Rework BDB block handling and PNPID->panel_type matching (rev7) Patchwork
2022-04-26 20:32 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-04-26 20:56 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2022-04-27 13:25 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/bios: Rework BDB block handling and PNPID->panel_type matching (rev8) Patchwork
2022-04-27 13:25 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-04-27 13:55 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " 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=20220426193222.3422-14-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@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