• Marek Vasut's avatar
    drm: mxsfb: Implement LCDIF scanout CRC32 support · 05ecc678
    Marek Vasut authored
    The LCDIF controller as present in i.MX28/i.MX6SX/i.MX8M Mini/Nano has
    CRC_STAT register, which contains CRC32 of the frame as it was clocked
    out of the DPI interface of the LCDIF. This is most likely meant as a
    functional safety feature.
    
    Unfortunately, there is zero documentation on how the CRC32 is calculated,
    there is no documentation of the polynomial, the init value, nor on which
    data is the checksum applied.
    
    By applying brute-force on 8 pixel / 2 line frame, which is the minimum
    size LCDIF would work with, it turns out the polynomial is CRC32_POLY_LE
    0xedb88320 , init value is 0xffffffff , the input data are bitrev32()
    of the entire frame and the resulting CRC has to be also bitrev32()ed.
    
    Doing this calculation in kernel for each frame is unrealistic due to the
    CPU demand, so attach the CRC collected from hardware to a frame instead.
    The DRM subsystem already has an interface for this purpose and the CRC
    can be accessed e.g. via debugfs:
    "
    $ echo auto > /sys/kernel/debug/dri/1/crtc-0/crc/control
    $ cat /sys/kernel/debug/dri/1/crtc-0/crc/data
    0x0000408c 0xa4e5cdd8
    0x0000408d 0x72f537b4
    "
    The per-frame CRC can be used by userspace e.g. during automated testing,
    to verify that whatever buffer was sent to be scanned out was actually
    scanned out of the LCDIF correctly.
    Acked-by: default avatarLucas Stach <l.stach@pengutronix.de>
    Acked-by: default avatarStefan Agner <stefan@agner.ch>
    Signed-off-by: default avatarMarek Vasut <marex@denx.de>
    Cc: Alexander Stein <alexander.stein@ew.tq-group.com>
    Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Cc: Lucas Stach <l.stach@pengutronix.de>
    Cc: Peng Fan <peng.fan@nxp.com>
    Cc: Robby Cai <robby.cai@nxp.com>
    Cc: Sam Ravnborg <sam@ravnborg.org>
    Cc: Stefan Agner <stefan@agner.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220429212313.305556-1-marex@denx.de
    05ecc678
mxsfb_kms.c 21 KB