tvin: vdin: tl1 improve vdin function [1/1]

PD#172587

Problem:
1.in the afbce mode,
  screen flicker when serial port print too many debugging information
2.vdin afbce 4K crash
3.viu loop back error
4.need afbce lossy mode

Solution:
1.vdin use rdma mode
2.change vdin afbce buff size
3.change VDIN_ASFIFO_CTRL3 register
4.add lossy mode

Verify:
x301

Change-Id: Id66c0d7df22a9aeaca15d645f9a2ce0ecf47be3f
Signed-off-by: Xuhua Zhang <xuhua.zhang@amlogic.com>
This commit is contained in:
Xuhua Zhang
2018-11-19 18:37:09 +08:00
committed by Bo Yang
parent 8850ab80a0
commit 4c7bb63845
6 changed files with 64 additions and 28 deletions

View File

@@ -487,9 +487,13 @@
*/
tv_bit_mode = <0x215>;
/* afbce_bit_mode: (amlogic frame buff compression encoder)
* 0: normal mode, not use afbce
* 1: use afbce non-mmu mode
* 2: use afbce mmu mode
* bit 0~3:
* 0 -- normal mode, not use afbce
* 1 -- use afbce non-mmu mode
* 2 -- use afbce mmu mode
* bit 4:
* 0 -- afbce compression-lossy disable
* 1 -- afbce compression-lossy enable
*/
afbce_bit_mode = <0>;
};

View File

@@ -491,9 +491,13 @@
*/
tv_bit_mode = <0x215>;
/* afbce_bit_mode: (amlogic frame buff compression encoder)
* 0: normal mode, not use afbce
* 1: use afbce non-mmu mode
* 2: use afbce mmu mode
* bit 0~3:
* 0 -- normal mode, not use afbce
* 1 -- use afbce non-mmu mode
* 2 -- use afbce mmu mode
* bit 4:
* 0 -- afbce compression-lossy disable
* 1 -- afbce compression-lossy enable
*/
afbce_bit_mode = <0>;
};

View File

@@ -73,7 +73,7 @@ unsigned int vdin_afbce_cma_alloc(struct vdin_dev_s *devp)
unsigned int max_buffer_num = min_buf_num;
unsigned int i;
/*afbce head need 1036800 byte at most*/
unsigned int afbce_head_size_byte = PAGE_SIZE * 300;/*1.2M*/
unsigned int afbce_head_size_byte = PAGE_SIZE * 576;
/*afbce map_table need 218700 byte at most*/
unsigned int afbce_table_size_byte = PAGE_SIZE * 60;/*0.3M*/
unsigned int afbce_mem_used;
@@ -475,6 +475,11 @@ void vdin_afbce_config(struct vdin_dev_s *devp)
W_VCBUS_BIT(AFBCE_QUANT_ENABLE, (lossy_luma_en & 0x1), 0, 1);//loosy
W_VCBUS_BIT(AFBCE_QUANT_ENABLE, (lossy_chrm_en & 0x1), 4, 1);//loosy
if (devp->afbce_lossy_en == 1) {
afbce_wr(AFBCE_QUANT_ENABLE, 0xc11);
pr_info("afbce use lossy compression mode\n");
}
afbce_wr(AFBCE_SIZE_IN,
((devp->h_active & 0x1fff) << 16) | // hsize_in of afbc input
((devp->v_active & 0x1fff) << 0) // vsize_in of afbc input
@@ -573,15 +578,13 @@ void vdin_afbce_set_next_frame(struct vdin_dev_s *devp,
vfe->vf.compHeadAddr = devp->afbce_info->fm_head_paddr[i];
vfe->vf.compBodyAddr = devp->afbce_info->fm_body_paddr[i];
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
if (rdma_enable) {
rdma_write_reg(devp->rdma_handle, AFBCE_HEAD_BADDR,
devp->afbce_info->fm_head_paddr[i]);
rdma_write_reg_bits(devp->rdma_handle, AFBCE_MMU_RMIF_CTRL4,
devp->afbce_info->fm_table_paddr[i], 0, 32);
rdma_write_reg_bits(devp->rdma_handle, AFBCE_ENABLE, 1, 0, 1);
//W_VCBUS_BIT(AFBCE_ENABLE, 1, 0, 1); //enable pulse mode
} else
#endif
{

View File

@@ -464,6 +464,8 @@ void vdin_get_format_convert(struct vdin_dev_s *devp)
format_convert = VDIN_FORMAT_CONVERT_YUV_NV21;
else if (devp->prop.dest_cfmt == TVIN_NV12)
format_convert = VDIN_FORMAT_CONVERT_YUV_NV12;
else if (devp->prop.dest_cfmt == TVIN_YUV444)
format_convert = VDIN_FORMAT_CONVERT_YUV_YUV444;
else
format_convert = VDIN_FORMAT_CONVERT_YUV_YUV422;
break;
@@ -745,18 +747,34 @@ void vdin_set_top(unsigned int offset,
if (port != TVIN_PORT_VIU1)
wr_bits(offset, VDIN_ASFIFO_CTRL3, 0xe4,
VDI6_ASFIFO_CTRL_BIT, VDI6_ASFIFO_CTRL_WID);
else
wr_bits(offset, VDIN_ASFIFO_CTRL3, 0xf4,
VDI6_ASFIFO_CTRL_BIT, VDI6_ASFIFO_CTRL_WID);
else {
if (/*is_meson_gxlx2_cpu() || */is_meson_g12b_cpu()
|| is_meson_tl1_cpu())
wr_bits(offset, VDIN_ASFIFO_CTRL3, 0xd4,
VDI6_ASFIFO_CTRL_BIT,
VDI6_ASFIFO_CTRL_WID);
else
wr_bits(offset, VDIN_ASFIFO_CTRL3, 0xf4,
VDI6_ASFIFO_CTRL_BIT,
VDI6_ASFIFO_CTRL_WID);
}
break;
case 0xc0: /* viu2 */
vdin_mux = VDIN_MUX_VIU_2;
if (port != TVIN_PORT_VIU2)
wr_bits(offset, VDIN_ASFIFO_CTRL3, 0xe4,
VDI8_ASFIFO_CTRL_BIT, VDI8_ASFIFO_CTRL_WID);
else
wr_bits(offset, VDIN_ASFIFO_CTRL3, 0xf4,
VDI8_ASFIFO_CTRL_BIT, VDI8_ASFIFO_CTRL_WID);
else {
if (/*is_meson_gxlx2_cpu() || */is_meson_g12b_cpu()
|| is_meson_tl1_cpu())
wr_bits(offset, VDIN_ASFIFO_CTRL3, 0xd4,
VDI6_ASFIFO_CTRL_BIT,
VDI6_ASFIFO_CTRL_WID);
else
wr_bits(offset, VDIN_ASFIFO_CTRL3, 0xf4,
VDI6_ASFIFO_CTRL_BIT,
VDI6_ASFIFO_CTRL_WID);
}
break;
case 0x100:/* mipi in mybe need modify base on truth */
vdin_mux = VDIN_MUX_MIPI;
@@ -1934,7 +1952,7 @@ void vdin_set_wr_ctrl_vsync(struct vdin_dev_s *devp,
hconv_mode = 2;
swap_cbcr = 0;
}
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
if (rdma_enable) {
rdma_write_reg_bits(devp->rdma_handle,
VDIN_WR_CTRL+devp->addr_offset,
@@ -2028,7 +2046,7 @@ unsigned int vdin_get_total_v(unsigned int offset)
void vdin_set_canvas_id(struct vdin_dev_s *devp, unsigned int rdma_enable,
unsigned int canvas_id)
{
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
if (rdma_enable) {
if (is_meson_g12a_cpu() || is_meson_g12b_cpu()) {
rdma_write_reg_bits(devp->rdma_handle,
@@ -2054,7 +2072,7 @@ unsigned int vdin_get_canvas_id(unsigned int offset)
void vdin_set_chma_canvas_id(struct vdin_dev_s *devp, unsigned int rdma_enable,
unsigned int canvas_id)
{
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
if (rdma_enable)
rdma_write_reg_bits(devp->rdma_handle,
VDIN_WR_CTRL2+devp->addr_offset,
@@ -4039,6 +4057,8 @@ u32 vdin_get_curr_field_type(struct vdin_dev_s *devp)
if (devp->afbce_mode == 1) {
type |= VIDTYPE_COMPRESS;
type |= VIDTYPE_SCATTER;
if (devp->afbce_lossy_en == 1)
type |= VIDTYPE_COMPRESS_LOSS;
}
return type;

View File

@@ -374,7 +374,7 @@ static void vdin_vf_init(struct vdin_dev_s *devp)
}
}
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
static void vdin_rdma_irq(void *arg)
{
struct vdin_dev_s *devp = arg;
@@ -561,7 +561,7 @@ void vdin_start_dec(struct vdin_dev_s *devp)
devp->frontend->dec_ops->start(devp->frontend,
devp->parm.info.fmt);
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
/*it is better put after all reg init*/
if (devp->rdma_enable && devp->rdma_handle > 0)
devp->flags |= VDIN_FLAG_RDMA_ENABLE;
@@ -668,7 +668,7 @@ void vdin_stop_dec(struct vdin_dev_s *devp)
switch_vpu_mem_pd_vmod(devp->addr_offset?VPU_VIU_VDIN1:VPU_VIU_VDIN0,
VPU_MEM_POWER_DOWN);
memset(&devp->prop, 0, sizeof(struct tvin_sig_property_s));
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
rdma_clear(devp->rdma_handle);
#endif
devp->flags &= (~VDIN_FLAG_RDMA_ENABLE);
@@ -1586,7 +1586,7 @@ irq_handled:
vdin_vf_disp_mode_skip(devp->vfp);
spin_unlock_irqrestore(&devp->isr_lock, flags);
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
if (devp->flags & VDIN_FLAG_RDMA_ENABLE)
rdma_config(devp->rdma_handle,
(devp->rdma_enable&1) ?
@@ -1763,7 +1763,7 @@ irqreturn_t vdin_v4l2_isr(int irq, void *dev_id)
irq_handled:
spin_unlock_irqrestore(&devp->isr_lock, flags);
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
if (devp->flags & VDIN_FLAG_RDMA_ENABLE)
rdma_config(devp->rdma_handle,
(devp->rdma_enable&1) ?
@@ -2412,6 +2412,7 @@ static int vdin_drv_probe(struct platform_device *pdev)
int ret = 0;
struct vdin_dev_s *vdevp;
struct resource *res;
unsigned int val;
unsigned int urgent_en = 0;
unsigned int bit_mode = VDIN_WR_COLOR_DEPTH_8BIT;
/* const void *name; */
@@ -2432,7 +2433,7 @@ static int vdin_drv_probe(struct platform_device *pdev)
}
}
vdin_devp[vdevp->index] = vdevp;
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
vdin_rdma_op.arg = vdin_devp;
vdevp->rdma_handle = rdma_register(&vdin_rdma_op,
NULL, RDMA_TABLE_SIZE);
@@ -2539,14 +2540,17 @@ static int vdin_drv_probe(struct platform_device *pdev)
/*set afbce mode*/
ret = of_property_read_u32(pdev->dev.of_node,
"afbce_bit_mode", &vdevp->afbce_mode);
"afbce_bit_mode", &val);
if (ret) {
vdevp->afbce_mode = 0;
pr_info("no afbce mode found, use normal mode\n");
} else {
vdevp->afbce_mode = val & 0xf;
vdevp->afbce_lossy_en = (val>>4)&0xf;
if ((is_meson_tl1_cpu()) && (vdevp->index == 0)) {
/* just use afbce at vdin0 */
pr_info("afbce mode = %d\n", vdevp->afbce_mode);
pr_info("afbce loosy en = %d\n", vdevp->afbce_lossy_en);
vdevp->afbce_info = devm_kzalloc(vdevp->dev,
sizeof(struct vdin_afbce_s), GFP_KERNEL);
if (!vdevp->afbce_info)
@@ -2714,7 +2718,7 @@ static int vdin_drv_remove(struct platform_device *pdev)
vdevp = platform_get_drvdata(pdev);
ret = cancel_delayed_work(&vdevp->vlock_dwork);
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
rdma_unregister(vdevp->rdma_handle);
#endif
mutex_destroy(&vdevp->fe_lock);

View File

@@ -36,7 +36,7 @@
#include <linux/amlogic/media/vfm/vframe_receiver.h>
#include <linux/amlogic/media/vfm/vframe_provider.h>
#include <linux/amlogic/media/frame_provider/tvin/tvin_v4l2.h>
#ifdef CONFIG_AML_RDMA
#ifdef CONFIG_AMLOGIC_MEDIA_RDMA
#include <linux/amlogic/media/rdma/rdma_mgr.h>
#endif
@@ -321,6 +321,7 @@ struct vdin_dev_s {
* 2: use afbce mmu mode: head set by code, body addr assigning by hw
*/
unsigned int afbce_mode;
unsigned int afbce_lossy_en;
unsigned int canvas_config_mode;
bool prehsc_en;
bool vshrk_en;