From: Chris Zhong <hidden> Date: 2017-07-18 11:21:00
The DP is using the same audio infoframe payload as hdmi, per DP 1.3
spec, but it has a different header. Provide a new interface here,
it just packs the payload.
Signed-off-by: Chris Zhong <redacted>
---
Changes in v2: None
drivers/video/hdmi.c | 66 ++++++++++++++++++++++++++++++++++++++--------------
include/linux/hdmi.h | 3 ++-
2 files changed, 50 insertions(+), 19 deletions(-)
From: Doug Anderson <dianders@chromium.org> Date: 2017-07-18 15:16:11
Hi,
On Tue, Jul 18, 2017 at 4:20 AM, Chris Zhong [off-list ref] wrote:
quoted hunk
The DP is using the same audio infoframe payload as hdmi, per DP 1.3
spec, but it has a different header. Provide a new interface here,
it just packs the payload.
Signed-off-by: Chris Zhong <redacted>
---
Changes in v2: None
drivers/video/hdmi.c | 66 ++++++++++++++++++++++++++++++++++++++--------------
include/linux/hdmi.h | 3 ++-
2 files changed, 50 insertions(+), 19 deletions(-)
@@ -240,6 +240,49 @@ int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame)EXPORT_SYMBOL(hdmi_audio_infoframe_init);/**+*hdmi_audio_infoframe_pack_payload()-writeHDMIaudioinfoframepayloadto+*binarybuffer+*@frame:HDMIaudioinfoframe+*@buffer:destinationbuffer+*@size:sizeofbuffer+*+*Packstheinformationcontainedinthe@framestructureintoabinary+*representationthatcanbewrittenintothecorrespondingcontroller+*registers.+*+*Returns0onsuccessoranegativeerrorcodeonfailure.+*/+ssize_thdmi_audio_infoframe_pack_payload(structhdmi_audio_infoframe*frame,+void*buffer,size_tsize)+{+unsignedcharchannels;+u8*ptr=buffer;++if(size<frame->length)
You also need to return -ENOSPC if (size < 5). That's because below
you always write 5 elements into this array. I'll leave it to someone
with actual DRM experience to say whether they want a #define of some
sort here. Probably they do since someone made a #define for
"HDMI_INFOFRAME_HEADER_SIZE".
Also: you don't use frame->length anywhere in this function and it
doesn't seem to be related with packing the payload. Seems like you
shouldn't check it here.
+ return -ENOSPC;
+
+ memset(buffer, 0, size);
I don't think the memset belongs here. It seems like all this
function is doing is setting up ptr[0] through ptr[4] and the memset()
doesn't belong with that, does it?
From: Chris Zhong <hidden> Date: 2017-07-19 00:49:13
Hi Doug
On Tuesday, July 18, 2017 11:16 PM, Doug Anderson wrote:
Hi,
On Tue, Jul 18, 2017 at 4:20 AM, Chris Zhong [off-list ref] wrote:
quoted
The DP is using the same audio infoframe payload as hdmi, per DP 1.3
spec, but it has a different header. Provide a new interface here,
it just packs the payload.
Signed-off-by: Chris Zhong <redacted>
---
Changes in v2: None
drivers/video/hdmi.c | 66 ++++++++++++++++++++++++++++++++++++++--------------
include/linux/hdmi.h | 3 ++-
2 files changed, 50 insertions(+), 19 deletions(-)
@@ -240,6 +240,49 @@ int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame)EXPORT_SYMBOL(hdmi_audio_infoframe_init);/**+*hdmi_audio_infoframe_pack_payload()-writeHDMIaudioinfoframepayloadto+*binarybuffer+*@frame:HDMIaudioinfoframe+*@buffer:destinationbuffer+*@size:sizeofbuffer+*+*Packstheinformationcontainedinthe@framestructureintoabinary+*representationthatcanbewrittenintothecorrespondingcontroller+*registers.+*+*Returns0onsuccessoranegativeerrorcodeonfailure.+*/+ssize_thdmi_audio_infoframe_pack_payload(structhdmi_audio_infoframe*frame,+void*buffer,size_tsize)+{+unsignedcharchannels;+u8*ptr=buffer;++if(size<frame->length)
You also need to return -ENOSPC if (size < 5). That's because below
you always write 5 elements into this array. I'll leave it to someone
with actual DRM experience to say whether they want a #define of some
sort here. Probably they do since someone made a #define for
"HDMI_INFOFRAME_HEADER_SIZE".
Also: you don't use frame->length anywhere in this function and it
doesn't seem to be related with packing the payload. Seems like you
shouldn't check it here.
Actually, I think it should be "if (size < HDMI_AUDIO_INFOFRAME_SIZE)"
quoted
+ return -ENOSPC;
+
+ memset(buffer, 0, size);
I don't think the memset belongs here. It seems like all this
function is doing is setting up ptr[0] through ptr[4] and the memset()
doesn't belong with that, does it?
I think the length of payload is 10 Bytes(DB1~DB10), per audio infoframe
Format,
but we only use the front 5 Bytes, the back 5 bytes must be 0. If we
take the 10
bytes as a whole, it make sense.
From: Doug Anderson <dianders@chromium.org> Date: 2017-07-19 17:27:11
Hi
On Tue, Jul 18, 2017 at 5:49 PM, Chris Zhong [off-list ref] wrote:
Hi Doug
On Tuesday, July 18, 2017 11:16 PM, Doug Anderson wrote:
quoted
Hi,
On Tue, Jul 18, 2017 at 4:20 AM, Chris Zhong [off-list ref] wrote:
quoted
The DP is using the same audio infoframe payload as hdmi, per DP 1.3
spec, but it has a different header. Provide a new interface here,
it just packs the payload.
Signed-off-by: Chris Zhong <redacted>
---
Changes in v2: None
drivers/video/hdmi.c | 66
++++++++++++++++++++++++++++++++++++++--------------
include/linux/hdmi.h | 3 ++-
2 files changed, 50 insertions(+), 19 deletions(-)
@@ -240,6 +240,49 @@ int hdmi_audio_infoframe_init(struct
hdmi_audio_infoframe *frame)
EXPORT_SYMBOL(hdmi_audio_infoframe_init);
/**
+ * hdmi_audio_infoframe_pack_payload() - write HDMI audio infoframe
payload to
+ * binary buffer
+ * @frame: HDMI audio infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Packs the information contained in the @frame structure into a binary
+ * representation that can be written into the corresponding controller
+ * registers.
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+ssize_t hdmi_audio_infoframe_pack_payload(struct hdmi_audio_infoframe
*frame,
+ void *buffer, size_t size)
+{
+ unsigned char channels;
+ u8 *ptr = buffer;
+
+ if (size < frame->length)
You also need to return -ENOSPC if (size < 5). That's because below
you always write 5 elements into this array. I'll leave it to someone
with actual DRM experience to say whether they want a #define of some
sort here. Probably they do since someone made a #define for
"HDMI_INFOFRAME_HEADER_SIZE".
Also: you don't use frame->length anywhere in this function and it
doesn't seem to be related with packing the payload. Seems like you
shouldn't check it here.
Actually, I think it should be "if (size < HDMI_AUDIO_INFOFRAME_SIZE)"
Ah, OK. My main point was that this function needed to make sense on
its own. ...and the function in your patch writes to [0] through [4]
without actually confirming that there are at least 5 elements. I'd
be OK with:
if ((size < frame->length || size < HDMI_AUDIO_INFOFRAME_SIZE)
quoted
quoted
+ return -ENOSPC;
+
+ memset(buffer, 0, size);
I don't think the memset belongs here. It seems like all this
function is doing is setting up ptr[0] through ptr[4] and the memset()
doesn't belong with that, does it?
I think the length of payload is 10 Bytes(DB1~DB10), per audio infoframe
Format,
but we only use the front 5 Bytes, the back 5 bytes must be 0. If we take
the 10
bytes as a whole, it make sense.
OK, memset() here makes sense with what you say about the frame
needing to be 10 bytes big.
-Doug