dst_vb2_v4l2 = container_of(dst_buf, struct vb2_v4l2_buffer, vb2_buf);
dst_buf_info = container_of(dst_vb2_v4l2, struct aml_video_dec_buf, vb);
+ pfb = &dst_buf_info->frame_buffer;
+ pfb->buf_idx = dst_buf->index;
+ pfb->num_planes = dst_buf->num_planes;
+ pfb->status = FB_ST_NORMAL;
if (dst_buf->num_planes == 1) {
- pfb = &dst_buf_info->frame_buffer;
pfb->m.mem[0].dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
pfb->m.mem[0].addr = dma_to_phys(v4l_get_dev_from_codec_mm(), pfb->m.mem[0].dma_addr);
pfb->m.mem[0].size = ctx->picinfo.y_len_sz + ctx->picinfo.c_len_sz;
pfb->m.mem[0].offset = ctx->picinfo.y_len_sz;
- pfb->num_planes = dst_buf->num_planes;
- pfb->status = FB_ST_NORMAL;
-
v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR,
"idx: %u, 1 plane, y:(0x%lx, %d)\n", dst_buf->index,
pfb->m.mem[0].addr, pfb->m.mem[0].size);
} else if (dst_buf->num_planes == 2) {
- pfb = &dst_buf_info->frame_buffer;
pfb->m.mem[0].dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
pfb->m.mem[0].addr = dma_to_phys(v4l_get_dev_from_codec_mm(), pfb->m.mem[0].dma_addr);
pfb->m.mem[0].size = ctx->picinfo.y_len_sz;
pfb->m.mem[1].addr = dma_to_phys(v4l_get_dev_from_codec_mm(), pfb->m.mem[1].dma_addr);
pfb->m.mem[1].size = ctx->picinfo.c_len_sz;
pfb->m.mem[1].offset = ctx->picinfo.c_len_sz >> 1;
- pfb->num_planes = dst_buf->num_planes;
- pfb->status = FB_ST_NORMAL;
-
v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR,
"idx: %u, 2 planes, y:(0x%lx, %d), c:(0x%lx, %d)\n", dst_buf->index,
pfb->m.mem[0].addr, pfb->m.mem[0].size,
pfb->m.mem[1].addr, pfb->m.mem[1].size);
} else {
- pfb = &dst_buf_info->frame_buffer;
pfb->m.mem[0].dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
pfb->m.mem[0].addr = dma_to_phys(v4l_get_dev_from_codec_mm(), pfb->m.mem[0].dma_addr);
pfb->m.mem[0].size = ctx->picinfo.y_len_sz;
pfb->m.mem[2].addr = dma_to_phys(v4l_get_dev_from_codec_mm(), pfb->m.mem[3].dma_addr);
pfb->m.mem[2].size = ctx->picinfo.c_len_sz >> 1;
pfb->m.mem[2].offset = 0;
- pfb->num_planes = dst_buf->num_planes;
- pfb->status = FB_ST_NORMAL;
v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR,
"idx: %u, 3 planes, y:(0x%lx, %d), u:(0x%lx, %d), v:(0x%lx, %d)\n",
info = container_of(pfb, struct aml_video_dec_buf, frame_buffer);
+ ctx->cap_pool.dec++;
ctx->cap_pool.seq[ctx->cap_pool.out++] =
(V4L_CAP_BUFF_IN_DEC << 16 | dst_buf->index);
v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
ctx->buf_used_count = 0;
ctx->cap_pool.in = 0;
ctx->cap_pool.out = 0;
+ ctx->cap_pool.dec = 0;
+ ctx->cap_pool.vpp = 0;
}
static void m2mops_vdec_device_run(void *priv)
int sidebind_channel_id;
u32 low_latency_mode;
int ip_field_error_count;
+ int buffer_wrap[BUFSPEC_POOL_SIZE];
};
static u32 again_threshold;
for (i = 0; i < BUFSPEC_POOL_SIZE; i++) {
hw->buffer_spec[i].used = -1;
hw->buffer_spec[i].canvas_pos = -1;
+ hw->buffer_wrap[i] = -1;
}
}
bs->cma_alloc_addr = (unsigned long)fb;
dpb_print(DECODE_ID(hw), PRINT_FLAG_V4L_DETAIL,
- "[%d] %s(), cma alloc addr: 0x%x\n",
- ctx->id, __func__, bs->cma_alloc_addr);
+ "[%d] %s(), cma alloc addr: 0x%x, out %d dec %d\n",
+ ctx->id, __func__, bs->cma_alloc_addr,
+ ctx->cap_pool.out, ctx->cap_pool.dec);
if (fb->num_planes == 1) {
y_addr = fb->m.mem[0].addr;
7);
}
+
+static int v4l_get_free_buffer_spec(struct vdec_h264_hw_s *hw)
+{
+ int i;
+
+ for (i = 0; i < BUFSPEC_POOL_SIZE; i++) {
+ if (hw->buffer_spec[i].cma_alloc_addr == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+static int v4l_find_buffer_spec_idx(struct vdec_h264_hw_s *hw, unsigned int v4l_indx)
+{
+ int i;
+
+ for (i = 0; i < BUFSPEC_POOL_SIZE; i++) {
+ if (hw->buffer_wrap[i] == v4l_indx)
+ return i;
+ }
+ return -1;
+}
+
static int v4l_get_free_buf_idx(struct vdec_s *vdec)
{
struct vdec_h264_hw_s *hw = (struct vdec_h264_hw_s *)vdec->private;
struct aml_vcodec_ctx * v4l = hw->v4l2_ctx;
struct v4l_buff_pool *pool = &v4l->cap_pool;
struct buffer_spec_s *pic = NULL;
- int i, idx = INVALID_IDX;
+ int i, rt, idx = INVALID_IDX;
ulong flags;
+ u32 state, index;
spin_lock_irqsave(&hw->bufspec_lock, flags);
for (i = 0; i < pool->in; ++i) {
- u32 state = (pool->seq[i] >> 16);
- u32 index = (pool->seq[i] & 0xffff);
+ state = (pool->seq[i] >> 16);
+ index = (pool->seq[i] & 0xffff);
switch (state) {
case V4L_CAP_BUFF_IN_DEC:
- pic = &hw->buffer_spec[i];
- if ((pic->vf_ref == 0) &&
- (pic->used == 0) &&
- pic->cma_alloc_addr) {
- idx = i;
+ rt = v4l_find_buffer_spec_idx(hw, index);
+ if (rt >= 0) {
+ pic = &hw->buffer_spec[rt];
+ if ((pic->vf_ref == 0) &&
+ (pic->used == 0) &&
+ pic->cma_alloc_addr) {
+ idx = rt;
+ }
}
break;
case V4L_CAP_BUFF_IN_M2M:
- pic = &hw->buffer_spec[index];
- if (!alloc_one_buf_spec_from_queue(hw, index)) {
- config_decode_canvas(hw, index);
- idx = index;
+ rt = v4l_get_free_buffer_spec(hw);
+ if (rt >= 0) {
+ pic = &hw->buffer_spec[rt];
+ if (!alloc_one_buf_spec_from_queue(hw, rt)) {
+ struct vdec_v4l2_buffer *fb;
+ config_decode_canvas(hw, rt);
+ fb = (struct vdec_v4l2_buffer *)pic->cma_alloc_addr;
+ hw->buffer_wrap[rt] = fb->buf_idx;
+ idx = rt;
+ }
}
break;
default:
if (idx < 0) {
dpb_print(DECODE_ID(hw), 0, "%s fail\n", __func__);
+ for (i = 0; i < BUFSPEC_POOL_SIZE; i++) {
+ dpb_print(DECODE_ID(hw), 0, "%s, %d\n",
+ __func__, hw->buffer_wrap[i]);
+ }
vmh264_dump_state(vdec);
}
hw->buffer_spec[i].used = 1;
hw->start_search_pos = i+1;
index = i;
+ hw->buffer_wrap[i] = index;
break;
}
}
hw->buffer_spec[i].used = 1;
hw->start_search_pos = i+1;
index = i;
+ hw->buffer_wrap[i] = index;
break;
}
}
}
}
- if (v4l->cap_pool.out < hw->dpb.mDPB.size &&
+ if (v4l->cap_pool.dec < hw->dpb.mDPB.size &&
v4l2_m2m_num_dst_bufs_ready(v4l->m2m_ctx)
>= run_ready_min_buf_num)
return 1;
&& (hw->frame_dur == 3840)) {
bForceInterlace = 1;
}
-
+ if (hw->is_used_v4l && (bForceInterlace == 0)) {
+ bForceInterlace = (frame->frame->mb_aff_frame_flag)?1:0;
+ }
return bForceInterlace;
}
if (hw->buffer_spec[i].used == -1)
continue;
dpb_print(DECODE_ID(hw), 0,
- "bufspec (%d): used %d adr 0x%x canvas(%d) vf_ref(%d) ",
+ "bufspec (%d): used %d adr 0x%x(%lx) canvas(%d) vf_ref(%d) ",
i, hw->buffer_spec[i].used,
hw->buffer_spec[i].buf_adr,
+ hw->buffer_spec[i].cma_alloc_addr,
hw->buffer_spec[i].canvas_pos,
hw->buffer_spec[i].vf_ref
);