All of lore.kernel.org
 help / color / mirror / Atom feed
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 v2 7/9] drm/i915/bios: Refactor panel_type code
Date: Wed,  4 May 2022 18:04:38 +0300	[thread overview]
Message-ID: <20220504150440.13748-8-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20220504150440.13748-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 63f50d219be4..46ce9e9f14f2 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


  parent reply	other threads:[~2022-05-04 15:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04 15:04 [Intel-gfx] [PATCH v2 0/9] drm/i915/bios: Rework BDB block handling Ville Syrjala
2022-05-04 15:04 ` [Intel-gfx] [PATCH v2 1/9] drm/i915/bios: Reorder panel DTD parsing Ville Syrjala
2022-05-04 15:04 ` [Intel-gfx] [PATCH v2 2/9] drm/i915/bios: Generate LFP data table pointers if the VBT lacks them Ville Syrjala
2022-05-04 15:04 ` [Intel-gfx] [PATCH v2 3/9] drm/i915/bios: Get access to the tail end of the LFP data block Ville Syrjala
2022-05-04 15:04 ` [Intel-gfx] [PATCH v2 4/9] drm/i915/bios: Document the mess around the LFP data tables Ville Syrjala
2022-05-04 15:04 ` [Intel-gfx] [PATCH v2 5/9] drm/i915/bios: Assume panel_type==0 if the VBT has bogus data Ville Syrjala
2022-05-04 15:04 ` [Intel-gfx] [PATCH v2 6/9] drm/i915/bios: Extract get_panel_type() Ville Syrjala
2022-05-04 15:04 ` Ville Syrjala [this message]
2022-05-04 15:04 ` [Intel-gfx] [PATCH v2 8/9] drm/i915/bios: Parse the seamless DRRS min refresh rate Ville Syrjala
2022-05-04 15:04 ` [Intel-gfx] [PATCH v2 9/9] drm/i915: Respect VBT " Ville Syrjala
2022-05-04 17:41 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/bios: Rework BDB block handling (rev5) Patchwork
2022-05-04 18:05 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2022-05-05  0:49 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/bios: Rework BDB block handling (rev6) Patchwork
2022-05-05  0:49 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-05-05  1:13 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2022-05-05  3:28 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/bios: Rework BDB block handling (rev7) Patchwork
2022-05-05  3:47 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-05-05 10:14 ` [Intel-gfx] ✓ Fi.CI.IGT: " 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=20220504150440.13748-8-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 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.