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