media: fix some coverity error

PD#170543

Change-Id: I8494394be526b99f16eab43f5510d4b48aa4a311
Signed-off-by: Peng Yixin <yixin.peng@amlogic.com>
This commit is contained in:
Peng Yixin
2018-07-26 20:42:42 +08:00
committed by Dongjin Kim
parent f84109b20a
commit 9e1e8402e0
31 changed files with 169 additions and 212 deletions

View File

@@ -664,7 +664,7 @@ int vdec_vframe_write(struct file *file, const char *buf,
do {
ret = vdec_write_vframe(vdec, buf, count);
if (ret == -EAGAIN) {
vdec_input_level(&vdec->input);
/*vdec_input_level(&vdec->input);*/
msleep(20);
}
} while (ret == -EAGAIN && try_cnt--);

View File

@@ -914,13 +914,11 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
if ((f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) &&
vb2_is_busy(&ctx->m2m_ctx->out_q_ctx.q)) {
aml_v4l2_err("out_q_ctx buffers already requested");
ret = -EBUSY;
}
if ((f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
vb2_is_busy(&ctx->m2m_ctx->cap_q_ctx.q)) {
aml_v4l2_err("cap_q_ctx buffers already requested");
ret = -EBUSY;
}
fmt = aml_vdec_find_format(f);

View File

@@ -84,7 +84,7 @@ static int fops_vcodec_open(struct file *file)
/* Deinit when failure occurred */
//err_load_fw:
v4l2_m2m_ctx_release(ctx->m2m_ctx);
/*v4l2_m2m_ctx_release(ctx->m2m_ctx);*/
err_m2m_ctx_init:
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
err_ctrls_setup:
@@ -147,11 +147,6 @@ static int aml_vcodec_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&dev->ctx_list);
dev->plat_dev = pdev;
if (ret < 0) {
dev_err(&pdev->dev, "Failed to get mt vcodec clock source");
return ret;
}
mutex_init(&dev->dec_mutex);
mutex_init(&dev->dev_mutex);
spin_lock_init(&dev->irqlock);

View File

@@ -275,9 +275,9 @@ static int vdec_h264_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec)
//vpu_dec_deinit(&inst->vpu);
//error_free_inst:
kfree(inst->vsi);
/*kfree(inst->vsi);
kfree(inst);
return err;
return err;*/
}
static int refer_buffer_num(int level_idc, int poc_cnt,
@@ -422,7 +422,8 @@ static int vdec_h264_probe(unsigned long h_vdec,
(struct vdec_h264_inst *)h_vdec;
struct h264_stream_t s;
struct h264_SPS_t *sps;
unsigned int nal_type, nal_idx;
unsigned int nal_type;
int nal_idx;
int real_data_pos, real_data_size;
unsigned char *buf = (unsigned char *)bs->va;
unsigned int size = bs->size;
@@ -440,7 +441,7 @@ static int vdec_h264_probe(unsigned long h_vdec,
real_data_size = size - real_data_pos;
sps = kzalloc(sizeof(struct h264_SPS_t), GFP_KERNEL);
if (IS_ERR_OR_NULL(sps))
if (sps == NULL)
return -ENOMEM;
h264_stream_set(&s, &buf[real_data_pos], real_data_size);
@@ -599,8 +600,8 @@ static int vdec_h264_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
}
//err = vpu_dec_start(vpu, data, 2);
if (err)
goto err_free_fb_out;
/*if (err)
goto err_free_fb_out;*/
#if 0
*res_chg = inst->vsi->dec.resolution_changed;
@@ -620,8 +621,8 @@ static int vdec_h264_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs,
if (nal_type == NAL_NON_IDR_SLICE || nal_type == NAL_IDR_SLICE) {
/* wait decoder done interrupt */
//err = aml_vcodec_wait_for_done_ctx(inst->ctx, aml_INST_IRQ_RECEIVED, WAIT_INTR_TIMEOUT_MS);
if (err)
goto err_free_fb_out;
/*if (err)
goto err_free_fb_out;*/
//vpu_dec_end(vpu);
}

View File

@@ -86,7 +86,7 @@ static bool get_cpu_id_from_dtb(enum AM_MESON_CPU_MAJOR_ID *pidType)
}
pDev = of_find_device_by_node(pNode);
if (NULL == pNode)
if (NULL == pDev)
{
return -EINVAL;
}

View File

@@ -120,7 +120,7 @@ int get_data_from_name(const char *name, char *buf)
struct fw_info_s *info;
char *fw_name = __getname();
if (IS_ERR_OR_NULL(fw_name))
if (fw_name == NULL)
return -ENOMEM;
strcat(fw_name, name);
@@ -394,7 +394,7 @@ static int fw_info_fill(void)
char *path = __getname();
const char *name;
if (IS_ERR_OR_NULL(path))
if (path == NULL)
return -ENOMEM;
for (i = 0; i < info_size; i++) {
@@ -408,7 +408,7 @@ static int fw_info_fill(void)
continue;
files = kzalloc(sizeof(struct fw_files_s), GFP_KERNEL);
if (IS_ERR_OR_NULL(files)) {
if (files == NULL) {
__putname(path);
return -ENOMEM;
}
@@ -416,7 +416,9 @@ static int fw_info_fill(void)
files->file_type = ucode_info[i].file_type;
files->fw_type = ucode_info[i].fw_type;
strncpy(files->path, path, sizeof(files->path));
files->path[sizeof(files->path) - 1] = '\0';
strncpy(files->name, name, sizeof(files->name));
files->name[sizeof(files->name) - 1] = '\0';
list_add(&files->node, &mgr->files_head);
}
@@ -497,9 +499,13 @@ static int fw_check_pack_version(char *buf)
{
struct package_s *pack = NULL;
int major, minor, rev, ver = 0;
int ret;
pack = (struct package_s *) buf;
sscanf(PACK_VERS, "v%x.%x.%x", &major, &minor, &rev);
ret = sscanf(PACK_VERS, "v%x.%x.%x", &major, &minor, &rev);
if (ret != 3)
return -1;
ver = (major << 24 | minor << 16 | rev);
pr_info("the package has %d fws totally.\n", pack->head.total);
@@ -534,7 +540,7 @@ static int fw_package_parse(struct fw_files_s *files,
int try_cnt = 100;
char *path = __getname();
if (IS_ERR_OR_NULL(path))
if (path == NULL)
return -ENOMEM;
pack_data = ((struct package_s *)buf)->data;
@@ -551,13 +557,13 @@ static int fw_package_parse(struct fw_files_s *files,
continue;
info = kzalloc(sizeof(struct fw_info_s), GFP_KERNEL);
if (IS_ERR_OR_NULL(info)) {
if (info == NULL) {
ret = -ENOMEM;
goto out;
}
data = kzalloc(FRIMWARE_SIZE, GFP_KERNEL);
if (IS_ERR_OR_NULL(data)) {
if (data == NULL) {
kfree(info);
ret = -ENOMEM;
goto out;
@@ -566,8 +572,10 @@ static int fw_package_parse(struct fw_files_s *files,
info->file_type = files->file_type;
strncpy(info->src_from, files->name,
sizeof(info->src_from));
info->src_from[sizeof(info->src_from) - 1] = '\0';
strncpy(info->name, pack_info->head.name,
sizeof(info->name));
info->name[sizeof(info->name) - 1] = '\0';
info->format = get_fw_format(pack_info->head.format);
len = pack_info->head.length;
@@ -604,21 +612,25 @@ static int fw_code_parse(struct fw_files_s *files,
struct fw_info_s *info;
info = kzalloc(sizeof(struct fw_info_s), GFP_KERNEL);
if (IS_ERR_OR_NULL(info))
if (info == NULL)
return -ENOMEM;
info->data = kzalloc(FRIMWARE_SIZE, GFP_KERNEL);
if (IS_ERR_OR_NULL(info->data))
if (info->data == NULL) {
kfree(info);
return -ENOMEM;
}
info->file_type = files->file_type;
strncpy(info->src_from, files->name,
sizeof(info->src_from));
info->src_from[sizeof(info->src_from) - 1] = '\0';
memcpy(info->data, buf, size);
if (!fw_data_check_sum(info->data)) {
pr_info("check sum fail !\n");
kfree(info->data);
kfree(info);
return -1;
}

View File

@@ -418,7 +418,7 @@ static void vavs_isr(void)
u32 picture_type;
u32 buffer_index;
unsigned int pts, pts_valid = 0, offset;
unsigned int pts, pts_valid = 0, offset = 0;
u64 pts_us64;
if (debug_flag & AVS_DEBUG_UCODE) {
if (READ_VREG(AV_SCRATCH_E) != 0) {

View File

@@ -3579,7 +3579,7 @@ static struct vframe_s *vavs2_vf_get(void *op_arg)
if (kfifo_get(&dec->display_q, &vf)) {
uint8_t index = vf->index & 0xff;
if (index >= 0 && index < dec->used_buf_num) {
if (index < dec->used_buf_num) {
struct avs2_frame_s *pic = get_pic_by_index(dec, index);
dec->vf_get_count++;
avs2_print(dec, AVS2_DBG_BUFMGR,
@@ -3612,8 +3612,7 @@ static void vavs2_vf_put(struct vframe_s *vf, void *op_arg)
__func__, vf->index,
dec->vf_put_count);
if (index >= 0
&& index < dec->used_buf_num) {
if (index < dec->used_buf_num) {
unsigned long flags;
struct avs2_frame_s *pic;
@@ -5387,16 +5386,16 @@ static void run(struct vdec_s *vdec, unsigned long mask,
dec->frame_count, r,
dec->chunk ? dec->chunk->size : 0,
dec->chunk ? dec->chunk->offset : 0,
(vdec_frame_based(vdec) &&
dec->chunk ? ((vdec_frame_based(vdec) &&
(debug & PRINT_FLAG_VDEC_STATUS)) ?
get_data_check_sum(dec, r) : 0,
get_data_check_sum(dec, r) : 0) : 0,
READ_VREG(HEVC_STREAM_START_ADDR),
READ_VREG(HEVC_STREAM_END_ADDR),
READ_VREG(HEVC_STREAM_LEVEL),
READ_VREG(HEVC_STREAM_WR_PTR),
READ_VREG(HEVC_STREAM_RD_PTR),
dec->start_shift_bytes);
if (vdec_frame_based(vdec)) {
if (vdec_frame_based(vdec) && dec->chunk) {
u8 *data = ((u8 *)dec->chunk->block->start_virt) +
dec->chunk->offset;
avs2_print_cont(dec, 0, "data adr %p:",
@@ -5431,7 +5430,7 @@ static void run(struct vdec_s *vdec, unsigned long mask,
WRITE_VREG(HEVC_DEC_STATUS_REG, AVS2_ACTION_DONE);
if (vdec_frame_based(vdec)) {
if (vdec_frame_based(vdec) && dec->chunk) {
if (debug & PRINT_FLAG_VDEC_DATA)
dump_data(dec, dec->chunk->size);
@@ -5677,7 +5676,7 @@ static int ammvdec_avs2_probe(struct platform_device *pdev)
dec->stat |= VP9_TRIGGER_FRAME_ENABLE;
#if 1
if ((debug & IGNORE_PARAM_FROM_CONFIG) == 0 &&
pdata->config && pdata->config_len) {
pdata->config_len) {
/*use ptr config for doubel_write_mode, etc*/
avs2_print(dec, 0, "pdata->config=%s\n", pdata->config);
if (get_config_int(pdata->config, "avs2_double_write_mode",
@@ -5761,13 +5760,6 @@ static int ammvdec_avs2_probe(struct platform_device *pdev)
dec->init_flag = 0;
dec->fatal_error = 0;
dec->show_frame_num = 0;
if (pdata == NULL) {
pr_info("\namvdec_avs2 memory resource undefined.\n");
uninit_mmu_buffers(dec);
/* devm_kfree(&pdev->dev, (void *)dec); */
vfree((void *)dec);
return -EFAULT;
}
if (debug) {
pr_info("===AVS2 decoder mem resource 0x%lx size 0x%x\n",

View File

@@ -768,6 +768,7 @@ static void userdata_push_do_work(struct work_struct *work)
unsigned int sei_itu35_data_length;
struct userdata_poc_info_t user_data_poc;
memset(&user_data_poc, 0x0, sizeof(struct userdata_poc_info_t));
sei_itu35_flags = READ_VREG(AV_SCRATCH_J);
sei_itu35_wp = (sei_itu35_flags >> 16) & 0xffff;
sei_itu35_data_length = sei_itu35_flags & 0x7fff;
@@ -955,7 +956,8 @@ static void vh264_set_params(struct work_struct *work)
if (!mb_width && mb_total)
mb_width = 256;
}
mb_height = mb_total / mb_width;
if (mb_width)
mb_height = mb_total / mb_width;
last_duration = 0;
/* AV_SCRATCH_2
* bit 15: frame_mbs_only_flag
@@ -2208,7 +2210,7 @@ static void vh264_put_timer_func(unsigned long arg)
struct vframe_s *vf;
if (kfifo_get(&recycle_q, &vf)) {
if ((vf->index >= 0) && (vf->index < VF_BUF_NUM)) {
if (vf->index < VF_BUF_NUM) {
if (--vfbuf_use[vf->index] == 0) {
if (READ_VREG(AV_SCRATCH_7) == 0) {
WRITE_VREG(AV_SCRATCH_7,
@@ -2231,8 +2233,7 @@ static void vh264_put_timer_func(unsigned long arg)
struct vframe_s *vf;
if (kfifo_get(&recycle_q, &vf)) {
if ((vf->index >= 0 &&
(vf->index < VF_BUF_NUM))) {
if (vf->index < VF_BUF_NUM) {
vf->index = VF_BUF_NUM;
kfifo_put(&newframe_q,
(const struct vframe_s *)vf);

View File

@@ -476,15 +476,14 @@ static struct vframe_s *vh264mvc_vf_get(void *op_arg)
INCPTR(get_ptr);
if (vf) {
if (frame_width == 0)
frame_width = vh264mvc_amstream_dec_info.width;
if (frame_height == 0)
frame_height = vh264mvc_amstream_dec_info.height;
if (frame_width == 0)
frame_width = vh264mvc_amstream_dec_info.width;
if (frame_height == 0)
frame_height = vh264mvc_amstream_dec_info.height;
vf->width = frame_width;
vf->height = frame_height;
vf->width = frame_width;
vf->height = frame_height;
}
if ((no_dropping_cnt < DROPPING_FIRST_WAIT) && (vf->frame_dirty == 0))
no_dropping_cnt++;
return vf;
@@ -1405,7 +1404,7 @@ static s32 vh264mvc_init(void)
int ret = -1, size = -1;
char *buf = vmalloc(0x1000 * 16);
if (IS_ERR_OR_NULL(buf))
if (buf == NULL)
return -ENOMEM;
pr_info("\nvh264mvc_init\n");
@@ -1414,12 +1413,16 @@ static s32 vh264mvc_init(void)
stat |= STAT_TIMER_INIT;
ret = vh264mvc_vdec_info_init();
if (0 != ret)
if (0 != ret) {
vfree(buf);
return -ret;
}
ret = vh264mvc_local_init();
if (ret < 0)
if (ret < 0) {
vfree(buf);
return ret;
}
amvdec_enable();
@@ -1428,6 +1431,7 @@ static s32 vh264mvc_init(void)
ret = tee_load_video_fw((u32)VIDEO_DEC_H264_MVC, 0);
if (ret != 0) {
amvdec_disable();
vfree(buf);
return -1;
}
} else {
@@ -1459,8 +1463,6 @@ static s32 vh264mvc_init(void)
/*slice*/
memcpy((u8 *) mc_cpu_addr + 0x3000, buf + 0x4000, 0x3000);
vfree(buf);
if (ret < 0) {
amvdec_disable();
@@ -1471,6 +1473,8 @@ static s32 vh264mvc_init(void)
return -EBUSY;
}
}
vfree(buf);
stat |= STAT_MC_LOAD;
/* enable AMRISC side protocol */

View File

@@ -1464,26 +1464,28 @@ static void dpb_combine_field(struct h264_dpb_stru *p_H264_Dpb,
fs->frame->data_flag |= (fs->bottom_field->data_flag & 0xf0);
#endif
if (fs->bottom_field) {
fs->poc = fs->frame->poc = fs->frame->frame_poc = imin(
fs->top_field->poc, fs->bottom_field->poc);
fs->poc = fs->frame->poc = fs->frame->frame_poc = imin(
fs->top_field->poc, fs->bottom_field->poc);
fs->bottom_field->frame_poc = fs->top_field->frame_poc = fs->frame->poc;
fs->bottom_field->frame_poc = fs->top_field->frame_poc = fs->frame->poc;
fs->bottom_field->top_poc = fs->frame->top_poc = fs->top_field->poc;
fs->top_field->bottom_poc = fs->frame->bottom_poc =
fs->bottom_field->poc;
fs->bottom_field->top_poc = fs->frame->top_poc = fs->top_field->poc;
fs->top_field->bottom_poc = fs->frame->bottom_poc =
fs->bottom_field->poc;
fs->frame->used_for_reference = (fs->top_field->used_for_reference &&
fs->bottom_field->used_for_reference);
fs->frame->is_long_term = (fs->top_field->is_long_term &&
fs->bottom_field->is_long_term);
fs->frame->used_for_reference = (fs->top_field->used_for_reference &&
fs->bottom_field->used_for_reference);
fs->frame->is_long_term = (fs->top_field->is_long_term &&
fs->bottom_field->is_long_term);
}
if (fs->frame->is_long_term)
fs->frame->long_term_frame_idx = fs->long_term_frame_idx;
fs->frame->top_field = fs->top_field;
fs->frame->bottom_field = fs->bottom_field;
if (fs->bottom_field)
fs->frame->bottom_field = fs->bottom_field;
fs->frame->frame = fs->frame;
fs->frame->coded_frame = 0;
@@ -1500,12 +1502,13 @@ static void dpb_combine_field(struct h264_dpb_stru *p_H264_Dpb,
fs->frame->frame_crop_right_offset =
fs->top_field->frame_crop_right_offset;
}
fs->top_field->frame = fs->bottom_field->frame = fs->frame;
fs->top_field->top_field = fs->top_field;
fs->top_field->bottom_field = fs->bottom_field;
fs->bottom_field->top_field = fs->top_field;
fs->bottom_field->bottom_field = fs->bottom_field;
if (fs->bottom_field) {
fs->top_field->frame = fs->bottom_field->frame = fs->frame;
fs->top_field->top_field = fs->top_field;
fs->top_field->bottom_field = fs->bottom_field;
fs->bottom_field->top_field = fs->top_field;
fs->bottom_field->bottom_field = fs->bottom_field;
}
/**/
#if (MVC_EXTENSION_ENABLE)
@@ -2829,12 +2832,12 @@ static void unmark1(struct DecodedPictureBuffer *p_Dpb,
unsigned int curr_frame_num, int i)
{
if (p_Dpb->last_picture) {
if ((p_Dpb->last_picture != p_Dpb->fs_ltref[i]) ||
p_Dpb->last_picture->frame_num != curr_frame_num) {
/*if ((p_Dpb->last_picture != p_Dpb->fs_ltref[i]) ||
p_Dpb->last_picture->frame_num != curr_frame_num) {*/
unmark_for_long_term_reference(p_Dpb->fs_ltref[i]);
} else {
/*} else {
unmark_for_long_term_reference(p_Dpb->fs_ltref[i]);
}
}*/
}
}

View File

@@ -1765,7 +1765,7 @@ int release_buf_spec_num(struct vdec_s *vdec, int buf_spec_num)
dpb_print(DECODE_ID(hw), PRINT_FLAG_MMU_DETAIL,
"%s buf_spec_num %d used %d\n",
__func__, buf_spec_num,
hw->buffer_spec[buf_spec_num].used);
buf_spec_num > 0 ? hw->buffer_spec[buf_spec_num].used : 0);
if (buf_spec_num >= 0 &&
buf_spec_num < BUFSPEC_POOL_SIZE
) {
@@ -3436,7 +3436,8 @@ static void vh264_config_canvs_for_mmu(struct vdec_h264_hw_s *hw)
if (hw->decode_pic_count == 0) {
for (j = 0; j < hw->dpb.mDPB.size; j++) {
i = get_buf_spec_by_canvas_pos(hw, j);
config_decode_canvas_ex(hw, i);
if (i >= 0)
config_decode_canvas_ex(hw, i);
}
}
mutex_unlock(&vmh264_mutex);
@@ -3449,7 +3450,7 @@ static int vh264_set_params(struct vdec_h264_hw_s *hw,
int i, j;
int mb_width, mb_total;
int max_reference_size, level_idc;
int mb_height;
int mb_height = 0;
unsigned long flags;
/*int mb_mv_byte;*/
struct vdec_s *vdec = hw_to_vdec(hw);
@@ -3474,7 +3475,8 @@ static int vh264_set_params(struct vdec_h264_hw_s *hw,
mb_total = (seq_info2 >> 8) & 0xffff;
if (!mb_width && mb_total) /*for 4k2k*/
mb_width = 256;
mb_height = mb_total/mb_width;
if (mb_width)
mb_height = mb_total/mb_width;
if (mb_width > 0x110 ||
mb_height > 0xa0 ||
mb_width <= 0 ||
@@ -3623,11 +3625,13 @@ static int vh264_set_params(struct vdec_h264_hw_s *hw,
i = get_buf_spec_by_canvas_pos(hw, 0);
if (hw->is_used_v4l) {
ret = alloc_one_buf_spec_from_queue(hw, i);
if (!ret)
config_decode_canvas(hw, i);
if (i != -1) {
ret = alloc_one_buf_spec_from_queue(hw, i);
if (!ret)
config_decode_canvas(hw, i);
}
} else {
if (alloc_one_buf_spec(hw, i) >= 0)
if ((i != -1) && alloc_one_buf_spec(hw, i) >= 0)
config_decode_canvas(hw, i);
else
ret = -1;
@@ -4764,11 +4768,9 @@ static irqreturn_t vh264_isr(struct vdec_s *vdec, int irq)
WRITE_VREG(ASSIST_MBOX1_CLR_REG, 1);
if (!hw) {
dpb_print(DECODE_ID(hw), PRINT_FLAG_ERROR,
"decoder is not running\n");
if (!hw)
return IRQ_HANDLED;
}
if (hw->eos)
return IRQ_HANDLED;
@@ -7076,7 +7078,7 @@ static int ammvdec_h264_probe(struct platform_device *pdev)
}
if (hw->mmu_enable) {
if (pdata->config && pdata->config_len) {
if (pdata->config_len) {
/*use ptr config for doubel_write_mode, etc*/
if (get_config_int(pdata->config,
"mh264_double_write_mode", &config_val) == 0)

View File

@@ -1692,7 +1692,7 @@ static unsigned char is_skip_decoding(struct hevc_state_s *hevc,
static int get_pic_poc(struct hevc_state_s *hevc,
unsigned int idx)
{
if (idx != 0xff && idx >= 0
if (idx != 0xff
&& idx < MAX_REF_PIC_NUM
&& hevc->m_PIC[idx])
return hevc->m_PIC[idx]->POC;
@@ -6564,7 +6564,7 @@ static void vh265_vf_put(struct vframe_s *vf, void *op_arg)
kfifo_put(&hevc->newframe_q, (const struct vframe_s *)vf);
spin_lock_irqsave(&lock, flags);
if (index_top != 0xff && index_top >= 0
if (index_top != 0xff
&& index_top < MAX_REF_PIC_NUM
&& hevc->m_PIC[index_top]) {
if (hevc->m_PIC[index_top]->vf_ref > 0) {
@@ -6580,7 +6580,7 @@ static void vh265_vf_put(struct vframe_s *vf, void *op_arg)
}
}
if (index_bot != 0xff && index_bot >= 0
if (index_bot != 0xff
&& index_bot < MAX_REF_PIC_NUM
&& hevc->m_PIC[index_bot]) {
if (hevc->m_PIC[index_bot]->vf_ref > 0) {
@@ -6632,7 +6632,7 @@ static int vh265_event_cb(int type, void *data, void *op_arg)
req->aux_size = 0;
if (req->bot_flag)
index = (req->vf->index >> 8) & 0xff;
if (index != 0xff && index >= 0
if (index != 0xff
&& index < MAX_REF_PIC_NUM
&& hevc->m_PIC[index]) {
req->aux_buf = hevc->m_PIC[index]->aux_data_buf;
@@ -10549,15 +10549,7 @@ static int ammvdec_h265_probe(struct platform_device *pdev)
hevc->uninit_list = 0;
hevc->fatal_error = 0;
hevc->show_frame_num = 0;
if (pdata == NULL) {
hevc_print(hevc, 0,
"\namvdec_h265 memory resource undefined.\n");
uninit_mmu_buffers(hevc);
/* devm_kfree(&pdev->dev, (void *)hevc); */
if (hevc)
vfree((void *)hevc);
return -EFAULT;
}
/*
*hevc->mc_buf_spec.buf_end = pdata->mem_end + 1;
*for (i = 0; i < WORK_BUF_SPEC_NUM; i++)
@@ -10607,6 +10599,9 @@ static int ammvdec_h265_remove(struct platform_device *pdev)
(struct hevc_state_s *)
(((struct vdec_s *)(platform_get_drvdata(pdev)))->private);
if (hevc == NULL)
return 0;
if (get_dbg_flag(hevc))
hevc_print(hevc, 0, "%s\r\n", __func__);
@@ -10617,8 +10612,8 @@ static int ammvdec_h265_remove(struct platform_device *pdev)
vdec_core_release(hw_to_vdec(hevc), CORE_MASK_HEVC);
vdec_set_status(hw_to_vdec(hevc), VDEC_STATUS_DISCONNECTED);
if (hevc)
vfree((void *)hevc);
vfree((void *)hevc);
return 0;
}

View File

@@ -398,8 +398,7 @@ static void vmjpeg_put_timer_func(unsigned long arg)
struct vframe_s *vf;
if (kfifo_get(&recycle_q, &vf)) {
if ((vf->index >= 0)
&& (vf->index < DECODE_BUFFER_NUM_MAX)
if ((vf->index < DECODE_BUFFER_NUM_MAX)
&& (--vfbuf_use[vf->index] == 0)) {
WRITE_VREG(MREG_TO_AMRISC, vf->index + 1);
vf->index = DECODE_BUFFER_NUM_MAX;

View File

@@ -758,7 +758,7 @@ static void userdata_push_do_work(struct work_struct *work)
}
if (p_userdata_mgr) {
if (p_userdata_mgr && ccbuf_phyAddress_virt) {
int new_wp;
new_wp = reg & 0xffff;

View File

@@ -715,8 +715,7 @@ static void vmpeg_put_timer_func(unsigned long arg)
struct vframe_s *vf;
if (kfifo_get(&recycle_q, &vf)) {
if ((vf->index >= 0)
&& (vf->index < DECODE_BUFFER_NUM_MAX)
if ((vf->index < DECODE_BUFFER_NUM_MAX)
&& (--vfbuf_use[vf->index] == 0)) {
WRITE_VREG(MREG_BUFFERIN, ~(1 << vf->index));
vf->index = DECODE_BUFFER_NUM_MAX;

View File

@@ -443,7 +443,7 @@ static irqreturn_t vmpeg4_isr(struct vdec_s *vdec, int irq)
if (duration == hw->last_duration) {
hw->rate_detect++;
if (hw->rate_detect >= RATE_DETECT_COUNT) {
if ((hw->rate_detect >= RATE_DETECT_COUNT) && (time_increment_resolution != 0)) {
hw->vmpeg4_amstream_dec_info.rate =
duration * DURATION_UNIT /
time_increment_resolution;

View File

@@ -499,7 +499,7 @@ static void vreal_put_timer_func(unsigned long arg)
struct vframe_s *vf;
if (kfifo_get(&recycle_q, &vf)) {
if ((vf->index >= 0) && (vf->index < VF_BUF_NUM)
if ((vf->index < VF_BUF_NUM)
&& (--vfbuf_use[vf->index] == 0)) {
WRITE_VREG(TO_AMRISC, ~(1 << vf->index));
vf->index = VF_BUF_NUM;

View File

@@ -312,6 +312,7 @@ static s32 am_loadmc_ex(enum vformat_e type,
err = (*load)((u32 *) pmc_addr);
if (err < 0) {
pr_err("loading firmware %s to vdec ram failed!\n", name);
vfree(mc_addr);
return err;
}
vfree(mc_addr);

View File

@@ -173,7 +173,7 @@ int decoder_bmmu_box_free_idx(void *handle, int idx)
if (!box || idx < 0 || idx >= box->max_mm_num) {
pr_err("can't free idx of box(%p),idx:%d in (%d-%d)\n",
box, idx, 0,
box->max_mm_num - 1);
box ? (box->max_mm_num - 1) : 0);
return -1;
}
mutex_lock(&box->mutex);
@@ -357,7 +357,7 @@ static int decoder_bmmu_box_dump(struct decoder_bmmu_box *box, void *buf,
int i;
if (!buf) {
pbuf = sbuf;
size = 100000;
size = 512;
}
#define BUFPRINT(args...) \
do {\
@@ -401,7 +401,7 @@ static int decoder_bmmu_box_dump_all(void *buf, int size)
struct list_head *head, *list;
if (!buf) {
pbuf = sbuf;
size = 100000;
size = 512;
}
#define BUFPRINT(args...) \
do {\

View File

@@ -170,7 +170,7 @@ int decoder_mmu_box_free_idx_tail(
if (!box || idx < 0 || idx >= box->max_sc_num) {
pr_err("can't free tail mmu box(%p),idx:%d in (%d-%d)\n",
box, idx, 0,
box->max_sc_num - 1);
box ? (box->max_sc_num - 1) : 0);
return -1;
}
mutex_lock(&box->mutex);
@@ -191,7 +191,7 @@ int decoder_mmu_box_free_idx(void *handle, int idx)
if (!box || idx < 0 || idx >= box->max_sc_num) {
pr_err("can't free idx of box(%p),idx:%d in (%d-%d)\n",
box, idx, 0,
box->max_sc_num - 1);
box ? (box->max_sc_num - 1) : 0);
return -1;
}
mutex_lock(&box->mutex);
@@ -251,7 +251,7 @@ static int decoder_mmu_box_dump(struct decoder_mmu_box *box,
if (!buf) {
pbuf = sbuf;
size = 100000;
size = 512;
}
#define BUFPRINT(args...) \
do {\
@@ -288,7 +288,7 @@ static int decoder_mmu_box_dump_all(void *buf, int size)
if (!pbuf) {
pbuf = sbuf;
size = 100000;
size = 512;
}
#define BUFPRINT(args...) \

View File

@@ -187,6 +187,7 @@ static int get_canvas(unsigned int index, unsigned int base)
{
int start;
int canvas_index = index * base;
int ret;
if ((base > 4) || (base == 0))
return -1;
@@ -204,17 +205,17 @@ static int get_canvas(unsigned int index, unsigned int base)
}
if (base == 1) {
return start;
ret = start;
} else if (base == 2) {
return ((start + 1) << 16) | ((start + 1) << 8) | start;
ret = ((start + 1) << 16) | ((start + 1) << 8) | start;
} else if (base == 3) {
return ((start + 2) << 16) | ((start + 1) << 8) | start;
ret = ((start + 2) << 16) | ((start + 1) << 8) | start;
} else if (base == 4) {
return (((start + 3) << 24) | (start + 2) << 16) |
ret = (((start + 3) << 24) | (start + 2) << 16) |
((start + 1) << 8) | start;
}
return -1;
return ret;
}
@@ -1696,14 +1697,14 @@ void vdec_release(struct vdec_s *vdec)
schedule();
platform_device_unregister(vdec->dev);
pr_debug("vdec_release instance %p, total %d\n", vdec,
atomic_read(&vdec_core->vdec_nr));
vdec_destroy(vdec);
mutex_lock(&vdec_mutex);
inited_vcodec_num--;
mutex_unlock(&vdec_mutex);
pr_debug("vdec_release instance %p, total %d\n", vdec,
atomic_read(&vdec_core->vdec_nr));
}
EXPORT_SYMBOL(vdec_release);
@@ -1754,10 +1755,10 @@ void vdec_free_cmabuf(void)
{
mutex_lock(&vdec_mutex);
if (inited_vcodec_num > 0) {
/*if (inited_vcodec_num > 0) {
mutex_unlock(&vdec_mutex);
return;
}
}*/
mutex_unlock(&vdec_mutex);
}
@@ -1783,7 +1784,7 @@ int vdec_core_release(struct vdec_s *vdec, unsigned long mask)
}
EXPORT_SYMBOL(vdec_core_release);
const bool vdec_core_with_input(unsigned long mask)
bool vdec_core_with_input(unsigned long mask)
{
enum vdec_type_e type;

View File

@@ -397,7 +397,7 @@ extern int vdec_core_request(struct vdec_s *vdec, unsigned long mask);
extern int vdec_core_release(struct vdec_s *vdec, unsigned long mask);
extern const bool vdec_core_with_input(unsigned long mask);
extern bool vdec_core_with_input(unsigned long mask);
extern void vdec_core_finish_run(struct vdec_s *vdec, unsigned long mask);

View File

@@ -273,7 +273,7 @@ static irqreturn_t vvc1_isr(int irq, void *dev_id)
u32 repeat_count;
u32 picture_type;
u32 buffer_index;
unsigned int pts, pts_valid = 0, offset;
unsigned int pts, pts_valid = 0, offset = 0;
u32 v_width, v_height;
u64 pts_us64 = 0;

View File

@@ -6284,7 +6284,7 @@ static struct vframe_s *vvp9_vf_get(void *op_arg)
if (kfifo_get(&pbi->display_q, &vf)) {
struct vframe_s *next_vf;
uint8_t index = vf->index & 0xff;
if (index >= 0 && index < pbi->used_buf_num) {
if (index < pbi->used_buf_num) {
pbi->vf_get_count++;
if (debug & VP9_DEBUG_BUFMGR)
pr_info("%s type 0x%x w/h %d/%d, pts %d, %lld\n",
@@ -6312,8 +6312,7 @@ static void vvp9_vf_put(struct vframe_s *vf, void *op_arg)
kfifo_put(&pbi->newframe_q, (const struct vframe_s *)vf);
pbi->vf_put_count++;
if (index >= 0
&& index < pbi->used_buf_num) {
if (index < pbi->used_buf_num) {
struct VP9_Common_s *cm = &pbi->common;
struct BufferPool_s *pool = cm->buffer_pool;
unsigned long flags;
@@ -8654,16 +8653,16 @@ static void run_front(struct vdec_s *vdec)
pbi->frame_count, size,
pbi->chunk ? pbi->chunk->size : 0,
pbi->chunk ? pbi->chunk->offset : 0,
(vdec_frame_based(vdec) &&
pbi->chunk ? ((vdec_frame_based(vdec) &&
(debug & PRINT_FLAG_VDEC_STATUS)) ?
get_data_check_sum(pbi, size) : 0,
get_data_check_sum(pbi, size) : 0) : 0,
READ_VREG(HEVC_STREAM_START_ADDR),
READ_VREG(HEVC_STREAM_END_ADDR),
READ_VREG(HEVC_STREAM_LEVEL),
READ_VREG(HEVC_STREAM_WR_PTR),
READ_VREG(HEVC_STREAM_RD_PTR),
pbi->start_shift_bytes);
if (vdec_frame_based(vdec)) {
if (vdec_frame_based(vdec) && pbi->chunk) {
u8 *data = ((u8 *)pbi->chunk->block->start_virt) +
pbi->chunk->offset;
vp9_print_cont(pbi, 0, "data adr %p:",
@@ -9103,7 +9102,7 @@ static int ammvdec_vp9_probe(struct platform_device *pdev)
pbi->stat |= VP9_TRIGGER_FRAME_ENABLE;
#if 1
if ((debug & IGNORE_PARAM_FROM_CONFIG) == 0 &&
pdata->config && pdata->config_len) {
pdata->config_len) {
#ifdef MULTI_INSTANCE_SUPPORT
/*use ptr config for doubel_write_mode, etc*/
vp9_print(pbi, 0, "pdata->config=%s\n", pdata->config);
@@ -9199,13 +9198,6 @@ static int ammvdec_vp9_probe(struct platform_device *pdev)
pbi->init_flag = 0;
pbi->fatal_error = 0;
pbi->show_frame_num = 0;
if (pdata == NULL) {
pr_info("\namvdec_vp9 memory resource undefined.\n");
uninit_mmu_buffers(pbi);
/* devm_kfree(&pdev->dev, (void *)pbi); */
vfree((void *)pbi);
return -EFAULT;
}
if (debug) {
pr_info("===VP9 decoder mem resource 0x%lx size 0x%x\n",

View File

@@ -224,7 +224,7 @@ s32 adec_init(struct stream_port_s *port)
astream_dev->datawidth = port->adatawidth;
/*wmb();don't need it...*/
if (af <= ARRAY_SIZE(astream_format))
if (af < ARRAY_SIZE(astream_format))
astream_dev->format = astream_format[af];
else
astream_dev->format = NULL;
@@ -250,7 +250,7 @@ int amstream_adec_show_fun(const char *trigger, int id, char *sbuf, int size)
int ret = -1;
void *buf, *getbuf = NULL;
if (size < PAGE_SIZE) {
void *getbuf = (void *)__get_free_page(GFP_KERNEL);
getbuf = (void *)__get_free_page(GFP_KERNEL);
if (!getbuf)
return -ENOMEM;
buf = getbuf;
@@ -277,7 +277,7 @@ int amstream_adec_show_fun(const char *trigger, int id, char *sbuf, int size)
ret = -1;
}
if (ret > 0 && getbuf != NULL) {
int ret = min_t(int, ret, size);
ret = min_t(int, ret, size);
strncpy(sbuf, buf, ret);
}
if (getbuf != NULL)

View File

@@ -1266,8 +1266,7 @@ static ssize_t amstream_sub_read(struct file *file, char __user *buf,
res = copy_to_user((void *)buf,
(void *)(codec_mm_phys_to_virt(sub_rp)),
data_size);
if (res >= 0)
stbuf_sub_rp_set(sub_rp + data_size - res);
stbuf_sub_rp_set(sub_rp + data_size - res);
return data_size - res;
} else {
@@ -1275,10 +1274,8 @@ static ssize_t amstream_sub_read(struct file *file, char __user *buf,
res = copy_to_user((void *)buf,
(void *)(codec_mm_phys_to_virt(sub_rp)),
first_num);
if (res >= 0) {
stbuf_sub_rp_set(sub_rp + first_num -
res);
}
stbuf_sub_rp_set(sub_rp + first_num -
res);
return first_num - res;
}
@@ -1287,10 +1284,8 @@ static ssize_t amstream_sub_read(struct file *file, char __user *buf,
(void *)(codec_mm_phys_to_virt(sub_start)),
data_size - first_num);
if (res >= 0) {
stbuf_sub_rp_set(sub_start + data_size -
first_num - res);
}
stbuf_sub_rp_set(sub_start + data_size -
first_num - res);
return data_size - first_num - res;
}
@@ -1300,8 +1295,7 @@ static ssize_t amstream_sub_read(struct file *file, char __user *buf,
(void *)(codec_mm_phys_to_virt(sub_rp)),
data_size);
if (res >= 0)
stbuf_sub_rp_set(sub_rp + data_size - res);
stbuf_sub_rp_set(sub_rp + data_size - res);
return data_size - res;
}
@@ -1987,7 +1981,7 @@ static long amstream_ioctl_set(struct port_priv_s *priv, ulong arg)
parm.data_32,
false);
}
r = stbuf_change_size(
r += stbuf_change_size(
&bufs[BUF_TYPE_VIDEO],
parm.data_32,
false);
@@ -2177,10 +2171,7 @@ static long amstream_ioctl_set(struct port_priv_s *priv, ulong arg)
tsync_set_dec_reset();
break;
case AMSTREAM_SET_TS_SKIPBYTE:
if (parm.data_32 >= 0)
tsdemux_set_skipbyte(parm.data_32);
else
r = -EINVAL;
tsdemux_set_skipbyte(parm.data_32);
break;
case AMSTREAM_SET_SUB_TYPE:
sub_type = parm.data_32;
@@ -2282,11 +2273,6 @@ static long amstream_ioctl_get_ex(struct port_priv_s *priv, ulong arg)
&bufs[BUF_TYPE_HEVC] :
&bufs[BUF_TYPE_VIDEO];
if (p == NULL) {
r = -EINVAL;
break;
}
if (this->type & PORT_TYPE_FRAME) {
struct vdec_input_status_s status;
@@ -2323,8 +2309,6 @@ static long amstream_ioctl_get_ex(struct port_priv_s *priv, ulong arg)
struct am_ioctl_parm_ex *p = &parm;
struct stream_buf_s *buf = &bufs[BUF_TYPE_AUDIO];
if (p == NULL)
r = -EINVAL;
p->status.size = stbuf_canusesize(buf);
p->status.data_len = stbuf_level(buf);
@@ -2342,8 +2326,6 @@ static long amstream_ioctl_get_ex(struct port_priv_s *priv, ulong arg)
struct vdec_info vstatus;
struct am_ioctl_parm_ex *p = &parm;
if (p == NULL)
return -EINVAL;
if (vdec_status(priv->vdec, &vstatus) == -1)
return -ENODEV;
p->vstatus.width = vstatus.frame_width;
@@ -2368,8 +2350,6 @@ static long amstream_ioctl_get_ex(struct port_priv_s *priv, ulong arg)
struct adec_status astatus;
struct am_ioctl_parm_ex *p = &parm;
if (p == NULL)
return -EINVAL;
amstream_adec_status(&astatus);
p->astatus.channels = astatus.channels;
p->astatus.sample_rate = astatus.sample_rate;
@@ -2419,7 +2399,7 @@ static long amstream_ioctl_get_ptr(struct port_priv_s *priv, ulong arg)
if (copy_from_user
((void *)&parm, (void *)arg,
sizeof(parm)))
r = -EFAULT;
return -EFAULT;
switch (parm.cmd) {
case AMSTREAM_GET_PTR_SUB_INFO:
@@ -2568,7 +2548,7 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
&bufs[BUF_TYPE_HEVC],
arg, false);
}
r = stbuf_change_size(
r += stbuf_change_size(
&bufs[BUF_TYPE_VIDEO],
arg, false);
}
@@ -2668,11 +2648,6 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
&bufs[BUF_TYPE_HEVC] :
&bufs[BUF_TYPE_VIDEO];
if (p == NULL) {
r = -EINVAL;
break;
}
if (this->type & PORT_TYPE_FRAME) {
struct vdec_input_status_s status;
@@ -2717,9 +2692,6 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
struct am_io_param *p = &para;
struct stream_buf_s *buf = &bufs[BUF_TYPE_AUDIO];
if (p == NULL)
r = -EINVAL;
p->status.size = stbuf_canusesize(buf);
p->status.data_len = stbuf_level(buf);
p->status.free_len = stbuf_space(buf);
@@ -2823,8 +2795,6 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
struct am_io_param para;
struct am_io_param *p = &para;
if (p == NULL)
return -EINVAL;
if (vdec_status(priv->vdec, &vstatus) == -1)
return -ENODEV;
p->vstatus.width = vstatus.frame_width;
@@ -2844,6 +2814,7 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
struct vdec_info vinfo;
struct am_io_info para;
memset(&para, 0x0, sizeof(struct am_io_info));
if (vdec_status(priv->vdec, &vinfo) == -1)
return -ENODEV;
memcpy(&para.vinfo, &vinfo, sizeof(struct vdec_info));
@@ -2862,8 +2833,6 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
struct am_io_param para;
struct am_io_param *p = &para;
if (p == NULL)
return -EINVAL;
amstream_adec_status(&astatus);
p->astatus.channels = astatus.channels;
p->astatus.sample_rate = astatus.sample_rate;

View File

@@ -783,7 +783,9 @@ ssize_t drm_write(struct file *file, struct stream_buf_s *stbuf,
if (stbuf->type != BUF_TYPE_SUBTITLE
&& stbuf_space(stbuf) < count) {
/*should not write partial data in drm mode*/
stbuf_wait_space(stbuf, count);
r = stbuf_wait_space(stbuf, count);
if (r < 0)
return r;
if (stbuf_space(stbuf) < count)
return -EAGAIN;
}

View File

@@ -598,15 +598,6 @@ static u32 parser_process(s32 type, s32 packet_len)
SET_DISCARD_SIZE(packet_len);
return DISCARD_SEARCH;
}
if (!packet_len)
return SEARCH_START_CODE;
else {
SET_BLOCK(packet_len);
audio_data_parsed += packet_len;
return SEND_AUDIO_SEARCH;
}
}
return SEARCH_START_CODE;

View File

@@ -111,7 +111,7 @@ int tsdemux_set_reset_flag(void)
static int tsdemux_reset(void)
{
unsigned long flags;
int r;
int r = 0;
spin_lock_irqsave(&demux_ops_lock, flags);
if (demux_ops && demux_ops->reset) {
@@ -126,7 +126,7 @@ static int tsdemux_reset(void)
static int tsdemux_request_irq(irq_handler_t handler, void *data)
{
unsigned long flags;
int r;
int r = 0;
spin_lock_irqsave(&demux_ops_lock, flags);
if (demux_ops && demux_ops->request_irq)
@@ -139,7 +139,7 @@ static int tsdemux_request_irq(irq_handler_t handler, void *data)
static int tsdemux_free_irq(void)
{
unsigned long flags;
int r;
int r = 0;
spin_lock_irqsave(&demux_ops_lock, flags);
if (demux_ops && demux_ops->free_irq)

View File

@@ -749,7 +749,7 @@ static int aml_fe_man_init(struct aml_fe_man *man, struct aml_fe *fe, int id)
ret = fe_of_property_u32(fe, "tuner", &value);
if (!ret) {
int id = value;
id = value;
if ((id < 0) || (id >= FE_DEV_COUNT) || !fe_man.tuner[id].drv) {
pr_error("invalid tuner device id %d\n", id);
@@ -762,7 +762,7 @@ static int aml_fe_man_init(struct aml_fe_man *man, struct aml_fe *fe, int id)
ret = fe_of_property_u32(fe, "atv_demod", &value);
if (!ret) {
int id = value;
id = value;
if ((id < 0) ||
(id >= FE_DEV_COUNT) ||
@@ -777,7 +777,7 @@ static int aml_fe_man_init(struct aml_fe_man *man, struct aml_fe *fe, int id)
ret = fe_of_property_u32(fe, "dtv_demod", &value);
if (!ret) {
int id = value;
id = value;
if ((id < 0) ||
(id >= FE_DEV_COUNT) ||
@@ -813,7 +813,7 @@ static int aml_fe_man_init(struct aml_fe_man *man, struct aml_fe *fe, int id)
ret = fe_of_property_u32(fe, "dev", &value);
if (!ret) {
int id = value;
id = value;
if ((id >= 0) && (id < FE_DEV_COUNT))
fe->dev_id = id;