|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# DTS playback restoration script for LG OLED CX |
| 4 | +# Copyright (c) 2022-2023 Pete Batard <pete@akeo.ie> |
| 5 | +# See https://github.com/RootMyTV/RootMyTV.github.io/issues/72#issuecomment-1343204028 |
| 6 | + |
| 7 | +# Set the following to the directory where you have the GST plugins |
| 8 | +GST_SRC=/home/root/gst |
| 9 | + |
| 10 | +# Validate that we have the relevant init.d directory |
| 11 | +INIT_DIR=/var/lib/webosbrew/init.d |
| 12 | +if [[ ! -d $INIT_DIR ]]; then |
| 13 | + echo "$INIT_DIR/ is missing - Aborting" |
| 14 | + exit 1 |
| 15 | +fi |
| 16 | + |
| 17 | +# Validate that there is a GStreamer registry to override |
| 18 | +if [[ ! -f $GST_REGISTRY_1_0 ]]; then |
| 19 | + echo "$GST_REGISTRY_1_0 is missing - Aborting" |
| 20 | + exit 1 |
| 21 | +fi |
| 22 | + |
| 23 | +# Validate that the media player isn't running |
| 24 | +MEDIA_PLAYER_INSTANCES=`ps -ef | grep [s]tarfish-media | wc -l` |
| 25 | +if [[ $MEDIA_PLAYER_INSTANCES -gt 1 ]]; then |
| 26 | + echo "Cannot install while media player is running - Aborting" |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +# Validate that the libraries we need are there |
| 31 | +for lib in libgstmatroska.so libgstlibav.so; do |
| 32 | + if [[ ! -f "$GST_SRC/$lib" ]]; then |
| 33 | + echo "$GST_SRC/$lib is missing - Aborting" |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | +done |
| 37 | + |
| 38 | +# Display a notice if not installing on the expected platform |
| 39 | +GST_VERSION=`gst-inspect-1.0 --version | grep GStreamer | cut -d " " -f 2` |
| 40 | +WEBOS_VERSION=`nyx-cmd OSInfo query webos_release` |
| 41 | +MODEL_NAME=`nyx-cmd DeviceInfo query product_id` |
| 42 | +if [[ "$GST_VERSION" != "1.14.4" || "${WEBOS_VERSION::1}" != "5" || "${MODEL_NAME::4}" != "OLED" || "${MODEL_NAME:6:2}" != "CX" ]]; then |
| 43 | + echo |
| 44 | + echo "This installer was designed specifically for LG OLED CX TVs running" |
| 45 | + echo "webOS 5.x with Gstreamer 1.14.4. However, you are trying run it on a(n)" |
| 46 | + echo "$MODEL_NAME TV with webOS $WEBOS_VERSION and GStreamer $GST_VERSION." |
| 47 | + echo |
| 48 | + echo "While installing this software on an incompatible platform should not" |
| 49 | + echo "cause irreversible damage, if you choose to proceed, you do acknowlegde" |
| 50 | + echo "that, because you are not using the relevant target system:" |
| 51 | + echo "1. The software may not work as expected, it at all." |
| 52 | + echo "2. You may lose existing features and/or functionality." |
| 53 | + echo "3. The entire responsibility for trying this software on an unsupported" |
| 54 | + echo " platform lies entirely with you." |
| 55 | + echo |
| 56 | + read -r -p "Do you wish to proceed? [y/N] " response |
| 57 | + case "$response" in |
| 58 | + [yY][eE][sS]|[yY]) |
| 59 | + ;; |
| 60 | + *) |
| 61 | + exit 1 |
| 62 | + ;; |
| 63 | + esac |
| 64 | +fi |
| 65 | + |
| 66 | +echo "Installing $INIT_DIR/restore_dts" |
| 67 | + |
| 68 | +# The script must *NOT* have a .sh extension |
| 69 | +cat <<EOS > $INIT_DIR/restore_dts |
| 70 | +#!/bin/bash |
| 71 | +
|
| 72 | +# Override the GST plugins that were nerfed by LG |
| 73 | +for lib in libgstmatroska.so libgstlibav.so; do |
| 74 | + if [[ -f $GST_SRC/\$lib ]]; then |
| 75 | + echo "Installing /usr/lib/gstreamer-1.0/\$lib override" |
| 76 | + mount -n --bind -o ro $GST_SRC/\$lib /usr/lib/gstreamer-1.0/\$lib |
| 77 | + fi |
| 78 | +done |
| 79 | +
|
| 80 | +# Override the GST registry |
| 81 | +if [[ -f $GST_REGISTRY_1_0 ]]; then |
| 82 | + echo "Installing $GST_REGISTRY_1_0 override" |
| 83 | + export GST_REGISTRY_1_0=/tmp/gst_1_0_registry.arm.bin |
| 84 | + /usr/bin/gst-inspect-1.0 > /var/tmp/gst-inspect.log |
| 85 | + chmod 666 \$GST_REGISTRY_1_0 |
| 86 | + chown :compositor \$GST_REGISTRY_1_0 |
| 87 | + mount -n --bind \$GST_REGISTRY_1_0 $GST_REGISTRY_1_0 |
| 88 | +fi |
| 89 | +
|
| 90 | +# Override /etc/gst/gstcool.conf |
| 91 | +if [[ ! -f /tmp/gstcool.conf ]]; then |
| 92 | + echo "Installing /etc/gst/gstcool.conf override" |
| 93 | + if [[ -f /etc/gst/gstcool.conf ]]; then |
| 94 | + sed "s/avdec_dca=0/avdec_dca=290/" /etc/gst/gstcool.conf > /tmp/gstcool.conf |
| 95 | + cat <<EOT >> /tmp/gstcool.conf |
| 96 | +
|
| 97 | +[downmix] |
| 98 | +front=1.25 |
| 99 | +center=0.75 |
| 100 | +lfe=0.75 |
| 101 | +rear=0.75 |
| 102 | +rear2=0.70 |
| 103 | +EOT |
| 104 | + mount -n --bind /tmp/gstcool.conf /etc/gst/gstcool.conf |
| 105 | + fi |
| 106 | +fi |
| 107 | +EOS |
| 108 | + |
| 109 | +chmod 755 $INIT_DIR/restore_dts |
| 110 | +if [[ ! -f /tmp/gstcool.conf ]]; then |
| 111 | + echo "Running $INIT_DIR/restore_dts" |
| 112 | + source $INIT_DIR/restore_dts |
| 113 | + echo "DTS playback has been permanently re-enabled - Enjoy!" |
| 114 | +fi |
0 commit comments