[PATCH v2] drm: mxsfb: Implement LCDIF scanout CRC32 support

Marek Vasut marex at denx.de
Fri Apr 29 21:21:54 UTC 2022


On 4/29/22 16:08, Stefan Agner wrote:
> On 2022-04-11 22:35, Marek Vasut wrote:
>> 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.
>>
>> Signed-off-by: Marek Vasut <marex at denx.de>
>> Cc: Alexander Stein <alexander.stein at ew.tq-group.com>
>> Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
>> Cc: Lucas Stach <l.stach at pengutronix.de>
>> Cc: Peng Fan <peng.fan at nxp.com>
>> Cc: Robby Cai <robby.cai at nxp.com>
>> Cc: Sam Ravnborg <sam at ravnborg.org>
>> Cc: Stefan Agner <stefan at agner.ch>
>> ---
>> V2: Check crtc for non-NULL before dereferencing it in mxsfb_crtc_set_crc_source
>> ---
>>   drivers/gpu/drm/mxsfb/mxsfb_drv.c  | 15 +++++++-
>>   drivers/gpu/drm/mxsfb/mxsfb_drv.h  |  3 ++
>>   drivers/gpu/drm/mxsfb/mxsfb_kms.c  | 61 ++++++++++++++++++++++++++++--
>>   drivers/gpu/drm/mxsfb/mxsfb_regs.h |  1 +
>>   4 files changed, 75 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>> b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>> index 94cafff7f68d5..ccf4107476ecc 100644
>> --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>> +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
>> @@ -9,6 +9,7 @@
>>    */
>>   
>>   #include <linux/clk.h>
>> +#include <linux/crc32.h>
> 
> Doesn't look like this is used?

Doh, testing remnant, dropped, thanks.


More information about the dri-devel mailing list