include/sound/hda_codec.h

Source file repositories/reference/linux-study-clean/include/sound/hda_codec.h

File Facts

System
Linux kernel
Corpus path
include/sound/hda_codec.h
Extension
.h
Size
19616 bytes
Lines
584
Domain
Driver Families
Bucket
include/sound
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct hda_bus {
	struct hdac_bus core;

	struct snd_card *card;

	struct pci_dev *pci;
	const char *modelname;

	struct mutex prepare_mutex;

	/* assigned PCMs */
	DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES);

	/* misc op flags */
	unsigned int allow_bus_reset:1;	/* allow bus reset at fatal error */
	/* status for codec/controller */
	unsigned int shutdown :1;	/* being unloaded */
	unsigned int response_reset:1;	/* controller was reset */
	unsigned int in_reset:1;	/* during reset operation */
	unsigned int no_response_fallback:1; /* don't fallback at RIRB error */
	unsigned int bus_probing :1;	/* during probing process */
	unsigned int keep_power:1;	/* keep power up for notification */
	unsigned int jackpoll_in_suspend:1; /* keep jack polling during
					     * runtime suspend
					     */

	int primary_dig_out_type;	/* primary digital out PCM type */
	unsigned int mixer_assigned;	/* codec addr for mixer name */
};

/* from hdac_bus to hda_bus */
#define to_hda_bus(bus)		container_of(bus, struct hda_bus, core)

/*
 * codec preset
 */

#define HDA_CODEC_ID_SKIP_PROBE		0x00000001
#define HDA_CODEC_ID_GENERIC_HDMI	0x00000101
#define HDA_CODEC_ID_GENERIC		0x00000201

#define HDA_CODEC_ID_REV_MODEL(_vid, _rev, _name, _model)	  \
	{ .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \
	  .api_version = HDA_DEV_LEGACY, .driver_data = (_model) }
#define HDA_CODEC_ID_MODEL(_vid, _name, _model)	  \
	HDA_CODEC_ID_REV_MODEL(_vid, 0, _name, _model)
#define HDA_CODEC_ID_REV(_vid, _rev, _name) \
	HDA_CODEC_ID_REV_MODEL(_vid, _rev, _name, 0)
#define HDA_CODEC_ID(_vid, _name) \
	HDA_CODEC_ID_REV(_vid, 0, _name)

struct hda_codec_driver {
	struct hdac_driver core;
	const struct hda_device_id *id;
	const struct hda_codec_ops *ops;
};

#define hda_codec_to_driver(codec) \
	container_of((codec)->core.dev.driver, struct hda_codec_driver, core.driver)

int __hda_codec_driver_register(struct hda_codec_driver *drv, const char *name,
			       struct module *owner);
#define hda_codec_driver_register(drv) \
	__hda_codec_driver_register(drv, KBUILD_MODNAME, THIS_MODULE)
void hda_codec_driver_unregister(struct hda_codec_driver *drv);
#define module_hda_codec_driver(drv) \
	module_driver(drv, hda_codec_driver_register, \
		      hda_codec_driver_unregister)

/* ops for hda codec driver */
struct hda_codec_ops {
	int (*probe)(struct hda_codec *codec, const struct hda_device_id *id);
	void (*remove)(struct hda_codec *codec);
	int (*build_controls)(struct hda_codec *codec);
	int (*build_pcms)(struct hda_codec *codec);
	int (*init)(struct hda_codec *codec);
	void (*unsol_event)(struct hda_codec *codec, unsigned int res);
	void (*set_power_state)(struct hda_codec *codec, hda_nid_t fg,
				unsigned int power_state);
	int (*suspend)(struct hda_codec *codec);
	int (*resume)(struct hda_codec *codec);
	int (*check_power_status)(struct hda_codec *codec, hda_nid_t nid);
	void (*stream_pm)(struct hda_codec *codec, hda_nid_t nid, bool on);
};

/* PCM callbacks */
struct hda_pcm_ops {
	int (*open)(struct hda_pcm_stream *info, struct hda_codec *codec,
		    struct snd_pcm_substream *substream);
	int (*close)(struct hda_pcm_stream *info, struct hda_codec *codec,

Annotation

Implementation Notes