hdmi-codec.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * hdmi-codec.h - HDMI Codec driver API
  4. *
  5. * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com
  6. *
  7. * Author: Jyri Sarha <jsarha@ti.com>
  8. */
  9. #ifndef __HDMI_CODEC_H__
  10. #define __HDMI_CODEC_H__
  11. #include <linux/of_graph.h>
  12. #include <linux/hdmi.h>
  13. #include <sound/asoundef.h>
  14. #include <sound/soc.h>
  15. #include <uapi/sound/asound.h>
  16. /*
  17. * Protocol between ASoC cpu-dai and HDMI-encoder
  18. */
  19. struct hdmi_codec_daifmt {
  20. enum {
  21. HDMI_I2S,
  22. HDMI_RIGHT_J,
  23. HDMI_LEFT_J,
  24. HDMI_DSP_A,
  25. HDMI_DSP_B,
  26. HDMI_AC97,
  27. HDMI_SPDIF,
  28. } fmt;
  29. unsigned int bit_clk_inv:1;
  30. unsigned int frame_clk_inv:1;
  31. unsigned int bit_clk_provider:1;
  32. unsigned int frame_clk_provider:1;
  33. /* bit_fmt could be standard PCM format or
  34. * IEC958 encoded format. ALSA IEC958 plugin will pass
  35. * IEC958_SUBFRAME format to the underneath driver.
  36. */
  37. snd_pcm_format_t bit_fmt;
  38. };
  39. /*
  40. * HDMI audio parameters
  41. */
  42. struct hdmi_codec_params {
  43. struct hdmi_audio_infoframe cea;
  44. struct snd_aes_iec958 iec;
  45. int sample_rate;
  46. int sample_width;
  47. int channels;
  48. };
  49. typedef void (*hdmi_codec_plugged_cb)(struct device *dev,
  50. bool plugged);
  51. struct hdmi_codec_pdata;
  52. struct hdmi_codec_ops {
  53. /*
  54. * Called when ASoC starts an audio stream setup.
  55. * Optional
  56. */
  57. int (*audio_startup)(struct device *dev, void *data);
  58. /*
  59. * Configures HDMI-encoder for audio stream.
  60. * Having either prepare or hw_params is mandatory.
  61. */
  62. int (*hw_params)(struct device *dev, void *data,
  63. struct hdmi_codec_daifmt *fmt,
  64. struct hdmi_codec_params *hparms);
  65. /*
  66. * Configures HDMI-encoder for audio stream. Can be called
  67. * multiple times for each setup.
  68. *
  69. * Having either prepare or hw_params is mandatory.
  70. */
  71. int (*prepare)(struct device *dev, void *data,
  72. struct hdmi_codec_daifmt *fmt,
  73. struct hdmi_codec_params *hparms);
  74. /*
  75. * Shuts down the audio stream.
  76. * Mandatory
  77. */
  78. void (*audio_shutdown)(struct device *dev, void *data);
  79. /*
  80. * Mute/unmute HDMI audio stream.
  81. * Optional
  82. */
  83. int (*mute_stream)(struct device *dev, void *data,
  84. bool enable, int direction);
  85. /*
  86. * Provides EDID-Like-Data from connected HDMI device.
  87. * Optional
  88. */
  89. int (*get_eld)(struct device *dev, void *data,
  90. uint8_t *buf, size_t len);
  91. /*
  92. * Getting DAI ID
  93. * Optional
  94. */
  95. int (*get_dai_id)(struct snd_soc_component *comment,
  96. struct device_node *endpoint,
  97. void *data);
  98. /*
  99. * Hook callback function to handle connector plug event.
  100. * Optional
  101. */
  102. int (*hook_plugged_cb)(struct device *dev, void *data,
  103. hdmi_codec_plugged_cb fn,
  104. struct device *codec_dev);
  105. };
  106. /* HDMI codec initalization data */
  107. struct hdmi_codec_pdata {
  108. const struct hdmi_codec_ops *ops;
  109. u64 i2s_formats;
  110. uint i2s:1;
  111. uint no_i2s_playback:1;
  112. uint no_i2s_capture:1;
  113. uint spdif:1;
  114. uint no_spdif_playback:1;
  115. uint no_spdif_capture:1;
  116. uint no_capture_mute:1;
  117. int max_i2s_channels;
  118. void *data;
  119. };
  120. struct snd_soc_component;
  121. struct snd_soc_jack;
  122. #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec"
  123. #endif /* __HDMI_CODEC_H__ */