#!/bin/bash { #//////////////////////////////////// # DietPi Function: # - Enables control and applies settings for specific hardware. # #//////////////////////////////////// # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com # #//////////////////////////////////// # # Usage: # - /DietPi/dietpi/func/dietpi-set_hardware rpi-camera enable/disable # - /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit 64/128/256 #RPi only # - /DietPi/dietpi/func/dietpi-set_hardware remoteir odroid_remote # - /DietPi/dietpi/func/dietpi-set_hardware kernel ??see sourcode # - /DietPi/dietpi/func/dietpi-set_hardware eth-forcespeed 10/100/1000/disable # - /DietPi/dietpi/func/dietpi-set_hardware rpi-opengl enable/disable # - /DietPi/dietpi/func/dietpi-set_hardware i2c enable/disable/khz # - /DietPi/dietpi/func/dietpi-set_hardware wificountrycode code # - /DietPi/dietpi/func/dietpi-set_hardware wifi enable/disable/onboard_enable/onboard_disable # - /DietPi/dietpi/func/dietpi-set_hardware preferipversion auto/ipv4/ipv6 # - /DietPi/dietpi/func/dietpi-set_hardware bluetooth enable/disable # - /DietPi/dietpi/func/dietpi-set_hardware serialconsole enable/disable # - /DietPi/dietpi/func/dietpi-set_hardware soundcard target_card (non-matching name for reset to default) add '-eq' to target_card string, enable alsa eq on card # - /DietPi/dietpi/func/dietpi-set_hardware lcdpanel target_panel (none to remove all) #//////////////////////////////////// #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. LANG=en_GB.UTF-8 INPUT_DEVICE_NAME=$(echo -e "$1" | tr '[:upper:]' '[:lower:]') INPUT_DEVICE_VALUE=$(echo -e "$2" | tr '[:upper:]' '[:lower:]') #support for 0/1 inputs for enable/disable if [ "$INPUT_DEVICE_VALUE" = "1" ]; then INPUT_DEVICE_VALUE='enable' elif [ "$INPUT_DEVICE_VALUE" = "0" ]; then INPUT_DEVICE_VALUE='disable' fi EXIT_CODE=0 HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) HW_CPUID=$(sed -n 9p /DietPi/dietpi/.hw_model) Unknown_Input_Name(){ EXIT_CODE=1 /DietPi/dietpi/func/dietpi-notify 2 "Unknown input name ($INPUT_DEVICE_NAME). Nothing has been applied." } Unknown_Input_Mode(){ EXIT_CODE=1 /DietPi/dietpi/func/dietpi-notify 2 "Unknown input value ($INPUT_DEVICE_VALUE). Nothing has been applied." } #///////////////////////////////////////////////////////////////////////////////////// #rpi-camera #///////////////////////////////////////////////////////////////////////////////////// RPi_Camera_Main(){ # - int, assume RPi if [ "$INPUT_DEVICE_VALUE" = "enable" ]; then # - Enable RPi Camera module sed -i '/start_x=/c\start_x=1' /DietPi/config.txt # - requires 128MB memory split min. if (( $(cat /DietPi/config.txt | grep -m1 'gpu_mem_' | sed 's/.*=//g') < 128 )); then /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit 128 fi elif [ "$INPUT_DEVICE_VALUE" = "disable" ]; then sed -i '/start_x=/c\start_x=0' /DietPi/config.txt else Unknown_Input_Mode fi } #///////////////////////////////////////////////////////////////////////////////////// #gpumemsplit #///////////////////////////////////////////////////////////////////////////////////// Gpu_Memory_Split_Main(){ # - int, assume RPi if [[ $INPUT_DEVICE_VALUE =~ ^-?[0-9]+$ ]]; then sed -i "/gpu_mem_256=/c\gpu_mem_256=$INPUT_DEVICE_VALUE" /DietPi/config.txt sed -i "/gpu_mem_512=/c\gpu_mem_512=$INPUT_DEVICE_VALUE" /DietPi/config.txt sed -i "/gpu_mem_1024=/c\gpu_mem_1024=$INPUT_DEVICE_VALUE" /DietPi/config.txt else Unknown_Input_Mode fi } #///////////////////////////////////////////////////////////////////////////////////// #remoteir #///////////////////////////////////////////////////////////////////////////////////// RemoteIR_Main(){ if [ "$INPUT_DEVICE_VALUE" = "odroid_remote" ]; then # - LIRC if (( ! $(dpkg --get-selections | grep -ci -m1 '^lirc') )); then apt-get update apt-get install -y lirc if (( $? != 0 )); then /DietPi/dietpi/func/dietpi-notify 1 "apt-get install lirc" EXIT_CODE=1 fi fi # - xu4 Cloudshell if (( $HW_MODEL == 11 )); then # - modules local string="options gpioplug_ir_recv gpio_nr=24 active_low=1" if (( ! $(cat /etc/modprobe.d/odroid-cloudshell.conf | grep -ci -m1 "^$string") )); then echo "$string" >> /etc/modprobe.d/odroid-cloudshell.conf fi string="gpio-ir-recv" if (( ! $(cat /etc/modules | grep -ci -m1 "^$string") )); then echo "$string" >> /etc/modules fi string="gpioplug-ir-recv" if (( ! $(cat /etc/modules | grep -ci -m1 "^$string") )); then echo "$string" >> /etc/modules fi # - c1/c2 elif (( $HW_MODEL == 10 || $HW_MODEL == 12 )); then # - Module if (( ! $(cat /etc/modules | grep -ci -m1 '^meson_ir') )); then echo -e "meson_ir" >> /etc/modules fi fi # - All # - SystemD systemctl disable lirc rm /etc/init.d/lirc cat << _EOF_ > /etc/systemd/system/odroid-remote.service [Unit] Description=Odroid Remote C1/C2/XU4 [Service] Type=forking ExecStartPre=/bin/bash -c 'mkdir -p /var/run/lirc' ExecStart=/usr/sbin/lircd --output=/run/lirc/lircd --driver=default --device=/dev/lirc0 --uinput [Install] WantedBy=multi-user.target _EOF_ systemctl daemon-reload systemctl enable odroid-remote.service # Lircd conf for Odroid Remote cat << _EOF_ > /etc/lirc/lircd.conf begin remote name lircd.conf bits 16 flags SPACE_ENC|CONST_LENGTH eps 30 aeps 100 header 9000 4500 one 563 1688 zero 563 564 ptrail 563 pre_data_bits 16 pre_data 0x4DB2 repeat 9000 2250 toggle_bit_mask 0x0 begin codes KEY_LEFT 0x9966 KEY_RIGHT 0x837C KEY_UP 0x53AC KEY_DOWN 0x4BB4 KEY_ENTER 0x738C KEY_HOME 0x41BE KEY_MUTE 0x11EE KEY_MENU 0xA35C KEY_BACK 0x59A6 KEY_VOLUMEDOWN 0x817E KEY_VOLUMEUP 0x01FE KEY_POWER 0x3BC4 end codes end remote _EOF_ elif [ "$INPUT_DEVICE_VALUE" = "none" ]; then # - Disable odroids systemctl stop odroid-remote systemctl disable odroid-remote rm /etc/systemd/system/odroid-remote.service else Unknown_Input_Mode fi } #///////////////////////////////////////////////////////////////////////////////////// #Kernel #///////////////////////////////////////////////////////////////////////////////////// Kernel_Main(){ if [ "$INPUT_DEVICE_VALUE" = "384khz_rpi" ]; then local install_url_address='http://dietpi.com/downloads/binaries/rpi/rpi2plus-4.4.30_384khz.7z' /DietPi/dietpi/func/check_connection "$install_url_address" # Install if (( $? == 0 )) && [ ! -f /etc/dietpi/.384khz_rpi ]; then #not already installed # - Prevent kernel/firmware/bootloader upgrades from Raspbian repo apt-mark hold raspberrypi-bootloader raspberrypi-kernel libraspberrypi-bin wget "$install_url_address" -O package.7z 7z x -aoa package.7z -o/ rm package.7z # - flag, trigger to enable 384khz in dietpi-justboom echo 1 > /etc/dietpi/.384khz_rpi else /DietPi/dietpi/func/dietpi-notify 1 "Failed to install $INPUT_DEVICE_NAME. $install_url_address may be offline or unreachable." fi else Unknown_Input_Mode fi } #///////////////////////////////////////////////////////////////////////////////////// #Ethernet force link speed #///////////////////////////////////////////////////////////////////////////////////// Eth_Force_Speed_Main(){ if (( $INPUT_DEVICE_VALUE > 0 )); then local eth_force_speed=$INPUT_DEVICE_VALUE local eth_adapter="eth$(sed -n 1p /DietPi/dietpi/.network)" cat << _EOF_ > /etc/systemd/system/ethtool_force_speed.service [Unit] Description=ethtool force speed After=network-online.target [Service] Type=oneshot ExecStart=/sbin/ethtool -s $eth_adapter speed $eth_force_speed duplex full autoneg off [Install] WantedBy=ifup@$eth_adapter.service _EOF_ systemctl enable ethtool_force_speed.service systemctl start ethtool_force_speed.service elif [ "$INPUT_DEVICE_VALUE" = "disable" ]; then #0 is converted to 'disabled' rm /etc/systemd/system/ethtool_force_speed.service &> /dev/null systemctl daemon-reload else Unknown_Input_Mode fi } #///////////////////////////////////////////////////////////////////////////////////// #RPi openGL #///////////////////////////////////////////////////////////////////////////////////// RPi_OpenGL_Main(){ if [ "$INPUT_DEVICE_VALUE" = "enable" ]; then #RPi 2/3+ only if (( $HW_MODEL >= 2 && $HW_MODEL < 10 )); then #install pre-reqs # - Install Xserver /DietPi/dietpi/dietpi-software install 6 # - GL packages /DietPi/dietpi/func/dietpi-notify 2 "Installing additional OpenGL packages, please wait...\n" sleep 1 apt-get install -y libgl1-mesa-dri mesa-utils sed -i '/dtoverlay=vc4-kms-v3d/d' /DietPi/config.txt echo -e "\ndtoverlay=vc4-kms-v3d" >> /DietPi/config.txt else /DietPi/dietpi/func/dietpi-notify 1 "OpenGL requires a RPi 2 or higher" sleep 2 fi elif [ "$INPUT_DEVICE_VALUE" = "disable" ]; then sed -i '/dtoverlay=vc4-kms-v3d/d' /DietPi/config.txt else Unknown_Input_Mode fi } #///////////////////////////////////////////////////////////////////////////////////// # lcdpanel eg: All non-HDMI/VGA based displays and monitors. #///////////////////////////////////////////////////////////////////////////////////// Lcd_Panel_Not_Available_For_Device(){ EXIT_CODE=1 /DietPi/dietpi/func/dietpi-notify 2 "$INPUT_DEVICE_VALUE is not available for this device. Nothing has been applied." } Lcd_Panel_Main(){ local update_dietpitxt=1 if [ "$INPUT_DEVICE_VALUE" = "odroid-lcd35" ]; then Lcd_Panel_OdroidLCD35_Enable elif [ "$INPUT_DEVICE_VALUE" = "waveshare32" ]; then Lcd_Panel_Waveshare32_Enable elif [ "$INPUT_DEVICE_VALUE" = "odroid-cloudshell" ]; then Lcd_Panel_Odroidcloudshell_Enable #disable all elif [ "$INPUT_DEVICE_VALUE" = "none" ]; then Lcd_Panel_Waveshare32_Disable Lcd_Panel_Odroidcloudshell_Disable Lcd_Panel_OdroidLCD35_Disable else update_dietpitxt=0 Unknown_Input_Mode fi #Update dietpi.txt entry? if (( $update_dietpitxt )); then sed -i "/^lcdpanel=/c\lcdpanel=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt fi } Lcd_Panel_Xorg_All_Enable(){ #Xinput calibrator apt-get install -y xinput-calibrator mkdir -p /etc/X11/xorg.conf.d # - Create desktop icon for xcalibration mkdir -p "$HOME"/Desktop cat << _EOF_ > "$HOME"/Desktop/xinput_calibrator.desktop [Desktop Entry] Version=1.0 Name=xinput_calibrator Type=Application Comment=xinput_calibrator Terminal=true Exec=xinput_calibrator #Icon=/DietPi/dietpi/conf/desktop/dietpi-icon.png Categories=System; GenericName=xinput_calibrator _EOF_ } # - Waveshare32 Lcd_Panel_Waveshare32_Enable_X11(){ cat << _EOF_ > /etc/X11/xorg.conf.d/99-waveshare32_xorg.conf Section "Device" Identifier "FBDEV" Driver "fbdev" Option "fbdev" "/dev/fb1" Option "SwapbuffersWait" "true" EndSection _EOF_ cat << _EOF_ > /etc/X11/xorg.conf.d/99-waveshare32_calibration.conf Section "InputClass" Identifier "calibration" MatchProduct "ADS7846 Touchscreen" Option "Calibration" "219 3835 3984 219" Option "SwapAxes" "0" EndSection _EOF_ } Lcd_Panel_Waveshare32_Enable(){ #Disable 1st to reset any existing installations: Lcd_Panel_Waveshare32_Disable #RPi if (( $HW_MODEL < 10 )); then # + X11 Lcd_Panel_Xorg_All_Enable Lcd_Panel_Waveshare32_Enable_X11 wget http://dietpi.com/downloads/conf/waveshare32b-overlay.dtb -O /boot/overlays/waveshare32b.dtbo #consoleblank=0 no effect sed -i 's/rootwait/rootwait fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo/' /boot/cmdline.txt sed -i "/dtparam=i2c_arm=/c\dtparam=i2c_arm=on" /DietPi/config.txt sed -i "/dtparam=spi=/c\dtparam=spi=on" /DietPi/config.txt cat << _EOF_ >> /DietPi/config.txt #Waveshare 32 LCD dtoverlay=waveshare32b:rotate=270 dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,swapxy=0,pmax=255,xohms=60,xmin=200,xmax=3900,ymin=200,ymax=3900 dtoverlay=w1-gpio-pullup,gpiopin=4,extpullup=1 _EOF_ # - Swap input axis sed -i '/"SwapAxes"/c\ Option "SwapAxes" "1"' /etc/X11/xorg.conf.d/99-waveshare32_calibration.conf #Odroids elif (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then # + X11 Lcd_Panel_Xorg_All_Enable Lcd_Panel_Waveshare32_Enable_X11 #con2fbmap, maps console (1) to panel(2). Run during boot. cat << _EOF_ > /etc/systemd/system/con2fbmap.service [Unit] Description=con2fbmap [Service] Type=oneshot ExecStart=/bin/con2fbmap 1 2 ExecStop=/bin/con2fbmap 1 0 RemainAfterExit=yes [Install] WantedBy=multi-user.target _EOF_ systemctl enable con2fbmap.service systemctl daemon-reload echo -e "spicc" >> /etc/modules echo -e "fbtft_device" >> /etc/modules cat << _EOF_ > /etc/modprobe.d/waveshare32.conf options fbtft_device name=odroidc_tft32 rotate=270 gpios=reset:116,dc:115 speed=32000000 cs=0 _EOF_ #x11 cat << _EOF_ > /etc/X11/xorg.conf.d/99-waveshare32_xorg.conf Section "Device" Identifier "FBDEV" Driver "fbdev" Option "fbdev" "/dev/fb2" #Option "SwapbuffersWait" "true" EndSection _EOF_ else Lcd_Panel_Not_Available_For_Device fi } Lcd_Panel_Waveshare32_Disable(){ #all rm /etc/X11/xorg.conf.d/99-waveshare32_calibration.conf rm /etc/X11/xorg.conf.d/99-waveshare32_xorg.conf rm /usr/share/applications/xinput_calibrator.desktop #RPi if (( $HW_MODEL < 10 )); then rm /boot/overlays/waveshare32b.dtbo sed -i 's/ fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo//' /boot/cmdline.txt sed -i '/Waveshare 32 LCD/d' /DietPi/config.txt sed -i '/dtoverlay=waveshare32b/d' /DietPi/config.txt sed -i '/dtoverlay=ads7846,cs=1,penirq=17/d' /DietPi/config.txt sed -i '/dtoverlay=w1-gpio-pullup,gpiopin=4,extpullup=1/d' /DietPi/config.txt # - Leave these enabled, just incase the user has other hardware that may use them. #sed -i "/dtparam=i2c_arm=/c\dtparam=i2c_arm=on" /DietPi/config.txt #sed -i "/dtparam=spi=/c\dtparam=spi=on" /DietPi/config.txt #Odroids elif (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then rm /etc/systemd/system/con2fbmap.service systemctl daemon-reload rm /etc/modprobe.d/waveshare32.conf sed -i '/^spicc/d' /etc/modules sed -i '/^fbtft_device/d' /etc/modules fi } # - Odroid Cloudshell Lcd_Panel_Odroidcloudshell_Enable(){ cat << _EOF_ > /etc/modprobe.d/odroid-cloudshell.conf options fbtft_device name=hktft9340 busnum=1 rotate=270 _EOF_ echo -e "spi_s3c64xx" >> /etc/modules echo -e "fbtft_device" >> /etc/modules } Lcd_Panel_Odroidcloudshell_Disable(){ rm /etc/modprobe.d/odroid-cloudshell.conf sed -i '/^spi_s3c64xx/d' /etc/modules sed -i '/^fbtft_device/d' /etc/modules ##Cant run it on the fly, locks up device. #root@DietPi-XU4:~# modprobe -rf spi_s3c64xx #root@DietPi-XU4:~# modprobe -rf fbtft_device #Segmentation fault } # - Odroid LCD 3.5 Lcd_Panel_OdroidLCD35_Enable(){ if (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then #Reset to disabled: Lcd_Panel_OdroidLCD35_Disable Lcd_Panel_Xorg_All_Enable cat << _EOF_ > /etc/modprobe.d/odroid-lcd35.conf options fbtft_device name=flexpfb rotate=90 options flexfb chip=ili9488 _EOF_ if (( ! $(cat /etc/modules | grep -ci -m1 'flexfb') )); then # - XU4 if (( $HW_MODEL == 11 )); then cat << _EOF_ >> /etc/modules fbtft_device flexfb sx865x _EOF_ # - C1/2 else # - awl_i2c is a shared module and not removed by disabling panel in this script. So lets clear any previous entries 1st to prevent dupes: sed -i '/^aml_i2c/d' /etc/modules cat << _EOF_ >> /etc/modules aml_i2c pwm-meson pwm-ctrl fbtft_device flexfb sx865x _EOF_ fi fi #Service # - XU4 if (( $HW_MODEL == 11 )); then cat << _EOF_ > /etc/systemd/system/odroid-lcd35.service [Unit] Description=Odroid LCD 3.5 [Path] PathExists=/dev/fb2 [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/setterm -blank 0 -powersave off ExecStart=/bin/con2fbmap 1 2 StandardOutput=tty [Install] WantedBy=multi-user.target _EOF_ # - C1/2 else cat << _EOF_ > /etc/systemd/system/odroid-lcd35.service [Unit] Description=Odroid LCD 3.5 [Path] PathExists=/dev/fb2 [Service] Type=oneshot RemainAfterExit=yes ExecStart=/bin/bash -c 'echo 500000 > /sys/devices/platform/pwm-ctrl/freq0' ExecStart=/bin/bash -c 'echo 1 > /sys/devices/platform/pwm-ctrl/enable0' ExecStart=/bin/bash -c 'echo 1023 > /sys/devices/platform/pwm-ctrl/duty0' ExecStart=/usr/bin/setterm -blank 0 -powersave off ExecStart=/bin/con2fbmap 1 2 StandardOutput=tty [Install] WantedBy=multi-user.target _EOF_ fi systemctl enable odroid-lcd35.service systemctl daemon-reload #XORG rm /etc/X11/xorg.conf.d/exynos.conf #XU4 mkdir -p /etc/X11/xorg.conf.d cat << _EOF_ > /etc/X11/xorg.conf.d/99-odroid-lcd35.conf Section "Device" Identifier "C fbdev" Driver "fbdev" Option "fbdev" "/dev/fb2" EndSection _EOF_ # - default calibration cat << _EOF_ > /etc/X11/xorg.conf.d/99-calibration.conf Section "InputClass" Identifier "calibration" MatchProduct "SX865X Touchscreen" Option "Calibration" "3854 155 3880 262" Option "SwapAxes" "0" EndSection _EOF_ else Lcd_Panel_Not_Available_For_Device fi } Lcd_Panel_OdroidLCD35_Disable(){ rm /etc/X11/xorg.conf.d/99-calibration.conf rm /etc/modprobe.d/odroid-lcd35.conf rm /etc/systemd/system/odroid-lcd35.service rm /etc/X11/xorg.conf.d/99-odroid-lcd35.conf systemctl daemon-reload } #///////////////////////////////////////////////////////////////////////////////////// # i2c #///////////////////////////////////////////////////////////////////////////////////// # Currently only for RPi. I2c_Main(){ if [ "$INPUT_DEVICE_VALUE" = "enable" ]; then #Check/install pre-reqs if (( $(dpkg -l | grep -ci -m1 'i2c-tools') == 0 )); then /DietPi/dietpi/func/dietpi-notify 2 "Installing Python-smbus, i2c-tools, pre-reqs.\nPlease wait...\n" sleep 1 apt-get install python-smbus i2c-tools -y fi #Kernel modules # - Remove all previous line references (includes commented ones) sed -i '/i2c-bcm2708/d' /etc/modules &> /dev/null sed -i '/i2c-dev/d' /etc/modules &> /dev/null # - Add modules echo -e "i2c-bcm2708" >> /etc/modules echo -e "i2c-dev" >> /etc/modules #Remove from blacklist (Wheezy only. Jessie doesnt exist) sed -i '/blacklist spi-bcm2708/d' /etc/modprobe.d/raspi-blacklist.conf &> /dev/null sed -i '/blacklist i2c-bcm2708/d' /etc/modprobe.d/raspi-blacklist.conf &> /dev/null #config.txt sed -i "/dtparam=i2c_arm=/c\dtparam=i2c_arm=on" /DietPi/config.txt sed -i "/dtparam=i2c1=/c\dtparam=i2c1=on" /DietPi/config.txt #DietPi-Software, set installed sed -i '/^aSOFTWARE_INSTALL_STATE\[72\]=/c\aSOFTWARE_INSTALL_STATE\[72\]=2' /DietPi/dietpi/.installed elif [ "$INPUT_DEVICE_VALUE" = "disable" ]; then sed -i '/i2c-bcm2708/d' /etc/modules &> /dev/null sed -i '/i2c-dev/d' /etc/modules &> /dev/null sed -i "/dtparam=i2c_arm=/c\dtparam=i2c_arm=off" /DietPi/config.txt sed -i "/dtparam=i2c1=/c\dtparam=i2c1=off" /DietPi/config.txt sed -i "/i2c_arm_baudrate=/c\i2c_arm_baudrate=100000" /DietPi/config.txt #Set baudrate (khz) | valid int elif [[ $INPUT_DEVICE_VALUE =~ ^-?[0-9]+$ ]] && (( $INPUT_DEVICE_VALUE >= 2 )); then sed -i "/i2c_arm_baudrate=/c\i2c_arm_baudrate=$(( $INPUT_DEVICE_VALUE * 1000 ))" /DietPi/config.txt #inform user INPUT_DEVICE_VALUE+="Khz" else Unknown_Input_Mode fi } #///////////////////////////////////////////////////////////////////////////////////// # bluetooth #///////////////////////////////////////////////////////////////////////////////////// Bluetooth_Main(){ local aBLUETOOTH_MODULES=() aBLUETOOTH_MODULES=("bluetooth") aBLUETOOTH_MODULES+=("bnep") aBLUETOOTH_MODULES+=("btbcm") # rpi3 broadcom onboard aBLUETOOTH_MODULES+=("rfcomm") # BPi pro/m2+ and others aBLUETOOTH_MODULES+=("hidp") # BPi pro/m2+ and others aBLUETOOTH_MODULES+=("hci_uart") # - Disable if [ "$INPUT_DEVICE_VALUE" = "disable" ]; then # + all Broadcom-based models that need brcm_patchram_plus if (( $HW_MODEL == 61 || $HW_MODEL == 62 )); then systemctl stop brcm_patchram_plus 2> /dev/null systemctl disable brcm_patchram_plus 2> /dev/null fi # + RPi 3 (apply to all, as pi-bluetooth package is default installed on all RPi's now) if (( $HW_MODEL < 10 )); then systemctl stop hciuart systemctl disable hciuart fi #bluetooth last systemctl stop bluetooth 2> /dev/null if (( $? != 0 )); then /DietPi/dietpi/func/dietpi-notify 2 "Bluetooth service failed to stop. Is it installed?" EXIT_CODE=1 fi systemctl disable bluetooth 2> /dev/null for ((i=$(( ${#aBLUETOOTH_MODULES[@]} - 1 )); i>=0; i--)) do modprobe -rf "${aBLUETOOTH_MODULES[$i]}" 2> /dev/null echo -e "blacklist ${aBLUETOOTH_MODULES[$i]}" >> /etc/modprobe.d/disable_bt.conf done # - Enable elif [ "$INPUT_DEVICE_VALUE" = "enable" ]; then rm /etc/modprobe.d/disable_bt.conf &> /dev/null #bluetooth first for ((i=0; i<${#aBLUETOOTH_MODULES[@]}; i++)) do modprobe "${aBLUETOOTH_MODULES[$i]}" 2> /dev/null done # + all Broadcom-based models that need brcm_patchram_plus if (( $HW_MODEL == 61 || $HW_MODEL == 62 )); then systemctl enable brcm_patchram_plus 2> /dev/null systemctl start brcm_patchram_plus 2> /dev/null if (( $? != 0 )); then /DietPi/dietpi/func/dietpi-notify 2 "brcm_patchram_plus service failed to start. Is it installed?" EXIT_CODE=1 fi fi systemctl enable bluetooth 2> /dev/null systemctl start bluetooth 2> /dev/null if (( $? != 0 )); then /DietPi/dietpi/func/dietpi-notify 2 "Bluetooth service failed to start. Is it installed?" EXIT_CODE=1 fi # + RPi 3 if (( $HW_MODEL == 3 )); then #pi-bluetooth contains hciuart service and also pulls in firmware: https://github.com/Fourdee/DietPi/issues/693 # Installed by default as of v142 if (( ! $(dpkg --get-selections | grep -ci -m1 '^pi-bluetooth') )); then apt-get install -y pi-bluetooth fi systemctl enable hciuart #Start service again, if it fails: https://github.com/Fourdee/DietPi/issues/376#issuecomment-230149754 loop_count=0 max_count=3 while (( $(systemctl start hciuart;echo $?) != 0 )) do if (( $loop_count >= $max_count )); then /DietPi/dietpi/func/dietpi-notify 1 "hciuart failed to start after $loop_count attempts." EXIT_CODE=1 break else /DietPi/dietpi/func/dietpi-notify 2 "hciuart failed to start. Attempting to restart it, please wait..." ((loop_count++)) sleep 1 fi done fi else Unknown_Input_Mode fi unset aBLUETOOTH_MODULES } #///////////////////////////////////////////////////////////////////////////////////// # Network #///////////////////////////////////////////////////////////////////////////////////// Prefer_IPversion(){ if [ "$INPUT_DEVICE_VALUE" = "ipv4" ]; then echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99force-ipv elif [ "$INPUT_DEVICE_VALUE" = "ipv6" ]; then echo 'Acquire::ForceIPv6 "true";' > /etc/apt/apt.conf.d/99force-ipv elif [ "$INPUT_DEVICE_VALUE" = "auto" ]; then rm /etc/apt/apt.conf.d/99force-ipv &> /dev/null else Unknown_Input_Mode fi #Update dietpi.txt global sed -i "/^prefer_ipversion=/c\prefer_ipversion=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt } Wifi_Main(){ local aWIFI_MODULES=() # - All aWIFI_MODULES=("cfg80211") #NB: we need to start doing these device specific via $HW_MODEL index. This prevents unnecessary modules getting loaded. # + RPi 3 aWIFI_MODULES+=("brcmfmac") #onboard WiFi aWIFI_MODULES+=("brcmutil") #onboard WiFi # + BPi Pro aWIFI_MODULES+=("ap6211") #onboard # + OrangePi Zero if (( $HW_MODEL == 32 )); then aWIFI_MODULES+=("xradio_wlan") # + OrangePi Plus elif (( $HW_MODEL == 34 )); then aWIFI_MODULES+=("8189es") # + Pine A64 elif (( $HW_MODEL >= 40 && $HW_MODEL < 50 )); then aWIFI_MODULES+=("8723bs") #addon WiFi/BT board. # + NanoPi NEO Air elif (( $HW_MODEL == 64 )); then #4.9 uses brcm, only enable dhd for 3.x if [ ! -d /boot/dtb ]; then aWIFI_MODULES+=("dhd") fi fi # + NanoPi T3 aWIFI_MODULES+=("bcmdhd") # - Disable if [ "$INPUT_DEVICE_VALUE" = "disable" ]; then rm /etc/modprobe.d/disable_wifi.conf &> /dev/null #cfg80211 last for ((i=$(( ${#aWIFI_MODULES[@]} - 1 )); i>=0; i--)) do modprobe -rf "${aWIFI_MODULES[$i]}" 2> /dev/null echo -e "blacklist ${aWIFI_MODULES[$i]}" >> /etc/modprobe.d/disable_wifi.conf done # - Enable elif [ "$INPUT_DEVICE_VALUE" = "enable" ]; then rm /etc/modprobe.d/disable_wifi.conf &> /dev/null # - Disable known powersaving options for specific chipsets echo -e "options 8192cu rtw_power_mgnt=0" > /etc/modprobe.d/8192cu.conf echo -e "options 8188eu rtw_power_mgnt=0" > /etc/modprobe.d/8188eu.conf echo -e "options 8189es rtw_power_mgnt=0" > /etc/modprobe.d/8189es.conf #OPi Plus echo -e "options 8723bs rtw_power_mgnt=0" > /etc/modprobe.d/8723bs.conf #PineA64 #cfg80211 first for ((i=0; i<${#aWIFI_MODULES[@]}; i++)) do modprobe "${aWIFI_MODULES[$i]}" 2> /dev/null done # - Delay. Without this, kernel reports wifi device not found with RPi 3 and Pine A64 addon board, when ran straight after this script. /DietPi/dietpi/func/dietpi-notify 2 "Please wait, enabling WiFi Modules..." sleep 3 #Update our networking file (refresh active wlan index) /DietPi/dietpi/func/obtain_network_details elif [ "$INPUT_DEVICE_VALUE" = "onboard_enable" ]; then #NB: Requires reboot #NB: Do not change filenames, -f check used by DietPi-Config to obtain state # - RPi 3 rm /etc/modprobe.d/disable_wifi_rpi3_onboard.conf &> /dev/null elif [ "$INPUT_DEVICE_VALUE" = "onboard_disable" ]; then #NB: Requires reboot #NB: Do not change filenames, -f check used by DietPi-Config to obtain state # - RPi 3 echo -e "blacklist brcmfmac" > /etc/modprobe.d/disable_wifi_rpi3_onboard.conf echo -e "blacklist brcmutil" >> /etc/modprobe.d/disable_wifi_rpi3_onboard.conf else Unknown_Input_Mode fi unset aWIFI_MODULES } Wifi_Countrycode_Main(){ #Use country code from command input. Implies new setting. if [ -n "$INPUT_DEVICE_VALUE" ]; then #convert to uppercase: https://github.com/Fourdee/DietPi/issues/431 INPUT_DEVICE_VALUE=$(echo -e "$INPUT_DEVICE_VALUE" | tr '[:lower:]' '[:upper:]') # - Apply value to DietPi.txt sed -i "/^wifi_country_code=/c\wifi_country_code=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt #save country code to known system configs. # /etc/default/crda | Seems to have no effect, but we will do it for consistency. # /etc/modprobe.d/cfg80211.conf | Kernel/udev seems to apply this setting during boot. Although we call this script to override any set country code, no harm being consistent: https://github.com/Fourdee/DietPi/issues/313#issuecomment-217716104 echo -e "REGDOMAIN=$INPUT_DEVICE_VALUE" > /etc/default/crda echo -e "options cfg80211 ieee80211_regdom=$INPUT_DEVICE_VALUE" > /etc/modprobe.d/cfg80211.conf # - Activate country code, if WiFi modules are enabled: https://github.com/Fourdee/DietPi/issues/590 if (( $(lsmod | grep -ci -m1 '^cfg80211') )); then iw reg set "$INPUT_DEVICE_VALUE" EXIT_CODE=$? fi else Unknown_Input_Mode fi } #///////////////////////////////////////////////////////////////////////////////////// # serialconsole #///////////////////////////////////////////////////////////////////////////////////// MAX_SERIAL_CONSOLES=2 # ttySAC2 used by nanoPi m3 Serial_Main(){ #------------------------------------------------------------------------------------- #Enable if [ "$INPUT_DEVICE_VALUE" = "enable" ]; then #systemctl enable serial-getty@*.service # Wildcard does not work, we need to specify each possible tty device name #systemctl enable serial-getty@ttyAMA[0-9].service # Number wildcards do not work, we need to specify each possible tty device number /DietPi/dietpi/func/dietpi-notify 2 "Enabling known serial-getty services, please wait..." systemctl enable serial-getty@.service for ((i=0; i<=$MAX_SERIAL_CONSOLES; i++)) do systemctl enable serial-getty@ttyAMA"$i".service systemctl enable serial-getty@ttySAC"$i".service systemctl enable serial-getty@ttyS"$i".service done #Device Specific: # - RPi if (( $HW_MODEL < 10 )); then if (( ! $(cat /boot/cmdline.txt | grep -ci -m1 'console=ttyAMA0,115200 ') )); then sed -i 's/console=tty1 /console=tty1 console=ttyAMA0,115200 /' /boot/cmdline.txt fi if (( $HW_MODEL == 3 )); then # - Must use 250mhz core frequency, else, corrupt characters: https://github.com/Fourdee/DietPi/issues/306#issuecomment-222304202 sed -i '/core_freq=/c\core_freq=250' /DietPi/config.txt fi # - Odroid C1 elif (( $HW_MODEL == 10 )); then sed -i '/^setenv condev/c\setenv condev "console=tty0 console=ttyS0,115200n8"' /DietPi/boot.ini # - Odroid XU4 elif (( $HW_MODEL == 11 )); then if (( ! $(cat /DietPi/boot.ini | grep -ci -m1 'console=ttySAC2,115200n8 ') )); then sed -i 's/console=tty1 /console=tty1 console=ttySAC2,115200n8 /' /DietPi/boot.ini fi # - Odroid C2 elif (( $HW_MODEL == 12 )); then sed -i '/^setenv condev/c\setenv condev "console=tty0 console=ttyS0,115200n8"' /DietPi/boot.ini # - Pine A64 elif (( $HW_MODEL >= 40 && $HW_MODEL < 50 )); then if (( ! $(cat /DietPi/uEnv.txt | grep -ci -m1 'console=ttyS0,115200n8 ') )); then sed -i 's/console=tty0 /console=tty0 console=ttyS0,115200n8 /' /DietPi/uEnv.txt fi fi # - Update dietpi.txt global var sed -i '/^serial_console_enabled=/c\serial_console_enabled=1' /DietPi/dietpi.txt #------------------------------------------------------------------------------------- #Disable elif [ "$INPUT_DEVICE_VALUE" = "disable" ]; then #Disable services. Although, this seems to have no effect on the cmdline.txt boot.ini etc serial console entries. They run regardless. But lets do it for consistency. /DietPi/dietpi/func/dietpi-notify 2 "Disabling known serial-getty services, please wait..." systemctl disable serial-getty@.service for ((i=0; i<=$MAX_SERIAL_CONSOLES; i++)) do systemctl disable serial-getty@ttyAMA"$i".service systemctl disable serial-getty@ttySAC"$i".service systemctl disable serial-getty@ttyS"$i".service done #Device Specific: # - RPi if (( $HW_MODEL < 10 )); then # RPi 1/2 sed -i 's/console=ttyAMA0,115200 //' /boot/cmdline.txt # + RPi 3 (old entry, now uses AMA0 with 4.4.21) sed -i 's/console=ttyS0,115200 //' /boot/cmdline.txt # RPi 3 - Put core freq back to default (400mhz), if set to 250mhz. if (( $HW_MODEL == 3 && $(cat /DietPi/config.txt | grep -m1 'core_freq=' | sed 's/.*=//') == 250 )); then sed -i '/core_freq=/c\#core_freq=400' /DietPi/config.txt fi # - Odroid C1 elif (( $HW_MODEL == 10 )); then sed -i '/^setenv condev/c\setenv condev "console=tty0"' /DietPi/boot.ini # - Odroid XU4 elif (( $HW_MODEL == 11 )); then sed -i 's/console=ttySAC2,115200n8 //' /DietPi/boot.ini # - Odroid C2 elif (( $HW_MODEL == 12 )); then sed -i '/^setenv condev/c\setenv condev "console=tty0"' /DietPi/boot.ini # - Pine A64 elif (( $HW_MODEL >= 40 && $HW_MODEL < 50 )); then sed -i 's/console=ttyS0,115200n8 //' /DietPi/uEnv.txt fi # - Update dietpi.txt global var sed -i '/^serial_console_enabled=/c\serial_console_enabled=0' /DietPi/dietpi.txt else Unknown_Input_Mode fi } #///////////////////////////////////////////////////////////////////////////////////// # soundcard #///////////////////////////////////////////////////////////////////////////////////// #NB: When adding a new dtoverlay soundcard, we must add the dtoverlay name for deletion in Soundcard_Reset_RPi() SOUNDCARD_TARGET_CARD=0 SOUNDCARD_TARGET_DEVICE=0 ALSA_EQ_ENABLED=0 #Disable all soundcards and revert back to HDMI output if available. Soundcard_Reset_All(){ SOUNDCARD_TARGET_CARD=0 SOUNDCARD_TARGET_DEVICE=0 ALSA_EQ_ENABLED=0 #Remove previous asound.conf rm /etc/asound.conf &> /dev/null # - Pre-Reqs for any soundcard if (( ! $(dpkg --get-selections | grep -ci -m1 '^alsa-utils') )); then /DietPi/dietpi/func/dietpi-notify 2 "Installing alsa-utils. Please wait..." apt-get install -y alsa-utils if (( $? != 0 )); then /DietPi/dietpi/func/dietpi-notify 1 "Unable to install alsa-utils." fi fi #HW specific # - RPI if (( $HW_MODEL < 10 )); then Soundcard_Reset_RPi # - Odroid elif (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then Soundcard_Reset_Odroid # - H3 elif (( $HW_CPUID == 1 )); then Soundcard_Reset_H3 # - Pine a64 elif (( $HW_MODEL >= 40 && $HW_MODEL < 50 )); then Soundcard_Reset_PineA64 # - BPi Pro elif (( $HW_MODEL == 51 )); then Soundcard_Reset_BPi_Pro #Sparky SBC elif (( $HW_MODEL == 70 )); then Soundcard_Reset_SparkySBC fi } Soundcard_Reset_RPi(){ # - Add dtparam=audio=off # as of 4.4 kernel: https://github.com/Fourdee/DietPi/issues/327 if (( $(cat /DietPi/config.txt | grep -ci -m1 'dtparam=audio=') == 0 )); then echo -e "dtparam=audio=off" >> /DietPi/config.txt else sed -i '/dtparam=audio=/c\dtparam=audio=off' /DietPi/config.txt fi # - Disable known soundcard dtoverlays sed -i '/dtoverlay=rpi-bcm2835/d' /DietPi/config.txt sed -i '/dtoverlay=hifiberry/d' /DietPi/config.txt sed -i '/dtoverlay=iqaudio/d' /DietPi/config.txt sed -i '/dtoverlay=justboom/d' /DietPi/config.txt sed -i '/dtoverlay=allo-piano-dac/d' /DietPi/config.txt # onboard blacklist module echo -e "blacklist snd-bcm2835" > /etc/modprobe.d/rpi-bcm2708.conf sed -i '/avoid_pwm_pll=/c\avoid_pwm_pll=1' /DietPi/config.txt # - forced analogue out systemctl disable rpi-bcm2835_forced_3.5mm.service &> /dev/null rm /etc/systemd/system/rpi-bcm2835_forced_3.5mm.service &> /dev/null systemctl daemon-reload } Soundcard_Reset_Odroid(){ # - hifi shield plus sed -i '/snd-soc-pcm5102/d' /etc/modules sed -i '/snd-soc-odroid-dac/d' /etc/modules # - hifi shield 2 sed -i '/snd-soc-pcm512x/d' /etc/modules sed -i '/snd-soc-pcm512x-i2c/d' /etc/modules sed -i '/snd-soc-odroid-dac2/d' /etc/modules if [ -f /etc/systemd/system/odroid-hifishield2.service ]; then rm /etc/systemd/system/odroid-hifishield2.service systemctl daemon-reload fi } Soundcard_Reset_H3(){ #set hdmi amixer set -c 0 'Audio lineout' mute &> /dev/null SOUNDCARD_TARGET_CARD=1 } Soundcard_Reset_SparkySBC(){ sed -i '/snd-soc-allo-piano-dac/d' /etc/modules # - HDMI SOUNDCARD_TARGET_DEVICE=1 amixer -c 0 sset 'audio output mode switch' 'hdmi' } Soundcard_Reset_PineA64(){ rm /etc/modules-load.d/pine64-audiojack.conf } Soundcard_Reset_BPi_Pro(){ #HDMI SOUNDCARD_TARGET_CARD=2 } Soundcard_Main(){ #----------------------------------------------------------------------------- #Always reset soundcards and revert back to HDMI Soundcard_Reset_All #----------------------------------------------------------------------------- #Apply specific asound.confs and additional settings # - ALSA EQ enabled? if [[ $INPUT_DEVICE_VALUE == *-eq ]]; then ALSA_EQ_ENABLED=1 # - remove -eq from string so it doesn't get sent as a dtoverlay= on rpi and dietpi.txt entry INPUT_DEVICE_VALUE=$(echo -e "$INPUT_DEVICE_VALUE" | sed 's/-eq//g') fi # - Update DietPi global soundcard var sed -i "/^soundcard=/c\soundcard=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt # - RPi: Enable DTPARAM audio setting if (( $HW_MODEL < 10 )); then # - Enable dtparam audio sed -i '/dtparam=audio=/c\dtparam=audio=on' /DietPi/config.txt fi #Cards case "$INPUT_DEVICE_VALUE" in #ALL: ---------------------------------------------------------------------- usb-dac) # - detect card local usb_detection_card_index=$(aplay -l | grep -m1 'USB Audio' | awk '{print $2}' | sed 's/://g') if [[ $usb_detection_card_index =~ ^-?[0-9]+$ ]]; then SOUNDCARD_TARGET_CARD=$usb_detection_card_index # - Not found else /DietPi/dietpi/func/dietpi-notify 1 "Unable to find a USB-DAC on system." EXIT_CODE=1 fi SOUNDCARD_TARGET_DEVICE=0 ;; #RPi ------------------------------------------------------------------------------- #rpi-bcm2835 #rpi-bcm2835-ultrahq #rpi-bcm2835-3.5mm #rpi-bcm2835-ultrahq-3.5mm rpi-bcm2835*) # - remove from blacklist to enable: rm /etc/modprobe.d/rpi-bcm2708.conf # - Enable HQ audio sed -i '/avoid_pwm_pll=/c\avoid_pwm_pll=0' /DietPi/config.txt # - Expermental UltraHQ audio: https://www.raspberrypi.org/forums/viewtopic.php?p=907075#p907075 if [[ $INPUT_DEVICE_VALUE == *ultrahq* ]]; then sed -i '/avoid_pwm_pll=/c\avoid_pwm_pll=2' /DietPi/config.txt fi # - Force 3.5mm out? if [[ $INPUT_DEVICE_VALUE == *3.5mm* ]]; then cat << _EOF_ > /etc/systemd/system/rpi-bcm2835_forced_3.5mm.service [Unit] Description=Forces sound through 3.5mm analogue Before=sound.target After=dietpi-boot.service dietpi-ramdisk.service dietpi-ramlog.service [Service] Type=simple RemainAfterExit=yes ExecStart=/usr/bin/amixer -c 0 cset numid=3 1 [Install] WantedBy=multi-user.target _EOF_ systemctl daemon-reload systemctl enable rpi-bcm2835_forced_3.5mm.service systemctl start rpi-bcm2835_forced_3.5mm.service fi ;; #hifiberry-dac #hifiberry-dacplus #hifiberry-digi #hifiberry-digi-pro #hifiberry-amp hifiberry-*) # - enable dtoverlay echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> /DietPi/config.txt ;; #JustBoom-dac: DAC HAT, Amp HAT, DAC Zero and Amp Zero #JustBoom-digi: Digi HAT and Digi Zero justboom-*) # - enable dtoverlay echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> /DietPi/config.txt ;; #RPi (dtoverlay) # allo-piano-dac-pcm512x-audio # allo-piano-dac-plus-pcm512x-audio (2.1) #Sparky SBC (module) # snd-soc-allo-piano-dac # snd-soc-allo-piano-dac-plus (2.1) *allo-piano-dac*) # - enable dtoverlay echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> /DietPi/config.txt # + Sparky SBC if (( $HW_MODEL == 70 )); then echo -e "$INPUT_DEVICE_VALUE" >> /etc/modules SOUNDCARD_TARGET_CARD=1 SOUNDCARD_TARGET_DEVICE=0 amixer -c 0 sset 'audio output mode switch' 'i2s' fi ;; #Sparky SBC #allo-cheapo-analogue #3.5mm/RCA #allo-cheapo-optical #Optical out allo-cheapo*) SOUNDCARD_TARGET_CARD=0 SOUNDCARD_TARGET_DEVICE=0 # - Vol amixer –c 0 set 'DAC PA' 35 if [ "$INPUT_DEVICE_VALUE" = "allo-cheapo-analogue" ]; then amixer -c 0 sset 'audio output mode switch' 'i2s' else amixer -c 0 sset 'audio output mode switch' 'spdif' fi ;; iqaudio-*) # - enable dtoverlay echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> /DietPi/config.txt ;; #Odroid ------------------------------------------------------------------------------- odroid-hifishield-plus) echo -e "snd-soc-pcm5102" >> /etc/modules echo -e "snd-soc-odroid-dac" >> /etc/modules SOUNDCARD_TARGET_CARD=1 ;; odroid-hifishield-2) sed -i '/^aml_i2c/d' /etc/modules # shared module, remove all previous entries before adding echo -e "aml_i2c" >> /etc/modules echo -e "snd-soc-pcm512x" >> /etc/modules echo -e "snd-soc-pcm512x-i2c" >> /etc/modules echo -e "snd-soc-odroid-dac2" >> /etc/modules SOUNDCARD_TARGET_CARD=1 cat << _EOF_ > /etc/systemd/system/odroid-hifishield2.service [Unit] Description=odroid-hifishield2 After=local-fs.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=/bin/bash -c 'echo pcm5242 0x4c > /sys/class/i2c-adapter/i2c-1/new_device' ExecStart=/bin/bash -c 'amixer -c 1 sset Analogue 0' ExecStart=/bin/bash -c 'amixer -c 1 sset Digital 201' ExecStart=/bin/bash -c 'amixer -c 1 sset Deemphasis on' [Install] WantedBy=sound.target _EOF_ systemctl enable odroid-hifishield2.service systemctl daemon-reload ;; #H3 ------------------------------------------------------------------------------- h3-analogue) amixer set -c 0 'Audio lineout' unmute &> /dev/null SOUNDCARD_TARGET_CARD=0 ;; #Pine A64 ------------------------------------------------------------------------------- pine64-analogue) cat << _EOF_ > /etc/modules-load.d/pine64-audiojack.conf sunxi_codec sunxi_i2s sunxi_sndcodec _EOF_ SOUNDCARD_TARGET_CARD=1 ;; #NanoPi M2/M3 ------------------------------------------------------------------------------- s5pxx18-hdmi) SOUNDCARD_TARGET_CARD=1 ;; esac # - Apply asound.conf if (( $ALSA_EQ_ENABLED )); then cat << _EOF_ > /etc/asound.conf ctl.eq { type equal controls "$HOME/.alsaequal.bin" } pcm.plugequal { type equal slave.pcm "plughw:$SOUNDCARD_TARGET_CARD,$SOUNDCARD_TARGET_DEVICE" controls "$HOME/.alsaequal.bin" } pcm.!default { type plug slave.pcm plugequal slave.channels 2 } ctl.!default { type hw card $SOUNDCARD_TARGET_CARD } _EOF_ if (( ! $(dpkg --get-selections | grep -ci -m1 '^libasound2-plugin-equal') )); then apt-get install -y libasound2-plugin-equal fi else cat << _EOF_ > /etc/asound.conf pcm.!default { type hw card $SOUNDCARD_TARGET_CARD device $SOUNDCARD_TARGET_DEVICE } ctl.!default { type hw card $SOUNDCARD_TARGET_CARD } _EOF_ fi } #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// #----------------------------------------------------------------------------------- #info /DietPi/dietpi/func/dietpi-notify 3 DietPi-Set_Hardware "$INPUT_DEVICE_NAME ($INPUT_DEVICE_VALUE)" #----------------------------------------------------------------------------------- if [ "$INPUT_DEVICE_NAME" = "soundcard" ]; then Soundcard_Main elif [ "$INPUT_DEVICE_NAME" = "serialconsole" ]; then Serial_Main elif [ "$INPUT_DEVICE_NAME" = "bluetooth" ]; then Bluetooth_Main elif [ "$INPUT_DEVICE_NAME" = "wifi" ]; then Wifi_Main elif [ "$INPUT_DEVICE_NAME" = "preferipversion" ]; then Prefer_IPversion elif [ "$INPUT_DEVICE_NAME" = "wificountrycode" ]; then Wifi_Countrycode_Main elif [ "$INPUT_DEVICE_NAME" = "i2c" ]; then I2c_Main elif [ "$INPUT_DEVICE_NAME" = "lcdpanel" ]; then Lcd_Panel_Main elif [ "$INPUT_DEVICE_NAME" = "rpi-opengl" ]; then RPi_OpenGL_Main elif [ "$INPUT_DEVICE_NAME" = "eth-forcespeed" ]; then Eth_Force_Speed_Main elif [ "$INPUT_DEVICE_NAME" = "kernel" ]; then Kernel_Main elif [ "$INPUT_DEVICE_NAME" = "remoteir" ]; then RemoteIR_Main elif [ "$INPUT_DEVICE_NAME" = "gpumemsplit" ]; then Gpu_Memory_Split_Main elif [ "$INPUT_DEVICE_NAME" = "rpi-camera" ]; then RPi_Camera_Main else Unknown_Input_Name fi #----------------------------------------------------------------------------------- /DietPi/dietpi/func/dietpi-notify -1 $EXIT_CODE "$INPUT_DEVICE_NAME $INPUT_DEVICE_VALUE |" #----------------------------------------------------------------------------------- exit $EXIT_CODE #----------------------------------------------------------------------------------- }