drivers/media/i2c/saa7115.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/saa7115.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/saa7115.c- Extension
.c- Size
- 56571 bytes
- Lines
- 1952
- 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
saa711x_regs.hlinux/bitops.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/i2c.hlinux/videodev2.hmedia/v4l2-device.hmedia/v4l2-ctrls.hmedia/v4l2-mc.hmedia/i2c/saa7115.hasm/div64.h
Detected Declarations
struct saa711x_stateenum saa711x_modelenum saa711x_padsfunction saa711x_writefunction saa711x_has_regfunction saa711x_writeregsfunction saa711x_readfunction saa711x_decode_vpsfunction saa711x_decode_wssfunction saa711x_s_clock_freqfunction saa711x_g_volatile_ctrlfunction saa711x_s_ctrlfunction saa711x_set_sizefunction saa711x_set_v4lstdfunction BGDHIfunction saa711x_set_lcrfunction saa711x_g_sliced_fmtfunction saa711x_s_raw_fmtfunction saa711x_s_sliced_fmtfunction saa711x_set_fmtfunction saa711x_decode_vbi_linefunction saa711x_g_tunerfunction saa711x_s_stdfunction saa711x_s_radiofunction saa711x_s_routingfunction saa711x_s_gpiofunction saa711x_s_streamfunction saa711x_s_crystal_freqfunction saa711x_resetfunction saa711x_g_vbi_datafunction saa711x_querystdfunction saa711x_g_input_statusfunction saa711x_g_registerfunction saa711x_s_registerfunction saa711x_log_statusfunction saa711x_write_platform_datafunction saa711x_detect_chipfunction saa711x_probefunction saa711x_remove
Annotated Snippet
struct saa711x_state {
struct v4l2_subdev sd;
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_pad pads[SAA711X_NUM_PADS];
#endif
struct v4l2_ctrl_handler hdl;
struct {
/* chroma gain control cluster */
struct v4l2_ctrl *agc;
struct v4l2_ctrl *gain;
};
v4l2_std_id std;
int input;
int output;
int enable;
int radio;
int width;
int height;
enum saa711x_model ident;
u32 audclk_freq;
u32 crystal_freq;
bool ucgc;
u8 cgcdiv;
bool apll;
bool double_asclk;
};
static inline struct saa711x_state *to_state(struct v4l2_subdev *sd)
{
return container_of(sd, struct saa711x_state, sd);
}
static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
{
return &container_of(ctrl->handler, struct saa711x_state, hdl)->sd;
}
/* ----------------------------------------------------------------------- */
static inline int saa711x_write(struct v4l2_subdev *sd, u8 reg, u8 value)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
return i2c_smbus_write_byte_data(client, reg, value);
}
/* Sanity routine to check if a register is present */
static int saa711x_has_reg(const int id, const u8 reg)
{
if (id == SAA7111)
return reg < 0x20 && reg != 0x01 && reg != 0x0f &&
(reg < 0x13 || reg > 0x19) && reg != 0x1d && reg != 0x1e;
if (id == SAA7111A)
return reg < 0x20 && reg != 0x01 && reg != 0x0f &&
reg != 0x14 && reg != 0x18 && reg != 0x19 &&
reg != 0x1d && reg != 0x1e;
/* common for saa7113/4/5/8 */
if (unlikely((reg >= 0x3b && reg <= 0x3f) || reg == 0x5c || reg == 0x5f ||
reg == 0xa3 || reg == 0xa7 || reg == 0xab || reg == 0xaf || (reg >= 0xb5 && reg <= 0xb7) ||
reg == 0xd3 || reg == 0xd7 || reg == 0xdb || reg == 0xdf || (reg >= 0xe5 && reg <= 0xe7) ||
reg == 0x82 || (reg >= 0x89 && reg <= 0x8e)))
return 0;
switch (id) {
case GM7113C:
return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && reg < 0x20;
case SAA7113:
return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && (reg < 0x20 || reg > 0x3f) &&
reg != 0x5d && reg < 0x63;
case SAA7114:
return (reg < 0x1a || reg > 0x1e) && (reg < 0x20 || reg > 0x2f) &&
(reg < 0x63 || reg > 0x7f) && reg != 0x33 && reg != 0x37 &&
reg != 0x81 && reg < 0xf0;
case SAA7115:
return (reg < 0x20 || reg > 0x2f) && reg != 0x65 && (reg < 0xfc || reg > 0xfe);
case SAA7118:
return (reg < 0x1a || reg > 0x1d) && (reg < 0x20 || reg > 0x22) &&
(reg < 0x26 || reg > 0x28) && reg != 0x33 && reg != 0x37 &&
(reg < 0x63 || reg > 0x7f) && reg != 0x81 && reg < 0xf0;
}
return 1;
}
static int saa711x_writeregs(struct v4l2_subdev *sd, const unsigned char *regs)
{
struct saa711x_state *state = to_state(sd);
unsigned char reg, data;
Annotation
- Immediate include surface: `saa711x_regs.h`, `linux/bitops.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/i2c.h`, `linux/videodev2.h`, `media/v4l2-device.h`.
- Detected declarations: `struct saa711x_state`, `enum saa711x_model`, `enum saa711x_pads`, `function saa711x_write`, `function saa711x_has_reg`, `function saa711x_writeregs`, `function saa711x_read`, `function saa711x_decode_vps`, `function saa711x_decode_wss`, `function saa711x_s_clock_freq`.
- 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.