diff --git a/drivers/amlogic/media/common/arch/registers/register_map.c b/drivers/amlogic/media/common/arch/registers/register_map.c index dcc109a36ff1..e333b065d2fb 100644 --- a/drivers/amlogic/media/common/arch/registers/register_map.c +++ b/drivers/amlogic/media/common/arch/registers/register_map.c @@ -53,7 +53,7 @@ static void __iomem *codecio_reg_map[CODECIO_BUS_MAX]; static int codecio_reg_read(u32 bus_type, unsigned int reg, unsigned int *val) { - if ((bus_type >= CODECIO_CBUS_BASE) && (bus_type < CODECIO_BUS_MAX)) { + if (bus_type < CODECIO_BUS_MAX) { if (codecio_reg_map[bus_type] == NULL) { pr_err("No support bus type %d to read.\n", bus_type); return -1; @@ -67,7 +67,7 @@ static int codecio_reg_read(u32 bus_type, unsigned int reg, unsigned int *val) static int codecio_reg_write(u32 bus_type, unsigned int reg, unsigned int val) { - if ((bus_type >= CODECIO_CBUS_BASE) && (bus_type < CODECIO_BUS_MAX)) { + if (bus_type < CODECIO_BUS_MAX) { if (codecio_reg_map[bus_type] == NULL) { pr_err("No support bus type %d to write.\n", bus_type); return -1; diff --git a/drivers/amlogic/media/common/arch/registers/register_ops.c b/drivers/amlogic/media/common/arch/registers/register_ops.c index d22c80d46943..b77e289e7caa 100644 --- a/drivers/amlogic/media/common/arch/registers/register_ops.c +++ b/drivers/amlogic/media/common/arch/registers/register_ops.c @@ -57,6 +57,8 @@ int codec_reg_read(u32 bus_type, unsigned int reg) { struct chip_register_ops *ops = amports_ops[bus_type]; + if (!ops) + return 0; ops->r_cnt++; CODEC_OPS_START(bus_type, reg, ops->r_cnt); @@ -78,6 +80,8 @@ void codec_reg_write(u32 bus_type, unsigned int reg, unsigned int val) { struct chip_register_ops *ops = amports_ops[bus_type]; + if (!ops) + return; ops->w_cnt++; CODEC_OPS_START(bus_type, reg, ops->w_cnt); diff --git a/drivers/amlogic/media/common/canvas/canvas.c b/drivers/amlogic/media/common/canvas/canvas.c index d81a7fdc489a..8e4b1f19a1fd 100644 --- a/drivers/amlogic/media/common/canvas/canvas.c +++ b/drivers/amlogic/media/common/canvas/canvas.c @@ -58,7 +58,7 @@ struct canvas_device_info { }; static struct canvas_device_info canvas_info; -#define CANVAS_VALID(n) ((n) >= 0 && (n) < canvas_pool_canvas_num()) +#define CANVAS_VALID(n) ((n) < canvas_pool_canvas_num()) static void canvas_lut_data_build(ulong addr, u32 width, u32 height, u32 wrap, u32 blkmode, diff --git a/drivers/amlogic/media/common/vfm/vfm.c b/drivers/amlogic/media/common/vfm/vfm.c index f60eb1f2c8bd..eaea9136f63d 100644 --- a/drivers/amlogic/media/common/vfm/vfm.c +++ b/drivers/amlogic/media/common/vfm/vfm.c @@ -249,8 +249,10 @@ retry: } else{ pr_err("%s: Error, map full\n", __func__); ret = -1; + kfree(p); } - } + } else + kfree(p); spin_unlock_irqrestore(&lock, flags); } if (add_ok) @@ -323,8 +325,6 @@ static char *vf_get_receiver_name_inmap(int i, const char *provider_name) } } - if (found) - break; } return receiver_name; } @@ -500,7 +500,7 @@ static void vfm_dump_provider(const char *name) return; buf = kzalloc(0x400, GFP_KERNEL); - if (IS_ERR_OR_NULL(buf)) + if (buf == NULL) return; pbuf = buf; @@ -802,6 +802,7 @@ static long vfm_ioctl(struct file *file, unsigned int cmd, ulong arg) copy_from_user(argp.val, user_argp->val, sizeof(argp.val)); if (ret) ret = -EINVAL; + argp.val[sizeof(argp.val) - 1] = '\0'; vfm_dump_provider(argp.val); } break; diff --git a/drivers/amlogic/media/common/vfm/vftrace.c b/drivers/amlogic/media/common/vfm/vftrace.c index 7ec062de5234..48cea06d9123 100644 --- a/drivers/amlogic/media/common/vfm/vftrace.c +++ b/drivers/amlogic/media/common/vfm/vftrace.c @@ -97,7 +97,7 @@ void vftrace_info_in(void *vhandle, struct vframe_s *vf) info->vf = vf; info->pts = vf->pts; info->in_time_us = div64_u64(timeval_to_ns(&tv), 1000); - info->duration = info->duration; + /*info->duration = info->duration;*/ vftrace->w_index++; vftrace->num++; if (vftrace->w_index >= vftrace->max) diff --git a/drivers/amlogic/media/video_processor/ionvideo/ionvideo.c b/drivers/amlogic/media/video_processor/ionvideo/ionvideo.c index 1db29dbe894e..cd3ad7a324bf 100644 --- a/drivers/amlogic/media/video_processor/ionvideo/ionvideo.c +++ b/drivers/amlogic/media/video_processor/ionvideo/ionvideo.c @@ -133,7 +133,7 @@ static int vidioc_g_parm(struct file *file, void *priv, { struct ionvideo_dev *dev = video_drvdata(file); struct v4l2_amlogic_parm *ap - = (struct v4l2_amlogic_parm *)&parms->parm.capture; + = (struct v4l2_amlogic_parm *)parms->parm.raw_data; if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; diff --git a/drivers/amlogic/media/video_sink/video.c b/drivers/amlogic/media/video_sink/video.c index 5c45f9ad246d..de278705f040 100644 --- a/drivers/amlogic/media/video_sink/video.c +++ b/drivers/amlogic/media/video_sink/video.c @@ -1236,7 +1236,7 @@ int ext_get_cur_video_frame(struct vframe_s **vf, int *canvas_index) } static void dump_vframe_status(const char *name) { - int ret = 0; + int ret = -1; struct vframe_states states; struct vframe_provider_s *vfp; @@ -1999,7 +1999,7 @@ static void zoom_display_vert(void) u32 ls, le, rs, re; - if (platform_type == 1) { + /*if (platform_type == 1) {*/ if (process_3d_type & MODE_3D_ENABLE) { zoom_get_vert_pos(cur_dispbuf, cur_frame_par->vpp_3d_mode, &ls, @@ -2008,7 +2008,7 @@ static void zoom_display_vert(void) ls = rs = zoom_start_y_lines; le = re = zoom_end_y_lines; } - } else { + /*} else { if (process_3d_type & MODE_3D_ENABLE) { zoom_get_vert_pos(cur_dispbuf, cur_frame_par->vpp_3d_mode, &ls, @@ -2018,6 +2018,7 @@ static void zoom_display_vert(void) le = re = zoom_end_y_lines; } } +*/ if ((cur_dispbuf) && (cur_dispbuf->type & VIDTYPE_MVC)) { if (is_need_framepacking_output()) { @@ -3069,6 +3070,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) 0x80 << v); /* chroma formatter */ /* TODO: afbc setting only cover 420 for now */ +/* #ifdef TV_REVERSE if (reverse) { #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION @@ -3096,6 +3098,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) VFORMATTER_EN); } else #endif +*/ { #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION if (is_meson_txlx_package_962X() @@ -5661,10 +5664,12 @@ SET_FILTER: (!(READ_VCBUS_REG(AFBC_ENABLE) & 0x100)); /*video on && afbc is off && is compress frame.*/ if (frame_par_ready_to_set || afbc_need_reset) { - viu_set_dcu(cur_frame_par, cur_dispbuf); - if (cur_dispbuf2) - vd2_set_dcu(cur_frame_par, - cur_dispbuf2); + if (cur_frame_par) { + viu_set_dcu(cur_frame_par, cur_dispbuf); + if (cur_dispbuf2) + vd2_set_dcu(cur_frame_par, + cur_dispbuf2); + } } else if (cur_dispbuf2) { u32 new_el_w = (cur_dispbuf2->type @@ -5701,7 +5706,7 @@ SET_FILTER: #endif if (platform_type == 1) { - if (cur_frame_par->hscale_skip_count) { + if (cur_frame_par && cur_frame_par->hscale_skip_count) { VSYNC_WR_MPEG_REG_BITS(VIU_VD1_FMT_CTRL + cur_dev->viu_off, 1, 20, 1); /* HFORMATTER_EN */ @@ -5756,8 +5761,9 @@ SET_FILTER: } if ((process_3d_type & MODE_3D_OUT_TB) || (process_3d_type & MODE_3D_OUT_LR)) { - if (cur_frame_par->vpp_2pic_mode & - VPP_PIC1_FIRST) { + if (cur_frame_par && + (cur_frame_par->vpp_2pic_mode & + VPP_PIC1_FIRST)) { VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + cur_dev->viu_off, 0x4000000); VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + @@ -5833,17 +5839,20 @@ SET_FILTER: } if (platform_type == 1) { if (force_3d_scaler == 3 && + cur_frame_par && cur_frame_par->vpp_3d_scale) { VSYNC_WR_MPEG_REG_BITS( VPP_VSC_PHASE_CTRL, 3, VPP_PHASECTL_DOUBLELINE_BIT, 2); } else if (force_3d_scaler == 1 && + cur_frame_par && cur_frame_par->vpp_3d_scale) { VSYNC_WR_MPEG_REG_BITS( VPP_VSC_PHASE_CTRL, 1, VPP_PHASECTL_DOUBLELINE_BIT, VPP_PHASECTL_DOUBLELINE_WID); } else if (force_3d_scaler == 2 && + cur_frame_par && cur_frame_par->vpp_3d_scale) { VSYNC_WR_MPEG_REG_BITS( VPP_VSC_PHASE_CTRL, 2, @@ -6924,7 +6933,7 @@ EXPORT_SYMBOL(pause_video); *********************************************************/ int _video_set_disable(u32 val) { - if ((val < VIDEO_DISABLE_NONE) || (val > VIDEO_DISABLE_FORNEXT)) + if (val > VIDEO_DISABLE_FORNEXT) return -EINVAL; disable_video = val; @@ -7299,6 +7308,7 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg) ret = _video_set_disable(val); else ret = -EFAULT; + break; } case AMSTREAM_IOC_GET_VIDEO_DISCONTINUE_REPORT: @@ -7659,23 +7669,27 @@ static int parse_para(const char *para, int para_num, int *result) params = kstrdup(para, GFP_KERNEL); params_base = params; token = params; - len = strlen(token); - do { - token = strsep(¶ms, " "); - while (token && (isspace(*token) - || !isgraph(*token)) && len) { - token++; - len--; - } - if (len == 0) - break; - ret = kstrtoint(token, 0, &res); - if (ret < 0) - break; + if (token) { len = strlen(token); - *out++ = res; - count++; - } while ((token) && (count < para_num) && (len > 0)); + do { + token = strsep(¶ms, " "); + if (!token) + break; + while (token && (isspace(*token) + || !isgraph(*token)) && len) { + token++; + len--; + } + if (len == 0) + break; + ret = kstrtoint(token, 0, &res); + if (ret < 0) + break; + len = strlen(token); + *out++ = res; + count++; + } while ((count < para_num) && (len > 0)); + } kfree(params_base); return count; @@ -7719,7 +7733,7 @@ static ssize_t video_3d_scale_store(struct class *cla, { #ifdef TV_3D_FUNCTION_OPEN u32 enable; - size_t r; + int r; r = kstrtouint(buf, 0, &enable); if (r < 0) @@ -8040,7 +8054,7 @@ static ssize_t video_blackout_policy_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; r = kstrtoint(buf, 0, &blackout); if (r < 0) @@ -8063,7 +8077,7 @@ static ssize_t video_seek_flag_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; r = kstrtoint(buf, 0, &video_seek_flag); if (r < 0) @@ -8114,7 +8128,7 @@ static ssize_t video_brightness_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; int val; r = kstrtoint(buf, 0, &val); @@ -8145,7 +8159,7 @@ static ssize_t video_contrast_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; int val; r = kstrtoint(buf, 0, &val); @@ -8175,7 +8189,7 @@ static ssize_t vpp_brightness_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; int val; r = kstrtoint(buf, 0, &val); @@ -8206,7 +8220,7 @@ static ssize_t vpp_contrast_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; int val; r = kstrtoint(buf, 0, &val); @@ -8232,7 +8246,7 @@ static ssize_t video_saturation_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; int val; r = kstrtoint(buf, 0, &val); @@ -8255,7 +8269,7 @@ static ssize_t vpp_saturation_hue_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; s32 mab = 0; s16 mc = 0, md = 0; @@ -8471,7 +8485,7 @@ static ssize_t video_test_screen_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; unsigned int data = 0x0; r = kstrtoint(buf, 0, &test_screen); @@ -8536,7 +8550,7 @@ static ssize_t video_rgb_screen_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; u32 yuv_eight; /* unsigned data = 0x0; */ @@ -8599,7 +8613,7 @@ static ssize_t video_nonlinear_factor_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; u32 factor; r = kstrtoint(buf, 0, &factor); @@ -8622,7 +8636,7 @@ static ssize_t video_disable_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; int val; if (debug_flag & DEBUG_FLAG_BLACKOUT) @@ -8648,7 +8662,7 @@ static ssize_t video_global_output_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; r = kstrtoint(buf, 0, &video_global_output); if (r < 0) @@ -8669,7 +8683,7 @@ static ssize_t video_freerun_mode_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; r = kstrtoint(buf, 0, &freerun_mode); if (r < 0) @@ -8708,7 +8722,7 @@ static ssize_t threedim_mode_store(struct class *cla, #ifdef TV_3D_FUNCTION_OPEN u32 type; - size_t r; + int r; r = kstrtoint(buf, 0, &type); if (r < 0) @@ -9051,8 +9065,8 @@ static ssize_t video_debugflags_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; - int value = -1, seted = 1; + int r; + int value = -1; /* * r = sscanf(buf, "%d", &value); @@ -9073,14 +9087,11 @@ static ssize_t video_debugflags_store(struct class *cla, return -EINVAL; debugflags = value; - seted = 1; - if (seted) { - pr_info("debugflags changed to %d(%x)\n", debugflags, - debugflags); - return count; - } else - return -EINVAL; + pr_info("debugflags changed to %d(%x)\n", debugflags, + debugflags); + return count; + } static ssize_t trickmode_duration_show(struct class *cla, @@ -9094,7 +9105,7 @@ static ssize_t trickmode_duration_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; u32 s_value; r = kstrtoint(buf, 0, &s_value); @@ -9124,7 +9135,7 @@ static ssize_t video_vsync_pts_inc_upint_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; r = kstrtoint(buf, 0, &vsync_pts_inc_upint); if (r < 0) @@ -9148,7 +9159,7 @@ static ssize_t slowsync_repeat_enable_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; r = kstrtoint(buf, 0, &slowsync_repeat_enable); if (r < 0) @@ -9171,7 +9182,7 @@ static ssize_t video_vsync_slow_factor_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; r = kstrtoint(buf, 0, &vsync_slow_factor); if (r < 0) @@ -9217,7 +9228,7 @@ static ssize_t video_layer1_state_show(struct class *cla, void set_video_angle(u32 s_value) { - if ((s_value >= 0 && s_value <= 3) && (video_angle != s_value)) { + if ((s_value <= 3) && (video_angle != s_value)) { video_angle = s_value; video_prot.angle_changed = 1; video_prot.video_started = 1; @@ -9236,7 +9247,7 @@ static ssize_t video_angle_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; u32 s_value; r = kstrtoint(buf, 0, &s_value); @@ -9258,7 +9269,7 @@ static ssize_t show_first_frame_nosync_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; int value; r = kstrtoint(buf, 0, &value); @@ -9277,7 +9288,7 @@ static ssize_t show_first_picture_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; int value; r = kstrtoint(buf, 0, &value); @@ -9296,7 +9307,7 @@ static ssize_t video_free_keep_buffer_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; int val; if (debug_flag & DEBUG_FLAG_BLACKOUT) @@ -9314,7 +9325,7 @@ static ssize_t free_cma_buffer_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; + int r; int val; r = kstrtoint(buf, 0, &val); diff --git a/drivers/amlogic/media/video_sink/video_keeper.c b/drivers/amlogic/media/video_sink/video_keeper.c index 1eaf894710f3..72d442fc5317 100644 --- a/drivers/amlogic/media/video_sink/video_keeper.c +++ b/drivers/amlogic/media/video_sink/video_keeper.c @@ -877,6 +877,7 @@ static unsigned int vf_keep_current_locked( if ((cur_dispbuf->type & VIDTYPE_VIU_422) == VIDTYPE_VIU_422) { return -1; /* no VIDTYPE_VIU_422 type frame need keep,avoid memcpy crash*/ +/* if ((Y_BUFFER_SIZE < (cd.width * cd.height))) { pr_info("[%s::%d]data > buf size: %x,%x,%x, %x,%x\n", __func__, __LINE__, Y_BUFFER_SIZE, @@ -899,7 +900,9 @@ static unsigned int vf_keep_current_locked( #endif if (get_video_debug_flags() & DEBUG_FLAG_BLACKOUT) pr_info("%s: VIDTYPE_VIU_422\n", __func__); + } +*/ } else if ((cur_dispbuf->type & VIDTYPE_VIU_444) == VIDTYPE_VIU_444) { if ((Y_BUFFER_SIZE < (cd.width * cd.height))) { pr_info