Skip to content

ams/rpi 6.18.y/mira upstream - #7802

Open
jmondi wants to merge 10 commits into
raspberrypi:rpi-6.18.yfrom
jmondi:ams/rpi-6.18.y/mira-upstream
Open

jmondi wants to merge 10 commits into
raspberrypi:rpi-6.18.yfrom
jmondi:ams/rpi-6.18.y/mira-upstream

Conversation

@jmondi

@jmondi jmondi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

The Mira220 and Mira016 sensor drivers are on their way to Linux v7.5

Mira220 was already in the RaspberryPi BSP, while Mira016 was not.

Update the Mira220 driver in the RaspberryPi BSP to match the mainline version and introduce Mira016 by applying the patches sent to linux-media for v7.5.

The libcamera PR that updates Mira220 support and add Mira016 will follow soon.

phili-b and others added 4 commits November 26, 2026 16:21
Add bindings for the AMSOSRAM Mira220 image sensor.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Philippe Baetens <philippebaetens@gmail.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Update the Mira220 driver to the version sent upstream for inclusion
in Linux v7.5.

The driver is available in the linux-media committers tree in the
next branch:
 https://gitlab.freedesktop.org/linux-media/media-committers/-/commit/d71751a7f67ffd31b78b0e93c5510f6d6810ee43

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Add bindings for the ams OSRAM Mira016 image sensor.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Add driver for the ams OSRAM Mira016 sensor.

Backport the driver from the version sent for upstream inclusion in
Linux v7.5.

The driver is available the linux-media committers tree in the
next branch:
 https://gitlab.freedesktop.org/linux-media/media-committers/-/commit/ab4a4c39c611a8fdf6fe20558186e8aa61e7c3b2

Reviewed-by: Tarang Raval <tarang.raval@siliconsignals.io>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Comment thread arch/arm/boot/dts/overlays/README Resolved
Jacopo Mondi added 2 commits November 27, 2026 09:17
Update dts overlays for the Mira220 image sensor.

Remove a few stray blank lines, the unused gpio.h inclusion and
add an overlay for the regulator node, to specify the startup and
ramp-down delays and allow to fully support connecting the camera
to the 'cam0' connector.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Add overlays for AMS-OSRAM Mira016 image sensor.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
@jmondi
jmondi force-pushed the ams/rpi-6.18.y/mira-upstream branch from 71d09c3 to f979626 Compare November 27, 2026 08:25
cam0-mira016 = <&mux_in0>, "remote-endpoint:0=",<&mira016_0_ep>,
<&mira016_0_ep>, "remote-endpoint:0=",<&mux_in0>,
<&mux_in0>, "clock-noncontinuous?",
<&mira016_0>, "status=okay";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mira016 only supports a single data lane, I'm not sure how I should specify it here..

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy ov7251 which also only supports a single data lane.
<0>,"+102-103";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AH thanks, I wasn't familiar with that syntax and searching around for data-lanes didn't help.

I've updated the MR.

The last item I'm not sure about is Mira016 only supports clock-noncontinuous so I'm not sure if the ? in

			      <&mux_in0>, "clock-noncontinuous?",

is correct

@pelwell pelwell Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically somebody could write "dtoverlay=...,cam0-mira016=off" which would delete clock-noncontinuous (it is unlikely though). But if you have a constant value, embed it in one of the fragments (which you have) and don't mention it in the parameter declarations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, if the "clock-noncontinuous?" syntax is conditional to the presence of clock-noncontinuous in the sensor's endpoint, I think we should be fine then ? Otherwise should I simply remove ? from

			      <&mux_in0>, "clock-noncontinuous?",

?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<&mux_in0>, "clock-noncontinuous?" means set or clear the boolean (?) property clock-noncontinuous on the node with label mux_in0 based on the value given to the parameter. A parameter used without a value is treated as if it was given the value 1/true/on/okay. But because we don't want the value of the boolean to change, just delete that part of the parameter declaration, as you guessed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, this is dragging for longer than expected: should I also add a fragment like

	fragment@108 {
		target = <&mux_in0>;
		__dormant__ {
			clock-noncontinuous;
		};
	};

(and 109, 110 and 111 for the other mux input ports)

and refer to it in the sensor node like I've done for data-lanes ?

			      <&mira016_0_ep>, "remote-endpoint:0=",<&mux_in0>,
			      <&mira016_0>, "status=okay",
			      <0>,"+100-101",
			      <0>,"+108";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it needs the flag on both ends? You could just leave the parameter as it was - the same syntax is used for plenty of other cameras.

The simplest change to guarantee the property exists is to include a literal assignment:

			      <&mux_in0>, "clock-noncontinuous?=0",

but I'm not convinced it's worth the effort.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it needs the flag on both ends? You could just leave the parameter as it was - the same syntax is used for plenty of other cameras.

I think when it comes to the actual physical link protocol it is the transmitter side that optionally operates the clock in non-cont mode and the receiver adjusts to it.

The unicam dts bindings however allow for the property to be specified

Documentation/devicetree/bindings/media/brcm,bcm2835-unicam.yaml:          clock-noncontinuous: true

and the driver actually uses it

	/* Enable clock lane and set up terminations */
	val = 0;
	if (unicam->bus_type == V4L2_MBUS_CSI2_DPHY) {
		/* CSI2 */
		unicam_set_field(&val, 1, UNICAM_CLE);
		unicam_set_field(&val, 1, UNICAM_CLLPE);
		if (!(unicam->bus_flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK)) {
			unicam_set_field(&val, 1, UNICAM_CLTRE);
			unicam_set_field(&val, 1, UNICAM_CLHSE);
		}

Maybe @6by9 has some insights here ?

The simplest change to guarantee the property exists is to include a literal assignment:

			      <&mux_in0>, "clock-noncontinuous?=0",

but I'm not convinced it's worth the effort.

Neither am I but let's first clarify the property is required in the receiver node as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the bits I think DRM has got right for DSI, and V4L2 isn't as great.

If the link is operated in continuous clock mode, then the source needs to know in order to set the appropriate registers.
The receiver also needs to know, as it has to engage the HS termination resistors on the clock lane at all times, and not look for LP<->HS transitions to control them. See https://download.tek.com/document/61W_25772_0_HR.pdf for an intro to MIPI D-PHY and what happens in those transitions.

There is get_mbus_config available through the subdev API which can set the number of lanes and the flags, but the maintainers say that should only be used if the source changes the configuration dynamically (eg tc358743), not to pass the configuration from source to receiver normally. If the configuration is static we have to have the information duplicated in DT/ACPI at both ends of the link :-(

The video-mux has to implement get_mbus_config as the different inputs to the mux can have different bus parameters, so it is actually the input pads to the mux that matter rather than those on Unicam/CFE. That's a downstream patch as any discussion of video-mux upstream generally ends up being that it needs to be rewritten to work in a different manner using (IIRC) the streams API, except that still isn't fully merged.

Yes, a literal assignment in the dt override would probably be the better approach here.

DRM by contrast passes a struct mipi_dsi_device from sink to transmitter to configure the number of lanes, modes, etc, so configuration comes from one place.

<&mira016_0>, "status=okay";
cam0-mira220 = <&mux_in0>, "remote-endpoint:0=",<&mira220_0_ep>,
<&mira220_0_ep>, "remote-endpoint:0=",<&mux_in0>,
<&mira220_0>, "status=okay";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mira220 only supports continuous clock, that's why I removed the

<&mux_in0>, "clock-noncontinuous?",

line from here.

@pelwell

pelwell commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

The 4port overlay is missing the clk_38mhz declaration, but otherwise the checker is happy with it. I'll also give it a read through.

@jmondi

jmondi commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

The 4port overlay is missing the clk_38mhz declaration, but otherwise the checker is happy with it. I'll also give it a read through.

fixed, sorry for missing it

@jmondi
jmondi force-pushed the ams/rpi-6.18.y/mira-upstream branch from f979626 to 6dfd6cd Compare November 27, 2026 09:07
@pelwell

pelwell commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

fixed, sorry for missing it

No apology needed. Thank you for the contribution.

Jacopo Mondi and others added 4 commits November 27, 2026 10:35
Add Mira016 and Mira220 to the camera-mux 2 and 4 ports overlays and
update the README file accordingly.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
The analogue gain control is created with a 1..1 range, which is only
valid for the 12-bit format, while init_state applies the 8-bit format.
The gain cannot be changed until userspace sets the active format.

Make the 12-bit format the default, and initialise row_length to the
matching value so the blanking, pixel rate and exposure limits are
computed for it.

The issue was found by code inspection with an LLM, build tested only.

Signed-off-by: David Carlier <devnexen@gmail.com>
Acked-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
The analogue gain handling is currently modeled using tables that
contains the values of the three registers that control the gain
(ADC_GAIN, RG_MULT and GDIG_PREAMP).

The undelying gain model has been characterized as

    analogue_gain =  57 * 2^(2 - RG_MULT) / (ADC_GAIN + 21)

In 8-bits mode the output of the 10-bit ADC is scaled to 8-bit allowing
an additional 4x digital gain, for a total achievable 16x gain, compared
to the 4x available in 10-bits mode.

Implement the calculation of the [ADC_GAIN, RG_MULT, GDIG_PREAMP]
registers values in mira016_fine_gain() and remove the tables.

The expected gain code is the desired gain value multiplied by 1000 to
perform all calculations with integers arithmetic.

Signed-off-by: Philippe Baetens <philippebaetens@gmail.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Slightly adjust the 8-bits mode gain init sequence.

Register 0xe024 controls the additional digital gain only available in
8-bits mode. Initialize it to the unit 1x value.

Also adjut the 0x005d register that controls the desired black level
pedestal to the 8-bits default value of 0x06.

Signed-off-by: Philippe Baetens <philippebaetens@gmail.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
@jmondi
jmondi force-pushed the ams/rpi-6.18.y/mira-upstream branch from 6dfd6cd to 7410c16 Compare November 27, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants