drivers/media/i2c/vp27smpx.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/vp27smpx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/vp27smpx.c- Extension
.c- Size
- 4493 bytes
- Lines
- 190
- 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/module.hlinux/types.hlinux/slab.hlinux/ioctl.hlinux/uaccess.hlinux/i2c.hlinux/videodev2.hmedia/v4l2-device.h
Detected Declarations
struct vp27smpx_statefunction vp27smpx_set_audmodefunction vp27smpx_s_radiofunction vp27smpx_s_stdfunction vp27smpx_s_tunerfunction vp27smpx_g_tunerfunction vp27smpx_log_statusfunction vp27smpx_probefunction vp27smpx_remove
Annotated Snippet
struct vp27smpx_state {
struct v4l2_subdev sd;
int radio;
u32 audmode;
};
static inline struct vp27smpx_state *to_state(struct v4l2_subdev *sd)
{
return container_of(sd, struct vp27smpx_state, sd);
}
static void vp27smpx_set_audmode(struct v4l2_subdev *sd, u32 audmode)
{
struct vp27smpx_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
u8 data[3] = { 0x00, 0x00, 0x04 };
switch (audmode) {
case V4L2_TUNER_MODE_MONO:
case V4L2_TUNER_MODE_LANG1:
break;
case V4L2_TUNER_MODE_STEREO:
case V4L2_TUNER_MODE_LANG1_LANG2:
data[1] = 0x01;
break;
case V4L2_TUNER_MODE_LANG2:
data[1] = 0x02;
break;
}
if (i2c_master_send(client, data, sizeof(data)) != sizeof(data))
v4l2_err(sd, "I/O error setting audmode\n");
else
state->audmode = audmode;
}
static int vp27smpx_s_radio(struct v4l2_subdev *sd)
{
struct vp27smpx_state *state = to_state(sd);
state->radio = 1;
return 0;
}
static int vp27smpx_s_std(struct v4l2_subdev *sd, v4l2_std_id norm)
{
struct vp27smpx_state *state = to_state(sd);
state->radio = 0;
return 0;
}
static int vp27smpx_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt)
{
struct vp27smpx_state *state = to_state(sd);
if (!state->radio)
vp27smpx_set_audmode(sd, vt->audmode);
return 0;
}
static int vp27smpx_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
{
struct vp27smpx_state *state = to_state(sd);
if (state->radio)
return 0;
vt->audmode = state->audmode;
vt->capability = V4L2_TUNER_CAP_STEREO |
V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
vt->rxsubchans = V4L2_TUNER_SUB_MONO;
return 0;
}
static int vp27smpx_log_status(struct v4l2_subdev *sd)
{
struct vp27smpx_state *state = to_state(sd);
v4l2_info(sd, "Audio Mode: %u%s\n", state->audmode,
state->radio ? " (Radio)" : "");
return 0;
}
/* ----------------------------------------------------------------------- */
static const struct v4l2_subdev_core_ops vp27smpx_core_ops = {
.log_status = vp27smpx_log_status,
};
static const struct v4l2_subdev_tuner_ops vp27smpx_tuner_ops = {
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/slab.h`, `linux/ioctl.h`, `linux/uaccess.h`, `linux/i2c.h`, `linux/videodev2.h`, `media/v4l2-device.h`.
- Detected declarations: `struct vp27smpx_state`, `function vp27smpx_set_audmode`, `function vp27smpx_s_radio`, `function vp27smpx_s_std`, `function vp27smpx_s_tuner`, `function vp27smpx_g_tuner`, `function vp27smpx_log_status`, `function vp27smpx_probe`, `function vp27smpx_remove`.
- 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.