deintlace: add recycle buffer q after unreg [1/2]
authorqianqian.cai <qianqian.cai@amlogic.com>
Mon, 23 Dec 2019 01:51:11 +0000 (09:51 +0800)
committerqianqian.cai <qianqian.cai@amlogic.com>
Tue, 24 Dec 2019 11:46:50 +0000 (19:46 +0800)
PD#SWPL-18786

Problem:
keep the buffer from DI need release

Solution:
modify the recycle flow

Verify:
newton

Change-Id: I2f7647468964236ac087704f60ef975c43549776
Signed-off-by: qianqian.cai <qianqian.cai@amlogic.com>
MAINTAINERS
drivers/amlogic/media/deinterlace/deinterlace.c
drivers/amlogic/media/deinterlace/deinterlace.h
drivers/amlogic/media/di_local/di_local.c
drivers/amlogic/media/di_multi/deinterlace.c
drivers/amlogic/media/di_multi/di_sys.c
drivers/amlogic/media/di_multi/di_sys.h
include/linux/amlogic/media/di/di.h [new file with mode: 0644]

index f48ad1eed56e2d163f03382d9bfed0f32feb6331..58c25232ed471f4fe28b2285b5a0d19ff7f6c7b6 100644 (file)
@@ -15161,6 +15161,10 @@ M:     Jihong Sui <jihong.sui@amlogic.com>
 F:     drivers/amlogic/media/deinterlace/di_pqa.h
 F:     drivers/amlogic/media/di_local/*
 
+AMLOGIC DEINTERLACE DRIVER
+M:     qianqian cai <qianqian.cai@amlogic.com>
+F:     include/linux/amlogic/media/di/di.h
+
 AMLOGIC ADD DI_MULTI DRIVER
 M:     Jihong Sui <jihong.sui@amlogic.com>
 F:     drivers/amlogic/media/di_multi/*
index 9e3acb8300be03f5666a14f8d08dc43b4c76f8bb..fb2bf42a49679fc0daa07e9b1e0e038c47c85acc 100644 (file)
@@ -570,6 +570,9 @@ int get_di_dump_state_flag(void)
  ********************************************/
 void di_trig_free_mirror_mem(void)
 {
+       if (dil_get_diffver_flag())
+               return;
+
        if (atomic_read(&di_flag_unreg)
                && de_devp->flag_cma != 2
                && de_devp->flag_cma != 0
@@ -8841,6 +8844,8 @@ static int di_probe(struct platform_device *pdev)
        dil_attach_ext_api(&di_ext);
        di_patch_mov_ini();
 
+       dil_set_diffver_flag(0);
+
        di_pr_info("%s:ok\n", __func__);
        return ret;
 
index d93e312837976aab5b31009801a49fdcaf6f2ce9..ad805ba44c5ffe0fe7a359e280b2d9359f036722 100644 (file)
@@ -486,8 +486,11 @@ extern bool di_wr_cue_int(void);
 extern int reg_cue_int_show(struct seq_file *seq, void *v);
 
 bool dil_attach_ext_api(const struct di_ext_ops *di_api);
-/*---------------------*/
+/*--Different DI versions flag---*/
+void dil_set_diffver_flag(unsigned int para);
 
+unsigned int dil_get_diffver_flag(void);
+/*-------------------------*/
 struct di_buf_s *get_di_buf(int queue_idx, int *start_pos);
 
 #define queue_for_each_entry(di_buf, ptm, queue_idx, list)      \
index 3d86532d8dc0aa190f97147f2057acdd88611fc8..e7cee1ef9544fd5b54c82e74f6a3045e698efc58 100644 (file)
@@ -68,6 +68,22 @@ static struct dil_dev_s *pdv;
 
 static const struct di_ext_ops *dil_api;       //temp
 
+static unsigned int diffver_flag;
+
+/***************************************
+ * dil api for make a distinction between old/new DI function *
+ **************************************/
+void dil_set_diffver_flag(unsigned int para)
+{
+       diffver_flag = para;
+}
+EXPORT_SYMBOL(dil_set_diffver_flag);
+unsigned int dil_get_diffver_flag(void)
+{
+       return diffver_flag;
+}
+EXPORT_SYMBOL(dil_get_diffver_flag);
+
 /***************************************
  * di api for other module *
  **************************************/
index 0ee47671def4c4381731a898a60604584ee1e340..6bac4fb09f9f83e45bcfe6613310a803cbc9294c 100644 (file)
@@ -2105,7 +2105,14 @@ bool dim_post_keep_release_one(unsigned int ch, unsigned int di_buf_index)
        di_buf = &pbuf_post[di_buf_index];
 
        if (!di_que_is_in_que(ch, QUE_POST_KEEP, di_buf)) {
-               PR_ERR("%s:buf[%d] is not in keep\n", __func__, di_buf_index);
+               if (is_in_queue(ch, di_buf, QUEUE_DISPLAY)) {
+                       di_buf->queue_index = -1;
+                       di_que_in(ch, QUE_POST_BACK, di_buf);
+                       dbg_keep("%s:to back[%d]\n", __func__, di_buf_index);
+               } else {
+                       PR_ERR("%s:buf[%d] is not in keep or display\n",
+                              __func__, di_buf_index);
+               }
                return false;
        }
        di_que_out_not_fifo(ch, QUE_POST_KEEP, di_buf);
@@ -2168,12 +2175,14 @@ void dim_post_keep_cmd_release(unsigned int ch, struct vframe_s *vframe)
                 di_buf->index);
        task_send_cmd(LCMD2(ECMD_RL_KEEP, di_buf->channel, di_buf->index));
 }
