drivers/staging/media/tegra-video/tegra210.c

Source file repositories/reference/linux-study-clean/drivers/staging/media/tegra-video/tegra210.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/media/tegra-video/tegra210.c
Extension
.c
Size
39181 bytes
Lines
1221
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 (!fs_sp) {
			dev_err(vi->dev, "failed to request frame start syncpoint\n");
			ret = -ENOMEM;
			goto free_syncpts;
		}

		mw_sp = host1x_syncpt_request(&vi->client, flags);
		if (!mw_sp) {
			dev_err(vi->dev, "failed to request memory ack syncpoint\n");
			host1x_syncpt_put(fs_sp);
			ret = -ENOMEM;
			goto free_syncpts;
		}

		chan->frame_start_sp[i] = fs_sp;
		chan->mw_ack_sp[i] = mw_sp;
		spin_lock_init(&chan->sp_incr_lock[i]);
	}

	return 0;

free_syncpts:
	for (i = 0; i < chan->numgangports; i++) {
		host1x_syncpt_put(chan->mw_ack_sp[i]);
		host1x_syncpt_put(chan->frame_start_sp[i]);
	}
	return ret;
}

static void tegra210_channel_host1x_syncpt_free(struct tegra_vi_channel *chan)
{
	int i;

	for (i = 0; i < chan->numgangports; i++) {
		host1x_syncpt_put(chan->mw_ack_sp[i]);
		host1x_syncpt_put(chan->frame_start_sp[i]);
	}
}

static void tegra210_fmt_align(struct v4l2_pix_format *pix, unsigned int bpp)
{
	unsigned int min_bpl;
	unsigned int max_bpl;
	unsigned int bpl;

	/*
	 * The transfer alignment requirements are expressed in bytes.
	 * Clamp the requested width and height to the limits.
	 */
	pix->width = clamp(pix->width, TEGRA210_MIN_WIDTH, TEGRA210_MAX_WIDTH);
	pix->height = clamp(pix->height, TEGRA210_MIN_HEIGHT, TEGRA210_MAX_HEIGHT);

	/* Clamp the requested bytes per line value. If the maximum bytes per
	 * line value is zero, the module doesn't support user configurable
	 * line sizes. Override the requested value with the minimum in that
	 * case.
	 */
	min_bpl = pix->width * bpp;
	max_bpl = rounddown(TEGRA210_MAX_WIDTH, SURFACE_ALIGN_BYTES);
	bpl = roundup(pix->bytesperline, SURFACE_ALIGN_BYTES);

	pix->bytesperline = clamp(bpl, min_bpl, max_bpl);
	pix->sizeimage = pix->bytesperline * pix->height;
	if (pix->pixelformat == V4L2_PIX_FMT_NV16)
		pix->sizeimage *= 2;
}

static int tegra_channel_capture_setup(struct tegra_vi_channel *chan,
				       u8 portno)
{
	u32 height = chan->format.height;
	u32 width = chan->format.width;
	u32 format = chan->fmtinfo->img_fmt;
	u32 data_type = chan->fmtinfo->img_dt;
	u32 word_count = (width * chan->fmtinfo->bit_width) / 8;
	u32 bypass_pixel_transform = BIT(BYPASS_PXL_TRANSFORM_OFFSET);

	/*
	 * VI Pixel transformation unit converts source pixels data format
	 * into selected destination pixel format and aligns properly while
	 * interfacing with memory packer.
	 * This pixel transformation should be enabled for YUV and RGB
	 * formats and should be bypassed for RAW formats as RAW formats
	 * only support direct to memory.
	 */
	if (chan->pg_mode || data_type == TEGRA_IMAGE_DT_YUV422_8 ||
	    data_type == TEGRA_IMAGE_DT_RGB888)
		bypass_pixel_transform = 0;

	/*

Annotation

Implementation Notes