blob: e508f319229454c2ad59a8c4516ec04764ee689d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Subhransu S. Prusty67b90cb2016-03-04 19:59:46 +05302/*
3 * For multichannel support
4 */
5
6#ifndef __SOUND_HDA_CHMAP_H
7#define __SOUND_HDA_CHMAP_H
8
Subhransu S. Prusty2f6e8a82016-03-04 19:59:51 +05309#include <sound/pcm.h>
Subhransu S. Prusty67b90cb2016-03-04 19:59:46 +053010#include <sound/hdaudio.h>
11
Subhransu S. Prusty828cb4e2016-03-04 19:59:50 +053012
13#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
14
Subhransu S. Prustyf3022402016-03-04 19:59:48 +053015struct hdac_cea_channel_speaker_allocation {
Subhransu S. Prusty67b90cb2016-03-04 19:59:46 +053016 int ca_index;
17 int speakers[8];
18
19 /* derived values, just for convenience */
20 int channels;
21 int spk_mask;
22};
23struct hdac_chmap;
24
25struct hdac_chmap_ops {
26 /*
27 * Helpers for producing the channel map TLVs. These can be overridden
28 * for devices that have non-standard mapping requirements.
29 */
30 int (*chmap_cea_alloc_validate_get_type)(struct hdac_chmap *chmap,
Subhransu S. Prustyf3022402016-03-04 19:59:48 +053031 struct hdac_cea_channel_speaker_allocation *cap, int channels);
Subhransu S. Prusty828cb4e2016-03-04 19:59:50 +053032 void (*cea_alloc_to_tlv_chmap)(struct hdac_chmap *hchmap,
33 struct hdac_cea_channel_speaker_allocation *cap,
Subhransu S. Prusty67b90cb2016-03-04 19:59:46 +053034 unsigned int *chmap, int channels);
35
36 /* check that the user-given chmap is supported */
Subhransu S. Prusty828cb4e2016-03-04 19:59:50 +053037 int (*chmap_validate)(struct hdac_chmap *hchmap, int ca,
38 int channels, unsigned char *chmap);
Subhransu S. Prusty9b3dc8a2016-03-04 19:59:47 +053039
Subhransu S. Prusty44fde3b2016-04-04 19:23:54 +053040 int (*get_spk_alloc)(struct hdac_device *hdac, int pcm_idx);
41
Subhransu S. Prusty9b3dc8a2016-03-04 19:59:47 +053042 void (*get_chmap)(struct hdac_device *hdac, int pcm_idx,
43 unsigned char *chmap);
44 void (*set_chmap)(struct hdac_device *hdac, int pcm_idx,
45 unsigned char *chmap, int prepared);
46 bool (*is_pcm_attached)(struct hdac_device *hdac, int pcm_idx);
Subhransu S. Prusty739ffee2016-03-04 19:59:49 +053047
48 /* get and set channel assigned to each HDMI ASP (audio sample packet) slot */
49 int (*pin_get_slot_channel)(struct hdac_device *codec,
50 hda_nid_t pin_nid, int asp_slot);
51 int (*pin_set_slot_channel)(struct hdac_device *codec,
52 hda_nid_t pin_nid, int asp_slot, int channel);
53 void (*set_channel_count)(struct hdac_device *codec,
54 hda_nid_t cvt_nid, int chs);
Subhransu S. Prusty67b90cb2016-03-04 19:59:46 +053055};
56
57struct hdac_chmap {
58 unsigned int channels_max; /* max over all cvts */
59 struct hdac_chmap_ops ops;
60 struct hdac_device *hdac;
61};
62
Subhransu S. Prusty739ffee2016-03-04 19:59:49 +053063void snd_hdac_register_chmap_ops(struct hdac_device *hdac,
64 struct hdac_chmap *chmap);
Subhransu S. Prustybb63f722016-03-04 19:59:52 +053065int snd_hdac_channel_allocation(struct hdac_device *hdac, int spk_alloc,
Subhransu S. Prusty2f6e8a82016-03-04 19:59:51 +053066 int channels, bool chmap_set,
67 bool non_pcm, unsigned char *map);
Subhransu S. Prustybb63f722016-03-04 19:59:52 +053068int snd_hdac_get_active_channels(int ca);
69void snd_hdac_setup_channel_mapping(struct hdac_chmap *chmap,
Subhransu S. Prusty2f6e8a82016-03-04 19:59:51 +053070 hda_nid_t pin_nid, bool non_pcm, int ca,
71 int channels, unsigned char *map,
72 bool chmap_set);
Subhransu S. Prustybb63f722016-03-04 19:59:52 +053073void snd_hdac_print_channel_allocation(int spk_alloc, char *buf, int buflen);
74struct hdac_cea_channel_speaker_allocation *snd_hdac_get_ch_alloc_from_ca(int ca);
75int snd_hdac_chmap_to_spk_mask(unsigned char c);
76int snd_hdac_spk_to_chmap(int spk);
Subhransu S. Prusty2f6e8a82016-03-04 19:59:51 +053077int snd_hdac_add_chmap_ctls(struct snd_pcm *pcm, int pcm_idx,
78 struct hdac_chmap *chmap);
Subhransu S. Prusty67b90cb2016-03-04 19:59:46 +053079#endif /* __SOUND_HDA_CHMAP_H */