drivers/media/pci/zoran/zr36016.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/zoran/zr36016.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/zoran/zr36016.c- Extension
.c- Size
- 10792 bytes
- Lines
- 407
- 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.hzr36016.hvideocodec.h
Detected Declarations
function zr36016_readfunction zr36016_writefunction zr36016_readifunction zr36016_writeifunction zr36016_read_versionfunction zr36016_basic_testfunction zr36016_initfunction zr36016_set_modefunction zr36016_set_videofunction zr36016_controlfunction zr36016_unsetfunction zr36016_setupfunction zr36016_init_modulefunction zr36016_cleanup_module
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Zoran ZR36016 basic configuration functions
*
* Copyright (C) 2001 Wolfgang Scherr <scherr@net4you.at>
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
/* headerfile of this module */
#include "zr36016.h"
/* codec io API */
#include "videocodec.h"
/*
* it doesn't make sense to have more than 20 or so,
* just to prevent some unwanted loops
*/
#define MAX_CODECS 20
/* amount of chips attached via this driver */
static int zr36016_codecs;
/*
* Local hardware I/O functions: read/write via codec layer
* (registers are located in the master device)
*/
/* read and write functions */
static u8 zr36016_read(struct zr36016 *ptr, u16 reg)
{
u8 value = 0;
struct zoran *zr = videocodec_to_zoran(ptr->codec);
/* just in case something is wrong... */
if (ptr->codec->master_data->readreg)
value = (ptr->codec->master_data->readreg(ptr->codec, reg)) & 0xFF;
else
zrdev_err(zr, "%s: invalid I/O setup, nothing read!\n", ptr->name);
zrdev_dbg(zr, "%s: reading from 0x%04x: %02x\n", ptr->name, reg, value);
return value;
}
static void zr36016_write(struct zr36016 *ptr, u16 reg, u8 value)
{
struct zoran *zr = videocodec_to_zoran(ptr->codec);
zrdev_dbg(zr, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value, reg);
// just in case something is wrong...
if (ptr->codec->master_data->writereg)
ptr->codec->master_data->writereg(ptr->codec, reg, value);
else
zrdev_err(zr, "%s: invalid I/O setup, nothing written!\n", ptr->name);
}
/*
* indirect read and write functions
*
* the 016 supports auto-addr-increment, but
* writing it all time cost not much and is safer...
*/
static u8 zr36016_readi(struct zr36016 *ptr, u16 reg)
{
u8 value = 0;
struct zoran *zr = videocodec_to_zoran(ptr->codec);
/* just in case something is wrong... */
if ((ptr->codec->master_data->writereg) && (ptr->codec->master_data->readreg)) {
ptr->codec->master_data->writereg(ptr->codec, ZR016_IADDR, reg & 0x0F);
value = (ptr->codec->master_data->readreg(ptr->codec, ZR016_IDATA)) & 0xFF;
} else {
zrdev_err(zr, "%s: invalid I/O setup, nothing read (i)!\n", ptr->name);
}
zrdev_dbg(zr, "%s: reading indirect from 0x%04x: %02x\n",
ptr->name, reg, value);
return value;
}
static void zr36016_writei(struct zr36016 *ptr, u16 reg, u8 value)
{
struct zoran *zr = videocodec_to_zoran(ptr->codec);
zrdev_dbg(zr, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name,
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/slab.h`, `zr36016.h`, `videocodec.h`.
- Detected declarations: `function zr36016_read`, `function zr36016_write`, `function zr36016_readi`, `function zr36016_writei`, `function zr36016_read_version`, `function zr36016_basic_test`, `function zr36016_init`, `function zr36016_set_mode`, `function zr36016_set_video`, `function zr36016_control`.
- 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.