@@ -134,12 +134,6 @@ def audio_pt(uos_type, sel, vmid, config):
134
134
fun_codec = bdf_codec [6 :7 ]
135
135
slot_codec = sel .slot ['audio_codec' ][vmid ]
136
136
137
- if uos_type == "WINDOWS" :
138
- print (' echo ${passthru_vpid["audio"]} > /sys/bus/pci/drivers/pci-stub/new_id' , file = config )
139
- print (' echo ${passthru_bdf["audio"]} > /sys/bus/pci/devices/${passthru_bdf["audio"]}/driver/unbind' , file = config )
140
- print (' echo ${passthru_bdf["audio"]} > /sys/bus/pci/drivers/pci-stub/bind' , file = config )
141
- return
142
-
143
137
if bdf_audio :
144
138
print ("kernel_version=$(uname -r)" , file = config )
145
139
print ('audio_module="/usr/lib/modules/$kernel_version/kernel/sound/soc/intel/boards/snd-soc-sst_bxt_sos_tdf8532.ko"' , file = config )
@@ -162,26 +156,40 @@ def audio_pt(uos_type, sel, vmid, config):
162
156
print ("audio_passthrough=1" , file = config )
163
157
print ("fi" , file = config )
164
158
print ('boot_audio_option=""' , file = config )
159
+
165
160
print ("if [ $audio_passthrough == 1 ]; then" , file = config )
166
161
print (" # for audio device" , file = config )
167
162
print (' echo ${passthru_vpid["audio"]} > /sys/bus/pci/drivers/pci-stub/new_id' , file = config )
168
163
print (' echo ${passthru_bdf["audio"]} > /sys/bus/pci/devices/${passthru_bdf["audio"]}/driver/unbind' , file = config )
169
164
print (' echo ${passthru_bdf["audio"]} > /sys/bus/pci/drivers/pci-stub/bind' , file = config )
170
165
print ("" , file = config )
171
166
172
- print (" # for audio codec" , file = config )
173
- print (' echo ${passthru_vpid["audio_codec"]} > /sys/bus/pci/drivers/pci-stub/new_id' , file = config )
174
- print (' echo ${passthru_bdf["audio_codec"]} > /sys/bus/pci/devices/${passthru_bdf["audio_codec"]}/driver/unbind' , file = config )
175
- print (' echo ${passthru_bdf["audio_codec"]} > /sys/bus/pci/drivers/pci-stub/bind' , file = config )
176
- print ("" , file = config )
167
+ if bdf_codec :
168
+ # select audio and audio_codec device to pass through to vm
169
+ print (" # for audio codec" , file = config )
170
+ print (' echo ${passthru_vpid["audio_codec"]} > /sys/bus/pci/drivers/pci-stub/new_id' , file = config )
171
+ print (' echo ${passthru_bdf["audio_codec"]} > /sys/bus/pci/devices/${passthru_bdf["audio_codec"]}/driver/unbind' , file = config )
172
+ print (' echo ${passthru_bdf["audio_codec"]} > /sys/bus/pci/drivers/pci-stub/bind' , file = config )
173
+ print ("" , file = config )
174
+
175
+ print (' boot_audio_option="-s {},passthru,{}/{}/{},keep_gsi ' .format (
176
+ slot_audio , bus , dev , fun ), end = "" , file = config )
177
+ print ('-s {},passthru,{}/{}/{}"' .format (
178
+ slot_codec , bus_codec , dev_codec , fun_codec ), file = config )
179
+ else :
180
+ # only select audio device to pass through to vm
181
+ print (' boot_audio_option="-s {},passthru,{}/{}/{},keep_gsi' .format (
182
+ slot_audio , bus , dev , fun ), file = config )
177
183
178
- print (' boot_audio_option="-s {},passthru,{}/{}/{},' .format (
179
- slot_audio , bus , dev , fun ), end = "" , file = config )
180
- print ('keep_gsi -s {},passthru,{}/{}/{}"' .format (
181
- slot_codec , bus_codec , dev_codec , fun_codec ), file = config )
182
184
print ("else" , file = config )
183
185
print (' boot_audio_option="-s {},virtio-audio"' .format (slot_audio ), file = config )
184
186
print ("fi" , file = config )
187
+ elif bdf_codec :
188
+ # only selected audio codec, then set error message
189
+ key = "audio/audio codec error:"
190
+ launch_cfg_lib .ERR_LIST [key ] = "Audio codec device should be pass through together with Audio devcie"
191
+ print (' boot_audio_option=-s {},passthru,{}/{}/{}"' .format (
192
+ slot_codec , bus_codec , dev_codec , fun_codec ), file = config )
185
193
186
194
187
195
def media_pt (uos_type , sel , vmid , config ):
0 commit comments