drivers/media/i2c/msp3400-driver.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/msp3400-driver.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/msp3400-driver.c- Extension
.c- Size
- 25967 bytes
- Lines
- 893
- 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/kernel.hlinux/module.hlinux/slab.hlinux/i2c.hlinux/kthread.hlinux/freezer.hlinux/videodev2.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/drv-intf/msp3400.hmedia/i2c/tvaudio.hmsp3400-driver.h
Detected Declarations
function msp_resetfunction i2c_transferfunction msp_readfunction msp_read_demfunction msp_read_dspfunction msp_writefunction msp_write_demfunction msp_write_dspfunction msp_set_scartfunction msp_wake_threadfunction msp_sleepfunction msp_s_ctrlfunction msp_update_volumefunction msp_s_radiofunction msp_s_frequencyfunction msp_querystdfunction msp_s_stdfunction msp_s_routingfunction msp_g_tunerfunction msp_s_tunerfunction msp_s_i2s_clock_freqfunction msp_log_statusfunction msp_suspendfunction msp_resumefunction msp_probefunction msp_remove
Annotated Snippet
i2c_transfer(client->adapter, test, 2) != 2) {
dev_err(&client->dev, "chip reset failed\n");
return -1;
}
return 0;
}
static int msp_read(struct i2c_client *client, int dev, int addr)
{
int err, retval;
u8 write[3];
u8 read[2];
struct i2c_msg msgs[2] = {
{
.addr = client->addr,
.len = 3,
.buf = write
},
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = 2,
.buf = read
}
};
write[0] = dev + 1;
write[1] = addr >> 8;
write[2] = addr & 0xff;
for (err = 0; err < 3; err++) {
if (i2c_transfer(client->adapter, msgs, 2) == 2)
break;
dev_warn(&client->dev, "I/O error #%d (read 0x%02x/0x%02x)\n", err,
dev, addr);
schedule_timeout_interruptible(msecs_to_jiffies(10));
}
if (err == 3) {
dev_warn(&client->dev, "resetting chip, sound will go off.\n");
msp_reset(client);
return -1;
}
retval = read[0] << 8 | read[1];
dev_dbg_lvl(&client->dev, 3, msp_debug, "msp_read(0x%x, 0x%x): 0x%x\n",
dev, addr, retval);
return retval;
}
int msp_read_dem(struct i2c_client *client, int addr)
{
return msp_read(client, I2C_MSP_DEM, addr);
}
int msp_read_dsp(struct i2c_client *client, int addr)
{
return msp_read(client, I2C_MSP_DSP, addr);
}
static int msp_write(struct i2c_client *client, int dev, int addr, int val)
{
int err;
u8 buffer[5];
buffer[0] = dev;
buffer[1] = addr >> 8;
buffer[2] = addr & 0xff;
buffer[3] = val >> 8;
buffer[4] = val & 0xff;
dev_dbg_lvl(&client->dev, 3, msp_debug, "msp_write(0x%x, 0x%x, 0x%x)\n",
dev, addr, val);
for (err = 0; err < 3; err++) {
if (i2c_master_send(client, buffer, 5) == 5)
break;
dev_warn(&client->dev, "I/O error #%d (write 0x%02x/0x%02x)\n", err,
dev, addr);
schedule_timeout_interruptible(msecs_to_jiffies(10));
}
if (err == 3) {
dev_warn(&client->dev, "resetting chip, sound will go off.\n");
msp_reset(client);
return -1;
}
return 0;
}
int msp_write_dem(struct i2c_client *client, int addr, int val)
{
return msp_write(client, I2C_MSP_DEM, addr, val);
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/i2c.h`, `linux/kthread.h`, `linux/freezer.h`, `linux/videodev2.h`, `media/v4l2-device.h`.
- Detected declarations: `function msp_reset`, `function i2c_transfer`, `function msp_read`, `function msp_read_dem`, `function msp_read_dsp`, `function msp_write`, `function msp_write_dem`, `function msp_write_dsp`, `function msp_set_scart`, `function msp_wake_thread`.
- 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.