media: atomisp: Turn asd->streaming state tracker into a bool
authorHans de Goede <hdegoede@redhat.com>
Thu, 11 May 2023 17:33:06 +0000 (18:33 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 9 Jun 2023 13:43:16 +0000 (14:43 +0100)
The ATOMISP_DEVICE_STREAMING_STOPPING pipe state comes from when we still
had continuous mode. This would be set when streaming from both capture +
preview devnodes when 1 of the 2 streams has been stopped and the driver
was waiting for the other stream to get stopped too.

With continuous mode gone the stopping state is no longer necessary and
asd->streaming can be changed to a bool.

Note that atomisp_assert_recovery_work() would still temporarily
set streaming to stopping, but it does so with the isp->mutex held and
changes streaming to either enabled or disabled before releasing
the mutex, so none of the consumers which care about the difference
ever see the stopping state.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_cmd.c
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
drivers/staging/media/atomisp/pci/atomisp_fops.c
drivers/staging/media/atomisp/pci/atomisp_internal.h
drivers/staging/media/atomisp/pci/atomisp_ioctl.c
drivers/staging/media/atomisp/pci/atomisp_subdev.h
drivers/staging/media/atomisp/pci/atomisp_v4l2.c

index ea07ddc..26a1942 100644 (file)
@@ -475,7 +475,7 @@ irqreturn_t atomisp_isr(int irq, void *dev)
        if (!atomisp_streaming_count(isp))
                goto out_nowake;
 
-       if (isp->asd.streaming == ATOMISP_DEVICE_STREAMING_ENABLED) {
+       if (isp->asd.streaming) {
                if (irq_infos & IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF) {
                        atomic_inc(&isp->asd.sof_count);
                        atomisp_sof_event(&isp->asd);
@@ -950,12 +950,11 @@ static void __atomisp_css_recover(struct atomisp_device *isp)
 
        atomisp_css_irq_enable(isp, IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF, false);
 
-       if (isp->asd.streaming == ATOMISP_DEVICE_STREAMING_ENABLED ||
-           isp->asd.stream_prepared) {
+       if (isp->asd.streaming || isp->asd.stream_prepared) {
                stream_restart = true;
 
                spin_lock_irqsave(&isp->lock, flags);
-               isp->asd.streaming = ATOMISP_DEVICE_STREAMING_STOPPING;
+               isp->asd.streaming = false;
                spin_unlock_irqrestore(&isp->lock, flags);
 
                /* stream off sensor */
@@ -971,10 +970,6 @@ static void __atomisp_css_recover(struct atomisp_device *isp)
                css_pipe_id = atomisp_get_css_pipe_id(&isp->asd);
                atomisp_css_stop(&isp->asd, css_pipe_id, true);
 
-               spin_lock_irqsave(&isp->lock, flags);
-               isp->asd.streaming = ATOMISP_DEVICE_STREAMING_DISABLED;
-               spin_unlock_irqrestore(&isp->lock, flags);
-
                isp->asd.preview_exp_id = 1;
                isp->asd.postview_exp_id = 1;
                /* notify HAL the CSS reset */
@@ -1003,7 +998,7 @@ static void __atomisp_css_recover(struct atomisp_device *isp)
                                 "start SP failed, so do not set streaming to be enable!\n");
                } else {
                        spin_lock_irqsave(&isp->lock, flags);
-                       isp->asd.streaming = ATOMISP_DEVICE_STREAMING_ENABLED;
+                       isp->asd.streaming = true;
                        spin_unlock_irqrestore(&isp->lock, flags);
                }
 
@@ -1128,7 +1123,7 @@ irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr)
        if (atomisp_css_isr_thread(isp))
                goto out;
 
-       if (isp->asd.streaming == ATOMISP_DEVICE_STREAMING_ENABLED)
+       if (isp->asd.streaming)
                atomisp_setup_flash(&isp->asd);
 out:
        mutex_unlock(&isp->mutex);
@@ -3211,7 +3206,7 @@ void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe)
         * CSS/FW requires set parameter and enqueue buffer happen after ISP
         * is streamon.
         */
-       if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
+       if (!asd->streaming)
                return;
 
        if (list_empty(&pipe->per_frame_params) ||
@@ -4761,7 +4756,7 @@ static int __checking_exp_id(struct atomisp_sub_device *asd, int exp_id)
                dev_warn(isp->dev, "%s Raw Buffer Lock is disable.\n", __func__);
                return -EINVAL;
        }
-       if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED) {
+       if (!asd->streaming) {
                dev_err(isp->dev, "%s streaming %d invalid exp_id %d.\n",
                        __func__, exp_id, asd->streaming);
                return -EINVAL;
@@ -4883,7 +4878,7 @@ int atomisp_enable_dz_capt_pipe(struct atomisp_sub_device *asd,
 
 int atomisp_inject_a_fake_event(struct atomisp_sub_device *asd, int *event)
 {
-       if (!event || asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
+       if (!event || !asd->streaming)
                return -EINVAL;
 
        lockdep_assert_held(&asd->isp->mutex);
index 092262e..cecdf11 100644 (file)
@@ -3081,7 +3081,7 @@ int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd,
                return -EINVAL;
 
        /* isp needs to be streaming to get DIS statistics */
-       if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
+       if (!asd->streaming)
                return -EINVAL;
 
        if (atomisp_compare_dvs_grid(asd, &stats->dvs2_stat.grid_info) != 0)
@@ -3210,7 +3210,7 @@ static bool atomisp_css_isr_get_stream_id(struct ia_css_pipe *css_pipe,
        struct atomisp_stream_env *stream_env;
        int i, j;
 
-       if (isp->asd.streaming == ATOMISP_DEVICE_STREAMING_DISABLED)
+       if (!isp->asd.streaming)
                return false;
 
        for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
index ef1a5ad..c7da5bf 100644 (file)
@@ -411,7 +411,7 @@ static void atomisp_buf_queue(struct vb2_buffer *vb)
        spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
 
        /* TODO: do this better, not best way to queue to css */
-       if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED) {
+       if (asd->streaming) {
                if (!list_empty(&pipe->buffers_waiting_for_param))
                        atomisp_handle_parameter_and_buffer(pipe);
                else
index 3d4f0f6..feaf403 100644 (file)
@@ -168,10 +168,6 @@ struct atomisp_regs {
        u32 csi_access_viol;
 };
 
-#define ATOMISP_DEVICE_STREAMING_DISABLED      0
-#define ATOMISP_DEVICE_STREAMING_ENABLED       1
-#define ATOMISP_DEVICE_STREAMING_STOPPING      2
-
 /*
  * ci device struct
  */
index 08a3d98..020d418 100644 (file)
@@ -601,7 +601,7 @@ static int atomisp_enum_input(struct file *file, void *fh,
 
 unsigned int atomisp_streaming_count(struct atomisp_device *isp)
 {
-       return isp->asd.streaming == ATOMISP_DEVICE_STREAMING_ENABLED;
+       return isp->asd.streaming;
 }
 
 /*
@@ -1163,7 +1163,7 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)
        }
 
        spin_lock_irqsave(&isp->lock, irqflags);
-       asd->streaming = ATOMISP_DEVICE_STREAMING_ENABLED;
+       asd->streaming = true;
        spin_unlock_irqrestore(&isp->lock, irqflags);
        atomic_set(&asd->sof_count, -1);
        atomic_set(&asd->sequence, -1);
@@ -1205,7 +1205,7 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)
        if (ret) {
                dev_err(isp->dev, "Starting sensor stream failed: %d\n", ret);
                spin_lock_irqsave(&isp->lock, irqflags);
-               asd->streaming = ATOMISP_DEVICE_STREAMING_DISABLED;
+               asd->streaming = false;
                spin_unlock_irqrestore(&isp->lock, irqflags);
                ret = -EINVAL;
                goto out_unlock;
@@ -1246,7 +1246,7 @@ void atomisp_stop_streaming(struct vb2_queue *vq)
                dev_warn(isp->dev, "Warning timeout waiting for CSS to return buffers\n");
 
        spin_lock_irqsave(&isp->lock, flags);
-       asd->streaming = ATOMISP_DEVICE_STREAMING_DISABLED;
+       asd->streaming = false;
        spin_unlock_irqrestore(&isp->lock, flags);
 
        atomisp_clear_css_buffer_counters(asd);
index a702890..4917738 100644 (file)
@@ -299,7 +299,7 @@ struct atomisp_sub_device {
         * Writers of streaming must hold both isp->mutex and isp->lock.
         * Readers of streaming need to hold only one of the two locks.
         */
-       unsigned int streaming;
+       bool streaming;
        bool stream_prepared; /* whether css stream is created */
 
        unsigned int latest_preview_exp_id; /* CSS ZSL/SDV raw buffer id */
index f914ab9..c68e906 100644 (file)
@@ -672,7 +672,7 @@ static int atomisp_suspend(struct device *dev)
                return -EBUSY;
 
        spin_lock_irqsave(&isp->lock, flags);
-       if (isp->asd.streaming != ATOMISP_DEVICE_STREAMING_DISABLED) {
+       if (isp->asd.streaming) {
                spin_unlock_irqrestore(&isp->lock, flags);
                dev_err(isp->dev, "atomisp cannot suspend at this time.\n");
                return -EINVAL;