drivers/media/pci/zoran/zr36050.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/zoran/zr36050.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/zoran/zr36050.c- Extension
.c- Size
- 23836 bytes
- Lines
- 818
- 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.hzr36050.hvideocodec.h
Detected Declarations
function zr36050_readfunction zr36050_writefunction zr36050_read_status1function zr36050_read_scalefactorfunction proceedfunction zr36050_basic_testfunction zr36050_readfunction zr36050_readfunction zr36050_pushitfunction SOFfunction SOSfunction zr36050_set_drifunction zr36050_initfunction zr36050_set_modefunction zr36050_set_videofunction zr36050_controlfunction zr36050_unsetfunction zr36050_setupfunction zr36050_init_modulefunction zr36050_cleanup_module
Annotated Snippet
if (i++ > 200000) { // 200ms, there is for sure something wrong!!!
zrdev_err(zr,
"%s: timeout at wait_end (last status: 0x%02x)\n",
ptr->name, ptr->status1);
break;
}
}
}
/*
* Local helper function: basic test of "connectivity", writes/reads
* to/from memory the SOF marker
*/
static int zr36050_basic_test(struct zr36050 *ptr)
{
struct zoran *zr = videocodec_to_zoran(ptr->codec);
zr36050_write(ptr, ZR050_SOF_IDX, 0x00);
zr36050_write(ptr, ZR050_SOF_IDX + 1, 0x00);
if ((zr36050_read(ptr, ZR050_SOF_IDX) |
zr36050_read(ptr, ZR050_SOF_IDX + 1)) != 0x0000) {
zrdev_err(zr,
"%s: attach failed, can't connect to jpeg processor!\n",
ptr->name);
return -ENXIO;
}
zr36050_write(ptr, ZR050_SOF_IDX, 0xff);
zr36050_write(ptr, ZR050_SOF_IDX + 1, 0xc0);
if (((zr36050_read(ptr, ZR050_SOF_IDX) << 8) |
zr36050_read(ptr, ZR050_SOF_IDX + 1)) != 0xffc0) {
zrdev_err(zr,
"%s: attach failed, can't connect to jpeg processor!\n",
ptr->name);
return -ENXIO;
}
zr36050_wait_end(ptr);
if ((ptr->status1 & 0x4) == 0) {
zrdev_err(zr,
"%s: attach failed, jpeg processor failed (end flag)!\n",
ptr->name);
return -EBUSY;
}
return 0; /* looks good! */
}
/* Local helper function: simple loop for pushing the init datasets */
static int zr36050_pushit(struct zr36050 *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)
zr36050_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 zr36050 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 zr36050_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,
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`, `zr36050.h`.
- Detected declarations: `function zr36050_read`, `function zr36050_write`, `function zr36050_read_status1`, `function zr36050_read_scalefactor`, `function proceed`, `function zr36050_basic_test`, `function zr36050_read`, `function zr36050_read`, `function zr36050_pushit`, `function SOF`.
- 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.