drivers/staging/media/tegra-video/csi.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/tegra-video/csi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/tegra-video/csi.c- Extension
.c- Size
- 22609 bytes
- Lines
- 899
- Domain
- Driver Families
- Bucket
- drivers/staging
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/clk/tegra.hlinux/device.hlinux/host1x.hlinux/module.hlinux/of.hlinux/of_graph.hlinux/platform_device.hlinux/pm_runtime.hlinux/tegra-mipi-cal.hmedia/v4l2-fwnode.hcsi.hvideo.h
Detected Declarations
function csi_enum_bus_codefunction csi_get_formatfunction csi_get_frmrate_table_indexfunction csi_chan_update_blank_intervalsfunction csi_enum_framesizesfunction csi_enum_frameintervalsfunction csi_set_formatfunction tegra_csi_get_frame_intervalfunction csi_get_pixel_ratefunction tegra_csi_calc_settle_timefunction tegra_csi_enable_streamfunction tegra_csi_disable_streamfunction tegra_csi_s_streamfunction tegra_csi_channel_allocfunction tegra_csi_tpg_channels_allocfunction tegra_csi_channels_allocfunction for_each_child_of_nodefunction tegra_csi_channel_initfunction tegra_csi_error_recoverfunction tegra_csi_channels_initfunction list_for_each_entryfunction tegra_csi_channels_cleanupfunction list_for_each_entry_safefunction csi_runtime_suspendfunction csi_runtime_resumefunction tegra_csi_initfunction tegra_csi_exitfunction tegra_csi_probefunction tegra_csi_remove
Annotated Snippet
if (ret < 0) {
dev_err(csi->dev,
"failed to enable MIPI pads: %d\n", ret);
goto rpm_put;
}
/*
* CSI MIPI pads PULLUP, PULLDN and TERM impedances need to
* be calibrated after power on.
* So, trigger the calibration start here and results will
* be latched and applied to the pads when link is in LP11
* state during start of sensor streaming.
*/
ret = tegra_mipi_start_calibration(csi_chan->mipi);
if (ret < 0) {
dev_err(csi->dev,
"failed to start MIPI calibration: %d\n", ret);
goto disable_mipi;
}
}
csi_chan->pg_mode = chan->pg_mode;
/*
* Tegra CSI receiver can detect the first LP to HS transition.
* So, start the CSI stream-on prior to sensor stream-on and
* vice-versa for stream-off.
*/
ret = csi->ops->csi_start_streaming(csi_chan);
if (ret < 0)
goto finish_calibration;
if (csi_chan->mipi) {
struct v4l2_subdev *src_subdev;
/*
* TRM has incorrectly documented to wait for done status from
* calibration logic after CSI interface power on.
* As per the design, calibration results are latched and applied
* to the pads only when the link is in LP11 state which will happen
* during the sensor stream-on.
* CSI subdev stream-on triggers start of MIPI pads calibration.
* Wait for calibration to finish here after sensor subdev stream-on.
*/
src_subdev = tegra_channel_get_remote_source_subdev(chan);
ret = v4l2_subdev_call(src_subdev, video, s_stream, true);
if (ret < 0 && ret != -ENOIOCTLCMD)
goto disable_csi_stream;
err = tegra_mipi_finish_calibration(csi_chan->mipi);
if (err < 0)
dev_warn(csi->dev, "MIPI calibration failed: %d\n", err);
}
return 0;
disable_csi_stream:
csi->ops->csi_stop_streaming(csi_chan);
finish_calibration:
if (csi_chan->mipi)
tegra_mipi_finish_calibration(csi_chan->mipi);
disable_mipi:
if (csi_chan->mipi) {
err = tegra_mipi_disable(csi_chan->mipi);
if (err < 0)
dev_err(csi->dev,
"failed to disable MIPI pads: %d\n", err);
}
rpm_put:
pm_runtime_put(csi->dev);
return ret;
}
static int tegra_csi_disable_stream(struct v4l2_subdev *subdev)
{
struct tegra_vi_channel *chan = v4l2_get_subdev_hostdata(subdev);
struct tegra_csi_channel *csi_chan = to_csi_chan(subdev);
struct tegra_csi *csi = csi_chan->csi;
int err;
/*
* Stream-off subdevices in reverse order to stream-on.
* Remote source subdev in TPG mode is same as CSI subdev.
*/
if (csi_chan->mipi) {
struct v4l2_subdev *src_subdev;
src_subdev = tegra_channel_get_remote_source_subdev(chan);
err = v4l2_subdev_call(src_subdev, video, s_stream, false);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk/tegra.h`, `linux/device.h`, `linux/host1x.h`, `linux/module.h`, `linux/of.h`, `linux/of_graph.h`, `linux/platform_device.h`.
- Detected declarations: `function csi_enum_bus_code`, `function csi_get_format`, `function csi_get_frmrate_table_index`, `function csi_chan_update_blank_intervals`, `function csi_enum_framesizes`, `function csi_enum_frameintervals`, `function csi_set_format`, `function tegra_csi_get_frame_interval`, `function csi_get_pixel_rate`, `function tegra_csi_calc_settle_time`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.