platform/kernel/linux-rpi.git
2 years agoregulator/rpi-panel-attiny: Use two transactions for I2C read
Dave Stevenson [Thu, 25 Nov 2021 14:50:10 +0000 (14:50 +0000)]
regulator/rpi-panel-attiny: Use two transactions for I2C read

The I2C to the Atmel is very fussy, and locks up easily on
Pi0-3 particularly on reads.
If running at 100kHz on Pi3, reading the ID register generally
locks up the Atmel, but splitting the register select write and
read into two transactions is reliable.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years 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>
2 years 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>
2 years agostaging/bcm2835-codec: Allow a different stride alignment per role
Dave Stevenson [Mon, 29 Nov 2021 19:11:29 +0000 (19:11 +0000)]
staging/bcm2835-codec: Allow a different stride alignment per role

Deinterlace and decode aren't affected in the same way as encode
and ISP by the alignment requirement on 3 plane YUV420.
Decode would be affected, but it always aligns the height up to
a macroblock, and uses the selection API to reflect that.

Add in the facility to set the bytesperline alignment per role.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: rpivid: remove min_buffers_needed from src queue
John Cox [Mon, 29 Nov 2021 16:39:35 +0000 (16:39 +0000)]
media: rpivid: remove min_buffers_needed from src queue

Remove min_buffers_needed=1 from src queue init. Src buffers are bound
to media requests therefore this setting is not needed and generates
a WARN in kernel 5.16.

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years agostaging/bcm2835-codec: bytesperline for YUV420/YVU420 needs to be 64
Dave Stevenson [Fri, 26 Nov 2021 16:46:22 +0000 (16:46 +0000)]
staging/bcm2835-codec: bytesperline for YUV420/YVU420 needs to be 64

Matching https://github.com/raspberrypi/linux/pull/4419, the ISP
block (which is also used on the input of the encoder, and output
of the decoder) needs the base address of all planes to be aligned
to multiples of 32. This includes the chroma planes of YUV420 and
YVU420.
If the height is only a multiple of 2 (not 4), then you get an odd
number of lines in the second plane, which means the 3rd plane
starts at a multiple of bytesperline/2.

Set the minimum bytesperline alignment to 64 for those formats
so that the plane alignment is always right.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodtoverlays: Use edt-ft5506 for 10 points, instead of edt-ft5x06
Dave Stevenson [Fri, 26 Nov 2021 16:56:37 +0000 (16:56 +0000)]
dtoverlays: Use edt-ft5506 for 10 points, instead of edt-ft5x06

Whilst all the datasheets describe FT5x06 as supporting "up to
10 points of absolution X and Y coordinates", the driver
implementation for the compatible string "edt,edt-ft5x06" only
allows for 5.

Switch to the "edt,edt-ft5506" compatible string which allows for
10 points with no other differences.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agoinput: edt-ft5x06: Handle unreliable TOUCH_UP events
Dave Stevenson [Fri, 26 Nov 2021 14:37:40 +0000 (14:37 +0000)]
input: edt-ft5x06: Handle unreliable TOUCH_UP events

The ft5x06 is unreliable in sending touch up events, so some
touch IDs can become stuck in the detected state.

Ensure that IDs that are unreported by the controller are
released.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm/vc4: Ensure vc4_hdmi doesn't use 2711 HPD registers on Pi0-3
Dave Stevenson [Fri, 19 Nov 2021 16:16:40 +0000 (16:16 +0000)]
drm/vc4: Ensure vc4_hdmi doesn't use 2711 HPD registers on Pi0-3

The existing logic was flawed in that it could try reading the
2711 specific registers for HPD on a CM1/3 where the HPD GPIO
hadn't been defined in DT.

Ensure we don't do the 2711 register read on invalid hardware,
and then

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm/vc4: Add support for composite syncs to vc4_dpi
Dave Stevenson [Thu, 25 Nov 2021 14:45:33 +0000 (14:45 +0000)]
drm/vc4: Add support for composite syncs to vc4_dpi

The hardware can combine H&V syncs onto the output enable line
as composite syncs, so add the relevant configuration to do that.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years 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>
2 years agoARM: dts: Update rpi-400 and cm4 dts to match 4-b
Phil Elwell [Fri, 26 Nov 2021 15:20:06 +0000 (15:20 +0000)]
ARM: dts: Update rpi-400 and cm4 dts to match 4-b

The Pi 4B dts file has had numerous updates since the Pi 400 and CM4
dts files were written. Apply those updates to the other files to
minimise the differences. The change is largely cosmetic, except for
the PCI "device-type" to "device_type" rename, and the correction of
the labels on the Pi 400 GPIO expander pins.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoPass V4L2_CID_MPEG_VIDEO_H264_MIN_QP/MAX_QP to bcm2835-v4l2-codec
Maxim Devaev [Wed, 17 Nov 2021 01:57:56 +0000 (04:57 +0300)]
Pass V4L2_CID_MPEG_VIDEO_H264_MIN_QP/MAX_QP to bcm2835-v4l2-codec

Following raspberrypi/linux#4704. This is necessary to set up
quantization for variable bitrate to avoid video flickering.

2 years 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>
2 years 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>
2 years 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>
2 years agoconfigs: Add USB gadget support (for Zero 2 W)
Phil Elwell [Mon, 22 Nov 2021 10:28:55 +0000 (10:28 +0000)]
configs: Add USB gadget support (for Zero 2 W)

Bring the Pi 3 kernel in line with the Pi Zero and Pi 4 by enabling
USB gadget support, which is useful on Zero 2 W.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoconfigs: add LEDS_PWM=y
Michael Heimpold [Thu, 4 Nov 2021 22:09:07 +0000 (23:09 +0100)]
configs: add LEDS_PWM=y

Enable support for PWM driven LEDs.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
2 years agoconfigs: add CONFIG_HID_PLAYSTATION=m and CONFIG_PLAYSTATION_FF=y
Ilya Trukhanov [Sat, 20 Nov 2021 14:26:36 +0000 (16:26 +0200)]
configs: add CONFIG_HID_PLAYSTATION=m and CONFIG_PLAYSTATION_FF=y

Enables support for the PlayStation 5 'DualSense' controller and its
force feedback.

Also, Sony is planning to move PlayStation peripheral support from
hid-sony into hid-playstation in the future:
https://lore.kernel.org/all/20201219062336.72568-1-roderick@gaikai.com/

This means that, potentially, in future kernel releases older
PlayStation controllers may stop working without this option. As
Raspberry Pis are a popular choice as emulation consoles, it is probably
a good idea to enable this.

Signed-off-by: Ilya Trukhanov <lahvuun@gmail.com>
2 years agoenable several virtual devices for hosting virtual machines
Sean McAvoy [Fri, 19 Nov 2021 07:36:24 +0000 (02:36 -0500)]
enable several virtual devices for hosting virtual machines

2 years agodrm/vc4: Don't try disabling SCDC on Pi0-3.
Dave Stevenson [Tue, 16 Nov 2021 10:34:34 +0000 (10:34 +0000)]
drm/vc4: Don't try disabling SCDC on Pi0-3.

The code that set the scdc_enabled flag to ensure it was
disabled at boot time also ran on Pi0-3 where there is no
SCDC support. This lead to a warning in vc4_hdmi_encoder_post_crtc_disable
due to vc4_hdmi_disable_scrambling being called and trying to
read (and write) register HDMI_SCRAMBLER_CTL which doesn't
exist on those platforms.

Only set the flag should the interface be configured to support
more than HDMI 1.4.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm/vc4: Validate the size of the gamma_lut
Dave Stevenson [Wed, 10 Nov 2021 16:36:12 +0000 (16:36 +0000)]
drm/vc4: Validate the size of the gamma_lut

Add a check to vc4_hvs_gamma_check to ensure a new non-empty
gamma LUT is of the correct length before accepting it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodtoverlays: Remove i2c0mux and i20if status from edt-ft5406.dtsi
Dave Stevenson [Wed, 10 Nov 2021 15:55:32 +0000 (15:55 +0000)]
dtoverlays: Remove i2c0mux and i20if status from edt-ft5406.dtsi

edt-ft5406.dtsi is included from vc4-kms-dsi-7inch which was
also setting i2c0mux and i2c0if status fields. This meant that
dtoverlay wouldn't apply the overlay due to multiple fragments
changing the same parameter.

Move the enable from edt-ft5406.dtsi to edt-ft5406-overlay.dts
for when it should be needed as an independent overlay.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm/vc4: Only add gamma properties once.
Dave Stevenson [Mon, 8 Nov 2021 18:25:49 +0000 (18:25 +0000)]
drm/vc4: Only add gamma properties once.

Two calls were made to drm_crtc_enable_color_mgmt to add gamma
and CTM, however they were both set to add the gamma properties,
so they ended up added twice.

Fixes: 766cc6b1f7fc "drm/vc4: Add CTM support"
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm/vc4: Enable gamma block only when required.
Dave Stevenson [Mon, 8 Nov 2021 17:32:45 +0000 (17:32 +0000)]
drm/vc4: Enable gamma block only when required.

With HVS5 the gamma block is now only reprogrammed with
a disable/enable. Loading the table from vc4_hvs_init_channel
(called from vc4_hvs_atomic_enable) appears to be at an
invalid point in time and so isn't applied.

Switch to enabling and disabling the gamma table instead. This
isn't safe if the pipeline is running, but it isn't now.
For HVS4 it is safe to enable and disable dynamically, so
adopt that approach there too.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm: Fix double free from checking if gamma lut has been updated
Dave Stevenson [Mon, 8 Nov 2021 13:55:15 +0000 (13:55 +0000)]
drm: Fix double free from checking if gamma lut has been updated

The code falls through to "fail" under all conditions, so there is no
need for the drm_property_blob_put if the gamma lut hasn't been changed.
Fixes: 9cca26674a2b "drm: Check whether the gamma lut has changed before updating"

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agoconfigs: Add TCA6416 driver module
VMsunghwan [Mon, 15 Nov 2021 18:24:36 +0000 (03:24 +0900)]
configs: Add TCA6416 driver module

Add a matrix keyboard on I2C

See: https://github.com/raspberrypi/linux/pull/4700

2 years agooverlays: Additional parameters for gpio-poweroff
Phil Elwell [Thu, 11 Nov 2021 10:24:02 +0000 (10:24 +0000)]
overlays: Additional parameters for gpio-poweroff

The gpio-poweroff driver supports active-delay-ms and inactive-delay-ms
properties. Add parameters to set these parameters - active_delay_ms
and inactive_delay_ms.

See: https://forums.raspberrypi.com/viewtopic.php?t=323508

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoconfig: Set TCA8418 to module
arturo182 [Tue, 9 Nov 2021 15:21:56 +0000 (16:21 +0100)]
config: Set TCA8418 to module

This chip is a popular way to add a matrix keyboard using I2C.

2 years agoconfigs: Add kernel SMB3 server support
Phil Elwell [Wed, 10 Nov 2021 09:54:35 +0000 (09:54 +0000)]
configs: Add kernel SMB3 server support

Enable the in-kernel (module) SMB3 server.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoconfigs: Add NTFS3 support
Phil Elwell [Wed, 10 Nov 2021 09:52:22 +0000 (09:52 +0000)]
configs: Add NTFS3 support

ntfs3 provides improved support for NTFS filesystems without the
performance hit of a userspace FUSE filesystem.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoconfigs: Regenerate defconfigs
Phil Elwell [Wed, 10 Nov 2021 09:48:50 +0000 (09:48 +0000)]
configs: Regenerate defconfigs

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agooverlays: Add fbtft overlay
Noralf Trønnes [Wed, 3 Nov 2021 11:21:14 +0000 (12:21 +0100)]
overlays: Add fbtft overlay

Add an overlay that provides much of the functionality that fbtft_device did.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
2 years agodrm/vc4: kms: Move clock request to our HVS state
Maxime Ripard [Thu, 4 Nov 2021 13:04:37 +0000 (14:04 +0100)]
drm/vc4: kms: Move clock request to our HVS state

Our current clock request has been stored so far on the main HVS
structure, but even though we shouldn't have two commits in parallel and
it shouldn't cause any functional change, the request itself is linked
to a given HVS state.

Move the request there to make a bit more sense.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2 years agodrm/vc4: kms: Fix return code check
Maxime Ripard [Wed, 20 Oct 2021 11:31:22 +0000 (13:31 +0200)]
drm/vc4: kms: Fix return code check

The HVS global state functions return an error pointer, but in most
cases we check if it's NULL, possibly resulting in an invalid pointer
dereference.

Fixes: 9ec03d7f1ed3 ("drm/vc4: kms: Wait on previous FIFO users before a commit")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2 years agobrcmfmac: Protect against reprobing
Phil Elwell [Wed, 3 Nov 2021 11:53:13 +0000 (11:53 +0000)]
brcmfmac: Protect against reprobing

It is important to reinitialise the firmware array pointers to protect
against the case that the brcmfmac driver is reprobed without first
being unloaded.

The potential hazard was noticed while investigating
https://github.com/raspberrypi/firmware/issues/1644 .

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agodrm: Check whether the gamma lut has changed before updating
Dave Stevenson [Tue, 2 Nov 2021 16:01:36 +0000 (16:01 +0000)]
drm: Check whether the gamma lut has changed before updating

drm_crtc_legacy_gamma_set updates the gamma_lut blob unconditionally,
which leads to unnecessary reprogramming of hardware.

Check whether the blob contents has actually changed before
signalling that it has been updated.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agoARM: dts: Provide WLAN firmware names for Zero 2 W
Phil Elwell [Thu, 28 Oct 2021 14:09:25 +0000 (15:09 +0100)]
ARM: dts: Provide WLAN firmware names for Zero 2 W

BCM43430/2 may be BCM43430B0 or BCM43436P, and BCM43430/1 can be either
BCM43430A1 or BCM43436S, the former being upstream names and the
latter downstream names for differently-sourced sister parts.

Make the choice of firmwares board-specific (without making the actual
firmwares board-specific) by placing the alternative firmware names for
each part in the DT node.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agobrcmfmac: Read alternative firmware names from DT
Phil Elwell [Thu, 28 Oct 2021 14:03:16 +0000 (15:03 +0100)]
brcmfmac: Read alternative firmware names from DT

Add the ability to load the names of alternative firmwares from the
Device Tree node. This permits separate firmwares for 43436s and 43438
and allows downstream firmwares to coexist with upstream.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoARM: dt: Add DT nodes for the WLAN interfaces
Phil Elwell [Tue, 26 Oct 2021 15:38:44 +0000 (16:38 +0100)]
ARM: dt: Add DT nodes for the WLAN interfaces

Mirror upstream changes into the downstream dts files.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agodtoverlays: Update all image sensor overlays for Media Controller option
Dave Stevenson [Thu, 21 Oct 2021 14:06:02 +0000 (15:06 +0100)]
dtoverlays: Update all image sensor overlays for Media Controller option

Add an option to enable configuration via the Media Controller API
(rather than the video-node-centric /dev/videoN) as about to
be used by libcamera as it enables more complex pipelines to be
handled.

Any source that has a libcamera tuning merged has MC enabled by
default.
Sources with no libcamera tuning merged have it disabled by
default.
In either case it can be overridden with the overlay parameter
"media-controller".

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years 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>
2 years agoARM: dts: Rename Zero 2 W DT files
Phil Elwell [Mon, 1 Nov 2021 15:44:31 +0000 (15:44 +0000)]
ARM: dts: Rename Zero 2 W DT files

Retain the old names for backwards compatibility for a while, while the
necessary firmware change rolls out.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agobcm2835-v4l2-codec: Remove advertised support of VP8
Dom Cobley [Sun, 31 Oct 2021 11:47:59 +0000 (11:47 +0000)]
bcm2835-v4l2-codec: Remove advertised support of VP8

The support for this format by firmware is very limited
and won't be faster than the arm.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agodrm/vc4: Make VEC progressive modes readily accessible
Mateusz Kwiatkowski [Wed, 14 Jul 2021 23:08:11 +0000 (01:08 +0200)]
drm/vc4: Make VEC progressive modes readily accessible

Add predefined modelines for the 240p (NTSC) and 288p (PAL) progressive
modes, and report them through vc4_vec_connector_get_modes().

Signed-off-by: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
2 years agodrm/vc4: Relax VEC modeline requirements and add progressive mode support
Mateusz Kwiatkowski [Wed, 14 Jul 2021 23:08:08 +0000 (01:08 +0200)]
drm/vc4: Relax VEC modeline requirements and add progressive mode support

Make vc4_vec_encoder_atomic_check() accept arbitrary modelines, as long
as they result in somewhat sane output from the VEC. The bounds have
been determined empirically. Additionally, add support for the
progressive 262-line and 312-line modes.

Signed-off-by: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
2 years agomedia: i2c: imx477: Add vsync trigger_mode parameter
neocortex-vision [Thu, 28 Oct 2021 16:37:36 +0000 (17:37 +0100)]
media: i2c: imx477: Add vsync trigger_mode parameter

trigger_mode == 0 (default) => no effect / no registers written
trigger_mode == 1           => source
trigger_mode == 2           => sink

This can be set e.g. in /boot/cmdline.txt as imx477.trigger_mode=N

Signed-off-by: Jonas Jacob <jonas.jacob@neocortexvision.com>
2 years agodrm/vc4: hvs: Force modeset on gamma lut change
Maxime Ripard [Mon, 14 Jun 2021 13:28:30 +0000 (15:28 +0200)]
drm/vc4: hvs: Force modeset on gamma lut change

The HVS Gamma block can only be updated when idle, so we need to disable
the HVS channel when the gamma property is set in an atomic commit.

Since the pixelvalve cannot have its assigned channel halted without
stalling unless it's disabled as well, in our case that means forcing a
full disable / enable cycle on the pipeline.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2 years agodrm/vc4: Add debugfs node that dumps the vc5 gamma PWL entries
Dave Stevenson [Wed, 28 Apr 2021 10:32:10 +0000 (12:32 +0200)]
drm/vc4: Add debugfs node that dumps the vc5 gamma PWL entries

This helps with debugging the conversion from a 256 point gamma LUT to
16 point PWL entries as used by the BCM2711.

Co-developed-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2 years agodrm/vc4: Add support for gamma on BCM2711
Dave Stevenson [Tue, 27 Apr 2021 12:24:21 +0000 (14:24 +0200)]
drm/vc4: Add support for gamma on BCM2711

BCM2711 changes from a 256 entry lookup table to a 16 point
piecewise linear function as the pipeline bitdepth has increased
to make a LUT unwieldy.

Implement a simple conversion from a 256 entry LUT that userspace
is likely to expect to 16 evenly spread points in the PWL. This
could be improved with curve fitting at a later date.

Co-developed-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2 years agoclk-bcm2835: Remove VEC clock support
Dom Cobley [Tue, 19 Oct 2021 13:14:55 +0000 (14:14 +0100)]
clk-bcm2835: Remove VEC clock support

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agodt: Move VEC clock to clk-raspberrypi
Dom Cobley [Tue, 19 Oct 2021 13:15:45 +0000 (14:15 +0100)]
dt: Move VEC clock to clk-raspberrypi

clk-2835 is deprecated and gets an innacurate clock for VEC (107MHz).
Switch to clk-raspberrypi which uses the right PLL to get an accurate 108MHz.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agoclk-raspberrypi: Support VEC clock
Dom Cobley [Tue, 19 Oct 2021 13:13:53 +0000 (14:13 +0100)]
clk-raspberrypi: Support VEC clock

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agoARM: dts: Add Pi Zero 2 support
Phil Elwell [Thu, 9 Sep 2021 09:37:15 +0000 (10:37 +0100)]
ARM: dts: Add Pi Zero 2 support

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years 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>
2 years 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>
2 years agoARM: dts: vc4-kms-v3d: Always disable firmware HDMI
Phil Elwell [Mon, 25 Oct 2021 10:48:18 +0000 (11:48 +0100)]
ARM: dts: vc4-kms-v3d: Always disable firmware HDMI

Both the firmware audio driver and the vc4-kms-v3d driver are capable
of providing HDMI audio, but only one should be active at any time.
The vc4-kms-v3d overlays disable the firmware audio driver, but they
also have a noaudio parameter that as well as disabling the ARM-side
HDMI audio also re-enables the firmware HDMI audio. This is not
guaranteed to work and has been seen to break the display completely.

Modify the noaudio parameters so that the firmware HDMI audio support
remains disabled.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years 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>
2 years 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>
2 years 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>
2 years agomedia: i2c: ov9281: Sensor should report RAW color space
David Plowman [Thu, 21 Oct 2021 13:47:20 +0000 (14:47 +0100)]
media: i2c: ov9281: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years 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>
2 years agomedia: i2c: imx519: Sensor should report RAW color space
David Plowman [Thu, 21 Oct 2021 13:45:07 +0000 (14:45 +0100)]
media: i2c: imx519: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years agomedia: i2c: imx477: Sensor should report RAW color space
David Plowman [Thu, 21 Oct 2021 13:44:43 +0000 (14:44 +0100)]
media: i2c: imx477: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years agomedia: i2c: imx290: Sensor should report RAW color space
David Plowman [Thu, 21 Oct 2021 13:44:01 +0000 (14:44 +0100)]
media: i2c: imx290: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years agomedia: i2c: imx219: Sensor should report RAW color space
David Plowman [Thu, 21 Oct 2021 13:41:55 +0000 (14:41 +0100)]
media: i2c: imx219: Sensor should report RAW color space

Tested on Raspberry Pi running libcamera.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years agoconfigs: Add CONFIG_FB_SIMPLE to bcmrpi3_defconfig
Erik Tagirov [Wed, 20 Oct 2021 07:51:26 +0000 (09:51 +0200)]
configs: Add CONFIG_FB_SIMPLE to bcmrpi3_defconfig

See: https://github.com/raspberrypi/linux/pull/4640

Signed-off-by: Erik Tagirov <erik@tagirov.ch>
2 years agogpio: bcm-virt: Fix the get() method
Phil Elwell [Tue, 19 Oct 2021 10:23:43 +0000 (11:23 +0100)]
gpio: bcm-virt: Fix the get() method

The get() method does not understand the on-the-wire encoding of the
remote GPIO states, thinking they are simple on/off bits when they are
really pairs of 16-bit counts. Rewrite the get() handler to return the
value last written, which will eventually match the actual GPIO state
if there are no other changes.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoconfig: Enable FSFS_FS_SECURITY
Phil Elwell [Mon, 18 Oct 2021 15:39:11 +0000 (16:39 +0100)]
config: Enable FSFS_FS_SECURITY

Add a negligible amount of core kernel code for capability-based
access control on F2FS.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoARM: dts: Delete vestigial vcsm node
Phil Elwell [Mon, 18 Oct 2021 10:13:35 +0000 (11:13 +0100)]
ARM: dts: Delete vestigial vcsm node

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoARM: dts: bcm2835_audio missing firmware reference
Phil Elwell [Mon, 18 Oct 2021 10:12:42 +0000 (11:12 +0100)]
ARM: dts: bcm2835_audio missing firmware reference

The firmware driver has been changed to count its clients. An earlier
commit removed the downstream patch permitting the hacky technique of
passing NULL to rpi_firmware_get to pick up the last instace, but
failed to add the necessary "firmware" property to the bcm2835_audio
node. Correct that omission.

See: https://github.com/raspberrypi/linux/issues/4634
     https://github.com/raspberrypi/linux/issues/4635

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoARM: dts: Make vcio a child of the firmware node
Phil Elwell [Tue, 12 Oct 2021 08:59:54 +0000 (09:59 +0100)]
ARM: dts: Make vcio a child of the firmware node

In order to resolve a potential startup order bug, the vcio driver has
been rewritten as a platform driver that depends on a DT node for
its instantiation and to locate the firmware driver.

Add that DT node.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agochar: vcio: Rewrite as a firmware node child
Phil Elwell [Mon, 11 Oct 2021 16:33:05 +0000 (17:33 +0100)]
char: vcio: Rewrite as a firmware node child

The old vcio driver is a simple character device that manually locates
the firmware driver. Initialising it before the firmware driver causes
a failure, and no retries are attempted.

Rewrite vcio as a platform driver that depends on a DT node for its
instantiation and the location of the firmware driver, making use of
the miscdevice framework to reduce the code size.

N.B. Using miscdevice changes the udev SUBSYSTEM string, so a change
to the companion udev rule is required in order to continue to set
the correct device permissions, e.g.:

    KERNEL="vcio", GROUP="video", MODE="0660"

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agortc: pcf85063: Always clear EXT_TEST from set_time
Phil Elwell [Fri, 15 Oct 2021 10:45:36 +0000 (11:45 +0100)]
rtc: pcf85063: Always clear EXT_TEST from set_time

Power-on reset after the insertion of a battery does not always complete
successfully, leading to corrupted register content. The EXT_TEST bit
will stop the clock from running, but currently the driver will never
recover.

Safely handle the erroneous state by clearing EXT_TEST as part of the
usual set_time method.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years 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>
2 years agoAdd module for 8111h chip used in various CM4 boards
Sten Spans [Tue, 12 Oct 2021 18:10:00 +0000 (20:10 +0200)]
Add module for 8111h chip used in various CM4 boards

2 years agoHifiberry DAC+ADCPro: adding optional headphone amp control
Joerg Schambacher [Wed, 6 Oct 2021 15:21:07 +0000 (17:21 +0200)]
Hifiberry DAC+ADCPro: adding optional headphone amp control

This is a copy of the code and approach from our DAC+ driver.
It allows to probe (and activate) an optional TPA6130A2 headphone
amplifier. Updated email address.

Signed-off-by: Joerg Schambacher <joerg@hifiberry.com>
2 years agoHifiberry DAC+ADCPro DT overlay: add optional headphone amp
Joerg Schambacher [Wed, 6 Oct 2021 15:19:58 +0000 (17:19 +0200)]
Hifiberry DAC+ADCPro DT overlay: add optional headphone amp

This is a copy of the approach from our DAC+ driver.
It allows to probe (and activate) an optional TPA6130A2 headphone
amplifier.

Signed-off-by: Joerg Schambacher <joerg@hifiberry.com>
2 years agodwc_otg: pay attention to qh->interval when rescheduling periodic queues
Jonathan Bell [Wed, 6 Oct 2021 14:27:53 +0000 (15:27 +0100)]
dwc_otg: pay attention to qh->interval when rescheduling periodic queues

A regression introduced in https://github.com/raspberrypi/linux/pull/3887
meant that if the newly scheduled transfer immediately returned data, and
the driver resubmitted a single URB after every transfer, then the effective
polling interval would end up being approx 1ms.

Use the larger of SCHEDULE_SLOP or the configured endpoint interval.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2 years agodtoverlays: Add overlay for ST7735R (160x128) TinyDRM driver
Dave Stevenson [Mon, 4 Oct 2021 13:15:38 +0000 (14:15 +0100)]
dtoverlays: Add overlay for ST7735R (160x128) TinyDRM driver

Adds an overlay to configure the TinyDRM driver for ST7735R
based 160x128 and 128x128 (untested) displays such as the
Adafruit 1.8" display.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agooverlays: Add imx519-overlay.dts
Lee Jackson [Fri, 27 Aug 2021 06:45:43 +0000 (14:45 +0800)]
overlays: Add imx519-overlay.dts

Added overlays for enabling IMX519 and add the
relevant information to the README.

Signed-off-by: Lee Jackson <info@arducam.com>
2 years agoconfigs: Add CONFIG_VIDEO_IMX519=m
Lee Jackson [Thu, 26 Aug 2021 03:15:26 +0000 (11:15 +0800)]
configs: Add CONFIG_VIDEO_IMX519=m

Include the driver module for the IMX519.

Signed-off-by: Lee Jackson <info@arducam.com>
2 years agomedia: i2c: imx519: Advertise embedded data node on media pad 1
Arducam [Wed, 15 Sep 2021 01:02:08 +0000 (09:02 +0800)]
media: i2c: imx519: Advertise embedded data node on media pad 1

This commit updates the imx519 driver to adverise support for embedded
data streams.

The imx519 sensor subdevice overloads the media pad to differentiate
between image stream (pad 0) and embedded data stream (pad 1) when
performing the v4l2_subdev_pad_ops functions.

Signed-off-by: Lee Jackson <info@arducam.com>
2 years agomedia: i2c: Add driver for IMX519 sensor
Lee Jackson [Fri, 27 Aug 2021 05:48:52 +0000 (13:48 +0800)]
media: i2c: Add driver for IMX519 sensor

Adds a driver for the 16MPix IMX519 CSI2 sensor.
Whilst the sensor supports 2 or 4 CSI2 data lanes, this driver
currently only supports 2 lanes.

The following Bayer modes are currently available:

4656x3496 10-bit @ 10fps
3840x2160 10-bit (cropped) @ 21fps
2328x1748 10-bit (binned) @ 30fps
1920x1080 10-bit (cropped/binned) @ 60fps
1280x720 10-bit (cropped/binned) @ 120fps

Signed-off-by: Lee Jackson <info@arducam.com>
2 years agodt-bindings: media: i2c: Add IMX519 CMOS sensor binding
Lee Jackson [Fri, 27 Aug 2021 06:36:55 +0000 (14:36 +0800)]
dt-bindings: media: i2c: Add IMX519 CMOS sensor binding

Add YAML device tree binding for IMX519 CMOS image sensor, and
the relevant MAINTAINERS entries.

Signed-off-by: Lee Jackson <info@arducam.com>
2 years agommc: sdhci-iproc: Fix vmmc regulators (pre-bcm2711)
Juerg Haefliger [Wed, 29 Sep 2021 09:42:23 +0000 (11:42 +0200)]
mmc: sdhci-iproc: Fix vmmc regulators (pre-bcm2711)

The Linux support for controlling card power via regulators appears to
be contentious. I would argue that the default behaviour is contrary to
the SDHCI spec - turning off the power writes a reserved value to the
SD Bus Voltage Select field of the Power Control Register, which
seems to kill the Arasan/iProc controller - but fortunately there is a
hook in sdhci_ops to override the behaviour.

Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoRevert "mmc: sdhci-iproc: Fix vmmc regulators on iProc"
Juerg Haefliger [Wed, 29 Sep 2021 09:39:46 +0000 (11:39 +0200)]
Revert "mmc: sdhci-iproc: Fix vmmc regulators on iProc"

This reverts commit aed19399a01733dbad9be8bf026a4f7dd823b04f.

Commit 6c92ae1e452f ("mmc: sdhci: Introduce sdhci_set_power_and_bus_voltage()")
introduced a generic helper that does the same thing so use that instead in
the following commit.

Signed-off-by: Juerg Haefliger <juergh@canonical.com>
2 years agobcm2835_smi_dev: Fix handling of word-odd lengths
madimario [Tue, 28 Sep 2021 08:20:06 +0000 (04:20 -0400)]
bcm2835_smi_dev: Fix handling of word-odd lengths

The read and write functions did not use the correct pointer offset
when dealing with an odd number of bytes after a DMA transfer. Also,
only handle the remaining odd bytes if the DMA transfer completed
successfully.

Submitted-by: @madimario (GitHub)
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoregulator: rpi-panel: Remove get_brightness hook
Dave Stevenson [Tue, 21 Sep 2021 14:32:50 +0000 (15:32 +0100)]
regulator: rpi-panel: Remove get_brightness hook

The driver was implementing a get_brightness function that
tried to read back the PWM setting of the display to report
as the current brightness.
The controller on the display does not support that, therefore
we end up reporting a brightness of 0, and that confuses
systemd's backlight service.

Remove the hook so that the framework returns the current
brightness automatically.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agooverlays: Add generic mcp2515 overlay
GabyPCgeeK [Mon, 27 Sep 2021 08:43:21 +0000 (04:43 -0400)]
overlays: Add generic mcp2515 overlay

Can configure mcp2515 on spi0/1/2 without the need for multiple overlays.

2 years agooverlays: add support for the MLX90640 thermal camera
Guennadi Liakhovetski [Sun, 19 Sep 2021 11:30:43 +0000 (13:30 +0200)]
overlays: add support for the MLX90640 thermal camera

This allows using the video-i2c camera driver with MLX90640 thermal
infrared sensors, connected to Raspberry Pi. CONFIG_VIDEO_V4L2_I2C
has to be selected to use the camera.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
2 years agostaging: bcm2835-codec: Add support for H&V Flips to ISP
Dave Stevenson [Mon, 20 Sep 2021 13:37:17 +0000 (14:37 +0100)]
staging: bcm2835-codec: Add support for H&V Flips to ISP

The ISP can do H & V flips whilst resizing or converting
the image, so expose that via V4L2_CID_[H|V]FLIP.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging: bcm2835-codec: Ensure all ctrls are set on streamon
Dave Stevenson [Mon, 20 Sep 2021 14:00:51 +0000 (15:00 +0100)]
staging: bcm2835-codec: Ensure all ctrls are set on streamon

Currently the code was only setting some controls from
bcm2835_codec_set_ctrls, but it's simpler to use
v4l2_ctrl_handler_setup to avoid forgetting to adding new
controls to the list.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging: bcm2835_codec: Correct flushing code for refcounting
Dave Stevenson [Wed, 22 Sep 2021 15:42:49 +0000 (16:42 +0100)]
staging: bcm2835_codec: Correct flushing code for refcounting

Completions don't reference count, so setting the completion
on the first buffer returned and then not reinitialising it
means that the flush function doesn't behave as intended.

Signal the completion when the last buffer is returned.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years 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>
2 years agostaging: bcm2835-codec: Queue flushed buffers instead of completing
Dave Stevenson [Thu, 16 Sep 2021 15:46:58 +0000 (16:46 +0100)]
staging: bcm2835-codec: Queue flushed buffers instead of completing

When a buffer is returned on a port that is disabled, return it
to the videobuf2 QUEUED state instead of DONE which returns it
to the client.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years 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>
2 years agostaging: bcm2835-codec: Signal the firmware to stop on all changes
Dave Stevenson [Thu, 16 Sep 2021 15:39:07 +0000 (16:39 +0100)]
staging: bcm2835-codec: Signal the firmware to stop on all changes

The firmware defaults to not stopping video decode if only the
pixel aspect ratio or colourspace change. V4L2 requires us
to stop decoding on any change, therefore tell the firmware
of the desire for this alternate behaviour.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging: bcm2835-codec: Format changed should trigger drain
Dave Stevenson [Thu, 16 Sep 2021 15:32:53 +0000 (16:32 +0100)]
staging: bcm2835-codec: Format changed should trigger drain

When a format changed event occurs, the spec says that it
triggers an implicit drain, and that needs to be signalled
via -EPIPE.

For BCM2835, the format changed event happens at the point
the format change occurs, so no further buffers exist from
before the resolution changed point. We therefore signal the
last buffer immediately.
We don't have a V4L2 available to us at this point, so set
the videobuf2 queue last_buffer_dequeued flag directly.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging/mmal-vchiq: Rationalise included headers
Dave Stevenson [Wed, 15 Sep 2021 16:49:41 +0000 (17:49 +0100)]
staging/mmal-vchiq: Rationalise included headers

The list of includes was slightly over generic, and wasn't
in alphabetical order. Clean it up.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>