drivers/video/fbdev/riva/rivafb-i2c.c
Source file repositories/reference/linux-study-clean/drivers/video/fbdev/riva/rivafb-i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/fbdev/riva/rivafb-i2c.c- Extension
.c- Size
- 3690 bytes
- Lines
- 167
- Domain
- Driver Families
- Bucket
- drivers/video
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/delay.hlinux/pci.hlinux/fb.hlinux/jiffies.hasm/io.hrivafb.h../edid.h
Detected Declarations
function riva_gpio_setsclfunction riva_gpio_setsdafunction riva_gpio_getsclfunction riva_gpio_getsdafunction riva_setup_i2c_busfunction riva_create_i2c_bussesfunction riva_delete_i2c_bussesfunction riva_probe_i2c_connector
Annotated Snippet
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/pci.h>
#include <linux/fb.h>
#include <linux/jiffies.h>
#include <asm/io.h>
#include "rivafb.h"
#include "../edid.h"
static void riva_gpio_setscl(void* data, int state)
{
struct riva_i2c_chan *chan = data;
struct riva_par *par = chan->par;
u32 val;
VGA_WR08(par->riva.PCIO, 0x3d4, chan->ddc_base + 1);
val = VGA_RD08(par->riva.PCIO, 0x3d5) & 0xf0;
if (state)
val |= 0x20;
else
val &= ~0x20;
VGA_WR08(par->riva.PCIO, 0x3d4, chan->ddc_base + 1);
VGA_WR08(par->riva.PCIO, 0x3d5, val | 0x1);
}
static void riva_gpio_setsda(void* data, int state)
{
struct riva_i2c_chan *chan = data;
struct riva_par *par = chan->par;
u32 val;
VGA_WR08(par->riva.PCIO, 0x3d4, chan->ddc_base + 1);
val = VGA_RD08(par->riva.PCIO, 0x3d5) & 0xf0;
if (state)
val |= 0x10;
else
val &= ~0x10;
VGA_WR08(par->riva.PCIO, 0x3d4, chan->ddc_base + 1);
VGA_WR08(par->riva.PCIO, 0x3d5, val | 0x1);
}
static int riva_gpio_getscl(void* data)
{
struct riva_i2c_chan *chan = data;
struct riva_par *par = chan->par;
u32 val = 0;
VGA_WR08(par->riva.PCIO, 0x3d4, chan->ddc_base);
if (VGA_RD08(par->riva.PCIO, 0x3d5) & 0x04)
val = 1;
return val;
}
static int riva_gpio_getsda(void* data)
{
struct riva_i2c_chan *chan = data;
struct riva_par *par = chan->par;
u32 val = 0;
VGA_WR08(par->riva.PCIO, 0x3d4, chan->ddc_base);
if (VGA_RD08(par->riva.PCIO, 0x3d5) & 0x08)
val = 1;
return val;
}
static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name,
unsigned int i2c_class)
{
int rc;
strscpy(chan->adapter.name, name);
chan->adapter.owner = THIS_MODULE;
chan->adapter.class = i2c_class;
chan->adapter.algo_data = &chan->algo;
chan->adapter.dev.parent = &chan->par->pdev->dev;
chan->algo.setsda = riva_gpio_setsda;
chan->algo.setscl = riva_gpio_setscl;
chan->algo.getsda = riva_gpio_getsda;
chan->algo.getscl = riva_gpio_getscl;
chan->algo.udelay = 40;
chan->algo.timeout = msecs_to_jiffies(2);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/delay.h`, `linux/pci.h`, `linux/fb.h`, `linux/jiffies.h`, `asm/io.h`, `rivafb.h`.
- Detected declarations: `function riva_gpio_setscl`, `function riva_gpio_setsda`, `function riva_gpio_getscl`, `function riva_gpio_getsda`, `function riva_setup_i2c_bus`, `function riva_create_i2c_busses`, `function riva_delete_i2c_busses`, `function riva_probe_i2c_connector`.
- Atlas domain: Driver Families / drivers/video.
- 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.