MFC_ERROR_CODE s3c_mfc_allocate_frame_buf(s3c_mfc_inst_ctx *mfc_ctx, s3c_mfc_args *args, s3c_mfc_frame_buf_arg_t buf_size) { s3c_mfc_dec_init_arg_t *init_arg; s3c_mfc_args local_param; unsigned int luma_size, chroma_size; MFC_ERROR_CODE ret_code = MFCINST_RET_OK; init_arg = (s3c_mfc_dec_init_arg_t *)args; luma_size = buf_size.luma; chroma_size = buf_size.chroma; /* * Allocate luma buf */ init_arg.out_frame_buf_size.luma = luma_size; memset(&local_param, 0, sizeof(local_param)); local_param.mem_alloc.buff_size = Align(luma_size, 2*BUF_S_UNIT); local_param.mem_alloc.mapped_addr = init_arg.in_mapped_addr; mfc_ctx->port_no = 0; ret_code = s3c_mfc_get_virt_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg.out_u_addr.luma = local_param.mem_alloc.out_addr; memset(&local_param, 0, sizeof(local_param)); local_param.get_phys_addr.u_addr = init_arg.out_u_addr.luma; ret_code = s3c_mfc_get_phys_addr(mfc_ctx, &local_param); if (ret_code < 0) return ret_code; init_arg.out_p_addr.luma = local_param.get_phys_addr.p_addr; /* * Allocate chroma & (Mv in case of H264) buf */ init_arg.out_frame_buf_size.chroma = chroma_size; memset(&local_param, 0, sizeof(local_param)); local_param.mem_alloc.buff_size = Align(chroma_size, 2*BUF_S_UNIT); local_param.mem_alloc.mapped_addr = init_arg.in_mapped_addr; // peter, it chould be checked in related to luma cases mfc_ctx->port_no = 1; ret_code = s3c_mfc_get_virt_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg.out_u_addr.chroma = local_param.mem_alloc.out_addr; memset(&local_param, 0, sizeof(local_param)); local_param.get_phys_addr.u_addr = init_arg.out_u_addr.chroma; ret_code = s3c_mfc_get_phys_addr(mfc_ctx, &local_param); if (ret_code < 0) return ret_code; init_arg.out_p_addr.chroma = local_param.get_phys_addr.p_addr; return ret_code; }
/* Allocate buffers for decoder */ enum SSBSIP_MFC_ERROR_CODE s3c_mfc_allocate_frame_buf(struct s3c_mfc_inst_ctx *mfc_ctx, union s3c_mfc_args *args, struct s3c_mfc_frame_buf_arg_t buf_size) { struct s3c_mfc_dec_init_arg_t *init_arg; union s3c_mfc_args local_param; unsigned int luma_size, chroma_size; enum SSBSIP_MFC_ERROR_CODE ret_code = MFC_RET_OK; init_arg = (struct s3c_mfc_dec_init_arg_t *) args; luma_size = ALIGN(buf_size.luma, 2 * BUF_L_UNIT) * mfc_ctx->totalDPBCnt; chroma_size = ALIGN(buf_size.chroma, 2 * BUF_L_UNIT) * mfc_ctx->totalDPBCnt; /* * Allocate chroma buf */ init_arg->out_frame_buf_size.chroma = chroma_size; memset(&local_param, 0, sizeof(local_param)); local_param.mem_alloc.buff_size = ALIGN(chroma_size, 2 * BUF_S_UNIT); local_param.mem_alloc.mapped_addr = init_arg->in_mapped_addr; mfc_ctx->mapped_addr = init_arg->in_mapped_addr; mfc_ctx->port_no = 0; ret_code = s3c_mfc_get_virt_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg->out_u_addr.chroma = local_param.mem_alloc.out_addr; memset(&local_param, 0, sizeof(local_param)); local_param.get_phys_addr.u_addr = init_arg->out_u_addr.chroma; ret_code = s3c_mfc_get_phys_addr(mfc_ctx, &local_param); if (ret_code < 0) return ret_code; init_arg->out_p_addr.chroma = local_param.get_phys_addr.p_addr; /* * Allocate luma buf & (Mv in case of H264) buf */ init_arg->out_frame_buf_size.luma = luma_size; /* It chould be checked in related to luma cases */ memset(&local_param, 0, sizeof(local_param)); local_param.mem_alloc.buff_size = ALIGN(luma_size, 2 * BUF_S_UNIT); local_param.mem_alloc.mapped_addr = init_arg->in_mapped_addr; #if CONFIG_VIDEO_MFC_MEM_PORT_COUNT == 1 mfc_ctx->port_no = 0; #else mfc_ctx->port_no = 1; #endif ret_code = s3c_mfc_get_virt_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg->out_u_addr.luma = local_param.mem_alloc.out_addr; memset(&local_param, 0, sizeof(local_param)); local_param.get_phys_addr.u_addr = init_arg->out_u_addr.luma; ret_code = s3c_mfc_get_phys_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg->out_p_addr.luma = local_param.get_phys_addr.p_addr; return ret_code; }
/* Allocate buffers for encoder */ MFC_ERROR_CODE s3c_mfc_allocate_stream_ref_buf(s3c_mfc_inst_ctx *mfc_ctx, s3c_mfc_args *args) { s3c_mfc_enc_init_mpeg4_arg_t *init_arg; s3c_mfc_args local_param; unsigned int buf_width, buf_height; MFC_ERROR_CODE ret_code = MFCINST_RET_OK; init_arg = (s3c_mfc_enc_init_mpeg4_arg_t *)args; /* * Allocate stream & ref Y0, Y2 buf */ buf_width = (mfc_ctx->img_width+15)/16*16; buf_height = (mfc_ctx->img_height+31)/32*32; init_arg->out_buf_size.strm_ref_y = STREAM_BUF_SIZE + Align(buf_width*buf_height, 64*BUF_L_UNIT)*2; memset(&local_param, 0, sizeof(local_param)); local_param.mem_alloc.buff_size = Align(init_arg->out_buf_size.strm_ref_y, 2*BUF_S_UNIT); local_param.mem_alloc.mapped_addr = init_arg->in_mapped_addr; mfc_ctx->port_no = 0; ret_code = s3c_mfc_get_virt_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg->out_u_addr.strm_ref_y = local_param.mem_alloc.out_addr; memset(&local_param, 0, sizeof(local_param)); local_param.get_phys_addr.u_addr = init_arg->out_u_addr.strm_ref_y; ret_code = s3c_mfc_get_phys_addr(mfc_ctx, &local_param); if (ret_code < 0) return ret_code; init_arg->out_p_addr.strm_ref_y = local_param.get_phys_addr.p_addr; /* * Allocate ref C0,C2,YC1,YC3 & MV buf */ init_arg->out_buf_size.mv_ref_yc = MV_BUF_SIZE + Align(buf_width*buf_height, 64*BUF_L_UNIT)*2 + Align(buf_width*buf_height/2, 64*BUF_L_UNIT)*4; memset(&local_param, 0, sizeof(local_param)); /* In IOCTL_MFC_GET_IN_BUF(), Cur Y/C buf start addr should be 64KB aligned */ local_param.mem_alloc.buff_size = Align(init_arg->out_buf_size.mv_ref_yc, 64*BUF_L_UNIT); local_param.mem_alloc.mapped_addr = init_arg->in_mapped_addr; // peter, it chould be checked in related to luma cases mfc_ctx->port_no = 1; ret_code = s3c_mfc_get_virt_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg->out_u_addr.mv_ref_yc = local_param.mem_alloc.out_addr; memset(&local_param, 0, sizeof(local_param)); local_param.get_phys_addr.u_addr = init_arg->out_u_addr.mv_ref_yc; ret_code = s3c_mfc_get_phys_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg->out_p_addr.mv_ref_yc = local_param.get_phys_addr.p_addr; return ret_code; }
/* Allocate buffers for encoder */ enum SSBSIP_MFC_ERROR_CODE s3c_mfc_allocate_stream_ref_buf(struct s3c_mfc_inst_ctx * mfc_ctx, union s3c_mfc_args *args) { struct s3c_mfc_enc_init_mpeg4_arg_t *init_arg; union s3c_mfc_args local_param; unsigned int buf_width, buf_height; enum SSBSIP_MFC_ERROR_CODE ret_code = MFC_RET_OK; init_arg = (struct s3c_mfc_enc_init_mpeg4_arg_t *) args; /* * Allocate stream & ref Y0, Y2 buf */ buf_width = (mfc_ctx->img_width + 15) / 16 * 16; buf_height = (mfc_ctx->img_height + 31) / 32 * 32; /* MFC fw 10/30, EVT0 */ #if defined(CONFIG_CPU_S5PV210_EVT0) init_arg->out_buf_size.strm_ref_y = STREAM_BUF_SIZE + ALIGN(buf_width * buf_height, 64 * BUF_L_UNIT) * 3 + ALIGN(buf_width * buf_height / 2, 64 * BUF_L_UNIT); #else init_arg->out_buf_size.strm_ref_y = STREAM_BUF_SIZE + ALIGN(buf_width * buf_height, 64 * BUF_L_UNIT) * 2; #endif memset(&local_param, 0, sizeof(local_param)); local_param.mem_alloc.buff_size = ALIGN(init_arg->out_buf_size.strm_ref_y, 2 * BUF_S_UNIT); local_param.mem_alloc.mapped_addr = init_arg->in_mapped_addr; mfc_ctx->port_no = 0; ret_code = s3c_mfc_get_virt_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg->out_u_addr.strm_ref_y = local_param.mem_alloc.out_addr; memset(&local_param, 0, sizeof(local_param)); local_param.get_phys_addr.u_addr = init_arg->out_u_addr.strm_ref_y; ret_code = s3c_mfc_get_phys_addr(mfc_ctx, &local_param); if (ret_code < 0) return ret_code; init_arg->out_p_addr.strm_ref_y = local_param.get_phys_addr.p_addr; /* * Allocate ref C0,C2,YC1,YC3 & MV buf */ init_arg->out_buf_size.mv_ref_yc = ENC_UP_INTRA_PRED_SIZE + ALIGN(buf_width * buf_height, 64 * BUF_L_UNIT) * 2 + ALIGN(buf_width * buf_height / 2, 64 * BUF_L_UNIT) * 4; memset(&local_param, 0, sizeof(local_param)); /* In IOCTL_MFC_GET_IN_BUF(), * Cur Y/C buf start addr should be 64KB aligned */ local_param.mem_alloc.buff_size = ALIGN(init_arg->out_buf_size.mv_ref_yc, 64 * BUF_L_UNIT); local_param.mem_alloc.mapped_addr = init_arg->in_mapped_addr; #if CONFIG_VIDEO_MFC_MEM_PORT_COUNT == 1 mfc_ctx->port_no = 0; #else mfc_ctx->port_no = 1; #endif ret_code = s3c_mfc_get_virt_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg->out_u_addr.mv_ref_yc = local_param.mem_alloc.out_addr; memset(&local_param, 0, sizeof(local_param)); local_param.get_phys_addr.u_addr = init_arg->out_u_addr.mv_ref_yc; ret_code = s3c_mfc_get_phys_addr(mfc_ctx, &(local_param)); if (ret_code < 0) return ret_code; init_arg->out_p_addr.mv_ref_yc = local_param.get_phys_addr.p_addr; return ret_code; }