platform/kernel/linux-rpi.git
4 years agodrm: vc4: Remove now unused structure.
Dave Stevenson [Fri, 5 Apr 2019 16:24:20 +0000 (17:24 +0100)]
drm: vc4: Remove now unused structure.

Cleaning up structure that was unused after
fbb59a2 drm: vc4: Add an overlay plane to vc4-firmware-kms

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agodrm: vc4: Select display to blank during initialisation
Dave Stevenson [Fri, 5 Apr 2019 16:23:15 +0000 (17:23 +0100)]
drm: vc4: Select display to blank during initialisation

Otherwise the rainbow splash screen remained in the display list

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agodrm: vc4: Fix build warning
Dave Stevenson [Fri, 5 Apr 2019 16:21:56 +0000 (17:21 +0100)]
drm: vc4: Fix build warning

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agodrm: vc4: Add support for multiple displays to fkms
Dave Stevenson [Wed, 3 Apr 2019 16:15:45 +0000 (17:15 +0100)]
drm: vc4: Add support for multiple displays to fkms

There is a slightly nasty hack in that all crtcs share the
same SMI interrupt from the firmware. This seems to currently
work well enough, but ought to be fixed at a later date.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agodrm: vc4: Increase max screen size to 4096x4096.
Dave Stevenson [Wed, 3 Apr 2019 14:20:05 +0000 (15:20 +0100)]
drm: vc4: Increase max screen size to 4096x4096.

We now should support 4k screens, therefore this limit needs to
be increased.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agodrm: vc4: Add an overlay plane to vc4-firmware-kms
Dave Stevenson [Wed, 27 Mar 2019 17:45:01 +0000 (17:45 +0000)]
drm: vc4: Add an overlay plane to vc4-firmware-kms

This uses a new API that is exposed via the mailbox service
to stick an element straight on the screen using DispmanX.

The primary and cursor planes have also been switched to using
the new plane API, and it supports layering based on the DRM
zpos parameter.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agogpu: vc4-fkms: Switch to the newer mailbox frame buffer API.
Dave Stevenson [Tue, 26 Mar 2019 14:43:06 +0000 (14:43 +0000)]
gpu: vc4-fkms: Switch to the newer mailbox frame buffer API.

The old mailbox FB API was ideally deprecated but still used by
the FKMS driver.
Update to the newer API.

NB This needs current firmware that accepts ARM allocated buffers
through the newer API.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agodrm/vc4: Fix vblank timestamping for firmwarekms.
Eric Anholt [Tue, 2 Apr 2019 20:29:00 +0000 (13:29 -0700)]
drm/vc4: Fix vblank timestamping for firmwarekms.

The core doesn't expect a false return from the scanoutpos function in
normal usage, so we were doing the precise vblank timestamping path
and thus "immediate" vblank disables (even though firmwarekms can't
actually disable vblanks interrupts, sigh), and the kernel would get
confused when getting timestamp info when also turning vblanks back
on.

Signed-off-by: Eric Anholt <eric@anholt.net>
4 years agodrm/vc4: Expose the format modifiers for firmware kms.
Eric Anholt [Mon, 18 Mar 2019 23:38:32 +0000 (16:38 -0700)]
drm/vc4: Expose the format modifiers for firmware kms.

This should technically not expose VC4_T_TILED on pi4.  However, if we
don't expose anything, then userspace will assume that display can
handle whatever modifiers 3d can do (UIF on 2711).  By exposing a
list, that will get intersected with what 3D can do so that we get T
tiling for display on 2710 and linear on 2711.

Signed-off-by: Eric Anholt <eric@anholt.net>
4 years agodrm/vc4: Fix synchronization firmwarekms against GL rendering.
Eric Anholt [Thu, 28 Mar 2019 18:58:51 +0000 (11:58 -0700)]
drm/vc4: Fix synchronization firmwarekms against GL rendering.

We would present the framebuffer immediately without waiting for
rendering to finish first, resulting in stuttering and flickering as a
window was dragged around when the GPU was busy enough to not just win
the race.

Signed-off-by: Eric Anholt <eric@anholt.net>
4 years agodrm/v3d: Hook up the runtime PM ops.
Eric Anholt [Mon, 14 Jan 2019 22:47:57 +0000 (14:47 -0800)]
drm/v3d: Hook up the runtime PM ops.

In translating the runtime PM code from vc4, I missed the ".pm"
assignment to actually connect them up.  Fixes missing MMU setup if
runtime PM resets V3D.

Signed-off-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit ca197699af29baa8236c74c53d4904ca8957ee06)

4 years agodrm/v3d: Skip MMU flush if the device is currently off.
Eric Anholt [Mon, 14 Jan 2019 20:35:43 +0000 (12:35 -0800)]
drm/v3d: Skip MMU flush if the device is currently off.

If it's off, we know it will be reset on poweron, so the MMU won't
have any TLB cached from before this point.  Avoids failed waits for
MMU flush to reply.

Signed-off-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit 3ee4e2e0a9e9587eacbb69b067bbc72ab2cdc47b)

4 years agodrm/v3d: Add support for 2711.
Eric Anholt [Fri, 5 Oct 2018 00:22:43 +0000 (17:22 -0700)]
drm/v3d: Add support for 2711.

Signed-off-by: Eric Anholt <eric@anholt.net>
4 years agodrm/vc4: Fix oops at boot with firmwarekms on 4.19.
Eric Anholt [Mon, 4 Mar 2019 19:59:34 +0000 (11:59 -0800)]
drm/vc4: Fix oops at boot with firmwarekms on 4.19.

Signed-off-by: Eric Anholt <eric@anholt.net>
4 years agoarm: bcm2835: Add bcm2838 compatible string.
Phil Elwell [Tue, 11 Jun 2019 16:38:28 +0000 (17:38 +0100)]
arm: bcm2835: Add bcm2838 compatible string.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agousbhid: call usb_fixup_endpoint after mangling intervals
Jonathan Bell [Tue, 11 Jun 2019 10:42:03 +0000 (11:42 +0100)]
usbhid: call usb_fixup_endpoint after mangling intervals

Lets the mousepoll override mechanism work with xhci.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 years agoxhci: implement xhci_fixup_endpoint for interval adjustments
Jonathan Bell [Tue, 11 Jun 2019 10:33:39 +0000 (11:33 +0100)]
xhci: implement xhci_fixup_endpoint for interval adjustments

Must be called in a non-atomic context, after the endpoint
has been registered with the hardware via xhci_add_endpoint
and before the first URB is submitted for the endpoint.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 years agousb: add plumbing for updating interrupt endpoint interval state
Jonathan Bell [Tue, 11 Jun 2019 09:55:00 +0000 (10:55 +0100)]
usb: add plumbing for updating interrupt endpoint interval state

xHCI caches device and endpoint data after the interface is configured,
so an explicit command needs to be issued for any device driver wanting
to alter the polling interval of an endpoint.

Add usb_fixup_endpoint() to allow drivers to do this. The fixup must be
called after calculating endpoint bandwidth requirements but before any
URBs are submitted.

If polling intervals are shortened, any bandwidth reservations are no
longer valid but in practice polling intervals are only ever relaxed.

Limit the scope to interrupt transfers for now.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 years agoclk: bcm2835: Allow reparenting leaf clocks while they're running.
Eric Anholt [Thu, 2 May 2019 22:24:04 +0000 (15:24 -0700)]
clk: bcm2835: Allow reparenting leaf clocks while they're running.

This falls under the same "we can reprogram glitch-free as long as we
pause generation" rule as updating the div/frac fields.  This can be
used for runtime reclocking of V3D to manage power leakage.

Signed-off-by: Eric Anholt <eric@anholt.net>
4 years agoclk: bcm2835: Add support for setting leaf clock rates while running.
Eric Anholt [Thu, 2 May 2019 22:11:05 +0000 (15:11 -0700)]
clk: bcm2835: Add support for setting leaf clock rates while running.

As long as you wait for !BUSY, you can do glitch-free updates of clock
rate while the clock is running.

Signed-off-by: Eric Anholt <eric@anholt.net>
4 years agoconfig: Permit LPAE and PCIE_BRCMSTB on BCM2835
Phil Elwell [Tue, 4 Sep 2018 10:50:25 +0000 (11:50 +0100)]
config: Permit LPAE and PCIE_BRCMSTB on BCM2835

4 years agosoc: bcm: bcm2835-pm: Add support for 2711.
Eric Anholt [Sat, 12 Jan 2019 01:31:07 +0000 (17:31 -0800)]
soc: bcm: bcm2835-pm: Add support for 2711.

Without the actual power management part any more, there's a lot less
to set up for V3D.  We just need to clear the RSTN field for the power
domain, and expose the reset controller for toggling it again.

This is definitely incomplete -- the old ISP and H264 is in the old
bridge, but since we have no consumers of it I've just done the
minimum to get V3D working.

Signed-off-by: Eric Anholt <eric@anholt.net>
4 years agoclk-bcm2835: Don't wait for pllh lock
Phil Elwell [Wed, 23 Jan 2019 16:11:50 +0000 (16:11 +0000)]
clk-bcm2835: Don't wait for pllh lock

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agospi: bcm2835: enable shared interrupt support
Martin Sperl [Mon, 13 May 2019 11:05:27 +0000 (11:05 +0000)]
spi: bcm2835: enable shared interrupt support

Add shared interrupt support for this driver.

Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
4 years agousb: xhci: Show that the VIA VL805 supports LPM
Phil Elwell [Thu, 23 May 2019 14:08:30 +0000 (15:08 +0100)]
usb: xhci: Show that the VIA VL805 supports LPM

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agousb: xhci: Disable the XHCI 5 second timeout
Tim Gover [Fri, 22 Mar 2019 09:47:14 +0000 (09:47 +0000)]
usb: xhci: Disable the XHCI 5 second timeout

If the VL805 EEPROM has not been programmed then boot will hang for five
seconds. The timeout seems to be arbitrary and is an unecessary
delay on the first boot. Remove the timeout.

This is common code and probably can't be upstreamed unless the timeout
can be configurable somehow or perhaps the XHCI driver can be skipped
on the first boot.

4 years agophy: bcm54213pe: configure the LED outputs to be more user-friendly
Jonathan Bell [Fri, 17 May 2019 12:31:21 +0000 (13:31 +0100)]
phy: bcm54213pe: configure the LED outputs to be more user-friendly

The default state was both LEDs indicating link speed.

Change the default configuration to
- Amber: 1000/100 link speed indication
- Green: link present + activity indication

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 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>
4 years agonet: genet: enable link energy detect powerdown for external PHYs
Jonathan Bell [Tue, 14 May 2019 16:17:59 +0000 (17:17 +0100)]
net: genet: enable link energy detect powerdown for external PHYs

There are several warts surrounding bcmgenet_mii_probe() as this
function is called from ndo_open, but it's calling registration-type
functions. The probe should be called at probe time and refactored
such that the PHY device data can be extracted to limit the scope
of this flag to Broadcom PHYs.

For now, pass this flag in as it puts our attached PHY into a low-power
state when disconnected.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
4 years agobcmgenet: Better coalescing parameter defaults
Phil Elwell [Wed, 27 Mar 2019 13:45:46 +0000 (13:45 +0000)]
bcmgenet: Better coalescing parameter defaults

Set defaults for TX and RX packet coalescing to be equivalent to:

  # ethtool -C eth0 tx-frames 10
  # ethtool -C eth0 rx-usecs 50

This may be something we want to set via DT parameters in the
future.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agobcmgenet: constrain max DMA burst length
Jonathan Bell [Wed, 12 Sep 2018 13:44:53 +0000 (14:44 +0100)]
bcmgenet: constrain max DMA burst length

