u32 ddl_close(u32 **ddl_handle) { struct ddl_context *ddl_context; struct ddl_client_context **pp_ddl = (struct ddl_client_context **)ddl_handle; DDL_MSG_HIGH("ddl_close"); if (!pp_ddl || !*pp_ddl) { DDL_MSG_ERROR("ddl_close:Bad_handle"); return VCD_ERR_BAD_HANDLE; } ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(ddl_context)) { DDL_MSG_ERROR("ddl_close:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (!DDLCLIENT_STATE_IS(*pp_ddl, DDL_CLIENT_OPEN)) { DDL_MSG_ERROR("ddl_close:Not_in_open_state"); return VCD_ERR_ILLEGAL_OP; } ddl_pmem_free(&(*pp_ddl)->shared_mem[0]); if (ddl_context->frame_channel_depth == VCD_DUAL_FRAME_COMMAND_CHANNEL) ddl_pmem_free(&(*pp_ddl)->shared_mem[1]); DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_INVALID", ddl_get_state_string((*pp_ddl)->client_state)); (*pp_ddl)->client_state = DDL_CLIENT_INVALID; ddl_codec_type_transact(*pp_ddl, true, (enum vcd_codec)0); ddl_client_transact(DDL_FREE_CLIENT, pp_ddl); return VCD_S_SUCCESS; }
u32 ddl_open(u32 **ddl_handle, u32 decoding) { struct ddl_context *ddl_context; struct ddl_client_context *ddl; void *ptr; u32 status; DDL_MSG_HIGH("ddl_open"); if (!ddl_handle) { DDL_MSG_ERROR("ddl_open:Bad_handle"); return VCD_ERR_BAD_HANDLE; } ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(ddl_context)) { DDL_MSG_ERROR("ddl_open:Not_inited"); return VCD_ERR_ILLEGAL_OP; } status = ddl_client_transact(DDL_GET_CLIENT, &ddl); if (status) { DDL_MSG_ERROR("ddl_open:Client_trasac_failed"); return status; } ptr = ddl_pmem_alloc(&ddl->shared_mem[0], DDL_FW_AUX_HOST_CMD_SPACE_SIZE, sizeof(u32)); if (!ptr) status = VCD_ERR_ALLOC_FAIL; if (!status && ddl_context->frame_channel_depth == VCD_DUAL_FRAME_COMMAND_CHANNEL) { ptr = ddl_pmem_alloc(&ddl->shared_mem[1], DDL_FW_AUX_HOST_CMD_SPACE_SIZE, sizeof(u32)); if (!ptr) { ddl_pmem_free(&ddl->shared_mem[0]); status = VCD_ERR_ALLOC_FAIL; } } if (!status) { memset(ddl->shared_mem[0].align_virtual_addr, 0, DDL_FW_AUX_HOST_CMD_SPACE_SIZE); if (ddl_context->frame_channel_depth == VCD_DUAL_FRAME_COMMAND_CHANNEL) { memset(ddl->shared_mem[1].align_virtual_addr, 0, DDL_FW_AUX_HOST_CMD_SPACE_SIZE); } DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_OPEN", ddl_get_state_string(ddl->client_state)); ddl->client_state = DDL_CLIENT_OPEN; ddl->codec_data.hdr.decoding = decoding; ddl->decoding = decoding; ddl_set_default_meta_data_hdr(ddl); ddl_set_initial_default_values(ddl); *ddl_handle = (u32 *) ddl; } else { ddl_pmem_free(&ddl->shared_mem[0]); if (ddl_context->frame_channel_depth == VCD_DUAL_FRAME_COMMAND_CHANNEL) ddl_pmem_free(&ddl->shared_mem[1]); ddl_client_transact(DDL_FREE_CLIENT, &ddl); } return status; }
void ddl_release_client_internal_buffers(struct ddl_client_context_type *p_ddl) { if (p_ddl->b_decoding) { struct ddl_decoder_data_type *p_decoder = &(p_ddl->codec_data.decoder); ddl_pmem_free(p_decoder->h264Vsp_temp_buffer); ddl_pmem_free(p_decoder->dpb_comv_buffer); ddl_pmem_free(p_decoder->ref_buffer); DDL_FREE(p_decoder->dp_buf.a_dec_pic_buffers); ddl_decode_dynamic_property(p_ddl, FALSE); p_decoder->decode_config.n_sequence_header_len = 0; p_decoder->decode_config.p_sequence_header = NULL; p_decoder->dpb_mask.n_client_mask = 0; p_decoder->dpb_mask.n_hw_mask = 0; p_decoder->dp_buf.n_no_of_dec_pic_buf = 0; p_decoder->n_dynamic_prop_change = 0; } else { struct ddl_encoder_data_type *p_encoder = &(p_ddl->codec_data.encoder); ddl_pmem_free(p_encoder->enc_dpb_addr); ddl_pmem_free(p_encoder->seq_header); ddl_encode_dynamic_property(p_ddl, FALSE); p_encoder->n_dynamic_prop_change = 0; } }
void ddl_release_context_buffers(struct ddl_context_type *p_ddl_context) { ddl_pmem_free(p_ddl_context->context_buf_addr); ddl_pmem_free(p_ddl_context->db_line_buffer); ddl_pmem_free(p_ddl_context->data_partition_tempbuf); ddl_pmem_free(p_ddl_context->metadata_shared_input); ddl_pmem_free(p_ddl_context->dbg_core_dump); vcd_fw_release(); }
void vcd_fw_release(void) { ddl_pmem_free(vcd_firmware.boot_code); ddl_pmem_free(vcd_firmware.enc_mpeg4); ddl_pmem_free(vcd_firmware.encH264); ddl_pmem_free(vcd_firmware.dec_mpeg4); ddl_pmem_free(vcd_firmware.decH264); ddl_pmem_free(vcd_firmware.decH263); ddl_pmem_free(vcd_firmware.dec_mpeg2); ddl_pmem_free(vcd_firmware.dec_vc1); }
u32 ddl_encode_start(u32 *ddl_handle, void *client_data) { struct ddl_client_context *ddl = (struct ddl_client_context *) ddl_handle; struct ddl_context *ddl_context; struct ddl_encoder_data *encoder; void *ptr; u32 status = VCD_S_SUCCESS; DDL_MSG_HIGH("ddl_encode_start"); if (first_time < 2) { ddl_reset_core_time_variables(ENC_OP_TIME); first_time++; } ddl_set_core_start_time(__func__, ENC_OP_TIME); ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(ddl_context)) { DDL_MSG_ERROR("ddl_enc_start:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(ddl_context)) { DDL_MSG_ERROR("ddl_enc_start:Ddl_busy"); return VCD_ERR_BUSY; } if (!ddl || ddl->decoding) { DDL_MSG_ERROR("ddl_enc_start:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { DDL_MSG_ERROR("ddl_enc_start:Not_opened"); return VCD_ERR_ILLEGAL_OP; } if (!ddl_encoder_ready_to_start(ddl)) { DDL_MSG_ERROR("ddl_enc_start:Err_param_settings"); return VCD_ERR_ILLEGAL_OP; } encoder = &ddl->codec_data.encoder; if (DDL_IS_LTR_ENABLED(encoder)) { DDL_MSG_HIGH("LTR enabled, mode %u count %u", (u32)encoder->ltr_control.ltrmode.ltr_mode, (u32)encoder->ltr_control.ltr_count); status = ddl_allocate_ltr_list(&encoder->ltr_control); if (status) { DDL_MSG_ERROR("%s: allocate ltr list failed", __func__); return status; } else { ddl_clear_ltr_list(&encoder->ltr_control, false); } encoder->num_references_for_p_frame = 2; encoder->ltr_control.callback_reqd = false; encoder->ltr_control.curr_ltr_id = (u32)DDL_LTR_FRAME_START_ID; DDL_MSG_HIGH("num_ref_for_p_frames %u, curr_ltr_id = %u", (u32)encoder->num_references_for_p_frame, (u32)encoder->ltr_control.curr_ltr_id); } status = ddl_allocate_enc_hw_buffers(ddl); if (status) return status; #ifdef DDL_BUF_LOG ddl_list_buffers(ddl); #endif encoder->seq_header.mem_type = DDL_MM_MEM; ptr = ddl_pmem_alloc(&encoder->seq_header, DDL_ENC_SEQHEADER_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (!ptr) { ddl_free_enc_hw_buffers(ddl); DDL_MSG_ERROR("ddl_enc_start:Seq_hdr_alloc_failed"); return VCD_ERR_ALLOC_FAIL; } msm_ion_do_cache_op(ddl_context->video_ion_client, encoder->seq_header.alloc_handle, encoder->seq_header.virtual_base_addr, encoder->seq_header.buffer_size, ION_IOC_CLEAN_INV_CACHES); if (encoder->slice_delivery_info.enable) { DDL_MSG_LOW("%s: slice mode allocate memory for struct\n", __func__); ptr = ddl_pmem_alloc(&encoder->batch_frame.slice_batch_in, DDL_ENC_SLICE_BATCH_INPSTRUCT_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (ptr) { ptr = ddl_pmem_alloc( &encoder->batch_frame.slice_batch_out, DDL_ENC_SLICE_BATCH_OUTSTRUCT_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); } if (!ptr) { ddl_pmem_free(&encoder->batch_frame.slice_batch_in); ddl_pmem_free(&encoder->batch_frame.slice_batch_out); ddl_free_enc_hw_buffers(ddl); ddl_pmem_free(&encoder->seq_header); DDL_MSG_ERROR("ddlEncStart:SeqHdrAllocFailed"); return VCD_ERR_ALLOC_FAIL; } } if (!ddl_take_command_channel(ddl_context, ddl, client_data)) return VCD_ERR_BUSY; ddl_vidc_channel_set(ddl); return status; }
u32 ddl_encode_start(u32 *ddl_handle, void *client_data) { struct ddl_client_context *ddl = (struct ddl_client_context *)ddl_handle; struct ddl_context *ddl_context; struct ddl_encoder_data *encoder; u32 dpb_size; ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(ddl_context)) { VIDC_LOGERR_STRING("ddl_enc_start:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(ddl_context)) { VIDC_LOGERR_STRING("ddl_enc_start:Ddl_busy"); return VCD_ERR_BUSY; } if (!ddl || ddl->decoding) { VIDC_LOGERR_STRING("ddl_enc_start:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { VIDC_LOGERR_STRING("ddl_enc_start:Not_opened"); return VCD_ERR_ILLEGAL_OP; } if (!ddl_encoder_ready_to_start(ddl)) { VIDC_LOGERR_STRING("ddl_enc_start:Err_param_settings"); return VCD_ERR_ILLEGAL_OP; } encoder = &ddl->codec_data.encoder; dpb_size = ddl_get_yuv_buffer_size(&encoder->frame_size, &encoder->re_con_buf_format, false, encoder->codec.codec); dpb_size *= DDL_ENC_NUM_DPB_BUFFERS; ddl_pmem_alloc(&encoder->enc_dpb_addr, dpb_size, DDL_TILE_BUFFER_ALIGN_BYTES); if (!encoder->enc_dpb_addr.virtual_base_addr) { VIDC_LOGERR_STRING("ddl_enc_start:Dpb_alloc_failed"); return VCD_ERR_ALLOC_FAIL; } if ((encoder->codec.codec == VCD_CODEC_MPEG4 && !encoder->short_header.short_header) || encoder->codec.codec == VCD_CODEC_H264) { ddl_pmem_alloc(&encoder->seq_header, DDL_ENC_SEQHEADER_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (!encoder->seq_header.virtual_base_addr) { ddl_pmem_free(&encoder->enc_dpb_addr); VIDC_LOGERR_STRING ("ddl_enc_start:Seq_hdr_alloc_failed"); return VCD_ERR_ALLOC_FAIL; } } else { encoder->seq_header.buffer_size = 0; encoder->seq_header.virtual_base_addr = 0; } DDL_BUSY(ddl_context); ddl_context->current_ddl = ddl; ddl_context->client_data = client_data; ddl_channel_set(ddl); return VCD_S_SUCCESS; }
u32 ddl_encode_start(u32 *ddl_handle, void *client_data) { struct ddl_client_context *ddl = (struct ddl_client_context *) ddl_handle; struct ddl_context *ddl_context; struct ddl_encoder_data *encoder; void *ptr; u32 status = VCD_S_SUCCESS; DDL_MSG_HIGH("ddl_encode_start"); if (vidc_msg_timing) { if (first_time < 2) { ddl_reset_core_time_variables(ENC_OP_TIME); first_time++; } ddl_set_core_start_time(__func__, ENC_OP_TIME); } ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(ddl_context)) { DDL_MSG_ERROR("ddl_enc_start:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(ddl_context)) { DDL_MSG_ERROR("ddl_enc_start:Ddl_busy"); return VCD_ERR_BUSY; } if (!ddl || ddl->decoding) { DDL_MSG_ERROR("ddl_enc_start:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { DDL_MSG_ERROR("ddl_enc_start:Not_opened"); return VCD_ERR_ILLEGAL_OP; } if (!ddl_encoder_ready_to_start(ddl)) { DDL_MSG_ERROR("ddl_enc_start:Err_param_settings"); return VCD_ERR_ILLEGAL_OP; } encoder = &ddl->codec_data.encoder; status = ddl_allocate_enc_hw_buffers(ddl); if (status) return status; #ifdef DDL_BUF_LOG ddl_list_buffers(ddl); #endif #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION encoder->seq_header.mem_type = DDL_MM_MEM; #endif ptr = ddl_pmem_alloc(&encoder->seq_header, DDL_ENC_SEQHEADER_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (!ptr) { ddl_free_enc_hw_buffers(ddl); DDL_MSG_ERROR("ddl_enc_start:Seq_hdr_alloc_failed"); return VCD_ERR_ALLOC_FAIL; } if (encoder->slice_delivery_info.enable) { DDL_MSG_LOW("%s: slice mode allocate memory for struct\n", __func__); ptr = ddl_pmem_alloc(&encoder->batch_frame.slice_batch_in, DDL_ENC_SLICE_BATCH_INPSTRUCT_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (ptr) { ptr = ddl_pmem_alloc( &encoder->batch_frame.slice_batch_out, DDL_ENC_SLICE_BATCH_OUTSTRUCT_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); } if (!ptr) { ddl_pmem_free(&encoder->batch_frame.slice_batch_in); ddl_pmem_free(&encoder->batch_frame.slice_batch_out); ddl_free_enc_hw_buffers(ddl); ddl_pmem_free(&encoder->seq_header); DDL_MSG_ERROR("ddlEncStart:SeqHdrAllocFailed"); return VCD_ERR_ALLOC_FAIL; } } if (!ddl_take_command_channel(ddl_context, ddl, client_data)) return VCD_ERR_BUSY; ddl_vidc_channel_set(ddl); return status; }
u32 ddl_encode_start(u32 *ddl_handle, void *p_client_data) { struct ddl_client_context_type *p_ddl = (struct ddl_client_context_type *)ddl_handle; struct ddl_context_type *p_ddl_context; struct ddl_encoder_data_type *p_encoder; u32 n_dpb_size; p_ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(p_ddl_context)) { VIDC_LOGERR_STRING("ddl_enc_start:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(p_ddl_context)) { VIDC_LOGERR_STRING("ddl_enc_start:Ddl_busy"); return VCD_ERR_BUSY; } if (NULL == p_ddl || TRUE == p_ddl->b_decoding) { VIDC_LOGERR_STRING("ddl_enc_start:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_OPEN)) { VIDC_LOGERR_STRING("ddl_enc_start:Not_opened"); return VCD_ERR_ILLEGAL_OP; } if (FALSE == ddl_encoder_ready_to_start(p_ddl)) { VIDC_LOGERR_STRING("ddl_enc_start:Err_param_settings"); return VCD_ERR_ILLEGAL_OP; } p_encoder = &p_ddl->codec_data.encoder; n_dpb_size = ddl_get_yuv_buffer_size(&p_encoder->frame_size, &p_encoder->re_con_buf_format, FALSE); n_dpb_size *= DDL_ENC_NUM_DPB_BUFFERS; ddl_pmem_alloc(&p_encoder->enc_dpb_addr, n_dpb_size, DDL_TILE_BUFFER_ALIGN_BYTES); if (NULL == p_encoder->enc_dpb_addr.p_virtual_base_addr) { VIDC_LOGERR_STRING("ddl_enc_start:Dpb_alloc_failed"); return VCD_ERR_ALLOC_FAIL; } if ((VCD_CODEC_MPEG4 == p_encoder->codec_type.e_codec && FALSE == p_encoder->short_header.b_short_header) || VCD_CODEC_H264 == p_encoder->codec_type.e_codec) { ddl_pmem_alloc(&p_encoder->seq_header, DDL_ENC_SEQHEADER_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (NULL == p_encoder->seq_header.p_virtual_base_addr) { ddl_pmem_free(p_encoder->enc_dpb_addr); VIDC_LOGERR_STRING ("ddl_enc_start:Seq_hdr_alloc_failed"); return VCD_ERR_ALLOC_FAIL; } } else { p_encoder->seq_header.n_buffer_size = 0; p_encoder->seq_header.p_virtual_base_addr = 0; } DDL_BUSY(p_ddl_context); p_ddl_context->p_current_ddl = p_ddl; p_ddl_context->p_client_data = p_client_data; ddl_channel_set(p_ddl); return VCD_S_SUCCESS; }