18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Local helper macros and functions for HD-audio core drivers 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef __HDAC_LOCAL_H 78c2ecf20Sopenharmony_ci#define __HDAC_LOCAL_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#define get_wcaps(codec, nid) \ 108c2ecf20Sopenharmony_ci snd_hdac_read_parm(codec, nid, AC_PAR_AUDIO_WIDGET_CAP) 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* get the widget type from widget capability bits */ 138c2ecf20Sopenharmony_cistatic inline int get_wcaps_type(unsigned int wcaps) 148c2ecf20Sopenharmony_ci{ 158c2ecf20Sopenharmony_ci if (!wcaps) 168c2ecf20Sopenharmony_ci return -1; /* invalid type */ 178c2ecf20Sopenharmony_ci return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 188c2ecf20Sopenharmony_ci} 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cistatic inline unsigned int get_wcaps_channels(u32 wcaps) 218c2ecf20Sopenharmony_ci{ 228c2ecf20Sopenharmony_ci unsigned int chans; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13; 258c2ecf20Sopenharmony_ci chans = (chans + 1) * 2; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci return chans; 288c2ecf20Sopenharmony_ci} 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ciextern const struct attribute_group *hdac_dev_attr_groups[]; 318c2ecf20Sopenharmony_ciint hda_widget_sysfs_init(struct hdac_device *codec); 328c2ecf20Sopenharmony_ciint hda_widget_sysfs_reinit(struct hdac_device *codec, hda_nid_t start_nid, 338c2ecf20Sopenharmony_ci int num_nodes); 348c2ecf20Sopenharmony_civoid hda_widget_sysfs_exit(struct hdac_device *codec); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciint snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec); 378c2ecf20Sopenharmony_civoid snd_hdac_bus_remove_device(struct hdac_bus *bus, 388c2ecf20Sopenharmony_ci struct hdac_device *codec); 398c2ecf20Sopenharmony_civoid snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex); 408c2ecf20Sopenharmony_ciint snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsigned int addr, 418c2ecf20Sopenharmony_ci unsigned int cmd, unsigned int *res); 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ciint snd_hdac_exec_verb(struct hdac_device *codec, unsigned int cmd, 448c2ecf20Sopenharmony_ci unsigned int flags, unsigned int *res); 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#endif /* __HDAC_LOCAL_H */ 47