From: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
To: linux-media@vger.kernel.org
Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com,
dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl,
linux-rockchip@lists.infradead.org, helen.koike@collabora.com,
laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com,
kernel@collabora.com, ezequiel@collabora.com
Subject: [PATCH v3 04/12] media: staging: rkisp1: params: avoid using buffer if params is not streaming
Date: Tue, 22 Sep 2020 13:33:54 +0200 [thread overview]
Message-ID: <20200922113402.12442-5-dafna.hirschfeld@collabora.com> (raw)
In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com>
Currently, the first buffer queued in the params node is returned
immediately to userspace and a copy of it is saved in the field
'cur_params'. The copy is later used for the first configuration
when the stream is initiated by one of selfpath/mainpath capture nodes.
There are 3 problems with this implementation:
- The first params buffer is applied and returned to userspace even if
userspace never calls to streamon on the params node.
- If the first params buffer is queued after the stream started on the
params node then it will return to userspace but will never be used.
- The frame_sequence of the first buffer is set to -1 if the main/selfpath
did not start streaming.
A correct implementation is to apply the first params buffer when stream
is started from mainpath/selfpath and only if params is also streaming.
The patch adds a new function 'rkisp1_params_apply_params_cfg' which takes
a buffer from the buffers queue, apply it and returns it to userspace.
The function is called from the irq handler and when main/selfpath stream
starts - in the function 'rkisp1_params_config_parameter'
Also remove the fields 'cur_params', 'is_first_params' which are no
more needed.
Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reported-by: kernel test robot <lkp@intel.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
---
changes since v2:
declare function 'rkisp1_params_apply_params_cfg' as static
to fix a warning reported by 'kernel test robot <lkp@intel.com>'
---
drivers/staging/media/rkisp1/rkisp1-common.h | 4 --
drivers/staging/media/rkisp1/rkisp1-params.c | 50 ++++++++------------
2 files changed, 20 insertions(+), 34 deletions(-)
diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h
index 992d8ec4c448..232bee92d0eb 100644
--- a/drivers/staging/media/rkisp1/rkisp1-common.h
+++ b/drivers/staging/media/rkisp1/rkisp1-common.h
@@ -262,10 +262,8 @@ struct rkisp1_stats {
* @rkisp1: pointer to the rkisp1 device
* @config_lock: locks the buffer list 'params' and 'is_streaming'
* @params: queue of rkisp1_buffer
- * @cur_params: the first params values from userspace
* @vdev_fmt: v4l2_format of the metadata format
* @is_streaming: device is streaming
- * @is_first_params: the first params should take effect immediately
* @quantization: the quantization configured on the isp's src pad
* @raw_type: the bayer pattern on the isp video sink pad
*/
@@ -275,10 +273,8 @@ struct rkisp1_params {
spinlock_t config_lock; /* locks the buffers list 'params' and 'is_streaming' */
struct list_head params;
- struct rkisp1_params_cfg cur_params;
struct v4l2_format vdev_fmt;
bool is_streaming;
- bool is_first_params;
enum v4l2_quantization quantization;
enum rkisp1_fmt_raw_pat_type raw_type;
diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c
index ab2deb57b1eb..e8049a50575f 100644
--- a/drivers/staging/media/rkisp1/rkisp1-params.c
+++ b/drivers/staging/media/rkisp1/rkisp1-params.c
@@ -1185,23 +1185,14 @@ static void rkisp1_isp_isr_meas_config(struct rkisp1_params *params,
}
}
-void rkisp1_params_isr(struct rkisp1_device *rkisp1)
+static void rkisp1_params_apply_params_cfg(struct rkisp1_params *params,
+ unsigned int frame_sequence)
{
- unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence);
- struct rkisp1_params *params = &rkisp1->params;
struct rkisp1_params_cfg *new_params;
struct rkisp1_buffer *cur_buf = NULL;
- spin_lock(¶ms->config_lock);
- if (!params->is_streaming) {
- spin_unlock(¶ms->config_lock);
- return;
- }
-
- if (list_empty(¶ms->params)) {
- spin_unlock(¶ms->config_lock);
+ if (list_empty(¶ms->params))
return;
- }
cur_buf = list_first_entry(¶ms->params,
struct rkisp1_buffer, queue);
@@ -1218,6 +1209,20 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1)
cur_buf->vb.sequence = frame_sequence;
vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
+}
+
+void rkisp1_params_isr(struct rkisp1_device *rkisp1)
+{
+ unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence);
+ struct rkisp1_params *params = &rkisp1->params;
+
+ spin_lock(¶ms->config_lock);
+ if (!params->is_streaming) {
+ spin_unlock(¶ms->config_lock);
+ return;
+ }
+ rkisp1_params_apply_params_cfg(params, frame_sequence);
+
spin_unlock(¶ms->config_lock);
}
@@ -1290,9 +1295,9 @@ static void rkisp1_params_config_parameter(struct rkisp1_params *params)
else
rkisp1_csm_config(params, false);
- /* override the default things */
- rkisp1_isp_isr_other_config(params, ¶ms->cur_params);
- rkisp1_isp_isr_meas_config(params, ¶ms->cur_params);
+ /* apply the first buffer if there is one already */
+ if (params->is_streaming)
+ rkisp1_params_apply_params_cfg(params, 0);
spin_unlock(¶ms->config_lock);
}
@@ -1420,8 +1425,6 @@ static int rkisp1_params_vb2_queue_setup(struct vb2_queue *vq,
sizes[0] = sizeof(struct rkisp1_params_cfg);
INIT_LIST_HEAD(¶ms->params);
- params->is_first_params = true;
-
return 0;
}
@@ -1432,20 +1435,7 @@ static void rkisp1_params_vb2_buf_queue(struct vb2_buffer *vb)
container_of(vbuf, struct rkisp1_buffer, vb);
struct vb2_queue *vq = vb->vb2_queue;
struct rkisp1_params *params = vq->drv_priv;
- struct rkisp1_params_cfg *new_params;
unsigned long flags;
- unsigned int frame_sequence =
- atomic_read(¶ms->rkisp1->isp.frame_sequence);
-
- if (params->is_first_params) {
- new_params = (struct rkisp1_params_cfg *)
- (vb2_plane_vaddr(vb, 0));
- vbuf->sequence = frame_sequence;
- vb2_buffer_done(¶ms_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
- params->is_first_params = false;
- params->cur_params = *new_params;
- return;
- }
params_buf->vaddr = vb2_plane_vaddr(vb, 0);
spin_lock_irqsave(¶ms->config_lock, flags);
--
2.17.1
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2020-09-22 11:34 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-22 11:33 [PATCH v3 00/12] media: staging: rkisp1: various bug fixes Dafna Hirschfeld
2020-09-22 11:33 ` [PATCH v3 01/12] media: staging: rkisp1: params: upon stream stop, iterate a local list to return the buffers Dafna Hirschfeld
2020-09-25 19:08 ` Tomasz Figa
2020-09-22 11:33 ` [PATCH v3 02/12] media: staging: rkisp1: params: in the isr, return if buffer list is empty Dafna Hirschfeld
2020-09-22 11:33 ` [PATCH v3 03/12] media: staging: rkisp1: params: use the new effect value in cproc config Dafna Hirschfeld
2020-09-22 11:33 ` Dafna Hirschfeld [this message]
2020-09-25 20:16 ` [PATCH v3 04/12] media: staging: rkisp1: params: avoid using buffer if params is not streaming Tomasz Figa
2020-09-22 11:33 ` [PATCH v3 05/12] media: staging: rkisp1: params: set vb.sequence to be the isp's frame_sequence + 1 Dafna Hirschfeld
2020-09-22 11:33 ` [PATCH v3 06/12] media: staging: rkisp1: remove atomic operations for frame sequence Dafna Hirschfeld
2020-09-25 20:42 ` Tomasz Figa
2020-10-02 9:16 ` Dafna Hirschfeld
2020-10-02 15:30 ` Tomasz Figa
2020-11-06 14:43 ` Helen Koike
2020-11-10 10:40 ` Tomasz Figa
2020-09-22 11:33 ` [PATCH v3 07/12] media: staging: rkisp1: isp: add a warning and debugfs var for irq delay Dafna Hirschfeld
2020-09-22 11:33 ` [PATCH v3 08/12] media: staging: rkisp1: isp: don't enable signal RKISP1_CIF_ISP_FRAME_IN Dafna Hirschfeld
2020-09-22 11:33 ` [PATCH v3 09/12] media: staging: rkisp1: stats: protect write to 'is_streaming' in start_streaming cb Dafna Hirschfeld
2020-09-25 20:47 ` Tomasz Figa
2020-09-22 11:34 ` [PATCH v3 10/12] media: staging: rkisp1: params: no need to lock default config Dafna Hirschfeld
2020-09-22 11:34 ` [PATCH v3 11/12] media: staging: rkisp1: use the right variants of spin_lock Dafna Hirschfeld
2020-09-25 20:51 ` Tomasz Figa
2020-09-22 11:34 ` [PATCH v3 12/12] media: staging: rkisp1: cap: protect access to buf with the spin lock Dafna Hirschfeld
2020-09-25 20:53 ` Tomasz Figa
2020-09-27 9:43 ` Mauro Carvalho Chehab
2020-09-27 9:54 ` Dafna Hirschfeld
2020-09-27 11:05 ` Mauro Carvalho Chehab
2020-09-28 15:29 ` Dafna Hirschfeld
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200922113402.12442-5-dafna.hirschfeld@collabora.com \
--to=dafna.hirschfeld@collabora.com \
--cc=dafna3@gmail.com \
--cc=ezequiel@collabora.com \
--cc=helen.koike@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=kernel@collabora.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tfiga@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).