di: fix coverity error
authorwenfeng.guo <wenfeng.guo@amlogic.com>
Tue, 26 Jun 2018 07:10:22 +0000 (15:10 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Wed, 18 Jul 2018 04:27:16 +0000 (21:27 -0700)
PD#169049: di: fix coverity error

Change-Id: I267ae15a1a72ad4255a182f4e7617ac641774c49
Signed-off-by: wenfeng.guo <wenfeng.guo@amlogic.com>
drivers/amlogic/media/deinterlace/deinterlace.c
drivers/amlogic/media/deinterlace/deinterlace.h
drivers/amlogic/media/deinterlace/deinterlace_dbg.c
drivers/amlogic/media/deinterlace/deinterlace_hw.h
drivers/amlogic/media/deinterlace/di_pps.c
drivers/amlogic/media/deinterlace/film_mode_fmw/film_fw1.c
drivers/amlogic/media/deinterlace/nr_drv.c
drivers/amlogic/media/deinterlace/nr_drv.h
drivers/amlogic/media/deinterlace/register.h

index 02a5ea9c6affa9f8821246a3da950b87740c1936..f900f1368ce4877baa04310648682efada7ec2f9 100644 (file)
@@ -118,7 +118,7 @@ static di_dev_t *de_devp;
 static dev_t di_devno;
 static struct class *di_clsp;
 
-static const char version_s[] = "2018-02-11a";
+static const char version_s[] = "2018-07-17a";
 
 static int bypass_state = 1;
 static int bypass_all;
@@ -303,9 +303,8 @@ void trigger_pre_di_process(unsigned char idx)
        if (di_sema_init_flag == 0)
                return;
 
-       if (idx != 'p')
-               log_buffer_state((idx == 'i') ? "irq" : ((idx == 'p') ?
-                       "put" : ((idx == 'r') ? "rdy" : "oth")));
+       log_buffer_state((idx == 'i') ? "irq" : ((idx == 'p') ?
+               "put" : ((idx == 'r') ? "rdy" : "oth")));
 
        /* tasklet_hi_schedule(&di_pre_tasklet); */
        tasklet_schedule(&di_pre_tasklet);
@@ -1181,15 +1180,13 @@ store_dump_mem(struct device *dev, struct device_attribute *attr,
        struct vframe_s *post_vf = NULL;
        char *buf_orig, *ps, *token;
        char *parm[3] = { NULL };
-       char delim1[2] = " ";
+       char delim1[3] = " ";
        char delim2[2] = "\n";
        struct file *filp = NULL;
        loff_t pos = 0;
        void *buff = NULL;
        mm_segment_t old_fs;
 
-       if (!buf)
-               return len;
        buf_orig = kstrdup(buf, GFP_KERNEL);
        ps = buf_orig;
        strcat(delim1, delim2);
@@ -1239,7 +1236,7 @@ store_dump_mem(struct device *dev, struct device_attribute *attr,
                        buff = (void *)phys_to_virt(dump_adr);
                else
                        buff = ioremap(dump_adr, nr_size);
-               if (buff == NULL)
+               if (IS_ERR_OR_NULL(buff))
                        pr_err("%s: ioremap error.\n", __func__);
                vfs_write(filp, buff, nr_size, &pos);
 /*     pr_dbg("di_chan2_buf_dup_p:\n   nr:%u,mtn:%u,cnt:%u\n",
@@ -6802,22 +6799,6 @@ static int di_event_cb(int type, void *data, void *private_data)
                pr_info("%s: RECEIVER_FORCE_UNREG return\n",
                        __func__);
                return 0;
-               di_pre_stru.force_unreg_req_flag = 1;
-
-               trigger_pre_di_process(TRIGGER_PRE_BY_FORCE_UNREG);
-               di_pre_stru.unreg_req_flag_cnt = 0;
-               while (di_pre_stru.force_unreg_req_flag) {
-                       usleep_range(1000, 1001);
-                       di_pr_info("%s:unreg_req_flag_cnt:%d!!!\n",
-                               __func__, di_pre_stru.unreg_req_flag_cnt);
-                       if (di_pre_stru.unreg_req_flag_cnt++ >
-                               di_reg_unreg_cnt) {
-                               di_pre_stru.unreg_req_flag_cnt = 0;
-                               di_pr_info("%s:unreg_reg_flag timeout!!!\n",
-                                       __func__);
-                               break;
-                       }
-               }
        }
        return 0;
 }
@@ -6915,6 +6896,11 @@ static long di_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                        pr_err("[DI] set pq parm errors\n");
                        return -EFAULT;
                }
+               if (tmp_pq_s.table_len >= TABLE_LEN_MAX) {
+                       pr_err("[DI] load 0x%x wrong pq table_len.\n",
+                               tmp_pq_s.table_len);
+                       return -EFAULT;
+               }
                tab_flag = TABLE_NAME_DI | TABLE_NAME_NR | TABLE_NAME_MCDI |
                        TABLE_NAME_DEBLOCK | TABLE_NAME_DEMOSQUITO;
                if (tmp_pq_s.table_name & tab_flag) {
index 6cee1954e4df83c27fac061a56ffbc22347030d1..15878b23324eed021c5771097336f43e39bd1370 100644 (file)
@@ -192,6 +192,9 @@ extern bool is_vsync_rdma_enable(void);
 #define DI_SUSPEND_FLAG 0x2
 #define DI_LOAD_REG_FLAG 0x4
 #define DI_VPU_CLKB_SET 0x8
+
+#define TABLE_LEN_MAX 10000
+
 struct di_dev_s {
        dev_t                      devt;
        struct cdev                cdev; /* The cdev structure */
index 0da7133b6dbf14b8be3148c9f3d1047c7d6c79ef..319a9d606e42bbe2a95782ece6762d10b66b788c 100644 (file)
@@ -40,7 +40,7 @@
 void parse_cmd_params(char *buf_orig, char **parm)
 {
        char *ps, *token;
-       char delim1[2] = " ";
+       char delim1[3] = " ";
        char delim2[2] = "\n";
        unsigned int n = 0;
 
index ce1345849b37b5ed594bf1ae7092eeeb2de0a435..145d44f337c4c213ff1bed5fea99acd67883a056 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/amlogic/media/amvecm/amvecm.h>
 #include "pulldown_drv.h"
 #include "nr_drv.h"
-#include "deinterlace_hw.h"
 
 /* if post size < 80, filter of ei can't work */
 #define MIN_POST_WIDTH  80
index 8c9f7f317e64a97b3ad8cfc954995e5539dffecf..750be0179d03b24bc82e9dd6bbdcf10cced8f0ec 100644 (file)
@@ -343,6 +343,11 @@ unsigned int di_filt_coef2[] =  //2 point bilinear, bank_length == 2
 #define ZOOM_BITS       20
 #define PHASE_BITS      16
 
+static enum f2v_vphase_type_e top_conv_type = F2V_P2P;
+static enum f2v_vphase_type_e bot_conv_type = F2V_P2P;
+static unsigned int prehsc_en;
+static unsigned int prevsc_en;
+
 static const unsigned char f2v_420_in_pos_luma[F2V_TYPE_MAX] = {
 0, 2, 0, 2, 0, 0, 0, 2, 0};
 //static const unsigned char f2v_420_in_pos_chroma[F2V_TYPE_MAX] = {
@@ -386,16 +391,14 @@ static void f2v_get_vertical_phase(unsigned int zoom_ratio,
 /*
  * patch 1: inp scaler 0: di wr scaler
  */
+
 void di_pps_config(unsigned char path, int src_w, int src_h,
        int dst_w, int dst_h)
 {
-       enum f2v_vphase_type_e top_conv_type = F2V_P2P;
-       enum f2v_vphase_type_e bot_conv_type = F2V_P2P;
        struct pps_f2v_vphase_s vphase;
 
        int i;
        int hsc_en = 0, vsc_en = 0;
-       int prehsc_en = 0, prevsc_en = 0;
        int vsc_double_line_mode;
        unsigned int p_src_w, p_src_h;
        unsigned int vert_phase_step, horz_phase_step;
index 6c111681c3918ab4fc2b2451388ecaaf534628a5..cd6b46782d1494c81eebbc8c1184318661c53c32 100644 (file)
@@ -1579,7 +1579,7 @@ int Flm22DetSft(struct sFlmDatSt *pRDat, int *nDif02,
                if (nFlgCk20 < flm22_chk20_sml)
                        nFlm22Lvl = nFlm22Lvl + flm22_comlev1 - nFlgCk20;
                if (nFlgCk21 < flm22_chk21_sml)
-                       nFlm22Lvl = nFlm22Lvl + flm22_comlev1 - nFlgCk20;
+                       nFlm22Lvl = nFlm22Lvl + flm22_comlev1 - nFlgCk21;
                if (prt_flg) {
                        pr_info("nFlm22Lvl=%d, nFlgCk20=%d, nFlgCk21=%d\n",
                                nFlm22Lvl, nFlgCk20, nFlgCk21);
@@ -1624,9 +1624,7 @@ static int DIweavedetec(struct sFlmSftPar *pPar, int nDif01)
                else
                        difflag = 0;
                if (difflag^predifflag) {
-                       if (numdif > 255)
-                               numdif = numdif;
-                       else
+                       if (numdif <= 255)
                                numdif = numdif + 1;
                        predifflag = difflag;
                } else if (numdif > numthd) {
index 4fa23f5d8cbdccd37021259e6f688b50b55aa55b..4d93d465f2aa6744900b79cede53b30094095d1d 100644 (file)
@@ -791,7 +791,7 @@ void nr_process_in_irq(void)
 static void parse_cmd_params(char *buf_orig, char **parm)
 {
        char *ps, *token;
-       char delim1[2] = " ";
+       char delim1[3] = " ";
        char delim2[2] = "\n";
        unsigned int n = 0;
 
@@ -875,7 +875,7 @@ static ssize_t dnr_param_show(struct device *dev,
        return len;
 }
 
-static nr4_param_t nr4_params[30];
+static nr4_param_t nr4_params[NR4_PARAMS_NUM];
 static void nr4_params_init(struct NR4_PARM_s *nr4_parm_p)
 {
        nr4_params[0].name = "prm_nr4_srch_stp";
@@ -892,44 +892,42 @@ static void nr4_params_init(struct NR4_PARM_s *nr4_parm_p)
        nr4_params[5].addr = &(nr4_parm_p->sw_nr4_scene_change_flg[1]);
        nr4_params[6].name = "sw_nr4_scene_change_flg[2]";
        nr4_params[6].addr = &(nr4_parm_p->sw_nr4_scene_change_flg[2]);
-       nr4_params[7].name = "sw_nr4_scene_change_flg[3]";
-       nr4_params[7].addr = &(nr4_parm_p->sw_nr4_scene_change_flg[3]);
-       nr4_params[8].name = "sw_nr4_sad2gain_en";
-       nr4_params[8].addr = &(nr4_parm_p->sw_nr4_sad2gain_en);
-       nr4_params[9].name = "sw_nr4_sad2gain_lut[0]";
-       nr4_params[9].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[0]);
-       nr4_params[10].name = "sw_nr4_sad2gain_lut[1]";
-       nr4_params[10].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[1]);
-       nr4_params[11].name = "sw_nr4_sad2gain_lut[2]";
-       nr4_params[11].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[2]);
-       nr4_params[12].name = "sw_nr4_sad2gain_lut[3]";
-       nr4_params[12].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[3]);
-       nr4_params[13].name = "sw_nr4_sad2gain_lut[4]";
-       nr4_params[13].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[4]);
-       nr4_params[14].name = "sw_nr4_sad2gain_lut[5]";
-       nr4_params[14].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[5]);
-       nr4_params[15].name = "sw_nr4_sad2gain_lut[6]";
-       nr4_params[15].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[6]);
-       nr4_params[16].name = "sw_nr4_sad2gain_lut[7]";
-       nr4_params[16].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[7]);
-       nr4_params[17].name = "sw_nr4_sad2gain_lut[8]";
-       nr4_params[17].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[8]);
-       nr4_params[18].name = "sw_nr4_sad2gain_lut[9]";
-       nr4_params[18].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[9]);
-       nr4_params[19].name = "sw_nr4_sad2gain_lut[10]";
-       nr4_params[19].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[10]);
-       nr4_params[20].name = "sw_nr4_sad2gain_lut11]";
-       nr4_params[20].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[11]);
-       nr4_params[21].name = "sw_nr4_sad2gain_lut[12]";
-       nr4_params[21].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[12]);
-       nr4_params[22].name = "sw_nr4_sad2gain_lut13]";
-       nr4_params[22].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[13]);
-       nr4_params[23].name = "sw_nr4_sad2gain_lut[14]";
-       nr4_params[23].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[14]);
-       nr4_params[24].name = "sw_nr4_sad2gain_lut[15]";
-       nr4_params[24].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[15]);
-       nr4_params[25].name = "nr4_debug";
-       nr4_params[25].addr = &(nr4_parm_p->nr4_debug);
+       nr4_params[7].name = "sw_nr4_sad2gain_en";
+       nr4_params[7].addr = &(nr4_parm_p->sw_nr4_sad2gain_en);
+       nr4_params[8].name = "sw_nr4_sad2gain_lut[0]";
+       nr4_params[8].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[0]);
+       nr4_params[9].name = "sw_nr4_sad2gain_lut[1]";
+       nr4_params[9].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[1]);
+       nr4_params[10].name = "sw_nr4_sad2gain_lut[2]";
+       nr4_params[10].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[2]);
+       nr4_params[11].name = "sw_nr4_sad2gain_lut[3]";
+       nr4_params[11].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[3]);
+       nr4_params[12].name = "sw_nr4_sad2gain_lut[4]";
+       nr4_params[12].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[4]);
+       nr4_params[13].name = "sw_nr4_sad2gain_lut[5]";
+       nr4_params[13].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[5]);
+       nr4_params[14].name = "sw_nr4_sad2gain_lut[6]";
+       nr4_params[14].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[6]);
+       nr4_params[15].name = "sw_nr4_sad2gain_lut[7]";
+       nr4_params[15].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[7]);
+       nr4_params[16].name = "sw_nr4_sad2gain_lut[8]";
+       nr4_params[16].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[8]);
+       nr4_params[17].name = "sw_nr4_sad2gain_lut[9]";
+       nr4_params[17].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[9]);
+       nr4_params[18].name = "sw_nr4_sad2gain_lut[10]";
+       nr4_params[18].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[10]);
+       nr4_params[19].name = "sw_nr4_sad2gain_lut11]";
+       nr4_params[19].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[11]);
+       nr4_params[20].name = "sw_nr4_sad2gain_lut[12]";
+       nr4_params[20].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[12]);
+       nr4_params[21].name = "sw_nr4_sad2gain_lut13]";
+       nr4_params[21].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[13]);
+       nr4_params[22].name = "sw_nr4_sad2gain_lut[14]";
+       nr4_params[22].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[14]);
+       nr4_params[23].name = "sw_nr4_sad2gain_lut[15]";
+       nr4_params[23].addr = &(nr4_parm_p->sw_nr4_sad2gain_lut[15]);
+       nr4_params[24].name = "nr4_debug";
+       nr4_params[24].addr = &(nr4_parm_p->nr4_debug);
 
 };
 
@@ -942,8 +940,9 @@ static ssize_t nr4_param_store(struct device *dev,
 
        buf_orig = kstrdup(buff, GFP_KERNEL);
        parse_cmd_params(buf_orig, (char **)(&parm));
-       for (i = 0; i < 30; i++) {
-               if (IS_ERR_OR_NULL(nr4_params[i].name))
+       for (i = 0; i < NR4_PARAMS_NUM; i++) {
+               if (IS_ERR_OR_NULL(nr4_params[i].name) ||
+                   IS_ERR_OR_NULL(nr4_params[i].addr))
                        continue;
                if (!strcmp(parm[0], nr4_params[i].name)) {
                        if (parm[1]) {
@@ -951,6 +950,7 @@ static ssize_t nr4_param_store(struct device *dev,
                                        pr_err("DI: input value error.\n");
                                *(nr4_params[i].addr) = value;
                        }
+                       pr_info(" %d\n",    *(nr4_params[i].addr));
                }
        }
 
@@ -965,8 +965,9 @@ static ssize_t nr4_param_show(struct device *dev,
        ssize_t len = 0;
        int i = 0;
 
-       for (i = 0; i < 30; i++) {
-               if (IS_ERR_OR_NULL(nr4_params[i].name))
+       for (i = 0; i < NR4_PARAMS_NUM; i++) {
+               if (IS_ERR_OR_NULL(nr4_params[i].name) ||
+                   IS_ERR_OR_NULL(nr4_params[i].addr))
                        continue;
                len += sprintf(buff+len, "%s=%d.\n",
                nr4_params[i].name, *(nr4_params[i].addr));
index 85e85874b4a2acebf19f2608280e7c078316847c..0ec80d60684738a8bdfaa1c884b466199a027968 100644 (file)
@@ -24,6 +24,7 @@ struct nr_param_s {
        int *addr;
 };
 
+#define NR4_PARAMS_NUM 25
 #define dnr_param_t struct nr_param_s
 #define nr4_param_t struct nr_param_s
 
index 1af98c1247e3bcbbd5f85ef2a0e2cd1f543168ab..adeedbbe1b469f23dc567d76c7700f1d16e531e0 100644 (file)
@@ -27,7 +27,7 @@
 #define Wr_reg_bits(adr, val, start, len)  \
                aml_vcbus_update_bits(adr, ((1<<len)-1)<<start, val<<start)
 #define Rd_reg_bits(adr, start, len)  \
-               ((aml_read_vcbus(adr)&(((1<<len)-1)<<start))>>start)
+               ((aml_read_vcbus(adr)&(((1UL<<len)-1UL)<<start))>>start)
 
 unsigned int RDMA_WR(unsigned int adr, unsigned int val);
 unsigned int RDMA_RD(unsigned int adr);