media: cedrus: identify buffers by timestamp

Use the new v4l2_m2m_buf_copy_data helper function and use
timestamps to refer to reference frames instead of using
buffer indices.

Also remove the padding fields in the structs, that's a bad
idea. Just use the right types to keep everything aligned.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Hans Verkuil 2018-11-09 04:16:21 -05:00 committed by Mauro Carvalho Chehab
parent 245ede423b
commit d998e03e32
5 changed files with 24 additions and 33 deletions

View File

@ -1661,15 +1661,6 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
return -EINVAL;
}
if (p_mpeg2_slice_params->backward_ref_index >= VIDEO_MAX_FRAME ||
p_mpeg2_slice_params->forward_ref_index >= VIDEO_MAX_FRAME)
return -EINVAL;
if (p_mpeg2_slice_params->pad ||
p_mpeg2_slice_params->picture.pad ||
p_mpeg2_slice_params->sequence.pad)
return -EINVAL;
return 0;
case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION:

View File

@ -140,11 +140,14 @@ static inline dma_addr_t cedrus_buf_addr(struct vb2_buffer *buf,
}
static inline dma_addr_t cedrus_dst_buf_addr(struct cedrus_ctx *ctx,
unsigned int index,
unsigned int plane)
int index, unsigned int plane)
{
struct vb2_buffer *buf = ctx->dst_bufs[index];
struct vb2_buffer *buf;
if (index < 0)
return 0;
buf = ctx->dst_bufs[index];
return buf ? cedrus_buf_addr(buf, &ctx->dst_fmt, plane) : 0;
}

View File

@ -50,6 +50,8 @@ void cedrus_device_run(void *priv)
break;
}
v4l2_m2m_buf_copy_data(run.src, run.dst, true);
dev->dec_ops[ctx->current_codec]->setup(ctx, &run);
/* Complete request(s) controls if needed. */

View File

@ -82,7 +82,10 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)
dma_addr_t fwd_luma_addr, fwd_chroma_addr;
dma_addr_t bwd_luma_addr, bwd_chroma_addr;
struct cedrus_dev *dev = ctx->dev;
struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q;
const u8 *matrix;
int forward_idx;
int backward_idx;
unsigned int i;
u32 reg;
@ -156,23 +159,19 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)
cedrus_write(dev, VE_DEC_MPEG_PICBOUNDSIZE, reg);
/* Forward and backward prediction reference buffers. */
forward_idx = vb2_find_timestamp(cap_q,
slice_params->forward_ref_ts, 0);
fwd_luma_addr = cedrus_dst_buf_addr(ctx,
slice_params->forward_ref_index,
0);
fwd_chroma_addr = cedrus_dst_buf_addr(ctx,
slice_params->forward_ref_index,
1);
fwd_luma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 0);
fwd_chroma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 1);
cedrus_write(dev, VE_DEC_MPEG_FWD_REF_LUMA_ADDR, fwd_luma_addr);
cedrus_write(dev, VE_DEC_MPEG_FWD_REF_CHROMA_ADDR, fwd_chroma_addr);
bwd_luma_addr = cedrus_dst_buf_addr(ctx,
slice_params->backward_ref_index,
0);
bwd_chroma_addr = cedrus_dst_buf_addr(ctx,
slice_params->backward_ref_index,
1);
backward_idx = vb2_find_timestamp(cap_q,
slice_params->backward_ref_ts, 0);
bwd_luma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 0);
bwd_chroma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 1);
cedrus_write(dev, VE_DEC_MPEG_BWD_REF_LUMA_ADDR, bwd_luma_addr);
cedrus_write(dev, VE_DEC_MPEG_BWD_REF_CHROMA_ADDR, bwd_chroma_addr);

View File

@ -30,10 +30,9 @@ struct v4l2_mpeg2_sequence {
__u32 vbv_buffer_size;
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */
__u8 profile_and_level_indication;
__u16 profile_and_level_indication;
__u8 progressive_sequence;
__u8 chroma_format;
__u8 pad;
};
struct v4l2_mpeg2_picture {
@ -51,23 +50,20 @@ struct v4l2_mpeg2_picture {
__u8 intra_vlc_format;
__u8 alternate_scan;
__u8 repeat_first_field;
__u8 progressive_frame;
__u8 pad;
__u16 progressive_frame;
};
struct v4l2_ctrl_mpeg2_slice_params {
__u32 bit_size;
__u32 data_bit_offset;
__u64 backward_ref_ts;
__u64 forward_ref_ts;
struct v4l2_mpeg2_sequence sequence;
struct v4l2_mpeg2_picture picture;
/* ISO/IEC 13818-2, ITU-T Rec. H.262: Slice */
__u8 quantiser_scale_code;
__u8 backward_ref_index;
__u8 forward_ref_index;
__u8 pad;
__u32 quantiser_scale_code;
};
struct v4l2_ctrl_mpeg2_quantization {