drivers/media/v4l2-core/v4l2-ctrls-core.c

Source file repositories/reference/linux-study-clean/drivers/media/v4l2-core/v4l2-ctrls-core.c

File Facts

System
Linux kernel
Corpus path
drivers/media/v4l2-core/v4l2-ctrls-core.c
Extension
.c
Size
76843 bytes
Lines
2844
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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 (value) {
			for (i = from_idx; i < tot_elems; i++)
				ptr.p_s64[i] = value;
		} else {
			memset(ptr.p_s64 + from_idx, 0, elems * sizeof(s64));
		}
		break;
	case V4L2_CTRL_TYPE_INTEGER:
	case V4L2_CTRL_TYPE_INTEGER_MENU:
	case V4L2_CTRL_TYPE_MENU:
	case V4L2_CTRL_TYPE_BITMASK:
	case V4L2_CTRL_TYPE_BOOLEAN:
		if (value) {
			for (i = from_idx; i < tot_elems; i++)
				ptr.p_s32[i] = value;
		} else {
			memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32));
		}
		break;
	case V4L2_CTRL_TYPE_BUTTON:
	case V4L2_CTRL_TYPE_CTRL_CLASS:
		memset(ptr.p_s32 + from_idx, 0, elems * sizeof(s32));
		break;
	case V4L2_CTRL_TYPE_U8:
		memset(ptr.p_u8 + from_idx, value, elems);
		break;
	case V4L2_CTRL_TYPE_U16:
		if (value) {
			for (i = from_idx; i < tot_elems; i++)
				ptr.p_u16[i] = value;
		} else {
			memset(ptr.p_u16 + from_idx, 0, elems * sizeof(u16));
		}
		break;
	case V4L2_CTRL_TYPE_U32:
		if (value) {
			for (i = from_idx; i < tot_elems; i++)
				ptr.p_u32[i] = value;
		} else {
			memset(ptr.p_u32 + from_idx, 0, elems * sizeof(u32));
		}
		break;
	default:
		for (i = from_idx; i < tot_elems; i++) {
			switch (which) {
			case V4L2_CTRL_WHICH_DEF_VAL:
				std_init_compound(ctrl, i, ptr);
				break;
			case V4L2_CTRL_WHICH_MAX_VAL:
				std_max_compound(ctrl, i, ptr);
				break;
			case V4L2_CTRL_WHICH_MIN_VAL:
				std_min_compound(ctrl, i, ptr);
				break;
			}
		}
		break;
	}
}

void v4l2_ctrl_type_op_init(const struct v4l2_ctrl *ctrl, u32 from_idx,
			    union v4l2_ctrl_ptr ptr)
{
	__v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_DEF_VAL, ptr);
}
EXPORT_SYMBOL(v4l2_ctrl_type_op_init);

static void v4l2_ctrl_type_op_minimum(const struct v4l2_ctrl *ctrl,
				      u32 from_idx, union v4l2_ctrl_ptr ptr)
{
	__v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_MIN_VAL, ptr);
}

static void v4l2_ctrl_type_op_maximum(const struct v4l2_ctrl *ctrl,
				      u32 from_idx, union v4l2_ctrl_ptr ptr)
{
	__v4l2_ctrl_type_op_init(ctrl, from_idx, V4L2_CTRL_WHICH_MAX_VAL, ptr);
}

void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl)
{
	union v4l2_ctrl_ptr ptr = ctrl->p_cur;

	if (ctrl->is_array) {
		unsigned i;

		for (i = 0; i < ctrl->nr_of_dims; i++)
			pr_cont("[%u]", ctrl->dims[i]);
		pr_cont(" ");
	}

Annotation

Implementation Notes