This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:
Subject: edid-decode: move HDCP parse code to parse-hdcp.cpp Author: Hans Verkuil <[email protected]> Date: Mon May 11 07:52:16 2026 +0200 Extract the HDCP parse code from ddc.cpp and move it to parse-hdcp.cpp. This keeps the parse code separate from the read code. No other changes. Signed-off-by: Hans Verkuil <[email protected]> utils/edid-decode/ddc.cpp | 93 +-------------------------------- utils/edid-decode/edid-decode.cpp | 2 +- utils/edid-decode/edid-decode.h | 5 ++ utils/edid-decode/meson.build | 1 + utils/edid-decode/parse-hdcp.cpp | 106 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 92 deletions(-) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=ce04d0c7d82e46884549fb238317d74194fffeea diff --git a/utils/edid-decode/ddc.cpp b/utils/edid-decode/ddc.cpp index 460458e893c5..209ef6aef230 100644 --- a/utils/edid-decode/ddc.cpp +++ b/utils/edid-decode/ddc.cpp @@ -344,7 +344,7 @@ static int read_hdcp_registers(int adapter_fd, __u8 *hdcp_prim, __u8 *hdcp_sec, return 0; } -int read_hdcp(int adapter_fd) +int edid_state::read_hdcp(int adapter_fd) { __u8 hdcp_prim[256] = {}; __u8 hdcp_sec[256] = {}; @@ -354,96 +354,7 @@ int read_hdcp(int adapter_fd) hdcp_sec[5] = 0xdd; if (read_hdcp_registers(adapter_fd, hdcp_prim, hdcp_sec, ksv_fifo)) return -1; - printf("HDCP Primary Link Hex Dump:\n\n"); - hex_block("", hdcp_prim, 128, false); - printf("\n"); - hex_block("", hdcp_prim + 128, 128, false); - printf("\n"); - if (hdcp_sec[5] != 0xdd) { - printf("HDCP Secondary Link Hex Dump:\n\n"); - hex_block("", hdcp_sec, 128, false); - printf("\n"); - hex_block("", hdcp_sec + 128, 128, false); - printf("\n"); - } - printf("HDCP Primary Link:\n\n"); - printf("Bksv: %02x %02x %02x %02x %02x\n", - hdcp_prim[0], hdcp_prim[1], hdcp_prim[2], hdcp_prim[3], hdcp_prim[4]); - printf("Ri': %02x %02x\n", hdcp_prim[9], hdcp_prim[8]); - printf("Pj': %02x\n", hdcp_prim[0x0a]); - printf("Aksv: %02x %02x %02x %02x %02x\n", - hdcp_prim[0x10], hdcp_prim[0x11], hdcp_prim[0x12], hdcp_prim[0x13], hdcp_prim[0x14]); - printf("Ainfo: %02x\n", hdcp_prim[0x15]); - printf("An: %02x %02x %02x %02x %02x %02x %02x %02x\n", - hdcp_prim[0x18], hdcp_prim[0x19], hdcp_prim[0x1a], hdcp_prim[0x1b], - hdcp_prim[0x1c], hdcp_prim[0x1d], hdcp_prim[0x1e], hdcp_prim[0x1f]); - printf("V'.H0: %02x %02x %02x %02x\n", - hdcp_prim[0x20], hdcp_prim[0x21], hdcp_prim[0x22], hdcp_prim[0x23]); - printf("V'.H1: %02x %02x %02x %02x\n", - hdcp_prim[0x24], hdcp_prim[0x25], hdcp_prim[0x26], hdcp_prim[0x27]); - printf("V'.H2: %02x %02x %02x %02x\n", - hdcp_prim[0x28], hdcp_prim[0x29], hdcp_prim[0x2a], hdcp_prim[0x2b]); - printf("V'.H3: %02x %02x %02x %02x\n", - hdcp_prim[0x2c], hdcp_prim[0x2d], hdcp_prim[0x2e], hdcp_prim[0x2f]); - printf("V'.H4: %02x %02x %02x %02x\n", - hdcp_prim[0x30], hdcp_prim[0x31], hdcp_prim[0x32], hdcp_prim[0x33]); - __u8 v = hdcp_prim[0x40]; - printf("Bcaps: %02x\n", v); - if (v & 0x01) - printf("\tFAST_REAUTHENTICATION\n"); - if (v & 0x02) - printf("\t1.1_FEATURES\n"); - if (v & 0x10) - printf("\tFAST\n"); - if (v & 0x20) - printf("\tREADY\n"); - if (v & 0x40) - printf("\tREPEATER\n"); - __u16 vv = hdcp_prim[0x41] | (hdcp_prim[0x42] << 8); - printf("Bstatus: %04x\n", vv); - printf("\tDEVICE_COUNT: %u\n", vv & 0x7f); - if (vv & 0x80) - printf("\tMAX_DEVS_EXCEEDED\n"); - printf("\tDEPTH: %u\n", (vv >> 8) & 0x07); - if (vv & 0x800) - printf("\tMAX_CASCADE_EXCEEDED\n"); - if (vv & 0x1000) - printf("\tHDMI_MODE\n"); - if (vv & 0x7f) { - printf("KSV FIFO:\n"); - for (unsigned i = 0; i < (vv & 0x7f); i++) - printf("\t%03u: %02x %02x %02x %02x %02x\n", i, - ksv_fifo[i * 5], ksv_fifo[i * 5 + 1], - ksv_fifo[i * 5 + 2], ksv_fifo[i * 5 + 3], - ksv_fifo[i * 5 + 4]); - } - v = hdcp_prim[0x50]; - printf("HDCP2Version: %02x\n", v); - if (v & 4) - printf("\tHDCP2.2\n"); - vv = hdcp_prim[0x70] | (hdcp_prim[0x71] << 8); - printf("RxStatus: %04x\n", vv); - if (vv & 0x3ff) - printf("\tMessage_Size: %u\n", vv & 0x3ff); - if (vv & 0x400) - printf("\tREADY\n"); - if (vv & 0x800) - printf("\tREAUTH_REQ\n"); - - if (hdcp_sec[5] == 0xdd) - return 0; - - printf("HDCP Secondary Link:\n\n"); - printf("Bksv: %02x %02x %02x %02x %02x\n", - hdcp_sec[0], hdcp_sec[1], hdcp_sec[2], hdcp_sec[3], hdcp_sec[4]); - printf("Ri': %02x %02x\n", hdcp_sec[9], hdcp_sec[9]); - printf("Pj': %02x\n", hdcp_sec[0x0a]); - printf("Aksv: %02x %02x %02x %02x %02x\n", - hdcp_sec[0x10], hdcp_sec[0x11], hdcp_sec[0x12], hdcp_sec[0x13], hdcp_sec[0x14]); - printf("Ainfo: %02x\n", hdcp_sec[0x15]); - printf("An: %02x %02x %02x %02x %02x %02x %02x %02x\n", - hdcp_sec[0x18], hdcp_sec[0x19], hdcp_sec[0x1a], hdcp_sec[0x1b], - hdcp_sec[0x1c], hdcp_sec[0x1d], hdcp_sec[0x1e], hdcp_sec[0x1f]); + parse_hdcp_data(hdcp_prim, hdcp_sec, ksv_fifo); return 0; } diff --git a/utils/edid-decode/edid-decode.cpp b/utils/edid-decode/edid-decode.cpp index ad373c8d427f..bb5cdaea197d 100644 --- a/utils/edid-decode/edid-decode.cpp +++ b/utils/edid-decode/edid-decode.cpp @@ -2866,7 +2866,7 @@ int main(int argc, char **argv) } } else if (adapter_fd >= 0) { if (options[OptI2CHDCP]) - ret = read_hdcp(adapter_fd); + ret = state.read_hdcp(adapter_fd); if (options[OptI2CHDCPRi]) ret = read_hdcp_ri(adapter_fd, hdcp_ri_sleep); if (options[OptI2CTestReliability]) diff --git a/utils/edid-decode/edid-decode.h b/utils/edid-decode/edid-decode.h index 0ff00e907ee4..a5482039a304 100644 --- a/utils/edid-decode/edid-decode.h +++ b/utils/edid-decode/edid-decode.h @@ -557,6 +557,11 @@ struct edid_state { int parse_eld(const std::string &fname); void parse_eld_baseline(const unsigned char *x, unsigned size); + + int read_hdcp(int adapter_fd); + void parse_hdcp_data(const unsigned char hdcp_prim[256], + const unsigned char hdcp_sec[256], + const unsigned char ksv_fifo[128 * 5]); }; static inline void add_str(std::string &s, const std::string &add) diff --git a/utils/edid-decode/meson.build b/utils/edid-decode/meson.build index d1ed5179413a..d0fd3d094e37 100644 --- a/utils/edid-decode/meson.build +++ b/utils/edid-decode/meson.build @@ -10,6 +10,7 @@ edid_decode_sources = [ 'parse-vtb-ext-block.cpp', 'parse-if.cpp', 'parse-eld.cpp', + 'parse-hdcp.cpp', ] edid_decode_args = [] diff --git a/utils/edid-decode/parse-hdcp.cpp b/utils/edid-decode/parse-hdcp.cpp new file mode 100644 index 000000000000..3359e1accd99 --- /dev/null +++ b/utils/edid-decode/parse-hdcp.cpp @@ -0,0 +1,106 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright 2026 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * + * Author: Hans Verkuil <[email protected]> + */ + +#include <stdio.h> + +#include "edid-decode.h" + +void edid_state::parse_hdcp_data(const unsigned char hdcp_prim[256], + const unsigned char hdcp_sec[256], + const unsigned char ksv_fifo[128 * 5]) +{ + printf("HDCP Primary Link Hex Dump:\n\n"); + hex_block("", hdcp_prim, 128, false); + printf("\n"); + hex_block("", hdcp_prim + 128, 128, false); + printf("\n"); + if (hdcp_sec[5] != 0xdd) { + printf("HDCP Secondary Link Hex Dump:\n\n"); + hex_block("", hdcp_sec, 128, false); + printf("\n"); + hex_block("", hdcp_sec + 128, 128, false); + printf("\n"); + } + printf("HDCP Primary Link:\n\n"); + printf("Bksv: %02x %02x %02x %02x %02x\n", + hdcp_prim[0], hdcp_prim[1], hdcp_prim[2], hdcp_prim[3], hdcp_prim[4]); + printf("Ri': %02x %02x\n", hdcp_prim[9], hdcp_prim[8]); + printf("Pj': %02x\n", hdcp_prim[0x0a]); + printf("Aksv: %02x %02x %02x %02x %02x\n", + hdcp_prim[0x10], hdcp_prim[0x11], hdcp_prim[0x12], hdcp_prim[0x13], hdcp_prim[0x14]); + printf("Ainfo: %02x\n", hdcp_prim[0x15]); + printf("An: %02x %02x %02x %02x %02x %02x %02x %02x\n", + hdcp_prim[0x18], hdcp_prim[0x19], hdcp_prim[0x1a], hdcp_prim[0x1b], + hdcp_prim[0x1c], hdcp_prim[0x1d], hdcp_prim[0x1e], hdcp_prim[0x1f]); + printf("V'.H0: %02x %02x %02x %02x\n", + hdcp_prim[0x20], hdcp_prim[0x21], hdcp_prim[0x22], hdcp_prim[0x23]); + printf("V'.H1: %02x %02x %02x %02x\n", + hdcp_prim[0x24], hdcp_prim[0x25], hdcp_prim[0x26], hdcp_prim[0x27]); + printf("V'.H2: %02x %02x %02x %02x\n", + hdcp_prim[0x28], hdcp_prim[0x29], hdcp_prim[0x2a], hdcp_prim[0x2b]); + printf("V'.H3: %02x %02x %02x %02x\n", + hdcp_prim[0x2c], hdcp_prim[0x2d], hdcp_prim[0x2e], hdcp_prim[0x2f]); + printf("V'.H4: %02x %02x %02x %02x\n", + hdcp_prim[0x30], hdcp_prim[0x31], hdcp_prim[0x32], hdcp_prim[0x33]); + unsigned char v = hdcp_prim[0x40]; + printf("Bcaps: %02x\n", v); + if (v & 0x01) + printf("\tFAST_REAUTHENTICATION\n"); + if (v & 0x02) + printf("\t1.1_FEATURES\n"); + if (v & 0x10) + printf("\tFAST\n"); + if (v & 0x20) + printf("\tREADY\n"); + if (v & 0x40) + printf("\tREPEATER\n"); + unsigned short vv = hdcp_prim[0x41] | (hdcp_prim[0x42] << 8); + printf("Bstatus: %04x\n", vv); + printf("\tDEVICE_COUNT: %u\n", vv & 0x7f); + if (vv & 0x80) + printf("\tMAX_DEVS_EXCEEDED\n"); + printf("\tDEPTH: %u\n", (vv >> 8) & 0x07); + if (vv & 0x800) + printf("\tMAX_CASCADE_EXCEEDED\n"); + if (vv & 0x1000) + printf("\tHDMI_MODE\n"); + if (vv & 0x7f) { + printf("KSV FIFO:\n"); + for (unsigned i = 0; i < (vv & 0x7f); i++) + printf("\t%03u: %02x %02x %02x %02x %02x\n", i, + ksv_fifo[i * 5], ksv_fifo[i * 5 + 1], + ksv_fifo[i * 5 + 2], ksv_fifo[i * 5 + 3], + ksv_fifo[i * 5 + 4]); + } + v = hdcp_prim[0x50]; + printf("HDCP2Version: %02x\n", v); + if (v & 4) + printf("\tHDCP2.2\n"); + vv = hdcp_prim[0x70] | (hdcp_prim[0x71] << 8); + printf("RxStatus: %04x\n", vv); + if (vv & 0x3ff) + printf("\tMessage_Size: %u\n", vv & 0x3ff); + if (vv & 0x400) + printf("\tREADY\n"); + if (vv & 0x800) + printf("\tREAUTH_REQ\n"); + + if (hdcp_sec[5] == 0xdd) + return; + + printf("HDCP Secondary Link:\n\n"); + printf("Bksv: %02x %02x %02x %02x %02x\n", + hdcp_sec[0], hdcp_sec[1], hdcp_sec[2], hdcp_sec[3], hdcp_sec[4]); + printf("Ri': %02x %02x\n", hdcp_sec[9], hdcp_sec[9]); + printf("Pj': %02x\n", hdcp_sec[0x0a]); + printf("Aksv: %02x %02x %02x %02x %02x\n", + hdcp_sec[0x10], hdcp_sec[0x11], hdcp_sec[0x12], hdcp_sec[0x13], hdcp_sec[0x14]); + printf("Ainfo: %02x\n", hdcp_sec[0x15]); + printf("An: %02x %02x %02x %02x %02x %02x %02x %02x\n", + hdcp_sec[0x18], hdcp_sec[0x19], hdcp_sec[0x1a], hdcp_sec[0x1b], + hdcp_sec[0x1c], hdcp_sec[0x1d], hdcp_sec[0x1e], hdcp_sec[0x1f]); +} _______________________________________________ linuxtv-commits mailing list -- [email protected] To unsubscribe send an email to [email protected]
