1# Copyright 2016 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5# Unified build config. 6device_config_dir="$(cros_config /audio/main cras-config-dir)" 7internal_ucm_suffix="$(cros_config /audio/main ucm-suffix)" 8 9# Deprecate HSP since it's just too old. 10# TODO(hychao): Clean up all CRAS codes that are related to HSP once we're 11# sure no headset breaks because of that. 12DISABLE_PROFILE="--disable_profile=hsp" 13 14# Handle legacy config. 15if [ -z "${device_config_dir}" ]; then 16 # Disable HSP/HFP on Google WiFi (Gale) with UART-HCI Bluetooth 17 # which is incapable of handling SCO audio. 18 platform_name="$(mosys platform name)" 19 if [ "$platform_name" = "Gale" ]; then 20 DISABLE_PROFILE="--disable_profile=hfp,hsp" 21 fi 22 # For boards that need a different device config, check which config 23 # directory to use. Use that directory for both volume curves 24 # and DSP config. 25 if [ -f /etc/cras/get_device_config_dir ]; then 26 device_config_dir="$(sh /etc/cras/get_device_config_dir)" 27 fi 28 if [ -f /etc/cras/get_internal_ucm_suffix ]; then 29 internal_ucm_suffix="$(sh /etc/cras/get_internal_ucm_suffix)" 30 fi 31else 32 device_config_dir="/etc/cras/${device_config_dir}" 33fi 34 35if [ -n "${device_config_dir}" ]; then 36 DEVICE_CONFIG_DIR="--device_config_dir=${device_config_dir}" 37 DSP_CONFIG="--dsp_config=${device_config_dir}/dsp.ini" 38fi 39if [ -n "${internal_ucm_suffix}" ]; then 40 INTERNAL_UCM_SUFFIX="--internal_ucm_suffix=${internal_ucm_suffix}" 41fi 42 43# Leave cras in the init pid namespace as it uses its PID as an IPC identifier. 44exec minijail0 -u cras -g cras -G --uts -v -l \ 45 -T static \ 46 -P /mnt/empty \ 47 -b /,/ \ 48 -k 'tmpfs,/run,tmpfs,MS_NODEV|MS_NOEXEC|MS_NOSUID,mode=755,size=10M' \ 49 -b /run/cras,/run/cras,1 \ 50 -b /run/dbus,/run/dbus,1 \ 51 -b /run/udev,/run/udev \ 52 -b /dev,/dev \ 53 -b /dev/shm,/dev/shm,1 \ 54 -k proc,/proc,proc \ 55 -b /sys,/sys \ 56 -k 'tmpfs,/var,tmpfs,MS_NODEV|MS_NOEXEC|MS_NOSUID,mode=755,size=10M' \ 57 -b /var/lib/metrics/,/var/lib/metrics/,1 \ 58 -- \ 59 /sbin/minijail0 -n \ 60 -S /usr/share/policy/cras-seccomp.policy \ 61 -- \ 62 /usr/bin/cras \ 63 ${DSP_CONFIG} ${DEVICE_CONFIG_DIR} ${DISABLE_PROFILE} \ 64 ${INTERNAL_UCM_SUFFIX} ${CRAS_ARGS} 65