drivers/media/platform/qcom/camss/camss-vfe-340.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/camss/camss-vfe-340.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/qcom/camss/camss-vfe-340.c
Extension
.c
Size
11821 bytes
Lines
385
Domain
Driver Families
Bucket
drivers/media
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 (fmt->formats[i].pixelformat == pixelformat) {
			bpp = fmt->formats[i].mbus_bpp;
			break;
		}
	}

	switch (bpp) {
	case 10:
		return TFE_BUS_PACKER_CFG_FMT_MIPI10;
	case 12:
		return TFE_BUS_PACKER_CFG_FMT_MIPI12;
	default:
		return TFE_BUS_PACKER_CFG_FMT_PLAIN8;
	}
}

static void vfe_wm_start(struct vfe_device *vfe, u8 wm, struct vfe_line *line)
{
	struct v4l2_pix_format_mplane *pix = &line->video_out.active_fmt.fmt.pix_mp;
	u32 stride = pix->plane_fmt[0].bytesperline;
	u8 client = tfe_wm_client_map[wm];
	u32 cfg = TFE_BUS_CLIENT_CFG_EN;

	if (client == TFE_CLI_BAYER) { /* PIX - Line based */
		struct v4l2_rect *crop = &line->crop;

		/* Cropping */
		writel_relaxed(TFE_PP_CROP_CFG_EN, vfe->base + TFE_PP_CROP_CFG);
		writel_relaxed(FIELD_PREP(TFE_PP_CROP_FIRST, crop->top) |
			       FIELD_PREP(TFE_PP_CROP_LAST, crop->top + crop->height - 1),
			       vfe->base + TFE_PP_CROP_LINE_CFG);
		writel_relaxed(FIELD_PREP(TFE_PP_CROP_FIRST, crop->left) |
			       FIELD_PREP(TFE_PP_CROP_LAST, crop->left + crop->width - 1),
			       vfe->base + TFE_PP_CROP_PIX_CFG);

		/* Write Engine */
		writel_relaxed(pix->width | (pix->height << 16),
			       vfe->base + TFE_BUS_IMAGE_CFG_0(client));
		writel_relaxed(0u, vfe->base + TFE_BUS_IMAGE_CFG_1(client));
		writel_relaxed(stride, vfe->base + TFE_BUS_IMAGE_CFG_2(client));
		writel_relaxed(stride * pix->height, vfe->base + TFE_BUS_FRAME_INCR(client));
		writel_relaxed(vfe_packer_format(vfe, pix->pixelformat),
			       vfe->base + TFE_BUS_PACKER_CFG(client));

		cfg |= TFE_BUS_CLIENT_CFG_AUTORECOVER;
	} else { /* RDI - Frame based */
		writel_relaxed(TFE_BUS_IMAGE_CFG_0_DEFAULT,
			       vfe->base + TFE_BUS_IMAGE_CFG_0(client));
		writel_relaxed(0u, vfe->base + TFE_BUS_IMAGE_CFG_1(client));
		writel_relaxed(TFE_BUS_IMAGE_CFG_2_DEFAULT,
			       vfe->base + TFE_BUS_IMAGE_CFG_2(client));
		writel_relaxed(stride * pix->height, vfe->base + TFE_BUS_FRAME_INCR(client));
		writel_relaxed(TFE_BUS_PACKER_CFG_FMT_PLAIN64,
			       vfe->base + TFE_BUS_PACKER_CFG(client));
		cfg |= TFE_BUS_CLIENT_CFG_MODE_FRAME;
	}

	/* No dropped frames, one irq per frame */
	writel_relaxed(0, vfe->base + TFE_BUS_FRAMEDROP_CFG_0(client));
	writel_relaxed(1, vfe->base + TFE_BUS_FRAMEDROP_CFG_1(client));
	writel_relaxed(0, vfe->base + TFE_BUS_IRQ_SUBSAMPLE_CFG_0(client));
	writel_relaxed(1, vfe->base + TFE_BUS_IRQ_SUBSAMPLE_CFG_1(client));

	vfe_enable_irq(vfe);

	writel(cfg, vfe->base + TFE_BUS_CLIENT_CFG(client));

	dev_dbg(vfe->camss->dev, "VFE%u: Started client %u width %u height %u stride %u\n",
		vfe->id, client, pix->width, pix->height, stride);
}

static void vfe_wm_stop(struct vfe_device *vfe, u8 wm)
{
	u8 client = tfe_wm_client_map[wm];

	writel(0, vfe->base + TFE_BUS_CLIENT_CFG(client));

	dev_dbg(vfe->camss->dev, "VFE%u: Stopped client %u\n", vfe->id, client);
}

static const struct camss_video_ops vfe_video_ops_520 = {
	.queue_buffer = vfe_queue_buffer_v2,
	.flush_buffers = vfe_flush_buffers,
};

static void vfe_subdev_init(struct device *dev, struct vfe_device *vfe)
{
	vfe->video_ops = vfe_video_ops_520;
}

Annotation

Implementation Notes