mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-06-29 23:43:21 -04:00
k1📷 fix the issue where udev scans nodes to release subdev node resource when the camera in use
Change-Id: Ia1a058965c379875e3f0ff91d5a4a87774dcd34e Signed-off-by: lizhirong <zhirong.li@spacemit.com>
This commit is contained in:
parent
563969041a
commit
f491cb1513
2 changed files with 20 additions and 11 deletions
|
@ -16,7 +16,11 @@
|
||||||
static int spm_subdev_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
|
static int spm_subdev_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
|
||||||
{
|
{
|
||||||
struct spm_camera_subdev *sc_subdev = v4l2_subdev_to_sc_subdev(sd);
|
struct spm_camera_subdev *sc_subdev = v4l2_subdev_to_sc_subdev(sd);
|
||||||
cam_dbg("%s(%s) enter.", __func__, sc_subdev->name);
|
cam_dbg("%s(%s) enter. cnt:%d", __func__, sc_subdev->name, atomic_read(&sc_subdev->ref_cnt));
|
||||||
|
|
||||||
|
if (atomic_inc_return(&sc_subdev->ref_cnt) != 1)
|
||||||
|
cam_warn("subdev(%s) was already openned.", sc_subdev->name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,18 +32,22 @@ static int spm_subdev_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
|
||||||
struct spm_camera_subdev *sc_subdev = v4l2_subdev_to_sc_subdev(sd);
|
struct spm_camera_subdev *sc_subdev = v4l2_subdev_to_sc_subdev(sd);
|
||||||
struct media_pipeline *pipe = media_entity_pipeline(me);
|
struct media_pipeline *pipe = media_entity_pipeline(me);
|
||||||
|
|
||||||
cam_dbg("%s(%s) enter.", __func__, sc_subdev->name);
|
cam_dbg("%s(%s) enter. cnt:%d", __func__, sc_subdev->name, atomic_read(&sc_subdev->ref_cnt));
|
||||||
mutex_lock(&mdev->graph_mutex);
|
|
||||||
if (pipe) {
|
if (atomic_dec_and_test(&sc_subdev->ref_cnt)) {
|
||||||
sc_pipeline = media_pipeline_to_sc_pipeline(pipe);
|
mutex_lock(&mdev->graph_mutex);
|
||||||
if (sc_pipeline->state >= PIPELINE_ST_STARTED) {
|
if (pipe) {
|
||||||
__spm_mlink_stop_pipeline(me);
|
sc_pipeline = media_pipeline_to_sc_pipeline(pipe);
|
||||||
}
|
if (sc_pipeline->state >= PIPELINE_ST_STARTED) {
|
||||||
while (sc_pipeline->state >= PIPELINE_ST_GET) {
|
__spm_mlink_stop_pipeline(me);
|
||||||
__spm_mlink_put_pipeline(me, 1);
|
}
|
||||||
|
while (sc_pipeline->state >= PIPELINE_ST_GET) {
|
||||||
|
__spm_mlink_put_pipeline(me, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&mdev->graph_mutex);
|
||||||
}
|
}
|
||||||
mutex_unlock(&mdev->graph_mutex);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ struct spm_camera_subdev {
|
||||||
struct notifier_block vnode_nb;
|
struct notifier_block vnode_nb;
|
||||||
uint32_t pads_stream_enable;
|
uint32_t pads_stream_enable;
|
||||||
int is_resetting;
|
int is_resetting;
|
||||||
|
atomic_t ref_cnt;
|
||||||
long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
|
long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
|
||||||
void (*release)(struct spm_camera_subdev *sc_subdev);
|
void (*release)(struct spm_camera_subdev *sc_subdev);
|
||||||
void (*notify)(struct spm_camera_subdev *sc_subdev, unsigned int notification,
|
void (*notify)(struct spm_camera_subdev *sc_subdev, unsigned int notification,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue