1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __SOUND_PCM_DRM_ELD_H
3 #define __SOUND_PCM_DRM_ELD_H
4 
5 enum eld_versions {
6 	ELD_VER_CEA_861D	= 2,
7 	ELD_VER_PARTIAL		= 31,
8 };
9 
10 enum cea_audio_coding_types {
11 	AUDIO_CODING_TYPE_REF_STREAM_HEADER	=  0,
12 	AUDIO_CODING_TYPE_LPCM			=  1,
13 	AUDIO_CODING_TYPE_AC3			=  2,
14 	AUDIO_CODING_TYPE_MPEG1			=  3,
15 	AUDIO_CODING_TYPE_MP3			=  4,
16 	AUDIO_CODING_TYPE_MPEG2			=  5,
17 	AUDIO_CODING_TYPE_AACLC			=  6,
18 	AUDIO_CODING_TYPE_DTS			=  7,
19 	AUDIO_CODING_TYPE_ATRAC			=  8,
20 	AUDIO_CODING_TYPE_SACD			=  9,
21 	AUDIO_CODING_TYPE_EAC3			= 10,
22 	AUDIO_CODING_TYPE_DTS_HD		= 11,
23 	AUDIO_CODING_TYPE_MLP			= 12,
24 	AUDIO_CODING_TYPE_DST			= 13,
25 	AUDIO_CODING_TYPE_WMAPRO		= 14,
26 	AUDIO_CODING_TYPE_REF_CXT		= 15,
27 	/* also include valid xtypes below */
28 	AUDIO_CODING_TYPE_HE_AAC		= 15,
29 	AUDIO_CODING_TYPE_HE_AAC2		= 16,
30 	AUDIO_CODING_TYPE_MPEG_SURROUND		= 17,
31 };
32 
33 enum cea_audio_coding_xtypes {
34 	AUDIO_CODING_XTYPE_HE_REF_CT		= 0,
35 	AUDIO_CODING_XTYPE_HE_AAC		= 1,
36 	AUDIO_CODING_XTYPE_HE_AAC2		= 2,
37 	AUDIO_CODING_XTYPE_MPEG_SURROUND	= 3,
38 	AUDIO_CODING_XTYPE_FIRST_RESERVED	= 4,
39 };
40 
41 /*
42  * CEA Short Audio Descriptor data
43  */
44 struct snd_cea_sad {
45 	int	channels;
46 	int	format;		/* (format == 0) indicates invalid SAD */
47 	int	rates;
48 	int	sample_bits;	/* for LPCM */
49 	int	max_bitrate;	/* for AC3...ATRAC */
50 	int	profile;	/* for WMAPRO */
51 };
52 
53 #define ELD_FIXED_BYTES	20
54 #define ELD_MAX_SIZE    256
55 #define ELD_MAX_MNL	16
56 #define ELD_MAX_SAD	16
57 
58 #define ELD_PCM_BITS_8		BIT(0)
59 #define ELD_PCM_BITS_16		BIT(1)
60 #define ELD_PCM_BITS_20		BIT(2)
61 #define ELD_PCM_BITS_24		BIT(3)
62 #define ELD_PCM_BITS_32		BIT(4)
63 
64 /*
65  * ELD: EDID Like Data
66  */
67 struct snd_parsed_hdmi_eld {
68 	/*
69 	 * all fields will be cleared before updating ELD
70 	 */
71 	int	baseline_len;
72 	int	eld_ver;
73 	int	cea_edid_ver;
74 	char	monitor_name[ELD_MAX_MNL + 1];
75 	int	manufacture_id;
76 	int	product_id;
77 	u64	port_id;
78 	int	support_hdcp;
79 	int	support_ai;
80 	int	conn_type;
81 	int	aud_synch_delay;
82 	int	spk_alloc;
83 	int	sad_count;
84 	struct snd_cea_sad sad[ELD_MAX_SAD];
85 };
86 
87 int snd_pcm_hw_constraint_eld(struct snd_pcm_runtime *runtime, void *eld);
88 
89 int snd_parse_eld(struct device *dev, struct snd_parsed_hdmi_eld *e,
90 		  const unsigned char *buf, int size);
91 void snd_show_eld(struct device *dev, struct snd_parsed_hdmi_eld *e);
92 
93 #ifdef CONFIG_SND_PROC_FS
94 void snd_print_eld_info(struct snd_parsed_hdmi_eld *eld,
95 			struct snd_info_buffer *buffer);
96 #endif
97 
98 #endif
99