drivers/media/radio/si4713/si4713.c
Source file repositories/reference/linux-study-clean/drivers/media/radio/si4713/si4713.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/radio/si4713/si4713.c- Extension
.c- Size
- 42680 bytes
- Lines
- 1666
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/completion.hlinux/delay.hlinux/err.hlinux/interrupt.hlinux/i2c.hlinux/slab.hlinux/gpio/consumer.hlinux/module.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/v4l2-common.hsi4713.h
Detected Declarations
function usecs_to_devfunction si4713_handlerfunction si4713_send_commandfunction si4713_read_propertyfunction si4713_write_propertyfunction si4713_powerupfunction si4713_powerdownfunction si4713_checkrevfunction si4713_wait_stcfunction si4713_tx_tune_freqfunction si4713_tx_tune_powerfunction si4713_tx_tune_measurefunction si4713_tx_tune_statusfunction si4713_tx_rds_bufffunction si4713_tx_rds_psfunction si4713_set_power_statefunction si4713_set_mutefunction si4713_set_rds_ps_namefunction si4713_set_rds_radio_textfunction si4713_update_tune_statusfunction si4713_choose_econtrol_actionfunction si4713_setupfunction si4713_initializefunction si4713_s_ctrlfunction si4713_ioctlfunction si4713_g_modulatorfunction si4713_s_modulatorfunction si4713_g_frequencyfunction si4713_s_frequencyfunction si4713_probefunction si4713_remove
Annotated Snippet
if (array[(i * 2) + 1] >= usecs) {
rval = array[i * 2];
break;
}
return rval;
}
/* si4713_handler: IRQ handler, just complete work */
static irqreturn_t si4713_handler(int irq, void *dev)
{
struct si4713_device *sdev = dev;
v4l2_dbg(2, debug, &sdev->sd,
"%s: sending signal to completion work.\n", __func__);
complete(&sdev->work);
return IRQ_HANDLED;
}
/*
* si4713_send_command - sends a command to si4713 and waits its response
* @sdev: si4713_device structure for the device we are communicating
* @command: command id
* @args: command arguments we are sending (up to 7)
* @argn: actual size of @args
* @response: buffer to place the expected response from the device (up to 15)
* @respn: actual size of @response
* @usecs: amount of time to wait before reading the response (in usecs)
*/
static int si4713_send_command(struct si4713_device *sdev, const u8 command,
const u8 args[], const int argn,
u8 response[], const int respn, const int usecs)
{
struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
unsigned long until_jiffies;
u8 data1[MAX_ARGS + 1];
int err;
if (!client->adapter)
return -ENODEV;
/* First send the command and its arguments */
data1[0] = command;
memcpy(data1 + 1, args, argn);
DBG_BUFFER(&sdev->sd, "Parameters", data1, argn + 1);
err = i2c_master_send(client, data1, argn + 1);
if (err != argn + 1) {
v4l2_err(&sdev->sd, "Error while sending command 0x%02x\n",
command);
return err < 0 ? err : -EIO;
}
until_jiffies = jiffies + usecs_to_jiffies(usecs) + 1;
/* Wait response from interrupt */
if (client->irq) {
if (!wait_for_completion_timeout(&sdev->work,
usecs_to_jiffies(usecs) + 1))
v4l2_warn(&sdev->sd,
"(%s) Device took too much time to answer.\n",
__func__);
}
do {
err = i2c_master_recv(client, response, respn);
if (err != respn) {
v4l2_err(&sdev->sd,
"Error %d while reading response for command 0x%02x\n",
err, command);
return err < 0 ? err : -EIO;
}
DBG_BUFFER(&sdev->sd, "Response", response, respn);
if (!check_command_failed(response[0]))
return 0;
if (client->irq)
return -EBUSY;
if (usecs <= 1000)
usleep_range(usecs, 1000);
else
usleep_range(1000, 2000);
} while (time_is_after_jiffies(until_jiffies));
return -EBUSY;
}
/*
Annotation
- Immediate include surface: `linux/completion.h`, `linux/delay.h`, `linux/err.h`, `linux/interrupt.h`, `linux/i2c.h`, `linux/slab.h`, `linux/gpio/consumer.h`, `linux/module.h`.
- Detected declarations: `function usecs_to_dev`, `function si4713_handler`, `function si4713_send_command`, `function si4713_read_property`, `function si4713_write_property`, `function si4713_powerup`, `function si4713_powerdown`, `function si4713_checkrev`, `function si4713_wait_stc`, `function si4713_tx_tune_freq`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.