di: add more debug info into dumpstate_board
authorwenfeng.guo <wenfeng.guo@amlogic.com>
Fri, 20 Jul 2018 10:52:00 +0000 (18:52 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Mon, 23 Jul 2018 08:24:31 +0000 (01:24 -0700)
PD#170100: di: add more debug info into dumpstate_board

1. add new debugfs:
cat /sys/kernel/debug/di/state
cat /sys/kernel/debug/vdin0/state
2. Retain the original usage
echo state > /sys/class/vdin/vdin0/attr;
echo state > /sys/class/deinterlace/di0/debug;

Change-Id: I98054baa260ae5e9bf945d23b5becd2064c81a69
Signed-off-by: wenfeng.guo <wenfeng.guo@amlogic.com>
drivers/amlogic/media/deinterlace/deinterlace.c
drivers/amlogic/media/deinterlace/deinterlace.h
drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c
drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c
drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h
drivers/amlogic/media/vin/tvin/vdin/vdin_vf.c
drivers/amlogic/media/vin/tvin/vdin/vdin_vf.h

index 7798ae7..c501f90 100644 (file)
 #include "di_pps.h"
 #define CREATE_TRACE_POINTS
 #include "deinterlace_trace.h"
+
+/*2018-07-18 add debugfs*/
+#include <linux/seq_file.h>
+#include <linux/debugfs.h>
+/*2018-07-18 -----------*/
+
 #ifdef DET3D
 #include "detect3d.h"
 #endif
@@ -1168,7 +1174,98 @@ static bool is_in_queue(struct di_buf_s *di_buf, int queue_idx)
        return ret;
 }
 
+/*2018-07-18 add debugfs*/
+/*same as dump_di_pre_stru*/
+static int dump_di_pre_stru_seq(struct seq_file *seq, void *v)
+{
+       seq_puts(seq, "di_pre_stru:\n");
+
+       seq_printf(seq, "%-25s = 0x%p\n", "di_mem_buf_dup_p",
+                       di_pre_stru.di_mem_buf_dup_p);
+       seq_printf(seq, "%-25s = 0x%p\n", "di_chan2_buf_dup_p",
+               di_pre_stru.di_chan2_buf_dup_p);
+       seq_printf(seq, "%-25s = %d\n", "in_seq",
+               di_pre_stru.in_seq);
+       seq_printf(seq, "%-25s = %d\n", "recycle_seq",
+               di_pre_stru.recycle_seq);
+       seq_printf(seq, "%-25s = %d\n", "pre_ready_seq",
+               di_pre_stru.pre_ready_seq);
+       seq_printf(seq, "%-25s = %d\n", "pre_de_busy",
+               di_pre_stru.pre_de_busy);
+       seq_printf(seq, "%-25s = %d\n", "pre_de_busy_timer_count",
+               di_pre_stru.pre_de_busy_timer_count);
+       seq_printf(seq, "%-25s = %d\n", "pre_de_process_done",
+               di_pre_stru.pre_de_process_done);
+       seq_printf(seq, "%-25s = %d\n", "pre_de_process_flag",
+               di_pre_stru.pre_de_process_flag);
+       seq_printf(seq, "%-25s =%d\n", "pre_de_irq_timeout_count",
+               di_pre_stru.pre_de_irq_timeout_count);
+       seq_printf(seq, "%-25s = %d\n", "unreg_req_flag",
+               di_pre_stru.unreg_req_flag);
+       seq_printf(seq, "%-25s = %d\n", "unreg_req_flag_irq",
+               di_pre_stru.unreg_req_flag_irq);
+       seq_printf(seq, "%-25s = %d\n", "reg_req_flag",
+               di_pre_stru.reg_req_flag);
+       seq_printf(seq, "%-25s = %d\n", "reg_req_flag_irq",
+               di_pre_stru.reg_req_flag_irq);
+       seq_printf(seq, "%-25s = %d\n", "cur_width",
+               di_pre_stru.cur_width);
+       seq_printf(seq, "%-25s = %d\n", "cur_height",
+               di_pre_stru.cur_height);
+       seq_printf(seq, "%-25s = 0x%x\n", "cur_inp_type",
+               di_pre_stru.cur_inp_type);
+       seq_printf(seq, "%-25s = %d\n", "cur_source_type",
+               di_pre_stru.cur_source_type);
+       seq_printf(seq, "%-25s = %d\n", "cur_prog_flag",
+               di_pre_stru.cur_prog_flag);
+       seq_printf(seq, "%-25s = %d\n", "source_change_flag",
+               di_pre_stru.source_change_flag);
+       seq_printf(seq, "%-25s = %s\n", "bypass_flag",
+               di_pre_stru.bypass_flag?"true":"false");
+       seq_printf(seq, "%-25s = %d\n", "prog_proc_type",
+               di_pre_stru.prog_proc_type);
+       seq_printf(seq, "%-25s = %d\n", "madi_enable",
+               di_pre_stru.madi_enable);
+       seq_printf(seq, "%-25s = %d\n", "mcdi_enable",
+               di_pre_stru.mcdi_enable);
+#ifdef DET3D
+       seq_printf(seq, "%-25s = %d\n", "vframe_interleave_flag",
+               di_pre_stru.vframe_interleave_flag);
+#endif
+       seq_printf(seq, "%-25s = %d\n", "left_right",
+               di_pre_stru.left_right);
+       seq_printf(seq, "%-25s = %s\n", "force_interlace",
+               di_pre_stru.force_interlace ? "true" : "false");
+       seq_printf(seq, "%-25s = %d\n", "vdin2nr",
+               di_pre_stru.vdin2nr);
+       seq_printf(seq, "%-25s = %s\n", "bypass_pre",
+               di_pre_stru.bypass_pre ? "true" : "false");
+       seq_printf(seq, "%-25s = %s\n", "invert_flag",
+               di_pre_stru.invert_flag ? "true" : "false");
+
+       return 0;
+}
+
+/*2018-07-18 add debugfs*/
+/*same as dump_di_post_stru*/
+static int dump_di_post_stru_seq(struct seq_file *seq, void *v)
+{
+       seq_puts(seq, "di_post_stru:\n");
+       seq_printf(seq, "run_early_proc_fun_flag        = %d\n",
+               di_post_stru.run_early_proc_fun_flag);
+       seq_printf(seq, "cur_disp_index = %d\n",
+               di_post_stru.cur_disp_index);
+       seq_printf(seq, "post_de_busy                   = %d\n",
+               di_post_stru.post_de_busy);
+       seq_printf(seq, "de_post_process_done   = %d\n",
+               di_post_stru.de_post_process_done);
+       seq_printf(seq, "cur_post_buf                   = 0x%p\n",
+               di_post_stru.cur_post_buf);
+       seq_printf(seq, "post_peek_underflow    = %u\n",
+               di_post_stru.post_peek_underflow);
 
+       return 0;
+}
 
 static ssize_t
 store_dump_mem(struct device *dev, struct device_attribute *attr,
@@ -2259,6 +2356,47 @@ static void log_buffer_state(unsigned char *tag)
        }
 }
 
+/*2018-07-18 add debugfs*/
+static void print_di_buf_seq(struct di_buf_s *di_buf, int format,
+                                       struct seq_file *seq)
+{
+       if (!di_buf)
+               return;
+       if (format == 1) {
+               seq_printf(seq,
+               "\t+index %d, 0x%p, type %d, vframetype 0x%x\n",
+                       di_buf->index,
+                       di_buf,
+                       di_buf->type,
+                       di_buf->vframe->type);
+               seq_printf(seq, "\t+trans_fmt %u,bitdepath %d pages %p\n",
+                       di_buf->vframe->trans_fmt,
+                       di_buf->vframe->bitdepth,
+                       di_buf->pages);
+               if (di_buf->di_wr_linked_buf) {
+                       seq_printf(seq, "\tlinked  +index %d, 0x%p, type %d\n",
+                               di_buf->di_wr_linked_buf->index,
+                               di_buf->di_wr_linked_buf,
+                               di_buf->di_wr_linked_buf->type);
+               }
+       } else if (format == 2) {
+               seq_printf(seq, "index %d, 0x%p(vframe 0x%p), type %d pages %p\n",
+                       di_buf->index, di_buf,
+                       di_buf->vframe, di_buf->type, di_buf->pages);
+               seq_printf(seq, "vframetype 0x%x, trans_fmt %u,duration %d pts %d,bitdepth %d\n",
+                       di_buf->vframe->type,
+                       di_buf->vframe->trans_fmt,
+                       di_buf->vframe->duration,
+                       di_buf->vframe->pts,
+                       di_buf->vframe->bitdepth);
+               if (di_buf->di_wr_linked_buf) {
+                       seq_printf(seq, "linked index %d, 0x%p, type %d\n",
+                               di_buf->di_wr_linked_buf->index,
+                               di_buf->di_wr_linked_buf,
+                               di_buf->di_wr_linked_buf->type);
+               }
+       }
+}
 
 static void dump_state(void)
 {
@@ -2370,6 +2508,121 @@ static void dump_state(void)
        dump_state_flag = 0;
 }
 
