The HDMI specification defines the SPD InfoFrame Vendor Name and
Product Description as fixed-size fields of 8 and 16 bytes
respectively.
Add defines for those lengths and use them in place of the related
magic numbers, including the payload offsets and the log format
precisions. While at it, fix the continuation line alignment in
hdmi_spd_infoframe_log().
No functional change intended.
Signed-off-by: Cristian Ciocaltea <redacted>
---
drivers/video/hdmi.c | 20 +++++++++++++-------
include/linux/hdmi.h | 7 +++++--
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index cd18121afa20..7eeadac2de69 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -304,9 +304,11 @@ ssize_t hdmi_spd_infoframe_pack_only(const struct hdmi_spd_infoframe *frame,
ptr += HDMI_INFOFRAME_HEADER_SIZE;
memcpy(ptr, frame->vendor, sizeof(frame->vendor));
- memcpy(ptr + 8, frame->product, sizeof(frame->product));
+ memcpy(ptr + HDMI_SPD_INFOFRAME_VENDOR_LEN, frame->product,
+ sizeof(frame->product));
- ptr[24] = frame->sdi;
+ ptr[HDMI_SPD_INFOFRAME_VENDOR_LEN + HDMI_SPD_INFOFRAME_PRODUCT_LEN] =
+ frame->sdi;
hdmi_infoframe_set_checksum(buffer, length);
@@ -1284,10 +1286,12 @@ static void hdmi_spd_infoframe_log(const char *level,
hdmi_infoframe_log_header(level, dev,
(const struct hdmi_any_infoframe *)frame);
- hdmi_log(" vendor: %.8s\n", frame->vendor);
- hdmi_log(" product: %.16s\n", frame->product);
+ hdmi_log(" vendor: %.*s\n", HDMI_SPD_INFOFRAME_VENDOR_LEN,
+ frame->vendor);
+ hdmi_log(" product: %.*s\n", HDMI_SPD_INFOFRAME_PRODUCT_LEN,
+ frame->product);
hdmi_log(" source device information: %s (0x%x)\n",
- hdmi_spd_sdi_get_name(frame->sdi), frame->sdi);
+ hdmi_spd_sdi_get_name(frame->sdi), frame->sdi);
}
static const char *@@ -1642,11 +1646,13 @@ static int hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame,
ptr += HDMI_INFOFRAME_HEADER_SIZE;
- ret = hdmi_spd_infoframe_init(frame, ptr, ptr + 8);
+ ret = hdmi_spd_infoframe_init(frame, ptr,
+ ptr + HDMI_SPD_INFOFRAME_VENDOR_LEN);
if (ret)
return ret;
- frame->sdi = ptr[24];
+ frame->sdi = ptr[HDMI_SPD_INFOFRAME_VENDOR_LEN +
+ HDMI_SPD_INFOFRAME_PRODUCT_LEN];
return 0;
}
diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h
index 08922d5330d6..7d96821b486d 100644
--- a/include/linux/hdmi.h
+++ b/include/linux/hdmi.h
@@ -267,12 +267,15 @@ enum hdmi_spd_sdi {
HDMI_SPD_SDI_PMP,
};
+#define HDMI_SPD_INFOFRAME_VENDOR_LEN 8
+#define HDMI_SPD_INFOFRAME_PRODUCT_LEN 16
+
struct hdmi_spd_infoframe {
enum hdmi_infoframe_type type;
unsigned char version;
unsigned char length;
- char vendor[8] __nonstring;
- char product[16] __nonstring;
+ char vendor[HDMI_SPD_INFOFRAME_VENDOR_LEN] __nonstring;
+ char product[HDMI_SPD_INFOFRAME_PRODUCT_LEN] __nonstring;
enum hdmi_spd_sdi sdi;
};
--
2.56.0