/*1: tvafe clk enabled;*/
/*0: tvafe clk disabled*/
/*read write cvd acd reg will crash when clk disabled*/
-bool tvafe_clk_status;
+bool tvafe_clk_onoff;
#ifdef CONFIG_AMLOGIC_MEDIA_TVIN_AVDETECT
/*opened port,1:av1, 2:av2, 0:none av*/
#ifdef CONFIG_AMLOGIC_ATV_DEMOD
static struct tvafe_info_s *g_tvafe_info;
#endif
+bool tvafe_probe_flag;
+struct tvafe_dev_s *tvafe_devp;
+
static struct tvafe_user_param_s tvafe_user_param = {
.cutwindow_val_h = {0, 10, 18, 20, 62},
{
int fmt = 0;
+ if (!tvafe_probe_flag || tvafe_devp == NULL) {
+ tvafe_pr_info("%s tvafe not proble\n", __func__);
+ return 0;
+ }
+
+ if (!(tvafe_devp->flags & TVAFE_FLAG_DEV_OPENED) ||
+ (tvafe_devp->flags & TVAFE_POWERDOWN_IN_IDLE)) {
+ tvafe_pr_info("%s tvafe is PW DOWN\n", __func__);
+ return 0;
+ }
+
if (tvin_get_sm_status(0) != TVIN_SM_STATUS_STABLE) {
tvafe_pr_info("%s tvafe is not STABLE\n", __func__);
return 0;
/* set the flag to enabble ioctl access */
devp->flags |= TVAFE_FLAG_DEV_OPENED;
- tvafe_clk_status = true;
+ tvafe_clk_onoff = true;
#ifdef CONFIG_AMLOGIC_ATV_DEMOD
g_tvafe_info = tvafe;
/* register aml_fe hook for atv search */
mutex_unlock(&devp->afe_mutex);
return;
}
- tvafe_clk_status = false;
+
+ devp->flags &= (~TVAFE_FLAG_DEV_STARTED);
+ devp->flags &= (~TVAFE_FLAG_DEV_OPENED);
+ tvafe_clk_onoff = false;
/*del_timer_sync(&devp->timer);*/
#ifdef CONFIG_AMLOGIC_ATV_DEMOD
g_tvafe_info = NULL;
#endif
/* init variable */
memset(tvafe, 0, sizeof(struct tvafe_info_s));
-
- devp->flags &= (~TVAFE_FLAG_DEV_STARTED);
- devp->flags &= (~TVAFE_FLAG_DEV_OPENED);
-
tvafe_pr_info("%s close afe ok.\n", __func__);
-
mutex_unlock(&devp->afe_mutex);
}
struct tvafe_info_s *tvafe = &devp->tvafe;
enum tvin_port_e port = tvafe->parm.port;
- if (!(devp->flags & TVAFE_FLAG_DEV_OPENED)) {
+ if (!(devp->flags & TVAFE_FLAG_DEV_OPENED) ||
+ (devp->flags & TVAFE_POWERDOWN_IN_IDLE)) {
tvafe_pr_err("tvafe havn't opened, get fmt chg error!!!\n");
return true;
}
struct tvafe_info_s *tvafe = &devp->tvafe;
enum tvin_port_e port = tvafe->parm.port;
- if (!(devp->flags & TVAFE_FLAG_DEV_OPENED)) {
+ if (!(devp->flags & TVAFE_FLAG_DEV_OPENED) ||
+ (devp->flags & TVAFE_POWERDOWN_IN_IDLE)) {
tvafe_pr_err("tvafe havn't opened, get sig fmt error!!!\n");
return fmt;
}
int tvafe_vbi_reg_read(unsigned int reg, unsigned int *val)
{
- if (tvafe_clk_status)
+ if (tvafe_clk_onoff)
*val = readl(tvafe_reg_base+reg);
else
return -1;
int tvafe_vbi_reg_write(unsigned int reg, unsigned int val)
{
- if (tvafe_clk_status)
+ if (tvafe_clk_onoff)
writel(val, (tvafe_reg_base+reg));
else
return -1;
const struct of_device_id *match;
/* struct tvin_frontend_s * frontend; */
+ tvafe_devp = NULL;
match = of_match_device(meson_tvafe_dt_match, &pdev->dev);
if (match == NULL) {
tvafe_pr_err("%s,no matched table\n", __func__);
tdevp = kzalloc(sizeof(struct tvafe_dev_s), GFP_KERNEL);
if (!tdevp)
goto fail_kzalloc_tdev;
+ tvafe_devp = tdevp;
if (pdev->dev.of_node) {
ret = of_property_read_u32(pdev->dev.of_node,
disableapi = false;
force_stable = false;
-
+ tvafe_probe_flag = true;
tvafe_pr_info("driver probe ok\n");
return 0;
}
/*disable and reset tvafe clock*/
tdevp->flags |= TVAFE_POWERDOWN_IN_IDLE;
- tvafe_clk_status = false;
+ tvafe_clk_onoff = false;
tvafe_enable_module(false);
adc_set_pll_reset();
adc_set_pll_reset();
tvafe_enable_module(true);
tdevp->flags &= (~TVAFE_POWERDOWN_IN_IDLE);
- tvafe_clk_status = false;
+ tvafe_clk_onoff = true;
tvafe_pr_info("resume module\n");
return 0;
}
static void tvafe_drv_shutdown(struct platform_device *pdev)
{
+ struct tvafe_dev_s *tdevp;
+ struct tvafe_info_s *tvafe;
+
+ tdevp = platform_get_drvdata(pdev);
+ tvafe = &tdevp->tvafe;
+
if (tvafe_cpu_type() == CPU_TYPE_TL1) {
W_APB_BIT(TVFE_VAFE_CTRL0, 0, 19, 1);
W_APB_BIT(TVFE_VAFE_CTRL1, 0, 8, 1);
}
adc_pll_down();
+ tdevp->flags |= TVAFE_POWERDOWN_IN_IDLE;
+ tvafe_clk_onoff = false;
tvafe_pr_info("tvafe_drv_shutdown ok.\n");
}
extern int tvafe_device_create_file(struct device *dev);
extern void tvafe_remove_device_files(struct device *dev);
+extern bool tvafe_clk_onoff;
extern bool disableapi;
extern bool force_stable;
struct tvafe_user_param_s *user_param = tvafe_get_user_param();
unsigned int i = 0;
+ if (!tvafe_clk_onoff) {
+ tvafe_pr_err("%s: tvafe clk is disabled!\n", __func__);
+ return;
+ }
+
/*disable vbi*/
W_APB_REG(CVD2_VBI_FRAME_CODE_CTL, 0x10);
W_APB_REG(ACD_REG_22, 0x07080000);
{
int format;
+ if (!tvafe_probe_flag || tvafe_devp == NULL) {
+ tvafe_pr_info("%s tvafe not proble\n", __func__);
+ return 0;
+ }
+
+ if (!(tvafe_devp->flags & TVAFE_FLAG_DEV_OPENED) ||
+ (tvafe_devp->flags & TVAFE_POWERDOWN_IN_IDLE)) {
+ tvafe_pr_info("%s tvafe is PW DOWN\n", __func__);
+ return 0;
+ }
+
format = R_APB_REG(CVD2_STATUS_REGISTER3)&0x7;
return format;
}
{
int lock_status;
+ if (!tvafe_probe_flag || tvafe_devp == NULL) {
+ tvafe_pr_info("%s tvafe not proble\n", __func__);
+ return 0;
+ }
+
+ if (!(tvafe_devp->flags & TVAFE_FLAG_DEV_OPENED) ||
+ (tvafe_devp->flags & TVAFE_POWERDOWN_IN_IDLE)) {
+ tvafe_pr_info("%s tvafe is PW DOWN\n", __func__);
+ return 0;
+ }
+
lock_status = R_APB_REG(CVD2_STATUS_REGISTER1)&0x6;
return lock_status;
}
struct tvafe_cvd2_mem_s *mem)
{
struct tvafe_user_param_s *user_param = tvafe_get_user_param();
- static bool ret;
+ bool ret = true;
+
+ if (!tvafe_clk_onoff) {
+ tvafe_pr_err("%s: tvafe clk is disabled!\n", __func__);
+ return ret;
+ }
tvafe_cvd2_get_signal_status(cvd2);
/* get signal status from HW */
extern unsigned int try_fmt_max_atv;
extern unsigned int try_fmt_max_av;
+extern bool tvafe_probe_flag;
+extern struct tvafe_dev_s *tvafe_devp;
#endif /* _TVAFE_CVD_H */
/*ADC_EN_TVAFE 0x2*/
/*ADC_EN_DTV_DEMOD 0x4*/
/*ADC_EN_DTV_DEMODPLL 0x8*/
-int adc_set_pll_cntl(bool on, unsigned int module_sel, void *pDtvPara)
+int adc_set_pll_cntl(bool on, enum eADC_PLL_EN module_sel, void *pDtvPara)
{
unsigned int adc_pll_lock_cnt = 0;
int ret = 0; /* 0: success; -x: failed*/
struct tvafe_cvd2_mem_s *mem, enum tvin_port_e port,
struct tvafe_pin_mux_s *pinmux)
{
- unsigned int module_sel = ADC_EN_TVAFE;
+ enum eADC_PLL_EN module_sel = ADC_EN_TVAFE;
if (port == TVIN_PORT_CVBS3)
module_sel = ADC_EN_ATV_DEMOD;
/* adc pll ctl, atv demod & tvafe use the same adc module*/
/* module index: atv demod:0x01; tvafe:0x2*/
-#define ADC_EN_ATV_DEMOD 0x1
-#define ADC_EN_TVAFE 0x2
-#define ADC_EN_DTV_DEMOD 0x4
-#define ADC_EN_DTV_DEMODPLL 0x8
+enum eADC_PLL_EN {
+ ADC_EN_ATV_DEMOD = 0x1,
+ ADC_EN_TVAFE = 0x2,
+ ADC_EN_DTV_DEMOD = 0x4,
+ ADC_EN_DTV_DEMODPLL = 0x8,
+};
#define LOG_ADC_CAL
/* #define LOG_VGA_EDID */
return;
if (devp->vbi_start == false)
return;
- if (tvafe_clk_status == false) {
+ if (tvafe_clk_onoff == false) {
vbi_ringbuffer_flush(&devp->slicer->buffer);
return;
}
local_rptr = devp->temp_addr_start;
datalen = sizeof(struct vbi_data_s);
while (chlen < len) {
- if (!devp->vbi_start || !tvafe_clk_status) {
+ if (!devp->vbi_start || !tvafe_clk_onoff) {
if (vbi_dbg_en & VBI_DBG_INFO)
tvafe_pr_info("%s: vbi stopped\n", __func__);
goto vbi_slicer_work_exit;
while (vbi_ringbuffer_empty(src)) {
if ((non_blocking || vbi_nonblock_en) ||
- (tvafe_clk_status == false) || (timeout++ > 50)) {
+ (tvafe_clk_onoff == false) || (timeout++ > 50)) {
ret = -EWOULDBLOCK;
tvafe_pr_info("%s:nonblock|closed|timeout return.\n",
__func__);
msleep(20);
}
- if (tvafe_clk_status == false) {
+ if (tvafe_clk_onoff == false) {
ret = -EWOULDBLOCK;
vbi_ringbuffer_flush(src);
if (vbi_dbg_en & VBI_DBG_READ)
free_irq(vbi_dev->vs_irq, (void *)vbi_dev);
vbi_dev->irq_free_status = 0;
vcnt = 1;
- if (tvafe_clk_status) {
+ if (tvafe_clk_onoff) {
/* vbi reset release, vbi agent enable */
/*W_VBI_APB_REG(ACD_REG_22, 0x06080000);*/
W_VBI_APB_REG(CVD2_VBI_FRAME_CODE_CTL, 0x10);
tvafe_pr_err("%s: slicer mutex error\n", __func__);
return -ERESTARTSYS;
}
- if (tvafe_clk_status)
+ if (tvafe_clk_onoff)
vbi_hw_init(vbi_dev);
else {
tvafe_pr_err("tvafe not opend.ioctl start err\n");
vbi_dev->vbi_start = false;
vbi_data_stable_flag = 0;
ret = vbi_slicer_stop(vbi_slicer);
- if (tvafe_clk_status) {
+ if (tvafe_clk_onoff) {
/* manuel reset vbi */
/*W_VBI_APB_REG(ACD_REG_22, 0x82080000);*/
/* vbi reset release, vbi agent enable*/
break;
case VBI_IOC_SET_TYPE:
- if (!tvafe_clk_status) {
+ if (!tvafe_clk_onoff) {
mutex_unlock(&vbi_dev->mutex);
tvafe_pr_info("[vbi..] %s: afe not open,SET_TYPE return\n",
__func__);
mutex_unlock(&vbi_slicer->mutex);
break;
}
- if (tvafe_clk_status) {
+ if (tvafe_clk_onoff) {
ret = vbi_slicer_set(vbi_dev, vbi_slicer);
} else {
ret = -EFAULT;
/*1: tvafe clk enable;*/
/*0: tvafe clk disable*/
/*read write cvd acd reg will crash when clk disabled*/
-extern bool tvafe_clk_status;
+extern bool tvafe_clk_onoff;
extern unsigned int vbi_mem_start;
#endif /* TVIN_VBI_H_ */