rsnd.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * Renesas R-Car
  3. *
  4. * Copyright (C) 2013 Renesas Solutions Corp.
  5. * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef RSND_H
  12. #define RSND_H
  13. #include <linux/clk.h>
  14. #include <linux/device.h>
  15. #include <linux/dma-mapping.h>
  16. #include <linux/io.h>
  17. #include <linux/list.h>
  18. #include <linux/module.h>
  19. #include <linux/of_device.h>
  20. #include <linux/of_irq.h>
  21. #include <linux/sh_dma.h>
  22. #include <linux/workqueue.h>
  23. #include <sound/rcar_snd.h>
  24. #include <sound/soc.h>
  25. #include <sound/pcm_params.h>
  26. /*
  27. * pseudo register
  28. *
  29. * The register address offsets SRU/SCU/SSIU on Gen1/Gen2 are very different.
  30. * This driver uses pseudo register in order to hide it.
  31. * see gen1/gen2 for detail
  32. */
  33. enum rsnd_reg {
  34. /* SRU/SCU/SSIU */
  35. RSND_REG_SSI_MODE0,
  36. RSND_REG_SSI_MODE1,
  37. RSND_REG_SRC_BUSIF_MODE,
  38. RSND_REG_SRC_ROUTE_MODE0,
  39. RSND_REG_SRC_SWRSR,
  40. RSND_REG_SRC_SRCIR,
  41. RSND_REG_SRC_ADINR,
  42. RSND_REG_SRC_IFSCR,
  43. RSND_REG_SRC_IFSVR,
  44. RSND_REG_SRC_SRCCR,
  45. RSND_REG_SCU_SYS_STATUS0,
  46. RSND_REG_SCU_SYS_INT_EN0,
  47. RSND_REG_CMD_ROUTE_SLCT,
  48. RSND_REG_CTU_CTUIR,
  49. RSND_REG_CTU_ADINR,
  50. RSND_REG_MIX_SWRSR,
  51. RSND_REG_MIX_MIXIR,
  52. RSND_REG_MIX_ADINR,
  53. RSND_REG_MIX_MIXMR,
  54. RSND_REG_MIX_MVPDR,
  55. RSND_REG_MIX_MDBAR,
  56. RSND_REG_MIX_MDBBR,
  57. RSND_REG_MIX_MDBCR,
  58. RSND_REG_MIX_MDBDR,
  59. RSND_REG_MIX_MDBER,
  60. RSND_REG_DVC_SWRSR,
  61. RSND_REG_DVC_DVUIR,
  62. RSND_REG_DVC_ADINR,
  63. RSND_REG_DVC_DVUCR,
  64. RSND_REG_DVC_ZCMCR,
  65. RSND_REG_DVC_VOL0R,
  66. RSND_REG_DVC_VOL1R,
  67. RSND_REG_DVC_DVUER,
  68. /* ADG */
  69. RSND_REG_BRRA,
  70. RSND_REG_BRRB,
  71. RSND_REG_SSICKR,
  72. RSND_REG_AUDIO_CLK_SEL0,
  73. RSND_REG_AUDIO_CLK_SEL1,
  74. /* SSI */
  75. RSND_REG_SSICR,
  76. RSND_REG_SSISR,
  77. RSND_REG_SSITDR,
  78. RSND_REG_SSIRDR,
  79. RSND_REG_SSIWSR,
  80. /* SHARE see below */
  81. RSND_REG_SHARE01,
  82. RSND_REG_SHARE02,
  83. RSND_REG_SHARE03,
  84. RSND_REG_SHARE04,
  85. RSND_REG_SHARE05,
  86. RSND_REG_SHARE06,
  87. RSND_REG_SHARE07,
  88. RSND_REG_SHARE08,
  89. RSND_REG_SHARE09,
  90. RSND_REG_SHARE10,
  91. RSND_REG_SHARE11,
  92. RSND_REG_SHARE12,
  93. RSND_REG_SHARE13,
  94. RSND_REG_SHARE14,
  95. RSND_REG_SHARE15,
  96. RSND_REG_SHARE16,
  97. RSND_REG_SHARE17,
  98. RSND_REG_SHARE18,
  99. RSND_REG_SHARE19,
  100. RSND_REG_SHARE20,
  101. RSND_REG_SHARE21,
  102. RSND_REG_SHARE22,
  103. RSND_REG_SHARE23,
  104. RSND_REG_SHARE24,
  105. RSND_REG_SHARE25,
  106. RSND_REG_SHARE26,
  107. RSND_REG_SHARE27,
  108. RSND_REG_SHARE28,
  109. RSND_REG_SHARE29,
  110. RSND_REG_MAX,
  111. };
  112. /* Gen1 only */
  113. #define RSND_REG_SRC_ROUTE_SEL RSND_REG_SHARE01
  114. #define RSND_REG_SRC_TMG_SEL0 RSND_REG_SHARE02
  115. #define RSND_REG_SRC_TMG_SEL1 RSND_REG_SHARE03
  116. #define RSND_REG_SRC_TMG_SEL2 RSND_REG_SHARE04
  117. #define RSND_REG_SRC_ROUTE_CTRL RSND_REG_SHARE05
  118. #define RSND_REG_SRC_MNFSR RSND_REG_SHARE06
  119. #define RSND_REG_AUDIO_CLK_SEL3 RSND_REG_SHARE07
  120. #define RSND_REG_AUDIO_CLK_SEL4 RSND_REG_SHARE08
  121. #define RSND_REG_AUDIO_CLK_SEL5 RSND_REG_SHARE09
  122. /* Gen2 only */
  123. #define RSND_REG_SRC_CTRL RSND_REG_SHARE01
  124. #define RSND_REG_SSI_CTRL RSND_REG_SHARE02
  125. #define RSND_REG_SSI_BUSIF_MODE RSND_REG_SHARE03
  126. #define RSND_REG_SSI_BUSIF_ADINR RSND_REG_SHARE04
  127. #define RSND_REG_SSI_INT_ENABLE RSND_REG_SHARE05
  128. #define RSND_REG_SRC_BSDSR RSND_REG_SHARE06
  129. #define RSND_REG_SRC_BSISR RSND_REG_SHARE07
  130. #define RSND_REG_DIV_EN RSND_REG_SHARE08
  131. #define RSND_REG_SRCIN_TIMSEL0 RSND_REG_SHARE09
  132. #define RSND_REG_SRCIN_TIMSEL1 RSND_REG_SHARE10
  133. #define RSND_REG_SRCIN_TIMSEL2 RSND_REG_SHARE11
  134. #define RSND_REG_SRCIN_TIMSEL3 RSND_REG_SHARE12
  135. #define RSND_REG_SRCIN_TIMSEL4 RSND_REG_SHARE13
  136. #define RSND_REG_SRCOUT_TIMSEL0 RSND_REG_SHARE14
  137. #define RSND_REG_SRCOUT_TIMSEL1 RSND_REG_SHARE15
  138. #define RSND_REG_SRCOUT_TIMSEL2 RSND_REG_SHARE16
  139. #define RSND_REG_SRCOUT_TIMSEL3 RSND_REG_SHARE17
  140. #define RSND_REG_SRCOUT_TIMSEL4 RSND_REG_SHARE18
  141. #define RSND_REG_AUDIO_CLK_SEL2 RSND_REG_SHARE19
  142. #define RSND_REG_CMD_CTRL RSND_REG_SHARE20
  143. #define RSND_REG_CMDOUT_TIMSEL RSND_REG_SHARE21
  144. #define RSND_REG_SSI_BUSIF_DALIGN RSND_REG_SHARE22
  145. #define RSND_REG_DVC_VRCTR RSND_REG_SHARE23
  146. #define RSND_REG_DVC_VRPDR RSND_REG_SHARE24
  147. #define RSND_REG_DVC_VRDBR RSND_REG_SHARE25
  148. #define RSND_REG_SCU_SYS_STATUS1 RSND_REG_SHARE26
  149. #define RSND_REG_SCU_SYS_INT_EN1 RSND_REG_SHARE27
  150. #define RSND_REG_SRC_INT_ENABLE0 RSND_REG_SHARE28
  151. #define RSND_REG_SRC_BUSIF_DALIGN RSND_REG_SHARE29
  152. struct rsnd_of_data;
  153. struct rsnd_priv;
  154. struct rsnd_mod;
  155. struct rsnd_dai;
  156. struct rsnd_dai_stream;
  157. /*
  158. * R-Car basic functions
  159. */
  160. #define rsnd_mod_read(m, r) \
  161. rsnd_read(rsnd_mod_to_priv(m), m, RSND_REG_##r)
  162. #define rsnd_mod_write(m, r, d) \
  163. rsnd_write(rsnd_mod_to_priv(m), m, RSND_REG_##r, d)
  164. #define rsnd_mod_force_write(m, r, d) \
  165. rsnd_force_write(rsnd_mod_to_priv(m), m, RSND_REG_##r, d)
  166. #define rsnd_mod_bset(m, r, s, d) \
  167. rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d)
  168. u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg);
  169. void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
  170. enum rsnd_reg reg, u32 data);
  171. void rsnd_force_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
  172. enum rsnd_reg reg, u32 data);
  173. void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg,
  174. u32 mask, u32 data);
  175. u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io);
  176. u32 rsnd_get_adinr_chan(struct rsnd_mod *mod, struct rsnd_dai_stream *io);
  177. u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io);
  178. void rsnd_path_parse(struct rsnd_priv *priv,
  179. struct rsnd_dai_stream *io);
  180. /*
  181. * R-Car DMA
  182. */
  183. struct rsnd_dma;
  184. struct rsnd_dmaen {
  185. struct dma_chan *chan;
  186. };
  187. struct rsnd_dmapp {
  188. int dmapp_id;
  189. u32 chcr;
  190. };
  191. struct rsnd_dma {
  192. struct rsnd_dma_ops *ops;
  193. dma_addr_t src_addr;
  194. dma_addr_t dst_addr;
  195. union {
  196. struct rsnd_dmaen en;
  197. struct rsnd_dmapp pp;
  198. } dma;
  199. };
  200. #define rsnd_dma_to_dmaen(dma) (&(dma)->dma.en)
  201. #define rsnd_dma_to_dmapp(dma) (&(dma)->dma.pp)
  202. void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
  203. void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
  204. int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id);
  205. void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
  206. int rsnd_dma_probe(struct platform_device *pdev,
  207. const struct rsnd_of_data *of_data,
  208. struct rsnd_priv *priv);
  209. struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node,
  210. struct rsnd_mod *mod, char *name);
  211. #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma)
  212. /*
  213. * R-Car sound mod
  214. */
  215. enum rsnd_mod_type {
  216. RSND_MOD_DVC = 0,
  217. RSND_MOD_MIX,
  218. RSND_MOD_CTU,
  219. RSND_MOD_SRC,
  220. RSND_MOD_SSI,
  221. RSND_MOD_MAX,
  222. };
  223. struct rsnd_mod_ops {
  224. char *name;
  225. struct dma_chan* (*dma_req)(struct rsnd_dai_stream *io,
  226. struct rsnd_mod *mod);
  227. int (*probe)(struct rsnd_mod *mod,
  228. struct rsnd_dai_stream *io,
  229. struct rsnd_priv *priv);
  230. int (*remove)(struct rsnd_mod *mod,
  231. struct rsnd_dai_stream *io,
  232. struct rsnd_priv *priv);
  233. int (*init)(struct rsnd_mod *mod,
  234. struct rsnd_dai_stream *io,
  235. struct rsnd_priv *priv);
  236. int (*quit)(struct rsnd_mod *mod,
  237. struct rsnd_dai_stream *io,
  238. struct rsnd_priv *priv);
  239. int (*start)(struct rsnd_mod *mod,
  240. struct rsnd_dai_stream *io,
  241. struct rsnd_priv *priv);
  242. int (*stop)(struct rsnd_mod *mod,
  243. struct rsnd_dai_stream *io,
  244. struct rsnd_priv *priv);
  245. int (*pcm_new)(struct rsnd_mod *mod,
  246. struct rsnd_dai_stream *io,
  247. struct snd_soc_pcm_runtime *rtd);
  248. int (*hw_params)(struct rsnd_mod *mod,
  249. struct rsnd_dai_stream *io,
  250. struct snd_pcm_substream *substream,
  251. struct snd_pcm_hw_params *hw_params);
  252. int (*fallback)(struct rsnd_mod *mod,
  253. struct rsnd_dai_stream *io,
  254. struct rsnd_priv *priv);
  255. };
  256. struct rsnd_dai_stream;
  257. struct rsnd_mod {
  258. int id;
  259. enum rsnd_mod_type type;
  260. struct rsnd_mod_ops *ops;
  261. struct rsnd_dma dma;
  262. struct rsnd_priv *priv;
  263. struct clk *clk;
  264. u32 status;
  265. };
  266. /*
  267. * status
  268. *
  269. * 0xH0000CBA
  270. *
  271. * A 0: probe 1: remove
  272. * B 0: init 1: quit
  273. * C 0: start 1: stop
  274. *
  275. * H is always called (see __rsnd_mod_call)
  276. * H 0: pcm_new
  277. * H 0: fallback
  278. * H 0: hw_params
  279. */
  280. #define __rsnd_mod_shift_probe 0
  281. #define __rsnd_mod_shift_remove 0
  282. #define __rsnd_mod_shift_init 4
  283. #define __rsnd_mod_shift_quit 4
  284. #define __rsnd_mod_shift_start 8
  285. #define __rsnd_mod_shift_stop 8
  286. #define __rsnd_mod_shift_pcm_new 28 /* always called */
  287. #define __rsnd_mod_shift_fallback 28 /* always called */
  288. #define __rsnd_mod_shift_hw_params 28 /* always called */
  289. #define __rsnd_mod_add_probe 1
  290. #define __rsnd_mod_add_remove -1
  291. #define __rsnd_mod_add_init 1
  292. #define __rsnd_mod_add_quit -1
  293. #define __rsnd_mod_add_start 1
  294. #define __rsnd_mod_add_stop -1
  295. #define __rsnd_mod_add_pcm_new 0
  296. #define __rsnd_mod_add_fallback 0
  297. #define __rsnd_mod_add_hw_params 0
  298. #define __rsnd_mod_call_probe 0
  299. #define __rsnd_mod_call_remove 1
  300. #define __rsnd_mod_call_init 0
  301. #define __rsnd_mod_call_quit 1
  302. #define __rsnd_mod_call_start 0
  303. #define __rsnd_mod_call_stop 1
  304. #define __rsnd_mod_call_pcm_new 0
  305. #define __rsnd_mod_call_fallback 0
  306. #define __rsnd_mod_call_hw_params 0
  307. #define rsnd_mod_to_priv(mod) ((mod)->priv)
  308. #define rsnd_mod_to_dma(mod) (&(mod)->dma)
  309. #define rsnd_mod_id(mod) ((mod) ? (mod)->id : -1)
  310. #define rsnd_mod_hw_start(mod) clk_enable((mod)->clk)
  311. #define rsnd_mod_hw_stop(mod) clk_disable((mod)->clk)
  312. int rsnd_mod_init(struct rsnd_priv *priv,
  313. struct rsnd_mod *mod,
  314. struct rsnd_mod_ops *ops,
  315. struct clk *clk,
  316. enum rsnd_mod_type type,
  317. int id);
  318. void rsnd_mod_quit(struct rsnd_mod *mod);
  319. char *rsnd_mod_name(struct rsnd_mod *mod);
  320. struct dma_chan *rsnd_mod_dma_req(struct rsnd_dai_stream *io,
  321. struct rsnd_mod *mod);
  322. void rsnd_mod_interrupt(struct rsnd_mod *mod,
  323. void (*callback)(struct rsnd_mod *mod,
  324. struct rsnd_dai_stream *io));
  325. /*
  326. * R-Car sound DAI
  327. */
  328. #define RSND_DAI_NAME_SIZE 16
  329. struct rsnd_dai_stream {
  330. char name[RSND_DAI_NAME_SIZE];
  331. struct snd_pcm_substream *substream;
  332. struct rsnd_mod *mod[RSND_MOD_MAX];
  333. struct rsnd_dai_path_info *info; /* rcar_snd.h */
  334. struct rsnd_dai *rdai;
  335. int byte_pos;
  336. int period_pos;
  337. int byte_per_period;
  338. int next_period_byte;
  339. };
  340. #define rsnd_io_to_mod(io, i) ((i) < RSND_MOD_MAX ? (io)->mod[(i)] : NULL)
  341. #define rsnd_io_to_mod_ssi(io) rsnd_io_to_mod((io), RSND_MOD_SSI)
  342. #define rsnd_io_to_mod_src(io) rsnd_io_to_mod((io), RSND_MOD_SRC)
  343. #define rsnd_io_to_mod_ctu(io) rsnd_io_to_mod((io), RSND_MOD_CTU)
  344. #define rsnd_io_to_mod_mix(io) rsnd_io_to_mod((io), RSND_MOD_MIX)
  345. #define rsnd_io_to_mod_dvc(io) rsnd_io_to_mod((io), RSND_MOD_DVC)
  346. #define rsnd_io_to_rdai(io) ((io)->rdai)
  347. #define rsnd_io_to_priv(io) (rsnd_rdai_to_priv(rsnd_io_to_rdai(io)))
  348. #define rsnd_io_is_play(io) (&rsnd_io_to_rdai(io)->playback == io)
  349. #define rsnd_io_to_runtime(io) ((io)->substream ? \
  350. (io)->substream->runtime : NULL)
  351. int rsnd_io_is_working(struct rsnd_dai_stream *io);
  352. struct rsnd_dai {
  353. char name[RSND_DAI_NAME_SIZE];
  354. struct rsnd_dai_stream playback;
  355. struct rsnd_dai_stream capture;
  356. struct rsnd_priv *priv;
  357. unsigned int clk_master:1;
  358. unsigned int bit_clk_inv:1;
  359. unsigned int frm_clk_inv:1;
  360. unsigned int sys_delay:1;
  361. unsigned int data_alignment:1;
  362. };
  363. #define rsnd_rdai_nr(priv) ((priv)->rdai_nr)
  364. #define rsnd_rdai_is_clk_master(rdai) ((rdai)->clk_master)
  365. #define rsnd_rdai_to_priv(rdai) ((rdai)->priv)
  366. #define for_each_rsnd_dai(rdai, priv, i) \
  367. for (i = 0; \
  368. (i < rsnd_rdai_nr(priv)) && \
  369. ((rdai) = rsnd_rdai_get(priv, i)); \
  370. i++)
  371. struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id);
  372. bool rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt);
  373. void rsnd_dai_period_elapsed(struct rsnd_dai_stream *io);
  374. int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional);
  375. /*
  376. * R-Car Gen1/Gen2
  377. */
  378. int rsnd_gen_probe(struct platform_device *pdev,
  379. const struct rsnd_of_data *of_data,
  380. struct rsnd_priv *priv);
  381. void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv,
  382. struct rsnd_mod *mod,
  383. enum rsnd_reg reg);
  384. phys_addr_t rsnd_gen_get_phy_addr(struct rsnd_priv *priv, int reg_id);
  385. #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1)
  386. #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2)
  387. /*
  388. * R-Car ADG
  389. */
  390. int rsnd_adg_ssi_clk_stop(struct rsnd_mod *mod);
  391. int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate);
  392. int rsnd_adg_probe(struct platform_device *pdev,
  393. const struct rsnd_of_data *of_data,
  394. struct rsnd_priv *priv);
  395. int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv,
  396. struct rsnd_mod *mod,
  397. unsigned int src_rate,
  398. unsigned int dst_rate);
  399. int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod,
  400. struct rsnd_dai_stream *io,
  401. unsigned int src_rate,
  402. unsigned int dst_rate);
  403. int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *mod,
  404. struct rsnd_dai_stream *io);
  405. int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *mod,
  406. struct rsnd_dai_stream *io);
  407. /*
  408. * R-Car sound priv
  409. */
  410. struct rsnd_of_data {
  411. u32 flags;
  412. };
  413. struct rsnd_priv {
  414. struct platform_device *pdev;
  415. struct rcar_snd_info *info;
  416. spinlock_t lock;
  417. /*
  418. * below value will be filled on rsnd_gen_probe()
  419. */
  420. void *gen;
  421. /*
  422. * below value will be filled on rsnd_adg_probe()
  423. */
  424. void *adg;
  425. /*
  426. * below value will be filled on rsnd_dma_probe()
  427. */
  428. void *dma;
  429. /*
  430. * below value will be filled on rsnd_ssi_probe()
  431. */
  432. void *ssi;
  433. int ssi_nr;
  434. /*
  435. * below value will be filled on rsnd_src_probe()
  436. */
  437. void *src;
  438. int src_nr;
  439. /*
  440. * below value will be filled on rsnd_ctu_probe()
  441. */
  442. void *ctu;
  443. int ctu_nr;
  444. /*
  445. * below value will be filled on rsnd_mix_probe()
  446. */
  447. void *mix;
  448. int mix_nr;
  449. /*
  450. * below value will be filled on rsnd_dvc_probe()
  451. */
  452. void *dvc;
  453. int dvc_nr;
  454. /*
  455. * below value will be filled on rsnd_dai_probe()
  456. */
  457. struct snd_soc_dai_driver *daidrv;
  458. struct rsnd_dai *rdai;
  459. int rdai_nr;
  460. };
  461. #define rsnd_priv_to_pdev(priv) ((priv)->pdev)
  462. #define rsnd_priv_to_dev(priv) (&(rsnd_priv_to_pdev(priv)->dev))
  463. #define rsnd_priv_to_info(priv) ((priv)->info)
  464. /*
  465. * rsnd_kctrl
  466. */
  467. struct rsnd_kctrl_cfg {
  468. unsigned int max;
  469. unsigned int size;
  470. u32 *val;
  471. const char * const *texts;
  472. void (*update)(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
  473. struct rsnd_dai_stream *io;
  474. struct snd_card *card;
  475. struct snd_kcontrol *kctrl;
  476. };
  477. #define RSND_DVC_CHANNELS 2
  478. struct rsnd_kctrl_cfg_m {
  479. struct rsnd_kctrl_cfg cfg;
  480. u32 val[RSND_DVC_CHANNELS];
  481. };
  482. struct rsnd_kctrl_cfg_s {
  483. struct rsnd_kctrl_cfg cfg;
  484. u32 val;
  485. };
  486. void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg);
  487. #define rsnd_kctrl_remove(_cfg) _rsnd_kctrl_remove(&((_cfg).cfg))
  488. int rsnd_kctrl_new_m(struct rsnd_mod *mod,
  489. struct rsnd_dai_stream *io,
  490. struct snd_soc_pcm_runtime *rtd,
  491. const unsigned char *name,
  492. void (*update)(struct rsnd_dai_stream *io,
  493. struct rsnd_mod *mod),
  494. struct rsnd_kctrl_cfg_m *_cfg,
  495. u32 max);
  496. int rsnd_kctrl_new_s(struct rsnd_mod *mod,
  497. struct rsnd_dai_stream *io,
  498. struct snd_soc_pcm_runtime *rtd,
  499. const unsigned char *name,
  500. void (*update)(struct rsnd_dai_stream *io,
  501. struct rsnd_mod *mod),
  502. struct rsnd_kctrl_cfg_s *_cfg,
  503. u32 max);
  504. int rsnd_kctrl_new_e(struct rsnd_mod *mod,
  505. struct rsnd_dai_stream *io,
  506. struct snd_soc_pcm_runtime *rtd,
  507. const unsigned char *name,
  508. struct rsnd_kctrl_cfg_s *_cfg,
  509. void (*update)(struct rsnd_dai_stream *io,
  510. struct rsnd_mod *mod),
  511. const char * const *texts,
  512. u32 max);
  513. /*
  514. * R-Car SSI
  515. */
  516. int rsnd_ssi_probe(struct platform_device *pdev,
  517. const struct rsnd_of_data *of_data,
  518. struct rsnd_priv *priv);
  519. void rsnd_ssi_remove(struct platform_device *pdev,
  520. struct rsnd_priv *priv);
  521. struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id);
  522. int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod);
  523. int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod);
  524. int rsnd_ssi_use_busif(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
  525. /*
  526. * R-Car SRC
  527. */
  528. int rsnd_src_probe(struct platform_device *pdev,
  529. const struct rsnd_of_data *of_data,
  530. struct rsnd_priv *priv);
  531. void rsnd_src_remove(struct platform_device *pdev,
  532. struct rsnd_priv *priv);
  533. struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id);
  534. unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv,
  535. struct rsnd_dai_stream *io,
  536. struct snd_pcm_runtime *runtime);
  537. int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod,
  538. struct rsnd_dai_stream *io,
  539. int use_busif);
  540. int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod,
  541. struct rsnd_dai_stream *io);
  542. int rsnd_src_ssi_irq_enable(struct rsnd_mod *ssi_mod);
  543. int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod);
  544. /*
  545. * R-Car CTU
  546. */
  547. int rsnd_ctu_probe(struct platform_device *pdev,
  548. const struct rsnd_of_data *of_data,
  549. struct rsnd_priv *priv);
  550. void rsnd_ctu_remove(struct platform_device *pdev,
  551. struct rsnd_priv *priv);
  552. struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id);
  553. /*
  554. * R-Car MIX
  555. */
  556. int rsnd_mix_probe(struct platform_device *pdev,
  557. const struct rsnd_of_data *of_data,
  558. struct rsnd_priv *priv);
  559. void rsnd_mix_remove(struct platform_device *pdev,
  560. struct rsnd_priv *priv);
  561. struct rsnd_mod *rsnd_mix_mod_get(struct rsnd_priv *priv, int id);
  562. /*
  563. * R-Car DVC
  564. */
  565. int rsnd_dvc_probe(struct platform_device *pdev,
  566. const struct rsnd_of_data *of_data,
  567. struct rsnd_priv *priv);
  568. void rsnd_dvc_remove(struct platform_device *pdev,
  569. struct rsnd_priv *priv);
  570. struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id);
  571. #endif