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.

Dependency Surface

Detected Declarations

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

Implementation Notes