Commit Graph

1399075 Commits

Author SHA1 Message Date
Dave Stevenson
1e93c19b8b drm/vc4: Correct arithmetic for shifting between columns of SAND images
Commit 69dbba71ac ("drm/vc4: Add algorithmic handling for SAND")
lost a multiplication by the tile width when doing the pointer arithmetic
for cropping off columns for vc6.

Correct that computation.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Dave Stevenson
ac1f355b1a drm/panel: Add panel driver for Ilitek ILI9806E panel
The Ilitek ILI9806E driver is used in the Pimoroni HyperPixel4
and potentially other displays. Whilst it can support multiple
interfaces, this driver only accounts for SPI configuration and
DPI video data.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Jonathan Bell
6fca76dcd5 dt-bindings: PCI: brcmstb: add optional property - "brcm,tperst-clk-ms"
This property can be used to delay deassertion of external fundamental
reset, which may be useful for endpoints that require an extended time for
internal setup to complete.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Jonathan Bell
89c085980b PCI: pcie-brcmstb: optionally extend Tperst_clk time
Some endpoints need longer than the minimum Tperst_clk time of 100us
that the PCIe specification allows for, as they may need to sequence
internal resets off the stable output of internal PLLs prior to removal
of fundamental reset. PCIe switches are an especially bad case, in some
cases requiring up to 100 milliseconds for stable downstream link
behaviour.

Parse the DT property brcm,tperst-clk-ms and use this to hold PERST# low
during brcm_pcie_start_link().

The BRCM RC typically outputs 200us of stable refclk before deasserting
PERST#. By masking/forcing the output signal while deasserting the
internal reset, the effect is to extend the length of time that the
refclk is active and stable before PERST# is released.

The TX lanes will enter the Polling state before PERST# is released, but
this appears to be harmless.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Jonathan Bell
3fd628bc68 dt-bindings: pci: pcie-brcmstb: add optional brcm,tperst-clk-ms property
Some platforms may require an extended time with refclk active before
PERST# is released. Add a property to let the RC driver know how long to
wait.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Jonathan Bell
d17cc695c8 PCI: brcmstb: add support for BCM2712 priority forwarding
The BCM2712 root complexes can interpret priority signalling in two
different ways, based on the incoming Traffic Class of a TLP.

The TLP TCs are assigned to separate internal request/response queues,
and assigned different AXI IDs. These queues can have outgoing AXI
transactions tagged based on:

- Static QoS values
- Dynamic QoS through internal backpressure
- Dynamic QoS with elevation based on Vendor Messages received by the RC

The VDM mechanism is of limited use due to implementation bugs, but the
implicit reordering due to separate ID assignment allows higher-priority
traffic from an EP to overtake other traffic in the RC and rest of the
system.

RP1 assigns TCs based on its internal bus managers, and internally tags
read requests to allow out-of-order completions, so these two features
operate in concert to provide priority service to e.g. MIPI camera or
display traffic.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Jonathan Bell
0631859b2a dt-bindings: pci: pcie-brcmstb: add BCM2712-specific properties
There is configurable priority forwarding hardware in this variant of the
Root Complex controller. Add optional properties to configure FIFO
backpressure or Vendor-Defined Message priority forwarding.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Jonathan Bell
3ffa82fe91 PCI: brcmstb: add NO_SSC quirk for BCM2712
The PHY MDIO register map is different on BCM2712, and as the PHY input
clock is 54MHz not 100MHz, enabling refclk SSC is both broken and
unfixable.

Mask out attempts to enable SSC with a controller quirk.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Jonathan Bell
31983e9149 PCI: brcmstb: Enable CRS software visibility after linkup
It appears that bits in the Root Control Register are reset with
perst_n, which means the PCI layer's call to enable CRS prior to
adding/scanning the bus has no effect. Open-code the enable in
brcm_pcie_start_link as a workaround.

Without CRS visibility, configuration reads issued by the CPU don't
retire if the endpoint returns a CRS response - the RC will poll until a
(large) timeout is reached. This means the core can stall for a long
time during boot.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Jonathan Bell
454aecf2f8 PCI: brcmstb: set BCM7712/2712-specific AXI bridge handling behaviours
These chips use a UBUS-AXI bridge component that has configurable
timeout and error response handling.

Suppress AXI error responses to CPU requests, otherwise these are fatal
if they reach the ARM cluster, and set reasonably large timeouts for
both Mem and Cfg requests.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Dave Stevenson
90a86be3cd drm/framebuffer: Pitch checks aren't valid for non-linear modifiers
Pitch has no meaning if the modifier isn't DRM_FORMAT_MOD_LINEAR
as there is no guarantee that the value passed follows the
pattern that pitch * height = size.

Remove that check from framebuffer_check.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Dave Stevenson
d09a75fec7 drm: vc4: plane: Avoid using pitch in calculating UBM for SAND
The SAND modifier with height 0 is now using the provided pitch as
the column stride, but the UBM allocation needs to be done based
on the plane width.
Recompute the width in these conditions.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:36 +00:00
Dave Stevenson
56cd2b899d drm/vc4: Add algorithmic handling for SAND
The SAND handling had been using what was believed to be a runtime
parameter in the modifier, however that has been clarified that
all permitted variants of the modifier must be advertised, so
making it variable wasn't practical.

With a rationalisation of how the producers of this format are
configured, we can switch to a variant that doesn't have as much
variation, and can be configured such that only 2 options are
required.

Add a modifier with value 0 to denote that the height of the luma
column matches the buffer height, and chroma column will be half
that due to YUV420.
A modifier of 1 denotes that the height of the luma column still
matches the buffer height, but the chroma column height is the same.
This can be used to replicate the previous behaviour.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:35 +00:00
Dave Stevenson
153391169b drm: vc4: hvs: Fix vc6_hvs_debugfs_dlist state lookup
vc4's debugfs support was updated with drm_debugfs_entry whilst
BCM2712 support was in progress, and missed that the lookup
in vc6_hvs_debugfs_dlist still followed the old pattern.

Correct that lookup to avoid an invalid dereference.

Fixes: f7af8ae9d3 ("drm/vc4: hvs: Add support for BCM2712 HVS")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:35 +00:00
Dave Stevenson
f9b9388bbc media: v4l2: Add single planar NV12 column formats
For downstream only, add back in the legacy single planar
SAND formats.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:35 +00:00
Dave Stevenson
07b48b7f78 media: hevc_dec: Drop the new image formats until we have Mesa 24
Supporting GL rendering of the new HEVC decoder pixel formats requires
Mesa 24.2.5 or later. There are a couple of minor issues holding up
switching to Mesa 24.

Drop the new pixel formats from enum_fmt so that FFMpeg will use
the older ones that earlier versions of Mesa do support.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:35 +00:00
John Cox
4a631ab34c media: platform: Add Raspberry Pi HEVC decoder driver
The BCM2711 and BCM2712 SoCs used on Rapsberry Pi 4 and Raspberry
Pi 5 boards include an HEVC decoder block. Add a driver for it.

Signed-off-by: John Cox <john.cox@raspberrypi.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

media: hevc_dec: Add in downstream single planar SAND variant

Upstream will take the multi-planar SAND format, but add back
in the downstream single planar variant for backwards compatibility

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

media: hevc_dec: Add module parameter for video_nr

To avoid user complaints that /dev/video0 isn't their USB
webcam, add downstream patch that allows setting the preferred
video device number.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:35 +00:00
Dave Stevenson
8e8d4348e1 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,
and BCM2712 / Raspberry Pi 5.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:35 +00:00
Dave Stevenson
31a9584f81 media: ioctl: Add pixel formats NV12MT_COL128 and NV12MT_10_COL128
Add V4L2_PIXFMT_NV12MT_COL128 and V4L2_PIXFMT_NV12MT_10_COL128
to describe the Raspberry Pi HEVC decoder NV12 multiplanar formats.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:35 +00:00
Dave Stevenson
afacc9be72 docs: uapi: media: Document Raspberry Pi NV12 column format
The Raspberry Pi HEVC decoder uses a tiled format based on
columns for 8 and 10 bit YUV images, so document them as
NV12MT_COL128 and NV12MT_10_COL128.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:35 +00:00
Hans Verkuil
47066eeb42 media: mc: add debugfs node to keep track of requests
Keep track of the number of requests and request objects of a media
device. Helps to verify that all request-related memory is freed.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2025-11-24 14:23:35 +00:00
Hans Verkuil
1a4bbf818e media: vicodec: add support for manual completion
Manually complete the requests: this tests the manual completion
code.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2025-11-24 14:23:35 +00:00
Hans Verkuil
943d67dd78 media: mc: add manual request completion
By default when the last request object is completed, the whole
request completes as well.

But sometimes you want to manually complete a request in a driver,
so add a manual complete mode for this.

In req_queue the driver marks the request for manual completion by
calling media_request_mark_manual_completion, and when the driver
wants to manually complete the request it calls
media_request_manual_complete().

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2025-11-24 14:23:35 +00:00
Dave Stevenson
694f48748f drm/vc4: Correct one logging message that got promoted from dbg to err
commit 59ac702a93 ("drm/vc4: Get the rid of DRM_ERROR()") converted
all calls to DRM_ERROR into drm_err, but also converted one DRM_DEBUG
into a drm_err.

Switch it back to drm_dbg.

Fixes: 59ac702a93 ("drm/vc4: Get the rid of DRM_ERROR()")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:35 +00:00
Dave Stevenson
4cb0b2bd1a drm/edid: When reset, assume HDMI displays support RGB444
If an HDMI connector has no EDID and the mode is set via the
kernel command line, then drm_reset_display_info() is the only
thing that will have set up any of connector->display_info.

With commit 26ff1c38fc ("drm/connector: hdmi: Compute bpc
and format automatically"), it is now checked that
DRM_COLOR_FORMAT_RGB444 is supported. Whilst it doesn't fail
the request, it does log dev_warn for every commit, spamming
the log.

For HDMI connectors initialise the color_format field to say
it supports RGB444.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:34 +00:00
Dave Stevenson
48ad3e2d80 drm/vc4: PV1 can be driven via any HVS channel, so adapt to allow it
It was noted that if PV1 was in use to drive DSI1, then the
writeback connector could not be used as HVS channel 2 was
already in use.
The HVS allows PV1 (HVS output 2) to be driven by any HVS
channel via the DSP3_MUX setting, but that was hardcoded to be
either 2 (for PV1) or disabled for TXP.

Expand the available channels field for PV1, and configure
DSP3_MUX accordingly.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:34 +00:00
Phil Elwell
2c48356199 drm/vc4: Use phys addresses for slave DMA config
Slave addresses for DMA are meant to be supplied as physical addresses
(contrary to what struct snd_dmaengine_dai_dma_data does).

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2025-11-24 14:23:34 +00:00
David Turner
3c4994f56e vc4: Add jack detection to HDMI audio driver
Add ALSA jack detection to the vc4-hdmi audio driver so userspace knows
when to add/remove HDMI audio devices.

Signed-off-by: David Turner <david.turner@raspberrypi.com>
2025-11-24 14:23:34 +00:00
Phil Elwell
cc1a843148 spi: dw: Wait for idle after TX
If this is a DMA transfer, and if there is no simultaneous RX transfer,
wait for the interface to go idle before reporting that TX is done.

Link: https://forums.raspberrypi.com/viewtopic.php?t=383027

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2025-11-24 14:23:34 +00:00
Phil Elwell
fe9868d2ec dmaengine: bcm2835: Fix a build warning
bcm2835_dma_suspend_late is only used if CONFIG_PM_SLEEP is defined,
so make it's presence similarly conditional to avoid a build warning
(and hence error).

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2025-11-24 14:23:34 +00:00
Naushir Patuck
dcbf83ffd7 drivers: media: pisp_be: Remove unused fields in struct pisp_be_config
These fields should not be set by either the user or the kernel driver
so remove them. Replace them with padding bytes to maintain backward
compatibility with existing userland applications.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2025-11-24 14:23:34 +00:00
Naushir Patuck
cdb3a3e948 drivers: media: pisp_be: Add support for YUV422 planar format
List V4L2_PIX_FMT_YUV422P as supported by the PiSP backend hardware.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2025-11-24 14:23:34 +00:00
Phil Elwell
c93ec32ecf mmc: bcm2835: Add downstream overclocking support
The principal differences between the downstream SDHOST driver and the
version accepted upstream driver are that the upstream version loses the
overclock support and DMA configuration via DT, but gains some tidying
up (and maintenance by the upstream devs).

Add the missing features (with the exception of the low-overhead logging)
as a patch to the upstream driver.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2025-11-24 14:23:34 +00:00
Naushir Patuck
c828b32bfc media: rp1: Add downstream CFE (Camera Front End) driver
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

v4l2: Add pisp compression format support to v4l2

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: cfe: Fix use of freed memory on errors

cfe_probe_complete() calls cfe_put() on both success and fail code paths.
This works for the success path, but causes the cfe_device struct to be
freed, even if it will be used later in the teardown code.

Fix this by making the ref handling a bit saner: Let the video nodes
have the refs as they do now, but also keep a ref in the "main" driver,
released only at cfe_remove() time. This way the driver does not depend
on the video nodes keeping the refs.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Fix width & height in cfe_start_channel()

The logic for handling width & height in cfe_start_channel() is somewhat
odd and, afaics, broken. The code reads:

bool start_fe = is_fe_enabled(cfe) &&
                test_all_nodes(cfe, NODE_ENABLED, NODE_STREAMING);

if (start_fe || is_image_output_node(node)) {
        width = node->fmt.fmt.pix.width;
        height = node->fmt.fmt.pix.height;
}

cfe_start_channel() is called for all video nodes that will be used. So
this means that if, say, fe_stats is enabled as the last node, start_fe
will be true, and width and height will be taken from fe_stats' node.
The width and height will thus contain garbage, which then gets
programmed to the csi2 registers.

It seems that this often still works fine, though, probably if the width
& height are large enough.

Drop the above code, and instead get the width & height from the csi2
subdev's sink pad for the csi2 channel that is used. For metadata the
width & height will be 0 as before.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Fix verbose debug print

The debug print in cfe_schedule_next_csi2_job() is printed every frame,
and should thus use cfe_dbg_irq() to avoid spamming, rather than cfe_dbg().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Rename xxx_dbg_irq() to xxx_dbg_verbose()

Rename the xxx_dbg_irq() macros to xxx_dbg_verbose(), as they can be
used to verbose debugs outside irq context too.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Add verbose debug module parameter

Expose the verbose debug flag as a module parameter.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Drop unused field

Drop 'sensor_embedded_data' field, as it is unused.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Fix default meta format's field

Set default meta format's field to V4L2_FIELD_NONE, instead of zeroing
it which indicates V4L2_FIELD_ANY. Metadata doesn't have fields, so NONE
makes sense, and furthermore the default v4l2 link validation will check
for matching fields, or that the sink field is NONE.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Fail streaming if FE_CONFIG node is not enabled

When the FE is enabled, ensure that the FE_CONFIG node is enabled.
Otherwise fail cfe_start_streaming() entirely.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: rp1_cfe: Remove PISP specific MBUS formats

Remove the MEDIA_BUS_FMT_PISP* format codcs entirely. For the image
pad formats, use the 16-bit Bayer format mbus codes instead. For the
config and stats pad formats, use MEDIA_BUS_FMT_FIXED.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: rp1_cfe: Fix link validate test for pixel format

Now that we have removed unique PISP media bus codes, the cfe format
table has multiple entries with the same media bus code for 16-bit
formats. The test in cfe_video_link_validate() did not account for this.
Fix it by testing the media bus code and the V4L2 pixelformat 4cc
together.

As a drive-by, ensure we have a valid CSI2 datatype id when programming
the hardware block.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: cfe: Set the CSI-2 link frequency correctly

Use the sensor provided link frequency to set the DPHY timing parameters
on stream_on. This replaces the hard-coded 999 MHz value currently being
used. As a fallback, revert to the original 999 Mhz link frequency.

As a drive-by, fix a 80-character line formatting error.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: cfe: Don't confuse MHz and Mbps

The driver was interchaning these units when talking about link rate.
Fix this to avoid confusion. Apart from the logging message change,
there is no function change in this commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: csi2: Fix missing reg writes

The driver has two places where it writes a register based on a
condition, and when that condition is false, the driver presumes that
the register has the reset value. This is not a good idea, so fix those
places to always write the register.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: fe: Use ~0, not -1, when working with unsigned values

Use ~0, not -1, when working with unsigned values (-1 is not unsigned).

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: Add back reg write debug prints

Add back debug prints in csi2 and pisp_fe reg_write() functions, but use
the 'irq' variants to avoid spamming in normal situation.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: csi2: Track CSI-2 errors

Track the errors from the CSI-2 receiver: overflows and discards. These
are recorded in a table which can be read by the userspace via debugfs.

As tracking the errors may cause much more interrupt load, the tracking
needs to be enabled with a module parameter.

Note that the recording is not perfect: we only record the last
discarded DT for each discard type, instead of recording all of them.
This means that e.g. if the device is discarding two unmatched DTs, the
debugfs file only shows the last one recorded. Recording all of them
would need a more sophisticated recording system to avoid the need of a
very large table, or dynamic allocation.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: csi2: Set values for enum csi2_mode

Set hardcoded values for enum csi2_mode, as the values will be
programmed to HW registers.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: fe: Fix default mbus code

When pisp_fe_pad_set_fmt() is given an mbus code that CFE does not
support, it currently defaults to MEDIA_BUS_FMT_SBGGR10_1X10. This is
not correct, as FE does not support SBGGR10.

Set the default to MEDIA_BUS_FMT_SRGGB16_1X16 instead.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

drivers: media: cfe: Find the source pads on the sensor entity

The driver was assuming that pad 0 on the sensor entity was the
appropriate source pad, but this isn't necessarily the case.
With video-mux, it has the sink pads first, and then the source
pad as the last one.

Iterate through the sensor pads to find the relevant source pads.

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

media: rp1: cfe: Expose find_format_by_pix()

Make find_format_by_pix() accessible to other files in the driver.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Add cfe_find_16bit_code() and cfe_find_compressed_code()

Add helper functions which, given an mbus code, return the 16-bit
remapped mbus code or the compressed mbus code.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: csi2: Use get_frame_desc to get CSI-2 VC and DT

Use get_frame_desc pad op for asking the CSI-2 VC and DT from the source
device driver, instead of hardcoding to VC 0, and getting the DT from a
formats table. To keep backward compatibility with sources that do not
implement get_frame_desc, implement a fallback mechanism that always
uses VC 0, and gets the DT from the formats table, based on the CSI2's
sink pad's format.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Add is_image_node()

The hardware supports streaming from memory (in addition to streaming
from the CSI-2 RX), but the driver does not support this at the moment.

There are multiple places in the driver which uses
is_image_output_node(), even if the "output" part is not relevant. Thus,
in a minor preparation for the possible support for streaming from
memory, and to make it more obvious that the pieces of code are not
about the "output", add is_image_node() which will return true for both
input and output video nodes.

While at it, reformat also the metadata related macros to fit inside 80
columns.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Dual purpose video nodes

The RP1 CSI-2 DMA can capture both video and metadata just fine, but at
the moment the video nodes are only set to support either video or
metadata.

Make the changes to support both video and metadata. This mostly means
tracking both video format and metadata format separately for each video
node, and using vb2_queue_change_type() to change the vb2 queue type
when needed.

Briefly, this means that the user can get/set both video and meta
formats to a single video node. The vb2 queue buffer type will be
changed when the user calls REQBUFS or CREATE_BUFS ioctls. This buffer
type will be then used as the "mode" for the video node when the user
starts the streaming, and based on that either the video or the meta
format will be used.

A bunch of macros are added (node_supports_xxx()), which tell if a node
can support a particular mode, whereas the existing macros
(is_xxx_node()) will tell if the node is currently in a particular mode.
Note that the latter will only work correctly between the start of the
streaming and the end of the streaming, and thus should be only used in
those code paths.

However, as the userspace (libcamera) does not support dual purpose
video nodes, for the time being let's keep the second video node as
V4L2_CAP_META_CAPTURE only to keep the userspace working.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: Drop LE handling

The driver registers for line-end interrupts, but never uses them. This
just causes extra interrupt load, with more complexity in the driver.

Drop the LE handling. It can easily be added back if later needed.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Improve link validation for metadata

Improve the link validation for metadata by:
- Allowing capture buffers that are larger than the incoming frame
  (instead of requiring exact match).

- Instead of assuming that a metadata unit ("pixel") is 8 bits, use
  find_format_by_code() to get the format and use the bit depth from
  there. E.g. bit depth for RAW10 metadata will be 10 bits, when we
  move to the upstream metadata formats.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

drivers: media: cfe: Add more robust ISR handlers

Update the ISR logic to be more robust to sensors in problematic states
where interrupts may start arriving overlapped and/or missing.

1) Test for cur_frame in the FE handler, and if present, dequeue it in
an error state so that it does not get orphaned.

2) Move the sequence counter and timestamp variables to the node
structures.  This allows the ISR to track channels running ahead when
interrupts arrive unordered.

3) Add a test to ensure we don't have a spurios (but harmlesS) call to
the FE handler in some circumstances.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: cfe: Fix error paths in cfe_start_streaming

Noted that if we get "node link is not enabled", then we also
get the videobuf2 splat for the driver not cleaning up correctly
on a failed start_streaming, and indeed we weren't returning the
buffers.

Checking the other error paths, noted that the "FE enabled, but
FE_CONFIG node is not" path was not calling pm_runtime_put.

Fix both paths.

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

drivers: media: cfe: Increase default size of embedded buffer

Increase the size of the default embedded buffer to 16k. This is done to
match what is advertised by the IMX219 driver and workaround a problem
where the embedded stream is not actually used. Without full streams API
support, the media pipeline validation will fail in these circumstances.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: cfe: Actually use the number of lanes configured

The driver was calling get_mbus_config to ask the sensor subdev
how many CSI2 data lanes it wished to use and with what other
properties, but then failed to pass that to the DPHY configuration.

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

media: rp1: csi2: Fix csi2_pad_set_fmt()

The CSI-2 subdev's set_fmt currently allows setting the source and sink
pad formats quite freely. This is not right, as the CSI-2 block can only
do one of the following when processing the stream: 1) pass through as
is, 2) expand to 16-bits, 3) compress.

The csi2_pad_set_fmt() should take this into account, and only allow
changing the source side mbus code, compared to the sink side format.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: csi2: Use standard link_validate

The current csi2_link_validate() skips some important checks. Let's
rather use the standard v4l2_subdev_link_validate_default() as the
link_validate hook.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: csi2: Squash fixes

media: rp1: fe: Fix pisp_fe_pad_set_fmt()

pisp_fe_pad_set_fmt() allows setting the pad formats quite freely. This
is not correct, and the function should only allow formats as supported
by the hardware. Fix this by:

Allow no format changes for FE_CONFIG_PAD and FE_STATS_PAD. They should
always be the hardcoded initial ones.

Allow setting FE_STREAM_PAD freely (but the mbus code must be
supported), and propagate the format to the FE_OUTPUT0_PAD and
FE_OUTPUT1_PAD pads.

Allow changing the mbus code for FE_OUTPUT0_PAD and FE_OUTPUT1_PAD pads
only if the mbus code is the compressed version of the sink side code.

TODO: FE supports scaling and cropping. This should be represented here
too?

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: fe: Use standard link_validate

The current pisp_fe_link_validate() skips some important checks. Let's
rather use the standard v4l2_subdev_link_validate_default() as the
link_validate hook.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

drivers: media: cfe: Add 16-bit and compressed mono format support

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: cfe: Add missing remaps

8-bit bayer formats are missing remap definitions. Add them.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

media: rp1: cfe: Add missing compressed remaps

16-bit bayer formats are missing compressed remap definitions. Add them.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

drivers: media: pisp_be: pisp_fe: Update UAPI header licenses

Update the license tags on the pisp UAPI header files with the
"Linux-syscall-note" clause.  Also replace the "GPL-2.0" tag with the
preferred "GPL-2.0-only" tag.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1: cfe: Use the MIPI_CSI2_DT_xxx defines for csi_dt

Seeing as we now have the CSI2 data types defined, make use of
them instead of hardcoding the values.

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

media: rp1: cfe: Add a csi_dt value for 16bit formats

Raw 16bit formats didn't have a csi_dt value defined, which
presumably would trip the WARN_ON(!fmt->csi_dt); in
cfe_start_channel.

The value is defined in CSI2 v2.0 as 0x2e, so set it accordingly.

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

drivers: media: pisp_be: Add mono and 48-bit RGB pixel format support

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: pisp_be: Update seqeuence numbers of the buffers

Add a framebuffer sequence counter and increment on every completed job.
This counter is then used to update the VB2 buffer sequence count before
calling vb2_buffer_done().

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: cfe: Add remap entries for mono formats

The 8-bit and 16-bit mono formats were missing the appropriate remap
entries in the format table.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

media: rp1-cfe: Fix up link validation for CFE CFG input

After commit 5fd3e2412a ("media: v4l2-subdev: Support hybrid links
in v4l2_subdev_link_validate()") link_validate is called on V4L2
OUTPUT devices such as the CFE cfg buffers input.
The CFE link_validate function was assuming it was always the
sink of a link, which goes wrong on that port and does an invalid
dereference.

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

media: rp1-cfe: Swap "raspberypi,rp1-cfe" compatible to downstream driver

Whilst we are wanting to maintain the downstream driver at the same time
as having the upstream merged, swap the "raspberypi,rp1-cfe" compatible
string across.

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

media/platform/raspberypi/rp1_cfe: Candidate fix for #5821

To avoid lost frame start in a subsequent session, avoid setting
the number of lanes back to 1 or putting CSI-2 Host into reset.

It's not clear if this is a watertight fix -- what if the camera
itself produced a truncated or garbled packet, or continued to
send until the next start? -- but it does seem to fix the issue.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>

drivers: media: rpi: cfe: Avoid unpack operation for 16-bit formats

The unpack operation is redundant for 16-bit sensor formats, don't set
the hardware to do it in these cases.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>

drivers: media: cfe: Workaround for 16-bit mismatch in the hardware

Set the data type for 16-bit modes to 0 (wildcard) to workarond the
16-bit mismatch in hardware.

We also need to suppress the warning about DT == 0 on start stream in
these cases.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2025-11-24 14:23:34 +00:00
Jonathan Bell
47f3b60310 mmc: use downstream DT property to modify CQE and/or SD CQ behaviour
Implement a tristate-style option for "supports-cqe". If the property is
absent or zero, disable CQ completely. For 1, enable CQ unconditionally
for eMMC cards, and known-good SD cards. For 2, enable for eMMC cards,
and all SD cards that are not known-bad.

The sdhci-brcmstb driver needs to know about the tristate as its probe
sequence would otherwise override a disable in mmc_of_parse().

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:34 +00:00
Jonathan Bell
895e91fd61 mmc: set MMC_QUIRK_KNOWN_WORKING_SD_CQ on Raspberry Pi class A2 cards
These cards have a known-good CQ implementation and are based on a
Longsys product. Add the MANFID for Longsys SD, and the particular CID
details for the Pi card.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:33 +00:00
Jonathan Bell
752d34b197 mmc: sd: filter card CQ support based on an allow-list
We have found that many SD cards in the field, even of the same make and
model, have latent bugs in their CQ implementation. Some product lines
have fewer bugs with newer manufacture dates, but this is not a
guarantee that a particular card is at a particular firmware revision
level.

Many of these bugs lead to card hangs or data corruption. Add a quirk to
mark a card as having a tested, working CQ implementation and ignore the
capability if absent.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
2025-11-24 14:23:33 +00:00
Dave Stevenson
b74016268d media: imx290: Add module parameter to allow selection of HCG mode
The sensor has Low Conversion Gain (HCG) and High Conversion Gain (HCG)
modes, with the supposedly the HCG mode having better noise performance
at high gains.

As this parameter changes the gain range of the sensor, it isn't
possible to make this an automatic property, and there is no
suitable V4L2 control to set it, so just add it as a module parameter.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:33 +00:00
Stephen Gordon
ac02964b5a docs: pcm3168a: Add DT bindings to force clock consumer mode
Document the new force-adc-cons/force-dac-cons DT bindings.

Signed-off-by: Stephen Gordon <gordoste@iinet.net.au>
2025-11-24 14:23:33 +00:00
Dave Stevenson
8089a8fde6 drm: Validate connector rotation has one bit set in the rotation property
Copy the same validation logic as from the plane rotation property.

Fixes: 8fec3ff870 ("drm: Add a rotation parameter to connectors.")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:33 +00:00
Nick Hollinghurst
2017af193e drm: bridge: panel: Connector to allow interlaced modes
When initialized from panel_bridge_attach(), connector should
allow interlaced modes rather than invariably rejecting them,
so that other components can validate them.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
2025-11-24 14:23:33 +00:00
Phil Elwell
f3f3768be2 cgroup: Add cgroup_enable option
The upstream addition of the kernel parameter cgroup_disable makes it
possible to configure cgroups at boot time. In theory, re-enabling a
disabled cgroup is simply a case of removing the relevant cgroup_disable
setting, but this is difficult if the setting comes from Device Tree.

Re-introduce cgroup_enable as a way around the problem.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2025-11-24 14:23:33 +00:00
eng33
057bb6fb2c input: Add support for no irq to ili210x driver
Signed-off-by: eng33 <eng33@waveshare.com>
2025-11-24 14:23:33 +00:00
Tim Gover
732b79eac1 serial: tty: Add a driver for the RPi firmware UART
On Raspberry Pi 4 and earlier models the firmware provides
a low speed (up to 115200 baud) bit-bashed UART on arbitrary
GPIOs using the second VPU core.

The firmware driver is designed to support 19200 baud. Higher
rates up to 115200 seem to work but there may be more jitter.

This can be useful for debug or managing additional low
speed peripherals if the hardware PL011 and 8250 hardware
UARTs are already used for console / bluetooth.

The firmware driver requires a fixed core clock frequency
and also requires the VPU PWM audio driver to be disabled
(dtparam=audio=off)

Runtime configuration is handled via the vc-mailbox APIs
with the FIFO buffers being allocated in uncached VPU
addressable memory. The FIFO pointers are stored in spare
VideoCore multi-core sync registers in order to reduce the number
of uncached SDRAM accesses thereby reducing jitter.

Signed-off-by: Tim Gover <tim.gover@raspberrypi.com>

serial: rpi-fw-uart: Demote debug log messages

A dev_info call in rpi_fw_uart_configure causes kernel log output every
time one opens the UART. Demote it to dev_dbg.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2025-11-24 14:23:33 +00:00
Tim Gover
220d9ee979 serial: core: Add the Raspberry Pi firmware UART id
Assign a new serial core number for the RPi firmware UART.

Signed-off-by: Tim Gover <tim.gover@raspberrypi.com>
2025-11-24 14:23:33 +00:00
Dave Stevenson
965955a547 drm/vc4: Cache LBM allocations to avoid double-buffering
LBM is only relevant for each active dlist, so there is
no need to double-buffer the allocations.

Cache the allocations per plane so that we can ensure the
allocations are possible.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:33 +00:00
Maíra Canal
21ca238c7b drm/vc4: backport 27e0a194a2 and b3bf19552e
Get the KUnit tests passing.

Signed-off-by: Maíra Canal <mcanal@igalia.com>
2025-11-24 14:23:33 +00:00
Phil Elwell
58947314fa drm/vc4: tests: Fix up vc4_test_lbm_size
Following the example of [1], move the state allocation out of the init
function to make it thread safe.

[1] commit 7e0351ae91 ("drm/vc4: tests: Stop allocating the state in
test init")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
2025-11-24 14:23:32 +00:00
Dave Stevenson
453c88b561 drm/vc4: tests: Update pv muxing tests now DSI1 is more flexible
The tests on vc4 (BCM2835-7) were checking for DSI1 muxing being
to restricted channel 2, and therefore muxing with TXP was impossible.

As we no longer have that restriction, update the capabilities
defined for DSI1, move the tests that used to be impossible to the
valid list, and extend for additional combinations that are now
possible.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
2025-11-24 14:23:32 +00:00
Maxime Ripard
3431520b60 drm/vc4: tests: Introduce a test for LBM buffer size
The BCM2712 comes with a different LBM size computation than the
previous generations, so let's add the few examples provided as kunit
tests to make sure we always satisfy those requirements.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
2025-11-24 14:23:32 +00:00