hda_chmap.h 2.6 KB

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