Commit 34253822 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] v4l: vsp1: Fix RPF/WPF U/V order in 3-planar formats on Gen3

The RPF and WPF U/V order bits have no effect for 3-planar formats on
Gen3 hardware. Swap the U and V planes addresses manually instead in
that case.

Fixes: b915bd24 ("[media] v4l: vsp1: Add tri-planar memory formats support")
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent dadc3be6
...@@ -72,7 +72,8 @@ static void rpf_configure(struct vsp1_entity *entity, ...@@ -72,7 +72,8 @@ static void rpf_configure(struct vsp1_entity *entity,
} }
if (params == VSP1_ENTITY_PARAMS_PARTITION) { if (params == VSP1_ENTITY_PARAMS_PARTITION) {
unsigned int offsets[2]; struct vsp1_device *vsp1 = rpf->entity.vsp1;
struct vsp1_rwpf_memory mem = rpf->mem;
struct v4l2_rect crop; struct v4l2_rect crop;
/* /*
...@@ -120,22 +121,30 @@ static void rpf_configure(struct vsp1_entity *entity, ...@@ -120,22 +121,30 @@ static void rpf_configure(struct vsp1_entity *entity,
(crop.width << VI6_RPF_SRC_ESIZE_EHSIZE_SHIFT) | (crop.width << VI6_RPF_SRC_ESIZE_EHSIZE_SHIFT) |
(crop.height << VI6_RPF_SRC_ESIZE_EVSIZE_SHIFT)); (crop.height << VI6_RPF_SRC_ESIZE_EVSIZE_SHIFT));
offsets[0] = crop.top * format->plane_fmt[0].bytesperline mem.addr[0] += crop.top * format->plane_fmt[0].bytesperline
+ crop.left * fmtinfo->bpp[0] / 8; + crop.left * fmtinfo->bpp[0] / 8;
if (format->num_planes > 1) if (format->num_planes > 1) {
offsets[1] = crop.top * format->plane_fmt[1].bytesperline unsigned int offset;
+ crop.left / fmtinfo->hsub
* fmtinfo->bpp[1] / 8; offset = crop.top * format->plane_fmt[1].bytesperline
else + crop.left / fmtinfo->hsub
offsets[1] = 0; * fmtinfo->bpp[1] / 8;
mem.addr[1] += offset;
vsp1_rpf_write(rpf, dl, VI6_RPF_SRCM_ADDR_Y, mem.addr[2] += offset;
rpf->mem.addr[0] + offsets[0]); }
vsp1_rpf_write(rpf, dl, VI6_RPF_SRCM_ADDR_C0,
rpf->mem.addr[1] + offsets[1]); /*
vsp1_rpf_write(rpf, dl, VI6_RPF_SRCM_ADDR_C1, * On Gen3 hardware the SPUVS bit has no effect on 3-planar
rpf->mem.addr[2] + offsets[1]); * formats. Swap the U and V planes manually in that case.
*/
if (vsp1->info->gen == 3 && format->num_planes == 3 &&
fmtinfo->swap_uv)
swap(mem.addr[1], mem.addr[2]);
vsp1_rpf_write(rpf, dl, VI6_RPF_SRCM_ADDR_Y, mem.addr[0]);
vsp1_rpf_write(rpf, dl, VI6_RPF_SRCM_ADDR_C0, mem.addr[1]);
vsp1_rpf_write(rpf, dl, VI6_RPF_SRCM_ADDR_C1, mem.addr[2]);
return; return;
} }
......
...@@ -216,6 +216,7 @@ static void wpf_configure(struct vsp1_entity *entity, ...@@ -216,6 +216,7 @@ static void wpf_configure(struct vsp1_entity *entity,
if (params == VSP1_ENTITY_PARAMS_PARTITION) { if (params == VSP1_ENTITY_PARAMS_PARTITION) {
const struct v4l2_pix_format_mplane *format = &wpf->format; const struct v4l2_pix_format_mplane *format = &wpf->format;
const struct vsp1_format_info *fmtinfo = wpf->fmtinfo;
struct vsp1_rwpf_memory mem = wpf->mem; struct vsp1_rwpf_memory mem = wpf->mem;
unsigned int flip = wpf->flip.active; unsigned int flip = wpf->flip.active;
unsigned int width = source_format->width; unsigned int width = source_format->width;
...@@ -281,6 +282,14 @@ static void wpf_configure(struct vsp1_entity *entity, ...@@ -281,6 +282,14 @@ static void wpf_configure(struct vsp1_entity *entity,
} }
} }
/*
* On Gen3 hardware the SPUVS bit has no effect on 3-planar
* formats. Swap the U and V planes manually in that case.
*/
if (vsp1->info->gen == 3 && format->num_planes == 3 &&
fmtinfo->swap_uv)
swap(mem.addr[1], mem.addr[2]);
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_Y, mem.addr[0]); vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_Y, mem.addr[0]);
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_C0, mem.addr[1]); vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_C0, mem.addr[1]);
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_C1, mem.addr[2]); vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_C1, mem.addr[2]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment