platform/kernel/linux-rpi.git
4 years agodrm/vc4: hdmi: Pass vc4_hdmi to CEC code
Maxime Ripard [Mon, 6 Jan 2020 17:47:53 +0000 (18:47 +0100)]
drm/vc4: hdmi: Pass vc4_hdmi to CEC code

Our CEC code also retrieves the associated vc4_hdmi by setting the
vc4_dev pointer as its private data, and then dereferences its vc4_hdmi
pointer.

In order to eventually get rid of that pointer, we can simply pass the
vc4_hdmi pointer directly.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: hdmi: Add container_of macros for encoders and connectors
Maxime Ripard [Mon, 6 Jan 2020 17:45:46 +0000 (18:45 +0100)]
drm/vc4: hdmi: Add container_of macros for encoders and connectors

Whenever the code needs to access the vc4_hdmi structure from a DRM
connector or encoder, it first accesses the drm_device associated to the
connector, then retrieve the drm_dev private data which gives it a
pointer to our vc4_dev, and will finally follow the vc4_hdmi pointer in
that structure.

That will also give us some trouble when having multiple controllers,
but now that we have our encoder and connector structures that are part
of vc4_hdmi, we can simply call container_of on the DRM connector or
encoder and retrieve the vc4_hdmi structure directly.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: hdmi: Use local vc4_hdmi directly
Maxime Ripard [Mon, 6 Jan 2020 17:44:36 +0000 (18:44 +0100)]
drm/vc4: hdmi: Use local vc4_hdmi directly

The function vc4_hdmi_connector_detect access its vc4_hdmi struct by
dereferencing the pointer in the structure vc4_dev. This will cause some
issues when we will have multiple HDMI controllers, so let's just use the
local variable for now instead of dereferencing that pointer all the time,
and we'll fix the local variable later.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: hdmi: Move accessors to vc4_hdmi
Maxime Ripard [Mon, 6 Jan 2020 17:21:44 +0000 (18:21 +0100)]
drm/vc4: hdmi: Move accessors to vc4_hdmi

The current driver only supports a single HDMI controller, and part of
the issue is that the main vc4_dev structure holds a pointer to its
(only) HDMI controller, and the HDMI registers accessors will use it to
retrieve the mapped addresses.

Let's modify those accessors to use directly the vc4_hdmi structure so
that we can eventually get rid of that single global pointer.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: hdmi: Rename hdmi to vc4_hdmi
Maxime Ripard [Mon, 6 Jan 2020 17:07:05 +0000 (18:07 +0100)]
drm/vc4: hdmi: Rename hdmi to vc4_hdmi

The driver isn't consistent with the name given to the vc4_hdmi
structure pointer in its functions. Make sure to use a consistent name.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: hdmi: rework connectors and encoders
Maxime Ripard [Mon, 6 Jan 2020 16:17:29 +0000 (17:17 +0100)]
drm/vc4: hdmi: rework connectors and encoders

the vc4_hdmi driver has some custom structures to hold the data it needs to
associate with the drm_encoder and drm_connector structures.

However, it allocates them separately from the vc4_hdmi structure which
makes it more complicated than it needs to be.

Move those structures to be contained by vc4_hdmi and update the code
accordingly.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: hdmi: Move structure to header
Maxime Ripard [Wed, 18 Dec 2019 17:35:12 +0000 (18:35 +0100)]
drm/vc4: hdmi: Move structure to header

We will need to share the vc4_hdmi and related structures with multiple
files, so let's create a header for it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: hdmi: Use debugfs private field
Maxime Ripard [Tue, 14 Jan 2020 16:24:32 +0000 (17:24 +0100)]
drm/vc4: hdmi: Use debugfs private field

We're calling vc4_debugfs_add_file with our struct vc4_hdmi pointer set
in the private field, but we don't use that field and go through the
main struct vc4_dev to get it.

Let's use the private field directly, that will save us some trouble
later on.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Add BCM2711 pixelvalves
Maxime Ripard [Thu, 26 Dec 2019 10:35:58 +0000 (11:35 +0100)]
drm/vc4: crtc: Add BCM2711 pixelvalves

The BCM2711 has 5 pixelvalves, so now that our driver is ready, let's add
support for them.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodt-bindings: display: vc4: pv: Add BCM2711 pixel valves
Maxime Ripard [Thu, 13 Feb 2020 16:07:02 +0000 (17:07 +0100)]
dt-bindings: display: vc4: pv: Add BCM2711 pixel valves

The BCM2711 comes with other pixelvalves that have different requirements
and capabilities. Let's document their compatible.

Cc: devicetree@vger.kernel.org
Reviewed-by: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Disable color management for HVS5
Maxime Ripard [Fri, 21 Feb 2020 15:54:21 +0000 (16:54 +0100)]
drm/vc4: crtc: Disable color management for HVS5

The HVS5 uses different color matrices. Disable color management support
for now.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Remove redundant call to drm_crtc_enable_color_mgmt
Maxime Ripard [Fri, 21 Feb 2020 15:48:19 +0000 (16:48 +0100)]
drm/vc4: crtc: Remove redundant call to drm_crtc_enable_color_mgmt

The driver calls the helper to add the color management properties twice,
which is redundant. Remove the first one.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Add HDMI1 encoder type
Maxime Ripard [Thu, 9 Jan 2020 17:39:30 +0000 (18:39 +0100)]
drm/vc4: crtc: Add HDMI1 encoder type

The BCM2711 sports a second HDMI controller, so let's add that second HDMI
encoder type.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Rename HDMI encoder type to HDMI0
Maxime Ripard [Thu, 9 Jan 2020 17:35:13 +0000 (18:35 +0100)]
drm/vc4: crtc: Rename HDMI encoder type to HDMI0

The previous generations were only supporting a single HDMI controller, but
that's about to change, so put an index as well to differentiate between
the two controllers.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Add function to compute FIFO level bits
Maxime Ripard [Mon, 13 Jan 2020 12:40:37 +0000 (13:40 +0100)]
drm/vc4: crtc: Add function to compute FIFO level bits

