From 3aa6c0bc71fefa0854c97ea295fc383d0a959fa4 Mon Sep 17 00:00:00 2001 From: Ding Wei Date: Tue, 20 Oct 2020 16:33:48 +0800 Subject: [PATCH] video: rockchip: mpp: add command support info show support cmd: cat /proc/mpp_service/support_cmd Change-Id: I5ba150fcf2da797e32c8f5b38c8ff27886182460 Signed-off-by: Ding Wei --- drivers/video/rockchip/mpp/mpp_common.c | 68 ++++++++++++++++-------- drivers/video/rockchip/mpp/mpp_common.h | 6 +++ drivers/video/rockchip/mpp/mpp_service.c | 36 +++++++++++-- 3 files changed, 84 insertions(+), 26 deletions(-) diff --git a/drivers/video/rockchip/mpp/mpp_common.c b/drivers/video/rockchip/mpp/mpp_common.c index 61eb1bd14fb8..dad3ed64fb76 100644 --- a/drivers/video/rockchip/mpp/mpp_common.c +++ b/drivers/video/rockchip/mpp/mpp_common.c @@ -42,13 +42,6 @@ #define MPP_IOC_CFG_V1 _IOW(MPP_IOC_MAGIC, 1, unsigned int) #define MPP_IOC_CFG_V2 _IOW(MPP_IOC_MAGIC, 2, unsigned int) -/* cmd support for version 1 */ -#define MPP_CMD_QUERY_SUPPORT_MASK_V1 (0x00000003) -#define MPP_CMD_INIT_SUPPORT_MASK_V1 (0x00000007) -#define MPP_CMD_SEND_SUPPORT_MASK_V1 (0x0000001F) -#define MPP_CMD_POLL_SUPPORT_MASK_V1 (0x00000001) -#define MPP_CMD_CONTROL_SUPPORT_MASK_V1 (0x0000000F) - /* input parmater structure for version 1 */ struct mpp_msg_v1 { __u32 cmd; @@ -816,24 +809,15 @@ int mpp_taskqueue_init(struct mpp_taskqueue *queue, static int mpp_check_cmd_v1(__u32 cmd) { - int ret; - __u64 mask = 0; + bool found; - if (cmd >= MPP_CMD_CONTROL_BASE) - mask = MPP_CMD_CONTROL_SUPPORT_MASK_V1; - else if (cmd >= MPP_CMD_POLL_BASE) - mask = MPP_CMD_POLL_SUPPORT_MASK_V1; - else if (cmd >= MPP_CMD_SEND_BASE) - mask = MPP_CMD_SEND_SUPPORT_MASK_V1; - else if (cmd >= MPP_CMD_INIT_BASE) - mask = MPP_CMD_INIT_SUPPORT_MASK_V1; - else - mask = MPP_CMD_QUERY_SUPPORT_MASK_V1; + found = (cmd < MPP_CMD_QUERY_BUTT) ? true : false; + found = (cmd >= MPP_CMD_INIT_BASE && cmd < MPP_CMD_INIT_BUTT) ? true : found; + found = (cmd >= MPP_CMD_SEND_BASE && cmd < MPP_CMD_SEND_BUTT) ? true : found; + found = (cmd >= MPP_CMD_POLL_BASE && cmd < MPP_CMD_POLL_BUTT) ? true : found; + found = (cmd >= MPP_CMD_CONTROL_BASE && cmd < MPP_CMD_CONTROL_BUTT) ? true : found; - cmd &= 0x3F; - ret = ((mask >> cmd) & 0x1) ? 0 : (-EINVAL); - - return ret; + return found ? 0 : -EINVAL; } static int mpp_parse_msg_v1(struct mpp_msg_v1 *msg, @@ -869,6 +853,35 @@ static inline int mpp_msg_is_last(struct mpp_request *req) return flag; } +static __u32 mpp_get_cmd_butt(__u32 cmd) +{ + __u32 mask = 0; + + switch (cmd) { + case MPP_CMD_QUERY_BASE: + mask = MPP_CMD_QUERY_BUTT; + break; + case MPP_CMD_INIT_BASE: + mask = MPP_CMD_INIT_BUTT; + break; + + case MPP_CMD_SEND_BASE: + mask = MPP_CMD_SEND_BUTT; + break; + case MPP_CMD_POLL_BASE: + mask = MPP_CMD_POLL_BUTT; + break; + case MPP_CMD_CONTROL_BASE: + mask = MPP_CMD_CONTROL_BUTT; + break; + default: + mpp_err("unknow dev cmd 0x%x\n", cmd); + break; + } + + return mask; +} + static int mpp_process_request(struct mpp_session *session, struct mpp_service *srv, struct mpp_request *req, @@ -897,6 +910,15 @@ static int mpp_process_request(struct mpp_session *session, if (put_user(hw_info->hw_id, (u32 __user *)req->data)) return -EFAULT; } break; + case MPP_CMD_QUERY_CMD_SUPPORT: { + __u32 cmd = 0; + + if (get_user(cmd, (u32 __user *)req->data)) + return -EINVAL; + + if (put_user(mpp_get_cmd_butt(cmd), (u32 __user *)req->data)) + return -EFAULT; + } break; case MPP_CMD_INIT_CLIENT_TYPE: { u32 client_type; diff --git a/drivers/video/rockchip/mpp/mpp_common.h b/drivers/video/rockchip/mpp/mpp_common.h index 807a23f53978..a0e92fb9c515 100644 --- a/drivers/video/rockchip/mpp/mpp_common.h +++ b/drivers/video/rockchip/mpp/mpp_common.h @@ -79,25 +79,31 @@ enum MPP_DEV_COMMAND_TYPE { MPP_CMD_QUERY_BASE = 0, MPP_CMD_QUERY_HW_SUPPORT = MPP_CMD_QUERY_BASE + 0, MPP_CMD_QUERY_HW_ID = MPP_CMD_QUERY_BASE + 1, + MPP_CMD_QUERY_CMD_SUPPORT = MPP_CMD_QUERY_BASE + 2, + MPP_CMD_QUERY_BUTT, MPP_CMD_INIT_BASE = 0x100, MPP_CMD_INIT_CLIENT_TYPE = MPP_CMD_INIT_BASE + 0, MPP_CMD_INIT_DRIVER_DATA = MPP_CMD_INIT_BASE + 1, MPP_CMD_INIT_TRANS_TABLE = MPP_CMD_INIT_BASE + 2, + MPP_CMD_INIT_BUTT, MPP_CMD_SEND_BASE = 0x200, MPP_CMD_SET_REG_WRITE = MPP_CMD_SEND_BASE + 0, MPP_CMD_SET_REG_READ = MPP_CMD_SEND_BASE + 1, MPP_CMD_SET_REG_ADDR_OFFSET = MPP_CMD_SEND_BASE + 2, + MPP_CMD_SEND_BUTT, MPP_CMD_POLL_BASE = 0x300, MPP_CMD_POLL_HW_FINISH = MPP_CMD_POLL_BASE + 0, + MPP_CMD_POLL_BUTT, MPP_CMD_CONTROL_BASE = 0x400, MPP_CMD_RESET_SESSION = MPP_CMD_CONTROL_BASE + 0, MPP_CMD_TRANS_FD_TO_IOVA = MPP_CMD_CONTROL_BASE + 1, MPP_CMD_RELEASE_FD = MPP_CMD_CONTROL_BASE + 2, MPP_CMD_SEND_CODEC_INFO = MPP_CMD_CONTROL_BASE + 3, + MPP_CMD_CONTROL_BUTT, MPP_CMD_BUTT, }; diff --git a/drivers/video/rockchip/mpp/mpp_service.c b/drivers/video/rockchip/mpp/mpp_service.c index fde84f465835..c4d3f8b75b78 100644 --- a/drivers/video/rockchip/mpp/mpp_service.c +++ b/drivers/video/rockchip/mpp/mpp_service.c @@ -187,20 +187,50 @@ static int mpp_show_session_summary(struct seq_file *seq, void *offset) return 0; } +static int mpp_show_support_cmd(struct seq_file *file, void *v) +{ + seq_puts(file, "------------- SUPPROT CMD -------------\n"); + seq_printf(file, "QUERY_HW_SUPPORT: 0x%08x\n", MPP_CMD_QUERY_HW_SUPPORT); + seq_printf(file, "QUERY_HW_ID: 0x%08x\n", MPP_CMD_QUERY_HW_ID); + seq_printf(file, "QUERY_CMD_SUPPORT: 0x%08x\n", MPP_CMD_QUERY_CMD_SUPPORT); + seq_printf(file, "QUERY BUTT: 0x%08x\n", MPP_CMD_QUERY_BUTT); + seq_puts(file, "----\n"); + seq_printf(file, "INIT_CLIENT_TYPE: 0x%08x\n", MPP_CMD_INIT_CLIENT_TYPE); + seq_printf(file, "INIT_TRANS_TABLE: 0x%08x\n", MPP_CMD_INIT_TRANS_TABLE); + seq_printf(file, "INIT BUTT: 0x%08x\n", MPP_CMD_INIT_BUTT); + seq_puts(file, "----\n"); + seq_printf(file, "SET_REG_WRITE: 0x%08x\n", MPP_CMD_SET_REG_WRITE); + seq_printf(file, "SET_REG_READ: 0x%08x\n", MPP_CMD_SET_REG_READ); + seq_printf(file, "SET_REG_ADDR_OFFSET: 0x%08x\n", MPP_CMD_SET_REG_ADDR_OFFSET); + seq_printf(file, "SEND BUTT: 0x%08x\n", MPP_CMD_SEND_BUTT); + seq_puts(file, "----\n"); + seq_printf(file, "POLL_HW_FINISH: 0x%08x\n", MPP_CMD_POLL_HW_FINISH); + seq_printf(file, "POLL BUTT: 0x%08x\n", MPP_CMD_POLL_BUTT); + seq_puts(file, "----\n"); + seq_printf(file, "RESET_SESSION: 0x%08x\n", MPP_CMD_RESET_SESSION); + seq_printf(file, "TRANS_FD_TO_IOVA: 0x%08x\n", MPP_CMD_TRANS_FD_TO_IOVA); + seq_printf(file, "RELEASE_FD: 0x%08x\n", MPP_CMD_RELEASE_FD); + seq_printf(file, "SEND_CODEC_INFO: 0x%08x\n", MPP_CMD_SEND_CODEC_INFO); + seq_printf(file, "CONTROL BUTT: 0x%08x\n", MPP_CMD_CONTROL_BUTT); + + return 0; +} + static int mpp_procfs_init(struct mpp_service *srv) { srv->procfs = proc_mkdir(MPP_SERVICE_NAME, NULL); if (IS_ERR_OR_NULL(srv->procfs)) { mpp_err("failed on mkdir /proc/%s\n", MPP_SERVICE_NAME); srv->procfs = NULL; + return -EIO; } /* show version */ - if (srv->procfs) - proc_create_single_data("version", 0644, srv->procfs, - mpp_show_version, NULL); + proc_create_single("version", 0644, srv->procfs, mpp_show_version); /* for show session info */ proc_create_single_data("session_summary", 0644, srv->procfs, mpp_show_session_summary, srv); + /* show support dev cmd */ + proc_create_single("support_cmd", 0644, srv->procfs, mpp_show_support_cmd); return 0; }