FILE
hdmi_local.h
File preview with syntax highlighting.
linux-6.19.14/sound/hda/codecs/hdmi/hdmi_local.h
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * HD-audio HDMI codec driver 4 */ 5 6#ifndef __HDA_HDMI_LOCAL_H 7#define __HDA_HDMI_LOCAL_H 8 9#include <sound/core.h> 10#include <sound/jack.h> 11#include <sound/hdaudio.h> 12#include <sound/hda_i915.h> 13#include <sound/hda_chmap.h> 14#include <sound/hda_codec.h> 15#include "hda_local.h" 16 17struct hdmi_spec_per_cvt { 18 hda_nid_t cvt_nid; 19 bool assigned; /* the stream has been assigned */ 20 bool silent_stream; /* silent stream activated */ 21 unsigned int channels_min; 22 unsigned int channels_max; 23 u32 rates; 24 u64 formats; 25 unsigned int maxbps; 26}; 27 28/* max. connections to a widget */ 29#define HDA_MAX_CONNECTIONS 32 30 31struct hdmi_spec_per_pin { 32 hda_nid_t pin_nid; 33 int dev_id; 34 /* pin idx, different device entries on the same pin use the same idx */ 35 int pin_nid_idx; 36 int num_mux_nids; 37 hda_nid_t mux_nids[HDA_MAX_CONNECTIONS]; 38 int mux_idx; 39 hda_nid_t cvt_nid; 40 41 struct hda_codec *codec; 42 struct hdmi_eld sink_eld; 43 struct mutex lock; 44 struct delayed_work work; 45 struct hdmi_pcm *pcm; /* pointer to spec->pcm_rec[n] dynamically*/ 46 int pcm_idx; /* which pcm is attached. -1 means no pcm is attached */ 47 int prev_pcm_idx; /* previously assigned pcm index */ 48 int repoll_count; 49 bool setup; /* the stream has been set up by prepare callback */ 50 bool silent_stream; 51 int channels; /* current number of channels */ 52 bool non_pcm; 53 bool chmap_set; /* channel-map override by ALSA API? */ 54 unsigned char chmap[8]; /* ALSA API channel-map */ 55#ifdef CONFIG_SND_PROC_FS 56 struct snd_info_entry *proc_entry; 57#endif 58}; 59 60/* operations used by generic code that can be overridden by codec drivers */ 61struct hdmi_ops { 62 int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid, 63 int dev_id, unsigned char *buf, int *eld_size); 64 65 void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid, 66 int dev_id, 67 int ca, int active_channels, int conn_type); 68 69 /* enable/disable HBR (HD passthrough) */ 70 int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid, 71 int dev_id, bool hbr); 72 73 int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid, 74 hda_nid_t pin_nid, int dev_id, u32 stream_tag, 75 int format); 76 77 void (*pin_cvt_fixup)(struct hda_codec *codec, 78 struct hdmi_spec_per_pin *per_pin, 79 hda_nid_t cvt_nid); 80 81 void (*silent_stream)(struct hda_codec *codec, 82 struct hdmi_spec_per_pin *per_pin, 83 bool enable); 84}; 85 86struct hdmi_pcm { 87 struct hda_pcm *pcm; 88 struct snd_jack *jack; 89 struct snd_kcontrol *eld_ctl; 90}; 91 92enum { 93 SILENT_STREAM_OFF = 0, 94 SILENT_STREAM_KAE, /* use standard HDA Keep-Alive */ 95 SILENT_STREAM_I915, /* Intel i915 extension */ 96}; 97 98struct hdmi_spec { 99 struct hda_codec *codec; 100 int num_cvts; 101 struct snd_array cvts; /* struct hdmi_spec_per_cvt */ 102 hda_nid_t cvt_nids[4]; /* only for haswell fix */ 103 104 /* 105 * num_pins is the number of virtual pins 106 * for example, there are 3 pins, and each pin 107 * has 4 device entries, then the num_pins is 12 108 */ 109 int num_pins; 110 /* 111 * num_nids is the number of real pins 112 * In the above example, num_nids is 3 113 */ 114 int num_nids; 115 /* 116 * dev_num is the number of device entries 117 * on each pin. 118 * In the above example, dev_num is 4 119 */ 120 int dev_num; 121 struct snd_array pins; /* struct hdmi_spec_per_pin */ 122 struct hdmi_pcm pcm_rec[8]; 123 struct mutex pcm_lock; 124 struct mutex bind_lock; /* for audio component binding */ 125 /* pcm_bitmap means which pcms have been assigned to pins*/ 126 unsigned long pcm_bitmap; 127 int pcm_used; /* counter of pcm_rec[] */ 128 /* bitmap shows whether the pcm is opened in user space 129 * bit 0 means the first playback PCM (PCM3); 130 * bit 1 means the second playback PCM, and so on. 131 */ 132 unsigned long pcm_in_use; 133 134 struct hdmi_eld temp_eld; 135 struct hdmi_ops ops; 136 137 bool dyn_pin_out; 138 bool static_pcm_mapping; 139 /* hdmi interrupt trigger control flag for Nvidia codec */ 140 bool hdmi_intr_trig_ctrl; 141 bool nv_dp_workaround; /* workaround DP audio infoframe for Nvidia */ 142 143 bool intel_hsw_fixup; /* apply Intel platform-specific fixups */ 144 /* 145 * Non-generic VIA/NVIDIA specific 146 */ 147 struct hda_multi_out multiout; 148 struct hda_pcm_stream pcm_playback; 149 150 bool use_acomp_notifier; /* use eld_notify callback for hotplug */ 151 bool acomp_registered; /* audio component registered in this driver */ 152 bool force_connect; /* force connectivity */ 153 struct drm_audio_component_audio_ops drm_audio_ops; 154 int (*port2pin)(struct hda_codec *codec, int port); /* reverse port/pin mapping */ 155 156 struct hdac_chmap chmap; 157 hda_nid_t vendor_nid; 158 const int *port_map; 159 int port_num; 160 int silent_stream_type; 161 162 const struct snd_pcm_hw_constraint_list *hw_constraints_channels; 163}; 164 165#ifdef CONFIG_SND_HDA_COMPONENT 166static inline bool codec_has_acomp(struct hda_codec *codec) 167{ 168 struct hdmi_spec *spec = codec->spec; 169 170 return spec->use_acomp_notifier; 171} 172#else 173#define codec_has_acomp(codec) false 174#endif 175 176struct hdmi_audio_infoframe { 177 u8 type; /* 0x84 */ 178 u8 ver; /* 0x01 */ 179 u8 len; /* 0x0a */ 180 181 u8 checksum; 182 183 u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */ 184 u8 SS01_SF24; 185 u8 CXT04; 186 u8 CA; 187 u8 LFEPBL01_LSV36_DM_INH7; 188}; 189 190struct dp_audio_infoframe { 191 u8 type; /* 0x84 */ 192 u8 len; /* 0x1b */ 193 u8 ver; /* 0x11 << 2 */ 194 195 u8 CC02_CT47; /* match with HDMI infoframe from this on */ 196 u8 SS01_SF24; 197 u8 CXT04; 198 u8 CA; 199 u8 LFEPBL01_LSV36_DM_INH7; 200}; 201 202union audio_infoframe { 203 struct hdmi_audio_infoframe hdmi; 204 struct dp_audio_infoframe dp; 205 DECLARE_FLEX_ARRAY(u8, bytes); 206}; 207 208#ifdef LIMITED_RATE_FMT_SUPPORT 209/* support only the safe format and rate */ 210#define SUPPORTED_RATES SNDRV_PCM_RATE_48000 211#define SUPPORTED_MAXBPS 16 212#define SUPPORTED_FORMATS SNDRV_PCM_FMTBIT_S16_LE 213#else 214/* support all rates and formats */ 215#define SUPPORTED_RATES \ 216 (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\ 217 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |\ 218 SNDRV_PCM_RATE_192000) 219#define SUPPORTED_MAXBPS 24 220#define SUPPORTED_FORMATS \ 221 (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE) 222#endif 223 224/* 225 * HDMI routines 226 */ 227 228#define get_pin(spec, idx) \ 229 ((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx)) 230#define get_cvt(spec, idx) \ 231 ((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx)) 232/* obtain hdmi_pcm object assigned to idx */ 233#define get_hdmi_pcm(spec, idx) (&(spec)->pcm_rec[idx]) 234/* obtain hda_pcm object assigned to idx */ 235#define get_pcm_rec(spec, idx) (get_hdmi_pcm(spec, idx)->pcm) 236 237/* Generic HDMI codec support */ 238int snd_hda_hdmi_generic_alloc(struct hda_codec *codec); 239int snd_hda_hdmi_parse_codec(struct hda_codec *codec); 240int snd_hda_hdmi_generic_probe(struct hda_codec *codec); 241void snd_hda_hdmi_generic_remove(struct hda_codec *codec); 242 243int snd_hda_hdmi_generic_build_pcms(struct hda_codec *codec); 244int snd_hda_hdmi_generic_build_controls(struct hda_codec *codec); 245int snd_hda_hdmi_generic_init(struct hda_codec *codec); 246int snd_hda_hdmi_generic_suspend(struct hda_codec *codec); 247int snd_hda_hdmi_generic_resume(struct hda_codec *codec); 248void snd_hda_hdmi_generic_unsol_event(struct hda_codec *codec, unsigned int res); 249 250int snd_hda_hdmi_pin_id_to_pin_index(struct hda_codec *codec, 251 hda_nid_t pin_nid, int dev_id); 252#define pin_id_to_pin_index(codec, pin, dev) \ 253 snd_hda_hdmi_pin_id_to_pin_index(codec, pin, dev) 254int snd_hda_hdmi_generic_init_per_pins(struct hda_codec *codec); 255void snd_hda_hdmi_generic_spec_free(struct hda_codec *codec); 256int snd_hda_hdmi_setup_stream(struct hda_codec *codec, 257 hda_nid_t cvt_nid, 258 hda_nid_t pin_nid, int dev_id, 259 u32 stream_tag, int format); 260 261int snd_hda_hdmi_generic_pcm_prepare(struct hda_pcm_stream *hinfo, 262 struct hda_codec *codec, 263 unsigned int stream_tag, 264 unsigned int format, 265 struct snd_pcm_substream *substream); 266int snd_hda_hdmi_generic_pcm_cleanup(struct hda_pcm_stream *hinfo, 267 struct hda_codec *codec, 268 struct snd_pcm_substream *substream); 269 270void snd_hda_hdmi_check_presence_and_report(struct hda_codec *codec, 271 hda_nid_t nid, int dev_id); 272void snd_hda_hdmi_setup_audio_infoframe(struct hda_codec *codec, 273 struct hdmi_spec_per_pin *per_pin, 274 bool non_pcm); 275 276/* Audio component support */ 277void snd_hda_hdmi_setup_drm_audio_ops(struct hda_codec *codec, 278 const struct drm_audio_component_audio_ops *ops); 279void snd_hda_hdmi_acomp_init(struct hda_codec *codec, 280 const struct drm_audio_component_audio_ops *ops, 281 int (*port2pin)(struct hda_codec *, int)); 282void snd_hda_hdmi_acomp_pin_eld_notify(void *audio_ptr, int port, int dev_id); 283int snd_hda_hdmi_acomp_master_bind(struct device *dev, 284 struct drm_audio_component *acomp); 285void snd_hda_hdmi_acomp_master_unbind(struct device *dev, 286 struct drm_audio_component *acomp); 287 288/* Simple / legacy HDMI codec support */ 289int snd_hda_hdmi_simple_probe(struct hda_codec *codec, 290 hda_nid_t cvt_nid, hda_nid_t pin_nid); 291void snd_hda_hdmi_simple_remove(struct hda_codec *codec); 292 293int snd_hda_hdmi_simple_build_pcms(struct hda_codec *codec); 294int snd_hda_hdmi_simple_build_controls(struct hda_codec *codec); 295int snd_hda_hdmi_simple_init(struct hda_codec *codec); 296void snd_hda_hdmi_simple_unsol_event(struct hda_codec *codec, 297 unsigned int res); 298int snd_hda_hdmi_simple_pcm_open(struct hda_pcm_stream *hinfo, 299 struct hda_codec *codec, 300 struct snd_pcm_substream *substream); 301 302#endif /* __HDA_HDMI_LOCAL_H */
~/
Read-only file preview.