Skip to content

add mira220 image sensor #6717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: rpi-6.12.y
Choose a base branch
from
Open

Conversation

fiepfiep
Copy link

@fiepfiep fiepfiep commented Mar 12, 2025

add driver / device tree support for ams mira220

needed changes also done for libcamera.

Copy link
Contributor

@6by9 6by9 left a comment

Choose a reason for hiding this comment

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

I've started to review this, but I'm noticing a lot of my comments from #6552 haven't been addressed.

If embedded data isn't required, then do not include it.


/* Embedded metadata stream structure */
#define MIRA220_EMBEDDED_LINE_WIDTH 16384
#define MIRA220_NUM_EMBEDDED_LINES 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this sensor actually have useful embedded metadata? It's disabled in libcamera.

I'd made the same comment in #6552 (comment) that this isn't how mainline are implementing metadata, so it's simpler to not implement it in the driver if not needed.

Copy link
Author

Choose a reason for hiding this comment

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

I have removed the embedded data


// 1600_1400_30fps_12b_2lanes

static const struct mira220_reg full_1600_1400_1500_12b_2lanes_reg[] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

You have about 18 registers that differ between these 3 huge tables. Break out all the common stuff into a common table, and only send the bits that change per mode

Copy link
Author

Choose a reason for hiding this comment

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

thanks, will do.

Copy link
Author

Choose a reason for hiding this comment

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

simplified, reduced driver to 1 mode only.

@pelwell
Copy link
Contributor

pelwell commented Apr 2, 2025

I'll warn you now that, once the content of these commits has been approved, the end result should ideally be 3 commits - driver changes, config changes, and overlay/README changes.

@@ -58,28 +58,6 @@
};
};

fragment@102 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you delete this fragment by mistake? The media-controller parameter refers to it.

Copy link
Author

Choose a reason for hiding this comment

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

Yes that is a mistake.

Copy link
Author

Choose a reason for hiding this comment

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

I put it back. thanks for finding out.

@fiepfiep fiepfiep marked this pull request as draft April 2, 2025 19:57
@fiepfiep
Copy link
Author

fiepfiep commented Apr 2, 2025

I'll warn you now that, once the content of these commits has been approved, the end result should ideally be 3 commits - driver changes, config changes, and overlay/README changes.

I will keep it in mind. Once all is approved by you I will refactor it to 3 commits.

@fiepfiep fiepfiep requested a review from 6by9 April 2, 2025 21:43
@fiepfiep fiepfiep marked this pull request as ready for review April 2, 2025 21:43
@fiepfiep fiepfiep marked this pull request as draft April 2, 2025 21:44
@fiepfiep
Copy link
Author

fiepfiep commented Apr 2, 2025

I cleaned up the driver a bit, implemented the new CCI_REG style writes, and took care of 6by9's comments.
Please let me know if you find other issues before we can do the merge.

Copy link
Contributor

@pelwell pelwell left a comment

Choose a reason for hiding this comment

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

Apart from the extra blank lines in the README, the overlay looks good.

Checkpatch has lots of complaints about the driver which you should really fix. Nobody using printk directly anymore, for example.

The only additional change I would like (apart from refactoring down to 3 commits as discussed) is the addition of CONFIG_VIDEO_MIRA220 to the new PREEMPT_RT config file arm64/bcm2711_rt_defconfig.

Copy link
Contributor

@6by9 6by9 left a comment

Choose a reason for hiding this comment

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

Still a number of my previous review comments haven't been addressed.

  • Please remove the references to the embedded data pad.
  • Please remove all commented out code.
  • Please remove all redundant comments.
  • Please rationalise the logging messages. Very few should be needed at all.
  • Regulator names should be consistently in lower case.

@pelwell
Copy link
Contributor

pelwell commented Apr 6, 2025

FYI the build checks explicitly set CONFIG_WERROR=y, overriding the defconfigs:

scripts/config --file ${{github.workspace}}/build/.config --set-val CONFIG_WERROR y

@fiepfiep fiepfiep force-pushed the rpi-6.12.y branch 2 times, most recently from 6c62034 to a0c3d9c Compare April 15, 2025 13:23
@fiepfiep fiepfiep requested a review from 6by9 April 15, 2025 13:25
@fiepfiep
Copy link
Author

@pelwell could you run your checks again? I split my changes into 3 commits as requested.

@pelwell
Copy link
Contributor

pelwell commented Apr 15, 2025

