From 99e772e98c0c01d0b835b282d819a1f01221ebd2 Mon Sep 17 00:00:00 2001 From: Nian Jing Date: Mon, 1 Apr 2019 18:38:41 +0800 Subject: [PATCH] vbi: fix vbi teletext no vcnt [1/1] PD#TV-3444 Problem: vbi teletext no vcnt vbi dump failed adc dump failed Solution: set 0x126[26]=1 fix dump issue fix adcdump issue Verify: test on x301 Change-Id: I7111a86f0259d2e57f06f885a1c8058d9578dc88 Signed-off-by: Nian Jing --- drivers/amlogic/media/vin/tvin/tvafe/tvafe.h | 2 +- .../amlogic/media/vin/tvin/tvafe/tvafe_cvd.c | 10 +---- .../amlogic/media/vin/tvin/tvafe/tvafe_cvd.h | 2 +- .../media/vin/tvin/tvafe/tvafe_debug.c | 39 +++++++++++++++---- .../amlogic/media/vin/tvin/tvafe/tvafe_vbi.c | 26 +++++++------ 5 files changed, 50 insertions(+), 29 deletions(-) diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h b/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h index 6dd89eef7260..c1b08ca3f650 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h @@ -32,7 +32,7 @@ /* ************************************************* */ /* *** macro definitions ********************************************* */ /* *********************************************************** */ -#define TVAFE_VER "Ref.2019/03/29" +#define TVAFE_VER "Ref.2019/04/24" /* used to set the flag of tvafe_dev_s */ #define TVAFE_FLAG_DEV_OPENED 0x00000010 diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c index e3fdd5e50efd..f3f284880427 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c @@ -321,6 +321,8 @@ static void tvafe_cvd2_memory_init(struct tvafe_cvd2_mem_s *mem, cvd_vbi_mem_set(vbi_start, vbi_size); /*open front lpf for av ring*/ W_APB_BIT(ACD_REG_26, 1, 8, 1); + /*for vbi vcnt*/ + W_APB_BIT(ACD_REG_26, 1, 26, 1); #endif } @@ -2016,16 +2018,8 @@ inline bool tvafe_cvd2_no_sig(struct tvafe_cvd2_s *cvd2, struct tvafe_cvd2_mem_s *mem) { static bool ret; - static int time_flag; tvafe_cvd2_get_signal_status(cvd2); - - /*TVAFE register status need more time to be stable.*/ - /*for double time delay.*/ - time_flag++; - if (time_flag%2 != 0) - return ret; - /* get signal status from HW */ /* search video mode */ diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.h b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.h index 0a851375ea83..b6641539ccdf 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.h +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.h @@ -32,7 +32,7 @@ /* vbi start line: unit is hcount value */ #define VBI_START_CC 0x54 #define VBI_START_WSS 0x54 -#define VBI_START_TT 0x82 +#define VBI_START_TT 0x64 #define VBI_START_VPS 0x82 /* cvd2 function enable/disable defines*/ diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c index dd4745534441..98a1694bdcf0 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c @@ -31,6 +31,7 @@ #include "tvafe_regs.h" #include "tvafe_debug.h" #include "tvafe.h" +#include "../vdin/vdin_ctl.h" bool disableapi; bool force_stable; @@ -383,6 +384,9 @@ static ssize_t tvafe_dumpmem_store(struct device *dev, struct tvafe_dev_s *devp; char delim1[3] = " "; char delim2[2] = "\n"; + unsigned int highmem_flag = 0; + unsigned long highaddr; + int i; strcat(delim1, delim2); if (!buff) @@ -415,15 +419,34 @@ static ssize_t tvafe_dumpmem_store(struct device *dev, kfree(buf_orig); return len; } - if (devp->cma_config_flag == 1) - buf = codec_mm_phys_to_virt(devp->mem.start); - else + highmem_flag = + PageHighMem(phys_to_page(devp->mem.start)); + pr_info("highmem_flag:%d\n", highmem_flag); + if (devp->cma_config_flag == 1 && + highmem_flag != 0) { + /*tvafe dts config 5M memory*/ + for (i = 0; + i < devp->cma_mem_size / SZ_1M; + i++) { + highaddr = devp->mem.start + i * SZ_1M; + buf = vdin_vmap(highaddr, SZ_1M); + if (!buf) { + pr_info("vdin_vmap error\n"); + return len; + } + pr_info("buf:0x%p\n", buf); + /*vdin_dma_flush(devp, buf, SZ_1M, DMA_FROM_DEVICE);*/ + vfs_write(filp, buf, SZ_1M, &pos); + vdin_unmap_phyaddr(buf); + } + } else { buf = phys_to_virt(devp->mem.start); - vfs_write(filp, buf, devp->mem.size, &pos); - tvafe_pr_info("write buffer %2d of %s.\n", - devp->mem.size, parm[1]); - tvafe_pr_info("devp->mem.start %x .\n", - devp->mem.start); + vfs_write(filp, buf, devp->mem.size, &pos); + tvafe_pr_info("write buffer %2d of %s.\n", + devp->mem.size, parm[1]); + tvafe_pr_info("devp->mem.start %x .\n", + devp->mem.start); + } vfs_fsync(filp, 0); filp_close(filp, NULL); set_fs(old_fs); diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_vbi.c b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_vbi.c index cd9d01e6c8ac..c1b7f73374bf 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_vbi.c +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_vbi.c @@ -133,7 +133,7 @@ static void vbi_data_type_set(struct vbi_dev_s *devp) W_VBI_APB_REG(CVD2_VBI_DATA_TYPE_LINE23, vbi_data_type); W_VBI_APB_REG(CVD2_VBI_DATA_TYPE_LINE24, vbi_data_type); W_VBI_APB_REG(CVD2_VBI_DATA_TYPE_LINE25, vbi_data_type); - W_VBI_APB_REG(CVD2_VBI_DATA_TYPE_LINE26, vbi_data_type); + /*W_VBI_APB_REG(CVD2_VBI_DATA_TYPE_LINE26, vbi_data_type);*/ } static void vbi_dto_set(struct vbi_dev_s *devp) @@ -380,10 +380,12 @@ static irqreturn_t vbi_isr(int irq, void *dev_id) spin_unlock_irqrestore(&devp->vbi_isr_lock, flags); return IRQ_HANDLED; } + if (devp->vbi_start == false) { spin_unlock_irqrestore(&devp->vbi_isr_lock, flags); return IRQ_HANDLED; } + if (devp->tasklet_enable) tasklet_schedule(&devp->tsklt_slicer); spin_unlock_irqrestore(&devp->vbi_isr_lock, flags); @@ -640,7 +642,8 @@ static void vbi_slicer_task(unsigned long arg) ret = init_cc_data_sync(devp); if (!ret) return; - + if (vbi_dbg_en & 2) + tvafe_pr_info("pac_addr:%p\n", devp->pac_addr); if (devp->pac_addr > devp->pac_addr_end) devp->pac_addr = devp->pac_addr_start; @@ -1305,7 +1308,6 @@ static void vbi_dump_mem(char *path, struct vbi_dev_s *devp) { struct file *filp = NULL; loff_t pos = 0; - void *buf = NULL; mm_segment_t old_fs = get_fs(); set_fs(KERNEL_DS); @@ -1315,15 +1317,10 @@ static void vbi_dump_mem(char *path, struct vbi_dev_s *devp) tvafe_pr_info("create %s error.\n", path); return; } - buf = phys_to_virt(devp->mem_start); - if (buf == NULL) { - tvafe_pr_info("buf is null!!!.\n"); - return; - } - vfs_write(filp, buf, devp->mem_size, &pos); + vfs_write(filp, devp->pac_addr_start, devp->mem_size, &pos); tvafe_pr_info("write buffer addr:0x%p size: %2u to %s.\n", - buf, devp->mem_size, path); + devp->pac_addr_start, devp->mem_size, path); vfs_fsync(filp, 0); filp_close(filp, NULL); set_fs(old_fs); @@ -1443,6 +1440,10 @@ static ssize_t vbi_store(struct device *dev, vbi_buffer->data_wmode = val; tvafe_pr_info("data_wmode:%d\n", vbi_buffer->data_wmode); } else if (!strncmp(parm[0], "start", strlen("start"))) { + W_APB_REG(ACD_REG_22, 0x07080000); + /* manuel reset vbi */ + W_APB_REG(ACD_REG_22, 0x87080000); + W_APB_REG(ACD_REG_22, 0x04080000); vbi_hw_init(devp); vbi_slicer_start(devp); /* enable data capture function */ @@ -1451,10 +1452,11 @@ static ssize_t vbi_store(struct device *dev, devp->vs_delay = VBI_VS_DELAY; tvafe_pr_info("start done!!!\n"); } else if (!strncmp(parm[0], "stop", strlen("stop"))) { - vbi_slicer_stop(vbi_slicer); /* disable data capture function */ devp->tasklet_enable = false; devp->vbi_start = false; + init_cc_data_flag = 0; + vbi_slicer_stop(vbi_slicer); /* manuel reset vbi */ /* vbi reset release, vbi agent enable*/ W_VBI_APB_REG(ACD_REG_22, 0x06080000); @@ -1475,6 +1477,7 @@ static ssize_t vbi_store(struct device *dev, tvafe_pr_info(" set slicer type to %d\n", vbi_slicer->type); } else if (!strncmp(parm[0], "open", strlen("open"))) { + tasklet_enable(&devp->tsklt_slicer); vbi_ringbuffer_init(vbi_buffer, NULL, VBI_DEFAULT_BUFFER_PACKAGE_NUM); devp->slicer->type = VBI_TYPE_NULL; @@ -1490,6 +1493,7 @@ static ssize_t vbi_store(struct device *dev, tvafe_pr_err("request_irq fail\n"); tvafe_pr_info(" open ok.\n"); } else if (!strncmp(parm[0], "release", strlen("release"))) { + tasklet_disable(&devp->tsklt_slicer); ret = vbi_slicer_free(devp, vbi_slicer); devp->tasklet_enable = false; devp->vbi_start = false; /*disable data capture function*/