Skip to content

Commit d4f2db3

Browse files
committed
topology2: common: Add new class definitions for input/output audio formats
The existing class definition for audio_format works only for widgets with exactly 1 input pin (Pin index 0) and 1 output pin (Pin index 0). Add two new classes that can be used to define the audio formats for any pin. These classes use the same tokens are the existing audio_format class and therefore can be used alongside the existing audio_format instances with non-zero pin indices. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 32c7890 commit d4f2db3

File tree

3 files changed

+275
-0
lines changed

3 files changed

+275
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Class definition for sink pin audio format object
2+
# audio_format objects can be instantiated as:
3+
#
4+
# Object.Base.sink_audio_format."0" {
5+
# in_rate 48000
6+
# in_sample_container_size 16
7+
# in_valid_bit_depth 16
8+
# in_interleaving_style "interleaved"
9+
10+
# }
11+
#
12+
13+
Class.Base."sink_audio_format" {
14+
15+
DefineAttribute."instance" {
16+
}
17+
18+
DefineAttribute."pin_index" {
19+
# Token set reference name
20+
token_ref "sof_tkn_cavs_audio_format.word"
21+
}
22+
23+
# input sampling rate
24+
DefineAttribute."in_rate" {
25+
# Token set reference name
26+
token_ref "sof_tkn_cavs_audio_format.word"
27+
}
28+
29+
# input bit depth
30+
DefineAttribute."in_bit_depth" {
31+
# Token set reference name
32+
token_ref "sof_tkn_cavs_audio_format.word"
33+
}
34+
35+
# input valid bit depth
36+
DefineAttribute."in_valid_bit_depth" {
37+
# Token set reference name
38+
token_ref "sof_tkn_cavs_audio_format.word"
39+
}
40+
41+
# input channel count
42+
DefineAttribute."in_channels" {
43+
# Token set reference name
44+
token_ref "sof_tkn_cavs_audio_format.word"
45+
constraints {
46+
min 1
47+
max 8
48+
}
49+
}
50+
51+
# input channel map
52+
DefineAttribute."in_ch_map" {
53+
# Token set reference name
54+
token_ref "sof_tkn_cavs_audio_format.word"
55+
}
56+
57+
# input channel config
58+
DefineAttribute."in_ch_cfg" {
59+
# Token set reference name
60+
token_ref "sof_tkn_cavs_audio_format.word"
61+
}
62+
63+
# input interleaving style
64+
DefineAttribute."in_interleaving_style" {
65+
type "string"
66+
# Token set reference name
67+
token_ref "sof_tkn_cavs_audio_format.word"
68+
constraints {
69+
!valid_values [
70+
"interleaved"
71+
"non-interleaved"
72+
]
73+
!tuple_values [
74+
0
75+
1
76+
]
77+
}
78+
}
79+
80+
# input format config
81+
DefineAttribute."in_fmt_cfg" {
82+
# Token set reference name
83+
token_ref "sof_tkn_cavs_audio_format.word"
84+
}
85+
86+
# input sample_type
87+
DefineAttribute."in_sample_type" {
88+
type string
89+
# Token set reference name
90+
token_ref "sof_tkn_cavs_audio_format.word"
91+
constraints {
92+
!valid_values [
93+
$SAMPLE_TYPE_MSB_INTEGER
94+
$SAMPLE_TYPE_LSB_INTEGER
95+
$SAMPLE_TYPE_SIGNED_INTEGER
96+
$SAMPLE_TYPE_UNSIGNED_INTEGER
97+
$SAMPLE_TYPE_FLOAT
98+
]
99+
}
100+
}
101+
102+
#
103+
# input buffer size
104+
#
105+
DefineAttribute."ibs" {
106+
# Token set reference name and type
107+
token_ref "sof_tkn_cavs_audio_format.word"
108+
}
109+
110+
attributes {
111+
!constructor [
112+
"instance"
113+
]
114+
115+
#
116+
# audio_format objects instantiated within the same alsaconf node must have unique
117+
# instance attribute values
118+
#
119+
unique "instance"
120+
}
121+
122+
in_rate 48000
123+
in_bit_depth 16
124+
in_valid_bit_depth 16
125+
in_channels 2
126+
in_interleaving_style "interleaved"
127+
in_sample_type $SAMPLE_TYPE_MSB_INTEGER
128+
in_ch_cfg $CHANNEL_CONFIG_STEREO
129+
in_ch_map $CHANNEL_MAP_STEREO
130+
131+
# math expression for computing input/output fmt_cfg
132+
in_fmt_cfg "$[($in_channels | ($in_valid_bit_depth * 256)) | ($in_sample_type * 65536)]"
133+
134+
# math expression for computing input/put buffer sizes
135+
# for 11.025 22.05, 44.1, 88.2 and 176.4khz, we need to round it to ceiling value
136+
ibs "$[($in_channels * ($[($in_rate + 999)] / 1000)) * ($in_bit_depth / 8)]"
137+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Class definition for spirce pin audio format object
2+
# audio_format objects can be instantiated as:
3+
#
4+
# Object.Base.source_audio_format."0" {
5+
# out_rate 48000
6+
# out_sample_container_size 16
7+
# out_valid_bit_depth 16
8+
# out_interleaving_style "interleaved"
9+
10+
# }
11+
#
12+
13+
Class.Base."source_audio_format" {
14+
15+
DefineAttribute."instance" {
16+
}
17+
18+
DefineAttribute."pin_index" {
19+
# Token set reference name
20+
token_ref "sof_tkn_cavs_audio_format.word"
21+
}
22+
23+
# output sampling rate
24+
DefineAttribute."out_rate" {
25+
# Token set reference name
26+
token_ref "sof_tkn_cavs_audio_format.word"
27+
}
28+
29+
# output bit depth
30+
DefineAttribute."out_bit_depth" {
31+
# Token set reference name
32+
token_ref "sof_tkn_cavs_audio_format.word"
33+
}
34+
35+
# output valid bit depth
36+
DefineAttribute."out_valid_bit_depth" {
37+
# Token set reference name
38+
token_ref "sof_tkn_cavs_audio_format.word"
39+
}
40+
41+
# output channel count
42+
DefineAttribute."out_channels" {
43+
# Token set reference name
44+
token_ref "sof_tkn_cavs_audio_format.word"
45+
constraints {
46+
min 1
47+
max 8
48+
}
49+
}
50+
51+
# output channel map
52+
DefineAttribute."out_ch_map" {
53+
# Token set reference name
54+
token_ref "sof_tkn_cavs_audio_format.word"
55+
}
56+
57+
# output channel config
58+
DefineAttribute."out_ch_cfg" {
59+
# Token set reference name
60+
token_ref "sof_tkn_cavs_audio_format.word"
61+
}
62+
63+
# output interleaving style
64+
DefineAttribute."out_interleaving_style" {
65+
type "string"
66+
# Token set reference name
67+
token_ref "sof_tkn_cavs_audio_format.word"
68+
constraints {
69+
!valid_values [
70+
"interleaved"
71+
"non-interleaved"
72+
]
73+
!tuple_values [
74+
0
75+
1
76+
]
77+
}
78+
}
79+
80+
# output format config
81+
DefineAttribute."out_fmt_cfg" {
82+
# Token set reference name
83+
token_ref "sof_tkn_cavs_audio_format.word"
84+
}
85+
86+
#
87+
# output buffer size
88+
#
89+
DefineAttribute."obs" {
90+
# Token set reference name and type
91+
token_ref "sof_tkn_cavs_audio_format.word"
92+
}
93+
94+
#output sample_type
95+
DefineAttribute."out_sample_type" {
96+
type string
97+
# Token set reference name
98+
token_ref "sof_tkn_cavs_audio_format.word"
99+
constraints {
100+
!valid_values [
101+
$SAMPLE_TYPE_MSB_INTEGER
102+
$SAMPLE_TYPE_LSB_INTEGER
103+
$SAMPLE_TYPE_SIGNED_INTEGER
104+
$SAMPLE_TYPE_UNSIGNED_INTEGER
105+
$SAMPLE_TYPE_FLOAT
106+
]
107+
}
108+
}
109+
110+
attributes {
111+
!constructor [
112+
"instance"
113+
]
114+
115+
#
116+
# output_audio_format objects instantiated within the same alsaconf node must have
117+
# unique instance attribute values
118+
#
119+
unique "instance"
120+
}
121+
122+
out_rate 48000
123+
out_bit_depth 16
124+
out_valid_bit_depth 16
125+
out_channels 2
126+
out_interleaving_style "interleaved"
127+
out_sample_type $SAMPLE_TYPE_MSB_INTEGER
128+
out_ch_cfg $CHANNEL_CONFIG_STEREO
129+
out_ch_map $CHANNEL_MAP_STEREO
130+
131+
# math expression for computing output fmt_cfg
132+
out_fmt_cfg "$[($out_channels | ($out_valid_bit_depth * 256)) | ($out_sample_type * 65536)]"
133+
134+
# math expression for computing input/put buffer sizes
135+
# for 11.025 22.05, 44.1, 88.2 and 176.4khz, we need to round it to ceiling value
136+
obs "$[($out_channels * ($[($out_rate + 999)] / 1000)) * ($out_bit_depth / 8)]"
137+
}

tools/topology/topology2/include/common/tokens.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ Object.Base.VendorToken {
162162
in_interleaving_style 1906
163163
in_fmt_cfg 1907
164164
in_sample_type 1908
165+
pin_index 1909
165166
# tokens up to 1929 reserved for future use
166167
out_rate 1930
167168
out_bit_depth 1931

0 commit comments

Comments
 (0)