+/*2018-07-18 add debugfs*/
+/*same as dump_state*/
+static int seq_file_di_state_show(struct seq_file *seq, void *v)
+{
+       int itmp, i;
+       struct di_buf_s *p = NULL, *keep_buf;;/* , *ptmp; */
+
+       dump_state_flag = 1;
+       seq_printf(seq, "version %s, init_flag %d, is_bypass %d\n",
+                       version_s, init_flag, is_bypass(NULL));
+       seq_printf(seq, "recovery_flag = %d, recovery_log_reason=%d, di_blocking=%d",
+               recovery_flag, recovery_log_reason, di_blocking);
+seq_printf(seq, "recovery_log_queue_idx=%d, recovery_log_di_buf=0x%p\n",
+               recovery_log_queue_idx, recovery_log_di_buf);
+       seq_printf(seq, "buffer_size=%d, mem_flag=%d, cma_flag=%d\n",
+               de_devp->buffer_size, atomic_read(&de_devp->mem_flag),
+               de_devp->flag_cma);
+       keep_buf = di_post_stru.keep_buf;
+       seq_printf(seq, "used_post_buf_index %d(0x%p),",
+               IS_ERR_OR_NULL(keep_buf) ?
+               -1 : keep_buf->index, keep_buf);
+       if (!IS_ERR_OR_NULL(keep_buf)) {
+               seq_puts(seq, "used_local_buf_index:\n");
+               for (i = 0; i < USED_LOCAL_BUF_MAX; i++) {
+                       p = keep_buf->di_buf_dup_p[i];
+                       seq_printf(seq, "%d(0x%p) ",
+                               IS_ERR_OR_NULL(p) ? -1 : p->index, p);
+               }
+       }
+       seq_printf(seq, "\nin_free_list (max %d):\n", MAX_IN_BUF_NUM);
+       queue_for_each_entry(p, ptmp, QUEUE_IN_FREE, list) {
+               seq_printf(seq, "index %2d, 0x%p, type %d\n",
+                       p->index, p, p->type);
+       }
+       seq_printf(seq, "local_free_list (max %d):\n", de_devp->buf_num_avail);
+       queue_for_each_entry(p, ptmp, QUEUE_LOCAL_FREE, list) {
+               seq_printf(seq, "index %2d, 0x%p, type %d\n",
+                       p->index, p, p->type);
+       }
+
+       seq_puts(seq, "post_doing_list:\n");
+       queue_for_each_entry(p, ptmp, QUEUE_POST_DOING, list) {
+               print_di_buf_seq(p, 2, seq);
+       }
+       seq_puts(seq, "pre_ready_list:\n");
+       queue_for_each_entry(p, ptmp, QUEUE_PRE_READY, list) {
+               print_di_buf_seq(p, 2, seq);
+       }
+       seq_printf(seq, "post_free_list (max %d):\n",
+               di_post_stru.di_post_num);
+       queue_for_each_entry(p, ptmp, QUEUE_POST_FREE, list) {
+               seq_printf(seq, "index %2d, 0x%p, type %d, vframetype 0x%x\n",
+                       p->index, p, p->type, p->vframe->type);
+       }
+       seq_puts(seq, "post_ready_list:\n");
+       queue_for_each_entry(p, ptmp, QUEUE_POST_READY, list) {
+               print_di_buf_seq(p, 2, seq);
+               print_di_buf_seq(p->di_buf[0], 1, seq);
+               print_di_buf_seq(p->di_buf[1], 1, seq);
+       }
+       seq_puts(seq, "display_list:\n");
+       queue_for_each_entry(p, ptmp, QUEUE_DISPLAY, list) {
+               print_di_buf_seq(p, 2, seq);
+               print_di_buf_seq(p->di_buf[0], 1, seq);
+               print_di_buf_seq(p->di_buf[1], 1, seq);
+       }
+       seq_puts(seq, "recycle_list:\n");
+       queue_for_each_entry(p, ptmp, QUEUE_RECYCLE, list) {
+               seq_printf(seq,
+                       "index %d, 0x%p, type %d, vframetype 0x%x pre_ref_count %d post_ref_count %d\n",
+                       p->index, p, p->type,
+                       p->vframe->type,
+                       p->pre_ref_count,
+                       p->post_ref_count);
+               if (p->di_wr_linked_buf) {
+                       seq_printf(seq,
+                               "linked index %2d, 0x%p, type %d pre_ref_count %d post_ref_count %d\n",
+                               p->di_wr_linked_buf->index,
+                               p->di_wr_linked_buf,
+                               p->di_wr_linked_buf->type,
+                               p->di_wr_linked_buf->pre_ref_count,
+                               p->di_wr_linked_buf->post_ref_count);
+               }
+       }
+       if (di_pre_stru.di_inp_buf) {
+               seq_printf(seq, "di_inp_buf:index %d, 0x%p, type %d\n",
+                       di_pre_stru.di_inp_buf->index,
+                       di_pre_stru.di_inp_buf,
+                       di_pre_stru.di_inp_buf->type);
+       } else {
+               seq_puts(seq, "di_inp_buf: NULL\n");
+       }
+       if (di_pre_stru.di_wr_buf) {
+               seq_printf(seq, "di_wr_buf:index %d, 0x%p, type %d\n",
+                       di_pre_stru.di_wr_buf->index,
+                       di_pre_stru.di_wr_buf,
+                       di_pre_stru.di_wr_buf->type);
+       } else {
+               seq_puts(seq, "di_wr_buf: NULL\n");
+       }
+       dump_di_pre_stru_seq(seq, v);/*dump_di_pre_stru();*/
+       dump_di_post_stru_seq(seq, v);/*dump_di_post_stru();*/
+       seq_puts(seq, "vframe_in[]:");
+
+       for (i = 0; i < MAX_IN_BUF_NUM; i++)
+               seq_printf(seq, "0x%p\n", vframe_in[i]);
+
+       seq_puts(seq, "\n");
+       seq_printf(seq, "vf_peek()=>0x%p, video_peek_cnt = %d\n",
+       vf_peek(VFM_NAME), video_peek_cnt);
+       seq_printf(seq, "reg_unreg_timerout = %lu\n", reg_unreg_timeout_cnt);
+       dump_state_flag = 0;
+       return 0;
+}
+
 static unsigned char check_di_buf(struct di_buf_s *di_buf, int reason)
 {
        int error = 0;
@@ -7255,6 +7508,65 @@ static void di_get_vpu_clkb(struct device *dev, struct di_dev_s *pdev)
        #endif
 }
 
