• Home
  • Raw
  • Download

Lines Matching refs:ctx

34 static int s5p_mfc_alloc_dec_temp_buffers_v5(struct s5p_mfc_ctx *ctx)  in s5p_mfc_alloc_dec_temp_buffers_v5()  argument
36 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_alloc_dec_temp_buffers_v5()
40 ctx->dsc.size = buf_size->dsc; in s5p_mfc_alloc_dec_temp_buffers_v5()
41 ret = s5p_mfc_alloc_priv_buf(dev, BANK_L_CTX, &ctx->dsc); in s5p_mfc_alloc_dec_temp_buffers_v5()
47 BUG_ON(ctx->dsc.dma & ((1 << MFC_BANK1_ALIGN_ORDER) - 1)); in s5p_mfc_alloc_dec_temp_buffers_v5()
48 memset(ctx->dsc.virt, 0, ctx->dsc.size); in s5p_mfc_alloc_dec_temp_buffers_v5()
55 static void s5p_mfc_release_dec_desc_buffer_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_release_dec_desc_buffer_v5() argument
57 s5p_mfc_release_priv_buf(ctx->dev, &ctx->dsc); in s5p_mfc_release_dec_desc_buffer_v5()
61 static int s5p_mfc_alloc_codec_buffers_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_alloc_codec_buffers_v5() argument
63 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_alloc_codec_buffers_v5()
69 if (ctx->type == MFCINST_DECODER) { in s5p_mfc_alloc_codec_buffers_v5()
71 ctx->luma_size, ctx->chroma_size, ctx->mv_size); in s5p_mfc_alloc_codec_buffers_v5()
72 mfc_debug(2, "Totals bufs: %d\n", ctx->total_dpb_count); in s5p_mfc_alloc_codec_buffers_v5()
73 } else if (ctx->type == MFCINST_ENCODER) { in s5p_mfc_alloc_codec_buffers_v5()
74 enc_ref_y_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) in s5p_mfc_alloc_codec_buffers_v5()
75 * ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN); in s5p_mfc_alloc_codec_buffers_v5()
78 if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC) { in s5p_mfc_alloc_codec_buffers_v5()
79 enc_ref_c_size = ALIGN(ctx->img_width, in s5p_mfc_alloc_codec_buffers_v5()
81 * ALIGN(ctx->img_height >> 1, in s5p_mfc_alloc_codec_buffers_v5()
86 guard_width = ALIGN(ctx->img_width + 16, in s5p_mfc_alloc_codec_buffers_v5()
88 guard_height = ALIGN((ctx->img_height >> 1) + 4, in s5p_mfc_alloc_codec_buffers_v5()
99 switch (ctx->codec_mode) { in s5p_mfc_alloc_codec_buffers_v5()
101 ctx->bank1.size = in s5p_mfc_alloc_codec_buffers_v5()
105 ctx->bank2.size = ctx->total_dpb_count * ctx->mv_size; in s5p_mfc_alloc_codec_buffers_v5()
108 ctx->bank1.size = in s5p_mfc_alloc_codec_buffers_v5()
115 ctx->bank2.size = 0; in s5p_mfc_alloc_codec_buffers_v5()
119 ctx->bank1.size = in s5p_mfc_alloc_codec_buffers_v5()
126 ctx->bank2.size = 0; in s5p_mfc_alloc_codec_buffers_v5()
129 ctx->bank1.size = 0; in s5p_mfc_alloc_codec_buffers_v5()
130 ctx->bank2.size = 0; in s5p_mfc_alloc_codec_buffers_v5()
133 ctx->bank1.size = in s5p_mfc_alloc_codec_buffers_v5()
139 ctx->bank2.size = 0; in s5p_mfc_alloc_codec_buffers_v5()
142 ctx->bank1.size = (enc_ref_y_size * 2) + in s5p_mfc_alloc_codec_buffers_v5()
147 ctx->bank2.size = (enc_ref_y_size * 2) + in s5p_mfc_alloc_codec_buffers_v5()
152 ctx->bank1.size = (enc_ref_y_size * 2) + in s5p_mfc_alloc_codec_buffers_v5()
156 ctx->bank2.size = (enc_ref_y_size * 2) + in s5p_mfc_alloc_codec_buffers_v5()
160 ctx->bank1.size = (enc_ref_y_size * 2) + in s5p_mfc_alloc_codec_buffers_v5()
163 ctx->bank2.size = (enc_ref_y_size * 2) + in s5p_mfc_alloc_codec_buffers_v5()
170 if (ctx->bank1.size > 0) { in s5p_mfc_alloc_codec_buffers_v5()
172 ret = s5p_mfc_alloc_priv_buf(dev, BANK_L_CTX, &ctx->bank1); in s5p_mfc_alloc_codec_buffers_v5()
177 BUG_ON(ctx->bank1.dma & ((1 << MFC_BANK1_ALIGN_ORDER) - 1)); in s5p_mfc_alloc_codec_buffers_v5()
180 if (ctx->bank2.size > 0) { in s5p_mfc_alloc_codec_buffers_v5()
181 ret = s5p_mfc_alloc_priv_buf(dev, BANK_R_CTX, &ctx->bank2); in s5p_mfc_alloc_codec_buffers_v5()
184 s5p_mfc_release_priv_buf(ctx->dev, &ctx->bank1); in s5p_mfc_alloc_codec_buffers_v5()
187 BUG_ON(ctx->bank2.dma & ((1 << MFC_BANK2_ALIGN_ORDER) - 1)); in s5p_mfc_alloc_codec_buffers_v5()
193 static void s5p_mfc_release_codec_buffers_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_release_codec_buffers_v5() argument
195 s5p_mfc_release_priv_buf(ctx->dev, &ctx->bank1); in s5p_mfc_release_codec_buffers_v5()
196 s5p_mfc_release_priv_buf(ctx->dev, &ctx->bank2); in s5p_mfc_release_codec_buffers_v5()
200 static int s5p_mfc_alloc_instance_buffer_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_alloc_instance_buffer_v5() argument
202 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_alloc_instance_buffer_v5()
206 if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC || in s5p_mfc_alloc_instance_buffer_v5()
207 ctx->codec_mode == S5P_MFC_CODEC_H264_ENC) in s5p_mfc_alloc_instance_buffer_v5()
208 ctx->ctx.size = buf_size->h264_ctx; in s5p_mfc_alloc_instance_buffer_v5()
210 ctx->ctx.size = buf_size->non_h264_ctx; in s5p_mfc_alloc_instance_buffer_v5()
212 ret = s5p_mfc_alloc_priv_buf(dev, BANK_L_CTX, &ctx->ctx); in s5p_mfc_alloc_instance_buffer_v5()
217 ctx->ctx.ofs = OFFSETA(ctx->ctx.dma); in s5p_mfc_alloc_instance_buffer_v5()
220 memset(ctx->ctx.virt, 0, ctx->ctx.size); in s5p_mfc_alloc_instance_buffer_v5()
224 ctx->shm.size = buf_size->shm; in s5p_mfc_alloc_instance_buffer_v5()
225 ret = s5p_mfc_alloc_priv_buf(dev, BANK_L_CTX, &ctx->shm); in s5p_mfc_alloc_instance_buffer_v5()
228 s5p_mfc_release_priv_buf(dev, &ctx->ctx); in s5p_mfc_alloc_instance_buffer_v5()
233 ctx->shm.ofs = ctx->shm.dma - dev->dma_base[BANK_L_CTX]; in s5p_mfc_alloc_instance_buffer_v5()
234 BUG_ON(ctx->shm.ofs & ((1 << MFC_BANK1_ALIGN_ORDER) - 1)); in s5p_mfc_alloc_instance_buffer_v5()
236 memset(ctx->shm.virt, 0, buf_size->shm); in s5p_mfc_alloc_instance_buffer_v5()
242 static void s5p_mfc_release_instance_buffer_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_release_instance_buffer_v5() argument
244 s5p_mfc_release_priv_buf(ctx->dev, &ctx->ctx); in s5p_mfc_release_instance_buffer_v5()
245 s5p_mfc_release_priv_buf(ctx->dev, &ctx->shm); in s5p_mfc_release_instance_buffer_v5()
260 static void s5p_mfc_write_info_v5(struct s5p_mfc_ctx *ctx, unsigned int data, in s5p_mfc_write_info_v5() argument
263 *(u32 *)(ctx->shm.virt + ofs) = data; in s5p_mfc_write_info_v5()
267 static unsigned int s5p_mfc_read_info_v5(struct s5p_mfc_ctx *ctx, in s5p_mfc_read_info_v5() argument
271 return *(u32 *)(ctx->shm.virt + ofs); in s5p_mfc_read_info_v5()
274 static void s5p_mfc_dec_calc_dpb_size_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_dec_calc_dpb_size_v5() argument
278 ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN); in s5p_mfc_dec_calc_dpb_size_v5()
279 ctx->buf_height = ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN); in s5p_mfc_dec_calc_dpb_size_v5()
282 ctx->img_width, ctx->img_height, ctx->buf_width, in s5p_mfc_dec_calc_dpb_size_v5()
283 ctx->buf_height); in s5p_mfc_dec_calc_dpb_size_v5()
285 if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC) { in s5p_mfc_dec_calc_dpb_size_v5()
286 ctx->luma_size = ALIGN(ctx->buf_width * ctx->buf_height, in s5p_mfc_dec_calc_dpb_size_v5()
288 ctx->chroma_size = ALIGN(ctx->buf_width * in s5p_mfc_dec_calc_dpb_size_v5()
289 ALIGN((ctx->img_height >> 1), in s5p_mfc_dec_calc_dpb_size_v5()
292 ctx->mv_size = ALIGN(ctx->buf_width * in s5p_mfc_dec_calc_dpb_size_v5()
293 ALIGN((ctx->buf_height >> 2), in s5p_mfc_dec_calc_dpb_size_v5()
298 ALIGN(ctx->img_width + 24, S5P_FIMV_NV12MT_HALIGN); in s5p_mfc_dec_calc_dpb_size_v5()
300 ALIGN(ctx->img_height + 16, S5P_FIMV_NV12MT_VALIGN); in s5p_mfc_dec_calc_dpb_size_v5()
301 ctx->luma_size = ALIGN(guard_width * guard_height, in s5p_mfc_dec_calc_dpb_size_v5()
305 ALIGN(ctx->img_width + 16, S5P_FIMV_NV12MT_HALIGN); in s5p_mfc_dec_calc_dpb_size_v5()
307 ALIGN((ctx->img_height >> 1) + 4, in s5p_mfc_dec_calc_dpb_size_v5()
309 ctx->chroma_size = ALIGN(guard_width * guard_height, in s5p_mfc_dec_calc_dpb_size_v5()
312 ctx->mv_size = 0; in s5p_mfc_dec_calc_dpb_size_v5()
316 static void s5p_mfc_enc_calc_src_size_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_enc_calc_src_size_v5() argument
318 if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12M) { in s5p_mfc_enc_calc_src_size_v5()
319 ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN); in s5p_mfc_enc_calc_src_size_v5()
321 ctx->luma_size = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN) in s5p_mfc_enc_calc_src_size_v5()
322 * ALIGN(ctx->img_height, S5P_FIMV_NV12M_LVALIGN); in s5p_mfc_enc_calc_src_size_v5()
323 ctx->chroma_size = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN) in s5p_mfc_enc_calc_src_size_v5()
324 * ALIGN((ctx->img_height >> 1), S5P_FIMV_NV12M_CVALIGN); in s5p_mfc_enc_calc_src_size_v5()
326 ctx->luma_size = ALIGN(ctx->luma_size, S5P_FIMV_NV12M_SALIGN); in s5p_mfc_enc_calc_src_size_v5()
327 ctx->chroma_size = in s5p_mfc_enc_calc_src_size_v5()
328 ALIGN(ctx->chroma_size, S5P_FIMV_NV12M_SALIGN); in s5p_mfc_enc_calc_src_size_v5()
329 } else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12MT) { in s5p_mfc_enc_calc_src_size_v5()
330 ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN); in s5p_mfc_enc_calc_src_size_v5()
332 ctx->luma_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) in s5p_mfc_enc_calc_src_size_v5()
333 * ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN); in s5p_mfc_enc_calc_src_size_v5()
334 ctx->chroma_size = in s5p_mfc_enc_calc_src_size_v5()
335 ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) in s5p_mfc_enc_calc_src_size_v5()
336 * ALIGN((ctx->img_height >> 1), S5P_FIMV_NV12MT_VALIGN); in s5p_mfc_enc_calc_src_size_v5()
338 ctx->luma_size = ALIGN(ctx->luma_size, S5P_FIMV_NV12MT_SALIGN); in s5p_mfc_enc_calc_src_size_v5()
339 ctx->chroma_size = in s5p_mfc_enc_calc_src_size_v5()
340 ALIGN(ctx->chroma_size, S5P_FIMV_NV12MT_SALIGN); in s5p_mfc_enc_calc_src_size_v5()
345 static void s5p_mfc_set_dec_desc_buffer(struct s5p_mfc_ctx *ctx) in s5p_mfc_set_dec_desc_buffer() argument
347 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_dec_desc_buffer()
350 mfc_write(dev, OFFSETA(ctx->dsc.dma), S5P_FIMV_SI_CH0_DESC_ADR); in s5p_mfc_set_dec_desc_buffer()
355 static void s5p_mfc_set_shared_buffer(struct s5p_mfc_ctx *ctx) in s5p_mfc_set_shared_buffer() argument
357 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_shared_buffer()
358 mfc_write(dev, ctx->shm.ofs, S5P_FIMV_SI_CH0_HOST_WR_ADR); in s5p_mfc_set_shared_buffer()
362 static int s5p_mfc_set_dec_stream_buffer_v5(struct s5p_mfc_ctx *ctx, in s5p_mfc_set_dec_stream_buffer_v5() argument
366 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_dec_stream_buffer_v5()
369 mfc_write(dev, ctx->dec_src_buf_size, S5P_FIMV_SI_CH0_CPB_SIZE); in s5p_mfc_set_dec_stream_buffer_v5()
371 s5p_mfc_write_info_v5(ctx, start_num_byte, START_BYTE_NUM); in s5p_mfc_set_dec_stream_buffer_v5()
376 static int s5p_mfc_set_dec_frame_buffer_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_set_dec_frame_buffer_v5() argument
380 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_dec_frame_buffer_v5()
385 buf_addr1 = ctx->bank1.dma; in s5p_mfc_set_dec_frame_buffer_v5()
386 buf_size1 = ctx->bank1.size; in s5p_mfc_set_dec_frame_buffer_v5()
387 buf_addr2 = ctx->bank2.dma; in s5p_mfc_set_dec_frame_buffer_v5()
388 buf_size2 = ctx->bank2.size; in s5p_mfc_set_dec_frame_buffer_v5()
391 mfc_write(dev, ctx->total_dpb_count | dpb, in s5p_mfc_set_dec_frame_buffer_v5()
393 s5p_mfc_set_shared_buffer(ctx); in s5p_mfc_set_dec_frame_buffer_v5()
394 switch (ctx->codec_mode) { in s5p_mfc_set_dec_frame_buffer_v5()
463 ctx->codec_mode); in s5p_mfc_set_dec_frame_buffer_v5()
466 frame_size_lu = ctx->luma_size; in s5p_mfc_set_dec_frame_buffer_v5()
467 frame_size_ch = ctx->chroma_size; in s5p_mfc_set_dec_frame_buffer_v5()
468 frame_size_mv = ctx->mv_size; in s5p_mfc_set_dec_frame_buffer_v5()
471 for (i = 0; i < ctx->total_dpb_count; i++) { in s5p_mfc_set_dec_frame_buffer_v5()
474 ctx->dst_bufs[i].cookie.raw.luma); in s5p_mfc_set_dec_frame_buffer_v5()
475 mfc_write(dev, OFFSETB(ctx->dst_bufs[i].cookie.raw.luma), in s5p_mfc_set_dec_frame_buffer_v5()
478 ctx->dst_bufs[i].cookie.raw.chroma); in s5p_mfc_set_dec_frame_buffer_v5()
479 mfc_write(dev, OFFSETA(ctx->dst_bufs[i].cookie.raw.chroma), in s5p_mfc_set_dec_frame_buffer_v5()
481 if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC) { in s5p_mfc_set_dec_frame_buffer_v5()
492 buf_size1, buf_size2, ctx->total_dpb_count); in s5p_mfc_set_dec_frame_buffer_v5()
497 s5p_mfc_write_info_v5(ctx, frame_size_lu, ALLOC_LUMA_DPB_SIZE); in s5p_mfc_set_dec_frame_buffer_v5()
498 s5p_mfc_write_info_v5(ctx, frame_size_ch, ALLOC_CHROMA_DPB_SIZE); in s5p_mfc_set_dec_frame_buffer_v5()
499 if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC) in s5p_mfc_set_dec_frame_buffer_v5()
500 s5p_mfc_write_info_v5(ctx, frame_size_mv, ALLOC_MV_SIZE); in s5p_mfc_set_dec_frame_buffer_v5()
502 << S5P_FIMV_CH_SHIFT) | (ctx->inst_no), in s5p_mfc_set_dec_frame_buffer_v5()
508 static int s5p_mfc_set_enc_stream_buffer_v5(struct s5p_mfc_ctx *ctx, in s5p_mfc_set_enc_stream_buffer_v5() argument
511 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_enc_stream_buffer_v5()
518 static void s5p_mfc_set_enc_frame_buffer_v5(struct s5p_mfc_ctx *ctx, in s5p_mfc_set_enc_frame_buffer_v5() argument
521 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_enc_frame_buffer_v5()
527 static void s5p_mfc_get_enc_frame_buffer_v5(struct s5p_mfc_ctx *ctx, in s5p_mfc_get_enc_frame_buffer_v5() argument
530 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_get_enc_frame_buffer_v5()
539 static int s5p_mfc_set_enc_ref_buffer_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_set_enc_ref_buffer_v5() argument
541 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_enc_ref_buffer_v5()
548 buf_addr1 = ctx->bank1.dma; in s5p_mfc_set_enc_ref_buffer_v5()
549 buf_size1 = ctx->bank1.size; in s5p_mfc_set_enc_ref_buffer_v5()
550 buf_addr2 = ctx->bank2.dma; in s5p_mfc_set_enc_ref_buffer_v5()
551 buf_size2 = ctx->bank2.size; in s5p_mfc_set_enc_ref_buffer_v5()
552 enc_ref_y_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) in s5p_mfc_set_enc_ref_buffer_v5()
553 * ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN); in s5p_mfc_set_enc_ref_buffer_v5()
555 if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC) { in s5p_mfc_set_enc_ref_buffer_v5()
556 enc_ref_c_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) in s5p_mfc_set_enc_ref_buffer_v5()
557 * ALIGN((ctx->img_height >> 1), S5P_FIMV_NV12MT_VALIGN); in s5p_mfc_set_enc_ref_buffer_v5()
560 guard_width = ALIGN(ctx->img_width + 16, in s5p_mfc_set_enc_ref_buffer_v5()
562 guard_height = ALIGN((ctx->img_height >> 1) + 4, in s5p_mfc_set_enc_ref_buffer_v5()
568 switch (ctx->codec_mode) { in s5p_mfc_set_enc_ref_buffer_v5()
668 ctx->codec_mode); in s5p_mfc_set_enc_ref_buffer_v5()
674 static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx) in s5p_mfc_set_enc_params() argument
676 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_enc_params()
677 struct s5p_mfc_enc_params *p = &ctx->enc_params; in s5p_mfc_set_enc_params()
682 mfc_write(dev, ctx->img_width, S5P_FIMV_ENC_HSIZE_PX); in s5p_mfc_set_enc_params()
684 mfc_write(dev, ctx->img_height, S5P_FIMV_ENC_VSIZE_PX); in s5p_mfc_set_enc_params()
706 if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12M) in s5p_mfc_set_enc_params()
708 else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12MT) in s5p_mfc_set_enc_params()
744 shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL); in s5p_mfc_set_enc_params()
751 s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL); in s5p_mfc_set_enc_params()
753 s5p_mfc_write_info_v5(ctx, p->fixed_target_bit, RC_CONTROL_CONFIG); in s5p_mfc_set_enc_params()
757 static int s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx) in s5p_mfc_set_enc_params_h264() argument
759 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_enc_params_h264()
760 struct s5p_mfc_enc_params *p = &ctx->enc_params; in s5p_mfc_set_enc_params_h264()
765 s5p_mfc_set_enc_params(ctx); in s5p_mfc_set_enc_params_h264()
785 mfc_write(dev, ctx->img_height >> 1, S5P_FIMV_ENC_VSIZE_PX); in s5p_mfc_set_enc_params_h264()
864 shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP); in s5p_mfc_set_enc_params_h264()
868 s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP); in s5p_mfc_set_enc_params_h264()
871 shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL); in s5p_mfc_set_enc_params_h264()
875 s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL); in s5p_mfc_set_enc_params_h264()
878 shm = s5p_mfc_read_info_v5(ctx, SAMPLE_ASPECT_RATIO_IDC); in s5p_mfc_set_enc_params_h264()
881 s5p_mfc_write_info_v5(ctx, shm, SAMPLE_ASPECT_RATIO_IDC); in s5p_mfc_set_enc_params_h264()
884 shm = s5p_mfc_read_info_v5(ctx, EXTENDED_SAR); in s5p_mfc_set_enc_params_h264()
888 s5p_mfc_write_info_v5(ctx, shm, EXTENDED_SAR); in s5p_mfc_set_enc_params_h264()
892 shm = s5p_mfc_read_info_v5(ctx, H264_I_PERIOD); in s5p_mfc_set_enc_params_h264()
901 s5p_mfc_write_info_v5(ctx, shm, H264_I_PERIOD); in s5p_mfc_set_enc_params_h264()
903 shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL); in s5p_mfc_set_enc_params_h264()
910 s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL); in s5p_mfc_set_enc_params_h264()
914 static int s5p_mfc_set_enc_params_mpeg4(struct s5p_mfc_ctx *ctx) in s5p_mfc_set_enc_params_mpeg4() argument
916 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_enc_params_mpeg4()
917 struct s5p_mfc_enc_params *p = &ctx->enc_params; in s5p_mfc_set_enc_params_mpeg4()
923 s5p_mfc_set_enc_params(ctx); in s5p_mfc_set_enc_params_mpeg4()
943 shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP); in s5p_mfc_set_enc_params_mpeg4()
947 s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP); in s5p_mfc_set_enc_params_mpeg4()
956 shm = s5p_mfc_read_info_v5(ctx, RC_VOP_TIMING); in s5p_mfc_set_enc_params_mpeg4()
961 s5p_mfc_write_info_v5(ctx, shm, RC_VOP_TIMING); in s5p_mfc_set_enc_params_mpeg4()
982 shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL); in s5p_mfc_set_enc_params_mpeg4()
989 s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL); in s5p_mfc_set_enc_params_mpeg4()
993 static int s5p_mfc_set_enc_params_h263(struct s5p_mfc_ctx *ctx) in s5p_mfc_set_enc_params_h263() argument
995 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_enc_params_h263()
996 struct s5p_mfc_enc_params *p = &ctx->enc_params; in s5p_mfc_set_enc_params_h263()
1001 s5p_mfc_set_enc_params(ctx); in s5p_mfc_set_enc_params_h263()
1004 shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP); in s5p_mfc_set_enc_params_h263()
1007 s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP); in s5p_mfc_set_enc_params_h263()
1031 shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL); in s5p_mfc_set_enc_params_h263()
1038 s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL); in s5p_mfc_set_enc_params_h263()
1043 static int s5p_mfc_init_decode_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_init_decode_v5() argument
1045 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_init_decode_v5()
1047 s5p_mfc_set_shared_buffer(ctx); in s5p_mfc_init_decode_v5()
1049 if (ctx->codec_mode == S5P_MFC_CODEC_MPEG4_DEC) in s5p_mfc_init_decode_v5()
1050 mfc_write(dev, ctx->loop_filter_mpeg4, S5P_FIMV_ENC_LF_CTRL); in s5p_mfc_init_decode_v5()
1053 mfc_write(dev, ((ctx->slice_interface & S5P_FIMV_SLICE_INT_MASK) << in s5p_mfc_init_decode_v5()
1054 S5P_FIMV_SLICE_INT_SHIFT) | (ctx->display_delay_enable << in s5p_mfc_init_decode_v5()
1055 S5P_FIMV_DDELAY_ENA_SHIFT) | ((ctx->display_delay & in s5p_mfc_init_decode_v5()
1060 | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); in s5p_mfc_init_decode_v5()
1064 static void s5p_mfc_set_flush(struct s5p_mfc_ctx *ctx, int flush) in s5p_mfc_set_flush() argument
1066 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_set_flush()
1079 static int s5p_mfc_decode_one_frame_v5(struct s5p_mfc_ctx *ctx, in s5p_mfc_decode_one_frame_v5() argument
1082 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_decode_one_frame_v5()
1084 mfc_write(dev, ctx->dec_dst_flag, S5P_FIMV_SI_CH0_RELEASE_BUF); in s5p_mfc_decode_one_frame_v5()
1085 s5p_mfc_set_shared_buffer(ctx); in s5p_mfc_decode_one_frame_v5()
1086 s5p_mfc_set_flush(ctx, ctx->dpb_flush_flag); in s5p_mfc_decode_one_frame_v5()
1092 S5P_FIMV_CH_SHIFT) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); in s5p_mfc_decode_one_frame_v5()
1096 S5P_FIMV_CH_SHIFT) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); in s5p_mfc_decode_one_frame_v5()
1100 S5P_FIMV_CH_MASK) << S5P_FIMV_CH_SHIFT) | (ctx->inst_no), in s5p_mfc_decode_one_frame_v5()
1108 static int s5p_mfc_init_encode_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_init_encode_v5() argument
1110 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_init_encode_v5()
1112 if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC) in s5p_mfc_init_encode_v5()
1113 s5p_mfc_set_enc_params_h264(ctx); in s5p_mfc_init_encode_v5()
1114 else if (ctx->codec_mode == S5P_MFC_CODEC_MPEG4_ENC) in s5p_mfc_init_encode_v5()
1115 s5p_mfc_set_enc_params_mpeg4(ctx); in s5p_mfc_init_encode_v5()
1116 else if (ctx->codec_mode == S5P_MFC_CODEC_H263_ENC) in s5p_mfc_init_encode_v5()
1117 s5p_mfc_set_enc_params_h263(ctx); in s5p_mfc_init_encode_v5()
1120 ctx->codec_mode); in s5p_mfc_init_encode_v5()
1123 s5p_mfc_set_shared_buffer(ctx); in s5p_mfc_init_encode_v5()
1125 (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); in s5p_mfc_init_encode_v5()
1130 static int s5p_mfc_encode_one_frame_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_encode_one_frame_v5() argument
1132 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_encode_one_frame_v5()
1135 if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12M) in s5p_mfc_encode_one_frame_v5()
1137 else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12MT) in s5p_mfc_encode_one_frame_v5()
1139 s5p_mfc_set_shared_buffer(ctx); in s5p_mfc_encode_one_frame_v5()
1141 if (ctx->state == MFCINST_FINISHING) in s5p_mfc_encode_one_frame_v5()
1146 | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); in s5p_mfc_encode_one_frame_v5()
1151 static void s5p_mfc_run_res_change(struct s5p_mfc_ctx *ctx) in s5p_mfc_run_res_change() argument
1153 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_run_res_change()
1155 s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0); in s5p_mfc_run_res_change()
1156 dev->curr_ctx = ctx->num; in s5p_mfc_run_res_change()
1157 s5p_mfc_decode_one_frame_v5(ctx, MFC_DEC_RES_CHANGE); in s5p_mfc_run_res_change()
1160 static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame) in s5p_mfc_run_dec_frame() argument
1162 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_run_dec_frame()
1165 if (ctx->state == MFCINST_FINISHING) { in s5p_mfc_run_dec_frame()
1167 s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0); in s5p_mfc_run_dec_frame()
1168 dev->curr_ctx = ctx->num; in s5p_mfc_run_dec_frame()
1169 s5p_mfc_decode_one_frame_v5(ctx, last_frame); in s5p_mfc_run_dec_frame()
1174 if (list_empty(&ctx->src_queue)) { in s5p_mfc_run_dec_frame()
1179 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); in s5p_mfc_run_dec_frame()
1181 s5p_mfc_set_dec_stream_buffer_v5(ctx, in s5p_mfc_run_dec_frame()
1183 ctx->consumed_stream, temp_vb->b->vb2_buf.planes[0].bytesused); in s5p_mfc_run_dec_frame()
1184 dev->curr_ctx = ctx->num; in s5p_mfc_run_dec_frame()
1188 ctx->state = MFCINST_FINISHING; in s5p_mfc_run_dec_frame()
1190 s5p_mfc_decode_one_frame_v5(ctx, last_frame); in s5p_mfc_run_dec_frame()
1194 static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx) in s5p_mfc_run_enc_frame() argument
1196 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_run_enc_frame()
1202 if (list_empty(&ctx->src_queue) && ctx->state != MFCINST_FINISHING) { in s5p_mfc_run_enc_frame()
1206 if (list_empty(&ctx->dst_queue)) { in s5p_mfc_run_enc_frame()
1210 if (list_empty(&ctx->src_queue)) { in s5p_mfc_run_enc_frame()
1212 s5p_mfc_set_enc_frame_buffer_v5(ctx, dev->dma_base[BANK_R_CTX], in s5p_mfc_run_enc_frame()
1216 src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, in s5p_mfc_run_enc_frame()
1221 s5p_mfc_set_enc_frame_buffer_v5(ctx, in s5p_mfc_run_enc_frame()
1224 ctx->state = MFCINST_FINISHING; in s5p_mfc_run_enc_frame()
1230 s5p_mfc_set_enc_frame_buffer_v5(ctx, src_y_addr, in s5p_mfc_run_enc_frame()
1233 ctx->state = MFCINST_FINISHING; in s5p_mfc_run_enc_frame()
1236 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); in s5p_mfc_run_enc_frame()
1240 s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size); in s5p_mfc_run_enc_frame()
1241 dev->curr_ctx = ctx->num; in s5p_mfc_run_enc_frame()
1243 src_mb ? src_mb->b->vb2_buf.index : -1, ctx->state); in s5p_mfc_run_enc_frame()
1244 s5p_mfc_encode_one_frame_v5(ctx); in s5p_mfc_run_enc_frame()
1248 static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx) in s5p_mfc_run_init_dec() argument
1250 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_run_init_dec()
1255 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); in s5p_mfc_run_init_dec()
1256 s5p_mfc_set_dec_desc_buffer(ctx); in s5p_mfc_run_init_dec()
1259 s5p_mfc_set_dec_stream_buffer_v5(ctx, in s5p_mfc_run_init_dec()
1262 dev->curr_ctx = ctx->num; in s5p_mfc_run_init_dec()
1263 s5p_mfc_init_decode_v5(ctx); in s5p_mfc_run_init_dec()
1266 static void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx) in s5p_mfc_run_init_enc() argument
1268 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_run_init_enc()
1273 s5p_mfc_set_enc_ref_buffer_v5(ctx); in s5p_mfc_run_init_enc()
1274 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); in s5p_mfc_run_init_enc()
1277 s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size); in s5p_mfc_run_init_enc()
1278 dev->curr_ctx = ctx->num; in s5p_mfc_run_init_enc()
1279 s5p_mfc_init_encode_v5(ctx); in s5p_mfc_run_init_enc()
1282 static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx) in s5p_mfc_run_init_dec_buffers() argument
1284 struct s5p_mfc_dev *dev = ctx->dev; in s5p_mfc_run_init_dec_buffers()
1292 if (ctx->capture_state != QUEUE_BUFS_MMAPED) { in s5p_mfc_run_init_dec_buffers()
1296 if (list_empty(&ctx->src_queue)) { in s5p_mfc_run_init_dec_buffers()
1300 temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); in s5p_mfc_run_init_dec_buffers()
1303 s5p_mfc_set_dec_stream_buffer_v5(ctx, in s5p_mfc_run_init_dec_buffers()
1306 dev->curr_ctx = ctx->num; in s5p_mfc_run_init_dec_buffers()
1307 ret = s5p_mfc_set_dec_frame_buffer_v5(ctx); in s5p_mfc_run_init_dec_buffers()
1310 ctx->state = MFCINST_ERROR; in s5p_mfc_run_init_dec_buffers()
1318 struct s5p_mfc_ctx *ctx; in s5p_mfc_try_run_v5() local
1343 ctx = dev->ctx[new_ctx]; in s5p_mfc_try_run_v5()
1350 s5p_mfc_clean_ctx_int_flags(ctx); in s5p_mfc_try_run_v5()
1352 if (ctx->type == MFCINST_DECODER) { in s5p_mfc_try_run_v5()
1353 s5p_mfc_set_dec_desc_buffer(ctx); in s5p_mfc_try_run_v5()
1354 switch (ctx->state) { in s5p_mfc_try_run_v5()
1356 s5p_mfc_run_dec_frame(ctx, MFC_DEC_LAST_FRAME); in s5p_mfc_try_run_v5()
1359 ret = s5p_mfc_run_dec_frame(ctx, MFC_DEC_FRAME); in s5p_mfc_try_run_v5()
1363 ctx); in s5p_mfc_try_run_v5()
1367 ctx); in s5p_mfc_try_run_v5()
1370 s5p_mfc_run_init_dec(ctx); in s5p_mfc_try_run_v5()
1373 ret = s5p_mfc_run_init_dec_buffers(ctx); in s5p_mfc_try_run_v5()
1377 s5p_mfc_run_res_change(ctx); in s5p_mfc_try_run_v5()
1380 s5p_mfc_run_dec_frame(ctx, MFC_DEC_FRAME); in s5p_mfc_try_run_v5()
1384 ctx->capture_state = QUEUE_FREE; in s5p_mfc_try_run_v5()
1386 s5p_mfc_run_init_dec(ctx); in s5p_mfc_try_run_v5()
1391 } else if (ctx->type == MFCINST_ENCODER) { in s5p_mfc_try_run_v5()
1392 switch (ctx->state) { in s5p_mfc_try_run_v5()
1395 ret = s5p_mfc_run_enc_frame(ctx); in s5p_mfc_try_run_v5()
1399 ctx); in s5p_mfc_try_run_v5()
1403 ctx); in s5p_mfc_try_run_v5()
1406 s5p_mfc_run_init_enc(ctx); in s5p_mfc_try_run_v5()
1412 mfc_err("Invalid context type: %d\n", ctx->type); in s5p_mfc_try_run_v5()
1462 static int s5p_mfc_get_disp_frame_type_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_get_disp_frame_type_v5() argument
1464 return (s5p_mfc_read_info_v5(ctx, DISP_PIC_FRAME_TYPE) >> in s5p_mfc_get_disp_frame_type_v5()
1573 static unsigned int s5p_mfc_get_pic_type_top_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_get_pic_type_top_v5() argument
1575 return s5p_mfc_read_info_v5(ctx, PIC_TIME_TOP); in s5p_mfc_get_pic_type_top_v5()
1578 static unsigned int s5p_mfc_get_pic_type_bot_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_get_pic_type_bot_v5() argument
1580 return s5p_mfc_read_info_v5(ctx, PIC_TIME_BOT); in s5p_mfc_get_pic_type_bot_v5()
1583 static unsigned int s5p_mfc_get_crop_info_h_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_get_crop_info_h_v5() argument
1585 return s5p_mfc_read_info_v5(ctx, CROP_INFO_H); in s5p_mfc_get_crop_info_h_v5()
1588 static unsigned int s5p_mfc_get_crop_info_v_v5(struct s5p_mfc_ctx *ctx) in s5p_mfc_get_crop_info_v_v5() argument
1590 return s5p_mfc_read_info_v5(ctx, CROP_INFO_V); in s5p_mfc_get_crop_info_v_v5()