drivers/media/pci/cx88/cx88-core.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/cx88/cx88-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/cx88/cx88-core.c- Extension
.c- Size
- 30245 bytes
- Lines
- 1100
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
cx88.hlinux/init.hlinux/list.hlinux/module.hlinux/kernel.hlinux/slab.hlinux/kmod.hlinux/sound.hlinux/interrupt.hlinux/pci.hlinux/delay.hlinux/videodev2.hlinux/mutex.hmedia/v4l2-common.hmedia/v4l2-ioctl.h
Detected Declarations
function cx88_risc_bufferfunction cx88_risc_databufferfunction cx88_sram_channel_setupfunction cx88_risc_decodefunction cx88_sram_channel_dumpfunction cx88_print_irqbitsfunction cx88_core_irqfunction cx88_wakeupfunction cx88_shutdownfunction cx88_resetfunction norm_swidthfunction norm_hdelayfunction norm_vdelayfunction norm_fsc8function norm_htotalfunction norm_vbipackfunction cx88_set_scalefunction set_pllfunction cx88_start_audio_dmafunction cx88_stop_audio_dmafunction set_tvaudiofunction cx88_set_tvnormfunction cx88_vdev_initfunction cx88_core_putexport cx88_risc_bufferexport cx88_risc_databufferexport cx88_sram_channelsexport cx88_sram_channel_setupexport cx88_sram_channel_dumpexport cx88_print_irqbitsexport cx88_core_irqexport cx88_wakeupexport cx88_shutdownexport cx88_resetexport cx88_set_scaleexport cx88_set_tvnormexport cx88_vdev_initexport cx88_core_getexport cx88_core_put
Annotated Snippet
while (offset && offset >= sg_dma_len(sg)) {
offset -= sg_dma_len(sg);
sg = sg_next(sg);
}
if (lpi && line > 0 && !(line % lpi))
sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC;
else
sol = RISC_SOL;
if (bpl <= sg_dma_len(sg) - offset) {
/* fits into current chunk */
*(rp++) = cpu_to_le32(RISC_WRITE | sol |
RISC_EOL | bpl);
*(rp++) = cpu_to_le32(sg_dma_address(sg) + offset);
offset += bpl;
} else {
/* scanline needs to be split */
todo = bpl;
*(rp++) = cpu_to_le32(RISC_WRITE | sol |
(sg_dma_len(sg) - offset));
*(rp++) = cpu_to_le32(sg_dma_address(sg) + offset);
todo -= (sg_dma_len(sg) - offset);
offset = 0;
sg = sg_next(sg);
while (todo > sg_dma_len(sg)) {
*(rp++) = cpu_to_le32(RISC_WRITE |
sg_dma_len(sg));
*(rp++) = cpu_to_le32(sg_dma_address(sg));
todo -= sg_dma_len(sg);
sg = sg_next(sg);
}
*(rp++) = cpu_to_le32(RISC_WRITE | RISC_EOL | todo);
*(rp++) = cpu_to_le32(sg_dma_address(sg));
offset += todo;
}
offset += padding;
}
return rp;
}
int cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc,
struct scatterlist *sglist,
unsigned int top_offset, unsigned int bottom_offset,
unsigned int bpl, unsigned int padding, unsigned int lines)
{
u32 instructions, fields;
__le32 *rp;
fields = 0;
if (top_offset != UNSET)
fields++;
if (bottom_offset != UNSET)
fields++;
/*
* estimate risc mem: worst case is one write per page border +
* one write per scan line + syncs + jump (all 2 dwords). Padding
* can cause next bpl to start close to a page border. First DMA
* region may be smaller than PAGE_SIZE
*/
instructions = fields * (1 + ((bpl + padding) * lines) /
PAGE_SIZE + lines);
instructions += 4;
risc->size = instructions * 8;
risc->dma = 0;
risc->cpu = dma_alloc_coherent(&pci->dev, risc->size, &risc->dma,
GFP_KERNEL);
if (!risc->cpu)
return -ENOMEM;
/* write risc instructions */
rp = risc->cpu;
if (top_offset != UNSET)
rp = cx88_risc_field(rp, sglist, top_offset, 0,
bpl, padding, lines, 0, true);
if (bottom_offset != UNSET)
rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200,
bpl, padding, lines, 0,
top_offset == UNSET);
/* save pointer to jmp instruction address */
risc->jmp = rp;
WARN_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
return 0;
}
EXPORT_SYMBOL(cx88_risc_buffer);
int cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc,
struct scatterlist *sglist, unsigned int bpl,
unsigned int lines, unsigned int lpi)
Annotation
- Immediate include surface: `cx88.h`, `linux/init.h`, `linux/list.h`, `linux/module.h`, `linux/kernel.h`, `linux/slab.h`, `linux/kmod.h`, `linux/sound.h`.
- Detected declarations: `function cx88_risc_buffer`, `function cx88_risc_databuffer`, `function cx88_sram_channel_setup`, `function cx88_risc_decode`, `function cx88_sram_channel_dump`, `function cx88_print_irqbits`, `function cx88_core_irq`, `function cx88_wakeup`, `function cx88_shutdown`, `function cx88_reset`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.