Re: [PATCH v4 01/11] media: atmel: atmel-isc: replace 'stop' variable with vb2 calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/7/22 12:46 PM, Jacopo Mondi wrote:
> Hi Eugen,
> 
> On Fri, Jan 21, 2022 at 03:14:06PM +0200, Eugen Hristev wrote:
>> The stop variable is redundant as the state of the streaming can be obtained
>> by calling vb2_start_streaming_called(&isc->vb2_vidq) or by calling
>> vb2_is_busy(&isc->vb2_vidq).
>> Thus, remove the stop variable completely.
>>
>> Suggested-by: Hans Verkuil <hverkuil@xxxxxxxxx>
>> Signed-off-by: Eugen Hristev <eugen.hristev@xxxxxxxxxxxxx>
> 
> I trust yours and Hans' judgment here.
> The patch looks sane
> Reviewed-by: Jacopo Mondi <jacopo+renesas@xxxxxxxxxx>
> 
> Thanks
>> ---
>> Changes in v4:
>> - new patch
>>
>>   drivers/media/platform/atmel/atmel-isc-base.c | 12 +++++-------
>>   drivers/media/platform/atmel/atmel-isc.h      |  2 --
>>   2 files changed, 5 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c
>> index db15770d5b88..9c62d0ae7887 100644
>> --- a/drivers/media/platform/atmel/atmel-isc-base.c
>> +++ b/drivers/media/platform/atmel/atmel-isc-base.c
>> @@ -362,7 +362,6 @@ static int isc_start_streaming(struct vb2_queue *vq, unsigned int count)
>>        spin_lock_irqsave(&isc->dma_queue_lock, flags);
>>
>>        isc->sequence = 0;
>> -     isc->stop = false;
>>        reinit_completion(&isc->comp);
>>
>>        isc->cur_frm = list_first_entry(&isc->dma_queue,
>> @@ -403,8 +402,6 @@ static void isc_stop_streaming(struct vb2_queue *vq)
>>
>>        v4l2_ctrl_activate(isc->do_wb_ctrl, false);
>>
>> -     isc->stop = true;
>> -
>>        /* Wait until the end of the current frame */
>>        if (isc->cur_frm && !wait_for_completion_timeout(&isc->comp, 5 * HZ))
>>                v4l2_err(&isc->v4l2_dev,
>> @@ -1029,7 +1026,7 @@ static int isc_s_fmt_vid_cap(struct file *file, void *priv,
>>   {
>>        struct isc_device *isc = video_drvdata(file);
>>
>> -     if (vb2_is_streaming(&isc->vb2_vidq))
>> +     if (vb2_is_busy(&isc->vb2_vidq))
>>                return -EBUSY;
>>
>>        return isc_set_fmt(isc, f);
>> @@ -1236,7 +1233,8 @@ irqreturn_t isc_interrupt(int irq, void *dev_id)
>>                        isc->cur_frm = NULL;
>>                }
>>
>> -             if (!list_empty(&isc->dma_queue) && !isc->stop) {
>> +             if (!list_empty(&isc->dma_queue) &&
>> +                 vb2_start_streaming_called(&isc->vb2_vidq)) {
>>                        isc->cur_frm = list_first_entry(&isc->dma_queue,
>>                                                     struct isc_buffer, list);
>>                        list_del(&isc->cur_frm->list);
>> @@ -1244,7 +1242,7 @@ irqreturn_t isc_interrupt(int irq, void *dev_id)
>>                        isc_start_dma(isc);
>>                }
>>
>> -             if (isc->stop)
>> +             if (!vb2_start_streaming_called(&isc->vb2_vidq))

Hello Hans, Jacopo,

This patch has a problem here. In the IRQ context, I cannot tell whether 
the stop streaming has been called or not.
When stop streaming is called, vb2_start_streaming_called still returns 
true.
So in the IRQ context I cannot know if I have to program the next buffer 
and start the next capture (next DMA), or I have to stop, and call 
complete on the isc completion , such that stop streaming will release 
all the other buffers.
To know this, it was previously done with the 'stop' variable which was 
set when stop_streaming was called.
Any idea how to handle this with vb2_ calls ?

Or I would have to rework this patch and keep the 'stop' internal variable ?

Thanks,
Eugen


>>                        complete(&isc->comp);
>>
>>                ret = IRQ_HANDLED;
>> @@ -1398,7 +1396,7 @@ static void isc_awb_work(struct work_struct *w)
>>        int ret;
>>
>>        /* streaming is not active anymore */
>> -     if (isc->stop)
>> +     if (!vb2_start_streaming_called(&isc->vb2_vidq))
>>                return;
>>
>>        if (ctrls->hist_stat != HIST_ENABLED)
>> diff --git a/drivers/media/platform/atmel/atmel-isc.h b/drivers/media/platform/atmel/atmel-isc.h
>> index 07fa6dbf8460..5fbf52a9080b 100644
>> --- a/drivers/media/platform/atmel/atmel-isc.h
>> +++ b/drivers/media/platform/atmel/atmel-isc.h
>> @@ -201,7 +201,6 @@ struct isc_reg_offsets {
>>    * @dma_queue:               the queue for dma buffers
>>    * @cur_frm:         current isc frame/buffer
>>    * @sequence:                current frame number
>> - * @stop:            true if isc is not streaming, false if streaming
>>    * @comp:            completion reference that signals frame completion
>>    *
>>    * @fmt:             current v42l format
>> @@ -276,7 +275,6 @@ struct isc_device {
>>        struct list_head        dma_queue;
>>        struct isc_buffer       *cur_frm;
>>        unsigned int            sequence;
>> -     bool                    stop;
>>        struct completion       comp;
>>
>>        struct v4l2_format      fmt;
>> --
>> 2.25.1
>>





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux