hdmi-codec.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 <[email protected]>
  8. */
  9. #ifndef __HDMI_CODEC_H__
  10. #define __HDMI_CODEC_H__
  11. #include <linux/of_graph.h>
  12. #include <linux/hdmi.h>
  13. #include <drm/drm_edid.h>
  14. #include <sound/asoundef.h>
  15. #include <sound/soc.h>
  16. #include <uapi/sound/asound.h>
  17. /*
  18. * Protocol between ASoC cpu-dai and HDMI-encoder
  19. */
  20. struct hdmi_codec_daifmt {
  21. enum {
  22. HDMI_I2S,
  23. HDMI_RIGHT_J,
  24. HDMI_LEFT_J,
  25. HDMI_DSP_A,
  26. HDMI_DSP_B,
  27. HDMI_AC97,
  28. HDMI_SPDIF,
  29. } fmt;
  30. unsigned int bit_clk_inv:1;
  31. unsigned int frame_clk_inv:1;
  32. unsigned int bit_clk_provider:1;
  33. unsigned int frame_clk_provider:1;
  34. /* bit_fmt could be standard PCM format or
  35. * IEC958 encoded format. ALSA IEC958 plugin will pass
  36. * IEC958_SUBFRAME format to the underneath driver.
  37. */
  38. snd_pcm_format_t bit_fmt;
  39. };
  40. /*
  41. * HDMI audio parameters
  42. */
  43. struct hdmi_codec_params {
  44. struct hdmi_audio_infoframe cea;
  45. struct snd_aes_iec958 iec;
  46. int sample_rate;
  47. int sample_width;
  48. int channels;
  49. };
  50. typedef void (*hdmi_codec_plugged_cb)(struct device *dev,
  51. bool plugged);
  52. struct hdmi_codec_pdata;
  53. struct hdmi_codec_ops {
  54. /*
  55. * Called when ASoC starts an audio stream setup.
  56. * Optional
  57. */
  58. int (*audio_startup)(struct device *dev, void *data);
  59. /*
  60. * Configures HDMI-encoder for audio stream.
  61. * Having either prepare or hw_params is mandatory.
  62. */
  63. int (*hw_params)(struct device *dev, void *data,
  64. struct hdmi_codec_daifmt *fmt,
  65. struct hdmi_codec_params *hparms);
  66. /*
  67. * Configures HDMI-encoder for audio stream. Can be called
  68. * multiple times for each setup.
  69. *
  70. * Having either prepare or hw_params is mandatory.
  71. */
  72. int (*prepare)(struct device *dev, void *data,
  73. struct hdmi_codec_daifmt *fmt,
  74. struct hdmi_codec_params *hparms);
  75. /*
  76. * Shuts down the audio stream.
  77. * Mandatory
  78. */
  79. void (*audio_shutdown)(struct device *dev, void *data);
  80. /*
  81. * Mute/unmute HDMI audio stream.
  82. * Optional
  83. */
  84. int (*mute_stream)(struct device *dev, void *data,
  85. bool enable, int direction);
  86. /*
  87. * Provides EDID-Like-Data from connected HDMI device.
  88. * Optional
  89. */
  90. int (*get_eld)(struct device *dev, void *data,
  91. uint8_t *buf, size_t len);
  92. /*
  93. * Getting DAI ID
  94. * Optional
  95. */
  96. int (*get_dai_id)(struct snd_soc_component *comment,
  97. struct device_node *endpoint);
  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. /* bit field */
  106. unsigned int no_capture_mute:1;
  107. };
  108. /* HDMI codec initalization data */
  109. struct hdmi_codec_pdata {
  110. const struct hdmi_codec_ops *ops;
  111. uint i2s:1;
  112. uint spdif:1;
  113. int max_i2s_channels;
  114. void *data;
  115. };
  116. struct snd_soc_component;
  117. struct snd_soc_jack;
  118. #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec"
  119. #endif /* __HDMI_CODEC_H__ */