sound/pci/oxygen/oxygen_io.c
Source file repositories/reference/linux-study-clean/sound/pci/oxygen/oxygen_io.c
File Facts
- System
- Linux kernel
- Corpus path
sound/pci/oxygen/oxygen_io.c- Extension
.c- Size
- 7511 bytes
- Lines
- 281
- Domain
- Driver Families
- Bucket
- sound/pci
- 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/delay.hlinux/sched.hlinux/export.hlinux/io.hsound/core.hsound/mpu401.hoxygen.h
Detected Declarations
function Copyrightfunction oxygen_read16function oxygen_read32function oxygen_write8function oxygen_write16function oxygen_write32function oxygen_write8_maskedfunction oxygen_write16_maskedfunction oxygen_write32_maskedfunction oxygen_ac97_waitfunction oxygen_write_ac97function oxygen_read_ac97function oxygen_write_ac97_maskedfunction oxygen_wait_spifunction oxygen_write_spifunction oxygen_write_i2cfunction _write_uartfunction oxygen_reset_uartfunction oxygen_write_uartfunction oxygen_read_eepromfunction oxygen_write_eepromexport oxygen_read8export oxygen_read16export oxygen_read32export oxygen_write8export oxygen_write16export oxygen_write32export oxygen_write8_maskedexport oxygen_write16_maskedexport oxygen_write32_maskedexport oxygen_write_ac97export oxygen_read_ac97export oxygen_write_ac97_maskedexport oxygen_write_spiexport oxygen_write_i2cexport oxygen_reset_uartexport oxygen_write_uart
Annotated Snippet
if (oxygen_ac97_wait(chip, OXYGEN_AC97_INT_READ_DONE) >= 0) {
u16 value = oxygen_read16(chip, OXYGEN_AC97_REGS);
/* we require two consecutive reads of the same value */
if (value == last_read)
return value;
last_read = value;
/*
* Invert the register value bits to make sure that two
* consecutive unsuccessful reads do not return the same
* value.
*/
reg ^= 0xffff;
}
}
dev_err(chip->card->dev, "AC'97 read timeout on codec %u\n", codec);
return 0;
}
EXPORT_SYMBOL(oxygen_read_ac97);
void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec,
unsigned int index, u16 data, u16 mask)
{
u16 value = oxygen_read_ac97(chip, codec, index);
value &= ~mask;
value |= data & mask;
oxygen_write_ac97(chip, codec, index, value);
}
EXPORT_SYMBOL(oxygen_write_ac97_masked);
static int oxygen_wait_spi(struct oxygen *chip)
{
unsigned int count;
/*
* Higher timeout to be sure: 200 us;
* actual transaction should not need more than 40 us.
*/
for (count = 50; count > 0; count--) {
udelay(4);
if ((oxygen_read8(chip, OXYGEN_SPI_CONTROL) &
OXYGEN_SPI_BUSY) == 0)
return 0;
}
dev_err(chip->card->dev, "oxygen: SPI wait timeout\n");
return -EIO;
}
int oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data)
{
/*
* We need to wait AFTER initiating the SPI transaction,
* otherwise read operations will not work.
*/
oxygen_write8(chip, OXYGEN_SPI_DATA1, data);
oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8);
if (control & OXYGEN_SPI_DATA_LENGTH_3)
oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16);
oxygen_write8(chip, OXYGEN_SPI_CONTROL, control);
return oxygen_wait_spi(chip);
}
EXPORT_SYMBOL(oxygen_write_spi);
void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data)
{
/* should not need more than about 300 us */
msleep(1);
oxygen_write8(chip, OXYGEN_2WIRE_MAP, map);
oxygen_write8(chip, OXYGEN_2WIRE_DATA, data);
oxygen_write8(chip, OXYGEN_2WIRE_CONTROL,
device | OXYGEN_2WIRE_DIR_WRITE);
}
EXPORT_SYMBOL(oxygen_write_i2c);
static void _write_uart(struct oxygen *chip, unsigned int port, u8 data)
{
if (oxygen_read8(chip, OXYGEN_MPU401 + 1) & MPU401_TX_FULL)
msleep(1);
oxygen_write8(chip, OXYGEN_MPU401 + port, data);
}
void oxygen_reset_uart(struct oxygen *chip)
{
_write_uart(chip, 1, MPU401_RESET);
msleep(1); /* wait for ACK */
_write_uart(chip, 1, MPU401_ENTER_UART);
}
EXPORT_SYMBOL(oxygen_reset_uart);
void oxygen_write_uart(struct oxygen *chip, u8 data)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/sched.h`, `linux/export.h`, `linux/io.h`, `sound/core.h`, `sound/mpu401.h`, `oxygen.h`.
- Detected declarations: `function Copyright`, `function oxygen_read16`, `function oxygen_read32`, `function oxygen_write8`, `function oxygen_write16`, `function oxygen_write32`, `function oxygen_write8_masked`, `function oxygen_write16_masked`, `function oxygen_write32_masked`, `function oxygen_ac97_wait`.
- Atlas domain: Driver Families / sound/pci.
- 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.