drivers/media/pci/zoran/zr36060.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/zoran/zr36060.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/zoran/zr36060.c- Extension
.c- Size
- 27553 bytes
- Lines
- 871
- 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/module.hlinux/init.hlinux/slab.hlinux/delay.hlinux/types.hlinux/wait.hlinux/io.hzr36060.hvideocodec.h
Detected Declarations
function zr36060_readfunction zr36060_writefunction zr36060_read_statusfunction zr36060_read_scalefactorfunction zr36060_wait_endfunction zr36060_basic_testfunction zr36060_pushitfunction SOFfunction zr36060_set_sosfunction zr36060_set_drifunction zr36060_initfunction zr36060_set_modefunction zr36060_set_videofunction zr36060_controlfunction zr36060_unsetfunction zr36060_setupfunction zr36060_init_modulefunction zr36060_cleanup_module
Annotated Snippet
if (i++ > 200000) { // 200ms, there is for sure something wrong!!!
zrdev_dbg(zr,
"%s: timeout at wait_end (last status: 0x%02x)\n",
ptr->name, ptr->status);
break;
}
}
}
/* Basic test of "connectivity", writes/reads to/from memory the SOF marker */
static int zr36060_basic_test(struct zr36060 *ptr)
{
struct zoran *zr = videocodec_to_zoran(ptr->codec);
if ((zr36060_read(ptr, ZR060_IDR_DEV) != 0x33) &&
(zr36060_read(ptr, ZR060_IDR_REV) != 0x01)) {
zrdev_err(zr, "%s: attach failed, can't connect to jpeg processor!\n", ptr->name);
return -ENXIO;
}
zr36060_wait_end(ptr);
if (ptr->status & ZR060_CFSR_BUSY) {
zrdev_err(zr, "%s: attach failed, jpeg processor failed (end flag)!\n", ptr->name);
return -EBUSY;
}
return 0; /* looks good! */
}
/* simple loop for pushing the init datasets */
static int zr36060_pushit(struct zr36060 *ptr, u16 startreg, u16 len, const char *data)
{
struct zoran *zr = videocodec_to_zoran(ptr->codec);
int i = 0;
zrdev_dbg(zr, "%s: write data block to 0x%04x (len=%d)\n", ptr->name,
startreg, len);
while (i < len)
zr36060_write(ptr, startreg++, data[i++]);
return i;
}
/* =========================================================================
* Basic datasets:
* jpeg baseline setup data (you find it on lots places in internet, or just
* extract it from any regular .jpg image...)
*
* Could be variable, but until it's not needed it they are just fixed to save
* memory. Otherwise expand zr36060 structure with arrays, push the values to
* it and initialize from there, as e.g. the linux zr36057/60 driver does it.
* =========================================================================
*/
static const char zr36060_dqt[0x86] = {
0xff, 0xdb, //Marker: DQT
0x00, 0x84, //Length: 2*65+2
0x00, //Pq,Tq first table
0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e,
0x0d, 0x0e, 0x12, 0x11, 0x10, 0x13, 0x18, 0x28,
0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23, 0x25,
0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 0x39, 0x33,
0x38, 0x37, 0x40, 0x48, 0x5c, 0x4e, 0x40, 0x44,
0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 0x51, 0x57,
0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71,
0x79, 0x70, 0x64, 0x78, 0x5c, 0x65, 0x67, 0x63,
0x01, //Pq,Tq second table
0x11, 0x12, 0x12, 0x18, 0x15, 0x18, 0x2f, 0x1a,
0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42, 0x63, 0x63,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63
};
static const char zr36060_dht[0x1a4] = {
0xff, 0xc4, //Marker: DHT
0x01, 0xa2, //Length: 2*AC, 2*DC
0x00, //DC first table
0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
0x01, //DC second table
0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
0x10, //AC first table
0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03,
0x05, 0x05, 0x04, 0x04, 0x00, 0x00,
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/delay.h`, `linux/types.h`, `linux/wait.h`, `linux/io.h`, `zr36060.h`.
- Detected declarations: `function zr36060_read`, `function zr36060_write`, `function zr36060_read_status`, `function zr36060_read_scalefactor`, `function zr36060_wait_end`, `function zr36060_basic_test`, `function zr36060_pushit`, `function SOF`, `function zr36060_set_sos`, `function zr36060_set_dri`.
- 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.