diff options
Diffstat (limited to 'sound/soc/sh/rcar/rsnd.h')
| -rw-r--r-- | sound/soc/sh/rcar/rsnd.h | 92 |
1 files changed, 61 insertions, 31 deletions
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index e7914bd610e2..4e6de6804cfb 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
| @@ -170,21 +170,47 @@ u32 rsnd_get_adinr(struct rsnd_mod *mod); | |||
| 170 | /* | 170 | /* |
| 171 | * R-Car DMA | 171 | * R-Car DMA |
| 172 | */ | 172 | */ |
| 173 | struct rsnd_dma { | 173 | struct rsnd_dma; |
| 174 | struct sh_dmae_slave slave; | 174 | struct rsnd_dma_ops { |
| 175 | void (*start)(struct rsnd_dma *dma); | ||
| 176 | void (*stop)(struct rsnd_dma *dma); | ||
| 177 | int (*init)(struct rsnd_priv *priv, struct rsnd_dma *dma, int id, | ||
| 178 | struct rsnd_mod *mod_from, struct rsnd_mod *mod_to); | ||
| 179 | void (*quit)(struct rsnd_dma *dma); | ||
| 180 | }; | ||
| 181 | |||
| 182 | struct rsnd_dmaen { | ||
| 175 | struct dma_chan *chan; | 183 | struct dma_chan *chan; |
| 176 | enum dma_transfer_direction dir; | ||
| 177 | dma_addr_t addr; | ||
| 178 | }; | 184 | }; |
| 179 | 185 | ||
| 186 | struct rsnd_dmapp { | ||
| 187 | int dmapp_id; | ||
| 188 | u32 chcr; | ||
| 189 | }; | ||
| 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 | |||
| 180 | void rsnd_dma_start(struct rsnd_dma *dma); | 203 | void rsnd_dma_start(struct rsnd_dma *dma); |
| 181 | void rsnd_dma_stop(struct rsnd_dma *dma); | 204 | void rsnd_dma_stop(struct rsnd_dma *dma); |
| 182 | int rsnd_dma_available(struct rsnd_dma *dma); | 205 | int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, int id); |
| 183 | int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, | 206 | void rsnd_dma_quit(struct rsnd_dma *dma); |
| 184 | int is_play, int id); | 207 | int rsnd_dma_probe(struct platform_device *pdev, |
| 185 | void rsnd_dma_quit(struct rsnd_priv *priv, | 208 | const struct rsnd_of_data *of_data, |
| 186 | struct rsnd_dma *dma); | 209 | struct rsnd_priv *priv); |
| 210 | struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, | ||
| 211 | struct rsnd_mod *mod, char *name); | ||
| 187 | 212 | ||
| 213 | #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) | ||
| 188 | 214 | ||
| 189 | /* | 215 | /* |
| 190 | * R-Car sound mod | 216 | * R-Car sound mod |
| @@ -198,7 +224,7 @@ enum rsnd_mod_type { | |||
| 198 | 224 | ||
| 199 | struct rsnd_mod_ops { | 225 | struct rsnd_mod_ops { |
| 200 | char *name; | 226 | char *name; |
| 201 | char* (*dma_name)(struct rsnd_mod *mod); | 227 | struct dma_chan* (*dma_req)(struct rsnd_mod *mod); |
| 202 | int (*probe)(struct rsnd_mod *mod, | 228 | int (*probe)(struct rsnd_mod *mod, |
| 203 | struct rsnd_priv *priv); | 229 | struct rsnd_priv *priv); |
| 204 | int (*remove)(struct rsnd_mod *mod, | 230 | int (*remove)(struct rsnd_mod *mod, |
| @@ -213,6 +239,9 @@ struct rsnd_mod_ops { | |||
| 213 | struct rsnd_priv *priv); | 239 | struct rsnd_priv *priv); |
| 214 | int (*pcm_new)(struct rsnd_mod *mod, | 240 | int (*pcm_new)(struct rsnd_mod *mod, |
| 215 | struct snd_soc_pcm_runtime *rtd); | 241 | struct snd_soc_pcm_runtime *rtd); |
| 242 | int (*hw_params)(struct rsnd_mod *mod, | ||
| 243 | struct snd_pcm_substream *substream, | ||
| 244 | struct snd_pcm_hw_params *hw_params); | ||
| 216 | int (*fallback)(struct rsnd_mod *mod, | 245 | int (*fallback)(struct rsnd_mod *mod, |
| 217 | struct rsnd_priv *priv); | 246 | struct rsnd_priv *priv); |
| 218 | }; | 247 | }; |
| @@ -236,6 +265,9 @@ struct rsnd_mod { | |||
| 236 | * 2 0: start 1: stop | 265 | * 2 0: start 1: stop |
| 237 | * 3 0: pcm_new | 266 | * 3 0: pcm_new |
| 238 | * 4 0: fallback | 267 | * 4 0: fallback |
| 268 | * | ||
| 269 | * 31 bit is always called (see __rsnd_mod_call) | ||
| 270 | * 31 0: hw_params | ||
| 239 | */ | 271 | */ |
| 240 | #define __rsnd_mod_shift_probe 0 | 272 | #define __rsnd_mod_shift_probe 0 |
| 241 | #define __rsnd_mod_shift_remove 0 | 273 | #define __rsnd_mod_shift_remove 0 |
| @@ -245,6 +277,7 @@ struct rsnd_mod { | |||
| 245 | #define __rsnd_mod_shift_stop 2 | 277 | #define __rsnd_mod_shift_stop 2 |
| 246 | #define __rsnd_mod_shift_pcm_new 3 | 278 | #define __rsnd_mod_shift_pcm_new 3 |
| 247 | #define __rsnd_mod_shift_fallback 4 | 279 | #define __rsnd_mod_shift_fallback 4 |
| 280 | #define __rsnd_mod_shift_hw_params 31 /* always called */ | ||
| 248 | 281 | ||
| 249 | #define __rsnd_mod_call_probe 0 | 282 | #define __rsnd_mod_call_probe 0 |
| 250 | #define __rsnd_mod_call_remove 1 | 283 | #define __rsnd_mod_call_remove 1 |
| @@ -254,28 +287,30 @@ struct rsnd_mod { | |||
| 254 | #define __rsnd_mod_call_stop 1 | 287 | #define __rsnd_mod_call_stop 1 |
| 255 | #define __rsnd_mod_call_pcm_new 0 | 288 | #define __rsnd_mod_call_pcm_new 0 |
| 256 | #define __rsnd_mod_call_fallback 0 | 289 | #define __rsnd_mod_call_fallback 0 |
| 290 | #define __rsnd_mod_call_hw_params 0 | ||
| 257 | 291 | ||
| 258 | #define rsnd_mod_to_priv(mod) (rsnd_io_to_priv(rsnd_mod_to_io(mod))) | 292 | #define rsnd_mod_to_priv(mod) (rsnd_io_to_priv(rsnd_mod_to_io(mod))) |
| 259 | #define rsnd_mod_to_dma(mod) (&(mod)->dma) | 293 | #define rsnd_mod_to_dma(mod) (&(mod)->dma) |
| 260 | #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) | ||
| 261 | #define rsnd_mod_to_io(mod) ((mod)->io) | 294 | #define rsnd_mod_to_io(mod) ((mod)->io) |
| 262 | #define rsnd_mod_id(mod) ((mod)->id) | 295 | #define rsnd_mod_id(mod) ((mod)->id) |
| 263 | #define rsnd_mod_hw_start(mod) clk_prepare_enable((mod)->clk) | 296 | #define rsnd_mod_hw_start(mod) clk_enable((mod)->clk) |
| 264 | #define rsnd_mod_hw_stop(mod) clk_disable_unprepare((mod)->clk) | 297 | #define rsnd_mod_hw_stop(mod) clk_disable((mod)->clk) |
| 265 | 298 | ||
| 266 | void rsnd_mod_init(struct rsnd_mod *mod, | 299 | int rsnd_mod_init(struct rsnd_mod *mod, |
| 267 | struct rsnd_mod_ops *ops, | 300 | struct rsnd_mod_ops *ops, |
| 268 | struct clk *clk, | 301 | struct clk *clk, |
| 269 | enum rsnd_mod_type type, | 302 | enum rsnd_mod_type type, |
| 270 | int id); | 303 | int id); |
| 304 | void rsnd_mod_quit(struct rsnd_mod *mod); | ||
| 271 | char *rsnd_mod_name(struct rsnd_mod *mod); | 305 | char *rsnd_mod_name(struct rsnd_mod *mod); |
| 272 | char *rsnd_mod_dma_name(struct rsnd_mod *mod); | 306 | struct dma_chan *rsnd_mod_dma_req(struct rsnd_mod *mod); |
| 273 | 307 | ||
| 274 | /* | 308 | /* |
| 275 | * R-Car sound DAI | 309 | * R-Car sound DAI |
| 276 | */ | 310 | */ |
| 277 | #define RSND_DAI_NAME_SIZE 16 | 311 | #define RSND_DAI_NAME_SIZE 16 |
| 278 | struct rsnd_dai_stream { | 312 | struct rsnd_dai_stream { |
| 313 | char name[RSND_DAI_NAME_SIZE]; | ||
| 279 | struct snd_pcm_substream *substream; | 314 | struct snd_pcm_substream *substream; |
| 280 | struct rsnd_mod *mod[RSND_MOD_MAX]; | 315 | struct rsnd_mod *mod[RSND_MOD_MAX]; |
| 281 | struct rsnd_dai_path_info *info; /* rcar_snd.h */ | 316 | struct rsnd_dai_path_info *info; /* rcar_snd.h */ |
| @@ -331,9 +366,7 @@ int rsnd_gen_probe(struct platform_device *pdev, | |||
| 331 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, | 366 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, |
| 332 | struct rsnd_mod *mod, | 367 | struct rsnd_mod *mod, |
| 333 | enum rsnd_reg reg); | 368 | enum rsnd_reg reg); |
| 334 | dma_addr_t rsnd_gen_dma_addr(struct rsnd_priv *priv, | 369 | phys_addr_t rsnd_gen_get_phy_addr(struct rsnd_priv *priv, int reg_id); |
| 335 | struct rsnd_mod *mod, | ||
| 336 | int is_play, int is_from); | ||
| 337 | 370 | ||
| 338 | #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) | 371 | #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) |
| 339 | #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2) | 372 | #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2) |
| @@ -389,6 +422,11 @@ struct rsnd_priv { | |||
| 389 | void *adg; | 422 | void *adg; |
| 390 | 423 | ||
| 391 | /* | 424 | /* |
| 425 | * below value will be filled on rsnd_dma_probe() | ||
| 426 | */ | ||
| 427 | void *dma; | ||
| 428 | |||
| 429 | /* | ||
| 392 | * below value will be filled on rsnd_ssi_probe() | 430 | * below value will be filled on rsnd_ssi_probe() |
| 393 | */ | 431 | */ |
| 394 | void *ssi; | 432 | void *ssi; |
| @@ -414,19 +452,6 @@ struct rsnd_priv { | |||
| 414 | #define rsnd_lock(priv, flags) spin_lock_irqsave(&priv->lock, flags) | 452 | #define rsnd_lock(priv, flags) spin_lock_irqsave(&priv->lock, flags) |
| 415 | #define rsnd_unlock(priv, flags) spin_unlock_irqrestore(&priv->lock, flags) | 453 | #define rsnd_unlock(priv, flags) spin_unlock_irqrestore(&priv->lock, flags) |
| 416 | 454 | ||
| 417 | #define rsnd_info_is_playback(priv, type) \ | ||
| 418 | ({ \ | ||
| 419 | struct rcar_snd_info *info = rsnd_priv_to_info(priv); \ | ||
| 420 | int i, is_play = 0; \ | ||
| 421 | for (i = 0; i < info->dai_info_nr; i++) { \ | ||
| 422 | if (info->dai_info[i].playback.type == (type)->info) { \ | ||
| 423 | is_play = 1; \ | ||
| 424 | break; \ | ||
| 425 | } \ | ||
| 426 | } \ | ||
| 427 | is_play; \ | ||
| 428 | }) | ||
| 429 | |||
| 430 | /* | 455 | /* |
| 431 | * rsnd_kctrl | 456 | * rsnd_kctrl |
| 432 | */ | 457 | */ |
| @@ -480,6 +505,8 @@ int rsnd_kctrl_new_e(struct rsnd_mod *mod, | |||
| 480 | int rsnd_src_probe(struct platform_device *pdev, | 505 | int rsnd_src_probe(struct platform_device *pdev, |
| 481 | const struct rsnd_of_data *of_data, | 506 | const struct rsnd_of_data *of_data, |
| 482 | struct rsnd_priv *priv); | 507 | struct rsnd_priv *priv); |
| 508 | void rsnd_src_remove(struct platform_device *pdev, | ||
| 509 | struct rsnd_priv *priv); | ||
| 483 | struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id); | 510 | struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id); |
| 484 | unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv, | 511 | unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv, |
| 485 | struct rsnd_dai_stream *io, | 512 | struct rsnd_dai_stream *io, |
| @@ -498,9 +525,12 @@ int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod); | |||
| 498 | int rsnd_ssi_probe(struct platform_device *pdev, | 525 | int rsnd_ssi_probe(struct platform_device *pdev, |
| 499 | const struct rsnd_of_data *of_data, | 526 | const struct rsnd_of_data *of_data, |
| 500 | struct rsnd_priv *priv); | 527 | struct rsnd_priv *priv); |
| 528 | void rsnd_ssi_remove(struct platform_device *pdev, | ||
| 529 | struct rsnd_priv *priv); | ||
| 501 | struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id); | 530 | struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id); |
| 502 | int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod); | 531 | int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod); |
| 503 | int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod); | 532 | int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod); |
| 533 | int rsnd_ssi_use_busif(struct rsnd_mod *mod); | ||
| 504 | 534 | ||
| 505 | /* | 535 | /* |
| 506 | * R-Car DVC | 536 | * R-Car DVC |
