drivers/media/i2c/rj54n1cb0c.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/rj54n1cb0c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/rj54n1cb0c.c- Extension
.c- Size
- 35892 bytes
- Lines
- 1435
- 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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/slab.hlinux/v4l2-mediabus.hlinux/videodev2.hmedia/i2c/rj54n1cb0c.hmedia/v4l2-device.hmedia/v4l2-ctrls.hmedia/v4l2-subdev.h
Detected Declarations
struct rj54n1_datafmtstruct rj54n1_clock_divstruct rj54n1struct rj54n1_reg_valfunction reg_readfunction reg_writefunction reg_setfunction reg_write_multiplefunction rj54n1_enum_mbus_codefunction rj54n1_s_streamfunction rj54n1_set_rectfunction rj54n1_commitfunction rj54n1_set_selectionfunction rj54n1_get_selectionfunction rj54n1_get_fmtfunction rj54n1_sensor_scalefunction rj54n1_set_clockfunction rj54n1_reg_initfunction rj54n1_set_fmtfunction rj54n1_g_registerfunction rj54n1_s_registerfunction rj54n1_s_powerfunction rj54n1_s_ctrlfunction rj54n1_video_probefunction rj54n1_probefunction rj54n1_remove
Annotated Snippet
struct rj54n1_datafmt {
u32 code;
enum v4l2_colorspace colorspace;
};
/* Find a data format by a pixel code in an array */
static const struct rj54n1_datafmt *rj54n1_find_datafmt(
u32 code, const struct rj54n1_datafmt *fmt,
int n)
{
int i;
for (i = 0; i < n; i++)
if (fmt[i].code == code)
return fmt + i;
return NULL;
}
static const struct rj54n1_datafmt rj54n1_colour_fmts[] = {
{MEDIA_BUS_FMT_YUYV8_2X8, V4L2_COLORSPACE_JPEG},
{MEDIA_BUS_FMT_YVYU8_2X8, V4L2_COLORSPACE_JPEG},
{MEDIA_BUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, V4L2_COLORSPACE_SRGB},
{MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
};
struct rj54n1_clock_div {
u8 ratio_tg; /* can be 0 or an odd number */
u8 ratio_t;
u8 ratio_r;
u8 ratio_op;
u8 ratio_o;
};
struct rj54n1 {
struct v4l2_subdev subdev;
struct v4l2_ctrl_handler hdl;
struct clk *clk;
struct gpio_desc *pwup_gpio;
struct gpio_desc *enable_gpio;
struct rj54n1_clock_div clk_div;
const struct rj54n1_datafmt *fmt;
struct v4l2_rect rect; /* Sensor window */
unsigned int tgclk_mhz;
bool auto_wb;
unsigned short width; /* Output window */
unsigned short height;
unsigned short resize; /* Sensor * 1024 / resize = Output */
unsigned short scale;
u8 bank;
};
struct rj54n1_reg_val {
u16 reg;
u8 val;
};
static const struct rj54n1_reg_val bank_4[] = {
{0x417, 0},
{0x42c, 0},
{0x42d, 0xf0},
{0x42e, 0},
{0x42f, 0x50},
{0x430, 0xf5},
{0x431, 0x16},
{0x432, 0x20},
{0x433, 0},
{0x434, 0xc8},
{0x43c, 8},
{0x43e, 0x90},
{0x445, 0x83},
{0x4ba, 0x58},
{0x4bb, 4},
{0x4bc, 0x20},
{0x4db, 4},
{0x4fe, 2},
};
static const struct rj54n1_reg_val bank_5[] = {
{0x514, 0},
{0x516, 0},
{0x518, 0},
{0x51a, 0},
{0x51d, 0xff},
{0x56f, 0x28},
{0x575, 0x40},
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/slab.h`, `linux/v4l2-mediabus.h`, `linux/videodev2.h`.
- Detected declarations: `struct rj54n1_datafmt`, `struct rj54n1_clock_div`, `struct rj54n1`, `struct rj54n1_reg_val`, `function reg_read`, `function reg_write`, `function reg_set`, `function reg_write_multiple`, `function rj54n1_enum_mbus_code`, `function rj54n1_s_stream`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.