hdaudio.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  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. int snd_hdac_keep_power_up(struct hdac_device *codec);
  147. #else
  148. static inline int snd_hdac_power_up(struct hdac_device *codec) { return 0; }
  149. static inline int snd_hdac_power_down(struct hdac_device *codec) { return 0; }
  150. static inline int snd_hdac_power_up_pm(struct hdac_device *codec) { return 0; }
  151. static inline int snd_hdac_power_down_pm(struct hdac_device *codec) { return 0; }
  152. static inline int snd_hdac_keep_power_up(struct hdac_device *codec) { return 0; }
  153. #endif
  154. /*
  155. * HD-audio codec base driver
  156. */
  157. struct hdac_driver {
  158. struct device_driver driver;
  159. int type;
  160. const struct hda_device_id *id_table;
  161. int (*match)(struct hdac_device *dev, struct hdac_driver *drv);
  162. void (*unsol_event)(struct hdac_device *dev, unsigned int event);
  163. };
  164. #define drv_to_hdac_driver(_drv) container_of(_drv, struct hdac_driver, driver)
  165. const struct hda_device_id *
  166. hdac_get_device_id(struct hdac_device *hdev, struct hdac_driver *drv);
  167. /*
  168. * Bus verb operators
  169. */
  170. struct hdac_bus_ops {
  171. /* send a single command */
  172. int (*command)(struct hdac_bus *bus, unsigned int cmd);
  173. /* get a response from the last command */
  174. int (*get_response)(struct hdac_bus *bus, unsigned int addr,
  175. unsigned int *res);
  176. /* control the link power */
  177. int (*link_power)(struct hdac_bus *bus, bool enable);
  178. };
  179. /*
  180. * Lowlevel I/O operators
  181. */
  182. struct hdac_io_ops {
  183. /* mapped register accesses */
  184. void (*reg_writel)(u32 value, u32 __iomem *addr);
  185. u32 (*reg_readl)(u32 __iomem *addr);
  186. void (*reg_writew)(u16 value, u16 __iomem *addr);
  187. u16 (*reg_readw)(u16 __iomem *addr);
  188. void (*reg_writeb)(u8 value, u8 __iomem *addr);
  189. u8 (*reg_readb)(u8 __iomem *addr);
  190. /* Allocation ops */
  191. int (*dma_alloc_pages)(struct hdac_bus *bus, int type, size_t size,
  192. struct snd_dma_buffer *buf);
  193. void (*dma_free_pages)(struct hdac_bus *bus,
  194. struct snd_dma_buffer *buf);
  195. };
  196. #define HDA_UNSOL_QUEUE_SIZE 64
  197. #define HDA_MAX_CODECS 8 /* limit by controller side */
  198. /* HD Audio class code */
  199. #define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
  200. /*
  201. * CORB/RIRB
  202. *
  203. * Each CORB entry is 4byte, RIRB is 8byte
  204. */
  205. struct hdac_rb {
  206. __le32 *buf; /* virtual address of CORB/RIRB buffer */
  207. dma_addr_t addr; /* physical address of CORB/RIRB buffer */
  208. unsigned short rp, wp; /* RIRB read/write pointers */
  209. int cmds[HDA_MAX_CODECS]; /* number of pending requests */
  210. u32 res[HDA_MAX_CODECS]; /* last read value */
  211. };
  212. /*
  213. * HD-audio bus base driver
  214. *
  215. * @ppcap: pp capabilities pointer
  216. * @spbcap: SPIB capabilities pointer
  217. * @mlcap: MultiLink capabilities pointer
  218. * @gtscap: gts capabilities pointer
  219. * @drsmcap: dma resume capabilities pointer
  220. */
  221. struct hdac_bus {
  222. struct device *dev;
  223. const struct hdac_bus_ops *ops;
  224. const struct hdac_io_ops *io_ops;
  225. /* h/w resources */
  226. unsigned long addr;
  227. void __iomem *remap_addr;
  228. int irq;
  229. void __iomem *ppcap;
  230. void __iomem *spbcap;
  231. void __iomem *mlcap;
  232. void __iomem *gtscap;
  233. void __iomem *drsmcap;
  234. /* codec linked list */
  235. struct list_head codec_list;
  236. unsigned int num_codecs;
  237. /* link caddr -> codec */
  238. struct hdac_device *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1];
  239. /* unsolicited event queue */
  240. u32 unsol_queue[HDA_UNSOL_QUEUE_SIZE * 2]; /* ring buffer */
  241. unsigned int unsol_rp, unsol_wp;
  242. struct work_struct unsol_work;
  243. /* bit flags of detected codecs */
  244. unsigned long codec_mask;
  245. /* bit flags of powered codecs */
  246. unsigned long codec_powered;
  247. /* CORB/RIRB */
  248. struct hdac_rb corb;
  249. struct hdac_rb rirb;
  250. unsigned int last_cmd[HDA_MAX_CODECS]; /* last sent command */
  251. /* CORB/RIRB and position buffers */
  252. struct snd_dma_buffer rb;
  253. struct snd_dma_buffer posbuf;
  254. /* hdac_stream linked list */
  255. struct list_head stream_list;
  256. /* operation state */
  257. bool chip_init:1; /* h/w initialized */
  258. /* behavior flags */
  259. bool sync_write:1; /* sync after verb write */
  260. bool use_posbuf:1; /* use position buffer */
  261. bool snoop:1; /* enable snooping */
  262. bool align_bdle_4k:1; /* BDLE align 4K boundary */
  263. bool reverse_assign:1; /* assign devices in reverse order */
  264. bool corbrp_self_clear:1; /* CORBRP clears itself after reset */
  265. int bdl_pos_adj; /* BDL position adjustment */
  266. /* locks */
  267. spinlock_t reg_lock;
  268. struct mutex cmd_mutex;
  269. /* i915 component interface */
  270. struct i915_audio_component *audio_component;
  271. int i915_power_refcount;
  272. };
  273. int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev,
  274. const struct hdac_bus_ops *ops,
  275. const struct hdac_io_ops *io_ops);
  276. void snd_hdac_bus_exit(struct hdac_bus *bus);
  277. int snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsigned int addr,
  278. unsigned int cmd, unsigned int *res);
  279. int snd_hdac_bus_exec_verb_unlocked(struct hdac_bus *bus, unsigned int addr,
  280. unsigned int cmd, unsigned int *res);
  281. void snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex);
  282. int snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec);
  283. void snd_hdac_bus_remove_device(struct hdac_bus *bus,
  284. struct hdac_device *codec);
  285. static inline void snd_hdac_codec_link_up(struct hdac_device *codec)
  286. {
  287. set_bit(codec->addr, &codec->bus->codec_powered);
  288. }
  289. static inline void snd_hdac_codec_link_down(struct hdac_device *codec)
  290. {
  291. clear_bit(codec->addr, &codec->bus->codec_powered);
  292. }
  293. int snd_hdac_bus_send_cmd(struct hdac_bus *bus, unsigned int val);
  294. int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,
  295. unsigned int *res);
  296. int snd_hdac_bus_parse_capabilities(struct hdac_bus *bus);
  297. int snd_hdac_link_power(struct hdac_device *codec, bool enable);
  298. bool snd_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset);
  299. void snd_hdac_bus_stop_chip(struct hdac_bus *bus);
  300. void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus);
  301. void snd_hdac_bus_stop_cmd_io(struct hdac_bus *bus);
  302. void snd_hdac_bus_enter_link_reset(struct hdac_bus *bus);
  303. void snd_hdac_bus_exit_link_reset(struct hdac_bus *bus);
  304. void snd_hdac_bus_update_rirb(struct hdac_bus *bus);
  305. int snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
  306. void (*ack)(struct hdac_bus *,
  307. struct hdac_stream *));
  308. int snd_hdac_bus_alloc_stream_pages(struct hdac_bus *bus);
  309. void snd_hdac_bus_free_stream_pages(struct hdac_bus *bus);
  310. /*
  311. * macros for easy use
  312. */
  313. #define _snd_hdac_chip_write(type, chip, reg, value) \
  314. ((chip)->io_ops->reg_write ## type(value, (chip)->remap_addr + (reg)))
  315. #define _snd_hdac_chip_read(type, chip, reg) \
  316. ((chip)->io_ops->reg_read ## type((chip)->remap_addr + (reg)))
  317. /* read/write a register, pass without AZX_REG_ prefix */
  318. #define snd_hdac_chip_writel(chip, reg, value) \
  319. _snd_hdac_chip_write(l, chip, AZX_REG_ ## reg, value)
  320. #define snd_hdac_chip_writew(chip, reg, value) \
  321. _snd_hdac_chip_write(w, chip, AZX_REG_ ## reg, value)
  322. #define snd_hdac_chip_writeb(chip, reg, value) \
  323. _snd_hdac_chip_write(b, chip, AZX_REG_ ## reg, value)
  324. #define snd_hdac_chip_readl(chip, reg) \
  325. _snd_hdac_chip_read(l, chip, AZX_REG_ ## reg)
  326. #define snd_hdac_chip_readw(chip, reg) \
  327. _snd_hdac_chip_read(w, chip, AZX_REG_ ## reg)
  328. #define snd_hdac_chip_readb(chip, reg) \
  329. _snd_hdac_chip_read(b, chip, AZX_REG_ ## reg)
  330. /* update a register, pass without AZX_REG_ prefix */
  331. #define snd_hdac_chip_updatel(chip, reg, mask, val) \
  332. snd_hdac_chip_writel(chip, reg, \
  333. (snd_hdac_chip_readl(chip, reg) & ~(mask)) | (val))
  334. #define snd_hdac_chip_updatew(chip, reg, mask, val) \
  335. snd_hdac_chip_writew(chip, reg, \
  336. (snd_hdac_chip_readw(chip, reg) & ~(mask)) | (val))
  337. #define snd_hdac_chip_updateb(chip, reg, mask, val) \
  338. snd_hdac_chip_writeb(chip, reg, \
  339. (snd_hdac_chip_readb(chip, reg) & ~(mask)) | (val))
  340. /*
  341. * HD-audio stream
  342. */
  343. struct hdac_stream {
  344. struct hdac_bus *bus;
  345. struct snd_dma_buffer bdl; /* BDL buffer */
  346. __le32 *posbuf; /* position buffer pointer */
  347. int direction; /* playback / capture (SNDRV_PCM_STREAM_*) */
  348. unsigned int bufsize; /* size of the play buffer in bytes */
  349. unsigned int period_bytes; /* size of the period in bytes */
  350. unsigned int frags; /* number for period in the play buffer */
  351. unsigned int fifo_size; /* FIFO size */
  352. void __iomem *sd_addr; /* stream descriptor pointer */
  353. u32 sd_int_sta_mask; /* stream int status mask */
  354. /* pcm support */
  355. struct snd_pcm_substream *substream; /* assigned substream,
  356. * set in PCM open
  357. */
  358. unsigned int format_val; /* format value to be set in the
  359. * controller and the codec
  360. */
  361. unsigned char stream_tag; /* assigned stream */
  362. unsigned char index; /* stream index */
  363. int assigned_key; /* last device# key assigned to */
  364. bool opened:1;
  365. bool running:1;
  366. bool prepared:1;
  367. bool no_period_wakeup:1;
  368. bool locked:1;
  369. /* timestamp */
  370. unsigned long start_wallclk; /* start + minimum wallclk */
  371. unsigned long period_wallclk; /* wallclk for period */
  372. struct timecounter tc;
  373. struct cyclecounter cc;
  374. int delay_negative_threshold;
  375. struct list_head list;
  376. #ifdef CONFIG_SND_HDA_DSP_LOADER
  377. /* DSP access mutex */
  378. struct mutex dsp_mutex;
  379. #endif
  380. };
  381. void snd_hdac_stream_init(struct hdac_bus *bus, struct hdac_stream *azx_dev,
  382. int idx, int direction, int tag);
  383. struct hdac_stream *snd_hdac_stream_assign(struct hdac_bus *bus,
  384. struct snd_pcm_substream *substream);
  385. void snd_hdac_stream_release(struct hdac_stream *azx_dev);
  386. struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus,
  387. int dir, int stream_tag);
  388. int snd_hdac_stream_setup(struct hdac_stream *azx_dev);
  389. void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev);
  390. int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev);
  391. int snd_hdac_stream_set_params(struct hdac_stream *azx_dev,
  392. unsigned int format_val);
  393. void snd_hdac_stream_start(struct hdac_stream *azx_dev, bool fresh_start);
  394. void snd_hdac_stream_clear(struct hdac_stream *azx_dev);
  395. void snd_hdac_stream_stop(struct hdac_stream *azx_dev);
  396. void snd_hdac_stream_reset(struct hdac_stream *azx_dev);
  397. void snd_hdac_stream_sync_trigger(struct hdac_stream *azx_dev, bool set,
  398. unsigned int streams, unsigned int reg);
  399. void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start,
  400. unsigned int streams);
  401. void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev,
  402. unsigned int streams);
  403. /*
  404. * macros for easy use
  405. */
  406. #define _snd_hdac_stream_write(type, dev, reg, value) \
  407. ((dev)->bus->io_ops->reg_write ## type(value, (dev)->sd_addr + (reg)))
  408. #define _snd_hdac_stream_read(type, dev, reg) \
  409. ((dev)->bus->io_ops->reg_read ## type((dev)->sd_addr + (reg)))
  410. /* read/write a register, pass without AZX_REG_ prefix */
  411. #define snd_hdac_stream_writel(dev, reg, value) \
  412. _snd_hdac_stream_write(l, dev, AZX_REG_ ## reg, value)
  413. #define snd_hdac_stream_writew(dev, reg, value) \
  414. _snd_hdac_stream_write(w, dev, AZX_REG_ ## reg, value)
  415. #define snd_hdac_stream_writeb(dev, reg, value) \
  416. _snd_hdac_stream_write(b, dev, AZX_REG_ ## reg, value)
  417. #define snd_hdac_stream_readl(dev, reg) \
  418. _snd_hdac_stream_read(l, dev, AZX_REG_ ## reg)
  419. #define snd_hdac_stream_readw(dev, reg) \
  420. _snd_hdac_stream_read(w, dev, AZX_REG_ ## reg)
  421. #define snd_hdac_stream_readb(dev, reg) \
  422. _snd_hdac_stream_read(b, dev, AZX_REG_ ## reg)
  423. /* update a register, pass without AZX_REG_ prefix */
  424. #define snd_hdac_stream_updatel(dev, reg, mask, val) \
  425. snd_hdac_stream_writel(dev, reg, \
  426. (snd_hdac_stream_readl(dev, reg) & \
  427. ~(mask)) | (val))
  428. #define snd_hdac_stream_updatew(dev, reg, mask, val) \
  429. snd_hdac_stream_writew(dev, reg, \
  430. (snd_hdac_stream_readw(dev, reg) & \
  431. ~(mask)) | (val))
  432. #define snd_hdac_stream_updateb(dev, reg, mask, val) \
  433. snd_hdac_stream_writeb(dev, reg, \
  434. (snd_hdac_stream_readb(dev, reg) & \
  435. ~(mask)) | (val))
  436. #ifdef CONFIG_SND_HDA_DSP_LOADER
  437. /* DSP lock helpers */
  438. #define snd_hdac_dsp_lock_init(dev) mutex_init(&(dev)->dsp_mutex)
  439. #define snd_hdac_dsp_lock(dev) mutex_lock(&(dev)->dsp_mutex)
  440. #define snd_hdac_dsp_unlock(dev) mutex_unlock(&(dev)->dsp_mutex)
  441. #define snd_hdac_stream_is_locked(dev) ((dev)->locked)
  442. /* DSP loader helpers */
  443. int snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format,
  444. unsigned int byte_size, struct snd_dma_buffer *bufp);
  445. void snd_hdac_dsp_trigger(struct hdac_stream *azx_dev, bool start);
  446. void snd_hdac_dsp_cleanup(struct hdac_stream *azx_dev,
  447. struct snd_dma_buffer *dmab);
  448. #else /* CONFIG_SND_HDA_DSP_LOADER */
  449. #define snd_hdac_dsp_lock_init(dev) do {} while (0)
  450. #define snd_hdac_dsp_lock(dev) do {} while (0)
  451. #define snd_hdac_dsp_unlock(dev) do {} while (0)
  452. #define snd_hdac_stream_is_locked(dev) 0
  453. static inline int
  454. snd_hdac_dsp_prepare(struct hdac_stream *azx_dev, unsigned int format,
  455. unsigned int byte_size, struct snd_dma_buffer *bufp)
  456. {
  457. return 0;
  458. }
  459. static inline void snd_hdac_dsp_trigger(struct hdac_stream *azx_dev, bool start)
  460. {
  461. }
  462. static inline void snd_hdac_dsp_cleanup(struct hdac_stream *azx_dev,
  463. struct snd_dma_buffer *dmab)
  464. {
  465. }
  466. #endif /* CONFIG_SND_HDA_DSP_LOADER */
  467. /*
  468. * generic array helpers
  469. */
  470. void *snd_array_new(struct snd_array *array);
  471. void snd_array_free(struct snd_array *array);
  472. static inline void snd_array_init(struct snd_array *array, unsigned int size,
  473. unsigned int align)
  474. {
  475. array->elem_size = size;
  476. array->alloc_align = align;
  477. }
  478. static inline void *snd_array_elem(struct snd_array *array, unsigned int idx)
  479. {
  480. return array->list + idx * array->elem_size;
  481. }
  482. static inline unsigned int snd_array_index(struct snd_array *array, void *ptr)
  483. {
  484. return (unsigned long)(ptr - array->list) / array->elem_size;
  485. }
  486. #endif /* __SOUND_HDAUDIO_H */