From 4a6926ea19c64b49e2bdeb30ceef98fc812cc52d Mon Sep 17 00:00:00 2001
From: Jernej Skrabec <jernej.skrabec@gmail.com>
Date: Thu, 19 Sep 2024 20:17:30 +0200
Subject: [PATCH] media: verisilicon: g2: Fix chroma offset calculation

Since bit depth may not be divisible by 8 (like 10 or 12), division must
be rounded up.

Fixes: 3eeaee737dce ("media: verisilicon: g2: Use common helpers to compute chroma and mv offsets")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
---
 drivers/media/platform/verisilicon/hantro_g2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/verisilicon/hantro_g2.c b/drivers/media/platform/verisilicon/hantro_g2.c
index b880a6849d5852..24ae7b69f6a0ae 100644
--- a/drivers/media/platform/verisilicon/hantro_g2.c
+++ b/drivers/media/platform/verisilicon/hantro_g2.c
@@ -47,7 +47,7 @@ irqreturn_t hantro_g2_irq(int irq, void *dev_id)
 
 size_t hantro_g2_chroma_offset(struct hantro_ctx *ctx)
 {
-	return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth / 8;
+	return ctx->dst_fmt.width * ctx->dst_fmt.height * DIV_ROUND_UP(ctx->bit_depth, 8);
 }
 
 size_t hantro_g2_motion_vectors_offset(struct hantro_ctx *ctx)
