drivers/media/pci/zoran/zoran_device.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/zoran/zoran_device.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/zoran/zoran_device.c- Extension
.c- Size
- 26325 bytes
- Lines
- 957
- 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.
- 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
linux/types.hlinux/kernel.hlinux/module.hlinux/interrupt.hlinux/i2c.hlinux/i2c-algo-bit.hlinux/videodev2.hmedia/v4l2-common.hlinux/spinlock.hlinux/pci.hlinux/delay.hlinux/wait.hlinux/dma-mapping.hlinux/io.hvideocodec.hzoran.hzoran_device.hzoran_card.h
Detected Declarations
function zr36057_init_vfefunction GPIOfunction post_office_waitfunction post_office_writefunction post_office_readfunction jpeg_codec_sleepfunction jpeg_codec_resetfunction zr36057_adjust_vfefunction zr36057_set_vfefunction zr36057_set_memgrabfunction set_framefunction set_videobus_dirfunction init_jpeg_queuefunction zr36057_set_jpgfunction clear_interrupt_countersfunction count_reset_interruptfunction jpeg_startfunction zr36057_enable_jpgfunction zoran_feed_stat_comfunction zoran_reap_stat_comfunction zoran_irqfunction zoran_set_pci_masterfunction zoran_init_hardwarefunction zr36057_restart
Annotated Snippet
if (isr & ZR36057_ISR_GIRQ1) {
btwrite(ZR36057_ISR_GIRQ1, ZR36057_ISR);
zr->intr_counter_GIRQ1++;
}
if (isr & ZR36057_ISR_GIRQ0) {
btwrite(ZR36057_ISR_GIRQ0, ZR36057_ISR);
zr->intr_counter_GIRQ0++;
}
if (isr & ZR36057_ISR_COD_REP_IRQ) {
btwrite(ZR36057_ISR_COD_REP_IRQ, ZR36057_ISR);
zr->intr_counter_cod_rep_irq++;
}
if (isr & ZR36057_ISR_JPEG_REP_IRQ) {
btwrite(ZR36057_ISR_JPEG_REP_IRQ, ZR36057_ISR);
zr->intr_counter_jpeg_rep_irq++;
}
}
return isr;
}
void jpeg_start(struct zoran *zr)
{
int reg;
zr->frame_num = 0;
/* deassert P_reset, disable code transfer, deassert Active */
btwrite(ZR36057_JPC_P_RESET, ZR36057_JPC);
/* stop flushing the internal code buffer */
btand(~ZR36057_MCTCR_C_FLUSH, ZR36057_MCTCR);
/* enable code transfer */
btor(ZR36057_JPC_COD_TRNS_EN, ZR36057_JPC);
/* clear IRQs */
btwrite(IRQ_MASK, ZR36057_ISR);
/* enable the JPEG IRQs */
btwrite(zr->card.jpeg_int | ZR36057_ICR_JPEG_REP_IRQ | ZR36057_ICR_INT_PIN_EN,
ZR36057_ICR);
set_frame(zr, 0); // \FRAME
/* set the JPEG codec guest ID */
reg = (zr->card.gpcs[1] << ZR36057_JCGI_JPE_GUEST_ID) |
(0 << ZR36057_JCGI_JPE_GUEST_REG);
btwrite(reg, ZR36057_JCGI);
if (zr->card.video_vfe == CODEC_TYPE_ZR36016 &&
zr->card.video_codec == CODEC_TYPE_ZR36050) {
/* Enable processing on the ZR36016 */
if (zr->vfe)
zr36016_write(zr->vfe, 0, 1);
/* load the address of the GO register in the ZR36050 latch */
post_office_write(zr, 0, 0, 0);
}
/* assert Active */
btor(ZR36057_JPC_ACTIVE, ZR36057_JPC);
/* enable the Go generation */
btor(ZR36057_JMC_GO_EN, ZR36057_JMC);
usleep_range(30, 100);
set_frame(zr, 1); // /FRAME
}
void zr36057_enable_jpg(struct zoran *zr, enum zoran_codec_mode mode)
{
struct vfe_settings cap;
int field_size = zr->buffer_size / zr->jpg_settings.field_per_buff;
zr->codec_mode = mode;
cap.x = zr->jpg_settings.img_x;
cap.y = zr->jpg_settings.img_y;
cap.width = zr->jpg_settings.img_width;
cap.height = zr->jpg_settings.img_height;
cap.decimation =
zr->jpg_settings.hor_dcm | (zr->jpg_settings.ver_dcm << 8);
cap.quality = zr->jpg_settings.jpg_comp.quality;
switch (mode) {
case BUZ_MODE_MOTION_COMPRESS: {
struct jpeg_app_marker app;
struct jpeg_com_marker com;
/* In motion compress mode, the decoder output must be enabled, and
* the video bus direction set to input.
*/
set_videobus_dir(zr, 0);
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/module.h`, `linux/interrupt.h`, `linux/i2c.h`, `linux/i2c-algo-bit.h`, `linux/videodev2.h`, `media/v4l2-common.h`.
- Detected declarations: `function zr36057_init_vfe`, `function GPIO`, `function post_office_wait`, `function post_office_write`, `function post_office_read`, `function jpeg_codec_sleep`, `function jpeg_codec_reset`, `function zr36057_adjust_vfe`, `function zr36057_set_vfe`, `function zr36057_set_memgrab`.
- 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.
- 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.