mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-26 18:40:23 +08:00
[mpp_service]: Fix error when cap hw info
Tips: User should close fd before changing the client_type. Otherwise the kernel will leak one info structure. Signed-off-by: Ding Wei <leo.ding@rock-chips.com> Change-Id: I2f99e4840d1e9a3805306be50e4afa3653f43c0c
This commit is contained in:
@@ -153,6 +153,7 @@ void check_mpp_service_cap(RK_U32 *codec_type, RK_U32 *hw_ids, MppServiceCmdCap
|
|||||||
RK_S32 fd = -1;
|
RK_S32 fd = -1;
|
||||||
RK_S32 ret = 0;
|
RK_S32 ret = 0;
|
||||||
RK_U32 *cmd_butt = &cap->query_cmd;;
|
RK_U32 *cmd_butt = &cap->query_cmd;;
|
||||||
|
RK_U32 hw_support = 0;
|
||||||
RK_U32 val;
|
RK_U32 val;
|
||||||
RK_U32 i;
|
RK_U32 i;
|
||||||
|
|
||||||
@@ -162,80 +163,21 @@ void check_mpp_service_cap(RK_U32 *codec_type, RK_U32 *hw_ids, MppServiceCmdCap
|
|||||||
*codec_type = 0;
|
*codec_type = 0;
|
||||||
memset(hw_ids, 0, sizeof(RK_U32) * 32);
|
memset(hw_ids, 0, sizeof(RK_U32) * 32);
|
||||||
|
|
||||||
|
/* check hw_support flag for valid client type */
|
||||||
fd = open(mpp_get_mpp_service_name(), O_RDWR);
|
fd = open(mpp_get_mpp_service_name(), O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
mpp_err("open mpp_service to check cmd capability failed\n");
|
mpp_err("open mpp_service to check cmd capability failed\n");
|
||||||
memset(cap, 0, sizeof(*cap));
|
memset(cap, 0, sizeof(*cap));
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
ret = mpp_service_ioctl(fd, MPP_CMD_PROBE_HW_SUPPORT, 0, &hw_support);
|
||||||
/* check hw_support flag for valid client type */
|
|
||||||
ret = mpp_service_ioctl(fd, MPP_CMD_PROBE_HW_SUPPORT, 0, &val);
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
mpp_dev_dbg_probe("vcodec_support %08x\n", val);
|
mpp_dev_dbg_probe("vcodec_support %08x\n", hw_support);
|
||||||
*codec_type = val;
|
*codec_type = hw_support;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check each valid client type for hw_id */
|
|
||||||
{
|
|
||||||
RK_U32 hw_support = val;
|
|
||||||
|
|
||||||
/* find first valid client type */
|
|
||||||
for (i = 0; i < 32; i++)
|
|
||||||
if (hw_support & (1 << i)) {
|
|
||||||
val = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* for compatible check hw_id read mode first */
|
|
||||||
ret = mpp_service_ioctl(fd, MPP_CMD_QUERY_HW_ID, sizeof(val), &val);
|
|
||||||
if (!ret) {
|
|
||||||
/* kernel support hw_id check by input client type */
|
|
||||||
for (i = 0; i < 32; i++) {
|
|
||||||
if (hw_support & (1 << i)) {
|
|
||||||
val = i;
|
|
||||||
|
|
||||||
/* send client type and get hw_id */
|
|
||||||
ret = mpp_service_ioctl(fd, MPP_CMD_QUERY_HW_ID, sizeof(val), &val);
|
|
||||||
if (!ret) {
|
|
||||||
mpp_dev_dbg_probe("client %-10s hw_id %08x\n", mpp_service_hw_name[i], val);
|
|
||||||
hw_ids[i] = val;
|
|
||||||
} else
|
|
||||||
mpp_err("check valid client %-10s for hw_id failed\n",
|
|
||||||
mpp_service_hw_name[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* kernel need to set client type then get hw_id */
|
|
||||||
for (i = 0; i < 32; i++) {
|
|
||||||
if (hw_support & (1 << i)) {
|
|
||||||
val = i;
|
|
||||||
|
|
||||||
/* set client type first */
|
|
||||||
ret = mpp_service_ioctl(fd, MPP_CMD_INIT_CLIENT_TYPE, sizeof(val), &val);
|
|
||||||
if (ret) {
|
|
||||||
mpp_err("check valid client type %d failed\n", i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* then get hw_id */
|
|
||||||
ret = mpp_service_ioctl(fd, MPP_CMD_QUERY_HW_ID, sizeof(val), &val);
|
|
||||||
if (!ret) {
|
|
||||||
mpp_dev_dbg_probe("client %-10s hw_id %08x\n", mpp_service_hw_name[i], val);
|
|
||||||
hw_ids[i] = val;
|
|
||||||
} else
|
|
||||||
mpp_err("check valid client %-10s for hw_id failed\n",
|
|
||||||
mpp_service_hw_name[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cap->support_cmd = !access("/proc/mpp_service/supports-cmd", F_OK) ||
|
cap->support_cmd = !access("/proc/mpp_service/supports-cmd", F_OK) ||
|
||||||
!access("/proc/mpp_service/support_cmd", F_OK);
|
!access("/proc/mpp_service/support_cmd", F_OK);
|
||||||
if (!cap->support_cmd)
|
if (cap->support_cmd) {
|
||||||
return ;
|
|
||||||
|
|
||||||
for (i = 0; i < query_count; i++, cmd_butt++) {
|
for (i = 0; i < query_count; i++, cmd_butt++) {
|
||||||
const MppServiceQueryCfg *cfg = &query_cfg[i];
|
const MppServiceQueryCfg *cfg = &query_cfg[i];
|
||||||
|
|
||||||
@@ -253,8 +195,37 @@ void check_mpp_service_cap(RK_U32 *codec_type, RK_U32 *hw_ids, MppServiceCmdCap
|
|||||||
mpp_dev_dbg_probe("query %-11s support %04x\n", cfg->name, val);
|
mpp_dev_dbg_probe("query %-11s support %04x\n", cfg->name, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
/* check each valid client type for hw_id */
|
||||||
|
/* kernel need to set client type then get hw_id */
|
||||||
|
for (i = 0; i < 32; i++) {
|
||||||
|
if (hw_support & (1 << i)) {
|
||||||
|
val = i;
|
||||||
|
|
||||||
|
fd = open(mpp_get_mpp_service_name(), O_RDWR);
|
||||||
|
if (fd < 0) {
|
||||||
|
mpp_err("open mpp_service to check cmd capability failed\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* set client type first */
|
||||||
|
ret = mpp_service_ioctl(fd, MPP_CMD_INIT_CLIENT_TYPE, sizeof(val), &val);
|
||||||
|
if (ret) {
|
||||||
|
mpp_err("check valid client type %d failed\n", i);
|
||||||
|
} else {
|
||||||
|
/* then get hw_id */
|
||||||
|
ret = mpp_service_ioctl(fd, MPP_CMD_QUERY_HW_ID, sizeof(val), &val);
|
||||||
|
if (!ret) {
|
||||||
|
mpp_dev_dbg_probe("client %-10s hw_id %08x\n", mpp_service_hw_name[i], val);
|
||||||
|
hw_ids[i] = val;
|
||||||
|
} else
|
||||||
|
mpp_err("check valid client %-10s for hw_id failed\n",
|
||||||
|
mpp_service_hw_name[i]);
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_REG_OFFSET 32
|
#define MAX_REG_OFFSET 32
|
||||||
|
|||||||
Reference in New Issue
Block a user