mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 04:48:04 +09:00
atv_demod: optimize calls with other modules [1/1]
PD#TV-9100 Problem: 1.optimize calls with other modules. Solution: 1.optimize calls with other modules. 2.add ext file interacts with other modules. 3.add sync to prevent NULL pointer crashes. Verify: Verified by x301 Change-Id: Id1930400454b020616e0c669cae5f473f498b6de Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ atvdemod_fe-objs = atvdemod_func.o \
|
||||
atv_demod_access.o \
|
||||
atv_demod_debug.o \
|
||||
atv_demod_isr.o \
|
||||
atv_demod_ext.o \
|
||||
|
||||
ccflags-y += -I.
|
||||
ccflags-y += -Idrivers/media/dvb-core
|
||||
97
drivers/amlogic/atv_demod/atv_demod_ext.c
Normal file
97
drivers/amlogic/atv_demod/atv_demod_ext.c
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* drivers/amlogic/atv_demod/atv_demod_ext.c
|
||||
*
|
||||
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#include "atv_demod_ext.h"
|
||||
|
||||
hook_func_t aml_fe_hook_atv_status;
|
||||
hook_func_t aml_fe_hook_hv_lock;
|
||||
hook_func_t aml_fe_hook_get_fmt;
|
||||
hook_func1_t aml_fe_hook_set_mode;
|
||||
|
||||
static DEFINE_MUTEX(aml_fe_hook_mutex);
|
||||
|
||||
void aml_fe_hook_cvd(hook_func_t atv_mode, hook_func_t cvd_hv_lock,
|
||||
hook_func_t get_fmt, hook_func1_t set_mode)
|
||||
{
|
||||
mutex_lock(&aml_fe_hook_mutex);
|
||||
|
||||
aml_fe_hook_atv_status = atv_mode;
|
||||
aml_fe_hook_hv_lock = cvd_hv_lock;
|
||||
aml_fe_hook_get_fmt = get_fmt;
|
||||
aml_fe_hook_set_mode = set_mode;
|
||||
|
||||
mutex_unlock(&aml_fe_hook_mutex);
|
||||
|
||||
pr_info("%s: %s OK.\n", __func__, atv_mode != NULL ? "set" : "reset");
|
||||
}
|
||||
EXPORT_SYMBOL(aml_fe_hook_cvd);
|
||||
|
||||
bool aml_fe_has_hook_up(void)
|
||||
{
|
||||
bool state = false;
|
||||
|
||||
mutex_lock(&aml_fe_hook_mutex);
|
||||
|
||||
if (!aml_fe_hook_atv_status ||
|
||||
!aml_fe_hook_hv_lock ||
|
||||
!aml_fe_hook_get_fmt ||
|
||||
!aml_fe_hook_set_mode)
|
||||
state = false;
|
||||
else
|
||||
state = true;
|
||||
|
||||
mutex_unlock(&aml_fe_hook_mutex);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
bool aml_fe_hook_call_get_fmt(int *fmt)
|
||||
{
|
||||
bool state = false;
|
||||
|
||||
mutex_lock(&aml_fe_hook_mutex);
|
||||
|
||||
if (aml_fe_hook_get_fmt && fmt) {
|
||||
*fmt = aml_fe_hook_get_fmt();
|
||||
state = true;
|
||||
} else
|
||||
state = false;
|
||||
|
||||
mutex_unlock(&aml_fe_hook_mutex);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
bool aml_fe_hook_call_set_mode(bool mode)
|
||||
{
|
||||
bool state = false;
|
||||
|
||||
mutex_lock(&aml_fe_hook_mutex);
|
||||
|
||||
if (aml_fe_hook_set_mode) {
|
||||
aml_fe_hook_set_mode(mode);
|
||||
state = true;
|
||||
} else
|
||||
state = false;
|
||||
|
||||
mutex_unlock(&aml_fe_hook_mutex);
|
||||
|
||||
return state;
|
||||
}
|
||||
35
drivers/amlogic/atv_demod/atv_demod_ext.h
Normal file
35
drivers/amlogic/atv_demod/atv_demod_ext.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* drivers/amlogic/atv_demod/atv_demod_ext.h
|
||||
*
|
||||
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ATV_DEMOD_EXT_H__
|
||||
#define __ATV_DEMOD_EXT_H__
|
||||
|
||||
/* This module is atv demod interacts with other modules */
|
||||
|
||||
typedef int (*hook_func_t) (void);
|
||||
typedef int (*hook_func1_t)(bool);
|
||||
|
||||
extern hook_func_t aml_fe_hook_atv_status;
|
||||
extern hook_func_t aml_fe_hook_hv_lock;
|
||||
extern hook_func_t aml_fe_hook_get_fmt;
|
||||
extern hook_func1_t aml_fe_hook_set_mode;
|
||||
|
||||
extern bool aml_fe_has_hook_up(void);
|
||||
extern bool aml_fe_hook_call_get_fmt(int *fmt);
|
||||
extern bool aml_fe_hook_call_set_mode(bool mode);
|
||||
|
||||
#endif /* __ATV_DEMOD_EXT_H__ */
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "atv_demod_afc.h"
|
||||
#include "atv_demod_monitor.h"
|
||||
#include "atv_demod_isr.h"
|
||||
#include "atv_demod_ext.h"
|
||||
|
||||
#define DEVICE_NAME "aml_atvdemod"
|
||||
|
||||
@@ -383,6 +384,8 @@ static int atv_demod_set_config(struct dvb_frontend *fe, void *priv_cfg)
|
||||
|
||||
if (priv->monitor.disable)
|
||||
priv->monitor.disable(&priv->monitor);
|
||||
|
||||
aml_fe_hook_call_set_mode(true);
|
||||
break;
|
||||
|
||||
case AML_ATVDEMOD_UNSCAN_MODE:
|
||||
@@ -397,6 +400,7 @@ static int atv_demod_set_config(struct dvb_frontend *fe, void *priv_cfg)
|
||||
if (priv->monitor.enable)
|
||||
priv->monitor.enable(&priv->monitor);
|
||||
#endif
|
||||
aml_fe_hook_call_set_mode(false);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -431,24 +435,6 @@ bool support_secam_l;
|
||||
|
||||
bool slow_mode;
|
||||
|
||||
typedef int (*hook_func_t) (void);
|
||||
typedef int (*hook_func1_t)(bool);
|
||||
hook_func_t aml_fe_hook_atv_status;
|
||||
hook_func_t aml_fe_hook_hv_lock;
|
||||
hook_func_t aml_fe_hook_get_fmt;
|
||||
hook_func1_t aml_fe_hook_set_mode;
|
||||
|
||||
void aml_fe_hook_cvd(hook_func_t atv_mode, hook_func_t cvd_hv_lock,
|
||||
hook_func_t get_fmt, hook_func1_t set_mode)
|
||||
{
|
||||
aml_fe_hook_atv_status = atv_mode;
|
||||
aml_fe_hook_hv_lock = cvd_hv_lock;
|
||||
aml_fe_hook_get_fmt = get_fmt;
|
||||
aml_fe_hook_set_mode = set_mode;
|
||||
|
||||
pr_info("%s: OK.\n", __func__);
|
||||
}
|
||||
EXPORT_SYMBOL(aml_fe_hook_cvd);
|
||||
|
||||
static v4l2_std_id atvdemod_fmt_2_v4l2_std(int fmt)
|
||||
{
|
||||
@@ -555,12 +541,12 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
|
||||
break;
|
||||
}
|
||||
|
||||
if (aml_fe_hook_get_fmt == NULL) {
|
||||
if (aml_fe_hook_call_get_fmt(&cvbs_std) == false) {
|
||||
pr_err("%s: aml_fe_hook_get_fmt == NULL.\n",
|
||||
__func__);
|
||||
break;
|
||||
}
|
||||
cvbs_std = aml_fe_hook_get_fmt();
|
||||
|
||||
if (cvbs_std) {
|
||||
varify_cnt++;
|
||||
pr_dbg("get cvbs_std varify_cnt:%d, cnt:%d, cvbs_std:0x%x\n",
|
||||
@@ -1144,7 +1130,7 @@ static enum v4l2_search atvdemod_fe_search(struct v4l2_frontend *v4l2_fe)
|
||||
!fe->ops.analog_ops.has_signal ||
|
||||
!fe->ops.analog_ops.set_params ||
|
||||
!fe->ops.analog_ops.set_config ||
|
||||
!aml_fe_hook_set_mode || !aml_fe_hook_set_mode)) {
|
||||
(aml_fe_has_hook_up() == false))) {
|
||||
pr_err("[%s] error: NULL function or pointer.\n", __func__);
|
||||
return V4L2_SEARCH_INVALID;
|
||||
}
|
||||
@@ -1157,11 +1143,8 @@ static enum v4l2_search atvdemod_fe_search(struct v4l2_frontend *v4l2_fe)
|
||||
|
||||
if (p->afc_range == 0) {
|
||||
pr_err("[%s] afc_range == 0, skip the search\n", __func__);
|
||||
aml_fe_hook_set_mode(0);
|
||||
|
||||
return V4L2_SEARCH_INVALID;
|
||||
} else {
|
||||
aml_fe_hook_set_mode(1);
|
||||
}
|
||||
|
||||
tuner_id = priv->atvdemod_param.tuner_id;
|
||||
|
||||
@@ -399,6 +399,10 @@ static int v4l2_set_frontend(struct v4l2_frontend *v4l2_fe,
|
||||
|
||||
/* Request the search algorithm to search */
|
||||
if (params->flag & ANALOG_FLAG_ENABLE_AFC) {
|
||||
|
||||
if (v4l2_fe->params.afc_range == 0)
|
||||
return 0;
|
||||
|
||||
fepriv->state = V4L2FE_STATE_RETUNE;
|
||||
|
||||
fepriv->algo_status |= V4L2_SEARCH_AGAIN;
|
||||
|
||||
Reference in New Issue
Block a user