* [igt-dev] [PATCH i-g-t] tools/dpcd_reg: Introduce dump as the default operation
@ 2018-10-10 6:44 Tarun Vyas
2018-10-10 10:35 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Tarun Vyas @ 2018-10-10 6:44 UTC (permalink / raw)
To: igt-dev; +Cc: dhinakaran.pandiyan, Rodrigo Vivi
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
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.
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Tarun Vyas <tarun.vyas@intel.com>
---
tools/dpcd_reg.c | 86 +++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 66 insertions(+), 20 deletions(-)
diff --git a/tools/dpcd_reg.c b/tools/dpcd_reg.c
index d577aa55..2761168d 100644
--- a/tools/dpcd_reg.c
+++ b/tools/dpcd_reg.c
@@ -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;
}
--
2.14.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [igt-dev] ✓ Fi.CI.BAT: success for tools/dpcd_reg: Introduce dump as the default operation
2018-10-10 6:44 [igt-dev] [PATCH i-g-t] tools/dpcd_reg: Introduce dump as the default operation Tarun Vyas
@ 2018-10-10 10:35 ` Patchwork
2018-10-10 12:29 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-10-17 0:23 ` [igt-dev] [PATCH i-g-t] " Rodrigo Vivi
2 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2018-10-10 10:35 UTC (permalink / raw)
To: Tarun Vyas; +Cc: igt-dev
== 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
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 7+ messages in thread
* [igt-dev] ✓ Fi.CI.IGT: success for tools/dpcd_reg: Introduce dump as the default operation
2018-10-10 6:44 [igt-dev] [PATCH i-g-t] tools/dpcd_reg: Introduce dump as the default operation Tarun Vyas
2018-10-10 10:35 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
@ 2018-10-10 12:29 ` Patchwork
2018-10-17 0:23 ` [igt-dev] [PATCH i-g-t] " Rodrigo Vivi
2 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2018-10-10 12:29 UTC (permalink / raw)
To: Tarun Vyas; +Cc: igt-dev
== 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
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tools/dpcd_reg: Introduce dump as the default operation
2018-10-10 6:44 [igt-dev] [PATCH i-g-t] tools/dpcd_reg: Introduce dump as the default operation Tarun Vyas
2018-10-10 10:35 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-10-10 12:29 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
@ 2018-10-17 0:23 ` Rodrigo Vivi
2018-10-18 13:30 ` Tarun Vyas
2 siblings, 1 reply; 7+ messages in thread
From: Rodrigo Vivi @ 2018-10-17 0:23 UTC (permalink / raw)
To: Tarun Vyas; +Cc: igt-dev, dhinakaran.pandiyan
On Tue, Oct 09, 2018 at 11:44:18PM -0700, Tarun Vyas wrote:
> From: Rodrigo Vivi <rodrigo.vivi@intel.com>
>
> 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.
>
> Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: Tarun Vyas <tarun.vyas@intel.com>
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?
> ---
> tools/dpcd_reg.c | 86 +++++++++++++++++++++++++++++++++++++++++++-------------
> 1 file changed, 66 insertions(+), 20 deletions(-)
>
> diff --git a/tools/dpcd_reg.c b/tools/dpcd_reg.c
> index d577aa55..2761168d 100644
> --- a/tools/dpcd_reg.c
> +++ b/tools/dpcd_reg.c
> @@ -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;
> }
>
> --
> 2.14.1
>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tools/dpcd_reg: Introduce dump as the default operation
2018-10-17 0:23 ` [igt-dev] [PATCH i-g-t] " Rodrigo Vivi
@ 2018-10-18 13:30 ` Tarun Vyas
2018-10-18 18:19 ` Rodrigo Vivi
0 siblings, 1 reply; 7+ messages in thread
From: Tarun Vyas @ 2018-10-18 13:30 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: igt-dev, dhinakaran.pandiyan
On Tue, Oct 16, 2018 at 05:23:59PM -0700, Rodrigo Vivi wrote:
> On Tue, Oct 09, 2018 at 11:44:18PM -0700, Tarun Vyas wrote:
> > From: Rodrigo Vivi <rodrigo.vivi@intel.com>
> >
> > 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.
> >
> > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Signed-off-by: Tarun Vyas <tarun.vyas@intel.com>
>
> 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?
>
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.
> > ---
> > tools/dpcd_reg.c | 86 +++++++++++++++++++++++++++++++++++++++++++-------------
> > 1 file changed, 66 insertions(+), 20 deletions(-)
> >
> > diff --git a/tools/dpcd_reg.c b/tools/dpcd_reg.c
> > index d577aa55..2761168d 100644
> > --- a/tools/dpcd_reg.c
> > +++ b/tools/dpcd_reg.c
> > @@ -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;
> > }
> >
> > --
> > 2.14.1
> >
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tools/dpcd_reg: Introduce dump as the default operation
2018-10-18 13:30 ` Tarun Vyas
@ 2018-10-18 18:19 ` Rodrigo Vivi
2018-10-18 18:34 ` Tarun Vyas
0 siblings, 1 reply; 7+ messages in thread
From: Rodrigo Vivi @ 2018-10-18 18:19 UTC (permalink / raw)
To: Tarun Vyas; +Cc: igt-dev, dhinakaran.pandiyan
On Thu, Oct 18, 2018 at 01:30:03PM +0000, Tarun Vyas wrote:
> On Tue, Oct 16, 2018 at 05:23:59PM -0700, Rodrigo Vivi wrote:
> > On Tue, Oct 09, 2018 at 11:44:18PM -0700, Tarun Vyas wrote:
> > > From: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > >
> > > 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.
> > >
> > > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> > > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > Signed-off-by: Tarun Vyas <tarun.vyas@intel.com>
> >
> > 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! :)
> >
> > 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...
> > > ---
> > > tools/dpcd_reg.c | 86 +++++++++++++++++++++++++++++++++++++++++++-------------
> > > 1 file changed, 66 insertions(+), 20 deletions(-)
> > >
> > > diff --git a/tools/dpcd_reg.c b/tools/dpcd_reg.c
> > > index d577aa55..2761168d 100644
> > > --- a/tools/dpcd_reg.c
> > > +++ b/tools/dpcd_reg.c
> > > @@ -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;
> > > }
> > >
> > > --
> > > 2.14.1
> > >
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [igt-dev] [PATCH i-g-t] tools/dpcd_reg: Introduce dump as the default operation
2018-10-18 18:19 ` Rodrigo Vivi
@ 2018-10-18 18:34 ` Tarun Vyas
0 siblings, 0 replies; 7+ messages in thread
From: Tarun Vyas @ 2018-10-18 18:34 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: igt-dev, dhinakaran.pandiyan
On Thu, Oct 18, 2018 at 11:19:38AM -0700, Rodrigo Vivi wrote:
> On Thu, Oct 18, 2018 at 01:30:03PM +0000, Tarun Vyas wrote:
> > On Tue, Oct 16, 2018 at 05:23:59PM -0700, Rodrigo Vivi wrote:
> > > On Tue, Oct 09, 2018 at 11:44:18PM -0700, Tarun Vyas wrote:
> > > > From: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > >
> > > > 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.
> > > >
> > > > Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> > > > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > > Signed-off-by: Tarun Vyas <tarun.vyas@intel.com>
> > >
> > > 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! :)
>
> > >
> > > 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...
>
Oh ok. I'll integrate the last patch in your series to dump all the available devices, as the default behavior.
Thanks,
Tarun
> > > > ---
> > > > tools/dpcd_reg.c | 86 +++++++++++++++++++++++++++++++++++++++++++-------------
> > > > 1 file changed, 66 insertions(+), 20 deletions(-)
> > > >
> > > > diff --git a/tools/dpcd_reg.c b/tools/dpcd_reg.c
> > > > index d577aa55..2761168d 100644
> > > > --- a/tools/dpcd_reg.c
> > > > +++ b/tools/dpcd_reg.c
> > > > @@ -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;
> > > > }
> > > >
> > > > --
> > > > 2.14.1
> > > >
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-10-18 23:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-10 6:44 [igt-dev] [PATCH i-g-t] tools/dpcd_reg: Introduce dump as the default operation Tarun Vyas
2018-10-10 10:35 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-10-10 12:29 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-10-17 0:23 ` [igt-dev] [PATCH i-g-t] " Rodrigo Vivi
2018-10-18 13:30 ` Tarun Vyas
2018-10-18 18:19 ` Rodrigo Vivi
2018-10-18 18:34 ` Tarun Vyas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox