platform/kernel/linux-rpi.git
2 years agodrm/vc4: Add all the HDMI registers into the debugfs dumps
Dave Stevenson [Wed, 21 Oct 2020 17:34:56 +0000 (18:34 +0100)]
drm/vc4: Add all the HDMI registers into the debugfs dumps

The vc5 HDMI registers hadn't been added into the debugfs
register sets, therefore weren't dumped on request.
Add them in.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm/vc4: Add debugfs node that dumps the current display lists
Dave Stevenson [Tue, 6 Oct 2020 17:44:42 +0000 (18:44 +0100)]
drm/vc4: Add debugfs node that dumps the current display lists

This allows easy analysis of display lists when debugging.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm/vc4: A present but empty dmas disables audio
Phil Elwell [Wed, 31 Jul 2019 16:36:34 +0000 (17:36 +0100)]
drm/vc4: A present but empty dmas disables audio

Overlays are unable to remove properties in the base DTB, but they
can overwrite them. Allow a present but empty 'dmas' property
to also disable the HDMI audio interface.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2 years agodrm/vc4: Add FKMS as an acceptable node for dma ranges.
Dave Stevenson [Tue, 19 May 2020 15:20:30 +0000 (16:20 +0100)]
drm/vc4: Add FKMS as an acceptable node for dma ranges.

Under FKMS, the firmware (via FKMS) also requires the VideoCore cache
aliases for image planes, as defined by the dma-ranges under /soc.

Add rpi-firmware-kms to the list of acceptable nodes to look for
to copy dma config from.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm/vc4: plane: Add support for YUV color encodings and ranges
Dave Stevenson [Wed, 15 Dec 2021 09:17:39 +0000 (10:17 +0100)]
drm/vc4: plane: Add support for YUV color encodings and ranges

The BT601/BT709 color encoding and limited vs full
range properties were not being exposed, defaulting
always to BT601 limited range.

Expose the parameters and set the registers appropriately.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20211215091739.135042-4-maxime@cerno.tech
2 years agodrm/vc4: plane: Add support for DRM_FORMAT_P030
Dave Stevenson [Wed, 15 Dec 2021 09:17:38 +0000 (10:17 +0100)]
drm/vc4: plane: Add support for DRM_FORMAT_P030

The P030 format, used with the DRM_FORMAT_MOD_BROADCOM_SAND128 modifier,
is a format output by the video decoder on the BCM2711.

Add native support to the KMS planes for that format.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20211215091739.135042-3-maxime@cerno.tech
2 years agoSupport RPi DPI interface in mode6 for 18-bit color
Joerg Quinten [Fri, 18 Jun 2021 11:02:29 +0000 (13:02 +0200)]
Support RPi DPI interface in mode6 for 18-bit color

A matching media bus format was added and an overlay for using it,
both with FB and VC4 was added as well.

Signed-off-by: Joerg Quinten <aBUGSworstnightmare@gmail.com>
2 years agodrm/vc4: Adopt the dma configuration from the HVS or V3D component
Dave Stevenson [Tue, 19 May 2020 13:54:28 +0000 (14:54 +0100)]
drm/vc4: Adopt the dma configuration from the HVS or V3D component

vc4_drv isn't necessarily under the /soc node in DT as it is a
virtual device, but it is the one that does the allocations.
The DMA addresses are consumed by primarily the HVS or V3D, and
those require VideoCore cache alias address mapping, and so will be
under /soc.

During probe find the a suitable device node for HVS or V3D,
and adopt the DMA configuration of that node.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: v4l2-subdev: add subdev-wide state struct
Dom Cobley [Thu, 15 Jul 2021 14:55:22 +0000 (15:55 +0100)]
media: v4l2-subdev: add subdev-wide state struct

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years 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>
2 years agobcm2711_thermal: Don't clamp temperature at zero
Dom Cobley [Thu, 8 Jul 2021 12:48:11 +0000 (13:48 +0100)]
bcm2711_thermal: Don't clamp temperature at zero

The temperature sensor is valid below zero and the linux framework is happy with it.

See: https://www.raspberrypi.org/forums/viewtopic.php?f=98&t=315382
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agodt-bindings: display: vc4: Add phandle to the firmware
Maxime Ripard [Wed, 23 Jun 2021 09:48:35 +0000 (11:48 +0200)]
dt-bindings: display: vc4: Add phandle to the firmware

The vc4 driver will need to tell the firmware that it takes over the
display for the firmware to free its resources (lower the clock, free
some memory, etc.)

Let's add an optional phandle to our firmware node.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2 years agodt-bindings: clk: raspberrypi: Remove unused property
Maxime Ripard [Wed, 23 Jun 2021 09:47:38 +0000 (11:47 +0200)]
dt-bindings: clk: raspberrypi: Remove unused property

The raspberrypi,firmware property has been documented as required in the
binding but was never actually used in the final version of the binding.
Remove it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2 years agomedia: i2c: imx477: Extend driver to support imx378 sensor
David Plowman [Tue, 29 Jun 2021 13:43:01 +0000 (14:43 +0100)]
media: i2c: imx477: Extend driver to support imx378 sensor

The imx378 sensor is almost identical to the imx477 and can be
supported as a "compatible" sensor with just a few extra register
writes.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years agoDocumentation: devicetree: Add documentation for imx378 sensor
David Plowman [Tue, 29 Jun 2021 13:38:23 +0000 (14:38 +0100)]
Documentation: devicetree: Add documentation for imx378 sensor

The imx378 sensor is compatible with the imx477 and shares common
device tree settings.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years 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>
2 years agomedia: i2c: ov9281: Remove override of subdev name
Dave Stevenson [Mon, 28 Jun 2021 09:49:04 +0000 (10:49 +0100)]
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>
2 years agomedia: rpivid: Fix H265 aux ent reuse of the same slot
John Cox [Thu, 24 Jun 2021 13:43:49 +0000 (14:43 +0100)]
media: rpivid: Fix H265 aux ent reuse of the same slot

It is legitimate, though unusual, for an aux ent associated with a slot
to be selected in phase 0 before a previous selection has been used and
released in phase 2. Fix such that if the slot is found to be in use
that the aux ent associated with it is reused rather than an new aux
ent being created. This fixes a problem where when the first aux ent
was released the second was lost track of.

This bug spotted in Nick's testing. It may explain some other occasional,
unreliable decode error reports where dmesg included "Missing DPB AUX
ent" logging.

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years agomedia: i2c: imx290: Fix clock setup register assignments
Dave Stevenson [Thu, 17 Jun 2021 16:27:46 +0000 (17:27 +0100)]
media: i2c: imx290: Fix clock setup register assignments

When the clock setups were added for the alternate external clocks,
the settings for 2 lane 720p and 4 lane 1080p were transposed.
2 lane 720p still worked, but 4 lane 1080p didn't.

Correct the assignments.

Fixes: 6b0c094a5b58 (media: i2c: imx290: Add support for 74.25MHz clock")

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Fix the pixel rate at 148.5Mpix/s
Dave Stevenson [Thu, 17 Jun 2021 12:00:39 +0000 (13:00 +0100)]
media: i2c: imx290: Fix the pixel rate at 148.5Mpix/s

Whilst the datasheet lists the link frequency changing between
1080p and 720p modes, reality is that with the default blanking
we have
(1920 + 280) * (1080 + 45) * 60fps = 148.5MPix/s
and
(1280 + 2020) * (720 + 30) * 60fps = 148.5MPix/s
and this reflects reality whether in 10 or 12 bit readout modes.

How this relates to link frequency is unclear as it differs
from the datasheet, but all exposure and frame rate calcs need
the pixel rate to be correct, so make it so.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Support 60fps in 2 lane operation
Dave Stevenson [Thu, 17 Jun 2021 11:05:25 +0000 (12:05 +0100)]
media: i2c: imx290: Support 60fps in 2 lane operation

Commit "97589ad61c73 media: i2c: imx290: Add support for 2 data lanes"
added support for running in two lane mode (instead of 4), but
without changing the link frequency that resulted in a max of 30fps.

Commit "98e0500eadb7 media: i2c: imx290: Add configurable link frequency
and pixel rate" then doubled the link frequency when in 2 lane mode,
but didn't undo the correction for running at only 30fps, just extending
horizontal blanking instead.
It also didn't update the CSI timing registers in accordance with the
datasheet.

Remove the 30fps limit on 2 lane by correcting the register config
in accordance with the datasheet for 60fps operation over 2 lanes.
Frame rate control (via V4L2_CID_VBLANK or HBLANK) can still reduce
the frame rate on 2 lanes back to 30fps.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agobcm2835-pcm: Fix up multichannel pcm audio
Dom Cobley [Tue, 27 Oct 2020 12:24:14 +0000 (12:24 +0000)]
bcm2835-pcm: Fix up multichannel pcm audio

Fixes: a9c1660ff5f02d048c5f31abf1fd1108ccf9ef87
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agobcm2835-pcm.c: Support multichannel audio
popcornmix [Tue, 30 Apr 2019 18:15:30 +0000 (19:15 +0100)]
bcm2835-pcm.c: Support multichannel audio

2 years agoclk: bcm2835: Pass DT node to rpi_firmware_get
Phil Elwell [Thu, 8 Jul 2021 08:37:10 +0000 (09:37 +0100)]
clk: bcm2835: Pass DT node to rpi_firmware_get

The fw_node pointer has already been retrieved, and using it allows
us to remove a downstream patch to the firmware driver.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agomedia: i2c: imx477: Fix for long exposure limit calculations
Naushir Patuck [Fri, 11 Jun 2021 11:47:07 +0000 (12:47 +0100)]
media: i2c: imx477: Fix for long exposure limit calculations

Do not scale IMX477_EXPOSURE_OFFSET with the long exposure factor during
the limit calculations. This allows larger exposure times, and does seem to be
what the sensor is doing internally.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agobcm2835: Allow compressed frames to set sizeimage (#4386)
jc-kynesim [Fri, 11 Jun 2021 14:14:31 +0000 (15:14 +0100)]
bcm2835: Allow compressed frames to set sizeimage (#4386)

Allow the user to set sizeimage in TRY_FMT and S_FMT if the format
flags have V4L2_FMT_FLAG_COMPRESSED set

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years agomedia: rpivid: Improve SPS/PPS error handling/validation
John Cox [Thu, 8 Apr 2021 17:34:09 +0000 (18:34 +0100)]
media: rpivid: Improve SPS/PPS error handling/validation

Move size and width checking from bitstream processing to control
validation

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years agomedia: rpivid: Improve stream_on/off conformance & clock setup
John Cox [Sat, 3 Apr 2021 15:27:03 +0000 (16:27 +0100)]
media: rpivid: Improve stream_on/off conformance & clock setup

Fix stream on & off such that failures leave the driver in the correct
state.  Ensure that the clock is on when we are streaming and off when
all contexts attached to this device have stopped streaming.

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years agomedia: rpivid: Improve values returned when setting output format
John Cox [Thu, 1 Apr 2021 15:20:58 +0000 (16:20 +0100)]
media: rpivid: Improve values returned when setting output format

Guess a better value for the compressed bitstream buffer size

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years agomedia: rpivid: Map cmd buffer directly
John Cox [Mon, 29 Mar 2021 16:42:16 +0000 (17:42 +0100)]
media: rpivid: Map cmd buffer directly

It is unnecessary to have a separate dmabuf to hold the cmd buffer.
Map it directly from the kmalloc.

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years agomedia: rpivid: Add a Pass0 to accumulate slices and rework job finish
John Cox [Thu, 11 Mar 2021 19:08:00 +0000 (19:08 +0000)]
media: rpivid: Add a Pass0 to accumulate slices and rework job finish

Due to overheads in assembling controls and requests it is worth having
the slice assembly phase separate from the h/w pass1 processing. Create
a queue to service pass1 rather than have the pass1 finished callback
trigger the next slice job.

This requires a rework of the logic that splits up the buffer and
request done events. This code contains two ways of doing that, we use
Ezequiel Garcias <ezequiel@collabora.com> solution, but expect that
in the future this will be handled by the framework in a cleaner manner.

Fix up the handling of some of the memory exhaustion crashes uncovered
in the process of writing this code.

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years agoRFC: media: Add media_request_{pin,unpin} API
Ezequiel Garcia [Sun, 21 Mar 2021 19:38:54 +0000 (16:38 -0300)]
RFC: media: Add media_request_{pin,unpin} API

This is probably not the API we will want to add, but it
should show what semantics are needed by drivers.

The goal is to allow the OUTPUT (aka source) buffer and the
controls associated to a request to be released from the request,
and in particular return the OUTPUT buffer back to userspace,
without signalling the media request fd.

This is useful for devices that are able to pre-process
the OUTPUT buffer, therefore able to release it before
the decoding is finished. These drivers should signal
the media request fd only after the CAPTURE buffer is done.

Tested-by: John Cox <jc@kynesim.co.uk>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
2 years agomedia: rpivid: Add an enable count to irq claim Qs
John Cox [Thu, 11 Mar 2021 18:43:15 +0000 (18:43 +0000)]
media: rpivid: Add an enable count to irq claim Qs

Add an enable count to the irq Q structures to allow the irq logic to
block further callbacks if resources associated with the irq are not
yet available.

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years agomedia: rpivid: Convert to MPLANE
John Cox [Thu, 11 Mar 2021 12:51:00 +0000 (12:51 +0000)]
media: rpivid: Convert to MPLANE

Use multi-planar interface rather than single plane interface. This
allows dmabufs holding compressed data to be resized.

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years agomedia: rpivid: Remove the need to have num_entry_points set
John Cox [Thu, 21 May 2020 10:49:37 +0000 (11:49 +0100)]
media: rpivid: Remove the need to have num_entry_points set

VAAPI H265 has num entry points but never sets it. Allow a VAAPI
shim to work without requiring rewriting the VAAPI driver.
num_entry_points can be calculated from the slice_segment_addr
of the next slice so delay processing until we have that.

Also includes some minor cosmetics.

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years agostaging/bcm2835-codec: Do not update crop from S_FMT after res change
Dave Stevenson [Thu, 15 Apr 2021 10:07:55 +0000 (11:07 +0100)]
staging/bcm2835-codec: Do not update crop from S_FMT after res change

During decode, setting the CAPTURE queue format was setting the crop
rectangle to the requested height before aligning up the format to
cater for simple clients that weren't expecting to deal with cropping
and the SELECTION API.
This caused problems on some resolution change events if the client
didn't also then use the selection API.

Disable the crop update after a resolution change.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years 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>
2 years agostaging/bcm2835-codec: Pass corrupt frame flag.
Dave Stevenson [Wed, 9 Dec 2020 18:53:56 +0000 (18:53 +0000)]
staging/bcm2835-codec: Pass corrupt frame flag.

MMAL has the flag MMAL_BUFFER_HEADER_FLAG_CORRUPTED but that
wasn't being passed through, so add it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging/bcm2835-codec: Set the colourspace appropriately for RGB formats
Dave Stevenson [Thu, 4 Feb 2021 19:08:23 +0000 (19:08 +0000)]
staging/bcm2835-codec: Set the colourspace appropriately for RGB formats

Video decode supports YUV and RGB formats. YUV needs to report SMPTE170M
or REC709 appropriately, whilst RGB should report SRGB.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging/bcm2835-codec: Fix support for levels 4.1 and 4.2
Dave Stevenson [Thu, 25 Mar 2021 18:28:40 +0000 (18:28 +0000)]
staging/bcm2835-codec: Fix support for levels 4.1 and 4.2

The driver said it supported H264 levels 4.1 and 4.2, but
was missing the V4L2 to MMAL mappings.

Add in those mappings.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agoclk: requests: Dereference the request pointer after the check
Maxime Ripard [Thu, 22 Apr 2021 08:45:37 +0000 (10:45 +0200)]
clk: requests: Dereference the request pointer after the check

The current code will first dereference the req pointer and then test if
it's NULL, resulting in a NULL pointer dereference if req is indeed
NULL. Reorder the test and derefence to avoid the issue

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2 years agoclk: requests: Ignore if the pointer is null
Maxime Ripard [Wed, 21 Apr 2021 10:14:44 +0000 (12:14 +0200)]
clk: requests: Ignore if the pointer is null

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2 years 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>
2 years agodwc_otg: fix an undeclared variable
wangzx [Tue, 20 Apr 2021 14:33:26 +0000 (22:33 +0800)]
dwc_otg: fix an undeclared variable
Replace an undeclared variable used by DWC_DEBUGPL with the real endpoint address. DWC_DEBUGPL does nothing with DEBUG undefined so it did not go wrong before.
Signed-off-by: Zixuan Wang <wangzixuan@sjtu.edu.cn>
2 years agorpivid: Only clk_request_done once
Dom Cobley [Tue, 20 Apr 2021 12:34:18 +0000 (13:34 +0100)]
rpivid: Only clk_request_done once

Fixes: 25486f49bfe2e3ae13b90478d1eebd91413136ad
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agorpivid: Switch to new clock api
Dom Cobley [Mon, 19 Apr 2021 18:30:26 +0000 (19:30 +0100)]
rpivid: Switch to new clock api

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agobcm2835-unicam: Switch to new clock api
Dom Cobley [Tue, 13 Apr 2021 15:48:35 +0000 (16:48 +0100)]
bcm2835-unicam: Switch to new clock api

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agoclk: Introduce a clock request API
Maxime Ripard [Tue, 13 Apr 2021 09:00:01 +0000 (11:00 +0200)]
clk: Introduce a clock request API

It's not unusual to find clocks being shared across multiple devices
that need to change the rate depending on what the device is doing at a
given time.

The SoC found on the RaspberryPi4 (BCM2711) is in such a situation
between its two HDMI controllers that share a clock that needs to be
raised depending on the output resolution of each controller.

The current clk_set_rate API doesn't really allow to support that case
since there's really no synchronisation between multiple users, it's
essentially a fire-and-forget solution.

clk_set_min_rate does allow for such a synchronisation, but has another
drawback: it doesn't allow to reduce the clock rate once the work is
over.

In our previous example, this means that if we were to raise the
resolution of one HDMI controller to the largest resolution and then
changing for a smaller one, we would still have the clock running at the
largest resolution rate resulting in a poor power-efficiency.

In order to address both issues, let's create an API that allows user to
create temporary requests to increase the rate to a minimum, before
going back to the initial rate once the request is done.

This introduces mainly two side-effects:

  * There's an interaction between clk_set_rate and requests. This has
    been addressed by having clk_set_rate increasing the rate if it's
    greater than what the requests asked for, and in any case changing
    the rate the clock will return to once all the requests are done.

  * Similarly, clk_round_rate has been adjusted to take the requests
    into account and return a rate that will be greater or equal to the
    requested rates.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2 years agostaging: vcsm-cma: Fix memory leak from not detaching dmabuf
Dave Stevenson [Wed, 4 Nov 2020 18:54:20 +0000 (18:54 +0000)]
staging: vcsm-cma: Fix memory leak from not detaching dmabuf

When importing there was a missing call to detach the buffer,
so each import leaked the sg table entry.

Actually the release process for both locally allocated and
imported buffers is identical, so fix them to both use the same
function.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodwc-otg: fix clang -Wpointer-bool-conversion warning
Jo Henke [Tue, 6 Apr 2021 11:45:14 +0000 (11:45 +0000)]
dwc-otg: fix clang -Wpointer-bool-conversion warning

warning: address of array 'desc->wMaxPacketSize' will always evaluate to 'true'

The wMaxPacketSize field is actually a two element array which content should
be accessed via the UGETW macro.

2 years agodwc-otg: fix clang -Wsometimes-uninitialized warning
Jo Henke [Tue, 6 Apr 2021 11:38:28 +0000 (11:38 +0000)]
dwc-otg: fix clang -Wsometimes-uninitialized warning

warning: variable 'retval' is used uninitialized whenever 'if' condition is false

2 years agodwc-otg: fix clang -Wignored-attributes warning
Jo Henke [Tue, 6 Apr 2021 11:21:35 +0000 (11:21 +0000)]
dwc-otg: fix clang -Wignored-attributes warning

warning: attribute declaration must precede definition

2 years 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>
2 years 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>
2 years agorpivid: Request maximum hevc clock
Dom Cobley [Mon, 22 Feb 2021 18:50:50 +0000 (18:50 +0000)]
rpivid: Request maximum hevc clock

Query maximum and minimum clock from driver
and use those

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agoclk-raspberrypi: Also support HEVC clock
Dom Cobley [Mon, 22 Feb 2021 18:47:19 +0000 (18:47 +0000)]
clk-raspberrypi: Also support HEVC clock

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years 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>
2 years 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>
2 years agoAdded hflip and vflip controls to ov9281
Mathias Anhalt [Wed, 3 Feb 2021 19:34:09 +0000 (20:34 +0100)]
Added hflip and vflip controls to ov9281

Signed-off-by: Mathias Anhalt <mathiasanhalt@web.de>
2 years agoFixed picture line bug in all ov9281 modes
Mathias Anhalt [Sun, 24 Jan 2021 14:15:01 +0000 (15:15 +0100)]
Fixed picture line bug in all ov9281 modes

Signed-off-by: Mathias Anhalt <mathiasanhalt@web.de>
2 years agomedia: ov9281: Add 1280x720 and 640x480 modes
Dave Stevenson [Sun, 22 Nov 2020 11:01:08 +0000 (11:01 +0000)]
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>
2 years agomedia: i2c: ov9281: Add support for 8 bit readout
Dave Stevenson [Tue, 7 Jul 2020 17:29:10 +0000 (18:29 +0100)]
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>
2 years agomedia: i2c: ov9281: Read chip ID via 2 reads
Dave Stevenson [Mon, 6 Jul 2020 16:51:32 +0000 (17:51 +0100)]
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>
2 years agomedia: i2c: ov9281: Fixup for recent kernel releases, and remove custom code
Dave Stevenson [Tue, 14 Apr 2020 15:12:33 +0000 (16:12 +0100)]
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>
2 years agomedia: i2c: ov9281: add enum_frame_interval function for iq tool 2.2 and hal3
Dave Stevenson [Tue, 14 Apr 2020 14:51:50 +0000 (15:51 +0100)]
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>
2 years agomedia: i2c: ov9281: fix mclk issue when probe multiple camera.
Dave Stevenson [Tue, 14 Apr 2020 14:47:09 +0000 (15:47 +0100)]
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>
2 years 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>
2 years agohack: fixup bcm2835-unicam
Dom Cobley [Wed, 17 Mar 2021 12:45:53 +0000 (12:45 +0000)]
hack: fixup bcm2835-unicam

2 years agostaging/bcm2835-codec: Add VC-1 support.
Dave Stevenson [Wed, 10 Mar 2021 19:07:48 +0000 (19:07 +0000)]
staging/bcm2835-codec: Add VC-1 support.

Providing the relevant licence has been purchased, then Pi0-3
can decode VC-1.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging/bcm2835-codec: Implement additional g_selection calls for decode
Dave Stevenson [Tue, 2 Feb 2021 16:46:39 +0000 (16:46 +0000)]
staging/bcm2835-codec: Implement additional g_selection calls for decode

v4l_cropcap calls our vidioc_g_pixelaspect function to get the pixel
aspect ratio, but also calls g_selection for V4L2_SEL_TGT_CROP_BOUNDS
and V4L2_SEL_TGT_CROP_DEFAULT. Whilst it allows for vidioc_g_pixelaspect
not to be implemented, it doesn't allow for either of the other two.

Add in support for the additional selection targets.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging/bcm2835-codec: Add support for pixel aspect ratio
Dave Stevenson [Tue, 2 Feb 2021 15:50:18 +0000 (15:50 +0000)]
staging/bcm2835-codec: Add support for pixel aspect ratio

If the format is detected by the driver and a V4L2_EVENT_SOURCE_CHANGE
event is generated, then pass on the pixel aspect ratio as well.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging/bcm2835-codec: Correct logging of size_t to %zu
Dave Stevenson [Mon, 1 Feb 2021 18:55:37 +0000 (18:55 +0000)]
staging/bcm2835-codec: Correct logging of size_t to %zu

Fixes: "staging/bcm2835-codec: Log the number of excess supported formats"
Which used %u for printing a size_t, and 64bit builds then log a warning.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years 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>
2 years 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>
2 years 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>
2 years agomedia: i2c: imx477: Remove unused function parameter
Naushir Patuck [Fri, 19 Feb 2021 11:06:40 +0000 (11:06 +0000)]
media: i2c: imx477: Remove unused function parameter

The struct imx477 *ctrl parameter is not used in the function
imx477_adjust_exposure_range(), so remove it.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agomedia: i2c: imx477: Remove internal v4l2_mbus_framefmt from the state
Naushir Patuck [Fri, 19 Feb 2021 10:30:49 +0000 (10:30 +0000)]
media: i2c: imx477: Remove internal v4l2_mbus_framefmt from the state

The only field in this struct that is used is the format code, so
replace the struct with this single field.

Save the format code in imx477_set_pad_format() when setting up a new
mode so that imx477_get_pad_format() performs the right lookup.
Otherwise, this caused a bug where the mode lookup occurred on the
12-bit table rather than the 10-bit table.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agomedia: i2c: imx477: Replace existing 1012x760 mode
Naushir Patuck [Thu, 18 Feb 2021 15:23:11 +0000 (15:23 +0000)]
media: i2c: imx477: Replace existing 1012x760 mode

The existing 1012x760 120 fps mode has significant IQ problem using
the internal sensor scaler. Replace this mode with a 1332x990 120 fps
mode instead. This new mode has a smaller field of view, but does not
suffer from the bad IQ of the original mode.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agomedia: i2c: imx477: Fix crop height for 2028x1080 mode
Naushir Patuck [Thu, 18 Feb 2021 15:05:57 +0000 (15:05 +0000)]
media: i2c: imx477: Fix crop height for 2028x1080 mode

The crop height for this mode was set at 2600 lines, it should be 2160
lines instead.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agomedia: i2c: imx290: Handle exposure correctly when vblank changes
David Plowman [Thu, 18 Feb 2021 11:58:29 +0000 (11:58 +0000)]
media: i2c: imx290: Handle exposure correctly when vblank changes

When vblank changes we must modify the exposure range. Also, with this
sensor, the effective exposure time implicitly changes when vblank
does, so we have to reset it after every vblank update.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years agomedia: i2c: imx290: Fix up exposure calcuations and ranges
David Plowman [Wed, 17 Feb 2021 18:08:12 +0000 (18:08 +0000)]
media: i2c: imx290: Fix up exposure calcuations and ranges

Should now correspond exactly to the datasheet.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years agomedia: i2c: imx477: Add very long exposure control to the driver
Naushir Patuck [Wed, 10 Feb 2021 10:50:32 +0000 (10:50 +0000)]
media: i2c: imx477: Add very long exposure control to the driver

Add support for very long exposures by using the exposure multiplier
register. Userland does not need to pass any additional controls to
enable long exposures, it simply requests a larger vblank to extend the
exposure control range appropriately.

Currently, since hblank is fixed, a maximum of approximately 124 seconds
of exposure time can be used. In a future change, hblank could also be
controlled in userland to give over 200 seconds of exposure time.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agomedia: i2c: imx477: Remove auto frame length adjusting
Naushir Patuck [Wed, 10 Feb 2021 10:18:53 +0000 (10:18 +0000)]
media: i2c: imx477: Remove auto frame length adjusting

The V4L2_CID_EXPOSURE_AUTO_PRIORITY was used to let the sensor control
frame length (effectively framerate) based on the requested exposure
time requested. Remove this feature as it is never used, and goes
against how V4L2 likes to handle exposure and vblank controls.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agostaging: rpivid: Fix crash when CMA alloc fails
John Cox [Mon, 8 Feb 2021 16:01:37 +0000 (16:01 +0000)]
staging: rpivid: Fix crash when CMA alloc fails

If realloc to increase coeff size fails then attempt to re-allocate
the original size.  If that also fails then flag a fatal error to abort
all further decode.

Signed-off-by: John Cox <jc@kynesim.co.uk>
2 years 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>
2 years agostaging:bcm2835-camera: Fix the cherry-pick of AWB Greyworld
Dave Stevenson [Mon, 8 Feb 2021 11:48:35 +0000 (11:48 +0000)]
staging:bcm2835-camera: Fix the cherry-pick of AWB Greyworld

The cherry-pick of the patch that added the greyworld AWB mode
was incomplete. Fix it up.

Fixes: b3ef481fe243 "staging: bcm2835-camera: Add greyworld AWB mode"
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodt-binding: display: bcm2711-hdmi: Add CEC and hotplug interrupts
Maxime Ripard [Mon, 11 Jan 2021 14:23:07 +0000 (15:23 +0100)]
dt-binding: display: bcm2711-hdmi: Add CEC and hotplug interrupts

The CEC and hotplug interrupts were missing when that binding was
introduced, let's add them in now that we've figured out how it works.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Fix number of controls in v4l2_ctrl_handler_init
David Plowman [Thu, 4 Feb 2021 21:21:44 +0000 (21:21 +0000)]
media: i2c: imx290: Fix number of controls in v4l2_ctrl_handler_init

The number is only a hint, but may as well be correct.

Fixes: 471e0029e98aa ("media: i2c: imx290: Convert HMAX setting into V4L2_CID_HBLANK")
Fixes: be0b9b7ad1c27 ("media: i2c: imx290: Add support for V4L2_CID_VBLANK")
Fixes: 8483f0d7599aa ("media: i2c: imx290: Add exposure control to the driver.")
Fixes: 9764f3459c401 ("media: i2c: imx290: Add H and V flip controls")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years agomedia: i2c: imx290: Replace V4L2_CID_GAIN with V4L2_CID_ANALOGUE_GAIN
David Plowman [Thu, 4 Feb 2021 17:29:32 +0000 (17:29 +0000)]
media: i2c: imx290: Replace V4L2_CID_GAIN with V4L2_CID_ANALOGUE_GAIN

Most software (including libcamera) requires V4L2_CID_ANALOGUE_GAIN,
not V4L2_CID_GAIN.

The range for the control is 0 to 100 for which the sensor uses only
analogue gain; higher values would involve digital gain which this
control should not apply.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years 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>
2 years 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")

2 years 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>
2 years 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>
2 years agobcm2835-dma: Add bcm2835-dma: Add DMA_WIDE_SOURCE and DMA_WIDE_DEST flags
Dom Cobley [Wed, 30 Dec 2020 14:51:29 +0000 (14:51 +0000)]
bcm2835-dma: Add bcm2835-dma: Add DMA_WIDE_SOURCE and DMA_WIDE_DEST flags

Use (reserved) bits 24 and 25 of the dreq value
(the second cell of the DT DMA descriptor) to request
that wide source reads or wide dest writes are required

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years agoarch/arm: Add __memset alias to memset_rpi.S
Phil Elwell [Fri, 8 Jan 2021 13:37:25 +0000 (13:37 +0000)]
arch/arm: Add __memset alias to memset_rpi.S

memset_rpi.S is an optimised memset implementation, but doesn't define
__memset (which was just added to memset.S). As a result, building
for the BCM2835 platform causes a link failure.

Add __memset as yet another alias to our common implementation.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>