It looks like somebody has started them. Please mark the PR as "Ready for review" when you think it is. However, there is no excuse for some of these (https://github.com/raspberrypi/linux/actions/runs/14470568709/job/40583365956?pr=6717#step:6:80) checkpatch errors such as trailing whitespace.

@fiepfiep fiepfiep marked this pull request as ready for review April 15, 2025 15:41
@fiepfiep
Copy link
Author

fiepfiep commented Apr 16, 2025

I still get this error in checkpatch, what does it mean?
@pelwell

 WARNING: From:/Signed-off-by: email name mismatch: 'From: philippe baetens <[email protected]>' != 'Signed-off-by: Philippe Baetens <[email protected]>'
Error: WARNING: From:/Signed-off-by: email name mismatch: 'From: philippe baetens <[email protected]>' != 'Signed-off-by: Philippe Baetens <[email protected]>'

@pelwell
Copy link
Contributor

pelwell commented Apr 16, 2025

Is it possibly just that your name appears with and without uppercase letters? I'm not bothered about that, but it makes sense to fix it to avoid such errors in the future.

@fiepfiep
Copy link
Author

Is it possibly just that your name appears with and without uppercase letters? I'm not bothered about that, but it makes sense to fix it to avoid such errors in the future.

that seems to be the case indeed. i modified the commit signoff message + some of the checkpatch remarks. Hope it is ok now.

@pelwell
Copy link
Contributor

pelwell commented Apr 16, 2025

That's fixed it. I'll give these builds time to complete, in which time 6by9 may want to chip in, but I've been taking his silence for consent.

@6by9
Copy link
Contributor

6by9 commented Apr 16, 2025

That's fixed it. I'll give these builds time to complete, in which time 6by9 may want to chip in, but I've been taking his silence for consent.

No, just hadn't had a chance to look through.
It looks like several of my previous comments haven't been addressed, eg the overlay override cam0 still setting VANA-supply and changing vana-supply.

@fiepfiep
Copy link
Author

So - what are the next steps to get this driver into the raspberry linux kernel?
At the moment I'm only merging into the 6.12 kernel. What about older or newer kernel versions?
How does this driver propagate to official bookworm builds?

thanks.

Copy link
Contributor

@6by9 6by9 left a comment

Choose a reason for hiding this comment

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

In reading through to see if my previous comments had been addressed, add a number more.

There are a fair number of commented out blocks of code. They should be reviewed and removed where redundant.

@6by9
Copy link
Contributor

6by9 commented Apr 16, 2025

So - what are the next steps to get this driver into the raspberry linux kernel? At the moment I'm only merging into the 6.12 kernel. What about older or newer kernel versions? How does this driver propagate to official bookworm builds?

Older kernels won't get updated.

Later kernels will get a forward port, as long as there aren't any significant build changes required by the every-changing kernel APIs. Simple changes are likely to get fixed up. Significant changes without obvious fixups will be reported back to you to fix - we don't undertake the full support burden of 3rd party drivers, and they may get dropped from the defconfigs if not fixed and/or get the BROKEN tag added to the Kconfig entry if the situation persists for a significant period.

rpi-update gets kernel updates normally several time a week.
Raspberry Pi OS gets updates every few months based on when significant things occur, providing no significant issues are known about at that point.

philippe baetens added 3 commits April 16, 2025 18:18
Adds defconfig for the Mira220 1600x1400 global
shutter image sensor

Signed-off-by: philippe baetens <[email protected]>
Adds an overlay for the Mira220 1600x1400 global
shutter image sensor

Signed-off-by: philippe baetens <[email protected]>
Adds a driver for the NIR-enhanced Mira220 1600x1400 global
shutter image sensor.

Signed-off-by: philippe baetens <[email protected]>
@pelwell
Copy link
Contributor

pelwell commented Apr 22, 2025

Some of @6by9's comments have yet to be addressed, but the overlay and general structure look okay to me.

@fiepfiep
Copy link
Author

fiepfiep commented Apr 22, 2025

Some of @6by9's comments have yet to be addressed, but the overlay and general structure look okay to me.

Thanks for reviewing. I believe I addressed all of @6by9's comments, but I might have missed something.. Can you be a bit more specific? thanks!

Also: each time I just 'force push' 3 new commits (overlay, conf, i2c driver) - not sure if this is your preferred way, or if you like to see my full commit history?

@pelwell
Copy link
Contributor

pelwell commented Apr 22, 2025

philippe baetens added 2 commits April 23, 2025 23:58
Small fixes, mostly cosmetic.
Removed unneeded code.
Differentiate between physical array and active array.

Signed-off-by: philippe baetens <[email protected]>
Remove commented out code.

Signed-off-by: philippe baetens <[email protected]>
Copy link
Contributor

@6by9 6by9 left a comment

Choose a reason for hiding this comment

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

There are still a number of remnants from the metadata pad kicking around. The things I've listed below would be nice to be cleaned up, but seeing as you'll be retaining responsibility for maintaining it, I'm not going to fuss. None of them should break the system.
You would be picked up on all these things if you try upstreaming the driver.

philippe baetens added 2 commits April 24, 2025 18:59
Fix vflip hflip. Still need to implement correct bayer pattern.
Small fixes, mostly cosmetic.
Removed unneeded code.

Signed-off-by: philippe baetens <[email protected]>
vflip and hflip work now with correct bayer format.
@fiepfiep fiepfiep requested a review from 6by9 May 7, 2025 09:24
@fiepfiep
Copy link
Author

i think the driver is now in good shape. requesting another review please..

@pelwell
Copy link
Contributor

pelwell commented May 12, 2025

This still applies (both aspects):

The only additional change I would like (apart from refactoring down to 3 commits as discussed) is the addition of CONFIG_VIDEO_MIRA220 to the new PREEMPT_RT config file arm64/bcm2711_rt_defconfig.

@fiepfiep
Copy link
Author

This still applies (both aspects):

The only additional change I would like (apart from refactoring down to 3 commits as discussed) is the addition of CONFIG_VIDEO_MIRA220 to the new PREEMPT_RT config file arm64/bcm2711_rt_defconfig.

okay, if all is good - I'll start refactoring down to 3 commits. I've added the rt_defconfig too.

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.

3 participants