platform/kernel/linux-rpi.git
4 months agostaging: vchiq_arm: Add log_level module params
Phil Elwell [Fri, 29 Apr 2022 08:19:10 +0000 (09:19 +0100)]
staging: vchiq_arm: Add log_level module params

Add module parameters to control the logging levels for the various
vchiq logging categories.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agotpm_tis_spi_main: Force probe routine to run synchronously with driver and device...
Scovotto Davide [Wed, 20 Apr 2022 15:22:17 +0000 (17:22 +0200)]
tpm_tis_spi_main: Force probe routine to run synchronously with driver and device registration when IMA is enabled

Co-authored-by: Alberto Solavagione <albertosolavagione30@gmail.com>
Co-developed-by: Alberto Solavagione <albertosolavagione30@gmail.com>
Signed-off-by: Alberto Solavagione <albertosolavagione30@gmail.com>
Signed-off-by: Davide Scovotto <scovottodavide@gmail.com>
4 months agoclk-bcm2835: use subsys_initcall for the clock driver when IMA is enabled
Alberto Solavagione [Wed, 20 Apr 2022 15:15:42 +0000 (17:15 +0200)]
clk-bcm2835: use subsys_initcall for the clock driver when IMA is enabled

Co-authored-by: Davide Scovotto <scovottodavide@gmail.com>
Co-developed-by: Davide Scovotto <scovottodavide@gmail.com>
Signed-off-by: Davide Scovotto <scovottodavide@gmail.com>
Signed-off-by: Alberto Solavagione <albertosolavagione30@gmail.com>
4 months agodrm/panel: panel-ilitek9881c: Add prepare_upstream_first flag
Dave Stevenson [Thu, 31 Mar 2022 11:05:04 +0000 (12:05 +0100)]
drm/panel: panel-ilitek9881c: Add prepare_upstream_first flag

The panel sends MIPI DCS commands during prepare and is expecting
the bus to remain in LP-11 state in-between.

Set the prepare_upstream_first flag so that the upstream DSI host
is prepared / pre_enabled first, and therefore the bus is in a
defined state.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrm/panel: ilitek-ili9881c: Clean up on mipi_dsi_attach failure
Dave Stevenson [Thu, 31 Mar 2022 11:03:36 +0000 (12:03 +0100)]
drm/panel: ilitek-ili9881c: Clean up on mipi_dsi_attach failure

mipi_dsi_attach is allowed to fail, and currently the probe
code doesn't clean up (mainly drm_panel_remove) if this happens.

Add cleanup code on failure.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agopinctrl: bcm2835: Only return non-GPIOs to inputs
Phil Elwell [Wed, 30 Mar 2022 08:48:41 +0000 (09:48 +0100)]
pinctrl: bcm2835: Only return non-GPIOs to inputs

Allowing GPIO state to persist allows the use of gpioset to control
GPIO levels without having to use the --mode=wait feature.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agomm,page_alloc,cma: introduce a customisable threshold for allocating pages in cma
David Plowman [Tue, 29 Mar 2022 15:10:06 +0000 (16:10 +0100)]
mm,page_alloc,cma: introduce a customisable threshold for allocating pages in cma

On some platforms the cma area can be half the entire system memory,
meaning that allocations start happening in the cma area immediately.
This leads to fragmentation and subsequent fatal cma_alloc failures.

We introduce an "alloc_in_cma_threshold" parameter which requires that
this many sixteenths of the free pages must be in cma before it will
try to use them. By default this is set to 12, but the previous
behaviour can be restored by setting it to 8 on startup.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 months agodrivers: staging: bcm2835-isp: Clear LS table handle in the firmware
Naushir Patuck [Tue, 22 Mar 2022 15:16:40 +0000 (15:16 +0000)]
drivers: staging: bcm2835-isp: Clear LS table handle in the firmware

When all nodes have stopped streaming, ensure the firmware has released its
handle on the LS table dmabuf. This is done by passing a null handle in the
LS params.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agomedia: i2c: Rename ad5398 to ad5398_vcm
Dave Stevenson [Thu, 17 Mar 2022 15:13:10 +0000 (15:13 +0000)]
media: i2c: Rename ad5398 to ad5398_vcm

There's already a regulator module called ad5398 that exposes
this device through the regulator API. That is meaningless in
the terms that it uses and how it maps to V4L2, so a new driver
was added. However the module name collision wasn't noted, so
rename it now.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agomedia: i2c: ov5647: Use v4l2_async_register_subdev_sensor for lens binding
Dave Stevenson [Wed, 16 Mar 2022 12:15:41 +0000 (12:15 +0000)]
media: i2c: ov5647: Use v4l2_async_register_subdev_sensor for lens binding

v4l2_async_register_subdev doesn't bind in lens or flash drivers,
but v4l2_async_register_subdev_sensor does.
Switch to using v4l2_async_register_subdev_sensor.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agomedia: i2c: Add driver for AD5398 VCM lens driver
Dave Stevenson [Wed, 29 Sep 2021 13:04:28 +0000 (14:04 +0100)]
media: i2c: Add driver for AD5398 VCM lens driver

Adds a driver for the Analog Devices AD5398 10 bit
I2C DAC which is commonly used for driving VCM lens
mechanisms.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodt-bindings: media: i2c: Add binding for ad5398 VCM
Dave Stevenson [Wed, 29 Sep 2021 11:33:35 +0000 (12:33 +0100)]
dt-bindings: media: i2c: Add binding for ad5398 VCM

Add a binding for Analog Devices AD5398 10bit current
sinking DAC when used as a lens VCM driver.

FIXME: Convert to YAML

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrivers: staging: bcm2835-isp: Do not cleanup mmal vcsm buffer on stop_streaming
Naushir Patuck [Thu, 3 Mar 2022 16:45:53 +0000 (16:45 +0000)]
drivers: staging: bcm2835-isp: Do not cleanup mmal vcsm buffer on stop_streaming

On stop_streaming() the vcsm buffer handle gets released by the buffer cleanup
code.  This will subsequently cause and error if userland re-queues the same
buffer on the next start_streaming() call.

Remove this cleanup code and rely on the vb2_ops->buf_cleanup() call to do the
cleanups instead.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agostaging: vc04_services: isp: Permit all sRGB colour spaces on ISP outputs
David Plowman [Wed, 2 Mar 2022 16:47:37 +0000 (16:47 +0000)]
staging: vc04_services: isp: Permit all sRGB colour spaces on ISP outputs

ISP outputs actually support all colour spaces that are fundamentally
sRGB underneath, regardless of whether an RGB or YUV output format is
actually requested.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 months agomedia/i2c: Add driver for Omnivision OV2311
Dave Stevenson [Fri, 25 Feb 2022 18:16:13 +0000 (18:16 +0000)]
media/i2c: Add driver for Omnivision OV2311

Omnivision OV2311 is a CSI2 1600x1300 global shutter image sensor.
Add a driver for it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: i2c: Update ov2311 Kconfig entry

Bring the OV2311 Kconfig declaration in line with upstream entries.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
media: i2c: ov2311: Fix uninitialized variable usage

Signed-off-by: Alexander Winkowski <dereference23@outlook.com>
4 months agomedia: i2c: ov7251: Reinstate setting ov7251_global_init_setting
Dave Stevenson [Thu, 17 Feb 2022 14:48:30 +0000 (14:48 +0000)]
media: i2c: ov7251: Reinstate setting ov7251_global_init_setting

"media: i2c: Remove .s_power() from ov7251" removed the call that
sent ov7251_global_init_setting to the sensor. Send it when starting
streaming.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agomedia: bcm2835-unicam: Handle a repeated frame start with no end
Dave Stevenson [Fri, 4 Feb 2022 16:12:35 +0000 (16:12 +0000)]
media: bcm2835-unicam: Handle a repeated frame start with no end

In the case of 2 frame starts being received with no frame end
between, the queued buffer held in next_frm was lost as the
pointer was overwritten with the dummy buffer.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agospi: gpio: Add sck-idle-input property
Phil Elwell [Wed, 12 Jan 2022 08:23:28 +0000 (08:23 +0000)]
spi: gpio: Add sck-idle-input property

The sck-idle-input property indicates that the spi-gpio driver should
return the SCK line to an input when the chip select signals are
inactive.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agobindings: Add sck-idle-input to spi-gpio
Phil Elwell [Fri, 4 Feb 2022 11:33:28 +0000 (11:33 +0000)]
bindings: Add sck-idle-input to spi-gpio

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agodrm/panel: Add panel driver for TDO Y17B based panels
Dave Stevenson [Wed, 26 Jan 2022 16:02:31 +0000 (16:02 +0000)]
drm/panel: Add panel driver for TDO Y17B based panels

The Top DisplayOptoelectronics (TDO) T17B driver chip is used
in the TL040HDS20CT panel (found in the Pimoroni HyperPixel4
Square display) and potentially other displays.
The driver chip supports SPI for  configuration and DPI
video data.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrm/panel: Add panel driver for Ilitek ILI9806E panel
Dave Stevenson [Wed, 5 Jan 2022 19:14:48 +0000 (19:14 +0000)]
drm/panel: Add panel driver for Ilitek ILI9806E panel

The Ilitek ILI9806E driver is used in the Pimoroni HyperPixel4
and potentially other displays. Whilst it can support multiple
interfaces, this driver only accounts for SPI configuration and
DPI video data.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrm/panel: simple: Remove custom handling of orientation
Dave Stevenson [Tue, 1 Feb 2022 12:24:51 +0000 (12:24 +0000)]
drm/panel: simple: Remove custom handling of orientation

Panel orientation is now handled by the drm_panel and
panel_bridge frameworks, so remove the custom handling.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrm/panel: simple: add Geekworm MZP280 Panel
Chris Morgan [Fri, 28 Jan 2022 23:42:12 +0000 (17:42 -0600)]
drm/panel: simple: add Geekworm MZP280 Panel

Add support for the Geekworm MZP280 Panel

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
Acked-by: Maxime Ripard <maxime@cerno.tech>
4 months agodt-bindings: display: simple: add Geekworm MZP280 Panel
Chris Morgan [Fri, 28 Jan 2022 23:41:18 +0000 (17:41 -0600)]
dt-bindings: display: simple: add Geekworm MZP280 Panel

The Geekworm MZP280 panel is a 480x640 (portrait) panel with a
capacitive touch interface and a 40 pin header meant to interface
directly with the Raspberry Pi. The screen is 2.8 inches diagonally,
and there appear to be at least 4 distinct versions all with the same
panel timings.

Timings were derived from drivers posted on the github located here:
https://github.com/tianyoujian/MZDPI/tree/master/vga

Additional details about this panel family can be found here:
https://wiki.geekworm.com/2.8_inch_Touch_Screen_for_Pi_zero

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
4 months agodt-bindings: vendor-prefixes: Add Geekworm
Chris Morgan [Fri, 28 Jan 2022 23:40:50 +0000 (17:40 -0600)]
dt-bindings: vendor-prefixes: Add Geekworm

Add vendor prefix for Geekworm (https://geekworm.com).

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
4 months agomedia: uapi: Document format MEDIA_BUS_FMT_RGB565_1X24_CPADHI
Chris Morgan [Fri, 28 Jan 2022 23:37:43 +0000 (17:37 -0600)]
media: uapi: Document format MEDIA_BUS_FMT_RGB565_1X24_CPADHI

Add support for MEDIA_BUS_FMT_RGB565_1X24_CPADHI. This format is used
by the Geekworm MZP280 panel which interfaces with the Raspberry Pi.

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
4 months agoPatching lan78xx for SOF_TIMESTAMPING_TX_SOFTWARE support
tiagofreire-pt [Sat, 29 Jan 2022 10:01:36 +0000 (10:01 +0000)]
Patching lan78xx for SOF_TIMESTAMPING_TX_SOFTWARE support

4 months agoi2c: bcm2835: Make clock-stretch timeout configurable
Alex Crawford [Fri, 28 Jan 2022 21:36:51 +0000 (13:36 -0800)]
i2c: bcm2835: Make clock-stretch timeout configurable

The default clock-stretch timeout is 35 mS, which works well for
SMBus, but there are some I2C devices which can stretch the clock even
longer. Rather than trying to prescribe a safe default for everyone,
allow the timeout to be configured.

Signed-off-by: Alex Crawford <raspberrypi/linux@code.acrawford.com>
4 months agomedia: bcm2835-unicam: Set ret on error path in unicam_async_complete()
Nathan Chancellor [Tue, 1 Feb 2022 00:23:38 +0000 (17:23 -0700)]
media: bcm2835-unicam: Set ret on error path in unicam_async_complete()

Clang warns:

  drivers/media/platform/bcm2835/bcm2835-unicam.c:3109:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
          if (!source_pads) {
              ^~~~~~~~~~~~
  drivers/media/platform/bcm2835/bcm2835-unicam.c:3152:9: note: uninitialized use occurs here
          return ret;
                 ^~~
  drivers/media/platform/bcm2835/bcm2835-unicam.c:3109:2: note: remove the 'if' if its condition is always false
          if (!source_pads) {
          ^~~~~~~~~~~~~~~~~~~
  drivers/media/platform/bcm2835/bcm2835-unicam.c:3091:9: note: initialize the variable 'ret' to silence this warning
          int ret;
                 ^
                  = 0
  1 warning generated.

When the if condition is true, ret will be used uninitialized, which
could result in undesirable behavior. Set ret to -ENODEV on the error
path, which is a standard error code for the ->complete() callback.

Fixes: d056e86eb35f ("media/bcm2835-unicam: Parse pad numbers correctly")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
4 months agoExtending ili9881c driver support for nwe080 panel
Dom Cobley [Tue, 12 Sep 2023 19:11:26 +0000 (20:11 +0100)]
Extending ili9881c driver support for nwe080 panel

Signed-off-by: Penk Chen <penk@cutiepi.io>
4 months agodrivers: bcm2835_unicam: Disable trigger mode operation
Naushir Patuck [Tue, 18 Jan 2022 13:13:14 +0000 (13:13 +0000)]
drivers: bcm2835_unicam: Disable trigger mode operation

On a Pi3 B/B+ platform the imx219 sensor frequently generates a single corrupt
frame when the sensor first starts. This can either be a missing line, or
invalid samples within the line. This only occurrs using the Unicam kernel
driver.

Disabling trigger mode elimiates this corruption. Since trigger mode is a
legacy feature copied from the firmware driver and not expected to be needed,
remove it. Tested on the Raspberry Pi cameras and shows no ill effects.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agopower: rpi-poe: Add option of being created by MFD or FW
Dave Stevenson [Thu, 20 Jan 2022 15:50:27 +0000 (15:50 +0000)]
power: rpi-poe: Add option of being created by MFD or FW

The firmware can only use I2C0 if the kernel isn't, therefore
with libcamera and DRM using it the PoE HAT fan control needs
to move to the kernel.

Add the option for the driver to be created by the PoE HAT core
MFD driver, and use the I2C regmap that provides to control fan
functions.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agopower: rpi-poe: Drop CURRENT_AVG as it is not hardware averaged
Dave Stevenson [Thu, 20 Jan 2022 15:48:03 +0000 (15:48 +0000)]
power: rpi-poe: Drop CURRENT_AVG as it is not hardware averaged

As documented the _AVG parameters are meant to be hardware
averaged, but the implementation for the PoE+ HAT was done in
software in the firmware.

Drop the property.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agopwm: raspberrypi-poe: Add option of being created by MFD or FW
Dave Stevenson [Wed, 19 Jan 2022 17:26:22 +0000 (17:26 +0000)]
pwm: raspberrypi-poe: Add option of being created by MFD or FW

The firmware can only use I2C0 if the kernel isn't, therefore
with libcamera and DRM using it the PoE HAT fan control needs
to move to the kernel.

Add the option for the driver to be created by the PoE HAT core
MFD driver, and use the I2C regmap that provides to control fan
functions.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agomfd: simple-mfd-i2c: Add configuration for RPi POE HAT
Dave Stevenson [Wed, 19 Jan 2022 17:22:57 +0000 (17:22 +0000)]
mfd: simple-mfd-i2c: Add configuration for RPi POE HAT

The Raspbery Pi PoE+ HAT exposes a fan controller and power
supply status reporting via a single I2C address.

Create an MFD device that allows loading of the relevant
sub-drivers, with a shared I2C regmap.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agobcm2835-v4l2-isp: Add missing lock initialization
Padmanabha Srinivasaiah [Thu, 30 Dec 2021 20:45:10 +0000 (21:45 +0100)]
bcm2835-v4l2-isp: Add missing lock initialization

ISP device allocation is dynamic hence the locks too.
struct mutex queue_lock is not initialized which result in bug.

Fixing same by initializing it.

[   29.847138] INFO: trying to register non-static key.
[   29.847156] The code is fine but needs lockdep annotation, or maybe
[   29.847159] you didn't initialize this object before use?
[   29.847161] turning off the locking correctness validator.
[   29.847167] CPU: 1 PID: 343 Comm: v4l_id Tainted: G         C        5.15.11-rt24-v8+ #8
[   29.847187] Hardware name: Raspberry Pi 4 Model B Rev 1.4 (DT)
[   29.847194] Call trace:
[   29.847197]  dump_backtrace+0x0/0x1b8
[   29.847227]  show_stack+0x20/0x30
[   29.847240]  dump_stack_lvl+0x8c/0xb8
[   29.847254]  dump_stack+0x18/0x34
[   29.847263]  register_lock_class+0x494/0x4a0
[   29.847278]  __lock_acquire+0x80/0x1680
[   29.847289]  lock_acquire+0x214/0x3a0
[   29.847300]  mutex_lock_nested+0x70/0xc8
[   29.847312]  _vb2_fop_release+0x3c/0xa8 [videobuf2_v4l2]
[   29.847346]  vb2_fop_release+0x34/0x60 [videobuf2_v4l2]
[   29.847367]  v4l2_release+0xc8/0x108 [videodev]
[   29.847453]  __fput+0x8c/0x258
[   29.847476]  ____fput+0x18/0x28
[   29.847487]  task_work_run+0x98/0x180
[   29.847502]  do_notify_resume+0x228/0x3f8
[   29.847515]  el0_svc+0xec/0xf0
[   29.847523]  el0t_64_sync_handler+0x90/0xb8
[   29.847531]  el0t_64_sync+0x180/0x184

Signed-off-by: Padmanabha Srinivasaiah <treasure4paddy@gmail.com>
4 months agouapi/v4l2-controls: Reset V4L2_CID_USER_BCM2835_ISP_BASE to same as 5.10
Dave Stevenson [Tue, 4 Jan 2022 13:56:42 +0000 (13:56 +0000)]
uapi/v4l2-controls: Reset V4L2_CID_USER_BCM2835_ISP_BASE to same as 5.10

https://github.com/raspberrypi/linux/issues/4440

Upstream has added additional device specific controls, so the
V4L2_CID_USER_BASE + 0x10e0 value that had been defined for use with
the ISP has been taken by something else (and +0x10f0 has been used as
well)

Duplicate the use on V4L2_CID_USER_BASE + 0x10e0 so that userspace
(libcamera) doesn't need to change. Once the driver is upstream, then
we'll update libcamera to adopt the new value as it then won't change.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agostaging/bcm2835-isp: Fix cleanup after init fail
Phil Elwell [Thu, 16 Dec 2021 16:25:00 +0000 (16:25 +0000)]
staging/bcm2835-isp: Fix cleanup after init fail

bcm2835_isp_remove is called on an initialisation failure, but at that
point the drvdata hasn't been set. This causes a crash when e.g. using
the cutdown firmware (gpu_mem=16).

Move platform_set_drvdata before the instance probing loop to avoid the
problem.

See: https://github.com/raspberrypi/linux/issues/4774

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agomedia: i2c: ov7251: Make the enable GPIO optional.
Dave Stevenson [Tue, 14 Dec 2021 17:18:49 +0000 (17:18 +0000)]
media: i2c: ov7251: Make the enable GPIO optional.

Not all implementations wire up the enable GPIO and may just tie
it to a supply rail.
Make it optional.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agomedia: i2c: ov5647: Add support for regulator control.
Dave Stevenson [Mon, 22 Nov 2021 12:31:35 +0000 (12:31 +0000)]
media: i2c: ov5647: Add support for regulator control.

The driver supported using GPIOs to control the shutdown line,
but no regulator control.

Add regulator hooks.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrm/panel-simple: Allow the bus format to be read from DT for panel-dpi
Dave Stevenson [Thu, 2 Dec 2021 18:16:21 +0000 (18:16 +0000)]
drm/panel-simple: Allow the bus format to be read from DT for panel-dpi

The "panel-dpi" compatible string configures panel from device tree,
but it doesn't provide any way of configuring the bus format (colour
representation), nor does it populate it.

Add a DT parameter "bus-format" that allows the MEDIA_BUS_FMT_xxx value
to be specified from device tree.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrm/panel-simple: Populate bpc when using panel-dpi
Dave Stevenson [Thu, 2 Dec 2021 18:10:55 +0000 (18:10 +0000)]
drm/panel-simple: Populate bpc when using panel-dpi

panel-dpi doesn't know the bit depth, so in the same way that
DPI is guessed for the connector type, guess that it'll be 8bpc.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agortc: pcf8523: Fix oscillator stop bit handling
Phil Elwell [Mon, 29 Oct 2018 14:45:45 +0000 (14:45 +0000)]
rtc: pcf8523: Fix oscillator stop bit handling

See: https://github.com/raspberrypi/firmware/issues/1065

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agoregulator/rpi-panel-attiny: Don't read the LCD power status
Dave Stevenson [Mon, 29 Nov 2021 18:31:37 +0000 (18:31 +0000)]
regulator/rpi-panel-attiny: Don't read the LCD power status

The I2C to the Atmel is very fussy, and locks up easily on
Pi0-3 particularly on reads.

The LCD power status is controlled solely by this driver, so
rather than reading it back from the Atmel, use the cached
status last set.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrivers: bcm2835_unicam: Add logging message when a frame is dropped.
Naushir Patuck [Tue, 30 Nov 2021 10:39:41 +0000 (10:39 +0000)]
drivers: bcm2835_unicam: Add logging message when a frame is dropped.

If a dummy buffer is still active on a frame start, it indicates that this frame
will be dropped. The explicit logging helps users identify performance issues.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agospi: spidev: Restore loading from Device Tree
Phil Elwell [Mon, 29 Nov 2021 12:14:49 +0000 (12:14 +0000)]
spi: spidev: Restore loading from Device Tree

As happens occasionally, an upstream change has once again prevented
spidev from being loaded via Device Tree. We now need "spidev" to be
included in the new spi_device_id list, otherwise although the
spidev driver gets loaded no /dev/spidev*.* entries will appear.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agodrivers: bcm2835_isp: Fix div by 0 bug.
Naushir Patuck [Thu, 25 Nov 2021 08:59:58 +0000 (08:59 +0000)]
drivers: bcm2835_isp: Fix div by 0 bug.

Fix a possible division by 0 bug when setting up the mmal port for the stats
port.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agodrivers: bcm2835_isp: Allow multiple users for the ISP driver.
Naushir Patuck [Tue, 16 Nov 2021 12:38:44 +0000 (12:38 +0000)]
drivers: bcm2835_isp: Allow multiple users for the ISP driver.

Add a second (identical) set of device nodes to allow concurrent use of the ISP
hardware by another user. This change effectively creates a second state
structure (struct bcm2835_isp_dev) to maintain independent state for the second
user. Node and media entity names are appened with the instance index
appropriately.

Further users can be added by changing the BCM2835_ISP_NUM_INSTANCES define.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agomedia: i2c: ov5647: Support HFLIP and VFLIP
David Plowman [Mon, 22 Nov 2021 13:10:39 +0000 (13:10 +0000)]
media: i2c: ov5647: Support HFLIP and VFLIP

Add these missing V4L2 controls. Tested binned and full resolution
modes in all four orientations using Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 months agobrcmfmac: Don't promote INFO logging to ERR
Phil Elwell [Tue, 2 Nov 2021 11:13:42 +0000 (11:13 +0000)]
brcmfmac: Don't promote INFO logging to ERR

An unwanted side effect of enabling the BRCMDBG config setting is
redefining brcmf_info to be brcmf_err. This can be alarming to users
and makes it harder to spot real errors, so don't do it.

See: https://github.com/raspberrypi/linux/issues/4663

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agostaging/bcm2835-camera: Add support for MPEG_VIDEO_FORCE_KEY_FRAME
Gergo Koteles [Sun, 24 Oct 2021 21:18:09 +0000 (23:18 +0200)]
staging/bcm2835-camera: Add support for MPEG_VIDEO_FORCE_KEY_FRAME

Signed-off-by: Gergo Koteles <soyer@irl.hu>
4 months agostaging/bcm2835-camera: Add support for H264_MIN_QP, H264_MAX_QP
soyer [Sat, 23 Oct 2021 10:23:50 +0000 (12:23 +0200)]
staging/bcm2835-camera: Add support for H264_MIN_QP, H264_MAX_QP

Signed-off-by: Gergo Koteles <soyer@irl.hu>
4 months agomedia/bcm2835-unicam: Add support for configuration via MC API
Dave Stevenson [Fri, 15 Oct 2021 16:57:27 +0000 (17:57 +0100)]
media/bcm2835-unicam: Add support for configuration via MC API

Adds Media Controller API support for more complex pipelines.
libcamera is about to switch to using this mechanism for configuring
sensors.

This can be enabled by either a module parameter, or device tree.

Various functions have been moved to group video-centric and
mc-centric functions together.

Based on a similar conversion done to ti-vpe.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: bcm2835-unicam: Fixup for 5.18 and new get_mbus_config struct

The number of active CSI2 data lanes has moved within the struct
v4l2_mbus_config used by the get_mbus_config API call.
Update the driver to match the changes in mainline.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agomedia/bcm2835-unicam: Parse pad numbers correctly
Dave Stevenson [Wed, 23 Sep 2020 14:16:18 +0000 (15:16 +0100)]
media/bcm2835-unicam: Parse pad numbers correctly

The driver was making big assumptions about the source device
using pad 0 and 1, which doesn't follow for more complex
devices where Unicam's source device may be a sink device for
something else.

Read the pad numbers through media controller, and reference
them appropriately.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agovc04_services: isp: Report input node as wanting full range RAW color space
David Plowman [Thu, 21 Oct 2021 13:49:15 +0000 (14:49 +0100)]
vc04_services: isp: Report input node as wanting full range RAW color space

RAW color spaces are more usually reported as having full range
quantization.

Tested using libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 months agomedia: i2c: ov5647: Sensor should report RAW color space
David Plowman [Thu, 21 Oct 2021 13:47:00 +0000 (14:47 +0100)]
media: i2c: ov5647: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 months agodrivers/gpio: Add a driver that wraps the PWM API as a GPIO controller
Dave Stevenson [Thu, 14 Oct 2021 10:09:18 +0000 (11:09 +0100)]
drivers/gpio: Add a driver that wraps the PWM API as a GPIO controller

For cases where spare PWM outputs are available, but are desired
to be addressed a standard outputs instead.
Wraps a PWM channel as a new GPIO chip with the one output.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agostaging: mmal-vchiq: Reset buffers_with_vpu on port_enable
Dave Stevenson [Tue, 21 Sep 2021 16:17:57 +0000 (17:17 +0100)]
staging: mmal-vchiq: Reset buffers_with_vpu on port_enable

Should we go through the timeout failure case with port_disable
not returning all buffers for whatever reason, the
buffers_with_vpu counter gets left at a non-zero value, which
will cause reference counting issues should the instance be
reused.

Reset the count when the port is enabled again, but before
any buffers have been sent to the VPU.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agostaging/mmal-vchiq: Add module parameter to enable logging.
Dave Stevenson [Wed, 15 Sep 2021 16:54:11 +0000 (17:54 +0100)]
staging/mmal-vchiq: Add module parameter to enable logging.

Adds a module parameter "debug" to enable various logging levels.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agoAdd Raspberry Pi PoE+ HAT support
Serge Schneider [Mon, 2 Dec 2019 14:48:05 +0000 (14:48 +0000)]
Add Raspberry Pi PoE+ HAT support

Signed-off-by: Serge Schneider <serge@raspberrypi.com>
4 months agostaging/vchiq-mmal: Add the deinterlace image effects enums
Dave Stevenson [Fri, 6 Aug 2021 14:44:21 +0000 (15:44 +0100)]
staging/vchiq-mmal: Add the deinterlace image effects enums

As we're wanting to wrap the image_fx component for deinterlacing,
add the deinterlace algorithm values to enum mmal_parameter_imagefx

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agostaging/vchiq-mmal: Add parameters for interlaced video support
Dave Stevenson [Thu, 5 Aug 2021 15:38:34 +0000 (16:38 +0100)]
staging/vchiq-mmal: Add parameters for interlaced video support

Adds enum mmal_interlace_type and struct
mmal_parameter_video_interlace_type to allow for querying the
interlacing mode on decoders.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agostaging/vchiq-mmal: Add buffer flags for interlaced video
Dave Stevenson [Sun, 10 Jan 2021 19:05:17 +0000 (19:05 +0000)]
staging/vchiq-mmal: Add buffer flags for interlaced video

Add the buffer flags that the firmware uses to identify fields
on interlaced video

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agoInput: edt-ft54x6: Clean up timer and workqueue on remove
Dave Stevenson [Wed, 8 Sep 2021 13:46:17 +0000 (14:46 +0100)]
Input: edt-ft54x6: Clean up timer and workqueue on remove

If no interrupt is defined then a timer and workqueue are used
to poll the controller.
On remove these were not being cleaned up correctly.

Fixes: ca61fdaba79f "Input: edt-ft5x06: Poll the device if no interrupt is
configured."

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrm/panel-simple: Add a timing for the Raspberry Pi 7" panel
Dave Stevenson [Fri, 26 Mar 2021 17:06:36 +0000 (17:06 +0000)]
drm/panel-simple: Add a timing for the Raspberry Pi 7" panel

The Raspberry Pi 7" 800x480 panel uses a Toshiba TC358762 DSI
to DPI bridge chip, so there is a requirement for the timings
to be specified for the end panel. Add such a definition.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrm/panel/raspberrypi-touchscreen: Handle I2C errors.
Dave Stevenson [Wed, 8 Sep 2021 13:21:38 +0000 (14:21 +0100)]
drm/panel/raspberrypi-touchscreen: Handle I2C errors.

rpi_touchscreen_i2c_read returns any errors from i2c_transfer,
or the 8 bit received value.
Check for error values before trying to process the data as
valid.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agostaging: vchiq_arm: Usa a DMA pool for small bulks
detule [Tue, 2 Oct 2018 08:10:08 +0000 (04:10 -0400)]
staging: vchiq_arm: Usa a DMA pool for small bulks

During a bulk transfer we request a DMA allocation to hold the
scatter-gather list.  Most of the time, this allocation is small
(<< PAGE_SIZE), however it can be requested at a high enough frequency
to cause fragmentation and/or stress the CMA allocator (think time
spent in compaction here, or during allocations elsewhere).

Implement a pool to serve up small DMA allocations, falling back
to a coherent allocation if the request is greater than
VCHIQ_DMA_POOL_SIZE.

Signed-off-by: Oliver Gjoneski <ogjoneski@gmail.com>
4 months agostaging: vchiq_arm: children inherit DMA config
Phil Elwell [Tue, 21 Jul 2020 16:34:09 +0000 (17:34 +0100)]
staging: vchiq_arm: children inherit DMA config

Although it is no longer necessary for vchiq's children to have a
different DMA configuration to the parent, they do still need to
explicitly to have their DMA configuration set - to be that of the
parent.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agostaging: vchiq_arm: Add 36-bit address support
Phil Elwell [Thu, 1 Nov 2018 17:31:37 +0000 (17:31 +0000)]
staging: vchiq_arm: Add 36-bit address support

Conditional on a new compatible string, change the pagelist encoding
such that the top 24 bits are the pfn, leaving 8 bits for run length
(-1), giving a 36-bit address range.

Manage the split between addresses for the VPU and addresses for the
40-bit DMA controller with a dedicated DMA device pointer that on non-
BCM2711 platforms is the same as the main VCHIQ device. This allows
the VCHIQ node to stay in the usual place in the DT.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agomedia: i2c: ov7251: Add fwnode properties controls
Dave Stevenson [Tue, 3 Aug 2021 10:33:33 +0000 (11:33 +0100)]
media: i2c: ov7251: Add fwnode properties controls

Add call to v4l2_ctrl_new_fwnode_properties to read and
create the fwnode based controls.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agomedia: bcm2835-unicam: Forward input status from subdevice
Jakub Vaněk [Wed, 7 Jul 2021 20:48:20 +0000 (22:48 +0200)]
media: bcm2835-unicam: Forward input status from subdevice

The vidioc_enum_input() v4l2 ioctl is capable of returning
sensor/input status as well. This is used in current
GStreamer HEAD for signal detection [1].

bcm2835-unicam does handle this syscall, but it didn't ask
the subdevice driver about the input status. The input then
appeared as always present.

This commit adds the necessary query. There is a precedent for
this - the R-Car VIN V4L2 driver does a similar call [2].

[1]: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/blob/ce0be27caf69aa9d96b73bc2b50737451b6f6936/sys/v4l2/gstv4l2src.c#L553
[2]: https://github.com/raspberrypi/linux/blob/7fb9d006d3ff3baf2e205e0c85c4e4fd0a64fcd0/drivers/media/platform/rcar-vin/rcar-v4l2.c#L548

Signed-off-by: Jakub Vaněk <linuxtardis@gmail.com>
4 months agostaging: vc04_services: isp: Set the YUV420/YVU420 format stride to 64 bytes
Naushir Patuck [Tue, 29 Jun 2021 11:50:58 +0000 (12:50 +0100)]
staging: vc04_services: isp: Set the YUV420/YVU420 format stride to 64 bytes

The bcm2835 ISP requires the base address of all input/output planes to have 32
byte alignment. Using a Y stride of 32 bytes would not guarantee that the V
plane would fulfil this, e.g. a height of 650 lines would mean the V plane
buffer is not 32 byte aligned for YUV420 formats.

Having a Y stride of 64 bytes would ensure both U and V planes have a 32 byte
alignment, as the luma height will always be an even number of lines.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agomedia: i2c: ov5647: Fix v4l2-compliance failure subscribing to events
David Plowman [Wed, 12 May 2021 06:39:21 +0000 (07:39 +0100)]
media: i2c: ov5647: Fix v4l2-compliance failure subscribing to events

Fixes the following v4l2-compliance failure:

fail: v4l2-test-controls.cpp(871): subscribe event for control 'User Controls' failed test

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 months agomedia: i2c: ov5647: Correct minimum VBLANK value
David Plowman [Tue, 11 May 2021 11:57:22 +0000 (12:57 +0100)]
media: i2c: ov5647: Correct minimum VBLANK value

Trial and error reveals that the minimum vblank value appears to be 24
(the OV5647 data sheet does not give any clues). This fixes streaming
lock-ups in full resolution mode.

Fixes: 9b5a5ebedc303 ("media: i2c: ov5647: Add support for V4L2_CID_VBLANK")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 months agomedia: i2c: ov5647: Correct pixel array offset
David Plowman [Tue, 11 May 2021 11:52:26 +0000 (12:52 +0100)]
media: i2c: ov5647: Correct pixel array offset

The top offset in the pixel array is actually 6 (see page 3-1 of the
OV5647 data sheet).

Fixes: f2f7ad5ce5e52 ("media: i2c: ov5647: Selection compliance fixes")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 months agogpio-poweroff: Remember the old poweroff handler
Phil Elwell [Tue, 27 Apr 2021 07:59:01 +0000 (08:59 +0100)]
gpio-poweroff: Remember the old poweroff handler

Keeping a copy of the old poweroff handler allows it to be restored
should this module be unloaded, but also provides a fallback if the
power hasn't been removed when the timeout elapses.

See: https://github.com/raspberrypi/rpi-eeprom/issues/330

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agostaging/bcm2835-isp: Fix compiler warning
Phil Elwell [Fri, 23 Apr 2021 15:16:49 +0000 (16:16 +0100)]
staging/bcm2835-isp: Fix compiler warning

The result of dividing a u32 by a size_t is an unsigned int on arm32
and a long unsigned int on arm64. Use "%zu" (the size_t format) to
remove the build warning for 64-bit builds.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agostaging/bcm2835-camera: Add support for H264 levels 4.1 and 4.2
Dave Stevenson [Thu, 25 Mar 2021 18:34:50 +0000 (18:34 +0000)]
staging/bcm2835-camera: Add support for H264 levels 4.1 and 4.2

Whilst the hardware can't achieve the limits of level 4.2 under
all situations, it can exceed level 4.0.

Allow selection of levels 4.1 and 4.2.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agodrm/panel: jdi-lt070me05000: Use gpiod_set_value_cansleep
Dave Stevenson [Thu, 15 Apr 2021 16:30:35 +0000 (17:30 +0100)]
drm/panel: jdi-lt070me05000: Use gpiod_set_value_cansleep

There is no reason why the control GPIOs for the panel can not
be connected to I2C or similar GPIO interfaces that may need to
sleep, therefore switch from gpiod_set_value to
gpiod_set_value_cansleep calls to configure them.
Without that you get complaints from gpiolib every time the state
is changed.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agostaging: fbtft: Add minipitft13 variant
Phil Elwell [Fri, 19 Feb 2021 10:25:01 +0000 (10:25 +0000)]
staging: fbtft: Add minipitft13 variant

The Adafruit Mini-PiTFT13 display needs offsets applying when rotated,
so use the "variant" mechanism to select a custom set_addr_win method
using a dedicated compatible string of "fbtft,minipitft13".

See: https://github.com/raspberrypi/firmware/issues/1524

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agostaging/bcm2835-camera: Add support for DMABUFs
Dave Stevenson [Wed, 17 Mar 2021 12:34:57 +0000 (12:34 +0000)]
staging/bcm2835-camera: Add support for DMABUFs

DMABUFs are all handled by videobuf2, so there is no reason not
to enable support for them.

Note that this driver is still using the vmalloc allocator, so
the buffers it allocates will not be compatible with the codec
or ISP driver that require contiguous buffers. However this
driver should be able to import the buffers allocated by them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agomedia: i2c: ov5647: Parse and register properties
Laurent Pinchart [Fri, 3 Jul 2020 22:45:08 +0000 (01:45 +0300)]
media: i2c: ov5647: Parse and register properties

Parse device properties and register controls for them using the V4L2
fwnode properties helpers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
4 months agomedia: ov5647: Fix return codes from ov5647_write/ov5647_read functions.
David Plowman [Wed, 15 Jan 2020 13:40:38 +0000 (13:40 +0000)]
media: ov5647: Fix return codes from ov5647_write/ov5647_read functions.

Previously they were returning positive non-zero codes for success,
which were getting passed up the call stack. Since release 4.19,
do_dentry_open (fs/open.c) has been catching these and flagging an
error. (So this driver has been broken since that date.)

Fixes: 3c2472a [media] media: i2c: Add support for OV5647 sensor
Signed-off-by: David Plowman <david.plowman@raspberrypi.org>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agomedia: i2c: add ov9281 driver.
Zefa Chen [Fri, 17 May 2019 10:23:03 +0000 (18:23 +0800)]
media: i2c: add ov9281 driver.

Change-Id: I7b77250bbc56d2f861450cf77271ad15f9b88ab1
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
media: i2c: ov9281: fix mclk issue when probe multiple camera.

Takes the ov9281 part only from the Rockchip's patch.

Change-Id: I30e833baf2c1bb07d6d87ddb3b00759ab45a90e4
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
media: i2c: ov9281: add enum_frame_interval function for iq tool 2.2 and hal3

Adds the ov9281 parts of the Rockchip patch adding enum_frame_interval to
a large number of drivers.

Change-Id: I03344cd6cf278dd7c18fce8e97479089ef185a5c
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
media: i2c: ov9281: Fixup for recent kernel releases, and remove custom code

The Rockchip driver was based on a 4.4 kernel, and had several custom
Rockchip parts.

Update to 5.4 kernel APIs, with the relevant controls required by
libcamera, and remove custom Rockchip parts.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: i2c: ov9281: Read chip ID via 2 reads

Vision Components have made an OV9281 module which blocks reading
back the majority of registers to comply with NDAs, and in doing
so doesn't allow auto-increment register reading as used when
reading the chip ID.

Use two reads and manually combine the results.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: i2c: ov9281: Add support for 8 bit readout

The sensor supports 8 bit mode as well as 10bit, so add the
relevant code to allow selection of this.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: ov9281: Add 1280x720 and 640x480 modes

Breaks out common register set and adds the different registers
for 1280x720 (cropped) and 640x480 (skipped) modes

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Fixed picture line bug in all ov9281 modes

Signed-off-by: Mathias Anhalt <mathiasanhalt@web.de>
Added hflip and vflip controls to ov9281

Signed-off-by: Mathias Anhalt <mathiasanhalt@web.de>
media: i2c: ov9281: Remove override of subdev name

From the original Rockchip driver, the subdev was renamed
from the default to being "mov9281 <dev_name>" whereas the
default would have been "ov9281 <dev_name>".

Remove the override to drop back to the default rather than
a vendor custom string.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: v4l2-subdev: add subdev-wide state struct

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
media: i2c: ov9281: Add fwnode properties controls

Add call to v4l2_ctrl_new_fwnode_properties to read and
create the fwnode based controls.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: i2c: ov9281: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Partial revert "media: i2c: add ov9281 driver."

This partially reverts commit 84e98e3a4f3eecb168ceb80231c3e8252929892e.

The commit had merged some changes to other drivers with adding the ov9281
driver. Only the ov9281 parts have been reverted.

4 months agomedia/v4l2_m2m: In buffered mode run jobs if either port is streaming
Dave Stevenson [Mon, 1 Feb 2021 18:48:47 +0000 (18:48 +0000)]
media/v4l2_m2m: In buffered mode run jobs if either port is streaming

In order to get the intended behaviour of the stateful video
decoder API where only the OUTPUT queue needs to be enabled and fed
buffers in order to get the SOURCE_CHANGED event that configures the
CAPTURE queue, we want the device to run should either queue be
streaming.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agoAssign crypto aliases to different AES implementation modules
Ben Avison [Mon, 8 Mar 2021 15:32:25 +0000 (15:32 +0000)]
Assign crypto aliases to different AES implementation modules

The kernel modules aes-neon-blk and aes-neon-bs perform poorly, at least on
Cortex-A72 without crypto extensions. In fact, aes-arm64 outperforms them
on benchmarks, despite it being a simpler implementation (only accelerating
the single-block AES cipher).

For modes of operation where multiple cipher blocks can be processed in
parallel, aes-neon-bs outperforms aes-neon-blk by around 60-70% and aes-arm64
is another 10-20% faster still. But the difference is even more marked with
modes of operation with dependencies between neighbouring blocks, such as
CBC encryption, which defeat parallelism: in these cases, aes-arm64 is
typically around 250% faster than either aes-neon-blk or aes-neon-bs.

The key trade-off with aes-arm64 is that the look-up tables are situated in
RAM. This leaves them potentially open to cache timing attacks. The two other
modules, by contrast, load the look-up tables into NEON registers and so are
able to perform in constant time.

This patch aims to load aes-arm64 more often.

If none of the currently-loaded crypto modules implement a given algorithm,
a new one is typically selected for loading using a platform-neutral alias
describing the required algorithm. To enable users to still
load aes-neon-blk or aes-neon-bs if they really want them, while still
ensuring that aes-arm64 is usually selected, remove the aliases from
aes-neonbs-glue.c and aes-glue.c and apply them to aes-cipher-glue.c, but
still build the two NEON modules.

Since aes-glue.c can also be used to build aes-ce-blk, leave them enabled
if USE_V8_CRYPTO_EXTENSIONS is defined, to ensure they are selected if we
in future use a CPU which has the crypto extensions enabled.

Note that the algorithm priority specifiers are unchanged, so if
aes-neon-bs is loaded at the same time as aes-arm64, the former will be
used in preference. However, aes-neon-blk and aes-arm64 have tied priority,
so whichever module was loaded first will be used (assuming aes-neon-bs is
not loaded).

Signed-off-by: Ben Avison <bavison@riscosopen.org>
4 months agomedia: bcm2835-unicam: Fix bug in buffer swapping logic
Naushir Patuck [Fri, 5 Mar 2021 15:40:45 +0000 (15:40 +0000)]
media: bcm2835-unicam: Fix bug in buffer swapping logic

If multiple sets of interrupts occur simultaneously, it may be unsafe
to swap buffers, as the hardware may already be re-using the current
buffers. In such cases, avoid swapping buffers, and wait for the next
opportunity at the Frame End interrupt to signal completion.

Additionally, check the packet compare status when watching for frame
end for buffers swaps, as this could also signify a frame end event.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agobcm2835-isp: Allow formats with different colour spaces.
David Plowman [Tue, 12 Jan 2021 13:55:39 +0000 (13:55 +0000)]
bcm2835-isp: Allow formats with different colour spaces.

Each supported format now includes a mask showing the allowed colour
spaces, as well as a default colour space for when one was not
specified.

Additionally we translate the colour space to mmal format and pass it
over to the VideoCore.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
4 months agokbuild: Silence unavoidable dtc overlay warnings
Phil Elwell [Fri, 29 Jan 2021 10:34:11 +0000 (10:34 +0000)]
kbuild: Silence unavoidable dtc overlay warnings

Much effort has been put into finding ways to avoid warnings from dtc
about overlays, usually to do with the presence of #address-cells and
size-cells, but not exclusively so. Since the issues being warned about
are harmless, suppress the warnings to declutter the build output and
to avoid alarming users.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agospi: bcm2835: Workaround/fix for zero-length transfers
Phil Elwell [Thu, 28 Jan 2021 11:30:04 +0000 (11:30 +0000)]
spi: bcm2835: Workaround/fix for zero-length transfers

A relatively recent commit ([1]) contained optimisation for the PIO
SPI FIFO-filling functions. The commit message includes the phrase
"[t]he blind and counted loops are always called with nonzero count".
This is technically true, but it is still possible for count to become
zero before the loop is entered - if tfr->len is zero. Moving the loop
exit condition to the end of the loop saves a few cycles, but results
in a near-infinite loop should the revised count be zero on entry.

Strangely, zero-lengthed transfers aren't filtered by the SPI framework
and, even more strangely, the Python3 spidev library is triggering them
for no obvious reason.

Avoid the problem completely by bailing out of the main transfer
function early if trf->len is zero, although there may be a case for
moving the mitigation into the framework.

See: https://github.com/raspberrypi/linux/issues/4100

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
[1] 26751de25d25 ("spi: bcm2835: Micro-optimise FIFO loops")

4 months agostaging: vc04_services: ISP: Add colour denoise control
Naushir Patuck [Thu, 14 Jan 2021 09:20:52 +0000 (09:20 +0000)]
staging: vc04_services: ISP: Add colour denoise control

Add colour denoise control to the bcm2835 driver through a new v4l2
control: V4L2_CID_USER_BCM2835_ISP_CDN.

Add the accompanying MMAL configuration structure definitions as well.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agouapi: bcm2835-isp: Add colour denoise configuration
Naushir Patuck [Thu, 14 Jan 2021 09:18:42 +0000 (09:18 +0000)]
uapi: bcm2835-isp: Add colour denoise configuration

Add a configuration structure for colour denoise to the bcm2835_isp
driver.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agostaging/bcm2835-isp: Log the number of excess supported formats
Dave Stevenson [Thu, 7 Jan 2021 11:43:22 +0000 (11:43 +0000)]
staging/bcm2835-isp: Log the number of excess supported formats

When logging that the firmware has provided more supported formats
than we had allocated storage for, log the number allocated and
returned.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agostaging/bcm2835-isp: Add the unpacked (16bpp) raw formats
Dave Stevenson [Thu, 7 Jan 2021 11:37:10 +0000 (11:37 +0000)]
staging/bcm2835-isp: Add the unpacked (16bpp) raw formats

Now that the firmware supports the unpacked (16bpp) variants
of the MIPI raw formats, add the mappings.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agostaging/vc04_services: Add additional unpacked raw formats
Dave Stevenson [Thu, 7 Jan 2021 10:43:20 +0000 (10:43 +0000)]
staging/vc04_services: Add additional unpacked raw formats

Support has been added for the unpacked (16bpp) versions of
the MIPI raw 10, 12, and 14 formats, so add the 4CCs for them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 months agonet: lan78xx: Ack pending PHY ints when resetting
Phil Elwell [Tue, 15 Dec 2020 16:38:37 +0000 (16:38 +0000)]
net: lan78xx: Ack pending PHY ints when resetting

lan78xx_link_reset explicitly clears the MAC's view of the PHY's IRQ
status. In doing so it potentially leaves the PHY with a pending
interrupt that will never be acknowledged, at which point no further
interrupts will be generated.

Avoid the problem by acknowledging any pending PHY interrupt after
clearing the MAC's status bit.

See: https://github.com/raspberrypi/linux/issues/2937

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agoPCI: brcmstb: Advertise MSI-X support
Phil Elwell [Thu, 3 Dec 2020 13:44:42 +0000 (13:44 +0000)]
PCI: brcmstb: Advertise MSI-X support

Although the BRCMSTB PCIe interface doesn't technically support the
MSI-X spec, in practise it seems to work provided no more than 32
MSI-Xs are required. Add the required flag to the driver to allow
experimentation with devices that demand MSI-X support.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 months agomedia: bcm2835-unicam: Clear clock state when stopping streaming
Naushir Patuck [Wed, 2 Dec 2020 16:48:41 +0000 (16:48 +0000)]
media: bcm2835-unicam: Clear clock state when stopping streaming

Commit 65e08c465020d4c5b51afb452efc2246d80fd66f failed to clear the
clock state when the device stopped streaming. Fix this, as it might
again cause the same problems when doing an unprepare.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agomedia: bcm2835-unicam: Return early from stop_streaming() if stopped
Naushir Patuck [Wed, 2 Dec 2020 15:26:09 +0000 (15:26 +0000)]
media: bcm2835-unicam: Return early from stop_streaming() if stopped

clk_disable_unprepare() is called unconditionally in stop_streaming().
This is incorrect in the cases where start_streaming() fails, and
unprepares all clocks as part of the failure cleanup. To avoid this,
ensure that clk_disable_unprepare() is only called in stop_streaming()
if the clocks are in a prepared state.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 months agomedia: bcm2835-unicam: Correctly handle error propagation for stream on
Naushir Patuck [Wed, 2 Dec 2020 15:22:23 +0000 (15:22 +0000)]
media: bcm2835-unicam: Correctly handle error propagation for stream on

On a failure in start_streaming(), the error code would not propagate to
the calling function on all conditions. This would cause the userland
caller to not know of the failure.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>