-EXPORT_SYMBOL(dim_post_keep_cmd_release);
 
 void dim_post_keep_cmd_release2(struct vframe_s *vframe)
 {
        struct di_buf_s *di_buf;
 
+       if (!dil_get_diffver_flag())
+               return;
+
        if (!vframe)
                return;
 
@@ -2189,15 +2198,11 @@ void dim_post_keep_cmd_release2(struct vframe_s *vframe)
                return;
        }
 
-       if (!di_que_is_in_que(di_buf->channel, QUE_POST_KEEP, di_buf)) {
-               PR_ERR("%s:not keep buf %d\n", __func__, di_buf->index);
-       } else {
-               dbg_keep("release keep ch[%d],index[%d]\n",
-                        di_buf->channel,
-                        di_buf->index);
-               task_send_cmd(LCMD2(ECMD_RL_KEEP, di_buf->channel,
-                                   di_buf->index));
-       }
+       dbg_keep("release keep ch[%d],index[%d]\n",
+                di_buf->channel,
+                di_buf->index);
+       task_send_cmd(LCMD2(ECMD_RL_KEEP, di_buf->channel,
+                           di_buf->index));
 }
 EXPORT_SYMBOL(dim_post_keep_cmd_release2);
 
@@ -2255,6 +2260,7 @@ void dim_post_keep_cmd_proc(unsigned int ch, unsigned int index)
        chst = dip_chst_get(ch);
        switch (chst) {
        case EDI_TOP_STATE_READY:
+       case eDI_TOP_STATE_UNREG_STEP2:
                dim_post_keep_release_one(ch, index);
                break;
        case EDI_TOP_STATE_IDLE:
@@ -2299,8 +2305,14 @@ void dim_post_keep_cmd_proc(unsigned int ch, unsigned int index)
                }
 
                di_buf = &pbuf_post[index];
-               di_buf->queue_index = -1;
-               di_que_in(ch, QUE_POST_KEEP_BACK, di_buf);
+               if (is_in_queue(ch, di_buf, QUEUE_DISPLAY)) {
+                       di_buf->queue_index = -1;
+                       di_que_in(ch, QUE_POST_BACK, di_buf);
+                       dbg_keep("%s:to back[%d]\n", __func__, index);
+               } else {
+                       PR_ERR("%s:buf[%d] is not in display\n",
+                              __func__, index);
+               }
                break;
        default:
                PR_ERR("%s:do nothing? %s:%d\n",
index 4e92430818d797478c38614b9cde956ee98fc0a1..fbd0a40ec8ff0207c2601cee944afcc2f00305ca 100644 (file)
@@ -972,6 +972,8 @@ static int dim_probe(struct platform_device *pdev)
 
        dimh_patch_post_update_mc_sw(DI_MC_SW_IC, true);
 
+       dil_set_diffver_flag(1);
+
        pr_info("%s:ok\n", __func__);
        return ret;
 
index 3bbb4f7fbed829755ac2a367c9eea6ca9615abd5..85ca73a3de6e34a6a6b29777c893b0c7a86dff5c 100644 (file)
@@ -38,5 +38,9 @@ bool dim_mm_release_api(int cma_mode,
 bool dim_cma_top_alloc(unsigned int ch);
 bool dim_cma_top_release(unsigned int ch);
 bool dim_rev_mem_check(void);
+/*--Different DI versions flag---*/
+void dil_set_diffver_flag(unsigned int para);
 
+unsigned int dil_get_diffver_flag(void);
+/*-------------------------*/
 #endif /*__DI_SYS_H__*/
diff --git a/include/linux/amlogic/media/di/di.h b/include/linux/amlogic/media/di/di.h
new file mode 100644 (file)
index 0000000..eafae38
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * include/linux/amlogic/media/di/di.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 DI_H
+#define DI_H
+
+void dim_post_keep_cmd_release2(struct vframe_s *vframe);
+
+#endif /* VIDEO_H */