media: rockchip: vpss: optimize module set

1: add module_get
2: module can't be changed dynamically

Signed-off-by: Mingwei Yan <mingwei.yan@rock-chips.com>
Change-Id: I4b7c6c5a8b3b600908a796224ab5fceaab6c995b
This commit is contained in:
Mingwei Yan
2024-03-12 11:18:30 +08:00
committed by Tao Huang
parent 4f9157021a
commit 7614b638e9
4 changed files with 41 additions and 0 deletions

View File

@@ -842,6 +842,7 @@ static int __maybe_unused rkvpss_runtime_suspend(struct device *dev)
rkvpss_hw_write(hw_dev, RKVPSS_MI_IMSC, 0);
rkvpss_hw_write(hw_dev, RKVPSS_VPSS_IMSC, 0);
disable_sys_clk(hw_dev);
hw_dev->ofl_dev.mode_sel_en = true;
return 0;
}

View File

@@ -607,6 +607,7 @@ static int rkvpss_ofl_run(struct file *file, struct rkvpss_frame_cfg *cfg)
t = ktime_get();
}
init_completion(&ofl->cmpl);
ofl->mode_sel_en = false;
in_c_offs = 0;
in_ctrl = 0;
@@ -958,6 +959,30 @@ err:
return -ENOMEM;
}
static int rkvpss_module_get(struct file *file,
struct rkvpss_module_sel *get)
{
struct rkvpss_offline_dev *ofl = video_drvdata(file);
struct rkvpss_hw_dev *hw = ofl->hw;
int i, ret = 0;
mutex_lock(&hw->dev_lock);
if (hw->is_ofl_cmsc)
get->mirror_cmsc_en = 1;
else
get->mirror_cmsc_en = 0;
for (i = 0; i < RKVPSS_OUTPUT_MAX; i++) {
if (hw->is_ofl_ch[i])
get->ch_en[i] = 1;
else
get->ch_en[i] = 0;
}
mutex_unlock(&hw->dev_lock);
return ret;
}
static int rkvpss_module_sel(struct file *file,
struct rkvpss_module_sel *sel)
{
@@ -967,6 +992,13 @@ static int rkvpss_module_sel(struct file *file,
int i, ret = 0;
mutex_lock(&hw->dev_lock);
if (!ofl->mode_sel_en) {
v4l2_err(&ofl->v4l2_dev, "already set module_sel\n");
ret = -EINVAL;
goto unlock;
}
for (i = 0; i < hw->dev_num; i++) {
vpss = hw->vpss[i];
if (vpss && (vpss->vpss_sdev.state & VPSS_START)) {
@@ -996,6 +1028,9 @@ static long rkvpss_ofl_ioctl(struct file *file, void *fh,
case RKVPSS_CMD_MODULE_SEL:
ret = rkvpss_module_sel(file, arg);
break;
case RKVPSS_CMD_MODULE_GET:
ret = rkvpss_module_get(file, arg);
break;
case RKVPSS_CMD_FRAME_HANDLE:
ret = rkvpss_ofl_run(file, arg);
break;
@@ -1097,6 +1132,7 @@ int rkvpss_register_offline(struct rkvpss_hw_dev *hw)
mutex_init(&ofl->apilock);
ofl->vfd = offline_videodev;
ofl->mode_sel_en = true;
vfd = &ofl->vfd;
vfd->device_caps = V4L2_CAP_STREAMING;
vfd->lock = &ofl->apilock;

View File

@@ -13,6 +13,7 @@ struct rkvpss_offline_dev {
struct mutex apilock;
struct completion cmpl;
struct list_head list;
bool mode_sel_en;
};
int rkvpss_register_offline(struct rkvpss_hw_dev *hw);

View File

@@ -62,6 +62,9 @@
#define RKVPSS_CMD_BUF_DEL \
_IOW('V', BASE_VIDIOC_PRIVATE + 53, struct rkvpss_buf_info)
#define RKVPSS_CMD_MODULE_GET \
_IOR('V', BASE_VIDIOC_PRIVATE + 54, struct rkvpss_module_sel)
/********************************************************************/
/* struct rkvpss_mirror_flip