summaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel@collabora.com>2020-07-01 15:16:05 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-07-19 13:25:22 +0200
commite765dba11ec26d7ea42974ec4d470b5ce00be3de (patch)
tree2a1329c8dff5f4a0a5b1791d9fbd1ca0bcfea9ad /drivers/staging/media/hantro/hantro_h1_jpeg_enc.c
parent21f0315b7b3ee6ca909d81a963744671fb27bf71 (diff)
downloadlinux-e765dba11ec26d7ea42974ec4d470b5ce00be3de.tar.bz2
hantro: Move hantro_enc_buf_finish to JPEG codec_ops.done
hantro_enc_buf_finish is used only for JPEG, and so should be moved to JPEG codec_ops.done. This cleanup is also taking care of addressing a subtle issue: checking the non-NULL bounce buffer using ctx->jpeg_enc, which is a member of a union is confusing and error-prone. Note that the issue is currently innocuous because an encoder context only supports JPEG. The codec_ops.done has an argument that codec-specific code shouldn't need, so drop that as well. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/staging/media/hantro/hantro_h1_jpeg_enc.c')
-rw-r--r--drivers/staging/media/hantro/hantro_h1_jpeg_enc.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c b/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c
index b22418436823..b88dc4ed06db 100644
--- a/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c
+++ b/drivers/staging/media/hantro/hantro_h1_jpeg_enc.c
@@ -137,3 +137,20 @@ void hantro_h1_jpeg_enc_run(struct hantro_ctx *ctx)
vepu_write(vpu, reg, H1_REG_ENC_CTRL);
}
+
+void hantro_jpeg_enc_done(struct hantro_ctx *ctx)
+{
+ struct hantro_dev *vpu = ctx->dev;
+ u32 bytesused = vepu_read(vpu, H1_REG_STR_BUF_LIMIT) / 8;
+ struct vb2_v4l2_buffer *dst_buf = hantro_get_dst_buf(ctx);
+
+ /*
+ * TODO: Rework the JPEG encoder to eliminate the need
+ * for a bounce buffer.
+ */
+ memcpy(vb2_plane_vaddr(&dst_buf->vb2_buf, 0) +
+ ctx->vpu_dst_fmt->header_size,
+ ctx->jpeg_enc.bounce_buffer.cpu, bytesused);
+ vb2_set_plane_payload(&dst_buf->vb2_buf, 0,
+ ctx->vpu_dst_fmt->header_size + bytesused);
+}