linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Dan Scally <dan.scally@ideasonboard.com>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	jacopo.mondi@ideasonboard.com, nayden.kanchev@arm.com,
	robh+dt@kernel.org, mchehab@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
	jerome.forissier@linaro.org, kieran.bingham@ideasonboard.com,
	sakari.ailus@iki.fi
Subject: Re: [PATCH v5 05/16] media: mali-c55: Add Mali-C55 ISP driver
Date: Sun, 16 Jun 2024 22:39:01 +0300	[thread overview]
Message-ID: <20240616193901.GA10964@pendragon.ideasonboard.com> (raw)
In-Reply-To: <6d0be0cf-ff77-4943-8505-f78ad922e3fb@ideasonboard.com>

Hi Dan,

On Fri, Jun 14, 2024 at 11:13:29AM +0100, Daniel Scally wrote:
> On 30/05/2024 01:15, Laurent Pinchart wrote:
> > On Wed, May 29, 2024 at 04:28:47PM +0100, Daniel Scally wrote:
> >> Add a driver for Arm's Mali-C55 Image Signal Processor. The driver is
> >> V4L2 and Media Controller compliant and creates subdevices to manage
> >> the ISP itself, its internal test pattern generator as well as the
> >> crop, scaler and output format functionality for each of its two
> >> output devices.
> >>
> >> Acked-by: Nayden Kanchev <nayden.kanchev@arm.com>
> >> Co-developed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> >> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> >> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
> >> ---
> >> Changes in v5:
> >>
> >> 	- Reworked input formats - previously we allowed representing input data
> >> 	  as any 8-16 bit format. Now we only allow input data to be represented
> >> 	  by the new 20-bit bayer formats, which is corrected to the equivalent
> >> 	  16-bit format in RAW bypass mode.
> >> 	- Stopped bypassing blocks that we haven't added supporting parameters
> >> 	  for yet.
> >> 	- Addressed most of Sakari's comments from the list
> >>
> >> Changes not yet made in v5:
> >>
> >> 	- The output pipelines can still be started and stopped independently of
> >> 	  one another - I'd like to discuss that more.
> >> 	- the TPG subdev still uses .s_stream() - I need to rebase onto a tree
> >> 	  with working .enable_streams() for a single-source-pad subdevice.
> >>
> >> Changes in v4:
> >>
> >> 	- Reworked mali_c55_update_bits() to internally perform the bit-shift
> >
> > I really don't like that, it makes the code very confusing, even more so
> > as it differs from regmap_update_bits().
> >
> > Look at this for instance:
> >
> > 	mali_c55_update_bits(mali_c55, MALI_C55_REG_MCU_CONFIG,
> > 			     MALI_C55_REG_MCU_CONFIG_OVERRIDE_MASK,
> > 			     MALI_C55_REG_MCU_CONFIG_OVERRIDE_MASK);
> >
> > It only works by change because MALI_C55_REG_MCU_CONFIG_OVERRIDE_MASK is
> > BIT(0).
> >
> > Sorry, I know it will be painful, but this change needs to be reverted.
> 
> I'd like to argue for keeping this, on the grounds that it's better. I got lazy in the change you 
> reference there, and because BIT(0) is the same as 0x01 didn't bother changing it. I agree that 
> that's confusing but I think it would be better to keep the change and just update all the call 
> sites properly. The benefits as I see them are two:
> 
> 
> 1. This method ensures sane consistent calling of the function. Without the internal shift you have 
> to shift the values at the call site, but there's no reason to do that if the value you're setting 
> is 0x00 or if the field you're targeting in the register starts at bit 0, so I think writing code 
> naturally we'd have a mix of situations like so:
> 
> 
> #define REG_1 0xfc00
> 
> #define REG_2 0xff
> 
> mali_c55_update_bits(mali_c55, 0x1234, REG_1, 0x02 << 10);
> 
> mali_c55_update_bits(mali_c55, 0x1234, REG_1, 0x00);
> 
> mali_c55_update_bits(mali_c55, 0x1234, REG_2, 0x02);
>
> And I think that the mixture is more confusing than the difference with regmap_update_bits(). We 
> could include the bitshifting for consistencies sake despite it being unecessary, but it's extra 
> work for no real reason and itself "looks wrong" if the field starts at bit(0)...it would look less 
> wrong with an offset macro that defines the number of bits to shift as 0 but then we're on to 
> advantage #2...
> 
> 2. It makes the driver far cleaner. Without it we either have magic numbers scattered throughout 
> (and sometimes have to calculate them with extra variables where the write can target different 
> places conditionally) or have macros defining the number of bits to shift, or have to do (ffs(mask) 
> - 1) everywhere, and that tends to make the call sites a lot messier - this was the original reason 
> I moved it internal actually.
> 
> What do you think?

All register values (possibly with the exception of 0) should have
macros. The callers will thus not need to perform shifts manually, they
will all be handled in the register fields macros. From a caller point
of view, not handling the shifts inside mali_c55_update_bits() will not
make a difference.

It's the first time I notice a driver trying to shift internally in its
update_bits function. I think that's really confusing, especially given
that it departs from how regmap operates. I still strongly favour
handling the shifts in the register macros.

> >> 	- Reworked the resizer to allow cropping during streaming
> >> 	- Fixed a bug in NV12 output
> >>
> >> Changes in v3:
> >>
> >> 	- Mostly minor fixes suggested by Sakari
> >> 	- Fixed the sequencing of vb2 buffers to be synchronised across the two
> >> 	  capture devices.
> >>
> >> Changes in v2:
> >>
> >> 	- Clock handling
> >> 	- Fixed the warnings raised by the kernel test robot
> >>
> >>   drivers/media/platform/Kconfig                |   1 +
> >>   drivers/media/platform/Makefile               |   1 +
> >>   drivers/media/platform/arm/Kconfig            |   5 +
> >>   drivers/media/platform/arm/Makefile           |   2 +
> >>   drivers/media/platform/arm/mali-c55/Kconfig   |  18 +
> >>   drivers/media/platform/arm/mali-c55/Makefile  |   9 +
> >>   .../platform/arm/mali-c55/mali-c55-capture.c  | 951 ++++++++++++++++++
> >>   .../platform/arm/mali-c55/mali-c55-common.h   | 266 +++++
> >>   .../platform/arm/mali-c55/mali-c55-core.c     | 767 ++++++++++++++
> >>   .../platform/arm/mali-c55/mali-c55-isp.c      | 611 +++++++++++
> >>   .../arm/mali-c55/mali-c55-registers.h         | 258 +++++
> >>   .../arm/mali-c55/mali-c55-resizer-coefs.h     | 382 +++++++
> >>   .../platform/arm/mali-c55/mali-c55-resizer.c  | 779 ++++++++++++++
> >>   .../platform/arm/mali-c55/mali-c55-tpg.c      | 402 ++++++++
> >>   14 files changed, 4452 insertions(+)
> >>   create mode 100644 drivers/media/platform/arm/Kconfig
> >>   create mode 100644 drivers/media/platform/arm/Makefile
> >>   create mode 100644 drivers/media/platform/arm/mali-c55/Kconfig
> >>   create mode 100644 drivers/media/platform/arm/mali-c55/Makefile
> >>   create mode 100644 drivers/media/platform/arm/mali-c55/mali-c55-capture.c
> >>   create mode 100644 drivers/media/platform/arm/mali-c55/mali-c55-common.h
> >>   create mode 100644 drivers/media/platform/arm/mali-c55/mali-c55-core.c
> >>   create mode 100644 drivers/media/platform/arm/mali-c55/mali-c55-isp.c
> >>   create mode 100644 drivers/media/platform/arm/mali-c55/mali-c55-registers.h
> >>   create mode 100644 drivers/media/platform/arm/mali-c55/mali-c55-resizer-coefs.h
> >>   create mode 100644 drivers/media/platform/arm/mali-c55/mali-c55-resizer.c
> >>   create mode 100644 drivers/media/platform/arm/mali-c55/mali-c55-tpg.c

[snip]

-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2024-06-16 19:39 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29 15:28 [PATCH v5 00/16] Add Arm Mali-C55 Image Signal Processor Driver Daniel Scally
2024-05-29 15:28 ` [PATCH v5 01/16] media: uapi: Add MEDIA_BUS_FMT_RGB202020_1X60 format code Daniel Scally
2024-05-29 18:14   ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 02/16] media: uapi: Add 20-bit bayer formats Daniel Scally
2024-05-29 18:18   ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 03/16] media: v4l2-common: Add RAW16 format info Daniel Scally
2024-05-29 18:20   ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 04/16] dt-bindings: media: Add bindings for ARM mali-c55 Daniel Scally
2024-05-29 18:21   ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 06/16] media: Documentation: Add Mali-C55 ISP Documentation Daniel Scally
2024-05-29 20:22   ` Laurent Pinchart
2024-05-29 20:35     ` Dan Scally
2024-05-29 20:51       ` Laurent Pinchart
2024-05-29 21:11         ` Dan Scally
2024-05-29 21:31           ` Dan Scally
2024-05-29 15:28 ` [PATCH v5 07/16] MAINTAINERS: Add entry for mali-c55 driver Daniel Scally
2024-05-29 18:25   ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 08/16] media: Add MALI_C55_3A_STATS meta format Daniel Scally
2024-05-30 21:49   ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 09/16] media: uapi: Add 3a stats buffer for mali-c55 Daniel Scally
2024-05-30 22:24   ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 10/16] media: platform: Add mali-c55 3a stats devnode Daniel Scally
2024-06-16 21:19   ` Laurent Pinchart
2024-06-20 15:10     ` Dan Scally
2024-06-29 15:04       ` Laurent Pinchart
2024-07-01 15:12         ` Dan Scally
2024-07-02  7:00           ` Dan Scally
2024-07-21 23:27             ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 11/16] media: platform: Fill stats buffer on ISP_START Daniel Scally
2024-05-29 15:28 ` [PATCH v5 12/16] Documentation: mali-c55: Add Statistics documentation Daniel Scally
2024-05-30 22:43   ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 13/16] media: mali-c55: Add image formats for Mali-C55 parameters buffer Daniel Scally
2024-05-30 22:44   ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 14/16] media: uapi: Add parameters structs to mali-c55-config.h Daniel Scally
2024-05-30  7:08   ` kernel test robot
2024-05-31  0:09   ` Laurent Pinchart
2024-05-31  7:30     ` Dan Scally
2024-06-02  0:24       ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 15/16] media: platform: Add mali-c55 parameters video node Daniel Scally
2024-05-30  7:18   ` kernel test robot
2024-05-30 12:54   ` kernel test robot
2024-06-14 18:53   ` Sakari Ailus
2024-06-14 20:15     ` Dan Scally
2024-06-14 21:11       ` Sakari Ailus
2024-06-14 21:49         ` Dan Scally
2024-06-16 21:32           ` Laurent Pinchart
2024-05-29 15:28 ` [PATCH v5 16/16] Documentation: mali-c55: Document the mali-c55 parameter setting Daniel Scally
2024-05-30 22:54   ` Laurent Pinchart
2024-05-29 23:27 ` [PATCH v5 00/16] Add Arm Mali-C55 Image Signal Processor Driver Laurent Pinchart
     [not found] ` <20240529152858.183799-6-dan.scally@ideasonboard.com>
     [not found]   ` <20240530001507.GG10586@pendragon.ideasonboard.com>
     [not found]     ` <20240530214348.GA5213@pendragon.ideasonboard.com>
2024-06-06 12:47       ` [PATCH v5 05/16] media: mali-c55: Add Mali-C55 ISP driver Jacopo Mondi
2024-06-06 17:53         ` Laurent Pinchart
2024-06-06 19:10           ` Tomi Valkeinen
2024-06-09  6:21             ` Sakari Ailus
2024-06-16 20:38               ` Laurent Pinchart
2024-06-17  6:53                 ` Sakari Ailus
2024-06-17 22:49                   ` Laurent Pinchart
     [not found]     ` <6d0be0cf-ff77-4943-8505-f78ad922e3fb@ideasonboard.com>
2024-06-16 19:39       ` Laurent Pinchart [this message]
2024-06-17  6:31         ` Dan Scally

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=20240616193901.GA10964@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=conor+dt@kernel.org \
    --cc=dan.scally@ideasonboard.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=jerome.forissier@linaro.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nayden.kanchev@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@iki.fi \
    /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).