Lines Matching refs:inst
145 static inline u32 vp8_enc_read_reg(struct venc_vp8_inst *inst, u32 addr) in vp8_enc_read_reg() argument
147 return readl(inst->hw_base + addr); in vp8_enc_read_reg()
150 static void vp8_enc_free_work_buf(struct venc_vp8_inst *inst) in vp8_enc_free_work_buf() argument
154 mtk_vcodec_debug_enter(inst); in vp8_enc_free_work_buf()
158 if (inst->work_bufs[i].size == 0) in vp8_enc_free_work_buf()
160 mtk_vcodec_mem_free(inst->ctx, &inst->work_bufs[i]); in vp8_enc_free_work_buf()
163 mtk_vcodec_debug_leave(inst); in vp8_enc_free_work_buf()
166 static int vp8_enc_alloc_work_buf(struct venc_vp8_inst *inst) in vp8_enc_alloc_work_buf() argument
170 struct venc_vp8_vpu_buf *wb = inst->vsi->work_bufs; in vp8_enc_alloc_work_buf()
172 mtk_vcodec_debug_enter(inst); in vp8_enc_alloc_work_buf()
187 inst->work_bufs[i].size = wb[i].size; in vp8_enc_alloc_work_buf()
188 ret = mtk_vcodec_mem_alloc(inst->ctx, &inst->work_bufs[i]); in vp8_enc_alloc_work_buf()
190 mtk_vcodec_err(inst, in vp8_enc_alloc_work_buf()
204 tmp_va = vpu_mapping_dm_addr(inst->vpu_inst.dev, in vp8_enc_alloc_work_buf()
206 memcpy(inst->work_bufs[i].va, tmp_va, wb[i].size); in vp8_enc_alloc_work_buf()
208 wb[i].iova = inst->work_bufs[i].dma_addr; in vp8_enc_alloc_work_buf()
210 mtk_vcodec_debug(inst, in vp8_enc_alloc_work_buf()
212 i, inst->work_bufs[i].va, in vp8_enc_alloc_work_buf()
213 &inst->work_bufs[i].dma_addr, in vp8_enc_alloc_work_buf()
214 inst->work_bufs[i].size); in vp8_enc_alloc_work_buf()
217 mtk_vcodec_debug_leave(inst); in vp8_enc_alloc_work_buf()
222 vp8_enc_free_work_buf(inst); in vp8_enc_alloc_work_buf()
227 static unsigned int vp8_enc_wait_venc_done(struct venc_vp8_inst *inst) in vp8_enc_wait_venc_done() argument
230 struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)inst->ctx; in vp8_enc_wait_venc_done()
235 mtk_vcodec_debug(inst, "isr return %x", irq_status); in vp8_enc_wait_venc_done()
244 static int vp8_enc_compose_one_frame(struct venc_vp8_inst *inst, in vp8_enc_compose_one_frame() argument
255 bs_frm_size = vp8_enc_read_reg(inst, VENC_BITSTREAM_FRAME_SIZE); in vp8_enc_compose_one_frame()
256 bs_hdr_len = vp8_enc_read_reg(inst, VENC_BITSTREAM_HEADER_LEN); in vp8_enc_compose_one_frame()
259 not_key = !inst->vpu_inst.is_key_frm; in vp8_enc_compose_one_frame()
271 ac_tag[6] = inst->vsi->config.pic_w; in vp8_enc_compose_one_frame()
272 ac_tag[7] = inst->vsi->config.pic_w >> 8; in vp8_enc_compose_one_frame()
273 ac_tag[8] = inst->vsi->config.pic_h; in vp8_enc_compose_one_frame()
274 ac_tag[9] = inst->vsi->config.pic_h >> 8; in vp8_enc_compose_one_frame()
280 mtk_vcodec_err(inst, "bitstream buf size is too small(%zu)", in vp8_enc_compose_one_frame()
295 inst->work_bufs[VENC_VP8_VPU_WORK_BUF_BS_HEADER].va, in vp8_enc_compose_one_frame()
303 static int vp8_enc_encode_frame(struct venc_vp8_inst *inst, in vp8_enc_encode_frame() argument
311 mtk_vcodec_debug(inst, "->frm_cnt=%d", inst->frm_cnt); in vp8_enc_encode_frame()
313 ret = vpu_enc_encode(&inst->vpu_inst, 0, frm_buf, bs_buf, bs_size); in vp8_enc_encode_frame()
317 irq_status = vp8_enc_wait_venc_done(inst); in vp8_enc_encode_frame()
319 mtk_vcodec_err(inst, "irq_status=%d failed", irq_status); in vp8_enc_encode_frame()
323 if (vp8_enc_compose_one_frame(inst, bs_buf, bs_size)) { in vp8_enc_encode_frame()
324 mtk_vcodec_err(inst, "vp8_enc_compose_one_frame failed"); in vp8_enc_encode_frame()
328 inst->frm_cnt++; in vp8_enc_encode_frame()
329 mtk_vcodec_debug(inst, "<-size=%d key_frm=%d", *bs_size, in vp8_enc_encode_frame()
330 inst->vpu_inst.is_key_frm); in vp8_enc_encode_frame()
338 struct venc_vp8_inst *inst; in vp8_enc_init() local
340 inst = kzalloc(sizeof(*inst), GFP_KERNEL); in vp8_enc_init()
341 if (!inst) in vp8_enc_init()
344 inst->ctx = ctx; in vp8_enc_init()
345 inst->vpu_inst.ctx = ctx; in vp8_enc_init()
346 inst->vpu_inst.dev = ctx->dev->vpu_plat_dev; in vp8_enc_init()
347 inst->vpu_inst.id = IPI_VENC_VP8; in vp8_enc_init()
348 inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx, VENC_LT_SYS); in vp8_enc_init()
350 mtk_vcodec_debug_enter(inst); in vp8_enc_init()
352 ret = vpu_enc_init(&inst->vpu_inst); in vp8_enc_init()
354 inst->vsi = (struct venc_vp8_vsi *)inst->vpu_inst.vsi; in vp8_enc_init()
356 mtk_vcodec_debug_leave(inst); in vp8_enc_init()
359 kfree(inst); in vp8_enc_init()
361 (*handle) = (unsigned long)inst; in vp8_enc_init()
373 struct venc_vp8_inst *inst = (struct venc_vp8_inst *)handle; in vp8_enc_encode() local
374 struct mtk_vcodec_ctx *ctx = inst->ctx; in vp8_enc_encode()
376 mtk_vcodec_debug_enter(inst); in vp8_enc_encode()
382 ret = vp8_enc_encode_frame(inst, frm_buf, bs_buf, in vp8_enc_encode()
386 result->is_key_frm = inst->vpu_inst.is_key_frm; in vp8_enc_encode()
390 mtk_vcodec_err(inst, "opt not support:%d", opt); in vp8_enc_encode()
398 mtk_vcodec_debug_leave(inst); in vp8_enc_encode()
408 struct venc_vp8_inst *inst = (struct venc_vp8_inst *)handle; in vp8_enc_set_param() local
410 mtk_vcodec_debug(inst, "->type=%d", type); in vp8_enc_set_param()
414 inst->vsi->config.input_fourcc = enc_prm->input_yuv_fmt; in vp8_enc_set_param()
415 inst->vsi->config.bitrate = enc_prm->bitrate; in vp8_enc_set_param()
416 inst->vsi->config.pic_w = enc_prm->width; in vp8_enc_set_param()
417 inst->vsi->config.pic_h = enc_prm->height; in vp8_enc_set_param()
418 inst->vsi->config.buf_w = enc_prm->buf_width; in vp8_enc_set_param()
419 inst->vsi->config.buf_h = enc_prm->buf_height; in vp8_enc_set_param()
420 inst->vsi->config.gop_size = enc_prm->gop_size; in vp8_enc_set_param()
421 inst->vsi->config.framerate = enc_prm->frm_rate; in vp8_enc_set_param()
422 inst->vsi->config.ts_mode = inst->ts_mode; in vp8_enc_set_param()
423 ret = vpu_enc_set_param(&inst->vpu_inst, type, enc_prm); in vp8_enc_set_param()
426 if (inst->work_buf_allocated) { in vp8_enc_set_param()
427 vp8_enc_free_work_buf(inst); in vp8_enc_set_param()
428 inst->work_buf_allocated = false; in vp8_enc_set_param()
430 ret = vp8_enc_alloc_work_buf(inst); in vp8_enc_set_param()
433 inst->work_buf_allocated = true; in vp8_enc_set_param()
440 inst->ts_mode = 1; in vp8_enc_set_param()
441 mtk_vcodec_debug(inst, "set ts_mode"); in vp8_enc_set_param()
445 ret = vpu_enc_set_param(&inst->vpu_inst, type, enc_prm); in vp8_enc_set_param()
449 mtk_vcodec_debug_leave(inst); in vp8_enc_set_param()
457 struct venc_vp8_inst *inst = (struct venc_vp8_inst *)handle; in vp8_enc_deinit() local
459 mtk_vcodec_debug_enter(inst); in vp8_enc_deinit()
461 ret = vpu_enc_deinit(&inst->vpu_inst); in vp8_enc_deinit()
463 if (inst->work_buf_allocated) in vp8_enc_deinit()
464 vp8_enc_free_work_buf(inst); in vp8_enc_deinit()
466 mtk_vcodec_debug_leave(inst); in vp8_enc_deinit()
467 kfree(inst); in vp8_enc_deinit()