[Intel-gfx] [i-g-t PATCH 09/10] tools/intel_vbt_decode: migrate child device type bits decoding to kernel defs

Jani Nikula jani.nikula at intel.com
Mon Aug 28 12:20:01 UTC 2017


This lets us use the verbatim copy of the kernel intel_vbt_defs.h file.

Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
 tools/intel_bios.h       | 18 ------------------
 tools/intel_vbt_decode.c | 47 +++++++++++++++++++++++++----------------------
 tools/intel_vbt_defs.h   | 16 ++++++++++++++++
 3 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/tools/intel_bios.h b/tools/intel_bios.h
index 9f0bc84f372c..85aa38e085be 100644
--- a/tools/intel_bios.h
+++ b/tools/intel_bios.h
@@ -38,24 +38,6 @@
 #define DEVICE_HANDLE_LPF1	0x08
 #define DEVICE_HANDLE_LFP2	0x80
 
-/* device type bits */
-#define DEVICE_TYPE_CLASS_EXTENSION	15
-#define DEVICE_TYPE_POWER_MANAGEMENT	14
-#define DEVICE_TYPE_HOTPLUG_SIGNALING	13
-#define DEVICE_TYPE_INTERNAL_CONNECTOR	12
-#define DEVICE_TYPE_NOT_HDMI_OUTPUT	11
-#define DEVICE_TYPE_MIPI_OUTPUT		10
-#define DEVICE_TYPE_COMPOSITE_OUTPUT	9
-#define DEVICE_TYPE_DIAL_CHANNEL	8
-#define DEVICE_TYPE_CONTENT_PROTECTION	7
-#define DEVICE_TYPE_HIGH_SPEED_LINK	6
-#define DEVICE_TYPE_LVDS_SIGNALING	5
-#define DEVICE_TYPE_TMDS_DVI_SIGNALING	4
-#define DEVICE_TYPE_VIDEO_SIGNALING	3
-#define DEVICE_TYPE_DISPLAYPORT_OUTPUT	2
-#define DEVICE_TYPE_DIGITAL_OUTPUT	1
-#define DEVICE_TYPE_ANALOG_OUTPUT	0
-
 #define DEVICE_TYPE_DP_DVI		0x68d6
 #define DEVICE_TYPE_DVI			0x68d2
 #define DEVICE_TYPE_MIPI		0x7cc2
diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c
index ed0b90bd63e6..d8ca0ee87198 100644
--- a/tools/intel_vbt_decode.c
+++ b/tools/intel_vbt_decode.c
@@ -299,34 +299,37 @@ static const char *child_device_type(unsigned short type)
 	return "unknown";
 }
 
-static const char * const child_device_type_bits[] = {
-	[DEVICE_TYPE_CLASS_EXTENSION] = "Class extension",
-	[DEVICE_TYPE_POWER_MANAGEMENT] = "Power management",
-	[DEVICE_TYPE_HOTPLUG_SIGNALING] = "Hotplug signaling",
-	[DEVICE_TYPE_INTERNAL_CONNECTOR] = "Internal connector",
-	[DEVICE_TYPE_NOT_HDMI_OUTPUT] = "HDMI output", /* decoded as inverse */
-	[DEVICE_TYPE_MIPI_OUTPUT] = "MIPI output",
-	[DEVICE_TYPE_COMPOSITE_OUTPUT] = "Composite output",
-	[DEVICE_TYPE_DIAL_CHANNEL] = "Dual channel",
-	[DEVICE_TYPE_CONTENT_PROTECTION] = "Content protection",
-	[DEVICE_TYPE_HIGH_SPEED_LINK] = "High speel link",
-	[DEVICE_TYPE_LVDS_SIGNALING] = "LVDS signaling",
-	[DEVICE_TYPE_TMDS_DVI_SIGNALING] = "TMDS/DVI signaling",
-	[DEVICE_TYPE_VIDEO_SIGNALING] = "Video signaling",
-	[DEVICE_TYPE_DISPLAYPORT_OUTPUT] = "DisplayPort output",
-	[DEVICE_TYPE_DIGITAL_OUTPUT] = "Digital output",
-	[DEVICE_TYPE_ANALOG_OUTPUT] = "Analog output",
+static const struct {
+	unsigned short mask;
+	const char *name;
+} child_device_type_bits[] = {
+	{ DEVICE_TYPE_CLASS_EXTENSION, "Class extension" },
+	{ DEVICE_TYPE_POWER_MANAGEMENT, "Power management" },
+	{ DEVICE_TYPE_HOTPLUG_SIGNALING, "Hotplug signaling" },
+	{ DEVICE_TYPE_INTERNAL_CONNECTOR, "Internal connector" },
+	{ DEVICE_TYPE_NOT_HDMI_OUTPUT, "HDMI output" }, /* decoded as inverse */
+	{ DEVICE_TYPE_MIPI_OUTPUT, "MIPI output" },
+	{ DEVICE_TYPE_COMPOSITE_OUTPUT, "Composite output" },
+	{ DEVICE_TYPE_DUAL_CHANNEL, "Dual channel" },
+	{ 1 << 7, "Content protection" },
+	{ DEVICE_TYPE_HIGH_SPEED_LINK, "High speel link" },
+	{ DEVICE_TYPE_LVDS_SINGALING, "LVDS signaling" },
+	{ DEVICE_TYPE_TMDS_DVI_SIGNALING, "TMDS/DVI signaling" },
+	{ DEVICE_TYPE_VIDEO_SIGNALING, "Video signaling" },
+	{ DEVICE_TYPE_DISPLAYPORT_OUTPUT, "DisplayPort output" },
+	{ DEVICE_TYPE_DIGITAL_OUTPUT, "Digital output" },
+	{ DEVICE_TYPE_ANALOG_OUTPUT, "Analog output" },
 };
 
 static void dump_child_device_type_bits(uint16_t type)
 {
-	int bit;
+	int i;
 
-	type ^= 1 << DEVICE_TYPE_NOT_HDMI_OUTPUT;
+	type ^= DEVICE_TYPE_NOT_HDMI_OUTPUT;
 
-	for (bit = 15; bit >= 0; bit--) {
-		if (type & (1 << bit))
-			printf("\t\t\t%s\n", child_device_type_bits[bit]);
+	for (i = 0; i < ARRAY_SIZE(child_device_type_bits); i++) {
+		if (child_device_type_bits[i].mask & type)
+			printf("\t\t\t%s\n", child_device_type_bits[i].name);
 	}
 }
 
diff --git a/tools/intel_vbt_defs.h b/tools/intel_vbt_defs.h
index 9513f9dc21ab..404569c9fdfc 100644
--- a/tools/intel_vbt_defs.h
+++ b/tools/intel_vbt_defs.h
@@ -218,6 +218,22 @@ struct bdb_general_features {
 #define DEVICE_TYPE_DP_DUAL_MODE	0x60D6
 #define DEVICE_TYPE_eDP			0x78C6
 
+#define DEVICE_TYPE_CLASS_EXTENSION	(1 << 15)
+#define DEVICE_TYPE_POWER_MANAGEMENT	(1 << 14)
+#define DEVICE_TYPE_HOTPLUG_SIGNALING	(1 << 13)
+#define DEVICE_TYPE_INTERNAL_CONNECTOR	(1 << 12)
+#define DEVICE_TYPE_NOT_HDMI_OUTPUT	(1 << 11)
+#define DEVICE_TYPE_MIPI_OUTPUT		(1 << 10)
+#define DEVICE_TYPE_COMPOSITE_OUTPUT	(1 << 9)
+#define DEVICE_TYPE_DUAL_CHANNEL	(1 << 8)
+#define DEVICE_TYPE_HIGH_SPEED_LINK	(1 << 6)
+#define DEVICE_TYPE_LVDS_SINGALING	(1 << 5)
+#define DEVICE_TYPE_TMDS_DVI_SIGNALING	(1 << 4)
+#define DEVICE_TYPE_VIDEO_SIGNALING	(1 << 3)
+#define DEVICE_TYPE_DISPLAYPORT_OUTPUT	(1 << 2)
+#define DEVICE_TYPE_DIGITAL_OUTPUT	(1 << 1)
+#define DEVICE_TYPE_ANALOG_OUTPUT	(1 << 0)
+
 /*
  * Bits we care about when checking for DEVICE_TYPE_eDP. Depending on the
  * system, the other bits may or may not be set for eDP outputs.
-- 
2.11.0



More information about the Intel-gfx mailing list