public inbox for linux-rockchip@lists.infradead.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Dafna Hirschfeld <dafna@fastmail.com>
Cc: linux-media@vger.kernel.org, Heiko Stuebner <heiko@sntech.de>,
	Paul Elder <paul.elder@ideasonboard.com>,
	Tomasz Figa <tfiga@google.com>,
	linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v3 14/17] media: rkisp1: debug: Collect input status by sampling ISP_FLAGS_SHD
Date: Tue, 22 Mar 2022 10:32:26 +0200	[thread overview]
Message-ID: <YjmJmoIxWcCdyrgl@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220322035624.mpkrod4g42xgpyfy@guri>

Hi Dafna,

On Tue, Mar 22, 2022 at 05:56:24AM +0200, Dafna Hirschfeld wrote:
> On 19.03.2022 18:30, Laurent Pinchart wrote:
> > The ISP_FLAGS_SHD register exposes the ISP parallel input signals (data
> > and synchronization) in real time. This can help debugging when the
> > device doesn't output any image. Sample the register 10000 times with a
> > 1µs delay and expose the result through debugfs.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> > ---
> >  .../platform/rockchip/rkisp1/rkisp1-debug.c   | 54 +++++++++++++++++++
> >  .../platform/rockchip/rkisp1/rkisp1-regs.h    |  9 ++++
> >  2 files changed, 63 insertions(+)
> > 
> > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c
> > index 64b33774cbdf..da3ed0ab697a 100644
> > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c
> > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c
> > @@ -9,9 +9,61 @@
> >   */
> >  
> >  #include <linux/debugfs.h>
> > +#include <linux/delay.h>
> >  #include <linux/device.h>
> > +#include <linux/pm_runtime.h>
> > +#include <linux/seq_file.h>
> >  
> >  #include "rkisp1-common.h"
> > +#include "rkisp1-regs.h"
> > +
> > +#define RKISP1_DEBUG_DATA_COUNT_BINS	32
> > +#define RKISP1_DEBUG_DATA_COUNT_STEP	(4096 / RKISP1_DEBUG_DATA_COUNT_BINS)
> > +
> > +static int rkisp1_debug_input_status_show(struct seq_file *m, void *p)
> > +{
> > +	struct rkisp1_device *rkisp1 = m->private;
> > +	u16 data_count[RKISP1_DEBUG_DATA_COUNT_BINS] = { };
> 
> Since this is just a counter, it could be int/short

Isn't u16 a short already ? Or do you mean using "short" instead of
"u16" ? That would be functionally equivalent, but I picked u16 to make
the size explicit, given that it has to hold values up to 10000.

> > +	unsigned int hsync_count = 0;
> > +	unsigned int vsync_count = 0;
> > +	unsigned int i;
> > +	u32 data;
> > +	u32 val;
> > +	int ret;
> > +
> > +	ret = pm_runtime_get_if_in_use(rkisp1->dev);
> > +	if (ret)
> > +		return ret;
> 
> We want to return here if the device is not is use right?
> If so we should return if (ret <= 0)

Correct, I'll fix that.

> > +
> > +	/* Sample the ISP input port status 10000 times with a 1µs interval. */
> > +	for (i = 0; i < 10000; ++i) {
> > +		val = rkisp1_read(rkisp1, RKISP1_CIF_ISP_FLAGS_SHD);
> > +
> > +		data = (val & RKISP1_CIF_ISP_FLAGS_SHD_S_DATA_MASK)
> > +		     >> RKISP1_CIF_ISP_FLAGS_SHD_S_DATA_SHIFT;
> 
> What is this data? the docs only says
> "state of ISP input port s_data, for test purposes"
> I guess it indicate somehow the amount of actuall sensor data arrived?
> Could be nice to add explanation here.

I'd the 12-bit parallel (pixel) data at the ISP input. I can add a
comment.

> > +		data_count[data / RKISP1_DEBUG_DATA_COUNT_STEP]++;
> > +
> > +		if (val & RKISP1_CIF_ISP_FLAGS_SHD_S_HSYNC)
> > +			hsync_count++;
> > +		if (val & RKISP1_CIF_ISP_FLAGS_SHD_S_VSYNC)
> > +			vsync_count++;
> > +
> > +		udelay(1);
> > +	}
> > +
> > +	pm_runtime_put(rkisp1->dev);
> > +
> > +	seq_printf(m, "vsync: %u, hsync: %u\n", vsync_count, hsync_count);
> > +	seq_puts(m, "data:\n");
> > +	for (i = 0; i < ARRAY_SIZE(data_count); ++i)
> > +		seq_printf(m, "- [%04u:%04u]: %u\n",
> > +			   i * RKISP1_DEBUG_DATA_COUNT_STEP,
> > +			   (i + 1) * RKISP1_DEBUG_DATA_COUNT_STEP - 1,
> > +			   data_count[i]);
> > +
> > +	return 0;
> > +}
> > +DEFINE_SHOW_ATTRIBUTE(rkisp1_debug_input_status);
> >  
> >  void rkisp1_debug_init(struct rkisp1_device *rkisp1)
> >  {
> > @@ -42,6 +94,8 @@ void rkisp1_debug_init(struct rkisp1_device *rkisp1)
> >  			     &debug->frame_drop[RKISP1_MAINPATH]);
> >  	debugfs_create_ulong("sp_frame_drop", 0444, debug->debugfs_dir,
> >  			     &debug->frame_drop[RKISP1_SELFPATH]);
> > +	debugfs_create_file("input_status", 0444, debug->debugfs_dir, rkisp1,
> > +			    &rkisp1_debug_input_status_fops);
> >  }
> >  
> >  void rkisp1_debug_cleanup(struct rkisp1_device *rkisp1)
> > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h
> > index 083d92ada73f..447c5f241d69 100644
> > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h
> > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h
> > @@ -454,6 +454,15 @@
> >  #define RKISP1_CIF_ISP_DEMOSAIC_BYPASS			BIT(10)
> >  #define RKISP1_CIF_ISP_DEMOSAIC_TH(x)			((x) & 0xFF)
> >  
> > +/* ISP_FLAGS_SHD */
> > +#define RKISP1_CIF_ISP_FLAGS_SHD_ISP_ENABLE_SHD		BIT(0)
> > +#define RKISP1_CIF_ISP_FLAGS_SHD_ISP_ENABLE_INFORM_SHD	BIT(1)
> > +#define RKISP1_CIF_ISP_FLAGS_SHD_INFORM_FIELD		BIT(2)
> > +#define RKISP1_CIF_ISP_FLAGS_SHD_S_DATA_MASK		GENMASK(27, 16)
> > +#define RKISP1_CIF_ISP_FLAGS_SHD_S_DATA_SHIFT		16
> > +#define RKISP1_CIF_ISP_FLAGS_SHD_S_VSYNC		BIT(30)
> > +#define RKISP1_CIF_ISP_FLAGS_SHD_S_HSYNC		BIT(31)
> > +
> >  /* AWB */
> >  /* ISP_AWB_PROP */
> >  #define RKISP1_CIF_ISP_AWB_YMAX_CMP_EN			BIT(2)

