drivers/media/i2c/s5k6a3.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/s5k6a3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/s5k6a3.c- Extension
.c- Size
- 9146 bytes
- Lines
- 374
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/device.hlinux/err.hlinux/errno.hlinux/gpio/consumer.hlinux/i2c.hlinux/kernel.hlinux/module.hlinux/pm_runtime.hlinux/regulator/consumer.hlinux/slab.hlinux/videodev2.hmedia/v4l2-async.hmedia/v4l2-subdev.h
Detected Declarations
struct s5k6a3function s5k6a3_enum_mbus_codefunction s5k6a3_try_formatfunction s5k6a3_set_fmtfunction s5k6a3_get_fmtfunction s5k6a3_openfunction __s5k6a3_power_onfunction __s5k6a3_power_offfunction s5k6a3_s_powerfunction s5k6a3_probefunction s5k6a3_remove
Annotated Snippet
struct s5k6a3 {
struct device *dev;
struct v4l2_subdev subdev;
struct media_pad pad;
struct regulator_bulk_data supplies[S5K6A3_NUM_SUPPLIES];
struct gpio_desc *gpio_reset;
struct mutex lock;
struct v4l2_mbus_framefmt format;
struct clk *clock;
int power_count;
};
static const char * const s5k6a3_supply_names[] = {
[S5K6A3_SUPP_VDDA] = "svdda",
[S5K6A3_SUPP_VDDIO] = "svddio",
[S5K6A3_SUPP_AFVDD] = "afvdd",
};
static inline struct s5k6a3 *sd_to_s5k6a3(struct v4l2_subdev *sd)
{
return container_of(sd, struct s5k6a3, subdev);
}
static const struct v4l2_mbus_framefmt s5k6a3_formats[] = {
{
.code = MEDIA_BUS_FMT_SGRBG10_1X10,
.colorspace = V4L2_COLORSPACE_SRGB,
.field = V4L2_FIELD_NONE,
}
};
static const struct v4l2_mbus_framefmt *find_sensor_format(
struct v4l2_mbus_framefmt *mf)
{
int i;
for (i = 0; i < ARRAY_SIZE(s5k6a3_formats); i++)
if (mf->code == s5k6a3_formats[i].code)
return &s5k6a3_formats[i];
return &s5k6a3_formats[0];
}
static int s5k6a3_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
{
if (code->index >= ARRAY_SIZE(s5k6a3_formats))
return -EINVAL;
code->code = s5k6a3_formats[code->index].code;
return 0;
}
static void s5k6a3_try_format(struct v4l2_mbus_framefmt *mf)
{
const struct v4l2_mbus_framefmt *fmt;
fmt = find_sensor_format(mf);
mf->code = fmt->code;
mf->field = V4L2_FIELD_NONE;
v4l_bound_align_image(&mf->width, S5K6A3_SENSOR_MIN_WIDTH,
S5K6A3_SENSOR_MAX_WIDTH, 0,
&mf->height, S5K6A3_SENSOR_MIN_HEIGHT,
S5K6A3_SENSOR_MAX_HEIGHT, 0, 0);
}
static struct v4l2_mbus_framefmt *__s5k6a3_get_format(
struct s5k6a3 *sensor, struct v4l2_subdev_state *sd_state,
u32 pad, enum v4l2_subdev_format_whence which)
{
if (which == V4L2_SUBDEV_FORMAT_TRY)
return sd_state ? v4l2_subdev_state_get_format(sd_state, pad) : NULL;
return &sensor->format;
}
static int s5k6a3_set_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *fmt)
{
struct s5k6a3 *sensor = sd_to_s5k6a3(sd);
struct v4l2_mbus_framefmt *mf;
s5k6a3_try_format(&fmt->format);
mf = __s5k6a3_get_format(sensor, sd_state, fmt->pad, fmt->which);
if (mf) {
mutex_lock(&sensor->lock);
*mf = fmt->format;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/errno.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/kernel.h`.
- Detected declarations: `struct s5k6a3`, `function s5k6a3_enum_mbus_code`, `function s5k6a3_try_format`, `function s5k6a3_set_fmt`, `function s5k6a3_get_fmt`, `function s5k6a3_open`, `function __s5k6a3_power_on`, `function __s5k6a3_power_off`, `function s5k6a3_s_power`, `function s5k6a3_probe`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.