drivers/media/i2c/saa6588.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/saa6588.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/saa6588.c- Extension
.c- Size
- 12282 bytes
- Lines
- 513
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/kernel.hlinux/i2c.hlinux/types.hlinux/videodev2.hlinux/init.hlinux/errno.hlinux/slab.hlinux/poll.hlinux/wait.hlinux/uaccess.hmedia/i2c/saa6588.hmedia/v4l2-device.h
Detected Declarations
struct saa6588function block_from_buffunction read_from_buffunction block_to_buffunction saa6588_i2c_pollfunction saa6588_workfunction saa6588_configurefunction saa6588_commandfunction saa6588_g_tunerfunction saa6588_s_tunerfunction saa6588_probefunction saa6588_remove
Annotated Snippet
struct saa6588 {
struct v4l2_subdev sd;
struct delayed_work work;
spinlock_t lock;
unsigned char *buffer;
unsigned int buf_size;
unsigned int rd_index;
unsigned int wr_index;
unsigned int block_count;
unsigned char last_blocknum;
wait_queue_head_t read_queue;
int data_available_for_read;
u8 sync;
};
static inline struct saa6588 *to_saa6588(struct v4l2_subdev *sd)
{
return container_of(sd, struct saa6588, sd);
}
/* ---------------------------------------------------------------------- */
/*
* SAA6588 defines
*/
/* Initialization and mode control byte (0w) */
/* bit 0+1 (DAC0/DAC1) */
#define cModeStandard 0x00
#define cModeFastPI 0x01
#define cModeReducedRequest 0x02
#define cModeInvalid 0x03
/* bit 2 (RBDS) */
#define cProcessingModeRDS 0x00
#define cProcessingModeRBDS 0x04
/* bit 3+4 (SYM0/SYM1) */
#define cErrCorrectionNone 0x00
#define cErrCorrection2Bits 0x08
#define cErrCorrection5Bits 0x10
#define cErrCorrectionNoneRBDS 0x18
/* bit 5 (NWSY) */
#define cSyncNormal 0x00
#define cSyncRestart 0x20
/* bit 6 (TSQD) */
#define cSigQualityDetectOFF 0x00
#define cSigQualityDetectON 0x40
/* bit 7 (SQCM) */
#define cSigQualityTriggered 0x00
#define cSigQualityContinous 0x80
/* Pause level and flywheel control byte (1w) */
/* bits 0..5 (FEB0..FEB5) */
#define cFlywheelMaxBlocksMask 0x3F
#define cFlywheelDefault 0x20
/* bits 6+7 (PL0/PL1) */
#define cPauseLevel_11mV 0x00
#define cPauseLevel_17mV 0x40
#define cPauseLevel_27mV 0x80
#define cPauseLevel_43mV 0xC0
/* Pause time/oscillator frequency/quality detector control byte (1w) */
/* bits 0..4 (SQS0..SQS4) */
#define cQualityDetectSensMask 0x1F
#define cQualityDetectDefault 0x0F
/* bit 5 (SOSC) */
#define cSelectOscFreqOFF 0x00
#define cSelectOscFreqON 0x20
/* bit 6+7 (PTF0/PTF1) */
#define cOscFreq_4332kHz 0x00
#define cOscFreq_8664kHz 0x40
#define cOscFreq_12996kHz 0x80
#define cOscFreq_17328kHz 0xC0
/* ---------------------------------------------------------------------- */
static bool block_from_buf(struct saa6588 *s, unsigned char *buf)
{
int i;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/i2c.h`, `linux/types.h`, `linux/videodev2.h`, `linux/init.h`, `linux/errno.h`, `linux/slab.h`.
- Detected declarations: `struct saa6588`, `function block_from_buf`, `function read_from_buf`, `function block_to_buf`, `function saa6588_i2c_poll`, `function saa6588_work`, `function saa6588_configure`, `function saa6588_command`, `function saa6588_g_tuner`, `function saa6588_s_tuner`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.