platform/kernel/linux-rpi.git
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>
2 years agobcm2835-dma: Avoid losing CS flags after interrupt
Dom Cobley [Wed, 6 Jan 2021 18:16:10 +0000 (18:16 +0000)]
bcm2835-dma: Avoid losing CS flags after interrupt

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
2 years 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>
2 years 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>
2 years agostaging/bcm2835-codec: Log the number of excess supported formats
Dave Stevenson [Thu, 7 Jan 2021 11:41:26 +0000 (11:41 +0000)]
staging/bcm2835-codec: 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>
2 years agostaging/bcm2835-codec: Add the unpacked (16bpp) raw formats
Dave Stevenson [Thu, 7 Jan 2021 10:45:16 +0000 (10:45 +0000)]
staging/bcm2835-codec: 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>
2 years 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>
2 years agovc-sm-cma: fixed kbuild problem
gesangtome [Fri, 1 Jan 2021 10:03:17 +0000 (18:03 +0800)]
vc-sm-cma: fixed kbuild problem

error logs:
  drivers/staging/vc04_services/vc-sm-cma/Kconfig:1:error: recursive dependency detected!
  drivers/staging/vc04_services/vc-sm-cma/Kconfig:1:      symbol BCM_VC_SM_CMA is selected by BCM2835_VCHIQ_MMAL
  drivers/staging/vc04_services/vchiq-mmal/Kconfig:1:     symbol BCM2835_VCHIQ_MMAL depends on BCM2835_VCHIQ
  drivers/staging/vc04_services/Kconfig:14:       symbol BCM2835_VCHIQ is selected by BCM_VC_SM_CMA
  For a resolution refer to Documentation/kbuild/kconfig-language.rst
  subsection "Kconfig recursive dependency limitations"

Tested-by: make ARCH=arm64 bcm2711_defconfig
Test platform: fedora 33
Branch: rpi-5.10.y

2 years agomedia: i2c: imx477: Selection compliance fixes
Naushir Patuck [Wed, 9 Dec 2020 11:30:12 +0000 (11:30 +0000)]
media: i2c: imx477: Selection compliance fixes

To comply with the intended usage of the V4L2 selection target when
used to retrieve a sensor image properties, adjust the rectangles
returned by the imx477 driver.

The top/left crop coordinates of the TGT_CROP rectangle were set to
(0, 0) instead of (8, 16) which is the offset from the larger physical
pixel array rectangle. This was also a mismatch with the default values
crop rectangle value, so this is corrected. Found with v4l2-compliance.

While at it, add V4L2_SEL_TGT_CROP_BOUNDS support: CROP_DEFAULT and
CROP_BOUNDS have the same size as the non-active pixels are not readable
using the selection API. Found with v4l2-compliance.

This commit mirrors 543790f777ba1b3264c168c653db6d415e7c983f done for
the imx219 sensor.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years agodt-bindings: Add compatible for BCM2711 DSI1
Dave Stevenson [Thu, 12 Nov 2020 17:01:52 +0000 (17:01 +0000)]
dt-bindings: Add compatible for BCM2711 DSI1

DSI1 on BCM2711 doesn't require the DMA workaround that is used
on BCM2835/6/7, therefore it needs a new compatible string.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm/panel/raspberrypi-ts: Insert delay before polling for startup state
Dave Stevenson [Tue, 10 Nov 2020 11:21:56 +0000 (11:21 +0000)]
drm/panel/raspberrypi-ts: Insert delay before polling for startup state

In switching to the hardware I2C controller there is an issue
where we seem to not get back the correct state from the Pi
touchscreen.
Insert a delay before polling to avoid this condition.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodrm/panel/raspberrypi-touchscreen: Use independent I2C actions with delay.
Dave Stevenson [Thu, 23 Apr 2020 09:17:18 +0000 (10:17 +0100)]
drm/panel/raspberrypi-touchscreen: Use independent I2C actions with delay.

We now have the hardware I2C controller pinmuxed to the drive the
display I2C, but this controller does not support clock stretching.
The Atmel micro-controller in the panel requires clock stretching
to allow it to prepare any data to be read.

Split the rpi_touchscreen_i2c_read into two independent transactions with
a delay between them for the Atmel to prepare the data.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agoInput: edt-ft5x06: Poll the device if no interrupt is configured.
Dave Stevenson [Fri, 6 Nov 2020 18:45:10 +0000 (18:45 +0000)]
Input: edt-ft5x06: Poll the device if no interrupt is configured.

Not all systems have the interrupt line wired up, so switch to
polling the touchscreen off a timer if no interrupt line is
configured.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agoPCI: brcmstb: Restore initial fundamental reset
Phil Elwell [Wed, 11 Nov 2020 17:08:33 +0000 (17:08 +0000)]
PCI: brcmstb: Restore initial fundamental reset

[1] replaced a single reset function with a pointer to one of two
implementations, but also removed the call asserting the reset
at the start of brcm_pcie_setup. Doing so breaks Raspberry Pis with
VL805 XHCI controllers lacking dedicated SPI EEPROMs, which have been
used for USB booting but then need to be reset so that the kernel
can reconfigure them. The lack of a reset causes the firmware's loading
of the EEPROM image to RAM to fail, breaking USB for the kernel.

See: https://www.raspberrypi.org/forums/viewtopic.php?p=1758157#p1758157

Fixes: 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")

[1] 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agophy: broadcom: Add bcm54213pe configuration
Phil Elwell [Thu, 29 Oct 2020 14:10:56 +0000 (14:10 +0000)]
phy: broadcom: Add bcm54213pe configuration

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agophy: broadcom: split out the BCM54213PE from the BCM54210E IDs
Jonathan Bell [Tue, 14 May 2019 16:00:41 +0000 (17:00 +0100)]
phy: broadcom: split out the BCM54213PE from the BCM54210E IDs

The last nibble is a revision ID, and the 54213pe is a later rev
than the 54210e. Running the 54210e setup code on a 54213pe results
in a broken RGMII interface.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
2 years agofirmware: raspberrypi: Add support for tryonce reboot flag
Tim Gover [Tue, 20 Oct 2020 10:55:37 +0000 (11:55 +0100)]
firmware: raspberrypi: Add support for tryonce reboot flag

Define a new mailbox (SET_REBOOT_FLAGS) which may be used to
pass optional flags to the Raspberry Pi firmware that changes
the behaviour of the bootloader and firmware during a reboot.

Currently this just defines the 'tryboot' flag which causes
the firmware to load tryboot.txt instead config.txt. This
alternate configuration file can be used to specify the
path of an alternate firmware and kernels allowing a fallback
mechanism to be implemented for OS upgrades.

2 years agowatchdog: bcm2835: Ignore params after the partition number
Tim Gover [Thu, 22 Oct 2020 14:30:55 +0000 (15:30 +0100)]
watchdog: bcm2835: Ignore params after the partition number

Use sscanf to extract the partition number and ignore extra parameters
which are only relevant to other reboot notifiers.

2 years agobcm2708_fb: Fix a build warning
Phil Elwell [Tue, 27 Oct 2020 12:12:22 +0000 (12:12 +0000)]
bcm2708_fb: Fix a build warning

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agorpivid_h625: Fix build warnings
Phil Elwell [Tue, 27 Oct 2020 12:10:40 +0000 (12:10 +0000)]
rpivid_h625: Fix build warnings

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agodwc_otg: Minimise header and fix build warnings
Phil Elwell [Tue, 27 Oct 2020 09:59:49 +0000 (09:59 +0000)]
dwc_otg: Minimise header and fix build warnings

Delete a large amount of unused declaration from "usb.h", some of which
were causing build warnings, and get the module building cleanly.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agorpisense-fb: Set pseudo_pallete to prevent crash on fbcon takeover
Serge Schneider [Mon, 26 Oct 2020 16:38:21 +0000 (16:38 +0000)]
rpisense-fb: Set pseudo_pallete to prevent crash on fbcon takeover

Signed-off-by: Serge Schneider <serge@raspberrypi.com>
2 years agostaging: bcm2835-audio: Add disable-headphones flag
Phil Elwell [Mon, 26 Oct 2020 10:23:22 +0000 (10:23 +0000)]
staging: bcm2835-audio: Add disable-headphones flag

Add a property to allow the headphone output to be disabled. Use an
integer property rather than a boolean so that an overlay can clear it.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agogpio: Add gpio-fsm driver
Phil Elwell [Wed, 30 Sep 2020 11:00:54 +0000 (12:00 +0100)]
gpio: Add gpio-fsm driver

