-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
base: rpi-6.12.y
Are you sure you want to change the base?
add mira220 image sensor #6717
Conversation
There was a problem hiding this 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.
data-lanes = <1 2>; | ||
// clock-noncontinuous; | ||
link-frequencies = | ||
/bits/ 64 <456000000>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the correct link frequency for this sensor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently operating at 1.5 Gbit/s per lane
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solved, set to 750, as datarate is 1500Mbit/s
drivers/media/i2c/mira220.c
Outdated
|
||
/* Embedded metadata stream structure */ | ||
#define MIRA220_EMBEDDED_LINE_WIDTH 16384 | ||
#define MIRA220_NUM_EMBEDDED_LINES 1 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
drivers/media/i2c/mira220.c
Outdated
// 1600_1400_30fps_12b_2lanes | ||
|
||
static const struct mira220_reg full_1600_1400_1500_12b_2lanes_reg[] = { | ||
{0x1003,0x2}, //,Initial Upload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment isn't useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solved
drivers/media/i2c/mira220.c
Outdated
|
||
// 1600_1400_30fps_12b_2lanes | ||
|
||
static const struct mira220_reg full_1600_1400_1500_12b_2lanes_reg[] = { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, will do.
There was a problem hiding this comment.
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.
drivers/media/i2c/mira220.c
Outdated
#define MIRA220_PIXEL_ARRAY_WIDTH 1600U | ||
#define MIRA220_PIXEL_ARRAY_HEIGHT 1400U | ||
|
||
#define MIRA220_ANALOG_GAIN_REG 0x400A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment made at #6552 (comment) that the V4L2_CCI is preferred rather than bare register defines as it encodes the size of each register.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I converted everything to the new style cci writes
drivers/media/i2c/mira220.c
Outdated
static const char * const mira220_supply_name[] = { | ||
// TODO(jalv): Check supply names | ||
/* Supplies can be enabled in any order */ | ||
"VANA", /* Analog (2.8V) supply */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regulators should be named in lower case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
I will keep it in mind. Once all is approved by you I will refactor it to 3 commits. |
I cleaned up the driver a bit, implemented the new CCI_REG style writes, and took care of 6by9's comments. |
There was a problem hiding this 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.
arch/arm/boot/dts/overlays/README
Outdated
@@ -3632,6 +3649,7 @@ Params: rotation Mounting rotation of the camera sensor (0 or | |||
Appears not to work on Pi3. | |||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an unnecessary change.
arch/arm/boot/dts/overlays/README
Outdated
@@ -3511,6 +3511,23 @@ Params: | |||
(default 16). | |||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 blank lines is enough.
configuring the sensor (default on) | ||
cam0 Adopt the default configuration for CAM0 on a | ||
Compute Module (CSI0, i2c_vc, and cam0_reg). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
There was a problem hiding this 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.
<&csi_frag>, "target:0=",<&csi0>, | ||
<&clk_frag>, "target:0=",<&cam0_clk>, | ||
<&cam_node>, "clocks:0=",<&cam0_clk>, | ||
<&cam_node>, "VANA-supply:0=",<&cam0_reg>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your supply is now vana-supply
, so this won't match.
drivers/media/i2c/Kconfig
Outdated
@@ -149,6 +149,20 @@ config VIDEO_HI847 | |||
To compile this driver as a module, choose M here: the | |||
module will be called hi847. | |||
|
|||
config VIDEO_MIRA220 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are normally in alphabetical order. (I see the Arducam drivers have got out of position during forward porting).
Annoyingly this will also move the position in the defconfigs, so perhaps I don't care enough.
drivers/media/i2c/Makefile
Outdated
@@ -49,6 +49,7 @@ obj-$(CONFIG_VIDEO_HI556) += hi556.o | |||
obj-$(CONFIG_VIDEO_HI846) += hi846.o | |||
obj-$(CONFIG_VIDEO_HI847) += hi847.o | |||
obj-$(CONFIG_VIDEO_I2C) += video-i2c.o | |||
obj-$(CONFIG_VIDEO_MIRA220) += mira220.o |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto - alphabetical order please.
drivers/media/i2c/mira220.c
Outdated
|
||
#define MIRA220_ANALOG_GAIN_MIN 1 | ||
#define MIRA220_ANALOG_GAIN_MAX \ | ||
1 /* Fixed analog gain to 1, to avoid unexpected behavior. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird line breaking. That does seem quite a limitation though if you have no analogue gain.
drivers/media/i2c/mira220.c
Outdated
// Outdated. See below. | ||
// pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample | ||
// 1.0Gb/s * 2 * 2 / 12 = 357913941 | ||
// #define MIRA220_PIXEL_RATE (357913941) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's outdated, then please remove it.
drivers/media/i2c/mira220.c
Outdated
|
||
/*test cci write*/ | ||
ret = cci_read(mira220->regmap, MIRA220_EXP_TIME_REG, &readval, &ret); | ||
otherval = readval & 0xFFFF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why read the value before writing it? You do nothing with the result.
if (mira220_check_hwcfg(dev)) | ||
return -EINVAL; | ||
|
||
/* Parse device tree to check if dtoverlay has param skip-reg-upload=1 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh?
drivers/media/i2c/mira220.c
Outdated
} | ||
|
||
static const struct dev_pm_ops mira220_pm_ops = { | ||
SET_SYSTEM_SLEEP_PM_OPS(mira220_suspend, mira220_resume) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't be implementing SLEEP_OPS.
drivers/media/i2c/mira220.c
Outdated
SET_RUNTIME_PM_OPS(mira220_power_off, mira220_power_on, NULL) | ||
}; | ||
|
||
static const struct of_device_id mira220_dt_ids[] = { { .compatible = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the normal formatting for dt_ids.
static const struct of_device_id mira220_dt_ids[] = {
{ .compatible = "ams,mira220" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, mira220_dt_ids); | ||
|
||
static const struct i2c_device_id mira220_ids[] = { { "mira220", 0 }, {} }; | ||
MODULE_DEVICE_TABLE(i2c, mira220_ids); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need I2C ids. This driver needs config data, so you can't load via sysfs.
FYI the build checks explicitly set CONFIG_WERROR=y, overriding the defconfigs:
|
6c62034
to
a0c3d9c
Compare
@pelwell could you run your checks again? I split my changes into 3 commits as requested. |
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. |
Adds defconfig for the Mira220 1600x1400 global shutter image sensor Signed-off-by: Philippe Baetens <philippe.baetens@ams-osram.com>
Adds an overlay for the Mira220 1600x1400 global shutter image sensor Signed-off-by: Philippe Baetens <philippe.baetens@ams-osram.com>
Adds a driver for the Mira220 1600x1400 global shutter image sensor Signed-off-by: Philippe Baetens <philippe.baetens@ams-osram.com>
add driver / device tree support for ams mira220
needed changes also done for libcamera.