+/*2018-07-18 add debugfs*/
+#define DEFINE_SHOW_DI(__name) \
+static int __name ## _open(struct inode *inode, struct file *file)     \
+{ \
+       return single_open(file, __name ## _show, inode->i_private);    \
+} \
+                                                                       \
+static const struct file_operations __name ## _fops = {                        \
+       .owner = THIS_MODULE,           \
+       .open = __name ## _open,        \
+       .read = seq_read,               \
+       .llseek = seq_lseek,            \
+       .release = single_release,      \
+}
+
+DEFINE_SHOW_DI(seq_file_di_state);
+
+struct di_debugfs_files_t {
+       const char *name;
+       const umode_t mode;
+       const struct file_operations *fops;
+};
+
+static struct di_debugfs_files_t di_debugfs_files[] = {
+       {"state", S_IFREG | 0644, &seq_file_di_state_fops},
+
+};
+
+
+static void di_debugfs_init(void)
+{
+       int i;
+       struct dentry *ent;
+
+       if (de_devp->dbg_root)
+               return;
+
+       de_devp->dbg_root = debugfs_create_dir("di", NULL);
+       if (!de_devp->dbg_root) {
+               pr_err("can't create debugfs dir di\n");
+               return;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(di_debugfs_files); i++) {
+               ent = debugfs_create_file(di_debugfs_files[i].name,
+                       di_debugfs_files[i].mode,
+                       de_devp->dbg_root, NULL,
+                       di_debugfs_files[i].fops);
+               if (!ent)
+                       pr_err("debugfs create failed\n");
+       }
+
+}
+static void di_debugfs_exit(void)
+{
+       if (de_devp && de_devp->dbg_root)
+               debugfs_remove(de_devp->dbg_root);
+}
+/*-----------------------*/
 
 static int di_probe(struct platform_device *pdev)
 {
@@ -7420,6 +7732,7 @@ static int di_probe(struct platform_device *pdev)
        di_devp->task = kthread_run(di_task_handle, di_devp, "kthread_di");
        if (IS_ERR(di_devp->task))
                pr_err("%s create kthread error.\n", __func__);
+       di_debugfs_init();      /*2018-07-18 add debugfs*/
 fail_kmalloc_dev:
        return ret;
 }
@@ -7620,6 +7933,7 @@ fail_alloc_cdev_region:
 static void __exit di_module_exit(void)
 {
        class_destroy(di_clsp);
+       di_debugfs_exit();
        unregister_chrdev_region(di_devno, DI_COUNT);
        platform_driver_unregister(&di_driver);
 }
index 15878b2..950bed3 100644 (file)
@@ -227,6 +227,7 @@ struct di_dev_s {
        unsigned int       flag_cma;
        struct page                     *total_pages;
        atomic_t                        mem_flag;
+       struct dentry *dbg_root;        /*dbg_fs*/
 };
 
 struct di_pre_stru_s {
index d0d5a88..14e9bc3 100644 (file)
@@ -31,6 +31,9 @@
 #include "vdin_drv.h"
 #include "vdin_ctl.h"
 #include "vdin_regs.h"
+/*2018-07-18 add debugfs*/
+#include <linux/seq_file.h>
+#include <linux/debugfs.h>
 
 static void vdin_get_vdin_yuv_rgb_mat0(unsigned int offset,
                unsigned int *rgb_yuv0,
@@ -552,6 +555,138 @@ static void vdin_dump_state(struct vdin_dev_s *devp)
        pr_info("Vdin driver version :  %s\n", VDIN_VER);
 }
 
+/*2018-07-18 add debugfs*/
+struct vdin_dev_s *vdin_get_dev(unsigned int index);
+
+/*same as vdin_dump_state*/
+static int seq_file_vdin_state_show(struct seq_file *seq, void *v)
+{
+       struct vdin_dev_s *devp;
+       unsigned int i;
+       struct vframe_s *vf;
+       struct tvin_parm_s *curparm;
+       struct vf_pool *vfp;
+
+       devp = vdin_get_dev(0);
+       vf = &devp->curr_wr_vfe->vf;
+       curparm = &devp->parm;
+       vfp = devp->vfp;
+
+       seq_printf(seq, "h_active = %d, v_active = %d\n",
+               devp->h_active, devp->v_active);
+       seq_printf(seq, "canvas_w = %d, canvas_h = %d\n",
+               devp->canvas_w, devp->canvas_h);
+       seq_printf(seq, "canvas_alin_w = %d, canvas_active_w = %d\n",
+               devp->canvas_alin_w, devp->canvas_active_w);
+       if ((devp->cma_config_en != 1) || !(devp->cma_config_flag & 0x1))
+               seq_printf(seq, "mem_start = %ld, mem_size = %d\n",
+                       devp->mem_start, devp->mem_size);
+       else
+               for (i = 0; i < devp->canvas_max_num; i++)
+                       seq_printf(seq, "buf[%d]mem_start = %ld, mem_size = %d\n",
+                       i, devp->vfmem_start[i], devp->vfmem_size);
+       seq_printf(seq, "signal format  = %s(0x%x)\n",
+               tvin_sig_fmt_str(devp->parm.info.fmt),
+               devp->parm.info.fmt);
+       seq_printf(seq, "trans_fmt      = %s(%d)\n",
+               tvin_trans_fmt_str(devp->prop.trans_fmt),
+               devp->prop.trans_fmt);
+       seq_printf(seq, "color_format   = %s(%d)\n",
+               tvin_color_fmt_str(devp->prop.color_format),
+               devp->prop.color_format);
+       seq_printf(seq, "format_convert = %s(%d)\n",
+               vdin_fmt_convert_str(devp->format_convert),
+               devp->format_convert);
+       seq_printf(seq, "aspect_ratio   = %s(%d)\ndecimation_ratio/dvi  = %u / %u\n",
+               tvin_aspect_ratio_str(devp->prop.aspect_ratio),
+               devp->prop.aspect_ratio,
+               devp->prop.decimation_ratio, devp->prop.dvi_info);
+       seq_printf(seq, "[pre->cur]:hs(%d->%d),he(%d->%d),vs(%d->%d),ve(%d->%d)\n",
+               devp->prop.pre_hs, devp->prop.hs,
+               devp->prop.pre_he, devp->prop.he,
+               devp->prop.pre_vs, devp->prop.vs,
+               devp->prop.pre_ve, devp->prop.ve);
+       seq_printf(seq, "frontend_fps:%d\n", devp->prop.fps);
+       seq_printf(seq, "frontend_colordepth:%d\n", devp->prop.colordepth);
+       seq_printf(seq, "source_bitdepth:%d\n", devp->source_bitdepth);
+       seq_printf(seq, "color_depth_config:%d\n", devp->color_depth_config);
+       seq_printf(seq, "color_depth_mode:%d\n", devp->color_depth_mode);
+       seq_printf(seq, "color_depth_support:0x%x\n",
+               devp->color_depth_support);
+       seq_printf(seq, "cma_flag:0x%x\n", devp->cma_config_flag);
+       seq_printf(seq, "auto_cutwindow_en:%d\n", devp->auto_cutwindow_en);
+       seq_printf(seq, "auto_ratio_en:%d\n", devp->auto_ratio_en);
+       seq_printf(seq, "cma_mem_alloc:%d\n", devp->cma_mem_alloc);
+       seq_printf(seq, "cma_mem_size:0x%x\n", devp->cma_mem_size);
+       seq_printf(seq, "cma_mem_mode:%d\n", devp->cma_mem_mode);
+       seq_printf(seq, "force_yuv444_malloc:%d\n", devp->force_yuv444_malloc);
+       vdin_dump_vf_state_seq(devp->vfp, seq);
+       if (vf) {
+               seq_printf(seq, "current vframe index(%u):\n", vf->index);
+               seq_printf(seq, "\t buf(w%u, h%u),type(0x%x),flag(0x%x), duration(%d),\n",
+               vf->width, vf->height, vf->type, vf->flag, vf->duration);
+               seq_printf(seq, "\t ratio_control(0x%x).\n", vf->ratio_control);
+               seq_printf(seq, "\t trans fmt %u, left_start_x %u,\n",
+                       vf->trans_fmt, vf->left_eye.start_x);
+               seq_printf(seq, "\t right_start_x %u, width_x %u\n",
+                       vf->right_eye.start_x, vf->left_eye.width);
+               seq_printf(seq, "\t left_start_y %u, right_start_y %u, height_y %u\n",
+                       vf->left_eye.start_y, vf->right_eye.start_y,
+                       vf->left_eye.height);
+       }
+       if (vfp) {
+               seq_printf(seq, "skip_vf_num:%d\n", vfp->skip_vf_num);
+               seq_puts(seq, "**************disp_mode**************\n");
+               for (i = 0; i < VFRAME_DISP_MAX_NUM; i++)
+                       seq_printf(seq, "[%d]:%-5d\n", i, vfp->disp_mode[i]);
+               seq_puts(seq, "\n**************disp_index**************\n");
+               for (i = 0; i < VFRAME_DISP_MAX_NUM; i++)
+                       seq_printf(seq, "[%d]:%-5d\n", i, vfp->disp_index[i]);
+       }
+       seq_puts(seq, "\n current parameters:\n");
+       seq_printf(seq, "\t frontend of vdin index :  %d, 3d flag : 0x%x\n",
+               curparm->index,  curparm->flag);
+       seq_printf(seq, "\t reserved 0x%x, devp->flags:0x%x\n",
+               curparm->reserved, devp->flags);
+       seq_printf(seq, "max buffer num %u, msr_clk_val:%d.\n",
+               devp->canvas_max_num, devp->msr_clk_val);
+       seq_printf(seq, "canvas buffer size %u, rdma_enable: %d.\n",
+               devp->canvas_max_size, devp->rdma_enable);
+       seq_printf(seq, "range(%d),csc_cfg:0x%x,urgent_en:%d\n",
+               devp->prop.color_fmt_range,
+               devp->csc_cfg, devp->urgent_en);
+       seq_printf(seq, "black_bar_enable: %d, hist_bar_enable: %d, use_frame_rate: %d\n ",
+               devp->black_bar_enable,
+               devp->hist_bar_enable, devp->use_frame_rate);
+       seq_printf(seq, "vdin_irq_flag: %d, vdin_rest_flag: %d, irq_cnt: %d, rdma_irq_cnt: %d\n",
+               devp->vdin_irq_flag, devp->vdin_reset_flag,
+               devp->irq_cnt, devp->rdma_irq_cnt);
+       seq_printf(seq, "rdma_enable :  %d\n", devp->rdma_enable);
+       seq_printf(seq, "dolby_input :  %d\n", devp->dv.dolby_input);
+       if ((devp->cma_config_en != 1) || !(devp->cma_config_flag & 0x100))
+               seq_printf(seq, "dolby_mem_start = %ld, dolby_mem_size = %d\n",
+                       (devp->mem_start +
+                       devp->mem_size - devp->canvas_max_num*dolby_size_byte),
+                       dolby_size_byte);
+       else
+               for (i = 0; i < devp->canvas_max_num; i++)
+                       seq_printf(seq, "dolby_mem_start[%d] = %ld, dolby_mem_size = %d\n",
+                               i, (devp->vfmem_start[i] + devp->vfmem_size -
+                               dolby_size_byte), dolby_size_byte);
+       for (i = 0; i < devp->canvas_max_num; i++) {
+               seq_printf(seq, "dv_mem(%d):0x%x\n",
+                       devp->vfp->dv_buf_size[i],
+                       devp->vfp->dv_buf_mem[i]);
+       }
+       seq_printf(seq, "dv_flag:%d;dv_config:%d,dolby_vision:%d\n",
+               devp->dv.dv_flag, devp->dv.dv_config, devp->prop.dolby_vision);
+       seq_printf(seq, "size of struct vdin_dev_s: %d\n",
+               devp->vdin_dev_ssize);
+       seq_printf(seq, "Vdin driver version :  %s\n", VDIN_VER);
+
+       return 0;
+}
+
 static void vdin_dump_histgram(struct vdin_dev_s *devp)
 {
        uint i;
@@ -2007,4 +2142,82 @@ void vdin_remove_class_files(struct class *vdin_clsp)
        class_remove_file(vdin_clsp, &class_attr_memp);
 }
 
+
 #endif
+
+/*2018-07-18 add debugfs*/
+#define DEFINE_SHOW_VDIN(__name) \
+static int __name ## _open(struct inode *inode, struct file *file)     \
+{ \
+       return single_open(file, __name ## _show, inode->i_private);    \
+} \
+                                                                       \
+static const struct file_operations __name ## _fops = {                        \
+       .owner = THIS_MODULE,           \
+       .open = __name ## _open,        \
+       .read = seq_read,               \
+       .llseek = seq_lseek,            \
+       .release = single_release,      \
+}
+
+DEFINE_SHOW_VDIN(seq_file_vdin_state);
+
+struct vdin_debugfs_files_t {
+       const char *name;
+       const umode_t mode;
+       const struct file_operations *fops;
+};
+
+static struct vdin_debugfs_files_t vdin_debugfs_files[] = {
+       {"state", S_IFREG | 0644, &seq_file_vdin_state_fops},
+
+};
+
+
+void vdin_debugfs_init(struct vdin_dev_s *vdevp)
+{
+       int i;
+       struct dentry *ent;
+       unsigned int nub;
+
+       nub = vdevp->index;
+
+       if (nub > 0) {
+               pr_info("%s only support debug vdin0 %d\n", __func__, nub);
+               return;
+       }
+
+       if (vdevp->dbg_root)
+               return;
+
+       vdevp->dbg_root = debugfs_create_dir("vdin0", NULL);
+
+       if (!vdevp->dbg_root) {
+               pr_err("can't create debugfs dir di\n");
+               return;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(vdin_debugfs_files); i++) {
+               ent = debugfs_create_file(vdin_debugfs_files[i].name,
+                       vdin_debugfs_files[i].mode,
+                       vdevp->dbg_root, NULL,
+                       vdin_debugfs_files[i].fops);
+               if (!ent)
+                       pr_err("debugfs create failed\n");
+       }
+
+}
+void vdin_debugfs_exit(struct vdin_dev_s *vdevp)
+{
+       unsigned int nub;
+
+       nub = vdevp->index;
+       if (nub > 0) {
+               pr_info("%s only support debug vdin0 %d\n", __func__, nub);
+               return;
+       }
+
+       debugfs_remove(vdevp->dbg_root);
+}
+/*------------------------------------------*/
+
index e9840bd..ed5c768 100644 (file)
@@ -2321,6 +2321,15 @@ static void vdin_delete_device(int minor)
        dev_t devno = MKDEV(MAJOR(vdin_devno), minor);
        device_destroy(vdin_clsp, devno);
 }
