buf.addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
buf.size = src_buf->planes[0].bytesused;
buf.model = src_buf->memory;
+ buf.timestamp = src_buf->timestamp;
if (!buf.vaddr && !buf.addr) {
v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
/*v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO,
"timestamp: 0x%llx\n", src_buf->timestamp);*/
- ret = vdec_if_decode(ctx, &buf, src_buf->timestamp, &res_chg);
+ ret = vdec_if_decode(ctx, &buf, &res_chg);
if (ret > 0) {
/*
* we only return src buffer with VB2_BUF_STATE_DONE
buf = container_of(vb2_v4l2, struct aml_video_dec_buf, vb);
v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT,
- "%s, vb: %lx, type: %d, idx: %d, state: %d, used: %d\n",
+ "%s, vb: %lx, type: %d, idx: %d, state: %d, used: %d, ts: %llu\n",
__func__, (ulong) vb, vb->vb2_queue->type,
- vb->index, vb->state, buf->used);
+ vb->index, vb->state, buf->used, vb->timestamp);
/*
* check if this buffer is ready to be used after decode
*/
src_mem.addr = vb2_dma_contig_plane_dma_addr(vb, 0);
src_mem.size = vb->planes[0].bytesused;
src_mem.model = vb->memory;
+ src_mem.timestamp = vb->timestamp;
if (vdec_if_probe(ctx, &src_mem, NULL)) {
v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
void *vaddr;
u32 bytes_used;
u32 offset;
+ u64 timestamp;
dma_addr_t dma_addr;
u32 model;
};
return pos;
}
-static int parse_stream_ucode(struct vdec_h264_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_h264_inst *inst,
+ u8 *buf, u32 size, u64 timestamp)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write(vdec, buf, size, 0);
+ ret = vdec_vframe_write(vdec, buf, size, timestamp);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
}
static int parse_stream_ucode_dma(struct vdec_h264_inst *inst,
- ulong buf, u32 size, u32 handle)
+ ulong buf, u32 size, u64 timestamp, u32 handle)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+ ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
return -1;
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, s->data, s->len);
+ ret = parse_stream_ucode(inst, s->data,
+ s->len, bs->timestamp);
} else {
skip_aud_data((u8 **)&s->data, &s->len);
ret = parse_stream_cpu(inst, s->data, s->len);
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = parse_stream_ucode_dma(inst, bs->addr, size,
- BUFF_IDX(bs, bs->index));
+ bs->timestamp, BUFF_IDX(bs, bs->index));
}
} else {
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, buf, size);
+ ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
} else {
skip_aud_data(&buf, &size);
ret = parse_stream_cpu(inst, buf, size);
return false;
}
-static int vdec_h264_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
- u64 timestamp, bool *res_chg)
+static int vdec_h264_decode(unsigned long h_vdec,
+ struct aml_vcodec_mem *bs, bool *res_chg)
{
struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec;
struct aml_vdec_adapt *vdec = &inst->vdec;
ret = vdec_vframe_write(vdec,
s->data,
s->len,
- timestamp);
+ bs->timestamp);
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = vdec_vframe_write_with_dma(vdec,
- bs->addr, size, timestamp,
+ bs->addr, size, bs->timestamp,
BUFF_IDX(bs, bs->index));
}
} else {
return 0;
}
}
- ret = vdec_write_nalu(inst, buf, size, timestamp);
+ ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
}
return ret;
dec->dpb_sz - margin, margin);
}
-static int parse_stream_ucode(struct vdec_hevc_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_hevc_inst *inst,
+ u8 *buf, u32 size, u64 timestamp)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write(vdec, buf, size, 0);
+ ret = vdec_vframe_write(vdec, buf, size, timestamp);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
}
static int parse_stream_ucode_dma(struct vdec_hevc_inst *inst,
- ulong buf, u32 size, u32 handle)
+ ulong buf, u32 size, u64 timestamp, u32 handle)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+ ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
return -1;
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, s->data, s->len);
+ ret = parse_stream_ucode(inst, s->data,
+ s->len, bs->timestamp);
} else {
ret = parse_stream_cpu(inst, s->data, s->len);
}
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = parse_stream_ucode_dma(inst, bs->addr, size,
- BUFF_IDX(bs, bs->index));
+ bs->timestamp, BUFF_IDX(bs, bs->index));
}
} else {
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, buf, size);
+ ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
} else {
ret = parse_stream_cpu(inst, buf, size);
}
return false;
}
-static int vdec_hevc_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
- u64 timestamp, bool *res_chg)
+static int vdec_hevc_decode(unsigned long h_vdec,
+ struct aml_vcodec_mem *bs, bool *res_chg)
{
struct vdec_hevc_inst *inst = (struct vdec_hevc_inst *)h_vdec;
struct aml_vdec_adapt *vdec = &inst->vdec;
ret = vdec_vframe_write(vdec,
s->data,
s->len,
- timestamp);
+ bs->timestamp);
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = vdec_vframe_write_with_dma(vdec,
- bs->addr, size, timestamp,
+ bs->addr, size, bs->timestamp,
BUFF_IDX(bs, bs->index));
}
} else {
if ((*res_chg = monitor_res_change(inst, buf, size)))
return 0;
}
- ret = vdec_write_nalu(inst, buf, size, timestamp);
+ ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
}
return ret;
pic->visible_width, pic->visible_height, dec->dpb_sz);
}
-static int parse_stream_ucode(struct vdec_mjpeg_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_mjpeg_inst *inst,
+ u8 *buf, u32 size, u64 timestamp)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write(vdec, buf, size, 0);
+ ret = vdec_vframe_write(vdec, buf, size, timestamp);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
}
static int parse_stream_ucode_dma(struct vdec_mjpeg_inst *inst,
- ulong buf, u32 size, u32 handle)
+ ulong buf, u32 size, u64 timestamp, u32 handle)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+ ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
return -1;
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, s->data, s->len);
+ ret = parse_stream_ucode(inst, s->data,
+ s->len, bs->timestamp);
} else {
ret = parse_stream_cpu(inst, s->data, s->len);
}
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = parse_stream_ucode_dma(inst, bs->addr, size,
- BUFF_IDX(bs, bs->index));
+ bs->timestamp, BUFF_IDX(bs, bs->index));
}
} else {
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, buf, size);
+ ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
} else {
ret = parse_stream_cpu(inst, buf, size);
}
return ret;
}
-static int vdec_mjpeg_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
- u64 timestamp, bool *res_chg)
+static int vdec_mjpeg_decode(unsigned long h_vdec,
+ struct aml_vcodec_mem *bs, bool *res_chg)
{
struct vdec_mjpeg_inst *inst = (struct vdec_mjpeg_inst *)h_vdec;
struct aml_vdec_adapt *vdec = &inst->vdec;
ret = vdec_vframe_write(vdec,
s->data,
s->len,
- timestamp);
+ bs->timestamp);
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = vdec_vframe_write_with_dma(vdec,
- bs->addr, size, timestamp,
+ bs->addr, size, bs->timestamp,
BUFF_IDX(bs, bs->index));
}
} else {
- ret = vdec_write_nalu(inst, buf, size, timestamp);
+ ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
}
return ret;
pic->visible_width, pic->visible_height, dec->dpb_sz);
}
-static int parse_stream_ucode(struct vdec_mpeg12_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_mpeg12_inst *inst,
+ u8 *buf, u32 size, u64 timestamp)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write(vdec, buf, size, 0);
+ ret = vdec_vframe_write(vdec, buf, size, timestamp);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
}
static int parse_stream_ucode_dma(struct vdec_mpeg12_inst *inst,
- ulong buf, u32 size, u32 handle)
+ ulong buf, u32 size, u64 timestamp, u32 handle)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+ ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
return -1;
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, s->data, s->len);
+ ret = parse_stream_ucode(inst, s->data,
+ s->len, bs->timestamp);
} else {
ret = parse_stream_cpu(inst, s->data, s->len);
}
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = parse_stream_ucode_dma(inst, bs->addr, size,
- BUFF_IDX(bs, bs->index));
+ bs->timestamp, BUFF_IDX(bs, bs->index));
}
} else {
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, buf, size);
+ ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
} else {
ret = parse_stream_cpu(inst, buf, size);
}
return ret;
}
-static int vdec_mpeg12_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
- u64 timestamp, bool *res_chg)
+static int vdec_mpeg12_decode(unsigned long h_vdec,
+ struct aml_vcodec_mem *bs, bool *res_chg)
{
struct vdec_mpeg12_inst *inst = (struct vdec_mpeg12_inst *)h_vdec;
struct aml_vdec_adapt *vdec = &inst->vdec;
ret = vdec_vframe_write(vdec,
s->data,
s->len,
- timestamp);
+ bs->timestamp);
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = vdec_vframe_write_with_dma(vdec,
- bs->addr, size, timestamp,
+ bs->addr, size, bs->timestamp,
BUFF_IDX(bs, bs->index));
}
} else {
- ret = vdec_write_nalu(inst, buf, size, timestamp);
+ ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
}
return ret;
pic->visible_width, pic->visible_height, dec->dpb_sz);
}
-static int parse_stream_ucode(struct vdec_mpeg4_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_mpeg4_inst *inst,
+ u8 *buf, u32 size, u64 timestamp)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write(vdec, buf, size, 0);
+ ret = vdec_vframe_write(vdec, buf, size, timestamp);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
}
static int parse_stream_ucode_dma(struct vdec_mpeg4_inst *inst,
- ulong buf, u32 size, u32 handle)
+ ulong buf, u32 size, u64 timestamp, u32 handle)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+ ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
return -1;
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, s->data, s->len);
+ ret = parse_stream_ucode(inst, s->data,
+ s->len, bs->timestamp);
} else {
ret = parse_stream_cpu(inst, s->data, s->len);
}
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = parse_stream_ucode_dma(inst, bs->addr, size,
- BUFF_IDX(bs, bs->index));
+ bs->timestamp, BUFF_IDX(bs, bs->index));
}
} else {
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, buf, size);
+ ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
} else {
ret = parse_stream_cpu(inst, buf, size);
}
return ret;
}
-static int vdec_mpeg4_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
- u64 timestamp, bool *res_chg)
+static int vdec_mpeg4_decode(unsigned long h_vdec,
+ struct aml_vcodec_mem *bs, bool *res_chg)
{
struct vdec_mpeg4_inst *inst = (struct vdec_mpeg4_inst *)h_vdec;
struct aml_vdec_adapt *vdec = &inst->vdec;
ret = vdec_vframe_write(vdec,
s->data,
s->len,
- timestamp);
+ bs->timestamp);
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = vdec_vframe_write_with_dma(vdec,
- bs->addr, size, timestamp,
+ bs->addr, size, bs->timestamp,
BUFF_IDX(bs, bs->index));
}
} else {
- ret = vdec_write_nalu(inst, buf, size, timestamp);
+ ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
}
return ret;
dec->dpb_sz - margin, margin);
}
-static int parse_stream_ucode(struct vdec_vp9_inst *inst, u8 *buf, u32 size)
+static int parse_stream_ucode(struct vdec_vp9_inst *inst,
+ u8 *buf, u32 size, u64 timestamp)
{
int ret = 0;
- ret = vdec_write_nalu(inst, buf, size, 0);
+ ret = vdec_write_nalu(inst, buf, size, timestamp);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
}
static int parse_stream_ucode_dma(struct vdec_vp9_inst *inst,
- ulong buf, u32 size, u32 handle)
+ ulong buf, u32 size, u64 timestamp, u32 handle)
{
int ret = 0;
struct aml_vdec_adapt *vdec = &inst->vdec;
- ret = vdec_vframe_write_with_dma(vdec, buf, size, 0, handle);
+ ret = vdec_vframe_write_with_dma(vdec, buf, size, timestamp, handle);
if (ret < 0) {
v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR,
"write frame data failed. err: %d\n", ret);
return -1;
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, s->data, s->len);
+ ret = parse_stream_ucode(inst, s->data,
+ s->len, bs->timestamp);
} else {
ret = parse_stream_cpu(inst, s->data, s->len);
}
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = parse_stream_ucode_dma(inst, bs->addr, size,
- BUFF_IDX(bs, bs->index));
+ bs->timestamp, BUFF_IDX(bs, bs->index));
}
} else {
if (inst->ctx->param_sets_from_ucode) {
- ret = parse_stream_ucode(inst, buf, size);
+ ret = parse_stream_ucode(inst, buf, size, bs->timestamp);
} else {
ret = parse_stream_cpu(inst, buf, size);
}
return false;
}
-static int vdec_vp9_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
- u64 timestamp, bool *res_chg)
+static int vdec_vp9_decode(unsigned long h_vdec,
+ struct aml_vcodec_mem *bs, bool *res_chg)
{
struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec;
struct aml_vdec_adapt *vdec = &inst->vdec;
ret = vdec_vframe_write(vdec,
s->data,
s->len,
- timestamp);
+ bs->timestamp);
} else if (bs->model == VB2_MEMORY_DMABUF ||
bs->model == VB2_MEMORY_USERPTR) {
ret = vdec_vframe_write_with_dma(vdec,
- bs->addr, size, timestamp,
+ bs->addr, size, bs->timestamp,
BUFF_IDX(bs, bs->index));
}
} else {
(*res_chg = monitor_res_change(inst, buf, size)))
return 0;
- ret = vdec_write_nalu(inst, buf, size, timestamp);
+ ret = vdec_write_nalu(inst, buf, size, bs->timestamp);
}
ATRACE_COUNTER("v4l2_decode_write", ret);
* @res_chg : [out] resolution change happen
*/
int (*decode)(unsigned long h_vdec, struct aml_vcodec_mem *bs,
- u64 pts, bool *res_chg);
+ bool *res_chg);
/**
* (*get_param)() - get driver's parameter
return ret;
}
-int vdec_if_decode(struct aml_vcodec_ctx *ctx, struct aml_vcodec_mem *bs,
- u64 timestamp, bool *res_chg)
+int vdec_if_decode(struct aml_vcodec_ctx *ctx,
+ struct aml_vcodec_mem *bs, bool *res_chg)
{
int ret = 0;
return -EIO;
aml_vcodec_set_curr_ctx(ctx->dev, ctx);
- ret = ctx->dec_if->decode(ctx->drv_handle, bs, timestamp, res_chg);
+ ret = ctx->dec_if->decode(ctx->drv_handle, bs, res_chg);
aml_vcodec_set_curr_ctx(ctx->dev, NULL);
return ret;
*
* Return: 0 on success. -EIO on unrecoverable error.
*/
-int vdec_if_decode(struct aml_vcodec_ctx *ctx, struct aml_vcodec_mem *bs,
- u64 timestamp, bool *res_chg);
+int vdec_if_decode(struct aml_vcodec_ctx *ctx,
+ struct aml_vcodec_mem *bs, bool *res_chg);
/**
* vdec_if_get_param() - get driver's parameter