[igt-dev] [PATCH i-g-t 4/6] tools/dpcd_reg: Introduce dump as the default operation.

Rodrigo Vivi rodrigo.vivi at intel.com
Sat Sep 1 04:18:04 UTC 2018


For now this only imports the registers that were used on
i915's debugfs dpcd dump. Later this could be extended.

Also for now this only do the dump on the specified
device. But it could become more flexible and dump
all DP devices if no char device number is specified.

Cc: Tarun Vyas <tarun.vyas at intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
---
 tools/dpcd_reg.c | 72 ++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 63 insertions(+), 9 deletions(-)

diff --git a/tools/dpcd_reg.c b/tools/dpcd_reg.c
index 09da4109..c533401c 100644
--- a/tools/dpcd_reg.c
+++ b/tools/dpcd_reg.c
@@ -31,6 +31,36 @@
 
 #define INVALID	0xff
 
+struct dpcd_block {
+	/* DPCD dump start address. */
+	unsigned int offset;
+	/* DPCD number of bytes to read. If unset, defaults to 1. */
+	size_t count;
+};
+
+static const struct dpcd_block dump_list[] = {
+	/* DP_DPCD_REV */
+	{ .offset = 0, .count = 15 },
+	/* DP_PSR_SUPPORT to DP_PSR_CAPS*/
+	{ .offset =  0x70, .count = 2 },
+	/* DP_DOWNSTREAM_PORT_0 */
+	{ .offset =  0x80, .count = 16 },
+	/* DP_LINK_BW_SET to DP_EDP_CONFIGURATION_SET */
+	{ .offset = 0x100, .count = 11 },
+	/* DP_SINK_COUNT to DP_ADJUST_REQUEST_LANE2_3 */
+	{ .offset = 0x200, .count = 8 },
+	/* DP_SET_POWER */
+	{ .offset = 0x600 },
+	/* DP_EDP_DPCD_REV */
+	{ .offset =  0x700 },
+	/* DP_EDP_GENERAL_CAP_1 to DP_EDP_GENERAL_CAP_3 */
+	{ .offset = 0x701, .count = 4 },
+	/* DP_EDP_DISPLAY_CONTROL_REGISTER to DP_EDP_BACKLIGHT_FREQ_CAP_MAX_LSB */
+	{ .offset = 0x720, .count = 16},
+	/* DP_EDP_DBC_MINIMUM_BRIGHTNESS_SET to DP_EDP_DBC_MAXIMUM_BRIGHTNESS_SET */
+	{ .offset =  0x732, .count = 2 },
+};
+
 const char aux_dev[] = "/dev/drm_dp_aux";
 
 static void print_usage(char *tool, int help)
@@ -107,6 +137,23 @@ out:
 	return ret;
 }
 
+static int dpcd_dump(int fd)
+{
+	size_t count;
+	int ret, i;
+
+	for (i = 0; i < sizeof(dump_list) / sizeof(dump_list[0]); i++) {
+		count = dump_list[i].count ? dump_list[i].count: 1;
+		ret = dpcd_read(fd, dump_list[i].offset, count);
+		if (ret != count) {
+			igt_warn("Dump failed while reading %04x\n",
+				 dump_list[i].offset);
+			return ret;
+		}
+	}
+	return 0;
+}
+
 int main(int argc, char **argv)
 {
 	char dev_name[20];
@@ -117,10 +164,10 @@ int main(int argc, char **argv)
 	int file_op = O_RDONLY;
 
 	enum command {
-		INV = -1,
-		READ = 2,
+		DUMP,
+		READ,
 		WRITE,
-	} cmd = INV;
+	} cmd = DUMP;
 
 	struct option longopts [] = {
 		{ "count",      required_argument,      NULL,      'c' },
@@ -174,8 +221,13 @@ int main(int argc, char **argv)
 	if (help_flg == 2)
 		print_usage(argv[0], 1);
 
-	if (devid == -1 || offset == INVALID) {
-		igt_warn("Aux device id and/or offset missing\n");
+	if (devid == -1) {
+		igt_warn("Aux device missing\n");
+		print_usage(argv[0], 0);
+	}
+
+	if (cmd != DUMP && offset == INVALID) {
+		printf("Offset needed for this operation\n");
 		print_usage(argv[0], 0);
 	}
 
@@ -210,10 +262,12 @@ int main(int argc, char **argv)
 			igt_warn("Failed to write to %s aux device\n",
 				 dev_name);
 		break;
-	case INV:
-	default:
-		igt_warn("Please specify a command: read/write. See usage\n");
-		print_usage(argv[0], 0);
+	case DUMP:
+		ret = dpcd_dump(fd);
+		if (ret < 0)
+			igt_warn("Failed to dump %s aux device\n",
+				 dev_name);
+		break;
 	}
 
 	close(fd);
-- 
2.17.1



More information about the igt-dev mailing list