mbox series

[v4,00/32] media: ov2680: Bugfixes + ACPI + selection(crop-tgt) API support

Message ID 20230802173046.368434-1-hdegoede@redhat.com
Headers show
Series media: ov2680: Bugfixes + ACPI + selection(crop-tgt) API support | expand

Message

Hans de Goede Aug. 2, 2023, 5:30 p.m. UTC
Hi All,

Here is v4 of my ov2680 sensor driver patch series.
Also available in this branch:
https://git.kernel.org/pub/scm/linux/kernel/git/hansg/linux.git/log/?h=media-ov2680

Changes in v4:
- Rebase on top of latest sailus/media_tree/master (69142f89b61e)
- Do not set v4l2_subdev.fwnode (let v4l2-core do endpoint matching)
- Make enum_frame_interval() input checks more strict
- Make enum_frame_size() returned full-size + binned-/quarter-size
- Use V4L2_CID_ANALOGUE_GAIN for gain
- 3 new patches:
  "media: ov2680: Add bus-cfg / endpoint property verification"
  "media: ipu-bridge: Add link-frequency to OV2680 ipu_supported_sensors[] entry"
  "media: atomisp: Drop atomisp-ov2680 sensor driver"

Changes in v3:
- Add Rui Miguel Silva's Ack for the series
- 2 small fixes for remarks from Andy
- Add a new patch adding me as co-maintainer in MAINTAINERS

Changes in v2
- Drop "media: Add MIPI CCI register access helper functions"
  (being reviewed in its own thread / patch-submission)
- Drop "media: ov2680: Add g_skip_frames op support"
- Add "media: ov2680: Fix regulators being left enabled on
  ov2680_power_on() errors"
- Add "media: ov2680: Add link-freq and pixel-rate controls"
  with this the driver now works on IPU3 with ipu3-capture.sh
  (libcamera support requires adding a couple more controls)
- Limit line length to 80 chars everywhere
- Address various small remarks from Andy

During all the work done on the atomisp driver I have mostly been testing
on devices with an ov2680 sensor. As such I have also done a lot of work
on the atomisp-ov2680.c atomisp specific sensor driver.

With the latest atomisp code from:
https://git.kernel.org/pub/scm/linux/kernel/git/hansg/linux.git/tag/?h=media-atomisp-6.5-1

The atomisp code can now work with standard v4l2 sensor drivers using
the selections (crop-tgt) api and v4l2-async sensor driver registration.

This patch series modifies the main drivers/media/i2c/ov2680.c driver
to add bugfixes, ACPI enumeration, selection API support and further
improvments. After this the driver can be used with the atomisp driver
and atomisp-ov2680.c can be dropped.

This also gets the driver much closer to having everything needed for
use with IPU3 / libcamera. I have a Lenovo Miix 510 now with an IPU3 +
ov2680 sensor and with this series raw-capture using the ipu3-capture.sh
script works. I plan to work on libcamera support for this in the near
future.

Regards,

Hans


Hans de Goede (32):
  media: ov2680: Remove auto-gain and auto-exposure controls
  media: ov2680: Fix ov2680_bayer_order()
  media: ov2680: Fix vflip / hflip set functions
  media: ov2680: Remove VIDEO_V4L2_SUBDEV_API ifdef-s
  media: ov2680: Don't take the lock for try_fmt calls
  media: ov2680: Add ov2680_fill_format() helper function
  media: ov2680: Fix ov2680_set_fmt() which == V4L2_SUBDEV_FORMAT_TRY
    not working
  media: ov2680: Fix regulators being left enabled on ov2680_power_on()
    errors
  media: ov2680: Convert to new CCI register access helpers
  media: ov2680: Store dev instead of i2c_client in ov2680_dev
  media: ov2680: Add runtime-pm support
  media: ov2680: Check for "powerdown" GPIO con-id before checking for
    "reset" GPIO con-id
  media: ov2680: Drop is_enabled flag
  media: ov2680: Add support for more clk setups
  media: ov2680: Add support for 19.2 MHz clock
  media: ov2680: Wait for endpoint fwnode before continuing with probe()
  media: ov2680: Add support for ACPI enumeration
  media: ov2680: Fix ov2680_enum_frame_interval()
  media: ov2680: Annotate the per mode register setting lists
  media: ov2680: Add ov2680_mode struct
  media: ov2680: Make setting the mode algorithm based
  media: ov2680: Add an __ov2680_get_pad_format() helper function
  media: ov2680: Implement selection support
  media: ov2680: Fix exposure and gain ctrls range and default value
  media: ov2680: Add a bunch of register tweaks
  media: ov2680: Drop unnecessary pad checks
  media: ov2680: Read and log sensor revision during probe
  media: ov2680: Add link-freq and pixel-rate controls
  media: ov2680: Add bus-cfg / endpoint property verification
  MAINTAINERS: Add Hans de Goede as OV2680 sensor driver maintainer
  media: ipu-bridge: Add link-frequency to OV2680
    ipu_supported_sensors[] entry
  media: atomisp: Drop atomisp-ov2680 sensor driver

 MAINTAINERS                                   |    1 +
 drivers/media/i2c/Kconfig                     |    1 +
 drivers/media/i2c/ov2680.c                    | 1380 +++++++++--------
 drivers/media/pci/intel/ipu-bridge.c          |    2 +-
 drivers/staging/media/atomisp/i2c/Kconfig     |   13 -
 drivers/staging/media/atomisp/i2c/Makefile    |    1 -
 .../media/atomisp/i2c/atomisp-ov2680.c        |  828 ----------
 drivers/staging/media/atomisp/i2c/ov2680.h    |  173 ---
 8 files changed, 752 insertions(+), 1647 deletions(-)
 delete mode 100644 drivers/staging/media/atomisp/i2c/atomisp-ov2680.c
 delete mode 100644 drivers/staging/media/atomisp/i2c/ov2680.h

Comments

Andy Shevchenko Aug. 2, 2023, 7:40 p.m. UTC | #1
On Wed, Aug 2, 2023 at 8:31 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Implement selection support. Modelled after ov5693 selection support,
> but allow setting sizes smaller than crop-size through set_fmt() since
> that was already allowed.

...

>  struct ov2680_mode {
> +       struct v4l2_rect                crop;
>         struct v4l2_mbus_framefmt       fmt;
>         struct v4l2_fract               frame_interval;
>         bool                            binning;

>  };

It might be useful to run pahole to check if you can make it shorter
and for how many bytes.

...

> -       width = min_t(unsigned int, ALIGN(format->format.width, 2),
> -                     OV2680_NATIVE_WIDTH);
> -       height = min_t(unsigned int, ALIGN(format->format.height, 2),
> -                      OV2680_NATIVE_HEIGHT);

Ah, short-live min_t(), but still...

...

> +       /* Make sure the crop rectangle isn't outside the bounds of the array */
> +       rect.width = min_t(unsigned int, rect.width,
> +                          OV2680_NATIVE_WIDTH - rect.left);
> +       rect.height = min_t(unsigned int, rect.height,
> +                           OV2680_NATIVE_HEIGHT - rect.top);

And here?
Hans de Goede Aug. 3, 2023, 9:28 a.m. UTC | #2
Hi,

On 8/3/23 11:17, Hans de Goede wrote:
> Hi,
> 
> On 8/2/23 21:37, Andy Shevchenko wrote:

<snip>

>>> +       width = min_t(unsigned int, ALIGN(format->format.width, 2),
>>> +                     OV2680_NATIVE_WIDTH);
>>> +       height = min_t(unsigned int, ALIGN(format->format.height, 2),
>>> +                      OV2680_NATIVE_HEIGHT);
>>
>> Wondering if you can switch these to use min() (with a strict type checking).
>> It might require adding U/UL to the respective constants.
> 
> 
> I'll try to switch to regular min() use here for v5.

Ok, so I tried and failed. format->format.height is an __u32 and even
if I add a 'u' suffix to OV2680_NATIVE_WIDTH regular min() does not
like it:

drivers/media/i2c/ov2680.c: In function ‘ov2680_calc_mode’:
./include/linux/minmax.h:20:35: warning: comparison of distinct pointer types lacks a cast
   20 |         (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
      |                                   ^~

Regards,

Hans