hdaudio.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /*
  2. * HD-audio core stuff
  3. */
  4. #ifndef __SOUND_HDAUDIO_H
  5. #define __SOUND_HDAUDIO_H
  6. #include <linux/device.h>
  7. #include <linux/interrupt.h>
  8. #include <linux/timecounter.h>
  9. #include <sound/core.h>
  10. #include <sound/memalloc.h>
  11. #include <sound/hda_verbs.h>
  12. #include <drm/i915_component.h>
  13. /* codec node id */
  14. typedef u16 hda_nid_t;
  15. struct hdac_bus;
  16. struct hdac_stream;
  17. struct hdac_device;
  18. struct hdac_driver;
  19. struct hdac_widget_tree;
  20. struct hda_device_id;
  21. /*
  22. * exported bus type
  23. */
  24. extern struct bus_type snd_hda_bus_type;
  25. /*
  26. * generic arrays
  27. */
  28. struct snd_array {
  29. unsigned int used;
  30. unsigned int alloced;
  31. unsigned int elem_size;
  32. unsigned int alloc_align;
  33. void *list;
  34. };
  35. /*
  36. * HD-audio codec base device
  37. */
  38. struct hdac_device {
  39. struct device dev;
  40. int type;
  41. struct hdac_bus *bus;
  42. unsigned int addr; /* codec address */
  43. struct list_head list; /* list point for bus codec_list */
  44. hda_nid_t afg; /* AFG node id */
  45. hda_nid_t mfg; /* MFG node id */
  46. /* ids */
  47. unsigned int vendor_id;
  48. unsigned int subsystem_id;
  49. unsigned int revision_id;
  50. unsigned int afg_function_id;
  51. unsigned int mfg_function_id;
  52. unsigned int afg_unsol:1;
  53. unsigned int mfg_unsol:1;
  54. unsigned int power_caps; /* FG power caps */
  55. const char *vendor_name; /* codec vendor name */
  56. const char *chip_name; /* codec chip name */
  57. /* verb exec op override */
  58. int (*exec_verb)(struct hdac_device *dev, unsigned int cmd,
  59. unsigned int flags, unsigned int *res);
  60. /* widgets */
  61. unsigned int num_nodes;
  62. hda_nid_t start_nid, end_nid;
  63. /* misc flags */
  64. atomic_t in_pm; /* suspend/resume being performed */
  65. bool link_power_control:1;
  66. /* sysfs */
  67. struct hdac_widget_tree *widgets;
  68. /* regmap */
  69. struct regmap *regmap;
  70. struct snd_array vendor_verbs;
  71. bool lazy_cache:1; /* don't wake up for writes */
  72. bool caps_overwriting:1; /* caps overwrite being in process */
  73. bool cache_coef:1; /* cache COEF read/write too */
  74. };
  75. /* device/driver type used for matching */
  76. enum {
  77. HDA_DEV_CORE,
  78. HDA_DEV_LEGACY,
  79. HDA_DEV_ASOC,
  80. };
  81. /* direction */
  82. enum {
  83. HDA_INPUT, HDA_OUTPUT
  84. };
  85. #define dev_to_hdac_dev(_dev) container_of(_dev, struct hdac_device, dev)
  86. int snd_hdac_device_init(struct hdac_device *dev, struct hdac_bus *bus,
  87. const char *name, unsigned int addr);
  88. void snd_hdac_device_exit(struct hdac_device *dev);
  89. int snd_hdac_device_register(struct hdac_device *codec);
  90. void snd_hdac_device_unregister(struct hdac_device *codec);
  91. int snd_hdac_device_set_chip_name(struct hdac_device *codec, const char *name);
  92. int snd_hdac_codec_modalias(struct hdac_device *hdac, char *buf, size_t size);
  93. int snd_hdac_refresh_widgets(struct hdac_device *codec);
  94. int snd_hdac_refresh_widget_sysfs(struct hdac_device *codec);
  95. unsigned int snd_hdac_make_cmd(struct hdac_device *codec, hda_nid_t nid,
  96. unsigned int verb, unsigned int parm);
  97. int snd_hdac_exec_verb(struct hdac_device *codec, unsigned int cmd,
  98. unsigned int flags, unsigned int *res);
  99. int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid,
  100. unsigned int verb, unsigned int parm, unsigned int *res);
  101. int _snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm,
  102. unsigned int *res);
  103. int snd_hdac_read_parm_uncached(struct hdac_device *codec, hda_nid_t nid,
  104. int parm);
  105. int snd_hdac_override_parm(struct hdac_device *codec, hda_nid_t nid,
  106. unsigned int parm, unsigned int val);
  107. int snd_hdac_get_connections(struct hdac_device *codec, hda_nid_t nid,
  108. hda_nid_t *conn_list, int max_conns);
  109. int snd_hdac_get_sub_nodes(struct hdac_device *codec, hda_nid_t nid,
  110. hda_nid_t *start_id);
  111. unsigned int snd_hdac_calc_stream_format(unsigned int rate,
  112. unsigned int channels,
  113. unsigned int format,
  114. unsigned int maxbps,
  115. unsigned short spdif_ctls);
  116. int snd_hdac_query_supported_pcm(struct hdac_device *codec, hda_nid_t nid,
  117. u32 *ratesp, u64 *formatsp, unsigned int *bpsp);
  118. bool snd_hdac_is_supported_format(struct hdac_device *codec, hda_nid_t nid,
  119. unsigned int format);
  120. int snd_hdac_codec_read(struct hdac_device *hdac, hda_nid_t nid,
  121. int flags, unsigned int verb, unsigned int parm);
  122. int snd_hdac_codec_write(struct hdac_device *hdac, hda_nid_t nid,
  123. int flags, unsigned int verb, unsigned int parm);
  124. bool snd_hdac_check_power_state(struct hdac_device *hdac,
  125. hda_nid_t nid, unsigned int target_state);
  126. /**
  127. * snd_hdac_read_parm - read a codec parameter
  128. * @codec: the codec object
  129. * @nid: NID to read a parameter
  130. * @parm: parameter to read
  131. *
  132. * Returns -1 for error. If you need to distinguish the error more
  133. * strictly, use _snd_hdac_read_parm() directly.
  134. */
  135. static inline int snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid,
  136. int parm)
  137. {
  138. unsigned int val;
  139. return _snd_hdac_read_parm(codec, nid, parm, &val) < 0 ? -1 : val;
  140. }
  141. #ifdef CONFIG_PM
  142. int snd_hdac_power_up(struct hdac_device *codec);
  143. int snd_hdac_power_down(struct hdac_device *codec);
  144. int snd_hdac_power_up_pm(struct hdac_device *codec);
  145. int snd_hdac_power_down_pm(struct hdac_device *codec);
  146. #else
  147. static inline int snd_hdac_power_up(struct hdac_device *codec) { return 0; }
  148. static inline int snd_hdac_power_down(struct hdac_device *codec) { return 0; }
  149. static inline int snd_hdac_power_up_pm(struct hdac_device *codec) { return 0; }
  150. static inline int snd_hdac_power_down_pm(struct hdac_device *codec) { return 0; }
  151. #endif
  152. /*
  153. * HD-audio codec base driver
  154. */
  155. struct hdac_driver {
  156. struct device_driver driver;
  157. int type;
  158. const struct hda_device_id *id_table;
  159. int (*match)(struct hdac_device *dev, struct hdac_driver *drv);
  160. void (*unsol_event)(struct hdac_device *dev, unsigned int event);
  161. };
  162. #define drv_to_hdac_driver(_drv) container_of(_drv, struct hdac_driver, driver)
  163. const struct hda_device_id *
  164. hdac_get_device_id(struct hdac_device *hdev, struct hdac_driver *drv);
  165. /*
  166. * Bus verb operators
  167. */
  168. struct hdac_bus_ops {
  169. /* send a single command */
  170. int (*command)(struct hdac_bus *bus, unsigned int cmd);
  171. /* get a response from the last command */
  172. int (*get_response)(struct hdac_bus *bus, unsigned int addr,
  173. unsigned int *res);
  174. /* control the link power */
  175. int (*link_power)(struct hdac_bus *bus, bool enable);
  176. };
  177. /*
  178. * Lowlevel I/O operators
  179. */
  180. struct hdac_io_ops {
  181. /* mapped register accesses */
  182. void (*reg_writel)(u32 value, u32 __iomem *addr);
  183. u32 (*reg_readl)(u32 __iomem *addr);
  184. void (*reg_writew)(u16 value, u16 __iomem *addr);
  185. u16 (*reg_readw)(u16 __iomem *addr);
  186. void (*reg_writeb)(u8 value, u8 __iomem *addr);
  187. u8 (*reg_readb)(u8 __iomem *addr);
  188. /* Allocation ops */
  189. int (*dma_alloc_pages)(struct hdac_bus *bus, int type, size_t size,
  190. struct snd_dma_buffer *buf);
  191. void (*dma_free_pages)(struct hdac_bus *bus,
  192. struct snd_dma_buffer *buf);
  193. };
  194. #define HDA_UNSOL_QUEUE_SIZE 64
  195. #define HDA_MAX_CODECS 8 /* limit by controller side */
  196. /* HD Audio class code */
  197. #define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
  198. /*
  199. * CORB/RIRB
  200. *
  201. * Each CORB entry is 4byte, RIRB is 8byte
  202. */
  203. struct hdac_rb {
  204. __le32 *buf; /* virtual address of CORB/RIRB buffer */
  205. dma_addr_t addr; /* physical address of CORB/RIRB buffer */
  206. unsigned short rp, wp; /* RIRB read/write pointers */
  207. int cmds[HDA_MAX_CODECS]; /* number of pending requests */
  208. u32 res[HDA_MAX_CODECS]; /* last read value */
  209. };
  210. /*
  211. * HD-audio bus base driver
  212. */
  213. struct hdac_bus {
  214. struct device *dev;
  215. const struct hdac_bus_ops *ops;
  216. const struct hdac_io_ops *io_ops;
  217. /* h/w resources */
  218. unsigned long addr;
  219. void __iomem *remap_addr;
  220. int irq;
  221. /* codec linked list */
  222. struct list_head codec_list;
  223. unsigned int num_codecs;
  224. /* link caddr -> codec */
  225. struct hdac_device *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1];
  226. /* unsolicited event queue */
  227. u32 unsol_queue[HDA_UNSOL_QUEUE_SIZE * 2]; /* ring buffer */
  228. unsigned int unsol_rp, unsol_wp;
  229. struct work_struct unsol_work;
  230. /* bit flags of detected codecs */
  231. unsigned long codec_mask;
  232. /* bit flags of powered codecs */
  233. unsigned long codec_powered;
  234. /* CORB/RIRB */
  235. struct hdac_rb corb;
  236. struct hdac_rb rirb;
  237. unsigned int last_cmd[HDA_MAX_CODECS]; /* last sent command */
  238. /* CORB/RIRB and position buffers */
  239. struct snd_dma_buffer rb;
  240. struct snd_dma_buffer posbuf;
  241. /* hdac_stream linked list */
  242. struct list_head stream_list;
  243. /* operation state */
  244. bool chip_init:1; /* h/w initialized */
  245. /* behavior flags */
  246. bool sync_write:1; /* sync after verb write */
  247. bool use_posbuf:1; /* use position buffer */
  248. bool snoop:1; /* enable snooping */
  249. bool align_bdle_4k:1; /* BDLE align 4K boundary */
  250. bool reverse_assign:1; /* assign devices in reverse order */
  251. bool corbrp_self_clear:1; /* CORBRP clears itself after reset */
  252. int bdl_pos_adj; /* BDL position adjustment */
  253. /* locks */
  254. spinlock_t reg_lock;
  255. struct mutex cmd_mutex;
  256. /* i915 component interface */
  257. struct i915_audio_component *audio_component;
  258. int i915_power_refcount;
  259. };
  260. int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev,
  261. const struct hdac_bus_ops *ops,
  262. const struct hdac_io_ops *io_ops);
  263. void snd_hdac_bus_exit(struct hdac_bus *bus);
  264. int snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsigned int addr,
  265. unsigned int cmd, unsigned int *res);
  266. int snd_hdac_bus_exec_verb_unlocked(struct hdac_bus *bus, unsigned int addr,
  267. unsigned int cmd, unsigned int *res);
  268. void snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex);
  269. int snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec);
  270. void snd_hdac_bus_remove_device(struct hdac_bus *bus,
  271. struct hdac_device *codec);
  272. static inline void snd_hdac_codec_link_up(struct hdac_device *codec)
  273. {
  274. set_bit(codec->addr, &codec->bus->codec_powered);
  275. }
  276. static inline void snd_hdac_codec_link_down(struct hdac_device *codec)
  277. {
  278. clear_bit(codec->addr, &codec->bus->codec_powered);
  279. }
  280. int snd_hdac_bus_send_cmd(struct hdac_bus *bus, unsigned int val);
  281. int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,
  282. unsigned int *res);
  283. int snd_hdac_link_power(struct hdac_device *codec, bool enable);
  284. bool snd_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset);
  285. void snd_hdac_bus_stop_chip(struct hdac_bus *bus);
  286. void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus);
  287. void snd_hdac_bus_stop_cmd_io(struct hdac_bus *bus);
  288. void snd_hdac_bus_enter_link_reset(struct hdac_bus *bus);
  289. void snd_hdac_bus_exit_link_reset(struct hdac_bus *bus);
  290. void snd_hdac_bus_update_rirb(struct hdac_bus *bus);
  291. void snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
  292. void (*ack)(struct hdac_bus *,
  293. struct hdac_stream *));
  294. int snd_hdac_bus_alloc_stream_pages(struct hdac_bus *bus);
  295. void snd_hdac_bus_free_stream_pages(struct hdac_bus *bus);
  296. /*
  297. * macros for easy use
  298. */
  299. #define _snd_hdac_chip_write(type, chip, reg, value) \
  300. ((chip)->io_ops->reg_write ## type(value, (chip)->remap_addr + (reg)))
  301. #define _snd_hdac_chip_read(type, chip, reg) \
  302. ((chip)->io_ops->reg_read ## type((chip)->remap_addr + (reg)))
  303. /* read/write a register, pass without AZX_REG_ prefix */
  304. #define snd_hdac_chip_writel(chip, reg, value) \
  305. _snd_hdac_chip_write(l, chip, AZX_REG_ ## reg, value)
  306. #define snd_hdac_chip_writew(chip, reg, value) \
  307. _snd_hdac_chip_write(w, chip, AZX_REG_ ## reg, value)
  308. #define snd_hdac_chip_writeb(chip, reg, value) \
  309. _snd_hdac_chip_write(b, chip, AZX_REG_ ## reg, value)
  310. #define snd_hdac_chip_readl(chip, reg) \
  311. _snd_hdac_chip_read(l, chip, AZX_REG_ ## reg)
  312. #define snd_hdac_chip_readw(chip, reg) \
  313. _snd_hdac_chip_read(w, chip, AZX_REG_ ## reg)
  314. #define snd_hdac_chip_readb(chip, reg) \
  315. _snd_hdac_chip_read(b, chip, AZX_REG_ ## reg)
  316. /* update a register, pass without AZX_REG_ prefix */
  317. #define snd_hdac_chip_updatel(chip, reg, mask, val) \
  318. snd_hdac_chip_writel(chip, reg, \
  319. (snd_hdac_chip_readl(chip, reg) & ~(mask)) | (val))
  320. #define snd_hdac_chip_updatew(chip, reg, mask, val) \
  321. snd_hdac_chip_writew(chip, reg, \
  322. (snd_hdac_chip_readw(chip, reg) & ~(mask)) | (val))
  323. #define snd_hdac_chip_updateb(chip, reg, mask, val) \
  324. snd_hdac_chip_writeb(chip, reg, \
  325. (snd_hdac_chip_readb(chip, reg) & ~(mask)) | (val))
  326. /*
  327. * HD-audio stream
  328. */
  329. struct hdac_stream {
  330. struct hdac_bus *bus;
  331. struct snd_dma_buffer bdl; /* BDL buffer */
  332. __le32 *posbuf; /* position buffer pointer */
  333. int direction; /* playback / capture (SNDRV_PCM_STREAM_*) */
  334. unsigned int bufsize; /* size of the play buffer in bytes */
  335. unsigned int period_bytes; /* size of the period in bytes */
  336. unsigned int frags; /* number for period in the play buffer */
  337. unsigned int fifo_size; /* FIFO size */
  338. void __iomem *sd_addr; /* stream descriptor pointer */
  339. u32 sd_int_sta_mask; /* stream int status mask */
  340. /* pcm support */
  341. struct snd_pcm_substream *substream; /* assigned substream,
  342. * set in PCM open
  343. */
  344. unsigned int format_val; /* format value to be set in the
  345. * controller and the codec
  346. */
  347. unsigned char stream_tag; /* assigned stream */
  348. unsigned char index; /* stream index */
  349. int assigned_key; /* last device# key assigned to */
  350. bool opened:1;
  351. bool running:1;
  352. bool prepared:1;
  353. bool no_period_wakeup:1;
  354. bool locked:1;
  355. /* timestamp */
  356. unsigned long start_wallclk; /* start + minimum wallclk */
  357. unsigned long period_wallclk; /* wallclk for period */
  358. struct timecounter tc;
  359. struct cyclecounter cc;
  360. int delay_negative_threshold;
  361. struct list_head list;
  362. #ifdef CONFIG_SND_HDA_DSP_LOADER
  363. /* DSP access mutex */
  364. struct mutex dsp_mutex;
  365. #endif
  366. };
  367. void snd_hdac_stream_init(struct hdac_bus *bus, struct hdac_stream *azx_dev,
  368. int idx, int direction, int tag);
  369. struct hdac_stream *snd_hdac_stream_assign(struct hdac_bus *bus,
  370. struct snd_pcm_substream *substream);
  371. void snd_hdac_stream_release(struct hdac_stream *azx_dev);
  372. struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus,
  373. int dir, int stream_tag);
  374. int snd_hdac_stream_setup(struct hdac_stream *azx_dev);
  375. void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev);
  376. int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev);
  377. int snd_hdac_stream_set_params(struct hdac_stream *azx_dev,
  378. unsigned int format_val);
  379. void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start);
  380. void snd_hdac_stream_clear(struct hdac_stream *azx_dev);
  381. void snd_hdac_stream_stop(struct hdac_stream *azx_dev);
  382. void snd_hdac_stream_reset(struct hdac_stream *azx_dev);
  383. void snd_hdac_stream_sync_trigger(struct hdac_stream *azx_dev, bool set,
  384. unsigned int streams, unsigned int reg);
  385. void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start,
  386. unsigned int streams);
  387. void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev,
  388. unsigned int streams);
  389. /*
  390. * macros for easy use
  391. */
  392. #define _snd_hdac_stream_write(type, dev, reg, value) \
  393. ((dev)->bus->io_ops->reg_write ## type(value, (dev)->sd_addr + (reg)))
  394. #define _snd_hdac_stream_read(type, dev, reg) \
  395. ((dev)->bus->io_ops->reg_read ## type((dev)->sd_addr + (reg)))
  396. /* read/write a register, pass without AZX_REG_ prefix */
  397. #define snd_hdac_stream_writel(dev, reg, value) \
  398. _snd_hdac_stream_write(l, dev, AZX_REG_ ## reg, value)
  399. #define snd_hdac_stream_writew(dev, reg, value) \
  400. _snd_hdac_stream_write(w, dev, AZX_REG_ ## reg, value)
  401. #define snd_hdac_stream_writeb(dev, reg, value) \
  402. _snd_hdac_stream_write(b, dev, AZX_REG_ ## reg, value)
  403. #define snd_hdac_stream_readl(dev, reg) \
  404. _snd_hdac_stream_read(l, dev, AZX_REG_ ## reg)
  405. #define snd_hdac_stream_readw(dev, reg) \
  406. _snd_hdac_stream_read(w, dev, AZX_REG_ ## reg)
  407. #define snd_hdac_stream_readb(dev, reg) \
  408. _snd_hdac_stream_read(b, dev, AZX_REG_ ## reg)
  409. /* update a register, pass without AZX_REG_ prefix */
  410. #define snd_hdac_stream_updatel(dev, reg, mask, val) \
  411. snd_hdac_stream_writel(dev, reg, \
  412. (snd_hdac_stream_readl(dev, reg) & \
  413. ~(mask)) | (val))
  414. #define snd_hdac_stream_updatew(dev, reg, mask, val) \
  415. snd_hdac_stream_writew(dev, reg, \
  416. (snd_hdac_stream_readw(dev, reg) & \
  417. ~(mask)) | (val))
  418. #define snd_hdac_stream_updateb(dev, reg, mask, val) \
  419. snd_hdac_stream_writeb(dev, reg, \
  420. (snd_hdac_stream_readb(dev, reg) & \
  421. ~(mask)) | (val))
  422. #ifdef CONFIG_SND_HDA_DSP_LOADER
  423. /* DSP lock helpers */
  424. #define snd_hdac_dsp_lock_init(dev) mutex_init(&(dev)->dsp_mutex)
  425. #define snd_hdac_dsp_lock(dev) mutex_lock(&(dev)->dsp_mutex)
  426. #define snd_hdac_dsp_unlock(dev) mutex_unlock(&(dev)->dsp_mutex)
  427. #define snd_hdac_stream_is_locked(dev) ((dev)->locked)
  428. /* DSP loader helpers */
  429. int snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format,
  430. unsigned int byte_size, struct snd_dma_buffer *bufp);
  431. void snd_hdac_dsp_trigger(struct hdac_stream *azx_dev, bool start);
  432. void snd_hdac_dsp_cleanup(struct hdac_stream *azx_dev,
  433. struct snd_dma_buffer *dmab);
  434. #else /* CONFIG_SND_HDA_DSP_LOADER */
  435. #define snd_hdac_dsp_lock_init(dev) do {} while (0)
  436. #define snd_hdac_dsp_lock(dev) do {} while (0)
  437. #define snd_hdac_dsp_unlock(dev) do {} while (0)
  438. #define snd_hdac_stream_is_locked(dev) 0
  439. static inline int
  440. snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format,
  441. unsigned int byte_size, struct snd_dma_buffer *bufp)
  442. {
  443. return 0;
  444. }
  445. static inline void snd_hdac_dsp_trigger(struct hdac_stream *azx_dev, bool start)
  446. {
  447. }
  448. static inline void snd_hdac_dsp_cleanup(struct hdac_stream *azx_dev,
  449. struct snd_dma_buffer *dmab)
  450. {
  451. }
  452. #endif /* CONFIG_SND_HDA_DSP_LOADER */
  453. /*
  454. * generic array helpers
  455. */
  456. void *snd_array_new(struct snd_array *array);
  457. void snd_array_free(struct snd_array *array);
  458. static inline void snd_array_init(struct snd_array *array, unsigned int size,
  459. unsigned int align)
  460. {
  461. array->elem_size = size;
  462. array->alloc_align = align;
  463. }
  464. static inline void *snd_array_elem(struct snd_array *array, unsigned int idx)
  465. {
  466. return array->list + idx * array->elem_size;
  467. }
  468. static inline unsigned int snd_array_index(struct snd_array *array, void *ptr)
  469. {
  470. return (unsigned long)(ptr - array->list) / array->elem_size;
  471. }
  472. #endif /* __SOUND_HDAUDIO_H */