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
\ No newline at end of file
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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__ */
#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"
if (priv->monitor.disable)
priv->monitor.disable(&priv->monitor);
+
+ aml_fe_hook_call_set_mode(true);
break;
case AML_ATVDEMOD_UNSCAN_MODE:
if (priv->monitor.enable)
priv->monitor.enable(&priv->monitor);
#endif
+ aml_fe_hook_call_set_mode(false);
break;
}
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)
{
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",
!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;
}
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;
/* 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;