drivers/media/i2c/tc358746.c

Source file repositories/reference/linux-study-clean/drivers/media/i2c/tc358746.c

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/tc358746.c
Extension
.c
Size
43485 bytes
Lines
1718
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

struct tc358746 {
	struct v4l2_subdev		sd;
	struct media_pad		pads[TC358746_NR_PADS];
	struct v4l2_async_notifier	notifier;
	struct v4l2_fwnode_endpoint	csi_vep;

	struct v4l2_ctrl_handler	ctrl_hdl;

	struct regmap			*regmap;
	struct clk			*refclk;
	struct gpio_desc		*reset_gpio;
	struct regulator_bulk_data	supplies[ARRAY_SIZE(tc358746_supplies)];

	struct clk_hw			mclk_hw;
	unsigned long			mclk_rate;
	u8				mclk_prediv;
	u16				mclk_postdiv;

	unsigned long			pll_rate;
	u8				pll_post_div;
	u16				pll_pre_div;
	u16				pll_mul;

	struct phy_configure_opts_mipi_dphy dphy_cfg;
};

static inline struct tc358746 *to_tc358746(struct v4l2_subdev *sd)
{
	return container_of(sd, struct tc358746, sd);
}

static inline struct tc358746 *clk_hw_to_tc358746(struct clk_hw *hw)
{
	return container_of(hw, struct tc358746, mclk_hw);
}

struct tc358746_format {
	u32		code;
	bool		csi_format;
	unsigned char	bus_width;
	unsigned char	bpp;
	/* Register values */
	u8		pdformat; /* Peripheral Data Format */
	u8		pdataf;   /* Parallel Data Format Option */
};

enum {
	PDFORMAT_RAW8 = 0,
	PDFORMAT_RAW10,
	PDFORMAT_RAW12,
	PDFORMAT_RGB888,
	PDFORMAT_RGB666,
	PDFORMAT_RGB565,
	PDFORMAT_YUV422_8BIT,
	/* RESERVED = 7 */
	PDFORMAT_RAW14 = 8,
	PDFORMAT_YUV422_10BIT,
	PDFORMAT_YUV444,
};

#define TC358746_FORMAT_RAW(_bpp, _code)		\
{							\
	.code = _code,					\
	.bus_width = _bpp,				\
	.bpp = _bpp,					\
	.pdformat = PDFORMAT_RAW##_bpp,			\
	.pdataf = PDATAF_MODE0, /* don't care */	\
}

/* Check tc358746_src_mbus_code() if you add new formats */
static const struct tc358746_format tc358746_formats[] = {
	{
		.code = MEDIA_BUS_FMT_UYVY8_2X8,
		.bus_width = 8,
		.bpp = 16,
		.pdformat = PDFORMAT_YUV422_8BIT,
		.pdataf = PDATAF_MODE0,
	}, {
		.code = MEDIA_BUS_FMT_UYVY8_1X16,
		.csi_format = true,
		.bus_width = 16,
		.bpp = 16,
		.pdformat = PDFORMAT_YUV422_8BIT,
		.pdataf = PDATAF_MODE1,
	}, {
		.code = MEDIA_BUS_FMT_YUYV8_1X16,
		.csi_format = true,
		.bus_width = 16,
		.bpp = 16,
		.pdformat = PDFORMAT_YUV422_8BIT,

Annotation

Implementation Notes