Skip to contentSkip to conversation

tools/dpcd_reg: Introduce dump as the default operation

PATCH In review Tarun Vyas 3 participants 7 messages Oct 10, 2018 – Oct 18, 2018

lore
Share & tools
lore

Tarun Vyas

author
#0 lore raw

PATCH 1/1 tools/dpcd_reg: Introduce dump as the default operation

From: Rodrigo Vivi <[email protected]>

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

With this, we should be able to kill i915_dpcd from the kernel debugfs and rely solely on dpcd_reg for dpcd dumps.

---
 tools/dpcd_reg.c | 86 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 66 insertions(+), 20 deletions(-)
tools/dpcd_reg.c +66 -20
index d577aa55..2761168d 100644
@@ -41,19 +41,50 @@
 
 const char aux_dev[] = "/dev/drm_dp_aux";
 
+struct dpcd_block {
+	/* DPCD dump start address. */
+	uint32_t offset;
+	/* DPCD number of bytes to read. If unset, defaults to 1. */
+	size_t count;
+};
+
 struct dpcd_data {
 	int devid;
 	int file_op;
-	uint32_t offset;
+	struct dpcd_block rw;
 	enum command {
-		INVALID = -1,
-		READ = 2,
+		DUMP,
+		READ,
 		WRITE,
 	} cmd;
-	size_t count;
 	uint8_t val;
 };
 
+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 },
+	/* DP_PSR_STATUS to DP_PSR_STATUS */
+	{ .offset = 0x2008, .count = 1 },
+};
+
 static void print_usage(void)
 {
 	printf("Usage: dpcd_reg [OPTION ...] COMMAND\n\n");
@@ -103,7 +134,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 				print_usage();
 				return EXIT_FAILURE;
 			}
-			dpcd->count = temp;
+			dpcd->rw.count = temp;
 			break;
 		case 'd':
 			temp = strtol(optarg, &endptr, 10);
@@ -131,7 +162,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 				print_usage();
 				return ERANGE;
 			}
-			dpcd->offset = temp;
+			dpcd->rw.offset = temp;
 			break;
 		case 'v':
 			vflag = 'v';
@@ -147,16 +178,15 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 		/* Command parsing */
 		case 1:
 			if (strcmp(optarg, "read") == 0) {
-				temp = READ;
+				dpcd->cmd = READ;
 			} else if (strcmp(optarg, "write") == 0) {
-				temp = WRITE;
+				dpcd->cmd = WRITE;
 				dpcd->file_op = O_WRONLY;
-			} else {
+			} else if (strcmp(optarg, "dump") != 0) {
 				fprintf(stderr, "Unrecognized command\n");
 				print_usage();
 				return EXIT_FAILURE;
 			}
-			dpcd->cmd = temp;
 			break;
 		case ':':
 			fprintf(stderr, "Option -%c requires an argument\n",
@@ -170,7 +200,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 		}
 	}
 
-	if ((dpcd->count + dpcd->offset) > (MAX_DP_OFFSET + 1)) {
+	if ((dpcd->rw.count + dpcd->rw.offset) > (MAX_DP_OFFSET + 1)) {
 		fprintf(stderr, "Out of bounds. Count + Offset <= 0x100000\n");
 		return ERANGE;
 	}
@@ -207,7 +237,7 @@ static int dpcd_read(int fd, uint32_t offset, size_t count)
 		ret = EXIT_FAILURE;
 	}
 
-	printf("0x%02x: ", offset);
+	printf("0x%04x: ", offset);
 	for (i = 0; i < pret; i++)
 		printf(" %02x", *(buf + i));
 	printf("\n");
@@ -233,6 +263,23 @@ static int dpcd_write(int fd, uint32_t offset, uint8_t val)
 	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 != EXIT_SUCCESS) {
+			fprintf(stderr, "Dump failed while reading %04x\n",
+				 dump_list[i].offset);
+			return ret;
+		}
+	}
+	return ret;
+}
+
 int main(int argc, char **argv)
 {
 	char dev_name[20];
@@ -241,9 +288,9 @@ int main(int argc, char **argv)
 	struct dpcd_data dpcd = {
 		.devid = 0,
 		.file_op = O_RDONLY,
-		.offset = 0x0,
-		.cmd = INVALID,
-		.count = 1,
+		.rw.offset = 0x0,
+		.rw.count = 1,
+		.cmd = DUMP,
 	};
 
 	ret = parse_opts(&dpcd, argc, argv);
@@ -262,15 +309,14 @@ int main(int argc, char **argv)
 
 	switch (dpcd.cmd) {
 	case READ:
-		ret = dpcd_read(fd, dpcd.offset, dpcd.count);
+		ret = dpcd_read(fd, dpcd.rw.offset, dpcd.rw.count);
 		break;
 	case WRITE:
-		ret = dpcd_write(fd, dpcd.offset, dpcd.val);
+		ret = dpcd_write(fd, dpcd.rw.offset, dpcd.val);
 		break;
+	case DUMP:
 	default:
-		fprintf(stderr, "Please specify a command: read/write.\n");
-		print_usage();
-		ret = EXIT_FAILURE;
+		ret = dpcd_dump(fd);
 		break;
 	}
 
Signature · 6 lines
2.14.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for tools/dpcd_reg: Introduce dump as the default operation

== Series Details ==

== Series Details ==

Series: tools/dpcd_reg: Introduce dump as the default operation
URL : https://patchwork.freedesktop.org/series/50779/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4952 -> IGTPW_1929 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/50779/revisions/1/mbox/

== Known issues ==

Here are the changes found in IGTPW_1929 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_module_reload@basic-reload:
      fi-blb-e6850:       NOTRUN -> INCOMPLETE (fdo#107718)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
      fi-byt-clapper:     PASS -> FAIL (fdo#103191, fdo#107362)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-cfl-8109u:       PASS -> DMESG-WARN (fdo#107345) +1

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
      fi-cfl-8109u:       PASS -> INCOMPLETE (fdo#106070, fdo#108126)

    
    ==== Possible fixes ====

    igt@gem_exec_suspend@basic-s3:
      fi-blb-e6850:       INCOMPLETE (fdo#107718) -> PASS

    igt@kms_frontbuffer_tracking@basic:
      fi-byt-clapper:     FAIL (fdo#103167) -> PASS

fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#106070 https://bugs.freedesktop.org/show_bug.cgi?id=106070
fdo#107345 https://bugs.freedesktop.org/show_bug.cgi?id=107345
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
fdo#107718 https://bugs.freedesktop.org/show_bug.cgi?id=107718
fdo#108126 https://bugs.freedesktop.org/show_bug.cgi?id=108126

== Participating hosts (47 -> 42) ==

Additional (1): fi-skl-6700hq
Missing (6): fi-kbl-soraka fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-icl-u2 fi-ctg-p8600

== Build changes ==

* IGT: IGT_4671 -> IGTPW_1929

CI_DRM_4952: a62e43ba13605a478b22307ea1790d48aea029a6 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1929: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1929/
IGT_4671: b121f7d42c260ae3a050c3f440d1c11f7cff7d1a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1929/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#2 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for tools/dpcd_reg: Introduce dump as the default operation

In reply to Tarun Vyas
== Series Details ==

== Series Details ==

Series: tools/dpcd_reg: Introduce dump as the default operation
URL : https://patchwork.freedesktop.org/series/50779/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4671_full -> IGTPW_1929_full =

== Summary - WARNING ==

Minor unknown changes coming with IGTPW_1929_full need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_1929_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/50779/revisions/1/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in IGTPW_1929_full:

=== IGT changes ===

    ==== Warnings ====

    igt@pm_rc6_residency@rc6-accuracy:
      shard-kbl:          PASS -> SKIP
      shard-snb:          PASS -> SKIP

== Known issues ==

Here are the changes found in IGTPW_1929_full that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@kms_cursor_crc@cursor-128x128-random:
      shard-glk:          PASS -> FAIL (fdo#103232)

    igt@kms_cursor_crc@cursor-64x21-random:
      shard-apl:          PASS -> FAIL (fdo#103232) +5

    igt@kms_cursor_crc@cursor-64x21-sliding:
      shard-kbl:          PASS -> FAIL (fdo#103232)

    igt@kms_cursor_crc@cursor-64x64-suspend:
      shard-apl:          PASS -> FAIL (fdo#103232, fdo#103191)
      shard-kbl:          PASS -> FAIL (fdo#103232, fdo#103191)

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-gtt:
      shard-apl:          PASS -> FAIL (fdo#103167) +1

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-wc:
      shard-kbl:          PASS -> FAIL (fdo#103167)

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-fullscreen:
      shard-apl:          NOTRUN -> FAIL (fdo#103167)

    igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-render:
      shard-glk:          PASS -> DMESG-FAIL (fdo#103167, fdo#106538)

    igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-wc:
      shard-glk:          PASS -> FAIL (fdo#103167) +2

    igt@kms_plane@pixel-format-pipe-b-planes:
      shard-kbl:          PASS -> FAIL (fdo#103166) +3

    igt@kms_plane@pixel-format-pipe-c-planes:
      shard-apl:          PASS -> FAIL (fdo#103166) +3

    igt@kms_plane@plane-position-covered-pipe-b-planes:
      shard-glk:          PASS -> FAIL (fdo#103166) +5

    igt@kms_setmode@basic:
      shard-kbl:          PASS -> FAIL (fdo#99912)

    
    ==== Possible fixes ====

    igt@gem_tiled_blits@interruptible:
      shard-apl:          INCOMPLETE (fdo#103927) -> PASS

    igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-a:
      shard-apl:          DMESG-WARN (fdo#107956) -> PASS

    igt@kms_ccs@pipe-a-crc-sprite-planes-basic:
      shard-glk:          FAIL (fdo#108145) -> PASS

    igt@kms_color@pipe-c-legacy-gamma:
      shard-kbl:          FAIL (fdo#104782) -> PASS
      shard-apl:          FAIL (fdo#104782) -> PASS

    igt@kms_cursor_crc@cursor-128x128-random:
      shard-kbl:          FAIL (fdo#103232) -> PASS

    igt@kms_cursor_crc@cursor-256x256-random:
      shard-glk:          FAIL (fdo#103232) -> PASS +3

    igt@kms_cursor_crc@cursor-256x256-suspend:
      shard-kbl:          INCOMPLETE (fdo#103665) -> PASS

    igt@kms_cursor_legacy@2x-cursor-vs-flip-legacy:
      shard-glk:          INCOMPLETE (fdo#103359, k.org#198133) -> PASS

    igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic:
      shard-hsw:          FAIL (fdo#105767) -> PASS

    igt@kms_flip@flip-vs-fences-interruptible:
      shard-snb:          INCOMPLETE (fdo#105411) -> PASS

    igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-mmap-gtt:
      shard-glk:          DMESG-FAIL (fdo#103167, fdo#106538) -> PASS

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt:
      shard-apl:          FAIL (fdo#103167) -> PASS +3

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-fullscreen:
      shard-kbl:          FAIL (fdo#103167) -> PASS

    igt@kms_frontbuffer_tracking@fbc-1p-rte:
      shard-glk:          FAIL (fdo#103167, fdo#105682) -> PASS

    igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-move:
      shard-glk:          FAIL (fdo#103167) -> PASS +14

    {igt@kms_plane_alpha_blend@pipe-a-coverage-7efc}:
      shard-glk:          DMESG-FAIL (fdo#106538) -> PASS

    igt@kms_plane_multiple@atomic-pipe-a-tiling-y:
      shard-glk:          FAIL (fdo#103166) -> PASS +4

    igt@kms_plane_multiple@atomic-pipe-c-tiling-y:
      shard-apl:          FAIL (fdo#103166) -> PASS +1

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#103232 https://bugs.freedesktop.org/show_bug.cgi?id=103232
fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#104782 https://bugs.freedesktop.org/show_bug.cgi?id=104782
fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
fdo#105682 https://bugs.freedesktop.org/show_bug.cgi?id=105682
fdo#105767 https://bugs.freedesktop.org/show_bug.cgi?id=105767
fdo#106538 https://bugs.freedesktop.org/show_bug.cgi?id=106538
fdo#107956 https://bugs.freedesktop.org/show_bug.cgi?id=107956
fdo#108145 https://bugs.freedesktop.org/show_bug.cgi?id=108145
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133

== Participating hosts (6 -> 5) ==

Missing (1): shard-skl

== Build changes ==

* IGT: IGT_4671 -> IGTPW_1929
* Linux: CI_DRM_4944 -> CI_DRM_4952

CI_DRM_4944: 66bd263b99fd264b57432c232756baf95b0a6255 @ git://anongit.freedesktop.org/gfx-ci/linux
CI_DRM_4952: a62e43ba13605a478b22307ea1790d48aea029a6 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1929: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1929/
IGT_4671: b121f7d42c260ae3a050c3f440d1c11f7cff7d1a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1929/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw
In reply to Tarun Vyas
Quoted 11 lines · Tarun Vyas

From: Rodrigo Vivi <[email protected]>

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

With this, we should be able to kill i915_dpcd from the kernel debugfs and rely solely on dpcd_reg for dpcd dumps.

This looks good to me and I believe I could just go there and merge since we have 2 people working together and agreeing here right?

DK, comments?

Tarun, do you have plans to make this dump without --device option to print all of available dpcd like my old series was doing?

Quoted 179 lines
---
 tools/dpcd_reg.c | 86 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 66 insertions(+), 20 deletions(-)
tools/dpcd_reg.c +66 -20
index d577aa55..2761168d 100644
@@ -41,19 +41,50 @@
 
 const char aux_dev[] = "/dev/drm_dp_aux";
 
+struct dpcd_block {
+	/* DPCD dump start address. */
+	uint32_t offset;
+	/* DPCD number of bytes to read. If unset, defaults to 1. */
+	size_t count;
+};
+
 struct dpcd_data {
 	int devid;
 	int file_op;
-	uint32_t offset;
+	struct dpcd_block rw;
 	enum command {
-		INVALID = -1,
-		READ = 2,
+		DUMP,
+		READ,
 		WRITE,
 	} cmd;
-	size_t count;
 	uint8_t val;
 };
 
+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 },
+	/* DP_PSR_STATUS to DP_PSR_STATUS */
+	{ .offset = 0x2008, .count = 1 },
+};
+
 static void print_usage(void)
 {
 	printf("Usage: dpcd_reg [OPTION ...] COMMAND\n\n");
@@ -103,7 +134,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 				print_usage();
 				return EXIT_FAILURE;
 			}
-			dpcd->count = temp;
+			dpcd->rw.count = temp;
 			break;
 		case 'd':
 			temp = strtol(optarg, &endptr, 10);
@@ -131,7 +162,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 				print_usage();
 				return ERANGE;
 			}
-			dpcd->offset = temp;
+			dpcd->rw.offset = temp;
 			break;
 		case 'v':
 			vflag = 'v';
@@ -147,16 +178,15 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 		/* Command parsing */
 		case 1:
 			if (strcmp(optarg, "read") == 0) {
-				temp = READ;
+				dpcd->cmd = READ;
 			} else if (strcmp(optarg, "write") == 0) {
-				temp = WRITE;
+				dpcd->cmd = WRITE;
 				dpcd->file_op = O_WRONLY;
-			} else {
+			} else if (strcmp(optarg, "dump") != 0) {
 				fprintf(stderr, "Unrecognized command\n");
 				print_usage();
 				return EXIT_FAILURE;
 			}
-			dpcd->cmd = temp;
 			break;
 		case ':':
 			fprintf(stderr, "Option -%c requires an argument\n",
@@ -170,7 +200,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 		}
 	}
 
-	if ((dpcd->count + dpcd->offset) > (MAX_DP_OFFSET + 1)) {
+	if ((dpcd->rw.count + dpcd->rw.offset) > (MAX_DP_OFFSET + 1)) {
 		fprintf(stderr, "Out of bounds. Count + Offset <= 0x100000\n");
 		return ERANGE;
 	}
@@ -207,7 +237,7 @@ static int dpcd_read(int fd, uint32_t offset, size_t count)
 		ret = EXIT_FAILURE;
 	}
 
-	printf("0x%02x: ", offset);
+	printf("0x%04x: ", offset);
 	for (i = 0; i < pret; i++)
 		printf(" %02x", *(buf + i));
 	printf("\n");
@@ -233,6 +263,23 @@ static int dpcd_write(int fd, uint32_t offset, uint8_t val)
 	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 != EXIT_SUCCESS) {
+			fprintf(stderr, "Dump failed while reading %04x\n",
+				 dump_list[i].offset);
+			return ret;
+		}
+	}
+	return ret;
+}
+
 int main(int argc, char **argv)
 {
 	char dev_name[20];
@@ -241,9 +288,9 @@ int main(int argc, char **argv)
 	struct dpcd_data dpcd = {
 		.devid = 0,
 		.file_op = O_RDONLY,
-		.offset = 0x0,
-		.cmd = INVALID,
-		.count = 1,
+		.rw.offset = 0x0,
+		.rw.count = 1,
+		.cmd = DUMP,
 	};
 
 	ret = parse_opts(&dpcd, argc, argv);
@@ -262,15 +309,14 @@ int main(int argc, char **argv)
 
 	switch (dpcd.cmd) {
 	case READ:
-		ret = dpcd_read(fd, dpcd.offset, dpcd.count);
+		ret = dpcd_read(fd, dpcd.rw.offset, dpcd.rw.count);
 		break;
 	case WRITE:
-		ret = dpcd_write(fd, dpcd.offset, dpcd.val);
+		ret = dpcd_write(fd, dpcd.rw.offset, dpcd.val);
 		break;
+	case DUMP:
 	default:
-		fprintf(stderr, "Please specify a command: read/write.\n");
-		print_usage();
-		ret = EXIT_FAILURE;
+		ret = dpcd_dump(fd);
 		break;
 	}
 
Signature · 1 line
2.14.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

author
#4 lore raw
Quoted 17 lines · Rodrigo Vivi
Quoted 11 lines · Tarun Vyas

From: Rodrigo Vivi <[email protected]>

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

With this, we should be able to kill i915_dpcd from the kernel debugfs and rely solely on dpcd_reg for dpcd dumps.

This looks good to me and I believe I could just go there and merge since we have 2 people working together and agreeing here right?

Quoted 6 lines

DK, comments?

Tarun, do you have plans to make this dump without --device option to print all of available dpcd like my old series was doing?

Thanks Rodrigo. DK and I discussed dumping dpcds for all the devices, but we weren't sure if we want to open every device that may or may not be connected and hence timeout on a read. So, by default we dump device 0, even if the user doesnt specifies anything. For other devices they can specify the device ids.

Quoted 176 lines
Quoted 176 lines
---
 tools/dpcd_reg.c | 86 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 66 insertions(+), 20 deletions(-)
tools/dpcd_reg.c +66 -20
index d577aa55..2761168d 100644
@@ -41,19 +41,50 @@
 
 const char aux_dev[] = "/dev/drm_dp_aux";
 
+struct dpcd_block {
+	/* DPCD dump start address. */
+	uint32_t offset;
+	/* DPCD number of bytes to read. If unset, defaults to 1. */
+	size_t count;
+};
+
 struct dpcd_data {
 	int devid;
 	int file_op;
-	uint32_t offset;
+	struct dpcd_block rw;
 	enum command {
-		INVALID = -1,
-		READ = 2,
+		DUMP,
+		READ,
 		WRITE,
 	} cmd;
-	size_t count;
 	uint8_t val;
 };
 
+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 },
+	/* DP_PSR_STATUS to DP_PSR_STATUS */
+	{ .offset = 0x2008, .count = 1 },
+};
+
 static void print_usage(void)
 {
 	printf("Usage: dpcd_reg [OPTION ...] COMMAND\n\n");
@@ -103,7 +134,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 				print_usage();
 				return EXIT_FAILURE;
 			}
-			dpcd->count = temp;
+			dpcd->rw.count = temp;
 			break;
 		case 'd':
 			temp = strtol(optarg, &endptr, 10);
@@ -131,7 +162,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 				print_usage();
 				return ERANGE;
 			}
-			dpcd->offset = temp;
+			dpcd->rw.offset = temp;
 			break;
 		case 'v':
 			vflag = 'v';
@@ -147,16 +178,15 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 		/* Command parsing */
 		case 1:
 			if (strcmp(optarg, "read") == 0) {
-				temp = READ;
+				dpcd->cmd = READ;
 			} else if (strcmp(optarg, "write") == 0) {
-				temp = WRITE;
+				dpcd->cmd = WRITE;
 				dpcd->file_op = O_WRONLY;
-			} else {
+			} else if (strcmp(optarg, "dump") != 0) {
 				fprintf(stderr, "Unrecognized command\n");
 				print_usage();
 				return EXIT_FAILURE;
 			}
-			dpcd->cmd = temp;
 			break;
 		case ':':
 			fprintf(stderr, "Option -%c requires an argument\n",
@@ -170,7 +200,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 		}
 	}
 
-	if ((dpcd->count + dpcd->offset) > (MAX_DP_OFFSET + 1)) {
+	if ((dpcd->rw.count + dpcd->rw.offset) > (MAX_DP_OFFSET + 1)) {
 		fprintf(stderr, "Out of bounds. Count + Offset <= 0x100000\n");
 		return ERANGE;
 	}
@@ -207,7 +237,7 @@ static int dpcd_read(int fd, uint32_t offset, size_t count)
 		ret = EXIT_FAILURE;
 	}
 
-	printf("0x%02x: ", offset);
+	printf("0x%04x: ", offset);
 	for (i = 0; i < pret; i++)
 		printf(" %02x", *(buf + i));
 	printf("\n");
@@ -233,6 +263,23 @@ static int dpcd_write(int fd, uint32_t offset, uint8_t val)
 	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 != EXIT_SUCCESS) {
+			fprintf(stderr, "Dump failed while reading %04x\n",
+				 dump_list[i].offset);
+			return ret;
+		}
+	}
+	return ret;
+}
+
 int main(int argc, char **argv)
 {
 	char dev_name[20];
@@ -241,9 +288,9 @@ int main(int argc, char **argv)
 	struct dpcd_data dpcd = {
 		.devid = 0,
 		.file_op = O_RDONLY,
-		.offset = 0x0,
-		.cmd = INVALID,
-		.count = 1,
+		.rw.offset = 0x0,
+		.rw.count = 1,
+		.cmd = DUMP,
 	};
 
 	ret = parse_opts(&dpcd, argc, argv);
@@ -262,15 +309,14 @@ int main(int argc, char **argv)
 
 	switch (dpcd.cmd) {
 	case READ:
-		ret = dpcd_read(fd, dpcd.offset, dpcd.count);
+		ret = dpcd_read(fd, dpcd.rw.offset, dpcd.rw.count);
 		break;
 	case WRITE:
-		ret = dpcd_write(fd, dpcd.offset, dpcd.val);
+		ret = dpcd_write(fd, dpcd.rw.offset, dpcd.val);
 		break;
+	case DUMP:
 	default:
-		fprintf(stderr, "Please specify a command: read/write.\n");
-		print_usage();
-		ret = EXIT_FAILURE;
+		ret = dpcd_dump(fd);
 		break;
 	}
 
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
2.14.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#5 lore raw
Quoted 10 lines · Tarun Vyas
Quoted 9 lines · Rodrigo Vivi
Quoted 8 lines · Tarun Vyas

From: Rodrigo Vivi <[email protected]>

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

With this, we should be able to kill i915_dpcd from the kernel debugfs and rely solely on dpcd_reg for dpcd dumps.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

This looks good to me and I believe I could just go there and merge since we have 2 people working together and agreeing here right?

no one seems to disagree, so pushed! :)

Quoted 8 lines
Quoted 7 lines

DK, comments?

Tarun, do you have plans to make this dump without --device option to print all of available dpcd like my old series was doing?

Thanks Rodrigo. DK and I discussed dumping dpcds for all the devices, but we weren't sure if we want to open every device that may or may not be connected and hence timeout on a read. So, by default we dump device 0, even if the user doesnt specifies anything. For other devices they can specify the device ids.

My idea on those first patches was to only iterate on the existing files. dev files will only exist if connector exist.

And then, just try a dummy byte read on it to see if there is really a connected DP there. If it replies print, otherwise skip.

And also print the connector name, so it gets easier when using this info for debugging...

Quoted 176 lines
Quoted 176 lines
Quoted 176 lines
---
 tools/dpcd_reg.c | 86 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 66 insertions(+), 20 deletions(-)
tools/dpcd_reg.c +66 -20
index d577aa55..2761168d 100644
@@ -41,19 +41,50 @@
 
 const char aux_dev[] = "/dev/drm_dp_aux";
 
+struct dpcd_block {
+	/* DPCD dump start address. */
+	uint32_t offset;
+	/* DPCD number of bytes to read. If unset, defaults to 1. */
+	size_t count;
+};
+
 struct dpcd_data {
 	int devid;
 	int file_op;
-	uint32_t offset;
+	struct dpcd_block rw;
 	enum command {
-		INVALID = -1,
-		READ = 2,
+		DUMP,
+		READ,
 		WRITE,
 	} cmd;
-	size_t count;
 	uint8_t val;
 };
 
+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 },
+	/* DP_PSR_STATUS to DP_PSR_STATUS */
+	{ .offset = 0x2008, .count = 1 },
+};
+
 static void print_usage(void)
 {
 	printf("Usage: dpcd_reg [OPTION ...] COMMAND\n\n");
@@ -103,7 +134,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 				print_usage();
 				return EXIT_FAILURE;
 			}
-			dpcd->count = temp;
+			dpcd->rw.count = temp;
 			break;
 		case 'd':
 			temp = strtol(optarg, &endptr, 10);
@@ -131,7 +162,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 				print_usage();
 				return ERANGE;
 			}
-			dpcd->offset = temp;
+			dpcd->rw.offset = temp;
 			break;
 		case 'v':
 			vflag = 'v';
@@ -147,16 +178,15 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 		/* Command parsing */
 		case 1:
 			if (strcmp(optarg, "read") == 0) {
-				temp = READ;
+				dpcd->cmd = READ;
 			} else if (strcmp(optarg, "write") == 0) {
-				temp = WRITE;
+				dpcd->cmd = WRITE;
 				dpcd->file_op = O_WRONLY;
-			} else {
+			} else if (strcmp(optarg, "dump") != 0) {
 				fprintf(stderr, "Unrecognized command\n");
 				print_usage();
 				return EXIT_FAILURE;
 			}
-			dpcd->cmd = temp;
 			break;
 		case ':':
 			fprintf(stderr, "Option -%c requires an argument\n",
@@ -170,7 +200,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 		}
 	}
 
-	if ((dpcd->count + dpcd->offset) > (MAX_DP_OFFSET + 1)) {
+	if ((dpcd->rw.count + dpcd->rw.offset) > (MAX_DP_OFFSET + 1)) {
 		fprintf(stderr, "Out of bounds. Count + Offset <= 0x100000\n");
 		return ERANGE;
 	}
@@ -207,7 +237,7 @@ static int dpcd_read(int fd, uint32_t offset, size_t count)
 		ret = EXIT_FAILURE;
 	}
 
-	printf("0x%02x: ", offset);
+	printf("0x%04x: ", offset);
 	for (i = 0; i < pret; i++)
 		printf(" %02x", *(buf + i));
 	printf("\n");
@@ -233,6 +263,23 @@ static int dpcd_write(int fd, uint32_t offset, uint8_t val)
 	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 != EXIT_SUCCESS) {
+			fprintf(stderr, "Dump failed while reading %04x\n",
+				 dump_list[i].offset);
+			return ret;
+		}
+	}
+	return ret;
+}
+
 int main(int argc, char **argv)
 {
 	char dev_name[20];
@@ -241,9 +288,9 @@ int main(int argc, char **argv)
 	struct dpcd_data dpcd = {
 		.devid = 0,
 		.file_op = O_RDONLY,
-		.offset = 0x0,
-		.cmd = INVALID,
-		.count = 1,
+		.rw.offset = 0x0,
+		.rw.count = 1,
+		.cmd = DUMP,
 	};
 
 	ret = parse_opts(&dpcd, argc, argv);
@@ -262,15 +309,14 @@ int main(int argc, char **argv)
 
 	switch (dpcd.cmd) {
 	case READ:
-		ret = dpcd_read(fd, dpcd.offset, dpcd.count);
+		ret = dpcd_read(fd, dpcd.rw.offset, dpcd.rw.count);
 		break;
 	case WRITE:
-		ret = dpcd_write(fd, dpcd.offset, dpcd.val);
+		ret = dpcd_write(fd, dpcd.rw.offset, dpcd.val);
 		break;
+	case DUMP:
 	default:
-		fprintf(stderr, "Please specify a command: read/write.\n");
-		print_usage();
-		ret = EXIT_FAILURE;
+		ret = dpcd_dump(fd);
 		break;
 	}
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
2.14.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

author
#6 lore raw
Quoted 30 lines · Rodrigo Vivi
Quoted 10 lines · Tarun Vyas
Quoted 9 lines · Rodrigo Vivi
Quoted 8 lines · Tarun Vyas

From: Rodrigo Vivi <[email protected]>

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

With this, we should be able to kill i915_dpcd from the kernel debugfs and rely solely on dpcd_reg for dpcd dumps.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

This looks good to me and I believe I could just go there and merge since we have 2 people working together and agreeing here right?

no one seems to disagree, so pushed! :)

Quoted 8 lines
Quoted 7 lines

DK, comments?

Tarun, do you have plans to make this dump without --device option to print all of available dpcd like my old series was doing?

Thanks Rodrigo. DK and I discussed dumping dpcds for all the devices, but we weren't sure if we want to open every device that may or may not be connected and hence timeout on a read. So, by default we dump device 0, even if the user doesnt specifies anything. For other devices they can specify the device ids.

Quoted 9 lines

My idea on those first patches was to only iterate on the existing files. dev files will only exist if connector exist.

And then, just try a dummy byte read on it to see if there is really a connected DP there. If it replies print, otherwise skip.

And also print the connector name, so it gets easier when using this info for debugging...

Oh ok. I'll integrate the last patch in your series to dump all the available devices, as the default behavior.

Thanks,
Tarun

Quoted 176 lines
Quoted 176 lines
Quoted 176 lines
Quoted 176 lines
---
 tools/dpcd_reg.c | 86 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 66 insertions(+), 20 deletions(-)
tools/dpcd_reg.c +66 -20
index d577aa55..2761168d 100644
@@ -41,19 +41,50 @@
 
 const char aux_dev[] = "/dev/drm_dp_aux";
 
+struct dpcd_block {
+	/* DPCD dump start address. */
+	uint32_t offset;
+	/* DPCD number of bytes to read. If unset, defaults to 1. */
+	size_t count;
+};
+
 struct dpcd_data {
 	int devid;
 	int file_op;
-	uint32_t offset;
+	struct dpcd_block rw;
 	enum command {
-		INVALID = -1,
-		READ = 2,
+		DUMP,
+		READ,
 		WRITE,
 	} cmd;
-	size_t count;
 	uint8_t val;
 };
 
+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 },
+	/* DP_PSR_STATUS to DP_PSR_STATUS */
+	{ .offset = 0x2008, .count = 1 },
+};
+
 static void print_usage(void)
 {
 	printf("Usage: dpcd_reg [OPTION ...] COMMAND\n\n");
@@ -103,7 +134,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 				print_usage();
 				return EXIT_FAILURE;
 			}
-			dpcd->count = temp;
+			dpcd->rw.count = temp;
 			break;
 		case 'd':
 			temp = strtol(optarg, &endptr, 10);
@@ -131,7 +162,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 				print_usage();
 				return ERANGE;
 			}
-			dpcd->offset = temp;
+			dpcd->rw.offset = temp;
 			break;
 		case 'v':
 			vflag = 'v';
@@ -147,16 +178,15 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 		/* Command parsing */
 		case 1:
 			if (strcmp(optarg, "read") == 0) {
-				temp = READ;
+				dpcd->cmd = READ;
 			} else if (strcmp(optarg, "write") == 0) {
-				temp = WRITE;
+				dpcd->cmd = WRITE;
 				dpcd->file_op = O_WRONLY;
-			} else {
+			} else if (strcmp(optarg, "dump") != 0) {
 				fprintf(stderr, "Unrecognized command\n");
 				print_usage();
 				return EXIT_FAILURE;
 			}
-			dpcd->cmd = temp;
 			break;
 		case ':':
 			fprintf(stderr, "Option -%c requires an argument\n",
@@ -170,7 +200,7 @@ static int parse_opts(struct dpcd_data *dpcd, int argc, char **argv)
 		}
 	}
 
-	if ((dpcd->count + dpcd->offset) > (MAX_DP_OFFSET + 1)) {
+	if ((dpcd->rw.count + dpcd->rw.offset) > (MAX_DP_OFFSET + 1)) {
 		fprintf(stderr, "Out of bounds. Count + Offset <= 0x100000\n");
 		return ERANGE;
 	}
@@ -207,7 +237,7 @@ static int dpcd_read(int fd, uint32_t offset, size_t count)
 		ret = EXIT_FAILURE;
 	}
 
-	printf("0x%02x: ", offset);
+	printf("0x%04x: ", offset);
 	for (i = 0; i < pret; i++)
 		printf(" %02x", *(buf + i));
 	printf("\n");
@@ -233,6 +263,23 @@ static int dpcd_write(int fd, uint32_t offset, uint8_t val)
 	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 != EXIT_SUCCESS) {
+			fprintf(stderr, "Dump failed while reading %04x\n",
+				 dump_list[i].offset);
+			return ret;
+		}
+	}
+	return ret;
+}
+
 int main(int argc, char **argv)
 {
 	char dev_name[20];
@@ -241,9 +288,9 @@ int main(int argc, char **argv)
 	struct dpcd_data dpcd = {
 		.devid = 0,
 		.file_op = O_RDONLY,
-		.offset = 0x0,
-		.cmd = INVALID,
-		.count = 1,
+		.rw.offset = 0x0,
+		.rw.count = 1,
+		.cmd = DUMP,
 	};
 
 	ret = parse_opts(&dpcd, argc, argv);
@@ -262,15 +309,14 @@ int main(int argc, char **argv)
 
 	switch (dpcd.cmd) {
 	case READ:
-		ret = dpcd_read(fd, dpcd.offset, dpcd.count);
+		ret = dpcd_read(fd, dpcd.rw.offset, dpcd.rw.count);
 		break;
 	case WRITE:
-		ret = dpcd_write(fd, dpcd.offset, dpcd.val);
+		ret = dpcd_write(fd, dpcd.rw.offset, dpcd.val);
 		break;
+	case DUMP:
 	default:
-		fprintf(stderr, "Please specify a command: read/write.\n");
-		print_usage();
-		ret = EXIT_FAILURE;
+		ret = dpcd_dump(fd);
 		break;
 	}
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
2.14.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev