drivers/staging/media/atomisp/pci/atomisp_subdev.c

Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/atomisp_subdev.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/media/atomisp/pci/atomisp_subdev.c
Extension
.c
Size
27198 bytes
Lines
920
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

switch (target) {
		case V4L2_SEL_TGT_CROP:
			return 0;
		}
		break;
	default:
		switch (target) {
		case V4L2_SEL_TGT_COMPOSE:
			return 0;
		}
		break;
	}

	return -EINVAL;
}

struct v4l2_rect *atomisp_subdev_get_rect(struct v4l2_subdev *sd,
	struct v4l2_subdev_state *sd_state,
	u32 which, u32 pad,
	u32 target)
{
	struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);

	if (which == V4L2_SUBDEV_FORMAT_TRY) {
		switch (target) {
		case V4L2_SEL_TGT_CROP:
			return v4l2_subdev_state_get_crop(sd_state, pad);
		case V4L2_SEL_TGT_COMPOSE:
			return v4l2_subdev_state_get_compose(sd_state, pad);
		}
	}

	switch (target) {
	case V4L2_SEL_TGT_CROP:
		return &isp_sd->fmt[pad].crop;
	case V4L2_SEL_TGT_COMPOSE:
		return &isp_sd->fmt[pad].compose;
	}

	return NULL;
}

struct v4l2_mbus_framefmt
*atomisp_subdev_get_ffmt(struct v4l2_subdev *sd,
			 struct v4l2_subdev_state *sd_state, u32 which,
			 u32 pad)
{
	struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);

	if (which == V4L2_SUBDEV_FORMAT_TRY)
		return v4l2_subdev_state_get_format(sd_state, pad);

	return &isp_sd->fmt[pad].fmt;
}

static void isp_get_fmt_rect(struct v4l2_subdev *sd,
			     struct v4l2_subdev_state *sd_state,
			     u32 which,
			     struct v4l2_mbus_framefmt **ffmt,
			     struct v4l2_rect *crop[ATOMISP_SUBDEV_PADS_NUM],
			     struct v4l2_rect *comp[ATOMISP_SUBDEV_PADS_NUM])
{
	unsigned int i;

	for (i = 0; i < ATOMISP_SUBDEV_PADS_NUM; i++) {
		ffmt[i] = atomisp_subdev_get_ffmt(sd, sd_state, which, i);
		crop[i] = atomisp_subdev_get_rect(sd, sd_state, which, i,
						  V4L2_SEL_TGT_CROP);
		comp[i] = atomisp_subdev_get_rect(sd, sd_state, which, i,
						  V4L2_SEL_TGT_COMPOSE);
	}
}

static int isp_subdev_get_selection(struct v4l2_subdev *sd,
				    struct v4l2_subdev_state *sd_state,
				    struct v4l2_subdev_selection *sel)
{
	struct v4l2_rect *rec;
	int rval = isp_subdev_validate_rect(sd, sel->pad, sel->target);

	if (rval)
		return rval;

	rec = atomisp_subdev_get_rect(sd, sd_state, sel->which, sel->pad,
				      sel->target);
	if (!rec)
		return -EINVAL;

	sel->r = *rec;
	return 0;

Annotation

Implementation Notes