media: hantro: HEVC: Fix auxilary buffer size calculation
authorBenjamin Gaignard <benjamin.gaignard@collabora.com>
Mon, 29 Aug 2022 16:21:54 +0000 (18:21 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 24 Sep 2022 06:58:12 +0000 (08:58 +0200)
SAO and FILTER buffers size depend of the bit depth.
Make sure we have enough space for 10bit bitstreams.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/verisilicon/hantro_hevc.c

index b990bc9..9383fb7 100644 (file)
@@ -104,7 +104,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
                hevc_dec->tile_bsd.cpu = NULL;
        }
 
-       size = VERT_FILTER_RAM_SIZE * height64 * (num_tile_cols - 1);
+       size = (VERT_FILTER_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bit_depth) / 8;
        hevc_dec->tile_filter.cpu = dma_alloc_coherent(vpu->dev, size,
                                                       &hevc_dec->tile_filter.dma,
                                                       GFP_KERNEL);
@@ -112,7 +112,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
                goto err_free_tile_buffers;
        hevc_dec->tile_filter.size = size;
 
-       size = VERT_SAO_RAM_SIZE * height64 * (num_tile_cols - 1);
+       size = (VERT_SAO_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bit_depth) / 8;
        hevc_dec->tile_sao.cpu = dma_alloc_coherent(vpu->dev, size,
                                                    &hevc_dec->tile_sao.dma,
                                                    GFP_KERNEL);