Message ID | 20190426012223.17826-14-andrealmeid@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: vimc: Add support for multiplanar formats | expand |
On 4/25/19 10:22 PM, André Almeida wrote: > Adapt vimc-capture to support multiplanar formats, copying > each plane to the correct buffer. > > Signed-off-by: André Almeida <andrealmeid@collabora.com> Acked-by: Helen Koike <helen.koike@collabora.com> > --- > Change in v4: > - Move variables to inside the for loop > - Change `plane_size` type from `unsigned int` to `size_t` > > Change in v3: > - Adapt to new vimc_frame > > Change in v2: none > > drivers/media/platform/vimc/vimc-capture.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c > index d9dae5b3a0bf..932d622d56ca 100644 > --- a/drivers/media/platform/vimc/vimc-capture.c > +++ b/drivers/media/platform/vimc/vimc-capture.c > @@ -523,7 +523,7 @@ static struct vimc_frame *vimc_cap_process_frame(struct vimc_ent_device *ved, > struct vimc_cap_device *vcap = container_of(ved, struct vimc_cap_device, > ved); > struct vimc_cap_buffer *vimc_buf; > - void *vbuf; > + unsigned int i; > > spin_lock(&vcap->qlock); > > @@ -545,13 +545,17 @@ static struct vimc_frame *vimc_cap_process_frame(struct vimc_ent_device *ved, > vimc_buf->vb2.sequence = vcap->sequence++; > vimc_buf->vb2.field = vcap->format.fmt.pix.field; > > - vbuf = vb2_plane_vaddr(&vimc_buf->vb2.vb2_buf, 0); > + /* For each plane, copy the pixels */ > + for (i = 0; i < vimc_buf->vb2.vb2_buf.num_planes; i++) { > + void *vbuf = vb2_plane_vaddr(&vimc_buf->vb2.vb2_buf, i); > + size_t plane_size = frame->fmt.plane_fmt[i].sizeimage; > + > + memcpy(vbuf, frame->plane_addr[i], plane_size); > > - memcpy(vbuf, frame->plane_addr[0], vcap->format.fmt.pix.sizeimage); > + /* Set it as ready */ > + vb2_set_plane_payload(&vimc_buf->vb2.vb2_buf, i, plane_size); > + } > > - /* Set it as ready */ > - vb2_set_plane_payload(&vimc_buf->vb2.vb2_buf, 0, > - vcap->format.fmt.pix.sizeimage); > vb2_buffer_done(&vimc_buf->vb2.vb2_buf, VB2_BUF_STATE_DONE); > return NULL; > } >
diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c index d9dae5b3a0bf..932d622d56ca 100644 --- a/drivers/media/platform/vimc/vimc-capture.c +++ b/drivers/media/platform/vimc/vimc-capture.c @@ -523,7 +523,7 @@ static struct vimc_frame *vimc_cap_process_frame(struct vimc_ent_device *ved, struct vimc_cap_device *vcap = container_of(ved, struct vimc_cap_device, ved); struct vimc_cap_buffer *vimc_buf; - void *vbuf; + unsigned int i; spin_lock(&vcap->qlock); @@ -545,13 +545,17 @@ static struct vimc_frame *vimc_cap_process_frame(struct vimc_ent_device *ved, vimc_buf->vb2.sequence = vcap->sequence++; vimc_buf->vb2.field = vcap->format.fmt.pix.field; - vbuf = vb2_plane_vaddr(&vimc_buf->vb2.vb2_buf, 0); + /* For each plane, copy the pixels */ + for (i = 0; i < vimc_buf->vb2.vb2_buf.num_planes; i++) { + void *vbuf = vb2_plane_vaddr(&vimc_buf->vb2.vb2_buf, i); + size_t plane_size = frame->fmt.plane_fmt[i].sizeimage; + + memcpy(vbuf, frame->plane_addr[i], plane_size); - memcpy(vbuf, frame->plane_addr[0], vcap->format.fmt.pix.sizeimage); + /* Set it as ready */ + vb2_set_plane_payload(&vimc_buf->vb2.vb2_buf, i, plane_size); + } - /* Set it as ready */ - vb2_set_plane_payload(&vimc_buf->vb2.vb2_buf, 0, - vcap->format.fmt.pix.sizeimage); vb2_buffer_done(&vimc_buf->vb2.vb2_buf, VB2_BUF_STATE_DONE); return NULL; }
Adapt vimc-capture to support multiplanar formats, copying each plane to the correct buffer. Signed-off-by: André Almeida <andrealmeid@collabora.com> --- Change in v4: - Move variables to inside the for loop - Change `plane_size` type from `unsigned int` to `size_t` Change in v3: - Adapt to new vimc_frame Change in v2: none drivers/media/platform/vimc/vimc-capture.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)