sound/usb/power.c
Source file repositories/reference/linux-study-clean/sound/usb/power.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/power.c- Extension
.c- Size
- 2585 bytes
- Lines
- 108
- Domain
- Driver Families
- Bucket
- sound/usb
- 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.
- 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/slab.hlinux/usb.hlinux/usb/audio.hlinux/usb/audio-v2.hlinux/usb/audio-v3.husbaudio.hhelper.hpower.h
Detected Declarations
function snd_usb_find_power_domainfunction snd_usb_power_domain_set
Annotated Snippet
if (pd_desc->baEntityID[i] == id) {
pd->pd_id = pd_desc->bPowerDomainID;
pd->pd_d1d0_rec =
le16_to_cpu(pd_desc->waRecoveryTime1);
pd->pd_d2d0_rec =
le16_to_cpu(pd_desc->waRecoveryTime2);
pd->ctrl_iface = ctrl_iface;
return pd;
}
}
}
kfree(pd);
return NULL;
}
int snd_usb_power_domain_set(struct snd_usb_audio *chip,
struct snd_usb_power_domain *pd,
unsigned char state)
{
struct usb_device *dev = chip->dev;
unsigned char current_state;
int err, idx;
idx = snd_usb_ctrl_intf(pd->ctrl_iface) | (pd->pd_id << 8);
err = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0),
UAC2_CS_CUR,
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
UAC3_AC_POWER_DOMAIN_CONTROL << 8, idx,
¤t_state, sizeof(current_state));
if (err < 0) {
dev_err(&dev->dev, "Can't get UAC3 power state for id %d\n",
pd->pd_id);
return err;
}
if (current_state == state) {
dev_dbg(&dev->dev, "UAC3 power domain id %d already in state %d\n",
pd->pd_id, state);
return 0;
}
err = snd_usb_ctl_msg(chip->dev, usb_sndctrlpipe(chip->dev, 0), UAC2_CS_CUR,
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
UAC3_AC_POWER_DOMAIN_CONTROL << 8, idx,
&state, sizeof(state));
if (err < 0) {
dev_err(&dev->dev, "Can't set UAC3 power state to %d for id %d\n",
state, pd->pd_id);
return err;
}
if (state == UAC3_PD_STATE_D0) {
switch (current_state) {
case UAC3_PD_STATE_D2:
udelay(pd->pd_d2d0_rec * 50);
break;
case UAC3_PD_STATE_D1:
udelay(pd->pd_d1d0_rec * 50);
break;
default:
return -EINVAL;
}
}
dev_dbg(&dev->dev, "UAC3 power domain id %d change to state %d\n",
pd->pd_id, state);
return 0;
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/usb.h`, `linux/usb/audio.h`, `linux/usb/audio-v2.h`, `linux/usb/audio-v3.h`, `usbaudio.h`, `helper.h`, `power.h`.
- Detected declarations: `function snd_usb_find_power_domain`, `function snd_usb_power_domain_set`.
- Atlas domain: Driver Families / sound/usb.
- 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.