Skip to content

Commit 4329847

Browse files
CyrillePitchencristibirsan
authored andcommitted
drm: atmel-hlcdc: fix atmel_xlcdc_plane_setup_scaler()
On SoCs, like the SAM9X75, which embed the XLCDC ip, the registers that configure the unified scaling engine were not filled with proper values. Indeed, for YCbCr formats, the VXSCFACT bitfield of the HEOCFG25 register and the HXSCFACT bitfield of the HEOCFG27 register were incorrect. For 4:2:0 formats, both vertical and horizontal factors for chroma chanels should be divided by 2 from the factors for the luma channel. Hence: HEOCFG24.VXSYFACT = VFACTOR HEOCFG25.VSXCFACT = VFACTOR / 2 HEOCFG26.HXSYFACT = HFACTOR HEOCFG27.HXSCFACT = HFACTOR / 2 However, for 4:2:2 formats, only the horizontal factor for chroma chanels should be divided by 2 from the factor for the luma channel; the vertical factor is the same for all the luma and chroma channels. Hence: HEOCFG24.VXSYFACT = VFACTOR HEOCFG25.VXSCFACT = VFACTOR HEOCFG26.HXSYFACT = HFACTOR HEOCFG27.HXSCFACT = HFACTOR / 2 Signed-off-by: Cyrille Pitchen <cyrille.pitchen@microchip.com>
1 parent afde659 commit 4329847

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,34 @@ void atmel_xlcdc_plane_setup_scaler(struct atmel_hlcdc_plane *plane,
365365
xfactor);
366366

367367
/*
368-
* With YCbCr 4:2:2 and YCbYcr 4:2:0 window resampling, configuration
369-
* register LCDC_HEOCFG25.VXSCFACT and LCDC_HEOCFG27.HXSCFACT is half
368+
* With YCbCr 4:2:0 window resampling, configuration register
369+
* LCDC_HEOCFG25.VXSCFACT and LCDC_HEOCFG27.HXSCFACT values are half
370370
* the value of yfactor and xfactor.
371+
*
372+
* On the other hand, with YCbCr 4:2:2 window resampling, only the
373+
* configuration register LCDC_HEOCFG27.HXSCFACT value is half the value
374+
* of the xfactor; the value of LCDC_HEOCFG25.VXSCFACT is yfactor (no
375+
* division by 2).
371376
*/
372-
if (state->base.fb->format->format == DRM_FORMAT_YUV420) {
377+
switch (state->base.fb->format->format) {
378+
/* YCbCr 4:2:2 */
379+
case DRM_FORMAT_YUYV:
380+
case DRM_FORMAT_UYVY:
381+
case DRM_FORMAT_YVYU:
382+
case DRM_FORMAT_VYUY:
383+
case DRM_FORMAT_YUV422:
384+
case DRM_FORMAT_NV61:
385+
xfactor /= 2;
386+
break;
387+
388+
/* YCbCr 4:2:0 */
389+
case DRM_FORMAT_YUV420:
390+
case DRM_FORMAT_NV21:
373391
yfactor /= 2;
374392
xfactor /= 2;
393+
break;
394+
default:
395+
break;
375396
}
376397

377398
atmel_hlcdc_layer_write_cfg(&plane->layer, desc->layout.scaler_config + 2,

0 commit comments

Comments
 (0)