The gpio-fsm driver implements simple state machines that allow GPIOs
to be controlled in response to inputs from other GPIOs - real and
soft/virtual - and time delays. It can:
+ create dummy GPIOs for drivers that demand them,
+ drive multiple GPIOs from a single input, with optional delays,
+ add a debounce circuit to an input,
+ drive pattern sequences onto LEDs
etc.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
gpio-fsm: Fix a build warning

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
gpio-fsm: Rename 'num-soft-gpios' to avoid warning

As of 5.10, the Device Tree parser warns about properties that look
like references to "suppliers" of various services. "num-soft-gpios"
resembles a declaration of a GPIO called "num-soft", causing the value
to be interpreted as a phandle, the owner of which is checked for a
"#gpio-cells" property.

To avoid this warning, rename the gpio-fsm property to "num-swgpios".

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
gpio-fsm: Show state info in /sys/class/gpio-fsm

Add gpio-fsm sysfs entries under /sys/class/gpio-fsm. For each state
machine show the current state, which state (if any) will be entered
after a delay, and the current value of that delay.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
gpio-fsm: Fix shutdown timeout handling

The driver is intended to jump directly to a shutdown state in the
event of a timeout during shutdown, but the sense of the test was
inverted.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
gpio-fsm: Clamp the delay time to zero

The sysfs delay_ms value is calculated live, and it is possible for
the time left to appear to be negative briefly if the timer handling
hasn't completed. Ensure the displayed value never goes below zero,
for the sake of appearances.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agostaging: vc04_services: ISP: Add a more complex ISP processing component
Naushir Patuck [Thu, 23 Apr 2020 09:17:37 +0000 (10:17 +0100)]
staging: vc04_services: ISP: Add a more complex ISP processing component

Driver for the BCM2835 ISP hardware block.  This driver uses the MMAL
component to program the ISP hardware through the VC firmware.

The ISP component can produce two video stream outputs, and Bayer
image statistics. This can't be encompassed in a simple V4L2
M2M device, so create a new device that registers 4 video nodes.

This patch squashes all the development patches from the earlier
rpi-5.4.y branch into one

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agouapi: bcm2835-isp: Add bcm2835-isp uapi header file
Dave Stevenson [Mon, 12 Oct 2020 16:03:14 +0000 (17:03 +0100)]
uapi: bcm2835-isp: Add bcm2835-isp uapi header file

This file defines the userland interface to the bcm2835-isp driver
that will follow in a separate commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agobcm2835-dma: only reserve channel 0 if legacy dma driver is enabled
Matthias Reichl [Sat, 10 Oct 2020 22:48:55 +0000 (00:48 +0200)]
bcm2835-dma: only reserve channel 0 if legacy dma driver is enabled

If CONFIG_DMA_BCM2708 isn't enabled there's no need to mask out
one of the already scarce DMA channels.

Signed-off-by: Matthias Reichl <hias@horus.com>
2 years agostaging: vc04_services: Add a V4L2 M2M codec driver
Dave Stevenson [Thu, 8 Oct 2020 19:24:12 +0000 (20:24 +0100)]
staging: vc04_services: Add a V4L2 M2M codec driver

This adds a V4L2 memory to memory device that wraps the MMAL
video decode and video_encode components for H264 and MJPEG encode
and decode, MPEG4, H263, and VP8 decode (and MPEG2 decode
if the appropriate licence has been purchased).

This patch squashes all the work done in developing the driver
on the Raspberry Pi rpi-5.4.y kernel branch.
Thanks to Kieran Bingham, Aman Gupta, Chen-Yu Tsai, and
Marek Behún for their contributions. Please refer to the
rpi-5.4.y branch for the full history.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
staging/bcm2835-codec: Ensure OUTPUT timestamps are always forwarded

The firmware by default tries to ensure that decoded frame
timestamps always increment. This is counter to the V4L2 API
which wants exactly the OUTPUT queue timestamps passed to the
CAPTURE queue buffers.

Disable the firmware option.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
staging/vc04_services/codec: Add support for CID MPEG_HEADER_MODE

Control V4L2_CID_MPEG_VIDEO_HEADER_MODE controls whether the encoder
is meant to emit the header bytes as a separate packet or with the
first encoded frame.
Add support for it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
staging/vc04_services/codec: Clear last buf dequeued flag on START

