Skip to content
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

cfe improvements/fixes #5630

Merged
merged 14 commits into from
Oct 4, 2023
Merged

cfe improvements/fixes #5630

merged 14 commits into from
Oct 4, 2023

Conversation

naushir
Copy link
Contributor

@naushir naushir commented Oct 4, 2023

No description provided.

tomba and others added 14 commits October 4, 2023 09:42
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Use ~0, not -1, when working with unsigned values (-1 is not unsigned).

Signed-off-by: Tomi Valkeinen <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Expose the verbose debug flag as a module parameter.

Signed-off-by: Tomi Valkeinen <[email protected]>
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 <[email protected]>
Drop 'sensor_embedded_data' field, as it is unused.

Signed-off-by: Tomi Valkeinen <[email protected]>
Set hardcoded values for enum csi2_mode, as the values will be
programmed to HW registers.

Signed-off-by: Tomi Valkeinen <[email protected]>
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 <[email protected]>
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 <[email protected]>
When the FE is enabled, ensure that the FE_CONFIG node is enabled.
Otherwise fail cfe_start_streaming() entirely.

Signed-off-by: Naushir Patuck <[email protected]>
@tomba
Copy link
Contributor

tomba commented Oct 4, 2023

@naushir looks good to me

@naushir naushir merged commit 3e2203b into raspberrypi:rpi-6.1.y Oct 4, 2023
12 checks passed
ret = -EINVAL;
goto err_streaming;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

@naushir Ah, noticed only now. The above code block is on the wrong side of the pm_runtime_resume_and_get. It will miss a runtime put in error case.

popcornmix added a commit to raspberrypi/firmware that referenced this pull request Oct 5, 2023
kernel: vc4/drm: Remove the clear of SCALER_DISPBKGND_FILL
See: raspberrypi/linux#5633

kernel: media: i2c: Move Kconfig entry for IMX477 to the camera sensor section
See: raspberrypi/linux#5631

kernel: cfe improvements/fixes
See: raspberrypi/linux#5630

kernel: Add DT aliases to map to DRM card names
See: raspberrypi/linux#5629

kernel: Replace hdmi-codec channel map fix with accepted version
See: raspberrypi/linux#5628

kernel: overlays: Fix vc4-kms-dsi-7inch
See: raspberrypi/linux#5622
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Oct 5, 2023
kernel: vc4/drm: Remove the clear of SCALER_DISPBKGND_FILL
See: raspberrypi/linux#5633

kernel: media: i2c: Move Kconfig entry for IMX477 to the camera sensor section
See: raspberrypi/linux#5631

kernel: cfe improvements/fixes
See: raspberrypi/linux#5630

kernel: Add DT aliases to map to DRM card names
See: raspberrypi/linux#5629

kernel: Replace hdmi-codec channel map fix with accepted version
See: raspberrypi/linux#5628

kernel: overlays: Fix vc4-kms-dsi-7inch
See: raspberrypi/linux#5622
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.

2 participants