rsnd.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/io.h>
  16. #include <linux/list.h>
  17. #include <linux/module.h>
  18. #include <sound/rcar_snd.h>
  19. #include <sound/soc.h>
  20. #include <sound/pcm_params.h>
  21. /*
  22. * pseudo register
  23. *
  24. * The register address offsets SRU/SCU/SSIU on Gen1/Gen2 are very different.
  25. * This driver uses pseudo register in order to hide it.
  26. * see gen1/gen2 for detail
  27. */
  28. struct rsnd_priv;
  29. struct rsnd_dai;
  30. struct rsnd_dai_stream;
  31. /*
  32. * R-Car sound DAI
  33. */
  34. #define RSND_DAI_NAME_SIZE 16
  35. struct rsnd_dai_stream {
  36. struct list_head head; /* head of rsnd_mod list */
  37. struct snd_pcm_substream *substream;
  38. int byte_pos;
  39. int period_pos;
  40. int byte_per_period;
  41. int next_period_byte;
  42. };
  43. struct rsnd_dai {
  44. char name[RSND_DAI_NAME_SIZE];
  45. struct rsnd_dai_platform_info *info; /* rcar_snd.h */
  46. struct rsnd_dai_stream playback;
  47. struct rsnd_dai_stream capture;
  48. int clk_master:1;
  49. int bit_clk_inv:1;
  50. int frm_clk_inv:1;
  51. int sys_delay:1;
  52. int data_alignment:1;
  53. };
  54. #define rsnd_dai_nr(priv) ((priv)->dai_nr)
  55. #define for_each_rsnd_dai(rdai, priv, i) \
  56. for (i = 0, (rdai) = rsnd_dai_get(priv, i); \
  57. i < rsnd_dai_nr(priv); \
  58. i++, (rdai) = rsnd_dai_get(priv, i))
  59. struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id);
  60. int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io);
  61. #define rsnd_dai_get_platform_info(rdai) ((rdai)->info)
  62. void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt);
  63. int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional);
  64. /*
  65. * R-Car sound priv
  66. */
  67. struct rsnd_priv {
  68. struct device *dev;
  69. struct rcar_snd_info *info;
  70. spinlock_t lock;
  71. /*
  72. * below value will be filled on rsnd_dai_probe()
  73. */
  74. struct snd_soc_dai_driver *daidrv;
  75. struct rsnd_dai *rdai;
  76. int dai_nr;
  77. };
  78. #define rsnd_priv_to_dev(priv) ((priv)->dev)
  79. #define rsnd_lock(priv, flags) spin_lock_irqsave(&priv->lock, flags)
  80. #define rsnd_unlock(priv, flags) spin_unlock_irqrestore(&priv->lock, flags)
  81. #endif