• Alvin Šipraga's avatar
    drm: bridge: adv7511: use non-legacy mode for CEC RX · ab0af093
    Alvin Šipraga authored
    The ADV7511 family of bridges supports two modes for CEC RX: legacy and
    non-legacy mode. The only difference is whether the chip uses a single
    CEC RX buffer, or uses all three available RX buffers. Currently the
    adv7511 driver uses legacy mode.
    
    While debugging a stall in CEC RX on an ADV7535, we reached out to
    Analog Devices, who suggested to use non-legacy mode instead.  According
    to the programming guide for the ADV7511 [1], and the register control
    manual of the ADV7535 [2], this is the default behaviour on reset. As
    previously stated, the adv7511 driver currently overrides this to legacy
    mode.
    
    This patch updates the adv7511 driver to instead use non-legacy mode
    with all three CEC RX buffers. As a result of this change, we no longer
    experience any stalling of CEC RX with the ADV7535. It is not known why
    non-legacy mode solves this particular issue, but besides this, no
    functional change is to be expected by this patch. Please note that this
    has only been tested on an ADV7535.
    
    What follows is a brief description of the non-legacy mode interrupt
    handling behaviour. The programming guide in [1] gives a more detailed
    explanation.
    
    With three RX buffers, the interrupt handler checks the CEC_RX_STATUS
    register (renamed from CEC_RX_ENABLE in this patch), which contains
    2-bit psuedo-timestamps for each of the RX buffers. The RX timestamps
    for each buffer represent the time of arrival for the CEC frame held in
    a given buffer, with lower timestamp values indicating chronologically
    older frames. A special value of 0 indicates that the given RX buffer
    is inactive and should be skipped. The interrupt handler parses these
    timestamps and then reads the active RX buffers in the prescribed order
    using the same logic as before. Changes have been made to ensure that
    the correct RX buffer is cleared after processing. This clearing
    procesure also sets the timestamp of the given RX buffer to 0 to mark it
    as inactive.
    
    [1] https://www.analog.com/media/en/technical-documentation/user-guides/ADV7511_Programming_Guide.pdf
        cf. CEC Map, register 0x4A, bit 3, default value 1:
        0 = Use only buffer 0 to store CEC frames (Legacy mode)
        1 = Use all 3 buffers to stores the CEC frames (Non-legacy mode)
    
    [2] The ADV7535 register control manual is under NDA, but trust me when
        I say that non-legacy CEC RX mode is the default here too. Here the
        register is offset by 0x70 and has an address of 0xBA in the DSI_CEC
        regiser map.
    Signed-off-by: default avatarAlvin Šipraga <alsi@bang-olufsen.dk>
    Reviewed-by: default avatarRobert Foss <robert.foss@linaro.org>
    Signed-off-by: default avatarRobert Foss <robert.foss@linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220423120854.1503163-3-alvin@pqrs.dk
    ab0af093
adv7511_cec.c 10.3 KB