void *ddl_pmem_alloc(struct ddl_buf_addr *addr, size_t sz, u32 alignment) { u32 alloc_size, offset = 0 ; u32 index = 0; struct ddl_context *ddl_context; struct msm_mapped_buffer *mapped_buffer = NULL; unsigned long iova = 0; unsigned long buffer_size = 0; unsigned long *kernel_vaddr = NULL; unsigned long ionflag = 0; unsigned long flags = 0; int ret = 0; ion_phys_addr_t phyaddr = 0; size_t len = 0; int rc = 0; DBG_PMEM("\n%s() IN: Requested alloc size(%u)", __func__, (u32)sz); if (!addr) { DDL_MSG_ERROR("\n%s() Invalid Parameters", __func__); goto bail_out; } ddl_context = ddl_get_context(); res_trk_set_mem_type(addr->mem_type); alloc_size = (sz + alignment); if (res_trk_get_enable_ion()) { if (!ddl_context->video_ion_client) ddl_context->video_ion_client = res_trk_get_ion_client(); if (!ddl_context->video_ion_client) { DDL_MSG_ERROR("%s() :DDL ION Client Invalid handle\n", __func__); goto bail_out; } alloc_size = (alloc_size+4095) & ~4095; addr->alloc_handle = ion_alloc( ddl_context->video_ion_client, alloc_size, SZ_4K, res_trk_get_mem_type(), res_trk_get_ion_flags()); if (IS_ERR_OR_NULL(addr->alloc_handle)) { DDL_MSG_ERROR("%s() :DDL ION alloc failed\n", __func__); goto bail_out; } if (res_trk_check_for_sec_session() || addr->mem_type == DDL_FW_MEM) ionflag = 0; else ionflag = ION_FLAG_CACHED; kernel_vaddr = (unsigned long *) ion_map_kernel( ddl_context->video_ion_client, addr->alloc_handle); if (IS_ERR_OR_NULL(kernel_vaddr)) { DDL_MSG_ERROR("%s() :DDL ION map failed\n", __func__); goto free_ion_alloc; } addr->virtual_base_addr = (u8 *) kernel_vaddr; if (res_trk_check_for_sec_session()) { rc = ion_phys(ddl_context->video_ion_client, addr->alloc_handle, &phyaddr, &len); if (rc || !phyaddr) { DDL_MSG_ERROR( "%s():DDL ION client physical failed\n", __func__); goto unmap_ion_alloc; } addr->alloced_phys_addr = phyaddr; } else { ret = ion_map_iommu(ddl_context->video_ion_client, addr->alloc_handle, VIDEO_DOMAIN, VIDEO_MAIN_POOL, SZ_4K, 0, &iova, &buffer_size, 0, 0); if (ret || !iova) { DDL_MSG_ERROR( "%s():DDL ION ion map iommu failed, ret = %d iova = 0x%lx\n", __func__, ret, iova); goto unmap_ion_alloc; } addr->alloced_phys_addr = (phys_addr_t) iova; msm_ion_do_cache_op(ddl_context->video_ion_client, addr->alloc_handle, addr->virtual_base_addr, sz, ION_IOC_CLEAN_INV_CACHES); } if (!addr->alloced_phys_addr) { DDL_MSG_ERROR("%s():DDL ION client physical failed\n", __func__); goto unmap_ion_alloc; } addr->mapped_buffer = NULL; addr->physical_base_addr = (u8 *) addr->alloced_phys_addr; addr->align_physical_addr = (u8 *) DDL_ALIGN((u32) addr->physical_base_addr, alignment); offset = (u32)(addr->align_physical_addr - addr->physical_base_addr); addr->align_virtual_addr = addr->virtual_base_addr + offset; addr->buffer_size = alloc_size; } else { addr->alloced_phys_addr = (phys_addr_t) allocate_contiguous_memory_nomap(alloc_size, res_trk_get_mem_type(), SZ_4K); if (!addr->alloced_phys_addr) { DDL_MSG_ERROR("%s() : acm alloc failed (%d)\n", __func__, alloc_size); goto bail_out; } flags = MSM_SUBSYSTEM_MAP_IOVA | MSM_SUBSYSTEM_MAP_KADDR; if (alignment == DDL_KILO_BYTE(128)) index = 1; else if (alignment > SZ_4K) flags |= MSM_SUBSYSTEM_ALIGN_IOVA_8K; addr->mapped_buffer = msm_subsystem_map_buffer((unsigned long)addr->alloced_phys_addr, alloc_size, flags, &vidc_mmu_subsystem[index], sizeof(vidc_mmu_subsystem[index])/sizeof(unsigned int)); if (IS_ERR(addr->mapped_buffer)) { pr_err(" %s() buffer map failed", __func__); goto free_acm_alloc; } mapped_buffer = addr->mapped_buffer; if (!mapped_buffer->vaddr || !mapped_buffer->iova[0]) { pr_err("%s() map buffers failed\n", __func__); goto free_map_buffers; } addr->physical_base_addr = (u8 *)mapped_buffer->iova[0]; addr->virtual_base_addr = mapped_buffer->vaddr; addr->align_physical_addr = (u8 *) DDL_ALIGN((u32) addr->physical_base_addr, alignment); offset = (u32)(addr->align_physical_addr - addr->physical_base_addr); addr->align_virtual_addr = addr->virtual_base_addr + offset; addr->buffer_size = sz; } return addr->virtual_base_addr; free_map_buffers: msm_subsystem_unmap_buffer(addr->mapped_buffer); addr->mapped_buffer = NULL; free_acm_alloc: free_contiguous_memory_by_paddr( (unsigned long)addr->alloced_phys_addr); addr->alloced_phys_addr = (phys_addr_t)NULL; return NULL; unmap_ion_alloc: ion_unmap_kernel(ddl_context->video_ion_client, addr->alloc_handle); addr->virtual_base_addr = NULL; addr->alloced_phys_addr = (phys_addr_t)NULL; free_ion_alloc: ion_free(ddl_context->video_ion_client, addr->alloc_handle); addr->alloc_handle = NULL; bail_out: return NULL; }
static void vcd_dev_cb_in_initing (struct vcd_drv_ctxt *drv_ctxt, u32 event, u32 status, void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { struct vcd_dev_ctxt *dev_ctxt; struct vcd_clnt_ctxt *client; struct vcd_clnt_ctxt *tmp_client; struct vcd_handle_container container; u32 rc = VCD_S_SUCCESS; u32 client_inited = false; u32 fail_all_open = false; struct ddl_context *ddl_context; ddl_context = ddl_get_context(); VCD_MSG_LOW("vcd_dev_cb_in_initing:"); if (event != VCD_EVT_RESP_DEVICE_INIT) { VCD_MSG_ERROR("vcd_dev_cb_in_initing: Unexpected event %d", (int)event); return; } dev_ctxt = &drv_ctxt->dev_ctxt; dev_ctxt->command_continue = false; if (VCD_FAILED(status)) { vcd_handle_device_init_failed(drv_ctxt, status); return; } vcd_do_device_state_transition(drv_ctxt, VCD_DEVICE_STATE_READY, DEVICE_STATE_EVENT_NUMBER(open)); if (!dev_ctxt->cctxt_list_head) { VCD_MSG_HIGH("All clients are closed"); dev_ctxt->pending_cmd = VCD_CMD_DEVICE_TERM; return; } if (!dev_ctxt->ddl_cmd_ch_depth || !dev_ctxt->trans_tbl) rc = vcd_setup_with_ddl_capabilities(dev_ctxt); if (VCD_FAILED(rc)) { VCD_MSG_ERROR ("rc = 0x%x: Failed vcd_setup_with_ddl_capabilities", rc); fail_all_open = true; } client = dev_ctxt->cctxt_list_head; while (client) { if (!fail_all_open) rc = vcd_init_client_context(client); if (!VCD_FAILED(rc)) { container.handle = (void *)client; client->callback(VCD_EVT_RESP_OPEN, VCD_S_SUCCESS, &container, sizeof(container), container.handle, client->client_data); client = client->next; client_inited = true; } else { VCD_MSG_ERROR ("rc = 0x%x, Failed: vcd_init_client_context", rc); client->callback(VCD_EVT_RESP_OPEN, rc, NULL, 0, 0, client->client_data); tmp_client = client; client = client->next; if (tmp_client == dev_ctxt->cctxt_list_head) fail_all_open = true; vcd_destroy_client_context(tmp_client); } } if (!client_inited || fail_all_open) { VCD_MSG_ERROR("All client open requests failed"); DDL_IDLE(ddl_context); vcd_handle_device_init_failed(drv_ctxt, DEVICE_STATE_EVENT_NUMBER(close)); dev_ctxt->pending_cmd = VCD_CMD_DEVICE_TERM; } else { if (vcd_power_event(dev_ctxt, NULL, VCD_EVT_PWR_DEV_INIT_END)) { VCD_MSG_ERROR("VCD_EVT_PWR_DEV_INIT_END failed"); } } }
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; }
void *ddl_pmem_alloc(struct ddl_buf_addr *addr, size_t sz, u32 alignment) { u32 alloc_size, offset = 0, flags = 0; u32 index = 0; struct ddl_context *ddl_context; struct msm_mapped_buffer *mapped_buffer = NULL; int rc = -EINVAL; ion_phys_addr_t phyaddr = 0; size_t len = 0; DBG_PMEM("\n%s() IN: Requested alloc size(%u)", __func__, (u32)sz); if (!addr) { DDL_MSG_ERROR("\n%s() Invalid Parameters", __func__); goto bail_out; } ddl_context = ddl_get_context(); res_trk_set_mem_type(addr->mem_type); alloc_size = (sz + alignment); if (res_trk_get_enable_ion()) { if (!ddl_context->video_ion_client) ddl_context->video_ion_client = res_trk_get_ion_client(); if (!ddl_context->video_ion_client) { DDL_MSG_ERROR("%s() :DDL ION Client Invalid handle\n", __func__); goto bail_out; } addr->alloc_handle = ion_alloc( ddl_context->video_ion_client, alloc_size, SZ_4K, res_trk_get_mem_type()); if (IS_ERR_OR_NULL(addr->alloc_handle)) { DDL_MSG_ERROR("%s() :DDL ION alloc failed\n", __func__); goto bail_out; } rc = ion_phys(ddl_context->video_ion_client, addr->alloc_handle, &phyaddr, &len); if (rc || !phyaddr) { DDL_MSG_ERROR("%s():DDL ION client physical failed\n", __func__); goto free_acm_ion_alloc; } addr->alloced_phys_addr = phyaddr; } else { addr->alloced_phys_addr = (phys_addr_t) allocate_contiguous_memory_nomap(alloc_size, res_trk_get_mem_type(), SZ_4K); if (!addr->alloced_phys_addr) { DDL_MSG_ERROR("%s() : acm alloc failed (%d)\n", __func__, alloc_size); goto bail_out; } } flags = MSM_SUBSYSTEM_MAP_IOVA | MSM_SUBSYSTEM_MAP_KADDR; if (alignment == DDL_KILO_BYTE(128)) index = 1; else if (alignment > SZ_4K) flags |= MSM_SUBSYSTEM_ALIGN_IOVA_8K; addr->mapped_buffer = msm_subsystem_map_buffer((unsigned long)addr->alloced_phys_addr, alloc_size, flags, &vidc_mmu_subsystem[index], sizeof(vidc_mmu_subsystem[index])/sizeof(unsigned int)); if (IS_ERR(addr->mapped_buffer)) { pr_err(" %s() buffer map failed", __func__); goto free_acm_ion_alloc; } mapped_buffer = addr->mapped_buffer; if (!mapped_buffer->vaddr || !mapped_buffer->iova[0]) { pr_err("%s() map buffers failed\n", __func__); goto free_map_buffers; } addr->physical_base_addr = (u8 *)mapped_buffer->iova[0]; addr->virtual_base_addr = mapped_buffer->vaddr; addr->align_physical_addr = (u8 *) DDL_ALIGN((u32) addr->physical_base_addr, alignment); offset = (u32)(addr->align_physical_addr - addr->physical_base_addr); addr->align_virtual_addr = addr->virtual_base_addr + offset; addr->buffer_size = sz; return addr->virtual_base_addr; free_map_buffers: msm_subsystem_unmap_buffer(addr->mapped_buffer); addr->mapped_buffer = NULL; free_acm_ion_alloc: if (ddl_context->video_ion_client) { if (addr->alloc_handle) { ion_free(ddl_context->video_ion_client, addr->alloc_handle); addr->alloc_handle = NULL; } } else { free_contiguous_memory_by_paddr( (unsigned long)addr->alloced_phys_addr); addr->alloced_phys_addr = (phys_addr_t)NULL; } bail_out: return NULL; }
u32 ddl_encode_frame(u32 *ddl_handle, struct ddl_frame_data_tag *input_frame, struct ddl_frame_data_tag *output_bit, void *client_data) { struct ddl_client_context *ddl = (struct ddl_client_context *)ddl_handle; struct ddl_context *ddl_context = ddl_get_context(); if (vidc_msg_timing) ddl_set_core_start_time(__func__, ENC_OP_TIME); if (!DDL_IS_INITIALIZED(ddl_context)) { VIDC_LOGERR_STRING("ddl_enc_frame:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(ddl_context)) { VIDC_LOGERR_STRING("ddl_enc_frame:Ddl_busy"); return VCD_ERR_BUSY; } if (!ddl || ddl->decoding) { VIDC_LOGERR_STRING("ddl_enc_frame:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!input_frame || !input_frame->vcd_frm.physical || !input_frame->vcd_frm.data_len) { VIDC_LOGERR_STRING("ddl_enc_frame:Bad_input_params"); return VCD_ERR_ILLEGAL_PARM; } if ((((u32) input_frame->vcd_frm.physical + input_frame->vcd_frm.offset) & (DDL_STREAMBUF_ALIGN_GUARD_BYTES) ) ) { VIDC_LOGERR_STRING ("ddl_enc_frame:Un_aligned_yuv_start_address"); return VCD_ERR_ILLEGAL_PARM; } if (!output_bit || !output_bit->vcd_frm.physical || !output_bit->vcd_frm.alloc_len) { VIDC_LOGERR_STRING("ddl_enc_frame:Bad_output_params"); return VCD_ERR_ILLEGAL_PARM; } if ((ddl->codec_data.encoder.output_buf_req.sz + output_bit->vcd_frm.offset) > output_bit->vcd_frm.alloc_len) { VIDC_LOGERR_STRING ("ddl_enc_frame:offset_large, Exceeds_min_buf_size"); } if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) { VIDC_LOGERR_STRING("ddl_enc_frame:Wrong_state"); return VCD_ERR_ILLEGAL_OP; } DDL_BUSY(ddl_context); ddl_context->current_ddl = ddl; ddl_context->client_data = client_data; ddl->input_frame = *input_frame; ddl->output_frame = *output_bit; ddl_encode_frame_run(ddl); return VCD_S_SUCCESS; }
static void *res_trk_pmem_map (struct ddl_buf_addr *addr, size_t sz, u32 alignment) { u32 offset = 0, flags = 0; u32 index = 0; struct ddl_context *ddl_context; struct msm_mapped_buffer *mapped_buffer = NULL; int ret = 0; unsigned long iova = 0; unsigned long buffer_size = 0; unsigned long *kernel_vaddr = NULL; ddl_context = ddl_get_context(); if (res_trk_get_enable_ion() && addr->alloc_handle) { kernel_vaddr = (unsigned long *) ion_map_kernel( ddl_context->video_ion_client, addr->alloc_handle); if (IS_ERR_OR_NULL(kernel_vaddr)) { DDL_MSG_ERROR("%s():DDL ION client map failed\n", __func__); goto ion_bail_out; } addr->virtual_base_addr = (u8 *) kernel_vaddr; ret = ion_map_iommu(ddl_context->video_ion_client, addr->alloc_handle, VIDEO_DOMAIN, VIDEO_FIRMWARE_POOL, SZ_4K, 0, &iova, &buffer_size, 0, 0); if (ret || !iova) { DDL_MSG_ERROR( "%s():DDL ION client iommu map failed, ret = %d iova = 0x%lx\n", __func__, ret, iova); goto ion_unmap_bail_out; } addr->mapped_buffer = NULL; addr->physical_base_addr = (u8 *)iova; addr->align_physical_addr = (u8 *) DDL_ALIGN((u32) addr->physical_base_addr, alignment); offset = (u32)(addr->align_physical_addr - addr->physical_base_addr); addr->align_virtual_addr = addr->virtual_base_addr + offset; addr->buffer_size = buffer_size; } else { if (!res_trk_check_for_sec_session()) { if (!addr->alloced_phys_addr) { pr_err(" %s() alloced addres NULL", __func__); goto bail_out; } flags = MSM_SUBSYSTEM_MAP_IOVA | MSM_SUBSYSTEM_MAP_KADDR; if (alignment == DDL_KILO_BYTE(128)) index = 1; else if (alignment > SZ_4K) flags |= MSM_SUBSYSTEM_ALIGN_IOVA_8K; addr->mapped_buffer = msm_subsystem_map_buffer( (unsigned long)addr->alloced_phys_addr, sz, flags, &restrk_mmu_subsystem[index], sizeof(restrk_mmu_subsystem[index])/ sizeof(unsigned int)); if (IS_ERR(addr->mapped_buffer)) { pr_err(" %s() buffer map failed", __func__); goto bail_out; } mapped_buffer = addr->mapped_buffer; if (!mapped_buffer->vaddr || !mapped_buffer->iova[0]) { pr_err("%s() map buffers failed\n", __func__); goto bail_out; } addr->physical_base_addr = (u8 *)mapped_buffer->iova[0]; addr->virtual_base_addr = mapped_buffer->vaddr; } else { addr->physical_base_addr = (u8 *) addr->alloced_phys_addr; addr->virtual_base_addr = (u8 *)addr->alloced_phys_addr; } addr->align_physical_addr = (u8 *) DDL_ALIGN((u32) addr->physical_base_addr, alignment); offset = (u32)(addr->align_physical_addr - addr->physical_base_addr); addr->align_virtual_addr = addr->virtual_base_addr + offset; addr->buffer_size = sz; } return addr->virtual_base_addr; bail_out: if (IS_ERR(addr->mapped_buffer)) msm_subsystem_unmap_buffer(addr->mapped_buffer); return NULL; ion_unmap_bail_out: if (!IS_ERR_OR_NULL(addr->alloc_handle)) { ion_unmap_kernel(resource_context. res_ion_client, addr->alloc_handle); } ion_bail_out: return NULL; }
u32 ddl_encode_frame_batch(u32 *ddl_handle, struct ddl_frame_data_tag *input_frame, struct ddl_frame_data_tag *output_bit, u32 num_in_frames, u32 num_out_frames, void *client_data) { struct ddl_client_context *ddl = (struct ddl_client_context *) ddl_handle; struct ddl_context *ddl_context; u32 vcd_status = VCD_S_SUCCESS; struct ddl_encoder_data *encoder; DDL_MSG_LOW("ddl_encode_frame_batch"); ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(ddl_context)) { DDL_MSG_ERROR("ddl_enc_frame:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(ddl_context)) { DDL_MSG_ERROR("ddl_enc_frame:Ddl_busy"); return VCD_ERR_BUSY; } if (!ddl || ddl->decoding) { DDL_MSG_ERROR("ddl_enc_frame:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!input_frame || !input_frame->vcd_frm.physical || !input_frame->vcd_frm.data_len) { DDL_MSG_ERROR("ddl_enc_frame:Bad_input_params"); return VCD_ERR_ILLEGAL_PARM; } if ((((u32) input_frame->vcd_frm.physical + input_frame->vcd_frm.offset) & (DDL_STREAMBUF_ALIGN_GUARD_BYTES))) { DDL_MSG_ERROR("ddl_enc_frame:Un_aligned_yuv_start_address"); return VCD_ERR_ILLEGAL_PARM; } if (!output_bit || !output_bit->vcd_frm.physical || !output_bit->vcd_frm.alloc_len) { DDL_MSG_ERROR("ddl_enc_frame:Bad_output_params"); return VCD_ERR_ILLEGAL_PARM; } if ((ddl->codec_data.encoder.output_buf_req.sz + output_bit->vcd_frm.offset) > output_bit->vcd_frm.alloc_len) DDL_MSG_ERROR("ddl_enc_frame:offset_large," "Exceeds_min_buf_size"); if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) { DDL_MSG_ERROR("ddl_enc_frame:Wrong_state"); return VCD_ERR_ILLEGAL_OP; } if (!ddl_take_command_channel(ddl_context, ddl, client_data)) return VCD_ERR_BUSY; encoder = &ddl->codec_data.encoder; if (encoder->slice_delivery_info.enable) { DDL_MEMCPY((void *)&(encoder->batch_frame.output_frame[0]), (void *)output_bit, sizeof(struct ddl_frame_data_tag) * num_out_frames); encoder->batch_frame.num_output_frames = num_out_frames; ddl->input_frame = *input_frame; vcd_status = ddl_insert_input_frame_to_pool(ddl, input_frame); if (!vcd_status) ddl_vidc_encode_slice_batch_run(ddl); else DDL_MSG_ERROR("insert to frame pool failed %u", vcd_status); } return vcd_status; }
u32 ddl_decode_start(u32 *ddl_handle, struct vcd_sequence_hdr *header, void *client_data) { struct ddl_client_context *ddl = (struct ddl_client_context *)ddl_handle; struct ddl_context *ddl_context; struct ddl_decoder_data *decoder; ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(ddl_context)) { VIDC_LOGERR_STRING("ddl_dec_start:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(ddl_context)) { VIDC_LOGERR_STRING("ddl_dec_start:Ddl_busy"); return VCD_ERR_BUSY; } if (!ddl || !ddl->decoding) { VIDC_LOGERR_STRING("ddl_dec_start:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { VIDC_LOGERR_STRING("ddl_dec_start:Not_in_opened_state"); return VCD_ERR_ILLEGAL_OP; } if ((header) && ((!header->sequence_header_len) || (!header->sequence_header) ) ) { VIDC_LOGERR_STRING("ddl_dec_start:Bad_param_seq_header"); return VCD_ERR_ILLEGAL_PARM; } if (!ddl_decoder_ready_to_start(ddl, header)) { VIDC_LOGERR_STRING("ddl_dec_start:Err_param_settings"); return VCD_ERR_ILLEGAL_OP; } DDL_BUSY(ddl_context); decoder = &ddl->codec_data.decoder; if (header) { decoder->header_in_start = true; decoder->decode_config = *header; } else { decoder->header_in_start = false; decoder->decode_config.sequence_header_len = 0; } if (decoder->codec.codec == VCD_CODEC_H264) { ddl_pmem_alloc(&decoder->h264Vsp_temp_buffer, DDL_DECODE_H264_VSPTEMP_BUFSIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (!decoder->h264Vsp_temp_buffer.virtual_base_addr) { DDL_IDLE(ddl_context); VIDC_LOGERR_STRING ("ddl_dec_start:H264Sps_alloc_failed"); return VCD_ERR_ALLOC_FAIL; } } ddl_context->current_ddl = ddl; ddl_context->client_data = client_data; ddl_channel_set(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; } if (res_trk_check_for_sec_session()) ddl->shared_mem[0].mem_type = DDL_CMD_MEM; else ddl->shared_mem[0].mem_type = DDL_FW_MEM; ptr = ddl_pmem_alloc(&ddl->shared_mem[0], DDL_FW_AUX_HOST_CMD_SPACE_SIZE, 0); if (!ptr) status = VCD_ERR_ALLOC_FAIL; if (!status && ddl_context->frame_channel_depth == VCD_DUAL_FRAME_COMMAND_CHANNEL) { if (res_trk_check_for_sec_session()) ddl->shared_mem[1].mem_type = DDL_CMD_MEM; else ddl->shared_mem[1].mem_type = DDL_FW_MEM; ptr = ddl_pmem_alloc(&ddl->shared_mem[1], DDL_FW_AUX_HOST_CMD_SPACE_SIZE, 0); 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; if (!res_trk_check_for_sec_session() || res_trk_get_enable_sec_metadata()) 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; }
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_frame(u32 *ddl_handle, struct ddl_frame_data_type_tag *p_input_frame, struct ddl_frame_data_type_tag *p_output_bit, 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 = ddl_get_context(); #ifdef CORE_TIMING_INFO ddl_get_core_start_time(1); #endif if (!DDL_IS_INITIALIZED(p_ddl_context)) { VIDC_LOGERR_STRING("ddl_enc_frame:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(p_ddl_context)) { VIDC_LOGERR_STRING("ddl_enc_frame:Ddl_busy"); return VCD_ERR_BUSY; } if (NULL == p_ddl || TRUE == p_ddl->b_decoding) { VIDC_LOGERR_STRING("ddl_enc_frame:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (NULL == p_input_frame || NULL == p_input_frame->vcd_frm.p_physical || p_ddl->codec_data.encoder.input_buf_req.n_size != p_input_frame->vcd_frm.n_data_len) { VIDC_LOGERR_STRING("ddl_enc_frame:Bad_input_params"); return VCD_ERR_ILLEGAL_PARM; } if (0 != (((u32) p_input_frame->vcd_frm.p_physical + p_input_frame->vcd_frm.n_offset) & (DDL_STREAMBUF_ALIGN_GUARD_BYTES) ) ) { VIDC_LOGERR_STRING ("ddl_enc_frame:Un_aligned_yuv_start_address"); return VCD_ERR_ILLEGAL_PARM; } if (NULL == p_output_bit || NULL == p_output_bit->vcd_frm.p_physical || 0 == p_output_bit->vcd_frm.n_alloc_len) { VIDC_LOGERR_STRING("ddl_enc_frame:Bad_output_params"); return VCD_ERR_ILLEGAL_PARM; } if ((p_ddl->codec_data.encoder.output_buf_req.n_size + p_output_bit->vcd_frm.n_offset) > p_output_bit->vcd_frm.n_alloc_len) { VIDC_LOGERR_STRING ("ddl_enc_frame:n_offset_large, Exceeds_min_buf_size"); } if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_FRAME)) { VIDC_LOGERR_STRING("ddl_enc_frame:Wrong_state"); return VCD_ERR_ILLEGAL_OP; } DDL_BUSY(p_ddl_context); p_ddl_context->p_current_ddl = p_ddl; p_ddl_context->p_client_data = p_client_data; p_ddl->input_frame = *p_input_frame; p_ddl->output_frame = *p_output_bit; ddl_encode_frame_run(p_ddl); return VCD_S_SUCCESS; }
u32 ddl_decode_frame(u32 *ddl_handle, struct ddl_frame_data_type_tag *p_input_bits, void *p_client_data) { u32 vcd_status = VCD_S_SUCCESS; struct ddl_client_context_type *p_ddl = (struct ddl_client_context_type *)ddl_handle; struct ddl_context_type *p_ddl_context = ddl_get_context(); #ifdef CORE_TIMING_INFO ddl_get_core_start_time(0); #endif if (!DDL_IS_INITIALIZED(p_ddl_context)) { VIDC_LOGERR_STRING("ddl_dec_frame:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(p_ddl_context)) { VIDC_LOGERR_STRING("ddl_dec_frame:Ddl_busy"); return VCD_ERR_BUSY; } if (NULL == p_ddl || FALSE == p_ddl->b_decoding) { VIDC_LOGERR_STRING("ddl_dec_frame:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (NULL == p_input_bits || ((0 == p_input_bits->vcd_frm.p_physical || 0 == p_input_bits->vcd_frm.n_data_len) && (0 == (VCD_FRAME_FLAG_EOS & p_input_bits->vcd_frm.n_flags)) ) ) { VIDC_LOGERR_STRING("ddl_dec_frame:Bad_input_param"); return VCD_ERR_ILLEGAL_PARM; } DDL_BUSY(p_ddl_context); p_ddl_context->p_current_ddl = p_ddl; p_ddl_context->p_client_data = p_client_data; p_ddl->input_frame = *p_input_bits; if (DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_FRAME)) { ddl_decode_frame_run(p_ddl); } else { if (0 == p_ddl->codec_data.decoder.dp_buf.n_no_of_dec_pic_buf) { VIDC_LOGERR_STRING("ddl_dec_frame:Dpbs_requied"); vcd_status = VCD_ERR_ILLEGAL_OP; } else if (DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_DPB)) { vcd_status = ddl_decode_set_buffers(p_ddl); } else if (DDLCLIENT_STATE_IS (p_ddl, DDL_CLIENT_WAIT_FOR_INITCODEC)) { p_ddl->codec_data.decoder.decode_config. p_sequence_header = p_ddl->input_frame.vcd_frm.p_physical; p_ddl->codec_data.decoder.decode_config. n_sequence_header_len = p_ddl->input_frame.vcd_frm.n_data_len; ddl_decode_init_codec(p_ddl); } else { VIDC_LOGERR_STRING("Dec_frame:Wrong_state"); vcd_status = VCD_ERR_ILLEGAL_OP; } if (VCD_S_SUCCESS != vcd_status) DDL_IDLE(p_ddl_context); } return vcd_status; }
u32 ddl_decode_start(u32 *ddl_handle, struct vcd_sequence_hdr_type *p_header, 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_decoder_data_type *p_decoder; p_ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(p_ddl_context)) { VIDC_LOGERR_STRING("ddl_dec_start:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(p_ddl_context)) { VIDC_LOGERR_STRING("ddl_dec_start:Ddl_busy"); return VCD_ERR_BUSY; } if (NULL == p_ddl || FALSE == p_ddl->b_decoding) { VIDC_LOGERR_STRING("ddl_dec_start:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_OPEN)) { VIDC_LOGERR_STRING("ddl_dec_start:Not_in_opened_state"); return VCD_ERR_ILLEGAL_OP; } if ((NULL != p_header) && ((0 == p_header->n_sequence_header_len) || (NULL == p_header->p_sequence_header) ) ) { VIDC_LOGERR_STRING("ddl_dec_start:Bad_param_seq_header"); return VCD_ERR_ILLEGAL_PARM; } if (FALSE == ddl_decoder_ready_to_start(p_ddl, p_header)) { VIDC_LOGERR_STRING("ddl_dec_start:Err_param_settings"); return VCD_ERR_ILLEGAL_OP; } DDL_BUSY(p_ddl_context); p_decoder = &p_ddl->codec_data.decoder; if (p_header) { p_decoder->b_header_in_start = TRUE; p_decoder->decode_config = *p_header; } else { p_decoder->b_header_in_start = FALSE; p_decoder->decode_config.n_sequence_header_len = 0; } if (p_decoder->codec_type.e_codec == VCD_CODEC_H264) { ddl_pmem_alloc(&p_decoder->h264Vsp_temp_buffer, DDL_DECODE_H264_VSPTEMP_BUFSIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (p_decoder->h264Vsp_temp_buffer.p_virtual_base_addr == NULL) { DDL_IDLE(p_ddl_context); VIDC_LOGERR_STRING ("ddl_dec_start:H264Sps_alloc_failed"); return VCD_ERR_ALLOC_FAIL; } } 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; }
u32 ddl_device_init(struct ddl_init_config *ddl_init_config, void *client_data) { struct ddl_context *ddl_context; u32 status = VCD_S_SUCCESS; if ((!ddl_init_config) || (!ddl_init_config->ddl_callback) || (!ddl_init_config->core_virtual_base_addr) ) { VIDC_LOGERR_STRING("ddl_dev_init:Bad_argument"); return VCD_ERR_ILLEGAL_PARM; } ddl_context = ddl_get_context(); if (DDL_IS_INITIALIZED(ddl_context)) { VIDC_LOGERR_STRING("ddl_dev_init:Multiple_init"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(ddl_context)) { VIDC_LOGERR_STRING("ddl_dev_init:Ddl_busy"); return VCD_ERR_BUSY; } DDL_MEMSET(ddl_context, 0, sizeof(struct ddl_context)); DDL_BUSY(ddl_context); ddl_context->ddl_callback = ddl_init_config->ddl_callback; ddl_context->interrupt_clr = ddl_init_config->interrupt_clr; ddl_context->core_virtual_base_addr = ddl_init_config->core_virtual_base_addr; ddl_context->client_data = client_data; vidc_720p_set_device_virtual_base(ddl_context-> core_virtual_base_addr); ddl_context->current_ddl = NULL; ddl_move_command_state(ddl_context, DDL_CMD_INVALID); ddl_client_transact(DDL_INIT_CLIENTS, NULL); ddl_pmem_alloc(&ddl_context->context_buf_addr, DDL_CONTEXT_MEMORY, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (!ddl_context->context_buf_addr.virtual_base_addr) { VIDC_LOGERR_STRING("ddl_dev_init:Context_alloc_fail"); status = VCD_ERR_ALLOC_FAIL; } if (!status) { ddl_pmem_alloc(&ddl_context->db_line_buffer, DDL_DB_LINE_BUF_SIZE, DDL_TILE_BUFFER_ALIGN_BYTES); if (!ddl_context->db_line_buffer.virtual_base_addr) { VIDC_LOGERR_STRING("ddl_dev_init:Line_buf_alloc_fail"); status = VCD_ERR_ALLOC_FAIL; } } if (!status) { ddl_pmem_alloc(&ddl_context->data_partition_tempbuf, DDL_MPEG4_DATA_PARTITION_BUF_SIZE, DDL_TILE_BUFFER_ALIGN_BYTES); if (ddl_context->data_partition_tempbuf.virtual_base_addr \ == NULL) { VIDC_LOGERR_STRING ("ddl_dev_init:Data_partition_buf_alloc_fail"); status = VCD_ERR_ALLOC_FAIL; } } if (!status) { ddl_pmem_alloc(&ddl_context->metadata_shared_input, DDL_METADATA_TOTAL_INPUTBUFSIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (!ddl_context->metadata_shared_input.virtual_base_addr) { VIDC_LOGERR_STRING ("ddl_dev_init:metadata_shared_input_alloc_fail"); status = VCD_ERR_ALLOC_FAIL; } } if (!status) { ddl_pmem_alloc(&ddl_context->dbg_core_dump, \ DDL_DBG_CORE_DUMP_SIZE, \ DDL_LINEAR_BUFFER_ALIGN_BYTES); if (!ddl_context->dbg_core_dump.virtual_base_addr) { VIDC_LOGERR_STRING ("ddl_dev_init:dbg_core_dump_alloc_failed"); status = VCD_ERR_ALLOC_FAIL; } ddl_context->enable_dbg_core_dump = 0; } if (!status && !vcd_fw_init()) { VIDC_LOGERR_STRING("ddl_dev_init:fw_init_failed"); status = VCD_ERR_ALLOC_FAIL; } if (status) { ddl_release_context_buffers(ddl_context); DDL_IDLE(ddl_context); return status; } ddl_move_command_state(ddl_context, DDL_CMD_DMA_INIT); ddl_core_init(ddl_context); return status; }
u32 ddl_device_init(struct ddl_init_config *ddl_init_config, void *client_data) { struct ddl_context *ddl_context; u32 status = VCD_S_SUCCESS; void *ptr = NULL; DDL_MSG_HIGH("ddl_device_init"); if ((!ddl_init_config) || (!ddl_init_config->ddl_callback) || (!ddl_init_config->core_virtual_base_addr)) { DDL_MSG_ERROR("ddl_dev_init:Bad_argument"); return VCD_ERR_ILLEGAL_PARM; } ddl_context = ddl_get_context(); if (DDL_IS_INITIALIZED(ddl_context)) { DDL_MSG_ERROR("ddl_dev_init:Multiple_init"); return VCD_ERR_ILLEGAL_OP; } if (!DDL_IS_IDLE(ddl_context)) { DDL_MSG_ERROR("ddl_dev_init:Ddl_busy"); return VCD_ERR_BUSY; } memset(ddl_context, 0, sizeof(struct ddl_context)); DDL_BUSY(ddl_context); ddl_context->ddl_callback = ddl_init_config->ddl_callback; if (ddl_init_config->interrupt_clr) ddl_context->interrupt_clr = ddl_init_config->interrupt_clr; ddl_context->core_virtual_base_addr = ddl_init_config->core_virtual_base_addr; ddl_context->client_data = client_data; ddl_context->ddl_hw_response.arg1 = DDL_INVALID_INTR_STATUS; ddl_context->frame_channel_depth = VCD_FRAME_COMMAND_DEPTH; DDL_MSG_LOW("%s() : virtual address of core(%x)\n", __func__, (u32) ddl_init_config->core_virtual_base_addr); vidc_1080p_set_device_base_addr( ddl_context->core_virtual_base_addr); ddl_context->cmd_state = DDL_CMD_INVALID; ddl_client_transact(DDL_INIT_CLIENTS, NULL); ddl_context->fw_memory_size = DDL_FW_INST_GLOBAL_CONTEXT_SPACE_SIZE; if (res_trk_get_firmware_addr(&ddl_context->dram_base_a)) { DDL_MSG_ERROR("firmware allocation failed"); ptr = NULL; } else { ptr = (void *)ddl_context->dram_base_a.virtual_base_addr; } if (!ptr) { DDL_MSG_ERROR("Memory Aocation Failed for FW Base"); status = VCD_ERR_ALLOC_FAIL; } else { DDL_MSG_LOW("%s() : physical address of base(%x)\n", __func__, (u32) ddl_context->dram_base_a.\ align_physical_addr); ddl_context->dram_base_b.align_physical_addr = ddl_context->dram_base_a.align_physical_addr; ddl_context->dram_base_b.align_virtual_addr = ddl_context->dram_base_a.align_virtual_addr; } if (!status) { ptr = ddl_pmem_alloc(&ddl_context->metadata_shared_input, DDL_METADATA_TOTAL_INPUTBUFSIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); if (!ptr) { DDL_MSG_ERROR("ddl_device_init: metadata alloc fail"); status = VCD_ERR_ALLOC_FAIL; } } if (!status && !ddl_fw_init(&ddl_context->dram_base_a)) { DDL_MSG_ERROR("ddl_dev_init:fw_init_failed"); status = VCD_ERR_ALLOC_FAIL; } if (!status) { ddl_context->cmd_state = DDL_CMD_DMA_INIT; ddl_vidc_core_init(ddl_context); } else { ddl_release_context_buffers(ddl_context); DDL_IDLE(ddl_context); } 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 if ((encoder->codec.codec == VCD_CODEC_MPEG4 && !encoder->short_header.short_header) || encoder->codec.codec == VCD_CODEC_H264) { 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; } } else { encoder->seq_header.buffer_size = 0; encoder->seq_header.virtual_base_addr = 0; encoder->seq_header.align_physical_addr = 0; encoder->seq_header.align_virtual_addr = 0; } if (!ddl_take_command_channel(ddl_context, ddl, client_data)) return VCD_ERR_BUSY; ddl_vidc_channel_set(ddl); return status; }
u32 ddl_decode_frame(u32 *ddl_handle, struct ddl_frame_data_tag *input_bits, void *client_data) { u32 vcd_status = VCD_S_SUCCESS; struct ddl_client_context *ddl = (struct ddl_client_context *)ddl_handle; struct ddl_context *ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(ddl_context)) { VIDC_LOGERR_STRING("ddl_dec_frame:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(ddl_context)) { VIDC_LOGERR_STRING("ddl_dec_frame:Ddl_busy"); return VCD_ERR_BUSY; } if (!ddl || !ddl->decoding) { VIDC_LOGERR_STRING("ddl_dec_frame:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!input_bits || ((!input_bits->vcd_frm.physical || !input_bits->vcd_frm.data_len) && (!(VCD_FRAME_FLAG_EOS & input_bits->vcd_frm.flags)) ) ) { VIDC_LOGERR_STRING("ddl_dec_frame:Bad_input_param"); return VCD_ERR_ILLEGAL_PARM; } DDL_BUSY(ddl_context); ddl_context->current_ddl = ddl; ddl_context->client_data = client_data; ddl->input_frame = *input_bits; if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) { ddl_decode_frame_run(ddl); } else { if (!ddl->codec_data.decoder.dp_buf.no_of_dec_pic_buf) { VIDC_LOGERR_STRING("ddl_dec_frame:Dpbs_requied"); vcd_status = VCD_ERR_ILLEGAL_OP; } else if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) { vcd_status = ddl_decode_set_buffers(ddl); } else if (DDLCLIENT_STATE_IS (ddl, DDL_CLIENT_WAIT_FOR_INITCODEC)) { ddl->codec_data.decoder.decode_config. sequence_header = ddl->input_frame.vcd_frm.physical; ddl->codec_data.decoder.decode_config. sequence_header_len = ddl->input_frame.vcd_frm.data_len; ddl_decode_init_codec(ddl); } else { VIDC_LOGERR_STRING("Dec_frame:Wrong_state"); vcd_status = VCD_ERR_ILLEGAL_OP; } if (vcd_status) DDL_IDLE(ddl_context); } return vcd_status; }
u32 ddl_decode_frame(u32 *ddl_handle, struct ddl_frame_data_tag *input_bits, void *client_data) { u32 vcd_status = VCD_S_SUCCESS; struct ddl_client_context *ddl = (struct ddl_client_context *) ddl_handle; struct ddl_context *ddl_context; struct ddl_decoder_data *decoder; DDL_MSG_HIGH("ddl_decode_frame"); ddl_context = ddl_get_context(); if (!DDL_IS_INITIALIZED(ddl_context)) { DDL_MSG_ERROR("ddl_dec_frame:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(ddl_context)) { DDL_MSG_ERROR("ddl_dec_frame:Ddl_busy"); return VCD_ERR_BUSY; } if (!ddl || !ddl->decoding) { DDL_MSG_ERROR("ddl_dec_frame:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!input_bits || ((!input_bits->vcd_frm.physical || !input_bits->vcd_frm.data_len) && (!(VCD_FRAME_FLAG_EOS & input_bits->vcd_frm.flags)))) { DDL_MSG_ERROR("ddl_dec_frame:Bad_input_param"); return VCD_ERR_ILLEGAL_PARM; } if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) && !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) && !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) { DDL_MSG_ERROR("Dec_frame:Wrong_state"); return VCD_ERR_ILLEGAL_OP; } decoder = &(ddl->codec_data.decoder); if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) && !ddl->codec_data.decoder.dp_buf.no_of_dec_pic_buf) { DDL_MSG_ERROR("ddl_dec_frame:Dpbs_requied"); return VCD_ERR_ILLEGAL_OP; } if (!ddl_take_command_channel(ddl_context, ddl, client_data)) return VCD_ERR_BUSY; ddl->input_frame = *input_bits; if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) ddl_vidc_decode_frame_run(ddl); else { if (!ddl->codec_data.decoder.dp_buf.no_of_dec_pic_buf) { DDL_MSG_ERROR("ddl_dec_frame:Dpbs_requied"); vcd_status = VCD_ERR_ILLEGAL_OP; } else if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) { vcd_status = ddl_vidc_decode_set_buffers(ddl); if (vcd_status) ddl_release_command_channel(ddl_context, ddl->command_channel); } else if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC)) { if (decoder->codec.codec == VCD_CODEC_DIVX_3) { if ((!decoder->client_frame_size.width) || (!decoder->client_frame_size.height)) return VCD_ERR_ILLEGAL_OP; } ddl->codec_data.decoder.decode_config.sequence_header = ddl->input_frame.vcd_frm.physical; ddl->codec_data.decoder.decode_config.sequence_header_len = ddl->input_frame.vcd_frm.data_len; ddl_vidc_decode_init_codec(ddl); } else { DDL_MSG_ERROR("Dec_frame:Wrong_state"); vcd_status = VCD_ERR_ILLEGAL_OP; } if (vcd_status) DDL_IDLE(ddl_context); } return vcd_status; }
static int res_trk_pmem_alloc (struct ddl_buf_addr *addr, size_t sz, u32 alignment) { u32 alloc_size; struct ddl_context *ddl_context; unsigned long fw_addr; int rc = 0; DBG_PMEM("\n%s() IN: Requested alloc size(%u)", __func__, (u32)sz); if (!addr) { DDL_MSG_ERROR("\n%s() Invalid Parameters", __func__); rc = -EINVAL; goto bail_out; } ddl_context = ddl_get_context(); res_trk_set_mem_type(addr->mem_type); alloc_size = (sz + alignment); if (res_trk_get_enable_ion()) { if (!res_trk_is_cp_enabled() || !res_trk_check_for_sec_session()) { if (!ddl_context->video_ion_client) ddl_context->video_ion_client = res_trk_get_ion_client(); if (!ddl_context->video_ion_client) { DDL_MSG_ERROR( "%s() :DDL ION Client Invalid handle\n", __func__); rc = -ENOMEM; goto bail_out; } alloc_size = (alloc_size+4095) & ~4095; addr->alloc_handle = ion_alloc( ddl_context->video_ion_client, alloc_size, SZ_4K, res_trk_get_mem_type(), res_trk_get_ion_flags()); if (IS_ERR_OR_NULL(addr->alloc_handle)) { DDL_MSG_ERROR("%s() :DDL ION alloc failed\n", __func__); rc = -ENOMEM; goto bail_out; } } else { fw_addr = resource_context.vidc_platform_data->fw_addr; addr->alloc_handle = NULL; addr->alloced_phys_addr = fw_addr; addr->buffer_size = sz; } } else { addr->alloced_phys_addr = (phys_addr_t) allocate_contiguous_memory_nomap(alloc_size, res_trk_get_mem_type(), SZ_4K); if (!addr->alloced_phys_addr) { DDL_MSG_ERROR("%s() : acm alloc failed (%d)\n", __func__, alloc_size); rc = -ENOMEM; goto bail_out; } addr->buffer_size = sz; return rc; } bail_out: return rc; }
u32 ddl_encode_frame(u32 *ddl_handle, struct ddl_frame_data_tag *input_frame, struct ddl_frame_data_tag *output_bit, void *client_data) { struct ddl_client_context *ddl = (struct ddl_client_context *) ddl_handle; struct ddl_context *ddl_context; u32 vcd_status = VCD_S_SUCCESS; DDL_MSG_HIGH("ddl_encode_frame"); if (vidc_msg_timing) 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_frame:Not_inited"); return VCD_ERR_ILLEGAL_OP; } if (DDL_IS_BUSY(ddl_context)) { DDL_MSG_ERROR("ddl_enc_frame:Ddl_busy"); return VCD_ERR_BUSY; } if (!ddl || ddl->decoding) { DDL_MSG_ERROR("ddl_enc_frame:Bad_handle"); return VCD_ERR_BAD_HANDLE; } if (!input_frame || !input_frame->vcd_frm.physical || !input_frame->vcd_frm.data_len) { DDL_MSG_ERROR("ddl_enc_frame:Bad_input_params"); return VCD_ERR_ILLEGAL_PARM; } if ((((u32) input_frame->vcd_frm.physical + input_frame->vcd_frm.offset) & (DDL_STREAMBUF_ALIGN_GUARD_BYTES))) { DDL_MSG_ERROR("ddl_enc_frame:Un_aligned_yuv_start_address"); return VCD_ERR_ILLEGAL_PARM; } if (!output_bit || !output_bit->vcd_frm.physical || !output_bit->vcd_frm.alloc_len) { DDL_MSG_ERROR("ddl_enc_frame:Bad_output_params"); return VCD_ERR_ILLEGAL_PARM; } if ((ddl->codec_data.encoder.output_buf_req.sz + output_bit->vcd_frm.offset) > output_bit->vcd_frm.alloc_len) DDL_MSG_ERROR("ddl_enc_frame:offset_large," "Exceeds_min_buf_size"); if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) { DDL_MSG_ERROR("ddl_enc_frame:Wrong_state"); return VCD_ERR_ILLEGAL_OP; } if (!ddl_take_command_channel(ddl_context, ddl, client_data)) return VCD_ERR_BUSY; ddl->input_frame = *input_frame; ddl->output_frame = *output_bit; if (ddl->codec_data.encoder.i_period.b_frames > 0) { if (!ddl->b_count) { ddl->first_output_frame = *output_bit; ddl->b_count++; } else if (ddl->codec_data.encoder.i_period.b_frames >= ddl->b_count) { ddl->extra_output_frame[ddl->b_count-1] = *output_bit; ddl->output_frame = ddl->first_output_frame; ddl->b_count++; } } ddl_insert_input_frame_to_pool(ddl, input_frame); if (!vcd_status) ddl_vidc_encode_frame_run(ddl); else DDL_MSG_ERROR("insert to frame pool failed %u", vcd_status); return vcd_status; }
static void *res_trk_pmem_alloc (struct ddl_buf_addr *addr, size_t sz, u32 alignment) { u32 alloc_size; struct ddl_context *ddl_context; int rc = -EINVAL; ion_phys_addr_t phyaddr = 0; size_t len = 0; DBG_PMEM("\n%s() IN: Requested alloc size(%u)", __func__, (u32)sz); if (!addr) { DDL_MSG_ERROR("\n%s() Invalid Parameters", __func__); goto bail_out; } ddl_context = ddl_get_context(); res_trk_set_mem_type(addr->mem_type); alloc_size = (sz + alignment); if (res_trk_get_enable_ion()) { if (!ddl_context->video_ion_client) ddl_context->video_ion_client = res_trk_get_ion_client(); if (!ddl_context->video_ion_client) { DDL_MSG_ERROR("%s() :DDL ION Client Invalid handle\n", __func__); goto bail_out; } addr->alloc_handle = ion_alloc( ddl_context->video_ion_client, alloc_size, SZ_4K, res_trk_get_mem_type()); if (IS_ERR_OR_NULL(addr->alloc_handle)) { DDL_MSG_ERROR("%s() :DDL ION alloc failed\n", __func__); goto bail_out; } rc = ion_phys(ddl_context->video_ion_client, addr->alloc_handle, &phyaddr, &len); if (rc || !phyaddr) { DDL_MSG_ERROR("%s():DDL ION client physical failed\n", __func__); goto free_acm_ion_alloc; } addr->alloced_phys_addr = phyaddr; } else { addr->alloced_phys_addr = (phys_addr_t) allocate_contiguous_memory_nomap(alloc_size, res_trk_get_mem_type(), SZ_4K); if (!addr->alloced_phys_addr) { DDL_MSG_ERROR("%s() : acm alloc failed (%d)\n", __func__, alloc_size); goto bail_out; } } addr->buffer_size = sz; return (void *)addr->alloced_phys_addr; free_acm_ion_alloc: if (ddl_context->video_ion_client) { if (addr->alloc_handle) { ion_free(ddl_context->video_ion_client, addr->alloc_handle); addr->alloc_handle = NULL; } } bail_out: return NULL; }
void ddl_pmem_alloc(struct ddl_buf_addr *buff_addr, size_t sz, u32 align) { u32 guard_bytes, align_mask; u32 physical_addr; u32 align_offset; u32 alloc_size, flags = 0; struct ddl_context *ddl_context; struct msm_mapped_buffer *mapped_buffer = NULL; unsigned long *kernel_vaddr = NULL; ion_phys_addr_t phyaddr = 0; size_t len = 0; int ret = -EINVAL; if (!buff_addr) { ERR("\n%s() Invalid Parameters\n", __func__); return; } if (align == DDL_LINEAR_BUFFER_ALIGN_BYTES) { guard_bytes = 31; align_mask = 0xFFFFFFE0U; } else { guard_bytes = DDL_TILE_BUF_ALIGN_GUARD_BYTES; align_mask = DDL_TILE_BUF_ALIGN_MASK; } ddl_context = ddl_get_context(); alloc_size = sz + guard_bytes; if (res_trk_get_enable_ion()) { if (!ddl_context->video_ion_client) ddl_context->video_ion_client = res_trk_get_ion_client(); if (!ddl_context->video_ion_client) { ERR("\n%s(): DDL ION Client Invalid handle\n", __func__); goto bailout; } buff_addr->mem_type = res_trk_get_mem_type(); buff_addr->alloc_handle = ion_alloc( ddl_context->video_ion_client, alloc_size, SZ_4K, buff_addr->mem_type); if (IS_ERR_OR_NULL(buff_addr->alloc_handle)) { ERR("\n%s(): DDL ION alloc failed\n", __func__); goto bailout; } ret = ion_phys(ddl_context->video_ion_client, buff_addr->alloc_handle, &phyaddr, &len); if (ret || !phyaddr) { ERR("\n%s(): DDL ION client physical failed\n", __func__); goto free_ion_buffer; } buff_addr->physical_base_addr = (u32 *)phyaddr; kernel_vaddr = (unsigned long *) ion_map_kernel( ddl_context->video_ion_client, buff_addr->alloc_handle, UNCACHED); if (IS_ERR_OR_NULL(kernel_vaddr)) { ERR("\n%s(): DDL ION map failed\n", __func__); goto unmap_ion_buffer; } buff_addr->virtual_base_addr = (u32 *)kernel_vaddr; DBG("ddl_ion_alloc: handle(0x%x), mem_type(0x%x), "\ "phys(0x%x), virt(0x%x), size(%u), align(%u), "\ "alloced_len(%u)", (u32)buff_addr->alloc_handle, (u32)buff_addr->mem_type, (u32)buff_addr->physical_base_addr, (u32)buff_addr->virtual_base_addr, alloc_size, align, len); } else { physical_addr = (u32) allocate_contiguous_memory_nomap(alloc_size, ddl_context->memtype, SZ_4K); if (!physical_addr) { ERR("\n%s(): DDL pmem allocate failed\n", __func__); goto bailout; } buff_addr->physical_base_addr = (u32 *) physical_addr; flags = MSM_SUBSYSTEM_MAP_KADDR; buff_addr->mapped_buffer = msm_subsystem_map_buffer((unsigned long)physical_addr, alloc_size, flags, NULL, 0); if (IS_ERR(buff_addr->mapped_buffer)) { ERR("\n%s() buffer map failed\n", __func__); goto free_pmem_buffer; } mapped_buffer = buff_addr->mapped_buffer; if (!mapped_buffer->vaddr) { ERR("\n%s() mapped virtual address is NULL\n", __func__); goto unmap_pmem_buffer; } buff_addr->virtual_base_addr = mapped_buffer->vaddr; DBG("ddl_pmem_alloc: mem_type(0x%x), phys(0x%x),"\ " virt(0x%x), sz(%u), align(%u)", (u32)buff_addr->mem_type, (u32)buff_addr->physical_base_addr, (u32)buff_addr->virtual_base_addr, alloc_size, SZ_4K); } memset(buff_addr->virtual_base_addr, 0 , sz + guard_bytes); buff_addr->buffer_size = sz; buff_addr->align_physical_addr = (u32 *) (((u32)buff_addr->physical_base_addr + guard_bytes) & align_mask); align_offset = (u32) (buff_addr->align_physical_addr) - (u32)buff_addr->physical_base_addr; buff_addr->align_virtual_addr = (u32 *) ((u32) (buff_addr->virtual_base_addr) + align_offset); DBG("%s(): phys(0x%x) align_phys(0x%x), virt(0x%x),"\ " align_virt(0x%x)", __func__, (u32)buff_addr->physical_base_addr, (u32)buff_addr->align_physical_addr, (u32)buff_addr->virtual_base_addr, (u32)buff_addr->align_virtual_addr); return; unmap_pmem_buffer: if (buff_addr->mapped_buffer) msm_subsystem_unmap_buffer(buff_addr->mapped_buffer); free_pmem_buffer: if (buff_addr->physical_base_addr) free_contiguous_memory_by_paddr((unsigned long) buff_addr->physical_base_addr); memset(buff_addr, 0, sizeof(struct ddl_buf_addr)); return; unmap_ion_buffer: if (ddl_context->video_ion_client) { if (buff_addr->alloc_handle) ion_unmap_kernel(ddl_context->video_ion_client, buff_addr->alloc_handle); } free_ion_buffer: if (ddl_context->video_ion_client) { if (buff_addr->alloc_handle) ion_free(ddl_context->video_ion_client, buff_addr->alloc_handle); } bailout: memset(buff_addr, 0, sizeof(struct ddl_buf_addr)); }