Skip to content

Commit 1326eec

Browse files
Wei Liuwenlingz
authored andcommitted
acrn-config: refine the tools for audio/audio_codec
There are 2 scenarios to pass through audio/audio_codec: 1. Only pass through audio device to vm. 2. Pass through audio and audio codec device to vm. The improvement is to generate proper boot audio option for each scenario. Tracked-On: #3853 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
1 parent 950e3aa commit 1326eec

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

misc/acrn-config/launch_config/launch_cfg_gen.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ def generate_script_file(names, pt_sel, dm, vmid, config):
133133

134134
print("{}".format(header_info), file=config)
135135
com.gen(names, pt_sel, dm, vmid, config)
136+
if launch_cfg_lib.ERR_LIST:
137+
return launch_cfg_lib.ERR_LIST
136138

137139

138140
def main(args):
@@ -201,14 +203,18 @@ def main(args):
201203
launch_script_file = output + script_name
202204
config_srcs.append(launch_script_file)
203205
with open(launch_script_file, mode = 'w', newline=None, encoding='utf-8') as config:
204-
generate_script_file(names, pt_sel, dm.args, vm_th, config)
206+
err_dic = generate_script_file(names, pt_sel, dm.args, vm_th, config)
207+
if err_dic:
208+
return err_dic
205209
else:
206210
for post_vm_i in post_num_list:
207211
script_name = "launch_uos_id{}.sh".format(post_vm_i)
208212
launch_script_file = output + script_name
209213
config_srcs.append(launch_script_file)
210214
with open(launch_script_file, mode = 'w', newline='\n', encoding='utf-8') as config:
211-
generate_script_file(names, pt_sel, dm.args, post_vm_i, config)
215+
err_dic = generate_script_file(names, pt_sel, dm.args, post_vm_i, config)
216+
if err_dic:
217+
return err_dic
212218

213219
commit_msg = "launch_uos_id{}.sh".format(launch_vm_count)
214220

misc/acrn-config/launch_config/pt.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ def audio_pt(uos_type, sel, vmid, config):
134134
fun_codec = bdf_codec[6:7]
135135
slot_codec = sel.slot['audio_codec'][vmid]
136136

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-
143137
if bdf_audio:
144138
print("kernel_version=$(uname -r)", file=config)
145139
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):
162156
print("audio_passthrough=1", file=config)
163157
print("fi", file=config)
164158
print('boot_audio_option=""', file=config)
159+
165160
print("if [ $audio_passthrough == 1 ]; then", file=config)
166161
print(" # for audio device", file=config)
167162
print(' echo ${passthru_vpid["audio"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
168163
print(' echo ${passthru_bdf["audio"]} > /sys/bus/pci/devices/${passthru_bdf["audio"]}/driver/unbind', file=config)
169164
print(' echo ${passthru_bdf["audio"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
170165
print("", file=config)
171166

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)
177183

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)
182184
print("else", file=config)
183185
print(' boot_audio_option="-s {},virtio-audio"'.format(slot_audio), file=config)
184186
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)
185193

186194

187195
def media_pt(uos_type, sel, vmid, config):

0 commit comments

Comments
 (0)