sound/virtio/virtio_jack.c
Source file repositories/reference/linux-study-clean/sound/virtio/virtio_jack.c
File Facts
- System
- Linux kernel
- Corpus path
sound/virtio/virtio_jack.c- Extension
.c- Size
- 5363 bytes
- Lines
- 234
- Domain
- Driver Families
- Bucket
- sound/virtio
- 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/virtio_config.hsound/jack.hsound/hda_verbs.hvirtio_card.h
Detected Declarations
struct virtio_jackfunction virtsnd_jack_get_labelfunction virtsnd_jack_get_typefunction virtsnd_jack_parse_cfgfunction virtsnd_jack_build_devsfunction virtsnd_jack_event
Annotated Snippet
struct virtio_jack {
struct snd_jack *jack;
u32 nid;
u32 features;
u32 defconf;
u32 caps;
bool connected;
int type;
};
/**
* virtsnd_jack_get_label() - Get the name string for the jack.
* @vjack: VirtIO jack.
*
* Returns the jack name based on the default pin configuration value (see HDA
* specification).
*
* Context: Any context.
* Return: Name string.
*/
static const char *virtsnd_jack_get_label(struct virtio_jack *vjack)
{
unsigned int defconf = vjack->defconf;
unsigned int device =
(defconf & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT;
unsigned int location =
(defconf & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT;
switch (device) {
case AC_JACK_LINE_OUT:
return "Line Out";
case AC_JACK_SPEAKER:
return "Speaker";
case AC_JACK_HP_OUT:
return "Headphone";
case AC_JACK_CD:
return "CD";
case AC_JACK_SPDIF_OUT:
case AC_JACK_DIG_OTHER_OUT:
if (location == AC_JACK_LOC_HDMI)
return "HDMI Out";
else
return "SPDIF Out";
case AC_JACK_LINE_IN:
return "Line";
case AC_JACK_AUX:
return "Aux";
case AC_JACK_MIC_IN:
return "Mic";
case AC_JACK_SPDIF_IN:
return "SPDIF In";
case AC_JACK_DIG_OTHER_IN:
return "Digital In";
default:
return "Misc";
}
}
/**
* virtsnd_jack_get_type() - Get the type for the jack.
* @vjack: VirtIO jack.
*
* Returns the jack type based on the default pin configuration value (see HDA
* specification).
*
* Context: Any context.
* Return: SND_JACK_XXX value.
*/
static int virtsnd_jack_get_type(struct virtio_jack *vjack)
{
unsigned int defconf = vjack->defconf;
unsigned int device =
(defconf & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT;
switch (device) {
case AC_JACK_LINE_OUT:
case AC_JACK_SPEAKER:
return SND_JACK_LINEOUT;
case AC_JACK_HP_OUT:
return SND_JACK_HEADPHONE;
case AC_JACK_SPDIF_OUT:
case AC_JACK_DIG_OTHER_OUT:
return SND_JACK_AVOUT;
case AC_JACK_MIC_IN:
return SND_JACK_MICROPHONE;
default:
return SND_JACK_LINEIN;
}
}
Annotation
- Immediate include surface: `linux/virtio_config.h`, `sound/jack.h`, `sound/hda_verbs.h`, `virtio_card.h`.
- Detected declarations: `struct virtio_jack`, `function virtsnd_jack_get_label`, `function virtsnd_jack_get_type`, `function virtsnd_jack_parse_cfg`, `function virtsnd_jack_build_devs`, `function virtsnd_jack_event`.
- Atlas domain: Driver Families / sound/virtio.
- 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.