drivers/media/pci/mantis/mantis_uart.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/mantis/mantis_uart.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/mantis/mantis_uart.c- Extension
.c- Size
- 4093 bytes
- Lines
- 187
- 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/spinlock.hasm/io.hlinux/signal.hlinux/sched.hlinux/interrupt.hlinux/pci.hmedia/dmxdev.hmedia/dvbdev.hmedia/dvb_demux.hmedia/dvb_frontend.hmedia/dvb_net.hmantis_common.hmantis_reg.hmantis_uart.hmantis_input.h
Detected Declarations
struct mantis_uart_paramsfunction mantis_uart_readfunction mantis_uart_workfunction mantis_uart_setupfunction mantis_uart_initfunction mantis_uart_exitexport mantis_uart_initexport mantis_uart_exit
Annotated Snippet
struct mantis_uart_params {
enum mantis_baud baud_rate;
enum mantis_parity parity;
};
static struct {
char string[7];
} rates[5] = {
{ "9600" },
{ "19200" },
{ "38400" },
{ "57600" },
{ "115200" }
};
static struct {
char string[5];
} parity[3] = {
{ "NONE" },
{ "ODD" },
{ "EVEN" }
};
static void mantis_uart_read(struct mantis_pci *mantis)
{
struct mantis_hwconfig *config = mantis->hwconfig;
int i, scancode = 0, err = 0;
/* get data */
dprintk(MANTIS_DEBUG, 1, "UART Reading ...");
for (i = 0; i < (config->bytes + 1); i++) {
int data = mmread(MANTIS_UART_RXD);
dprintk(MANTIS_DEBUG, 0, " <%02x>", data);
scancode = (scancode << 8) | (data & 0x3f);
err |= data;
if (data & (1 << 7))
dprintk(MANTIS_ERROR, 1, "UART framing error");
if (data & (1 << 6))
dprintk(MANTIS_ERROR, 1, "UART parity error");
}
dprintk(MANTIS_DEBUG, 0, "\n");
if ((err & 0xC0) == 0)
mantis_input_process(mantis, scancode);
}
static void mantis_uart_work(struct work_struct *work)
{
struct mantis_pci *mantis = container_of(work, struct mantis_pci, uart_work);
u32 stat;
unsigned long timeout;
stat = mmread(MANTIS_UART_STAT);
if (stat & MANTIS_UART_RXFIFO_FULL)
dprintk(MANTIS_ERROR, 1, "RX Fifo FULL");
/*
* MANTIS_UART_RXFIFO_DATA is only set if at least
* config->bytes + 1 bytes are in the FIFO.
*/
/* FIXME: is 10ms good enough ? */
timeout = jiffies + msecs_to_jiffies(10);
while (stat & MANTIS_UART_RXFIFO_DATA) {
mantis_uart_read(mantis);
stat = mmread(MANTIS_UART_STAT);
if (!time_is_after_jiffies(timeout))
break;
}
/* re-enable UART (RX) interrupt */
mantis_unmask_ints(mantis, MANTIS_INT_IRQ1);
}
static int mantis_uart_setup(struct mantis_pci *mantis,
struct mantis_uart_params *params)
{
u32 reg;
mmwrite((mmread(MANTIS_UART_CTL) | (params->parity & 0x3)), MANTIS_UART_CTL);
reg = mmread(MANTIS_UART_BAUD);
switch (params->baud_rate) {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/spinlock.h`, `asm/io.h`, `linux/signal.h`, `linux/sched.h`, `linux/interrupt.h`, `linux/pci.h`, `media/dmxdev.h`.
- Detected declarations: `struct mantis_uart_params`, `function mantis_uart_read`, `function mantis_uart_work`, `function mantis_uart_setup`, `function mantis_uart_init`, `function mantis_uart_exit`, `export mantis_uart_init`, `export mantis_uart_exit`.
- 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.