From 4373e91adbe7ca6fe212ff0d1b06d27428d95bb4 Mon Sep 17 00:00:00 2001 From: miaohong chen Date: Wed, 26 Feb 2020 16:14:45 +0800 Subject: [PATCH] vdec: add vfm path config [1/1] PD#SWPL-20691 Problem: vfm path need config in driver. Solution: cfg in decoder driver. Verify: u212 Change-Id: I1d53c514b9fdc8efcf4ad89af31d9eebb20e55ea Signed-off-by: miaohong chen --- drivers/frame_provider/decoder/utils/vdec.c | 120 +++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/drivers/frame_provider/decoder/utils/vdec.c b/drivers/frame_provider/decoder/utils/vdec.c index 7399d17..f98ea39 100644 --- a/drivers/frame_provider/decoder/utils/vdec.c +++ b/drivers/frame_provider/decoder/utils/vdec.c @@ -213,6 +213,43 @@ bit [0] static int debugflags; +static char vfm_path[VDEC_MAP_NAME_SIZE] = {"disable"}; +static const char vfm_path_node[][VDEC_MAP_NAME_SIZE] = +{ + "video_render.0", + "video_render.1", + "amvideo", + "videopip", + "deinterlace", + "dimulti.1", + "amlvideo", + "aml_video.1", + "amlvideo2.0", + "amlvideo2.1", + "ppmgr", + "ionvideo", + "ionvideo.1", + "ionvideo.2", + "ionvideo.3", + "ionvideo.4", + "ionvideo.5", + "ionvideo.6", + "ionvideo.7", + "ionvideo.8", + "videosync.0", + "v4lvideo.0", + "v4lvideo.1", + "v4lvideo.2", + "v4lvideo.3", + "v4lvideo.4", + "v4lvideo.5", + "v4lvideo.6", + "v4lvideo.7", + "v4lvideo.8", + "disable", + "reserved", +}; + static struct canvas_status_s canvas_stat[AMVDEC_CANVAS_MAX1 - AMVDEC_CANVAS_START_INDEX + 1 + AMVDEC_CANVAS_MAX2 + 1]; @@ -2197,7 +2234,13 @@ s32 vdec_init(struct vdec_s *vdec, int is_4k) goto error; } - if (p->frame_base_video_path == FRAME_BASE_PATH_IONVIDEO) { + + if (strncmp("disable", vfm_path, strlen("disable"))) { + snprintf(vdec->vfm_map_chain, VDEC_MAP_NAME_SIZE, + "%s %s", vdec->vf_provider_name, vfm_path); + snprintf(vdec->vfm_map_id, VDEC_MAP_NAME_SIZE, + "vdec-map-%d", vdec->id); + } else if (p->frame_base_video_path == FRAME_BASE_PATH_IONVIDEO) { #if 1 r = ionvideo_assign_map(&vdec->vf_receiver_name, &vdec->vf_receiver_inst); @@ -4418,6 +4461,79 @@ static ssize_t show_debug(struct class *class, } #endif +static ssize_t store_vdec_vfm_path(struct class *class, + struct class_attribute *attr, + const char *buf, size_t count) +{ + char *buf_dup, *ps, *token; + char str[VDEC_MAP_NAME_SIZE] = "\0"; + bool found = false; + int i; + + if (strlen(buf) >= VDEC_MAP_NAME_SIZE) { + pr_info("parameter is overflow\n"); + return -1; + } + + buf_dup = kstrdup(buf, GFP_KERNEL); + ps = buf_dup; + while (1) { + token = strsep(&ps, "\n "); + if (token == NULL) + break; + if (*token == '\0') + continue; + + for (i = 0; strcmp("reserved", vfm_path_node[i]) != 0; i++) { + if (!strncmp (vfm_path_node[i], token, strlen(vfm_path_node[i]))) { + break; + } + } + + if (strcmp("reserved", vfm_path_node[i]) == 0 || + strncmp("help", buf, strlen("help")) == 0) { + if (strncmp("help", buf, strlen("help")) != 0) { + pr_info("warnning! Input parameter is invalid. set failed!\n"); + } + pr_info("\nusage for example: \n"); + pr_info("echo help > /sys/class/vdec/vfm_path \n"); + pr_info("echo disable > /sys/class/vdec/vfm_path \n"); + pr_info("echo amlvideo ppmgr amvideo > /sys/class/vdec/vfm_path \n"); + found = false; + + break; + } else { + strcat(str, vfm_path_node[i]); + strcat(str, " "); + found = true; + } + } + + if (found == true) { + memset(vfm_path, 0, sizeof(vfm_path)); + strncpy(vfm_path, str, strlen(str)); + vfm_path[VDEC_MAP_NAME_SIZE - 1] = '\0'; + pr_info("cfg path success: decoder %s\n", vfm_path); + } + kfree(buf_dup); + + return count; +} + +static ssize_t show_vdec_vfm_path(struct class *class, + struct class_attribute *attr, char *buf) +{ + int len = 0; + int i; + len += sprintf(buf + len, "cfg vfm path: decoder %s\n", vfm_path); + len += sprintf(buf + len, "\nvfm path node list: \n"); + for (i = 0; strcmp("reserved", vfm_path_node[i]) != 0; i++) { + len += sprintf(buf + len, "\t%s \n", vfm_path_node[i]); + } + + return len; +} + /*irq num as same as .dts*/ /* * interrupts = <0 3 1 @@ -4925,6 +5041,8 @@ static struct class_attribute vdec_class_attrs[] = { frame_check_show, frame_check_store), #endif __ATTR_RO(dump_fps), + __ATTR(vfm_path, S_IRUGO | S_IWUSR | S_IWGRP, + show_vdec_vfm_path, store_vdec_vfm_path), __ATTR_NULL }; -- 2.20.1