drivers/media/pci/mantis/mantis_ioc.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/mantis/mantis_ioc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/mantis/mantis_ioc.c- Extension
.c- Size
- 2596 bytes
- Lines
- 113
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/i2c.hlinux/signal.hlinux/sched.hlinux/interrupt.hasm/io.hmedia/dmxdev.hmedia/dvbdev.hmedia/dvb_demux.hmedia/dvb_frontend.hmedia/dvb_net.hmantis_common.hmantis_reg.hmantis_ioc.h
Detected Declarations
function Copyrightfunction mantis_get_macfunction mantis_gpio_set_bitsfunction mantis_stream_controlexport mantis_get_macexport mantis_gpio_set_bitsexport mantis_stream_control
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
Mantis PCI bridge driver
Copyright (C) Manu Abraham (abraham.manu@gmail.com)
*/
#include <linux/kernel.h>
#include <linux/i2c.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#include <media/dmxdev.h>
#include <media/dvbdev.h>
#include <media/dvb_demux.h>
#include <media/dvb_frontend.h>
#include <media/dvb_net.h>
#include "mantis_common.h"
#include "mantis_reg.h"
#include "mantis_ioc.h"
static int read_eeprom_bytes(struct mantis_pci *mantis, u8 reg, u8 *data, u8 length)
{
struct i2c_adapter *adapter = &mantis->adapter;
int err;
u8 buf = reg;
struct i2c_msg msg[] = {
{ .addr = 0x50, .flags = 0, .buf = &buf, .len = 1 },
{ .addr = 0x50, .flags = I2C_M_RD, .buf = data, .len = length },
};
err = i2c_transfer(adapter, msg, 2);
if (err < 0) {
dprintk(MANTIS_ERROR, 1, "ERROR: i2c read: < err=%i d0=0x%02x d1=0x%02x >",
err, data[0], data[1]);
return err;
}
return 0;
}
int mantis_get_mac(struct mantis_pci *mantis)
{
int err;
u8 mac_addr[6] = {0};
err = read_eeprom_bytes(mantis, 0x08, mac_addr, 6);
if (err < 0) {
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis EEPROM read error <%d>", err);
return err;
}
dprintk(MANTIS_ERROR, 0, " MAC Address=[%pM]\n", mac_addr);
return 0;
}
EXPORT_SYMBOL_GPL(mantis_get_mac);
/* Turn the given bit on or off. */
void mantis_gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value)
{
u32 cur;
dprintk(MANTIS_DEBUG, 1, "Set Bit <%d> to <%d>", bitpos, value);
cur = mmread(MANTIS_GPIF_ADDR);
if (value)
mantis->gpio_status = cur | (1 << bitpos);
else
mantis->gpio_status = cur & (~(1 << bitpos));
dprintk(MANTIS_DEBUG, 1, "GPIO Value <%02x>", mantis->gpio_status);
mmwrite(mantis->gpio_status, MANTIS_GPIF_ADDR);
mmwrite(0x00, MANTIS_GPIF_DOUT);
}
EXPORT_SYMBOL_GPL(mantis_gpio_set_bits);
int mantis_stream_control(struct mantis_pci *mantis, enum mantis_stream_control stream_ctl)
{
u32 reg;
reg = mmread(MANTIS_CONTROL);
switch (stream_ctl) {
case STREAM_TO_HIF:
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/i2c.h`, `linux/signal.h`, `linux/sched.h`, `linux/interrupt.h`, `asm/io.h`, `media/dmxdev.h`, `media/dvbdev.h`.
- Detected declarations: `function Copyright`, `function mantis_get_mac`, `function mantis_gpio_set_bits`, `function mantis_stream_control`, `export mantis_get_mac`, `export mantis_gpio_set_bits`, `export mantis_stream_control`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.