mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
atv_demod: optimize set frontend time [1/1]
PD#SWPL-8072 Problem: optimize set frontend time. Solution: 1.To optimize the atv demod init. 2.Turn off nicam/btsc/A2 recognition by default. 3.atv demod version: V2.11. Verify: Verified by x301 Change-Id: I4f894626da18fef61ce8283260e1d75adb0e3640 Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
This commit is contained in:
@@ -108,7 +108,7 @@ void atv_demod_afc_do_work(struct work_struct *work)
|
||||
int tmp = 0;
|
||||
int field_lock = 0;
|
||||
|
||||
if (afc->state == false)
|
||||
if (afc->state != AFC_ENABLE)
|
||||
return;
|
||||
|
||||
retrieve_vpll_carrier_lock(&tmp);/* 0 means lock, 1 means unlock */
|
||||
@@ -201,7 +201,7 @@ static void atv_demod_afc_timer_handler(unsigned long arg)
|
||||
struct dvb_frontend *fe = afc->fe;
|
||||
unsigned int delay_ms = 0;
|
||||
|
||||
if (afc->state == false)
|
||||
if (afc->state == AFC_DISABLE)
|
||||
return;
|
||||
|
||||
if (afc->status == AFC_LOCK_STATUS_POST_OVER_RANGE ||
|
||||
@@ -224,6 +224,9 @@ static void atv_demod_afc_timer_handler(unsigned long arg)
|
||||
if ((afc_timer_en == false) || (fe->ops.info.type != FE_ANALOG))
|
||||
return;
|
||||
|
||||
if (afc->state == AFC_PAUSE)
|
||||
return;
|
||||
|
||||
schedule_work(&afc->work);
|
||||
}
|
||||
|
||||
@@ -231,8 +234,8 @@ static void atv_demod_afc_disable(struct atv_demod_afc *afc)
|
||||
{
|
||||
mutex_lock(&afc->mtx);
|
||||
|
||||
if (afc_timer_en && (afc->state == true)) {
|
||||
afc->state = false;
|
||||
if (afc_timer_en && (afc->state != AFC_DISABLE)) {
|
||||
afc->state = AFC_DISABLE;
|
||||
del_timer_sync(&afc->timer);
|
||||
cancel_work_sync(&afc->work);
|
||||
}
|
||||
@@ -246,7 +249,7 @@ static void atv_demod_afc_enable(struct atv_demod_afc *afc)
|
||||
{
|
||||
mutex_lock(&afc->mtx);
|
||||
|
||||
if (afc_timer_en && (afc->state == false)) {
|
||||
if (afc_timer_en && (afc->state == AFC_DISABLE)) {
|
||||
init_timer(&afc->timer);
|
||||
afc->timer.function = atv_demod_afc_timer_handler;
|
||||
afc->timer.data = (ulong) afc;
|
||||
@@ -259,7 +262,14 @@ static void atv_demod_afc_enable(struct atv_demod_afc *afc)
|
||||
afc->timer_delay_cnt = 20;
|
||||
afc->status = AFC_LOCK_STATUS_NULL;
|
||||
add_timer(&afc->timer);
|
||||
afc->state = true;
|
||||
afc->state = AFC_ENABLE;
|
||||
} else if (afc_timer_en && (afc->state == AFC_PAUSE)) {
|
||||
afc->offset = 0;
|
||||
afc->no_sig_cnt = 0;
|
||||
afc->pre_step = 0;
|
||||
afc->timer_delay_cnt = 20;
|
||||
afc->status = AFC_LOCK_STATUS_NULL;
|
||||
afc->state = AFC_ENABLE;
|
||||
}
|
||||
|
||||
mutex_unlock(&afc->mtx);
|
||||
@@ -267,19 +277,31 @@ static void atv_demod_afc_enable(struct atv_demod_afc *afc)
|
||||
pr_afc("%s: state: %d.\n", __func__, afc->state);
|
||||
}
|
||||
|
||||
static void atv_demod_afc_pause(struct atv_demod_afc *afc)
|
||||
{
|
||||
mutex_lock(&afc->mtx);
|
||||
|
||||
if (afc->state == AFC_ENABLE) {
|
||||
afc->state = AFC_PAUSE;
|
||||
cancel_work_sync(&afc->work);
|
||||
}
|
||||
|
||||
mutex_unlock(&afc->mtx);
|
||||
}
|
||||
|
||||
void atv_demod_afc_init(struct atv_demod_afc *afc)
|
||||
{
|
||||
mutex_lock(&afc_mutex);
|
||||
|
||||
mutex_init(&afc->mtx);
|
||||
|
||||
afc->state = false;
|
||||
afc->state = AFC_DISABLE;
|
||||
afc->timer_delay_cnt = 0;
|
||||
afc->disable = atv_demod_afc_disable;
|
||||
afc->enable = atv_demod_afc_enable;
|
||||
afc->pause = atv_demod_afc_pause;
|
||||
|
||||
INIT_WORK(&afc->work, atv_demod_afc_do_work);
|
||||
|
||||
mutex_unlock(&afc_mutex);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
|
||||
#define AFC_BEST_LOCK 50
|
||||
|
||||
#define AFC_DISABLE (0)
|
||||
#define AFC_ENABLE (1)
|
||||
#define AFC_PAUSE (2)
|
||||
|
||||
struct atv_demod_afc {
|
||||
struct work_struct work;
|
||||
struct timer_list timer;
|
||||
@@ -44,7 +48,7 @@ struct atv_demod_afc {
|
||||
|
||||
struct mutex mtx;
|
||||
|
||||
bool state;
|
||||
int state;
|
||||
|
||||
int timer_delay_cnt;
|
||||
|
||||
@@ -60,6 +64,7 @@ struct atv_demod_afc {
|
||||
|
||||
void (*disable)(struct atv_demod_afc *afc);
|
||||
void (*enable)(struct atv_demod_afc *afc);
|
||||
void (*pause)(struct atv_demod_afc *afc);
|
||||
};
|
||||
|
||||
extern void atv_demod_afc_init(struct atv_demod_afc *afc);
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "atvauddemod_func.h"
|
||||
|
||||
|
||||
#define AMLATVDEMOD_VER "V2.10"
|
||||
#define AMLATVDEMOD_VER "V2.11"
|
||||
|
||||
struct aml_atvdemod_device *amlatvdemod_devp;
|
||||
|
||||
|
||||
@@ -23,20 +23,6 @@
|
||||
#include "drivers/media/dvb-core/dvb_frontend.h"
|
||||
#include "atv_demod_v4l2.h"
|
||||
|
||||
struct aml_atvdemod_parameters {
|
||||
|
||||
struct analog_parameters param;
|
||||
|
||||
unsigned int soundsys;/* A2,BTSC/EIAJ/NICAM */
|
||||
unsigned int lock_range;
|
||||
unsigned int leap_step;
|
||||
|
||||
unsigned int afc_range;
|
||||
unsigned int tuner_id;
|
||||
unsigned int if_freq;
|
||||
unsigned int if_inv;
|
||||
unsigned int reserved;
|
||||
};
|
||||
|
||||
struct aml_tuner {
|
||||
struct tuner_config cfg;
|
||||
@@ -57,7 +43,7 @@ struct aml_atvdemod_device {
|
||||
unsigned int if_inv;
|
||||
u64 std;
|
||||
unsigned int audmode;
|
||||
unsigned int soundsys;
|
||||
unsigned int sound_mode;
|
||||
int fre_offset;
|
||||
|
||||
struct pinctrl *agc_pin;
|
||||
|
||||
@@ -49,7 +49,7 @@ static void atv_demod_monitor_do_work(struct work_struct *work)
|
||||
struct atv_demod_monitor *monitor =
|
||||
container_of(work, struct atv_demod_monitor, work);
|
||||
|
||||
if (!monitor->state)
|
||||
if (monitor->state == MONI_DISABLE)
|
||||
return;
|
||||
|
||||
retrieve_vpll_carrier_lock(&vpll_lock);
|
||||
@@ -104,6 +104,9 @@ static void atv_demod_monitor_timer_handler(unsigned long arg)
|
||||
if (vdac_enable_check_dtv())
|
||||
return;
|
||||
|
||||
if (monitor->state == MONI_PAUSE)
|
||||
return;
|
||||
|
||||
schedule_work(&monitor->work);
|
||||
}
|
||||
|
||||
@@ -111,7 +114,7 @@ static void atv_demod_monitor_enable(struct atv_demod_monitor *monitor)
|
||||
{
|
||||
mutex_lock(&monitor->mtx);
|
||||
|
||||
if (atvdemod_timer_en && !monitor->state) {
|
||||
if (atvdemod_timer_en && monitor->state == MONI_DISABLE) {
|
||||
atv_dmd_non_std_set(false);
|
||||
|
||||
init_timer(&monitor->timer);
|
||||
@@ -121,7 +124,12 @@ static void atv_demod_monitor_enable(struct atv_demod_monitor *monitor)
|
||||
monitor->timer.expires = jiffies +
|
||||
ATVDEMOD_INTERVAL * atvdemod_timer_delay;
|
||||
add_timer(&monitor->timer);
|
||||
monitor->state = true;
|
||||
monitor->state = MONI_ENABLE;
|
||||
monitor->lock_cnt = 0;
|
||||
} else if (atvdemod_timer_en && monitor->state == MONI_PAUSE) {
|
||||
atv_dmd_non_std_set(false);
|
||||
|
||||
monitor->state = MONI_ENABLE;
|
||||
monitor->lock_cnt = 0;
|
||||
}
|
||||
|
||||
@@ -134,9 +142,8 @@ static void atv_demod_monitor_disable(struct atv_demod_monitor *monitor)
|
||||
{
|
||||
mutex_lock(&monitor->mtx);
|
||||
|
||||
if (atvdemod_timer_en && monitor->state) {
|
||||
monitor->state = false;
|
||||
atv_dmd_non_std_set(false);
|
||||
if (atvdemod_timer_en && monitor->state != MONI_DISABLE) {
|
||||
monitor->state = MONI_DISABLE;
|
||||
del_timer_sync(&monitor->timer);
|
||||
cancel_work_sync(&monitor->work);
|
||||
}
|
||||
@@ -146,20 +153,33 @@ static void atv_demod_monitor_disable(struct atv_demod_monitor *monitor)
|
||||
pr_dbg("%s: state: %d.\n", __func__, monitor->state);
|
||||
}
|
||||
|
||||
static void atv_demod_monitor_pause(struct atv_demod_monitor *monitor)
|
||||
{
|
||||
mutex_lock(&monitor->mtx);
|
||||
|
||||
if (monitor->state == MONI_ENABLE) {
|
||||
monitor->state = MONI_PAUSE;
|
||||
atv_dmd_non_std_set(false);
|
||||
cancel_work_sync(&monitor->work);
|
||||
}
|
||||
|
||||
mutex_unlock(&monitor->mtx);
|
||||
}
|
||||
|
||||
void atv_demod_monitor_init(struct atv_demod_monitor *monitor)
|
||||
{
|
||||
mutex_lock(&monitor_mutex);
|
||||
|
||||
mutex_init(&monitor->mtx);
|
||||
|
||||
monitor->state = false;
|
||||
monitor->state = MONI_DISABLE;
|
||||
monitor->lock = false;
|
||||
monitor->lock_cnt = 0;
|
||||
monitor->disable = atv_demod_monitor_disable;
|
||||
monitor->enable = atv_demod_monitor_enable;
|
||||
monitor->pause = atv_demod_monitor_pause;
|
||||
|
||||
INIT_WORK(&monitor->work, atv_demod_monitor_do_work);
|
||||
|
||||
mutex_unlock(&monitor_mutex);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
#include <linux/mutex.h>
|
||||
|
||||
|
||||
#define MONI_DISABLE (0)
|
||||
#define MONI_ENABLE (1)
|
||||
#define MONI_PAUSE (2)
|
||||
|
||||
struct atv_demod_monitor {
|
||||
struct work_struct work;
|
||||
struct timer_list timer;
|
||||
@@ -31,13 +35,14 @@ struct atv_demod_monitor {
|
||||
|
||||
struct mutex mtx;
|
||||
|
||||
bool state;
|
||||
int state;
|
||||
bool lock;
|
||||
|
||||
unsigned int lock_cnt;
|
||||
|
||||
void (*disable)(struct atv_demod_monitor *monitor);
|
||||
void (*enable)(struct atv_demod_monitor *monitor);
|
||||
void (*pause)(struct atv_demod_monitor *monitor);
|
||||
};
|
||||
|
||||
extern void atv_demod_monitor_init(struct atv_demod_monitor *monitor);
|
||||
|
||||
@@ -162,7 +162,7 @@ int atv_demod_enter_mode(struct dvb_frontend *fe)
|
||||
|
||||
amlatvdemod_devp->std = 0;
|
||||
amlatvdemod_devp->audmode = 0;
|
||||
amlatvdemod_devp->soundsys = 0xFF;
|
||||
amlatvdemod_devp->sound_mode = 0xFF;
|
||||
|
||||
pr_info("%s: OK.\n", __func__);
|
||||
|
||||
@@ -198,7 +198,7 @@ int atv_demod_leave_mode(struct dvb_frontend *fe)
|
||||
|
||||
amlatvdemod_devp->std = 0;
|
||||
amlatvdemod_devp->audmode = 0;
|
||||
amlatvdemod_devp->soundsys = 0xFF;
|
||||
amlatvdemod_devp->sound_mode = 0xFF;
|
||||
|
||||
pr_info("%s: OK.\n", __func__);
|
||||
|
||||
@@ -211,17 +211,16 @@ static void atv_demod_set_params(struct dvb_frontend *fe,
|
||||
int ret = -1;
|
||||
u32 if_info[2] = { 0 };
|
||||
struct atv_demod_priv *priv = fe->analog_demod_priv;
|
||||
struct aml_atvdemod_parameters *p = &priv->atvdemod_param;
|
||||
bool reconfig = false;
|
||||
struct atv_demod_parameters *p = &priv->atvdemod_param;
|
||||
|
||||
priv->standby = true;
|
||||
|
||||
/* afc tune disable,must cancel wq before set tuner freq*/
|
||||
if (priv->afc.disable)
|
||||
priv->afc.disable(&priv->afc);
|
||||
if (priv->afc.pause)
|
||||
priv->afc.pause(&priv->afc);
|
||||
|
||||
if (priv->monitor.disable)
|
||||
priv->monitor.disable(&priv->monitor);
|
||||
if (priv->monitor.pause)
|
||||
priv->monitor.pause(&priv->monitor);
|
||||
|
||||
if (fe->ops.tuner_ops.set_analog_params)
|
||||
ret = fe->ops.tuner_ops.set_analog_params(fe, params);
|
||||
@@ -233,37 +232,12 @@ static void atv_demod_set_params(struct dvb_frontend *fe,
|
||||
p->param.mode = params->mode;
|
||||
p->param.audmode = params->audmode;
|
||||
p->param.std = params->std;
|
||||
p->last_frequency = params->frequency;
|
||||
|
||||
p->if_inv = if_info[0];
|
||||
p->if_freq = if_info[1];
|
||||
|
||||
if ((p->tuner_id == AM_TUNER_R840) ||
|
||||
(p->tuner_id == AM_TUNER_R842) ||
|
||||
(p->tuner_id == AM_TUNER_SI2151) ||
|
||||
(p->tuner_id == AM_TUNER_SI2159) ||
|
||||
(p->tuner_id == AM_TUNER_MXL661))
|
||||
reconfig = false;
|
||||
|
||||
/* In general, demod does not need to be reconfigured
|
||||
* if parameters such as STD remain unchanged,
|
||||
* but when the input signal frequency offset -0.25MHz,
|
||||
* demod will be unlocked. That's very strange.
|
||||
*/
|
||||
if (reconfig || !priv->scanning ||
|
||||
amlatvdemod_devp->std != p->param.std ||
|
||||
amlatvdemod_devp->audmode != p->param.audmode ||
|
||||
amlatvdemod_devp->if_freq != p->if_freq ||
|
||||
amlatvdemod_devp->if_inv != p->if_inv) {
|
||||
|
||||
amlatvdemod_devp->std = p->param.std;
|
||||
amlatvdemod_devp->audmode = p->param.audmode;
|
||||
amlatvdemod_devp->if_freq = p->if_freq;
|
||||
amlatvdemod_devp->if_inv = p->if_inv;
|
||||
|
||||
atv_dmd_set_std();
|
||||
atvdemod_init(!priv->scanning);
|
||||
} else
|
||||
atv_dmd_soft_reset();
|
||||
atvdemod_init(priv);
|
||||
|
||||
if (!priv->scanning)
|
||||
atvauddemod_init();
|
||||
@@ -686,12 +660,14 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
|
||||
|
||||
*audio_fmt = audio;
|
||||
|
||||
#if 0 /* no detect when searching */
|
||||
/* for audio standard detection */
|
||||
if (is_meson_txlx_cpu() || is_meson_txhd_cpu() || is_meson_tl1_cpu()
|
||||
|| is_meson_tm2_cpu()) {
|
||||
*soundsys = amlfmt_aud_standard(broad_std);
|
||||
*soundsys = (*soundsys << 16) | 0x00FFFF;
|
||||
} else
|
||||
#endif
|
||||
*soundsys = 0xFFFFFF;
|
||||
|
||||
pr_info("auto detect audio broad_std %d, [%s][0x%x] soundsys[0x%x]\n",
|
||||
@@ -967,12 +943,12 @@ static int atvdemod_fe_set_property(struct v4l2_frontend *v4l2_fe,
|
||||
switch (tvp->cmd) {
|
||||
case V4L2_SOUND_SYS:
|
||||
/* aud_mode = tvp->data & 0xFF; */
|
||||
amlatvdemod_devp->soundsys = tvp->data & 0xFF;
|
||||
if (amlatvdemod_devp->soundsys != 0xFF) {
|
||||
aud_mode = amlatvdemod_devp->soundsys;
|
||||
params->soundsys = aud_mode;
|
||||
amlatvdemod_devp->sound_mode = tvp->data & 0xFF;
|
||||
if (amlatvdemod_devp->sound_mode != 0xFF) {
|
||||
aud_mode = amlatvdemod_devp->sound_mode;
|
||||
params->soundsys = params->soundsys | aud_mode;
|
||||
}
|
||||
priv->sound_sys.output_mode = tvp->data & 0xFF;
|
||||
priv->atvdemod_sound.output_mode = tvp->data & 0xFF;
|
||||
break;
|
||||
|
||||
case V4L2_SLOW_SEARCH_MODE:
|
||||
@@ -980,7 +956,7 @@ static int atvdemod_fe_set_property(struct v4l2_frontend *v4l2_fe,
|
||||
break;
|
||||
|
||||
case V4L2_SIF_OVER_MODULATION:
|
||||
priv->sound_sys.sif_over_modulation = tvp->data;
|
||||
priv->atvdemod_sound.sif_over_modulation = tvp->data;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -46,22 +46,37 @@
|
||||
#define AUTO_DETECT_COLOR (1 << 0)
|
||||
#define AUTO_DETECT_AUDIO (1 << 1)
|
||||
|
||||
struct atv_demod_sound_system {
|
||||
unsigned int broadcast_std;
|
||||
unsigned int audio_std;
|
||||
unsigned int input_mode;
|
||||
unsigned int output_mode;
|
||||
struct atv_demod_sound {
|
||||
unsigned int broadcast_std; /* PAL-I/BG/DK/M, NTSC-M */
|
||||
unsigned int soundsys; /* A2/BTSC/EIAJ/NICAM */
|
||||
unsigned int input_mode; /* Mono/Stereo/Dual/Sap */
|
||||
unsigned int output_mode; /* Mono/Stereo/Dual/Sap */
|
||||
int sif_over_modulation;
|
||||
};
|
||||
|
||||
struct atv_demod_parameters {
|
||||
|
||||
struct analog_parameters param;
|
||||
|
||||
unsigned int last_frequency;
|
||||
unsigned int lock_range;
|
||||
unsigned int leap_step;
|
||||
|
||||
unsigned int afc_range;
|
||||
unsigned int tuner_id;
|
||||
unsigned int if_freq;
|
||||
unsigned int if_inv;
|
||||
unsigned int reserved;
|
||||
};
|
||||
|
||||
struct atv_demod_priv {
|
||||
struct tuner_i2c_props i2c_props;
|
||||
struct list_head hybrid_tuner_instance_list;
|
||||
|
||||
bool standby;
|
||||
|
||||
struct aml_atvdemod_parameters atvdemod_param;
|
||||
struct atv_demod_sound_system sound_sys;
|
||||
struct atv_demod_parameters atvdemod_param;
|
||||
struct atv_demod_sound atvdemod_sound;
|
||||
|
||||
struct atv_demod_afc afc;
|
||||
|
||||
|
||||
@@ -110,8 +110,16 @@ static void v4l2_frontend_add_event(struct v4l2_frontend *v4l2_fe,
|
||||
e = &events->events[events->eventw];
|
||||
e->status = status;
|
||||
|
||||
memcpy(&e->parameters, &v4l2_fe->params,
|
||||
sizeof(struct v4l2_analog_parameters));
|
||||
/* memcpy(&e->parameters, &v4l2_fe->params,
|
||||
* sizeof(struct v4l2_analog_parameters));
|
||||
*/
|
||||
e->parameters.frequency = v4l2_fe->params.frequency;
|
||||
e->parameters.audmode = v4l2_fe->params.audmode;
|
||||
e->parameters.soundsys = v4l2_fe->params.soundsys;
|
||||
e->parameters.std = v4l2_fe->params.std;
|
||||
e->parameters.flag = v4l2_fe->params.flag;
|
||||
e->parameters.afc_range = v4l2_fe->params.afc_range;
|
||||
e->parameters.reserved = v4l2_fe->params.reserved;
|
||||
|
||||
events->eventw = wp;
|
||||
|
||||
@@ -375,18 +383,29 @@ static int v4l2_set_frontend(struct v4l2_frontend *v4l2_fe,
|
||||
* the user. FE_SET_FRONTEND triggers an initial frontend event
|
||||
* with status = 0, which copies output parameters to userspace.
|
||||
*/
|
||||
//dtv_property_legacy_params_sync_ex(fe, &fepriv->parameters_out);
|
||||
memcpy(&v4l2_fe->params, params, sizeof(struct v4l2_analog_parameters));
|
||||
|
||||
fepriv->state = V4L2FE_STATE_RETUNE;
|
||||
/* memcpy(&v4l2_fe->params, params,
|
||||
* sizeof(struct v4l2_analog_parameters));
|
||||
*/
|
||||
v4l2_fe->params.frequency = params->frequency;
|
||||
v4l2_fe->params.audmode = params->audmode;
|
||||
v4l2_fe->params.soundsys = params->soundsys;
|
||||
v4l2_fe->params.std = params->std;
|
||||
v4l2_fe->params.flag = params->flag;
|
||||
v4l2_fe->params.afc_range = params->afc_range;
|
||||
v4l2_fe->params.reserved = params->reserved;
|
||||
|
||||
/* Request the search algorithm to search */
|
||||
if (params->flag & ANALOG_FLAG_ENABLE_AFC) {
|
||||
fepriv->state = V4L2FE_STATE_RETUNE;
|
||||
|
||||
fepriv->algo_status |= V4L2_SEARCH_AGAIN;
|
||||
|
||||
/*dvb_frontend_add_event(fe, 0); */
|
||||
v4l2_frontend_clear_events(v4l2_fe);
|
||||
v4l2_frontend_wakeup(v4l2_fe);
|
||||
|
||||
fepriv->status = 0;
|
||||
|
||||
} else if (fe->ops.analog_ops.set_params) {
|
||||
/* TODO:*/
|
||||
p.frequency = params->frequency;
|
||||
@@ -402,8 +421,6 @@ static int v4l2_set_frontend(struct v4l2_frontend *v4l2_fe,
|
||||
fe->ops.analog_ops.set_params(fe, &p);
|
||||
}
|
||||
|
||||
fepriv->status = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -412,7 +429,14 @@ static int v4l2_get_frontend(struct v4l2_frontend *v4l2_fe,
|
||||
{
|
||||
pr_dbg("%s.\n", __func__);
|
||||
|
||||
memcpy(p, &v4l2_fe->params, sizeof(struct v4l2_analog_parameters));
|
||||
/*memcpy(p, &v4l2_fe->params, sizeof(struct v4l2_analog_parameters));*/
|
||||
p->frequency = v4l2_fe->params.frequency;
|
||||
p->audmode = v4l2_fe->params.audmode;
|
||||
p->soundsys = v4l2_fe->params.soundsys;
|
||||
p->std = v4l2_fe->params.std;
|
||||
p->flag = v4l2_fe->params.flag;
|
||||
p->afc_range = v4l2_fe->params.afc_range;
|
||||
p->reserved = v4l2_fe->params.reserved;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -107,8 +107,16 @@ struct v4l2_frontend;
|
||||
struct v4l2_analog_parameters {
|
||||
unsigned int frequency;
|
||||
unsigned int audmode;
|
||||
unsigned int soundsys; /*A2,BTSC,EIAJ,NICAM */
|
||||
/* std & 0xff000000: PAL/NTSC/SECAM, std & 0x00ffffff: cvbs format */
|
||||
|
||||
/* soundsys & 0xff0000: A2,BTSC,EIAJ,NICAM.
|
||||
* soundsys & 0xff00: signal input mode.
|
||||
* soundsys & 0xff: output mode.
|
||||
*/
|
||||
unsigned int soundsys;
|
||||
|
||||
/* std & 0xff000000: PAL/NTSC/SECAM.
|
||||
* std & 0x00ffffff: CVBS format.
|
||||
*/
|
||||
v4l2_std_id std;
|
||||
unsigned int flag; /* for search or play */
|
||||
unsigned int afc_range;
|
||||
|
||||
@@ -41,7 +41,7 @@ unsigned int aud_std = AUDIO_STANDARD_NICAM_DK;
|
||||
unsigned int aud_mode = AUDIO_OUTMODE_STEREO;
|
||||
bool aud_auto = true;
|
||||
bool aud_reinit;
|
||||
bool aud_mono_only;
|
||||
bool aud_mono_only = true;
|
||||
unsigned long over_threshold = 0xffff;
|
||||
unsigned long input_amplitude = 0xffff;
|
||||
|
||||
@@ -141,6 +141,8 @@ void atv_dmd_soft_reset(void)
|
||||
atv_dmd_wr_byte(APB_BLOCK_ADDR_SYSTEM_MGT, 0x0, 0x0);
|
||||
atv_dmd_wr_byte(APB_BLOCK_ADDR_SYSTEM_MGT, 0x0, 0x1);
|
||||
atv_dmd_wr_long(0x1d, 0x0, 0x1037);/* enable dac */
|
||||
|
||||
pr_dbg("%s done.\n", __func__);
|
||||
}
|
||||
|
||||
void atv_dmd_input_clk_32m(void)
|
||||
@@ -311,13 +313,20 @@ void atv_dmd_misc(void)
|
||||
atvaudio_ctrl_write(reg | 0x3);/* bit[1-0] */
|
||||
audio_atv_ov_flag = 0;
|
||||
}
|
||||
|
||||
pr_dbg("%s done.\n", __func__);
|
||||
}
|
||||
|
||||
void atv_dmd_ring_filter(bool on)
|
||||
{
|
||||
unsigned long filter_status = 0;
|
||||
if (!is_meson_tl1_cpu() && !is_meson_tm2_cpu())
|
||||
return;
|
||||
|
||||
filter_status = atv_dmd_rd_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c);
|
||||
if (((filter_status & 0x01) && on) || (!(filter_status & 0x01) && !on))
|
||||
return;
|
||||
|
||||
if (on) {
|
||||
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x10, 0x8274bf);
|
||||
atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x14, 0x1d175c);
|
||||
@@ -1723,18 +1732,18 @@ int amlfmt_aud_standard(int broad_std)
|
||||
reg_value = adec_rd_reg(CARRIER_MAG_REPORT);
|
||||
pr_info("\n%s CARRIER_MAG_REPORT: 0x%x\n",
|
||||
__func__, (reg_value >> 16) & 0xffff);
|
||||
if (((reg_value>>16)&0xffff) > audio_a2_threshold) {
|
||||
if (((reg_value >> 16) & 0xffff) > audio_a2_threshold) {
|
||||
std = AUDIO_STANDARD_A2_K;
|
||||
if (amlatvdemod_devp->soundsys == 0xFF)
|
||||
if (amlatvdemod_devp->sound_mode == 0xFF)
|
||||
aud_mode = AUDIO_OUTMODE_A2_STEREO;
|
||||
else
|
||||
aud_mode = amlatvdemod_devp->soundsys;
|
||||
aud_mode = amlatvdemod_devp->sound_mode;
|
||||
} else {
|
||||
std = AUDIO_STANDARD_BTSC;
|
||||
if (amlatvdemod_devp->soundsys == 0xFF)
|
||||
if (amlatvdemod_devp->sound_mode == 0xFF)
|
||||
aud_mode = AUDIO_OUTMODE_STEREO;
|
||||
else
|
||||
aud_mode = amlatvdemod_devp->soundsys;
|
||||
aud_mode = amlatvdemod_devp->sound_mode;
|
||||
configure_adec(std);
|
||||
adec_soft_reset();
|
||||
}
|
||||
@@ -1776,16 +1785,16 @@ int amlfmt_aud_standard(int broad_std)
|
||||
__func__, reg_value);
|
||||
if (nicam_lock) {
|
||||
std = AUDIO_STANDARD_NICAM_BG;
|
||||
if (amlatvdemod_devp->soundsys == 0xFF)
|
||||
if (amlatvdemod_devp->sound_mode == 0xFF)
|
||||
aud_mode = AUDIO_OUTMODE_NICAM_STEREO;
|
||||
else
|
||||
aud_mode = amlatvdemod_devp->soundsys;
|
||||
aud_mode = amlatvdemod_devp->sound_mode;
|
||||
} else {
|
||||
std = AUDIO_STANDARD_A2_BG;
|
||||
if (amlatvdemod_devp->soundsys == 0xFF)
|
||||
if (amlatvdemod_devp->sound_mode == 0xFF)
|
||||
aud_mode = AUDIO_OUTMODE_A2_STEREO;
|
||||
else
|
||||
aud_mode = amlatvdemod_devp->soundsys;
|
||||
aud_mode = amlatvdemod_devp->sound_mode;
|
||||
configure_adec(std);
|
||||
adec_soft_reset();
|
||||
}
|
||||
@@ -1814,16 +1823,16 @@ int amlfmt_aud_standard(int broad_std)
|
||||
__func__, reg_value);
|
||||
if (nicam_lock) {
|
||||
std = AUDIO_STANDARD_NICAM_DK;
|
||||
if (amlatvdemod_devp->soundsys == 0xFF)
|
||||
if (amlatvdemod_devp->sound_mode == 0xFF)
|
||||
aud_mode = AUDIO_OUTMODE_NICAM_STEREO;
|
||||
else
|
||||
aud_mode = amlatvdemod_devp->soundsys;
|
||||
aud_mode = amlatvdemod_devp->sound_mode;
|
||||
} else {
|
||||
std = AUDIO_STANDARD_A2_DK1;
|
||||
if (amlatvdemod_devp->soundsys == 0xFF)
|
||||
if (amlatvdemod_devp->sound_mode == 0xFF)
|
||||
aud_mode = AUDIO_OUTMODE_A2_STEREO;
|
||||
else
|
||||
aud_mode = amlatvdemod_devp->soundsys;
|
||||
aud_mode = amlatvdemod_devp->sound_mode;
|
||||
configure_adec(std);
|
||||
adec_soft_reset();
|
||||
}
|
||||
@@ -1852,10 +1861,10 @@ int amlfmt_aud_standard(int broad_std)
|
||||
__func__, reg_value);
|
||||
if (nicam_lock) {
|
||||
std = AUDIO_STANDARD_NICAM_I;
|
||||
if (amlatvdemod_devp->soundsys == 0xFF)
|
||||
if (amlatvdemod_devp->sound_mode == 0xFF)
|
||||
aud_mode = AUDIO_OUTMODE_NICAM_STEREO;
|
||||
else
|
||||
aud_mode = amlatvdemod_devp->soundsys;
|
||||
aud_mode = amlatvdemod_devp->sound_mode;
|
||||
} else {
|
||||
std = AUDIO_STANDARD_MONO_I;
|
||||
aud_mode = AUDIO_OUTMODE_MONO;
|
||||
@@ -1887,10 +1896,10 @@ int amlfmt_aud_standard(int broad_std)
|
||||
__func__, reg_value);
|
||||
if (nicam_lock) {
|
||||
std = AUDIO_STANDARD_NICAM_L;
|
||||
if (amlatvdemod_devp->soundsys == 0xFF)
|
||||
if (amlatvdemod_devp->sound_mode == 0xFF)
|
||||
aud_mode = AUDIO_OUTMODE_NICAM_STEREO;
|
||||
else
|
||||
aud_mode = amlatvdemod_devp->soundsys;
|
||||
aud_mode = amlatvdemod_devp->sound_mode;
|
||||
} else {
|
||||
std = AUDIO_STANDARD_MONO_L;
|
||||
aud_mode = AUDIO_OUTMODE_MONO;
|
||||
@@ -1949,41 +1958,45 @@ void atvauddemod_set_outputmode(void)
|
||||
}
|
||||
}
|
||||
|
||||
int atvdemod_init(bool on)
|
||||
int atvdemod_init(struct atv_demod_priv *priv)
|
||||
{
|
||||
/* 1.set system clock when atv enter*/
|
||||
struct atv_demod_parameters *p = &priv->atvdemod_param;
|
||||
|
||||
pr_dbg("%s do configure_receiver ...\n", __func__);
|
||||
if (is_meson_txlx_cpu() || is_meson_txhd_cpu() || is_meson_tl1_cpu()
|
||||
|| is_meson_tm2_cpu())
|
||||
sound_format = 1;
|
||||
configure_receiver(broad_std, if_freq, if_inv, gde_curve, sound_format);
|
||||
pr_dbg("%s do atv_dmd_misc ...\n", __func__);
|
||||
atv_dmd_misc();
|
||||
if (amlatvdemod_devp->std != p->param.std ||
|
||||
amlatvdemod_devp->audmode != p->param.audmode ||
|
||||
amlatvdemod_devp->if_freq != p->if_freq ||
|
||||
amlatvdemod_devp->if_inv != p->if_inv) {
|
||||
|
||||
if (on && (broad_std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M ||
|
||||
amlatvdemod_devp->std = p->param.std;
|
||||
amlatvdemod_devp->audmode = p->param.audmode;
|
||||
amlatvdemod_devp->if_freq = p->if_freq;
|
||||
amlatvdemod_devp->if_inv = p->if_inv;
|
||||
|
||||
atv_dmd_set_std(amlatvdemod_devp->std);
|
||||
|
||||
if (is_meson_txlx_cpu() || is_meson_txhd_cpu()
|
||||
|| is_meson_tl1_cpu() || is_meson_tm2_cpu())
|
||||
sound_format = 1;
|
||||
|
||||
configure_receiver(broad_std, if_freq, if_inv, gde_curve,
|
||||
sound_format);
|
||||
}
|
||||
|
||||
if (!priv->scanning)
|
||||
atv_dmd_misc();
|
||||
|
||||
if (!priv->scanning &&
|
||||
(broad_std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M ||
|
||||
broad_std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC))
|
||||
atv_dmd_ring_filter(true);
|
||||
else
|
||||
atv_dmd_ring_filter(false);
|
||||
|
||||
pr_dbg("%s do atv_dmd_soft_reset ...\n", __func__);
|
||||
/*4.software reset*/
|
||||
atv_dmd_soft_reset();
|
||||
|
||||
/* check the PLL, line lock status, don't need to check. */
|
||||
/* while (!all_lock) {
|
||||
* data32 = atv_dmd_rd_long(APB_BLOCK_ADDR_VDAGC,0x13<<2);
|
||||
* if ((data32 & 0x1c) == 0x0) {
|
||||
* all_lock = 1;
|
||||
* }
|
||||
* delay_us(400);
|
||||
* }
|
||||
*/
|
||||
|
||||
mix1_freq = atv_dmd_rd_byte(APB_BLOCK_ADDR_MIXER_1, 0x0);
|
||||
|
||||
pr_info("%s done\n", __func__);
|
||||
pr_dbg("%s done.\n", __func__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1997,10 +2010,8 @@ void atvdemod_uninit(void)
|
||||
atv_dmd_non_std_set(false);
|
||||
}
|
||||
|
||||
void atv_dmd_set_std(void)
|
||||
void atv_dmd_set_std(unsigned long ptstd)
|
||||
{
|
||||
v4l2_std_id ptstd = amlatvdemod_devp->std;
|
||||
|
||||
/* set broad standard of tuner*/
|
||||
if (((ptstd & V4L2_COLOR_STD_PAL)
|
||||
|| (ptstd & V4L2_COLOR_STD_SECAM)
|
||||
@@ -2086,8 +2097,8 @@ void atv_dmd_set_std(void)
|
||||
|
||||
pr_dbg("[%s] set std color %s, audio type %s.\n",
|
||||
__func__,
|
||||
v4l2_std_to_str((0xff000000 & amlatvdemod_devp->std)),
|
||||
v4l2_std_to_str((0xffffff & amlatvdemod_devp->std)));
|
||||
v4l2_std_to_str((0xff000000 & ptstd)),
|
||||
v4l2_std_to_str((0xffffff & ptstd)));
|
||||
|
||||
pr_dbg("[%s] set if_freq %d, if_inv %d.\n",
|
||||
__func__, amlatvdemod_devp->if_freq,
|
||||
@@ -2097,6 +2108,7 @@ void atv_dmd_set_std(void)
|
||||
int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe)
|
||||
{
|
||||
struct dvb_frontend *fe = &v4l2_fe->fe;
|
||||
struct atv_demod_priv *priv = fe->analog_demod_priv;
|
||||
struct v4l2_analog_parameters *p = &v4l2_fe->params;
|
||||
struct analog_parameters params;
|
||||
|
||||
@@ -2140,7 +2152,7 @@ int aml_audiomode_autodet(struct v4l2_frontend *v4l2_fe)
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M;
|
||||
} else {
|
||||
broad_std = AML_ATV_DEMOD_VIDEO_MODE_PROP_SECAM_L;
|
||||
atvdemod_init(false);
|
||||
atvdemod_init(priv);
|
||||
temp_data = atv_dmd_rd_reg(APB_BLOCK_ADDR_SIF_STG_2,
|
||||
0x02);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define __ATV_DEMOD_FUNC_H__
|
||||
|
||||
struct v4l2_frontend;
|
||||
struct atv_demod_priv;
|
||||
|
||||
#define HHI_ATV_DMD_SYS_CLK_CNTL 0x10f3
|
||||
|
||||
@@ -71,9 +72,9 @@ extern void configure_receiver(int Broadcast_Standard,
|
||||
int Tuner_Input_IF_inverted, int GDE_Curve,
|
||||
int sound_format);
|
||||
extern int atvdemod_clk_init(void);
|
||||
extern int atvdemod_init(bool on);
|
||||
extern int atvdemod_init(struct atv_demod_priv *priv);
|
||||
extern void atvdemod_uninit(void);
|
||||
extern void atv_dmd_set_std(void);
|
||||
extern void atv_dmd_set_std(unsigned long std);
|
||||
extern void retrieve_adc_power(int *adc_level);
|
||||
extern void retrieve_vpll_carrier_lock(int *lock);
|
||||
extern void retrieve_vpll_carrier_line_lock(int *lock);
|
||||
|
||||
Reference in New Issue
Block a user