sound/pci/bt87x.c
Source file repositories/reference/linux-study-clean/sound/pci/bt87x.c
File Facts
- System
- Linux kernel
- Corpus path
sound/pci/bt87x.c- Extension
.c- Size
- 28258 bytes
- Lines
- 919
- Domain
- Driver Families
- Bucket
- sound/pci
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/init.hlinux/interrupt.hlinux/pci.hlinux/slab.hlinux/module.hlinux/bitops.hlinux/io.hsound/core.hsound/pcm.hsound/pcm_params.hsound/control.hsound/initval.h
Detected Declarations
struct snd_bt87x_boardstruct snd_bt87xenum snd_bt87x_boardidfunction snd_bt87x_readlfunction snd_bt87x_writelfunction snd_bt87x_create_riscfunction snd_bt87x_free_riscfunction snd_bt87x_pci_errorfunction snd_bt87x_interruptfunction snd_bt87x_set_digital_hwfunction snd_bt87x_set_analog_hwfunction snd_bt87x_pcm_openfunction snd_bt87x_closefunction scoped_guardfunction snd_bt87x_hw_paramsfunction snd_bt87x_hw_freefunction snd_bt87x_preparefunction snd_bt87x_startfunction snd_bt87x_stopfunction snd_bt87x_triggerfunction snd_bt87x_pointerfunction snd_bt87x_capture_volume_infofunction snd_bt87x_capture_volume_getfunction snd_bt87x_capture_volume_putfunction snd_bt87x_capture_boost_getfunction snd_bt87x_capture_boost_putfunction snd_bt87x_capture_source_infofunction snd_bt87x_capture_source_getfunction snd_bt87x_capture_source_putfunction snd_bt87x_freefunction snd_bt87x_pcmfunction snd_bt87x_createfunction snd_bt87x_detect_cardfunction __snd_bt87x_probefunction snd_bt87x_probefunction alsa_card_bt87x_initfunction alsa_card_bt87x_exitmodule init alsa_card_bt87x_init
Annotated Snippet
static struct pci_driver driver;
/* return the id of the card, or a negative value if it's on the denylist */
static int snd_bt87x_detect_card(struct pci_dev *pci)
{
int i;
const struct pci_device_id *supported;
supported = pci_match_id(snd_bt87x_ids, pci);
if (supported && supported->driver_data > 0)
return supported->driver_data;
for (i = 0; i < ARRAY_SIZE(denylist); ++i)
if (denylist[i].subvendor == pci->subsystem_vendor &&
denylist[i].subdevice == pci->subsystem_device) {
dev_dbg(&pci->dev,
"card %#04x-%#04x:%#04x has no audio\n",
pci->device, pci->subsystem_vendor, pci->subsystem_device);
return -EBUSY;
}
dev_info(&pci->dev, "unknown card %#04x-%#04x:%#04x\n",
pci->device, pci->subsystem_vendor, pci->subsystem_device);
dev_info(&pci->dev, "please mail id, board name, and, "
"if it works, the correct digital_rate option to "
"<alsa-devel@alsa-project.org>\n");
return SND_BT87X_BOARD_UNKNOWN;
}
static int __snd_bt87x_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
{
static int dev;
struct snd_card *card;
struct snd_bt87x *chip;
int err;
enum snd_bt87x_boardid boardid;
if (!pci_id->driver_data) {
err = snd_bt87x_detect_card(pci);
if (err < 0)
return -ENODEV;
boardid = err;
} else
boardid = pci_id->driver_data;
if (dev >= SNDRV_CARDS)
return -ENODEV;
if (!enable[dev]) {
++dev;
return -ENOENT;
}
err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
sizeof(*chip), &card);
if (err < 0)
return err;
chip = card->private_data;
err = snd_bt87x_create(card, pci);
if (err < 0)
return err;
memcpy(&chip->board, &snd_bt87x_boards[boardid], sizeof(chip->board));
if (!chip->board.no_digital) {
if (digital_rate[dev] > 0)
chip->board.dig_rate = digital_rate[dev];
chip->reg_control |= chip->board.digital_fmt;
err = snd_bt87x_pcm(chip, DEVICE_DIGITAL, "Bt87x Digital");
if (err < 0)
return err;
}
if (!chip->board.no_analog) {
err = snd_bt87x_pcm(chip, DEVICE_ANALOG, "Bt87x Analog");
if (err < 0)
return err;
err = snd_ctl_add(card, snd_ctl_new1(
&snd_bt87x_capture_volume, chip));
if (err < 0)
return err;
err = snd_ctl_add(card, snd_ctl_new1(
&snd_bt87x_capture_boost, chip));
if (err < 0)
return err;
err = snd_ctl_add(card, snd_ctl_new1(
&snd_bt87x_capture_source, chip));
if (err < 0)
Annotation
- Immediate include surface: `linux/init.h`, `linux/interrupt.h`, `linux/pci.h`, `linux/slab.h`, `linux/module.h`, `linux/bitops.h`, `linux/io.h`, `sound/core.h`.
- Detected declarations: `struct snd_bt87x_board`, `struct snd_bt87x`, `enum snd_bt87x_boardid`, `function snd_bt87x_readl`, `function snd_bt87x_writel`, `function snd_bt87x_create_risc`, `function snd_bt87x_free_risc`, `function snd_bt87x_pci_error`, `function snd_bt87x_interrupt`, `function snd_bt87x_set_digital_hw`.
- Atlas domain: Driver Families / sound/pci.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.