drivers/media/pci/ivtv/ivtv-firmware.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/ivtv/ivtv-firmware.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/ivtv/ivtv-firmware.c- Extension
.c- Size
- 11333 bytes
- Lines
- 391
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ivtv-driver.hivtv-mailbox.hivtv-firmware.hivtv-yuv.hivtv-ioctl.hivtv-cards.hlinux/firmware.hmedia/i2c/saa7127.h
Detected Declarations
function Copyrightfunction ivtv_halt_firmwarefunction ivtv_firmware_versionsfunction ivtv_firmware_copyfunction ivtv_firmware_initfunction ivtv_init_mpeg_decoderfunction ivtv_firmware_restartfunction ivtv_firmware_check
Annotated Snippet
if (fw->size != size) {
/* Due to race conditions in firmware loading (esp. with udev <0.95)
the wrong file was sometimes loaded. So we check filesizes to
see if at least the right-sized file was loaded. If not, then we
retry. */
IVTV_INFO("Retry: file loaded was not %s (expected size %ld, got %zu)\n", fn, size, fw->size);
release_firmware(fw);
retries--;
goto retry;
}
for (i = 0; i < fw->size; i += 4) {
/* no need for endianness conversion on the ppc */
__raw_writel(*src, dst);
dst++;
src++;
}
IVTV_INFO("Loaded %s firmware (%zu bytes)\n", fn, fw->size);
release_firmware(fw);
return size;
}
IVTV_ERR("Unable to open firmware %s (must be %ld bytes)\n", fn, size);
IVTV_ERR("Did you put the firmware in the hotplug firmware directory?\n");
return -ENOMEM;
}
void ivtv_halt_firmware(struct ivtv *itv)
{
IVTV_DEBUG_INFO("Preparing for firmware halt.\n");
if (itv->has_cx23415 && itv->dec_mbox.mbox)
ivtv_vapi(itv, CX2341X_DEC_HALT_FW, 0);
if (itv->enc_mbox.mbox)
ivtv_vapi(itv, CX2341X_ENC_HALT_FW, 0);
ivtv_msleep_timeout(10, 0);
itv->enc_mbox.mbox = itv->dec_mbox.mbox = NULL;
IVTV_DEBUG_INFO("Stopping VDM\n");
write_reg(IVTV_CMD_VDM_STOP, IVTV_REG_VDM);
IVTV_DEBUG_INFO("Stopping AO\n");
write_reg(IVTV_CMD_AO_STOP, IVTV_REG_AO);
IVTV_DEBUG_INFO("pinging (?) APU\n");
write_reg(IVTV_CMD_APU_PING, IVTV_REG_APU);
IVTV_DEBUG_INFO("Stopping VPU\n");
if (!itv->has_cx23415)
write_reg(IVTV_CMD_VPU_STOP16, IVTV_REG_VPU);
else
write_reg(IVTV_CMD_VPU_STOP15, IVTV_REG_VPU);
IVTV_DEBUG_INFO("Resetting Hw Blocks\n");
write_reg(IVTV_CMD_HW_BLOCKS_RST, IVTV_REG_HW_BLOCKS);
IVTV_DEBUG_INFO("Stopping SPU\n");
write_reg(IVTV_CMD_SPU_STOP, IVTV_REG_SPU);
ivtv_msleep_timeout(10, 0);
IVTV_DEBUG_INFO("init Encoder SDRAM pre-charge\n");
write_reg(IVTV_CMD_SDRAM_PRECHARGE_INIT, IVTV_REG_ENC_SDRAM_PRECHARGE);
IVTV_DEBUG_INFO("init Encoder SDRAM refresh to 1us\n");
write_reg(IVTV_CMD_SDRAM_REFRESH_INIT, IVTV_REG_ENC_SDRAM_REFRESH);
if (itv->has_cx23415) {
IVTV_DEBUG_INFO("init Decoder SDRAM pre-charge\n");
write_reg(IVTV_CMD_SDRAM_PRECHARGE_INIT, IVTV_REG_DEC_SDRAM_PRECHARGE);
IVTV_DEBUG_INFO("init Decoder SDRAM refresh to 1us\n");
write_reg(IVTV_CMD_SDRAM_REFRESH_INIT, IVTV_REG_DEC_SDRAM_REFRESH);
}
IVTV_DEBUG_INFO("Sleeping for %dms\n", IVTV_SDRAM_SLEEPTIME);
ivtv_msleep_timeout(IVTV_SDRAM_SLEEPTIME, 0);
}
void ivtv_firmware_versions(struct ivtv *itv)
{
u32 data[CX2341X_MBOX_MAX_DATA];
/* Encoder */
ivtv_vapi_result(itv, data, CX2341X_ENC_GET_VERSION, 0);
IVTV_INFO("Encoder revision: 0x%08x\n", data[0]);
if (data[0] != 0x02060039)
IVTV_WARN("Recommended firmware version is 0x02060039.\n");
if (itv->has_cx23415) {
/* Decoder */
Annotation
- Immediate include surface: `ivtv-driver.h`, `ivtv-mailbox.h`, `ivtv-firmware.h`, `ivtv-yuv.h`, `ivtv-ioctl.h`, `ivtv-cards.h`, `linux/firmware.h`, `media/i2c/saa7127.h`.
- Detected declarations: `function Copyright`, `function ivtv_halt_firmware`, `function ivtv_firmware_versions`, `function ivtv_firmware_copy`, `function ivtv_firmware_init`, `function ivtv_init_mpeg_decoder`, `function ivtv_firmware_restart`, `function ivtv_firmware_check`.
- 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.