4 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

4 years agovchiq: Add 36-bit address support
Phil Elwell [Thu, 1 Nov 2018 17:31:37 +0000 (17:31 +0000)]
vchiq: Add 36-bit address support

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agothermal: brcmstb_thermal: Add BCM2838 support
Stefan Wahren [Sat, 18 May 2019 10:26:11 +0000 (12:26 +0200)]
thermal: brcmstb_thermal: Add BCM2838 support

The BCM2838 has an AVS TMON hardware block. This adds the necessary
support to the brcmstb_thermal driver ( no trip handling ).

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
4 years agohwrng: iproc-rng200: Add BCM2838 support
Stefan Wahren [Sat, 4 May 2019 15:06:15 +0000 (17:06 +0200)]
hwrng: iproc-rng200: Add BCM2838 support

The HWRNG on the BCM2838 is compatible to iproc-rng200, so add the
support to this driver instead of bcm2835-rng.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
4 years agommc: sdhci: Mask "spurious" interrupts
Phil Elwell [Fri, 28 Sep 2018 15:24:05 +0000 (16:24 +0100)]
mmc: sdhci: Mask "spurious" interrupts

Add a filter for "spurious" Transfer Complete interrupts, attempting
to make it as specific as possible:
* INT_DATA_END (transfer complete) is set
* There is a stop command in progress
* There is no data transfer in progress

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agoarm: bcm2835: DMA can only address 1GB
Phil Elwell [Wed, 29 May 2019 14:47:42 +0000 (15:47 +0100)]
arm: bcm2835: DMA can only address 1GB

The legacy peripherals can only address the first gigabyte of RAM, so
ensure that DMA allocations are restricted to that region.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agopcie-brcmstb: Changes for BCM2711
Phil Elwell [Tue, 19 Feb 2019 22:06:59 +0000 (22:06 +0000)]
pcie-brcmstb: Changes for BCM2711

The initial brcmstb PCIe driver - originally taken from the V3(?)
patch set - has been modified significantly for the BCM2711.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agodt-bindings: pci: Add DT docs for Brcmstb PCIe device
Jim Quinlan [Mon, 15 Jan 2018 23:28:39 +0000 (18:28 -0500)]
dt-bindings: pci: Add DT docs for Brcmstb PCIe device

The DT bindings description of the Brcmstb PCIe device is described.  This
node can be used by almost all Broadcom settop box chips, using
ARM, ARM64, or MIPS CPU architectures.

Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
4 years agoPCI: brcmstb: Add MSI capability
Phil Elwell [Tue, 19 Feb 2019 22:06:59 +0000 (22:06 +0000)]
PCI: brcmstb: Add MSI capability

This commit adds MSI to the Broadcom STB PCIe host controller. It does
not add MSIX since that functionality is not in the HW.  The MSI
controller is physically located within the PCIe block, however, there
is no reason why the MSI controller could not be moved elsewhere in
the future.

Since the internal Brcmstb MSI controller is intertwined with the PCIe
controller, it is not its own platform device but rather part of the
PCIe platform device.

Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
4 years agoPCI: brcmstb: Add dma-range mapping for inbound traffic
Phil Elwell [Tue, 19 Feb 2019 22:06:59 +0000 (22:06 +0000)]
PCI: brcmstb: Add dma-range mapping for inbound traffic

The Broadcom STB PCIe host controller is intimately related to the
memory subsystem.  This close relationship adds complexity to how cpu
system memory is mapped to PCIe memory.  Ideally, this mapping is an
identity mapping, or an identity mapping off by a constant.  Not so in
this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB
of system memory.  Here is how the PCIe controller maps the
system memory to PCIe memory:

  memc0-a@[        0....3fffffff] <=> pci@[        0....3fffffff]
  memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff]
  memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff]
  memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff]
  memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff]
  memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

Although there are some "gaps" that can be added between the
individual mappings by software, the permutation of memory regions for
the most part is fixed by HW.  The solution of having something close
to an identity mapping is not possible.

The idea behind this HW design is that the same PCIe module can
act as an RC or EP, and if it acts as an EP it concatenates all
of system memory into a BAR so anything can be accessed.  Unfortunately,
when the PCIe block is in the role of an RC it also presents this
"BAR" to downstream PCIe devices, rather than offering an identity map
between its system memory and PCIe space.

Suppose that an endpoint driver allocs some DMA memory.  Suppose this
memory is located at 0x6000_0000, which is in the middle of memc1-a.
The driver wants a dma_addr_t value that it can pass on to the EP to
use.  Without doing any custom mapping, the EP will use this value for
DMA: the driver will get a dma_addr_t equal to 0x6000_0000.  But this
won't work; the device needs a dma_addr_t that reflects the PCIe space
address, namely 0xa000_0000.

So, essentially the solution to this problem must modify the
dma_addr_t returned by the DMA routines routines.  There are two
ways (I know of) of doing this:

(a) overriding/redefining the dma_to_phys() and phys_to_dma() calls
that are used by the dma_ops routines.  This is the approach of

arch/mips/cavium-octeon/dma-octeon.c

In ARM and ARM64 these two routines are defiend in asm/dma-mapping.h
as static inline functions.

(b) Subscribe to a notifier that notifies when a device is added to a
bus.  When this happens, set_dma_ops() can be called for the device.
This method is mentioned in:

    http://lxr.free-electrons.com/source/drivers/of/platform.c?v=3.16#L152

where it says as a comment

    "In case if platform code need to use own special DMA
    configuration, it can use Platform bus notifier and
    handle BUS_NOTIFY_ADD_DEVICE event to fix up DMA
    configuration."

Solution (b) is what this commit does.  It uses its own set of
dma_ops which are wrappers around the arch_dma_ops.  The
wrappers translate the dma addresses before/after invoking
the arch_dma_ops, as appropriate.

Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
4 years agoPCI: brcmstb: Add Broadcom STB PCIe host controller driver
Phil Elwell [Tue, 19 Feb 2019 22:06:59 +0000 (22:06 +0000)]
PCI: brcmstb: Add Broadcom STB PCIe host controller driver

This commit adds the basic Broadcom STB PCIe controller.  Missing is
the ability to process MSI and also handle dma-ranges for inbound
memory accesses.  These two functionalities are added in subsequent
commits.

The PCIe block contains an MDIO interface.  This is a local interface
only accessible by the PCIe controller.  It cannot be used or shared
by any other HW.  As such, the small amount of code for this
controller is included in this driver as there is little upside to put
it elsewhere.

Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
4 years agoFix copy_from_user if BCM2835_FAST_MEMCPY=n
Tim Gover [Thu, 14 Mar 2019 10:16:02 +0000 (10:16 +0000)]
Fix copy_from_user if BCM2835_FAST_MEMCPY=n

The change which introduced CONFIG_BCM2835_FAST_MEMCPY unconditionally
changed the behaviour of arm_copy_from_user. The page pinning code
is not safe on ARMv7 if LPAE & high memory is enabled and causes
crashes which look like PTE corruption.

Make __copy_from_user_memcpy conditional on CONFIG_2835_FAST_MEMCPY=y
which is really an ARMv6 / Pi1 optimization and not necessary on newer
ARM processors.

4 years agoarm: bcm2835: Fix FIQ early ioremap
Phil Elwell [Wed, 20 Feb 2019 08:49:39 +0000 (08:49 +0000)]
arm: bcm2835: Fix FIQ early ioremap

The ioremapping creates mappings within the vmalloc area. The
equivalent early function, create_mapping, now checks that the
requested explicit virtual address is between VMALLOC_START and
VMALLOC_END. As there is no reason to have any correlation between
the physical and virtual addresses, put the required mappings at
VMALLOC_START and above.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agow1: w1-gpio: Make GPIO an output for strong pullup
Phil Elwell [Wed, 12 Jun 2019 16:15:05 +0000 (17:15 +0100)]
w1: w1-gpio: Make GPIO an output for strong pullup

The logic to drive the data line high to implement a strong pullup
assumed that the pin was already an output - setting a value does
not change an input.

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

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
4 years agostaging: bcm2835-codec: Add support for setting S_PARM and G_PARM
Dave Stevenson [Fri, 10 May 2019 13:13:11 +0000 (14:13 +0100)]
staging: bcm2835-codec: Add support for setting S_PARM and G_PARM

Video encode can use the frame rate for rate control calculations,
therefore plumb it through from V4L2's [S|G]_PARM ioctl.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835-codec: Convert V4L2 nsec timestamps to MMAL usec
Dave Stevenson [Fri, 10 May 2019 13:11:58 +0000 (14:11 +0100)]
staging: bcm2835-codec: Convert V4L2 nsec timestamps to MMAL usec

V4L2 uses nsecs, whilst MMAL uses usecs, but the code wasn't converting
between them. This upsets video encode rate control.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agoBluetooth: Check key sizes only when Secure Simple Pairing is enabled
Marcel Holtmann [Wed, 22 May 2019 07:05:40 +0000 (09:05 +0200)]
Bluetooth: Check key sizes only when Secure Simple Pairing is enabled

The encryption is only mandatory to be enforced when both sides are using
Secure Simple Pairing and this means the key size check makes only sense
in that case.

On legacy Bluetooth 2.0 and earlier devices like mice the encryption was
optional and thus causing an issue if the key size check is not bound to
using Secure Simple Pairing.

Fixes: d5bb334a8e17 ("Bluetooth: Align minimum encryption key size for LE and BR/EDR connections")
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: stable@vger.kernel.org
4 years agostaging: mmal-vchiq: Fix memory leak in error path
Dave Stevenson [Thu, 2 May 2019 14:50:01 +0000 (15:50 +0100)]
staging: mmal-vchiq: Fix memory leak in error path

On error, vchiq_mmal_component_init could leave the
event context allocated for ports.
Clean them up in the error path.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal-vchiq: Free the event context for control ports
Dave Stevenson [Wed, 1 May 2019 12:27:23 +0000 (13:27 +0100)]
staging: mmal-vchiq: Free the event context for control ports

vchiq_mmal_component_init calls init_event_context for the
control port, but vchiq_mmal_component_finalise didn't free
it, causing a memory leak..

Add the free call.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835-codec: Remove height padding for ISP role
Dave Stevenson [Thu, 2 May 2019 13:32:21 +0000 (14:32 +0100)]
staging: bcm2835-codec: Remove height padding for ISP role

The ISP has no need for heights to be a multiple of macroblock
sizes, therefore doesn't require the align on the height.
Remove it for the ISP role. (It is required for the codecs).

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835-codec: Correct port width calc for truncation
Dave Stevenson [Thu, 2 May 2019 13:30:24 +0000 (14:30 +0100)]
staging: bcm2835-codec: Correct port width calc for truncation

The calculation converting from V4L2 bytesperline to MMAL
width had an operator ordering issue that lead to Bayer raw 10
(and 12 and 14) setting an incorrect stride for the buffer.
Correct this operation ordering issue.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835-codec: Refactor default resolution code
Dave Stevenson [Wed, 20 Mar 2019 10:06:51 +0000 (10:06 +0000)]
staging: bcm2835-codec: Refactor default resolution code

The default resolution code was different for each role
as compressed formats need to pass bytesperline as 0 and
set up customised buffer sizes.
This is common setup, therefore amend get_sizeimage and
get_bytesperline to do the correct thing whether compressed
or uncompressed.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835_codec: Clean up logging on unloading the driver
Dave Stevenson [Fri, 8 Mar 2019 11:26:00 +0000 (11:26 +0000)]
staging: bcm2835_codec: Clean up logging on unloading the driver

The log line was missing a closing \n, so wasn't added to the
log immediately.
Adds the function of the V4L2 device that is being unregistered
too.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835-codec: NULL component handle on queue_setup failure
Dave Stevenson [Tue, 19 Mar 2019 17:55:09 +0000 (17:55 +0000)]
staging: bcm2835-codec: NULL component handle on queue_setup failure

queue_setup tries creating the relevant MMAL component and configures
the input and output ports as we're expecting to start streaming.
If the port configuration failed then it destroyed the component,
but failed to clear the component handle, therefore release tried
destroying the component again.
Adds some logging should the port config fail as well.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835_codec: Include timing info in SPS headers
Dave Stevenson [Mon, 18 Feb 2019 15:56:42 +0000 (15:56 +0000)]
staging: bcm2835_codec: Include timing info in SPS headers

Inserting timing information into the VUI block of the SPS is
optional with the VPU encoder.
GStreamer appears to require them when using V4L2 M2M, therefore
set the option to enable them from the encoder.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal-vchiq: Update mmal_parameters.h with recently defined params
Dave Stevenson [Mon, 18 Feb 2019 15:52:29 +0000 (15:52 +0000)]
staging: mmal-vchiq: Update mmal_parameters.h with recently defined params

mmal_parameters.h hasn't been updated to reflect additions made
over the last few years. Update it to reflect the currently
supported parameters.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835_codec: Fix handling of VB2_MEMORY_DMABUF buffers
Dave Stevenson [Fri, 15 Feb 2019 11:38:45 +0000 (11:38 +0000)]
staging: bcm2835_codec: Fix handling of VB2_MEMORY_DMABUF buffers

If the queue is configured as VB2_MEMORY_DMABUF then vb2_core_expbuf
fails as it ensures the queue is defined as VB2_MEMORY_MMAP.

Correct the handling so that we unmap the buffer from vcsm and the
VPU on cleanup, and then correctly get the dma buf of the new buffer.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835_codec: Add an option for ignoring Bayer formats.
Dave Stevenson [Fri, 15 Feb 2019 11:36:14 +0000 (11:36 +0000)]
staging: bcm2835_codec: Add an option for ignoring Bayer formats.

This is a workaround for GStreamer currently not identifying Bayer
as a raw format, therefore any device that supports it does not
match the criteria for v4l2convert.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835_codec: Add support for the ISP as an M2M device
Dave Stevenson [Wed, 13 Feb 2019 14:07:52 +0000 (14:07 +0000)]
staging: bcm2835_codec: Add support for the ISP as an M2M device

The MMAL ISP component can also use this same V4L2 wrapper to
provide a M2M format conversion and resizer.
Instantiate 3 V4L2 devices now, one for each of decode, encode,
and isp.
The ISP currently doesn't expose any controls via V4L2, but this
can be extended in the future.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835_codec: Query supported formats from the component
Dave Stevenson [Wed, 13 Feb 2019 13:44:00 +0000 (13:44 +0000)]
staging: bcm2835_codec: Query supported formats from the component

The driver was previously working with hard coded tables of
which video formats were supported by each component.
The components advertise this information via a MMAL parameter,
so retrieve the information from there during probe, and store
in the state structure for that device.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal-vchiq: If the VPU returns an error, don't negate it
Dave Stevenson [Wed, 13 Feb 2019 12:51:03 +0000 (12:51 +0000)]
staging: mmal-vchiq: If the VPU returns an error, don't negate it

There is an enum for the errors that the VPU can return.
port_parameter_get was negating that value, but also using -EINVAL
from the Linux error codes.
Pass the VPU error code as positive values. Should the function
need to pass a Linux failure, then return that as negative.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal-vchiq: Always return the param size from param_get
Dave Stevenson [Wed, 13 Feb 2019 12:36:56 +0000 (12:36 +0000)]
staging: mmal-vchiq: Always return the param size from param_get

mmal-vchiq is a reimplementation of the userland library for MMAL.
When getting a parameter, the client provides the storage and
the size of the storage. The VPU then returns the size of the
parameter that it wished to return, and as much as possible of
that parameter is returned to the client.

The implementation previously only returned the size provided
by the VPU should it exceed the buffer size. So for parameters
such as the supported encodings list the client had no idea
how much of the provided storage had been populated.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal_vchiq: Add in the Bayer encoding formats
Dave Stevenson [Wed, 13 Feb 2019 12:33:29 +0000 (12:33 +0000)]
staging: mmal_vchiq: Add in the Bayer encoding formats

The list of formats was copied before Bayer support was added.
The ISP supports Bayer and is being supported by the bcm2835_codec
driver, so add in the encodings for them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835-codec: Fix potentially uninitialised vars
Dave Stevenson [Thu, 24 Jan 2019 16:36:19 +0000 (16:36 +0000)]
staging: bcm2835-codec: Fix potentially uninitialised vars

src_m2m_buf and dst_m2m_buf were printed in log messages
when there are code paths that don't initialise them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835-codec: variable vb2 may be used uninitialised
Dave Stevenson [Thu, 24 Jan 2019 16:40:01 +0000 (16:40 +0000)]
staging: bcm2835-codec: variable vb2 may be used uninitialised

In op_buffer_cb, the failure path checked whether there was
an associated vb2 buffer before the variable vb2 had been
assigned.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agomedia: ov5647: Use gpiod_set_value_cansleep
Dave Stevenson [Tue, 18 Sep 2018 10:08:51 +0000 (11:08 +0100)]
media: ov5647: Use gpiod_set_value_cansleep

All calls to the gpio library are in contexts that can sleep,
therefore there is no issue with having those GPIOs controlled
by controllers which require sleeping (eg I2C GPIO expanders).

Switch to using gpiod_set_value_cansleep instead of gpiod_set_value
to avoid triggering the warning in gpiolib should the GPIO
controller need to sleep.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agoclk: clk-bcm2835: Use %zd when printing size_t
Dave Stevenson [Thu, 24 Jan 2019 15:09:28 +0000 (15:09 +0000)]
clk: clk-bcm2835: Use %zd when printing size_t

The debug text for how many clocks have been registered
uses "%d" with a size_t. Correct it to "%zd".

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal-vchiq: Fix client_component for 64 bit kernel
Dave Stevenson [Tue, 22 Jan 2019 12:04:09 +0000 (12:04 +0000)]
staging: mmal-vchiq: Fix client_component for 64 bit kernel

The MMAL client_component field is used with the event
mechanism to allow the client to identify the component for
which the event is generated.
The field is only 32bits in size, therefore we can't use a
pointer to the component in a 64 bit kernel.

Component handles are already held in an array per VCHI
instance, so use the array index as the client_component handle
to avoid having to create a new IDR for this purpose.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: vc04_services: Add a V4L2 M2M codec driver
Dave Stevenson [Tue, 25 Sep 2018 13:53:49 +0000 (14:53 +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).

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agomedia: videobuf2: Allow exporting of a struct dmabuf
Dave Stevenson [Mon, 29 Oct 2018 17:57:45 +0000 (17:57 +0000)]
media: videobuf2: Allow exporting of a struct dmabuf

videobuf2 only allowed exporting a dmabuf as a file descriptor,
but there are instances where having the struct dma_buf is
useful within the kernel.

Split the current implementation into two, one step which
exports a struct dma_buf, and the second which converts that
into an fd.

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

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Use a void* pointer as the handle within the kernel

The driver was using an unsigned int as the handle to the outside world,
and doing a nasty cast to the struct dmabuf when handed it back.
This breaks badly with a 64 bit kernel where the pointer doesn't fit
in an unsigned int.

Switch to using a void* within the kernel. Reality is that it is
a struct dma_buf*, but advertising it as such to other drivers seems
to encourage the use of it as such, and I'm not sure on the implications
of that.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: vc04_services: Add new vc-sm-cma driver
Dave Stevenson [Tue, 25 Sep 2018 09:27:11 +0000 (10:27 +0100)]
staging: vc04_services: Add new vc-sm-cma driver

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.org>
staging: vc-sm-cma: Correct DMA configuration.

Now that VCHIQ is setting up the DMA configuration as our
parent device, don't try to configure it during probe.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Use a void* pointer as the handle within the kernel

The driver was using an unsigned int as the handle to the outside world,
and doing a nasty cast to the struct dmabuf when handed it back.
This breaks badly with a 64 bit kernel where the pointer doesn't fit
in an unsigned int.

Switch to using a void* within the kernel. Reality is that it is
a struct dma_buf*, but advertising it as such to other drivers seems
to encourage the use of it as such, and I'm not sure on the implications
of that.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Fix up for 64bit builds

There were a number of logging lines that were using
inappropriate formatting under 64bit kernels.

The kernel_id field passed to/from the VPU was being
abused for storing the struct vc_sm_buffer *.
This breaks with 64bit kernels, so change to using an IDR.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc_sm_cma: Remove erroneous misc_deregister

Code from the misc /dev node was still present in
bcm2835_vc_sm_cma_remove, which caused a NULL deref.
Remove it.

See #2885.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Remove the debugfs directory on remove

Without removing that, reloading the driver fails.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Use devm_ allocs for sm_state.

Use managed allocations for sm_state, removing reliance on
manual management.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Don't fail if debugfs calls fail.

Return codes from debugfs calls should never alter the
flow of the main code.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Ensure mutex and idr are destroyed

map_lock and kernelid_map are created in probe, but not released
in release should the vcsm service not connect (eg running the
cutdown firmware).

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Remove obsolete comment and make function static

Removes obsolete comment about wanting to pass a function
pointer into mmal-vchiq as we now do.
As the function is passed as a function pointer, the function itself
can be static.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Add in allocation for VPU requests.

Module has to change from tristate to bool as all CMA functions
are boolean.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Update TODO.

The driver is already a platform driver, so that can be
deleted from the TODO.
There are no known issues that need to be resolved.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Add in userspace allocation API

Replacing the functionality from the older vc-sm driver,
add in a userspace API that allows allocation of buffers,
and importing of dma-bufs.
The driver hands out dma-buf fds, therefore much of the
handling around lifespan and odd mmaps from the old driver
goes away.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vcsm-cma: Add cache control ioctls

The old driver allowed for direct cache manipulation and that
was used by various clients. Replicate here.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vcsm-cma: Alter dev node permissions to 0666

Until the udev rules are updated, open up access to this node by
default.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vcsm-cma: Drop logging level on messages in vc_sm_release_resource

They weren't errors but were logged as such.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vcsm-cma: Fixup the alloc code handling of kernel_id

The allocation code had been copied in from an old branch prior
to having added the IDR for 64bit support. It was therefore pushing
a pointer into the kernel_id field instead of an IDR handle, the
lookup therefore failed, and we never released the buffer.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vcsm-cma: Remove cache manipulation ioctl from ARM64

The cache flushing ioctls are used by the Pi3 HEVC hw-assisted
decoder as it needs finer grained flushing control than dma_ops
allow.
These cache calls are not present for ARM64, therefore disable
them. We are not actively supporting 64bit kernels at present,
and the use case of the HEVC decoder is fairly limited.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vcsm-cma: Rework to use dma APIs, not CMA

Due to a misunderstanding of the DMA mapping APIs, I made
the wrong decision on how to implement this.

Rework to use dma_alloc_coherent instead of the CMA
API. This also allows it to be built as a module easily.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc-sm-cma: Fix the few remaining coding style issues

Fix a few minor checkpatch complaints to make the driver clean

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
staging: vc04_services: fix compiling in separate directory

The vc04_services Makefiles do not respect the O=path argument
correctly: include paths in CFLAGS are given relatively to object path,
not source path. Compiling in a separate directory yields #include
errors.

Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
vc-sm-cma: Fix compatibility ioctl

This code path hasn't been used previously.
Fixed up after testing with kodi on 32-bit userland and 64-bit kernel

Signed-off-by: popcornmix <popcornmix@gmail.com>
4 years agostaging: vc04_services: Fixup vchiq-mmal include ordering
Dave Stevenson [Tue, 25 Sep 2018 15:57:40 +0000 (16:57 +0100)]
staging: vc04_services: Fixup vchiq-mmal include ordering

There were dependencies on including the headers in the correct
order. Fix up the headers so that they include the other
headers that they depend on themselves.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: vc04_services: Support sending data to MMAL ports
Dave Stevenson [Mon, 24 Sep 2018 17:26:02 +0000 (18:26 +0100)]
staging: vc04_services: Support sending data to MMAL ports

Add the ability to send data to ports. This only supports
zero copy mode as the required bulk transfer setup calls
are not done.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal-vchiq: Add support for event callbacks.
Dave Stevenson [Mon, 24 Sep 2018 17:15:38 +0000 (18:15 +0100)]
staging: mmal-vchiq: Add support for event callbacks.

(Preparation for the codec driver).
The codec uses the event mechanism to report things such as
resolution changes. It is signalled by the cmd field of the buffer
being non-zero.

Add support for passing this information out to the client.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal-vchiq: Make a mmal_buf struct for passing parameters
Dave Stevenson [Mon, 24 Sep 2018 16:33:37 +0000 (17:33 +0100)]
staging: mmal-vchiq: Make a mmal_buf struct for passing parameters

The callback from vchi_mmal to the client was growing lots of extra
parameters. Consolidate them into a single struct instead of
growing the list further.
The struct is associated with the client buffer, therefore there
are various changes to setup various containers for the struct,
and pass the appropriate members.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal-vchiq: Make timeout a defined parameter
Dave Stevenson [Mon, 24 Sep 2018 15:57:09 +0000 (16:57 +0100)]
staging: mmal-vchiq: Make timeout a defined parameter

The timeout period for VPU communications is a useful thing
to extend when debugging.
Set it via a define, rather than a magic number buried in the code.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal-vchiq: Avoid use of bool in structures
Dave Stevenson [Mon, 29 Oct 2018 16:20:46 +0000 (16:20 +0000)]
staging: mmal-vchiq: Avoid use of bool in structures

Fixes up a checkpatch error "Avoid using bool structure members
because of possible alignment issues".

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: mmal-vchiq: Allocate and free components as required
Dave Stevenson [Mon, 24 Sep 2018 15:51:13 +0000 (16:51 +0100)]
staging: mmal-vchiq: Allocate and free components as required

The existing code assumed that there would only ever be 4 components,
and never freed the entries once used.
Allow arbitrary creation and destruction of components.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: vc04_services: Split vchiq-mmal into a module
Dave Stevenson [Mon, 24 Sep 2018 15:30:37 +0000 (16:30 +0100)]
staging: vc04_services: Split vchiq-mmal into a module

In preparation for adding a video codec V4L2 module which also
wants to use vchiq-mmal functions, split it out into an
independent module.
The minimum number of changes have been made to achieve this
(eg straight moves where possible) so existing checkpatch
errors will still be present.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835-camera: Ensure timestamps never go backwards.
Dave Stevenson [Tue, 24 Jul 2018 11:08:29 +0000 (12:08 +0100)]
staging: bcm2835-camera: Ensure timestamps never go backwards.

There is an awkward situation with H264 header bytes. Currently
they are returned with a PTS of 0 because they aren't associated
with a timestamped frame to encode. These are handled by either
returning the timestamp of the last buffer to have been received,
or in the case of the first buffer the timestamp taken at
start_streaming.
This results in a race where the current frame may have started
before we take the start time, which results in the first encoded
frame having an earlier timestamp than the header bytes.

Ensure that we never return a negative delta to the user by checking
against the previous timestamp.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: bcm2835-camera: Fix logical continuation splits
Dave Stevenson [Wed, 21 Feb 2018 15:48:54 +0000 (15:48 +0000)]
staging: bcm2835-camera: Fix logical continuation splits

Fix checkpatch errors for "Logical continuations should be
on the previous line".

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agostaging: vchiq_arm: Fix platform device unregistration
Stefan Wahren [Sat, 13 Oct 2018 18:51:23 +0000 (20:51 +0200)]
staging: vchiq_arm: Fix platform device unregistration

In error case platform_device_register_data would return an ERR_PTR
instead of NULL. So we better check this before unregistration.

Fixes: 37b7b3087a2f ("staging/vc04_services: Register a platform device for the camera driver.")
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
4 years agomedia: tc358743: Return an appropriate colorspace from tc358743_set_fmt
Dave Stevenson [Thu, 22 Nov 2018 17:31:06 +0000 (17:31 +0000)]
media: tc358743: Return an appropriate colorspace from tc358743_set_fmt

When calling tc358743_set_fmt, the code was calling tc358743_get_fmt
to choose a valid format. However that sets the colorspace
based on what was read back from the chip. When you set the format,
then the driver would choose and program the colorspace based
on the format code.

The result was that if you called try or set format for UYVY
when the current format was RGB3 then you would get told sRGB,
and try RGB3 when current was UYVY and you would get told
SMPTE170M.

The value programmed into the chip is determined by this driver,
therefore there is no need to read back the value. Return the
colorspace based on the format set/tried instead.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agoMAINTAINERS: Add entry for BCM2835 Unicam driver
Dave Stevenson [Wed, 31 Oct 2018 14:59:40 +0000 (14:59 +0000)]
MAINTAINERS: Add entry for BCM2835 Unicam driver

Adds entry for the new BCM2835 Unicam (CSI-2 receiver) driver

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agodt-bindings: Document BCM283x CSI2/CCP2 receiver
Dave Stevenson [Wed, 31 Oct 2018 14:59:06 +0000 (14:59 +0000)]
dt-bindings: Document BCM283x CSI2/CCP2 receiver

Document the DT bindings for the CSI2/CCP2 receiver peripheral
(known as Unicam) on BCM283x SoCs.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
Acked-by: Rob Herring <robh@kernel.org>
4 years agomedia: videodev2: Add helper defines for printing FOURCCs
Dave Stevenson [Wed, 31 Oct 2018 14:58:08 +0000 (14:58 +0000)]
media: videodev2: Add helper defines for printing FOURCCs

New helper defines that allow printing of a FOURCC using
printf(V4L2_FOURCC_CONV, V4L2_FOURCC_CONV_ARGS(fourcc));

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agomedia: adv7180: Add YPrPb support for ADV7282M
Dave Stevenson [Wed, 31 Oct 2018 14:57:56 +0000 (14:57 +0000)]
media: adv7180: Add YPrPb support for ADV7282M

The ADV7282M can support YPbPr on AIN1-3, but this was
not selectable from the driver. Add it to the list of
supported input modes.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agomedia: adv7180: Default to the first valid input
Dave Stevenson [Wed, 31 Oct 2018 14:57:46 +0000 (14:57 +0000)]
media: adv7180: Default to the first valid input

The hardware default is differential CVBS on AIN1 & 2, which
isn't very useful.

Select the first input that is defined as valid for the
chip variant (typically CVBS_AIN1).

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agomedia: tc358743: Check I2C succeeded during probe.
Dave Stevenson [Wed, 31 Oct 2018 14:57:34 +0000 (14:57 +0000)]
media: tc358743: Check I2C succeeded during probe.

The probe for the TC358743 reads the CHIPID register from
the device and compares it to the expected value of 0.
If the I2C request fails then that also returns 0, so
the driver loads thinking that the device is there.

Generally I2C communications are reliable so there is
limited need to check the return value on every transfer,
therefore only amend the one read during probe to check
for I2C errors.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agomedia: tc358743: Add support for 972Mbit/s link freq.
Dave Stevenson [Wed, 31 Oct 2018 14:57:21 +0000 (14:57 +0000)]
media: tc358743: Add support for 972Mbit/s link freq.

Adds register setups for running the CSI lanes at 972Mbit/s,
which allows 1080P50 UYVY down 2 lanes.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agomedia: tc358743: fix connected/active CSI-2 lane reporting
Philipp Zabel [Thu, 21 Sep 2017 15:30:24 +0000 (17:30 +0200)]
media: tc358743: fix connected/active CSI-2 lane reporting

g_mbus_config was supposed to indicate all supported lane numbers, not
only the number of those currently in active use. Since the TC358743
can dynamically reduce the number of active lanes if the required
bandwidth allows for it, report all lane numbers up to the connected
number of lanes as supported in pdata mode.
In device tree mode, do not report lane count and clock mode at all, as
the receiver driver can determine these from the device tree.

To allow communicating the number of currently active lanes, add a new
bitfield to the v4l2_mbus_config flags. This is a temporary fix, to be
used only until a better solution is found.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
4 years agomedia: tc358743: Increase FIFO level to 374.
Dave Stevenson [Wed, 31 Oct 2018 14:56:59 +0000 (14:56 +0000)]
media: tc358743: Increase FIFO level to 374.

The existing fixed value of 16 worked for UYVY 720P60 over
2 lanes at 594MHz, or UYVY 1080P60 over 4 lanes. (RGB888
1080P60 needs 6 lanes at 594MHz).
It doesn't allow for lower resolutions to work as the FIFO
underflows.

374 is required for 1080P24-30 UYVY over 2 lanes @ 972Mbit/s, but
>374 means that the FIFO underflows on 1080P50 UYVY over 2 lanes
@ 972Mbit/s.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agomedia: ov5647: Add support for non-continuous clock mode
Dave Stevenson [Wed, 31 Oct 2018 14:56:47 +0000 (14:56 +0000)]
media: ov5647: Add support for non-continuous clock mode

The driver was only supporting continuous clock mode
although this was not stated anywhere.
Non-continuous clock saves a small amount of power and
on some SoCs is easier to interface with.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agomedia: ov5647: Add support for PWDN GPIO.
Dave Stevenson [Wed, 31 Oct 2018 14:56:33 +0000 (14:56 +0000)]
media: ov5647: Add support for PWDN GPIO.

Add support for an optional GPIO connected to PWDN on the sensor.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years ago[media] Documentation: DT: add device tree for PWDN control
Dave Stevenson [Wed, 31 Oct 2018 14:55:59 +0000 (14:55 +0000)]
[media] Documentation: DT: add device tree for PWDN control

Add optional GPIO pwdn to connect to the PWDN line on the sensor.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agomedia: ov5647: Add set_fmt and get_fmt calls.
Dave Stevenson [Wed, 31 Oct 2018 14:55:37 +0000 (14:55 +0000)]
media: ov5647: Add set_fmt and get_fmt calls.

There's no way to query the subdevice for the supported
resolutions.
Add set_fmt and get_fmt implementations.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
4 years agosound: pcm512x-codec: Adding 352.8kHz samplerate support
Klaus Schulz [Thu, 16 May 2019 11:35:32 +0000 (13:35 +0200)]
sound: pcm512x-codec: Adding 352.8kHz samplerate support

4 years agoAdded IQaudIO Pi-Codec board support (#2969)
IQaudIO [Mon, 13 May 2019 20:53:05 +0000 (21:53 +0100)]
Added IQaudIO Pi-Codec board support (#2969)

Add support for the IQaudIO Pi-Codec board.

Signed-off-by: Gordon <gordon@iqaudio.com>
Fixed 48k timing issue

ASoC: iqaudio-codec: use modern dai_link style

Signed-off-by: Hui Wang <hui.wang@canonical.com>