diff options
author | andy.hu <andy.hu@starfivetech.com> | 2023-01-11 11:06:13 +0000 |
---|---|---|
committer | andy.hu <andy.hu@starfivetech.com> | 2023-01-11 11:06:13 +0000 |
commit | 4e21c7a829519a5faa064382bce82a8d6c965095 (patch) | |
tree | 42bf658484e532d3574de3e7bd825d3355a76fe0 | |
parent | 4891ff0cdf696a72edb11d09d15a4954d779a6e3 (diff) | |
parent | e1d30510a9551c1027f242fa72bfea2faa79847b (diff) | |
download | linux-starfive-4e21c7a829519a5faa064382bce82a8d6c965095.tar.gz linux-starfive-4e21c7a829519a5faa064382bce82a8d6c965095.tar.bz2 linux-starfive-4e21c7a829519a5faa064382bce82a8d6c965095.zip |
Merge branch 'CR_3054_vin_system_pm_changhuang.liang' into 'jh7110-5.15.y-devel'
CR_3054_vin_system_pm_changhuang.liang media: starfive: Delete unused USE_MEDIA_PIPELINE macro code
See merge request sdk/linux!665
4 files changed, 77 insertions, 114 deletions
diff --git a/drivers/media/platform/starfive/v4l2_driver/stf_video.c b/drivers/media/platform/starfive/v4l2_driver/stf_video.c index 7a634e91fc6a..9aef386e9b54 100644 --- a/drivers/media/platform/starfive/v4l2_driver/stf_video.c +++ b/drivers/media/platform/starfive/v4l2_driver/stf_video.c @@ -11,8 +11,6 @@ #include <media/videobuf2-vmalloc.h> #include <media/videobuf2-dma-contig.h> -#define USE_MEDIA_PIPELINE - static const struct stfcamss_format_info formats_pix_st7110_wr[] = { { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_PIX_FMT_YUYV, 1, { { 1, 1 } }, { { 1, 1 } }, { 16 } }, @@ -552,15 +550,13 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count) struct v4l2_subdev *subdev; int ret; -#ifdef USE_MEDIA_PIPELINE - // ret = media_pipeline_start(&vdev->entity, &video->pipe); ret = media_pipeline_start(&vdev->entity, &video->stfcamss->pipe); if (ret < 0) { st_err(ST_VIDEO, "Failed to media_pipeline_start: %d\n", ret); return ret; } -#endif + ret = video_check_format(video); if (ret < 0) goto error; @@ -584,9 +580,7 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count) return 0; error: -#ifdef USE_MEDIA_PIPELINE media_pipeline_stop(&vdev->entity); -#endif video->ops->flush_buffers(video, VB2_BUF_STATE_QUEUED); return ret; } @@ -615,9 +609,7 @@ static void video_stop_streaming(struct vb2_queue *q) v4l2_subdev_call(subdev, video, s_stream, 0); } -#ifdef USE_MEDIA_PIPELINE media_pipeline_stop(&vdev->entity); -#endif video->ops->flush_buffers(video, VB2_BUF_STATE_ERROR); } @@ -1619,59 +1611,21 @@ static int video_open(struct file *file) file->private_data = vfh; -#ifdef USE_MEDIA_PIPELINE - ret = v4l2_pipeline_pm_get(&vdev->entity); - if (ret < 0) { - st_err(ST_VIDEO, - "Failed to power up pipeline: %d\n", ret); - goto error_pm_use; + if (!video->pm_count) { + ret = v4l2_pipeline_pm_get(&vdev->entity); + if (ret < 0) { + st_err(ST_VIDEO, + "Failed to power up pipeline: %d\n", ret); + goto error_pm_use; + } } -#else - struct media_entity *entity; - struct media_pad *pad; - struct v4l2_subdev *subdev; - int i = 0; - - entity = &vdev->entity; - while (1) { - pad = &entity->pads[0]; - if (!(pad->flags & MEDIA_PAD_FL_SINK)) - break; - pad = media_entity_remote_pad(pad); - if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) - break; + video->pm_count++; - entity = pad->entity; - subdev = media_entity_to_v4l2_subdev(entity); - - ret = v4l2_subdev_call(subdev, core, s_power, 1); - if (ret < 0 && ret != -ENOIOCTLCMD) - goto error_power; - i++; - } -#endif mutex_unlock(&video->lock); return 0; -#ifndef USE_MEDIA_PIPELINE -error_power: - entity = &vdev->entity; - while (i--) { - pad = &entity->pads[0]; - if (!(pad->flags & MEDIA_PAD_FL_SINK)) - break; - pad = media_entity_remote_pad(pad); - if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) - break; - - entity = pad->entity; - subdev = media_entity_to_v4l2_subdev(entity); - - v4l2_subdev_call(subdev, core, s_power, 0); - } -#endif error_pm_use: v4l2_fh_release(file); error_alloc: @@ -1682,31 +1636,15 @@ error_alloc: static int video_release(struct file *file) { struct video_device *vdev = video_devdata(file); + struct stfcamss_video *video = video_drvdata(file); vb2_fop_release(file); -#ifdef USE_MEDIA_PIPELINE - v4l2_pipeline_pm_put(&vdev->entity); -#else - struct media_entity *entity; - struct media_pad *pad; - struct v4l2_subdev *subdev; - entity = &vdev->entity; - while (1) { - pad = &entity->pads[0]; - if (!(pad->flags & MEDIA_PAD_FL_SINK)) - break; - - pad = media_entity_remote_pad(pad); - if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) - break; + video->pm_count--; - entity = pad->entity; - subdev = media_entity_to_v4l2_subdev(entity); + if (!video->pm_count) + v4l2_pipeline_pm_put(&vdev->entity); - v4l2_subdev_call(subdev, core, s_power, 0); - } -#endif file->private_data = NULL; return 0; diff --git a/drivers/media/platform/starfive/v4l2_driver/stf_video.h b/drivers/media/platform/starfive/v4l2_driver/stf_video.h index d134ee69c34e..6037d0ec7ac5 100644 --- a/drivers/media/platform/starfive/v4l2_driver/stf_video.h +++ b/drivers/media/platform/starfive/v4l2_driver/stf_video.h @@ -69,6 +69,7 @@ struct stfcamss_video { const struct stfcamss_format_info *formats; unsigned int nformats; unsigned int is_mp; + unsigned int pm_count; }; int stf_video_register(struct stfcamss_video *video, diff --git a/drivers/media/platform/starfive/v4l2_driver/stf_vin.h b/drivers/media/platform/starfive/v4l2_driver/stf_vin.h index 5625621c1544..492bffe27d17 100644 --- a/drivers/media/platform/starfive/v4l2_driver/stf_vin.h +++ b/drivers/media/platform/starfive/v4l2_driver/stf_vin.h @@ -82,6 +82,10 @@ struct vin_line { spinlock_t output_lock; const struct vin2_format *formats; unsigned int nformats; +#ifdef CONFIG_PM_SLEEP + int pm_stream_count; + int pm_power_count; +#endif }; struct stf_vin2_dev; diff --git a/drivers/media/platform/starfive/v4l2_driver/stfcamss.c b/drivers/media/platform/starfive/v4l2_driver/stfcamss.c index 11dbb85c5e5e..d9213cbf64fb 100644 --- a/drivers/media/platform/starfive/v4l2_driver/stfcamss.c +++ b/drivers/media/platform/starfive/v4l2_driver/stfcamss.c @@ -1201,31 +1201,43 @@ static int stfcamss_suspend(struct device *dev) struct stfcamss_video *video; struct video_device *vdev; int i = 0; + int pm_power_count; + int pm_stream_count; for (i = 0; i < VIN_LINE_MAX; i++) { - if (vin_dev->line[i].stream_count) { - vin_dev->line[i].stream_count ++; - video = &vin_dev->line[i].video_out; - vdev = &vin_dev->line[i].video_out.vdev; - entity = &vdev->entity; - while (1) { - pad = &entity->pads[0]; - if (!(pad->flags & MEDIA_PAD_FL_SINK)) - break; - - pad = media_entity_remote_pad(pad); - if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) - break; - - entity = pad->entity; - subdev = media_entity_to_v4l2_subdev(entity); - - v4l2_subdev_call(subdev, video, s_stream, 0); + video = &vin_dev->line[i].video_out; + vdev = &vin_dev->line[i].video_out.vdev; + vin_dev->line[i].pm_power_count = vin_dev->line[i].power_count; + vin_dev->line[i].pm_stream_count = vin_dev->line[i].stream_count; + pm_power_count = vin_dev->line[i].pm_power_count; + pm_stream_count = vin_dev->line[i].pm_stream_count; + + if (pm_stream_count) { + while (pm_stream_count--) { + entity = &vdev->entity; + while (1) { + pad = &entity->pads[0]; + if (!(pad->flags & MEDIA_PAD_FL_SINK)) + break; + + pad = media_entity_remote_pad(pad); + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) + break; + + entity = pad->entity; + subdev = media_entity_to_v4l2_subdev(entity); + + v4l2_subdev_call(subdev, video, s_stream, 0); + } } media_pipeline_stop(&vdev->entity); video->ops->flush_buffers(video, VB2_BUF_STATE_ERROR); - v4l2_pipeline_pm_put(&vdev->entity); } + + if (!pm_power_count) + continue; + + v4l2_pipeline_pm_put(&vdev->entity); } return pm_runtime_force_suspend(dev); @@ -1241,40 +1253,48 @@ static int stfcamss_resume(struct device *dev) struct stfcamss_video *video; struct video_device *vdev; int i = 0; + int pm_power_count; + int pm_stream_count; int ret = 0; pm_runtime_force_resume(dev); for (i = 0; i < VIN_LINE_MAX; i++) { - if (vin_dev->line[i].stream_count) { - vin_dev->line[i].stream_count--; - video = &vin_dev->line[i].video_out; - vdev = &vin_dev->line[i].video_out.vdev; + video = &vin_dev->line[i].video_out; + vdev = &vin_dev->line[i].video_out.vdev; + pm_power_count = vin_dev->line[i].pm_power_count; + pm_stream_count = vin_dev->line[i].pm_stream_count; - ret = v4l2_pipeline_pm_get(&vdev->entity); - if (ret < 0) - goto err; + if (!pm_power_count) + continue; + ret = v4l2_pipeline_pm_get(&vdev->entity); + if (ret < 0) + goto err; + + if (pm_stream_count) { ret = media_pipeline_start(&vdev->entity, &video->stfcamss->pipe); if (ret < 0) goto err_pm_put; - entity = &vdev->entity; - while (1) { - pad = &entity->pads[0]; - if (!(pad->flags & MEDIA_PAD_FL_SINK)) - break; + while (pm_stream_count--) { + entity = &vdev->entity; + while (1) { + pad = &entity->pads[0]; + if (!(pad->flags & MEDIA_PAD_FL_SINK)) + break; - pad = media_entity_remote_pad(pad); - if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) - break; + pad = media_entity_remote_pad(pad); + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) + break; - entity = pad->entity; - subdev = media_entity_to_v4l2_subdev(entity); + entity = pad->entity; + subdev = media_entity_to_v4l2_subdev(entity); - ret = v4l2_subdev_call(subdev, video, s_stream, 1); - if (ret < 0 && ret != -ENOIOCTLCMD) - goto err_pipeline_stop; + ret = v4l2_subdev_call(subdev, video, s_stream, 1); + if (ret < 0 && ret != -ENOIOCTLCMD) + goto err_pipeline_stop; + } } } } |