drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/atomisp/i2c/atomisp-gc2235.c- Extension
.c- Size
- 19791 bytes
- Lines
- 878
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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/module.hlinux/types.hlinux/kernel.hlinux/mm.hlinux/string.hlinux/errno.hlinux/init.hlinux/kmod.hlinux/device.hlinux/delay.hlinux/slab.hlinux/i2c.hlinux/moduleparam.hmedia/v4l2-device.h../include/linux/atomisp_gmin_platform.hlinux/acpi.hlinux/io.hgc2235.h
Detected Declarations
function Copyrightfunction gc2235_i2c_writefunction gc2235_write_regfunction __gc2235_flush_reg_arrayfunction __gc2235_buf_reg_arrayfunction __gc2235_write_reg_is_consecutivefunction gc2235_write_reg_arrayfunction __gc2235_set_exposurefunction gc2235_set_exposurefunction gc2235_s_exposurefunction gc2235_ioctlfunction gc2235_q_exposurefunction gc2235_g_volatile_ctrlfunction __gc2235_initfunction power_ctrlfunction gpio_ctrlfunction power_upfunction power_downfunction gc2235_s_powerfunction gc2235_startupfunction gc2235_set_fmtfunction gc2235_get_fmtfunction gc2235_detectfunction gc2235_s_streamfunction gc2235_s_configfunction gc2235_get_frame_intervalfunction gc2235_enum_mbus_codefunction gc2235_enum_frame_sizefunction gc2235_g_skip_framesfunction gc2235_removefunction gc2235_probe
Annotated Snippet
switch (next->type & GC2235_TOK_MASK) {
case GC2235_TOK_DELAY:
err = __gc2235_flush_reg_array(client, &ctrl);
if (err)
return err;
msleep(next->val);
break;
default:
/*
* If next address is not consecutive, data needs to be
* flushed before proceed.
*/
if (!__gc2235_write_reg_is_consecutive(client, &ctrl,
next)) {
err = __gc2235_flush_reg_array(client, &ctrl);
if (err)
return err;
}
err = __gc2235_buf_reg_array(client, &ctrl, next);
if (err) {
dev_err(&client->dev, "%s: write error, aborted\n",
__func__);
return err;
}
break;
}
}
return __gc2235_flush_reg_array(client, &ctrl);
}
static long __gc2235_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
int gain, int digitgain)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
u16 coarse_integration = (u16)coarse_itg;
int ret = 0;
u16 expo_coarse_h, expo_coarse_l, gain_val = 0xF0, gain_val2 = 0xF0;
expo_coarse_h = coarse_integration >> 8;
expo_coarse_l = coarse_integration & 0xff;
ret = gc2235_write_reg(client, GC2235_8BIT,
GC2235_EXPOSURE_H, expo_coarse_h);
ret = gc2235_write_reg(client, GC2235_8BIT,
GC2235_EXPOSURE_L, expo_coarse_l);
if (gain <= 0x58) {
gain_val = 0x40;
gain_val2 = 0x58;
} else if (gain < 256) {
gain_val = 0x40;
gain_val2 = gain;
} else {
gain_val2 = 64 * gain / 256;
gain_val = 0xff;
}
ret = gc2235_write_reg(client, GC2235_8BIT,
GC2235_GLOBAL_GAIN, (u8)gain_val);
ret = gc2235_write_reg(client, GC2235_8BIT,
GC2235_PRE_GAIN, (u8)gain_val2);
return ret;
}
static int gc2235_set_exposure(struct v4l2_subdev *sd, int exposure,
int gain, int digitgain)
{
struct gc2235_device *dev = to_gc2235_sensor(sd);
int ret;
mutex_lock(&dev->input_lock);
ret = __gc2235_set_exposure(sd, exposure, gain, digitgain);
mutex_unlock(&dev->input_lock);
return ret;
}
static long gc2235_s_exposure(struct v4l2_subdev *sd,
struct atomisp_exposure *exposure)
{
int exp = exposure->integration_time[0];
int gain = exposure->gain[0];
int digitgain = exposure->gain[1];
/* we should not accept the invalid value below. */
if (gain == 0) {
struct i2c_client *client = v4l2_get_subdevdata(sd);
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/kernel.h`, `linux/mm.h`, `linux/string.h`, `linux/errno.h`, `linux/init.h`, `linux/kmod.h`.
- Detected declarations: `function Copyright`, `function gc2235_i2c_write`, `function gc2235_write_reg`, `function __gc2235_flush_reg_array`, `function __gc2235_buf_reg_array`, `function __gc2235_write_reg_is_consecutive`, `function gc2235_write_reg_array`, `function __gc2235_set_exposure`, `function gc2235_set_exposure`, `function gc2235_s_exposure`.
- Atlas domain: Driver Families / drivers/staging.
- 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.