diff options
Diffstat (limited to 'sound/soc/sh/rcar/rsnd.h')
-rw-r--r-- | sound/soc/sh/rcar/rsnd.h | 81 |
1 files changed, 44 insertions, 37 deletions
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 5826c8abf794..e7914bd610e2 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
@@ -44,6 +44,8 @@ enum rsnd_reg { | |||
44 | RSND_REG_SRC_IFSCR, | 44 | RSND_REG_SRC_IFSCR, |
45 | RSND_REG_SRC_IFSVR, | 45 | RSND_REG_SRC_IFSVR, |
46 | RSND_REG_SRC_SRCCR, | 46 | RSND_REG_SRC_SRCCR, |
47 | RSND_REG_SCU_SYS_STATUS0, | ||
48 | RSND_REG_SCU_SYS_INT_EN0, | ||
47 | RSND_REG_CMD_ROUTE_SLCT, | 49 | RSND_REG_CMD_ROUTE_SLCT, |
48 | RSND_REG_DVC_SWRSR, | 50 | RSND_REG_DVC_SWRSR, |
49 | RSND_REG_DVC_DVUIR, | 51 | RSND_REG_DVC_DVUIR, |
@@ -94,6 +96,9 @@ enum rsnd_reg { | |||
94 | RSND_REG_SHARE23, | 96 | RSND_REG_SHARE23, |
95 | RSND_REG_SHARE24, | 97 | RSND_REG_SHARE24, |
96 | RSND_REG_SHARE25, | 98 | RSND_REG_SHARE25, |
99 | RSND_REG_SHARE26, | ||
100 | RSND_REG_SHARE27, | ||
101 | RSND_REG_SHARE28, | ||
97 | 102 | ||
98 | RSND_REG_MAX, | 103 | RSND_REG_MAX, |
99 | }; | 104 | }; |
@@ -135,6 +140,9 @@ enum rsnd_reg { | |||
135 | #define RSND_REG_DVC_VRCTR RSND_REG_SHARE23 | 140 | #define RSND_REG_DVC_VRCTR RSND_REG_SHARE23 |
136 | #define RSND_REG_DVC_VRPDR RSND_REG_SHARE24 | 141 | #define RSND_REG_DVC_VRPDR RSND_REG_SHARE24 |
137 | #define RSND_REG_DVC_VRDBR RSND_REG_SHARE25 | 142 | #define RSND_REG_DVC_VRDBR RSND_REG_SHARE25 |
143 | #define RSND_REG_SCU_SYS_STATUS1 RSND_REG_SHARE26 | ||
144 | #define RSND_REG_SCU_SYS_INT_EN1 RSND_REG_SHARE27 | ||
145 | #define RSND_REG_SRC_INT_ENABLE0 RSND_REG_SHARE28 | ||
138 | 146 | ||
139 | struct rsnd_of_data; | 147 | struct rsnd_of_data; |
140 | struct rsnd_priv; | 148 | struct rsnd_priv; |
@@ -182,9 +190,9 @@ void rsnd_dma_quit(struct rsnd_priv *priv, | |||
182 | * R-Car sound mod | 190 | * R-Car sound mod |
183 | */ | 191 | */ |
184 | enum rsnd_mod_type { | 192 | enum rsnd_mod_type { |
185 | RSND_MOD_SRC = 0, | 193 | RSND_MOD_DVC = 0, |
194 | RSND_MOD_SRC, | ||
186 | RSND_MOD_SSI, | 195 | RSND_MOD_SSI, |
187 | RSND_MOD_DVC, | ||
188 | RSND_MOD_MAX, | 196 | RSND_MOD_MAX, |
189 | }; | 197 | }; |
190 | 198 | ||
@@ -192,32 +200,31 @@ struct rsnd_mod_ops { | |||
192 | char *name; | 200 | char *name; |
193 | char* (*dma_name)(struct rsnd_mod *mod); | 201 | char* (*dma_name)(struct rsnd_mod *mod); |
194 | int (*probe)(struct rsnd_mod *mod, | 202 | int (*probe)(struct rsnd_mod *mod, |
195 | struct rsnd_dai *rdai); | 203 | struct rsnd_priv *priv); |
196 | int (*remove)(struct rsnd_mod *mod, | 204 | int (*remove)(struct rsnd_mod *mod, |
197 | struct rsnd_dai *rdai); | 205 | struct rsnd_priv *priv); |
198 | int (*init)(struct rsnd_mod *mod, | 206 | int (*init)(struct rsnd_mod *mod, |
199 | struct rsnd_dai *rdai); | 207 | struct rsnd_priv *priv); |
200 | int (*quit)(struct rsnd_mod *mod, | 208 | int (*quit)(struct rsnd_mod *mod, |
201 | struct rsnd_dai *rdai); | 209 | struct rsnd_priv *priv); |
202 | int (*start)(struct rsnd_mod *mod, | 210 | int (*start)(struct rsnd_mod *mod, |
203 | struct rsnd_dai *rdai); | 211 | struct rsnd_priv *priv); |
204 | int (*stop)(struct rsnd_mod *mod, | 212 | int (*stop)(struct rsnd_mod *mod, |
205 | struct rsnd_dai *rdai); | 213 | struct rsnd_priv *priv); |
206 | int (*pcm_new)(struct rsnd_mod *mod, | 214 | int (*pcm_new)(struct rsnd_mod *mod, |
207 | struct rsnd_dai *rdai, | ||
208 | struct snd_soc_pcm_runtime *rtd); | 215 | struct snd_soc_pcm_runtime *rtd); |
209 | int (*fallback)(struct rsnd_mod *mod, | 216 | int (*fallback)(struct rsnd_mod *mod, |
210 | struct rsnd_dai *rdai); | 217 | struct rsnd_priv *priv); |
211 | }; | 218 | }; |
212 | 219 | ||
213 | struct rsnd_dai_stream; | 220 | struct rsnd_dai_stream; |
214 | struct rsnd_mod { | 221 | struct rsnd_mod { |
215 | int id; | 222 | int id; |
216 | enum rsnd_mod_type type; | 223 | enum rsnd_mod_type type; |
217 | struct rsnd_priv *priv; | ||
218 | struct rsnd_mod_ops *ops; | 224 | struct rsnd_mod_ops *ops; |
219 | struct rsnd_dma dma; | 225 | struct rsnd_dma dma; |
220 | struct rsnd_dai_stream *io; | 226 | struct rsnd_dai_stream *io; |
227 | struct clk *clk; | ||
221 | u32 status; | 228 | u32 status; |
222 | }; | 229 | }; |
223 | /* | 230 | /* |
@@ -248,15 +255,17 @@ struct rsnd_mod { | |||
248 | #define __rsnd_mod_call_pcm_new 0 | 255 | #define __rsnd_mod_call_pcm_new 0 |
249 | #define __rsnd_mod_call_fallback 0 | 256 | #define __rsnd_mod_call_fallback 0 |
250 | 257 | ||
251 | #define rsnd_mod_to_priv(mod) ((mod)->priv) | 258 | #define rsnd_mod_to_priv(mod) (rsnd_io_to_priv(rsnd_mod_to_io(mod))) |
252 | #define rsnd_mod_to_dma(mod) (&(mod)->dma) | 259 | #define rsnd_mod_to_dma(mod) (&(mod)->dma) |
253 | #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) | 260 | #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) |
254 | #define rsnd_mod_to_io(mod) ((mod)->io) | 261 | #define rsnd_mod_to_io(mod) ((mod)->io) |
255 | #define rsnd_mod_id(mod) ((mod)->id) | 262 | #define rsnd_mod_id(mod) ((mod)->id) |
263 | #define rsnd_mod_hw_start(mod) clk_prepare_enable((mod)->clk) | ||
264 | #define rsnd_mod_hw_stop(mod) clk_disable_unprepare((mod)->clk) | ||
256 | 265 | ||
257 | void rsnd_mod_init(struct rsnd_priv *priv, | 266 | void rsnd_mod_init(struct rsnd_mod *mod, |
258 | struct rsnd_mod *mod, | ||
259 | struct rsnd_mod_ops *ops, | 267 | struct rsnd_mod_ops *ops, |
268 | struct clk *clk, | ||
260 | enum rsnd_mod_type type, | 269 | enum rsnd_mod_type type, |
261 | int id); | 270 | int id); |
262 | char *rsnd_mod_name(struct rsnd_mod *mod); | 271 | char *rsnd_mod_name(struct rsnd_mod *mod); |
@@ -270,6 +279,7 @@ struct rsnd_dai_stream { | |||
270 | struct snd_pcm_substream *substream; | 279 | struct snd_pcm_substream *substream; |
271 | struct rsnd_mod *mod[RSND_MOD_MAX]; | 280 | struct rsnd_mod *mod[RSND_MOD_MAX]; |
272 | struct rsnd_dai_path_info *info; /* rcar_snd.h */ | 281 | struct rsnd_dai_path_info *info; /* rcar_snd.h */ |
282 | struct rsnd_dai *rdai; | ||
273 | int byte_pos; | 283 | int byte_pos; |
274 | int period_pos; | 284 | int period_pos; |
275 | int byte_per_period; | 285 | int byte_per_period; |
@@ -278,12 +288,18 @@ struct rsnd_dai_stream { | |||
278 | #define rsnd_io_to_mod_ssi(io) ((io)->mod[RSND_MOD_SSI]) | 288 | #define rsnd_io_to_mod_ssi(io) ((io)->mod[RSND_MOD_SSI]) |
279 | #define rsnd_io_to_mod_src(io) ((io)->mod[RSND_MOD_SRC]) | 289 | #define rsnd_io_to_mod_src(io) ((io)->mod[RSND_MOD_SRC]) |
280 | #define rsnd_io_to_mod_dvc(io) ((io)->mod[RSND_MOD_DVC]) | 290 | #define rsnd_io_to_mod_dvc(io) ((io)->mod[RSND_MOD_DVC]) |
291 | #define rsnd_io_to_rdai(io) ((io)->rdai) | ||
292 | #define rsnd_io_to_priv(io) (rsnd_rdai_to_priv(rsnd_io_to_rdai(io))) | ||
293 | #define rsnd_io_is_play(io) (&rsnd_io_to_rdai(io)->playback == io) | ||
294 | #define rsnd_io_to_runtime(io) ((io)->substream ? \ | ||
295 | (io)->substream->runtime : NULL) | ||
296 | |||
281 | 297 | ||
282 | struct rsnd_dai { | 298 | struct rsnd_dai { |
283 | char name[RSND_DAI_NAME_SIZE]; | 299 | char name[RSND_DAI_NAME_SIZE]; |
284 | struct rsnd_dai_platform_info *info; /* rcar_snd.h */ | ||
285 | struct rsnd_dai_stream playback; | 300 | struct rsnd_dai_stream playback; |
286 | struct rsnd_dai_stream capture; | 301 | struct rsnd_dai_stream capture; |
302 | struct rsnd_priv *priv; | ||
287 | 303 | ||
288 | unsigned int clk_master:1; | 304 | unsigned int clk_master:1; |
289 | unsigned int bit_clk_inv:1; | 305 | unsigned int bit_clk_inv:1; |
@@ -293,22 +309,18 @@ struct rsnd_dai { | |||
293 | }; | 309 | }; |
294 | 310 | ||
295 | #define rsnd_rdai_nr(priv) ((priv)->rdai_nr) | 311 | #define rsnd_rdai_nr(priv) ((priv)->rdai_nr) |
312 | #define rsnd_rdai_is_clk_master(rdai) ((rdai)->clk_master) | ||
313 | #define rsnd_rdai_to_priv(rdai) ((rdai)->priv) | ||
296 | #define for_each_rsnd_dai(rdai, priv, i) \ | 314 | #define for_each_rsnd_dai(rdai, priv, i) \ |
297 | for (i = 0; \ | 315 | for (i = 0; \ |
298 | (i < rsnd_rdai_nr(priv)) && \ | 316 | (i < rsnd_rdai_nr(priv)) && \ |
299 | ((rdai) = rsnd_dai_get(priv, i)); \ | 317 | ((rdai) = rsnd_rdai_get(priv, i)); \ |
300 | i++) | 318 | i++) |
301 | 319 | ||
302 | struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id); | 320 | struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id); |
303 | int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io); | ||
304 | int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai); | ||
305 | #define rsnd_dai_get_platform_info(rdai) ((rdai)->info) | ||
306 | #define rsnd_io_to_runtime(io) ((io)->substream ? \ | ||
307 | (io)->substream->runtime : NULL) | ||
308 | 321 | ||
309 | void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt); | 322 | void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt); |
310 | int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional); | 323 | int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional); |
311 | #define rsnd_dai_is_clk_master(rdai) ((rdai)->clk_master) | ||
312 | 324 | ||
313 | /* | 325 | /* |
314 | * R-Car Gen1/Gen2 | 326 | * R-Car Gen1/Gen2 |
@@ -339,15 +351,12 @@ int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv, | |||
339 | unsigned int src_rate, | 351 | unsigned int src_rate, |
340 | unsigned int dst_rate); | 352 | unsigned int dst_rate); |
341 | int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod, | 353 | int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod, |
342 | struct rsnd_dai *rdai, | ||
343 | struct rsnd_dai_stream *io, | 354 | struct rsnd_dai_stream *io, |
344 | unsigned int src_rate, | 355 | unsigned int src_rate, |
345 | unsigned int dst_rate); | 356 | unsigned int dst_rate); |
346 | int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *mod, | 357 | int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *mod, |
347 | struct rsnd_dai *rdai, | ||
348 | struct rsnd_dai_stream *io); | 358 | struct rsnd_dai_stream *io); |
349 | int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_dai *rdai, | 359 | int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *mod, |
350 | struct rsnd_mod *mod, | ||
351 | struct rsnd_dai_stream *io); | 360 | struct rsnd_dai_stream *io); |
352 | 361 | ||
353 | /* | 362 | /* |
@@ -427,6 +436,8 @@ struct rsnd_kctrl_cfg { | |||
427 | u32 *val; | 436 | u32 *val; |
428 | const char * const *texts; | 437 | const char * const *texts; |
429 | void (*update)(struct rsnd_mod *mod); | 438 | void (*update)(struct rsnd_mod *mod); |
439 | struct snd_card *card; | ||
440 | struct snd_kcontrol *kctrl; | ||
430 | }; | 441 | }; |
431 | 442 | ||
432 | #define RSND_DVC_CHANNELS 2 | 443 | #define RSND_DVC_CHANNELS 2 |
@@ -440,22 +451,22 @@ struct rsnd_kctrl_cfg_s { | |||
440 | u32 val; | 451 | u32 val; |
441 | }; | 452 | }; |
442 | 453 | ||
454 | void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg); | ||
455 | #define rsnd_kctrl_remove(_cfg) _rsnd_kctrl_remove(&((_cfg).cfg)) | ||
456 | |||
443 | int rsnd_kctrl_new_m(struct rsnd_mod *mod, | 457 | int rsnd_kctrl_new_m(struct rsnd_mod *mod, |
444 | struct rsnd_dai *rdai, | ||
445 | struct snd_soc_pcm_runtime *rtd, | 458 | struct snd_soc_pcm_runtime *rtd, |
446 | const unsigned char *name, | 459 | const unsigned char *name, |
447 | void (*update)(struct rsnd_mod *mod), | 460 | void (*update)(struct rsnd_mod *mod), |
448 | struct rsnd_kctrl_cfg_m *_cfg, | 461 | struct rsnd_kctrl_cfg_m *_cfg, |
449 | u32 max); | 462 | u32 max); |
450 | int rsnd_kctrl_new_s(struct rsnd_mod *mod, | 463 | int rsnd_kctrl_new_s(struct rsnd_mod *mod, |
451 | struct rsnd_dai *rdai, | ||
452 | struct snd_soc_pcm_runtime *rtd, | 464 | struct snd_soc_pcm_runtime *rtd, |
453 | const unsigned char *name, | 465 | const unsigned char *name, |
454 | void (*update)(struct rsnd_mod *mod), | 466 | void (*update)(struct rsnd_mod *mod), |
455 | struct rsnd_kctrl_cfg_s *_cfg, | 467 | struct rsnd_kctrl_cfg_s *_cfg, |
456 | u32 max); | 468 | u32 max); |
457 | int rsnd_kctrl_new_e(struct rsnd_mod *mod, | 469 | int rsnd_kctrl_new_e(struct rsnd_mod *mod, |
458 | struct rsnd_dai *rdai, | ||
459 | struct snd_soc_pcm_runtime *rtd, | 470 | struct snd_soc_pcm_runtime *rtd, |
460 | const unsigned char *name, | 471 | const unsigned char *name, |
461 | struct rsnd_kctrl_cfg_s *_cfg, | 472 | struct rsnd_kctrl_cfg_s *_cfg, |
@@ -474,14 +485,10 @@ unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv, | |||
474 | struct rsnd_dai_stream *io, | 485 | struct rsnd_dai_stream *io, |
475 | struct snd_pcm_runtime *runtime); | 486 | struct snd_pcm_runtime *runtime); |
476 | int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, | 487 | int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, |
477 | struct rsnd_dai *rdai, | ||
478 | int use_busif); | 488 | int use_busif); |
479 | int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod, | 489 | int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod); |
480 | struct rsnd_dai *rdai); | 490 | int rsnd_src_ssi_irq_enable(struct rsnd_mod *ssi_mod); |
481 | int rsnd_src_ssi_irq_enable(struct rsnd_mod *ssi_mod, | 491 | int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod); |
482 | struct rsnd_dai *rdai); | ||
483 | int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod, | ||
484 | struct rsnd_dai *rdai); | ||
485 | 492 | ||
486 | #define rsnd_src_nr(priv) ((priv)->src_nr) | 493 | #define rsnd_src_nr(priv) ((priv)->src_nr) |
487 | 494 | ||