It appears that the V4L2 M2M framework requires the driver to manually
call vb2_clear_last_buffer_dequeued on the CAPTURE queue during a
V4L2_DEC_CMD_START.
Add such a call.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
staging/vc04-services/codec: Fix logical precedence issue

Two issues identified with operator precedence in logical
expressions. Fix them.

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

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging: mmal-vchiq: Use vc-sm-cma to support zero copy
Dave Stevenson [Tue, 25 Sep 2018 15:07:55 +0000 (16:07 +0100)]
staging: mmal-vchiq: Use vc-sm-cma to support zero copy

With the vc-sm-cma driver we can support zero copy of buffers between
the kernel and VPU. Add this support to mmal-vchiq.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging: mmal-vchiq: Add monochrome image formats
Dave Stevenson [Wed, 6 May 2020 17:11:14 +0000 (18:11 +0100)]
staging: mmal-vchiq: Add monochrome image formats

Adds support for monochrome image formats in the various
MIPI packings.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging: vchiq-mmal: Add support for 14bit Bayer
Dave Stevenson [Wed, 6 May 2020 17:09:04 +0000 (18:09 +0100)]
staging: vchiq-mmal: Add support for 14bit Bayer

Add in the missing defines.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging: vc04_services: Add new vc-sm-cma driver
Dave Stevenson [Thu, 8 Oct 2020 17:49:52 +0000 (18:49 +0100)]
staging: vc04_services: Add new vc-sm-cma driver

Add Broadcom VideoCore Shared Memory support.

This new driver allows contiguous memory blocks to be imported
into the VideoCore VPU memory map, and manages the lifetime of
those objects, only releasing the source dmabuf once the VPU has
confirmed it has finished with it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging: bcm2835-camera: Replace deprecated V4L2_PIX_FMT_BGR32
Dave Stevenson [Thu, 8 Oct 2020 14:35:14 +0000 (15:35 +0100)]
staging: bcm2835-camera: Replace deprecated V4L2_PIX_FMT_BGR32

V4L2_PIX_FMT_BGR32 is deprecated as it is ambiguous over where
the alpha byte is. Cheese/GStreamer appear to get it wrong for
one, and qv4l2 gets red and blue swapped.

Swap to the newer V4L2_PIX_FMT_BGRX32 format.

https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=267736&p=1738912

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodwc_otg: initialise sched_frame for periodic QHs that were parked
Jonathan Bell [Wed, 7 Oct 2020 14:09:29 +0000 (15:09 +0100)]
dwc_otg: initialise sched_frame for periodic QHs that were parked

If a periodic QH has no remaining QTDs, then it is removed from all
periodic schedules. When re-adding, initialise the sched_frame and
start_split_frame from the current value of the frame counter.

See https://bugs.launchpad.net/raspbian/+bug/1819560
and
 https://github.com/raspberrypi/linux/issues/3883

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2 years agochar: Add broadcom char drivers back to build files
popcornmix [Mon, 28 Sep 2020 19:23:30 +0000 (20:23 +0100)]
char: Add broadcom char drivers back to build files

See: https://github.com/raspberrypi/linux/issues/3875
Signed-off-by: popcornmix <popcornmix@gmail.com>
2 years agonet: bcmgenet: Reset RBUF on first open
Phil Elwell [Fri, 25 Sep 2020 14:07:23 +0000 (15:07 +0100)]
net: bcmgenet: Reset RBUF on first open

If the RBUF logic is not reset when the kernel starts then there
may be some data left over from any network boot loader. If the
64-byte packet headers are enabled then this can be fatal.

Extend bcmgenet_dma_disable to do perform the reset, but not when
called from bcmgenet_resume in order to preserve a wake packet.

N.B. This different handling of resume is just based on a hunch -
why else wouldn't one reset the RBUF as well as the TBUF? If this
isn't the case then it's easy to change the patch to make the RBUF
reset unconditional.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agorpivid_h265: Fix width/height typo
popcornmix [Mon, 21 Sep 2020 13:02:44 +0000 (14:02 +0100)]
rpivid_h265: Fix width/height typo

Signed-off-by: popcornmix <popcornmix@gmail.com>
2 years agobrcmfmac: Increase power saving delay to 2s
Phil Elwell [Mon, 3 Feb 2020 09:32:22 +0000 (09:32 +0000)]
brcmfmac: Increase power saving delay to 2s

Increase the delay before entering the lower power state to 2 seconds
(the maximum allowed) in order to reduce the packet latencies,
particularly for inbound packets.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agostaging/fbtft: Add support for display variants
Phil Elwell [Tue, 1 Sep 2020 17:15:27 +0000 (18:15 +0100)]
staging/fbtft: Add support for display variants

Display variants are intended as a replacement for the now-deleted
fbtft_device drivers. Drivers can register additional compatible
strings with a custom callback that can make the required changes
to the fbtft_display structure.

Start the ball rolling by adding adafruit18, adafruit18_green and
sainsmart18 displays.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agomedia: bcm2835-unicam: change minimum number of vb2_queue buffers to 1
David Plowman [Thu, 28 May 2020 10:09:48 +0000 (11:09 +0100)]
media: bcm2835-unicam: change minimum number of vb2_queue buffers to 1

Since the unicam driver was modified to write to a dummy buffer when no
user-supplied buffer is available, it can now write to and return a
buffer even when there's only a single one. Enable this by changing the
min_buffers_needed in the vb2_queue; it will be useful for enabling
still captures without allocating more memory than absolutely necessary.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2 years agomedia: bcm2835-unicam: Retain packing information on G_FMT
Dave Stevenson [Tue, 19 May 2020 10:46:47 +0000 (11:46 +0100)]
media: bcm2835-unicam: Retain packing information on G_FMT

The change to retrieve the pixel format always on g_fmt didn't
check whether the native or unpacked version of the format
had been requested, and always returned the packed one.
Correct this so that the packing setting is retained whereever
possible.

Fixes "9d59e89 media: bcm2835-unicam: Re-fetch mbus code from subdev
on a g_fmt call"

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: bcm2835-unicam: Fixup review comments from Hans.
Dave Stevenson [Tue, 23 Jun 2020 14:14:05 +0000 (15:14 +0100)]
media: bcm2835-unicam: Fixup review comments from Hans.

Updates the driver based on the upstream review comments from
Hans Verkuil at https://patchwork.linuxtv.org/patch/63531/

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: bcm2835: unicam: Fix uninitialized warning
Jacko Dirks [Tue, 5 May 2020 12:33:31 +0000 (14:33 +0200)]
media: bcm2835: unicam: Fix uninitialized warning

Signed-off-by: Jacko Dirks <jdirks.linuxdev@gmail.com>
2 years agomedia: bcm2835-unicam: Always service interrupts
Dave Stevenson [Wed, 13 May 2020 17:28:27 +0000 (18:28 +0100)]
media: bcm2835-unicam: Always service interrupts

From when bringing up the driver, there was a check in the isr
to ignore interrupts (claiming them handled) should the driver
not be streaming.

The VPU now will not register a camera driver if it finds a
CSI2 node enabled in device tree, therefore this flawed check is
redundant.

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

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx477: Parse and register properties
Laurent Pinchart [Fri, 3 Jul 2020 22:45:08 +0000 (01:45 +0300)]
media: i2c: imx477: 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: i2c: imx477: Return correct result on sensor id verification
Naushir Patuck [Tue, 19 May 2020 15:56:33 +0000 (16:56 +0100)]
media: i2c: imx477: Return correct result on sensor id verification

The test should return -EIO if the register read id does not match
the expected sensor id.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agomedia: i2c: imx477: Add support for adaptive frame control
Naushir Patuck [Fri, 8 May 2020 08:41:17 +0000 (09:41 +0100)]
media: i2c: imx477: Add support for adaptive frame control

Use V4L2_CID_EXPOSURE_AUTO_PRIORITY to control if the driver should
automatically adjust the sensor frame length based on exposure time,
allowing variable frame rates and longer exposures.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agomedia: i2c: Add driver for Sony IMX477 sensor
Naushir Patuck [Fri, 8 May 2020 09:00:12 +0000 (10:00 +0100)]
media: i2c: Add driver for Sony IMX477 sensor

Adds a driver for the 12MPix Sony IMX477 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:

4056x3040 12-bit @ 10fps
2028x1520 12-bit (binned) @ 40fps
2028x1050 12-bit (cropped/binned) @ 50fps
1012x760 10-bit (scaled) @ 120 fps

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agoinclude/firmware: Add enum for RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_ID
Dave Stevenson [Thu, 3 Sep 2020 16:09:07 +0000 (17:09 +0100)]
include/firmware: Add enum for RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_ID

Used by audio and FKMS.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agodwc_otg: whitelist_table is now productlist_table
popcornmix [Thu, 3 Sep 2020 13:02:41 +0000 (14:02 +0100)]
dwc_otg: whitelist_table is now productlist_table

2 years agomedia: i2c: tc358743: Only allow supported pixel fmts in set_fmt
Dave Stevenson [Fri, 10 Jul 2020 11:40:50 +0000 (12:40 +0100)]
media: i2c: tc358743: Only allow supported pixel fmts in set_fmt

Fix commit "media: tc358743: Return an appropriate colorspace from
tc358743_set_fmt" to ensure that the format passed in to set_fmt
is checked to be valid, and reset to the current format if not.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: bcm2835-unicam: Drop WARN on uing direct cache alias
Dave Stevenson [Thu, 27 Aug 2020 15:30:26 +0000 (16:30 +0100)]
media: bcm2835-unicam: Drop WARN on uing direct cache alias

Pi 0&1 pass all ARM accesses through the VPU L2 cache, therefore
the dma-ranges property sets the cache alias bits to other
than the direct alias, hence this WARN was firing.

It was overprotective coding, so assume that everything is OK
with the dma-ranges, and remove the WARN.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agostaging: media: rpivid: Select MEDIA_CONTROLLER and MEDIA_CONTROLLER_REQUEST_API
Hristo Venev [Wed, 19 Aug 2020 14:05:53 +0000 (17:05 +0300)]
staging: media: rpivid: Select MEDIA_CONTROLLER and MEDIA_CONTROLLER_REQUEST_API

MEDIA_CONTROLLER_REQUEST_API is a hidden option. If rpivid depends on it,
the user would need to first enable another driver that selects
MEDIA_CONTROLLER_REQUEST_API, and only then rpivid would become available.

By selecting it instead of depending on it, it becomes possible to enable
rpivid without having to enable other potentially unnecessary drivers.

Signed-off-by: Hristo Venev <hristo@venev.name>
2 years agomedia: bcm2835: unicam: Select MEDIA_CONTROLLER and VIDEO_V4L2_SUBDEV_API
Hristo Venev [Wed, 19 Aug 2020 14:02:22 +0000 (17:02 +0300)]
media: bcm2835: unicam: Select MEDIA_CONTROLLER and VIDEO_V4L2_SUBDEV_API

That is what almost all other drivers appear to be doing.

Signed-off-by: Hristo Venev <hristo@venev.name>
2 years agobcm2835-dma: Advertise the full DMA range
Phil Elwell [Wed, 22 Jul 2020 16:59:31 +0000 (17:59 +0100)]
bcm2835-dma: Advertise the full DMA range

Unless the DMA mask is set wider than 32 bits, DMA mapping will use a
bounce buffer.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agoleds: Add the actpwr trigger
Phil Elwell [Mon, 13 Jul 2020 09:33:19 +0000 (10:33 +0100)]
leds: Add the actpwr trigger

The actpwr trigger is a meta trigger that cycles between an inverted
mmc0 and default-on. It is written in a way that could fairly easily
be generalised to support alternative sets of source triggers.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agodt-bindings: bcm2835-unicam: Update documentation with new clock params
Naushir Patuck [Mon, 11 May 2020 12:06:27 +0000 (13:06 +0100)]
dt-bindings: bcm2835-unicam: Update documentation with new clock params

Update the documentation to reflect the new "VPU" clock needed
by the bcm2835-unicam driver.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agomedia: bcm2835: unicam: Set VPU min clock freq to 250Mhz.
Naushir Patuck [Mon, 11 May 2020 12:02:22 +0000 (13:02 +0100)]
media: bcm2835: unicam: Set VPU min clock freq to 250Mhz.

When streaming with Unicam, the VPU must have a clock frequency of at
least 250Mhz.  Otherwise, the input fifos could overrun, causing
image corruption.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2 years agomedia: bcm2835-unicam: Ensure type is VIDEO_CAPTURE in [g|s]_selection
Dave Stevenson [Tue, 7 Jul 2020 13:52:43 +0000 (14:52 +0100)]
media: bcm2835-unicam: Ensure type is VIDEO_CAPTURE in [g|s]_selection

[g|s]_selection pass in a buffer type that needs to be validated
before passing on to the sensor subdev.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: bcm2835-unicam: Reinstate V4L2_CAP_READWRITE in the caps
Dave Stevenson [Tue, 7 Jul 2020 13:23:40 +0000 (14:23 +0100)]
media: bcm2835-unicam: Reinstate V4L2_CAP_READWRITE in the caps

v4l2-compliance throws a failure if the device doesn't advertise
V4L2_CAP_READWRITE but allows read or write operations.
We do support read, so reinstate the flag.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Set the colorspace fields in the format
Dave Stevenson [Tue, 7 Jul 2020 10:51:26 +0000 (11:51 +0100)]
media: i2c: imx290: Set the colorspace fields in the format

The colorspace fields were left untouched in imx290_set_fmt
which lead to a v4l2-compliance failure.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Add support for g_selection to report cropping
Dave Stevenson [Tue, 7 Jul 2020 10:23:48 +0000 (11:23 +0100)]
media: i2c: imx290: Add support for g_selection to report cropping

Userspace needs to know the cropping arrangements for each mode,
so expose this through g_selection.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Explicitly set v&h blank on mode change
Dave Stevenson [Tue, 7 Jul 2020 09:31:53 +0000 (10:31 +0100)]
media: i2c: imx290: Explicitly set v&h blank on mode change

__v4l2_ctrl_modify_range only updates the current value should
it be invalid within the new range. That can leave modes producing
odd frame rates.

Explicitly update the HBLANK and VBLANK values so that on mode
change we revert to the default frame rate for the mode.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agobcm2835-dma: Add NO_WAIT_RESP flag
Phil Elwell [Wed, 1 Jul 2020 19:28:27 +0000 (20:28 +0100)]
bcm2835-dma: Add NO_WAIT_RESP flag

Use bit 27 of the dreq value (the second cell of the DT DMA descriptor)
to request that the WAIT_RESP bit is not set.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agomedia: bcm2835-unicam: Add support for unpacked 14bit Bayer formats
Dave Stevenson [Wed, 1 Jul 2020 09:57:57 +0000 (10:57 +0100)]
media: bcm2835-unicam: Add support for unpacked 14bit Bayer formats

Now that the 14bit non-packed Bayer formats are defined, add them
into the supported formats lookup table.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: bcm2835-unicam: Add support for 14bit mono sources
Dave Stevenson [Thu, 25 Jun 2020 17:03:47 +0000 (18:03 +0100)]
media: bcm2835-unicam: Add support for 14bit mono sources

Now that V4L2_PIX_FMT_Y14 and V4L2_PIX_FMT_Y14P are defined,
allow passing 14bit mono data through the peripheral.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: bcm2835-unicam: Add support for 12bit mono packed format
Dave Stevenson [Thu, 25 Jun 2020 16:53:32 +0000 (17:53 +0100)]
media: bcm2835-unicam: Add support for 12bit mono packed format

Now that V4L2_PIX_FMT_Y12P is defined, allow passing raw 12bit
mono packed data through the peripheral.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: Add a pixel format for MIPI packed 14bit luma only.
Dave Stevenson [Thu, 25 Jun 2020 16:51:03 +0000 (17:51 +0100)]
media: Add a pixel format for MIPI packed 14bit luma only.

This is the format used by monochrome 14bit image sensors.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: Add a pixel format for MIPI packed 12bit luma only.
Dave Stevenson [Thu, 7 May 2020 15:59:03 +0000 (16:59 +0100)]
media: Add a pixel format for MIPI packed 12bit luma only.

This is the format used by monochrome 12bit image sensors.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agoserial: 8250: bcm2835aux - defer if clock is zero
Phil Elwell [Thu, 2 Jul 2020 12:53:20 +0000 (13:53 +0100)]
serial: 8250: bcm2835aux - defer if clock is zero

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

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2 years agomedia: i2c: imx290: Switch set_hmax to use imx290_write_buffered_reg
Dave Stevenson [Fri, 26 Jun 2020 17:11:49 +0000 (18:11 +0100)]
media: i2c: imx290: Switch set_hmax to use imx290_write_buffered_reg

imx290_set_hmax was using two independent writes to set up hmax,
when all other multi-register writes were using imx290_write_buffered_reg
which claims the group hold first.

Switch imx290_set_hmax to using imx290_write_buffered_reg too.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia : i2c: imx290: Add support for the mono sensor variant.
Dave Stevenson [Thu, 25 Jun 2020 16:03:11 +0000 (17:03 +0100)]
media : i2c: imx290: Add support for the mono sensor variant.

The IMX290 module is available as either mono or colour (Bayer).

Update the driver so that it can advertise the correct mono
formats instead of the colour ones.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: dt-bindings: media: i2c: Add mono version to IMX290 bindings
Dave Stevenson [Thu, 25 Jun 2020 15:52:14 +0000 (16:52 +0100)]
media: dt-bindings: media: i2c: Add mono version to IMX290 bindings

The IMX290 module is available as either monochrome or colour and
the variant is not detectable at runtime.

Add a new compatible string for the monochrome version.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Add H and V flip controls
Dave Stevenson [Thu, 11 Jun 2020 17:34:16 +0000 (18:34 +0100)]
media: i2c: imx290: Add H and V flip controls

The sensor supports horizontal and vertical flips, so support them
through V4L2_CID_HFLIP and V4L2_CID_VFLIP.

This sensor does NOT change the Bayer order when changing the
direction of readout, therefore no special handling is required for
that.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Add exposure control to the driver.
Dave Stevenson [Thu, 11 Jun 2020 17:19:13 +0000 (18:19 +0100)]
media: i2c: imx290: Add exposure control to the driver.

Adds support for V4L2_CID_EXPOSURE so that userspace can control
the sensor exposure time.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Add support for V4L2_CID_VBLANK
Dave Stevenson [Thu, 11 Jun 2020 17:09:12 +0000 (18:09 +0100)]
media: i2c: imx290: Add support for V4L2_CID_VBLANK

In order to calculate framerate and durations userspace needs
the vertical blanking information. This can be configurable,
and indeed the datasheet lists different values for VBLANK for
the 1080p and 720p modes.

Add the new control, and adopt the datasheet values for each mode.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Convert HMAX setting into V4L2_CID_HBLANK
Dave Stevenson [Thu, 11 Jun 2020 13:36:40 +0000 (14:36 +0100)]
media: i2c: imx290: Convert HMAX setting into V4L2_CID_HBLANK

Userspace needs to know HBLANK if it is to work out exposure times
and frame rates, therefore convert it to map onto V4L2_CID_HBLANK

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Correct range for V4L2_CID_GAIN to 0-238
Dave Stevenson [Thu, 11 Jun 2020 12:41:43 +0000 (13:41 +0100)]
media: i2c: imx290: Correct range for V4L2_CID_GAIN to 0-238

The datasheet lists the gain as being 0.0 to 72.0dB in 0.3dB steps, which
makes 238 steps total.
Correct the 0-72 range defined in the driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: Add support for 74.25MHz clock
Dave Stevenson [Thu, 25 Jun 2020 07:28:51 +0000 (08:28 +0100)]
media: i2c: imx290: Add support for 74.25MHz clock

The existing driver only supported a clock of 37.125MHz, but the
sensor also supports 74.25MHz.

Add the relevant register modifications to support this alternate
clock frequency.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2 years agomedia: i2c: imx290: set the format before VIDIOC_SUBDEV_G_FMT is called
Andrey Konovalov [Fri, 12 Jun 2020 13:53:46 +0000 (15:53 +0200)]
media: i2c: imx290: set the format before VIDIOC_SUBDEV_G_FMT is called

Commit d46cfdc86c30d5ec768924f0b1e2683c8d20b671 upstream.

With the current driver 'media-ctl -p' issued right after the imx290 driver
is loaded prints:
pad0: Source
             [fmt:unknown/0x0]

The format value of zero is due to the current_format field of the imx290
struct not being initialized yet.

As imx290_entity_init_cfg() calls imx290_set_fmt(), the current_mode field
is also initialized, so the line which set current_mode to a default value
in driver's probe() function is no longer needed.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2 years agomedia: bcm2835-unicam: Avoid gcc warning over {0} on endpoint
Dave Stevenson [Fri, 26 Jun 2020 14:53:44 +0000 (15:53 +0100)]
media: bcm2835-unicam: Avoid gcc warning over {0} on endpoint

Older gcc versions object to = { 0 } initialisation if the first
elemtn in the structure is a substructure.

Use = { } to avoid this compiler warning.

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