📄 hda_codec.h
字号:
AC_JACK_CONN_OPTICAL, AC_JACK_CONN_OTHER_DIGITAL, AC_JACK_CONN_OTHER_ANALOG, AC_JACK_CONN_DIN, AC_JACK_CONN_XLR, AC_JACK_CONN_RJ11, AC_JACK_CONN_COMB, AC_JACK_CONN_OTHER = 0xf,};/* jack colors (0x0-0xf) */enum { AC_JACK_COLOR_UNKNOWN, AC_JACK_COLOR_BLACK, AC_JACK_COLOR_GREY, AC_JACK_COLOR_BLUE, AC_JACK_COLOR_GREEN, AC_JACK_COLOR_RED, AC_JACK_COLOR_ORANGE, AC_JACK_COLOR_YELLOW, AC_JACK_COLOR_PURPLE, AC_JACK_COLOR_PINK, AC_JACK_COLOR_WHITE = 0xe, AC_JACK_COLOR_OTHER,};/* Jack location (0x0-0x3f) *//* common case */enum { AC_JACK_LOC_NONE, AC_JACK_LOC_REAR, AC_JACK_LOC_FRONT, AC_JACK_LOC_LEFT, AC_JACK_LOC_RIGHT, AC_JACK_LOC_TOP, AC_JACK_LOC_BOTTOM,};/* bits 4-5 */enum { AC_JACK_LOC_EXTERNAL = 0x00, AC_JACK_LOC_INTERNAL = 0x10, AC_JACK_LOC_SEPARATE = 0x20, AC_JACK_LOC_OTHER = 0x30,};enum { /* external on primary chasis */ AC_JACK_LOC_REAR_PANEL = 0x07, AC_JACK_LOC_DRIVE_BAY, /* internal */ AC_JACK_LOC_RISER = 0x17, AC_JACK_LOC_HDMI, AC_JACK_LOC_ATAPI, /* others */ AC_JACK_LOC_MOBILE_IN = 0x37, AC_JACK_LOC_MOBILE_OUT,};/* Port connectivity (0-3) */enum { AC_JACK_PORT_COMPLEX, AC_JACK_PORT_NONE, AC_JACK_PORT_FIXED, AC_JACK_PORT_BOTH,};/* max. connections to a widget */#define HDA_MAX_CONNECTIONS 16/* max. codec address */#define HDA_MAX_CODEC_ADDRESS 0x0f/* * Structures */struct hda_bus;struct hda_codec;struct hda_pcm;struct hda_pcm_stream;struct hda_bus_unsolicited;/* NID type */typedef u16 hda_nid_t;/* bus operators */struct hda_bus_ops { /* send a single command */ int (*command)(struct hda_codec *codec, hda_nid_t nid, int direct, unsigned int verb, unsigned int parm); /* get a response from the last command */ unsigned int (*get_response)(struct hda_codec *codec); /* free the private data */ void (*private_free)(struct hda_bus *);};/* template to pass to the bus constructor */struct hda_bus_template { void *private_data; struct pci_dev *pci; const char *modelname; struct hda_bus_ops ops;};/* * codec bus * * each controller needs to creata a hda_bus to assign the accessor. * A hda_bus contains several codecs in the list codec_list. */struct hda_bus { snd_card_t *card; /* copied from template */ void *private_data; struct pci_dev *pci; const char *modelname; struct hda_bus_ops ops; /* codec linked list */ struct list_head codec_list; struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1]; /* caddr -> codec */ struct semaphore cmd_mutex; /* unsolicited event queue */ struct hda_bus_unsolicited *unsol; snd_info_entry_t *proc;};/* * codec preset * * Known codecs have the patch to build and set up the controls/PCMs * better than the generic parser. */struct hda_codec_preset { unsigned int id; unsigned int mask; unsigned int subs; unsigned int subs_mask; unsigned int rev; const char *name; int (*patch)(struct hda_codec *codec);}; /* ops set by the preset patch */struct hda_codec_ops { int (*build_controls)(struct hda_codec *codec); int (*build_pcms)(struct hda_codec *codec); int (*init)(struct hda_codec *codec); void (*free)(struct hda_codec *codec); void (*unsol_event)(struct hda_codec *codec, unsigned int res);#ifdef CONFIG_PM int (*suspend)(struct hda_codec *codec, pm_message_t state); int (*resume)(struct hda_codec *codec);#endif};/* record for amp information cache */struct hda_amp_info { u32 key; /* hash key */ u32 amp_caps; /* amp capabilities */ u16 vol[2]; /* current volume & mute*/ u16 status; /* update flag */ u16 next; /* next link */};/* PCM callbacks */struct hda_pcm_ops { int (*open)(struct hda_pcm_stream *info, struct hda_codec *codec, snd_pcm_substream_t *substream); int (*close)(struct hda_pcm_stream *info, struct hda_codec *codec, snd_pcm_substream_t *substream); int (*prepare)(struct hda_pcm_stream *info, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, snd_pcm_substream_t *substream); int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec, snd_pcm_substream_t *substream);};/* PCM information for each substream */struct hda_pcm_stream { unsigned int substreams; /* number of substreams, 0 = not exist */ unsigned int channels_min; /* min. number of channels */ unsigned int channels_max; /* max. number of channels */ hda_nid_t nid; /* default NID to query rates/formats/bps, or set up */ u32 rates; /* supported rates */ u64 formats; /* supported formats (SNDRV_PCM_FMTBIT_) */ unsigned int maxbps; /* supported max. bit per sample */ struct hda_pcm_ops ops;};/* for PCM creation */struct hda_pcm { char *name; struct hda_pcm_stream stream[2]; unsigned int is_modem; /* modem codec? */};/* codec information */struct hda_codec { struct hda_bus *bus; unsigned int addr; /* codec addr*/ struct list_head list; /* list point */ hda_nid_t afg; /* AFG node id */ hda_nid_t mfg; /* MFG node id */ /* ids */ u32 vendor_id; u32 subsystem_id; u32 revision_id; /* detected preset */ const struct hda_codec_preset *preset; /* set by patch */ struct hda_codec_ops patch_ops; /* resume phase - all controls should update even if * the values are not changed */ unsigned int in_resume; /* PCM to create, set by patch_ops.build_pcms callback */ unsigned int num_pcms; struct hda_pcm *pcm_info; /* codec specific info */ void *spec; /* hash for amp access */ u16 amp_hash[32]; int num_amp_entries; struct hda_amp_info amp_info[128]; /* big enough? */ struct semaphore spdif_mutex; unsigned int spdif_status; /* IEC958 status bits */ unsigned short spdif_ctls; /* SPDIF control bits */ unsigned int spdif_in_enable; /* SPDIF input enable? */};/* direction */enum { HDA_INPUT, HDA_OUTPUT};/* * constructors */int snd_hda_bus_new(snd_card_t *card, const struct hda_bus_template *temp, struct hda_bus **busp);int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, struct hda_codec **codecp);/* * low level functions */unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int direct, unsigned int verb, unsigned int parm);int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct, unsigned int verb, unsigned int parm);#define snd_hda_param_read(codec, nid, param) snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param)int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *start_id);int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *conn_list, int max_conns);struct hda_verb { hda_nid_t nid; u32 verb; u32 param;};void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq);/* unsolicited event */int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex);/* * Mixer */int snd_hda_build_controls(struct hda_bus *bus);/* * PCM */int snd_hda_build_pcms(struct hda_bus *bus);void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, int channel_id, int format);unsigned int snd_hda_calc_stream_format(unsigned int rate, unsigned int channels, unsigned int format, unsigned int maxbps);int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, u32 *ratesp, u64 *formatsp, unsigned int *bpsp);int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid, unsigned int format);/* * Misc */void snd_hda_get_codec_name(struct hda_codec *codec, char *name, int namelen);/* * power management */#ifdef CONFIG_PMint snd_hda_suspend(struct hda_bus *bus, pm_message_t state);int snd_hda_resume(struct hda_bus *bus);#endif#endif /* __SOUND_HDA_CODEC_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -