hda_chmap.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * For multichannel support
  4. */
  5. #ifndef __SOUND_HDA_CHMAP_H
  6. #define __SOUND_HDA_CHMAP_H
  7. #include <sound/pcm.h>
  8. #include <sound/hdaudio.h>
  9. #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
  10. struct hdac_cea_channel_speaker_allocation {
  11. int ca_index;
  12. int speakers[8];
  13. /* derived values, just for convenience */
  14. int channels;
  15. int spk_mask;
  16. };
  17. struct hdac_chmap;
  18. struct hdac_chmap_ops {
  19. /*
  20. * Helpers for producing the channel map TLVs. These can be overridden
  21. * for devices that have non-standard mapping requirements.
  22. */
  23. int (*chmap_cea_alloc_validate_get_type)(struct hdac_chmap *chmap,
  24. struct hdac_cea_channel_speaker_allocation *cap, int channels);
  25. void (*cea_alloc_to_tlv_chmap)(struct hdac_chmap *hchmap,
  26. struct hdac_cea_channel_speaker_allocation *cap,
  27. unsigned int *chmap, int channels);
  28. /* check that the user-given chmap is supported */
  29. int (*chmap_validate)(struct hdac_chmap *hchmap, int ca,
  30. int channels, unsigned char *chmap);
  31. int (*get_spk_alloc)(struct hdac_device *hdac, int pcm_idx);
  32. void (*get_chmap)(struct hdac_device *hdac, int pcm_idx,
  33. unsigned char *chmap);
  34. void (*set_chmap)(struct hdac_device *hdac, int pcm_idx,
  35. unsigned char *chmap, int prepared);
  36. bool (*is_pcm_attached)(struct hdac_device *hdac, int pcm_idx);
  37. /* get and set channel assigned to each HDMI ASP (audio sample packet) slot */
  38. int (*pin_get_slot_channel)(struct hdac_device *codec,
  39. hda_nid_t pin_nid, int asp_slot);
  40. int (*pin_set_slot_channel)(struct hdac_device *codec,
  41. hda_nid_t pin_nid, int asp_slot, int channel);
  42. void (*set_channel_count)(struct hdac_device *codec,
  43. hda_nid_t cvt_nid, int chs);
  44. };
  45. struct hdac_chmap {
  46. unsigned int channels_max; /* max over all cvts */
  47. struct hdac_chmap_ops ops;
  48. struct hdac_device *hdac;
  49. };
  50. void snd_hdac_register_chmap_ops(struct hdac_device *hdac,
  51. struct hdac_chmap *chmap);
  52. int snd_hdac_channel_allocation(struct hdac_device *hdac, int spk_alloc,
  53. int channels, bool chmap_set,
  54. bool non_pcm, unsigned char *map);
  55. int snd_hdac_get_active_channels(int ca);
  56. void snd_hdac_setup_channel_mapping(struct hdac_chmap *chmap,
  57. hda_nid_t pin_nid, bool non_pcm, int ca,
  58. int channels, unsigned char *map,
  59. bool chmap_set);
  60. void snd_hdac_print_channel_allocation(int spk_alloc, char *buf, int buflen);
  61. struct hdac_cea_channel_speaker_allocation *snd_hdac_get_ch_alloc_from_ca(int ca);
  62. int snd_hdac_chmap_to_spk_mask(unsigned char c);
  63. int snd_hdac_spk_to_chmap(int spk);
  64. int snd_hdac_add_chmap_ctls(struct snd_pcm *pcm, int pcm_idx,
  65. struct hdac_chmap *chmap);
  66. #endif /* __SOUND_HDA_CHMAP_H */