From: Eric Anholt <eric@anholt.net>
To: Hans Verkuil <hverkuil@xs4all.nl>, linux-media@vger.kernel.org
Cc: Hans Verkuil <hans.verkuil@cisco.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 4/4] drm/vc4: add HDMI CEC support
Date: Tue, 18 Jul 2017 15:03:55 -0700 [thread overview]
Message-ID: <87vampjtbo.fsf@eliezer.anholt.net> (raw)
In-Reply-To: <e8289d89-bfd5-d964-2b9a-2d36394ce868@xs4all.nl>
[-- Attachment #1: Type: text/plain, Size: 2059 bytes --]
Hans Verkuil <hverkuil@xs4all.nl> writes:
> On 12/07/17 21:43, Hans Verkuil wrote:
>> On 12/07/17 21:02, Eric Anholt wrote:
>>>> +static int vc4_hdmi_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
>>>> + u32 signal_free_time, struct cec_msg *msg)
>>>> +{
>>>> + struct vc4_dev *vc4 = cec_get_drvdata(adap);
>>>> + u32 val;
>>>> + unsigned int i;
>>>> +
>>>> + for (i = 0; i < msg->len; i += 4)
>>>> + HDMI_WRITE(VC4_HDMI_CEC_TX_DATA_1 + i,
>>>> + (msg->msg[i]) |
>>>> + (msg->msg[i + 1] << 8) |
>>>> + (msg->msg[i + 2] << 16) |
>>>> + (msg->msg[i + 3] << 24));
>>>> +
>>>> + val = HDMI_READ(VC4_HDMI_CEC_CNTRL_1);
>>>> + val &= ~VC4_HDMI_CEC_START_XMIT_BEGIN;
>>>> + HDMI_WRITE(VC4_HDMI_CEC_CNTRL_1, val);
>>>> + val &= ~VC4_HDMI_CEC_MESSAGE_LENGTH_MASK;
>>>> + val |= (msg->len - 1) << VC4_HDMI_CEC_MESSAGE_LENGTH_SHIFT;
>>>> + val |= VC4_HDMI_CEC_START_XMIT_BEGIN;
>>>
>>> It doesn't look to me like len should have 1 subtracted from it. The
>>> field has 4 bits for our up-to-16-byte length, and the firmware seems to
>>> be setting it to the same value as a memcpy for the message data uses.
>>
>> You need to subtract by one. The CEC protocol supports messages of 1-16
>> bytes in length. Since the message length mask is only 4 bits you need to
>> encode this in the value 0-15. Hence the '-1', otherwise you would never
>> be able to send 16 byte messages.
>>
>> I actually found this when debugging the messages it was transmitting: they
>> were one too long.
>>
>> This suggests that the firmware does this wrong. I don't have time tomorrow,
>> but I'll see if I can do a quick test on Friday to verify that.
>
> I double-checked this and both the driver and the firmware do the right thing.
> Just to be certain I also tried sending a message that uses the full 16 byte
> payload and that too went well. So the code is definitely correct.
Great, I'll assume that I just missed the subtraction somewhere in the
layers of firmware code. Thanks for checking!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
prev parent reply other threads:[~2017-07-18 22:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-11 11:20 [PATCH 0/4] drm/vc4: add HDMI CEC support Hans Verkuil
2017-07-11 11:20 ` [PATCH 1/4] cec: be smarter about detecting the number of attempts made Hans Verkuil
2017-07-11 11:20 ` [PATCH 2/4] drm/vc4: prepare for CEC support Hans Verkuil
2017-07-12 18:42 ` Eric Anholt
2017-07-12 19:30 ` Hans Verkuil
2017-07-11 11:20 ` [PATCH 3/4] drm/vc4: Add register defines for CEC Hans Verkuil
2017-07-12 18:33 ` Eric Anholt
2017-07-11 11:20 ` [PATCH 4/4] drm/vc4: add HDMI CEC support Hans Verkuil
2017-07-12 19:02 ` Eric Anholt
2017-07-12 19:43 ` Hans Verkuil
2017-07-16 10:46 ` Hans Verkuil
2017-07-18 22:03 ` Eric Anholt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vampjtbo.fsf@eliezer.anholt.net \
--to=eric@anholt.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).