You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1888 lines
61 KiB
1888 lines
61 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2021. All rights reserved.
|
|
* Description: demux iapi func impl.
|
|
* Author: Hisilicon
|
|
* Create: 2019-04-12
|
|
*/
|
|
|
|
#include "securec.h"
|
|
#include "td_type.h"
|
|
#include "soc_log.h"
|
|
|
|
#include "soc_errno.h"
|
|
#include "mpi_memory_ext.h"
|
|
#include "uapi_demux.h"
|
|
|
|
#include "api_demux_utils.h"
|
|
#include "mpi_demux_ext.h"
|
|
|
|
/* general function */
|
|
static dmx_port convert_iapi_port_to_dmx_port(uapi_dmx_port port)
|
|
{
|
|
if (port >= UAPI_DMX_PORT_IF_0 && port <= UAPI_DMX_PORT_IF_15) {
|
|
return (dmx_port)((td_u32)DMX_IF_PORT_0 + ((td_u32)port - (td_u32)UAPI_DMX_PORT_IF_0));
|
|
} else if (port >= UAPI_DMX_PORT_TSI_0 && port <= UAPI_DMX_PORT_TSI_15) {
|
|
return (dmx_port)((td_u32)DMX_TSI_PORT_0 + ((td_u32)port - (td_u32)UAPI_DMX_PORT_TSI_0));
|
|
} else if (port >= UAPI_DMX_PORT_RAM_0 && port <= UAPI_DMX_PORT_RAM_15) {
|
|
return (dmx_port)((td_u32)DMX_RAM_PORT_0 + ((td_u32)port - (td_u32)UAPI_DMX_PORT_RAM_0));
|
|
} else if (port >= UAPI_DMX_PORT_TSIO_0 && port <= UAPI_DMX_PORT_TSIO_7) {
|
|
return (dmx_port)((td_u32)DMX_TSIO_PORT_0 + ((td_u32)port - (td_u32)UAPI_DMX_PORT_TSIO_0));
|
|
} else if (port >= UAPI_DMX_PORT_TAG_0 && port <= UAPI_DMX_PORT_TAG_7) {
|
|
return (dmx_port)((td_u32)DMX_TAG_PORT_0 + ((td_u32)port - (td_u32)UAPI_DMX_PORT_TAG_0));
|
|
} else {
|
|
soc_log_err("invalid iapi port type(%u).\n", port);
|
|
return DMX_PORT_MAX;
|
|
}
|
|
}
|
|
|
|
static uapi_dmx_port convert_dmx_port_to_iapi_port(dmx_port port)
|
|
{
|
|
if (port >= DMX_IF_PORT_0 && port < DMX_IF_PORT_MAX) {
|
|
return (uapi_dmx_port)((td_u32)UAPI_DMX_PORT_IF_0 + ((td_u32)port - (td_u32)DMX_IF_PORT_0));
|
|
} else if (port >= DMX_TSI_PORT_0 && port < DMX_TSI_PORT_MAX) {
|
|
return (uapi_dmx_port)((td_u32)UAPI_DMX_PORT_TSI_0 + ((td_u32)port - (td_u32)DMX_TSI_PORT_0));
|
|
} else if (port >= DMX_RAM_PORT_0 && port < DMX_RAM_PORT_MAX) {
|
|
return (uapi_dmx_port)((td_u32)UAPI_DMX_PORT_RAM_0 + ((td_u32)port - (td_u32)DMX_RAM_PORT_0));
|
|
} else if (port >= DMX_TAG_PORT_0 && port < DMX_TAG_PORT_MAX) {
|
|
return (uapi_dmx_port)((td_u32)UAPI_DMX_PORT_TAG_0 + ((td_u32)port - (td_u32)DMX_TAG_PORT_0));
|
|
} else if (port >= DMX_TSIO_PORT_0 && port < DMX_TSIO_PORT_MAX) {
|
|
return (uapi_dmx_port)((td_u32)UAPI_DMX_PORT_TSIO_0 + ((td_u32)port - (td_u32)DMX_TSIO_PORT_0));
|
|
} else {
|
|
soc_log_err("invalid dmx port type(%u).\n", port);
|
|
return UAPI_DMX_PORT_MAX;
|
|
}
|
|
}
|
|
|
|
static ext_dmx_port_type convert_iapi_port_type_to_dmx_port_type(uapi_dmx_port_type port_type)
|
|
{
|
|
if (port_type == UAPI_DMX_PORT_TYPE_PARALLEL_BURST) {
|
|
return DMX_PORT_TYPE_PARALLEL_BURST;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_PARALLEL_VALID) {
|
|
return DMX_PORT_TYPE_PARALLEL_VALID;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_PARALLEL_NOSYNC_188) {
|
|
return DMX_PORT_TYPE_PARALLEL_NOSYNC_188;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_PARALLEL_NOSYNC_204) {
|
|
return DMX_PORT_TYPE_PARALLEL_NOSYNC_204;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_PARALLEL_NOSYNC_188_204) {
|
|
return DMX_PORT_TYPE_PARALLEL_NOSYNC_188_204;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_SERIAL) {
|
|
return DMX_PORT_TYPE_SERIAL;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_SERIAL2BIT) {
|
|
return DMX_PORT_TYPE_SERIAL2BIT;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_SERIAL_NOSYNC) {
|
|
return DMX_PORT_TYPE_SERIAL_NOSYNC;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_SERIAL2BIT_NOSYNC) {
|
|
return DMX_PORT_TYPE_SERIAL2BIT_NOSYNC;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_USER_DEFINED) {
|
|
return DMX_PORT_TYPE_USER_DEFINED;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_AUTO) {
|
|
return DMX_PORT_TYPE_AUTO;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_SERIAL_NOSYNC_NOVALID) {
|
|
return DMX_PORT_TYPE_SERIAL_NOSYNC_NOVALID;
|
|
} else if (port_type == UAPI_DMX_PORT_TYPE_SERIAL2BIT_NOSYNC_NOVALID) {
|
|
return DMX_PORT_TYPE_SERIAL2BIT_NOSYNC_NOVALID;
|
|
} else {
|
|
soc_log_err("Invalid iapi port type[%u]\n", port_type);
|
|
return DMX_PORT_TYPE_MAX;
|
|
}
|
|
}
|
|
|
|
static uapi_dmx_port_type convert_dmx_port_type_to_iapi_port_type(ext_dmx_port_type port_type)
|
|
{
|
|
if (port_type == DMX_PORT_TYPE_PARALLEL_BURST) {
|
|
return UAPI_DMX_PORT_TYPE_PARALLEL_BURST;
|
|
} else if (port_type == DMX_PORT_TYPE_PARALLEL_VALID) {
|
|
return UAPI_DMX_PORT_TYPE_PARALLEL_VALID;
|
|
} else if (port_type == DMX_PORT_TYPE_PARALLEL_NOSYNC_188) {
|
|
return UAPI_DMX_PORT_TYPE_PARALLEL_NOSYNC_188;
|
|
} else if (port_type == DMX_PORT_TYPE_PARALLEL_NOSYNC_204) {
|
|
return UAPI_DMX_PORT_TYPE_PARALLEL_NOSYNC_204;
|
|
} else if (port_type == DMX_PORT_TYPE_PARALLEL_NOSYNC_188_204) {
|
|
return UAPI_DMX_PORT_TYPE_PARALLEL_NOSYNC_188_204;
|
|
} else if (port_type == DMX_PORT_TYPE_SERIAL) {
|
|
return UAPI_DMX_PORT_TYPE_SERIAL;
|
|
} else if (port_type == DMX_PORT_TYPE_SERIAL2BIT) {
|
|
return UAPI_DMX_PORT_TYPE_SERIAL2BIT;
|
|
} else if (port_type == DMX_PORT_TYPE_SERIAL_NOSYNC) {
|
|
return UAPI_DMX_PORT_TYPE_SERIAL_NOSYNC;
|
|
} else if (port_type == DMX_PORT_TYPE_SERIAL2BIT_NOSYNC) {
|
|
return UAPI_DMX_PORT_TYPE_SERIAL2BIT_NOSYNC;
|
|
} else if (port_type == DMX_PORT_TYPE_USER_DEFINED) {
|
|
return UAPI_DMX_PORT_TYPE_USER_DEFINED;
|
|
} else if (port_type == DMX_PORT_TYPE_AUTO) {
|
|
return UAPI_DMX_PORT_TYPE_AUTO;
|
|
} else if (port_type == DMX_PORT_TYPE_SERIAL_NOSYNC_NOVALID) {
|
|
return UAPI_DMX_PORT_TYPE_SERIAL_NOSYNC_NOVALID;
|
|
} else if (port_type == DMX_PORT_TYPE_SERIAL2BIT_NOSYNC_NOVALID) {
|
|
return UAPI_DMX_PORT_TYPE_SERIAL2BIT_NOSYNC_NOVALID;
|
|
} else {
|
|
soc_log_err("Invalid dmx port type[%u]\n", port_type);
|
|
return UAPI_DMX_PORT_TYPE_MAX;
|
|
}
|
|
}
|
|
|
|
static dmx_vcodec_type convert_iapi_vcodec_type_to_dmx_vcodec_type(uapi_vcodec_type vcodec_type)
|
|
{
|
|
if (vcodec_type == UAPI_VCODEC_TYPE_START_RESERVE || vcodec_type == UAPI_VCODEC_TYPE_MPEG2) {
|
|
return DMX_VCODEC_TYPE_MPEG2;
|
|
} else if (vcodec_type == UAPI_VCODEC_TYPE_MPEG4) {
|
|
return DMX_VCODEC_TYPE_MPEG4;
|
|
} else if (vcodec_type == UAPI_VCODEC_TYPE_H264) {
|
|
return DMX_VCODEC_TYPE_H264;
|
|
} else if (vcodec_type == UAPI_VCODEC_TYPE_H265) {
|
|
return DMX_VCODEC_TYPE_HEVC;
|
|
} else if (vcodec_type == UAPI_VCODEC_TYPE_AVS) {
|
|
return DMX_VCODEC_TYPE_AVS;
|
|
} else {
|
|
soc_log_warn("This video type[%u] is not currently supported.\n", vcodec_type);
|
|
return DMX_VCODEC_TYPE_MAX;
|
|
}
|
|
}
|
|
|
|
static dmx_play_type play_type_iapi_to_mpi(uapi_dmx_chan_type iapi_type)
|
|
{
|
|
if (iapi_type == UAPI_DMX_CHAN_TYPE_SEC) {
|
|
return DMX_PLAY_TYPE_SEC;
|
|
} else if (iapi_type == UAPI_DMX_CHAN_TYPE_PES) {
|
|
return DMX_PLAY_TYPE_PES;
|
|
} else if (iapi_type == UAPI_DMX_CHAN_TYPE_AUD) {
|
|
return DMX_PLAY_TYPE_AUD;
|
|
} else if (iapi_type == UAPI_DMX_CHAN_TYPE_VID) {
|
|
return DMX_PLAY_TYPE_VID;
|
|
} else if (iapi_type == UAPI_DMX_CHAN_TYPE_POST) {
|
|
return DMX_PLAY_TYPE_TS;
|
|
} else {
|
|
soc_log_err("not support iapi type(%u).\n", iapi_type);
|
|
return DMX_PLAY_TYPE_MAX;
|
|
}
|
|
}
|
|
|
|
static uapi_dmx_chan_type play_type_mpi_to_iapi(dmx_play_type mpi_type)
|
|
{
|
|
if (mpi_type == DMX_PLAY_TYPE_SEC) {
|
|
return UAPI_DMX_CHAN_TYPE_SEC;
|
|
} else if (mpi_type == DMX_PLAY_TYPE_PES) {
|
|
return UAPI_DMX_CHAN_TYPE_PES;
|
|
} else if (mpi_type == DMX_PLAY_TYPE_AUD) {
|
|
return UAPI_DMX_CHAN_TYPE_AUD;
|
|
} else if (mpi_type == DMX_PLAY_TYPE_VID) {
|
|
return UAPI_DMX_CHAN_TYPE_VID;
|
|
} else if (mpi_type == DMX_PLAY_TYPE_TS) {
|
|
return UAPI_DMX_CHAN_TYPE_POST;
|
|
} else {
|
|
soc_log_err("not support mpi type(%u).\n", mpi_type);
|
|
return UAPI_DMX_CHAN_TYPE_MAX;
|
|
}
|
|
}
|
|
|
|
td_s32 uapi_dmx_init(td_void)
|
|
{
|
|
td_s32 ret;
|
|
|
|
ret = ext_mpi_dmx_init();
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("ext_mpi_dmx_init failed, ret[%#x]\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
ret = dmx_api_utils_init();
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("iapi adapter init failed, ret[%#x]\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_deinit(td_void)
|
|
{
|
|
td_s32 ret;
|
|
|
|
ret = dmx_api_utils_deinit();
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("iapi adapter deinit failed, ret[%#x]\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_de_init();
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("ext_mpi_dmx_de_init failed, ret[%#x]\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_capability(uapi_dmx_capability *capability)
|
|
{
|
|
td_s32 ret;
|
|
dmx_capability cap = {0};
|
|
|
|
if (capability == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_get_capability(&cap);
|
|
if (ret == TD_SUCCESS) {
|
|
capability->if_port_num = cap.if_port_num;
|
|
capability->tsi_port_num = cap.tsi_port_num;
|
|
capability->tso_port_num = cap.tso_port_num;
|
|
capability->ram_port_num = cap.ram_port_num;
|
|
capability->tag_port_num = cap.tag_port_num;
|
|
capability->tsio_port_num = cap.tsio_port_num;
|
|
capability->dmx_num = cap.dmx_num;
|
|
capability->total_play_chan_num = cap.channel_num;
|
|
capability->av_play_chan_num = cap.av_channel_num;
|
|
capability->filter_num = cap.filter_num;
|
|
capability->desc_num = cap.key_num;
|
|
capability->rec_chan_num = cap.rec_chn_num;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_attach_demod(td_u8 demod_id)
|
|
{
|
|
return ext_mpi_dmx_attach_demod(demod_id);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_ts_port_attr(uapi_dmx_port id, uapi_dmx_port_attr *attr)
|
|
{
|
|
td_s32 ret;
|
|
dmx_port_attr local_attr = {0};
|
|
dmx_port dmx_port = convert_iapi_port_to_dmx_port(id);
|
|
|
|
if (attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
if (dmx_port >= DMX_IF_PORT_0 && dmx_port < DMX_IF_PORT_MAX) {
|
|
ret = ext_mpi_dmx_if_get_port_attrs(dmx_port, &local_attr);
|
|
} else if (dmx_port >= DMX_TSI_PORT_0 && dmx_port < DMX_TSI_PORT_MAX) {
|
|
ret = ext_mpi_dmx_tsi_get_port_attrs(dmx_port, &local_attr);
|
|
} else if (dmx_port >= DMX_RAM_PORT_0 && dmx_port < DMX_RAM_PORT_MAX) {
|
|
td_handle handle;
|
|
ret = ext_mpi_dmx_ram_get_handle(dmx_port, &handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get ramport handle failed, ret[0x%x]!\n", ret);
|
|
return ret;
|
|
}
|
|
ret = ext_mpi_dmx_ram_get_port_attrs(handle, &local_attr);
|
|
} else {
|
|
ret = SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
|
|
if (ret == TD_SUCCESS) {
|
|
attr->port_type = convert_dmx_port_type_to_iapi_port_type(local_attr.port_type);
|
|
if (attr->port_type == UAPI_DMX_PORT_TYPE_MAX) {
|
|
soc_log_err("Invalid dmx port type(%u).\n", local_attr.port_type);
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
attr->serial_bit_selector = local_attr.serial_bit_select;
|
|
attr->serial_port_share_clk = convert_dmx_port_to_iapi_port(local_attr.serial_port_share_clk);
|
|
attr->sync_lock_threshold = local_attr.sync_lock_threshold;
|
|
attr->sync_lost_threshold = local_attr.sync_lost_threshold;
|
|
attr->frontend_err_mode = local_attr.tuner_err_mod;
|
|
attr->frontend_clk_inverse = local_attr.tuner_in_clk;
|
|
attr->frontend_clk_mode = local_attr.tuner_clk_mode;
|
|
attr->user_def_len1 = local_attr.user_define_len1;
|
|
attr->user_def_len2 = local_attr.user_define_len2;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_set_ts_port_attr(uapi_dmx_port id, const uapi_dmx_port_attr *attr)
|
|
{
|
|
td_s32 ret;
|
|
dmx_port_attr local_attr = {0};
|
|
dmx_port dmx_port = convert_iapi_port_to_dmx_port(id);
|
|
|
|
if (attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
local_attr.port_type = convert_iapi_port_type_to_dmx_port_type(attr->port_type);
|
|
if (local_attr.port_type == DMX_PORT_TYPE_MAX) {
|
|
soc_log_err("not support port type(%u).\n", attr->port_type);
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
|
|
local_attr.serial_bit_select = attr->serial_bit_selector;
|
|
local_attr.serial_port_share_clk = convert_iapi_port_to_dmx_port(attr->serial_port_share_clk);
|
|
local_attr.sync_lock_threshold = attr->sync_lock_threshold;
|
|
local_attr.sync_lost_threshold = attr->sync_lost_threshold;
|
|
local_attr.tuner_err_mod = attr->frontend_err_mode;
|
|
local_attr.tuner_in_clk = attr->frontend_clk_inverse;
|
|
local_attr.tuner_clk_mode = attr->frontend_clk_mode;
|
|
local_attr.user_define_len1 = attr->user_def_len1;
|
|
local_attr.user_define_len2 = attr->user_def_len2;
|
|
|
|
if (dmx_port >= DMX_IF_PORT_0 && dmx_port < DMX_IF_PORT_MAX) {
|
|
return ext_mpi_dmx_if_set_port_attrs(dmx_port, &local_attr);
|
|
} else if (dmx_port >= DMX_TSI_PORT_0 && dmx_port < DMX_TSI_PORT_MAX) {
|
|
return ext_mpi_dmx_tsi_set_port_attrs(dmx_port, &local_attr);
|
|
} else if (dmx_port >= DMX_RAM_PORT_0 && dmx_port < DMX_RAM_PORT_MAX) {
|
|
td_handle handle;
|
|
ret = ext_mpi_dmx_ram_get_handle(dmx_port, &handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get ramport handle failed, ret[0x%x]!\n", ret);
|
|
return ret;
|
|
}
|
|
return ext_mpi_dmx_ram_set_port_attrs(handle, &local_attr);
|
|
} else {
|
|
soc_log_err("not support port(0x%x).\n", dmx_port);
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_tso_port_attr(uapi_dmx_tso_port id, uapi_dmx_tso_port_attr *attr)
|
|
{
|
|
td_s32 ret;
|
|
dmx_port port = (dmx_port)((td_u32)DMX_TSO_PORT_0 + ((td_u32)id - (td_u32)UAPI_DMX_PORT_TSO_0));
|
|
dmx_tso_port_attr local_attr = {0};
|
|
|
|
if (attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_tso_get_port_attrs(port, &local_attr);
|
|
if (ret == TD_SUCCESS) {
|
|
attr->port_type = convert_dmx_port_type_to_iapi_port_type(local_attr.port_type);
|
|
if (attr->port_type == UAPI_DMX_PORT_TYPE_MAX) {
|
|
soc_log_err("Invalid dmx port type(%u).\n", local_attr.port_type);
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
attr->bit_selector = (uapi_dmx_tso_serial_bit)local_attr.bit_selector;
|
|
attr->bit_sync = local_attr.bit_sync;
|
|
attr->clk = (uapi_dmx_tso_clk)local_attr.en_clk;
|
|
attr->clk_div = local_attr.clk_div;
|
|
attr->clk_mode = (uapi_dmx_tso_clk_mode)local_attr.clk_mode;
|
|
attr->clk_reverse = local_attr.clk_reverse;
|
|
attr->enable = local_attr.enable;
|
|
attr->lsb = local_attr.out_mode;
|
|
attr->ts_source = convert_dmx_port_to_iapi_port(local_attr.ts_source);
|
|
attr->valid_mode = (uapi_dmx_tso_valid_mode)local_attr.valid_mode;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_set_tso_port_attr(uapi_dmx_tso_port id, const uapi_dmx_tso_port_attr *attr)
|
|
{
|
|
dmx_port port = (dmx_port)((td_u32)DMX_TSO_PORT_0 + ((td_u32)id - (td_u32)UAPI_DMX_PORT_TSO_0));
|
|
dmx_tso_port_attr local_attr = {0};
|
|
|
|
if (attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
local_attr.port_type = convert_iapi_port_type_to_dmx_port_type(attr->port_type);
|
|
if (local_attr.port_type == DMX_PORT_TYPE_MAX) {
|
|
soc_log_err("not support port type(%u).\n", attr->port_type);
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
|
|
local_attr.bit_selector = (ext_dmx_tso_serial_bit)attr->bit_selector;
|
|
local_attr.bit_sync = attr->bit_sync;
|
|
local_attr.en_clk = (ext_dmx_tso_clk)attr->clk;
|
|
local_attr.clk_div = attr->clk_div;
|
|
local_attr.clk_mode = (ext_dmx_tso_clk_mode)attr->clk_mode;
|
|
local_attr.clk_reverse = attr->clk_reverse;
|
|
local_attr.enable = attr->enable;
|
|
local_attr.out_mode = attr->lsb;
|
|
local_attr.ts_source = (dmx_port)attr->ts_source;
|
|
local_attr.valid_mode = (ext_dmx_tso_valid_mode)attr->valid_mode;
|
|
|
|
return ext_mpi_dmx_tso_set_port_attrs(port, &local_attr);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_tag_port_attr(uapi_dmx_port id, uapi_dmx_tag_attr *attr)
|
|
{
|
|
td_s32 ret;
|
|
dmx_tag_port_attr local_attr = {0};
|
|
dmx_port port = convert_iapi_port_to_dmx_port(id);
|
|
|
|
if (attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_tag_get_port_attrs(port, &local_attr);
|
|
if (ret == TD_SUCCESS) {
|
|
attr->enable = local_attr.enable;
|
|
attr->sync_mode = (uapi_dmx_tag_sync_mode)local_attr.sync_mod;
|
|
attr->tag_len = local_attr.tag_len;
|
|
attr->ts_source = (uapi_dmx_port)local_attr.ts_src;
|
|
ret = memcpy_s(attr->tag, sizeof(attr->tag), local_attr.tag, sizeof(local_attr.tag));
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("memcpy_s failed!\n");
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_set_tag_port_attr(uapi_dmx_port id, const uapi_dmx_tag_attr *attr)
|
|
{
|
|
dmx_tag_port_attr local_attr = {0};
|
|
dmx_port port = convert_iapi_port_to_dmx_port(id);
|
|
|
|
if (attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
local_attr.enable = attr->enable;
|
|
local_attr.sync_mod = (ext_dmx_tag_sync_mode)attr->sync_mode;
|
|
local_attr.tag_len = attr->tag_len;
|
|
local_attr.ts_src = (dmx_port)attr->ts_source;
|
|
if (memcpy_s(local_attr.tag, sizeof(local_attr.tag), attr->tag, sizeof(attr->tag)) != TD_SUCCESS) {
|
|
soc_log_err("memcpy_s failed!\n");
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
return ext_mpi_dmx_tag_set_port_attrs(port, &local_attr);
|
|
}
|
|
|
|
td_s32 uapi_dmx_attach_ts_port(td_u32 dmx_id, uapi_dmx_port id)
|
|
{
|
|
td_s32 ret;
|
|
td_handle band_handle;
|
|
dmx_port port = convert_iapi_port_to_dmx_port(id);
|
|
|
|
ret = dmx_api_utils_band_get_handle(dmxid_2_bandid(dmx_id), &band_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get band handle failed, dmxId(%u), ret(0x%x)!\n", dmx_id, ret);
|
|
return ret;
|
|
}
|
|
|
|
return ext_mpi_dmx_band_attach_port(band_handle, port);
|
|
}
|
|
|
|
td_s32 uapi_dmx_detach_ts_port(td_u32 dmx_id)
|
|
{
|
|
td_s32 ret;
|
|
td_handle band_handle;
|
|
|
|
ret = dmx_api_utils_band_get_handle(dmxid_2_bandid(dmx_id), &band_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get band handle failed, dmxId(%u), ret(0x%x)!\n", dmx_id, ret);
|
|
return ret;
|
|
}
|
|
|
|
return ext_mpi_dmx_band_detach_port(band_handle);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_ts_port_id(td_u32 dmx_id, uapi_dmx_port *id)
|
|
{
|
|
td_s32 ret;
|
|
td_handle band_handle;
|
|
dmx_band_status band_status;
|
|
if (id == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = dmx_api_utils_band_get_handle(dmxid_2_bandid(dmx_id), &band_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get band handle failed, dmxId(%u), ret(0x%x)!\n", dmx_id, ret);
|
|
return ret;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_band_get_status(band_handle, &band_status);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get band status failed, handle(%u), ret(0x%x).\n", band_handle, ret);
|
|
} else {
|
|
*id = convert_dmx_port_to_iapi_port(band_status.port_id);
|
|
if (*id == UAPI_DMX_PORT_MAX) {
|
|
soc_log_err("band did not attach port yet!\n");
|
|
ret = SOC_ERR_DMX_NOATTACH_PORT;
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_ts_buffer_default_attr(uapi_dmx_ts_buffer_attr *buffer_attr)
|
|
{
|
|
td_s32 ret;
|
|
dmx_ram_port_attr ts_buf_attr = {0};
|
|
|
|
if (buffer_attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_ram_get_port_default_attrs(&ts_buf_attr);
|
|
if (ret == TD_SUCCESS) {
|
|
buffer_attr->secure_mode = (uapi_dmx_secure_mode)ts_buf_attr.secure_mode;
|
|
buffer_attr->buffer_size = ts_buf_attr.buffer_size;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_create_ts_buffer(uapi_dmx_port id, const uapi_dmx_ts_buffer_attr *ts_buffer_attr, td_handle *ts_buffer)
|
|
{
|
|
dmx_ram_port_attr ts_buf_attr = {0};
|
|
|
|
dmx_port port = convert_iapi_port_to_dmx_port(id);
|
|
|
|
if (ts_buffer_attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ts_buf_attr.buffer_size = ts_buffer_attr->buffer_size;
|
|
ts_buf_attr.secure_mode = (dmx_secure_mode)ts_buffer_attr->secure_mode;
|
|
|
|
return ext_mpi_dmx_ram_open_port(port, &ts_buf_attr, ts_buffer);
|
|
}
|
|
|
|
td_s32 uapi_dmx_destroy_ts_buffer(td_handle ts_buffer)
|
|
{
|
|
return ext_mpi_dmx_ram_close_port(ts_buffer);
|
|
}
|
|
|
|
td_s32 uapi_dmx_ts_buffer_attach_ssm(td_handle handle, td_handle ssm_handle, uapi_dmx_buffer_attach_type attach_type)
|
|
{
|
|
dmx_buffer_attach_type attach_type_tmp = EXT_DMX_BUFFER_ATTACH_MAX;
|
|
|
|
if (attach_type == UAPI_DMX_BUFFER_ATTACH_TYPE_TSR2RCIPHER) {
|
|
attach_type_tmp = EXT_DMX_BUFFER_ATTACH_TSR2RCIPHER;
|
|
} else if (attach_type == UAPI_DMX_BUFFER_ATTACH_TYPE_CIPHER) {
|
|
attach_type_tmp = EXT_DMX_BUFFER_ATTACH_CIPHER;
|
|
} else {
|
|
soc_log_err("Invalid attach attach_type %u.\n", attach_type_tmp);
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
|
|
return ext_mpi_dmx_ram_attach_ssm(handle, ssm_handle, attach_type_tmp);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_ts_buffer(td_handle ts_buffer, td_u32 req_len, uapi_stream_buf *ts_stream, td_u32 timeout_ms)
|
|
{
|
|
td_s32 ret;
|
|
dmx_ram_buffer ram_buffer;
|
|
|
|
if (ts_stream == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_ram_get_buffer(ts_buffer, req_len, &ram_buffer, timeout_ms);
|
|
if (ret == TD_SUCCESS) {
|
|
ts_stream->data = ram_buffer.data;
|
|
ts_stream->size = ram_buffer.length;
|
|
ts_stream->buf_handle.mem_handle = ram_buffer.buf_handle;
|
|
ts_stream->buf_handle.addr_offset = ram_buffer.offset;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_put_ts_buffer(td_handle ts_buffer, td_u32 valid_data_len, td_u32 start_pos)
|
|
{
|
|
return ext_mpi_dmx_ram_put_buffer(ts_buffer, valid_data_len, start_pos);
|
|
}
|
|
|
|
td_s32 uapi_dmx_push_ts_buffer(td_handle ts_buffer, const uapi_stream_buf *ts_stream)
|
|
{
|
|
dmx_ram_buffer ram_buffer = {0};
|
|
|
|
if (ts_stream == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ram_buffer.data = ts_stream->data;
|
|
ram_buffer.length = ts_stream->size;
|
|
|
|
ram_buffer.buf_handle = ts_stream->buf_handle.mem_handle;
|
|
ram_buffer.offset = ts_stream->buf_handle.addr_offset;
|
|
|
|
return ext_mpi_dmx_ram_push_buffer(ts_buffer, &ram_buffer);
|
|
}
|
|
|
|
td_s32 uapi_dmx_release_ts_buffer(td_handle ts_buffer, const uapi_stream_buf *ts_stream)
|
|
{
|
|
dmx_ram_buffer ram_buffer = {0};
|
|
|
|
if (ts_stream == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ram_buffer.data = ts_stream->data;
|
|
ram_buffer.length = ts_stream->size;
|
|
ram_buffer.buf_handle = ts_stream->buf_handle.mem_handle;
|
|
ram_buffer.offset = ts_stream->buf_handle.addr_offset;
|
|
|
|
return ext_mpi_dmx_ram_release_buffer(ts_buffer, &ram_buffer);
|
|
}
|
|
|
|
td_s32 uapi_dmx_flush_ts_buffer(td_handle ts_buffer)
|
|
{
|
|
return ext_mpi_dmx_ram_flush_buffer(ts_buffer);
|
|
}
|
|
|
|
td_s32 uapi_dmx_reset_ts_buffer(td_handle ts_buffer)
|
|
{
|
|
return ext_mpi_dmx_ram_reset_buffer(ts_buffer);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_ts_buffer_status(td_handle ts_buffer, uapi_dmx_ts_buffer_status *ts_buffer_status)
|
|
{
|
|
td_s32 ret;
|
|
dmx_ram_port_status ts_buf_status = {0};
|
|
|
|
if (ts_buffer_status == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_ram_get_port_status(ts_buffer, &ts_buf_status);
|
|
if (ret == TD_SUCCESS) {
|
|
ts_buffer_status->secure_mode = (uapi_dmx_secure_mode)ts_buf_status.secure_mode;
|
|
ts_buffer_status->buffer_size = ts_buf_status.buffer_size;
|
|
ts_buffer_status->used_size = ts_buf_status.buffer_used;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_ts_buffer_port_id(td_handle ts_buffer, uapi_dmx_port *id)
|
|
{
|
|
td_s32 ret;
|
|
dmx_port port = DMX_PORT_MAX;
|
|
|
|
if (id == TD_NULL) {
|
|
soc_log_err("invalid para!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_ram_get_port_id(ts_buffer, &port);
|
|
if (ret == TD_SUCCESS) {
|
|
*id = convert_dmx_port_to_iapi_port(port);
|
|
} else {
|
|
soc_log_err("get ram port id failed, handle(0x%x).\n", ts_buffer);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_ts_buffer_handle(uapi_dmx_port id, td_handle *ts_buffer)
|
|
{
|
|
td_s32 ret;
|
|
dmx_port port = convert_iapi_port_to_dmx_port(id);
|
|
|
|
if (ts_buffer == TD_NULL) {
|
|
soc_log_err("invalid para!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_ram_get_handle(port, ts_buffer);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get ram handle failed, port(%u).\n", id);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_play_chan_default_attr(uapi_dmx_chan_attr *play_chan_attr)
|
|
{
|
|
td_s32 ret;
|
|
dmx_play_attrs local_chan_attr = {0};
|
|
|
|
if (play_chan_attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_play_get_default_attrs(&local_chan_attr);
|
|
if (ret == TD_SUCCESS) {
|
|
play_chan_attr->chan_type = play_type_mpi_to_iapi(local_chan_attr.type);
|
|
play_chan_attr->crc_mode = (uapi_dmx_chan_crc_mode)local_chan_attr.crc_mode;
|
|
play_chan_attr->secure_mode = (uapi_dmx_secure_mode)local_chan_attr.secure_mode;
|
|
play_chan_attr->buffer_size = local_chan_attr.buf_size;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_create_play_chan(td_u32 dmx_id, const uapi_dmx_chan_attr *play_chan_attr, td_handle *play_chan)
|
|
{
|
|
td_s32 ret;
|
|
dmx_play_attrs local_chan_attr = {0};
|
|
|
|
if (play_chan_attr == TD_NULL || play_chan == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
local_chan_attr.buf_size = play_chan_attr->buffer_size;
|
|
local_chan_attr.type = play_type_iapi_to_mpi(play_chan_attr->chan_type);
|
|
local_chan_attr.live_play = TD_TRUE;
|
|
local_chan_attr.data_mode = DMX_DATA_MODE_STREAM;
|
|
local_chan_attr.secure_mode = (dmx_secure_mode)play_chan_attr->secure_mode;
|
|
local_chan_attr.crc_mode = (dmx_flt_crc_mode)play_chan_attr->crc_mode;
|
|
|
|
ret = ext_mpi_dmx_play_create(&local_chan_attr, play_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("create play fct failed, ret(0x%x), dmxId(%u)\n", ret, dmx_id);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = dmx_api_utils_play_create_entry(&local_chan_attr, *play_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("api utils play create failed, ret(0x%x), dmxId(%u)\n", ret, dmx_id);
|
|
|
|
goto out1;
|
|
}
|
|
|
|
ret = dmx_api_utils_play_set_bandid(*play_chan, dmxid_2_bandid(dmx_id));
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("api utils play set bandid failed, ret(0x%x), dmxId(%u).\n", ret, dmx_id);
|
|
|
|
goto out2;
|
|
}
|
|
|
|
return ret;
|
|
out2:
|
|
if (dmx_api_utils_play_destroy_entry(*play_chan) != TD_SUCCESS) {
|
|
soc_log_err("api utils destroy play entry failed.\n");
|
|
}
|
|
out1:
|
|
if (ext_mpi_dmx_play_destroy(*play_chan) != TD_SUCCESS) {
|
|
soc_log_err("destroy play failed!\n");
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_create_play_chan_with_pid(td_u32 dmx_id, td_u32 pid, const uapi_dmx_chan_attr *chan_attr,
|
|
td_handle *play_chan)
|
|
{
|
|
td_s32 ret;
|
|
dmx_play_attrs local_chan_attr = {0};
|
|
td_handle band_handle;
|
|
td_handle pidch_handle;
|
|
|
|
if ((chan_attr == TD_NULL) || (play_chan == TD_NULL)) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
local_chan_attr.buf_size = chan_attr->buffer_size;
|
|
local_chan_attr.type = play_type_iapi_to_mpi(chan_attr->chan_type);
|
|
local_chan_attr.live_play = TD_TRUE;
|
|
local_chan_attr.data_mode = DMX_DATA_MODE_STREAM;
|
|
local_chan_attr.secure_mode = (dmx_secure_mode)chan_attr->secure_mode;
|
|
local_chan_attr.crc_mode = (dmx_flt_crc_mode)chan_attr->crc_mode;
|
|
|
|
ret = ext_mpi_dmx_play_create(&local_chan_attr, play_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("create play fct failed, ret(0x%x)\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
dmx_api_dofunc_goto(dmx_api_utils_band_get_handle(dmxid_2_bandid(dmx_id), &band_handle), ret, out1);
|
|
|
|
dmx_api_dofunc_goto(ext_mpi_dmx_inc_and_attach_pidch(band_handle, pid, *play_chan, &pidch_handle), ret, out1);
|
|
|
|
dmx_api_dofunc_goto(dmx_api_utils_play_create_entry(&local_chan_attr, *play_chan), ret, out3);
|
|
|
|
dmx_api_dofunc_goto(dmx_api_utils_play_set_bandid(*play_chan, dmxid_2_bandid(dmx_id)), ret, out4);
|
|
|
|
dmx_api_dofunc_goto(dmx_api_utils_play_set_pidch(*play_chan, pidch_handle, pid), ret, out4);
|
|
|
|
return ret;
|
|
out4:
|
|
if (dmx_api_utils_play_destroy_entry(*play_chan) != TD_SUCCESS) {
|
|
soc_log_err("api utils destroy play entry failed.\n");
|
|
}
|
|
out3:
|
|
if (ext_mpi_dmx_play_detach_pid_ch(*play_chan) != TD_SUCCESS) {
|
|
soc_log_err("detach pid ch failed!\n");
|
|
}
|
|
out1:
|
|
if (ext_mpi_dmx_play_destroy(*play_chan) != TD_SUCCESS) {
|
|
soc_log_err("api utils destroy play entry failed.\n");
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_destroy_play_chan(td_handle play_chan)
|
|
{
|
|
td_s32 ret;
|
|
td_u32 dmx_id;
|
|
td_u32 pid;
|
|
td_handle pidch_handle;
|
|
|
|
ret = dmx_api_utils_play_get_entry(play_chan, &pidch_handle, &pid, &dmx_id);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get entry faild, ret(0x%x), handle(%u).\n", ret, play_chan);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_play_close(play_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("close pid ch failed, ret(0x%x), handle(%u).\n", ret, play_chan);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_detach_and_dec_pidch(play_chan, pidch_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("detach&dec pidch failed, ret(0x%x), play_chan(%u), pidch(%u).\n", ret, play_chan, pidch_handle);
|
|
|
|
return ret;
|
|
}
|
|
|
|
if (dmx_id != DMX_BAND_MAX) {
|
|
ret = dmx_api_utils_band_put_handle(dmx_id);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("api utils put handle failed, ret(0x%x), dmxId(%u).\n", ret, dmx_id);
|
|
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
ret = dmx_api_utils_play_destroy_entry(play_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("destroy entry failed, ret(0x%x).\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_play_destroy(play_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("play close failed, ret(0x%x), handle(%u).\n", ret, play_chan);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_play_chan_attach_ssm(td_handle play_chan, td_handle ssm_handle)
|
|
{
|
|
return ext_mpi_dmx_play_attach_ssm(play_chan, ssm_handle);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_play_chan_attr(td_handle play_chan, uapi_dmx_chan_attr *chan_attr)
|
|
{
|
|
td_s32 ret;
|
|
dmx_play_attrs local_chan_attr = {0};
|
|
|
|
if (chan_attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_play_get_attrs(play_chan, &local_chan_attr);
|
|
if (ret == TD_SUCCESS) {
|
|
chan_attr->chan_type = play_type_mpi_to_iapi(local_chan_attr.type);
|
|
chan_attr->crc_mode = (uapi_dmx_chan_crc_mode)local_chan_attr.crc_mode;
|
|
chan_attr->secure_mode = (uapi_dmx_secure_mode)local_chan_attr.secure_mode;
|
|
chan_attr->buffer_size = local_chan_attr.buf_size;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_set_play_chan_attr(td_handle play_chan, const uapi_dmx_chan_attr *chan_attr)
|
|
{
|
|
dmx_play_attrs local_chan_attr = {0};
|
|
|
|
if (chan_attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
local_chan_attr.buf_size = chan_attr->buffer_size;
|
|
local_chan_attr.type = play_type_iapi_to_mpi(chan_attr->chan_type);
|
|
local_chan_attr.crc_mode = (dmx_flt_crc_mode)chan_attr->crc_mode;
|
|
local_chan_attr.secure_mode = (dmx_secure_mode)chan_attr->secure_mode;
|
|
|
|
return ext_mpi_dmx_play_set_attrs(play_chan, &local_chan_attr);
|
|
}
|
|
|
|
td_s32 uapi_dmx_set_play_chan_pid(td_handle play_chan, td_u32 pid)
|
|
{
|
|
td_s32 ret;
|
|
td_u32 band_id;
|
|
td_handle pidch_handle;
|
|
td_handle band_handle;
|
|
|
|
ret = dmx_api_utils_play_get_bandid(play_chan, &band_id);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get band id falid, ret(0x%x), handle(%#x).\n", ret, play_chan);
|
|
goto out;
|
|
}
|
|
|
|
ret = dmx_api_utils_band_get_handle(band_id, &band_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get handle failed, ret(0x%x), bandId(%u).\n", ret, band_id);
|
|
goto out;
|
|
}
|
|
|
|
/* if play facility has already attach pid channel,detach it at first */
|
|
ret = ext_mpi_dmx_play_get_pid_ch(play_chan, &pidch_handle);
|
|
if (ret == TD_SUCCESS) {
|
|
ret = ext_mpi_dmx_detach_and_dec_pidch(play_chan, pidch_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("detach&dec failed, ret(0x%x), play_chan(%u), pidch(%u).\n", ret, play_chan, pidch_handle);
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
/* if could not get pid channel, create it. */
|
|
ret = ext_mpi_dmx_inc_and_attach_pidch(band_handle, pid, play_chan, &pidch_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("inc&attach failed, ret(0x%x), handle(%u), pid(%u).\n", ret, band_handle, pid);
|
|
goto out;
|
|
}
|
|
|
|
ret = dmx_api_utils_play_set_pidch(play_chan, pidch_handle, pid);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("set pid ch failed, ret(0x%x), pid(%u).\n", ret, pid);
|
|
|
|
goto detach;
|
|
}
|
|
|
|
return ret;
|
|
|
|
detach:
|
|
if (ext_mpi_dmx_play_detach_pid_ch(play_chan) != TD_SUCCESS) {
|
|
soc_log_err("detach pid ch failed.\n");
|
|
}
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_play_chan_pid(td_handle play_chan, td_u32 *pid)
|
|
{
|
|
td_s32 ret;
|
|
td_u32 local_pid;
|
|
td_handle pidch_handle;
|
|
|
|
if (pid == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = dmx_api_utils_play_get_pidch(play_chan, &pidch_handle, &local_pid);
|
|
if (ret == TD_SUCCESS) {
|
|
*pid = local_pid;
|
|
} else {
|
|
dmx_pidch_status status = {0};
|
|
ret = ext_mpi_dmx_play_get_pid_ch(play_chan, &pidch_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get pidch failed, ret[%x]\n", ret);
|
|
goto out;
|
|
}
|
|
ret = ext_mpi_dmx_pid_ch_get_status(pidch_handle, &status);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get pidch status failed, ret[%x]\n", ret);
|
|
goto out;
|
|
}
|
|
|
|
*pid = status.pid;
|
|
}
|
|
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_open_play_chan(td_handle play_chan)
|
|
{
|
|
return ext_mpi_dmx_play_open(play_chan);
|
|
}
|
|
|
|
td_s32 uapi_dmx_close_play_chan(td_handle play_chan)
|
|
{
|
|
return ext_mpi_dmx_play_close(play_chan);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_play_chan_status(td_handle play_chan, uapi_dmx_chan_status *chan_status)
|
|
{
|
|
td_s32 ret;
|
|
dmx_play_status play_status = {0};
|
|
dmx_chan_packet_num chn_stat = {0};
|
|
|
|
if (chan_status == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_play_get_status(play_chan, &play_status);
|
|
if (ret == TD_SUCCESS) {
|
|
chan_status->is_opened = play_status.is_opened;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_play_get_packet_num(play_chan, &chn_stat);
|
|
if (ret == TD_SUCCESS) {
|
|
chan_status->ts_cnt = chn_stat.ts_cnt;
|
|
chan_status->cc_disc_cnt = chn_stat.cc_disc_cnt;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_pid_chan_handle(td_u32 dmx_id, td_u32 pid, td_handle *pid_chan)
|
|
{
|
|
td_s32 ret;
|
|
td_handle band_handle = TD_INVALID_HANDLE;
|
|
|
|
if (pid_chan == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = dmx_api_utils_band_get_handle(dmxid_2_bandid(dmx_id), &band_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("band get handle failed, ret(0x%x), dmxId(%u).\n", ret, dmx_id);
|
|
return ret;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_pid_ch_get_handle_by_pid(band_handle, pid, pid_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_info("the matching channel does not exist, ret(0x%x), dmxId(%d), pid(0x%x).\n", ret, dmx_id, pid);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_free_play_chan_count(td_u32 dmx_id, td_u32 *free_count)
|
|
{
|
|
if (free_count == TD_NULL) {
|
|
soc_log_err("Null Pointer.\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
return ext_mpi_dmx_pid_ch_get_free_cnt(dmx_id, free_count);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_play_chan_scrambled_flag(td_handle play_chan, uapi_dmx_scrambled_flag *scramble_flag)
|
|
{
|
|
td_s32 ret;
|
|
ext_dmx_scrambled_flag scramble_flag_tmp;
|
|
|
|
if (scramble_flag == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_play_get_scrambled_flag(play_chan, &scramble_flag_tmp);
|
|
if (ret == TD_SUCCESS) {
|
|
*scramble_flag = (uapi_dmx_scrambled_flag)scramble_flag_tmp;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_create_filter(td_u32 dmx_id, const uapi_dmx_filter_attr *filter_attr, td_handle *filter)
|
|
{
|
|
td_s32 ret;
|
|
dmx_filter_attrs attr = {0};
|
|
|
|
if (filter_attr == TD_NULL || filter == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
TD_UNUSED(dmx_id);
|
|
|
|
attr.depth = filter_attr->filter_depth;
|
|
ret = memcpy_s(attr.mask, sizeof(attr.mask), filter_attr->mask, sizeof(filter_attr->mask));
|
|
if (ret != EOK) {
|
|
soc_log_err("call memcpy_s failed. ret=0x%x\n", ret);
|
|
return ret;
|
|
}
|
|
ret = memcpy_s(attr.match, sizeof(attr.match), filter_attr->match, sizeof(filter_attr->match));
|
|
if (ret != EOK) {
|
|
soc_log_err("call memcpy_s failed. ret=0x%x\n", ret);
|
|
return ret;
|
|
}
|
|
ret = memcpy_s(attr.negate, sizeof(attr.negate), filter_attr->negate, sizeof(filter_attr->negate));
|
|
if (ret != EOK) {
|
|
soc_log_err("call memcpy_s failed. ret=0x%x\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
return ext_mpi_dmx_play_create_filter(&attr, filter);
|
|
}
|
|
|
|
td_s32 uapi_dmx_destroy_filter(td_handle filter)
|
|
{
|
|
return ext_mpi_dmx_play_destroy_filter(filter);
|
|
}
|
|
|
|
td_s32 uapi_dmx_delete_all_filter(td_handle play_chan)
|
|
{
|
|
return ext_mpi_dmx_play_del_all_filter(play_chan);
|
|
}
|
|
|
|
td_s32 uapi_dmx_set_filter_attr(td_handle filter, const uapi_dmx_filter_attr *filter_attr)
|
|
{
|
|
td_s32 ret;
|
|
dmx_filter_attrs attr = {0};
|
|
|
|
if (filter_attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
attr.depth = filter_attr->filter_depth;
|
|
ret = memcpy_s(attr.mask, sizeof(attr.mask), filter_attr->mask, sizeof(filter_attr->mask));
|
|
if (ret != EOK) {
|
|
soc_log_err("call memcpy_s failed. ret=0x%x\n", ret);
|
|
return ret;
|
|
}
|
|
ret = memcpy_s(attr.match, sizeof(attr.match), filter_attr->match, sizeof(filter_attr->match));
|
|
if (ret != EOK) {
|
|
soc_log_err("call memcpy_s failed. ret=0x%x\n", ret);
|
|
return ret;
|
|
}
|
|
ret = memcpy_s(attr.negate, sizeof(attr.negate), filter_attr->negate, sizeof(filter_attr->negate));
|
|
if (ret != EOK) {
|
|
soc_log_err("call memcpy_s failed. ret=0x%x\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
return ext_mpi_dmx_play_update_filter(filter, &attr);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_filter_attr(td_handle filter, uapi_dmx_filter_attr *filter_attr)
|
|
{
|
|
td_s32 ret;
|
|
dmx_filter_attrs attr;
|
|
|
|
if (filter_attr == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_play_get_filter(filter, &attr);
|
|
if (ret == TD_SUCCESS) {
|
|
filter_attr->filter_depth = attr.depth;
|
|
ret = memcpy_s(filter_attr->mask, sizeof(filter_attr->mask), attr.mask, sizeof(attr.mask));
|
|
if (ret != EOK) {
|
|
soc_log_err("call memcpy_s failed. ret=0x%x\n", ret);
|
|
return ret;
|
|
}
|
|
ret = memcpy_s(filter_attr->match, sizeof(filter_attr->match), attr.match, sizeof(attr.match));
|
|
if (ret != EOK) {
|
|
soc_log_err("call memcpy_s failed. ret=0x%x\n", ret);
|
|
return ret;
|
|
}
|
|
ret = memcpy_s(filter_attr->negate, sizeof(filter_attr->negate), attr.negate, sizeof(attr.negate));
|
|
if (ret != EOK) {
|
|
soc_log_err("call memcpy_s failed. ret=0x%x\n", ret);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_attach_filter(td_handle filter, td_handle play_chan)
|
|
{
|
|
return ext_mpi_dmx_play_add_filter(play_chan, filter);
|
|
}
|
|
|
|
td_s32 uapi_dmx_detach_filter(td_handle filter, td_handle play_chan)
|
|
{
|
|
return ext_mpi_dmx_play_del_filter(play_chan, filter);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_filter_play_chan_handle(td_handle filter, td_handle *play_chan)
|
|
{
|
|
if (play_chan == TD_NULL) {
|
|
soc_log_err("Null Pointer.\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
return ext_mpi_dmx_play_get_handle_by_filter(filter, play_chan);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_free_filter_count(td_u32 dmx_id, td_u32 *free_count)
|
|
{
|
|
if (free_count == TD_NULL) {
|
|
soc_log_err("Null Pointer.\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
return ext_mpi_dmx_play_get_free_filter_cnt(dmx_id, free_count);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_data_handle(td_handle play_chan[], td_u32 *play_chan_num, td_u32 timeout_ms)
|
|
{
|
|
return ext_mpi_dmx_play_get_data_handle(play_chan, play_chan_num, timeout_ms);
|
|
}
|
|
|
|
td_s32 uapi_dmx_select_data_handle(td_handle *watch_play_chan, td_u32 watch_num, td_handle *data_chan, td_u32 *chn_num,
|
|
td_u32 timeout_ms)
|
|
{
|
|
return ext_mpi_dmx_play_select_data_handle(watch_play_chan, watch_num, data_chan, chn_num, timeout_ms);
|
|
}
|
|
|
|
td_s32 uapi_dmx_acquire_buffer(td_handle play_chan, td_u32 acquire_num, td_u32 *acquired_num, uapi_dmx_data *buffer,
|
|
td_u32 timeout_ms)
|
|
{
|
|
td_s32 ret;
|
|
td_s32 i;
|
|
dmx_buffer *buf = TD_NULL;
|
|
|
|
if (acquired_num == TD_NULL || buffer == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
if (acquire_num > MAX_ACQUIRE_NUM) {
|
|
soc_log_err("acquire_num[%#x] invalid!\n", acquire_num);
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
|
|
buf = malloc(acquire_num * sizeof(dmx_buffer));
|
|
if (buf == TD_NULL) {
|
|
soc_log_err("malloc failed!\n");
|
|
return TD_FAILURE;
|
|
}
|
|
if (memset_s(buf, acquire_num * sizeof(dmx_buffer), 0, acquire_num * sizeof(dmx_buffer)) != EOK) {
|
|
soc_log_err("memset_s failed!\n");
|
|
free(buf);
|
|
buf = TD_NULL;
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_play_acquire_buf(play_chan, acquire_num, acquired_num, buf, timeout_ms);
|
|
if (ret == TD_SUCCESS) {
|
|
if (*acquired_num >= 0 && *acquired_num <= acquire_num) {
|
|
for (i = 0; i < (td_s32)*acquired_num; i++) {
|
|
buffer[i].data = buf[i].data;
|
|
buffer[i].size = buf[i].length;
|
|
buffer[i].data_type = (uapi_dmx_data_type)buf[i].data_type;
|
|
}
|
|
} else {
|
|
soc_log_err("*acquired_num[%d] valid", *acquired_num);
|
|
ret = TD_FAILURE;
|
|
}
|
|
}
|
|
|
|
free(buf);
|
|
buf = TD_NULL;
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_release_buffer(td_handle play_chan, td_u32 release_num, const uapi_dmx_data *buffer)
|
|
{
|
|
td_s32 ret;
|
|
td_u32 i;
|
|
dmx_buffer *buf = TD_NULL;
|
|
|
|
if (buffer == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
if (release_num > MAX_ACQUIRE_NUM) {
|
|
soc_log_err("release_num[%#x] invalid!\n", release_num);
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
|
|
if (release_num == 0) {
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
buf = malloc(release_num * sizeof(dmx_buffer));
|
|
if (buf == TD_NULL) {
|
|
soc_log_err("malloc failed\n");
|
|
return TD_FAILURE;
|
|
}
|
|
if (memset_s(buf, release_num * sizeof(dmx_buffer), 0, release_num * sizeof(dmx_buffer)) != EOK) {
|
|
soc_log_err("memset_s failed!\n");
|
|
free(buf);
|
|
buf = TD_NULL;
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
for (i = 0; i < release_num; i++) {
|
|
buf[i].data = buffer[i].data;
|
|
buf[i].length = buffer[i].size;
|
|
buf[i].data_type = (dmx_data_type)buffer[i].data_type;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_play_release_buf(play_chan, release_num, buf);
|
|
|
|
free(buf);
|
|
buf = TD_NULL;
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_acquire_es(td_handle play_chan, uapi_es_buf *es_buffer)
|
|
{
|
|
td_s32 ret;
|
|
td_u32 acquired_num = 0;
|
|
dmx_buffer buffer = {0};
|
|
|
|
if (es_buffer == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
/* default 50ms timeout */
|
|
ret = ext_mpi_dmx_play_acquire_buf(play_chan, 1, &acquired_num, &buffer, 50);
|
|
if (ret == TD_SUCCESS && acquired_num == 1) {
|
|
es_buffer->buf = buffer.data;
|
|
es_buffer->buf_len = buffer.length;
|
|
es_buffer->pts = buffer.pts;
|
|
es_buffer->private_es_buf_addr.kernel_vir_addr = buffer.ker_vir_addr;
|
|
es_buffer->private_es_buf_addr.buf_handle.mem_handle = buffer.buf_handle;
|
|
es_buffer->private_es_buf_addr.buf_handle.addr_offset = buffer.offset;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_release_es(td_handle play_chan, const uapi_es_buf *es_buffer)
|
|
{
|
|
dmx_buffer buffer = {0};
|
|
|
|
if (es_buffer == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
buffer.data = es_buffer->buf;
|
|
buffer.length = es_buffer->buf_len;
|
|
buffer.data_type = DMX_DATA_WHOLE;
|
|
buffer.pts = es_buffer->pts;
|
|
buffer.ker_vir_addr = es_buffer->private_es_buf_addr.kernel_vir_addr;
|
|
buffer.buf_handle = es_buffer->private_es_buf_addr.buf_handle.mem_handle;
|
|
buffer.offset = es_buffer->private_es_buf_addr.buf_handle.addr_offset;
|
|
|
|
return ext_mpi_dmx_play_release_buf(play_chan, 1, &buffer);
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_ts_port_packet_num(uapi_dmx_port id, uapi_dmx_port_packet_num *port_status)
|
|
{
|
|
td_s32 ret;
|
|
dmx_port_packet_num port_stat = {0};
|
|
dmx_port port = convert_iapi_port_to_dmx_port(id);
|
|
|
|
if (port_status == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_get_ts_port_packet_num(port, &port_stat);
|
|
if (ret == TD_SUCCESS) {
|
|
port_status->err_ts_pack_cnt = port_stat.err_ts_packet_cnt;
|
|
port_status->pack_dis_cc_cnt = port_stat.packet_dis_cc_cnt;
|
|
port_status->pack_dis_cc_cnt_ca = port_stat.packet_dis_cc_cnt_ca;
|
|
port_status->ts_pack_cnt = port_stat.ts_packet_cnt;
|
|
port_status->ts_pack_drained_cnt = port_stat.ts_packet_drained_cnt;
|
|
port_status->ts_sync_byte_err_cnt = port_stat.ts_sync_byte_err_cnt;
|
|
port_status->ts_sync_loss_cnt = port_stat.ts_sync_loss_cnt;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_create_rec_chan(const uapi_dmx_rec_attr *rec_attr, td_handle *rec_chan)
|
|
{
|
|
td_s32 ret;
|
|
td_handle band_handle;
|
|
dmx_rec_attrs attr = {0};
|
|
|
|
if ((rec_attr == TD_NULL) || (rec_chan == TD_NULL)) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
attr.index_src_pid = rec_attr->index_src_pid;
|
|
attr.index_type = (dmx_rec_index_type)rec_attr->index_type;
|
|
attr.descramed = rec_attr->descramed;
|
|
attr.rec_buf_size = rec_attr->rec_buf_size;
|
|
attr.rec_type = (dmx_rec_type)rec_attr->rec_type;
|
|
attr.secure_mode = (dmx_secure_mode)rec_attr->secure_mode;
|
|
attr.ts_packet_type = (dmx_ts_packet_type)rec_attr->ts_packet_type;
|
|
attr.vcodec_type = convert_iapi_vcodec_type_to_dmx_vcodec_type(rec_attr->video_codec_type);
|
|
|
|
ret = ext_mpi_dmx_rec_create(&attr, rec_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("rec create failed, ret(0x%x).\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
dmx_api_dofunc_goto(dmx_api_utils_rec_create_entry(*rec_chan), ret, out1);
|
|
|
|
dmx_api_dofunc_goto(dmx_api_utils_rec_set_bandid(*rec_chan, dmxid_2_bandid(rec_attr->dmx_id)), ret, out2);
|
|
|
|
/* all pid record or all data record */
|
|
if ((attr.rec_type == DMX_REC_TYPE_ALL_PID) || (attr.rec_type == DMX_REC_TYPE_ALL_DATA)) {
|
|
dmx_api_dofunc_goto(dmx_api_utils_band_get_handle(dmxid_2_bandid(rec_attr->dmx_id), &band_handle), ret, out2);
|
|
|
|
dmx_api_dofunc_goto(ext_mpi_dmx_rec_add_ch(*rec_chan, band_handle), ret, out2);
|
|
|
|
dmx_api_dofunc_goto(dmx_api_utils_rec_set_bandch(*rec_chan, band_handle), ret, out3);
|
|
}
|
|
|
|
return ret;
|
|
out3:
|
|
if (ext_mpi_dmx_rec_del_ch(*rec_chan, band_handle) != TD_SUCCESS) {
|
|
soc_log_err("rec del ch falied!\n");
|
|
}
|
|
out2:
|
|
if (dmx_api_utils_rec_destroy_entry(*rec_chan) != TD_SUCCESS) {
|
|
soc_log_err("rec entry destroy failed.\n");
|
|
}
|
|
out1:
|
|
if (ext_mpi_dmx_rec_destroy(*rec_chan) != TD_SUCCESS) {
|
|
soc_log_err("destroy rec failed!\n");
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_destroy_rec_chan(td_handle rec_chan)
|
|
{
|
|
td_s32 ret;
|
|
td_handle band_handle = TD_INVALID_HANDLE;
|
|
|
|
ret = dmx_api_utils_rec_get_bandch(rec_chan, &band_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get band handle failed, rec handle(%u).\n", rec_chan);
|
|
|
|
return ret;
|
|
}
|
|
|
|
if (band_handle != TD_INVALID_HANDLE) { /* all pid record */
|
|
ret = ext_mpi_dmx_rec_del_ch(rec_chan, band_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("del ch falied, handle(%u).\n", band_handle);
|
|
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
ret = dmx_api_utils_rec_destroy_entry(rec_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("rec destroy entry failed, ret(0x%x).\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_rec_destroy(rec_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("rec destroy failed, ret(%d).\n", ret);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_rec_chan_attach_ssm(td_handle rec_chan, td_handle ssm_handle, uapi_dmx_buffer_attach_type type)
|
|
{
|
|
dmx_buffer_attach_type attach_type = EXT_DMX_BUFFER_ATTACH_MAX;
|
|
|
|
if (type == UAPI_DMX_BUFFER_ATTACH_TYPE_TSR2RCIPHER) {
|
|
attach_type = EXT_DMX_BUFFER_ATTACH_TSR2RCIPHER;
|
|
} else if (type == UAPI_DMX_BUFFER_ATTACH_TYPE_CIPHER) {
|
|
attach_type = EXT_DMX_BUFFER_ATTACH_CIPHER;
|
|
} else {
|
|
soc_log_err("Invalid attach type %u.\n", type);
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
|
|
return ext_mpi_dmx_rec_attach_ssm(rec_chan, ssm_handle, attach_type);
|
|
}
|
|
|
|
td_s32 uapi_dmx_add_rec_pid(td_handle rec_chan, td_u32 pid, td_handle *pid_chan)
|
|
{
|
|
td_s32 ret;
|
|
td_u32 dmx_id;
|
|
td_handle band_handle;
|
|
td_handle pidch_handle;
|
|
|
|
if (pid_chan == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = dmx_api_utils_rec_get_bandid(rec_chan, &dmx_id);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("rec get bandid failed, ret(0x%x).\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = dmx_api_utils_band_get_handle(dmx_id, &band_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("band get handle failed, ret(0x%x).\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_pid_ch_ref_inc(band_handle, pid, &pidch_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("ch ref inc failed, ret(0x%x).\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_rec_add_ch(rec_chan, pidch_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("rec add ch failed, ret(0x%x).\n", ret);
|
|
|
|
goto out1;
|
|
}
|
|
|
|
ret = dmx_api_utils_rec_add_pidch(rec_chan, pidch_handle, pid);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("rec add pidch failed, ret(0x%x).\n", ret);
|
|
|
|
goto out2;
|
|
} else {
|
|
*pid_chan = pidch_handle;
|
|
}
|
|
|
|
return ret;
|
|
out2:
|
|
if (ext_mpi_dmx_rec_del_ch(rec_chan, pidch_handle) != TD_SUCCESS) {
|
|
soc_log_err("rec del ch failed!\n");
|
|
}
|
|
out1:
|
|
if (ext_mpi_dmx_pid_ch_ref_dec(pidch_handle) != TD_SUCCESS) {
|
|
soc_log_err("ch ref dec failed!\n");
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_del_rec_pid(td_handle rec_chan, td_handle pid_chan)
|
|
{
|
|
td_s32 ret;
|
|
|
|
ret = ext_mpi_dmx_rec_del_ch(rec_chan, pid_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("rec del ch failed, ret(0x%x).\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_pid_ch_ref_dec(pid_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("ch ref dec failed, ret(0x%x).\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = dmx_api_utils_rec_del_pidch(rec_chan, pid_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("api utils rec del pidch failed, ret(0x%x).\n", ret);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_del_all_rec_pid(td_handle rec_chan)
|
|
{
|
|
td_s32 ret;
|
|
|
|
ret = ext_mpi_dmx_rec_del_all_ch(rec_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("rec del all ch failed, ret(0x%x).\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
ret = dmx_api_utils_rec_del_all_pidch(rec_chan);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("api utils rec del all pidch failed, ret(0x%x).\n", ret);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_start_rec_chan(td_handle rec_chan)
|
|
{
|
|
return ext_mpi_dmx_rec_open(rec_chan);
|
|
}
|
|
|
|
td_s32 uapi_dmx_stop_rec_chan(td_handle rec_chan)
|
|
{
|
|
return ext_mpi_dmx_rec_close(rec_chan);
|
|
}
|
|
|
|
td_s32 uapi_dmx_acquire_rec_data(td_handle rec_chan, uapi_dmx_rec_data *rec_data, td_u32 timeout_ms)
|
|
{
|
|
td_s32 ret;
|
|
dmx_buffer raw_data = {0};
|
|
|
|
if (rec_data == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_rec_acquire_buf(rec_chan, 47 * 1024, &raw_data, timeout_ms); /* 47*1024: acquire len,47k */
|
|
if (ret == TD_SUCCESS) {
|
|
rec_data->data_addr = raw_data.data;
|
|
rec_data->len = raw_data.length;
|
|
rec_data->buf_handle.mem_handle = raw_data.buf_handle;
|
|
rec_data->buf_handle.addr_offset = raw_data.offset;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_release_rec_data(td_handle rec_chan, const uapi_dmx_rec_data *rec_data)
|
|
{
|
|
dmx_buffer raw_data = {0};
|
|
|
|
if (rec_data == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
raw_data.data = rec_data->data_addr;
|
|
raw_data.length = rec_data->len;
|
|
raw_data.buf_handle = rec_data->buf_handle.mem_handle;
|
|
raw_data.offset = rec_data->buf_handle.addr_offset;
|
|
|
|
return ext_mpi_dmx_rec_release_buf(rec_chan, &raw_data);
|
|
}
|
|
|
|
td_s32 uapi_dmx_acquire_rec_index(td_handle rec_chan, td_u32 acquire_num, td_u32 *acquired_num,
|
|
uapi_dmx_rec_index *rec_index, td_u32 timeout_ms)
|
|
{
|
|
td_s32 ret;
|
|
td_u32 acquired = 0;
|
|
dmx_index_data *raw_index = TD_NULL;
|
|
|
|
if (rec_index == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
if (acquire_num > DMX_MAX_ACQUIRE_INDEX_NUM) {
|
|
soc_log_err("acquire_num[%u] invalid!\n", acquire_num);
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
|
|
raw_index = malloc(acquire_num * sizeof(dmx_index_data));
|
|
if (raw_index == TD_NULL) {
|
|
soc_log_err("malloc failed\n");
|
|
return TD_FAILURE;
|
|
}
|
|
if (memset_s(raw_index, acquire_num * sizeof(dmx_index_data), 0, acquire_num * sizeof(dmx_index_data)) != EOK) {
|
|
soc_log_err("memset_s failed!\n");
|
|
free(raw_index);
|
|
raw_index = TD_NULL;
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_rec_recv_idx(rec_chan, acquire_num, &acquired, raw_index, timeout_ms);
|
|
if (ret == TD_SUCCESS) {
|
|
td_u32 i;
|
|
for (i = 0; i < acquired; i++) {
|
|
rec_index[i].frame_type = (uapi_video_frame_type)raw_index[i].frame_type;
|
|
|
|
/* translate BLA and CRA to IDR for customer pvr */
|
|
if ((rec_index[i].frame_type == UAPI_FRAME_TYPE_BLA) ||
|
|
(rec_index[i].frame_type == UAPI_FRAME_TYPE_CRA)) {
|
|
rec_index[i].frame_type = UAPI_FRAME_TYPE_IDR;
|
|
}
|
|
|
|
rec_index[i].pts_us = raw_index[i].pts_us;
|
|
rec_index[i].global_offset = raw_index[i].global_offset;
|
|
rec_index[i].frame_size = raw_index[i].frame_size;
|
|
rec_index[i].data_time_ms = raw_index[i].data_time_ms;
|
|
*acquired_num = acquired;
|
|
}
|
|
}
|
|
|
|
free(raw_index);
|
|
raw_index = TD_NULL;
|
|
|
|
return ret;
|
|
}
|
|
|
|
/* POK, not use these two function yet */
|
|
td_s32 uapi_dmx_acquire_rec_data_and_index(td_handle rec_chan, uapi_dmx_rec_data_index *rec_data_idx)
|
|
{
|
|
td_s32 ret;
|
|
dmx_rec_data_index *raw_data_idx = TD_NULL;
|
|
|
|
if (rec_data_idx == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
raw_data_idx = malloc(sizeof(dmx_rec_data_index));
|
|
if (raw_data_idx == TD_NULL) {
|
|
soc_log_err("malloc RecDataIndex struct failed.\n");
|
|
return SOC_ERR_DMX_ALLOC_MEM_FAILED;
|
|
}
|
|
if (memset_s(raw_data_idx, sizeof(dmx_rec_data_index), 0, sizeof(dmx_rec_data_index)) != EOK) {
|
|
soc_log_err("memset_s failed!\n");
|
|
free(raw_data_idx);
|
|
raw_data_idx = TD_NULL;
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_acquire_rec_data_and_index(rec_chan, raw_data_idx);
|
|
if (ret == TD_SUCCESS) {
|
|
td_u32 idx;
|
|
|
|
/* covert MPI to IAPI structure. */
|
|
rec_data_idx->rec_data_count = raw_data_idx->rec_data_cnt;
|
|
for (idx = 0; idx < rec_data_idx->rec_data_count; idx++) {
|
|
rec_data_idx->rec_data[idx].data_addr = raw_data_idx->rec_data[idx].data;
|
|
rec_data_idx->rec_data[idx].buf_handle.mem_handle = raw_data_idx->rec_data[idx].buf_handle;
|
|
rec_data_idx->rec_data[idx].buf_handle.addr_offset = raw_data_idx->rec_data[idx].offset;
|
|
rec_data_idx->rec_data[idx].len = raw_data_idx->rec_data[idx].length;
|
|
}
|
|
|
|
rec_data_idx->index_num = raw_data_idx->index_num;
|
|
for (idx = 0; idx < rec_data_idx->index_num; idx++) {
|
|
rec_data_idx->index[idx].frame_type = (uapi_video_frame_type)raw_data_idx->index[idx].frame_type;
|
|
rec_data_idx->index[idx].pts_us = raw_data_idx->index[idx].pts_us;
|
|
rec_data_idx->index[idx].global_offset = raw_data_idx->index[idx].global_offset;
|
|
rec_data_idx->index[idx].frame_size = raw_data_idx->index[idx].frame_size;
|
|
rec_data_idx->index[idx].data_time_ms = raw_data_idx->index[idx].data_time_ms;
|
|
}
|
|
}
|
|
|
|
free(raw_data_idx);
|
|
raw_data_idx = TD_NULL;
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_release_rec_data_and_index(td_handle rec_chan, const uapi_dmx_rec_data_index *rec_data_idx)
|
|
{
|
|
td_s32 ret;
|
|
td_u32 idx;
|
|
dmx_rec_data_index *raw_data_idx = TD_NULL;
|
|
td_u32 rec_data_cnt;
|
|
|
|
if (rec_data_idx == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
rec_data_cnt = rec_data_idx->rec_data_count;
|
|
if (rec_data_cnt > 2) { /* only 2 data packets are allowed */
|
|
soc_log_err("release para invalid!\n");
|
|
return SOC_ERR_DMX_INVALID_PARA;
|
|
}
|
|
|
|
raw_data_idx = malloc(sizeof(dmx_rec_data_index));
|
|
if (raw_data_idx == TD_NULL) {
|
|
soc_log_err("malloc RecDataIndex struct failed!\n");
|
|
return SOC_ERR_DMX_ALLOC_MEM_FAILED;
|
|
}
|
|
if (memset_s(raw_data_idx, sizeof(dmx_rec_data_index), 0, sizeof(dmx_rec_data_index)) != EOK) {
|
|
soc_log_err("memset_s failed!\n");
|
|
free(raw_data_idx);
|
|
raw_data_idx = TD_NULL;
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
/* covert iapi to mpi structure. */
|
|
raw_data_idx->rec_data_cnt = rec_data_cnt;
|
|
for (idx = 0; idx < raw_data_idx->rec_data_cnt; idx++) {
|
|
raw_data_idx->rec_data[idx].data = rec_data_idx->rec_data[idx].data_addr;
|
|
raw_data_idx->rec_data[idx].buf_handle = rec_data_idx->rec_data[idx].buf_handle.mem_handle;
|
|
raw_data_idx->rec_data[idx].offset = rec_data_idx->rec_data[idx].buf_handle.addr_offset;
|
|
raw_data_idx->rec_data[idx].length = rec_data_idx->rec_data[idx].len;
|
|
}
|
|
|
|
/* idx info unused when release. */
|
|
raw_data_idx->index_num = 0;
|
|
|
|
ret = ext_mpi_dmx_release_rec_data_and_index(rec_chan, raw_data_idx);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("call EXT_MPI_DMX_ReleaseRecDataAndIndex failed!\n");
|
|
}
|
|
|
|
free(raw_data_idx);
|
|
raw_data_idx = TD_NULL;
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_get_rec_buffer_status(td_handle rec_chan, uapi_dmx_rec_buf_status *buffer_status)
|
|
{
|
|
td_s32 ret;
|
|
dmx_rec_status rec_status;
|
|
|
|
if (buffer_status == TD_NULL) {
|
|
soc_log_err("Null point!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
ret = ext_mpi_dmx_rec_get_status(rec_chan, &rec_status);
|
|
if (ret == TD_SUCCESS) {
|
|
buffer_status->buffer_size = rec_status.buf_size;
|
|
buffer_status->used_size = rec_status.used_size;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
td_s32 uapi_dmx_register_callback(td_handle chan, const uapi_dmx_cb_desc *cb_desc)
|
|
{
|
|
td_void *temp_cb_desc = (td_void*)cb_desc;
|
|
return ext_mpi_dmx_play_register_callback(chan, (ext_mpi_dmx_cb_desc *)temp_cb_desc);
|
|
}
|
|
|
|
td_s32 uapi_dmx_unregister_callback(td_handle chan)
|
|
{
|
|
return ext_mpi_dmx_play_unregister_callback(chan);
|
|
}
|
|
|
|
td_s32 uapi_dmx_invoke(uapi_dmx_invoke_type cmd_type, const td_void *cmd_para)
|
|
{
|
|
td_s32 ret;
|
|
dmx_invoke_type local_cmd = (dmx_invoke_type)(((td_u32)cmd_type - (td_u32)UAPI_DMX_INVOKE_TYPE_CHAN_CC_REPEAT_SET) +
|
|
(td_u32)EXT_DMX_INVOKE_TYPE_CHAN_CC_REPEAT_SET);
|
|
|
|
if (cmd_para == TD_NULL) {
|
|
soc_log_err("Null Pointer!\n");
|
|
return SOC_ERR_DMX_NULL_PTR;
|
|
}
|
|
|
|
if (local_cmd == EXT_DMX_INVOKE_TYPE_TEI_SET) {
|
|
td_handle band_handle;
|
|
dmx_tei_set tei_info;
|
|
uapi_dmx_tei_set *tei_set = (uapi_dmx_tei_set *)cmd_para;
|
|
|
|
ret = dmx_api_utils_band_get_handle(dmxid_2_bandid(tei_set->dmx_id), &band_handle);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_log_err("get band handle failed, dmxId(%u), ret(0x%x)!\n", tei_set->dmx_id, ret);
|
|
return ret;
|
|
}
|
|
tei_info.band_handle = band_handle;
|
|
tei_info.tei = tei_set->tei;
|
|
|
|
return ext_mpi_dmx_invoke(local_cmd, &tei_info);
|
|
} else {
|
|
return ext_mpi_dmx_invoke(local_cmd, cmd_para);
|
|
}
|
|
}
|
|
|