+
+struct vdin_dev_s *vdin_get_dev(unsigned int index)
+{
+       if (index)
+               return vdin_devp[1];
+       else
+               return vdin_devp[0];
+}
+
 static int vdin_drv_probe(struct platform_device *pdev)
 {
        int ret = 0;
@@ -2569,6 +2578,7 @@ static int vdin_drv_probe(struct platform_device *pdev)
        vdevp->canvas_config_mode = canvas_config_mode;
        INIT_DELAYED_WORK(&vdevp->dv.dv_dwork, vdin_dv_dwork);
 
+       vdin_debugfs_init(vdevp);/*2018-07-18 add debugfs*/
        pr_info("%s: driver initialized ok\n", __func__);
        return 0;
 
@@ -2600,6 +2610,7 @@ static int vdin_drv_remove(struct platform_device *pdev)
 #endif
        mutex_destroy(&vdevp->fe_lock);
 
+       vdin_debugfs_exit(vdevp);/*2018-07-18 add debugfs*/
        vf_pool_free(vdevp->vfp);
        vdin_remove_device_files(vdevp->dev);
        vdin_delete_device(vdevp->index);
index a222940..35fe508 100644 (file)
@@ -303,6 +303,8 @@ struct vdin_dev_s {
        unsigned int vdin_reset_flag;
        unsigned int vdin_dev_ssize;
        wait_queue_head_t queue;
+
+       struct dentry *dbg_root;        /*dbg_fs*/
 };
 
 extern struct vframe_provider_s *vf_get_provider_by_name(
@@ -338,5 +340,9 @@ extern void vdin_vf_unreg(struct vdin_dev_s *devp);
 extern void vdin_pause_dec(struct vdin_dev_s *devp);
 extern void vdin_resume_dec(struct vdin_dev_s *devp);
 extern bool is_dolby_vision_enable(void);
+
+extern void vdin_debugfs_init(struct vdin_dev_s *vdevp);
+extern void vdin_debugfs_exit(struct vdin_dev_s *vdevp);
+
 #endif /* __TVIN_VDIN_DRV_H */
 
index 73ad19f..6204a83 100644 (file)
@@ -945,6 +945,63 @@ void vdin_dump_vf_state(struct vf_pool *p)
 
 }
 
+/*2018-07-18 add debugfs*/
+/*same as vdin_dump_vf_state*/
+void vdin_dump_vf_state_seq(struct vf_pool *p, struct seq_file *seq)
+{
+       unsigned long flags;
+       struct vf_entry *pos = NULL, *tmp = NULL;
+
+       seq_puts(seq, "buffers in writeable list:\n");
+       spin_lock_irqsave(&p->wr_lock, flags);
+       list_for_each_entry_safe(pos, tmp, &p->wr_list, list) {
+               seq_printf(seq, "index: %2u,status %u, canvas index0: 0x%x,\n",
+                       pos->vf.index, pos->status, pos->vf.canvas0Addr);
+               seq_printf(seq, "\t canvas index1: 0x%x, vframe type: 0x%x.\n",
+                       pos->vf.canvas1Addr, pos->vf.type);
+               seq_printf(seq, "\t ratio_control(0x%x).\n",
+                       pos->vf.ratio_control);
+       }
+       spin_unlock_irqrestore(&p->wr_lock, flags);
+
+       seq_puts(seq, "buffer in readable list:\n");
+       spin_lock_irqsave(&p->rd_lock, flags);
+       list_for_each_entry_safe(pos, tmp, &p->rd_list, list) {
+               seq_printf(seq, "index: %u,status %u, canvas index0: 0x%x,\n",
+                       pos->vf.index, pos->status, pos->vf.canvas0Addr);
+               seq_printf(seq, "\t canvas index1: 0x%x, vframe type: 0x%x.\n",
+                       pos->vf.canvas1Addr, pos->vf.type);
+               seq_printf(seq, "\t ratio_control(0x%x).\n",
+                       pos->vf.ratio_control);
+       }
+       spin_unlock_irqrestore(&p->rd_lock, flags);
+
+       seq_puts(seq, "buffer in waiting list:\n");
+       spin_lock_irqsave(&p->wt_lock, flags);
+       list_for_each_entry_safe(pos, tmp, &p->wt_list, list) {
+               seq_printf(seq, "index: %u, status %u, canvas index0: 0x%x,\n",
+                       pos->vf.index, pos->status, pos->vf.canvas0Addr);
+               seq_printf(seq, "\t canvas index1: 0x%x, vframe type: 0x%x.\n",
+                       pos->vf.canvas1Addr, pos->vf.type);
+               seq_printf(seq, "\t ratio_control(0x%x).\n",
+                       pos->vf.ratio_control);
+       }
+       spin_unlock_irqrestore(&p->wt_lock, flags);
+       seq_puts(seq, "buffer in temp list:\n");
+       spin_lock_irqsave(&p->tmp_lock, flags);
+       list_for_each_entry_safe(pos, tmp, &p->tmp_list, list) {
+               seq_printf(seq, "index: %u, status %u, canvas index0: 0x%x,\n",
+                       pos->vf.index, pos->status, pos->vf.canvas0Addr);
+               seq_printf(seq, "\t canvas index1: 0x%x, vframe type: 0x%x.\n",
+                       pos->vf.canvas1Addr, pos->vf.type);
+               seq_printf(seq, "\t ratio_control(0x%x).\n",
+                       pos->vf.ratio_control);
+       }
+       spin_unlock_irqrestore(&p->tmp_lock, flags);
+       seq_printf(seq, "buffer get count %d.\n", atomic_read(&p->buffer_cnt));
+
+}
+
 /*update the vframe disp_mode
  *     a.VFRAME_DISP_MODE_UNKNOWN
  *     b. VFRAME_DISP_MODE_OK
index ccbb73a..75a1a77 100644 (file)
@@ -185,6 +185,7 @@ extern void vdin_vf_freeze(struct vf_pool *p, unsigned int hold_num);
 extern void vdin_vf_unfreeze(struct vf_pool *p);
 
 extern void vdin_dump_vf_state(struct vf_pool *p);
+extern void vdin_dump_vf_state_seq(struct vf_pool *p, struct seq_file *seq);
 
 extern void vdin_vf_disp_mode_update(struct vf_entry *vfe, struct vf_pool *p);
 extern void vdin_vf_disp_mode_skip(struct vf_pool *p);