The longer FIFOs in vc5 pixelvalves means that the FIFO full level
doesn't fit in the original register field and that we also have a
secondary field. In order to prepare for this, let's move the registers
fill part to a helper function.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Add FIFO depth to vc4_crtc_data
Maxime Ripard [Mon, 13 Jan 2020 12:39:20 +0000 (13:39 +0100)]
drm/vc4: crtc: Add FIFO depth to vc4_crtc_data

Not all pixelvalve FIFOs in vc5 have the same depth, so we need to add that
to our vc4_crtc_data structure to be able to compute the fill level
properly later on.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Assign output to channel automatically
Maxime Ripard [Thu, 26 Dec 2019 16:53:18 +0000 (17:53 +0100)]
drm/vc4: crtc: Assign output to channel automatically

The HVS found in the BCM2711 has 6 outputs and 3 FIFOs, with each output
being connected to a pixelvalve, and some muxing between the FIFOs and
outputs.

Any output cannot feed from any FIFO though, and they all have a bunch of
constraints.

In order to support this, let's store the possible FIFOs each output can be
assigned to in the vc4_crtc_data, and use that information at atomic_check
time to iterate over all the CRTCs enabled and assign them FIFOs.

The channel assigned is then set in the vc4_crtc_state so that the rest of
the driver can use it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Enable and disable the PV in atomic_enable / disable
Maxime Ripard [Fri, 21 Feb 2020 13:34:31 +0000 (14:34 +0100)]
drm/vc4: crtc: Enable and disable the PV in atomic_enable / disable

The VIDEN bit in the pixelvalve currently being used to enable or disable
the pixelvalve seems to not be enough in some situations, which whill end
up with the pixelvalve stalling.

In such a case, even re-enabling VIDEN doesn't bring it back and we need to
clear the FIFO. This can only be done if the pixelvalve is disabled though.

In order to overcome this, we can configure the pixelvalve during
mode_set_no_fb, but only enable it in atomic_enable and flush the FIFO
there, and in atomic_disable disable the pixelvalve again.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Use local chan variable
Maxime Ripard [Tue, 14 Jan 2020 12:37:27 +0000 (13:37 +0100)]
drm/vc4: crtc: Use local chan variable

The vc4_crtc_handle_page_flip already has a local variable holding the
value of vc4_crtc->channel, so let's use it instead.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Rename HVS channel to output
Maxime Ripard [Thu, 26 Dec 2019 12:49:17 +0000 (13:49 +0100)]
drm/vc4: crtc: Rename HVS channel to output

In vc5, the HVS has 6 outputs and 3 FIFOs (or channels), with
pixelvalves each being assigned to a given output, but each output can
then be muxed to feed from multiple FIFOs.

Since vc4 had that entirely static, both were probably equivalent, but
since that changes, let's rename hvs_channel to hvs_output in the
vc4_crtc_data, since a pixelvalve is really connected to an output, and
not to a FIFO.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Move the cob allocation outside of bind
Maxime Ripard [Thu, 26 Dec 2019 14:48:09 +0000 (15:48 +0100)]
drm/vc4: crtc: Move the cob allocation outside of bind

The COB allocation depends on the HVS channel used for a given
pixelvalve.

While the channel allocation was entirely static in vc4, vc5 changes
that and at bind time, a pixelvalve can be assigned to multiple
HVS channels.

Let's prepare that rework by allocating the COB when it's actually
needed.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Turn static const variable into a define
Maxime Ripard [Mon, 13 Jan 2020 12:39:32 +0000 (13:39 +0100)]
drm/vc4: crtc: Turn static const variable into a define

The hvs_latency_pix variable doesn't need to be a variable and can just be
defined.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Use a shared interrupt
Maxime Ripard [Thu, 9 Jan 2020 17:40:49 +0000 (18:40 +0100)]
drm/vc4: crtc: Use a shared interrupt

Some pixelvalves in vc5 use the same interrupt line so let's register our
interrupt handler as a shared one.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Deal with different number of pixel per clock
Maxime Ripard [Thu, 26 Dec 2019 10:36:50 +0000 (11:36 +0100)]
drm/vc4: crtc: Deal with different number of pixel per clock

Some of the HDMI pixelvalves in vc5 output two pixels per clock cycle.
Let's put the number of pixel output per clock cycle in the CRTC data and
update the various calculations to reflect that.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Move crtc state to common header
Maxime Ripard [Thu, 26 Dec 2019 14:45:04 +0000 (15:45 +0100)]
drm/vc4: crtc: Move crtc state to common header

We'll need to access the crtc_state from outside of vc4_crtc.c, so let's
move it to vc4_drv.h

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: crtc: Rename SoC data structures
Maxime Ripard [Thu, 26 Dec 2019 10:45:04 +0000 (11:45 +0100)]
drm/vc4: crtc: Rename SoC data structures

Since we're going to introduce pixelvalve data structures for other SoCs
than the BCM2835, let's rename the structures defined in the code to
make it obvious which SoC we're targetting.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: plane: Create more planes
Maxime Ripard [Thu, 6 Feb 2020 13:52:42 +0000 (14:52 +0100)]
drm/vc4: plane: Create more planes

Let's now create more planes that can be affected to all the CRTCs.

vc4 has 3 CRTCs, 1 primary and 1 cursor each, and was having 24 (8
planes per CRTC) overlays.

However, vc5 has 5 CRTCs, so keeping the same logic would put us at 50
planes which is well above the 32 planes limit imposed by DRM.

Using 16 seems like a good tradeoff between staying under 32 and yet
providing enough planes.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: plane: Create overlays for any CRTC
Maxime Ripard [Thu, 6 Feb 2020 13:50:06 +0000 (14:50 +0100)]
drm/vc4: plane: Create overlays for any CRTC

Now that we have everything in place, we can now register all the overlay
planes that can be assigned to all the CRTCs.

This has two side effects:

  - The number of overlay planes is reduced from 24 to 8. This is temporary
    and will be increased again in the next patch.

  - The ID of the various planes is changed again, and we will now have all
    the primary planes, then all the overlay planes and finally the cursor
    planes. This shouldn't cause any issue since the ordering between
    primary, overlay and cursor planes is preserved.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: plane: Register all the planes at once
Maxime Ripard [Thu, 6 Feb 2020 13:46:14 +0000 (14:46 +0100)]
drm/vc4: plane: Register all the planes at once

Instead of creating planes for each CRTC, we eventually want to create all
the planes for each CRTCs.

In order to make that more convenient, let's iterate on the CRTCs in the
plane creation function instead of its caller.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: plane: Move additional planes creation to driver
Maxime Ripard [Thu, 6 Feb 2020 13:41:41 +0000 (14:41 +0100)]
drm/vc4: plane: Move additional planes creation to driver

So far the plane creation was done when each CRTC was bound, and those
planes were only tied to the CRTC that was registering them.

This causes two main issues:
  - The planes in the vc4 hardware are actually not tied to any CRTC, but
    can be used with every combination

  - More importantly, so far, we allocate 10 planes per CRTC, with 3 CRTCs.
    However, the next generation of hardware will have 5 CRTCs, putting us
    well above the maximum of 32 planes currently allowed by DRM.

This patch is the first one in a series of patches that will take down both
of these issues so that we can support the next generation of hardware
while keeping a good amount of planes.

We start by changing the way the planes are registered to first registering
the primary planes for each CRTC in the CRTC bind function as we used to,
but moving the overlay and cursor creation to the main driver bind
function, after all the CRTCs have been bound.

This will slightly change the ID order of the planes, since the primary
planes of all CRTCs will be first, and then a pattern of 8 overlays, 1
cursor plane for each CRTC.

This shouldn't cause any trouble since the ordering between the planes is
preserved though.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: plane: Move planes creation to its own function
Maxime Ripard [Thu, 6 Feb 2020 13:32:57 +0000 (14:32 +0100)]
drm/vc4: plane: Move planes creation to its own function

The planes so far were created as part of the CRTC binding code with
each planes created associated only to one CRTC. However, the hardware
in the vc4 doesn't really have such constraint and can be used with any
CRTC.

In order to rework this, let's first move the overlay and cursor planes
creation to a function of its own.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: plane: Improve LBM usage
Dave Stevenson [Tue, 11 Feb 2020 16:55:02 +0000 (16:55 +0000)]
drm/vc4: plane: Improve LBM usage

LBM allocations were always taking the worst case sizing of
max(src_width, dst_width) * 16. This is significantly over
the required sizing, and stops us rendering multiple 4k images
to the screen.

Add some of the additional constraints to more accurately
describe the LBM requirements.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: drv: Add support for the BCM2711 HVS5
Dave Stevenson [Thu, 8 Aug 2019 16:51:07 +0000 (17:51 +0100)]
drm/vc4: drv: Add support for the BCM2711 HVS5

The HVS found in the BCM2711 is slightly different from the previous
generations.

Most notably, the display list layout changes a bit, the LBM doesn't have
the same size and the formats ordering for some formats is swapped.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: drv: Support BCM2711
Maxime Ripard [Thu, 6 Feb 2020 14:40:34 +0000 (15:40 +0100)]
drm/vc4: drv: Support BCM2711

The BCM2711 has a reworked display pipeline, and the load tracker needs
some adjustement to operate properly. Let's add a compatible for BCM2711
and disable the load tracker until properly supported.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodrm/vc4: drv: Add include guards
Maxime Ripard [Thu, 19 Dec 2019 17:08:48 +0000 (18:08 +0100)]
drm/vc4: drv: Add include guards

vc4_drv.h doesn't have any include guards which prevents it from being
included twice. Let's add them.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodt-bindings: display: vc4: Document BCM2711 VC5
Maxime Ripard [Thu, 13 Feb 2020 16:40:56 +0000 (17:40 +0100)]
dt-bindings: display: vc4: Document BCM2711 VC5

The BCM2711 comes with a new VideoCore. Add a compatible for it.

Cc: devicetree@vger.kernel.org
Reviewed-by: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodt-bindings: display: vc4: hdmi: Add missing clock-names property
Maxime Ripard [Thu, 13 Feb 2020 14:47:18 +0000 (15:47 +0100)]
dt-bindings: display: vc4: hdmi: Add missing clock-names property

While the device tree and the driver expected a clock-names property, it
wasn't explicitly documented in the previous binding. The documented order
was wrong too, so make sure clock-names is there and in the proper order.

Cc: devicetree@vger.kernel.org
Reviewed-by: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodt-bindings: display: vc4: dsi: Add missing clock properties
Maxime Ripard [Thu, 13 Feb 2020 14:47:18 +0000 (15:47 +0100)]
dt-bindings: display: vc4: dsi: Add missing clock properties

While the device tree and the driver expected a clock-names and a
clock-cells properties, it wasn't explicitly documented in the previous
binding. Make sure it is now.

Cc: devicetree@vger.kernel.org
Reviewed-by: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodt-bindings: display: vc4: dpi: Add missing clock-names property
Maxime Ripard [Thu, 13 Feb 2020 14:47:18 +0000 (15:47 +0100)]
dt-bindings: display: vc4: dpi: Add missing clock-names property

While the device tree and the driver expected a clock-names property, it
wasn't explicitly documented in the previous binding. Make sure it is now.

Cc: devicetree@vger.kernel.org
Reviewed-by: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodt-bindings: display: Convert VC4 bindings to schemas
Maxime Ripard [Thu, 13 Feb 2020 14:42:05 +0000 (15:42 +0100)]
dt-bindings: display: Convert VC4 bindings to schemas

The BCM283x SoCs have a display pipeline composed of several controllers
with device tree bindings that are supported by Linux.

Now that we have the DT validation in place, let's split into separate
files and convert the device tree bindings for those controllers to
schemas.

This is just a 1:1 conversion though, and some bindings were incomplete so
it results in example validation warnings that are going to be addressed in
the following patches.

Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoARM: dts: bcm2711: Add HDMI DVP
Maxime Ripard [Tue, 28 Jan 2020 08:37:06 +0000 (09:37 +0100)]
ARM: dts: bcm2711: Add HDMI DVP

Now that we have a driver for the DVP, let's add its DT node.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: Add BCM2711 DVP driver
Maxime Ripard [Tue, 28 Jan 2020 08:36:27 +0000 (09:36 +0100)]
clk: bcm: Add BCM2711 DVP driver

The HDMI block has a block that controls clocks and reset signals to the
HDMI0 and HDMI1 controllers.

Let's expose that through a clock driver implementing a clock and reset
provider.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: linux-clk@vger.kernel.org
Cc: devicetree@vger.kernel.org
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodt-bindings: clock: Add BCM2711 DVP binding
Maxime Ripard [Thu, 13 Feb 2020 16:50:31 +0000 (17:50 +0100)]
dt-bindings: clock: Add BCM2711 DVP binding

The BCM2711 has a unit controlling the HDMI0 and HDMI1 clock and reset
signals. Let's add a binding for it.

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Reviewed-by: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoreset: simple: Add reset callback
Maxime Ripard [Tue, 28 Jan 2020 15:22:20 +0000 (16:22 +0100)]
reset: simple: Add reset callback

The reset-simple code lacks a reset callback that is still pretty easy to
implement. The only real thing to consider is the delay needed for a device
to be reset, so let's expose that as part of the reset-simple driver data.

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoreset: Move reset-simple header out of drivers/reset
Maxime Ripard [Tue, 28 Jan 2020 08:33:52 +0000 (09:33 +0100)]
reset: Move reset-simple header out of drivers/reset

The reset-simple code can be useful for drivers outside of drivers/reset
that have a few reset controls as part of their features. Let's move it to
include/linux/reset.

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoARM: dts: bcm2711: Add firmware clocks node
Maxime Ripard [Mon, 23 Dec 2019 18:58:30 +0000 (19:58 +0100)]
ARM: dts: bcm2711: Add firmware clocks node

Now that we have a clock driver for the clocks exposed by the firmware,
let's add the device tree nodes for it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Discover the firmware clocks
Maxime Ripard [Mon, 10 Feb 2020 13:06:09 +0000 (14:06 +0100)]
clk: bcm: rpi: Discover the firmware clocks

The RaspberryPi4 firmware actually exposes more clocks than are currently
handled by the driver and we will need to change some of them directly
based on the pixel rate for the display related clocks, or the load for the
GPU.

This rate change can have a number of side-effects, including adjusting the
various PLL voltages or the PLL parents. The firmware will also update
those clocks by itself for example if the SoC runs too hot.

In order to make Linux play as nice as possible with those constraints, it
makes sense to rely on the firmware clocks as much as possible.

Fortunately,t he firmware has an interface to discover the clocks it
exposes.

Let's use it to discover, register the clocks in the clocks framework and
then expose them through the device tree for consumers to use them.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Add DT provider for the clocks
Maxime Ripard [Fri, 7 Feb 2020 16:03:46 +0000 (17:03 +0100)]
clk: bcm: rpi: Add DT provider for the clocks

For the upcoming registration of the clocks provided by the firmware, make
sure it's exposed to the device tree providers.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Make the PLLB registration function return a clk_hw
Maxime Ripard [Fri, 7 Feb 2020 15:30:01 +0000 (16:30 +0100)]
clk: bcm: rpi: Make the PLLB registration function return a clk_hw

The raspberrypi_register_pllb has been returning an integer so far to
notify whether the functions has exited successfully or not.

However, the OF provider functions in the clock framework require access to
the clk_hw structure so that we can expose those clocks to device tree
consumers.

Since we'll want that for the future clocks, let's return a clk_hw pointer
instead of the return code.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Split pllb clock hooks
Maxime Ripard [Fri, 7 Feb 2020 15:14:18 +0000 (16:14 +0100)]
clk: bcm: rpi: Split pllb clock hooks

The driver only supports the pllb for now and all the clock framework hooks
are a mix of the generic firmware interface and the specifics of the pllb.
Since we will support more clocks in the future let's split the generic and
specific hooks

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Rename is_prepared function
Maxime Ripard [Thu, 20 Feb 2020 11:45:47 +0000 (12:45 +0100)]
clk: bcm: rpi: Rename is_prepared function

The raspberrypi_fw_pll_is_on function doesn't only apply to PLL
registered in the driver, but any clock exposed by the firmware.

Since we also implement the is_prepared hook, make the function
consistent with the other function names.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Pass the clocks data to the firmware function
Maxime Ripard [Fri, 7 Feb 2020 15:08:17 +0000 (16:08 +0100)]
clk: bcm: rpi: Pass the clocks data to the firmware function

The raspberry_clock_property only takes the clock ID as an argument, but
now that we have a clock data structure it makes more sense to just pass
that structure instead.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Add clock id to data
Maxime Ripard [Fri, 7 Feb 2020 15:04:16 +0000 (16:04 +0100)]
clk: bcm: rpi: Add clock id to data

The driver has really only supported one clock so far and has hardcoded the
ID used in communications with the firmware in all the functions
implementing the clock framework hooks. Let's store that in the clock data
structure so that we can support more clocks later on.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Create a data structure for the clocks
Maxime Ripard [Fri, 7 Feb 2020 15:01:33 +0000 (16:01 +0100)]
clk: bcm: rpi: Create a data structure for the clocks

So far the driver has really only been providing a single clock, and stored
both the data associated to that clock in particular with the data
associated to the "controller".

Since we will change that in the future, let's decouple the clock data from
the provider data.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Make sure the clkdev lookup is removed
Maxime Ripard [Fri, 7 Feb 2020 14:47:13 +0000 (15:47 +0100)]
clk: bcm: rpi: Make sure the clkdev lookup is removed

The clkdev lookup created for the cpufreq device is never removed if
there's an issue later in probe or at module removal time.

Let's convert to the managed variant of the clk_hw_register_clkdev function
to make sure it happens.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Switch to clk_hw_register_clkdev
Maxime Ripard [Wed, 12 Feb 2020 13:21:45 +0000 (14:21 +0100)]
clk: bcm: rpi: Switch to clk_hw_register_clkdev

Since we don't care about retrieving the clk_lookup structure pointer
returned by clkdev_hw_create, we can just use the clk_hw_register_clkdev
function.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Remove pllb_arm_lookup global pointer
Maxime Ripard [Fri, 7 Feb 2020 14:46:24 +0000 (15:46 +0100)]
clk: bcm: rpi: Remove pllb_arm_lookup global pointer

The pllb_arm_lookup pointer in the struct raspberrypi_clk is not used for
anything but to store the returned pointer to clkdev_hw_create, and is not
used anywhere else in the driver.

Let's remove that global pointer from the structure.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Make sure pllb_arm is removed
Maxime Ripard [Fri, 7 Feb 2020 14:42:40 +0000 (15:42 +0100)]
clk: bcm: rpi: Make sure pllb_arm is removed

The pllb_arm clock was created at probe time, but was never removed if
something went wrong later in probe, or if the driver was ever removed from
the system.

Now that we are using clk_hw_register, we can just use its managed variant
to take care of that for us.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Remove global pllb_arm clock pointer
Maxime Ripard [Fri, 7 Feb 2020 14:41:37 +0000 (15:41 +0100)]
clk: bcm: rpi: Remove global pllb_arm clock pointer

The pllb_arm clk_hw pointer in the raspberry_clk structure isn't used
anywhere but in the raspberrypi_register_pllb_arm.

Let's remove it, this will make our lives easier in future patches.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Use clk_hw_register for pllb_arm
Maxime Ripard [Fri, 7 Feb 2020 14:40:00 +0000 (15:40 +0100)]
clk: bcm: rpi: Use clk_hw_register for pllb_arm

The pllb_arm clock is defined as a fixed factor clock with the pllb clock
as a parent. However, all its configuration is entirely static, and thus we
don't really need to call clk_hw_register_fixed_factor() but can simply call
clk_hw_register() with a static clk_fixed_factor structure.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Statically init clk_init_data
Maxime Ripard [Fri, 7 Feb 2020 13:17:54 +0000 (14:17 +0100)]
clk: bcm: rpi: Statically init clk_init_data

Instead of declaring the clk_init_data and then calling memset on it, just
initialise properly.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoclk: bcm: rpi: Allow the driver to be probed by DT
Maxime Ripard [Mon, 23 Dec 2019 18:58:08 +0000 (19:58 +0100)]
clk: bcm: rpi: Allow the driver to be probed by DT

The current firmware clock driver for the RaspberryPi can only be probed by
manually registering an associated platform_device.

While this works fine for cpufreq where the device gets attached a clkdev
lookup, it would be tedious to maintain a table of all the devices using
one of the clocks exposed by the firmware.

Since the DT on the other hand is the perfect place to store those
associations, make the firmware clocks driver probe-able through the device
tree so that we can represent it as a node.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodt-bindings: clock: Add a binding for the RPi Firmware clocks
Maxime Ripard [Thu, 13 Feb 2020 16:51:09 +0000 (17:51 +0100)]
dt-bindings: clock: Add a binding for the RPi Firmware clocks

The firmare running on the RPi VideoCore can be used to discover and
change the various clocks running in the BCM2711. Since devices will
need to use them through the DT, let's add a pretty simple binding.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: linux-clk@vger.kernel.org
Cc: devicetree@vger.kernel.org
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoi2c: brcmstb: Allow to compile it on BCM2835
Maxime Ripard [Tue, 14 Jan 2020 12:36:42 +0000 (13:36 +0100)]
i2c: brcmstb: Allow to compile it on BCM2835

The BCM2711, supported by ARCH_BCM2835, also has a controller by the
brcmstb driver so let's allow it to be compiled on that platform.

Cc: Kamal Dasu <kdasu.kdev@gmail.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: linux-i2c@vger.kernel.org
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoi2c: brcmstb: Support BCM2711 HDMI BSC controllers
Maxime Ripard [Tue, 17 Dec 2019 08:58:34 +0000 (09:58 +0100)]
i2c: brcmstb: Support BCM2711 HDMI BSC controllers

The HDMI blocks in the BCM2771 have an i2c controller to retrieve the
EDID. This block is split into two parts, the BSC and the AUTO_I2C,
lying in two separate register areas.

The AUTO_I2C block has a mailbox-like interface and will take away the
BSC control from the CPU if enabled. However, the BSC is the actually
the same controller than the one supported by the brcmstb driver, and
the AUTO_I2C doesn't really bring any immediate benefit.

Let's use the BSC then, but let's also tie the AUTO_I2C registers with a
separate compatible so that we can enable AUTO_I2C if needed in the
future.

The AUTO_I2C is enabled by default at boot though, so we first need to
release the BSC from the AUTO_I2C control.

Cc: Kamal Dasu <kdasu.kdev@gmail.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: linux-i2c@vger.kernel.org
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodt-bindings: i2c: brcmstb: Add BCM2711 BSC/AUTO-I2C binding
Maxime Ripard [Tue, 17 Dec 2019 08:58:34 +0000 (09:58 +0100)]
dt-bindings: i2c: brcmstb: Add BCM2711 BSC/AUTO-I2C binding

The HDMI blocks in the BCM2771 have an i2c controller to retrieve the
EDID. This block is split into two parts, the BSC and the AUTO_I2C,
lying in two separate register areas.

The AUTO_I2C block has a mailbox-like interface and will take away the
BSC control from the CPU if enabled. However, the BSC is the actually
the same controller than the one supported by the brcmstb driver, and
the AUTO_I2C doesn't really bring any immediate benefit.

We can model it in the DT as a single device with two register range,
which will allow us to use or or the other in the driver without
changing anything in the DT.

Cc: Kamal Dasu <kdasu.kdev@gmail.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: linux-i2c@vger.kernel.org
Cc: devicetree@vger.kernel.org
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodt-bindings: i2c: brcmstb: Convert the BRCMSTB binding to a schema
Maxime Ripard [Thu, 13 Feb 2020 15:55:01 +0000 (16:55 +0100)]
dt-bindings: i2c: brcmstb: Convert the BRCMSTB binding to a schema

Switch the DT binding to a YAML schema to enable the DT validation.

Cc: Kamal Dasu <kdasu.kdev@gmail.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: linux-i2c@vger.kernel.org
Cc: devicetree@vger.kernel.org
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agoRevert "clk-raspberrypi: Allow cpufreq driver to also adjust gpu clocks"
Maxime Ripard [Wed, 12 Feb 2020 08:33:59 +0000 (09:33 +0100)]
Revert "clk-raspberrypi: Allow cpufreq driver to also adjust gpu clocks"

This reverts commit 60dc4841efc8fe97b710b49d37d50bd719e8ca07.

4 years agoRevert "clk-raspberrypi: Also support v3d clock"
Maxime Ripard [Wed, 12 Feb 2020 08:33:51 +0000 (09:33 +0100)]
Revert "clk-raspberrypi: Also support v3d clock"

This reverts commit 54354f31352ca1e058b029abd384819435c9ef47.

4 years agoRevert "v3d_drv: Allow clock retrieval by name"
Maxime Ripard [Mon, 17 Feb 2020 15:20:27 +0000 (16:20 +0100)]
Revert "v3d_drv: Allow clock retrieval by name"

This reverts commit 229fbb896ca6e0a40272cc846e41eeb0c29a551f.

4 years agommc: sdhci: Silence MMC warnings
Maxime Ripard [Fri, 6 Dec 2019 12:05:27 +0000 (13:05 +0100)]
mmc: sdhci: Silence MMC warnings

When the MMC isn't plugged in, the driver will spam the console which is
pretty annoying when using NFS.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodefconfig: Add V4L2 HEVC driver to bcm2711_defconfig
Dave Stevenson [Fri, 13 Mar 2020 16:55:32 +0000 (16:55 +0000)]
defconfig: Add V4L2 HEVC driver to bcm2711_defconfig

This replaces the register mapped driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agodtoverlays: Add overlay to enable the HEVC V4L2 driver
Dave Stevenson [Fri, 13 Mar 2020 16:52:55 +0000 (16:52 +0000)]
dtoverlays: Add overlay to enable the HEVC V4L2 driver

This replaces the rpivid_mem register mapping driver.
When the driver is complete, these DT changes should be
merged into the base DT instead of being an overlay.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agostaging: media: Add Raspberry Pi V4L2 H265 decoder
John Cox [Thu, 5 Mar 2020 18:30:41 +0000 (18:30 +0000)]
staging: media: Add Raspberry Pi V4L2 H265 decoder

This driver is for the HEVC/H265 decoder block on the Raspberry
Pi 4, and conforms to the V4L2 stateless decoder API.

Signed-off-by: John Cox <jc@kynesim.co.uk>
4 years agomedia: dt-bindings: media: Add binding for the Raspberry PI HEVC decoder
Dave Stevenson [Tue, 17 Mar 2020 10:53:16 +0000 (10:53 +0000)]
media: dt-bindings: media: Add binding for the Raspberry PI HEVC decoder

Adds a binding for the HEVC decoder found on the BCM2711 / Raspberry Pi 4.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: v4l2-mem2mem: allow request job buffer processing after job finish
John Cox [Thu, 5 Mar 2020 14:46:54 +0000 (14:46 +0000)]
media: v4l2-mem2mem: allow request job buffer processing after job finish

Allow the capture buffer to be detached from a v4l2 request job such
that another job can start before the capture buffer is returned. This
allows h/w codecs that can process multiple requests at the same time
to operate more efficiently.

Signed-off-by: John Cox <jc@kynesim.co.uk>
4 years agomedia: videodev2.h: Add a format for column YUV4:2:0 modes
Dave Stevenson [Fri, 24 Jan 2020 14:28:21 +0000 (14:28 +0000)]
media: videodev2.h: Add a format for column YUV4:2:0 modes

Some of the Broadcom codec blocks use a column based YUV4:2:0 image
format, so add the documentation and defines for both 8 and 10 bit
versions.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: uapi: Add hevc ctrls for WPP decoding
Dave Stevenson [Mon, 23 Mar 2020 19:00:17 +0000 (19:00 +0000)]
media: uapi: Add hevc ctrls for WPP decoding

WPP can allow greater parallelism within the decode, but needs
offset information to be passed in.

Adds num_entry_point_offsets and entry_point_offset_minus1 to
v4l2_ctrl_hevc_slice_params.

This is based on Jernej Skrabec's patches for cedrus which
implement the same feature.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: hevc_ctrls: Add slice param dependent slice segment
Dave Stevenson [Mon, 23 Mar 2020 18:34:01 +0000 (18:34 +0000)]
media: hevc_ctrls: Add slice param dependent slice segment

Adds V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT define.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: uapi: hevc: Add segment address field
Jernej Skrabec [Fri, 13 Dec 2019 16:04:27 +0000 (17:04 +0100)]
media: uapi: hevc: Add segment address field

From https://patchwork.linuxtv.org/patch/60725/
Changes requested, but mainly docs.

If HEVC frame consists of multiple slices, segment address has to be
known in order to properly decode it.

Add segment address field to slice parameters.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
4 years agomedia: uapi: hevc: Add scaling matrix control
Jernej Skrabec [Fri, 13 Dec 2019 16:04:25 +0000 (17:04 +0100)]
media: uapi: hevc: Add scaling matrix control

Taken from https://patchwork.linuxtv.org/patch/60728/
Changes (mainly documentation) have been requested.

HEVC has a scaling matrix concept. Add support for it.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
4 years agomedia: pixfmt: Document the HEVC slice pixel format
Paul Kocialkowski [Tue, 22 Oct 2019 15:26:53 +0000 (12:26 -0300)]
media: pixfmt: Document the HEVC slice pixel format

Commit de06f289283298e2938445019999cec46435375c upstream.

Document the current state of the HEVC slice pixel format.
The format will need to evolve in the future, which is why it is
not part of the public API.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-mem2mem: Fix hold buf flag checks
Jernej Skrabec [Wed, 6 Nov 2019 07:02:53 +0000 (08:02 +0100)]
media: v4l2-mem2mem: Fix hold buf flag checks

Commit 1076df3a77b490d33429560a9e0603b3673223e2 upstream.

Hold buf flag is set on output queue, not capture. Fix that.

Fixes: f07602ac3887 ("media: v4l2-mem2mem: add new_frame detection")
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 years agomedia: v4l: Add definitions for HEVC stateless decoding
Paul Kocialkowski [Tue, 22 Oct 2019 15:26:52 +0000 (12:26 -0300)]
media: v4l: Add definitions for HEVC stateless decoding

This introduces the required definitions for HEVC decoding support with
stateless VPUs. The controls associated to the HEVC slice format provide
the required meta-data for decoding slices extracted from the bitstream.

They are not exported to the public V4L2 API since reworking this API
will likely be needed for covering various use-cases and new hardware.

Multi-slice decoding is exposed as a valid decoding mode to match current
H.264 support but it is not yet implemented.

The interface comes with the following limitations:
* No custom quantization matrices (scaling lists);
* Support for a single temporal layer only;
* No slice entry point offsets support;
* No conformance window support;
* No VUI parameters support;
* No support for SPS extensions: range, multilayer, 3d, scc, 4 bits;
* No support for PPS extensions: range, multilayer, 3d, scc, 4 bits.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
[hverkuil-cisco@xs4all.nl: use 1ULL in flags defines in hevc-ctrls.h]
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: Documentation: media: Document V4L2_CTRL_TYPE_AREA
Ricardo Ribalda Delgado [Mon, 7 Oct 2019 15:06:32 +0000 (12:06 -0300)]
media: Documentation: media: Document V4L2_CTRL_TYPE_AREA

Commit 8ae3a0862993c09a8ef0f9abb379553370c517e3 upstream.

A struct v4l2_area containing the width and the height of a rectangular
area.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-mem2mem: add new_frame detection
Hans Verkuil [Fri, 11 Oct 2019 09:32:44 +0000 (06:32 -0300)]
media: v4l2-mem2mem: add new_frame detection

Commit f07602ac388723233e9e3c5a05b54baf34e0a3e9 upstream.

Drivers that support VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF
typically want to know if a new frame is started (i.e. the first
slice is about to be processed). Add a new_frame bool to v4l2_m2m_ctx
and set it accordingly.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-mem2mem: add stateless_(try_)decoder_cmd ioctl helpers
Jernej Skrabec [Fri, 11 Oct 2019 09:32:43 +0000 (06:32 -0300)]
media: v4l2-mem2mem: add stateless_(try_)decoder_cmd ioctl helpers

Commit bef41d93aac64b54c3008ca6170bec54f85784f5 upstream.

These helpers are used by stateless codecs when they support multiple
slices per frame and hold capture buffer flag is set. It's expected that
all such codecs will use this code.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Co-developed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: videodev2.h: add V4L2_DEC_CMD_FLUSH
Hans Verkuil [Fri, 11 Oct 2019 09:32:42 +0000 (06:32 -0300)]
media: videodev2.h: add V4L2_DEC_CMD_FLUSH

Add this new V4L2_DEC_CMD_FLUSH decoder command and document it.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-mem2mem: support held capture buffers
Hans Verkuil [Fri, 11 Oct 2019 09:32:41 +0000 (06:32 -0300)]
media: v4l2-mem2mem: support held capture buffers

Commit f8cca8c97a63d77f48334cde81d15014f43530ef upstream.

Check for held buffers that are ready to be returned to vb2 in
__v4l2_m2m_try_queue(). This avoids drivers having to handle this
case.

Add v4l2_m2m_buf_done_and_job_finish() to correctly return source
and destination buffers and mark the job as finished while taking
a held destination buffer into account (i.e. that buffer won't be
returned). This has to be done while job_spinlock is held to avoid
race conditions.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vb2: add V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF
Hans Verkuil [Fri, 11 Oct 2019 09:32:40 +0000 (06:32 -0300)]
media: vb2: add V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF

This patch adds support for the V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF
flag.

It also adds a new V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF
capability.

Drivers should set vb2_queue->subsystem_flags to
VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF to indicate support
for this flag.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-common: add RGB565 and RGB55 to v4l2_format_info
Benoit Parrot [Mon, 7 Oct 2019 15:10:08 +0000 (12:10 -0300)]
media: v4l2-common: add RGB565 and RGB55 to v4l2_format_info

Commit b373f84d77e1c409aacb4ff5bb5726c45fc8b166 upstream.

Add RGB565 and RGB555 to the v4l2_format_info table.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-common: add pixel encoding support
Benoit Parrot [Mon, 7 Oct 2019 15:10:07 +0000 (12:10 -0300)]
media: v4l2-common: add pixel encoding support

Commit d5a897c8428b38053df4b427a4277b1a0722bfa0 upstream.

It is often useful to figure out if a pixel_format is either YUV or RGB
especially for driver who can perform the pixel encoding conversion.

Instead of having each driver implement its own "is_this_yuv/rgb"
function based on a restricted set of pixel value, it is better to do
this in centralized manner.

We therefore add a pixel_enc member to the v4l2_format_info structure to
quickly identify the related pixel encoding.
And add helper functions to check pixel encoding.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: add V4L2_CID_UNIT_CELL_SIZE control
Ricardo Ribalda Delgado [Mon, 7 Oct 2019 15:06:33 +0000 (12:06 -0300)]
media: add V4L2_CID_UNIT_CELL_SIZE control

Commit 61fd036d01111679b01e4b92e6bd0cdd33809aea upstream.

This control returns the unit cell size in nanometres. The struct provides
the width and the height in separated fields to take into consideration
asymmetric pixels and/or hardware binning.
This control is required for automatic calibration of sensors/cameras.

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: add V4L2_CTRL_TYPE_AREA control type
Ricardo Ribalda Delgado [Mon, 7 Oct 2019 15:06:31 +0000 (12:06 -0300)]
media: add V4L2_CTRL_TYPE_AREA control type

Commit d1dc49370f8371b00e682ac409aa1987ce641e93 upstream.

This type contains the width and the height of a rectangular area.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agoadd Sensirion SPS30 to i2c-sensor overlay
Petr Štetiar [Sat, 7 Mar 2020 21:37:52 +0000 (22:37 +0100)]
add Sensirion SPS30 to i2c-sensor overlay

Add support for Sensirion SPS30 particulate matter sensor with fixed
address 0x69.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
4 years agoReduce noise from rpi poe hat fan
Nick B [Mon, 9 Mar 2020 13:05:39 +0000 (09:05 -0400)]
Reduce noise from rpi poe hat fan

This adds 2 extra states, at 40c and 45c, with PWM of 31 and 63 (out
of 255) for the rpi poe hat fan.  This significantly improves user
experience by providing a smoother ramp up of the fan, from a pwm 0
to 31 to 63 then finally to 150, and additionally makes it very easy
for users to further tweak the values as needed for their specific
application.

The possible concerns I have are that a hysteresis of 2000 (2c) could
be too narrow, and that running the fan more at a reduced temperature
(40000 - 40c) could cause problems.

Signed-off-by: Nick B <nick@pelagiris.org>
4 years agodrm/v3d: Replace wait_for macros to remove use of msleep (#3510)
Yukimasa Sugizaki [Fri, 20 Mar 2020 10:01:23 +0000 (19:01 +0900)]
drm/v3d: Replace wait_for macros to remove use of msleep (#3510)

commit 9daee6141cc9c75b09659b02b1cb9eeb2f5e16cc upstream.

The wait_for macro's for Broadcom V3D driver used msleep, which is
inappropriate due to its inaccuracy at low values (minimum wait time
is about 30ms on the Raspberry Pi).  This sleep was triggering in
v3d_clean_caches(), causing us to only be able to dispatch ~33 compute
jobs per second.

This patch replaces the macro with the one from the Intel i915 version
which uses usleep_range to provide more accurate waits.

v2: Split from the vc4 patch so that we can confidently apply to
    stable (by anholt)

Signed-off-by: James Hughes <james.hughes@raspberrypi.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20200217153145.13780-1-james.hughes@raspberrypi.com
Link: https://github.com/raspberrypi/linux/issues/3460
Fixes: 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")

Co-authored-by: James Hughes <james.hughes@raspberrypi.com>
4 years agodrm/modes: parse_cmdline: Explicitly memset the passed in drm_cmdline_mode struct
Hans de Goede [Mon, 18 Nov 2019 15:51:32 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Explicitly memset the passed in drm_cmdline_mode struct

Commit d1fe276b5115f0d581c3cfe6154633b3547e8aab upstream.

Instead of only setting mode->specified on false on an early exit and
leaving e.g. mode->bpp_specified and mode->refresh_specified as is,
lets be consistent and just zero out the entire passed in struct at
the top of drm_mode_parse_command_line_for_connector()

Changes in v3:
-Drop "mode->specified = false;" line instead of the "return false;" (oops)
 This crasher was reported-by: kernel test robot <lkp@intel.com>

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-11-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Remove some unnecessary code (v2)
Hans de Goede [Mon, 18 Nov 2019 15:51:31 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Remove some unnecessary code (v2)

Commit 5b926617cdef41ce0696e09834991194b1759e28 upstream.

fb_get_options() will return fb_mode_option if no video=<connector-name>
argument is present on the kernel commandline, so there is no need to also
do this in drm_mode_parse_command_line_for_connector() as our only caller
uses fb_get_options() to get the mode_option argument.

Changes in v2:
-Split out the changes dealing with the initialization of the mode struct
 into a separate patch

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-10-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Add support for specifying panel_orientation (v2)
Hans de Goede [Mon, 18 Nov 2019 15:51:30 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Add support for specifying panel_orientation (v2)

Commit 4e7a4a6fbdc669c44e6079f9d5eb25673749455f upstream.

Sometimes we want to override a connector's panel_orientation from the
kernel commandline. Either for testing and for special cases, e.g. a kiosk
like setup which uses a TV mounted in portrait mode.

Users can already specify a "rotate" option through a video= kernel cmdline
option. But that only supports 0/180 degrees (see drm_client_modeset TODO)
and only works for in kernel modeset clients, not for userspace kms users.

The "panel-orientation" connector property OTOH does support 90/270 degrees
as it leaves dealing with the rotation up to userspace and this does work
for userspace kms clients (at least those which support this property).

Changes in v2:
-Add missing ':' after @panel_orientation (reported by kbuild test robot)

BugLink: https://gitlab.freedesktop.org/plymouth/plymouth/merge_requests/83
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-9-hdegoede@redhat.com