Commit e9120e76 authored by Jernej Skrabec's avatar Jernej Skrabec Committed by Hans Verkuil

media: cedrus: hevc: Fix offset adjustments

As it turns out, current padding size check works fine in theory but it
doesn't in practice. Most probable reason are caching issues.

Let's rework reading data from bitstream using Cedrus engine instead of
CPU. That way we avoid all cache issues and make sure that we're reading
same data as Cedrus.

Fixes: e7060d9a ("media: uapi: Change data_bit_offset definition")
Signed-off-by: default avatarJernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent c558f69c
...@@ -242,6 +242,18 @@ static void cedrus_h265_skip_bits(struct cedrus_dev *dev, int num) ...@@ -242,6 +242,18 @@ static void cedrus_h265_skip_bits(struct cedrus_dev *dev, int num)
} }
} }
static u32 cedrus_h265_show_bits(struct cedrus_dev *dev, int num)
{
cedrus_write(dev, VE_DEC_H265_TRIGGER,
VE_DEC_H265_TRIGGER_SHOW_BITS |
VE_DEC_H265_TRIGGER_TYPE_N_BITS(num));
cedrus_wait_for(dev, VE_DEC_H265_STATUS,
VE_DEC_H265_STATUS_VLD_BUSY);
return cedrus_read(dev, VE_DEC_H265_BITS_READ);
}
static void cedrus_h265_write_scaling_list(struct cedrus_ctx *ctx, static void cedrus_h265_write_scaling_list(struct cedrus_ctx *ctx,
struct cedrus_run *run) struct cedrus_run *run)
{ {
...@@ -406,7 +418,7 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) ...@@ -406,7 +418,7 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)
u32 num_entry_point_offsets; u32 num_entry_point_offsets;
u32 output_pic_list_index; u32 output_pic_list_index;
u32 pic_order_cnt[2]; u32 pic_order_cnt[2];
u8 *padding; u8 padding;
int count; int count;
u32 reg; u32 reg;
...@@ -520,21 +532,22 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) ...@@ -520,21 +532,22 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)
if (slice_params->data_byte_offset == 0) if (slice_params->data_byte_offset == 0)
return -EOPNOTSUPP; return -EOPNOTSUPP;
padding = (u8 *)vb2_plane_vaddr(&run->src->vb2_buf, 0) + cedrus_h265_skip_bits(dev, (slice_params->data_byte_offset - 1) * 8);
slice_params->data_byte_offset - 1;
padding = cedrus_h265_show_bits(dev, 8);
/* at least one bit must be set in that byte */ /* at least one bit must be set in that byte */
if (*padding == 0) if (padding == 0)
return -EINVAL; return -EINVAL;
for (count = 0; count < 8; count++) for (count = 0; count < 8; count++)
if (*padding & (1 << count)) if (padding & (1 << count))
break; break;
/* Include the one bit. */ /* Include the one bit. */
count++; count++;
cedrus_h265_skip_bits(dev, slice_params->data_byte_offset * 8 - count); cedrus_h265_skip_bits(dev, 8 - count);
/* Bitstream parameters. */ /* Bitstream parameters. */
......
...@@ -505,6 +505,8 @@ ...@@ -505,6 +505,8 @@
#define VE_DEC_H265_LOW_ADDR_ENTRY_POINTS_BUF(a) \ #define VE_DEC_H265_LOW_ADDR_ENTRY_POINTS_BUF(a) \
SHIFT_AND_MASK_BITS(a, 7, 0) SHIFT_AND_MASK_BITS(a, 7, 0)
#define VE_DEC_H265_BITS_READ (VE_ENGINE_DEC_H265 + 0xdc)
#define VE_DEC_H265_SRAM_OFFSET (VE_ENGINE_DEC_H265 + 0xe0) #define VE_DEC_H265_SRAM_OFFSET (VE_ENGINE_DEC_H265 + 0xe0)
#define VE_DEC_H265_SRAM_OFFSET_PRED_WEIGHT_LUMA_L0 0x00 #define VE_DEC_H265_SRAM_OFFSET_PRED_WEIGHT_LUMA_L0 0x00
......
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