-- 
Regards,

Laurent Pinchart

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

  reply	other threads:[~2022-03-22  8:32 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-19 16:30 [PATCH v3 00/17] media: rkisp1: Misc bug fixes and cleanups Laurent Pinchart
2022-03-19 16:30 ` [PATCH v3 01/17] media: rkisp1: capture: Initialize entity before video device Laurent Pinchart
2022-03-19 16:30 ` [PATCH v3 02/17] media: rkisp1: capture: Fix and simplify (un)registration Laurent Pinchart
2022-03-19 16:30 ` [PATCH v3 03/17] media: rkisp1: isp: " Laurent Pinchart
2022-03-22  4:23   ` Dafna Hirschfeld
2022-03-22  9:58     ` Laurent Pinchart
2022-03-19 16:30 ` [PATCH v3 04/17] media: rkisp1: resizer: " Laurent Pinchart
2022-03-19 16:30 ` [PATCH v3 05/17] media: rkisp1: params: " Laurent Pinchart
2022-03-22  4:27   ` Dafna Hirschfeld
2022-03-22 10:01     ` Laurent Pinchart
2022-03-19 16:30 ` [PATCH v3 06/17] media: rkisp1: stats: Simplify (un)registration Laurent Pinchart
2022-03-19 16:30 ` [PATCH v3 07/17] media: rkisp1: Simplify rkisp1_entities_register() error path Laurent Pinchart
2022-03-19 16:30 ` [PATCH v3 08/17] media: rkisp1: regs: Don't use BIT() macro for multi-bit register fields Laurent Pinchart
2022-03-22  5:07   ` Dafna Hirschfeld
2022-03-19 16:30 ` [PATCH v3 09/17] media: rkisp1: regs: Rename CCL, ICCL and IRCL registers with VI_ prefix Laurent Pinchart
2022-03-22  5:12   ` Dafna Hirschfeld
2022-03-19 16:30 ` [PATCH v3 10/17] media: rkisp1: Swap value and address arguments to rkisp1_write() Laurent Pinchart
2022-03-22  4:37   ` Dafna Hirschfeld
2022-03-19 16:30 ` [PATCH v3 11/17] media: rkisp1: resizer: Simplify register access Laurent Pinchart
2022-03-19 16:30 ` [PATCH v3 12/17] media: rkisp1: Move debugfs code to a separate file Laurent Pinchart
2022-03-22  4:12   ` Dafna Hirschfeld
2022-03-19 16:30 ` [PATCH v3 13/17] media: rkisp1: Compile debugfs support conditionally Laurent Pinchart
2022-03-21 12:11   ` kernel test robot
2022-03-21 12:44   ` [PATCH v3.1 " Laurent Pinchart
2022-03-22  4:12     ` Dafna Hirschfeld
2022-03-19 16:30 ` [PATCH v3 14/17] media: rkisp1: debug: Collect input status by sampling ISP_FLAGS_SHD Laurent Pinchart
2022-03-22  3:56   ` Dafna Hirschfeld
2022-03-22  8:32     ` Laurent Pinchart [this message]
2022-03-25 18:22       ` Dafna Hirschfeld
2022-03-19 16:30 ` [PATCH v3 15/17] media: rkisp1: debug: Add debugfs files to dump core and ISP registers Laurent Pinchart
2022-03-22  5:25   ` Dafna Hirschfeld
2022-03-22 10:08     ` Laurent Pinchart
2022-03-19 16:30 ` [PATCH v3 16/17] media: rkisp1: debug: Move resizer register dump to debugfs Laurent Pinchart
2022-03-22  5:28   ` Dafna Hirschfeld
2022-03-22 10:10     ` Laurent Pinchart
2022-03-19 16:31 ` [PATCH v3 17/17] media: rkisp1: capture: Bypass the main device for handling querycap Laurent Pinchart
2022-03-22  5:08   ` 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=YjmJmoIxWcCdyrgl@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dafna@fastmail.com \
    --cc=heiko@sntech.de \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=paul.elder@ideasonboard.com \
    --cc=tfiga@google.com \
    /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