From fca74dc1123d1db809136788bad8709b36cc5fd2 Mon Sep 17 00:00:00 2001 From: Ding Wei Date: Thu, 29 Oct 2020 09:10:07 +0800 Subject: [PATCH] video: rockchip: mpp: add query hw_id via client_type if device in session has initialized, return hw_id directly. otherwise, return hw_id via client_type which user set. cat /proc/mpp_service/supports-device will show the hw_id. Change-Id: Ie5e7c0227774ff5cacc8654f048c1447857e9e9d Signed-off-by: Ding Wei --- drivers/video/rockchip/mpp/mpp_common.c | 15 ++++++++++++++- drivers/video/rockchip/mpp/mpp_service.c | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/video/rockchip/mpp/mpp_common.c b/drivers/video/rockchip/mpp/mpp_common.c index e860d73bf26f..0372173e92fd 100644 --- a/drivers/video/rockchip/mpp/mpp_common.c +++ b/drivers/video/rockchip/mpp/mpp_common.c @@ -904,7 +904,20 @@ static int mpp_process_request(struct mpp_session *session, case MPP_CMD_QUERY_HW_ID: { struct mpp_hw_info *hw_info; - mpp = session->mpp; + mpp = NULL; + if (session && session->mpp) { + mpp = session->mpp; + } else { + u32 client_type; + + if (get_user(client_type, (u32 __user *)req->data)) + return -EFAULT; + + mpp_debug(DEBUG_IOCTL, "client %d\n", client_type); + client_type = array_index_nospec(client_type, MPP_DEVICE_BUTT); + if (test_bit(client_type, &srv->hw_support)) + mpp = srv->sub_devices[client_type]; + } if (!mpp) return -EINVAL; hw_info = mpp->var->hw_info; diff --git a/drivers/video/rockchip/mpp/mpp_service.c b/drivers/video/rockchip/mpp/mpp_service.c index f0052f76a6c0..430ea0715360 100644 --- a/drivers/video/rockchip/mpp/mpp_service.c +++ b/drivers/video/rockchip/mpp/mpp_service.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "mpp_debug.h" @@ -223,8 +224,20 @@ static int mpp_show_support_device(struct seq_file *file, void *v) seq_puts(file, "---- SUPPORT DEVICES ----\n"); for (i = 0; i < MPP_DEVICE_BUTT; i++) { - if (test_bit(i, &srv->hw_support)) - seq_printf(file, "DEVICE[%2d]:%s\n", i, mpp_device_name[i]); + struct mpp_dev *mpp; + struct mpp_hw_info *hw_info; + + if (test_bit(i, &srv->hw_support)) { + mpp = srv->sub_devices[array_index_nospec(i, MPP_DEVICE_BUTT)]; + if (!mpp) + continue; + + seq_printf(file, "DEVICE[%2d]:%-10s", i, mpp_device_name[i]); + hw_info = mpp->var->hw_info; + if (hw_info->hw_id) + seq_printf(file, "HW_ID:0x%08x", hw_info->hw_id); + seq_puts(file, "\n"); + } } return 0;