Commit 0f072c1e authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

media: atomisp: Turn asd->streaming state tracker into a bool

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: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent e1278e61
...@@ -475,7 +475,7 @@ irqreturn_t atomisp_isr(int irq, void *dev) ...@@ -475,7 +475,7 @@ irqreturn_t atomisp_isr(int irq, void *dev)
if (!atomisp_streaming_count(isp)) if (!atomisp_streaming_count(isp))
goto out_nowake; 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) { if (irq_infos & IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF) {
atomic_inc(&isp->asd.sof_count); atomic_inc(&isp->asd.sof_count);
atomisp_sof_event(&isp->asd); atomisp_sof_event(&isp->asd);
...@@ -950,12 +950,11 @@ static void __atomisp_css_recover(struct atomisp_device *isp) ...@@ -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); atomisp_css_irq_enable(isp, IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF, false);
if (isp->asd.streaming == ATOMISP_DEVICE_STREAMING_ENABLED || if (isp->asd.streaming || isp->asd.stream_prepared) {
isp->asd.stream_prepared) {
stream_restart = true; stream_restart = true;
spin_lock_irqsave(&isp->lock, flags); spin_lock_irqsave(&isp->lock, flags);
isp->asd.streaming = ATOMISP_DEVICE_STREAMING_STOPPING; isp->asd.streaming = false;
spin_unlock_irqrestore(&isp->lock, flags); spin_unlock_irqrestore(&isp->lock, flags);
/* stream off sensor */ /* stream off sensor */
...@@ -971,10 +970,6 @@ static void __atomisp_css_recover(struct atomisp_device *isp) ...@@ -971,10 +970,6 @@ static void __atomisp_css_recover(struct atomisp_device *isp)
css_pipe_id = atomisp_get_css_pipe_id(&isp->asd); css_pipe_id = atomisp_get_css_pipe_id(&isp->asd);
atomisp_css_stop(&isp->asd, css_pipe_id, true); 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.preview_exp_id = 1;
isp->asd.postview_exp_id = 1; isp->asd.postview_exp_id = 1;
/* notify HAL the CSS reset */ /* notify HAL the CSS reset */
...@@ -1003,7 +998,7 @@ static void __atomisp_css_recover(struct atomisp_device *isp) ...@@ -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"); "start SP failed, so do not set streaming to be enable!\n");
} else { } else {
spin_lock_irqsave(&isp->lock, flags); spin_lock_irqsave(&isp->lock, flags);
isp->asd.streaming = ATOMISP_DEVICE_STREAMING_ENABLED; isp->asd.streaming = true;
spin_unlock_irqrestore(&isp->lock, flags); spin_unlock_irqrestore(&isp->lock, flags);
} }
...@@ -1128,7 +1123,7 @@ irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr) ...@@ -1128,7 +1123,7 @@ irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr)
if (atomisp_css_isr_thread(isp)) if (atomisp_css_isr_thread(isp))
goto out; goto out;
if (isp->asd.streaming == ATOMISP_DEVICE_STREAMING_ENABLED) if (isp->asd.streaming)
atomisp_setup_flash(&isp->asd); atomisp_setup_flash(&isp->asd);
out: out:
mutex_unlock(&isp->mutex); mutex_unlock(&isp->mutex);
...@@ -3211,7 +3206,7 @@ void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe) ...@@ -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 * CSS/FW requires set parameter and enqueue buffer happen after ISP
* is streamon. * is streamon.
*/ */
if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED) if (!asd->streaming)
return; return;
if (list_empty(&pipe->per_frame_params) || if (list_empty(&pipe->per_frame_params) ||
...@@ -4761,7 +4756,7 @@ static int __checking_exp_id(struct atomisp_sub_device *asd, int exp_id) ...@@ -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__); dev_warn(isp->dev, "%s Raw Buffer Lock is disable.\n", __func__);
return -EINVAL; return -EINVAL;
} }
if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED) { if (!asd->streaming) {
dev_err(isp->dev, "%s streaming %d invalid exp_id %d.\n", dev_err(isp->dev, "%s streaming %d invalid exp_id %d.\n",
__func__, exp_id, asd->streaming); __func__, exp_id, asd->streaming);
return -EINVAL; return -EINVAL;
...@@ -4883,7 +4878,7 @@ int atomisp_enable_dz_capt_pipe(struct atomisp_sub_device *asd, ...@@ -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) 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; return -EINVAL;
lockdep_assert_held(&asd->isp->mutex); lockdep_assert_held(&asd->isp->mutex);
......
...@@ -3081,7 +3081,7 @@ int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd, ...@@ -3081,7 +3081,7 @@ int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd,
return -EINVAL; return -EINVAL;
/* isp needs to be streaming to get DIS statistics */ /* isp needs to be streaming to get DIS statistics */
if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED) if (!asd->streaming)
return -EINVAL; return -EINVAL;
if (atomisp_compare_dvs_grid(asd, &stats->dvs2_stat.grid_info) != 0) 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, ...@@ -3210,7 +3210,7 @@ static bool atomisp_css_isr_get_stream_id(struct ia_css_pipe *css_pipe,
struct atomisp_stream_env *stream_env; struct atomisp_stream_env *stream_env;
int i, j; int i, j;
if (isp->asd.streaming == ATOMISP_DEVICE_STREAMING_DISABLED) if (!isp->asd.streaming)
return false; return false;
for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) { for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
......
...@@ -411,7 +411,7 @@ static void atomisp_buf_queue(struct vb2_buffer *vb) ...@@ -411,7 +411,7 @@ static void atomisp_buf_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(&pipe->irq_lock, irqflags); spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
/* TODO: do this better, not best way to queue to css */ /* 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)) if (!list_empty(&pipe->buffers_waiting_for_param))
atomisp_handle_parameter_and_buffer(pipe); atomisp_handle_parameter_and_buffer(pipe);
else else
......
...@@ -168,10 +168,6 @@ struct atomisp_regs { ...@@ -168,10 +168,6 @@ struct atomisp_regs {
u32 csi_access_viol; 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 * ci device struct
*/ */
......
...@@ -601,7 +601,7 @@ static int atomisp_enum_input(struct file *file, void *fh, ...@@ -601,7 +601,7 @@ static int atomisp_enum_input(struct file *file, void *fh,
unsigned int atomisp_streaming_count(struct atomisp_device *isp) 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) ...@@ -1163,7 +1163,7 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)
} }
spin_lock_irqsave(&isp->lock, irqflags); spin_lock_irqsave(&isp->lock, irqflags);
asd->streaming = ATOMISP_DEVICE_STREAMING_ENABLED; asd->streaming = true;
spin_unlock_irqrestore(&isp->lock, irqflags); spin_unlock_irqrestore(&isp->lock, irqflags);
atomic_set(&asd->sof_count, -1); atomic_set(&asd->sof_count, -1);
atomic_set(&asd->sequence, -1); atomic_set(&asd->sequence, -1);
...@@ -1205,7 +1205,7 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count) ...@@ -1205,7 +1205,7 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)
if (ret) { if (ret) {
dev_err(isp->dev, "Starting sensor stream failed: %d\n", ret); dev_err(isp->dev, "Starting sensor stream failed: %d\n", ret);
spin_lock_irqsave(&isp->lock, irqflags); spin_lock_irqsave(&isp->lock, irqflags);
asd->streaming = ATOMISP_DEVICE_STREAMING_DISABLED; asd->streaming = false;
spin_unlock_irqrestore(&isp->lock, irqflags); spin_unlock_irqrestore(&isp->lock, irqflags);
ret = -EINVAL; ret = -EINVAL;
goto out_unlock; goto out_unlock;
...@@ -1246,7 +1246,7 @@ void atomisp_stop_streaming(struct vb2_queue *vq) ...@@ -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"); dev_warn(isp->dev, "Warning timeout waiting for CSS to return buffers\n");
spin_lock_irqsave(&isp->lock, flags); spin_lock_irqsave(&isp->lock, flags);
asd->streaming = ATOMISP_DEVICE_STREAMING_DISABLED; asd->streaming = false;
spin_unlock_irqrestore(&isp->lock, flags); spin_unlock_irqrestore(&isp->lock, flags);
atomisp_clear_css_buffer_counters(asd); atomisp_clear_css_buffer_counters(asd);
......
...@@ -299,7 +299,7 @@ struct atomisp_sub_device { ...@@ -299,7 +299,7 @@ struct atomisp_sub_device {
* Writers of streaming must hold both isp->mutex and isp->lock. * Writers of streaming must hold both isp->mutex and isp->lock.
* Readers of streaming need to hold only one of the two locks. * 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 */ bool stream_prepared; /* whether css stream is created */
unsigned int latest_preview_exp_id; /* CSS ZSL/SDV raw buffer id */ unsigned int latest_preview_exp_id; /* CSS ZSL/SDV raw buffer id */
......
...@@ -672,7 +672,7 @@ static int atomisp_suspend(struct device *dev) ...@@ -672,7 +672,7 @@ static int atomisp_suspend(struct device *dev)
return -EBUSY; return -EBUSY;
spin_lock_irqsave(&isp->lock, flags); spin_lock_irqsave(&isp->lock, flags);
if (isp->asd.streaming != ATOMISP_DEVICE_STREAMING_DISABLED) { if (isp->asd.streaming) {
spin_unlock_irqrestore(&isp->lock, flags); spin_unlock_irqrestore(&isp->lock, flags);
dev_err(isp->dev, "atomisp cannot suspend at this time.\n"); dev_err(isp->dev, "atomisp cannot suspend at this time.\n");
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment