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.
206 lines
6.9 KiB
206 lines
6.9 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2021. All rights reserved.
|
|
* Description: ATV IAPI interface
|
|
* Author: Hisilicon
|
|
* Created: 2019-12-07
|
|
*/
|
|
|
|
#include "soc_log.h"
|
|
#include "td_type.h"
|
|
#include "soc_errno.h"
|
|
#include "iapi_frontend.h"
|
|
#include "mpi_frontend_ext.h"
|
|
#include "iapi_atv.h"
|
|
|
|
td_s32 atv_connect(td_u32 tuner_id, const uapi_frontend_connect_para *connect_para)
|
|
{
|
|
td_s32 ret;
|
|
static fe_ioctrl_signal tuner_signal_data;
|
|
frontend_acc_qam_params tuner_para = {0};
|
|
|
|
if (connect_para == TD_NULL) {
|
|
soc_log_err("null pointer!\n");
|
|
return SOC_ERR_FRONTEND_INVALID_POINT;
|
|
}
|
|
|
|
tuner_para.frequency = connect_para->connect_para.atv.freq;
|
|
tuner_para.modpol.system = (ext_drv_atv_system)connect_para->connect_para.atv.system;
|
|
tuner_para.srbw.atv_sif_bw = (ext_drv_atv_sif_bw)connect_para->connect_para.atv.sif_bw;
|
|
tuner_para.connect_work_mode = (ext_drv_atv_connect_work_mode)connect_para->connect_para.atv.connect_work_mode;
|
|
|
|
if ((connect_para->connect_para.atv.freq < ATV_RF_MIN) ||
|
|
(connect_para->connect_para.atv.freq > ATV_RF_MAX)) {
|
|
soc_log_err("Freq Invalid.\n");
|
|
soc_err_print_u32(connect_para->connect_para.atv.freq);
|
|
return SOC_ERR_FRONTEND_INVALID_PARA;
|
|
}
|
|
if (connect_para->connect_para.atv.system >= UAPI_ATV_SYSTEM_MAX) {
|
|
soc_log_err("ATV System Invalid.\n");
|
|
soc_err_print_u32(tuner_para.modpol.system);
|
|
return SOC_ERR_FRONTEND_INVALID_PARA;
|
|
}
|
|
if (connect_para->connect_para.atv.sif_bw >= UAPI_ATV_SIF_BW_MAX) {
|
|
soc_log_err("Sif BandWidth Invalid.\n");
|
|
soc_err_print_u32(tuner_para.srbw.atv_sif_bw);
|
|
return SOC_ERR_FRONTEND_INVALID_PARA;
|
|
}
|
|
|
|
tuner_signal_data.sig_type = (ext_drv_frontend_sig_type)connect_para->sig_type;
|
|
tuner_signal_data.port = tuner_id;
|
|
tuner_signal_data.signal = tuner_para;
|
|
ret = ext_mpi_frontend_connect(&tuner_signal_data);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_err_print_call_fun_err(ext_mpi_frontend_connect, ret);
|
|
return ret;
|
|
}
|
|
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
td_s32 uapi_frontend_set_step(td_u32 port, uapi_frontend_atv_step step)
|
|
{
|
|
td_s32 ret;
|
|
fe_ioctrl_frontend_step tmp_tuner_step;
|
|
if (port >= IAPI_TUNER_NUM) {
|
|
soc_log_err("Input parameter(tuner_id) invalid.\n");
|
|
soc_err_print_u32(port);
|
|
return SOC_ERR_FRONTEND_INVALID_PORT;
|
|
}
|
|
if (step >= UAPI_FRONTEDN_ATV_STEP_MAX) {
|
|
soc_log_err("Input parameter(step) invalid.\n");
|
|
soc_err_print_u32(step);
|
|
return SOC_ERR_FRONTEND_INVALID_PARA;
|
|
}
|
|
tmp_tuner_step.port = port;
|
|
tmp_tuner_step.step = (ext_drv_frontend_atv_step)step;
|
|
ret = ext_mpi_frontend_set_step(tmp_tuner_step);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_err_print_call_fun_err(ext_mpi_frontend_set_step, ret);
|
|
return ret;
|
|
}
|
|
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
td_s32 uapi_frontend_get_step(td_u32 port, uapi_frontend_atv_step *step)
|
|
{
|
|
td_s32 ret;
|
|
fe_ioctrl_frontend_step tmp_tuner_step = {0};
|
|
if (port >= IAPI_TUNER_NUM) {
|
|
soc_log_err("Input parameter(tuner_id) invalid.\n");
|
|
soc_err_print_u32(port);
|
|
return SOC_ERR_FRONTEND_INVALID_PORT;
|
|
}
|
|
if (step == NULL) {
|
|
soc_log_err("Input parameter(step) invalid.\n");
|
|
return SOC_ERR_FRONTEND_INVALID_POINT;
|
|
}
|
|
tmp_tuner_step.port = port;
|
|
ret = ext_mpi_frontend_get_step(&tmp_tuner_step);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_err_print_call_fun_err(ext_mpi_frontend_get_step, ret);
|
|
return ret;
|
|
}
|
|
|
|
*step = (uapi_frontend_atv_step)tmp_tuner_step.step;
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
td_s32 uapi_frontend_get_band(td_u32 port, td_u32 frequency, uapi_frontend_atv_band *band)
|
|
{
|
|
td_s32 ret;
|
|
fe_ioctrl_band tmp_tuner_band = {0};
|
|
if (port >= IAPI_TUNER_NUM) {
|
|
soc_log_err("Input parameter(tuner_id) invalid.\n");
|
|
soc_err_print_u32(port);
|
|
return SOC_ERR_FRONTEND_INVALID_PORT;
|
|
}
|
|
if (band == NULL) {
|
|
soc_log_err("Input parameter(step) invalid.\n");
|
|
return SOC_ERR_FRONTEND_INVALID_POINT;
|
|
}
|
|
tmp_tuner_band.port = port;
|
|
tmp_tuner_band.freq = frequency;
|
|
ret = ext_mpi_frontend_get_band(&tmp_tuner_band);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_err_print_call_fun_err(ext_mpi_frontend_get_band, ret);
|
|
return ret;
|
|
}
|
|
|
|
*band = (uapi_frontend_atv_band)tmp_tuner_band.band;
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
td_s32 uapi_frontend_get_band_range(td_u32 port, uapi_frontend_atv_band band,
|
|
uapi_frontend_atv_band_range *band_range)
|
|
{
|
|
td_s32 ret;
|
|
fe_ioctrl_band_range tmp_tuner_band_range;
|
|
if (port >= IAPI_TUNER_NUM) {
|
|
soc_log_err("Input parameter(tuner_id) invalid.\n");
|
|
soc_err_print_u32(port);
|
|
return SOC_ERR_FRONTEND_INVALID_PORT;
|
|
}
|
|
if (band_range == NULL) {
|
|
soc_log_err("Input parameter(bandrange) invalid\n");
|
|
return SOC_ERR_FRONTEND_INVALID_POINT;
|
|
}
|
|
tmp_tuner_band_range.port = port;
|
|
tmp_tuner_band_range.band = (ext_drv_frontend_atv_band)band;
|
|
ret = ext_mpi_frontend_get_band_range(&tmp_tuner_band_range);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_err_print_call_fun_err(ext_mpi_frontend_get_band_range, ret);
|
|
return ret;
|
|
}
|
|
|
|
band_range->start_freq = tmp_tuner_band_range.band_range.start_freq;
|
|
band_range->end_freq = tmp_tuner_band_range.band_range.end_freq;
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
td_s32 uapi_frontend_set_top_adjustment(td_u32 port, td_u32 top)
|
|
{
|
|
td_s32 ret;
|
|
fe_ioctrl_top_adjust tmp_tuner_top_adjust;
|
|
if (port >= IAPI_TUNER_NUM) {
|
|
soc_log_err("Input parameter(port) invalid.\n");
|
|
soc_err_print_u32(port);
|
|
return SOC_ERR_FRONTEND_INVALID_PORT;
|
|
}
|
|
tmp_tuner_top_adjust.port = port;
|
|
tmp_tuner_top_adjust.top = top;
|
|
ret = ext_mpi_frontend_set_top_adjustment(tmp_tuner_top_adjust);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_err_print_call_fun_err(ext_mpi_frontend_set_top_adjustment, ret);
|
|
soc_err_print_u32(tmp_tuner_top_adjust.top);
|
|
return SOC_ERR_FRONTEND_FAILED_SETTOPADJUST;
|
|
}
|
|
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
td_s32 uapi_frontend_get_bit_rate(td_u32 port, td_u32 *bit_rate)
|
|
{
|
|
td_s32 ret;
|
|
fe_ioctrl_bit_rate tmp_tuner_bit_rate;
|
|
if (port >= IAPI_TUNER_NUM) {
|
|
soc_log_err("Input parameter(port) invalid.\n");
|
|
soc_err_print_u32(port);
|
|
return SOC_ERR_FRONTEND_INVALID_PORT;
|
|
}
|
|
if (bit_rate == NULL) {
|
|
soc_log_err("Input parameter(bit_rate) invalid.\n");
|
|
return SOC_ERR_FRONTEND_INVALID_PARA;
|
|
}
|
|
tmp_tuner_bit_rate.port = port;
|
|
ret = ext_mpi_frontend_get_bit_rate(&tmp_tuner_bit_rate);
|
|
if (ret != TD_SUCCESS) {
|
|
soc_err_print_call_fun_err(ext_mpi_frontend_get_bit_rate, ret);
|
|
return SOC_ERR_FRONTEND_FAILED_GETBAND;
|
|
}
|
|
|
|
*bit_rate = tmp_tuner_bit_rate.bit_rate;
|
|
return TD_SUCCESS;
|
|
}
|
|
|