diff --git a/.github/labeler.yml b/.github/labeler.yml index 5ef0264783e3..5e42b0e67642 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -14,27 +14,27 @@ - all: - changed-files: - any-glob-to-any-file: ['patch/**/*','config/**/*'] - - any-globs-to-all-files: ['!config/cli/*','!config/desktop/*','!config/distributions/*'] + - any-glob-to-all-files: ['!config/cli/**/*','!config/desktop/**/*','!config/distributions/**/*'] "Framework": - all: - changed-files: - - any-glob-to-any-file: ['lib/*','tools/*','config/cli/*','packages/*','extensions/*'] + - any-glob-to-any-file: ['lib/**/*','tools/**/*','config/cli/**/*','packages/**/*','extensions/**/*'] "Actions scripts": - all: - changed-files: - - any-glob-to-any-file: ['.github/workflows/*'] + - any-glob-to-any-file: ['.github/workflows/**/*'] "Desktop": - all: - changed-files: - - any-glob-to-any-file: ['config/desktop/*'] + - any-glob-to-any-file: ['config/desktop/**/*'] "Patches": - all: - changed-files: - - any-glob-to-any-file: ['patch/*'] + - any-glob-to-any-file: ['patch/**/*'] # Add 'Documentation' label to any change to .md files within the entire repository "Documentation": diff --git a/config/boards/khadas-edge2.conf b/config/boards/khadas-edge2.conf index 7692afc66650..f10bafa83bf8 100644 --- a/config/boards/khadas-edge2.conf +++ b/config/boards/khadas-edge2.conf @@ -14,10 +14,28 @@ enable_extension "bluetooth-hciattach" # E declare -g KHADAS_OOWOW_BOARD_ID="Edge2" # for use with EXT=output-image-oowow declare -g UEFI_EDK2_BOARD_ID="edge2" # This _only_ used for uefi-edk2-rk3588 extension +function post_family_tweaks__kedge2_naming_audios() { + display_alert "$BOARD" "Renaming khadas-edge2 audios" "info" + + mkdir -p $SDCARD/etc/udev/rules.d/ + echo 'SUBSYSTEM=="sound", ENV{ID_PATH}=="platform-hdmi0-sound", ENV{SOUND_DESCRIPTION}="HDMI0 Audio"' > $SDCARD/etc/udev/rules.d/90-naming-audios.rules + echo 'SUBSYSTEM=="sound", ENV{ID_PATH}=="platform-dp0-sound", ENV{SOUND_DESCRIPTION}="DP0 Audio"' >> $SDCARD/etc/udev/rules.d/90-naming-audios.rules + echo 'SUBSYSTEM=="sound", ENV{ID_PATH}=="platform-es8316-sound", ENV{SOUND_DESCRIPTION}="ES8316 Audio"' >> $SDCARD/etc/udev/rules.d/90-naming-audios.rules + + return 0 +} + +declare -g DDR_BLOB='rk35/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.16.bin' +declare -g BL31_BLOB='rk35/rk3588_bl31_v1.45.elf' +declare -g BL32_BLOB='rk35/rk3588_bl32_v1.15.bin' + # for the kedge2, we're counting on the blobs+u-boot in SPI working, as it comes from factory. It does not support bootscripts. function post_family_config__uboot_kedge2() { - display_alert "$BOARD" "Configuring ($BOARD) non-u-boot" "info" - unset BOOTSOURCE - declare -g BOOTCONFIG='none' + display_alert "$BOARD" "Configuring ($BOARD) u-boot" "info" + + declare -g BOOTSOURCE='https://github.com/khadas/u-boot.git' + declare -g BOOTBRANCH='branch:khadas-edges-v2017.09' + declare -g BOOTPATCHDIR="legacy/u-boot-khadas-edge2-rk3588" + declare -g BOOTCONFIG="khadas-edge2-rk3588s_defconfig" declare -g SRC_EXTLINUX="yes" # For now, use extlinux. Thanks Monka } diff --git a/config/boards/lckfb-taishanpi.csc b/config/boards/lckfb-taishanpi.csc new file mode 100644 index 000000000000..1f6415fafe84 --- /dev/null +++ b/config/boards/lckfb-taishanpi.csc @@ -0,0 +1,21 @@ +# Rockchip RK3566 quad core 1GB-2GB GBE eMMC USB3 WiFi +BOARD_NAME="LCKFB Taishan Pi" +BOARDFAMILY="rk35xx" +BOARD_MAINTAINER="" +BOOTCONFIG="radxa-zero3-rk3566_defconfig" +KERNEL_TARGET="legacy,vendor" +BOOT_FDT_FILE="rockchip/rk3566-taishanpi-v10.dtb" +BOOT_SCENARIO="spl-blobs" +IMAGE_PARTITION_TABLE="gpt" + +# Override family config for this board; let's avoid conditionals in family config. +function post_family_config__tspi_use_radxa_vendor() { + BOOTSOURCE='https://github.com/radxa/u-boot.git' + BOOTBRANCH='branch:rk35xx-2024.01' + BOOTPATCHDIR="u-boot-radxa-latest" + UBOOT_TARGET_MAP="BL31=$RKBIN_DIR/$BL31_BLOB ROCKCHIP_TPL=$RKBIN_DIR/$DDR_BLOB;;u-boot-rockchip.bin" + unset uboot_custom_postprocess write_uboot_platform write_uboot_platform_mtd + function write_uboot_platform() { + dd if=$1/u-boot-rockchip.bin of=$2 seek=64 conv=notrunc status=none + } +} diff --git a/config/boards/leez-p710.csc b/config/boards/leez-p710.csc new file mode 100644 index 000000000000..2cb1565c2d50 --- /dev/null +++ b/config/boards/leez-p710.csc @@ -0,0 +1,10 @@ +# Rockchip RK3399 hexa core 4GB RAM SOC 16GB eMMC 2x USB2 1x USB3 1x USB-C HDMI 1x GbE WiFi/BT +BOARD_NAME="Lenovo Leez P710" +BOARDFAMILY="rockchip64" +BOARD_MAINTAINER="Andyshrk" +BOOTCONFIG="leez-rk3399_defconfig" +BOOT_FDT_FILE="rockchip/rk3399-leez-p710.dtb" +BOOT_LOGO="desktop" +BOOT_SCENARIO="blobless" +FULL_DESKTOP="yes" +KERNEL_TARGET="current,edge" diff --git a/config/boards/orangepi5-plus.conf b/config/boards/orangepi5-plus.conf index f8372da79644..b551b0063e68 100644 --- a/config/boards/orangepi5-plus.conf +++ b/config/boards/orangepi5-plus.conf @@ -1,4 +1,4 @@ -# Rockchip RK3588 octa core 4/8/16GB RAM SoC NVMe USB3 USB-C 2.5GbE eMMC +# Rockchip RK3588 octa core 4/8/16GB RAM SoC SPI NVMe 2x USB2 2x USB3 1x USB-C 2x 2.5GbE 3x HDMI BOARD_NAME="Orange Pi 5 Plus" BOARDFAMILY="rockchip-rk3588" BOARD_MAINTAINER="efectn" @@ -10,6 +10,8 @@ FULL_DESKTOP="yes" BOOT_LOGO="desktop" BOOT_FDT_FILE="rockchip/rk3588-orangepi-5-plus.dtb" BOOT_SCENARIO="spl-blobs" +DDR_BLOB='rk35/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.16.bin' +BL31_BLOB='rk35/rk3588_bl31_v1.45.elf' BOOT_SUPPORT_SPI="yes" BOOT_SPI_RKSPI_LOADER="yes" IMAGE_PARTITION_TABLE="gpt" @@ -28,9 +30,39 @@ function post_family_tweaks__orangepi5plus_naming_audios() { return 0 } -# Override uboot family config for this board; let's avoid conditionals in family config. -function post_family_config__orangepi5plus_use_vendor_uboot() { +# Use vendor-provided U-Boot for 'legacy' kernel branch; let's avoid conditionals in family config. +function post_family_config_branch_legacy__orangepi5plus_use_vendor_uboot() { BOOTSOURCE='https://github.com/orangepi-xunlong/u-boot-orangepi.git' BOOTBRANCH='branch:v2017.09-rk3588' BOOTPATCHDIR="legacy/u-boot-orangepi5-rk3588" } + +# Use vendor-provided U-Boot for 'vendor' kernel branch; let's avoid conditionals in family config. +function post_family_config_branch_vendor__orangepi5plus_use_vendor_uboot() { + BOOTSOURCE='https://github.com/orangepi-xunlong/u-boot-orangepi.git' + BOOTBRANCH='branch:v2017.09-rk3588' + BOOTPATCHDIR="legacy/u-boot-orangepi5-rk3588" +} + +# Mainline U-Boot for edge kernel +function post_family_config_branch_edge__orangepi5plus_use_mainline_uboot() { + display_alert "$BOARD" "Mainline U-Boot overrides for $BOARD - $BRANCH" "info" + + declare -g BOOTCONFIG="orangepi-5-plus-rk3588_defconfig" # override the default for the board/family + declare -g BOOTDELAY=1 # Wait for UART interrupt to enter UMS/RockUSB mode etc + declare -g BOOTSOURCE="https://github.com/u-boot/u-boot.git" # We ❤️ mainline U-Boot + declare -g BOOTBRANCH="tag:v2024.07-rc4" + declare -g BOOTPATCHDIR="v2024.07/board_${BOARD}" + declare -g BOOTDIR="u-boot-${BOARD}" # do not share u-boot directory + declare -g UBOOT_TARGET_MAP="BL31=${RKBIN_DIR}/${BL31_BLOB} ROCKCHIP_TPL=${RKBIN_DIR}/${DDR_BLOB};;u-boot-rockchip.bin u-boot-rockchip-spi.bin" + unset uboot_custom_postprocess write_uboot_platform write_uboot_platform_mtd # disable stuff from rockchip64_common; we're using binman here which does all the work already + + # Just use the binman-provided u-boot-rockchip.bin, which is ready-to-go + function write_uboot_platform() { + dd "if=$1/u-boot-rockchip.bin" "of=$2" bs=32k seek=1 conv=notrunc status=none + } + + function write_uboot_platform_mtd() { + flashcp -v -p "$1/u-boot-rockchip-spi.bin" /dev/mtd0 + } +} diff --git a/config/boards/station-m2.csc b/config/boards/station-m2.csc index f202f1019d87..3d7cc48a08ce 100644 --- a/config/boards/station-m2.csc +++ b/config/boards/station-m2.csc @@ -2,29 +2,34 @@ BOARD_NAME="Station M2" BOARDFAMILY="rk35xx" BOARD_MAINTAINER="" -BOOTCONFIG="firefly-m2-rk3568_defconfig" +BOOTCONFIG="station-m2-rk3566_defconfig" KERNEL_TARGET="legacy,vendor,current,edge" FULL_DESKTOP="yes" BOOT_LOGO="desktop" BOOT_FDT_FILE="rockchip/rk3566-firefly-roc-pc.dtb" -SRC_EXTLINUX="yes" -SRC_CMDLINE="console=ttyS02,1500000 console=tty0" +BOOT_SCENARIO="spl-blobs" ASOUND_STATE="asound.state.station-m2" IMAGE_PARTITION_TABLE="gpt" function post_family_tweaks__station_m2() { display_alert "$BOARD" "Installing board tweaks" "info" - cp -R $SRC/packages/blobs/rtl8723bt_fw/* $SDCARD/lib/firmware/rtl_bt/ cp -R $SRC/packages/blobs/station/firmware/* $SDCARD/lib/firmware/ return 0 } # Override family config for this board; let's avoid conditionals in family config. -function post_family_config__stationm2_use_vendor_uboot() { - BOOTSOURCE='https://github.com/150balbes/u-boot-rk' - BOOTBRANCH='branch:rk356x' - BOOTDIR="u-boot-${BOARD}" - BOOTPATCHDIR="u-boot-station-p2" +function post_family_config__stationm2_use_radxa_vendor_uboot() { + BOOTSOURCE='https://github.com/radxa/u-boot.git' + BOOTBRANCH='branch:rk35xx-2024.01' + BOOTPATCHDIR="u-boot-radxa-latest" + + UBOOT_TARGET_MAP="BL31=$RKBIN_DIR/$BL31_BLOB ROCKCHIP_TPL=$RKBIN_DIR/$DDR_BLOB;;u-boot-rockchip.bin" + + unset uboot_custom_postprocess write_uboot_platform write_uboot_platform_mtd + + function write_uboot_platform() { + dd if=$1/u-boot-rockchip.bin of=$2 seek=64 conv=notrunc status=none + } } diff --git a/config/boards/xiaomi-elish.conf b/config/boards/xiaomi-elish.conf index 4dce9d4ca849..ab8e1e269363 100644 --- a/config/boards/xiaomi-elish.conf +++ b/config/boards/xiaomi-elish.conf @@ -37,6 +37,10 @@ function post_family_tweaks_bsp__xiaomi-elish_firmware() { install -Dm655 $SRC/packages/bsp/usb-gadget-network/remove-usbgadget-network.sh $destination/usr/local/bin/ install -Dm644 $SRC/packages/bsp/usb-gadget-network/usbgadget-rndis.service $destination/usr/lib/systemd/system/ + # Bluetooth MAC addr setup service + install -Dm655 $SRC/packages/bsp/generate-bt-mac-addr/bt-fixed-mac.sh $destination/usr/local/bin/ + install -Dm644 $SRC/packages/bsp/generate-bt-mac-addr/bt-fixed-mac.service $destination/usr/lib/systemd/system/ + # Kernel postinst script to update abl boot partition install -Dm655 $SRC/packages/bsp/xiaomi-elish/zz-update-abl-kernel $destination/etc/kernel/postinst.d/ @@ -71,6 +75,7 @@ function post_family_tweaks__xiaomi-elish_enable_services() { chroot_sdcard systemctl enable usbgadget-rndis.service chroot_sdcard systemctl enable pd-mapper.service chroot_sdcard systemctl enable tqftpserv.service + chroot_sdcard systemctl enable bt-fixed-mac.service return 0 } diff --git a/config/cli/bullseye/main/packages b/config/cli/bullseye/main/packages index 1b4794f752be..4f3ac52ba15e 100644 --- a/config/cli/bullseye/main/packages +++ b/config/cli/bullseye/main/packages @@ -1,8 +1,6 @@ alsa-utils bc bridge-utils -chrony -command-not-found console-setup cron curl @@ -30,8 +28,6 @@ man-db mmc-utils ncurses-term nano -netplan.io -network-manager openssh-server parted psmisc diff --git a/config/cli/common/main/packages b/config/cli/common/main/packages index 29093ccdb345..0bb543231039 100644 --- a/config/cli/common/main/packages +++ b/config/cli/common/main/packages @@ -1,8 +1,6 @@ alsa-utils +bash-completion bc -bridge-utils -chrony -command-not-found console-setup cron curl @@ -10,9 +8,7 @@ dbus-user-session dialog debconf-utils debsums -device-tree-compiler dosfstools -ethtool fake-hwclock fdisk figlet @@ -20,6 +16,7 @@ htop inetutils-ping init initramfs-tools +iproute2 iw jq logrotate @@ -30,8 +27,6 @@ man-db mmc-utils ncurses-term nano -netplan.io -network-manager openssh-server parted psmisc @@ -39,13 +34,10 @@ rsync rsyslog sudo systemd-resolved -sysfsutils -sysstat toilet tzdata u-boot-tools usbutils -vlan wget wireless-tools wireguard-tools diff --git a/config/cli/common/main/packages.additional b/config/cli/common/main/packages.additional index c42920e1dae5..db545ca7c5e2 100644 --- a/config/cli/common/main/packages.additional +++ b/config/cli/common/main/packages.additional @@ -3,12 +3,14 @@ apt-utils aptitude automake avahi-autoipd -bash-completion bison btrfs-progs build-essential +command-not-found cracklib-runtime +device-tree-compiler dkms +ethtool evtest expect f2fs-tools @@ -23,7 +25,6 @@ hdparm htop html2text i2c-tools -ifenslave iotop iperf3 iptables @@ -37,7 +38,6 @@ libpam-systemd libproc-processtable-perl libwrap0-dev mc -network-manager-openvpn nfs-common ntfs-3g pciutils @@ -51,7 +51,8 @@ screen software-properties-common smartmontools stress -sudo +sysfsutils +sysstat unattended-upgrades unicode-data unzip diff --git a/config/cli/jammy/main/packages b/config/cli/jammy/main/packages index 1b4794f752be..4f3ac52ba15e 100644 --- a/config/cli/jammy/main/packages +++ b/config/cli/jammy/main/packages @@ -1,8 +1,6 @@ alsa-utils bc bridge-utils -chrony -command-not-found console-setup cron curl @@ -30,8 +28,6 @@ man-db mmc-utils ncurses-term nano -netplan.io -network-manager openssh-server parted psmisc diff --git a/config/cli/noble/main/packages.additional b/config/cli/noble/main/packages.additional index 6905bfd03083..a2a78f4ac303 100644 --- a/config/cli/noble/main/packages.additional +++ b/config/cli/noble/main/packages.additional @@ -23,7 +23,6 @@ hdparm htop html2text i2c-tools -ifenslave iotop iperf3 iptables @@ -37,7 +36,6 @@ libpam-systemd libproc-processtable-perl libwrap0-dev mc -network-manager-openvpn nfs-common ntfs-3g pciutils diff --git a/config/cli/sid/main/packages.additional b/config/cli/sid/main/packages.additional index 6905bfd03083..a2a78f4ac303 100644 --- a/config/cli/sid/main/packages.additional +++ b/config/cli/sid/main/packages.additional @@ -23,7 +23,6 @@ hdparm htop html2text i2c-tools -ifenslave iotop iperf3 iptables @@ -37,7 +36,6 @@ libpam-systemd libproc-processtable-perl libwrap0-dev mc -network-manager-openvpn nfs-common ntfs-3g pciutils diff --git a/config/cli/trixie/main/packages.additional b/config/cli/trixie/main/packages.additional index 6905bfd03083..a2a78f4ac303 100644 --- a/config/cli/trixie/main/packages.additional +++ b/config/cli/trixie/main/packages.additional @@ -23,7 +23,6 @@ hdparm htop html2text i2c-tools -ifenslave iotop iperf3 iptables @@ -37,7 +36,6 @@ libpam-systemd libproc-processtable-perl libwrap0-dev mc -network-manager-openvpn nfs-common ntfs-3g pciutils diff --git a/config/desktop/bookworm/environments/budgie/config_base/packages b/config/desktop/bookworm/environments/budgie/config_base/packages index 876a4a36dfa5..e3c1bb7fbc98 100644 --- a/config/desktop/bookworm/environments/budgie/config_base/packages +++ b/config/desktop/bookworm/environments/budgie/config_base/packages @@ -88,7 +88,6 @@ libnotify-bin libplank1 libplank-common libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxapp1 libxcursor1 @@ -101,9 +100,6 @@ nemo-data nemo-fileroller nemo-font-manager nemo-gtkhash -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/bookworm/environments/cinnamon/config_base/packages b/config/desktop/bookworm/environments/cinnamon/config_base/packages index a1c3808dc5cb..70db79a9410f 100644 --- a/config/desktop/bookworm/environments/cinnamon/config_base/packages +++ b/config/desktop/bookworm/environments/cinnamon/config_base/packages @@ -76,10 +76,6 @@ nemo-data nemo-fileroller nemo-font-manager nemo-gtkhash -network-manager-gnome -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/bookworm/environments/gnome/config_base/packages b/config/desktop/bookworm/environments/gnome/config_base/packages index 5c0e9a521abf..de572a432954 100644 --- a/config/desktop/bookworm/environments/gnome/config_base/packages +++ b/config/desktop/bookworm/environments/gnome/config_base/packages @@ -30,8 +30,6 @@ libpulsedsp gdm3 lm-sensors nautilus -network-manager-gnome -network-manager-openvpn-gnome pavucontrol #printer-driver-all profile-sync-daemon diff --git a/config/desktop/bookworm/environments/i3-wm/config_base/packages b/config/desktop/bookworm/environments/i3-wm/config_base/packages index 509f35afd4b3..4e03d0c3325a 100644 --- a/config/desktop/bookworm/environments/i3-wm/config_base/packages +++ b/config/desktop/bookworm/environments/i3-wm/config_base/packages @@ -77,7 +77,6 @@ libgsettings-qt1 libjson-xs-perl libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcb-cursor0 libxcursor1 @@ -87,8 +86,6 @@ lightdm-gtk-greeter-settings lightdm-settings lxappearance mousetweaks -network-manager-openvpn-gnome -network-manager-vpnc nitrogen numix-gtk-theme openprinting-ppds diff --git a/config/desktop/bookworm/environments/kde-plasma/config_base/packages b/config/desktop/bookworm/environments/kde-plasma/config_base/packages index 55a122cf2fc1..c4566645015d 100644 --- a/config/desktop/bookworm/environments/kde-plasma/config_base/packages +++ b/config/desktop/bookworm/environments/kde-plasma/config_base/packages @@ -61,16 +61,12 @@ libgsettings-qt1 libgtk2.0-bin libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcursor1 sddm mesa-utils mousepad mousetweaks -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/bookworm/environments/mate/config_base/packages b/config/desktop/bookworm/environments/mate/config_base/packages index 91aeafc79d9e..d3386a36ce72 100644 --- a/config/desktop/bookworm/environments/mate/config_base/packages +++ b/config/desktop/bookworm/environments/mate/config_base/packages @@ -76,7 +76,6 @@ mate-window-applets-common mate-window-buttons-applet mate-window-menu-applet mate-window-title-applet -network-manager-gnome numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/bookworm/environments/xfce/config_base/packages b/config/desktop/bookworm/environments/xfce/config_base/packages index 07bf2783ca63..9bebc223e2eb 100644 --- a/config/desktop/bookworm/environments/xfce/config_base/packages +++ b/config/desktop/bookworm/environments/xfce/config_base/packages @@ -52,7 +52,6 @@ libgtk2.0-bin libnotify-bin libpam-gnome-keyring libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcursor1 lightdm @@ -61,10 +60,6 @@ lxtask mesa-utils mousepad mousetweaks -network-manager-gnome -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/bookworm/environments/xmonad/config_base/packages b/config/desktop/bookworm/environments/xmonad/config_base/packages index 392efdbf9302..376976ac6603 100644 --- a/config/desktop/bookworm/environments/xmonad/config_base/packages +++ b/config/desktop/bookworm/environments/xmonad/config_base/packages @@ -64,7 +64,6 @@ libgnome-bluetooth13 libgsettings-qt1 libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxapp1 libxcursor1 @@ -73,8 +72,6 @@ lightdm-gtk-greeter lightdm-gtk-greeter-settings lightdm-settings mousetweaks -network-manager-openvpn-gnome -network-manager-vpnc nitrogen numix-gtk-theme openprinting-ppds diff --git a/config/desktop/common/environments/budgie/config_base/packages b/config/desktop/common/environments/budgie/config_base/packages index 269d710701e4..32f17a63b376 100644 --- a/config/desktop/common/environments/budgie/config_base/packages +++ b/config/desktop/common/environments/budgie/config_base/packages @@ -109,7 +109,6 @@ libnotify-bin libplank1 libplank-common libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcursor1 gdm3 @@ -121,10 +120,6 @@ nemo-data nemo-fileroller nemo-font-manager nemo-gtkhash -network-manager-config-connectivity-ubuntu -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-blue-gtk-theme numix-gtk-theme numix-icon-theme diff --git a/config/desktop/common/environments/cinnamon/config_base/packages b/config/desktop/common/environments/cinnamon/config_base/packages index 83554a85e46a..2cf2f5d27d44 100644 --- a/config/desktop/common/environments/cinnamon/config_base/packages +++ b/config/desktop/common/environments/cinnamon/config_base/packages @@ -80,10 +80,6 @@ nemo-data nemo-fileroller nemo-font-manager nemo-gtkhash -network-manager-gnome -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/common/environments/deepin/config_base/packages b/config/desktop/common/environments/deepin/config_base/packages index c15de62a937f..4d1831920daf 100644 --- a/config/desktop/common/environments/deepin/config_base/packages +++ b/config/desktop/common/environments/deepin/config_base/packages @@ -119,7 +119,6 @@ libgsettings-qt1 libgtk2.0-bin libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcursor1 lightdm @@ -128,10 +127,6 @@ lxtask mesa-utils mousepad mousetweaks -network-manager-config-connectivity-ubuntu -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-blue-gtk-theme numix-gtk-theme numix-icon-theme diff --git a/config/desktop/common/environments/enlightenment/config_base/packages b/config/desktop/common/environments/enlightenment/config_base/packages index c6d0262c947c..5382bc9c4bed 100644 --- a/config/desktop/common/environments/enlightenment/config_base/packages +++ b/config/desktop/common/environments/enlightenment/config_base/packages @@ -85,7 +85,6 @@ libnotify-bin libplank1 libplank-common libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcursor1 lightdm @@ -93,10 +92,6 @@ lxtask mesa-utils mousepad mousetweaks -network-manager-config-connectivity-ubuntu -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-blue-gtk-theme numix-gtk-theme numix-icon-theme diff --git a/config/desktop/common/environments/gnome/config_base/packages b/config/desktop/common/environments/gnome/config_base/packages index e652b9c1bb71..610eb96475f0 100644 --- a/config/desktop/common/environments/gnome/config_base/packages +++ b/config/desktop/common/environments/gnome/config_base/packages @@ -30,8 +30,6 @@ libnotify-bin gdm3 lm-sensors nautilus -network-manager-gnome -network-manager-openvpn-gnome pavucontrol printer-driver-all profile-sync-daemon diff --git a/config/desktop/common/environments/i3-wm/config_base/packages b/config/desktop/common/environments/i3-wm/config_base/packages index fc5cd6a82eb8..307f0b7709cf 100644 --- a/config/desktop/common/environments/i3-wm/config_base/packages +++ b/config/desktop/common/environments/i3-wm/config_base/packages @@ -81,7 +81,6 @@ libgsettings-qt1 libjson-xs-perl libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcb-cursor0 libxcursor1 @@ -91,8 +90,6 @@ lightdm-gtk-greeter-settings lightdm-settings lxappearance mousetweaks -network-manager-openvpn-gnome -network-manager-vpnc nitrogen numix-gtk-theme openprinting-ppds diff --git a/config/desktop/common/environments/kde-plasma/config_base/packages b/config/desktop/common/environments/kde-plasma/config_base/packages index 5cd0675e7215..7c53dbecbc9d 100644 --- a/config/desktop/common/environments/kde-plasma/config_base/packages +++ b/config/desktop/common/environments/kde-plasma/config_base/packages @@ -81,17 +81,12 @@ libgsettings-qt1 libgtk2.0-bin libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcursor1 sddm mesa-utils mousepad mousetweaks -network-manager-config-connectivity-ubuntu -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/common/environments/mate/config_base/packages b/config/desktop/common/environments/mate/config_base/packages index 912e44c9693f..305d0ab3b491 100644 --- a/config/desktop/common/environments/mate/config_base/packages +++ b/config/desktop/common/environments/mate/config_base/packages @@ -81,7 +81,6 @@ libgsettings-qt1 libgtk2.0-bin libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcursor1 lightdm @@ -149,10 +148,6 @@ mate-window-title-applet mesa-utils mousepad mousetweaks -network-manager-config-connectivity-ubuntu -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/common/environments/xfce/config_base/packages b/config/desktop/common/environments/xfce/config_base/packages index 7e7a28d043a3..c200b3366ab4 100644 --- a/config/desktop/common/environments/xfce/config_base/packages +++ b/config/desktop/common/environments/xfce/config_base/packages @@ -52,7 +52,6 @@ libgtk2.0-bin libnotify-bin libpam-gnome-keyring libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcursor1 lightdm @@ -61,10 +60,6 @@ lxtask mesa-utils mousepad mousetweaks -network-manager-gnome -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/common/environments/xmonad/config_base/packages b/config/desktop/common/environments/xmonad/config_base/packages index 907011196fb6..ebd6450214a7 100644 --- a/config/desktop/common/environments/xmonad/config_base/packages +++ b/config/desktop/common/environments/xmonad/config_base/packages @@ -73,7 +73,6 @@ libgnome-bluetooth13 libgsettings-qt1 libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libwmf0.2-7-gtk libxcursor1 lightdm @@ -81,8 +80,6 @@ lightdm-gtk-greeter lightdm-gtk-greeter-settings lightdm-settings mousetweaks -network-manager-openvpn-gnome -network-manager-vpnc nitrogen numix-gtk-theme openprinting-ppds diff --git a/config/desktop/jammy/environments/budgie/config_base/packages b/config/desktop/jammy/environments/budgie/config_base/packages index ef9b418210d2..6d5cb39b72f1 100644 --- a/config/desktop/jammy/environments/budgie/config_base/packages +++ b/config/desktop/jammy/environments/budgie/config_base/packages @@ -108,7 +108,6 @@ libnotify-bin libplank1 libplank-common libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libu2f-udev libwmf0.2-7-gtk libxapp1 @@ -122,10 +121,6 @@ nemo-data nemo-fileroller nemo-font-manager nemo-gtkhash -network-manager-config-connectivity-ubuntu -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/jammy/environments/cinnamon/config_base/packages b/config/desktop/jammy/environments/cinnamon/config_base/packages index 83554a85e46a..2cf2f5d27d44 100644 --- a/config/desktop/jammy/environments/cinnamon/config_base/packages +++ b/config/desktop/jammy/environments/cinnamon/config_base/packages @@ -80,10 +80,6 @@ nemo-data nemo-fileroller nemo-font-manager nemo-gtkhash -network-manager-gnome -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/jammy/environments/gnome/config_base/packages b/config/desktop/jammy/environments/gnome/config_base/packages index eeb86298396d..b72243e2b5af 100644 --- a/config/desktop/jammy/environments/gnome/config_base/packages +++ b/config/desktop/jammy/environments/gnome/config_base/packages @@ -34,8 +34,6 @@ libpulsedsp gdm3 lm-sensors nautilus -network-manager-gnome -network-manager-openvpn-gnome pavucontrol printer-driver-all profile-sync-daemon diff --git a/config/desktop/jammy/environments/i3-wm/config_base/packages b/config/desktop/jammy/environments/i3-wm/config_base/packages index d29d625d8039..efa6c8907b08 100644 --- a/config/desktop/jammy/environments/i3-wm/config_base/packages +++ b/config/desktop/jammy/environments/i3-wm/config_base/packages @@ -79,7 +79,6 @@ libgsettings-qt1 libjson-xs-perl libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libu2f-udev libwmf0.2-7-gtk libxcb-cursor0 @@ -90,8 +89,6 @@ lightdm-gtk-greeter-settings lightdm-settings lxappearance mousetweaks -network-manager-openvpn-gnome -network-manager-vpnc nitrogen numix-gtk-theme openprinting-ppds diff --git a/config/desktop/jammy/environments/kde-plasma/config_base/packages b/config/desktop/jammy/environments/kde-plasma/config_base/packages index 3068b9c28363..3761ed403f90 100644 --- a/config/desktop/jammy/environments/kde-plasma/config_base/packages +++ b/config/desktop/jammy/environments/kde-plasma/config_base/packages @@ -80,7 +80,6 @@ libgsettings-qt1 libgtk2.0-bin libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libu2f-udev libwmf0.2-7-gtk libxcursor1 @@ -88,10 +87,6 @@ sddm mesa-utils mousepad mousetweaks -network-manager-config-connectivity-ubuntu -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/jammy/environments/mate/config_base/packages b/config/desktop/jammy/environments/mate/config_base/packages index ff7d930ad1ec..625518426a9b 100644 --- a/config/desktop/jammy/environments/mate/config_base/packages +++ b/config/desktop/jammy/environments/mate/config_base/packages @@ -74,7 +74,6 @@ mate-window-applets-common mate-window-buttons-applet mate-window-menu-applet mate-window-title-applet -network-manager-gnome numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/jammy/environments/xfce/config_base/packages b/config/desktop/jammy/environments/xfce/config_base/packages index f2e30904531d..b519476703a9 100644 --- a/config/desktop/jammy/environments/xfce/config_base/packages +++ b/config/desktop/jammy/environments/xfce/config_base/packages @@ -53,7 +53,6 @@ libgtk2.0-bin libnotify-bin libpam-gnome-keyring libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libu2f-udev libwmf0.2-7-gtk libxcursor1 @@ -63,10 +62,6 @@ lxtask mesa-utils mousepad mousetweaks -network-manager-gnome -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/desktop/jammy/environments/xmonad/config_base/packages b/config/desktop/jammy/environments/xmonad/config_base/packages index ef2855f2650c..f9a03ad7b724 100644 --- a/config/desktop/jammy/environments/xmonad/config_base/packages +++ b/config/desktop/jammy/environments/xmonad/config_base/packages @@ -74,7 +74,6 @@ libgnome-bluetooth13 libgsettings-qt1 libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libu2f-udev libwmf0.2-7-gtk libxapp1 @@ -84,8 +83,6 @@ lightdm-gtk-greeter lightdm-gtk-greeter-settings lightdm-settings mousetweaks -network-manager-openvpn-gnome -network-manager-vpnc nitrogen numix-gtk-theme openprinting-ppds diff --git a/config/desktop/noble/environments/i3-wm/config_base/packages b/config/desktop/noble/environments/i3-wm/config_base/packages index 9d2567f5ce05..012e3a7e667f 100644 --- a/config/desktop/noble/environments/i3-wm/config_base/packages +++ b/config/desktop/noble/environments/i3-wm/config_base/packages @@ -50,7 +50,6 @@ gnome-system-monitor gromit gstreamer1.0-packagekit gstreamer1.0-plugins-base-apps -gstreamer1.0-pulseaudio gvfs-backends hplip i3 @@ -75,7 +74,6 @@ libgsettings-qt1 libjson-xs-perl libnotify-bin libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libu2f-udev libwmf0.2-7-gtk libxcb-cursor0 @@ -86,8 +84,6 @@ lightdm-gtk-greeter-settings lightdm-settings lxappearance mousetweaks -network-manager-openvpn-gnome -network-manager-vpnc nitrogen numix-gtk-theme openprinting-ppds @@ -104,7 +100,6 @@ policykit-1-gnome policykit-desktop-privileges printer-driver-all profile-sync-daemon -pulseaudio-module-bluetooth redshift rofi samba diff --git a/config/desktop/noble/environments/xfce/config_base/packages b/config/desktop/noble/environments/xfce/config_base/packages index 440deb65d046..4cc45ea1e125 100644 --- a/config/desktop/noble/environments/xfce/config_base/packages +++ b/config/desktop/noble/environments/xfce/config_base/packages @@ -52,7 +52,6 @@ libgtk2.0-bin libnotify-bin libpam-gnome-keyring libproxy1-plugin-gsettings -libproxy1-plugin-networkmanager libu2f-udev libwmf0.2-7-gtk libxcursor1 @@ -62,10 +61,6 @@ lxtask mesa-utils mousepad mousetweaks -network-manager-gnome -network-manager-openvpn -network-manager-ssh -network-manager-vpnc numix-gtk-theme numix-icon-theme numix-icon-theme-circle diff --git a/config/kernel/linux-rockchip-rk3588-6.10.config b/config/kernel/linux-rockchip-rk3588-6.10.config index 89f6423ad1f8..cc5fe736b6b1 100644 --- a/config/kernel/linux-rockchip-rk3588-6.10.config +++ b/config/kernel/linux-rockchip-rk3588-6.10.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm64 6.10.0-rc3 Kernel Configuration +# Linux/arm64 6.10.0-rc4 Kernel Configuration # CONFIG_CC_VERSION_TEXT="aarch64-linux-gnu-gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0" CONFIG_CC_IS_GCC=y @@ -4337,9 +4337,7 @@ CONFIG_SERIAL_JSM=m CONFIG_SERIAL_SIFIVE=m CONFIG_SERIAL_SCCNXP=y CONFIG_SERIAL_SCCNXP_CONSOLE=y -CONFIG_SERIAL_SC16IS7XX_CORE=m -CONFIG_SERIAL_SC16IS7XX_I2C=m -CONFIG_SERIAL_SC16IS7XX_SPI=m +# CONFIG_SERIAL_SC16IS7XX is not set CONFIG_SERIAL_ALTERA_JTAGUART=m CONFIG_SERIAL_ALTERA_UART=m CONFIG_SERIAL_ALTERA_UART_MAXPORTS=4 @@ -8417,6 +8415,7 @@ CONFIG_DVB_BUDGET_PATCH=m CONFIG_DVB_SP8870=m # CONFIG_VIDEO_MAX96712 is not set CONFIG_VIDEO_ROCKCHIP_VDEC=m +CONFIG_VIDEO_ROCKCHIP_VDEC2=m # # StarFive media platform drivers diff --git a/config/sources/families/imx8m.conf b/config/sources/families/imx8m.conf index c5a98987d957..4b2a9fd78329 100644 --- a/config/sources/families/imx8m.conf +++ b/config/sources/families/imx8m.conf @@ -30,8 +30,7 @@ case $BOARD in esac # bootloader releated -pre_config_uboot_target() -{ +pre_config_uboot_target() { # get the firmware rm -rf ${IMX_FIRMWARE}* wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/${IMX_FIRMWARE}.bin -O ${IMX_FIRMWARE}.bin @@ -46,8 +45,7 @@ pre_config_uboot_target() export ATF_LOAD_ADDR=${ATF_ADDR} } -write_uboot_platform() -{ +write_uboot_platform() { echo ${OFFSET} dd if=$1/flash.bin of=$2 bs=1K seek=${OFFSET} status=noxfer conv=fsync > /dev/null 2>&1 } diff --git a/config/sources/families/include/imx8_common.inc b/config/sources/families/include/imx8_common.inc index d17d25f0fa6c..697c5a63beb2 100644 --- a/config/sources/families/include/imx8_common.inc +++ b/config/sources/families/include/imx8_common.inc @@ -25,13 +25,13 @@ case $BOARD in LINUXCONFIG='linux-tqma-'$BRANCH # one config for "tq arm modules" case $BRANCH in - current) # active lts mainline kernel + current) # active lts mainline kernel KERNEL_MAJOR_MINOR="6.6" KERNELBRANCH='branch:linux-6.6.y' KERNELPATCHDIR="archive/imx8m-6.6" ;; - edge|default) # use for tests with recent mainline kernels + edge | default) # use for tests with recent mainline kernels ;; esac diff --git a/config/sources/families/include/meson_common.inc b/config/sources/families/include/meson_common.inc index c08a27f45741..77e0ad5bee64 100644 --- a/config/sources/families/include/meson_common.inc +++ b/config/sources/families/include/meson_common.inc @@ -42,9 +42,9 @@ esac case $BRANCH in - legacy) - declare -g KERNEL_MAJOR_MINOR="6.1" - ;; + legacy) + declare -g KERNEL_MAJOR_MINOR="6.1" + ;; current) declare -g KERNEL_MAJOR_MINOR="6.6" diff --git a/config/sources/families/include/rockchip64_common.inc b/config/sources/families/include/rockchip64_common.inc index cb06959501a9..d2442b9be5e0 100644 --- a/config/sources/families/include/rockchip64_common.inc +++ b/config/sources/families/include/rockchip64_common.inc @@ -174,6 +174,10 @@ prepare_boot_configuration() { ;; esac + if [[ ! -z $BL32_BLOB ]]; then + UBOOT_TARGET_MAP="BL32=$RKBIN_DIR/$BL32_BLOB ${UBOOT_TARGET_MAP}" + fi + if [[ $BOOT_SUPPORT_SPI == yes ]]; then if [[ "${BOOT_SPI_RKSPI_LOADER:-"no"}" != "yes" ]]; then diff --git a/config/sources/families/jethub.conf b/config/sources/families/jethub.conf index f2e225261d43..617928938bd3 100644 --- a/config/sources/families/jethub.conf +++ b/config/sources/families/jethub.conf @@ -35,11 +35,10 @@ elif [[ "$BOARD" == "jethubj200" ]]; then BOOTPATCHDIR="v2024.01" fi - ######## # @TODO: Put this in the board configs of the respective boards ######## -if [[ "$BOARD" == "jethubj80" ]] || [[ "$BOARD" == "jethubj100" ]] ; then +if [[ "$BOARD" == "jethubj80" ]] || [[ "$BOARD" == "jethubj100" ]]; then function family_tweaks__blacklistrtw88() { if [[ "$BOARD" == jethubj80 ]] || [[ "$BOARD" == jethubj100 ]]; then mkdir -p "${destination}"/etc/modprobe.d @@ -49,19 +48,16 @@ if [[ "$BOARD" == "jethubj80" ]] || [[ "$BOARD" == "jethubj100" ]] ; then } fi - # JetHub builds userspace tooling with c++ (gpp) toolchain in buildjethomecmds() below. # The C++ compiler is no longer included by default in the Armbian build system. # Enable the extension that brings includes it. It could've been an inline extension (eg: the function right here), # but having a core extension allows it to be pre-included in the Dockerfile generation and thus in the Docker images. enable_extension "c-plus-plus-compiler" - function fetch_sources_tools__jethub_amlogic_fip() { - fetch_from_repo "https://github.com/adeepn/amlogic-boot-fip" "amlogic-boot-fip-jethub" "branch:add_jethub_j200" + fetch_from_repo "https://github.com/adeepn/amlogic-boot-fip" "amlogic-boot-fip-jethub" "branch:add_jethub_j200" } - uboot_custom_postprocess() { if [[ "$BOARD" == "jethubj80" ]]; then uboot_gxl_postprocess_ng "$SRC/cache/sources/amlogic-boot-fip/jethub-j80" diff --git a/config/sources/families/meson-s4t7.conf b/config/sources/families/meson-s4t7.conf index 12bda00f4d01..0a5967b29a3b 100644 --- a/config/sources/families/meson-s4t7.conf +++ b/config/sources/families/meson-s4t7.conf @@ -15,9 +15,9 @@ enable_extension "bluetooth-hciattach" # E case $BRANCH in legacy) - declare -g KERNEL_MAJOR_MINOR="5.15" # Major and minor versions of this kernel. For mainline caching. + declare -g KERNEL_MAJOR_MINOR="5.15" # Major and minor versions of this kernel. For mainline caching. declare -g KERNELSOURCE="${GITHUB_SOURCE}/khadas/linux.git" # Khadas kernel - declare -g KERNELBRANCH="branch:khadas-vims-5.15.y" # Branch or tag to build from. It should match MAJOR_MINOR + declare -g KERNELBRANCH="branch:khadas-vims-5.15.y" # Branch or tag to build from. It should match MAJOR_MINOR declare -g KERNELPATCHDIR="archive/meson-s4t7-5.15" declare -g COMMON_DRIVERS_SOURCE="${GITHUB_SOURCE}/khadas/common_drivers" declare -g EXTRAWIFI=no @@ -128,7 +128,7 @@ function custom_kernel_config__add_khadas_common_drivers() { memoize_cache_ttl=$common_drivers_cache_ttl_seconds run_memoized GIT_INFO_COMMON_DRIVERS "git2info" memoized_git_ref_to_info # Hack to ensure that we will recreate kernel if common_drivers source changes - kernel_config_modifying_hashes+=( "khadas_common_drivers=${GIT_INFO_COMMON_DRIVERS[SHA1]}" ) + kernel_config_modifying_hashes+=("khadas_common_drivers=${GIT_INFO_COMMON_DRIVERS[SHA1]}") # viraniac: kernel_config_modifying_hashes is only needed during first call of this function to calculate kernel artifact version string. It serves no purpose whatsoever during second call. kernel_config_modifying_hashes+=("CONFIG_DEBUG_KERNEL=y" "CONFIG_EXPERT=y" "CONFIG_EMBEDDED=y") @@ -152,7 +152,7 @@ function kernel_copy_extra_sources__khadas_common_drivers() { rm -rf "${common_drivers_git_bare_tree}" fi - run_host_command_logged git clone --tags --no-checkout \ + run_host_command_logged git clone --tags --no-checkout \ "${COMMON_DRIVERS_SOURCE}" "${common_drivers_git_bare_tree}" touch "${common_drivers_git_bare_tree_done_marker}" @@ -196,8 +196,8 @@ function post_family_tweaks_bsp__disable_uinitrd_generation() { } function image_specific_armbian_env_ready__enable_earlycon() { - display_alert "Enabling earlycon" - run_host_command_logged echo "earlycon=on" >>${SDCARD}/boot/armbianEnv.txt + display_alert "Enabling earlycon" + run_host_command_logged echo "earlycon=on" >> ${SDCARD}/boot/armbianEnv.txt } function post_family_tweaks_bsp__add_fan_service() { diff --git a/config/sources/families/mt7623.conf b/config/sources/families/mt7623.conf index 42e25d39851c..81e81acec331 100644 --- a/config/sources/families/mt7623.conf +++ b/config/sources/families/mt7623.conf @@ -30,7 +30,15 @@ CPUMIN=98000 CPUMAX=1300000 GOVERNOR="ondemand" -NM_IGNORE_DEVICES="interface-name:eth*,interface-name:wan*,interface-name:lan*,interface-name:br*" +function pre_install_kernel_debs__network_manager_ignore_devices() { + display_alert "Board: ${BOARD}: Disabling Network-Manager for all devices" "interface-name:eth*,interface-name:wan*,interface-name:lan*,interface-name:br*" "info" + + mkdir -p "${SDCARD}"/etc/NetworkManager/conf.d/ + cat <<- EOF > "${SDCARD}"/etc/NetworkManager/conf.d/99-ignore-interfaces.conf + [keyfile] + unmanaged-devices="interface-name:eth*,interface-name:wan*,interface-name:lan*,interface-name:br*" + EOF +} write_uboot_platform() { if [[ $2 == /dev/mmcblk* && -b ${2}boot0 ]]; then diff --git a/config/sources/families/mvebu64.conf b/config/sources/families/mvebu64.conf index d7085eee674c..637629098ab8 100644 --- a/config/sources/families/mvebu64.conf +++ b/config/sources/families/mvebu64.conf @@ -72,7 +72,15 @@ CPUMIN=200000 CPUMAX=1300000 GOVERNOR=ondemand -NM_IGNORE_DEVICES="interface-name:eth*,interface-name:wan*,interface-name:lan*,interface-name:br*" +function pre_install_kernel_debs__network_manager_ignore_devices() { + display_alert "Board: ${BOARD}: Disabling Network-Manager for all devices" "interface-name:eth*,interface-name:wan*,interface-name:lan*,interface-name:br*" "info" + + mkdir -p "${SDCARD}"/etc/NetworkManager/conf.d/ + cat <<- EOF > "${SDCARD}"/etc/NetworkManager/conf.d/99-ignore-interfaces.conf + [keyfile] + unmanaged-devices="interface-name:eth*,interface-name:wan*,interface-name:lan*,interface-name:br*" + EOF +} write_uboot_platform() { if [[ $BOARD = macchiatobin-doubleshot ]]; then diff --git a/config/sources/families/phytium-embedded.conf b/config/sources/families/phytium-embedded.conf index e337e44b0749..c38ba4018910 100644 --- a/config/sources/families/phytium-embedded.conf +++ b/config/sources/families/phytium-embedded.conf @@ -22,7 +22,7 @@ case "${BRANCH}" in EXTRAWIFI="no" ;; - + current) KERNELSOURCE='https://github.com/chainsx/phytium-linux-kernel' KERNELBRANCH="branch:linux-6.6" @@ -38,11 +38,11 @@ esac write_uboot_platform() { declare ptuboot_cache_dir="${SRC}/cache/phytiumpi-uboot" mkdir -p "${ptuboot_cache_dir}" - - sfdisk --dump "$2" > "${ptuboot_cache_dir}/part.txt" # Backup partition table, command sfdisk is belong to util-linux - dd if="${SRC}/packages/blobs/phytiumpi/fip-all-sd-boot.bin" of="$2" conv=notrunc # Write non-free u-boot file - sfdisk --no-reread "$2" < "${ptuboot_cache_dir}/part.txt" # Recover partition table - + + sfdisk --dump "$2" > "${ptuboot_cache_dir}/part.txt" # Backup partition table, command sfdisk is belong to util-linux + dd if="${SRC}/packages/blobs/phytiumpi/fip-all-sd-boot.bin" of="$2" conv=notrunc # Write non-free u-boot file + sfdisk --no-reread "$2" < "${ptuboot_cache_dir}/part.txt" # Recover partition table + # Update u-boot env mkenvimage -s 0x1000 -o "${ptuboot_cache_dir}/env.bin" "${SRC}/packages/blobs/phytiumpi/env.txt" dd if="${ptuboot_cache_dir}/env.bin" of="$2" bs=1k seek=1472 conv=notrunc diff --git a/config/sources/families/rock-s0.conf b/config/sources/families/rock-s0.conf index e5ef3ed8acad..dca45de39d3f 100644 --- a/config/sources/families/rock-s0.conf +++ b/config/sources/families/rock-s0.conf @@ -32,8 +32,8 @@ IDBLOADER_BLOB=$SRC/packages/blobs/rockchip/rk3308_idbloader_ddr589MHz_uart0_m0_ case $BRANCH in legacy) - echo "Legacy not supported for rock-s0 board" - exit 99 + echo "Legacy not supported for rock-s0 board" + exit 99 ;; esac diff --git a/config/sources/families/rockchip-rk3588.conf b/config/sources/families/rockchip-rk3588.conf index 25dbcf85e1bb..f0158e088f58 100644 --- a/config/sources/families/rockchip-rk3588.conf +++ b/config/sources/families/rockchip-rk3588.conf @@ -42,16 +42,16 @@ case $BRANCH in current) # Branch based on a stable kernel release (will stay on the next LTS kernel release once released, 6.12? LTS) LINUXFAMILY=rockchip-rk3588 - KERNEL_MAJOR_MINOR="6.8" # Major and minor versions of this kernel. - LINUXCONFIG="linux-rockchip-rk3588-${KERNEL_MAJOR_MINOR}" # Attention: not -${BRANCH} (edge/current/legacy), but -${KERNEL_MAJOR_MINOR} thus 6.6 / 6.12 etc + KERNEL_MAJOR_MINOR="6.8" # Major and minor versions of this kernel. + LINUXCONFIG="linux-rockchip-rk3588-${KERNEL_MAJOR_MINOR}" # Attention: not -${BRANCH} (edge/current/legacy), but -${KERNEL_MAJOR_MINOR} thus 6.6 / 6.12 etc # No need to set KERNELPATCHDIR, since default is: KERNELPATCHDIR='archive/rockchip-rk3588-${KERNEL_MAJOR_MINOR}' ;; edge) # Branch based on the latest kernel release including RC releases, to benefit from the latest RK3588 mainline advancements. Might be unstable! LINUXFAMILY=rockchip-rk3588 - KERNEL_MAJOR_MINOR="6.10" # Major and minor versions of this kernel. - LINUXCONFIG="linux-rockchip-rk3588-${KERNEL_MAJOR_MINOR}" # Attention: not -${BRANCH} (edge/current/legacy), but -${KERNEL_MAJOR_MINOR} thus 6.8 / 6.10 etc + KERNEL_MAJOR_MINOR="6.10" # Major and minor versions of this kernel. + LINUXCONFIG="linux-rockchip-rk3588-${KERNEL_MAJOR_MINOR}" # Attention: not -${BRANCH} (edge/current/legacy), but -${KERNEL_MAJOR_MINOR} thus 6.8 / 6.10 etc # No need to set KERNELPATCHDIR, since default is: KERNELPATCHDIR='archive/rockchip-rk3588-${KERNEL_MAJOR_MINOR}' ;; @@ -59,7 +59,7 @@ case $BRANCH in # Collabora's rk3588, where the action is these days LINUXFAMILY=rockchip-rk3588 LINUXCONFIG='linux-rockchip-rk3588-'$BRANCH - KERNEL_MAJOR_MINOR="6.9" # Major and minor versions of this kernel. + KERNEL_MAJOR_MINOR="6.9" # Major and minor versions of this kernel. KERNELPATCHDIR='rockchip-rk3588-collabora' # Try to keep this as empty as possible. We won't work on top of Collabora's branch, they rebase all the time. New DTs are ok. KERNELSOURCE='https://gitlab.collabora.com/hardware-enablement/rockchip-3588/linux.git' # Directly from Collabora... KERNELBRANCH='branch:rk3588-v6.9' # Rolling kernel branch, will be rebased diff --git a/config/sources/families/sm8250.conf b/config/sources/families/sm8250.conf index e019797523cb..e02bb87177c8 100644 --- a/config/sources/families/sm8250.conf +++ b/config/sources/families/sm8250.conf @@ -15,16 +15,13 @@ enable_extension "image-output-abl" case $BRANCH in current) - declare -g KERNEL_MAJOR_MINOR="6.7" # Major and minor versions of this kernel. - declare -g KERNELBRANCH='tag:v6.7.5' - declare -g KERNELPATCHDIR='archive/sm8250-6.7' + declare -g KERNEL_MAJOR_MINOR="6.9" # Major and minor versions of this kernel. + declare -g KERNELBRANCH='branch:linux-6.9.y' declare -g -i KERNEL_GIT_CACHE_TTL=120 # 2 minutes; this is a high-traffic repo ;; edge) - declare -g KERNEL_MAJOR_MINOR="6.8" # Major and minor versions of this kernel. - declare -g KERNELBRANCH='tag:v6.8.6' - declare -g KERNELPATCHDIR='archive/sm8250-6.8' + declare -g KERNEL_MAJOR_MINOR="6.10" # Major and minor versions of this kernel. ;; esac diff --git a/config/sources/families/sun50iw6.conf b/config/sources/families/sun50iw6.conf index 707b690aa4ca..57d8cb9bc610 100644 --- a/config/sources/families/sun50iw6.conf +++ b/config/sources/families/sun50iw6.conf @@ -15,13 +15,13 @@ OVERLAY_PREFIX='sun50i-h6' GOVERNOR=ondemand ASOUND_STATE='asound.state.sun50iw2-dev' -function post_family_config__install_lightdm_gtk_greeter(){ +function post_family_config__install_lightdm_gtk_greeter() { if [[ ${BUILD_DESKTOP} == "yes" ]] && [[ ! ${DESKTOP_ENVIRONMENT} =~ ^(kde|gnome)$ ]]; then add_packages_to_image lightdm-gtk-greeter fi } -function post_family_tweaks__switch_to_lightdm_gtk_greeter(){ +function post_family_tweaks__switch_to_lightdm_gtk_greeter() { # Mali T720 seems to have some issues with slick-greeter. # Use gtk greeter instead if [[ ${BUILD_DESKTOP} == "yes" ]] && [[ ! ${DESKTOP_ENVIRONMENT} =~ ^(kde|gnome)$ ]]; then diff --git a/config/sources/families/sun8i.conf b/config/sources/families/sun8i.conf index 1df77a68983c..da933f315db1 100644 --- a/config/sources/families/sun8i.conf +++ b/config/sources/families/sun8i.conf @@ -15,4 +15,3 @@ fi [[ -z $CPUMIN ]] && CPUMIN=480000 [[ -z $CPUMAX ]] && CPUMAX=1400000 - diff --git a/config/sources/mainline-kernel.conf.sh b/config/sources/mainline-kernel.conf.sh index 0bc3ab768739..8fecdbedcdb5 100644 --- a/config/sources/mainline-kernel.conf.sh +++ b/config/sources/mainline-kernel.conf.sh @@ -8,7 +8,7 @@ function mainline_kernel_decide_version__upstream_release_candidate_number() { [[ -n "${KERNELBRANCH}" ]] && return 0 # if already set, don't touch it; that way other hooks can run in any order if [[ "${KERNEL_MAJOR_MINOR}" == "6.10" ]]; then # @TODO: roll over to next MAJOR.MINOR and MAJOR.MINOR-rc1 when it is released - declare -g KERNELBRANCH="tag:v6.10-rc3" + declare -g KERNELBRANCH="tag:v6.10-rc4" display_alert "mainline-kernel: upstream release candidate" "Using KERNELBRANCH='${KERNELBRANCH}' for KERNEL_MAJOR_MINOR='${KERNEL_MAJOR_MINOR}'" "info" fi } diff --git a/dtb-fix/u-boot/a/arch/arm/dts/Makefile b/dtb-fix/u-boot/a/arch/arm/dts/Makefile index f2a7658092a9..a7e0d9f6c0e8 100644 --- a/dtb-fix/u-boot/a/arch/arm/dts/Makefile +++ b/dtb-fix/u-boot/a/arch/arm/dts/Makefile @@ -120,14 +120,11 @@ dtb-$(CONFIG_ROCKCHIP_RK3288) += \ dtb-$(CONFIG_ROCKCHIP_RK3308) += \ rk3308-evb.dtb \ - rk3308-roc-cc.dtb \ - rk3308-rock-pi-s.dtb + rk3308-roc-cc.dtb dtb-$(CONFIG_ROCKCHIP_RK3328) += \ rk3328-evb.dtb \ rk3328-nanopi-r2s.dtb \ - rk3328-orangepi-r1-plus.dtb \ - rk3328-orangepi-r1-plus-lts.dtb \ rk3328-roc-cc.dtb \ rk3328-rock64.dtb \ rk3328-rock-pi-e.dtb @@ -139,13 +136,11 @@ dtb-$(CONFIG_ROCKCHIP_RK3368) += \ rk3368-px5-evb.dtb \ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ - rk3399-clockworkpi-a06.dtb \ rk3399-evb.dtb \ rk3399-ficus.dtb \ rk3399-firefly.dtb \ rk3399-gru-bob.dtb \ rk3399-gru-kevin.dtb \ - rk3399-kobol-helios64.dtb \ rk3399-khadas-edge.dtb \ rk3399-khadas-edge-captain.dtb \ rk3399-khadas-edge-v.dtb \ @@ -154,11 +149,9 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ rk3399-nanopi-m4.dtb \ rk3399-nanopi-m4-2gb.dtb \ rk3399-nanopi-m4b.dtb \ - rk3399-nanopi-m4v2.dtb \ rk3399-nanopi-neo4.dtb \ rk3399-nanopi-r4s.dtb \ rk3399-orangepi.dtb \ - rk3399-orangepi-4.dtb \ rk3399-pinebook-pro.dtb \ rk3399-puma-haikou.dtb \ rk3399-roc-pc.dtb \ @@ -168,9 +161,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ rk3399-rock-pi-4c.dtb \ rk3399-rock960.dtb \ rk3399-rockpro64.dtb \ - rk3399pro-rock-pi-n10.dtb \ - rk3399pro-tinker_edge_r.dtb \ - rk3399-xiaobao-nas.dtb + rk3399pro-rock-pi-n10.dtb dtb-$(CONFIG_ROCKCHIP_RK3568) += \ rk3568-evb.dtb diff --git a/dtb-fix/u-boot/b/arch/arm/dts/Makefile b/dtb-fix/u-boot/b/arch/arm/dts/Makefile index 1a1226eb5da4..154406899c6b 100644 --- a/dtb-fix/u-boot/b/arch/arm/dts/Makefile +++ b/dtb-fix/u-boot/b/arch/arm/dts/Makefile @@ -120,19 +120,16 @@ dtb-$(CONFIG_ROCKCHIP_RK3288) += \ dtb-$(CONFIG_ROCKCHIP_RK3308) += \ rk3308-evb.dtb \ - rk3308-roc-cc.dtb \ - rk3308-rock-pi-s.dtb + rk3308-roc-cc.dtb dtb-$(CONFIG_ROCKCHIP_RK3328) += \ rk3328-artillery-x4.dtb \ rk3328-evb.dtb \ rk3328-nanopi-r2s.dtb \ - rk3328-orangepi-r1-plus.dtb \ - rk3328-orangepi-r1-plus-lts.dtb \ rk3328-roc-cc.dtb \ rk3328-rock64.dtb \ rk3328-rock-pi-e.dtb - + dtb-$(CONFIG_ROCKCHIP_RK3368) += \ rk3368-lion-haikou.dtb \ rk3368-sheep.dtb \ @@ -140,13 +137,11 @@ dtb-$(CONFIG_ROCKCHIP_RK3368) += \ rk3368-px5-evb.dtb \ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ - rk3399-clockworkpi-a06.dtb \ rk3399-evb.dtb \ rk3399-ficus.dtb \ rk3399-firefly.dtb \ rk3399-gru-bob.dtb \ rk3399-gru-kevin.dtb \ - rk3399-kobol-helios64.dtb \ rk3399-khadas-edge.dtb \ rk3399-khadas-edge-captain.dtb \ rk3399-khadas-edge-v.dtb \ @@ -155,11 +150,9 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ rk3399-nanopi-m4.dtb \ rk3399-nanopi-m4-2gb.dtb \ rk3399-nanopi-m4b.dtb \ - rk3399-nanopi-m4v2.dtb \ rk3399-nanopi-neo4.dtb \ rk3399-nanopi-r4s.dtb \ rk3399-orangepi.dtb \ - rk3399-orangepi-4.dtb \ rk3399-pinebook-pro.dtb \ rk3399-puma-haikou.dtb \ rk3399-roc-pc.dtb \ @@ -169,8 +162,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ rk3399-rock-pi-4c.dtb \ rk3399-rock960.dtb \ rk3399-rockpro64.dtb \ - rk3399pro-rock-pi-n10.dtb \ - rk3399pro-tinker_edge_r.dtb + rk3399pro-rock-pi-n10.dtb dtb-$(CONFIG_ROCKCHIP_RK3568) += \ rk3568-evb.dtb diff --git a/extensions/allwinner-kernel-bump.sh b/extensions/allwinner-kernel-bump.sh index 889906d11682..92c8d4afcf31 100644 --- a/extensions/allwinner-kernel-bump.sh +++ b/extensions/allwinner-kernel-bump.sh @@ -37,7 +37,7 @@ function extension_finish_config__prepare_megous_patches() { if [[ -d ${patch_dir_base} ]]; then display_alert "allwinner-kernel-bump" "Found existing kernel patch directory" "info" - if [[ "${OVERWRITE_PATCHDIR:-no}" == "yes" ]]; then + if [[ "${OVERWRITE_PATCHDIR:-no}" == "yes" ]]; then display_alert "allwinner-kernel-bump" "Removing as requested. Any manual changes will get overwritten" "info" rm -rf ${patch_dir_base} else @@ -69,9 +69,9 @@ function extension_finish_config__prepare_megous_patches() { run_host_command_logged rm -f ${patch_dir_base}/series.{conf,megous} display_alert "allwinner-kernel-bump" "Extracting latest Megous patches" "info" - megous_trees=( "a83t-suspend" "af8133j" "anx" "audio" "axp" "cam" "drm" + megous_trees=("a83t-suspend" "af8133j" "anx" "audio" "axp" "cam" "drm" "err" "fixes" "mbus" "modem" "opi3" "pb" "pinetab" "pp" "ppkb" "samuel" - "speed" "tbs-a711" "ths" ) + "speed" "tbs-a711" "ths") run_host_command_logged mkdir -p ${patch_dir_megous} ${patch_dir_tmp} diff --git a/extensions/armbian-live-patch.sh b/extensions/armbian-live-patch.sh index a986f6e89094..f7c816aa4625 100644 --- a/extensions/armbian-live-patch.sh +++ b/extensions/armbian-live-patch.sh @@ -1,6 +1,6 @@ function post_family_tweaks_bsp__armbian-live-patch() { -display_alert "Installing Armbian Live Patch" "${EXTENSION}" "info" + display_alert "Installing Armbian Live Patch" "${EXTENSION}" "info" run_host_command_logged cat <<- 'armbian-live-patch' > "${destination}"/etc/systemd/system/armbian-live-patch.service # Armbian simple patch system service diff --git a/extensions/cloud-init/cloud-init.sh b/extensions/cloud-init/cloud-init.sh index 376457f966d9..30c89732e33d 100644 --- a/extensions/cloud-init/cloud-init.sh +++ b/extensions/cloud-init/cloud-init.sh @@ -10,23 +10,23 @@ # Implementaiton is based on the NoCLoud data source that will use # the FAT partition with armbi_boot label to source the configuration from -# The Cloud init files in the boot partition are meant to be replaced with user provided ones, they are empty +# The Cloud init files in the boot partition are meant to be replaced with user provided ones, they are empty # of configurations except for setting hostname and DHCP on ethernet adapters. # This extension also disables armbian-first-run # Cloud-Init image marker function extension_prepare_config__ci_image_suffix() { - # Add to image suffix. - EXTRA_IMAGE_SUFFIXES+=("-ci") + # Add to image suffix. + EXTRA_IMAGE_SUFFIXES+=("-ci") } -function extension_prepare_config__prepare_ci() { +function extension_prepare_config__prepare_ci() { # Cloud Init related packages selected from Ubuntu RPI distirbution add_packages_to_image cloud-init cloud-initramfs-dyn-netconf } -function extension_prepare_config__ci_compatibility_check(){ +function extension_prepare_config__ci_compatibility_check() { # We require fat boot partition, will change and if the user provided another type, will fail. if [[ -z "${BOOTFS_TYPE}" ]]; then declare -g BOOTFS_TYPE="fat" @@ -53,7 +53,6 @@ function pre_customize_image__inject_cloud_init_config() { return 0 } - # @TODO: would be better to have "armbian first run" as an extension that can be disabled function pre_customize_image__disable_armbian_first_run() { display_alert "Disabling" "armbian first run" "info" diff --git a/extensions/fs-cryptroot-support.sh b/extensions/fs-cryptroot-support.sh index 95e70f95e915..6bda8d6f395b 100644 --- a/extensions/fs-cryptroot-support.sh +++ b/extensions/fs-cryptroot-support.sh @@ -15,13 +15,13 @@ function add_host_dependencies__add_cryptroot_tooling() { fi } -function extension_prepare_config__prepare_cryptroot() { +function extension_prepare_config__prepare_cryptroot() { # Config for cryptroot, a boot partition is required. declare -g BOOTPART_REQUIRED=yes EXTRA_IMAGE_SUFFIXES+=("-crypt") } -function prepare_root_device__encrypt_root_device(){ +function prepare_root_device__encrypt_root_device() { # We encrypt the rootdevice (currently a loop device) and return the new mapped rootdevice check_loop_device "$rootdevice" display_alert "Encrypting root partition with LUKS..." "cryptsetup luksFormat $rootdevice" "" diff --git a/extensions/lvm.sh b/extensions/lvm.sh index f3e26de44233..fad48294fa69 100644 --- a/extensions/lvm.sh +++ b/extensions/lvm.sh @@ -5,26 +5,25 @@ # # This extension will place the root partition on an LVM volume. -# It is possible to customise the volume group name and the image is extended to allow +# It is possible to customise the volume group name and the image is extended to allow # for LVM headers -# In case of failed builds check for leaked logical volumes with "dmsetup list" and +# In case of failed builds check for leaked logical volumes with "dmsetup list" and # remove them with "dmsetup remove" # Additional log infomration will be created on lvm.log - # We will need to create several LVM objects: PV VG VOL on the image from the host function add_host_dependencies__lvm_host_deps() { declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} lvm2" } function extension_prepare_config__lvm_image_suffix() { - # Add to image suffix. - EXTRA_IMAGE_SUFFIXES+=("-lvm") + # Add to image suffix. + EXTRA_IMAGE_SUFFIXES+=("-lvm") } -function extension_prepare_config__prepare_lvm() { +function extension_prepare_config__prepare_lvm() { # Config for lvm, boot partition is required, many bootloaders do not support LVM. declare -g BOOTPART_REQUIRED=yes declare -g LVM_VG_NAME="${LVM_VG_NAME:-armbivg}" @@ -32,7 +31,7 @@ function extension_prepare_config__prepare_lvm() { add_packages_to_image lvm2 } -function post_create_partitions__setup_lvm(){ +function post_create_partitions__setup_lvm() { LOOP=$(losetup -f) [[ -z $LOOP ]] && exit_with_error "Unable to find free loop device" @@ -71,7 +70,7 @@ function post_create_partitions__setup_lvm(){ display_alert "LVM created volume group" "${EXTENSION}" "info" } -function prepare_root_device__create_volume_group(){ +function prepare_root_device__create_volume_group() { display_alert "Using LVM root" "${EXTENSION}" "info" vgscan vgchange -a y ${LVM_VG_NAME} @@ -80,15 +79,15 @@ function prepare_root_device__create_volume_group(){ display_alert "Root device is ${rootdevice}" "${EXTENSION}" "info" } -function format_partitions__format_lvm(){ +function format_partitions__format_lvm() { # Label the root volume e2label /dev/mapper/${LVM_VG_NAME}-root armbi_root blkid | grep ${LVM_VG_NAME} >> "${DEST}"/${LOG_SUBPATH}/lvm.log 2>&1 display_alert "LVM labeled partitions" "${EXTENSION}" "info" } -function post_umount_final_image__close_lvm(){ +function post_umount_final_image__close_lvm() { # Deactivat the Volume Group vgchange -a n ${LVM_VG_NAME} display_alert "LVM deactivated volume group" "${EXTENSION}" "info" -} \ No newline at end of file +} diff --git a/extensions/network/config-networkd/netplan/10-dhcp-all-interfaces.yaml b/extensions/network/config-networkd/netplan/10-dhcp-all-interfaces.yaml new file mode 100644 index 000000000000..1aced1ba5108 --- /dev/null +++ b/extensions/network/config-networkd/netplan/10-dhcp-all-interfaces.yaml @@ -0,0 +1,16 @@ +# Added by Armbian +# +# Reference: https://netplan.readthedocs.io/en/stable/netplan-yaml/ +# +# Let systemd-networkd manage all Ethernet devices on this system, but be configured by Netplan. + +network: + version: 2 + renderer: networkd + ethernets: + all-eth-interfaces: + match: + name: "*" + dhcp4: yes + dhcp6: yes + ipv6-privacy: yes # Enabled by default on most current systems, but networkd currently doesn't enable IPv6 privacy by default, see https://man.archlinux.org/man/systemd.network.5 diff --git a/extensions/network/config-networkd/systemd/network/00-armbian-readme.network b/extensions/network/config-networkd/systemd/network/00-armbian-readme.network new file mode 100644 index 000000000000..8d51d51426dd --- /dev/null +++ b/extensions/network/config-networkd/systemd/network/00-armbian-readme.network @@ -0,0 +1,8 @@ +# Added by Armbian +# +# The systemd-networkd configuration is managed by Netplan +# See /etc/netplan/ + +# The match section is just to ignore a warning due to empty file +[Match] +MACAddress=NONE.ABCD.NONE # Will never match with anything diff --git a/extensions/network/config-nm/NetworkManager/00-armbian-readme.conf b/extensions/network/config-nm/NetworkManager/00-armbian-readme.conf new file mode 100644 index 000000000000..6df264c2f59c --- /dev/null +++ b/extensions/network/config-nm/NetworkManager/00-armbian-readme.conf @@ -0,0 +1,3 @@ +# Added by Armbian +# The NetworkManager configuration is mainly managed by Netplan +# See /etc/netplan/ diff --git a/packages/bsp/common/etc/NetworkManager/conf.d/zz-10-override-wifi-random-mac-disable.conf b/extensions/network/config-nm/NetworkManager/zz-10-override-wifi-random-mac-disable.conf similarity index 100% rename from packages/bsp/common/etc/NetworkManager/conf.d/zz-10-override-wifi-random-mac-disable.conf rename to extensions/network/config-nm/NetworkManager/zz-10-override-wifi-random-mac-disable.conf diff --git a/packages/bsp/common/etc/NetworkManager/conf.d/zz-20-override-wifi-powersave-disable.conf b/extensions/network/config-nm/NetworkManager/zz-20-override-wifi-powersave-disable.conf similarity index 100% rename from packages/bsp/common/etc/NetworkManager/conf.d/zz-20-override-wifi-powersave-disable.conf rename to extensions/network/config-nm/NetworkManager/zz-20-override-wifi-powersave-disable.conf diff --git a/extensions/network/config-nm/netplan/00-default-use-network-manager.yaml b/extensions/network/config-nm/netplan/00-default-use-network-manager.yaml new file mode 100644 index 000000000000..23f31cdb9585 --- /dev/null +++ b/extensions/network/config-nm/netplan/00-default-use-network-manager.yaml @@ -0,0 +1,11 @@ +# Added by Armbian +# +# Reference: https://netplan.readthedocs.io/en/stable/netplan-yaml/ +# +# Let NetworkManager manage all devices on this system. +# Any device will come up with DHCP, once carrier is detected. +# This is basically Netplan passing control over to NetworkManager at boot time. + +network: + version: 2 + renderer: NetworkManager diff --git a/extensions/network/net-chrony.sh b/extensions/network/net-chrony.sh new file mode 100644 index 000000000000..585ef48942a9 --- /dev/null +++ b/extensions/network/net-chrony.sh @@ -0,0 +1,7 @@ +# +# Extension to manage network time synchronization with Chrony +# +function add_host_dependencies__install_chrony() { + display_alert "Extension: ${EXTENSION}: Installing additional packages" "chrony" "info" + add_packages_to_image chrony +} diff --git a/extensions/network/net-network-manager.sh b/extensions/network/net-network-manager.sh new file mode 100644 index 000000000000..6fa20950e16c --- /dev/null +++ b/extensions/network/net-network-manager.sh @@ -0,0 +1,47 @@ +# +# Extension to manage network interfaces with NetworkManager + Netplan +# +function add_host_dependencies__install_network_manager() { + display_alert "Extension: ${EXTENSION}: Installing additional packages" "network-manager network-manager-openvpn netplan.io" "info" + add_packages_to_image network-manager network-manager-openvpn netplan.io + + if [[ "${BUILD_DESKTOP}" == "yes" ]]; then + display_alert "Extension: ${EXTENSION}: Installing additional packages for desktop" "network-manager-gnome network-manager-ssh network-manager-vpnc" "info" + add_packages_to_image network-manager-gnome network-manager-ssh network-manager-vpnc + fi + + if [[ "${DISTRIBUTION}" == "Ubuntu" ]]; then + display_alert "Extension: ${EXTENSION}: Installing additional packages for Ubuntu" "network-manager-config-connectivity-ubuntu" "info" + add_packages_to_image network-manager-config-connectivity-ubuntu + fi +} + +function pre_install_kernel_debs__configure_network_manager() { + display_alert "Extension: ${EXTENSION}: Enabling Network-Manager" "" "info" + + # Enable resolved + # Very likely not needed to enable manually since resolved is enabled by default + # NetworkManager can use systemd-resolved as a DNS resolver and cache. + # systemd-resolved will be used automatically if /etc/resolv.conf is a symlink to /run/systemd/resolve/stub-resolv.conf (source: https://wiki.archlinux.org/title/NetworkManager) + chroot_sdcard systemctl enable systemd-resolved.service || display_alert "Failed to enable systemd-resolved.service" "" "wrn" + + # We can't disable/mask systemd-networkd.service since it is required by Netplan + # There shouldn't be any conflicts since Netplan is configured in such a way that NetworkManager manages all network devices + + # Most likely we don't need to wait for nm to get online + chroot_sdcard systemctl disable NetworkManager-wait-online.service + + # Copy network config files into the appropriate folders + display_alert "Configuring" "NetworkManager and Netplan" "info" + local netplan_config_src_folder="${EXTENSION_DIR}/config-nm/netplan/" + local netplan_config_dst_folder="${SDCARD}/etc/netplan/" + + local network_manager_config_src_folder="${EXTENSION_DIR}/config-nm/NetworkManager/" + local network_manager_config_dst_folder="${SDCARD}/etc/NetworkManager/conf.d/" + + run_host_command_logged cp "${netplan_config_src_folder}"* "${netplan_config_dst_folder}" + run_host_command_logged cp "${network_manager_config_src_folder}"* "${network_manager_config_dst_folder}" + + # Change the file permissions according to https://netplan.readthedocs.io/en/stable/security/ + chmod 600 "${SDCARD}"/etc/netplan/* +} diff --git a/extensions/network/net-systemd-neworkd.sh b/extensions/network/net-systemd-neworkd.sh new file mode 100644 index 000000000000..6e522c48d438 --- /dev/null +++ b/extensions/network/net-systemd-neworkd.sh @@ -0,0 +1,30 @@ +# +# Extension to manage network interfaces with systemd-networkd + Netplan +# +function add_host_dependencies__install_systemd_networkd() { + display_alert "Extension: ${EXTENSION}: Installing additional packages" "netplan.io" "info" + add_packages_to_image netplan.io +} + +function pre_install_kernel_debs__configure_systemd_networkd() { + display_alert "Extension: ${EXTENSION}: Enabling systemd-networkd" "" "info" + + # Enable networkd and resolved + # Very likely not needed to enable manually since these services are enabled by default + chroot_sdcard systemctl enable systemd-networkd.service || display_alert "Failed to enable systemd-networkd.service" "" "wrn" + chroot_sdcard systemctl enable systemd-resolved.service || display_alert "Failed to enable systemd-resolved.service" "" "wrn" + + # Copy network config files into the appropriate folders + display_alert "Configuring" "systemd-networkd and Netplan" "info" + local netplan_config_src_folder="${EXTENSION_DIR}/config-networkd/netplan/" + local netplan_config_dst_folder="${SDCARD}/etc/netplan/" + + local networkd_config_src_folder="${EXTENSION_DIR}/config-networkd/systemd/network/" + local networkd_config_dst_folder="${SDCARD}/etc/systemd/network/" + + run_host_command_logged cp "${netplan_config_src_folder}"* "${netplan_config_dst_folder}" + run_host_command_logged cp "${networkd_config_src_folder}"* "${networkd_config_dst_folder}" + + # Change the file permissions according to https://netplan.readthedocs.io/en/stable/security/ + chmod 600 "${SDCARD}"/etc/netplan/* +} diff --git a/extensions/network/net-systemd-timesyncd.sh b/extensions/network/net-systemd-timesyncd.sh new file mode 100644 index 000000000000..f1a31c2399f8 --- /dev/null +++ b/extensions/network/net-systemd-timesyncd.sh @@ -0,0 +1,13 @@ +# +# Extension to manage network time synchronization with systemd-timesyncd +# +function add_host_dependencies__install_systemd-timesyncd() { + display_alert "Extension: ${EXTENSION}: Installing additional packages" "systemd-timesyncd" "info" + add_packages_to_image systemd-timesyncd +} + +function pre_install_kernel_debs__configure_systemd-timesyncd() { + # Enable timesyncd + display_alert "Extension: ${EXTENSION}: Enabling systemd-timesyncd" "" "info" + chroot_sdcard systemctl enable systemd-timesyncd.service +} diff --git a/extensions/radxa-aic8800.sh b/extensions/radxa-aic8800.sh index 098a793e20d2..1b81374696b2 100644 --- a/extensions/radxa-aic8800.sh +++ b/extensions/radxa-aic8800.sh @@ -12,11 +12,11 @@ function post_install_kernel_debs__install_aic8800_dkms_package() { [[ -z $AIC8800_TYPE ]] && return 0 api_url="https://api.github.com/repos/radxa-pkg/aic8800/releases/latest" latest_version=$(curl -s "${api_url}" | jq -r '.tag_name') - aic8800_firmware_url="https://github.com/radxa-pkg/aic8800/releases/download/${latest_version}/aic8800-firmware_${latest_version}_arm64.deb" + aic8800_firmware_url="https://github.com/radxa-pkg/aic8800/releases/download/${latest_version}/aic8800-firmware_${latest_version}_all.deb" aic8800_pcie_url="https://github.com/radxa-pkg/aic8800/releases/download/${latest_version}/aic8800-pcie-dkms_${latest_version}_all.deb" aic8800_sdio_url="https://github.com/radxa-pkg/aic8800/releases/download/${latest_version}/aic8800-sdio-dkms_${latest_version}_all.deb" aic8800_usb_url="https://github.com/radxa-pkg/aic8800/releases/download/${latest_version}/aic8800-usb-dkms_${latest_version}_all.deb" - if [[ "${GITHUB_MIRROR}" == "ghproxy" ]];then + if [[ "${GITHUB_MIRROR}" == "ghproxy" ]]; then ghproxy_header="https://mirror.ghproxy.com/" aic8800_firmware_url=${ghproxy_header}${aic8800_firmware_url} aic8800_pcie_url=${ghproxy_header}${aic8800_pcie_url} @@ -43,6 +43,6 @@ function post_install_kernel_debs__install_aic8800_dkms_package() { use_clean_environment="yes" chroot_sdcard "wget ${aic8800_firmware_url} -P /tmp" display_alert "Install aic8800 packages, will build kernel module in chroot" "${EXTENSION}" "info" declare -ag if_error_find_files_sdcard=("/var/lib/dkms/aic8800*/*/build/*.log") - use_clean_environment="yes" chroot_sdcard_apt_get_install "/tmp/${aic8800_dkms_file_name} /tmp/aic8800-firmware_${latest_version}_arm64.deb" + use_clean_environment="yes" chroot_sdcard_apt_get_install "/tmp/${aic8800_dkms_file_name} /tmp/aic8800-firmware_${latest_version}_all.deb" use_clean_environment="yes" chroot_sdcard "rm -f /tmp/aic8800*.deb" } diff --git a/extensions/xorg-lima-serverflags.sh b/extensions/xorg-lima-serverflags.sh index 38bef01add02..0bb54c05c13e 100644 --- a/extensions/xorg-lima-serverflags.sh +++ b/extensions/xorg-lima-serverflags.sh @@ -1,6 +1,6 @@ # # SPDX-License-Identifier: GPL-2.0 -# Copyright (c) 2023 Armbian +# Copyright (c) 2023 Armbian # This file is a part of the Armbian Build Framework https://github.com/armbian/build/ # @@ -31,4 +31,3 @@ function post_family_tweaks_bsp__install_lima_serverflags() { return 0 } - diff --git a/lib/functions/artifacts/artifact-uboot.sh b/lib/functions/artifacts/artifact-uboot.sh index 09deb309e540..0d0947c4bb86 100644 --- a/lib/functions/artifacts/artifact-uboot.sh +++ b/lib/functions/artifacts/artifact-uboot.sh @@ -95,11 +95,11 @@ function artifact_uboot_prepare_version() { # Hash variables that affect the build and package of u-boot declare -a vars_to_hash=( "${BOOTCONFIG:-"no_bootconfig"}" - "${BOOTDELAY}" "${UBOOT_DEBUGGING}" "${UBOOT_TARGET_MAP}" # general for all families - "${BOOT_SCENARIO}" "${BOOT_SUPPORT_SPI}" "${BOOT_SOC}" # rockchip stuff, sorry. - "${DDR_BLOB}" "${BL31_BLOB}" "${MINILOADER_BLOB}" # More rockchip stuff, even more sorry. - "${ATF_COMPILE}" "${ATFBRANCH}" "${ATFPATCHDIR}" # arm-trusted-firmware stuff - "${CRUSTCONFIG}" "${CRUSTBRANCH}" "${CRUSTPATCHDIR}" # crust stuff + "${BOOTDELAY}" "${UBOOT_DEBUGGING}" "${UBOOT_TARGET_MAP}" # general for all families + "${BOOT_SCENARIO}" "${BOOT_SUPPORT_SPI}" "${BOOT_SOC}" # rockchip stuff, sorry. + "${DDR_BLOB}" "${BL31_BLOB}" "${BL32_BLOB}" "${MINILOADER_BLOB}" # More rockchip stuff, even more sorry. + "${ATF_COMPILE}" "${ATFBRANCH}" "${ATFPATCHDIR}" # arm-trusted-firmware stuff + "${CRUSTCONFIG}" "${CRUSTBRANCH}" "${CRUSTPATCHDIR}" # crust stuff ) declare hash_variables="undetermined" # will be set by calculate_hash_for_variables(), which normalizes the input calculate_hash_for_variables "${vars_to_hash[@]}" diff --git a/lib/functions/bsp/armbian-bsp-cli-deb.sh b/lib/functions/bsp/armbian-bsp-cli-deb.sh index bd9de359ba6a..5f8897fe8dc0 100644 --- a/lib/functions/bsp/armbian-bsp-cli-deb.sh +++ b/lib/functions/bsp/armbian-bsp-cli-deb.sh @@ -175,9 +175,6 @@ function compile_armbian-bsp-cli() { echo "$(echo $i | sed 's/.*\///')=$(cat $i/support)" >> "${destination}"/etc/armbian-distribution-status done - # this is required for NFS boot to prevent deconfiguring the network on shutdown - sed -i 's/#no-auto-down/no-auto-down/g' "${destination}"/etc/network/interfaces.default - # execute $LINUXFAMILY-specific tweaks if [[ $(type -t family_tweaks_bsp) == function ]]; then display_alert "Running family_tweaks_bsp" "${LINUXFAMILY} - ${BOARDFAMILY}" "debug" @@ -198,11 +195,11 @@ function compile_armbian-bsp-cli() { # This is never run in build context; instead, it's source code is dumped inside a file that is packaged. # It is done this way so we get shellcheck and formatting instead of a huge heredoc. ### preinst - artifact_package_hook_helper_board_side_functions "preinst" board_side_bsp_cli_preinst "${preinst_functions[@]}" + artifact_package_hook_helper_board_side_functions "preinst" board_side_bsp_cli_preinst "${preinst_functions[@]}" unset board_side_bsp_cli_preinst ### postrm - artifact_package_hook_helper_board_side_functions "postrm" board_side_bsp_cli_postrm "${postrm_functions[@]}" + artifact_package_hook_helper_board_side_functions "postrm" board_side_bsp_cli_postrm "${postrm_functions[@]}" unset board_side_bsp_cli_postrm ### postinst -- a bit more complex, extendable via postinst_functions which can be customized in hook above @@ -245,7 +242,7 @@ function reversion_armbian-bsp-cli_deb_contents() { depends_base_files="" fi cat <<- EOF >> "${control_file_new}" - Depends: bash, linux-base, u-boot-tools, initramfs-tools, lsb-release, fping${depends_base_files} + Depends: bash, linux-base, u-boot-tools, initramfs-tools, lsb-release, fping${depends_base_files}, device-tree-compiler Replaces: zram-config, armbian-bsp-cli-${BOARD}${EXTRA_BSP_NAME} (<< ${REVISION}) Breaks: armbian-bsp-cli-${BOARD}${EXTRA_BSP_NAME} (<< ${REVISION}) EOF @@ -338,13 +335,6 @@ function board_side_bsp_cli_preinst() { # tell people to reboot at next login [ "$1" = "upgrade" ] && touch /var/run/.reboot_required - # convert link to file - if [ -L "/etc/network/interfaces" ]; then - cp /etc/network/interfaces /etc/network/interfaces.tmp - rm /etc/network/interfaces - mv /etc/network/interfaces.tmp /etc/network/interfaces - fi - # fixing ramdisk corruption when using lz4 compression method sed -i "s/^COMPRESS=.*/COMPRESS=gzip/" /etc/initramfs-tools/initramfs.conf @@ -430,7 +420,6 @@ function board_side_bsp_cli_postinst_base() { } function board_side_bsp_cli_postinst_finish() { - [ ! -f "/etc/network/interfaces" ] && [ -f "/etc/network/interfaces.default" ] && cp /etc/network/interfaces.default /etc/network/interfaces ln -sf /var/run/motd /etc/motd rm -f /etc/update-motd.d/00-header /etc/update-motd.d/10-help-text diff --git a/lib/functions/cli/commands.sh b/lib/functions/cli/commands.sh index 6cc89a4b7035..0430ec36c9e9 100644 --- a/lib/functions/cli/commands.sh +++ b/lib/functions/cli/commands.sh @@ -40,13 +40,13 @@ function armbian_register_commands() { ["debs-to-repo-reprepro"]="json_info" # implemented in cli_json_info_pre_run and cli_json_info_run # Patch to git & patch rewrite, for kernel - ["kernel-patches-to-git"]="patch_kernel" # implemented in cli_patch_kernel_pre_run and cli_patch_kernel_run - ["rewrite-kernel-patches"]="patch_kernel" # implemented in cli_patch_kernel_pre_run and cli_patch_kernel_run + ["kernel-patches-to-git"]="patch_kernel" # implemented in cli_patch_kernel_pre_run and cli_patch_kernel_run + ["rewrite-kernel-patches"]="patch_kernel" # implemented in cli_patch_kernel_pre_run and cli_patch_kernel_run ["rewrite-kernel-patches-needing-rebase"]="patch_kernel" # implemented in cli_patch_kernel_pre_run and cli_patch_kernel_run # Patch to git & patch rewrite, for u-boot - ["uboot-patches-to-git"]="patch_uboot" # implemented in cli_patch_uboot_pre_run and cli_patch_uboot_run - ["rewrite-uboot-patches"]="patch_uboot" # implemented in cli_patch_uboot_pre_run and cli_patch_uboot_run + ["uboot-patches-to-git"]="patch_uboot" # implemented in cli_patch_uboot_pre_run and cli_patch_uboot_run + ["rewrite-uboot-patches"]="patch_uboot" # implemented in cli_patch_uboot_pre_run and cli_patch_uboot_run ["rewrite-uboot-patches-needing-rebase"]="patch_uboot" # implemented in cli_patch_uboot_pre_run and cli_patch_uboot_run ["build"]="standard_build" # implemented in cli_standard_build_pre_run and cli_standard_build_run diff --git a/lib/functions/compilation/kernel-config.sh b/lib/functions/compilation/kernel-config.sh index 4cff8d8f4a7a..6ea0e69775ea 100644 --- a/lib/functions/compilation/kernel-config.sh +++ b/lib/functions/compilation/kernel-config.sh @@ -84,7 +84,7 @@ function kernel_config_initialize() { run_host_command_logged cp -pv ".config" "${config_after_kernel_config_extension_filename}" # Check sanity of kernel config and repair the config if necessary kernel_config_check_and_repair - + display_alert "Kernel configuration" "${LINUXCONFIG}" "info" } diff --git a/lib/functions/compilation/patch/drivers_network.sh b/lib/functions/compilation/patch/drivers_network.sh index 2983d52ca27b..7453ab42e8d2 100644 --- a/lib/functions/compilation/patch/drivers_network.sh +++ b/lib/functions/compilation/patch/drivers_network.sh @@ -446,8 +446,8 @@ driver_uwe5622() { fi fi - process_patch_file "${SRC}/patch/misc/wireless-uwe5622/wireless-uwe5622-Fix-compilation-with-6.7-kernel.patch" "applying" - process_patch_file "${SRC}/patch/misc/wireless-uwe5622/wireless-uwe5622-reduce-system-load.patch" "applying" + process_patch_file "${SRC}/patch/misc/wireless-uwe5622/wireless-uwe5622-Fix-compilation-with-6.7-kernel.patch" "applying" + process_patch_file "${SRC}/patch/misc/wireless-uwe5622/wireless-uwe5622-reduce-system-load.patch" "applying" if linux-version compare "${version}" ge 6.9; then process_patch_file "${SRC}/patch/misc/wireless-uwe5622/uwe5622-v6.9.patch" "applying" @@ -643,7 +643,6 @@ driver_mt7921u_add_pids() { fi } - ### ### ### NOTICE: <=5.x BELOW ONLY @@ -654,7 +653,6 @@ driver_mt7921u_add_pids() { ### ### v v v v v v v v v v v v v v v v v v v v v v v - #_bt for blueteeth driver_rtl8822cs_bt() { diff --git a/lib/functions/compilation/utils-compilation.sh b/lib/functions/compilation/utils-compilation.sh index 50206c72dd24..7648966a8067 100644 --- a/lib/functions/compilation/utils-compilation.sh +++ b/lib/functions/compilation/utils-compilation.sh @@ -27,7 +27,7 @@ grab_version() { ver[1]=$(grep "^PATCHLEVEL" "${1}"/Makefile | head -1 | awk '{print $(NF)}' | grep -oE '^[[:digit:]]+' || true) ver[2]=$(grep "^SUBLEVEL" "${1}"/Makefile | head -1 | awk '{print $(NF)}' | grep -oE '^[[:digit:]]+' || true) ver[3]=$(grep "^EXTRAVERSION" "${1}"/Makefile | head -1 | awk '{print $(NF)}' | grep -oE '^-rc[[:digit:]]+' || true) - ver[4]=$(if [ -f localversion-next ];then echo $(cat localversion-next); fi || true) + ver[4]=$(if [ -f localversion-next ]; then echo $(cat localversion-next); fi || true) echo "${ver[0]:-0}${ver[1]:+.${ver[1]}}${ver[2]:+.${ver[2]}}${ver[3]}${ver[4]}" return 0 } diff --git a/lib/functions/configuration/main-config.sh b/lib/functions/configuration/main-config.sh index 241396be5c87..1963e84f1249 100644 --- a/lib/functions/configuration/main-config.sh +++ b/lib/functions/configuration/main-config.sh @@ -61,6 +61,16 @@ function do_main_configuration() { declare -g SKIP_EXTERNAL_TOOLCHAINS="${SKIP_EXTERNAL_TOOLCHAINS:-yes}" # don't use any external toolchains, by default. + # Network-manager and Chrony for standard CLI and desktop, systemd-networkd and systemd-timesyncd for minimal + # systemd-timesyncd is slimmer and less resource intensive than Chrony, see https://unix.stackexchange.com/questions/504381/chrony-vs-systemd-timesyncd-what-are-the-differences-and-use-cases-as-ntp-cli + if [[ ${BUILD_MINIMAL} == yes ]]; then + enable_extension "net-systemd-neworkd" + enable_extension "net-systemd-timesyncd" + else + enable_extension "net-network-manager" + enable_extension "net-chrony" + fi + # Timezone if [[ -f /etc/timezone ]]; then # Timezone for target is taken from host, if it exists. TZDATA=$(cat /etc/timezone) diff --git a/lib/functions/general/extensions.sh b/lib/functions/general/extensions.sh index 4fb9cff6afbd..00c487c4cbd0 100644 --- a/lib/functions/general/extensions.sh +++ b/lib/functions/general/extensions.sh @@ -476,6 +476,14 @@ function enable_extension() { extension_dir="${extension_base_path}" # this is misleading. only directory-based extensions should have this. extension_file="${extension_floating_file}" break + else + # Search for the extension file in any subdirectory + extension_file=$(find "${extension_base_path}" -type f -name "${extension_name}.sh" | head -n 1) # Example format: extensions/network/net-network-manager.sh + if [[ -n "${extension_file}" ]]; then + # Extract extension dir from file, e.g. from "extensions/network/net-network-manager.sh" the dir "extensions/network/" gets extracted + extension_dir="${extension_file%/*}" + break + fi fi done diff --git a/lib/functions/general/git-ref2info.sh b/lib/functions/general/git-ref2info.sh index a2a12fe9efc5..2d0079f8100e 100644 --- a/lib/functions/general/git-ref2info.sh +++ b/lib/functions/general/git-ref2info.sh @@ -89,8 +89,8 @@ function memoized_git_ref_to_info() { else \ . + [{\"source\": \$source, \"branch\": \$branch, \"sha1\": \$sha1}] \ end" /dev/fd/5 >&6 - cat /dev/fd/6 >"${SRC}"/output/info/git_sources.json - } 5<>"${SRC}"/output/info/git_sources.json 6<>"${SRC}"/output/info/git_sources.json.new + cat /dev/fd/6 > "${SRC}"/output/info/git_sources.json + } 5<> "${SRC}"/output/info/git_sources.json 6<> "${SRC}"/output/info/git_sources.json.new fi if [[ -f "${SRC}"/config/sources/git_sources.json && ${ref_type} == "branch" ]]; then diff --git a/lib/functions/image/partitioning.sh b/lib/functions/image/partitioning.sh index 9407c3bd3325..52dbb597fc04 100644 --- a/lib/functions/image/partitioning.sh +++ b/lib/functions/image/partitioning.sh @@ -99,7 +99,7 @@ function prepare_partitions() { fi # Check if we need boot partition # Specialized storage extensions like cryptroot or lvm may require a boot partition - if [[ $BOOTSIZE != "0" && ( -n $BOOTFS_TYPE || $ROOTFS_TYPE != ext4 || $BOOTPART_REQUIRED == yes ) ]]; then + if [[ $BOOTSIZE != "0" && (-n $BOOTFS_TYPE || $ROOTFS_TYPE != ext4 || $BOOTPART_REQUIRED == yes) ]]; then local bootpart=$((next++)) local bootfs=${BOOTFS_TYPE:-ext4} [[ -z $BOOTSIZE || $BOOTSIZE -le 8 ]] && BOOTSIZE=${DEFAULT_BOOTSIZE} @@ -216,25 +216,9 @@ function prepare_partitions() { flock -x $FD declare -g LOOP - # replace losetup --find with own function and do 10 cycles - # losetup always return 1st free loop device and in parallel build, - # it often happens that same is found which resoults in: - # "failed to set up loop device: Device or resource busy" - # If we seek random way, chanches of allocating the same are significantly smaller. - FIND_LOOP_CYCLES=1 - while : ; do - LOOP=$(find /dev/loop* | grep -Po "(\/dev\/loop\d|\/dev\/loop\d\d)$" | sort -R | head -1) - LOOP_COMPARE=$(losetup -l --noheadings --raw --output=NAME | grep $LOOP || true) - [[ -z $LOOP_COMPARE ]] && break - [[ $FIND_LOOP_CYCLES -gt 30 ]] && exit_with_error "Unable to find free loop device" - FIND_LOOP_CYCLES=$(( FIND_LOOP_CYCLES + 1 )) - done - display_alert "Allocated loop device" "LOOP=${LOOP} in cycle $FIND_LOOP_CYCLES" - - CHECK_LOOP_FOR_SIZE="no" check_loop_device "$LOOP" # initially loop is zero sized, ignore it. - - #--partscan is using to force the kernel for scaning partition table in preventing of partprobe errors - run_host_command_logged losetup --partscan "${LOOP}" "${SDCARD}".raw + #--partscan is using to force the kernel for scaning partition table in preventing of partprobe errors + LOOP=$(losetup --show --partscan --find "${SDCARD}".raw) || exit_with_error "Unable to find free loop device" + display_alert "Allocated loop device" "LOOP=${LOOP}" # loop device was grabbed here, unlock flock -u $FD diff --git a/lib/functions/logging/display-alert.sh b/lib/functions/logging/display-alert.sh index d5ce75869c4e..e757f9e89683 100644 --- a/lib/functions/logging/display-alert.sh +++ b/lib/functions/logging/display-alert.sh @@ -31,8 +31,8 @@ function display_alert() { fi level_indicator="🐛" case "${background_dark_or_light}" in - light) inline_logs_color="\e[1;2;33m" ;; - *) inline_logs_color="\e[1;33m" ;; + light) inline_logs_color="\e[1;2;33m" ;; + *) inline_logs_color="\e[1;33m" ;; esac skip_logfile=1 ;; @@ -48,8 +48,8 @@ function display_alert() { info) level_indicator="🌱" case "${background_dark_or_light}" in - light) inline_logs_color="\e[1;2;32m" ;; - *) inline_logs_color="\e[1;32m" ;; + light) inline_logs_color="\e[1;2;32m" ;; + *) inline_logs_color="\e[1;32m" ;; esac ;; @@ -59,8 +59,8 @@ function display_alert() { fi level_indicator="🧽" case "${background_dark_or_light}" in - light) inline_logs_color="\e[1;2;33m" ;; - *) inline_logs_color="\e[1;33m" ;; + light) inline_logs_color="\e[1;2;33m" ;; + *) inline_logs_color="\e[1;33m" ;; esac skip_logfile=1 ;; @@ -151,8 +151,8 @@ function display_alert() { ext) level_indicator="✨" case "${background_dark_or_light}" in - light) inline_logs_color="\e[1;2;32m" ;; - *) inline_logs_color="\e[1;32m" ;; + light) inline_logs_color="\e[1;2;32m" ;; + *) inline_logs_color="\e[1;32m" ;; esac ;; @@ -165,8 +165,8 @@ function display_alert() { level="${level:-info}" # for file logging. level_indicator="🌿" case "${background_dark_or_light}" in - dark) inline_logs_color="\e[1;37m" ;; - *) inline_logs_color="\e[1;39m" ;; + dark) inline_logs_color="\e[1;37m" ;; + *) inline_logs_color="\e[1;39m" ;; esac ;; esac diff --git a/lib/functions/logging/logging.sh b/lib/functions/logging/logging.sh index 8f2cb7c67dd5..26fdc9c7aef0 100644 --- a/lib/functions/logging/logging.sh +++ b/lib/functions/logging/logging.sh @@ -21,10 +21,10 @@ function logging_init() { # detect terminal background color case "${COLORFGBG+${COLORFGBG#*;}}" in - [0-6]|8) + [0-6] | 8) declare -g background_dark_or_light=dark ;; - 7|9|1[0-5]) + 7 | 9 | 1[0-5]) declare -g background_dark_or_light=light ;; *) diff --git a/lib/functions/rootfs/distro-agnostic.sh b/lib/functions/rootfs/distro-agnostic.sh index 69ce3f9f44b5..26dc81195555 100644 --- a/lib/functions/rootfs/distro-agnostic.sh +++ b/lib/functions/rootfs/distro-agnostic.sh @@ -44,10 +44,6 @@ function install_distribution_agnostic() { GOVERNOR=$GOVERNOR EOF - # remove default interfaces file if present - # before installing board support package - rm -f "${SDCARD}"/etc/network/interfaces - # disable selinux by default mkdir -p "${SDCARD}"/selinux [[ -f "${SDCARD}"/etc/selinux/config ]] && sed "s/^SELINUX=.*/SELINUX=disabled/" -i "${SDCARD}"/etc/selinux/config @@ -148,13 +144,14 @@ function install_distribution_agnostic() { fi if [[ -n $DEFAULT_OVERLAYS ]]; then - DEFAULT_OVERLAYS=(${DEFAULT_OVERLAYS//,/ }) - DEFAULT_OVERLAYS=("${DEFAULT_OVERLAYS[@]/%/".dtbo"}") - DEFAULT_OVERLAYS=("${DEFAULT_OVERLAYS[@]/#/"${bootpart_prefix}dtb/${BOOT_FDT_FILE%%/*}/overlay/${OVERLAY_PREFIX}-"}") + DEFAULT_OVERLAYS_ARR=(${DEFAULT_OVERLAYS//,/ }) + DEFAULT_OVERLAYS_ARR=("${DEFAULT_OVERLAYS_ARR[@]/%/".dtbo"}") + DEFAULT_OVERLAYS_ARR=("${DEFAULT_OVERLAYS_ARR[@]/#/"${bootpart_prefix}dtb/${BOOT_FDT_FILE%%/*}/overlay/${OVERLAY_PREFIX}-"}") - display_alert "Adding to extlinux.conf" "fdtoverlays=${DEFAULT_OVERLAYS[@]}" "debug" - echo " fdtoverlays ${DEFAULT_OVERLAYS[@]}" >> "$SDCARD/boot/extlinux/extlinux.conf" + display_alert "Adding to extlinux.conf" "fdtoverlays=${DEFAULT_OVERLAYS_ARR[*]}" "debug" + echo " fdtoverlays ${DEFAULT_OVERLAYS_ARR[*]}" >> "$SDCARD/boot/extlinux/extlinux.conf" fi + else # ... not extlinux ... if [[ -n "${BOOTSCRIPT}" ]]; then # @TODO: && "${BOOTCONFIG}" != "none" @@ -494,62 +491,6 @@ function install_distribution_agnostic() { # enable PubkeyAuthentication sed -i 's/#\?PubkeyAuthentication .*/PubkeyAuthentication yes/' "${SDCARD}"/etc/ssh/sshd_config - if [[ -f "${SDCARD}"/etc/NetworkManager/NetworkManager.conf ]]; then - # configure network manager - sed "s/managed=\(.*\)/managed=true/g" -i "${SDCARD}"/etc/NetworkManager/NetworkManager.conf - - ## remove network manager defaults to handle eth by default @TODO: why? - rm -f "${SDCARD}"/usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf - - # `systemd-networkd.service` will be enabled by `/lib/systemd/system-preset/90-systemd.preset` during first-run. - # Mask it to avoid conflict - chroot_sdcard systemctl mask systemd-networkd.service - - # most likely we don't need to wait for nm to get online - chroot_sdcard systemctl disable NetworkManager-wait-online.service - - # Just regular DNS and maintain /etc/resolv.conf as a file @TODO: this does not apply as of impish at least - sed "/dns/d" -i "${SDCARD}"/etc/NetworkManager/NetworkManager.conf - sed "s/\[main\]/\[main\]\ndns=default\nrc-manager=file/g" -i "${SDCARD}"/etc/NetworkManager/NetworkManager.conf - - if [[ -n $NM_IGNORE_DEVICES ]]; then - mkdir -p "${SDCARD}"/etc/NetworkManager/conf.d/ - cat <<- EOF > "${SDCARD}"/etc/NetworkManager/conf.d/10-ignore-interfaces.conf - [keyfile] - unmanaged-devices=$NM_IGNORE_DEVICES - EOF - fi - - elif [ -d "${SDCARD}"/etc/systemd/network ]; then - # enable services - chroot_sdcard systemctl enable systemd-networkd.service - chroot_sdcard systemctl enable systemd-resolved.service || display_alert "Failed to enable systemd-resolved.service" "" "wrn" - - # Mask `NetworkManager.service` to avoid conflict - chroot_sdcard systemctl mask NetworkManager.service - - if [ -e "${SDCARD}"/etc/systemd/timesyncd.conf ]; then - chroot_sdcard systemctl enable systemd-timesyncd.service - fi - - umask 022 - cat > "${SDCARD}"/etc/systemd/network/eth0.network <<- __EOF__ - [Match] - Name=eth0 - - [Network] - #MACAddress= - DHCP=ipv4 - LinkLocalAddressing=ipv4 - #Address=192.168.1.100/24 - #Gateway=192.168.1.1 - #DNS=192.168.1.1 - #Domains=example.com - NTP=0.pool.ntp.org 1.pool.ntp.org - __EOF__ - - fi - # avahi daemon defaults if exists [[ -f "${SDCARD}"/usr/share/doc/avahi-daemon/examples/sftp-ssh.service ]] && cp "${SDCARD}"/usr/share/doc/avahi-daemon/examples/sftp-ssh.service "${SDCARD}"/etc/avahi/services/ diff --git a/lib/functions/rootfs/distro-specific.sh b/lib/functions/rootfs/distro-specific.sh index 103fb6b28a29..63e8c7a3d3f9 100644 --- a/lib/functions/rootfs/distro-specific.sh +++ b/lib/functions/rootfs/distro-specific.sh @@ -28,9 +28,6 @@ function install_distribution_specific() { sed -i "s/#RateLimitIntervalSec=.*/RateLimitIntervalSec=30s/g" "${SDCARD}"/etc/systemd/journald.conf sed -i "s/#RateLimitBurst=.*/RateLimitBurst=10000/g" "${SDCARD}"/etc/systemd/journald.conf - # Chrony temporal fix https://bugs.launchpad.net/ubuntu/+source/chrony/+bug/1878005 - [[ -f "${SDCARD}"/etc/default/chrony ]] && sed -i '/DAEMON_OPTS=/s/"-F -1"/"-F 0"/' "${SDCARD}"/etc/default/chrony - # disable conflicting services disable_systemd_service_sdcard ondemand.service @@ -44,25 +41,21 @@ function install_distribution_specific() { install_artifact_deb_chroot "armbian-base-files" fi - # Basic Netplan config. Let NetworkManager/networkd manage all devices on this system - if [[ -d "${SDCARD}"/etc/netplan ]]; then - - declare RENDERER=networkd - if [ -d "${SDCARD}"/etc/NetworkManager ]; then - local RENDERER=NetworkManager - fi - - cat <<- EOF > "${SDCARD}"/etc/netplan/armbian-default.yaml - network: - version: 2 - renderer: ${RENDERER} - EOF - fi - # Set DNS server if systemd-resolved is in use if [[ -n "$NAMESERVER" && -f "${SDCARD}"/etc/systemd/resolved.conf ]]; then - sed -i "s/#DNS=.*/DNS=$NAMESERVER/g" "${SDCARD}"/etc/systemd/resolved.conf display_alert "Setup DNS server for systemd-resolved" "${NAMESERVER}" "info" + + # Use resolved.conf.d/ directory as recommended by resolved itself + mkdir -p "${SDCARD}"/etc/systemd/resolved.conf.d/ + + cat <<- EOF > "${SDCARD}"/etc/systemd/resolved.conf.d/00-armbian-default-dns.conf + # Added by Armbian + # + # See resolved.conf(5) for details + + [Resolve] + DNS=${NAMESERVER} + EOF fi # cleanup motd services and related files @@ -106,9 +99,6 @@ function create_sources_list_and_deploy_repo_key() { deb http://${DEBIAN_MIRROR} ${release}-updates main contrib non-free #deb-src http://${DEBIAN_MIRROR} ${release}-updates main contrib non-free - deb http://${DEBIAN_MIRROR} ${release}-backports main contrib non-free - #deb-src http://${DEBIAN_MIRROR} ${release}-backports main contrib non-free - deb http://${DEBIAN_SECURTY} ${release}/updates main contrib non-free #deb-src http://${DEBIAN_SECURTY} ${release}/updates main contrib non-free EOF diff --git a/lib/functions/rootfs/post-tweaks.sh b/lib/functions/rootfs/post-tweaks.sh index 16a1edb1ff28..f714a30841ae 100644 --- a/lib/functions/rootfs/post-tweaks.sh +++ b/lib/functions/rootfs/post-tweaks.sh @@ -13,14 +13,11 @@ function post_debootstrap_tweaks() { # adjust tzselect to improve political correctness sed -i "s/Please select a country/Please select a country or a region/g" "${SDCARD}"/usr/bin/tzselect - # activate systemd-resolved, if not using NetworkManager - if [[ ! -f "${SDCARD}"/etc/NetworkManager/NetworkManager.conf ]]; then - if [[ -d "${SDCARD}"/etc/systemd/network ]]; then - display_alert "Activating systemd-resolved" "Symlink resolv.conf to systemd-resolved's" "debug" - run_host_command_logged rm -fv "${SDCARD}"/etc/resolv.conf - run_host_command_logged ln -s /run/systemd/resolve/resolv.conf "${SDCARD}"/etc/resolv.conf - fi - fi + # activate systemd-resolved + display_alert "Activating systemd-resolved" "Symlinking /etc/resolv.conf to /run/systemd/resolve/stub-resolv.conf" "debug" + run_host_command_logged rm -fv "${SDCARD}"/etc/resolv.conf + # The method of symlinking to /run/systemd/resolve/stub-resolv.conf is recommended, see https://www.man7.org/linux/man-pages/man8/systemd-resolved.service.8.html + run_host_command_logged ln -s /run/systemd/resolve/stub-resolv.conf "${SDCARD}"/etc/resolv.conf # remove service start blockers run_host_command_logged rm -fv "${SDCARD}"/sbin/initctl "${SDCARD}"/sbin/start-stop-daemon @@ -36,5 +33,4 @@ function post_debootstrap_tweaks() { Last chance to touch the `${SDCARD}` filesystem before it is copied to the final media. It is too late to run any chrooted commands, since the supporting filesystems are already unmounted. POST_POST_DEBOOTSTRAP_TWEAKS - } diff --git a/lib/functions/rootfs/rootfs-create.sh b/lib/functions/rootfs/rootfs-create.sh index 45794cb0335f..efc8550d3f78 100644 --- a/lib/functions/rootfs/rootfs-create.sh +++ b/lib/functions/rootfs/rootfs-create.sh @@ -68,7 +68,7 @@ function create_new_rootfs_cache_via_debootstrap() { display_alert "Preparing debootstrap" "for ${DISTRIBUTION}'s ${RELEASE}" "info" case "${DISTRIBUTION}" in Ubuntu) - GIT_FIXED_WORKDIR="debootstrap-ubuntu-devel" fetch_from_repo "https://git.launchpad.net/ubuntu/+source/debootstrap" "debootstrap-ubuntu-devel" "branch:ubuntu/devel" + GIT_FIXED_WORKDIR="debootstrap-ubuntu-devel" fetch_from_repo "https://git.launchpad.net/ubuntu/+source/debootstrap" "debootstrap-ubuntu-devel" "tag:import/1.0.118ubuntu1.13" debootstrap_wanted_dir="${SRC}/cache/sources/debootstrap-ubuntu-devel" debootstrap_default_script="gutsy" ;; diff --git a/packages/bsp/common/etc/network/interfaces.default b/packages/bsp/common/etc/network/interfaces.default deleted file mode 100644 index eb7a0fc46ee2..000000000000 --- a/packages/bsp/common/etc/network/interfaces.default +++ /dev/null @@ -1,4 +0,0 @@ -source /etc/network/interfaces.d/* -# Network is managed by Network manager -auto lo -iface lo inet loopback diff --git a/packages/bsp/common/etc/udev/rules.d/90-chromium-video.rules b/packages/bsp/common/etc/udev/rules.d/90-chromium-video.rules index 79d8dc00e376..d33f62d942cf 100644 --- a/packages/bsp/common/etc/udev/rules.d/90-chromium-video.rules +++ b/packages/bsp/common/etc/udev/rules.d/90-chromium-video.rules @@ -14,3 +14,7 @@ SUBSYSTEM=="media", ATTR{model}=="hantro-vpu", SYMLINK+="media-dec%n" # These rules are for rkvdec v4l2 stateless decoder found on rk3399 SUBSYSTEM=="video4linux", ATTR{name}=="rkvdec", SYMLINK+="video-dec%n" SUBSYSTEM=="media", ATTR{model}=="rkvdec", SYMLINK+="media-dec%n" + +# These rules are for rkvdec2 v4l2 stateless decoder found on rk35xx +SUBSYSTEM=="video4linux", ATTR{name}=="rkvdec2", SYMLINK+="video-dec%n" +SUBSYSTEM=="media", ATTR{model}=="rkvdec2", SYMLINK+="media-dec%n" diff --git a/packages/bsp/common/usr/lib/armbian/armbian-common b/packages/bsp/common/usr/lib/armbian/armbian-common index 2f1eb72943b4..714e03408094 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-common +++ b/packages/bsp/common/usr/lib/armbian/armbian-common @@ -9,6 +9,8 @@ # Functions: # # show_motd_warning +# generate_random_mac +# set_fixed_mac export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin my_name="${0##*/}" @@ -23,38 +25,42 @@ EOT chmod +x /etc/update-motd.d/90-warning } # show_motd_warning -get_random_mac () +# Generate a random MAC address +generate_random_mac () { -local prefixes=("02" "06" "0A" "0E") -local random=$(shuf -i 0-3 -n 1) -MACADDR=$(printf ${prefixes[$random]}':%02X:%02X:%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256]) + # These prefixes are 4 sets of Locally Administered Address Ranges which can be used on the network without fear of conflict + local prefixes=("02" "06" "0A" "0E") + local random=$(shuf -i 0-3 -n 1) + MACADDR=$(printf ${prefixes[$random]}':%02X:%02X:%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256]) } - -# set fixed IP address from first randomly assigned one. If nothing is detected, generate one. +# Set a fixed random MAC for each Ethernet interface set_fixed_mac () { - if [ -n "$(command -v nmcli)" ]; then - CONNECTION="$(nmcli -f UUID,ACTIVE,DEVICE,TYPE connection show --active | tail -n1)" - UUID=$(awk -F" " '/ethernet/ {print $1}' <<< "${CONNECTION}") - DEVNAME=$(awk -F" " '/ethernet/ {print $3}' <<< "${CONNECTION}") - else - DEVNAME=eth0 - fi - - MACADDR=$(/sbin/ip link | grep -A1 ${DEVNAME} | awk -F" " '/ether / {print $2}') - - [[ -z $MACADDR ]] && get_random_mac - - if [[ -n "$(command -v nmcli)" && -n $UUID ]]; then - nmcli connection modify "$UUID" ethernet.cloned-mac-address "$MACADDR" - nmcli connection modify "$UUID" -ethernet.mac-address "" - nmcli connection down "$UUID" >/dev/null 2>&1 - nmcli connection up "$UUID" >/dev/null 2>&1 - elif [[ -f /etc/systemd/network/$DEVNAME.network ]]; then - if ! grep '^ *MACAddress=' /etc/systemd/network/$DEVNAME.network > /dev/null; then - sed -i "s/#MACAddress=/MACAddress=$MACADDR/g" /etc/systemd/network/$DEVNAME.network - fi - fi - return 0 -} # set fixed mac to the 1st active network adapter + local netplan_config_file="/etc/netplan/20-eth-fixed-mac.yaml" + + # Initialize a new Netplan config file + cat <<- EOF > "${netplan_config_file}" + network: + version: 2 + ethernets: + EOF + + # Iterate over each Ethernet interface + for iface in $(ip link | awk -F: '$0 !~ "lo|vir|wl|^[^0-9]"{print $2;getline}' | sed 's/^[ \t]*//' | grep "^e") + do + generate_random_mac + + # Append the MAC address configuration for the interface to the Netplan configuration file + cat <<- EOF >> "${netplan_config_file}" + $iface: + macaddress: $MACADDR + EOF + done + + # Change the file permissions according to https://netplan.readthedocs.io/en/stable/security/ + chmod 600 "${netplan_config_file}" + + # Apply the Netplan configuration + netplan apply +} diff --git a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin index eabec5eaf322..fefc37f373c7 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin +++ b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin @@ -47,6 +47,30 @@ mask2cidr() { echo "$nbits" } +createYAML() { + local YAML="network:\n" + YAML+=" $DEVTYPE:\n" + YAML+=" $DEVICE_NAME:\n" + if [[ "${PRESET_NET_USE_STATIC}" == 0 ]]; then YAML+=" dhcp4: yes\n";fi + if [[ "${PRESET_NET_USE_STATIC}" == 0 ]]; then YAML+=" dhcp6: yes\n";fi + if [[ "${PRESET_NET_USE_STATIC}" == 1 ]]; then + YAML+=" addresses:\n" + YAML+=" - $PRESET_NET_STATIC_IP/$PRESET_NET_STATIC_MASK\n" + if [[ -n "${PRESET_NET_STATIC_GATEWAY}" ]]; then YAML+=" routes:\n";fi + if [[ -n "${PRESET_NET_STATIC_GATEWAY}" ]]; then YAML+=" - to: default\n";fi + if [[ -n "${PRESET_NET_STATIC_GATEWAY}" ]]; then YAML+=" via: ${PRESET_NET_STATIC_GATEWAY}\n";fi + if [[ -n "${PRESET_NET_STATIC_DNS}" ]]; then YAML+=" nameservers:\n"; fi + if [[ -n "${PRESET_NET_STATIC_DNS}" ]]; then YAML+=" addresses: [$PRESET_NET_STATIC_DNS]\n"; fi + fi + if [[ "${PRESET_NET_WIFI_ENABLED}" == 1 ]]; then + if [[ -n "${PRESET_NET_WIFI_COUNTRYCODE}" ]]; then YAML+=" regulatory-domain: $PRESET_NET_WIFI_COUNTRYCODE\n"; fi + if [[ -n "${PRESET_NET_WIFI_SSID}" ]]; then YAML+=" access-points:\n"; fi + if [[ -n "${PRESET_NET_WIFI_SSID}" ]]; then YAML+=" \"$PRESET_NET_WIFI_SSID\":\n"; fi + if [[ -n "${PRESET_NET_WIFI_KEY}" ]]; then YAML+=" password: \"$PRESET_NET_WIFI_KEY\"\n" ; fi + fi + printf "%s" "$YAML" +} + do_firstrun_automated_network_configuration() { #----------------------------------------------------------------------------- @@ -73,50 +97,81 @@ do_firstrun_automated_network_configuration() #----------------------------------------------------------------------------- # Set Network if [[ $PRESET_NET_CHANGE_DEFAULTS == 1 ]]; then - # Only run at tty1 - if [ "$(who am i | awk '{print $2}')" != "tty1" ];then - exit - fi + # - Get name of 1st available ethernet and wifi adapter - eth_index="$(nmcli d | grep ethernet | cut -d ' ' -f 1 | head -n 1)" - wlan_index="$(nmcli d | grep wifi | cut -d ' ' -f 1 | head -n 1)" + eth_index="$(ip link | awk -F: '$0 !~ "lo|vir|wl|^[^0-9]"{print $2;getline}' | sed 's/^[ \t]*//' | grep "^e" | head -1)" + wlan_index="$(iw dev | awk '$1=="Interface"{print $2}' | head -n 1)" + local CONFIG_NAME="-dhcp" # for static IP we only append settings if [[ $PRESET_NET_USE_STATIC == 1 ]]; then - local FIXED_IP_SETTINGS="ipv4.method manual ipv4.address ${PRESET_NET_STATIC_IP}/${PRESET_NET_STATIC_MASK} ipv4.dns ${PRESET_NET_STATIC_DNS} ipv4.gateway ${PRESET_NET_STATIC_GATEWAY}" + local CONFIG_NAME="-static" fi + # at least one device has to exits if [[ -n $eth_index || -n $wlan_index ]]; then - # delete all current connections - LC_ALL=C nmcli -t -f UUID,DEVICE connection show | awk '{print $1}' | cut -f1 -d":" | xargs nmcli connection delete # - Wifi enable if [[ $PRESET_NET_WIFI_ENABLED == 1 ]]; then - #Set wifi country code - iw reg set "$PRESET_NET_WIFI_COUNTRYCODE" - - nmcli con add con-name "Armbian wireless" type wifi ifname ${wlan_index} ssid "$PRESET_NET_WIFI_SSID" -- wifi-sec.key-mgmt wpa-psk wifi-sec.psk "$PRESET_NET_WIFI_KEY" ${FIXED_IP_SETTINGS} - nmcli con up "Armbian wireless" - - #Enable Wlan, disable Eth - PRESET_NET_ETHERNET_ENABLED=0 + DEVICE_NAME=${wlan_index} + DEVTYPE=wifis + echo -e "$(createYAML)" > /etc/netplan/30-${DEVTYPE}${CONFIG_NAME}.yaml + chmod 600 /etc/netplan/30-${DEVTYPE}${CONFIG_NAME}.yaml + #Enable Wlan, disable Eth + PRESET_NET_ETHERNET_ENABLED=0 + netplan apply > /dev/null 2>&1 # - Ethernet enable elif [[ $PRESET_NET_ETHERNET_ENABLED == 1 ]]; then - nmcli con add con-name "Armbian ethernet" type ethernet ifname ${eth_index} -- ${FIXED_IP_SETTINGS} - nmcli con up "Armbian ethernet" - - #Enable Eth, disable Wlan - PRESET_NET_WIFI_ENABLED=0 - + DEVICE_NAME=${eth_index} + DEVTYPE=ethernets + echo -e "$(createYAML)" > /etc/netplan/30-${DEVTYPE}${CONFIG_NAME}.yaml + chmod 600 /etc/netplan/30-${DEVTYPE}${CONFIG_NAME}.yaml + # Enable Eth, disable Wlan + PRESET_NET_WIFI_ENABLED=0 + netplan apply > /dev/null 2>&1 fi + fi fi fi } #do_firstrun_automated_network_configuration +# Try to retrieve the local IP address to display +get_local_ip_addr() { + # How many seconds to wait at maximum to find out the local IP address + local ip_wait_seconds_counter=6 + local local_device_ip="" + local retry_message="" + + while [[ -z "$local_device_ip" ]] && [ ${ip_wait_seconds_counter} -ge 0 ]; do + local_device_ip=$(ip -4 addr show scope global | grep inet | awk '{print $2}' | cut -d/ -f1 | awk '{$1=$1}1' FS='\n' OFS=',' RS=) + + # Set retry message if some retries are left, but no IP address has been found yet + if [[ -z "$local_device_ip" ]] && [[ $ip_wait_seconds_counter -gt 0 ]]; then + retry_message="\e[1m\e[97mWaiting for local connection!\x1B[0m Retrying... (${ip_wait_seconds_counter})" + # Empty retry message if IP address has been found + elif [[ -n "$local_device_ip" ]]; then + retry_message="" + # Set timeout message if no retries are left and no IP address has been found + else + retry_message="\e[1m\e[31mNetwork connection timeout!\x1B[0m" + fi + + # Display the message + echo -e "\e[1A\e[KIP address: \x1B[92m${local_device_ip}\x1B[0m ${retry_message}" + + # Wait for 1 second if the IP has not yet been found + if [[ -z "$local_device_ip" ]]; then + sleep 1 + fi + + ip_wait_seconds_counter=$((ip_wait_seconds_counter - 1)) + done +} + read_password() { unset password @@ -210,7 +265,11 @@ set_timezone_and_locales() { PUBLIC_IP=$(curl --max-time 5 -s https://ipinfo.io/ip) # Check if we have wireless adaptor - WIFI_DEVICE=$(LC_ALL=C nmcli dev status | grep " wifi " 2> /dev/null) + if command -v nmcli > /dev/null 2>&1; then + WIFI_DEVICE=$(LC_ALL=C nmcli dev status | grep " wifi " 2> /dev/null) + elif command -v iw > /dev/null 2>&1; then + WIFI_DEVICE=$(LC_ALL=C iw dev | awk '$1=="Interface"{print $2}' 2> /dev/null) + fi if [ -z "$PUBLIC_IP" ]; then @@ -226,10 +285,47 @@ set_timezone_and_locales() { else response=n fi - echo "$response" done if [[ "${response}" =~ ^(Y|y)$ ]]; then - nmtui-connect + + # get list of wireless networks + echo -e "\nDetected wireless networks:\n" + ARRAY=($(sudo iwlist ${WIFI_DEVICE} scanning | egrep 'ESSID' | sed 's/^[ \t]*//' | sed 's/"//g' | sed 's/ESSID://' | awk 'BEGIN{FS=OFS=","} {$NF=++count OFS $NF} 1')) + while [[ 1 ]] ; do + while [[ 1 ]] ; do + for str in ${ARRAY[@]}; do echo $str | sed "s/,/ \t /g"; done + read -r -p "Enter a number of SSID: " input + if [[ "$input" =~ ^[0-9]{,2}$ ]] ; then break; fi + done + echo "" + # get password + while [[ 1 ]] ; do + SSID=$(echo ${ARRAY[$input-1]} | cut -d"," -f2) + read -r -p "Enter a password for ${SSID}: " password + break + done + + # generate config + cat <<- EOF > "${SDCARD}"/etc/netplan/30-wifis-dhcp.yaml + # Created by Armbian firstlogin script + network: + wifis: + ${WIFI_DEVICE}: + dhcp4: yes + dhcp6: yes + access-points: + "$SSID": + password: "${password}" + EOF + + # apply to netplan + systemctl daemon-reload + netplan apply --timeout 0 2>/dev/null + sleep 5 + + # exit if connection is suffesful + if [[ -n $(sudo iw ${WIFI_DEVICE} link | grep "$SSID") ]]; then break; fi + done fi echo "" fi @@ -260,7 +356,6 @@ set_timezone_and_locales() { else response=$SET_LANG_BASED_ON_LOCATION fi - echo "$response" done # change it only if we have a match and if we agree if [[ "${response}" =~ ^(N|n)$ ]]; then @@ -482,8 +577,13 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then echo -e "Welcome to \e[1m\e[97m${VENDOR}\x1B[0m! \n" echo -e "Documentation: \e[1m\e[92m${VENDORDOCS}\x1B[0m | Community support: \e[1m\e[92m${VENDORSUPPORT}\x1B[0m\n" - GET_IP=$(bash /etc/update-motd.d/30-armbian-sysinfo | grep IP | sed "s/.*IP://" | sed 's/^[ \t]*//') - [[ -n "$GET_IP" ]] && echo -e "IP address: $GET_IP\n" + + echo "" # empty line + + # Try to get the local IP address (script halts until IP was found or x retries were done) + get_local_ip_addr + + echo "" # empty line trap '' 2 REPEATS=3 diff --git a/packages/bsp/common/usr/lib/armbian/armbian-firstrun b/packages/bsp/common/usr/lib/armbian/armbian-firstrun index 4b7134b57ba7..4bfdbb934393 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-firstrun +++ b/packages/bsp/common/usr/lib/armbian/armbian-firstrun @@ -77,9 +77,9 @@ case "$1" in # randomize mac in armbianEnv.txt if [[ -f /boot/armbianEnv.txt ]]; then - get_random_mac + generate_random_mac sed -i "s/^ethaddr=.*/ethaddr=$MACADDR/" /boot/armbianEnv.txt - get_random_mac + generate_random_mac sed -i "s/^eth1addr=.*/eth1addr=$MACADDR/" /boot/armbianEnv.txt fi @@ -99,7 +99,7 @@ case "$1" in sed -i "s/^PORT=.*/PORT=ttyS3/" /etc/default/ap6212 ;; "Orange Pi Zero"|"NanoPi Duo"|"Sunvell R69") - get_random_mac + generate_random_mac echo "options xradio_wlan macaddr=${MACADDR}" >/etc/modprobe.d/xradio_wlan.conf echo -e "\n### [firstrun] Use MAC address ${MACADDR} for Wi-Fi from now" >>${Log} cd /etc/network/ && ln -sf interfaces.network-manager interfaces @@ -111,15 +111,6 @@ case "$1" in echo heartbeat >/sys/class/leds/*red*/trigger 2>/dev/null || echo heartbeat >/sys/class/leds/*blue*/trigger 2>/dev/null ;; - mvebu64|mt7623) - # configure/enable/start systemd-networkd - systemctl start systemd-networkd.service - systemctl start systemd-resolved.service - systemctl enable systemd-networkd.service - systemctl enable systemd-resolved.service - ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf - systemctl restart systemd-networkd - ;; x86|arm64) [[ -n "$(dmesg | grep "No NVIDIA GPU found")" ]] && sudo apt-get -y -qq purge nvidia-dkms-510 nvidia-driver-510 nvidia-settings nvidia-common >> /dev/null ;; @@ -129,7 +120,6 @@ case "$1" in # varios temporary hardware workarounds [[ $LINUXFAMILY == rk3399 || $LINUXFAMILY == rockchip64 ]] && [[ $BOARD != helios64 && $BOARD != khadas-edge ]] && set_fixed_mac - [[ $BRANCH == dev && $LINUXFAMILY == rockchip ]] && set_fixed_mac [[ $LINUXFAMILY == meson ]] && set_fixed_mac [[ $LINUXFAMILY == meson64 ]] && set_fixed_mac systemctl disable armbian-firstrun diff --git a/packages/bsp/common/usr/lib/armbian/armbian-hardware-monitor b/packages/bsp/common/usr/lib/armbian/armbian-hardware-monitor index 6a35ba7e794d..9f170b280db5 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-hardware-monitor +++ b/packages/bsp/common/usr/lib/armbian/armbian-hardware-monitor @@ -84,7 +84,7 @@ log_hardware_info() { echo -e "\n### ip addr:\n" >>${Log} /sbin/ip r s >>${Log} ; /sbin/ip a >>${Log} echo " " >>${Log} - else + elif [ -x /sbin/ifconfig ]; then echo -e "\n### ifconfig:\n" >>${Log} ifconfig >>${Log} fi diff --git a/packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh b/packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh index fdf0dac62023..39aa4b0d817c 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh +++ b/packages/bsp/common/usr/lib/armbian/armbian-led-state-save.sh @@ -19,7 +19,7 @@ CMD_FIND=$(which find) # $1 = base led path # $2 = path of destination state file function store_led() { - + PATH="$1" TRIGGER_PATH="$1/trigger" DESTINATION="$2" @@ -35,7 +35,9 @@ function store_led() { # In case the trigger is any of the kbd-*, don't store any other parameter # This avoids num/scroll/capslock from being restored at startup - [[ "$TRIGGER_VALUE" =~ kbd-* ]] && return + # In case trigger is representing link-state for any network, don't store its previous state + # This avoids ghost wan/lan/etc (led up while cable unplugged) + [[ "$TRIGGER_VALUE" =~ kbd-* || "$TRIGGER_VALUE" == *":link" ]] && return COMMAND_PARAMS="$CMD_FIND $PATH/ -maxdepth 1 -type f ! -iname uevent ! -iname trigger -perm /u+w -printf %f\\n" PARAMS=$($COMMAND_PARAMS) diff --git a/packages/bsp/generate-bt-mac-addr/bt-fixed-mac.service b/packages/bsp/generate-bt-mac-addr/bt-fixed-mac.service new file mode 100644 index 000000000000..8a9f7b08a2d1 --- /dev/null +++ b/packages/bsp/generate-bt-mac-addr/bt-fixed-mac.service @@ -0,0 +1,11 @@ +[Unit] +Description=Bluetooth Fixed Mac Address +After=bluetooth.service systemd-machine-id-commit.service +Wants=bluetooth.service +[Service] +Type=oneshot +RemainAfterExit=yes +SyslogIdentifier=bt-fixed-mac +ExecStart=/usr/local/bin/bt-fixed-mac.sh +[Install] +WantedBy=bluetooth.target diff --git a/packages/bsp/generate-bt-mac-addr/bt-fixed-mac.sh b/packages/bsp/generate-bt-mac-addr/bt-fixed-mac.sh new file mode 100644 index 000000000000..03d9d51787e0 --- /dev/null +++ b/packages/bsp/generate-bt-mac-addr/bt-fixed-mac.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +mac="$(echo $(cat /etc/machine-id; echo bluetooth)| sha256sum -)" +bt_mac=$(echo "42:${mac:0:2}:${mac:4:2}:${mac:8:2}:${mac:12:2}:${mac:16:2}") +echo $bt_mac +/usr/bin/bluetoothctl mgmt.public-addr $bt_mac diff --git a/patch/kernel/archive/rockchip-rk3588-6.10/0025-RK3588-Add-VPU121-H.264-Decoder-Support.patch b/patch/kernel/archive/rockchip-rk3588-6.10/0026-RK3588-Add-VPU121-H.264-Decoder-Support.patch similarity index 86% rename from patch/kernel/archive/rockchip-rk3588-6.10/0025-RK3588-Add-VPU121-H.264-Decoder-Support.patch rename to patch/kernel/archive/rockchip-rk3588-6.10/0026-RK3588-Add-VPU121-H.264-Decoder-Support.patch index 46eee186ce2b..78b7d8bf8bb1 100644 --- a/patch/kernel/archive/rockchip-rk3588-6.10/0025-RK3588-Add-VPU121-H.264-Decoder-Support.patch +++ b/patch/kernel/archive/rockchip-rk3588-6.10/0026-RK3588-Add-VPU121-H.264-Decoder-Support.patch @@ -32,43 +32,6 @@ index 111111111111..222222222222 100644 -- Armbian -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Sebastian Reichel -Date: Thu, 13 Jun 2024 15:48:43 +0200 -Subject: media: dt-bindings: rockchip-vpu: Add RK3588 VPU121 - -From: Jianfeng Liu - -RK3588 has four Hantro H1 VEPUs (encoder-only) modules and one combined -Hantro H1/G1 VPU (decoder and encoder). These are not described as -separate IP, since they are sharing an internal cache. This adds the -RK3588 specific compatible string for the combined VPU, which seems to -be identical to the version found in the RK3568. - -Signed-off-by: Jianfeng Liu -Acked-by: Conor Dooley -Signed-off-by: Sebastian Reichel ---- - Documentation/devicetree/bindings/media/rockchip-vpu.yaml | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/Documentation/devicetree/bindings/media/rockchip-vpu.yaml b/Documentation/devicetree/bindings/media/rockchip-vpu.yaml -index 111111111111..222222222222 100644 ---- a/Documentation/devicetree/bindings/media/rockchip-vpu.yaml -+++ b/Documentation/devicetree/bindings/media/rockchip-vpu.yaml -@@ -31,6 +31,9 @@ properties: - - items: - - const: rockchip,rk3228-vpu - - const: rockchip,rk3399-vpu -+ - items: -+ - const: rockchip,rk3588-vpu121 -+ - const: rockchip,rk3568-vpu - - reg: - maxItems: 1 --- -Armbian - From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Thu, 13 Jun 2024 15:48:44 +0200 @@ -169,7 +132,7 @@ index 111111111111..222222222222 100644 { .compatible = "rockchip,rk3399-vpu", .data = &rk3399_vpu_variant, }, { .compatible = "rockchip,rk3568-vepu", .data = &rk3568_vepu_variant, }, { .compatible = "rockchip,rk3568-vpu", .data = &rk3568_vpu_variant, }, -+ { .compatible = "rockchip,rk3588-vepu121", .data = &rk3568_vpu_variant, }, ++ { .compatible = "rockchip,rk3588-vepu121", .data = &rk3568_vepu_variant, }, { .compatible = "rockchip,rk3588-av1-vpu", .data = &rk3588_vpu981_variant, }, #endif #ifdef CONFIG_VIDEO_HANTRO_IMX8M @@ -307,22 +270,23 @@ Signed-off-by: Jianfeng Liu Tested-by: Hugh Cole-Baker Signed-off-by: Sebastian Reichel --- - arch/arm64/boot/dts/rockchip/rk3588s.dtsi | 21 ++++++++++ - 1 file changed, 21 insertions(+) + arch/arm64/boot/dts/rockchip/rk3588s.dtsi | 22 ++++++++++ + 1 file changed, 22 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi index 111111111111..222222222222 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi -@@ -1282,6 +1282,27 @@ power-domain@RK3588_PD_SDMMC { +@@ -1282,6 +1282,28 @@ power-domain@RK3588_PD_SDMMC { }; }; + vpu121: video-codec@fdb50000 { -+ compatible = "rockchip,rk3588-vpu121", "rockchip,rk3568-vpu"; ++ compatible = "rockchip,rk3588-vpu121", "rockchip,rk3399-vpu"; + reg = <0x0 0xfdb50000 0x0 0x800>; -+ interrupts = ; -+ interrupt-names = "vdpu"; ++ interrupts = , ++ ; ++ interrupt-names = "vepu", "vdpu"; + clocks = <&cru ACLK_VPU>, <&cru HCLK_VPU>; + clock-names = "aclk", "hclk"; + iommus = <&vpu121_mmu>; diff --git a/patch/kernel/archive/rockchip-rk3588-6.10/0027-RK3588-Add-rkvdec2-Support-v3.patch b/patch/kernel/archive/rockchip-rk3588-6.10/0027-RK3588-Add-rkvdec2-Support-v3.patch new file mode 100644 index 000000000000..8f1f4ce87cf7 --- /dev/null +++ b/patch/kernel/archive/rockchip-rk3588-6.10/0027-RK3588-Add-rkvdec2-Support-v3.patch @@ -0,0 +1,3746 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Detlev Casanova +Date: Thu, 20 Jun 2024 10:19:43 -0400 +Subject: media: rockchip: Move H264 CABAC table to header file + +The table will be shared with the rkvdec2 driver in following commits. + +Signed-off-by: Detlev Casanova +--- + drivers/staging/media/rkvdec/rkvdec-h264-cabac.h | 509 ++++++++++ + drivers/staging/media/rkvdec/rkvdec-h264.c | 500 +-------- + 2 files changed, 510 insertions(+), 499 deletions(-) + +diff --git a/drivers/staging/media/rkvdec/rkvdec-h264-cabac.h b/drivers/staging/media/rkvdec/rkvdec-h264-cabac.h +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/staging/media/rkvdec/rkvdec-h264-cabac.h +@@ -0,0 +1,509 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++ ++/* ++ * Define the H264 CABAC table common to rkvdec and rkvdec2 drivers. ++ */ ++ ++#ifndef RKVDEC_H264_CABAC_H_ ++#define RKVDEC_H264_CABAC_H_ ++ ++#define CABAC_ENTRY(ctxidx, idc0_m, idc0_n, idc1_m, idc1_n, \ ++ idc2_m, idc2_n, intra_m, intra_n) \ ++ [0][(ctxidx)] = {idc0_m, idc0_n}, \ ++ [1][(ctxidx)] = {idc1_m, idc1_n}, \ ++ [2][(ctxidx)] = {idc2_m, idc2_n}, \ ++ [3][(ctxidx)] = {intra_m, intra_n} ++ ++/* ++ * Constant CABAC table. ++ * Built from the tables described in section '9.3.1.1 Initialisation process ++ * for context variables' of the H264 spec. ++ */ ++static const s8 rkvdec_h264_cabac_table[4][464][2] = { ++ /* Table 9-12 – Values of variables m and n for ctxIdx from 0 to 10 */ ++ CABAC_ENTRY(0, 20, -15, 20, -15, 20, -15, 20, -15), ++ CABAC_ENTRY(1, 2, 54, 2, 54, 2, 54, 2, 54), ++ CABAC_ENTRY(2, 3, 74, 3, 74, 3, 74, 3, 74), ++ CABAC_ENTRY(3, 20, -15, 20, -15, 20, -15, 20, -15), ++ CABAC_ENTRY(4, 2, 54, 2, 54, 2, 54, 2, 54), ++ CABAC_ENTRY(5, 3, 74, 3, 74, 3, 74, 3, 74), ++ CABAC_ENTRY(6, -28, 127, -28, 127, -28, 127, -28, 127), ++ CABAC_ENTRY(7, -23, 104, -23, 104, -23, 104, -23, 104), ++ CABAC_ENTRY(8, -6, 53, -6, 53, -6, 53, -6, 53), ++ CABAC_ENTRY(9, -1, 54, -1, 54, -1, 54, -1, 54), ++ CABAC_ENTRY(10, 7, 51, 7, 51, 7, 51, 7, 51), ++ ++ /* Table 9-13 – Values of variables m and n for ctxIdx from 11 to 23 */ ++ CABAC_ENTRY(11, 23, 33, 22, 25, 29, 16, 0, 0), ++ CABAC_ENTRY(12, 23, 2, 34, 0, 25, 0, 0, 0), ++ CABAC_ENTRY(13, 21, 0, 16, 0, 14, 0, 0, 0), ++ CABAC_ENTRY(14, 1, 9, -2, 9, -10, 51, 0, 0), ++ CABAC_ENTRY(15, 0, 49, 4, 41, -3, 62, 0, 0), ++ CABAC_ENTRY(16, -37, 118, -29, 118, -27, 99, 0, 0), ++ CABAC_ENTRY(17, 5, 57, 2, 65, 26, 16, 0, 0), ++ CABAC_ENTRY(18, -13, 78, -6, 71, -4, 85, 0, 0), ++ CABAC_ENTRY(19, -11, 65, -13, 79, -24, 102, 0, 0), ++ CABAC_ENTRY(20, 1, 62, 5, 52, 5, 57, 0, 0), ++ CABAC_ENTRY(21, 12, 49, 9, 50, 6, 57, 0, 0), ++ CABAC_ENTRY(22, -4, 73, -3, 70, -17, 73, 0, 0), ++ CABAC_ENTRY(23, 17, 50, 10, 54, 14, 57, 0, 0), ++ ++ /* Table 9-14 – Values of variables m and n for ctxIdx from 24 to 39 */ ++ CABAC_ENTRY(24, 18, 64, 26, 34, 20, 40, 0, 0), ++ CABAC_ENTRY(25, 9, 43, 19, 22, 20, 10, 0, 0), ++ CABAC_ENTRY(26, 29, 0, 40, 0, 29, 0, 0, 0), ++ CABAC_ENTRY(27, 26, 67, 57, 2, 54, 0, 0, 0), ++ CABAC_ENTRY(28, 16, 90, 41, 36, 37, 42, 0, 0), ++ CABAC_ENTRY(29, 9, 104, 26, 69, 12, 97, 0, 0), ++ CABAC_ENTRY(30, -46, 127, -45, 127, -32, 127, 0, 0), ++ CABAC_ENTRY(31, -20, 104, -15, 101, -22, 117, 0, 0), ++ CABAC_ENTRY(32, 1, 67, -4, 76, -2, 74, 0, 0), ++ CABAC_ENTRY(33, -13, 78, -6, 71, -4, 85, 0, 0), ++ CABAC_ENTRY(34, -11, 65, -13, 79, -24, 102, 0, 0), ++ CABAC_ENTRY(35, 1, 62, 5, 52, 5, 57, 0, 0), ++ CABAC_ENTRY(36, -6, 86, 6, 69, -6, 93, 0, 0), ++ CABAC_ENTRY(37, -17, 95, -13, 90, -14, 88, 0, 0), ++ CABAC_ENTRY(38, -6, 61, 0, 52, -6, 44, 0, 0), ++ CABAC_ENTRY(39, 9, 45, 8, 43, 4, 55, 0, 0), ++ ++ /* Table 9-15 – Values of variables m and n for ctxIdx from 40 to 53 */ ++ CABAC_ENTRY(40, -3, 69, -2, 69, -11, 89, 0, 0), ++ CABAC_ENTRY(41, -6, 81, -5, 82, -15, 103, 0, 0), ++ CABAC_ENTRY(42, -11, 96, -10, 96, -21, 116, 0, 0), ++ CABAC_ENTRY(43, 6, 55, 2, 59, 19, 57, 0, 0), ++ CABAC_ENTRY(44, 7, 67, 2, 75, 20, 58, 0, 0), ++ CABAC_ENTRY(45, -5, 86, -3, 87, 4, 84, 0, 0), ++ CABAC_ENTRY(46, 2, 88, -3, 100, 6, 96, 0, 0), ++ CABAC_ENTRY(47, 0, 58, 1, 56, 1, 63, 0, 0), ++ CABAC_ENTRY(48, -3, 76, -3, 74, -5, 85, 0, 0), ++ CABAC_ENTRY(49, -10, 94, -6, 85, -13, 106, 0, 0), ++ CABAC_ENTRY(50, 5, 54, 0, 59, 5, 63, 0, 0), ++ CABAC_ENTRY(51, 4, 69, -3, 81, 6, 75, 0, 0), ++ CABAC_ENTRY(52, -3, 81, -7, 86, -3, 90, 0, 0), ++ CABAC_ENTRY(53, 0, 88, -5, 95, -1, 101, 0, 0), ++ ++ /* Table 9-16 – Values of variables m and n for ctxIdx from 54 to 59 */ ++ CABAC_ENTRY(54, -7, 67, -1, 66, 3, 55, 0, 0), ++ CABAC_ENTRY(55, -5, 74, -1, 77, -4, 79, 0, 0), ++ CABAC_ENTRY(56, -4, 74, 1, 70, -2, 75, 0, 0), ++ CABAC_ENTRY(57, -5, 80, -2, 86, -12, 97, 0, 0), ++ CABAC_ENTRY(58, -7, 72, -5, 72, -7, 50, 0, 0), ++ CABAC_ENTRY(59, 1, 58, 0, 61, 1, 60, 0, 0), ++ ++ /* Table 9-17 – Values of variables m and n for ctxIdx from 60 to 69 */ ++ CABAC_ENTRY(60, 0, 41, 0, 41, 0, 41, 0, 41), ++ CABAC_ENTRY(61, 0, 63, 0, 63, 0, 63, 0, 63), ++ CABAC_ENTRY(62, 0, 63, 0, 63, 0, 63, 0, 63), ++ CABAC_ENTRY(63, 0, 63, 0, 63, 0, 63, 0, 63), ++ CABAC_ENTRY(64, -9, 83, -9, 83, -9, 83, -9, 83), ++ CABAC_ENTRY(65, 4, 86, 4, 86, 4, 86, 4, 86), ++ CABAC_ENTRY(66, 0, 97, 0, 97, 0, 97, 0, 97), ++ CABAC_ENTRY(67, -7, 72, -7, 72, -7, 72, -7, 72), ++ CABAC_ENTRY(68, 13, 41, 13, 41, 13, 41, 13, 41), ++ CABAC_ENTRY(69, 3, 62, 3, 62, 3, 62, 3, 62), ++ ++ /* Table 9-18 – Values of variables m and n for ctxIdx from 70 to 104 */ ++ CABAC_ENTRY(70, 0, 45, 13, 15, 7, 34, 0, 11), ++ CABAC_ENTRY(71, -4, 78, 7, 51, -9, 88, 1, 55), ++ CABAC_ENTRY(72, -3, 96, 2, 80, -20, 127, 0, 69), ++ CABAC_ENTRY(73, -27, 126, -39, 127, -36, 127, -17, 127), ++ CABAC_ENTRY(74, -28, 98, -18, 91, -17, 91, -13, 102), ++ CABAC_ENTRY(75, -25, 101, -17, 96, -14, 95, 0, 82), ++ CABAC_ENTRY(76, -23, 67, -26, 81, -25, 84, -7, 74), ++ CABAC_ENTRY(77, -28, 82, -35, 98, -25, 86, -21, 107), ++ CABAC_ENTRY(78, -20, 94, -24, 102, -12, 89, -27, 127), ++ CABAC_ENTRY(79, -16, 83, -23, 97, -17, 91, -31, 127), ++ CABAC_ENTRY(80, -22, 110, -27, 119, -31, 127, -24, 127), ++ CABAC_ENTRY(81, -21, 91, -24, 99, -14, 76, -18, 95), ++ CABAC_ENTRY(82, -18, 102, -21, 110, -18, 103, -27, 127), ++ CABAC_ENTRY(83, -13, 93, -18, 102, -13, 90, -21, 114), ++ CABAC_ENTRY(84, -29, 127, -36, 127, -37, 127, -30, 127), ++ CABAC_ENTRY(85, -7, 92, 0, 80, 11, 80, -17, 123), ++ CABAC_ENTRY(86, -5, 89, -5, 89, 5, 76, -12, 115), ++ CABAC_ENTRY(87, -7, 96, -7, 94, 2, 84, -16, 122), ++ CABAC_ENTRY(88, -13, 108, -4, 92, 5, 78, -11, 115), ++ CABAC_ENTRY(89, -3, 46, 0, 39, -6, 55, -12, 63), ++ CABAC_ENTRY(90, -1, 65, 0, 65, 4, 61, -2, 68), ++ CABAC_ENTRY(91, -1, 57, -15, 84, -14, 83, -15, 84), ++ CABAC_ENTRY(92, -9, 93, -35, 127, -37, 127, -13, 104), ++ CABAC_ENTRY(93, -3, 74, -2, 73, -5, 79, -3, 70), ++ CABAC_ENTRY(94, -9, 92, -12, 104, -11, 104, -8, 93), ++ CABAC_ENTRY(95, -8, 87, -9, 91, -11, 91, -10, 90), ++ CABAC_ENTRY(96, -23, 126, -31, 127, -30, 127, -30, 127), ++ CABAC_ENTRY(97, 5, 54, 3, 55, 0, 65, -1, 74), ++ CABAC_ENTRY(98, 6, 60, 7, 56, -2, 79, -6, 97), ++ CABAC_ENTRY(99, 6, 59, 7, 55, 0, 72, -7, 91), ++ CABAC_ENTRY(100, 6, 69, 8, 61, -4, 92, -20, 127), ++ CABAC_ENTRY(101, -1, 48, -3, 53, -6, 56, -4, 56), ++ CABAC_ENTRY(102, 0, 68, 0, 68, 3, 68, -5, 82), ++ CABAC_ENTRY(103, -4, 69, -7, 74, -8, 71, -7, 76), ++ CABAC_ENTRY(104, -8, 88, -9, 88, -13, 98, -22, 125), ++ ++ /* Table 9-19 – Values of variables m and n for ctxIdx from 105 to 165 */ ++ CABAC_ENTRY(105, -2, 85, -13, 103, -4, 86, -7, 93), ++ CABAC_ENTRY(106, -6, 78, -13, 91, -12, 88, -11, 87), ++ CABAC_ENTRY(107, -1, 75, -9, 89, -5, 82, -3, 77), ++ CABAC_ENTRY(108, -7, 77, -14, 92, -3, 72, -5, 71), ++ CABAC_ENTRY(109, 2, 54, -8, 76, -4, 67, -4, 63), ++ CABAC_ENTRY(110, 5, 50, -12, 87, -8, 72, -4, 68), ++ CABAC_ENTRY(111, -3, 68, -23, 110, -16, 89, -12, 84), ++ CABAC_ENTRY(112, 1, 50, -24, 105, -9, 69, -7, 62), ++ CABAC_ENTRY(113, 6, 42, -10, 78, -1, 59, -7, 65), ++ CABAC_ENTRY(114, -4, 81, -20, 112, 5, 66, 8, 61), ++ CABAC_ENTRY(115, 1, 63, -17, 99, 4, 57, 5, 56), ++ CABAC_ENTRY(116, -4, 70, -78, 127, -4, 71, -2, 66), ++ CABAC_ENTRY(117, 0, 67, -70, 127, -2, 71, 1, 64), ++ CABAC_ENTRY(118, 2, 57, -50, 127, 2, 58, 0, 61), ++ CABAC_ENTRY(119, -2, 76, -46, 127, -1, 74, -2, 78), ++ CABAC_ENTRY(120, 11, 35, -4, 66, -4, 44, 1, 50), ++ CABAC_ENTRY(121, 4, 64, -5, 78, -1, 69, 7, 52), ++ CABAC_ENTRY(122, 1, 61, -4, 71, 0, 62, 10, 35), ++ CABAC_ENTRY(123, 11, 35, -8, 72, -7, 51, 0, 44), ++ CABAC_ENTRY(124, 18, 25, 2, 59, -4, 47, 11, 38), ++ CABAC_ENTRY(125, 12, 24, -1, 55, -6, 42, 1, 45), ++ CABAC_ENTRY(126, 13, 29, -7, 70, -3, 41, 0, 46), ++ CABAC_ENTRY(127, 13, 36, -6, 75, -6, 53, 5, 44), ++ CABAC_ENTRY(128, -10, 93, -8, 89, 8, 76, 31, 17), ++ CABAC_ENTRY(129, -7, 73, -34, 119, -9, 78, 1, 51), ++ CABAC_ENTRY(130, -2, 73, -3, 75, -11, 83, 7, 50), ++ CABAC_ENTRY(131, 13, 46, 32, 20, 9, 52, 28, 19), ++ CABAC_ENTRY(132, 9, 49, 30, 22, 0, 67, 16, 33), ++ CABAC_ENTRY(133, -7, 100, -44, 127, -5, 90, 14, 62), ++ CABAC_ENTRY(134, 9, 53, 0, 54, 1, 67, -13, 108), ++ CABAC_ENTRY(135, 2, 53, -5, 61, -15, 72, -15, 100), ++ CABAC_ENTRY(136, 5, 53, 0, 58, -5, 75, -13, 101), ++ CABAC_ENTRY(137, -2, 61, -1, 60, -8, 80, -13, 91), ++ CABAC_ENTRY(138, 0, 56, -3, 61, -21, 83, -12, 94), ++ CABAC_ENTRY(139, 0, 56, -8, 67, -21, 64, -10, 88), ++ CABAC_ENTRY(140, -13, 63, -25, 84, -13, 31, -16, 84), ++ CABAC_ENTRY(141, -5, 60, -14, 74, -25, 64, -10, 86), ++ CABAC_ENTRY(142, -1, 62, -5, 65, -29, 94, -7, 83), ++ CABAC_ENTRY(143, 4, 57, 5, 52, 9, 75, -13, 87), ++ CABAC_ENTRY(144, -6, 69, 2, 57, 17, 63, -19, 94), ++ CABAC_ENTRY(145, 4, 57, 0, 61, -8, 74, 1, 70), ++ CABAC_ENTRY(146, 14, 39, -9, 69, -5, 35, 0, 72), ++ CABAC_ENTRY(147, 4, 51, -11, 70, -2, 27, -5, 74), ++ CABAC_ENTRY(148, 13, 68, 18, 55, 13, 91, 18, 59), ++ CABAC_ENTRY(149, 3, 64, -4, 71, 3, 65, -8, 102), ++ CABAC_ENTRY(150, 1, 61, 0, 58, -7, 69, -15, 100), ++ CABAC_ENTRY(151, 9, 63, 7, 61, 8, 77, 0, 95), ++ CABAC_ENTRY(152, 7, 50, 9, 41, -10, 66, -4, 75), ++ CABAC_ENTRY(153, 16, 39, 18, 25, 3, 62, 2, 72), ++ CABAC_ENTRY(154, 5, 44, 9, 32, -3, 68, -11, 75), ++ CABAC_ENTRY(155, 4, 52, 5, 43, -20, 81, -3, 71), ++ CABAC_ENTRY(156, 11, 48, 9, 47, 0, 30, 15, 46), ++ CABAC_ENTRY(157, -5, 60, 0, 44, 1, 7, -13, 69), ++ CABAC_ENTRY(158, -1, 59, 0, 51, -3, 23, 0, 62), ++ CABAC_ENTRY(159, 0, 59, 2, 46, -21, 74, 0, 65), ++ CABAC_ENTRY(160, 22, 33, 19, 38, 16, 66, 21, 37), ++ CABAC_ENTRY(161, 5, 44, -4, 66, -23, 124, -15, 72), ++ CABAC_ENTRY(162, 14, 43, 15, 38, 17, 37, 9, 57), ++ CABAC_ENTRY(163, -1, 78, 12, 42, 44, -18, 16, 54), ++ CABAC_ENTRY(164, 0, 60, 9, 34, 50, -34, 0, 62), ++ CABAC_ENTRY(165, 9, 69, 0, 89, -22, 127, 12, 72), ++ ++ /* Table 9-20 – Values of variables m and n for ctxIdx from 166 to 226 */ ++ CABAC_ENTRY(166, 11, 28, 4, 45, 4, 39, 24, 0), ++ CABAC_ENTRY(167, 2, 40, 10, 28, 0, 42, 15, 9), ++ CABAC_ENTRY(168, 3, 44, 10, 31, 7, 34, 8, 25), ++ CABAC_ENTRY(169, 0, 49, 33, -11, 11, 29, 13, 18), ++ CABAC_ENTRY(170, 0, 46, 52, -43, 8, 31, 15, 9), ++ CABAC_ENTRY(171, 2, 44, 18, 15, 6, 37, 13, 19), ++ CABAC_ENTRY(172, 2, 51, 28, 0, 7, 42, 10, 37), ++ CABAC_ENTRY(173, 0, 47, 35, -22, 3, 40, 12, 18), ++ CABAC_ENTRY(174, 4, 39, 38, -25, 8, 33, 6, 29), ++ CABAC_ENTRY(175, 2, 62, 34, 0, 13, 43, 20, 33), ++ CABAC_ENTRY(176, 6, 46, 39, -18, 13, 36, 15, 30), ++ CABAC_ENTRY(177, 0, 54, 32, -12, 4, 47, 4, 45), ++ CABAC_ENTRY(178, 3, 54, 102, -94, 3, 55, 1, 58), ++ CABAC_ENTRY(179, 2, 58, 0, 0, 2, 58, 0, 62), ++ CABAC_ENTRY(180, 4, 63, 56, -15, 6, 60, 7, 61), ++ CABAC_ENTRY(181, 6, 51, 33, -4, 8, 44, 12, 38), ++ CABAC_ENTRY(182, 6, 57, 29, 10, 11, 44, 11, 45), ++ CABAC_ENTRY(183, 7, 53, 37, -5, 14, 42, 15, 39), ++ CABAC_ENTRY(184, 6, 52, 51, -29, 7, 48, 11, 42), ++ CABAC_ENTRY(185, 6, 55, 39, -9, 4, 56, 13, 44), ++ CABAC_ENTRY(186, 11, 45, 52, -34, 4, 52, 16, 45), ++ CABAC_ENTRY(187, 14, 36, 69, -58, 13, 37, 12, 41), ++ CABAC_ENTRY(188, 8, 53, 67, -63, 9, 49, 10, 49), ++ CABAC_ENTRY(189, -1, 82, 44, -5, 19, 58, 30, 34), ++ CABAC_ENTRY(190, 7, 55, 32, 7, 10, 48, 18, 42), ++ CABAC_ENTRY(191, -3, 78, 55, -29, 12, 45, 10, 55), ++ CABAC_ENTRY(192, 15, 46, 32, 1, 0, 69, 17, 51), ++ CABAC_ENTRY(193, 22, 31, 0, 0, 20, 33, 17, 46), ++ CABAC_ENTRY(194, -1, 84, 27, 36, 8, 63, 0, 89), ++ CABAC_ENTRY(195, 25, 7, 33, -25, 35, -18, 26, -19), ++ CABAC_ENTRY(196, 30, -7, 34, -30, 33, -25, 22, -17), ++ CABAC_ENTRY(197, 28, 3, 36, -28, 28, -3, 26, -17), ++ CABAC_ENTRY(198, 28, 4, 38, -28, 24, 10, 30, -25), ++ CABAC_ENTRY(199, 32, 0, 38, -27, 27, 0, 28, -20), ++ CABAC_ENTRY(200, 34, -1, 34, -18, 34, -14, 33, -23), ++ CABAC_ENTRY(201, 30, 6, 35, -16, 52, -44, 37, -27), ++ CABAC_ENTRY(202, 30, 6, 34, -14, 39, -24, 33, -23), ++ CABAC_ENTRY(203, 32, 9, 32, -8, 19, 17, 40, -28), ++ CABAC_ENTRY(204, 31, 19, 37, -6, 31, 25, 38, -17), ++ CABAC_ENTRY(205, 26, 27, 35, 0, 36, 29, 33, -11), ++ CABAC_ENTRY(206, 26, 30, 30, 10, 24, 33, 40, -15), ++ CABAC_ENTRY(207, 37, 20, 28, 18, 34, 15, 41, -6), ++ CABAC_ENTRY(208, 28, 34, 26, 25, 30, 20, 38, 1), ++ CABAC_ENTRY(209, 17, 70, 29, 41, 22, 73, 41, 17), ++ CABAC_ENTRY(210, 1, 67, 0, 75, 20, 34, 30, -6), ++ CABAC_ENTRY(211, 5, 59, 2, 72, 19, 31, 27, 3), ++ CABAC_ENTRY(212, 9, 67, 8, 77, 27, 44, 26, 22), ++ CABAC_ENTRY(213, 16, 30, 14, 35, 19, 16, 37, -16), ++ CABAC_ENTRY(214, 18, 32, 18, 31, 15, 36, 35, -4), ++ CABAC_ENTRY(215, 18, 35, 17, 35, 15, 36, 38, -8), ++ CABAC_ENTRY(216, 22, 29, 21, 30, 21, 28, 38, -3), ++ CABAC_ENTRY(217, 24, 31, 17, 45, 25, 21, 37, 3), ++ CABAC_ENTRY(218, 23, 38, 20, 42, 30, 20, 38, 5), ++ CABAC_ENTRY(219, 18, 43, 18, 45, 31, 12, 42, 0), ++ CABAC_ENTRY(220, 20, 41, 27, 26, 27, 16, 35, 16), ++ CABAC_ENTRY(221, 11, 63, 16, 54, 24, 42, 39, 22), ++ CABAC_ENTRY(222, 9, 59, 7, 66, 0, 93, 14, 48), ++ CABAC_ENTRY(223, 9, 64, 16, 56, 14, 56, 27, 37), ++ CABAC_ENTRY(224, -1, 94, 11, 73, 15, 57, 21, 60), ++ CABAC_ENTRY(225, -2, 89, 10, 67, 26, 38, 12, 68), ++ CABAC_ENTRY(226, -9, 108, -10, 116, -24, 127, 2, 97), ++ ++ /* Table 9-21 – Values of variables m and n for ctxIdx from 227 to 275 */ ++ CABAC_ENTRY(227, -6, 76, -23, 112, -24, 115, -3, 71), ++ CABAC_ENTRY(228, -2, 44, -15, 71, -22, 82, -6, 42), ++ CABAC_ENTRY(229, 0, 45, -7, 61, -9, 62, -5, 50), ++ CABAC_ENTRY(230, 0, 52, 0, 53, 0, 53, -3, 54), ++ CABAC_ENTRY(231, -3, 64, -5, 66, 0, 59, -2, 62), ++ CABAC_ENTRY(232, -2, 59, -11, 77, -14, 85, 0, 58), ++ CABAC_ENTRY(233, -4, 70, -9, 80, -13, 89, 1, 63), ++ CABAC_ENTRY(234, -4, 75, -9, 84, -13, 94, -2, 72), ++ CABAC_ENTRY(235, -8, 82, -10, 87, -11, 92, -1, 74), ++ CABAC_ENTRY(236, -17, 102, -34, 127, -29, 127, -9, 91), ++ CABAC_ENTRY(237, -9, 77, -21, 101, -21, 100, -5, 67), ++ CABAC_ENTRY(238, 3, 24, -3, 39, -14, 57, -5, 27), ++ CABAC_ENTRY(239, 0, 42, -5, 53, -12, 67, -3, 39), ++ CABAC_ENTRY(240, 0, 48, -7, 61, -11, 71, -2, 44), ++ CABAC_ENTRY(241, 0, 55, -11, 75, -10, 77, 0, 46), ++ CABAC_ENTRY(242, -6, 59, -15, 77, -21, 85, -16, 64), ++ CABAC_ENTRY(243, -7, 71, -17, 91, -16, 88, -8, 68), ++ CABAC_ENTRY(244, -12, 83, -25, 107, -23, 104, -10, 78), ++ CABAC_ENTRY(245, -11, 87, -25, 111, -15, 98, -6, 77), ++ CABAC_ENTRY(246, -30, 119, -28, 122, -37, 127, -10, 86), ++ CABAC_ENTRY(247, 1, 58, -11, 76, -10, 82, -12, 92), ++ CABAC_ENTRY(248, -3, 29, -10, 44, -8, 48, -15, 55), ++ CABAC_ENTRY(249, -1, 36, -10, 52, -8, 61, -10, 60), ++ CABAC_ENTRY(250, 1, 38, -10, 57, -8, 66, -6, 62), ++ CABAC_ENTRY(251, 2, 43, -9, 58, -7, 70, -4, 65), ++ CABAC_ENTRY(252, -6, 55, -16, 72, -14, 75, -12, 73), ++ CABAC_ENTRY(253, 0, 58, -7, 69, -10, 79, -8, 76), ++ CABAC_ENTRY(254, 0, 64, -4, 69, -9, 83, -7, 80), ++ CABAC_ENTRY(255, -3, 74, -5, 74, -12, 92, -9, 88), ++ CABAC_ENTRY(256, -10, 90, -9, 86, -18, 108, -17, 110), ++ CABAC_ENTRY(257, 0, 70, 2, 66, -4, 79, -11, 97), ++ CABAC_ENTRY(258, -4, 29, -9, 34, -22, 69, -20, 84), ++ CABAC_ENTRY(259, 5, 31, 1, 32, -16, 75, -11, 79), ++ CABAC_ENTRY(260, 7, 42, 11, 31, -2, 58, -6, 73), ++ CABAC_ENTRY(261, 1, 59, 5, 52, 1, 58, -4, 74), ++ CABAC_ENTRY(262, -2, 58, -2, 55, -13, 78, -13, 86), ++ CABAC_ENTRY(263, -3, 72, -2, 67, -9, 83, -13, 96), ++ CABAC_ENTRY(264, -3, 81, 0, 73, -4, 81, -11, 97), ++ CABAC_ENTRY(265, -11, 97, -8, 89, -13, 99, -19, 117), ++ CABAC_ENTRY(266, 0, 58, 3, 52, -13, 81, -8, 78), ++ CABAC_ENTRY(267, 8, 5, 7, 4, -6, 38, -5, 33), ++ CABAC_ENTRY(268, 10, 14, 10, 8, -13, 62, -4, 48), ++ CABAC_ENTRY(269, 14, 18, 17, 8, -6, 58, -2, 53), ++ CABAC_ENTRY(270, 13, 27, 16, 19, -2, 59, -3, 62), ++ CABAC_ENTRY(271, 2, 40, 3, 37, -16, 73, -13, 71), ++ CABAC_ENTRY(272, 0, 58, -1, 61, -10, 76, -10, 79), ++ CABAC_ENTRY(273, -3, 70, -5, 73, -13, 86, -12, 86), ++ CABAC_ENTRY(274, -6, 79, -1, 70, -9, 83, -13, 90), ++ CABAC_ENTRY(275, -8, 85, -4, 78, -10, 87, -14, 97), ++ ++ /* Table 9-22 – Values of variables m and n for ctxIdx from 277 to 337 */ ++ CABAC_ENTRY(277, -13, 106, -21, 126, -22, 127, -6, 93), ++ CABAC_ENTRY(278, -16, 106, -23, 124, -25, 127, -6, 84), ++ CABAC_ENTRY(279, -10, 87, -20, 110, -25, 120, -8, 79), ++ CABAC_ENTRY(280, -21, 114, -26, 126, -27, 127, 0, 66), ++ CABAC_ENTRY(281, -18, 110, -25, 124, -19, 114, -1, 71), ++ CABAC_ENTRY(282, -14, 98, -17, 105, -23, 117, 0, 62), ++ CABAC_ENTRY(283, -22, 110, -27, 121, -25, 118, -2, 60), ++ CABAC_ENTRY(284, -21, 106, -27, 117, -26, 117, -2, 59), ++ CABAC_ENTRY(285, -18, 103, -17, 102, -24, 113, -5, 75), ++ CABAC_ENTRY(286, -21, 107, -26, 117, -28, 118, -3, 62), ++ CABAC_ENTRY(287, -23, 108, -27, 116, -31, 120, -4, 58), ++ CABAC_ENTRY(288, -26, 112, -33, 122, -37, 124, -9, 66), ++ CABAC_ENTRY(289, -10, 96, -10, 95, -10, 94, -1, 79), ++ CABAC_ENTRY(290, -12, 95, -14, 100, -15, 102, 0, 71), ++ CABAC_ENTRY(291, -5, 91, -8, 95, -10, 99, 3, 68), ++ CABAC_ENTRY(292, -9, 93, -17, 111, -13, 106, 10, 44), ++ CABAC_ENTRY(293, -22, 94, -28, 114, -50, 127, -7, 62), ++ CABAC_ENTRY(294, -5, 86, -6, 89, -5, 92, 15, 36), ++ CABAC_ENTRY(295, 9, 67, -2, 80, 17, 57, 14, 40), ++ CABAC_ENTRY(296, -4, 80, -4, 82, -5, 86, 16, 27), ++ CABAC_ENTRY(297, -10, 85, -9, 85, -13, 94, 12, 29), ++ CABAC_ENTRY(298, -1, 70, -8, 81, -12, 91, 1, 44), ++ CABAC_ENTRY(299, 7, 60, -1, 72, -2, 77, 20, 36), ++ CABAC_ENTRY(300, 9, 58, 5, 64, 0, 71, 18, 32), ++ CABAC_ENTRY(301, 5, 61, 1, 67, -1, 73, 5, 42), ++ CABAC_ENTRY(302, 12, 50, 9, 56, 4, 64, 1, 48), ++ CABAC_ENTRY(303, 15, 50, 0, 69, -7, 81, 10, 62), ++ CABAC_ENTRY(304, 18, 49, 1, 69, 5, 64, 17, 46), ++ CABAC_ENTRY(305, 17, 54, 7, 69, 15, 57, 9, 64), ++ CABAC_ENTRY(306, 10, 41, -7, 69, 1, 67, -12, 104), ++ CABAC_ENTRY(307, 7, 46, -6, 67, 0, 68, -11, 97), ++ CABAC_ENTRY(308, -1, 51, -16, 77, -10, 67, -16, 96), ++ CABAC_ENTRY(309, 7, 49, -2, 64, 1, 68, -7, 88), ++ CABAC_ENTRY(310, 8, 52, 2, 61, 0, 77, -8, 85), ++ CABAC_ENTRY(311, 9, 41, -6, 67, 2, 64, -7, 85), ++ CABAC_ENTRY(312, 6, 47, -3, 64, 0, 68, -9, 85), ++ CABAC_ENTRY(313, 2, 55, 2, 57, -5, 78, -13, 88), ++ CABAC_ENTRY(314, 13, 41, -3, 65, 7, 55, 4, 66), ++ CABAC_ENTRY(315, 10, 44, -3, 66, 5, 59, -3, 77), ++ CABAC_ENTRY(316, 6, 50, 0, 62, 2, 65, -3, 76), ++ CABAC_ENTRY(317, 5, 53, 9, 51, 14, 54, -6, 76), ++ CABAC_ENTRY(318, 13, 49, -1, 66, 15, 44, 10, 58), ++ CABAC_ENTRY(319, 4, 63, -2, 71, 5, 60, -1, 76), ++ CABAC_ENTRY(320, 6, 64, -2, 75, 2, 70, -1, 83), ++ CABAC_ENTRY(321, -2, 69, -1, 70, -2, 76, -7, 99), ++ CABAC_ENTRY(322, -2, 59, -9, 72, -18, 86, -14, 95), ++ CABAC_ENTRY(323, 6, 70, 14, 60, 12, 70, 2, 95), ++ CABAC_ENTRY(324, 10, 44, 16, 37, 5, 64, 0, 76), ++ CABAC_ENTRY(325, 9, 31, 0, 47, -12, 70, -5, 74), ++ CABAC_ENTRY(326, 12, 43, 18, 35, 11, 55, 0, 70), ++ CABAC_ENTRY(327, 3, 53, 11, 37, 5, 56, -11, 75), ++ CABAC_ENTRY(328, 14, 34, 12, 41, 0, 69, 1, 68), ++ CABAC_ENTRY(329, 10, 38, 10, 41, 2, 65, 0, 65), ++ CABAC_ENTRY(330, -3, 52, 2, 48, -6, 74, -14, 73), ++ CABAC_ENTRY(331, 13, 40, 12, 41, 5, 54, 3, 62), ++ CABAC_ENTRY(332, 17, 32, 13, 41, 7, 54, 4, 62), ++ CABAC_ENTRY(333, 7, 44, 0, 59, -6, 76, -1, 68), ++ CABAC_ENTRY(334, 7, 38, 3, 50, -11, 82, -13, 75), ++ CABAC_ENTRY(335, 13, 50, 19, 40, -2, 77, 11, 55), ++ CABAC_ENTRY(336, 10, 57, 3, 66, -2, 77, 5, 64), ++ CABAC_ENTRY(337, 26, 43, 18, 50, 25, 42, 12, 70), ++ ++ /* Table 9-23 – Values of variables m and n for ctxIdx from 338 to 398 */ ++ CABAC_ENTRY(338, 14, 11, 19, -6, 17, -13, 15, 6), ++ CABAC_ENTRY(339, 11, 14, 18, -6, 16, -9, 6, 19), ++ CABAC_ENTRY(340, 9, 11, 14, 0, 17, -12, 7, 16), ++ CABAC_ENTRY(341, 18, 11, 26, -12, 27, -21, 12, 14), ++ CABAC_ENTRY(342, 21, 9, 31, -16, 37, -30, 18, 13), ++ CABAC_ENTRY(343, 23, -2, 33, -25, 41, -40, 13, 11), ++ CABAC_ENTRY(344, 32, -15, 33, -22, 42, -41, 13, 15), ++ CABAC_ENTRY(345, 32, -15, 37, -28, 48, -47, 15, 16), ++ CABAC_ENTRY(346, 34, -21, 39, -30, 39, -32, 12, 23), ++ CABAC_ENTRY(347, 39, -23, 42, -30, 46, -40, 13, 23), ++ CABAC_ENTRY(348, 42, -33, 47, -42, 52, -51, 15, 20), ++ CABAC_ENTRY(349, 41, -31, 45, -36, 46, -41, 14, 26), ++ CABAC_ENTRY(350, 46, -28, 49, -34, 52, -39, 14, 44), ++ CABAC_ENTRY(351, 38, -12, 41, -17, 43, -19, 17, 40), ++ CABAC_ENTRY(352, 21, 29, 32, 9, 32, 11, 17, 47), ++ CABAC_ENTRY(353, 45, -24, 69, -71, 61, -55, 24, 17), ++ CABAC_ENTRY(354, 53, -45, 63, -63, 56, -46, 21, 21), ++ CABAC_ENTRY(355, 48, -26, 66, -64, 62, -50, 25, 22), ++ CABAC_ENTRY(356, 65, -43, 77, -74, 81, -67, 31, 27), ++ CABAC_ENTRY(357, 43, -19, 54, -39, 45, -20, 22, 29), ++ CABAC_ENTRY(358, 39, -10, 52, -35, 35, -2, 19, 35), ++ CABAC_ENTRY(359, 30, 9, 41, -10, 28, 15, 14, 50), ++ CABAC_ENTRY(360, 18, 26, 36, 0, 34, 1, 10, 57), ++ CABAC_ENTRY(361, 20, 27, 40, -1, 39, 1, 7, 63), ++ CABAC_ENTRY(362, 0, 57, 30, 14, 30, 17, -2, 77), ++ CABAC_ENTRY(363, -14, 82, 28, 26, 20, 38, -4, 82), ++ CABAC_ENTRY(364, -5, 75, 23, 37, 18, 45, -3, 94), ++ CABAC_ENTRY(365, -19, 97, 12, 55, 15, 54, 9, 69), ++ CABAC_ENTRY(366, -35, 125, 11, 65, 0, 79, -12, 109), ++ CABAC_ENTRY(367, 27, 0, 37, -33, 36, -16, 36, -35), ++ CABAC_ENTRY(368, 28, 0, 39, -36, 37, -14, 36, -34), ++ CABAC_ENTRY(369, 31, -4, 40, -37, 37, -17, 32, -26), ++ CABAC_ENTRY(370, 27, 6, 38, -30, 32, 1, 37, -30), ++ CABAC_ENTRY(371, 34, 8, 46, -33, 34, 15, 44, -32), ++ CABAC_ENTRY(372, 30, 10, 42, -30, 29, 15, 34, -18), ++ CABAC_ENTRY(373, 24, 22, 40, -24, 24, 25, 34, -15), ++ CABAC_ENTRY(374, 33, 19, 49, -29, 34, 22, 40, -15), ++ CABAC_ENTRY(375, 22, 32, 38, -12, 31, 16, 33, -7), ++ CABAC_ENTRY(376, 26, 31, 40, -10, 35, 18, 35, -5), ++ CABAC_ENTRY(377, 21, 41, 38, -3, 31, 28, 33, 0), ++ CABAC_ENTRY(378, 26, 44, 46, -5, 33, 41, 38, 2), ++ CABAC_ENTRY(379, 23, 47, 31, 20, 36, 28, 33, 13), ++ CABAC_ENTRY(380, 16, 65, 29, 30, 27, 47, 23, 35), ++ CABAC_ENTRY(381, 14, 71, 25, 44, 21, 62, 13, 58), ++ CABAC_ENTRY(382, 8, 60, 12, 48, 18, 31, 29, -3), ++ CABAC_ENTRY(383, 6, 63, 11, 49, 19, 26, 26, 0), ++ CABAC_ENTRY(384, 17, 65, 26, 45, 36, 24, 22, 30), ++ CABAC_ENTRY(385, 21, 24, 22, 22, 24, 23, 31, -7), ++ CABAC_ENTRY(386, 23, 20, 23, 22, 27, 16, 35, -15), ++ CABAC_ENTRY(387, 26, 23, 27, 21, 24, 30, 34, -3), ++ CABAC_ENTRY(388, 27, 32, 33, 20, 31, 29, 34, 3), ++ CABAC_ENTRY(389, 28, 23, 26, 28, 22, 41, 36, -1), ++ CABAC_ENTRY(390, 28, 24, 30, 24, 22, 42, 34, 5), ++ CABAC_ENTRY(391, 23, 40, 27, 34, 16, 60, 32, 11), ++ CABAC_ENTRY(392, 24, 32, 18, 42, 15, 52, 35, 5), ++ CABAC_ENTRY(393, 28, 29, 25, 39, 14, 60, 34, 12), ++ CABAC_ENTRY(394, 23, 42, 18, 50, 3, 78, 39, 11), ++ CABAC_ENTRY(395, 19, 57, 12, 70, -16, 123, 30, 29), ++ CABAC_ENTRY(396, 22, 53, 21, 54, 21, 53, 34, 26), ++ CABAC_ENTRY(397, 22, 61, 14, 71, 22, 56, 29, 39), ++ CABAC_ENTRY(398, 11, 86, 11, 83, 25, 61, 19, 66), ++ ++ /* Values of variables m and n for ctxIdx from 399 to 463 (not documented) */ ++ CABAC_ENTRY(399, 12, 40, 25, 32, 21, 33, 31, 21), ++ CABAC_ENTRY(400, 11, 51, 21, 49, 19, 50, 31, 31), ++ CABAC_ENTRY(401, 14, 59, 21, 54, 17, 61, 25, 50), ++ CABAC_ENTRY(402, -4, 79, -5, 85, -3, 78, -17, 120), ++ CABAC_ENTRY(403, -7, 71, -6, 81, -8, 74, -20, 112), ++ CABAC_ENTRY(404, -5, 69, -10, 77, -9, 72, -18, 114), ++ CABAC_ENTRY(405, -9, 70, -7, 81, -10, 72, -11, 85), ++ CABAC_ENTRY(406, -8, 66, -17, 80, -18, 75, -15, 92), ++ CABAC_ENTRY(407, -10, 68, -18, 73, -12, 71, -14, 89), ++ CABAC_ENTRY(408, -19, 73, -4, 74, -11, 63, -26, 71), ++ CABAC_ENTRY(409, -12, 69, -10, 83, -5, 70, -15, 81), ++ CABAC_ENTRY(410, -16, 70, -9, 71, -17, 75, -14, 80), ++ CABAC_ENTRY(411, -15, 67, -9, 67, -14, 72, 0, 68), ++ CABAC_ENTRY(412, -20, 62, -1, 61, -16, 67, -14, 70), ++ CABAC_ENTRY(413, -19, 70, -8, 66, -8, 53, -24, 56), ++ CABAC_ENTRY(414, -16, 66, -14, 66, -14, 59, -23, 68), ++ CABAC_ENTRY(415, -22, 65, 0, 59, -9, 52, -24, 50), ++ CABAC_ENTRY(416, -20, 63, 2, 59, -11, 68, -11, 74), ++ CABAC_ENTRY(417, 9, -2, 17, -10, 9, -2, 23, -13), ++ CABAC_ENTRY(418, 26, -9, 32, -13, 30, -10, 26, -13), ++ CABAC_ENTRY(419, 33, -9, 42, -9, 31, -4, 40, -15), ++ CABAC_ENTRY(420, 39, -7, 49, -5, 33, -1, 49, -14), ++ CABAC_ENTRY(421, 41, -2, 53, 0, 33, 7, 44, 3), ++ CABAC_ENTRY(422, 45, 3, 64, 3, 31, 12, 45, 6), ++ CABAC_ENTRY(423, 49, 9, 68, 10, 37, 23, 44, 34), ++ CABAC_ENTRY(424, 45, 27, 66, 27, 31, 38, 33, 54), ++ CABAC_ENTRY(425, 36, 59, 47, 57, 20, 64, 19, 82), ++ CABAC_ENTRY(426, -6, 66, -5, 71, -9, 71, -3, 75), ++ CABAC_ENTRY(427, -7, 35, 0, 24, -7, 37, -1, 23), ++ CABAC_ENTRY(428, -7, 42, -1, 36, -8, 44, 1, 34), ++ CABAC_ENTRY(429, -8, 45, -2, 42, -11, 49, 1, 43), ++ CABAC_ENTRY(430, -5, 48, -2, 52, -10, 56, 0, 54), ++ CABAC_ENTRY(431, -12, 56, -9, 57, -12, 59, -2, 55), ++ CABAC_ENTRY(432, -6, 60, -6, 63, -8, 63, 0, 61), ++ CABAC_ENTRY(433, -5, 62, -4, 65, -9, 67, 1, 64), ++ CABAC_ENTRY(434, -8, 66, -4, 67, -6, 68, 0, 68), ++ CABAC_ENTRY(435, -8, 76, -7, 82, -10, 79, -9, 92), ++ CABAC_ENTRY(436, -5, 85, -3, 81, -3, 78, -14, 106), ++ CABAC_ENTRY(437, -6, 81, -3, 76, -8, 74, -13, 97), ++ CABAC_ENTRY(438, -10, 77, -7, 72, -9, 72, -15, 90), ++ CABAC_ENTRY(439, -7, 81, -6, 78, -10, 72, -12, 90), ++ CABAC_ENTRY(440, -17, 80, -12, 72, -18, 75, -18, 88), ++ CABAC_ENTRY(441, -18, 73, -14, 68, -12, 71, -10, 73), ++ CABAC_ENTRY(442, -4, 74, -3, 70, -11, 63, -9, 79), ++ CABAC_ENTRY(443, -10, 83, -6, 76, -5, 70, -14, 86), ++ CABAC_ENTRY(444, -9, 71, -5, 66, -17, 75, -10, 73), ++ CABAC_ENTRY(445, -9, 67, -5, 62, -14, 72, -10, 70), ++ CABAC_ENTRY(446, -1, 61, 0, 57, -16, 67, -10, 69), ++ CABAC_ENTRY(447, -8, 66, -4, 61, -8, 53, -5, 66), ++ CABAC_ENTRY(448, -14, 66, -9, 60, -14, 59, -9, 64), ++ CABAC_ENTRY(449, 0, 59, 1, 54, -9, 52, -5, 58), ++ CABAC_ENTRY(450, 2, 59, 2, 58, -11, 68, 2, 59), ++ CABAC_ENTRY(451, 21, -13, 17, -10, 9, -2, 21, -10), ++ CABAC_ENTRY(452, 33, -14, 32, -13, 30, -10, 24, -11), ++ CABAC_ENTRY(453, 39, -7, 42, -9, 31, -4, 28, -8), ++ CABAC_ENTRY(454, 46, -2, 49, -5, 33, -1, 28, -1), ++ CABAC_ENTRY(455, 51, 2, 53, 0, 33, 7, 29, 3), ++ CABAC_ENTRY(456, 60, 6, 64, 3, 31, 12, 29, 9), ++ CABAC_ENTRY(457, 61, 17, 68, 10, 37, 23, 35, 20), ++ CABAC_ENTRY(458, 55, 34, 66, 27, 31, 38, 29, 36), ++ CABAC_ENTRY(459, 42, 62, 47, 57, 20, 64, 14, 67), ++}; ++ ++#endif /* RKVDEC_H264_CABAC_H_ */ +diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/rkvdec/rkvdec-h264.c ++++ b/drivers/staging/media/rkvdec/rkvdec-h264.c +@@ -14,6 +14,7 @@ + + #include "rkvdec.h" + #include "rkvdec-regs.h" ++#include "rkvdec-h264-cabac.h" + + /* Size with u32 units. */ + #define RKV_CABAC_INIT_BUFFER_SIZE (3680 + 128) +@@ -117,505 +118,6 @@ struct rkvdec_h264_ctx { + struct rkvdec_h264_reflists reflists; + }; + +-#define CABAC_ENTRY(ctxidx, idc0_m, idc0_n, idc1_m, idc1_n, \ +- idc2_m, idc2_n, intra_m, intra_n) \ +- [0][(ctxidx)] = {idc0_m, idc0_n}, \ +- [1][(ctxidx)] = {idc1_m, idc1_n}, \ +- [2][(ctxidx)] = {idc2_m, idc2_n}, \ +- [3][(ctxidx)] = {intra_m, intra_n} +- +-/* +- * Constant CABAC table. +- * Built from the tables described in section '9.3.1.1 Initialisation process +- * for context variables' of the H264 spec. +- */ +-static const s8 rkvdec_h264_cabac_table[4][464][2] = { +- /* Table 9-12 – Values of variables m and n for ctxIdx from 0 to 10 */ +- CABAC_ENTRY(0, 20, -15, 20, -15, 20, -15, 20, -15), +- CABAC_ENTRY(1, 2, 54, 2, 54, 2, 54, 2, 54), +- CABAC_ENTRY(2, 3, 74, 3, 74, 3, 74, 3, 74), +- CABAC_ENTRY(3, 20, -15, 20, -15, 20, -15, 20, -15), +- CABAC_ENTRY(4, 2, 54, 2, 54, 2, 54, 2, 54), +- CABAC_ENTRY(5, 3, 74, 3, 74, 3, 74, 3, 74), +- CABAC_ENTRY(6, -28, 127, -28, 127, -28, 127, -28, 127), +- CABAC_ENTRY(7, -23, 104, -23, 104, -23, 104, -23, 104), +- CABAC_ENTRY(8, -6, 53, -6, 53, -6, 53, -6, 53), +- CABAC_ENTRY(9, -1, 54, -1, 54, -1, 54, -1, 54), +- CABAC_ENTRY(10, 7, 51, 7, 51, 7, 51, 7, 51), +- +- /* Table 9-13 – Values of variables m and n for ctxIdx from 11 to 23 */ +- CABAC_ENTRY(11, 23, 33, 22, 25, 29, 16, 0, 0), +- CABAC_ENTRY(12, 23, 2, 34, 0, 25, 0, 0, 0), +- CABAC_ENTRY(13, 21, 0, 16, 0, 14, 0, 0, 0), +- CABAC_ENTRY(14, 1, 9, -2, 9, -10, 51, 0, 0), +- CABAC_ENTRY(15, 0, 49, 4, 41, -3, 62, 0, 0), +- CABAC_ENTRY(16, -37, 118, -29, 118, -27, 99, 0, 0), +- CABAC_ENTRY(17, 5, 57, 2, 65, 26, 16, 0, 0), +- CABAC_ENTRY(18, -13, 78, -6, 71, -4, 85, 0, 0), +- CABAC_ENTRY(19, -11, 65, -13, 79, -24, 102, 0, 0), +- CABAC_ENTRY(20, 1, 62, 5, 52, 5, 57, 0, 0), +- CABAC_ENTRY(21, 12, 49, 9, 50, 6, 57, 0, 0), +- CABAC_ENTRY(22, -4, 73, -3, 70, -17, 73, 0, 0), +- CABAC_ENTRY(23, 17, 50, 10, 54, 14, 57, 0, 0), +- +- /* Table 9-14 – Values of variables m and n for ctxIdx from 24 to 39 */ +- CABAC_ENTRY(24, 18, 64, 26, 34, 20, 40, 0, 0), +- CABAC_ENTRY(25, 9, 43, 19, 22, 20, 10, 0, 0), +- CABAC_ENTRY(26, 29, 0, 40, 0, 29, 0, 0, 0), +- CABAC_ENTRY(27, 26, 67, 57, 2, 54, 0, 0, 0), +- CABAC_ENTRY(28, 16, 90, 41, 36, 37, 42, 0, 0), +- CABAC_ENTRY(29, 9, 104, 26, 69, 12, 97, 0, 0), +- CABAC_ENTRY(30, -46, 127, -45, 127, -32, 127, 0, 0), +- CABAC_ENTRY(31, -20, 104, -15, 101, -22, 117, 0, 0), +- CABAC_ENTRY(32, 1, 67, -4, 76, -2, 74, 0, 0), +- CABAC_ENTRY(33, -13, 78, -6, 71, -4, 85, 0, 0), +- CABAC_ENTRY(34, -11, 65, -13, 79, -24, 102, 0, 0), +- CABAC_ENTRY(35, 1, 62, 5, 52, 5, 57, 0, 0), +- CABAC_ENTRY(36, -6, 86, 6, 69, -6, 93, 0, 0), +- CABAC_ENTRY(37, -17, 95, -13, 90, -14, 88, 0, 0), +- CABAC_ENTRY(38, -6, 61, 0, 52, -6, 44, 0, 0), +- CABAC_ENTRY(39, 9, 45, 8, 43, 4, 55, 0, 0), +- +- /* Table 9-15 – Values of variables m and n for ctxIdx from 40 to 53 */ +- CABAC_ENTRY(40, -3, 69, -2, 69, -11, 89, 0, 0), +- CABAC_ENTRY(41, -6, 81, -5, 82, -15, 103, 0, 0), +- CABAC_ENTRY(42, -11, 96, -10, 96, -21, 116, 0, 0), +- CABAC_ENTRY(43, 6, 55, 2, 59, 19, 57, 0, 0), +- CABAC_ENTRY(44, 7, 67, 2, 75, 20, 58, 0, 0), +- CABAC_ENTRY(45, -5, 86, -3, 87, 4, 84, 0, 0), +- CABAC_ENTRY(46, 2, 88, -3, 100, 6, 96, 0, 0), +- CABAC_ENTRY(47, 0, 58, 1, 56, 1, 63, 0, 0), +- CABAC_ENTRY(48, -3, 76, -3, 74, -5, 85, 0, 0), +- CABAC_ENTRY(49, -10, 94, -6, 85, -13, 106, 0, 0), +- CABAC_ENTRY(50, 5, 54, 0, 59, 5, 63, 0, 0), +- CABAC_ENTRY(51, 4, 69, -3, 81, 6, 75, 0, 0), +- CABAC_ENTRY(52, -3, 81, -7, 86, -3, 90, 0, 0), +- CABAC_ENTRY(53, 0, 88, -5, 95, -1, 101, 0, 0), +- +- /* Table 9-16 – Values of variables m and n for ctxIdx from 54 to 59 */ +- CABAC_ENTRY(54, -7, 67, -1, 66, 3, 55, 0, 0), +- CABAC_ENTRY(55, -5, 74, -1, 77, -4, 79, 0, 0), +- CABAC_ENTRY(56, -4, 74, 1, 70, -2, 75, 0, 0), +- CABAC_ENTRY(57, -5, 80, -2, 86, -12, 97, 0, 0), +- CABAC_ENTRY(58, -7, 72, -5, 72, -7, 50, 0, 0), +- CABAC_ENTRY(59, 1, 58, 0, 61, 1, 60, 0, 0), +- +- /* Table 9-17 – Values of variables m and n for ctxIdx from 60 to 69 */ +- CABAC_ENTRY(60, 0, 41, 0, 41, 0, 41, 0, 41), +- CABAC_ENTRY(61, 0, 63, 0, 63, 0, 63, 0, 63), +- CABAC_ENTRY(62, 0, 63, 0, 63, 0, 63, 0, 63), +- CABAC_ENTRY(63, 0, 63, 0, 63, 0, 63, 0, 63), +- CABAC_ENTRY(64, -9, 83, -9, 83, -9, 83, -9, 83), +- CABAC_ENTRY(65, 4, 86, 4, 86, 4, 86, 4, 86), +- CABAC_ENTRY(66, 0, 97, 0, 97, 0, 97, 0, 97), +- CABAC_ENTRY(67, -7, 72, -7, 72, -7, 72, -7, 72), +- CABAC_ENTRY(68, 13, 41, 13, 41, 13, 41, 13, 41), +- CABAC_ENTRY(69, 3, 62, 3, 62, 3, 62, 3, 62), +- +- /* Table 9-18 – Values of variables m and n for ctxIdx from 70 to 104 */ +- CABAC_ENTRY(70, 0, 45, 13, 15, 7, 34, 0, 11), +- CABAC_ENTRY(71, -4, 78, 7, 51, -9, 88, 1, 55), +- CABAC_ENTRY(72, -3, 96, 2, 80, -20, 127, 0, 69), +- CABAC_ENTRY(73, -27, 126, -39, 127, -36, 127, -17, 127), +- CABAC_ENTRY(74, -28, 98, -18, 91, -17, 91, -13, 102), +- CABAC_ENTRY(75, -25, 101, -17, 96, -14, 95, 0, 82), +- CABAC_ENTRY(76, -23, 67, -26, 81, -25, 84, -7, 74), +- CABAC_ENTRY(77, -28, 82, -35, 98, -25, 86, -21, 107), +- CABAC_ENTRY(78, -20, 94, -24, 102, -12, 89, -27, 127), +- CABAC_ENTRY(79, -16, 83, -23, 97, -17, 91, -31, 127), +- CABAC_ENTRY(80, -22, 110, -27, 119, -31, 127, -24, 127), +- CABAC_ENTRY(81, -21, 91, -24, 99, -14, 76, -18, 95), +- CABAC_ENTRY(82, -18, 102, -21, 110, -18, 103, -27, 127), +- CABAC_ENTRY(83, -13, 93, -18, 102, -13, 90, -21, 114), +- CABAC_ENTRY(84, -29, 127, -36, 127, -37, 127, -30, 127), +- CABAC_ENTRY(85, -7, 92, 0, 80, 11, 80, -17, 123), +- CABAC_ENTRY(86, -5, 89, -5, 89, 5, 76, -12, 115), +- CABAC_ENTRY(87, -7, 96, -7, 94, 2, 84, -16, 122), +- CABAC_ENTRY(88, -13, 108, -4, 92, 5, 78, -11, 115), +- CABAC_ENTRY(89, -3, 46, 0, 39, -6, 55, -12, 63), +- CABAC_ENTRY(90, -1, 65, 0, 65, 4, 61, -2, 68), +- CABAC_ENTRY(91, -1, 57, -15, 84, -14, 83, -15, 84), +- CABAC_ENTRY(92, -9, 93, -35, 127, -37, 127, -13, 104), +- CABAC_ENTRY(93, -3, 74, -2, 73, -5, 79, -3, 70), +- CABAC_ENTRY(94, -9, 92, -12, 104, -11, 104, -8, 93), +- CABAC_ENTRY(95, -8, 87, -9, 91, -11, 91, -10, 90), +- CABAC_ENTRY(96, -23, 126, -31, 127, -30, 127, -30, 127), +- CABAC_ENTRY(97, 5, 54, 3, 55, 0, 65, -1, 74), +- CABAC_ENTRY(98, 6, 60, 7, 56, -2, 79, -6, 97), +- CABAC_ENTRY(99, 6, 59, 7, 55, 0, 72, -7, 91), +- CABAC_ENTRY(100, 6, 69, 8, 61, -4, 92, -20, 127), +- CABAC_ENTRY(101, -1, 48, -3, 53, -6, 56, -4, 56), +- CABAC_ENTRY(102, 0, 68, 0, 68, 3, 68, -5, 82), +- CABAC_ENTRY(103, -4, 69, -7, 74, -8, 71, -7, 76), +- CABAC_ENTRY(104, -8, 88, -9, 88, -13, 98, -22, 125), +- +- /* Table 9-19 – Values of variables m and n for ctxIdx from 105 to 165 */ +- CABAC_ENTRY(105, -2, 85, -13, 103, -4, 86, -7, 93), +- CABAC_ENTRY(106, -6, 78, -13, 91, -12, 88, -11, 87), +- CABAC_ENTRY(107, -1, 75, -9, 89, -5, 82, -3, 77), +- CABAC_ENTRY(108, -7, 77, -14, 92, -3, 72, -5, 71), +- CABAC_ENTRY(109, 2, 54, -8, 76, -4, 67, -4, 63), +- CABAC_ENTRY(110, 5, 50, -12, 87, -8, 72, -4, 68), +- CABAC_ENTRY(111, -3, 68, -23, 110, -16, 89, -12, 84), +- CABAC_ENTRY(112, 1, 50, -24, 105, -9, 69, -7, 62), +- CABAC_ENTRY(113, 6, 42, -10, 78, -1, 59, -7, 65), +- CABAC_ENTRY(114, -4, 81, -20, 112, 5, 66, 8, 61), +- CABAC_ENTRY(115, 1, 63, -17, 99, 4, 57, 5, 56), +- CABAC_ENTRY(116, -4, 70, -78, 127, -4, 71, -2, 66), +- CABAC_ENTRY(117, 0, 67, -70, 127, -2, 71, 1, 64), +- CABAC_ENTRY(118, 2, 57, -50, 127, 2, 58, 0, 61), +- CABAC_ENTRY(119, -2, 76, -46, 127, -1, 74, -2, 78), +- CABAC_ENTRY(120, 11, 35, -4, 66, -4, 44, 1, 50), +- CABAC_ENTRY(121, 4, 64, -5, 78, -1, 69, 7, 52), +- CABAC_ENTRY(122, 1, 61, -4, 71, 0, 62, 10, 35), +- CABAC_ENTRY(123, 11, 35, -8, 72, -7, 51, 0, 44), +- CABAC_ENTRY(124, 18, 25, 2, 59, -4, 47, 11, 38), +- CABAC_ENTRY(125, 12, 24, -1, 55, -6, 42, 1, 45), +- CABAC_ENTRY(126, 13, 29, -7, 70, -3, 41, 0, 46), +- CABAC_ENTRY(127, 13, 36, -6, 75, -6, 53, 5, 44), +- CABAC_ENTRY(128, -10, 93, -8, 89, 8, 76, 31, 17), +- CABAC_ENTRY(129, -7, 73, -34, 119, -9, 78, 1, 51), +- CABAC_ENTRY(130, -2, 73, -3, 75, -11, 83, 7, 50), +- CABAC_ENTRY(131, 13, 46, 32, 20, 9, 52, 28, 19), +- CABAC_ENTRY(132, 9, 49, 30, 22, 0, 67, 16, 33), +- CABAC_ENTRY(133, -7, 100, -44, 127, -5, 90, 14, 62), +- CABAC_ENTRY(134, 9, 53, 0, 54, 1, 67, -13, 108), +- CABAC_ENTRY(135, 2, 53, -5, 61, -15, 72, -15, 100), +- CABAC_ENTRY(136, 5, 53, 0, 58, -5, 75, -13, 101), +- CABAC_ENTRY(137, -2, 61, -1, 60, -8, 80, -13, 91), +- CABAC_ENTRY(138, 0, 56, -3, 61, -21, 83, -12, 94), +- CABAC_ENTRY(139, 0, 56, -8, 67, -21, 64, -10, 88), +- CABAC_ENTRY(140, -13, 63, -25, 84, -13, 31, -16, 84), +- CABAC_ENTRY(141, -5, 60, -14, 74, -25, 64, -10, 86), +- CABAC_ENTRY(142, -1, 62, -5, 65, -29, 94, -7, 83), +- CABAC_ENTRY(143, 4, 57, 5, 52, 9, 75, -13, 87), +- CABAC_ENTRY(144, -6, 69, 2, 57, 17, 63, -19, 94), +- CABAC_ENTRY(145, 4, 57, 0, 61, -8, 74, 1, 70), +- CABAC_ENTRY(146, 14, 39, -9, 69, -5, 35, 0, 72), +- CABAC_ENTRY(147, 4, 51, -11, 70, -2, 27, -5, 74), +- CABAC_ENTRY(148, 13, 68, 18, 55, 13, 91, 18, 59), +- CABAC_ENTRY(149, 3, 64, -4, 71, 3, 65, -8, 102), +- CABAC_ENTRY(150, 1, 61, 0, 58, -7, 69, -15, 100), +- CABAC_ENTRY(151, 9, 63, 7, 61, 8, 77, 0, 95), +- CABAC_ENTRY(152, 7, 50, 9, 41, -10, 66, -4, 75), +- CABAC_ENTRY(153, 16, 39, 18, 25, 3, 62, 2, 72), +- CABAC_ENTRY(154, 5, 44, 9, 32, -3, 68, -11, 75), +- CABAC_ENTRY(155, 4, 52, 5, 43, -20, 81, -3, 71), +- CABAC_ENTRY(156, 11, 48, 9, 47, 0, 30, 15, 46), +- CABAC_ENTRY(157, -5, 60, 0, 44, 1, 7, -13, 69), +- CABAC_ENTRY(158, -1, 59, 0, 51, -3, 23, 0, 62), +- CABAC_ENTRY(159, 0, 59, 2, 46, -21, 74, 0, 65), +- CABAC_ENTRY(160, 22, 33, 19, 38, 16, 66, 21, 37), +- CABAC_ENTRY(161, 5, 44, -4, 66, -23, 124, -15, 72), +- CABAC_ENTRY(162, 14, 43, 15, 38, 17, 37, 9, 57), +- CABAC_ENTRY(163, -1, 78, 12, 42, 44, -18, 16, 54), +- CABAC_ENTRY(164, 0, 60, 9, 34, 50, -34, 0, 62), +- CABAC_ENTRY(165, 9, 69, 0, 89, -22, 127, 12, 72), +- +- /* Table 9-20 – Values of variables m and n for ctxIdx from 166 to 226 */ +- CABAC_ENTRY(166, 11, 28, 4, 45, 4, 39, 24, 0), +- CABAC_ENTRY(167, 2, 40, 10, 28, 0, 42, 15, 9), +- CABAC_ENTRY(168, 3, 44, 10, 31, 7, 34, 8, 25), +- CABAC_ENTRY(169, 0, 49, 33, -11, 11, 29, 13, 18), +- CABAC_ENTRY(170, 0, 46, 52, -43, 8, 31, 15, 9), +- CABAC_ENTRY(171, 2, 44, 18, 15, 6, 37, 13, 19), +- CABAC_ENTRY(172, 2, 51, 28, 0, 7, 42, 10, 37), +- CABAC_ENTRY(173, 0, 47, 35, -22, 3, 40, 12, 18), +- CABAC_ENTRY(174, 4, 39, 38, -25, 8, 33, 6, 29), +- CABAC_ENTRY(175, 2, 62, 34, 0, 13, 43, 20, 33), +- CABAC_ENTRY(176, 6, 46, 39, -18, 13, 36, 15, 30), +- CABAC_ENTRY(177, 0, 54, 32, -12, 4, 47, 4, 45), +- CABAC_ENTRY(178, 3, 54, 102, -94, 3, 55, 1, 58), +- CABAC_ENTRY(179, 2, 58, 0, 0, 2, 58, 0, 62), +- CABAC_ENTRY(180, 4, 63, 56, -15, 6, 60, 7, 61), +- CABAC_ENTRY(181, 6, 51, 33, -4, 8, 44, 12, 38), +- CABAC_ENTRY(182, 6, 57, 29, 10, 11, 44, 11, 45), +- CABAC_ENTRY(183, 7, 53, 37, -5, 14, 42, 15, 39), +- CABAC_ENTRY(184, 6, 52, 51, -29, 7, 48, 11, 42), +- CABAC_ENTRY(185, 6, 55, 39, -9, 4, 56, 13, 44), +- CABAC_ENTRY(186, 11, 45, 52, -34, 4, 52, 16, 45), +- CABAC_ENTRY(187, 14, 36, 69, -58, 13, 37, 12, 41), +- CABAC_ENTRY(188, 8, 53, 67, -63, 9, 49, 10, 49), +- CABAC_ENTRY(189, -1, 82, 44, -5, 19, 58, 30, 34), +- CABAC_ENTRY(190, 7, 55, 32, 7, 10, 48, 18, 42), +- CABAC_ENTRY(191, -3, 78, 55, -29, 12, 45, 10, 55), +- CABAC_ENTRY(192, 15, 46, 32, 1, 0, 69, 17, 51), +- CABAC_ENTRY(193, 22, 31, 0, 0, 20, 33, 17, 46), +- CABAC_ENTRY(194, -1, 84, 27, 36, 8, 63, 0, 89), +- CABAC_ENTRY(195, 25, 7, 33, -25, 35, -18, 26, -19), +- CABAC_ENTRY(196, 30, -7, 34, -30, 33, -25, 22, -17), +- CABAC_ENTRY(197, 28, 3, 36, -28, 28, -3, 26, -17), +- CABAC_ENTRY(198, 28, 4, 38, -28, 24, 10, 30, -25), +- CABAC_ENTRY(199, 32, 0, 38, -27, 27, 0, 28, -20), +- CABAC_ENTRY(200, 34, -1, 34, -18, 34, -14, 33, -23), +- CABAC_ENTRY(201, 30, 6, 35, -16, 52, -44, 37, -27), +- CABAC_ENTRY(202, 30, 6, 34, -14, 39, -24, 33, -23), +- CABAC_ENTRY(203, 32, 9, 32, -8, 19, 17, 40, -28), +- CABAC_ENTRY(204, 31, 19, 37, -6, 31, 25, 38, -17), +- CABAC_ENTRY(205, 26, 27, 35, 0, 36, 29, 33, -11), +- CABAC_ENTRY(206, 26, 30, 30, 10, 24, 33, 40, -15), +- CABAC_ENTRY(207, 37, 20, 28, 18, 34, 15, 41, -6), +- CABAC_ENTRY(208, 28, 34, 26, 25, 30, 20, 38, 1), +- CABAC_ENTRY(209, 17, 70, 29, 41, 22, 73, 41, 17), +- CABAC_ENTRY(210, 1, 67, 0, 75, 20, 34, 30, -6), +- CABAC_ENTRY(211, 5, 59, 2, 72, 19, 31, 27, 3), +- CABAC_ENTRY(212, 9, 67, 8, 77, 27, 44, 26, 22), +- CABAC_ENTRY(213, 16, 30, 14, 35, 19, 16, 37, -16), +- CABAC_ENTRY(214, 18, 32, 18, 31, 15, 36, 35, -4), +- CABAC_ENTRY(215, 18, 35, 17, 35, 15, 36, 38, -8), +- CABAC_ENTRY(216, 22, 29, 21, 30, 21, 28, 38, -3), +- CABAC_ENTRY(217, 24, 31, 17, 45, 25, 21, 37, 3), +- CABAC_ENTRY(218, 23, 38, 20, 42, 30, 20, 38, 5), +- CABAC_ENTRY(219, 18, 43, 18, 45, 31, 12, 42, 0), +- CABAC_ENTRY(220, 20, 41, 27, 26, 27, 16, 35, 16), +- CABAC_ENTRY(221, 11, 63, 16, 54, 24, 42, 39, 22), +- CABAC_ENTRY(222, 9, 59, 7, 66, 0, 93, 14, 48), +- CABAC_ENTRY(223, 9, 64, 16, 56, 14, 56, 27, 37), +- CABAC_ENTRY(224, -1, 94, 11, 73, 15, 57, 21, 60), +- CABAC_ENTRY(225, -2, 89, 10, 67, 26, 38, 12, 68), +- CABAC_ENTRY(226, -9, 108, -10, 116, -24, 127, 2, 97), +- +- /* Table 9-21 – Values of variables m and n for ctxIdx from 227 to 275 */ +- CABAC_ENTRY(227, -6, 76, -23, 112, -24, 115, -3, 71), +- CABAC_ENTRY(228, -2, 44, -15, 71, -22, 82, -6, 42), +- CABAC_ENTRY(229, 0, 45, -7, 61, -9, 62, -5, 50), +- CABAC_ENTRY(230, 0, 52, 0, 53, 0, 53, -3, 54), +- CABAC_ENTRY(231, -3, 64, -5, 66, 0, 59, -2, 62), +- CABAC_ENTRY(232, -2, 59, -11, 77, -14, 85, 0, 58), +- CABAC_ENTRY(233, -4, 70, -9, 80, -13, 89, 1, 63), +- CABAC_ENTRY(234, -4, 75, -9, 84, -13, 94, -2, 72), +- CABAC_ENTRY(235, -8, 82, -10, 87, -11, 92, -1, 74), +- CABAC_ENTRY(236, -17, 102, -34, 127, -29, 127, -9, 91), +- CABAC_ENTRY(237, -9, 77, -21, 101, -21, 100, -5, 67), +- CABAC_ENTRY(238, 3, 24, -3, 39, -14, 57, -5, 27), +- CABAC_ENTRY(239, 0, 42, -5, 53, -12, 67, -3, 39), +- CABAC_ENTRY(240, 0, 48, -7, 61, -11, 71, -2, 44), +- CABAC_ENTRY(241, 0, 55, -11, 75, -10, 77, 0, 46), +- CABAC_ENTRY(242, -6, 59, -15, 77, -21, 85, -16, 64), +- CABAC_ENTRY(243, -7, 71, -17, 91, -16, 88, -8, 68), +- CABAC_ENTRY(244, -12, 83, -25, 107, -23, 104, -10, 78), +- CABAC_ENTRY(245, -11, 87, -25, 111, -15, 98, -6, 77), +- CABAC_ENTRY(246, -30, 119, -28, 122, -37, 127, -10, 86), +- CABAC_ENTRY(247, 1, 58, -11, 76, -10, 82, -12, 92), +- CABAC_ENTRY(248, -3, 29, -10, 44, -8, 48, -15, 55), +- CABAC_ENTRY(249, -1, 36, -10, 52, -8, 61, -10, 60), +- CABAC_ENTRY(250, 1, 38, -10, 57, -8, 66, -6, 62), +- CABAC_ENTRY(251, 2, 43, -9, 58, -7, 70, -4, 65), +- CABAC_ENTRY(252, -6, 55, -16, 72, -14, 75, -12, 73), +- CABAC_ENTRY(253, 0, 58, -7, 69, -10, 79, -8, 76), +- CABAC_ENTRY(254, 0, 64, -4, 69, -9, 83, -7, 80), +- CABAC_ENTRY(255, -3, 74, -5, 74, -12, 92, -9, 88), +- CABAC_ENTRY(256, -10, 90, -9, 86, -18, 108, -17, 110), +- CABAC_ENTRY(257, 0, 70, 2, 66, -4, 79, -11, 97), +- CABAC_ENTRY(258, -4, 29, -9, 34, -22, 69, -20, 84), +- CABAC_ENTRY(259, 5, 31, 1, 32, -16, 75, -11, 79), +- CABAC_ENTRY(260, 7, 42, 11, 31, -2, 58, -6, 73), +- CABAC_ENTRY(261, 1, 59, 5, 52, 1, 58, -4, 74), +- CABAC_ENTRY(262, -2, 58, -2, 55, -13, 78, -13, 86), +- CABAC_ENTRY(263, -3, 72, -2, 67, -9, 83, -13, 96), +- CABAC_ENTRY(264, -3, 81, 0, 73, -4, 81, -11, 97), +- CABAC_ENTRY(265, -11, 97, -8, 89, -13, 99, -19, 117), +- CABAC_ENTRY(266, 0, 58, 3, 52, -13, 81, -8, 78), +- CABAC_ENTRY(267, 8, 5, 7, 4, -6, 38, -5, 33), +- CABAC_ENTRY(268, 10, 14, 10, 8, -13, 62, -4, 48), +- CABAC_ENTRY(269, 14, 18, 17, 8, -6, 58, -2, 53), +- CABAC_ENTRY(270, 13, 27, 16, 19, -2, 59, -3, 62), +- CABAC_ENTRY(271, 2, 40, 3, 37, -16, 73, -13, 71), +- CABAC_ENTRY(272, 0, 58, -1, 61, -10, 76, -10, 79), +- CABAC_ENTRY(273, -3, 70, -5, 73, -13, 86, -12, 86), +- CABAC_ENTRY(274, -6, 79, -1, 70, -9, 83, -13, 90), +- CABAC_ENTRY(275, -8, 85, -4, 78, -10, 87, -14, 97), +- +- /* Table 9-22 – Values of variables m and n for ctxIdx from 277 to 337 */ +- CABAC_ENTRY(277, -13, 106, -21, 126, -22, 127, -6, 93), +- CABAC_ENTRY(278, -16, 106, -23, 124, -25, 127, -6, 84), +- CABAC_ENTRY(279, -10, 87, -20, 110, -25, 120, -8, 79), +- CABAC_ENTRY(280, -21, 114, -26, 126, -27, 127, 0, 66), +- CABAC_ENTRY(281, -18, 110, -25, 124, -19, 114, -1, 71), +- CABAC_ENTRY(282, -14, 98, -17, 105, -23, 117, 0, 62), +- CABAC_ENTRY(283, -22, 110, -27, 121, -25, 118, -2, 60), +- CABAC_ENTRY(284, -21, 106, -27, 117, -26, 117, -2, 59), +- CABAC_ENTRY(285, -18, 103, -17, 102, -24, 113, -5, 75), +- CABAC_ENTRY(286, -21, 107, -26, 117, -28, 118, -3, 62), +- CABAC_ENTRY(287, -23, 108, -27, 116, -31, 120, -4, 58), +- CABAC_ENTRY(288, -26, 112, -33, 122, -37, 124, -9, 66), +- CABAC_ENTRY(289, -10, 96, -10, 95, -10, 94, -1, 79), +- CABAC_ENTRY(290, -12, 95, -14, 100, -15, 102, 0, 71), +- CABAC_ENTRY(291, -5, 91, -8, 95, -10, 99, 3, 68), +- CABAC_ENTRY(292, -9, 93, -17, 111, -13, 106, 10, 44), +- CABAC_ENTRY(293, -22, 94, -28, 114, -50, 127, -7, 62), +- CABAC_ENTRY(294, -5, 86, -6, 89, -5, 92, 15, 36), +- CABAC_ENTRY(295, 9, 67, -2, 80, 17, 57, 14, 40), +- CABAC_ENTRY(296, -4, 80, -4, 82, -5, 86, 16, 27), +- CABAC_ENTRY(297, -10, 85, -9, 85, -13, 94, 12, 29), +- CABAC_ENTRY(298, -1, 70, -8, 81, -12, 91, 1, 44), +- CABAC_ENTRY(299, 7, 60, -1, 72, -2, 77, 20, 36), +- CABAC_ENTRY(300, 9, 58, 5, 64, 0, 71, 18, 32), +- CABAC_ENTRY(301, 5, 61, 1, 67, -1, 73, 5, 42), +- CABAC_ENTRY(302, 12, 50, 9, 56, 4, 64, 1, 48), +- CABAC_ENTRY(303, 15, 50, 0, 69, -7, 81, 10, 62), +- CABAC_ENTRY(304, 18, 49, 1, 69, 5, 64, 17, 46), +- CABAC_ENTRY(305, 17, 54, 7, 69, 15, 57, 9, 64), +- CABAC_ENTRY(306, 10, 41, -7, 69, 1, 67, -12, 104), +- CABAC_ENTRY(307, 7, 46, -6, 67, 0, 68, -11, 97), +- CABAC_ENTRY(308, -1, 51, -16, 77, -10, 67, -16, 96), +- CABAC_ENTRY(309, 7, 49, -2, 64, 1, 68, -7, 88), +- CABAC_ENTRY(310, 8, 52, 2, 61, 0, 77, -8, 85), +- CABAC_ENTRY(311, 9, 41, -6, 67, 2, 64, -7, 85), +- CABAC_ENTRY(312, 6, 47, -3, 64, 0, 68, -9, 85), +- CABAC_ENTRY(313, 2, 55, 2, 57, -5, 78, -13, 88), +- CABAC_ENTRY(314, 13, 41, -3, 65, 7, 55, 4, 66), +- CABAC_ENTRY(315, 10, 44, -3, 66, 5, 59, -3, 77), +- CABAC_ENTRY(316, 6, 50, 0, 62, 2, 65, -3, 76), +- CABAC_ENTRY(317, 5, 53, 9, 51, 14, 54, -6, 76), +- CABAC_ENTRY(318, 13, 49, -1, 66, 15, 44, 10, 58), +- CABAC_ENTRY(319, 4, 63, -2, 71, 5, 60, -1, 76), +- CABAC_ENTRY(320, 6, 64, -2, 75, 2, 70, -1, 83), +- CABAC_ENTRY(321, -2, 69, -1, 70, -2, 76, -7, 99), +- CABAC_ENTRY(322, -2, 59, -9, 72, -18, 86, -14, 95), +- CABAC_ENTRY(323, 6, 70, 14, 60, 12, 70, 2, 95), +- CABAC_ENTRY(324, 10, 44, 16, 37, 5, 64, 0, 76), +- CABAC_ENTRY(325, 9, 31, 0, 47, -12, 70, -5, 74), +- CABAC_ENTRY(326, 12, 43, 18, 35, 11, 55, 0, 70), +- CABAC_ENTRY(327, 3, 53, 11, 37, 5, 56, -11, 75), +- CABAC_ENTRY(328, 14, 34, 12, 41, 0, 69, 1, 68), +- CABAC_ENTRY(329, 10, 38, 10, 41, 2, 65, 0, 65), +- CABAC_ENTRY(330, -3, 52, 2, 48, -6, 74, -14, 73), +- CABAC_ENTRY(331, 13, 40, 12, 41, 5, 54, 3, 62), +- CABAC_ENTRY(332, 17, 32, 13, 41, 7, 54, 4, 62), +- CABAC_ENTRY(333, 7, 44, 0, 59, -6, 76, -1, 68), +- CABAC_ENTRY(334, 7, 38, 3, 50, -11, 82, -13, 75), +- CABAC_ENTRY(335, 13, 50, 19, 40, -2, 77, 11, 55), +- CABAC_ENTRY(336, 10, 57, 3, 66, -2, 77, 5, 64), +- CABAC_ENTRY(337, 26, 43, 18, 50, 25, 42, 12, 70), +- +- /* Table 9-23 – Values of variables m and n for ctxIdx from 338 to 398 */ +- CABAC_ENTRY(338, 14, 11, 19, -6, 17, -13, 15, 6), +- CABAC_ENTRY(339, 11, 14, 18, -6, 16, -9, 6, 19), +- CABAC_ENTRY(340, 9, 11, 14, 0, 17, -12, 7, 16), +- CABAC_ENTRY(341, 18, 11, 26, -12, 27, -21, 12, 14), +- CABAC_ENTRY(342, 21, 9, 31, -16, 37, -30, 18, 13), +- CABAC_ENTRY(343, 23, -2, 33, -25, 41, -40, 13, 11), +- CABAC_ENTRY(344, 32, -15, 33, -22, 42, -41, 13, 15), +- CABAC_ENTRY(345, 32, -15, 37, -28, 48, -47, 15, 16), +- CABAC_ENTRY(346, 34, -21, 39, -30, 39, -32, 12, 23), +- CABAC_ENTRY(347, 39, -23, 42, -30, 46, -40, 13, 23), +- CABAC_ENTRY(348, 42, -33, 47, -42, 52, -51, 15, 20), +- CABAC_ENTRY(349, 41, -31, 45, -36, 46, -41, 14, 26), +- CABAC_ENTRY(350, 46, -28, 49, -34, 52, -39, 14, 44), +- CABAC_ENTRY(351, 38, -12, 41, -17, 43, -19, 17, 40), +- CABAC_ENTRY(352, 21, 29, 32, 9, 32, 11, 17, 47), +- CABAC_ENTRY(353, 45, -24, 69, -71, 61, -55, 24, 17), +- CABAC_ENTRY(354, 53, -45, 63, -63, 56, -46, 21, 21), +- CABAC_ENTRY(355, 48, -26, 66, -64, 62, -50, 25, 22), +- CABAC_ENTRY(356, 65, -43, 77, -74, 81, -67, 31, 27), +- CABAC_ENTRY(357, 43, -19, 54, -39, 45, -20, 22, 29), +- CABAC_ENTRY(358, 39, -10, 52, -35, 35, -2, 19, 35), +- CABAC_ENTRY(359, 30, 9, 41, -10, 28, 15, 14, 50), +- CABAC_ENTRY(360, 18, 26, 36, 0, 34, 1, 10, 57), +- CABAC_ENTRY(361, 20, 27, 40, -1, 39, 1, 7, 63), +- CABAC_ENTRY(362, 0, 57, 30, 14, 30, 17, -2, 77), +- CABAC_ENTRY(363, -14, 82, 28, 26, 20, 38, -4, 82), +- CABAC_ENTRY(364, -5, 75, 23, 37, 18, 45, -3, 94), +- CABAC_ENTRY(365, -19, 97, 12, 55, 15, 54, 9, 69), +- CABAC_ENTRY(366, -35, 125, 11, 65, 0, 79, -12, 109), +- CABAC_ENTRY(367, 27, 0, 37, -33, 36, -16, 36, -35), +- CABAC_ENTRY(368, 28, 0, 39, -36, 37, -14, 36, -34), +- CABAC_ENTRY(369, 31, -4, 40, -37, 37, -17, 32, -26), +- CABAC_ENTRY(370, 27, 6, 38, -30, 32, 1, 37, -30), +- CABAC_ENTRY(371, 34, 8, 46, -33, 34, 15, 44, -32), +- CABAC_ENTRY(372, 30, 10, 42, -30, 29, 15, 34, -18), +- CABAC_ENTRY(373, 24, 22, 40, -24, 24, 25, 34, -15), +- CABAC_ENTRY(374, 33, 19, 49, -29, 34, 22, 40, -15), +- CABAC_ENTRY(375, 22, 32, 38, -12, 31, 16, 33, -7), +- CABAC_ENTRY(376, 26, 31, 40, -10, 35, 18, 35, -5), +- CABAC_ENTRY(377, 21, 41, 38, -3, 31, 28, 33, 0), +- CABAC_ENTRY(378, 26, 44, 46, -5, 33, 41, 38, 2), +- CABAC_ENTRY(379, 23, 47, 31, 20, 36, 28, 33, 13), +- CABAC_ENTRY(380, 16, 65, 29, 30, 27, 47, 23, 35), +- CABAC_ENTRY(381, 14, 71, 25, 44, 21, 62, 13, 58), +- CABAC_ENTRY(382, 8, 60, 12, 48, 18, 31, 29, -3), +- CABAC_ENTRY(383, 6, 63, 11, 49, 19, 26, 26, 0), +- CABAC_ENTRY(384, 17, 65, 26, 45, 36, 24, 22, 30), +- CABAC_ENTRY(385, 21, 24, 22, 22, 24, 23, 31, -7), +- CABAC_ENTRY(386, 23, 20, 23, 22, 27, 16, 35, -15), +- CABAC_ENTRY(387, 26, 23, 27, 21, 24, 30, 34, -3), +- CABAC_ENTRY(388, 27, 32, 33, 20, 31, 29, 34, 3), +- CABAC_ENTRY(389, 28, 23, 26, 28, 22, 41, 36, -1), +- CABAC_ENTRY(390, 28, 24, 30, 24, 22, 42, 34, 5), +- CABAC_ENTRY(391, 23, 40, 27, 34, 16, 60, 32, 11), +- CABAC_ENTRY(392, 24, 32, 18, 42, 15, 52, 35, 5), +- CABAC_ENTRY(393, 28, 29, 25, 39, 14, 60, 34, 12), +- CABAC_ENTRY(394, 23, 42, 18, 50, 3, 78, 39, 11), +- CABAC_ENTRY(395, 19, 57, 12, 70, -16, 123, 30, 29), +- CABAC_ENTRY(396, 22, 53, 21, 54, 21, 53, 34, 26), +- CABAC_ENTRY(397, 22, 61, 14, 71, 22, 56, 29, 39), +- CABAC_ENTRY(398, 11, 86, 11, 83, 25, 61, 19, 66), +- +- /* Values of variables m and n for ctxIdx from 399 to 463 (not documented) */ +- CABAC_ENTRY(399, 12, 40, 25, 32, 21, 33, 31, 21), +- CABAC_ENTRY(400, 11, 51, 21, 49, 19, 50, 31, 31), +- CABAC_ENTRY(401, 14, 59, 21, 54, 17, 61, 25, 50), +- CABAC_ENTRY(402, -4, 79, -5, 85, -3, 78, -17, 120), +- CABAC_ENTRY(403, -7, 71, -6, 81, -8, 74, -20, 112), +- CABAC_ENTRY(404, -5, 69, -10, 77, -9, 72, -18, 114), +- CABAC_ENTRY(405, -9, 70, -7, 81, -10, 72, -11, 85), +- CABAC_ENTRY(406, -8, 66, -17, 80, -18, 75, -15, 92), +- CABAC_ENTRY(407, -10, 68, -18, 73, -12, 71, -14, 89), +- CABAC_ENTRY(408, -19, 73, -4, 74, -11, 63, -26, 71), +- CABAC_ENTRY(409, -12, 69, -10, 83, -5, 70, -15, 81), +- CABAC_ENTRY(410, -16, 70, -9, 71, -17, 75, -14, 80), +- CABAC_ENTRY(411, -15, 67, -9, 67, -14, 72, 0, 68), +- CABAC_ENTRY(412, -20, 62, -1, 61, -16, 67, -14, 70), +- CABAC_ENTRY(413, -19, 70, -8, 66, -8, 53, -24, 56), +- CABAC_ENTRY(414, -16, 66, -14, 66, -14, 59, -23, 68), +- CABAC_ENTRY(415, -22, 65, 0, 59, -9, 52, -24, 50), +- CABAC_ENTRY(416, -20, 63, 2, 59, -11, 68, -11, 74), +- CABAC_ENTRY(417, 9, -2, 17, -10, 9, -2, 23, -13), +- CABAC_ENTRY(418, 26, -9, 32, -13, 30, -10, 26, -13), +- CABAC_ENTRY(419, 33, -9, 42, -9, 31, -4, 40, -15), +- CABAC_ENTRY(420, 39, -7, 49, -5, 33, -1, 49, -14), +- CABAC_ENTRY(421, 41, -2, 53, 0, 33, 7, 44, 3), +- CABAC_ENTRY(422, 45, 3, 64, 3, 31, 12, 45, 6), +- CABAC_ENTRY(423, 49, 9, 68, 10, 37, 23, 44, 34), +- CABAC_ENTRY(424, 45, 27, 66, 27, 31, 38, 33, 54), +- CABAC_ENTRY(425, 36, 59, 47, 57, 20, 64, 19, 82), +- CABAC_ENTRY(426, -6, 66, -5, 71, -9, 71, -3, 75), +- CABAC_ENTRY(427, -7, 35, 0, 24, -7, 37, -1, 23), +- CABAC_ENTRY(428, -7, 42, -1, 36, -8, 44, 1, 34), +- CABAC_ENTRY(429, -8, 45, -2, 42, -11, 49, 1, 43), +- CABAC_ENTRY(430, -5, 48, -2, 52, -10, 56, 0, 54), +- CABAC_ENTRY(431, -12, 56, -9, 57, -12, 59, -2, 55), +- CABAC_ENTRY(432, -6, 60, -6, 63, -8, 63, 0, 61), +- CABAC_ENTRY(433, -5, 62, -4, 65, -9, 67, 1, 64), +- CABAC_ENTRY(434, -8, 66, -4, 67, -6, 68, 0, 68), +- CABAC_ENTRY(435, -8, 76, -7, 82, -10, 79, -9, 92), +- CABAC_ENTRY(436, -5, 85, -3, 81, -3, 78, -14, 106), +- CABAC_ENTRY(437, -6, 81, -3, 76, -8, 74, -13, 97), +- CABAC_ENTRY(438, -10, 77, -7, 72, -9, 72, -15, 90), +- CABAC_ENTRY(439, -7, 81, -6, 78, -10, 72, -12, 90), +- CABAC_ENTRY(440, -17, 80, -12, 72, -18, 75, -18, 88), +- CABAC_ENTRY(441, -18, 73, -14, 68, -12, 71, -10, 73), +- CABAC_ENTRY(442, -4, 74, -3, 70, -11, 63, -9, 79), +- CABAC_ENTRY(443, -10, 83, -6, 76, -5, 70, -14, 86), +- CABAC_ENTRY(444, -9, 71, -5, 66, -17, 75, -10, 73), +- CABAC_ENTRY(445, -9, 67, -5, 62, -14, 72, -10, 70), +- CABAC_ENTRY(446, -1, 61, 0, 57, -16, 67, -10, 69), +- CABAC_ENTRY(447, -8, 66, -4, 61, -8, 53, -5, 66), +- CABAC_ENTRY(448, -14, 66, -9, 60, -14, 59, -9, 64), +- CABAC_ENTRY(449, 0, 59, 1, 54, -9, 52, -5, 58), +- CABAC_ENTRY(450, 2, 59, 2, 58, -11, 68, 2, 59), +- CABAC_ENTRY(451, 21, -13, 17, -10, 9, -2, 21, -10), +- CABAC_ENTRY(452, 33, -14, 32, -13, 30, -10, 24, -11), +- CABAC_ENTRY(453, 39, -7, 42, -9, 31, -4, 28, -8), +- CABAC_ENTRY(454, 46, -2, 49, -5, 33, -1, 28, -1), +- CABAC_ENTRY(455, 51, 2, 53, 0, 33, 7, 29, 3), +- CABAC_ENTRY(456, 60, 6, 64, 3, 31, 12, 29, 9), +- CABAC_ENTRY(457, 61, 17, 68, 10, 37, 23, 35, 20), +- CABAC_ENTRY(458, 55, 34, 66, 27, 31, 38, 29, 36), +- CABAC_ENTRY(459, 42, 62, 47, 57, 20, 64, 14, 67), +-}; +- + static void set_ps_field(u32 *buf, struct rkvdec_ps_field field, u32 value) + { + u8 bit = field.offset % 32, word = field.offset / 32; +-- +Armbian + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Detlev Casanova +Date: Thu, 20 Jun 2024 10:19:44 -0400 +Subject: media: rockchip: Introduce the rkvdec2 driver + +This driver supports the second generation of the Rockchip Video +decoder, also known as vdpu34x. +It is currently only used on the RK3588(s) SoC. + +There are 2 decoders on the RK3588 SoC that can work in pair to decode +8K video at 30 FPS but currently, only using one core at a time is +supported. + +Scheduling requests between the two cores will be implemented later. + +The core supports H264, HEVC, VP9 and AVS2 decoding but this driver +currently only supports H264. + +The driver is based on rkvdec and they may share some code in the +future. +The decision to make a different driver is mainly because rkvdec2 has +more features and can work with multiple cores. + +The registers are mapped in a struct in RAM using bitfields. It is IO +copied to the HW when all values are configured. +The decision to use such a struct instead of writing buffers one by one +is based on the following reasons: + - Rockchip cores are known to misbehave when registers are not written + in address order, + - Those cores also need the software to write all registers, even if + they are written their default values or are not related to the task + (this core will not start decoding some H264 frames if some VP9 + registers are not written to 0) + - In the future, to support multiple cores, the scheduler could be + optimized by storing the precomputed registers values and copy them + to the HW as soos as a core becomes available. + +This makes the code more readable and may bring performance improvements +in future features. + +Signed-off-by: Detlev Casanova +--- + drivers/staging/media/Kconfig | 1 + + drivers/staging/media/Makefile | 1 + + drivers/staging/media/rkvdec2/Kconfig | 15 + + drivers/staging/media/rkvdec2/Makefile | 3 + + drivers/staging/media/rkvdec2/TODO | 9 + + drivers/staging/media/rkvdec2/rkvdec2-h264.c | 739 ++++++ + drivers/staging/media/rkvdec2/rkvdec2-regs.h | 345 +++ + drivers/staging/media/rkvdec2/rkvdec2.c | 1253 ++++++++++ + drivers/staging/media/rkvdec2/rkvdec2.h | 130 + + 9 files changed, 2496 insertions(+) + +diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/Kconfig ++++ b/drivers/staging/media/Kconfig +@@ -35,6 +35,7 @@ source "drivers/staging/media/meson/vdec/Kconfig" + source "drivers/staging/media/omap4iss/Kconfig" + + source "drivers/staging/media/rkvdec/Kconfig" ++source "drivers/staging/media/rkvdec2/Kconfig" + + source "drivers/staging/media/starfive/Kconfig" + +diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile +index 111111111111..222222222222 100644 +--- a/drivers/staging/media/Makefile ++++ b/drivers/staging/media/Makefile +@@ -6,6 +6,7 @@ obj-$(CONFIG_VIDEO_MAX96712) += max96712/ + obj-$(CONFIG_VIDEO_MESON_VDEC) += meson/vdec/ + obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ + obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += rkvdec/ ++obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC2) += rkvdec2/ + obj-$(CONFIG_VIDEO_STARFIVE_CAMSS) += starfive/ + obj-$(CONFIG_VIDEO_SUNXI) += sunxi/ + obj-$(CONFIG_VIDEO_TEGRA) += tegra-video/ +diff --git a/drivers/staging/media/rkvdec2/Kconfig b/drivers/staging/media/rkvdec2/Kconfig +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/staging/media/rkvdec2/Kconfig +@@ -0,0 +1,15 @@ ++# SPDX-License-Identifier: GPL-2.0 ++config VIDEO_ROCKCHIP_VDEC2 ++ tristate "Rockchip Video Decoder driver 2" ++ depends on ARCH_ROCKCHIP || COMPILE_TEST ++ depends on VIDEO_DEV ++ select MEDIA_CONTROLLER ++ select VIDEOBUF2_DMA_CONTIG ++ select VIDEOBUF2_VMALLOC ++ select V4L2_MEM2MEM_DEV ++ select V4L2_H264 ++ help ++ Support for the Rockchip Video Decoder 2 IP present on Rockchip SoCs, ++ which accelerates video decoding. ++ To compile this driver as a module, choose M here: the module ++ will be called rockchip-vdec2. +diff --git a/drivers/staging/media/rkvdec2/Makefile b/drivers/staging/media/rkvdec2/Makefile +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/staging/media/rkvdec2/Makefile +@@ -0,0 +1,3 @@ ++obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC2) += rockchip-vdec2.o ++ ++rockchip-vdec2-y += rkvdec2.o rkvdec2-h264.o +diff --git a/drivers/staging/media/rkvdec2/TODO b/drivers/staging/media/rkvdec2/TODO +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/staging/media/rkvdec2/TODO +@@ -0,0 +1,9 @@ ++* Support for 4:2:2 and 10 bits ++* Support for rockchip IOMMU ++* Support for HEVC and VP9 are planned for this driver. ++ ++ First, the h264 backend needs to be stabilized. ++ ++* Evaluate sharing code with rkvdec ++ ++ As rkvdec is still in staging, this driver stays there as well. +diff --git a/drivers/staging/media/rkvdec2/rkvdec2-h264.c b/drivers/staging/media/rkvdec2/rkvdec2-h264.c +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/staging/media/rkvdec2/rkvdec2-h264.c +@@ -0,0 +1,739 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Rockchip Video Decoder 2 H264 backend ++ * ++ * Copyright (C) 2024 Collabora, Ltd. ++ * Detlev Casanova ++ * ++ * Based on rkvdec driver by Boris Brezillon ++ */ ++ ++#include ++#include ++ ++#include "rkvdec2.h" ++#include "rkvdec2-regs.h" ++/* This header will move to a rockchip/common folder when de-staging */ ++#include "../rkvdec/rkvdec-h264-cabac.h" ++ ++#define RKVDEC_NUM_REFLIST 3 ++ ++struct rkvdec2_h264_scaling_list { ++ u8 scaling_list_4x4[6][16]; ++ u8 scaling_list_8x8[6][64]; ++ u8 padding[128]; ++}; ++ ++struct rkvdec2_sps { ++ u16 seq_parameter_set_id: 4; ++ u16 profile_idc: 8; ++ u16 constraint_set3_flag: 1; ++ u16 chroma_format_idc: 2; ++ u16 bit_depth_luma: 3; ++ u16 bit_depth_chroma: 3; ++ u16 qpprime_y_zero_transform_bypass_flag: 1; ++ u16 log2_max_frame_num_minus4: 4; ++ u16 max_num_ref_frames: 5; ++ u16 pic_order_cnt_type: 2; ++ u16 log2_max_pic_order_cnt_lsb_minus4: 4; ++ u16 delta_pic_order_always_zero_flag: 1; ++ u16 pic_width_in_mbs: 12; ++ u16 pic_height_in_mbs: 12; ++ u16 frame_mbs_only_flag: 1; ++ u16 mb_adaptive_frame_field_flag: 1; ++ u16 direct_8x8_inference_flag: 1; ++ u16 mvc_extension_enable: 1; ++ u16 num_views: 2; ++ ++ u16 reserved_bits: 12; ++ u16 reserved[11]; ++} __packed; ++ ++struct rkvdec2_pps { ++ u16 pic_parameter_set_id: 8; ++ u16 pps_seq_parameter_set_id: 5; ++ u16 entropy_coding_mode_flag: 1; ++ u16 bottom_field_pic_order_in_frame_present_flag: 1; ++ u16 num_ref_idx_l0_default_active_minus1: 5; ++ u16 num_ref_idx_l1_default_active_minus1: 5; ++ u16 weighted_pred_flag: 1; ++ u16 weighted_bipred_idc: 2; ++ u16 pic_init_qp_minus26: 7; ++ u16 pic_init_qs_minus26: 6; ++ u16 chroma_qp_index_offset: 5; ++ u16 deblocking_filter_control_present_flag: 1; ++ u16 constrained_intra_pred_flag: 1; ++ u16 redundant_pic_cnt_present: 1; ++ u16 transform_8x8_mode_flag: 1; ++ u16 second_chroma_qp_index_offset: 5; ++ u16 scaling_list_enable_flag: 1; ++ u32 scaling_list_address; ++ u16 is_longterm; ++ ++ u8 reserved[3]; ++} __packed; ++ ++struct rkvdec2_rps_entry { ++ u32 dpb_info0: 5; ++ u32 bottom_flag0: 1; ++ u32 view_index_off0: 1; ++ u32 dpb_info1: 5; ++ u32 bottom_flag1: 1; ++ u32 view_index_off1: 1; ++ u32 dpb_info2: 5; ++ u32 bottom_flag2: 1; ++ u32 view_index_off2: 1; ++ u32 dpb_info3: 5; ++ u32 bottom_flag3: 1; ++ u32 view_index_off3: 1; ++ u32 dpb_info4: 5; ++ u32 bottom_flag4: 1; ++ u32 view_index_off4: 1; ++ u32 dpb_info5: 5; ++ u32 bottom_flag5: 1; ++ u32 view_index_off5: 1; ++ u32 dpb_info6: 5; ++ u32 bottom_flag6: 1; ++ u32 view_index_off6: 1; ++ u32 dpb_info7: 5; ++ u32 bottom_flag7: 1; ++ u32 view_index_off7: 1; ++} __packed; ++ ++struct rkvdec2_rps { ++ u16 frame_num[16]; ++ u32 reserved0; ++ struct rkvdec2_rps_entry entries[12]; ++ u32 reserved1[66]; ++} __packed; ++ ++struct rkvdec2_sps_pps { ++ struct rkvdec2_sps sps; ++ struct rkvdec2_pps pps; ++} __packed; ++ ++/* Data structure describing auxiliary buffer format. */ ++struct rkvdec2_h264_priv_tbl { ++ u32 cabac_table[928]; ++ struct rkvdec2_h264_scaling_list scaling_list; ++ struct rkvdec2_sps_pps param_set[256]; ++ struct rkvdec2_rps rps; ++}; ++ ++struct rkvdec2_h264_reflists { ++ struct v4l2_h264_reference p[V4L2_H264_REF_LIST_LEN]; ++ struct v4l2_h264_reference b0[V4L2_H264_REF_LIST_LEN]; ++ struct v4l2_h264_reference b1[V4L2_H264_REF_LIST_LEN]; ++}; ++ ++struct rkvdec2_h264_run { ++ struct rkvdec2_run base; ++ const struct v4l2_ctrl_h264_decode_params *decode_params; ++ const struct v4l2_ctrl_h264_sps *sps; ++ const struct v4l2_ctrl_h264_pps *pps; ++ const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; ++ struct vb2_buffer *ref_buf[V4L2_H264_NUM_DPB_ENTRIES]; ++}; ++ ++struct rkvdec2_h264_ctx { ++ struct rkvdec2_aux_buf priv_tbl; ++ struct rkvdec2_h264_reflists reflists; ++ struct rkvdec2_regs_h264 regs; ++}; ++ ++static void assemble_hw_pps(struct rkvdec2_ctx *ctx, ++ struct rkvdec2_h264_run *run) ++{ ++ struct rkvdec2_h264_ctx *h264_ctx = ctx->priv; ++ const struct v4l2_ctrl_h264_sps *sps = run->sps; ++ const struct v4l2_ctrl_h264_pps *pps = run->pps; ++ const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params; ++ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb; ++ struct rkvdec2_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu; ++ struct rkvdec2_sps_pps *hw_ps; ++ dma_addr_t scaling_list_address; ++ u32 scaling_distance; ++ u32 i; ++ ++ /* ++ * HW read the SPS/PPS information from PPS packet index by PPS id. ++ * offset from the base can be calculated by PPS_id * 32 (size per PPS ++ * packet unit). so the driver copy SPS/PPS information to the exact PPS ++ * packet unit for HW accessing. ++ */ ++ hw_ps = &priv_tbl->param_set[pps->pic_parameter_set_id]; ++ memset(hw_ps, 0, sizeof(*hw_ps)); ++ ++ /* write sps */ ++ hw_ps->sps.seq_parameter_set_id = 0xf; ++ hw_ps->sps.profile_idc = 0xff; ++ hw_ps->sps.constraint_set3_flag = 1; ++ hw_ps->sps.chroma_format_idc = sps->chroma_format_idc; ++ hw_ps->sps.bit_depth_luma = sps->bit_depth_luma_minus8; ++ hw_ps->sps.bit_depth_chroma = sps->bit_depth_chroma_minus8; ++ hw_ps->sps.qpprime_y_zero_transform_bypass_flag = 0; ++ hw_ps->sps.log2_max_frame_num_minus4 = sps->log2_max_frame_num_minus4; ++ hw_ps->sps.max_num_ref_frames = sps->max_num_ref_frames; ++ hw_ps->sps.pic_order_cnt_type = sps->pic_order_cnt_type; ++ hw_ps->sps.log2_max_pic_order_cnt_lsb_minus4 = ++ sps->log2_max_pic_order_cnt_lsb_minus4; ++ hw_ps->sps.delta_pic_order_always_zero_flag = ++ !!(sps->flags & V4L2_H264_SPS_FLAG_DELTA_PIC_ORDER_ALWAYS_ZERO); ++ hw_ps->sps.mvc_extension_enable = 1; ++ hw_ps->sps.num_views = 1; ++ ++ /* ++ * Use the SPS values since they are already in macroblocks ++ * dimensions, height can be field height (halved) if ++ * V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY is not set and also it allows ++ * decoding smaller images into larger allocation which can be used ++ * to implementing SVC spatial layer support. ++ */ ++ hw_ps->sps.pic_width_in_mbs = sps->pic_width_in_mbs_minus1 + 1; ++ hw_ps->sps.pic_height_in_mbs = sps->pic_height_in_map_units_minus1 + 1; ++ hw_ps->sps.frame_mbs_only_flag = ++ !!(sps->flags & V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY); ++ hw_ps->sps.mb_adaptive_frame_field_flag = ++ !!(sps->flags & V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD); ++ hw_ps->sps.direct_8x8_inference_flag = ++ !!(sps->flags & V4L2_H264_SPS_FLAG_DIRECT_8X8_INFERENCE); ++ ++ /* write pps */ ++ hw_ps->pps.pic_parameter_set_id = 0xff; ++ hw_ps->pps.pps_seq_parameter_set_id = 0x1f; ++ hw_ps->pps.entropy_coding_mode_flag = ++ !!(pps->flags & V4L2_H264_PPS_FLAG_ENTROPY_CODING_MODE); ++ hw_ps->pps.bottom_field_pic_order_in_frame_present_flag = ++ !!(pps->flags & V4L2_H264_PPS_FLAG_BOTTOM_FIELD_PIC_ORDER_IN_FRAME_PRESENT); ++ hw_ps->pps.num_ref_idx_l0_default_active_minus1 = ++ pps->num_ref_idx_l0_default_active_minus1; ++ hw_ps->pps.num_ref_idx_l1_default_active_minus1 = ++ pps->num_ref_idx_l1_default_active_minus1; ++ hw_ps->pps.weighted_pred_flag = ++ !!(pps->flags & V4L2_H264_PPS_FLAG_WEIGHTED_PRED); ++ hw_ps->pps.weighted_bipred_idc = pps->weighted_bipred_idc; ++ hw_ps->pps.pic_init_qp_minus26 = pps->pic_init_qp_minus26; ++ hw_ps->pps.pic_init_qs_minus26 = pps->pic_init_qs_minus26; ++ hw_ps->pps.chroma_qp_index_offset = pps->chroma_qp_index_offset; ++ hw_ps->pps.deblocking_filter_control_present_flag = ++ !!(pps->flags & V4L2_H264_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT); ++ hw_ps->pps.constrained_intra_pred_flag = ++ !!(pps->flags & V4L2_H264_PPS_FLAG_CONSTRAINED_INTRA_PRED); ++ hw_ps->pps.redundant_pic_cnt_present = ++ !!(pps->flags & V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT); ++ hw_ps->pps.transform_8x8_mode_flag = ++ !!(pps->flags & V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE); ++ hw_ps->pps.second_chroma_qp_index_offset = pps->second_chroma_qp_index_offset; ++ hw_ps->pps.scaling_list_enable_flag = ++ !!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT); ++ ++ /* ++ * To be on the safe side, program the scaling matrix address ++ * ++ * With this set here, ++ * RKVDEC_SWREG12_SENCODARY_EN:sw_scanlist_addr_valid_en ++ * can stay at 0 ++ */ ++ scaling_distance = offsetof(struct rkvdec2_h264_priv_tbl, scaling_list); ++ scaling_list_address = h264_ctx->priv_tbl.dma + scaling_distance; ++ hw_ps->pps.scaling_list_address = scaling_list_address; ++ ++ for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { ++ if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) ++ hw_ps->pps.is_longterm |= (1 << i); ++ } ++} ++ ++static void lookup_ref_buf_idx(struct rkvdec2_ctx *ctx, ++ struct rkvdec2_h264_run *run) ++{ ++ const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params; ++ u32 i; ++ ++ for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { ++ struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; ++ const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; ++ struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; ++ struct vb2_buffer *buf = NULL; ++ ++ if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) { ++ buf = vb2_find_buffer(cap_q, dpb[i].reference_ts); ++ if (!buf) { ++ dev_dbg(ctx->dev->dev, "No buffer for reference_ts %llu", ++ dpb[i].reference_ts); ++ } ++ } ++ ++ run->ref_buf[i] = buf; ++ } ++} ++ ++static void set_dpb_info(struct rkvdec2_rps_entry *entries, ++ u8 reflist, ++ u8 refnum, ++ u8 info, ++ bool bottom) ++{ ++ struct rkvdec2_rps_entry *entry = &entries[(reflist * 4) + refnum / 8]; ++ u8 idx = refnum % 8; ++ ++ switch (idx) { ++ case 0: ++ entry->dpb_info0 = info; ++ entry->bottom_flag0 = bottom; ++ break; ++ case 1: ++ entry->dpb_info1 = info; ++ entry->bottom_flag1 = bottom; ++ break; ++ case 2: ++ entry->dpb_info2 = info; ++ entry->bottom_flag2 = bottom; ++ break; ++ case 3: ++ entry->dpb_info3 = info; ++ entry->bottom_flag3 = bottom; ++ break; ++ case 4: ++ entry->dpb_info4 = info; ++ entry->bottom_flag4 = bottom; ++ break; ++ case 5: ++ entry->dpb_info5 = info; ++ entry->bottom_flag5 = bottom; ++ break; ++ case 6: ++ entry->dpb_info6 = info; ++ entry->bottom_flag6 = bottom; ++ break; ++ case 7: ++ entry->dpb_info7 = info; ++ entry->bottom_flag7 = bottom; ++ break; ++ } ++} ++ ++static void assemble_hw_rps(struct rkvdec2_ctx *ctx, ++ struct v4l2_h264_reflist_builder *builder, ++ struct rkvdec2_h264_run *run) ++{ ++ const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params; ++ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb; ++ struct rkvdec2_h264_ctx *h264_ctx = ctx->priv; ++ struct rkvdec2_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu; ++ ++ struct rkvdec2_rps *hw_rps = &priv_tbl->rps; ++ u32 i, j; ++ ++ memset(hw_rps, 0, sizeof(priv_tbl->rps)); ++ ++ /* ++ * Assign an invalid pic_num if DPB entry at that position is inactive. ++ * If we assign 0 in that position hardware will treat that as a real ++ * reference picture with pic_num 0, triggering output picture ++ * corruption. ++ */ ++ for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { ++ if (!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) ++ continue; ++ ++ hw_rps->frame_num[i] = builder->refs[i].frame_num; ++ } ++ ++ for (j = 0; j < RKVDEC_NUM_REFLIST; j++) { ++ for (i = 0; i < builder->num_valid; i++) { ++ struct v4l2_h264_reference *ref; ++ bool dpb_valid; ++ bool bottom; ++ ++ switch (j) { ++ case 0: ++ ref = &h264_ctx->reflists.p[i]; ++ break; ++ case 1: ++ ref = &h264_ctx->reflists.b0[i]; ++ break; ++ case 2: ++ ref = &h264_ctx->reflists.b1[i]; ++ break; ++ } ++ ++ if (WARN_ON(ref->index >= ARRAY_SIZE(dec_params->dpb))) ++ continue; ++ ++ dpb_valid = !!(run->ref_buf[ref->index]); ++ bottom = ref->fields == V4L2_H264_BOTTOM_FIELD_REF; ++ ++ set_dpb_info(hw_rps->entries, j, i, ref->index | (dpb_valid << 4), bottom); ++ } ++ } ++} ++ ++static void assemble_hw_scaling_list(struct rkvdec2_ctx *ctx, ++ struct rkvdec2_h264_run *run) ++{ ++ const struct v4l2_ctrl_h264_scaling_matrix *scaling = run->scaling_matrix; ++ const struct v4l2_ctrl_h264_pps *pps = run->pps; ++ struct rkvdec2_h264_ctx *h264_ctx = ctx->priv; ++ struct rkvdec2_h264_priv_tbl *tbl = h264_ctx->priv_tbl.cpu; ++ ++ if (!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT)) ++ return; ++ ++ BUILD_BUG_ON(sizeof(tbl->scaling_list.scaling_list_4x4) != ++ sizeof(scaling->scaling_list_4x4)); ++ BUILD_BUG_ON(sizeof(tbl->scaling_list.scaling_list_8x8) != ++ sizeof(scaling->scaling_list_8x8)); ++ ++ memcpy(tbl->scaling_list.scaling_list_4x4, ++ scaling->scaling_list_4x4, ++ sizeof(scaling->scaling_list_4x4)); ++ ++ memcpy(tbl->scaling_list.scaling_list_8x8, ++ scaling->scaling_list_8x8, ++ sizeof(scaling->scaling_list_8x8)); ++} ++ ++static inline void rkvdec2_memcpy_toio(void __iomem *dst, void *src, size_t len) ++{ ++#ifdef CONFIG_ARM64 ++ __iowrite32_copy(dst, src, len); ++#elif defined(CONFIG_ARM) ++ memcpy_toio(dst, src, len); ++#endif ++} ++ ++static void rkvdec2_write_regs(struct rkvdec2_ctx *ctx) ++{ ++ struct rkvdec2_dev *rkvdec = ctx->dev; ++ struct rkvdec2_h264_ctx *h264_ctx = ctx->priv; ++ ++ rkvdec2_memcpy_toio(rkvdec->regs + OFFSET_COMMON_REGS, ++ &h264_ctx->regs.common, ++ sizeof(h264_ctx->regs.common)); ++ rkvdec2_memcpy_toio(rkvdec->regs + OFFSET_CODEC_PARAMS_REGS, ++ &h264_ctx->regs.h264_param, ++ sizeof(h264_ctx->regs.h264_param)); ++ rkvdec2_memcpy_toio(rkvdec->regs + OFFSET_COMMON_ADDR_REGS, ++ &h264_ctx->regs.common_addr, ++ sizeof(h264_ctx->regs.common_addr)); ++ rkvdec2_memcpy_toio(rkvdec->regs + OFFSET_CODEC_ADDR_REGS, ++ &h264_ctx->regs.h264_addr, ++ sizeof(h264_ctx->regs.h264_addr)); ++ rkvdec2_memcpy_toio(rkvdec->regs + OFFSET_POC_HIGHBIT_REGS, ++ &h264_ctx->regs.h264_highpoc, ++ sizeof(h264_ctx->regs.h264_highpoc)); ++} ++ ++static void config_registers(struct rkvdec2_ctx *ctx, ++ struct rkvdec2_h264_run *run) ++{ ++ const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params; ++ const struct v4l2_ctrl_h264_sps *sps = run->sps; ++ const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb; ++ struct rkvdec2_h264_ctx *h264_ctx = ctx->priv; ++ dma_addr_t priv_start_addr = h264_ctx->priv_tbl.dma; ++ const struct v4l2_pix_format_mplane *dst_fmt; ++ struct vb2_v4l2_buffer *src_buf = run->base.bufs.src; ++ struct vb2_v4l2_buffer *dst_buf = run->base.bufs.dst; ++ struct rkvdec2_regs_h264 *regs = &h264_ctx->regs; ++ const struct v4l2_format *f; ++ dma_addr_t rlc_addr; ++ dma_addr_t dst_addr; ++ u32 hor_virstride = 0; ++ u32 ver_virstride = 0; ++ u32 y_virstride = 0; ++ u32 offset; ++ u32 pixels; ++ u32 i; ++ ++ memset(regs, 0, sizeof(*regs)); ++ ++ /* Set H264 mode */ ++ regs->common.reg009.dec_mode = RKVDEC2_MODE_H264; ++ ++ /* Set config */ ++ regs->common.reg011.buf_empty_en = 1; ++ regs->common.reg011.dec_clkgate_e = 1; ++ regs->common.reg011.dec_timeout_e = 1; ++ regs->common.reg011.pix_range_detection_e = 1; ++ ++ /* Set IDR flag */ ++ regs->common.reg013.cur_pic_is_idr = ++ !!(dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC); ++ ++ /* Set input stream length */ ++ regs->common.stream_len = vb2_get_plane_payload(&src_buf->vb2_buf, 0); ++ ++ /* Set max slice number */ ++ regs->common.reg017.slice_num = MAX_SLICE_NUMBER; ++ ++ /* Set strides */ ++ f = &ctx->decoded_fmt; ++ dst_fmt = &f->fmt.pix_mp; ++ hor_virstride = (sps->bit_depth_luma_minus8 + 8) * dst_fmt->width / 8; ++ ver_virstride = round_up(dst_fmt->height, 16); ++ y_virstride = hor_virstride * ver_virstride; ++ pixels = dst_fmt->height * dst_fmt->width; ++ ++ regs->common.reg018.y_hor_virstride = hor_virstride / 16; ++ regs->common.reg019.uv_hor_virstride = hor_virstride / 16; ++ regs->common.reg020.y_virstride = y_virstride / 16; ++ ++ /* Activate block gating */ ++ regs->common.reg026.swreg_block_gating_e = 0xfffef; ++ regs->common.reg026.reg_cfg_gating_en = 1; ++ ++ /* Set timeout threshold */ ++ if (pixels < RKVDEC2_1080P_PIXELS) ++ regs->common.timeout_threshold = RKVDEC2_TIMEOUT_1080p; ++ else if (pixels < RKVDEC2_4K_PIXELS) ++ regs->common.timeout_threshold = RKVDEC2_TIMEOUT_4K; ++ else if (pixels < RKVDEC2_8K_PIXELS) ++ regs->common.timeout_threshold = RKVDEC2_TIMEOUT_8K; ++ ++ /* Set TOP and BOTTOM POCs */ ++ regs->h264_param.cur_top_poc = dec_params->top_field_order_cnt; ++ regs->h264_param.cur_bot_poc = dec_params->bottom_field_order_cnt; ++ ++ /* Set ref pic address & poc */ ++ for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { ++ struct vb2_buffer *vb_buf = run->ref_buf[i]; ++ dma_addr_t buf_dma; ++ ++ /* ++ * If a DPB entry is unused or invalid, address of current destination ++ * buffer is returned. ++ */ ++ if (!vb_buf) ++ vb_buf = &dst_buf->vb2_buf; ++ ++ buf_dma = vb2_dma_contig_plane_dma_addr(vb_buf, 0); ++ ++ /* Set reference addresses */ ++ regs->h264_addr.ref_base[i] = buf_dma; ++ ++ /* Set COLMV addresses */ ++ regs->h264_addr.colmv_base[i] = buf_dma + ctx->colmv_offset; ++ ++ struct rkvdec2_h264_ref_info *ref_info = ++ ®s->h264_param.ref_info_regs[i / 4].ref_info[i % 4]; ++ ++ ref_info->ref_field = ++ !!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_FIELD); ++ ref_info->ref_colmv_use_flag = ++ !!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE); ++ ref_info->ref_topfield_used = ++ !!(dpb[i].fields & V4L2_H264_TOP_FIELD_REF); ++ ref_info->ref_botfield_used = ++ !!(dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF); ++ ++ regs->h264_param.ref_pocs[i * 2] = ++ dpb[i].top_field_order_cnt; ++ regs->h264_param.ref_pocs[i * 2 + 1] = ++ dpb[i].bottom_field_order_cnt; ++ } ++ ++ /* Set rlc base address (input stream) */ ++ rlc_addr = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0); ++ regs->common_addr.rlc_base = rlc_addr; ++ regs->common_addr.rlcwrite_base = rlc_addr; ++ ++ /* Set output base address */ ++ dst_addr = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0); ++ regs->common_addr.decout_base = dst_addr; ++ ++ /* Set colmv address */ ++ regs->common_addr.colmv_cur_base = dst_addr + ctx->colmv_offset; ++ ++ /* Set RCB addresses */ ++ for (i = 0; i < RKVDEC2_RCB_COUNT; i++) ++ regs->common_addr.rcb_base[i] = ctx->rcb_bufs[i].dma; ++ ++ /* Set hw pps address */ ++ offset = offsetof(struct rkvdec2_h264_priv_tbl, param_set); ++ regs->h264_addr.pps_base = priv_start_addr + offset; ++ ++ /* Set hw rps address */ ++ offset = offsetof(struct rkvdec2_h264_priv_tbl, rps); ++ regs->h264_addr.rps_base = priv_start_addr + offset; ++ ++ /* Set cabac table */ ++ offset = offsetof(struct rkvdec2_h264_priv_tbl, cabac_table); ++ regs->h264_addr.cabactbl_base = priv_start_addr + offset; ++ ++ rkvdec2_write_regs(ctx); ++} ++ ++#define RKVDEC_H264_MAX_DEPTH_IN_BYTES 2 ++ ++static int rkvdec2_h264_adjust_fmt(struct rkvdec2_ctx *ctx, ++ struct v4l2_format *f) ++{ ++ struct v4l2_pix_format_mplane *fmt = &f->fmt.pix_mp; ++ ++ fmt->num_planes = 1; ++ if (!fmt->plane_fmt[0].sizeimage) ++ fmt->plane_fmt[0].sizeimage = fmt->width * fmt->height * ++ RKVDEC_H264_MAX_DEPTH_IN_BYTES; ++ return 0; ++} ++ ++static int rkvdec2_h264_validate_sps(struct rkvdec2_ctx *ctx, ++ const struct v4l2_ctrl_h264_sps *sps) ++{ ++ unsigned int width, height; ++ ++ /* ++ * TODO: The hardware supports 10-bit and 4:2:2 profiles, ++ * but it's currently broken in the driver. ++ * Reject them for now, until it's fixed. ++ */ ++ if (sps->chroma_format_idc > 1) ++ /* Only 4:0:0 and 4:2:0 are supported */ ++ return -EINVAL; ++ if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8) ++ /* Luma and chroma bit depth mismatch */ ++ return -EINVAL; ++ if (sps->bit_depth_luma_minus8 != 0) ++ /* Only 8-bit is supported */ ++ return -EINVAL; ++ ++ width = (sps->pic_width_in_mbs_minus1 + 1) * 16; ++ height = (sps->pic_height_in_map_units_minus1 + 1) * 16; ++ ++ /* ++ * When frame_mbs_only_flag is not set, this is field height, ++ * which is half the final height (see (7-8) in the ++ * specification) ++ */ ++ if (!(sps->flags & V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY)) ++ height *= 2; ++ ++ if (width > ctx->coded_fmt.fmt.pix_mp.width || ++ height > ctx->coded_fmt.fmt.pix_mp.height) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static int rkvdec2_h264_start(struct rkvdec2_ctx *ctx) ++{ ++ struct rkvdec2_dev *rkvdec = ctx->dev; ++ struct rkvdec2_h264_priv_tbl *priv_tbl; ++ struct rkvdec2_h264_ctx *h264_ctx; ++ struct v4l2_ctrl *ctrl; ++ int ret; ++ ++ ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl, ++ V4L2_CID_STATELESS_H264_SPS); ++ if (!ctrl) ++ return -EINVAL; ++ ++ ret = rkvdec2_h264_validate_sps(ctx, ctrl->p_new.p_h264_sps); ++ if (ret) ++ return ret; ++ ++ h264_ctx = kzalloc(sizeof(*h264_ctx), GFP_KERNEL); ++ if (!h264_ctx) ++ return -ENOMEM; ++ ++ priv_tbl = dma_alloc_coherent(rkvdec->dev, sizeof(*priv_tbl), ++ &h264_ctx->priv_tbl.dma, GFP_KERNEL); ++ if (!priv_tbl) { ++ ret = -ENOMEM; ++ goto err_free_ctx; ++ } ++ ++ h264_ctx->priv_tbl.size = sizeof(*priv_tbl); ++ h264_ctx->priv_tbl.cpu = priv_tbl; ++ memcpy(priv_tbl->cabac_table, rkvdec_h264_cabac_table, ++ sizeof(rkvdec_h264_cabac_table)); ++ ++ ctx->priv = h264_ctx; ++ return 0; ++ ++err_free_ctx: ++ kfree(h264_ctx); ++ return ret; ++} ++ ++static void rkvdec2_h264_stop(struct rkvdec2_ctx *ctx) ++{ ++ struct rkvdec2_h264_ctx *h264_ctx = ctx->priv; ++ struct rkvdec2_dev *rkvdec = ctx->dev; ++ ++ dma_free_coherent(rkvdec->dev, h264_ctx->priv_tbl.size, ++ h264_ctx->priv_tbl.cpu, h264_ctx->priv_tbl.dma); ++ kfree(h264_ctx); ++} ++ ++static void rkvdec2_h264_run_preamble(struct rkvdec2_ctx *ctx, ++ struct rkvdec2_h264_run *run) ++{ ++ struct v4l2_ctrl *ctrl; ++ ++ ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl, ++ V4L2_CID_STATELESS_H264_DECODE_PARAMS); ++ run->decode_params = ctrl ? ctrl->p_cur.p : NULL; ++ ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl, ++ V4L2_CID_STATELESS_H264_SPS); ++ run->sps = ctrl ? ctrl->p_cur.p : NULL; ++ ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl, ++ V4L2_CID_STATELESS_H264_PPS); ++ run->pps = ctrl ? ctrl->p_cur.p : NULL; ++ ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl, ++ V4L2_CID_STATELESS_H264_SCALING_MATRIX); ++ run->scaling_matrix = ctrl ? ctrl->p_cur.p : NULL; ++ ++ rkvdec2_run_preamble(ctx, &run->base); ++} ++ ++static int rkvdec2_h264_run(struct rkvdec2_ctx *ctx) ++{ ++ struct v4l2_h264_reflist_builder reflist_builder; ++ struct rkvdec2_dev *rkvdec = ctx->dev; ++ struct rkvdec2_h264_ctx *h264_ctx = ctx->priv; ++ struct rkvdec2_h264_run run; ++ ++ rkvdec2_h264_run_preamble(ctx, &run); ++ ++ /* Build the P/B{0,1} ref lists. */ ++ v4l2_h264_init_reflist_builder(&reflist_builder, run.decode_params, ++ run.sps, run.decode_params->dpb); ++ v4l2_h264_build_p_ref_list(&reflist_builder, h264_ctx->reflists.p); ++ v4l2_h264_build_b_ref_lists(&reflist_builder, h264_ctx->reflists.b0, ++ h264_ctx->reflists.b1); ++ ++ assemble_hw_scaling_list(ctx, &run); ++ assemble_hw_pps(ctx, &run); ++ lookup_ref_buf_idx(ctx, &run); ++ assemble_hw_rps(ctx, &reflist_builder, &run); ++ ++ config_registers(ctx, &run); ++ ++ rkvdec2_run_postamble(ctx, &run.base); ++ ++ schedule_delayed_work(&rkvdec->watchdog_work, msecs_to_jiffies(2000)); ++ ++ /* Start decoding! */ ++ writel(RKVDEC2_REG_DEC_E_BIT, rkvdec->regs + RKVDEC2_REG_DEC_E); ++ ++ return 0; ++} ++ ++static int rkvdec2_h264_try_ctrl(struct rkvdec2_ctx *ctx, struct v4l2_ctrl *ctrl) ++{ ++ if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) ++ return rkvdec2_h264_validate_sps(ctx, ctrl->p_new.p_h264_sps); ++ ++ return 0; ++} ++ ++const struct rkvdec2_coded_fmt_ops rkvdec2_h264_fmt_ops = { ++ .adjust_fmt = rkvdec2_h264_adjust_fmt, ++ .start = rkvdec2_h264_start, ++ .stop = rkvdec2_h264_stop, ++ .run = rkvdec2_h264_run, ++ .try_ctrl = rkvdec2_h264_try_ctrl, ++}; +diff --git a/drivers/staging/media/rkvdec2/rkvdec2-regs.h b/drivers/staging/media/rkvdec2/rkvdec2-regs.h +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/staging/media/rkvdec2/rkvdec2-regs.h +@@ -0,0 +1,345 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * Rockchip Video Decoder 2 driver registers description ++ * ++ * Copyright (C) 2024 Collabora, Ltd. ++ * Detlev Casanova ++ */ ++ ++#ifndef _RKVDEC_REGS_H_ ++#define _RKVDEC_REGS_H_ ++ ++#define OFFSET_COMMON_REGS (8 * sizeof(u32)) ++#define OFFSET_CODEC_PARAMS_REGS (64 * sizeof(u32)) ++#define OFFSET_COMMON_ADDR_REGS (128 * sizeof(u32)) ++#define OFFSET_CODEC_ADDR_REGS (160 * sizeof(u32)) ++#define OFFSET_POC_HIGHBIT_REGS (200 * sizeof(u32)) ++ ++#define RKVDEC2_MODE_HEVC 0 ++#define RKVDEC2_MODE_H264 1 ++#define RKVDEC2_MODE_VP9 2 ++#define RKVDEC2_MODE_AVS2 3 ++ ++#define MAX_SLICE_NUMBER 0x3fff ++ ++#define RKVDEC2_1080P_PIXELS (1920 * 1080) ++#define RKVDEC2_4K_PIXELS (4096 * 2304) ++#define RKVDEC2_8K_PIXELS (7680 * 4320) ++#define RKVDEC2_TIMEOUT_1080p (0xefffff) ++#define RKVDEC2_TIMEOUT_4K (0x2cfffff) ++#define RKVDEC2_TIMEOUT_8K (0x4ffffff) ++ ++#define RKVDEC2_REG_DEC_E 0x028 ++#define RKVDEC2_REG_DEC_E_BIT 1 ++ ++#define RKVDEC2_REG_IMPORTANT_EN 0x02c ++#define RKVDEC2_REG_DEC_IRQ_DISABLE BIT(4) ++ ++#define RKVDEC2_REG_STA_INT 0x380 ++#define STA_INT_DEC_RDY_STA BIT(2) ++ ++/* base: OFFSET_COMMON_REGS */ ++struct rkvdec2_regs_common { ++ struct rkvdec2_in_out { ++ u32 in_endian : 1; ++ u32 in_swap32_e : 1; ++ u32 in_swap64_e : 1; ++ u32 str_endian : 1; ++ u32 str_swap32_e : 1; ++ u32 str_swap64_e : 1; ++ u32 out_endian : 1; ++ u32 out_swap32_e : 1; ++ u32 out_cbcr_swap : 1; ++ u32 out_swap64_e : 1; ++ u32 reserved : 22; ++ } reg008; ++ ++ struct rkvdec2_dec_mode { ++ u32 dec_mode : 10; ++ u32 reserved : 22; ++ } reg009; ++ ++ struct rkvdec2_dec_e { ++ u32 dec_e : 1; ++ u32 reserved : 31; ++ } reg010; ++ ++ struct rkvdec2_important_en { ++ u32 reserved : 1; ++ u32 dec_clkgate_e : 1; ++ u32 dec_e_strmd_clkgate_dis : 1; ++ u32 reserved0 : 1; ++ ++ u32 dec_irq_dis : 1; ++ u32 dec_timeout_e : 1; ++ u32 buf_empty_en : 1; ++ u32 reserved1 : 3; ++ ++ u32 dec_e_rewrite_valid : 1; ++ u32 reserved2 : 9; ++ u32 softrst_en_p : 1; ++ u32 force_softreset_valid : 1; ++ u32 reserved3 : 2; ++ u32 pix_range_detection_e : 1; ++ u32 reserved4 : 7; ++ } reg011; ++ ++ struct rkvdec2_sencodary_en { ++ u32 wr_ddr_align_en : 1; ++ u32 colmv_compress_en : 1; ++ u32 fbc_e : 1; ++ u32 reserved0 : 1; ++ ++ u32 buspr_slot_disable : 1; ++ u32 error_info_en : 1; ++ u32 info_collect_en : 1; ++ u32 wait_reset_en : 1; ++ ++ u32 scanlist_addr_valid_en : 1; ++ u32 scale_down_en : 1; ++ u32 error_cfg_wr_disable : 1; ++ u32 reserved1 : 21; ++ } reg012; ++ ++ struct rkvdec2_en_mode_set { ++ u32 timeout_mode : 1; ++ u32 req_timeout_rst_sel : 1; ++ u32 reserved0 : 1; ++ u32 dec_commonirq_mode : 1; ++ u32 reserved1 : 2; ++ u32 stmerror_waitdecfifo_empty : 1; ++ u32 reserved2 : 2; ++ u32 h26x_streamd_error_mode : 1; ++ u32 reserved3 : 2; ++ u32 allow_not_wr_unref_bframe : 1; ++ u32 fbc_output_wr_disable : 1; ++ u32 reserved4 : 1; ++ u32 colmv_error_mode : 1; ++ ++ u32 reserved5 : 2; ++ u32 h26x_error_mode : 1; ++ u32 reserved6 : 2; ++ u32 ycacherd_prior : 1; ++ u32 reserved7 : 2; ++ u32 cur_pic_is_idr : 1; ++ u32 reserved8 : 1; ++ u32 right_auto_rst_disable : 1; ++ u32 frame_end_err_rst_flag : 1; ++ u32 rd_prior_mode : 1; ++ u32 rd_ctrl_prior_mode : 1; ++ u32 reserved9 : 1; ++ u32 filter_outbuf_mode : 1; ++ } reg013; ++ ++ struct rkvdec2_fbc_param_set { ++ u32 fbc_force_uncompress : 1; ++ ++ u32 reserved0 : 2; ++ u32 allow_16x8_cp_flag : 1; ++ u32 reserved1 : 2; ++ ++ u32 fbc_h264_exten_4or8_flag : 1; ++ u32 reserved2 : 25; ++ } reg014; ++ ++ struct rkvdec2_stream_param_set { ++ u32 rlc_mode_direct_write : 1; ++ u32 rlc_mode : 1; ++ u32 reserved0 : 3; ++ ++ u32 strm_start_bit : 7; ++ u32 reserved1 : 20; ++ } reg015; ++ ++ u32 stream_len; ++ ++ struct rkvdec2_slice_number { ++ u32 slice_num : 25; ++ u32 reserved : 7; ++ } reg017; ++ ++ struct rkvdec2_y_hor_stride { ++ u32 y_hor_virstride : 16; ++ u32 reserved : 16; ++ } reg018; ++ ++ struct rkvdec2_uv_hor_stride { ++ u32 uv_hor_virstride : 16; ++ u32 reserved : 16; ++ } reg019; ++ ++ struct rkvdec2_y_stride { ++ u32 y_virstride : 28; ++ u32 reserved : 4; ++ } reg020; ++ ++ struct rkvdec2_error_ctrl_set { ++ u32 inter_error_prc_mode : 1; ++ u32 error_intra_mode : 1; ++ u32 error_deb_en : 1; ++ u32 picidx_replace : 5; ++ u32 error_spread_e : 1; ++ u32 reserved0 : 3; ++ u32 error_inter_pred_cross_slice : 1; ++ u32 reserved1 : 11; ++ u32 roi_error_ctu_cal_en : 1; ++ u32 reserved2 : 7; ++ } reg021; ++ ++ struct rkvdec2_err_roi_ctu_offset_start { ++ u32 roi_x_ctu_offset_st : 12; ++ u32 reserved0 : 4; ++ u32 roi_y_ctu_offset_st : 12; ++ u32 reserved1 : 4; ++ } reg022; ++ ++ struct rkvdec2_err_roi_ctu_offset_end { ++ u32 roi_x_ctu_offset_end : 12; ++ u32 reserved0 : 4; ++ u32 roi_y_ctu_offset_end : 12; ++ u32 reserved1 : 4; ++ } reg023; ++ ++ struct rkvdec2_cabac_error_en_lowbits { ++ u32 cabac_err_en_lowbits : 32; ++ } reg024; ++ ++ struct rkvdec2_cabac_error_en_highbits { ++ u32 cabac_err_en_highbits : 30; ++ u32 reserved : 2; ++ } reg025; ++ ++ struct rkvdec2_block_gating_en { ++ u32 swreg_block_gating_e : 20; ++ u32 reserved : 11; ++ u32 reg_cfg_gating_en : 1; ++ } reg026; ++ ++ struct SW027_CORE_SAFE_PIXELS { ++ u32 core_safe_x_pixels : 16; ++ u32 core_safe_y_pixels : 16; ++ } reg027; ++ ++ struct rkvdec2_multiply_core_ctrl { ++ u32 swreg_vp9_wr_prob_idx : 3; ++ u32 reserved0 : 1; ++ u32 swreg_vp9_rd_prob_idx : 3; ++ u32 reserved1 : 1; ++ ++ u32 swreg_ref_req_advance_flag : 1; ++ u32 sw_colmv_req_advance_flag : 1; ++ u32 sw_poc_only_highbit_flag : 1; ++ u32 sw_poc_arb_flag : 1; ++ ++ u32 reserved2 : 4; ++ u32 sw_film_idx : 10; ++ u32 reserved3 : 2; ++ u32 sw_pu_req_mismatch_dis : 1; ++ u32 sw_colmv_req_mismatch_dis : 1; ++ u32 reserved4 : 2; ++ } reg028; ++ ++ struct SW029_SCALE_DOWN_CTRL { ++ u32 scale_down_hor_ratio : 2; ++ u32 reserved0 : 6; ++ u32 scale_down_vrz_ratio : 2; ++ u32 reserved1 : 22; ++ } reg029; ++ ++ struct SW032_Y_SCALE_DOWN_TILE8x8_HOR_STRIDE { ++ u32 y_scale_down_hor_stride : 20; ++ u32 reserved0 : 12; ++ } reg030; ++ ++ struct SW031_UV_SCALE_DOWN_TILE8x8_HOR_STRIDE { ++ u32 uv_scale_down_hor_stride : 20; ++ u32 reserved0 : 12; ++ } reg031; ++ ++ u32 timeout_threshold; ++} __packed; ++ ++/* base: OFFSET_COMMON_ADDR_REGS */ ++struct rkvdec2_regs_common_addr { ++ u32 rlc_base; ++ u32 rlcwrite_base; ++ u32 decout_base; ++ u32 colmv_cur_base; ++ u32 error_ref_base; ++ u32 rcb_base[10]; ++} __packed; ++ ++/* base: OFFSET_CODEC_PARAMS_REGS */ ++struct rkvdec2_regs_h264_params { ++ struct rkvdec2_h26x_set { ++ u32 h26x_frame_orslice : 1; ++ u32 h26x_rps_mode : 1; ++ u32 h26x_stream_mode : 1; ++ u32 h26x_stream_lastpacket : 1; ++ u32 h264_firstslice_flag : 1; ++ u32 reserved : 27; ++ } reg064; ++ ++ u32 cur_top_poc; ++ u32 cur_bot_poc; ++ u32 ref_pocs[32]; ++ ++ struct rkvdec2_h264_info { ++ struct rkvdec2_h264_ref_info { ++ u32 ref_field : 1; ++ u32 ref_topfield_used : 1; ++ u32 ref_botfield_used : 1; ++ u32 ref_colmv_use_flag : 1; ++ u32 ref_reserved : 4; ++ } __packed ref_info[4]; ++ } __packed ref_info_regs[4]; ++ ++ u32 reserved_103_111[9]; ++ ++ struct rkvdec2_error_ref_info { ++ u32 avs2_ref_error_field : 1; ++ u32 avs2_ref_error_topfield : 1; ++ u32 ref_error_topfield_used : 1; ++ u32 ref_error_botfield_used : 1; ++ u32 reserved : 28; ++ } reg112; ++} __packed; ++ ++/* base: OFFSET_CODEC_ADDR_REGS */ ++struct rkvdec2_regs_h264_addr { ++ u32 reserved_160; ++ u32 pps_base; ++ u32 reserved_162; ++ u32 rps_base; ++ u32 ref_base[16]; ++ u32 scanlist_addr; ++ u32 colmv_base[16]; ++ u32 cabactbl_base; ++} __packed; ++ ++struct rkvdec2_regs_h264_highpoc { ++ struct rkvdec2_ref_poc_highbit { ++ u32 ref0_poc_highbit : 4; ++ u32 ref1_poc_highbit : 4; ++ u32 ref2_poc_highbit : 4; ++ u32 ref3_poc_highbit : 4; ++ u32 ref4_poc_highbit : 4; ++ u32 ref5_poc_highbit : 4; ++ u32 ref6_poc_highbit : 4; ++ u32 ref7_poc_highbit : 4; ++ } reg200[4]; ++ struct rkvdec2_cur_poc_highbit { ++ u32 cur_poc_highbit : 4; ++ u32 reserved : 28; ++ } reg204; ++} __packed; ++ ++struct rkvdec2_regs_h264 { ++ struct rkvdec2_regs_common common; ++ struct rkvdec2_regs_h264_params h264_param; ++ struct rkvdec2_regs_common_addr common_addr; ++ struct rkvdec2_regs_h264_addr h264_addr; ++ struct rkvdec2_regs_h264_highpoc h264_highpoc; ++} __packed; ++ ++#endif /* __RKVDEC_REGS_H__ */ +diff --git a/drivers/staging/media/rkvdec2/rkvdec2.c b/drivers/staging/media/rkvdec2/rkvdec2.c +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/staging/media/rkvdec2/rkvdec2.c +@@ -0,0 +1,1253 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Rockchip Video Decoder 2 driver ++ * ++ * Copyright (C) 2024 Collabora, Ltd. ++ * Detlev Casanova ++ * ++ * Based on rkvdec driver by Boris Brezillon ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "rkvdec2.h" ++ ++static int rkvdec2_try_ctrl(struct v4l2_ctrl *ctrl) ++{ ++ struct rkvdec2_ctx *ctx = container_of(ctrl->handler, struct rkvdec2_ctx, ctrl_hdl); ++ const struct rkvdec2_coded_fmt_desc *desc = ctx->coded_fmt_desc; ++ ++ if (desc->ops->try_ctrl) ++ return desc->ops->try_ctrl(ctx, ctrl); ++ ++ return 0; ++} ++ ++static const struct v4l2_ctrl_ops rkvdec2_ctrl_ops = { ++ .try_ctrl = rkvdec2_try_ctrl, ++}; ++ ++static const struct rkvdec2_ctrl_desc rkvdec2_h264_ctrl_descs[] = { ++ { ++ .cfg.id = V4L2_CID_STATELESS_H264_DECODE_PARAMS, ++ }, ++ { ++ .cfg.id = V4L2_CID_STATELESS_H264_SPS, ++ .cfg.ops = &rkvdec2_ctrl_ops, ++ }, ++ { ++ .cfg.id = V4L2_CID_STATELESS_H264_PPS, ++ }, ++ { ++ .cfg.id = V4L2_CID_STATELESS_H264_SCALING_MATRIX, ++ }, ++ { ++ .cfg.id = V4L2_CID_STATELESS_H264_DECODE_MODE, ++ .cfg.min = V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED, ++ .cfg.max = V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED, ++ .cfg.def = V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED, ++ }, ++ { ++ .cfg.id = V4L2_CID_STATELESS_H264_START_CODE, ++ .cfg.min = V4L2_STATELESS_H264_START_CODE_ANNEX_B, ++ .cfg.def = V4L2_STATELESS_H264_START_CODE_ANNEX_B, ++ .cfg.max = V4L2_STATELESS_H264_START_CODE_ANNEX_B, ++ }, ++ { ++ .cfg.id = V4L2_CID_MPEG_VIDEO_H264_PROFILE, ++ .cfg.min = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, ++ .cfg.max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, ++ .cfg.menu_skip_mask = ++ BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED), ++ .cfg.def = V4L2_MPEG_VIDEO_H264_PROFILE_MAIN, ++ }, ++ { ++ .cfg.id = V4L2_CID_MPEG_VIDEO_H264_LEVEL, ++ .cfg.min = V4L2_MPEG_VIDEO_H264_LEVEL_1_0, ++ .cfg.max = V4L2_MPEG_VIDEO_H264_LEVEL_6_1, ++ }, ++}; ++ ++static const struct rkvdec2_ctrls rkvdec2_h264_ctrls = { ++ .ctrls = rkvdec2_h264_ctrl_descs, ++ .num_ctrls = ARRAY_SIZE(rkvdec2_h264_ctrl_descs), ++}; ++ ++static const u32 rkvdec2_h264_decoded_fmts[] = { ++ V4L2_PIX_FMT_NV12 ++}; ++ ++static const struct rkvdec2_coded_fmt_desc rkvdec2_coded_fmts[] = { ++ { ++ .fourcc = V4L2_PIX_FMT_H264_SLICE, ++ .frmsize = { ++ .min_width = 16, ++ .max_width = 65520, ++ .step_width = 16, ++ .min_height = 16, ++ .max_height = 65520, ++ .step_height = 16, ++ }, ++ .ctrls = &rkvdec2_h264_ctrls, ++ .ops = &rkvdec2_h264_fmt_ops, ++ .num_decoded_fmts = ARRAY_SIZE(rkvdec2_h264_decoded_fmts), ++ .decoded_fmts = rkvdec2_h264_decoded_fmts, ++ .subsystem_flags = VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF, ++ }, ++}; ++ ++enum rcb_axis { ++ PIC_WIDTH = 0, ++ PIC_HEIGHT = 1 ++}; ++ ++struct rcb_size_info { ++ u8 multiplier; ++ enum rcb_axis axis; ++}; ++ ++static struct rcb_size_info rcb_sizes[] = { ++ {6, PIC_WIDTH}, // intrar ++ {1, PIC_WIDTH}, // transdr (Is actually 0.4*pic_width) ++ {1, PIC_HEIGHT}, // transdc (Is actually 0.1*pic_height) ++ {3, PIC_WIDTH}, // streamdr ++ {6, PIC_WIDTH}, // interr ++ {3, PIC_HEIGHT}, // interc ++ {22, PIC_WIDTH}, // dblkr ++ {6, PIC_WIDTH}, // saor ++ {11, PIC_WIDTH}, // fbcr ++ {67, PIC_HEIGHT}, // filtc col ++}; ++ ++#define RCB_SIZE(n) (rcb_sizes[(n)].multiplier * (rcb_sizes[(n)].axis ? height : width)) ++ ++static const struct rkvdec2_coded_fmt_desc * ++rkvdec2_find_coded_fmt_desc(u32 fourcc) ++{ ++ unsigned int i; ++ ++ for (i = 0; i < ARRAY_SIZE(rkvdec2_coded_fmts); i++) { ++ if (rkvdec2_coded_fmts[i].fourcc == fourcc) ++ return &rkvdec2_coded_fmts[i]; ++ } ++ ++ return NULL; ++} ++ ++static void rkvdec2_reset_fmt(struct rkvdec2_ctx *ctx, struct v4l2_format *f, ++ u32 fourcc) ++{ ++ memset(f, 0, sizeof(*f)); ++ f->fmt.pix_mp.pixelformat = fourcc; ++ f->fmt.pix_mp.field = V4L2_FIELD_NONE; ++ f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_REC709; ++ f->fmt.pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; ++ f->fmt.pix_mp.quantization = V4L2_QUANTIZATION_DEFAULT; ++ f->fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_DEFAULT; ++} ++ ++static void rkvdec2_reset_coded_fmt(struct rkvdec2_ctx *ctx) ++{ ++ struct v4l2_format *f = &ctx->coded_fmt; ++ ++ ctx->coded_fmt_desc = &rkvdec2_coded_fmts[0]; ++ rkvdec2_reset_fmt(ctx, f, ctx->coded_fmt_desc->fourcc); ++ ++ f->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; ++ f->fmt.pix_mp.width = ctx->coded_fmt_desc->frmsize.min_width; ++ f->fmt.pix_mp.height = ctx->coded_fmt_desc->frmsize.min_height; ++ ++ if (ctx->coded_fmt_desc->ops->adjust_fmt) ++ ctx->coded_fmt_desc->ops->adjust_fmt(ctx, f); ++} ++ ++static void rkvdec2_reset_decoded_fmt(struct rkvdec2_ctx *ctx) ++{ ++ struct v4l2_format *f = &ctx->decoded_fmt; ++ ++ rkvdec2_reset_fmt(ctx, f, ctx->coded_fmt_desc->decoded_fmts[0]); ++ f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; ++ v4l2_fill_pixfmt_mp(&f->fmt.pix_mp, ++ ctx->coded_fmt_desc->decoded_fmts[0], ++ ctx->coded_fmt.fmt.pix_mp.width, ++ ctx->coded_fmt.fmt.pix_mp.height); ++ ++ ctx->colmv_offset = f->fmt.pix_mp.plane_fmt[0].sizeimage; ++ ++ f->fmt.pix_mp.plane_fmt[0].sizeimage += 128 * ++ DIV_ROUND_UP(f->fmt.pix_mp.width, 16) * ++ DIV_ROUND_UP(f->fmt.pix_mp.height, 16); ++} ++ ++static int rkvdec2_enum_framesizes(struct file *file, void *priv, ++ struct v4l2_frmsizeenum *fsize) ++{ ++ const struct rkvdec2_coded_fmt_desc *fmt; ++ ++ if (fsize->index != 0) ++ return -EINVAL; ++ ++ fmt = rkvdec2_find_coded_fmt_desc(fsize->pixel_format); ++ if (!fmt) ++ return -EINVAL; ++ ++ fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; ++ fsize->stepwise = fmt->frmsize; ++ return 0; ++} ++ ++static int rkvdec2_querycap(struct file *file, void *priv, ++ struct v4l2_capability *cap) ++{ ++ struct rkvdec2_dev *rkvdec = video_drvdata(file); ++ struct video_device *vdev = video_devdata(file); ++ ++ strscpy(cap->driver, rkvdec->dev->driver->name, ++ sizeof(cap->driver)); ++ strscpy(cap->card, vdev->name, sizeof(cap->card)); ++ snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s", ++ rkvdec->dev->driver->name); ++ return 0; ++} ++ ++static int rkvdec2_try_capture_fmt(struct file *file, void *priv, ++ struct v4l2_format *f) ++{ ++ struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; ++ struct rkvdec2_ctx *ctx = fh_to_rkvdec2_ctx(priv); ++ const struct rkvdec2_coded_fmt_desc *coded_desc; ++ unsigned int i; ++ ++ /* ++ * The codec context should point to a coded format desc, if the format ++ * on the coded end has not been set yet, it should point to the ++ * default value. ++ */ ++ coded_desc = ctx->coded_fmt_desc; ++ if (WARN_ON(!coded_desc)) ++ return -EINVAL; ++ ++ for (i = 0; i < coded_desc->num_decoded_fmts; i++) { ++ if (coded_desc->decoded_fmts[i] == pix_mp->pixelformat) ++ break; ++ } ++ ++ if (i == coded_desc->num_decoded_fmts) ++ pix_mp->pixelformat = coded_desc->decoded_fmts[0]; ++ ++ /* Always apply the frmsize constraint of the coded end. */ ++ pix_mp->width = max(pix_mp->width, ctx->coded_fmt.fmt.pix_mp.width); ++ pix_mp->height = max(pix_mp->height, ctx->coded_fmt.fmt.pix_mp.height); ++ v4l2_apply_frmsize_constraints(&pix_mp->width, ++ &pix_mp->height, ++ &coded_desc->frmsize); ++ ++ v4l2_fill_pixfmt_mp(pix_mp, pix_mp->pixelformat, ++ pix_mp->width, pix_mp->height); ++ ++ pix_mp->plane_fmt[0].sizeimage += ++ 128 * ++ DIV_ROUND_UP(pix_mp->width, 16) * ++ DIV_ROUND_UP(pix_mp->height, 16); ++ ++ pix_mp->field = V4L2_FIELD_NONE; ++ ++ return 0; ++} ++ ++static int rkvdec2_try_output_fmt(struct file *file, void *priv, ++ struct v4l2_format *f) ++{ ++ struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; ++ struct rkvdec2_ctx *ctx = fh_to_rkvdec2_ctx(priv); ++ const struct rkvdec2_coded_fmt_desc *desc; ++ ++ desc = rkvdec2_find_coded_fmt_desc(pix_mp->pixelformat); ++ if (!desc) { ++ pix_mp->pixelformat = rkvdec2_coded_fmts[0].fourcc; ++ desc = &rkvdec2_coded_fmts[0]; ++ } ++ ++ v4l2_apply_frmsize_constraints(&pix_mp->width, ++ &pix_mp->height, ++ &desc->frmsize); ++ ++ pix_mp->field = V4L2_FIELD_NONE; ++ /* All coded formats are considered single planar for now. */ ++ pix_mp->num_planes = 1; ++ ++ if (desc->ops->adjust_fmt) { ++ int ret; ++ ++ ret = desc->ops->adjust_fmt(ctx, f); ++ if (ret) ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int rkvdec2_s_capture_fmt(struct file *file, void *priv, ++ struct v4l2_format *f) ++{ ++ struct rkvdec2_ctx *ctx = fh_to_rkvdec2_ctx(priv); ++ struct vb2_queue *vq; ++ int ret; ++ ++ /* Change not allowed if queue is busy */ ++ vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, ++ V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); ++ if (vb2_is_busy(vq)) ++ return -EBUSY; ++ ++ ret = rkvdec2_try_capture_fmt(file, priv, f); ++ if (ret) ++ return ret; ++ ++ ctx->decoded_fmt = *f; ++ return 0; ++} ++ ++static int rkvdec2_s_output_fmt(struct file *file, void *priv, ++ struct v4l2_format *f) ++{ ++ struct rkvdec2_ctx *ctx = fh_to_rkvdec2_ctx(priv); ++ struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; ++ const struct rkvdec2_coded_fmt_desc *desc; ++ struct v4l2_format *cap_fmt; ++ struct vb2_queue *peer_vq, *vq; ++ int ret; ++ ++ /* ++ * In order to support dynamic resolution change, the decoder admits ++ * a resolution change, as long as the pixelformat remains. Can't be ++ * done if streaming. ++ */ ++ vq = v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); ++ if (vb2_is_streaming(vq) || ++ (vb2_is_busy(vq) && ++ f->fmt.pix_mp.pixelformat != ctx->coded_fmt.fmt.pix_mp.pixelformat)) ++ return -EBUSY; ++ ++ /* ++ * Since format change on the OUTPUT queue will reset the CAPTURE ++ * queue, we can't allow doing so when the CAPTURE queue has buffers ++ * allocated. ++ */ ++ peer_vq = v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); ++ if (vb2_is_busy(peer_vq)) ++ return -EBUSY; ++ ++ ret = rkvdec2_try_output_fmt(file, priv, f); ++ if (ret) ++ return ret; ++ ++ desc = rkvdec2_find_coded_fmt_desc(f->fmt.pix_mp.pixelformat); ++ if (!desc) ++ return -EINVAL; ++ ctx->coded_fmt_desc = desc; ++ ctx->coded_fmt = *f; ++ ++ /* ++ * Current decoded format might have become invalid with newly ++ * selected codec, so reset it to default just to be safe and ++ * keep internal driver state sane. User is mandated to set ++ * the decoded format again after we return, so we don't need ++ * anything smarter. ++ * ++ * Note that this will propagate any size changes to the decoded format. ++ */ ++ rkvdec2_reset_decoded_fmt(ctx); ++ ++ /* Propagate colorspace information to capture. */ ++ cap_fmt = &ctx->decoded_fmt; ++ cap_fmt->fmt.pix_mp.colorspace = f->fmt.pix_mp.colorspace; ++ cap_fmt->fmt.pix_mp.xfer_func = f->fmt.pix_mp.xfer_func; ++ cap_fmt->fmt.pix_mp.ycbcr_enc = f->fmt.pix_mp.ycbcr_enc; ++ cap_fmt->fmt.pix_mp.quantization = f->fmt.pix_mp.quantization; ++ ++ /* Enable format specific queue features */ ++ vq->subsystem_flags |= desc->subsystem_flags; ++ ++ return 0; ++} ++ ++static int rkvdec2_g_output_fmt(struct file *file, void *priv, ++ struct v4l2_format *f) ++{ ++ struct rkvdec2_ctx *ctx = fh_to_rkvdec2_ctx(priv); ++ ++ *f = ctx->coded_fmt; ++ return 0; ++} ++ ++static int rkvdec2_g_capture_fmt(struct file *file, void *priv, ++ struct v4l2_format *f) ++{ ++ struct rkvdec2_ctx *ctx = fh_to_rkvdec2_ctx(priv); ++ ++ *f = ctx->decoded_fmt; ++ return 0; ++} ++ ++static int rkvdec2_enum_output_fmt(struct file *file, void *priv, ++ struct v4l2_fmtdesc *f) ++{ ++ if (f->index >= ARRAY_SIZE(rkvdec2_coded_fmts)) ++ return -EINVAL; ++ ++ f->pixelformat = rkvdec2_coded_fmts[f->index].fourcc; ++ return 0; ++} ++ ++static int rkvdec2_enum_capture_fmt(struct file *file, void *priv, ++ struct v4l2_fmtdesc *f) ++{ ++ struct rkvdec2_ctx *ctx = fh_to_rkvdec2_ctx(priv); ++ ++ if (WARN_ON(!ctx->coded_fmt_desc)) ++ return -EINVAL; ++ ++ if (f->index >= ctx->coded_fmt_desc->num_decoded_fmts) ++ return -EINVAL; ++ ++ f->pixelformat = ctx->coded_fmt_desc->decoded_fmts[f->index]; ++ return 0; ++} ++ ++static const struct v4l2_ioctl_ops rkvdec2_ioctl_ops = { ++ .vidioc_querycap = rkvdec2_querycap, ++ .vidioc_enum_framesizes = rkvdec2_enum_framesizes, ++ ++ .vidioc_try_fmt_vid_cap_mplane = rkvdec2_try_capture_fmt, ++ .vidioc_try_fmt_vid_out_mplane = rkvdec2_try_output_fmt, ++ .vidioc_s_fmt_vid_out_mplane = rkvdec2_s_output_fmt, ++ .vidioc_s_fmt_vid_cap_mplane = rkvdec2_s_capture_fmt, ++ .vidioc_g_fmt_vid_out_mplane = rkvdec2_g_output_fmt, ++ .vidioc_g_fmt_vid_cap_mplane = rkvdec2_g_capture_fmt, ++ .vidioc_enum_fmt_vid_out = rkvdec2_enum_output_fmt, ++ .vidioc_enum_fmt_vid_cap = rkvdec2_enum_capture_fmt, ++ ++ .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, ++ .vidioc_querybuf = v4l2_m2m_ioctl_querybuf, ++ .vidioc_qbuf = v4l2_m2m_ioctl_qbuf, ++ .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, ++ .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, ++ .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, ++ .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, ++ ++ .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, ++ .vidioc_unsubscribe_event = v4l2_event_unsubscribe, ++ ++ .vidioc_streamon = v4l2_m2m_ioctl_streamon, ++ .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, ++ ++ .vidioc_decoder_cmd = v4l2_m2m_ioctl_stateless_decoder_cmd, ++ .vidioc_try_decoder_cmd = v4l2_m2m_ioctl_stateless_try_decoder_cmd, ++}; ++ ++static int rkvdec2_queue_setup(struct vb2_queue *vq, unsigned int *num_buffers, ++ unsigned int *num_planes, unsigned int sizes[], ++ struct device *alloc_devs[]) ++{ ++ struct rkvdec2_ctx *ctx = vb2_get_drv_priv(vq); ++ struct v4l2_format *f; ++ unsigned int i; ++ ++ if (V4L2_TYPE_IS_OUTPUT(vq->type)) ++ f = &ctx->coded_fmt; ++ else ++ f = &ctx->decoded_fmt; ++ ++ if (*num_planes) { ++ if (*num_planes != f->fmt.pix_mp.num_planes) ++ return -EINVAL; ++ ++ for (i = 0; i < f->fmt.pix_mp.num_planes; i++) { ++ if (sizes[i] < f->fmt.pix_mp.plane_fmt[i].sizeimage) ++ return -EINVAL; ++ } ++ } else { ++ *num_planes = f->fmt.pix_mp.num_planes; ++ for (i = 0; i < f->fmt.pix_mp.num_planes; i++) ++ sizes[i] = f->fmt.pix_mp.plane_fmt[i].sizeimage; ++ } ++ ++ return 0; ++} ++ ++static int rkvdec2_buf_prepare(struct vb2_buffer *vb) ++{ ++ struct vb2_queue *vq = vb->vb2_queue; ++ struct rkvdec2_ctx *ctx = vb2_get_drv_priv(vq); ++ struct v4l2_format *f; ++ unsigned int i; ++ ++ if (V4L2_TYPE_IS_OUTPUT(vq->type)) ++ f = &ctx->coded_fmt; ++ else ++ f = &ctx->decoded_fmt; ++ ++ for (i = 0; i < f->fmt.pix_mp.num_planes; ++i) { ++ u32 sizeimage = f->fmt.pix_mp.plane_fmt[i].sizeimage; ++ ++ if (vb2_plane_size(vb, i) < sizeimage) ++ return -EINVAL; ++ } ++ ++ /* ++ * Buffer's bytesused must be written by driver for CAPTURE buffers. ++ * (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets ++ * it to buffer length). ++ */ ++ if (V4L2_TYPE_IS_CAPTURE(vq->type)) ++ vb2_set_plane_payload(vb, 0, f->fmt.pix_mp.plane_fmt[0].sizeimage); ++ ++ return 0; ++} ++ ++static void rkvdec2_buf_queue(struct vb2_buffer *vb) ++{ ++ struct rkvdec2_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); ++ struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); ++ ++ v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); ++} ++ ++static int rkvdec2_buf_out_validate(struct vb2_buffer *vb) ++{ ++ struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); ++ ++ vbuf->field = V4L2_FIELD_NONE; ++ return 0; ++} ++ ++static void rkvdec2_buf_request_complete(struct vb2_buffer *vb) ++{ ++ struct rkvdec2_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); ++ ++ v4l2_ctrl_request_complete(vb->req_obj.req, &ctx->ctrl_hdl); ++} ++ ++static void rkvdec2_free_rcb(struct rkvdec2_ctx *ctx) ++{ ++ u32 width, height; ++ int i; ++ ++ width = ctx->decoded_fmt.fmt.pix_mp.width; ++ height = ctx->decoded_fmt.fmt.pix_mp.height; ++ ++ for (i = 0; i < RKVDEC2_RCB_COUNT; i++) { ++ if (!ctx->rcb_bufs[i].cpu) ++ continue; ++ ++ switch (ctx->rcb_bufs[i].type) { ++ case RKVDEC2_ALLOC_SRAM: ++ gen_pool_free(ctx->dev->sram_pool, ++ (unsigned long)ctx->rcb_bufs[i].cpu, ++ RCB_SIZE(i)); ++ break; ++ case RKVDEC2_ALLOC_DMA: ++ dma_free_coherent(ctx->dev->dev, ++ RCB_SIZE(i), ++ ctx->rcb_bufs[i].cpu, ++ ctx->rcb_bufs[i].dma); ++ break; ++ } ++ } ++} ++ ++static int rkvdec2_allocate_rcb(struct rkvdec2_ctx *ctx) ++{ ++ int ret, i; ++ u32 width, height; ++ ++ memset(ctx->rcb_bufs, 0, sizeof(*ctx->rcb_bufs)); ++ ++ width = ctx->decoded_fmt.fmt.pix_mp.width; ++ height = ctx->decoded_fmt.fmt.pix_mp.height; ++ ++ for (i = 0; i < RKVDEC2_RCB_COUNT; i++) { ++ void *cpu = NULL; ++ dma_addr_t dma; ++ size_t rcb_size = RCB_SIZE(i); ++ enum rkvdec2_alloc_type alloc_type = RKVDEC2_ALLOC_SRAM; ++ ++ if (ctx->dev->sram_pool) { ++ cpu = gen_pool_dma_zalloc_align(ctx->dev->sram_pool, ++ rcb_size, ++ &dma, ++ 64); ++ } ++ ++ /* Fallback to RAM */ ++ if (!cpu) { ++ cpu = dma_alloc_coherent(ctx->dev->dev, ++ rcb_size, ++ &dma, ++ GFP_KERNEL); ++ alloc_type = RKVDEC2_ALLOC_DMA; ++ } ++ ++ if (!cpu) { ++ ret = -ENOMEM; ++ goto err_alloc; ++ } ++ ++ ctx->rcb_bufs[i].cpu = cpu; ++ ctx->rcb_bufs[i].dma = dma; ++ ctx->rcb_bufs[i].size = rcb_size; ++ ctx->rcb_bufs[i].type = alloc_type; ++ } ++ ++ return 0; ++ ++err_alloc: ++ rkvdec2_free_rcb(ctx); ++ ++ return ret; ++} ++ ++static int rkvdec2_start_streaming(struct vb2_queue *q, unsigned int count) ++{ ++ struct rkvdec2_ctx *ctx = vb2_get_drv_priv(q); ++ const struct rkvdec2_coded_fmt_desc *desc; ++ int ret; ++ ++ if (V4L2_TYPE_IS_CAPTURE(q->type)) ++ return 0; ++ ++ desc = ctx->coded_fmt_desc; ++ if (WARN_ON(!desc)) ++ return -EINVAL; ++ ++ ret = rkvdec2_allocate_rcb(ctx); ++ if (ret) ++ return ret; ++ ++ if (desc->ops->start) { ++ ret = desc->ops->start(ctx); ++ if (ret) ++ goto err_ops_start; ++ } ++ ++ return 0; ++ ++err_ops_start: ++ rkvdec2_free_rcb(ctx); ++ ++ return ret; ++} ++ ++static void rkvdec2_queue_cleanup(struct vb2_queue *vq, u32 state) ++{ ++ struct rkvdec2_ctx *ctx = vb2_get_drv_priv(vq); ++ ++ while (true) { ++ struct vb2_v4l2_buffer *vbuf; ++ ++ if (V4L2_TYPE_IS_OUTPUT(vq->type)) ++ vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); ++ else ++ vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); ++ ++ if (!vbuf) ++ break; ++ ++ v4l2_ctrl_request_complete(vbuf->vb2_buf.req_obj.req, ++ &ctx->ctrl_hdl); ++ v4l2_m2m_buf_done(vbuf, state); ++ } ++} ++ ++static void rkvdec2_stop_streaming(struct vb2_queue *q) ++{ ++ struct rkvdec2_ctx *ctx = vb2_get_drv_priv(q); ++ ++ if (V4L2_TYPE_IS_OUTPUT(q->type)) { ++ const struct rkvdec2_coded_fmt_desc *desc = ctx->coded_fmt_desc; ++ ++ if (WARN_ON(!desc)) ++ return; ++ ++ if (desc->ops->stop) ++ desc->ops->stop(ctx); ++ ++ rkvdec2_free_rcb(ctx); ++ } ++ ++ rkvdec2_queue_cleanup(q, VB2_BUF_STATE_ERROR); ++} ++ ++static const struct vb2_ops rkvdec2_queue_ops = { ++ .queue_setup = rkvdec2_queue_setup, ++ .buf_prepare = rkvdec2_buf_prepare, ++ .buf_queue = rkvdec2_buf_queue, ++ .buf_out_validate = rkvdec2_buf_out_validate, ++ .buf_request_complete = rkvdec2_buf_request_complete, ++ .start_streaming = rkvdec2_start_streaming, ++ .stop_streaming = rkvdec2_stop_streaming, ++ .wait_prepare = vb2_ops_wait_prepare, ++ .wait_finish = vb2_ops_wait_finish, ++}; ++ ++static int rkvdec2_request_validate(struct media_request *req) ++{ ++ unsigned int count; ++ ++ count = vb2_request_buffer_cnt(req); ++ if (!count) ++ return -ENOENT; ++ else if (count > 1) ++ return -EINVAL; ++ ++ return vb2_request_validate(req); ++} ++ ++static const struct media_device_ops rkvdec2_media_ops = { ++ .req_validate = rkvdec2_request_validate, ++ .req_queue = v4l2_m2m_request_queue, ++}; ++ ++static void rkvdec2_job_finish_no_pm(struct rkvdec2_ctx *ctx, ++ enum vb2_buffer_state result) ++{ ++ if (ctx->coded_fmt_desc->ops->done) { ++ struct vb2_v4l2_buffer *src_buf, *dst_buf; ++ ++ src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); ++ dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); ++ ctx->coded_fmt_desc->ops->done(ctx, src_buf, dst_buf, result); ++ } ++ ++ v4l2_m2m_buf_done_and_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx, ++ result); ++} ++ ++static void rkvdec2_job_finish(struct rkvdec2_ctx *ctx, ++ enum vb2_buffer_state result) ++{ ++ struct rkvdec2_dev *rkvdec = ctx->dev; ++ ++ pm_runtime_mark_last_busy(rkvdec->dev); ++ pm_runtime_put_autosuspend(rkvdec->dev); ++ rkvdec2_job_finish_no_pm(ctx, result); ++} ++ ++void rkvdec2_run_preamble(struct rkvdec2_ctx *ctx, struct rkvdec2_run *run) ++{ ++ struct media_request *src_req; ++ ++ memset(run, 0, sizeof(*run)); ++ ++ run->bufs.src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); ++ run->bufs.dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); ++ ++ /* Apply request(s) controls if needed. */ ++ src_req = run->bufs.src->vb2_buf.req_obj.req; ++ if (src_req) ++ v4l2_ctrl_request_setup(src_req, &ctx->ctrl_hdl); ++ ++ v4l2_m2m_buf_copy_metadata(run->bufs.src, run->bufs.dst, true); ++} ++ ++void rkvdec2_run_postamble(struct rkvdec2_ctx *ctx, struct rkvdec2_run *run) ++{ ++ struct media_request *src_req = run->bufs.src->vb2_buf.req_obj.req; ++ ++ if (src_req) ++ v4l2_ctrl_request_complete(src_req, &ctx->ctrl_hdl); ++} ++ ++static void rkvdec2_device_run(void *priv) ++{ ++ struct rkvdec2_ctx *ctx = priv; ++ struct rkvdec2_dev *rkvdec = ctx->dev; ++ const struct rkvdec2_coded_fmt_desc *desc = ctx->coded_fmt_desc; ++ int ret; ++ ++ if (WARN_ON(!desc)) ++ return; ++ ++ ret = pm_runtime_resume_and_get(rkvdec->dev); ++ if (ret < 0) { ++ rkvdec2_job_finish_no_pm(ctx, VB2_BUF_STATE_ERROR); ++ return; ++ } ++ ++ ret = desc->ops->run(ctx); ++ if (ret) ++ rkvdec2_job_finish(ctx, VB2_BUF_STATE_ERROR); ++} ++ ++static const struct v4l2_m2m_ops rkvdec2_m2m_ops = { ++ .device_run = rkvdec2_device_run, ++}; ++ ++static int rkvdec2_queue_init(void *priv, ++ struct vb2_queue *src_vq, ++ struct vb2_queue *dst_vq) ++{ ++ struct rkvdec2_ctx *ctx = priv; ++ struct rkvdec2_dev *rkvdec = ctx->dev; ++ int ret; ++ ++ src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; ++ src_vq->io_modes = VB2_MMAP | VB2_DMABUF; ++ src_vq->drv_priv = ctx; ++ src_vq->ops = &rkvdec2_queue_ops; ++ src_vq->mem_ops = &vb2_dma_contig_memops; ++ ++ /* ++ * No CPU access on the queues, so no kernel mapping needed. ++ */ ++ src_vq->dma_attrs = DMA_ATTR_NO_KERNEL_MAPPING; ++ src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); ++ src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; ++ src_vq->lock = &rkvdec->vdev_lock; ++ src_vq->dev = rkvdec->v4l2_dev.dev; ++ src_vq->supports_requests = true; ++ src_vq->requires_requests = true; ++ ++ ret = vb2_queue_init(src_vq); ++ if (ret) ++ return ret; ++ ++ dst_vq->bidirectional = true; ++ dst_vq->mem_ops = &vb2_dma_contig_memops; ++ dst_vq->dma_attrs = DMA_ATTR_NO_KERNEL_MAPPING; ++ dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; ++ dst_vq->io_modes = VB2_MMAP | VB2_DMABUF; ++ dst_vq->drv_priv = ctx; ++ dst_vq->ops = &rkvdec2_queue_ops; ++ dst_vq->buf_struct_size = sizeof(struct rkvdec2_decoded_buffer); ++ dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; ++ dst_vq->lock = &rkvdec->vdev_lock; ++ dst_vq->dev = rkvdec->v4l2_dev.dev; ++ ++ return vb2_queue_init(dst_vq); ++} ++ ++static int rkvdec2_add_ctrls(struct rkvdec2_ctx *ctx, ++ const struct rkvdec2_ctrls *ctrls) ++{ ++ unsigned int i; ++ ++ for (i = 0; i < ctrls->num_ctrls; i++) { ++ const struct v4l2_ctrl_config *cfg = &ctrls->ctrls[i].cfg; ++ ++ v4l2_ctrl_new_custom(&ctx->ctrl_hdl, cfg, ctx); ++ if (ctx->ctrl_hdl.error) ++ return ctx->ctrl_hdl.error; ++ } ++ ++ return 0; ++} ++ ++static int rkvdec2_init_ctrls(struct rkvdec2_ctx *ctx) ++{ ++ unsigned int i, nctrls = 0; ++ int ret; ++ ++ for (i = 0; i < ARRAY_SIZE(rkvdec2_coded_fmts); i++) ++ nctrls += rkvdec2_coded_fmts[i].ctrls->num_ctrls; ++ ++ v4l2_ctrl_handler_init(&ctx->ctrl_hdl, nctrls); ++ ++ for (i = 0; i < ARRAY_SIZE(rkvdec2_coded_fmts); i++) { ++ ret = rkvdec2_add_ctrls(ctx, rkvdec2_coded_fmts[i].ctrls); ++ if (ret) ++ goto err_free_handler; ++ } ++ ++ ret = v4l2_ctrl_handler_setup(&ctx->ctrl_hdl); ++ if (ret) ++ goto err_free_handler; ++ ++ ctx->fh.ctrl_handler = &ctx->ctrl_hdl; ++ return 0; ++ ++err_free_handler: ++ v4l2_ctrl_handler_free(&ctx->ctrl_hdl); ++ return ret; ++} ++ ++static int rkvdec2_open(struct file *filp) ++{ ++ struct rkvdec2_dev *rkvdec = video_drvdata(filp); ++ struct rkvdec2_ctx *ctx; ++ int ret; ++ ++ ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); ++ if (!ctx) ++ return -ENOMEM; ++ ++ ctx->dev = rkvdec; ++ rkvdec2_reset_coded_fmt(ctx); ++ rkvdec2_reset_decoded_fmt(ctx); ++ v4l2_fh_init(&ctx->fh, video_devdata(filp)); ++ ++ ret = rkvdec2_init_ctrls(ctx); ++ if (ret) ++ goto err_free_ctx; ++ ++ ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(rkvdec->m2m_dev, ctx, ++ rkvdec2_queue_init); ++ if (IS_ERR(ctx->fh.m2m_ctx)) { ++ ret = PTR_ERR(ctx->fh.m2m_ctx); ++ goto err_cleanup_ctrls; ++ } ++ ++ filp->private_data = &ctx->fh; ++ v4l2_fh_add(&ctx->fh); ++ ++ return 0; ++ ++err_cleanup_ctrls: ++ v4l2_ctrl_handler_free(&ctx->ctrl_hdl); ++ ++err_free_ctx: ++ kfree(ctx); ++ return ret; ++} ++ ++static int rkvdec2_release(struct file *filp) ++{ ++ struct rkvdec2_ctx *ctx = fh_to_rkvdec2_ctx(filp->private_data); ++ ++ v4l2_fh_del(&ctx->fh); ++ v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); ++ v4l2_ctrl_handler_free(&ctx->ctrl_hdl); ++ v4l2_fh_exit(&ctx->fh); ++ kfree(ctx); ++ ++ return 0; ++} ++ ++static const struct v4l2_file_operations rkvdec2_fops = { ++ .owner = THIS_MODULE, ++ .open = rkvdec2_open, ++ .release = rkvdec2_release, ++ .poll = v4l2_m2m_fop_poll, ++ .unlocked_ioctl = video_ioctl2, ++ .mmap = v4l2_m2m_fop_mmap, ++}; ++ ++static int rkvdec2_v4l2_init(struct rkvdec2_dev *rkvdec) ++{ ++ int ret; ++ ++ ret = v4l2_device_register(rkvdec->dev, &rkvdec->v4l2_dev); ++ if (ret) { ++ dev_err(rkvdec->dev, "Failed to register V4L2 device\n"); ++ return ret; ++ } ++ ++ rkvdec->m2m_dev = v4l2_m2m_init(&rkvdec2_m2m_ops); ++ if (IS_ERR(rkvdec->m2m_dev)) { ++ v4l2_err(&rkvdec->v4l2_dev, "Failed to init mem2mem device\n"); ++ ret = PTR_ERR(rkvdec->m2m_dev); ++ goto err_unregister_v4l2; ++ } ++ ++ rkvdec->mdev.dev = rkvdec->dev; ++ strscpy(rkvdec->mdev.model, "rkvdec2", sizeof(rkvdec->mdev.model)); ++ strscpy(rkvdec->mdev.bus_info, "platform:rkvdec2", ++ sizeof(rkvdec->mdev.bus_info)); ++ media_device_init(&rkvdec->mdev); ++ rkvdec->mdev.ops = &rkvdec2_media_ops; ++ rkvdec->v4l2_dev.mdev = &rkvdec->mdev; ++ ++ rkvdec->vdev.lock = &rkvdec->vdev_lock; ++ rkvdec->vdev.v4l2_dev = &rkvdec->v4l2_dev; ++ rkvdec->vdev.fops = &rkvdec2_fops; ++ rkvdec->vdev.release = video_device_release_empty; ++ rkvdec->vdev.vfl_dir = VFL_DIR_M2M; ++ rkvdec->vdev.device_caps = V4L2_CAP_STREAMING | ++ V4L2_CAP_VIDEO_M2M_MPLANE; ++ rkvdec->vdev.ioctl_ops = &rkvdec2_ioctl_ops; ++ video_set_drvdata(&rkvdec->vdev, rkvdec); ++ strscpy(rkvdec->vdev.name, "rkvdec2", sizeof(rkvdec->vdev.name)); ++ ++ ret = video_register_device(&rkvdec->vdev, VFL_TYPE_VIDEO, -1); ++ if (ret) { ++ v4l2_err(&rkvdec->v4l2_dev, "Failed to register video device\n"); ++ goto err_cleanup_mc; ++ } ++ ++ ret = v4l2_m2m_register_media_controller(rkvdec->m2m_dev, &rkvdec->vdev, ++ MEDIA_ENT_F_PROC_VIDEO_DECODER); ++ if (ret) { ++ v4l2_err(&rkvdec->v4l2_dev, ++ "Failed to initialize V4L2 M2M media controller\n"); ++ goto err_unregister_vdev; ++ } ++ ++ ret = media_device_register(&rkvdec->mdev); ++ if (ret) { ++ v4l2_err(&rkvdec->v4l2_dev, "Failed to register media device\n"); ++ goto err_unregister_mc; ++ } ++ ++ return 0; ++ ++err_unregister_mc: ++ v4l2_m2m_unregister_media_controller(rkvdec->m2m_dev); ++ ++err_unregister_vdev: ++ video_unregister_device(&rkvdec->vdev); ++ ++err_cleanup_mc: ++ media_device_cleanup(&rkvdec->mdev); ++ v4l2_m2m_release(rkvdec->m2m_dev); ++ ++err_unregister_v4l2: ++ v4l2_device_unregister(&rkvdec->v4l2_dev); ++ return ret; ++} ++ ++static void rkvdec2_v4l2_cleanup(struct rkvdec2_dev *rkvdec) ++{ ++ media_device_unregister(&rkvdec->mdev); ++ v4l2_m2m_unregister_media_controller(rkvdec->m2m_dev); ++ video_unregister_device(&rkvdec->vdev); ++ media_device_cleanup(&rkvdec->mdev); ++ v4l2_m2m_release(rkvdec->m2m_dev); ++ v4l2_device_unregister(&rkvdec->v4l2_dev); ++} ++ ++static irqreturn_t rkvdec2_irq_handler(int irq, void *priv) ++{ ++ struct rkvdec2_dev *rkvdec = priv; ++ enum vb2_buffer_state state; ++ u32 status; ++ ++ status = readl(rkvdec->regs + RKVDEC2_REG_STA_INT); ++ state = (status & STA_INT_DEC_RDY_STA) ? ++ VB2_BUF_STATE_DONE : VB2_BUF_STATE_ERROR; ++ ++ /* Clear interrupt status */ ++ writel(0, rkvdec->regs + RKVDEC2_REG_STA_INT); ++ if (cancel_delayed_work(&rkvdec->watchdog_work)) { ++ struct rkvdec2_ctx *ctx; ++ ++ ctx = v4l2_m2m_get_curr_priv(rkvdec->m2m_dev); ++ rkvdec2_job_finish(ctx, state); ++ } ++ ++ return IRQ_HANDLED; ++} ++ ++static void rkvdec2_watchdog_func(struct work_struct *work) ++{ ++ struct rkvdec2_dev *rkvdec = container_of(to_delayed_work(work), struct rkvdec2_dev, ++ watchdog_work); ++ struct rkvdec2_ctx *ctx; ++ ++ ctx = v4l2_m2m_get_curr_priv(rkvdec->m2m_dev); ++ if (ctx) { ++ dev_err(rkvdec->dev, "Frame processing timed out!\n"); ++ writel(RKVDEC2_REG_DEC_IRQ_DISABLE, rkvdec->regs + RKVDEC2_REG_IMPORTANT_EN); ++ writel(0, rkvdec->regs + RKVDEC2_REG_DEC_E); ++ rkvdec2_job_finish(ctx, VB2_BUF_STATE_ERROR); ++ } ++} ++ ++static const struct of_device_id of_rkvdec2_match[] = { ++ { .compatible = "rockchip,rk3588-vdec" }, ++ { /* sentinel */ } ++}; ++MODULE_DEVICE_TABLE(of, of_rkvdec2_match); ++ ++static const char * const rkvdec2_clk_names[] = { ++ "axi", ++ "ahb", ++ "core", ++ "cabac", ++ "hevc_cabac", ++}; ++ ++/* ++ * Some SoCs, like RK3588 have multiple identical vdpu34x cores, but the ++ * kernel is currently missing support for multi-core handling. Exposing ++ * separate devices for each core to userspace is bad, since that does ++ * not allow scheduling tasks properly (and creates ABI). With this workaround ++ * the driver will only probe for the first core and early exit for the other ++ * cores. Once the driver gains multi-core support, the same technique ++ * for detecting the main core can be used to cluster all cores together. ++ */ ++static int rkvdec2_disable_multicore(struct rkvdec2_dev *rkvdec) ++{ ++ const char *compatible; ++ struct device_node *node; ++ int ret; ++ ++ /* Intentionally ignores the fallback strings */ ++ ret = of_property_read_string(rkvdec->dev->of_node, "compatible", &compatible); ++ if (ret) ++ return ret; ++ ++ /* first compatible node found from the root node is considered the main core */ ++ node = of_find_compatible_node(NULL, NULL, compatible); ++ if (!node) ++ return -EINVAL; /* broken DT? */ ++ ++ if (rkvdec->dev->of_node != node) { ++ dev_info(rkvdec->dev, "missing multi-core support, ignoring this instance\n"); ++ return -ENODEV; ++ } ++ ++ return 0; ++} ++ ++static int rkvdec2_probe(struct platform_device *pdev) ++{ ++ struct rkvdec2_dev *rkvdec; ++ unsigned int i; ++ int ret, irq; ++ ++ rkvdec = devm_kzalloc(&pdev->dev, sizeof(*rkvdec), GFP_KERNEL); ++ if (!rkvdec) ++ return -ENOMEM; ++ ++ platform_set_drvdata(pdev, rkvdec); ++ rkvdec->dev = &pdev->dev; ++ ++ ret = rkvdec2_disable_multicore(rkvdec); ++ if (ret) ++ return ret; ++ ++ mutex_init(&rkvdec->vdev_lock); ++ INIT_DELAYED_WORK(&rkvdec->watchdog_work, rkvdec2_watchdog_func); ++ ++ rkvdec->clocks = devm_kcalloc(&pdev->dev, ARRAY_SIZE(rkvdec2_clk_names), ++ sizeof(*rkvdec->clocks), GFP_KERNEL); ++ if (!rkvdec->clocks) ++ return -ENOMEM; ++ ++ for (i = 0; i < ARRAY_SIZE(rkvdec2_clk_names); i++) ++ rkvdec->clocks[i].id = rkvdec2_clk_names[i]; ++ ++ ret = devm_clk_bulk_get(&pdev->dev, ARRAY_SIZE(rkvdec2_clk_names), ++ rkvdec->clocks); ++ if (ret) ++ return ret; ++ ++ rkvdec->regs = devm_platform_ioremap_resource(pdev, 0); ++ if (IS_ERR(rkvdec->regs)) ++ return PTR_ERR(rkvdec->regs); ++ ++ /* ++ * Without IOMMU support, keep DMA in the lower 32 bits. ++ */ ++ ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); ++ if (ret) { ++ dev_err(&pdev->dev, "Could not set DMA coherent mask.\n"); ++ return ret; ++ } ++ ++ vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); ++ ++ irq = platform_get_irq(pdev, 0); ++ if (irq <= 0) ++ return -ENXIO; ++ ++ ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, ++ rkvdec2_irq_handler, IRQF_ONESHOT, ++ dev_name(&pdev->dev), rkvdec); ++ if (ret) { ++ dev_err(&pdev->dev, "Could not request vdec2 IRQ\n"); ++ return ret; ++ } ++ ++ rkvdec->sram_pool = of_gen_pool_get(pdev->dev.of_node, "sram", 0); ++ if (!rkvdec->sram_pool) ++ dev_info(&pdev->dev, "No sram node, RCB will be stored in RAM\n"); ++ ++ pm_runtime_set_autosuspend_delay(&pdev->dev, 100); ++ pm_runtime_use_autosuspend(&pdev->dev); ++ pm_runtime_enable(&pdev->dev); ++ ++ ret = rkvdec2_v4l2_init(rkvdec); ++ if (ret) ++ goto err_disable_runtime_pm; ++ ++ return 0; ++ ++err_disable_runtime_pm: ++ pm_runtime_dont_use_autosuspend(&pdev->dev); ++ pm_runtime_disable(&pdev->dev); ++ ++ if (rkvdec->sram_pool) ++ gen_pool_destroy(rkvdec->sram_pool); ++ ++ return ret; ++} ++ ++static void rkvdec2_remove(struct platform_device *pdev) ++{ ++ struct rkvdec2_dev *rkvdec = platform_get_drvdata(pdev); ++ ++ cancel_delayed_work_sync(&rkvdec->watchdog_work); ++ ++ rkvdec2_v4l2_cleanup(rkvdec); ++ pm_runtime_disable(&pdev->dev); ++ pm_runtime_dont_use_autosuspend(&pdev->dev); ++ ++ if (rkvdec->sram_pool) ++ gen_pool_destroy(rkvdec->sram_pool); ++} ++ ++#ifdef CONFIG_PM ++static int rkvdec2_runtime_resume(struct device *dev) ++{ ++ struct rkvdec2_dev *rkvdec = dev_get_drvdata(dev); ++ ++ return clk_bulk_prepare_enable(ARRAY_SIZE(rkvdec2_clk_names), ++ rkvdec->clocks); ++} ++ ++static int rkvdec2_runtime_suspend(struct device *dev) ++{ ++ struct rkvdec2_dev *rkvdec = dev_get_drvdata(dev); ++ ++ clk_bulk_disable_unprepare(ARRAY_SIZE(rkvdec2_clk_names), ++ rkvdec->clocks); ++ return 0; ++} ++#endif ++ ++static const struct dev_pm_ops rkvdec2_pm_ops = { ++ SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, ++ pm_runtime_force_resume) ++ SET_RUNTIME_PM_OPS(rkvdec2_runtime_suspend, rkvdec2_runtime_resume, NULL) ++}; ++ ++static struct platform_driver rkvdec2_driver = { ++ .probe = rkvdec2_probe, ++ .remove_new = rkvdec2_remove, ++ .driver = { ++ .name = "rkvdec2", ++ .of_match_table = of_rkvdec2_match, ++ .pm = &rkvdec2_pm_ops, ++ }, ++}; ++module_platform_driver(rkvdec2_driver); ++ ++MODULE_AUTHOR("Detlev Casanova "); ++MODULE_DESCRIPTION("Rockchip Video Decoder 2 driver"); ++MODULE_LICENSE("GPL"); +diff --git a/drivers/staging/media/rkvdec2/rkvdec2.h b/drivers/staging/media/rkvdec2/rkvdec2.h +new file mode 100644 +index 000000000000..111111111111 +--- /dev/null ++++ b/drivers/staging/media/rkvdec2/rkvdec2.h +@@ -0,0 +1,130 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * Rockchip Video Decoder 2 driver ++ * ++ * Copyright (C) 2024 Collabora, Ltd. ++ * Detlev Casanova ++ * ++ * Based on rkvdec driver by Boris Brezillon ++ */ ++#ifndef RKVDEC_H_ ++#define RKVDEC_H_ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "rkvdec2-regs.h" ++ ++#define RKVDEC2_RCB_COUNT 10 ++ ++struct rkvdec2_ctx; ++ ++enum rkvdec2_alloc_type { ++ RKVDEC2_ALLOC_SRAM, ++ RKVDEC2_ALLOC_DMA, ++}; ++ ++struct rkvdec2_aux_buf { ++ void *cpu; ++ dma_addr_t dma; ++ size_t size; ++ enum rkvdec2_alloc_type type; ++}; ++ ++struct rkvdec2_ctrl_desc { ++ struct v4l2_ctrl_config cfg; ++}; ++ ++struct rkvdec2_ctrls { ++ const struct rkvdec2_ctrl_desc *ctrls; ++ unsigned int num_ctrls; ++}; ++ ++struct rkvdec2_run { ++ struct { ++ struct vb2_v4l2_buffer *src; ++ struct vb2_v4l2_buffer *dst; ++ } bufs; ++}; ++ ++struct rkvdec2_decoded_buffer { ++ /* Must be the first field in this struct. */ ++ struct v4l2_m2m_buffer base; ++}; ++ ++static inline struct rkvdec2_decoded_buffer * ++vb2_to_rkvdec2_decoded_buf(struct vb2_buffer *buf) ++{ ++ return container_of(buf, struct rkvdec2_decoded_buffer, ++ base.vb.vb2_buf); ++} ++ ++struct rkvdec2_coded_fmt_ops { ++ int (*adjust_fmt)(struct rkvdec2_ctx *ctx, ++ struct v4l2_format *f); ++ int (*start)(struct rkvdec2_ctx *ctx); ++ void (*stop)(struct rkvdec2_ctx *ctx); ++ int (*run)(struct rkvdec2_ctx *ctx); ++ void (*done)(struct rkvdec2_ctx *ctx, struct vb2_v4l2_buffer *src_buf, ++ struct vb2_v4l2_buffer *dst_buf, ++ enum vb2_buffer_state result); ++ int (*try_ctrl)(struct rkvdec2_ctx *ctx, struct v4l2_ctrl *ctrl); ++}; ++ ++struct rkvdec2_coded_fmt_desc { ++ u32 fourcc; ++ struct v4l2_frmsize_stepwise frmsize; ++ const struct rkvdec2_ctrls *ctrls; ++ const struct rkvdec2_coded_fmt_ops *ops; ++ unsigned int num_decoded_fmts; ++ const u32 *decoded_fmts; ++ u32 subsystem_flags; ++}; ++ ++struct rkvdec2_dev { ++ struct v4l2_device v4l2_dev; ++ struct media_device mdev; ++ struct video_device vdev; ++ struct v4l2_m2m_dev *m2m_dev; ++ struct device *dev; ++ struct clk_bulk_data *clocks; ++ void __iomem *regs; ++ struct gen_pool *sram_pool; ++ struct mutex vdev_lock; /* serializes ioctls */ ++ struct delayed_work watchdog_work; ++}; ++ ++struct rkvdec2_ctx { ++ struct v4l2_fh fh; ++ struct v4l2_format coded_fmt; ++ struct v4l2_format decoded_fmt; ++ const struct rkvdec2_coded_fmt_desc *coded_fmt_desc; ++ struct v4l2_ctrl_handler ctrl_hdl; ++ struct rkvdec2_dev *dev; ++ struct rkvdec2_aux_buf rcb_bufs[RKVDEC2_RCB_COUNT]; ++ ++ u32 colmv_offset; ++ ++ void *priv; ++}; ++ ++static inline struct rkvdec2_ctx *fh_to_rkvdec2_ctx(struct v4l2_fh *fh) ++{ ++ return container_of(fh, struct rkvdec2_ctx, fh); ++} ++ ++void rkvdec2_run_preamble(struct rkvdec2_ctx *ctx, struct rkvdec2_run *run); ++void rkvdec2_run_postamble(struct rkvdec2_ctx *ctx, struct rkvdec2_run *run); ++ ++extern const struct rkvdec2_coded_fmt_ops rkvdec2_h264_fmt_ops; ++ ++#endif /* RKVDEC_H_ */ +-- +Armbian + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Detlev Casanova +Date: Thu, 20 Jun 2024 10:19:46 -0400 +Subject: arm64: dts: rockchip: Add rkvdec2 Video Decoder on rk3588(s) + +Add the rkvdec2 Video Decoder to the RK3588s devicetree. + +Signed-off-by: Detlev Casanova +--- + arch/arm64/boot/dts/rockchip/rk3588s.dtsi | 48 ++++++++++ + 1 file changed, 48 insertions(+) + +diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi +index 111111111111..222222222222 100644 +--- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi ++++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi +@@ -3001,6 +3001,16 @@ system_sram2: sram@ff001000 { + ranges = <0x0 0x0 0xff001000 0xef000>; + #address-cells = <1>; + #size-cells = <1>; ++ ++ vdec0_sram: rkvdec-sram@0 { ++ reg = <0x0 0x78000>; ++ pool; ++ }; ++ ++ vdec1_sram: rkvdec-sram@1 { ++ reg = <0x78000 0x77000>; ++ pool; ++ }; + }; + + pinctrl: pinctrl { +@@ -3070,6 +3080,44 @@ gpio4: gpio@fec50000 { + #interrupt-cells = <2>; + }; + }; ++ ++ vdec0: video-decoder@fdc38100 { ++ compatible = "rockchip,rk3588-vdec"; ++ reg = <0x0 0xfdc38100 0x0 0x500>; ++ interrupts = ; ++ clocks = <&cru ACLK_RKVDEC0>, <&cru HCLK_RKVDEC0>, <&cru CLK_RKVDEC0_CA>, ++ <&cru CLK_RKVDEC0_CORE>, <&cru CLK_RKVDEC0_HEVC_CA>; ++ clock-names = "axi", "ahb", "cabac", "core", "hevc_cabac"; ++ assigned-clocks = <&cru ACLK_RKVDEC0>, <&cru CLK_RKVDEC0_CORE>, ++ <&cru CLK_RKVDEC0_CA>, <&cru CLK_RKVDEC0_HEVC_CA>; ++ assigned-clock-rates = <800000000>, <600000000>, ++ <600000000>, <1000000000>; ++ resets = <&cru SRST_A_RKVDEC0>, <&cru SRST_H_RKVDEC0>, <&cru SRST_RKVDEC0_CA>, ++ <&cru SRST_RKVDEC0_CORE>, <&cru SRST_RKVDEC0_HEVC_CA>; ++ reset-names = "rst_axi", "rst_ahb", "rst_cabac", ++ "rst_core", "rst_hevc_cabac"; ++ power-domains = <&power RK3588_PD_RKVDEC0>; ++ sram = <&vdec0_sram>; ++ }; ++ ++ vdec1: video-decoder@fdc40100 { ++ compatible = "rockchip,rk3588-vdec"; ++ reg = <0x0 0xfdc40100 0x0 0x500>; ++ interrupts = ; ++ clocks = <&cru ACLK_RKVDEC1>, <&cru HCLK_RKVDEC1>, <&cru CLK_RKVDEC1_CA>, ++ <&cru CLK_RKVDEC1_CORE>, <&cru CLK_RKVDEC1_HEVC_CA>; ++ clock-names = "axi", "ahb", "cabac", "core", "hevc_cabac"; ++ assigned-clocks = <&cru ACLK_RKVDEC1>, <&cru CLK_RKVDEC1_CORE>, ++ <&cru CLK_RKVDEC1_CA>, <&cru CLK_RKVDEC1_HEVC_CA>; ++ assigned-clock-rates = <800000000>, <600000000>, ++ <600000000>, <1000000000>; ++ resets = <&cru SRST_A_RKVDEC1>, <&cru SRST_H_RKVDEC1>, <&cru SRST_RKVDEC1_CA>, ++ <&cru SRST_RKVDEC1_CORE>, <&cru SRST_RKVDEC1_HEVC_CA>; ++ reset-names = "rst_axi", "rst_ahb", "rst_cabac", ++ "rst_core", "rst_hevc_cabac"; ++ power-domains = <&power RK3588_PD_RKVDEC1>; ++ sram = <&vdec1_sram>; ++ }; + }; + + #include "rk3588s-pinctrl.dtsi" +-- +Armbian + diff --git a/patch/kernel/archive/rockchip-rk3588-6.10/0028-media-v4l2-core-Initialize-h264-frame_mbs_only_flag-.patch b/patch/kernel/archive/rockchip-rk3588-6.10/0028-media-v4l2-core-Initialize-h264-frame_mbs_only_flag-.patch new file mode 100644 index 000000000000..13b5aecefc5b --- /dev/null +++ b/patch/kernel/archive/rockchip-rk3588-6.10/0028-media-v4l2-core-Initialize-h264-frame_mbs_only_flag-.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: amazingfate +Date: Fri, 21 Jun 2024 16:32:55 +0800 +Subject: media: v4l2-core: Initialize h264 frame_mbs_only_flag as 1 + +--- + drivers/media/v4l2-core/v4l2-ctrls-core.c | 13 ++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c +index 111111111111..222222222222 100644 +--- a/drivers/media/v4l2-core/v4l2-ctrls-core.c ++++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c +@@ -111,6 +111,7 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, + struct v4l2_ctrl_vp9_frame *p_vp9_frame; + struct v4l2_ctrl_fwht_params *p_fwht_params; + struct v4l2_ctrl_h264_scaling_matrix *p_h264_scaling_matrix; ++ struct v4l2_ctrl_h264_sps *p_h264_sps; + struct v4l2_ctrl_av1_sequence *p_av1_sequence; + void *p = ptr.p + idx * ctrl->elem_size; + +@@ -179,6 +180,18 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, + */ + memset(p_h264_scaling_matrix, 16, sizeof(*p_h264_scaling_matrix)); + break; ++ case V4L2_CTRL_TYPE_H264_SPS: ++ p_h264_sps = p; ++ /* ++ * Without V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY, ++ * frame_mbs_only_flag set to 0 will translate to a miniumum ++ * height of 32 (see H.264 specification 7-8). Some driver may ++ * have a minimum size lower then 32, which would fail ++ * validation with the SPS value. Set this flag, so that there ++ * is now doubling in the height, allowing a valid default. ++ */ ++ p_h264_sps->flags = V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY; ++ break; + } + } + +-- +Armbian + diff --git a/patch/kernel/archive/rockchip-rk3588-6.10/0138-arm64-dts-rockchip-Add-HDMI0-bridge-to-rk3588.patch b/patch/kernel/archive/rockchip-rk3588-6.10/0138-arm64-dts-rockchip-Add-HDMI0-bridge-to-rk3588.patch index 5bdbf4b672f2..0e5c748d021a 100644 --- a/patch/kernel/archive/rockchip-rk3588-6.10/0138-arm64-dts-rockchip-Add-HDMI0-bridge-to-rk3588.patch +++ b/patch/kernel/archive/rockchip-rk3588-6.10/0138-arm64-dts-rockchip-Add-HDMI0-bridge-to-rk3588.patch @@ -14,7 +14,7 @@ diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi b/arch/arm64/boot/dts/roc index 111111111111..222222222222 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi -@@ -1515,6 +1515,61 @@ i2s9_8ch: i2s@fddfc000 { +@@ -1516,6 +1516,61 @@ i2s9_8ch: i2s@fddfc000 { status = "disabled"; }; diff --git a/patch/kernel/archive/rockchip-rk3588-6.10/0139-arm64-dts-rockchip-Enable-HDMI0-PHY-clk-provider-on-.patch b/patch/kernel/archive/rockchip-rk3588-6.10/0139-arm64-dts-rockchip-Enable-HDMI0-PHY-clk-provider-on-.patch index 80d68c45e7f0..6013a8d65a2f 100644 --- a/patch/kernel/archive/rockchip-rk3588-6.10/0139-arm64-dts-rockchip-Enable-HDMI0-PHY-clk-provider-on-.patch +++ b/patch/kernel/archive/rockchip-rk3588-6.10/0139-arm64-dts-rockchip-Enable-HDMI0-PHY-clk-provider-on-.patch @@ -13,7 +13,7 @@ diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi b/arch/arm64/boot/dts/roc index 111111111111..222222222222 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi -@@ -2984,6 +2984,7 @@ hdptxphy_hdmi0: phy@fed60000 { +@@ -2985,6 +2985,7 @@ hdptxphy_hdmi0: phy@fed60000 { reg = <0x0 0xfed60000 0x0 0x2000>; clocks = <&cru CLK_USB2PHY_HDPTXRXPHY_REF>, <&cru PCLK_HDPTX0>; clock-names = "ref", "apb"; diff --git a/patch/kernel/archive/rockchip-rk3588-6.10/0170-drm-rockchip-vop2-add-clocks-reset-support.patch b/patch/kernel/archive/rockchip-rk3588-6.10/0170-drm-rockchip-vop2-add-clocks-reset-support.patch index e67dea963614..68ee38e939cb 100644 --- a/patch/kernel/archive/rockchip-rk3588-6.10/0170-drm-rockchip-vop2-add-clocks-reset-support.patch +++ b/patch/kernel/archive/rockchip-rk3588-6.10/0170-drm-rockchip-vop2-add-clocks-reset-support.patch @@ -102,7 +102,7 @@ diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi b/arch/arm64/boot/dts/roc index 111111111111..222222222222 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi -@@ -1348,6 +1348,14 @@ vop: vop@fdd90000 { +@@ -1429,6 +1429,14 @@ vop: vop@fdd90000 { "pclk_vop"; iommus = <&vop_mmu>; power-domains = <&power RK3588_PD_VOP>; diff --git a/patch/kernel/archive/rockchip-rk3588-6.10/dt/rk3588s-nanopi-r6s.dts b/patch/kernel/archive/rockchip-rk3588-6.10/dt/rk3588s-nanopi-r6s.dts index 42b9d72f4bfd..b39a3fc976b5 100644 --- a/patch/kernel/archive/rockchip-rk3588-6.10/dt/rk3588s-nanopi-r6s.dts +++ b/patch/kernel/archive/rockchip-rk3588-6.10/dt/rk3588s-nanopi-r6s.dts @@ -482,6 +482,8 @@ pinctrl-0 = <&pmic_pins>, <&rk806_dvs1_null>, <&rk806_dvs2_null>, <&rk806_dvs3_null>; + system-power-controller; + vcc1-supply = <&vcc5v0_sys>; vcc2-supply = <&vcc5v0_sys>; vcc3-supply = <&vcc5v0_sys>; diff --git a/patch/kernel/archive/rockchip-rk3588-6.8/dt/rk3588s-nanopi-r6s.dts b/patch/kernel/archive/rockchip-rk3588-6.8/dt/rk3588s-nanopi-r6s.dts index 42b9d72f4bfd..b39a3fc976b5 100644 --- a/patch/kernel/archive/rockchip-rk3588-6.8/dt/rk3588s-nanopi-r6s.dts +++ b/patch/kernel/archive/rockchip-rk3588-6.8/dt/rk3588s-nanopi-r6s.dts @@ -482,6 +482,8 @@ pinctrl-0 = <&pmic_pins>, <&rk806_dvs1_null>, <&rk806_dvs2_null>, <&rk806_dvs3_null>; + system-power-controller; + vcc1-supply = <&vcc5v0_sys>; vcc2-supply = <&vcc5v0_sys>; vcc3-supply = <&vcc5v0_sys>; diff --git a/patch/kernel/archive/sm8250-6.8/0000.patching_config.yaml b/patch/kernel/archive/sm8250-6.10/0000.patching_config.yaml similarity index 94% rename from patch/kernel/archive/sm8250-6.8/0000.patching_config.yaml rename to patch/kernel/archive/sm8250-6.10/0000.patching_config.yaml index a458d5ea166e..8fa367ff5ccb 100644 --- a/patch/kernel/archive/sm8250-6.8/0000.patching_config.yaml +++ b/patch/kernel/archive/sm8250-6.10/0000.patching_config.yaml @@ -1,11 +1,11 @@ config: # This is file 'patch/kernel/archive/sm8250-6.7/0000.patching_config.yaml' # Just some info stuff; not used by the patching scripts - name: sm8250-6.8 + name: sm8250-6.10 kind: kernel type: mainline # or: vendor - branch: linux-6.8.y - last-known-good-tag: v6.8.0 + branch: linux-6.10.y + last-known-good-tag: v6.10-rc2 maintainers: - { github: rpardini, name: Ricardo Pardini, email: ricardo@pardini.net, armbian-forum: rpardini } diff --git a/patch/kernel/archive/sm8250-6.7/dt/sm8250-xiaomi-umi-common.dtsi b/patch/kernel/archive/sm8250-6.10/dt/sm8250-xiaomi-umi-common.dtsi similarity index 100% rename from patch/kernel/archive/sm8250-6.7/dt/sm8250-xiaomi-umi-common.dtsi rename to patch/kernel/archive/sm8250-6.10/dt/sm8250-xiaomi-umi-common.dtsi diff --git a/patch/kernel/archive/sm8250-6.7/dt/sm8250-xiaomi-umi-csot.dts b/patch/kernel/archive/sm8250-6.10/dt/sm8250-xiaomi-umi-csot.dts similarity index 100% rename from patch/kernel/archive/sm8250-6.7/dt/sm8250-xiaomi-umi-csot.dts rename to patch/kernel/archive/sm8250-6.10/dt/sm8250-xiaomi-umi-csot.dts diff --git a/patch/kernel/archive/sm8250-6.7/dt/sm8250-xiaomi-umi-sms.dts b/patch/kernel/archive/sm8250-6.10/dt/sm8250-xiaomi-umi-sms.dts similarity index 100% rename from patch/kernel/archive/sm8250-6.7/dt/sm8250-xiaomi-umi-sms.dts rename to patch/kernel/archive/sm8250-6.10/dt/sm8250-xiaomi-umi-sms.dts diff --git a/patch/kernel/archive/sm8250-6.5/0001-drm-msm-dpu1-improve-support-for-active-CTLs.patch b/patch/kernel/archive/sm8250-6.5/0001-drm-msm-dpu1-improve-support-for-active-CTLs.patch deleted file mode 100644 index 8701076f42a6..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0001-drm-msm-dpu1-improve-support-for-active-CTLs.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sun, 14 Mar 2021 04:52:34 +0300 -Subject: drm/msm/dpu1: improve support for active CTLs - -- Support setting master interface if several INTFs are to be handled by - a single CTL - -- Support setting handling several MERGE_3D instances using a single - CTL. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 15 ++++++++++ - drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 2 ++ - 2 files changed, 17 insertions(+) - -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c -index 86182c734606..4ecffbcdba20 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c -@@ -510,6 +510,7 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx, - u32 intf_active = 0; - u32 wb_active = 0; - u32 mode_sel = 0; -+ u32 merge_3d_active = 0; - - /* CTL_TOP[31:28] carries group_id to collate CTL paths - * per VM. Explicitly disable it until VM support is -@@ -530,16 +531,30 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx, - if (cfg->wb) - wb_active |= BIT(cfg->wb - WB_0); - -+ merge_3d_active = DPU_REG_READ(c, CTL_MERGE_3D_ACTIVE); -+ if (cfg->merge_3d) -+ merge_3d_active |= BIT(cfg->merge_3d - MERGE_3D_0); -+ - DPU_REG_WRITE(c, CTL_TOP, mode_sel); - DPU_REG_WRITE(c, CTL_INTF_ACTIVE, intf_active); - DPU_REG_WRITE(c, CTL_WB_ACTIVE, wb_active); - -+ if (cfg->intf_master) -+ DPU_REG_WRITE(c, CTL_INTF_MASTER, BIT(cfg->intf_master - INTF_0)); -+ - if (cfg->merge_3d) - DPU_REG_WRITE(c, CTL_MERGE_3D_ACTIVE, - BIT(cfg->merge_3d - MERGE_3D_0)); - - if (cfg->dsc) - DPU_REG_WRITE(c, CTL_DSC_ACTIVE, cfg->dsc); -+ if (cfg->merge_3d) -+ DPU_REG_WRITE(c, CTL_MERGE_3D_ACTIVE, merge_3d_active); -+ -+ if (cfg->intf_master) -+ DPU_DEBUG_DRIVER("ACTIVE: %x %x %lx\n", intf_active, merge_3d_active, BIT(cfg->intf_master - INTF_0)); -+ else -+ DPU_DEBUG_DRIVER("ACTIVE: %x %x\n", intf_active, merge_3d_active); - } - - static void dpu_hw_ctl_intf_cfg(struct dpu_hw_ctl *ctx, -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h -index 1c242298ff2e..36dd4e91a0b4 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h -@@ -36,6 +36,7 @@ struct dpu_hw_stage_cfg { - /** - * struct dpu_hw_intf_cfg :Describes how the DPU writes data to output interface - * @intf : Interface id -+ * @intf_master: Master interface id in the dual pipe topology - * @mode_3d: 3d mux configuration - * @merge_3d: 3d merge block used - * @intf_mode_sel: Interface mode, cmd / vid -@@ -44,6 +45,7 @@ struct dpu_hw_stage_cfg { - */ - struct dpu_hw_intf_cfg { - enum dpu_intf intf; -+ enum dpu_intf intf_master; - enum dpu_wb wb; - enum dpu_3d_blend_mode mode_3d; - enum dpu_merge_3d merge_3d; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0002-drm-msm-dpu1-use-one-active-CTL-if-it-is-available.patch b/patch/kernel/archive/sm8250-6.5/0002-drm-msm-dpu1-use-one-active-CTL-if-it-is-available.patch deleted file mode 100644 index d12843f09b56..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0002-drm-msm-dpu1-use-one-active-CTL-if-it-is-available.patch +++ /dev/null @@ -1,136 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sun, 14 Mar 2021 04:58:32 +0300 -Subject: drm/msm/dpu1: use one active CTL if it is available - -Unlike previous generation, with newer ("active") CTLs it is possible to -use just one CTL to handle both interfaces. And one has to use single -CTL to support master/slave DSI config. So use one active CTL if it is -available. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_0_sm8150.h | 1 + - drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_6_0_sm8250.h | 1 + - drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 8 ++++-- - drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h | 1 + - drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 14 +++++++--- - drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 1 + - 6 files changed, 20 insertions(+), 6 deletions(-) - -diff --git a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_0_sm8150.h b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_0_sm8150.h -index 4589b7a04399..e81230fe6895 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_0_sm8150.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_0_sm8150.h -@@ -15,6 +15,7 @@ static const struct dpu_caps sm8150_dpu_caps = { - .has_dim_layer = true, - .has_idle_pc = true, - .has_3d_merge = true, -+ .has_active_ctls = true, - .max_linewidth = 4096, - .pixel_ram_size = DEFAULT_PIXEL_RAM_SIZE, - .max_hdeci_exp = MAX_HORZ_DECIMATION, -diff --git a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_6_0_sm8250.h b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_6_0_sm8250.h -index 0e17be6ed94f..04e85889c6ec 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_6_0_sm8250.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_6_0_sm8250.h -@@ -15,6 +15,7 @@ static const struct dpu_caps sm8250_dpu_caps = { - .has_dim_layer = true, - .has_idle_pc = true, - .has_3d_merge = true, -+ .has_active_ctls = true, - .max_linewidth = 4096, - .pixel_ram_size = DEFAULT_PIXEL_RAM_SIZE, - }; -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c -index 493905a5b63a..2e3c767d9427 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c -@@ -1107,14 +1107,18 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc, - return; - } - -- if (!hw_ctl[i]) { -+ /* Use first (and only) CTL if active CTLs are supported */ -+ if (dpu_kms->catalog->caps->has_active_ctls) -+ phys->hw_ctl = to_dpu_hw_ctl(hw_ctl[0]); -+ else -+ phys->hw_ctl = to_dpu_hw_ctl(hw_ctl[i]); -+ if (!phys->hw_ctl) { - DPU_ERROR_ENC(dpu_enc, - "no ctl block assigned at idx: %d\n", i); - return; - } - - phys->hw_pp = dpu_enc->hw_pp[i]; -- phys->hw_ctl = to_dpu_hw_ctl(hw_ctl[i]); - - phys->cached_mode = crtc_state->adjusted_mode; - if (phys->ops.atomic_mode_set) -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h -index b860784ade72..0a290add46ad 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h -@@ -382,6 +382,7 @@ struct dpu_caps { - bool has_dim_layer; - bool has_idle_pc; - bool has_3d_merge; -+ bool has_active_ctls; - /* SSPP limits */ - u32 max_linewidth; - u32 pixel_ram_size; -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c -index 471842bbb950..978d03e4988e 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c -@@ -195,6 +195,7 @@ int dpu_rm_init(struct dpu_rm *rm, - } - rm->ctl_blks[ctl->id - CTL_0] = &hw->base; - } -+ rm->has_active_ctls = cat->caps->has_active_ctls; - - for (i = 0; i < cat->dspp_count; i++) { - struct dpu_hw_dspp *hw; -@@ -427,10 +428,15 @@ static int _dpu_rm_reserve_ctls( - int i = 0, j, num_ctls; - bool needs_split_display; - -- /* each hw_intf needs its own hw_ctrl to program its control path */ -- num_ctls = top->num_intf; -+ if (rm->has_active_ctls) { -+ num_ctls = 1; -+ needs_split_display = false; -+ } else { -+ /* each hw_intf needs its own hw_ctrl to program its control path */ -+ num_ctls = top->num_intf; - -- needs_split_display = _dpu_rm_needs_split_display(top); -+ needs_split_display = _dpu_rm_needs_split_display(top); -+ } - - for (j = 0; j < ARRAY_SIZE(rm->ctl_blks); j++) { - const struct dpu_hw_ctl *ctl; -@@ -448,7 +454,7 @@ static int _dpu_rm_reserve_ctls( - - DPU_DEBUG("ctl %d caps 0x%lX\n", j + CTL_0, features); - -- if (needs_split_display != has_split_display) -+ if (!rm->has_active_ctls && needs_split_display != has_split_display) - continue; - - ctl_idx[i] = j; -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h -index d62c2edb2460..d1b55482b8b1 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h -@@ -33,6 +33,7 @@ struct dpu_rm { - struct dpu_hw_blk *merge_3d_blks[MERGE_3D_MAX - MERGE_3D_0]; - struct dpu_hw_blk *dsc_blks[DSC_MAX - DSC_0]; - struct dpu_hw_sspp *hw_sspp[SSPP_MAX - SSPP_NONE]; -+ bool has_active_ctls; - }; - - /** --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0003-drm-msm-dpu1-dpu_encoder_phys_-proper-suppor-for-act.patch b/patch/kernel/archive/sm8250-6.5/0003-drm-msm-dpu1-dpu_encoder_phys_-proper-suppor-for-act.patch deleted file mode 100644 index e4d4c1bfb4f8..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0003-drm-msm-dpu1-dpu_encoder_phys_-proper-suppor-for-act.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sun, 14 Mar 2021 05:03:35 +0300 -Subject: drm/msm/dpu1: dpu_encoder_phys_*: proper suppor for active CTLs - -Adapt dpu_encoder_phys_* to properly support active CTLs and their -features. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 2 ++ - drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 5 ++++- - 2 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c -index b856c6286c85..c821b6a53b12 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c -@@ -56,6 +56,8 @@ static void _dpu_encoder_phys_cmd_update_intf_cfg( - return; - - intf_cfg.intf = phys_enc->hw_intf->idx; -+ if (phys_enc->split_role == ENC_ROLE_MASTER) -+ intf_cfg.intf_master = phys_enc->hw_intf->idx; - intf_cfg.intf_mode_sel = DPU_CTL_MODE_SEL_CMD; - intf_cfg.stream_sel = cmd_enc->stream_sel; - intf_cfg.mode_3d = dpu_encoder_helper_get_3d_blend_mode(phys_enc); -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c -index 662d74ded1b9..a379d0e3a3f7 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c -@@ -271,6 +271,8 @@ static void dpu_encoder_phys_vid_setup_timing_engine( - DPU_DEBUG_VIDENC(phys_enc, "fmt_fourcc 0x%X\n", fmt_fourcc); - - intf_cfg.intf = phys_enc->hw_intf->idx; -+ if (phys_enc->split_role == ENC_ROLE_MASTER) -+ intf_cfg.intf_master = phys_enc->hw_intf->idx; - intf_cfg.intf_mode_sel = DPU_CTL_MODE_SEL_VID; - intf_cfg.stream_sel = 0; /* Don't care value for video mode */ - intf_cfg.mode_3d = dpu_encoder_helper_get_3d_blend_mode(phys_enc); -@@ -344,7 +346,8 @@ static void dpu_encoder_phys_vid_underrun_irq(void *arg, int irq_idx) - static bool dpu_encoder_phys_vid_needs_single_flush( - struct dpu_encoder_phys *phys_enc) - { -- return phys_enc->split_role != ENC_ROLE_SOLO; -+ return !(phys_enc->hw_ctl->caps->features & BIT(DPU_CTL_ACTIVE_CFG)) && -+ phys_enc->split_role != ENC_ROLE_SOLO; - } - - static void dpu_encoder_phys_vid_atomic_mode_set( --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0004-dt-bindings-mfd-qcom-qca639x-add-binding-for-QCA639x.patch b/patch/kernel/archive/sm8250-6.5/0004-dt-bindings-mfd-qcom-qca639x-add-binding-for-QCA639x.patch deleted file mode 100644 index 5a17b7e1029c..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0004-dt-bindings-mfd-qcom-qca639x-add-binding-for-QCA639x.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sun, 20 Dec 2020 18:47:57 +0300 -Subject: dt-bindings: mfd: qcom,qca639x: add binding for QCA639x defvice - -Qualcomm QCA639x is a family of WiFi + Bluetooth SoCs, with BT part -being controlled through the UART and WiFi being present on PCIe bus. -Both blocks share common power sources. Add binding to describe power -sequencing required to power up this device. - -Signed-off-by: Dmitry Baryshkov ---- - Documentation/devicetree/bindings/mfd/qcom,qca639x.yaml | 84 ++++++++++ - 1 file changed, 84 insertions(+) - -diff --git a/Documentation/devicetree/bindings/mfd/qcom,qca639x.yaml b/Documentation/devicetree/bindings/mfd/qcom,qca639x.yaml -new file mode 100644 -index 000000000000..d43c75da136f ---- /dev/null -+++ b/Documentation/devicetree/bindings/mfd/qcom,qca639x.yaml -@@ -0,0 +1,84 @@ -+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) -+%YAML 1.2 -+--- -+$id: "http://devicetree.org/schemas/mfd/qcom,qca639x.yaml#" -+$schema: "http://devicetree.org/meta-schemas/core.yaml#" -+ -+title: Qualcomm QCA639x WiFi + Bluetoot SoC bindings -+ -+maintainers: -+ - Andy Gross -+ - Bjorn Andersson -+ -+description: | -+ This binding describes thes Qualcomm QCA6390 or QCA6391 power supplies and -+ enablement pins. -+ -+properties: -+ compatible: -+ const: qcom,qca639x -+ -+ '#power-domain-cells': -+ const: 0 -+ -+ pinctrl-0: true -+ pinctrl-1: true -+ -+ pinctrl-names: -+ items: -+ - const: default -+ - const: active -+ -+ vddaon-supply: -+ description: -+ 0.95V always-on LDO power input -+ -+ vddpmu-supply: -+ description: -+ 0.95V LDO power input to PMU -+ -+ vddrfa1-supply: -+ description: -+ 0.95V LDO power input to RFA -+ -+ vddrfa2-supply: -+ description: -+ 1.25V LDO power input to RFA -+ -+ vddrfa3-supply: -+ description: -+ 2V LDO power input to RFA -+ -+ vddpcie1-supply: -+ description: -+ 1.25V LDO power input to PCIe part -+ -+ vddpcie2-supply: -+ description: -+ 2V LDO power input to PCIe part -+ -+ vddio-supply: -+ description: -+ 1.8V VIO input -+ -+additionalProperties: false -+ -+examples: -+ - | -+ qca639x: qca639x { -+ compatible = "qcom,qca639x"; -+ #power-domain-cells = <0>; -+ -+ vddaon-supply = <&vreg_s6a_0p95>; -+ vddpmu-supply = <&vreg_s2f_0p95>; -+ vddrfa1-supply = <&vreg_s2f_0p95>; -+ vddrfa2-supply = <&vreg_s8c_1p3>; -+ vddrfa3-supply = <&vreg_s5a_1p9>; -+ vddpcie1-supply = <&vreg_s8c_1p3>; -+ vddpcie2-supply = <&vreg_s5a_1p9>; -+ vddio-supply = <&vreg_s4a_1p8>; -+ pinctrl-names = "default", "active"; -+ pinctrl-0 = <&wlan_default_state &bt_default_state>; -+ pinctrl-1 = <&wlan_active_state &bt_active_state>; -+ }; -+... --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0005-mfd-qca639x-add-support-for-QCA639x-powerup-sequence.patch b/patch/kernel/archive/sm8250-6.5/0005-mfd-qca639x-add-support-for-QCA639x-powerup-sequence.patch deleted file mode 100644 index a519dc117691..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0005-mfd-qca639x-add-support-for-QCA639x-powerup-sequence.patch +++ /dev/null @@ -1,223 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Fri, 18 Dec 2020 16:24:56 +0300 -Subject: mfd: qca639x: add support for QCA639x powerup sequence - -Qualcomm QCA639x is a family of WiFi + Bluetooth SoCs, with BT part -being controlled through the UART and WiFi being present on PCIe -bus. Both blocks share common power sources. So add mfd device driver -handling power sequencing of QCA6390/1. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/mfd/Kconfig | 12 + - drivers/mfd/Makefile | 1 + - drivers/mfd/qcom-qca639x.c | 162 ++++++++++ - 3 files changed, 175 insertions(+) - -diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig -index f6b519eaaa71..eda2ae2ac764 100644 ---- a/drivers/mfd/Kconfig -+++ b/drivers/mfd/Kconfig -@@ -1099,6 +1099,18 @@ config MFD_PM8XXX - Say M here if you want to include support for PM8xxx chips as a - module. This will build a module called "pm8xxx-core". - -+config MFD_QCOM_QCA639X -+ tristate "Qualcomm QCA639x WiFi/Bluetooth module support" -+ depends on REGULATOR && PM_GENERIC_DOMAINS -+ help -+ If you say yes to this option, support will be included for Qualcomm -+ QCA639x family of WiFi and Bluetooth SoCs. Note, this driver supports -+ only power control for this SoC, you still have to enable individual -+ Bluetooth and WiFi drivers. -+ -+ Say M here if you want to include support for QCA639x chips as a -+ module. This will build a module called "qcom-qca639x". -+ - config MFD_QCOM_RPM - tristate "Qualcomm Resource Power Manager (RPM)" - depends on ARCH_QCOM && OF -diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile -index f3d1f1dc73b5..954bb5f992ae 100644 ---- a/drivers/mfd/Makefile -+++ b/drivers/mfd/Makefile -@@ -201,6 +201,7 @@ obj-$(CONFIG_MFD_SI476X_CORE) += si476x-core.o - obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o - obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o omap-usb-tll.o - obj-$(CONFIG_MFD_PM8XXX) += qcom-pm8xxx.o ssbi.o -+obj-$(CONFIG_MFD_QCOM_QCA639X) += qcom-qca639x.o - obj-$(CONFIG_MFD_QCOM_RPM) += qcom_rpm.o - obj-$(CONFIG_MFD_SPMI_PMIC) += qcom-spmi-pmic.o - obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o -diff --git a/drivers/mfd/qcom-qca639x.c b/drivers/mfd/qcom-qca639x.c -new file mode 100644 -index 000000000000..b31e4b65bec5 ---- /dev/null -+++ b/drivers/mfd/qcom-qca639x.c -@@ -0,0 +1,162 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define MAX_NUM_REGULATORS 8 -+ -+static struct vreg { -+ const char *name; -+ unsigned int load_uA; -+} vregs [MAX_NUM_REGULATORS] = { -+ /* 2.0 V */ -+ { "vddpcie2", 15000 }, -+ { "vddrfa3", 400000 }, -+ -+ /* 0.95 V */ -+ { "vddaon", 100000 }, -+ { "vddpmu", 1250000 }, -+ { "vddrfa1", 200000 }, -+ -+ /* 1.35 V */ -+ { "vddrfa2", 400000 }, -+ { "vddpcie1", 35000 }, -+ -+ /* 1.8 V */ -+ { "vddio", 20000 }, -+}; -+ -+struct qca639x_data { -+ struct regulator_bulk_data regulators[MAX_NUM_REGULATORS]; -+ size_t num_vregs; -+ struct device *dev; -+ struct pinctrl_state *active_state; -+ struct generic_pm_domain pd; -+}; -+ -+#define domain_to_data(domain) container_of(domain, struct qca639x_data, pd) -+ -+static int qca639x_power_on(struct generic_pm_domain *domain) -+{ -+ struct qca639x_data *data = domain_to_data(domain); -+ int ret; -+ -+ dev_warn(&domain->dev, "DUMMY POWER ON\n"); -+ -+ ret = regulator_bulk_enable(data->num_vregs, data->regulators); -+ if (ret) { -+ dev_err(data->dev, "Failed to enable regulators"); -+ return ret; -+ } -+ -+ /* Wait for 1ms before toggling enable pins. */ -+ msleep(1); -+ -+ ret = pinctrl_select_state(data->dev->pins->p, data->active_state); -+ if (ret) { -+ dev_err(data->dev, "Failed to select active state"); -+ return ret; -+ } -+ -+ /* Wait for all power levels to stabilize */ -+ msleep(6); -+ -+ return 0; -+} -+ -+static int qca639x_power_off(struct generic_pm_domain *domain) -+{ -+ struct qca639x_data *data = domain_to_data(domain); -+ -+ dev_warn(&domain->dev, "DUMMY POWER OFF\n"); -+ -+ pinctrl_select_default_state(data->dev); -+ regulator_bulk_disable(data->num_vregs, data->regulators); -+ -+ return 0; -+} -+ -+static int qca639x_probe(struct platform_device *pdev) -+{ -+ struct qca639x_data *data; -+ struct device *dev = &pdev->dev; -+ int i, ret; -+ -+ if (!dev->pins || IS_ERR_OR_NULL(dev->pins->default_state)) -+ return -EINVAL; -+ -+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); -+ if (!data) -+ return -ENOMEM; -+ -+ data->dev = dev; -+ data->num_vregs = ARRAY_SIZE(vregs); -+ -+ data->active_state = pinctrl_lookup_state(dev->pins->p, "active"); -+ if (IS_ERR(data->active_state)) { -+ ret = PTR_ERR(data->active_state); -+ dev_err(dev, "Failed to get active_state: %d\n", ret); -+ return ret; -+ } -+ -+ for (i = 0; i < data->num_vregs; i++) -+ data->regulators[i].supply = vregs[i].name; -+ ret = devm_regulator_bulk_get(dev, data->num_vregs, data->regulators); -+ if (ret < 0) -+ return ret; -+ -+ for (i = 0; i < data->num_vregs; i++) { -+ ret = regulator_set_load(data->regulators[i].consumer, vregs[i].load_uA); -+ if (ret) -+ return ret; -+ } -+ -+ data->pd.name = dev_name(dev); -+ data->pd.power_on = qca639x_power_on; -+ data->pd.power_off = qca639x_power_off; -+ -+ ret = pm_genpd_init(&data->pd, NULL, true); -+ if (ret < 0) -+ return ret; -+ -+ ret = of_genpd_add_provider_simple(dev->of_node, &data->pd); -+ if (ret < 0) { -+ pm_genpd_remove(&data->pd); -+ return ret; -+ } -+ -+ platform_set_drvdata(pdev, data); -+ -+ return 0; -+} -+ -+static int qca639x_remove(struct platform_device *pdev) -+{ -+ struct qca639x_data *data = platform_get_drvdata(pdev); -+ -+ pm_genpd_remove(&data->pd); -+ -+ return 0; -+} -+ -+static const struct of_device_id qca639x_of_match[] = { -+ { .compatible = "qcom,qca639x" }, -+}; -+ -+static struct platform_driver qca639x_driver = { -+ .probe = qca639x_probe, -+ .remove = qca639x_remove, -+ .driver = { -+ .name = "qca639x", -+ .of_match_table = qca639x_of_match, -+ }, -+}; -+ -+module_platform_driver(qca639x_driver); -+MODULE_LICENSE("GPL v2"); --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0009-drm-Add-drm-notifier-support.patch b/patch/kernel/archive/sm8250-6.5/0009-drm-Add-drm-notifier-support.patch deleted file mode 100644 index 4b05ac6fce40..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0009-drm-Add-drm-notifier-support.patch +++ /dev/null @@ -1,135 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Thu, 4 Aug 2022 13:26:53 +0800 -Subject: drm: Add drm notifier support - ---- - drivers/gpu/drm/Makefile | 3 +- - drivers/gpu/drm/drm_notifier.c | 57 ++++++++++ - include/drm/drm_notifier.h | 37 ++++++ - 3 files changed, 96 insertions(+), 1 deletion(-) - -diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile -index 7a09a89b493b..8e18dbb6986c 100644 ---- a/drivers/gpu/drm/Makefile -+++ b/drivers/gpu/drm/Makefile -@@ -45,7 +45,8 @@ drm-y := \ - drm_vblank.o \ - drm_vblank_work.o \ - drm_vma_manager.o \ -- drm_writeback.o -+ drm_writeback.o \ -+ drm_notifier.o - drm-$(CONFIG_DRM_LEGACY) += \ - drm_agpsupport.o \ - drm_bufs.o \ -diff --git a/drivers/gpu/drm/drm_notifier.c b/drivers/gpu/drm/drm_notifier.c -new file mode 100644 -index 000000000000..792069640ea7 ---- /dev/null -+++ b/drivers/gpu/drm/drm_notifier.c -@@ -0,0 +1,57 @@ -+/* -+ * Copyright (c) 2019, The Linux Foundation. All rights reserved. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 and -+ * only version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ */ -+ -+#include -+ -+static BLOCKING_NOTIFIER_HEAD(mi_drm_notifier_list); -+ -+/** -+ * mi_drm_register_client - register a client notifier -+ * @nb: notifier block to callback on events -+ * -+ * This function registers a notifier callback function -+ * to msm_drm_notifier_list, which would be called when -+ * received unblank/power down event. -+ */ -+int mi_drm_register_client(struct notifier_block *nb) -+{ -+ return blocking_notifier_chain_register(&mi_drm_notifier_list, nb); -+} -+EXPORT_SYMBOL(mi_drm_register_client); -+ -+/** -+ * mi_drm_unregister_client - unregister a client notifier -+ * @nb: notifier block to callback on events -+ * -+ * This function unregisters the callback function from -+ * msm_drm_notifier_list. -+ */ -+int mi_drm_unregister_client(struct notifier_block *nb) -+{ -+ return blocking_notifier_chain_unregister(&mi_drm_notifier_list, nb); -+} -+EXPORT_SYMBOL(mi_drm_unregister_client); -+ -+/** -+ * mi_drm_notifier_call_chain - notify clients of drm_events -+ * @val: event MSM_DRM_EARLY_EVENT_BLANK or MSM_DRM_EVENT_BLANK -+ * @v: notifier data, inculde display id and display blank -+ * event(unblank or power down). -+ */ -+int mi_drm_notifier_call_chain(unsigned long val, void *v) -+{ -+ return blocking_notifier_call_chain(&mi_drm_notifier_list, val, v); -+} -+EXPORT_SYMBOL(mi_drm_notifier_call_chain); -\ No newline at end of file -diff --git a/include/drm/drm_notifier.h b/include/drm/drm_notifier.h -new file mode 100644 -index 000000000000..fd0e976559b8 ---- /dev/null -+++ b/include/drm/drm_notifier.h -@@ -0,0 +1,37 @@ -+/* -+ * Copyright (c) 2019, The Linux Foundation. All rights reserved. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 and -+ * only version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ */ -+ -+#ifndef _DRM_NOTIFIER_H_ -+#define _DRM_NOTIFIER_H_ -+ -+#include -+ -+/* A hardware display blank change occurred */ -+#define MI_DRM_EVENT_BLANK 0x01 -+/* A hardware display blank early change occurred */ -+#define MI_DRM_EARLY_EVENT_BLANK 0x02 -+ -+enum drm_notifier_data { -+ /* panel: power on */ -+ MI_DRM_BLANK_UNBLANK, -+ /* panel: power down */ -+ MI_DRM_BLANK_POWERDOWN, -+}; -+ -+int mi_drm_register_client(struct notifier_block *nb); -+int mi_drm_unregister_client(struct notifier_block *nb); -+int mi_drm_notifier_call_chain(unsigned long val, void *v); -+ -+#endif /* _DRM_NOTIFIER_H */ --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0010-drm-dsi-emit-panel-turn-on-off-signal-to-touchscreen.patch b/patch/kernel/archive/sm8250-6.5/0010-drm-dsi-emit-panel-turn-on-off-signal-to-touchscreen.patch deleted file mode 100644 index ec52243de5ca..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0010-drm-dsi-emit-panel-turn-on-off-signal-to-touchscreen.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Mon, 17 Oct 2022 08:02:58 +0800 -Subject: drm: dsi: emit panel turn on/off signal to touchscreen - ---- - drivers/gpu/drm/msm/dsi/dsi_manager.c | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c -index 28b8012a21f2..f9d05c711c2f 100644 ---- a/drivers/gpu/drm/msm/dsi/dsi_manager.c -+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c -@@ -7,6 +7,7 @@ - - #include "msm_kms.h" - #include "dsi.h" -+#include "drm/drm_notifier.h" - - #define DSI_CLOCK_MASTER DSI_0 - #define DSI_CLOCK_SLAVE DSI_1 -@@ -303,6 +304,7 @@ static void dsi_mgr_bridge_pre_enable(struct drm_bridge *bridge) - struct mipi_dsi_host *host = msm_dsi->host; - bool is_bonded_dsi = IS_BONDED_DSI(); - int ret; -+ enum drm_notifier_data notifier_data; - - DBG("id=%d", id); - if (!msm_dsi_device_connected(msm_dsi)) -@@ -318,6 +320,9 @@ static void dsi_mgr_bridge_pre_enable(struct drm_bridge *bridge) - return; - } - -+ notifier_data = MI_DRM_BLANK_UNBLANK; -+ mi_drm_notifier_call_chain(MI_DRM_EVENT_BLANK, ¬ifier_data); -+ - ret = msm_dsi_host_enable(host); - if (ret) { - pr_err("%s: enable host %d failed, %d\n", __func__, id, ret); -@@ -361,12 +366,16 @@ static void dsi_mgr_bridge_post_disable(struct drm_bridge *bridge) - struct mipi_dsi_host *host = msm_dsi->host; - bool is_bonded_dsi = IS_BONDED_DSI(); - int ret; -+ enum drm_notifier_data notifier_data; - - DBG("id=%d", id); - - if (!msm_dsi_device_connected(msm_dsi)) - return; - -+ notifier_data = MI_DRM_BLANK_POWERDOWN; -+ mi_drm_notifier_call_chain(MI_DRM_EARLY_EVENT_BLANK, ¬ifier_data); -+ - /* - * Do nothing with the host if it is slave-DSI in case of bonded DSI. - * It is safe to call dsi_mgr_phy_disable() here because a single PHY --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0011-Input-Add-nt36523-touchscreen-driver.patch b/patch/kernel/archive/sm8250-6.5/0011-Input-Add-nt36523-touchscreen-driver.patch deleted file mode 100644 index a0c02f0bd248..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0011-Input-Add-nt36523-touchscreen-driver.patch +++ /dev/null @@ -1,3491 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Thu, 4 Aug 2022 13:26:26 +0800 -Subject: Input: Add nt36523 touchscreen driver - ---- - drivers/input/touchscreen/Kconfig | 2 + - drivers/input/touchscreen/Makefile | 1 + - drivers/input/touchscreen/nt36523/Kconfig | 11 + - drivers/input/touchscreen/nt36523/Makefile | 8 + - drivers/input/touchscreen/nt36523/nt36xxx.c | 1908 ++++++++++ - drivers/input/touchscreen/nt36523/nt36xxx.h | 240 ++ - drivers/input/touchscreen/nt36523/nt36xxx_fw_update.c | 857 +++++ - drivers/input/touchscreen/nt36523/nt36xxx_mem_map.h | 390 ++ - 8 files changed, 3417 insertions(+) - -diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig -index c2cbd332af1d..5bc85a3c7bb8 100644 ---- a/drivers/input/touchscreen/Kconfig -+++ b/drivers/input/touchscreen/Kconfig -@@ -12,6 +12,8 @@ menuconfig INPUT_TOUCHSCREEN - - if INPUT_TOUCHSCREEN - -+source "drivers/input/touchscreen/nt36523/Kconfig" -+ - config TOUCHSCREEN_88PM860X - tristate "Marvell 88PM860x touchscreen" - depends on MFD_88PM860X -diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile -index 159cd5136fdb..9b99430d79d6 100644 ---- a/drivers/input/touchscreen/Makefile -+++ b/drivers/input/touchscreen/Makefile -@@ -117,3 +117,4 @@ obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o - obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o - obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o - obj-$(CONFIG_TOUCHSCREEN_HIMAX_HX83112B) += himax_hx83112b.o -+obj-$(CONFIG_TOUCHSCREEN_NT36523_SPI) += nt36523/ -diff --git a/drivers/input/touchscreen/nt36523/Kconfig b/drivers/input/touchscreen/nt36523/Kconfig -new file mode 100644 -index 000000000000..5f4ef5abfd6a ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/Kconfig -@@ -0,0 +1,11 @@ -+# -+# Novatek NT36523 touchscreen driver configuration -+# -+config TOUCHSCREEN_NT36523_SPI -+ tristate "Novatek NT36523 no flash SPI driver" -+ default n -+ help -+ Say Y here if you have a Novatek NT36523 no flash touchscreen connected -+ to your system by SPI bus. -+ -+ If unsure, say N. -diff --git a/drivers/input/touchscreen/nt36523/Makefile b/drivers/input/touchscreen/nt36523/Makefile -new file mode 100644 -index 000000000000..d16afc8f127f ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/Makefile -@@ -0,0 +1,8 @@ -+# -+# Makefile for the Novatek NT36523 touchscreen driver. -+# -+ -+# Each configuration option enables a list of files. -+obj-$(CONFIG_TOUCHSCREEN_NT36523_SPI) += nt36523_ts.o -+nt36523_ts-y := nt36xxx.o \ -+ nt36xxx_fw_update.o -diff --git a/drivers/input/touchscreen/nt36523/nt36xxx.c b/drivers/input/touchscreen/nt36523/nt36xxx.c -new file mode 100644 -index 000000000000..45500ad5cd91 ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/nt36xxx.c -@@ -0,0 +1,1908 @@ -+/* -+ * Copyright (C) 2010 - 2018 Novatek, Inc. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * $Revision: 73033 $ -+ * $Date: 2020-11-26 10:09:14 +0800 (週四, 26 十一月 2020) $ -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ * more details. -+ * -+ */ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#ifdef CONFIG_DRM -+#include -+#endif -+ -+#include "nt36xxx.h" -+ -+#if NVT_TOUCH_ESD_PROTECT -+#include -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+#if NVT_TOUCH_ESD_PROTECT -+static struct delayed_work nvt_esd_check_work; -+static struct workqueue_struct *nvt_esd_check_wq; -+static unsigned long irq_timer = 0; -+uint8_t esd_check = false; -+uint8_t esd_retry = 0; -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+struct nvt_ts_data *ts; -+ -+#if BOOT_UPDATE_FIRMWARE -+static struct workqueue_struct *nvt_fwu_wq; -+extern void Boot_Update_Firmware(struct work_struct *work); -+#endif -+ -+#ifdef CONFIG_DRM -+static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data); -+#endif -+ -+static int32_t nvt_ts_suspend(struct device *dev); -+static int32_t nvt_ts_resume(struct device *dev); -+ -+uint32_t ENG_RST_ADDR = 0x7FFF80; -+uint32_t SWRST_N8_ADDR = 0; //read from dtsi -+uint32_t SPI_RD_FAST_ADDR = 0; //read from dtsi -+ -+#if TOUCH_KEY_NUM > 0 -+const uint16_t touch_key_array[TOUCH_KEY_NUM] = { -+ KEY_BACK, -+ KEY_HOME, -+ KEY_MENU -+}; -+#endif -+ -+static uint8_t bTouchIsAwake = 0; -+ -+/******************************************************* -+Description: -+ Novatek touchscreen irq enable/disable function. -+ -+return: -+ n.a. -+*******************************************************/ -+static void nvt_irq_enable(bool enable) -+{ -+ if (enable) { -+ if (!ts->irq_enabled) { -+ enable_irq(ts->client->irq); -+ ts->irq_enabled = true; -+ } -+ } else { -+ if (ts->irq_enabled) { -+ disable_irq(ts->client->irq); -+ ts->irq_enabled = false; -+ } -+ } -+} -+ -+static inline int32_t spi_read_write(struct spi_device *client, uint8_t *buf, size_t len , NVT_SPI_RW rw) -+{ -+ struct spi_message m; -+ struct spi_transfer t = { -+ .len = len, -+ }; -+ -+ memset(ts->xbuf, 0, len + DUMMY_BYTES); -+ memcpy(ts->xbuf, buf, len); -+ -+ switch (rw) { -+ case NVTREAD: -+ t.tx_buf = ts->xbuf; -+ t.rx_buf = ts->rbuf; -+ t.len = (len + DUMMY_BYTES); -+ break; -+ -+ case NVTWRITE: -+ t.tx_buf = ts->xbuf; -+ break; -+ } -+ -+ spi_message_init(&m); -+ spi_message_add_tail(&t, &m); -+ return spi_sync(client, &m); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen spi read function. -+ -+return: -+ Executive outcomes. 2---succeed. -5---I/O error -+*******************************************************/ -+int32_t CTP_SPI_READ(struct spi_device *client, uint8_t *buf, uint16_t len) -+{ -+ int32_t ret = -1; -+ int32_t retries = 0; -+ -+ mutex_lock(&ts->xbuf_lock); -+ -+ buf[0] = SPI_READ_MASK(buf[0]); -+ -+ while (retries < 5) { -+ ret = spi_read_write(client, buf, len, NVTREAD); -+ if (ret == 0) break; -+ retries++; -+ } -+ -+ if (unlikely(retries == 5)) { -+ NVT_ERR("read error, ret=%d\n", ret); -+ ret = -EIO; -+ } else { -+ memcpy((buf+1), (ts->rbuf+2), (len-1)); -+ } -+ -+ mutex_unlock(&ts->xbuf_lock); -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen spi write function. -+ -+return: -+ Executive outcomes. 1---succeed. -5---I/O error -+*******************************************************/ -+int32_t CTP_SPI_WRITE(struct spi_device *client, uint8_t *buf, uint16_t len) -+{ -+ int32_t ret = -1; -+ int32_t retries = 0; -+ -+ mutex_lock(&ts->xbuf_lock); -+ -+ buf[0] = SPI_WRITE_MASK(buf[0]); -+ -+ while (retries < 5) { -+ ret = spi_read_write(client, buf, len, NVTWRITE); -+ if (ret == 0) break; -+ retries++; -+ } -+ -+ if (unlikely(retries == 5)) { -+ NVT_ERR("error, ret=%d\n", ret); -+ ret = -EIO; -+ } -+ -+ mutex_unlock(&ts->xbuf_lock); -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen set index/page/addr address. -+ -+return: -+ Executive outcomes. 0---succeed. -5---access fail. -+*******************************************************/ -+int32_t nvt_set_page(uint32_t addr) -+{ -+ uint8_t buf[4] = {0}; -+ -+ buf[0] = 0xFF; //set index/page/addr command -+ buf[1] = (addr >> 15) & 0xFF; -+ buf[2] = (addr >> 7) & 0xFF; -+ -+ return CTP_SPI_WRITE(ts->client, buf, 3); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen write data to specify address. -+ -+return: -+ Executive outcomes. 0---succeed. -5---access fail. -+*******************************************************/ -+int32_t nvt_write_addr(uint32_t addr, uint8_t data) -+{ -+ int32_t ret = 0; -+ uint8_t buf[4] = {0}; -+ -+ //---set xdata index--- -+ buf[0] = 0xFF; //set index/page/addr command -+ buf[1] = (addr >> 15) & 0xFF; -+ buf[2] = (addr >> 7) & 0xFF; -+ ret = CTP_SPI_WRITE(ts->client, buf, 3); -+ if (ret) { -+ NVT_ERR("set page 0x%06X failed, ret = %d\n", addr, ret); -+ return ret; -+ } -+ -+ //---write data to index--- -+ buf[0] = addr & (0x7F); -+ buf[1] = data; -+ ret = CTP_SPI_WRITE(ts->client, buf, 2); -+ if (ret) { -+ NVT_ERR("write data to 0x%06X failed, ret = %d\n", addr, ret); -+ return ret; -+ } -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen enable hw bld crc function. -+ -+return: -+ N/A. -+*******************************************************/ -+void nvt_bld_crc_enable(void) -+{ -+ uint8_t buf[4] = {0}; -+ -+ //---set xdata index to BLD_CRC_EN_ADDR--- -+ nvt_set_page(ts->mmap->BLD_CRC_EN_ADDR); -+ -+ //---read data from index--- -+ buf[0] = ts->mmap->BLD_CRC_EN_ADDR & (0x7F); -+ buf[1] = 0xFF; -+ CTP_SPI_READ(ts->client, buf, 2); -+ -+ //---write data to index--- -+ buf[0] = ts->mmap->BLD_CRC_EN_ADDR & (0x7F); -+ buf[1] = buf[1] | (0x01 << 7); -+ CTP_SPI_WRITE(ts->client, buf, 2); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen clear status & enable fw crc function. -+ -+return: -+ N/A. -+*******************************************************/ -+void nvt_fw_crc_enable(void) -+{ -+ uint8_t buf[4] = {0}; -+ -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR); -+ -+ //---clear fw reset status--- -+ buf[0] = EVENT_MAP_RESET_COMPLETE & (0x7F); -+ buf[1] = 0x00; -+ CTP_SPI_WRITE(ts->client, buf, 2); -+ -+ //---enable fw crc--- -+ buf[0] = EVENT_MAP_HOST_CMD & (0x7F); -+ buf[1] = 0xAE; //enable fw crc command -+ CTP_SPI_WRITE(ts->client, buf, 2); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen set boot ready function. -+ -+return: -+ N/A. -+*******************************************************/ -+void nvt_boot_ready(void) -+{ -+ //---write BOOT_RDY status cmds--- -+ nvt_write_addr(ts->mmap->BOOT_RDY_ADDR, 1); -+ -+ mdelay(5); -+ -+ if (!ts->hw_crc) { -+ //---write BOOT_RDY status cmds--- -+ nvt_write_addr(ts->mmap->BOOT_RDY_ADDR, 0); -+ -+ //---write POR_CD cmds--- -+ nvt_write_addr(ts->mmap->POR_CD_ADDR, 0xA0); -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen enable auto copy mode function. -+ -+return: -+ N/A. -+*******************************************************/ -+void nvt_tx_auto_copy_mode(void) -+{ -+ //---write TX_AUTO_COPY_EN cmds--- -+ nvt_write_addr(ts->mmap->TX_AUTO_COPY_EN, 0x69); -+ -+ NVT_ERR("tx auto copy mode enable\n"); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen check spi dma tx info function. -+ -+return: -+ N/A. -+*******************************************************/ -+int32_t nvt_check_spi_dma_tx_info(void) -+{ -+ uint8_t buf[8] = {0}; -+ int32_t i = 0; -+ const int32_t retry = 200; -+ -+ for (i = 0; i < retry; i++) { -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->SPI_DMA_TX_INFO); -+ -+ //---read fw status--- -+ buf[0] = ts->mmap->SPI_DMA_TX_INFO & 0x7F; -+ buf[1] = 0xFF; -+ CTP_SPI_READ(ts->client, buf, 2); -+ -+ if (buf[1] == 0x00) -+ break; -+ -+ usleep_range(1000, 1000); -+ } -+ -+ if (i >= retry) { -+ NVT_ERR("failed, i=%d, buf[1]=0x%02X\n", i, buf[1]); -+ return -1; -+ } else { -+ return 0; -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen eng reset cmd -+ function. -+ -+return: -+ n.a. -+*******************************************************/ -+void nvt_eng_reset(void) -+{ -+ //---eng reset cmds to ENG_RST_ADDR--- -+ nvt_write_addr(ENG_RST_ADDR, 0x5A); -+ -+ mdelay(1); //wait tMCU_Idle2TP_REX_Hi after TP_RST -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen reset MCU -+ function. -+ -+return: -+ n.a. -+*******************************************************/ -+void nvt_sw_reset(void) -+{ -+ //---software reset cmds to SWRST_N8_ADDR--- -+ nvt_write_addr(SWRST_N8_ADDR, 0x55); -+ -+ msleep(10); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen reset MCU then into idle mode -+ function. -+ -+return: -+ n.a. -+*******************************************************/ -+void nvt_sw_reset_idle(void) -+{ -+ //---MCU idle cmds to SWRST_N8_ADDR--- -+ nvt_write_addr(SWRST_N8_ADDR, 0xAA); -+ -+ msleep(15); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen reset MCU (boot) function. -+ -+return: -+ n.a. -+*******************************************************/ -+void nvt_bootloader_reset(void) -+{ -+ //---reset cmds to SWRST_N8_ADDR--- -+ nvt_write_addr(SWRST_N8_ADDR, 0x69); -+ -+ mdelay(5); //wait tBRST2FR after Bootload RST -+ -+ if (SPI_RD_FAST_ADDR) { -+ /* disable SPI_RD_FAST */ -+ nvt_write_addr(SPI_RD_FAST_ADDR, 0x00); -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen clear FW status function. -+ -+return: -+ Executive outcomes. 0---succeed. -1---fail. -+*******************************************************/ -+int32_t nvt_clear_fw_status(void) -+{ -+ uint8_t buf[8] = {0}; -+ int32_t i = 0; -+ const int32_t retry = 20; -+ -+ for (i = 0; i < retry; i++) { -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE); -+ -+ //---clear fw status--- -+ buf[0] = EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE; -+ buf[1] = 0x00; -+ CTP_SPI_WRITE(ts->client, buf, 2); -+ -+ //---read fw status--- -+ buf[0] = EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE; -+ buf[1] = 0xFF; -+ CTP_SPI_READ(ts->client, buf, 2); -+ -+ if (buf[1] == 0x00) -+ break; -+ -+ usleep_range(10000, 10000); -+ } -+ -+ if (i >= retry) { -+ NVT_ERR("failed, i=%d, buf[1]=0x%02X\n", i, buf[1]); -+ return -1; -+ } else { -+ return 0; -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen check FW status function. -+ -+return: -+ Executive outcomes. 0---succeed. -1---failed. -+*******************************************************/ -+int32_t nvt_check_fw_status(void) -+{ -+ uint8_t buf[8] = {0}; -+ int32_t i = 0; -+ const int32_t retry = 50; -+ -+ for (i = 0; i < retry; i++) { -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE); -+ -+ //---read fw status--- -+ buf[0] = EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE; -+ buf[1] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 2); -+ -+ if ((buf[1] & 0xF0) == 0xA0) -+ break; -+ -+ usleep_range(10000, 10000); -+ } -+ -+ if (i >= retry) { -+ NVT_ERR("failed, i=%d, buf[1]=0x%02X\n", i, buf[1]); -+ return -1; -+ } else { -+ return 0; -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen check FW reset state function. -+ -+return: -+ Executive outcomes. 0---succeed. -1---failed. -+*******************************************************/ -+int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state) -+{ -+ uint8_t buf[8] = {0}; -+ int32_t ret = 0; -+ int32_t retry = 0; -+ int32_t retry_max = (check_reset_state == RESET_STATE_INIT) ? 10 : 50; -+ -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_RESET_COMPLETE); -+ -+ while (1) { -+ //---read reset state--- -+ buf[0] = EVENT_MAP_RESET_COMPLETE; -+ buf[1] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 6); -+ -+ if ((buf[1] >= check_reset_state) && (buf[1] <= RESET_STATE_MAX)) { -+ ret = 0; -+ break; -+ } -+ -+ retry++; -+ if(unlikely(retry > retry_max)) { -+ NVT_ERR("error, retry=%d, buf[1]=0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X\n", -+ retry, buf[1], buf[2], buf[3], buf[4], buf[5]); -+ ret = -1; -+ break; -+ } -+ -+ usleep_range(10000, 10000); -+ } -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen get novatek project id information -+ function. -+ -+return: -+ Executive outcomes. 0---success. -1---fail. -+*******************************************************/ -+int32_t nvt_read_pid(void) -+{ -+ uint8_t buf[4] = {0}; -+ int32_t ret = 0; -+ -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_PROJECTID); -+ -+ //---read project id--- -+ buf[0] = EVENT_MAP_PROJECTID; -+ buf[1] = 0x00; -+ buf[2] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 3); -+ -+ ts->nvt_pid = (buf[2] << 8) + buf[1]; -+ -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR); -+ -+ NVT_LOG("PID=%04X\n", ts->nvt_pid); -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen get firmware related information -+ function. -+ -+return: -+ Executive outcomes. 0---success. -1---fail. -+*******************************************************/ -+int32_t nvt_get_fw_info(void) -+{ -+ uint8_t buf[64] = {0}; -+ uint32_t retry_count = 0; -+ int32_t ret = 0; -+ -+info_retry: -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_FWINFO); -+ -+ //---read fw info--- -+ buf[0] = EVENT_MAP_FWINFO; -+ CTP_SPI_READ(ts->client, buf, 39); -+ ts->fw_ver = buf[1]; -+ ts->x_num = buf[3]; -+ ts->y_num = buf[4]; -+ ts->abs_x_max = (uint16_t)((buf[5] << 8) | buf[6]); -+ ts->abs_y_max = (uint16_t)((buf[7] << 8) | buf[8]); -+ ts->max_button_num = buf[11]; -+ ts->cascade = buf[34] & 0x01; -+ if (ts->pen_support) { -+ ts->x_gang_num = buf[37]; -+ ts->y_gang_num = buf[38]; -+ } -+ -+ //---clear x_num, y_num if fw info is broken--- -+ if ((buf[1] + buf[2]) != 0xFF) { -+ NVT_ERR("FW info is broken! fw_ver=0x%02X, ~fw_ver=0x%02X\n", buf[1], buf[2]); -+ ts->fw_ver = 0; -+ ts->x_num = 18; -+ ts->y_num = 32; -+ ts->abs_x_max = TOUCH_DEFAULT_MAX_WIDTH; -+ ts->abs_y_max = TOUCH_DEFAULT_MAX_HEIGHT; -+ ts->max_button_num = TOUCH_KEY_NUM; -+ -+ if(retry_count < 3) { -+ retry_count++; -+ NVT_ERR("retry_count=%d\n", retry_count); -+ goto info_retry; -+ } else { -+ NVT_ERR("Set default fw_ver=%d, x_num=%d, y_num=%d, " -+ "abs_x_max=%d, abs_y_max=%d, max_button_num=%d!\n", -+ ts->fw_ver, ts->x_num, ts->y_num, -+ ts->abs_x_max, ts->abs_y_max, ts->max_button_num); -+ ret = -1; -+ } -+ } else { -+ ret = 0; -+ } -+ -+ NVT_LOG("fw_ver = 0x%02X, fw_type = 0x%02X, x_num=%d, y_num=%d\n", ts->fw_ver, buf[14], ts->x_num, ts->y_num); -+ -+ //---Get Novatek PID--- -+ nvt_read_pid(); -+ -+ return ret; -+} -+ -+static void release_pen_event(void) { -+ if (ts && ts->pen_input_dev) { -+ input_report_abs(ts->pen_input_dev, ABS_X, 0); -+ input_report_abs(ts->pen_input_dev, ABS_Y, 0); -+ input_report_abs(ts->pen_input_dev, ABS_PRESSURE, 0); -+ input_report_abs(ts->pen_input_dev, ABS_TILT_X, 0); -+ input_report_abs(ts->pen_input_dev, ABS_TILT_Y, 0); -+ input_report_abs(ts->pen_input_dev, ABS_DISTANCE, 0); -+ input_report_key(ts->pen_input_dev, BTN_TOUCH, 0); -+ input_report_key(ts->pen_input_dev, BTN_TOOL_PEN, 0); -+ input_report_key(ts->pen_input_dev, BTN_STYLUS, 0); -+ input_report_key(ts->pen_input_dev, BTN_STYLUS2, 0); -+ input_sync(ts->pen_input_dev); -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen parse device tree function. -+ -+return: -+ n.a. -+*******************************************************/ -+#ifdef CONFIG_OF -+static int32_t nvt_parse_dt(struct device *dev) -+{ -+ struct device_node *np = dev->of_node; -+ int32_t ret = 0; -+ -+#if NVT_TOUCH_SUPPORT_HW_RST -+ ts->reset_gpio = of_get_named_gpio_flags(np, "novatek,reset-gpio", 0, &ts->reset_flags); -+ NVT_LOG("novatek,reset-gpio=%d\n", ts->reset_gpio); -+#endif -+ ts->irq_gpio = of_get_named_gpio(np, "novatek,irq-gpio", 0); -+ NVT_LOG("novatek,irq-gpio=%d\n", ts->irq_gpio); -+ -+ ts->pen_support = of_property_read_bool(np, "novatek,pen-support"); -+ NVT_LOG("novatek,pen-support=%d\n", ts->pen_support); -+ -+ ts->wgp_stylus = of_property_read_bool(np, "novatek,wgp-stylus"); -+ NVT_LOG("novatek,wgp-stylus=%d\n", ts->wgp_stylus); -+ -+ ret = of_property_read_u32(np, "novatek,swrst-n8-addr", &SWRST_N8_ADDR); -+ if (ret) { -+ NVT_ERR("error reading novatek,swrst-n8-addr. ret=%d\n", ret); -+ return ret; -+ } else { -+ NVT_LOG("SWRST_N8_ADDR=0x%06X\n", SWRST_N8_ADDR); -+ } -+ -+ ret = of_property_read_u32(np, "novatek,spi-rd-fast-addr", &SPI_RD_FAST_ADDR); -+ if (ret) { -+ NVT_LOG("not support novatek,spi-rd-fast-addr\n"); -+ SPI_RD_FAST_ADDR = 0; -+ ret = 0; -+ } else { -+ NVT_LOG("SPI_RD_FAST_ADDR=0x%06X\n", SPI_RD_FAST_ADDR); -+ } -+ -+ ret = of_property_read_string(np, "firmware-name", &ts->fw_name); -+ if (ret) { -+ NVT_LOG("Unable to get touchscreen firmware name\n"); -+ ts->fw_name = DEFAULT_BOOT_UPDATE_FIRMWARE_NAME; -+ } -+ -+ ret = of_property_read_u32(np, "spi-max-frequency", &ts->spi_max_freq); -+ if (ret) { -+ NVT_LOG("Unable to get spi freq\n"); -+ return ret; -+ } else { -+ NVT_LOG("spi-max-frequency: %u\n", ts->spi_max_freq); -+ } -+ -+ return ret; -+} -+#else -+static int32_t nvt_parse_dt(struct device *dev) -+{ -+#if NVT_TOUCH_SUPPORT_HW_RST -+ ts->reset_gpio = NVTTOUCH_RST_PIN; -+#endif -+ ts->irq_gpio = NVTTOUCH_INT_PIN; -+ return 0; -+} -+#endif -+ -+/******************************************************* -+Description: -+ Novatek touchscreen config and request gpio -+ -+return: -+ Executive outcomes. 0---succeed. not 0---failed. -+*******************************************************/ -+static int nvt_gpio_config(struct nvt_ts_data *ts) -+{ -+ int32_t ret = 0; -+ -+#if NVT_TOUCH_SUPPORT_HW_RST -+ /* request RST-pin (Output/High) */ -+ if (gpio_is_valid(ts->reset_gpio)) { -+ ret = gpio_request_one(ts->reset_gpio, GPIOF_OUT_INIT_LOW, "NVT-tp-rst"); -+ if (ret) { -+ NVT_ERR("Failed to request NVT-tp-rst GPIO\n"); -+ goto err_request_reset_gpio; -+ } -+ } -+#endif -+ -+ /* request INT-pin (Input) */ -+ if (gpio_is_valid(ts->irq_gpio)) { -+ ret = gpio_request_one(ts->irq_gpio, GPIOF_IN, "NVT-int"); -+ if (ret) { -+ NVT_ERR("Failed to request NVT-int GPIO\n"); -+ goto err_request_irq_gpio; -+ } -+ } -+ -+ return ret; -+ -+err_request_irq_gpio: -+#if NVT_TOUCH_SUPPORT_HW_RST -+ gpio_free(ts->reset_gpio); -+err_request_reset_gpio: -+#endif -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen deconfig gpio -+ -+return: -+ n.a. -+*******************************************************/ -+static void nvt_gpio_deconfig(struct nvt_ts_data *ts) -+{ -+ if (gpio_is_valid(ts->irq_gpio)) -+ gpio_free(ts->irq_gpio); -+#if NVT_TOUCH_SUPPORT_HW_RST -+ if (gpio_is_valid(ts->reset_gpio)) -+ gpio_free(ts->reset_gpio); -+#endif -+} -+ -+static uint8_t nvt_fw_recovery(uint8_t *point_data) -+{ -+ uint8_t i = 0; -+ uint8_t detected = true; -+ -+ /* check pattern */ -+ for (i=1 ; i<7 ; i++) { -+ if (point_data[i] != 0x77) { -+ detected = false; -+ break; -+ } -+ } -+ -+ return detected; -+} -+ -+void nvt_set_dbgfw_status(bool enable) -+{ -+ ts->fw_debug = enable; -+} -+ -+bool nvt_get_dbgfw_status(void) -+{ -+ return ts->fw_debug; -+} -+ -+#if NVT_TOUCH_ESD_PROTECT -+void nvt_esd_check_enable(uint8_t enable) -+{ -+ /* update interrupt timer */ -+ irq_timer = jiffies; -+ /* clear esd_retry counter, if protect function is enabled */ -+ esd_retry = enable ? 0 : esd_retry; -+ /* enable/disable esd check flag */ -+ esd_check = enable; -+} -+ -+static void nvt_esd_check_func(struct work_struct *work) -+{ -+ unsigned int timer = jiffies_to_msecs(jiffies - irq_timer); -+ -+ //NVT_LOG("esd_check = %d (retry %d)\n", esd_check, esd_retry); //DEBUG -+ -+ if ((timer > NVT_TOUCH_ESD_CHECK_PERIOD) && esd_check) { -+ mutex_lock(&ts->lock); -+ NVT_ERR("do ESD recovery, timer = %d, retry = %d\n", timer, esd_retry); -+ /* do esd recovery, reload fw */ -+ nvt_update_firmware(ts->fw_name); -+ mutex_unlock(&ts->lock); -+ /* update interrupt timer */ -+ irq_timer = jiffies; -+ /* update esd_retry counter */ -+ esd_retry++; -+ } -+ -+ queue_delayed_work(nvt_esd_check_wq, &nvt_esd_check_work, -+ msecs_to_jiffies(NVT_TOUCH_ESD_CHECK_PERIOD)); -+} -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+#if NVT_TOUCH_WDT_RECOVERY -+static uint8_t recovery_cnt = 0; -+static uint8_t nvt_wdt_fw_recovery(uint8_t *point_data) -+{ -+ uint32_t recovery_cnt_max = 10; -+ uint8_t recovery_enable = false; -+ uint8_t i = 0; -+ -+ recovery_cnt++; -+ -+ /* check pattern */ -+ for (i=1 ; i<7 ; i++) { -+ if ((point_data[i] != 0xFD) && (point_data[i] != 0xFE)) { -+ recovery_cnt = 0; -+ break; -+ } -+ } -+ -+ if (recovery_cnt > recovery_cnt_max){ -+ recovery_enable = true; -+ recovery_cnt = 0; -+ } -+ -+ return recovery_enable; -+} -+#endif /* #if NVT_TOUCH_WDT_RECOVERY */ -+ -+#define PEN_DATA_LEN 14 -+#define FW_HISTORY_SIZE 128 -+static uint32_t nvt_dump_fw_history(void) -+{ -+ int32_t ret = 0; -+ uint8_t buf[FW_HISTORY_SIZE + 1 + DUMMY_BYTES] = {0}; -+ int32_t i = 0; -+ char *tmp_dump = NULL; -+ int32_t line_cnt = 0; -+ -+ if (ts->mmap->FW_HISTORY_ADDR == 0) { -+ NVT_ERR("FW_HISTORY_ADDR not available!\n"); -+ ret = -1; -+ goto exit_nvt_dump_fw_history; -+ } -+ nvt_set_page(ts->mmap->FW_HISTORY_ADDR); -+ buf[0] = ts->mmap->FW_HISTORY_ADDR & 0xFF; -+ CTP_SPI_READ(ts->client, buf, FW_HISTORY_SIZE + 1); -+ if (ret) { -+ NVT_ERR("CTP_SPI_READ failed.(%d)\n", ret); -+ ret = -1; -+ goto exit_nvt_dump_fw_history; -+ } -+ -+ tmp_dump = (char *)kzalloc(FW_HISTORY_SIZE * 4, GFP_KERNEL); -+ for (i = 0; i < FW_HISTORY_SIZE; i++) { -+ sprintf(tmp_dump + i * 3 + line_cnt, "%02X ", buf[1 + i]); -+ if ((i + 1) % 16 == 0) { -+ sprintf(tmp_dump + i * 3 + line_cnt + 3, "%c", '\n'); -+ line_cnt++; -+ } -+ } -+ NVT_LOG("%s", tmp_dump); -+ -+exit_nvt_dump_fw_history: -+ if (tmp_dump) { -+ kfree(tmp_dump); -+ tmp_dump = NULL; -+ } -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR); -+ -+ return ret; -+} -+ -+#define POINT_DATA_LEN 65 -+/******************************************************* -+Description: -+ Novatek touchscreen work function. -+ -+return: -+ n.a. -+*******************************************************/ -+static irqreturn_t nvt_ts_work_func(int irq, void *data) -+{ -+ int32_t ret = -1; -+ uint8_t point_data[POINT_DATA_LEN + PEN_DATA_LEN + 1 + DUMMY_BYTES] = {0}; -+ uint32_t position = 0; -+ uint32_t input_x = 0; -+ uint32_t input_y = 0; -+ uint32_t input_w = 0; -+ uint32_t input_p = 0; -+ uint8_t input_id = 0; -+#if MT_PROTOCOL_B -+ uint8_t press_id[TOUCH_MAX_FINGER_NUM] = {0}; -+#endif /* MT_PROTOCOL_B */ -+ int32_t i = 0; -+ int32_t finger_cnt = 0; -+ uint8_t pen_format_id = 0; -+ uint32_t pen_x = 0; -+ uint32_t pen_y = 0; -+ uint32_t pen_pressure = 0; -+ uint32_t pen_distance = 0; -+ int8_t pen_tilt_x = 0; -+ int8_t pen_tilt_y = 0; -+ uint32_t pen_btn1 = 0; -+ uint32_t pen_btn2 = 0; -+ uint32_t pen_battery = 0; -+ -+ mutex_lock(&ts->lock); -+ -+ if (ts->dev_pm_suspend) { -+ ret = wait_for_completion_timeout(&ts->dev_pm_suspend_completion, msecs_to_jiffies(500)); -+ if (!ret) { -+ NVT_ERR("system(spi) can't finished resuming procedure, skip it\n"); -+ goto XFER_ERROR; -+ } -+ } -+ -+ if (ts->pen_support) -+ ret = CTP_SPI_READ(ts->client, point_data, POINT_DATA_LEN + PEN_DATA_LEN + 1); -+ else -+ ret = CTP_SPI_READ(ts->client, point_data, POINT_DATA_LEN + 1); -+ if (ret < 0) { -+ NVT_ERR("CTP_SPI_READ failed.(%d)\n", ret); -+ goto XFER_ERROR; -+ } -+ -+ /*--- dump SPI buf --- -+ for (i = 0; i < 10; i++) { -+ NVT_LOG("%02X %02X %02X %02X %02X %02X \n", -+ point_data[1+i*6], point_data[2+i*6], point_data[3+i*6], point_data[4+i*6], point_data[5+i*6], point_data[6+i*6]); -+ } -+ */ -+ -+#if NVT_TOUCH_WDT_RECOVERY -+ /* ESD protect by WDT */ -+ if (nvt_wdt_fw_recovery(point_data)) { -+ NVT_ERR("Recover for fw reset, %02X\n", point_data[1]); -+ if (point_data[1] == 0xFD) { -+ NVT_ERR("Dump FW history:\n"); -+ nvt_dump_fw_history(); -+ } -+ nvt_update_firmware(ts->fw_name); -+ goto XFER_ERROR; -+ } -+#endif /* #if NVT_TOUCH_WDT_RECOVERY */ -+ -+ /* ESD protect by FW handshake */ -+ if (nvt_fw_recovery(point_data)) { -+#if NVT_TOUCH_ESD_PROTECT -+ nvt_esd_check_enable(true); -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ goto XFER_ERROR; -+ } -+ -+ finger_cnt = 0; -+ -+ for (i = 0; i < ts->max_touch_num; i++) { -+ position = 1 + 6 * i; -+ input_id = (uint8_t)(point_data[position + 0] >> 3); -+ if ((input_id == 0) || (input_id > ts->max_touch_num)) -+ continue; -+ -+ if (((point_data[position] & 0x07) == 0x01) || ((point_data[position] & 0x07) == 0x02)) { //finger down (enter & moving) -+#if NVT_TOUCH_ESD_PROTECT -+ /* update interrupt timer */ -+ irq_timer = jiffies; -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ input_x = (uint32_t)(point_data[position + 1] << 4) + (uint32_t) (point_data[position + 3] >> 4); -+ input_y = (uint32_t)(point_data[position + 2] << 4) + (uint32_t) (point_data[position + 3] & 0x0F); -+ if ((input_x < 0) || (input_y < 0)) -+ continue; -+ if ((input_x > ts->abs_x_max) || (input_y > ts->abs_y_max)) -+ continue; -+ input_w = (uint32_t)(point_data[position + 4]); -+ if (input_w == 0) -+ input_w = 1; -+ if (i < 2) { -+ input_p = (uint32_t)(point_data[position + 5]) + (uint32_t)(point_data[i + 63] << 8); -+ if (input_p > TOUCH_FORCE_NUM) -+ input_p = TOUCH_FORCE_NUM; -+ } else { -+ input_p = (uint32_t)(point_data[position + 5]); -+ } -+ if (input_p == 0) -+ input_p = 1; -+ -+#if MT_PROTOCOL_B -+ press_id[input_id - 1] = 1; -+ input_mt_slot(ts->input_dev, input_id - 1); -+ input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); -+#else /* MT_PROTOCOL_B */ -+ input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, input_id - 1); -+ input_report_key(ts->input_dev, BTN_TOUCH, 1); -+#endif /* MT_PROTOCOL_B */ -+ -+ input_report_abs(ts->input_dev, ABS_MT_POSITION_X, input_x); -+ input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, input_y); -+ input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, input_w); -+ input_report_abs(ts->input_dev, ABS_MT_PRESSURE, input_p); -+ -+#if MT_PROTOCOL_B -+#else /* MT_PROTOCOL_B */ -+ input_mt_sync(ts->input_dev); -+#endif /* MT_PROTOCOL_B */ -+ -+ finger_cnt++; -+ } -+ } -+ -+#if MT_PROTOCOL_B -+ for (i = 0; i < ts->max_touch_num; i++) { -+ if (press_id[i] != 1) { -+ input_mt_slot(ts->input_dev, i); -+ input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); -+ input_report_abs(ts->input_dev, ABS_MT_PRESSURE, 0); -+ input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false); -+ } -+ } -+ input_report_key(ts->input_dev, BTN_TOUCH, (finger_cnt > 0)); -+#else /* MT_PROTOCOL_B */ -+ if (finger_cnt == 0) { -+ input_report_key(ts->input_dev, BTN_TOUCH, 0); -+ input_mt_sync(ts->input_dev); -+ } -+#endif /* MT_PROTOCOL_B */ -+ -+#if TOUCH_KEY_NUM > 0 -+ if (point_data[61] == 0xF8) { -+#if NVT_TOUCH_ESD_PROTECT -+ /* update interrupt timer */ -+ irq_timer = jiffies; -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ for (i = 0; i < ts->max_button_num; i++) { -+ input_report_key(ts->input_dev, touch_key_array[i], ((point_data[62] >> i) & 0x01)); -+ } -+ } else { -+ for (i = 0; i < ts->max_button_num; i++) { -+ input_report_key(ts->input_dev, touch_key_array[i], 0); -+ } -+ } -+#endif -+ -+ input_sync(ts->input_dev); -+ -+ if (ts->pen_support && ts->pen_input_dev_enable && !(ts->pen_is_charge)) { -+/* -+ //--- dump pen buf --- -+ printk("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", -+ point_data[66], point_data[67], point_data[68], point_data[69], point_data[70], -+ point_data[71], point_data[72], point_data[73], point_data[74], point_data[75], -+ point_data[76], point_data[77], point_data[78], point_data[79]); -+*/ -+ // parse and handle pen report -+ pen_format_id = point_data[66]; -+ if (pen_format_id != 0xFF) { -+ if (pen_format_id == 0x01) { -+ // report pen data -+ pen_x = (uint32_t)(point_data[67] << 8) + (uint32_t)(point_data[68]); -+ pen_y = (uint32_t)(point_data[69] << 8) + (uint32_t)(point_data[70]); -+ if (pen_x >= ts->abs_x_max * 2 - 1) { -+ pen_x -= 1; -+ } -+ if (pen_y >= ts->abs_y_max * 2 - 1) { -+ pen_y -= 1; -+ } -+ pen_pressure = (uint32_t)(point_data[71] << 8) + (uint32_t)(point_data[72]); -+ pen_tilt_x = (int32_t)point_data[73]; -+ pen_tilt_y = (int32_t)point_data[74]; -+ pen_distance = (uint32_t)(point_data[75] << 8) + (uint32_t)(point_data[76]); -+ pen_btn1 = (uint32_t)(point_data[77] & 0x01); -+ pen_btn2 = (uint32_t)((point_data[77] >> 1) & 0x01); -+ pen_battery = (uint32_t)point_data[78]; -+// printk("x=%d,y=%d,p=%d,tx=%d,ty=%d,d=%d,b1=%d,b2=%d,bat=%d\n", pen_x, pen_y, pen_pressure, -+// pen_tilt_x, pen_tilt_y, pen_distance, pen_btn1, pen_btn2, pen_battery); -+ -+ input_report_abs(ts->pen_input_dev, ABS_X, pen_x); -+ input_report_abs(ts->pen_input_dev, ABS_Y, pen_y); -+ input_report_abs(ts->pen_input_dev, ABS_PRESSURE, pen_pressure); -+ input_report_key(ts->pen_input_dev, BTN_TOUCH, !!pen_pressure); -+ input_report_abs(ts->pen_input_dev, ABS_TILT_X, pen_tilt_x); -+ input_report_abs(ts->pen_input_dev, ABS_TILT_Y, pen_tilt_y); -+ input_report_abs(ts->pen_input_dev, ABS_DISTANCE, pen_distance); -+ input_report_key(ts->pen_input_dev, BTN_TOOL_PEN, !!pen_distance || !!pen_pressure); -+ input_report_key(ts->pen_input_dev, BTN_STYLUS, pen_btn1); -+ input_report_key(ts->pen_input_dev, BTN_STYLUS2, pen_btn2); -+ input_sync(ts->pen_input_dev); -+ // TBD: pen battery event report -+ // NVT_LOG("pen_battery=%d\n", pen_battery); -+ } else if (pen_format_id == 0xF0) { -+ // report Pen ID -+ } else { -+ NVT_ERR("Unknown pen format id!\n"); -+ goto XFER_ERROR; -+ } -+ } else { // pen_format_id = 0xFF, i.e. no pen present -+ release_pen_event(); -+ } -+ } /* if (ts->pen_support) */ -+ -+XFER_ERROR: -+ -+ mutex_unlock(&ts->lock); -+ return IRQ_HANDLED; -+} -+ -+ -+/******************************************************* -+Description: -+ Novatek touchscreen check chip version trim function. -+ -+return: -+ Executive outcomes. 0---NVT IC. -1---not NVT IC. -+*******************************************************/ -+static int8_t nvt_ts_check_chip_ver_trim(uint32_t chip_ver_trim_addr) -+{ -+ -+ ts->mmap = &NT36523_memory_map; -+ ts->carrier_system = NT36523_hw_info.carrier_system; -+ ts->hw_crc = NT36523_hw_info.hw_crc; -+ return 0; -+} -+ -+static void nvt_suspend_work(struct work_struct *work) -+{ -+ struct nvt_ts_data *ts_core = container_of(work, struct nvt_ts_data, suspend_work); -+ nvt_ts_suspend(&ts_core->client->dev); -+} -+ -+static void nvt_resume_work(struct work_struct *work) -+{ -+ struct nvt_ts_data *ts_core = container_of(work, struct nvt_ts_data, resume_work); -+ nvt_ts_resume(&ts_core->client->dev); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen driver probe function. -+ -+return: -+ Executive outcomes. 0---succeed. negative---failed -+*******************************************************/ -+static int32_t nvt_ts_probe(struct spi_device *client) -+{ -+ int32_t ret = 0; -+#if (TOUCH_KEY_NUM > 0) -+ int32_t retry = 0; -+#endif -+ -+ NVT_LOG("probe start\n"); -+ -+ ts = kzalloc(sizeof(struct nvt_ts_data), GFP_KERNEL); -+ if (ts == NULL) { -+ NVT_ERR("failed to allocated memory for nvt ts data\n"); -+ return -ENOMEM; -+ } -+ -+ ts->xbuf = (uint8_t *)kzalloc((NVT_TRANSFER_LEN+1+DUMMY_BYTES), GFP_KERNEL); -+ if(ts->xbuf == NULL) { -+ NVT_ERR("kzalloc for xbuf failed!\n"); -+ ret = -ENOMEM; -+ goto err_malloc_xbuf; -+ } -+ -+ ts->rbuf = (uint8_t *)kzalloc(NVT_READ_LEN, GFP_KERNEL); -+ if(ts->rbuf == NULL) { -+ NVT_ERR("kzalloc for rbuf failed!\n"); -+ ret = -ENOMEM; -+ goto err_malloc_rbuf; -+ } -+ -+ ts->client = client; -+ spi_set_drvdata(client, ts); -+ -+ //---prepare for spi parameter--- -+ if (ts->client->master->flags & SPI_MASTER_HALF_DUPLEX) { -+ NVT_ERR("Full duplex not supported by master\n"); -+ ret = -EIO; -+ goto err_ckeck_full_duplex; -+ } -+ ts->client->bits_per_word = 8; -+ ts->client->mode = SPI_MODE_0; -+ -+ ret = spi_setup(ts->client); -+ if (ret < 0) { -+ NVT_ERR("Failed to perform SPI setup\n"); -+ goto err_spi_setup; -+ } -+ -+#ifdef CONFIG_MTK_SPI -+ /* old usage of MTK spi API */ -+ memcpy(&ts->spi_ctrl, &spi_ctrdata, sizeof(struct mt_chip_conf)); -+ ts->client->controller_data = (void *)&ts->spi_ctrl; -+#endif -+ -+#ifdef CONFIG_SPI_MT65XX -+ /* new usage of MTK spi API */ -+ memcpy(&ts->spi_ctrl, &spi_ctrdata, sizeof(struct mtk_chip_config)); -+ ts->client->controller_data = (void *)&ts->spi_ctrl; -+#endif -+ -+ NVT_LOG("mode=%d, max_speed_hz=%d\n", ts->client->mode, ts->client->max_speed_hz); -+ -+ //---parse dts--- -+ ret = nvt_parse_dt(&client->dev); -+ if (ret) { -+ NVT_ERR("parse dt error\n"); -+ goto err_spi_setup; -+ } -+ -+ //---request and config GPIOs--- -+ ret = nvt_gpio_config(ts); -+ if (ret) { -+ NVT_ERR("gpio config error!\n"); -+ goto err_gpio_config_failed; -+ } -+ -+ mutex_init(&ts->lock); -+ mutex_init(&ts->xbuf_lock); -+ -+ //---eng reset before TP_RESX high -+ nvt_eng_reset(); -+ -+#if NVT_TOUCH_SUPPORT_HW_RST -+ gpio_set_value(ts->reset_gpio, 1); -+#endif -+ -+ // need 10ms delay after POR(power on reset) -+ msleep(10); -+ -+ //---check chip version trim--- -+ ret = nvt_ts_check_chip_ver_trim(CHIP_VER_TRIM_ADDR); -+ if (ret) { -+ NVT_LOG("try to check from old chip ver trim address\n"); -+ ret = nvt_ts_check_chip_ver_trim(CHIP_VER_TRIM_OLD_ADDR); -+ if (ret) { -+ NVT_ERR("chip is not identified\n"); -+ ret = -EINVAL; -+ goto err_chipvertrim_failed; -+ } -+ } -+ -+ ts->abs_x_max = TOUCH_DEFAULT_MAX_WIDTH; -+ ts->abs_y_max = TOUCH_DEFAULT_MAX_HEIGHT; -+ -+ //---allocate input device--- -+ ts->input_dev = input_allocate_device(); -+ if (ts->input_dev == NULL) { -+ NVT_ERR("allocate input device failed\n"); -+ ret = -ENOMEM; -+ goto err_input_dev_alloc_failed; -+ } -+ -+ ts->max_touch_num = TOUCH_MAX_FINGER_NUM; -+ -+#if TOUCH_KEY_NUM > 0 -+ ts->max_button_num = TOUCH_KEY_NUM; -+#endif -+ -+ ts->int_trigger_type = INT_TRIGGER_TYPE; -+ -+ //---set input device info.--- -+ ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); -+ ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); -+ ts->input_dev->propbit[0] = BIT(INPUT_PROP_DIRECT); -+ -+ ts->db_wakeup = 0; -+ ts->fw_ver = 0; -+ ts->x_num = 32; -+ ts->y_num = 50; -+ ts->x_gang_num = 4; -+ ts->y_gang_num = 6; -+ ts->abs_x_max = TOUCH_DEFAULT_MAX_WIDTH; -+ ts->abs_y_max = TOUCH_DEFAULT_MAX_HEIGHT; -+ ts->max_button_num = TOUCH_KEY_NUM; -+ NVT_LOG("Set default fw_ver=%d, x_num=%d, y_num=%d, " -+ "abs_x_max=%d, abs_y_max=%d, max_button_num=%d!\n", -+ ts->fw_ver, ts->x_num, ts->y_num, -+ ts->abs_x_max, ts->abs_y_max, ts->max_button_num); -+ -+#if MT_PROTOCOL_B -+ input_mt_init_slots(ts->input_dev, ts->max_touch_num, 0); -+#endif -+ -+ input_set_abs_params(ts->input_dev, ABS_MT_PRESSURE, 0, TOUCH_FORCE_NUM, 0, 0); //pressure = TOUCH_FORCE_NUM -+ -+#if TOUCH_MAX_FINGER_NUM > 1 -+ input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); //area = 255 -+ -+ input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, ts->abs_x_max - 1, 0, 0); -+ input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, ts->abs_y_max - 1, 0, 0); -+#if MT_PROTOCOL_B -+ // no need to set ABS_MT_TRACKING_ID, input_mt_init_slots() already set it -+#else -+ input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, ts->max_touch_num, 0, 0); -+#endif //MT_PROTOCOL_B -+#endif //TOUCH_MAX_FINGER_NUM > 1 -+ -+#if TOUCH_KEY_NUM > 0 -+ for (retry = 0; retry < ts->max_button_num; retry++) { -+ input_set_capability(ts->input_dev, EV_KEY, touch_key_array[retry]); -+ } -+#endif -+ -+ sprintf(ts->phys, "input/ts"); -+ ts->input_dev->name = NVT_TS_NAME; -+ ts->input_dev->phys = ts->phys; -+ ts->input_dev->id.bustype = BUS_SPI; -+ -+ //---register input device--- -+ ret = input_register_device(ts->input_dev); -+ if (ret) { -+ NVT_ERR("register input device (%s) failed. ret=%d\n", ts->input_dev->name, ret); -+ goto err_input_register_device_failed; -+ } -+ -+ if (ts->pen_support) { -+ //---allocate pen input device--- -+ ts->pen_input_dev = input_allocate_device(); -+ if (ts->pen_input_dev == NULL) { -+ NVT_ERR("allocate pen input device failed\n"); -+ ret = -ENOMEM; -+ goto err_pen_input_dev_alloc_failed; -+ } -+ -+ //---set pen input device info.--- -+ ts->pen_input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); -+ ts->pen_input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); -+ ts->pen_input_dev->keybit[BIT_WORD(BTN_TOOL_PEN)] |= BIT_MASK(BTN_TOOL_PEN); -+ //ts->pen_input_dev->keybit[BIT_WORD(BTN_TOOL_RUBBER)] |= BIT_MASK(BTN_TOOL_RUBBER); -+ ts->pen_input_dev->keybit[BIT_WORD(BTN_STYLUS)] |= BIT_MASK(BTN_STYLUS); -+ ts->pen_input_dev->keybit[BIT_WORD(BTN_STYLUS2)] |= BIT_MASK(BTN_STYLUS2); -+ ts->pen_input_dev->propbit[0] = BIT(INPUT_PROP_DIRECT); -+ -+ if (ts->wgp_stylus) { -+ input_set_abs_params(ts->pen_input_dev, ABS_X, 0, ts->abs_x_max * 2 - 1, 0, 0); -+ input_set_abs_params(ts->pen_input_dev, ABS_Y, 0, ts->abs_y_max * 2 - 1, 0, 0); -+ } else { -+ input_set_abs_params(ts->pen_input_dev, ABS_X, 0, ts->abs_x_max - 1, 0, 0); -+ input_set_abs_params(ts->pen_input_dev, ABS_Y, 0, ts->abs_y_max - 1, 0, 0); -+ } -+ -+ input_set_abs_params(ts->pen_input_dev, ABS_PRESSURE, 0, PEN_PRESSURE_MAX, 0, 0); -+ input_set_abs_params(ts->pen_input_dev, ABS_DISTANCE, 0, PEN_DISTANCE_MAX, 0, 0); -+ input_set_abs_params(ts->pen_input_dev, ABS_TILT_X, PEN_TILT_MIN, PEN_TILT_MAX, 0, 0); -+ input_set_abs_params(ts->pen_input_dev, ABS_TILT_Y, PEN_TILT_MIN, PEN_TILT_MAX, 0, 0); -+ -+ sprintf(ts->pen_phys, "input/pen"); -+ ts->pen_input_dev->name = NVT_PEN_NAME; -+ ts->pen_input_dev->phys = ts->pen_phys; -+ ts->pen_input_dev->id.bustype = BUS_SPI; -+ -+ //---register pen input device--- -+ ret = input_register_device(ts->pen_input_dev); -+ if (ret) { -+ NVT_ERR("register pen input device (%s) failed. ret=%d\n", ts->pen_input_dev->name, ret); -+ goto err_pen_input_register_device_failed; -+ } -+ } /* if (ts->pen_support) */ -+ -+ //---set int-pin & request irq--- -+ client->irq = gpio_to_irq(ts->irq_gpio); -+ if (client->irq) { -+ NVT_LOG("int_trigger_type=%d\n", ts->int_trigger_type); -+ ts->irq_enabled = true; -+ ret = request_threaded_irq(client->irq, NULL, nvt_ts_work_func, -+ ts->int_trigger_type | IRQF_ONESHOT, NVT_SPI_NAME, ts); -+ if (ret != 0) { -+ NVT_ERR("request irq failed. ret=%d\n", ret); -+ goto err_int_request_failed; -+ } else { -+ nvt_irq_enable(false); -+ NVT_LOG("request irq %d succeed\n", client->irq); -+ } -+ } -+ -+ ts->pen_is_charge = false; -+ -+ ts->lkdown_readed =false; -+ pm_stay_awake(&client->dev); -+ -+ ts->ic_state = NVT_IC_INIT; -+ ts->dev_pm_suspend = false; -+ ts->gesture_command_delayed = -1; -+ init_completion(&ts->dev_pm_suspend_completion); -+ ts->fw_debug = false; -+ -+#ifdef CONFIG_FACTORY_BUILD -+ ts->pen_input_dev_enable = 1; -+#else -+ ts->pen_input_dev_enable = 0; -+#endif -+ -+#if BOOT_UPDATE_FIRMWARE -+ nvt_fwu_wq = alloc_workqueue("nvt_fwu_wq", WQ_UNBOUND | WQ_MEM_RECLAIM, 1); -+ if (!nvt_fwu_wq) { -+ NVT_ERR("nvt_fwu_wq create workqueue failed\n"); -+ ret = -ENOMEM; -+ goto err_create_nvt_fwu_wq_failed; -+ } -+ INIT_DELAYED_WORK(&ts->nvt_fwu_work, Boot_Update_Firmware); -+ // please make sure boot update start after display reset(RESX) sequence -+ queue_delayed_work(nvt_fwu_wq, &ts->nvt_fwu_work, msecs_to_jiffies(14000)); -+#endif -+ -+ NVT_LOG("NVT_TOUCH_ESD_PROTECT is %d\n", NVT_TOUCH_ESD_PROTECT); -+#if NVT_TOUCH_ESD_PROTECT -+ INIT_DELAYED_WORK(&nvt_esd_check_work, nvt_esd_check_func); -+ nvt_esd_check_wq = alloc_workqueue("nvt_esd_check_wq", WQ_MEM_RECLAIM, 1); -+ if (!nvt_esd_check_wq) { -+ NVT_ERR("nvt_esd_check_wq create workqueue failed\n"); -+ ret = -ENOMEM; -+ goto err_create_nvt_esd_check_wq_failed; -+ } -+ queue_delayed_work(nvt_esd_check_wq, &nvt_esd_check_work, -+ msecs_to_jiffies(NVT_TOUCH_ESD_CHECK_PERIOD)); -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+ ts->event_wq = alloc_workqueue("nvt-event-queue", -+ WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE, 1); -+ if (!ts->event_wq) { -+ NVT_ERR("Can not create work thread for suspend/resume!!"); -+ ret = -ENOMEM; -+ goto err_alloc_work_thread_failed; -+ } -+ INIT_WORK(&ts->resume_work, nvt_resume_work); -+ INIT_WORK(&ts->suspend_work, nvt_suspend_work); -+ -+#ifdef CONFIG_DRM -+ ts->drm_notif.notifier_call = nvt_drm_notifier_callback; -+ ret = mi_drm_register_client(&ts->drm_notif); -+ if(ret) { -+ NVT_ERR("register drm_notifier failed. ret=%d\n", ret); -+ goto err_register_drm_notif_failed; -+ } -+#endif -+ -+ bTouchIsAwake = 1; -+ NVT_LOG("end\n"); -+ -+ nvt_irq_enable(true); -+ -+ return 0; -+ -+#ifdef CONFIG_DRM -+ if (mi_drm_unregister_client(&ts->drm_notif)) -+ NVT_ERR("Error occurred while unregistering drm_notifier.\n"); -+err_register_drm_notif_failed: -+#endif -+ -+err_alloc_work_thread_failed: -+ -+#if NVT_TOUCH_ESD_PROTECT -+ if (nvt_esd_check_wq) { -+ cancel_delayed_work_sync(&nvt_esd_check_work); -+ destroy_workqueue(nvt_esd_check_wq); -+ nvt_esd_check_wq = NULL; -+ } -+err_create_nvt_esd_check_wq_failed: -+#endif -+#if BOOT_UPDATE_FIRMWARE -+ if (nvt_fwu_wq) { -+ cancel_delayed_work_sync(&ts->nvt_fwu_work); -+ destroy_workqueue(nvt_fwu_wq); -+ nvt_fwu_wq = NULL; -+ } -+err_create_nvt_fwu_wq_failed: -+ -+#endif -+ free_irq(client->irq, ts); -+err_int_request_failed: -+ if (ts->pen_support) { -+ input_unregister_device(ts->pen_input_dev); -+ ts->pen_input_dev = NULL; -+ } -+err_pen_input_register_device_failed: -+ if (ts->pen_support) { -+ if (ts->pen_input_dev) { -+ input_free_device(ts->pen_input_dev); -+ ts->pen_input_dev = NULL; -+ } -+ } -+err_pen_input_dev_alloc_failed: -+ input_unregister_device(ts->input_dev); -+ ts->input_dev = NULL; -+err_input_register_device_failed: -+ if (ts->input_dev) { -+ input_free_device(ts->input_dev); -+ ts->input_dev = NULL; -+ } -+err_input_dev_alloc_failed: -+err_chipvertrim_failed: -+ mutex_destroy(&ts->xbuf_lock); -+ mutex_destroy(&ts->lock); -+ nvt_gpio_deconfig(ts); -+err_gpio_config_failed: -+err_spi_setup: -+err_ckeck_full_duplex: -+ spi_set_drvdata(client, NULL); -+ if (ts->rbuf) { -+ kfree(ts->rbuf); -+ ts->rbuf = NULL; -+ } -+err_malloc_rbuf: -+ if (ts->xbuf) { -+ kfree(ts->xbuf); -+ ts->xbuf = NULL; -+ } -+err_malloc_xbuf: -+ if (ts) { -+ kfree(ts); -+ ts = NULL; -+ } -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen driver release function. -+ -+return: -+ Executive outcomes. 0---succeed. -+*******************************************************/ -+static void nvt_ts_remove(struct spi_device *client) -+{ -+ NVT_LOG("Removing driver...\n"); -+ -+#ifdef CONFIG_DRM -+ if (mi_drm_unregister_client(&ts->drm_notif)) -+ NVT_ERR("Error occurred while unregistering drm_notifier.\n"); -+#endif -+ -+#if NVT_TOUCH_ESD_PROTECT -+ if (nvt_esd_check_wq) { -+ cancel_delayed_work_sync(&nvt_esd_check_work); -+ nvt_esd_check_enable(false); -+ destroy_workqueue(nvt_esd_check_wq); -+ nvt_esd_check_wq = NULL; -+ } -+#endif -+ -+#if BOOT_UPDATE_FIRMWARE -+ if (nvt_fwu_wq) { -+ cancel_delayed_work_sync(&ts->nvt_fwu_work); -+ destroy_workqueue(nvt_fwu_wq); -+ nvt_fwu_wq = NULL; -+ } -+#endif -+ -+ nvt_irq_enable(false); -+ free_irq(client->irq, ts); -+ -+ mutex_destroy(&ts->xbuf_lock); -+ mutex_destroy(&ts->lock); -+ -+ nvt_gpio_deconfig(ts); -+ -+ if (ts->pen_support) { -+ if (ts->pen_input_dev) { -+ input_unregister_device(ts->pen_input_dev); -+ ts->pen_input_dev = NULL; -+ } -+ } -+ -+ if (ts->input_dev) { -+ input_unregister_device(ts->input_dev); -+ ts->input_dev = NULL; -+ } -+ -+ spi_set_drvdata(client, NULL); -+ -+ if (ts) { -+ kfree(ts); -+ ts = NULL; -+ } -+} -+ -+static void nvt_ts_shutdown(struct spi_device *client) -+{ -+ NVT_LOG("Shutdown driver...\n"); -+ -+ nvt_irq_enable(false); -+ -+#ifdef CONFIG_DRM -+ if (mi_drm_unregister_client(&ts->drm_notif)) -+ NVT_ERR("Error occurred while unregistering drm_notifier.\n"); -+#endif -+ -+ destroy_workqueue(ts->event_wq); -+ -+#if NVT_TOUCH_ESD_PROTECT -+ if (nvt_esd_check_wq) { -+ cancel_delayed_work_sync(&nvt_esd_check_work); -+ nvt_esd_check_enable(false); -+ destroy_workqueue(nvt_esd_check_wq); -+ nvt_esd_check_wq = NULL; -+ } -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+#if BOOT_UPDATE_FIRMWARE -+ if (nvt_fwu_wq) { -+ cancel_delayed_work_sync(&ts->nvt_fwu_work); -+ destroy_workqueue(nvt_fwu_wq); -+ nvt_fwu_wq = NULL; -+ } -+#endif -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen driver suspend function. -+ -+return: -+ Executive outcomes. 0---succeed. -+*******************************************************/ -+static int32_t nvt_ts_suspend(struct device *dev) -+{ -+ uint8_t buf[4] = {0}; -+#if MT_PROTOCOL_B -+ uint32_t i = 0; -+#endif -+ -+ if (!bTouchIsAwake) { -+ NVT_LOG("Touch is already suspend\n"); -+ return 0; -+ } -+ -+ pm_stay_awake(dev); -+ ts->ic_state = NVT_IC_SUSPEND_IN; -+ -+ if (!ts->db_wakeup) { -+ if (!ts->irq_enabled) -+ NVT_LOG("IRQ already disabled\n"); -+ else -+ nvt_irq_enable(false); -+ } -+ -+#if NVT_TOUCH_ESD_PROTECT -+ NVT_LOG("cancel delayed work sync\n"); -+ cancel_delayed_work_sync(&nvt_esd_check_work); -+ nvt_esd_check_enable(false); -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+ mutex_lock(&ts->lock); -+ -+ NVT_LOG("suspend start\n"); -+ -+ bTouchIsAwake = 0; -+ -+ if (ts->pen_input_dev_enable) { -+ NVT_LOG("if enable pen,will close it"); -+ } -+ -+ if (ts->db_wakeup) { -+ /*---write command to enter "wakeup gesture mode"---*/ -+ /*DoubleClick wakeup CMD was sent by display to meet timing*/ -+ /* -+ buf[0] = EVENT_MAP_HOST_CMD; -+ buf[1] = 0x13; -+ CTP_SPI_WRITE(ts->client, buf, 2); -+ */ -+ enable_irq_wake(ts->client->irq); -+ -+ NVT_LOG("Enabled touch wakeup gesture\n"); -+ } else { -+ /*---write command to enter "deep sleep mode"---*/ -+ buf[0] = EVENT_MAP_HOST_CMD; -+ buf[1] = 0x11; -+ CTP_SPI_WRITE(ts->client, buf, 2); -+ } -+ -+ mutex_unlock(&ts->lock); -+ -+ /* release all touches */ -+#if MT_PROTOCOL_B -+ for (i = 0; i < ts->max_touch_num; i++) { -+ input_mt_slot(ts->input_dev, i); -+ input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); -+ input_report_abs(ts->input_dev, ABS_MT_PRESSURE, 0); -+ input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, 0); -+ } -+#endif -+ input_report_key(ts->input_dev, BTN_TOUCH, 0); -+#if !MT_PROTOCOL_B -+ input_mt_sync(ts->input_dev); -+#endif -+ input_sync(ts->input_dev); -+ -+ msleep(50); -+ /* release pen event */ -+ release_pen_event(); -+ if (likely(ts->ic_state == NVT_IC_SUSPEND_IN)) -+ ts->ic_state = NVT_IC_SUSPEND_OUT; -+ else -+ NVT_ERR("IC state may error,caused by suspend/resume flow, please CHECK!!"); -+ pm_relax(dev); -+ NVT_LOG("end\n"); -+ -+ return 0; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen driver resume function. -+ -+return: -+ Executive outcomes. 0---succeed. -+*******************************************************/ -+static int32_t nvt_ts_resume(struct device *dev) -+{ -+ int ret = 0; -+ if (bTouchIsAwake) { -+ NVT_LOG("Touch is already resume\n"); -+ return 0; -+ } -+ -+ if (ts->dev_pm_suspend) -+ pm_stay_awake(dev); -+ -+ mutex_lock(&ts->lock); -+ -+ NVT_LOG("resume start\n"); -+ ts->ic_state = NVT_IC_RESUME_IN; -+ -+ // please make sure display reset(RESX) sequence and mipi dsi cmds sent before this -+#if NVT_TOUCH_SUPPORT_HW_RST -+ gpio_set_value(ts->reset_gpio, 1); -+#endif -+ ret = nvt_update_firmware(ts->fw_name); -+ if (ret) -+ NVT_ERR("download firmware failed\n"); -+ -+ nvt_check_fw_reset_state(RESET_STATE_REK); -+ -+ if (!ts->db_wakeup && !ts->irq_enabled) { -+ nvt_irq_enable(true); -+ } -+ -+#if NVT_TOUCH_ESD_PROTECT -+ nvt_esd_check_enable(false); -+ queue_delayed_work(nvt_esd_check_wq, &nvt_esd_check_work, -+ msecs_to_jiffies(NVT_TOUCH_ESD_CHECK_PERIOD)); -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+ bTouchIsAwake = 1; -+ -+ mutex_unlock(&ts->lock); -+ -+ if (likely(ts->ic_state == NVT_IC_RESUME_IN)) { -+ ts->ic_state = NVT_IC_RESUME_OUT; -+ } else { -+ NVT_ERR("IC state may error,caused by suspend/resume flow, please CHECK!!"); -+ } -+ if (ts->gesture_command_delayed >= 0){ -+ ts->db_wakeup = ts->gesture_command_delayed; -+ ts->gesture_command_delayed = -1; -+ NVT_LOG("execute delayed command, set double click wakeup %d\n", ts->db_wakeup); -+ } -+ -+ if (ts->dev_pm_suspend) -+ pm_relax(dev); -+ NVT_LOG("end\n"); -+ -+ return 0; -+} -+ -+ -+#ifdef CONFIG_DRM -+static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data) -+{ -+ int blank = *(enum drm_notifier_data *)data; -+ struct nvt_ts_data *ts_data = -+ container_of(self, struct nvt_ts_data, drm_notif); -+ -+ if (data && ts_data) { -+ if (event == MI_DRM_EARLY_EVENT_BLANK) { -+ if (blank == MI_DRM_BLANK_POWERDOWN) { -+ NVT_LOG("event=%lu, *blank=%d\n", event, blank); -+ flush_workqueue(ts_data->event_wq); -+ queue_work(ts_data->event_wq, &ts_data->suspend_work); -+ } -+ } else if (event == MI_DRM_EVENT_BLANK) { -+ if (blank == MI_DRM_BLANK_UNBLANK) { -+ NVT_LOG("event=%lu, *blank=%d\n", event, blank); -+ flush_workqueue(ts_data->event_wq); -+ queue_work(ts_data->event_wq, &ts_data->resume_work); -+ } -+ } -+ } -+ -+ return 0; -+} -+#endif -+ -+static int nvt_pm_suspend(struct device *dev) -+{ -+ if (device_may_wakeup(dev) && ts->db_wakeup) { -+ NVT_LOG("enable touch irq wake\n"); -+ enable_irq_wake(ts->client->irq); -+ } -+ ts->dev_pm_suspend = true; -+ reinit_completion(&ts->dev_pm_suspend_completion); -+ -+ return 0; -+} -+ -+static int nvt_pm_resume(struct device *dev) -+{ -+ if (device_may_wakeup(dev) && ts->db_wakeup) { -+ NVT_LOG("disable touch irq wake\n"); -+ disable_irq_wake(ts->client->irq); -+ } -+ ts->dev_pm_suspend = false; -+ complete(&ts->dev_pm_suspend_completion); -+ -+ return 0; -+} -+ -+static const struct dev_pm_ops nvt_dev_pm_ops = { -+ .suspend = nvt_pm_suspend, -+ .resume = nvt_pm_resume, -+}; -+ -+static const struct spi_device_id nvt_ts_id[] = { -+ { NVT_SPI_NAME, 0 }, -+ { } -+}; -+ -+#ifdef CONFIG_OF -+static struct of_device_id nvt_match_table[] = { -+ { .compatible = "novatek,NVT-ts-spi",}, -+ { }, -+}; -+#endif -+ -+static struct spi_driver nvt_spi_driver = { -+ .probe = nvt_ts_probe, -+ .remove = nvt_ts_remove, -+ .shutdown = nvt_ts_shutdown, -+ .id_table = nvt_ts_id, -+ .driver = { -+ .name = NVT_SPI_NAME, -+ .owner = THIS_MODULE, -+#ifdef CONFIG_PM -+ .pm = &nvt_dev_pm_ops, -+#endif -+#ifdef CONFIG_OF -+ .of_match_table = nvt_match_table, -+#endif -+ }, -+}; -+ -+module_spi_driver(nvt_spi_driver); -+ -+MODULE_DESCRIPTION("Novatek Touchscreen Driver"); -+MODULE_LICENSE("GPL"); -diff --git a/drivers/input/touchscreen/nt36523/nt36xxx.h b/drivers/input/touchscreen/nt36523/nt36xxx.h -new file mode 100644 -index 000000000000..2ec9ccb3b522 ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/nt36xxx.h -@@ -0,0 +1,240 @@ -+/* -+ * Copyright (C) 2010 - 2018 Novatek, Inc. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * $Revision: 69262 $ -+ * $Date: 2020-09-23 15:07:14 +0800 (週三, 23 九月 2020) $ -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ * more details. -+ * -+ */ -+#ifndef _LINUX_NVT_TOUCH_H -+#define _LINUX_NVT_TOUCH_H -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "nt36xxx_mem_map.h" -+ -+#define NVT_DEBUG 1 -+ -+//---GPIO number--- -+#define NVTTOUCH_RST_PIN 980 -+#define NVTTOUCH_INT_PIN 943 -+ -+#define PINCTRL_STATE_ACTIVE "pmx_ts_active" -+#define PINCTRL_STATE_SUSPEND "pmx_ts_suspend" -+ -+//---INT trigger mode--- -+//#define IRQ_TYPE_EDGE_RISING 1 -+//#define IRQ_TYPE_EDGE_FALLING 2 -+#define INT_TRIGGER_TYPE IRQ_TYPE_EDGE_RISING -+ -+ -+//---SPI driver info.--- -+#define NVT_SPI_NAME "NVT-ts" -+ -+#if NVT_DEBUG -+#define NVT_LOG(fmt, args...) pr_err("[%s] %s %d: " fmt, NVT_SPI_NAME, __func__, __LINE__, ##args) -+#else -+#define NVT_LOG(fmt, args...) pr_info("[%s] %s %d: " fmt, NVT_SPI_NAME, __func__, __LINE__, ##args) -+#endif -+#define NVT_ERR(fmt, args...) pr_err("[%s] %s %d: " fmt, NVT_SPI_NAME, __func__, __LINE__, ##args) -+ -+//---Input device info.--- -+#define NVT_TS_NAME "NVTCapacitiveTouchScreen" -+#define NVT_PEN_NAME "NVTCapacitivePen" -+ -+//---Touch info.--- -+#define TOUCH_DEFAULT_MAX_WIDTH 1600 -+#define TOUCH_DEFAULT_MAX_HEIGHT 2560 -+#define TOUCH_MAX_FINGER_NUM 10 -+#define TOUCH_KEY_NUM 0 -+#if TOUCH_KEY_NUM > 0 -+extern const uint16_t touch_key_array[TOUCH_KEY_NUM]; -+#endif -+#define TOUCH_FORCE_NUM 1000 -+//---for Pen--- -+#define PEN_PRESSURE_MAX (4095) -+#define PEN_DISTANCE_MAX (1) -+#define PEN_TILT_MIN (-60) -+#define PEN_TILT_MAX (60) -+ -+/* Enable only when module have tp reset pin and connected to host */ -+#define NVT_TOUCH_SUPPORT_HW_RST 0 -+ -+//---Customerized func.--- -+#define NVT_TOUCH_MP 0 -+#define NVT_TOUCH_MP_SETTING_CRITERIA_FROM_CSV 0 -+#define MT_PROTOCOL_B 1 -+#define FUNCPAGE_PALM 4 -+#define PACKET_PALM_ON 3 -+#define PACKET_PALM_OFF 4 -+ -+#define BOOT_UPDATE_FIRMWARE 1 -+#define DEFAULT_BOOT_UPDATE_FIRMWARE_NAME "novatek/nt36523.bin" -+#define DEFAULT_MP_UPDATE_FIRMWARE_NAME "novatek_ts_mp.bin" -+ -+//---ESD Protect.--- -+#define NVT_TOUCH_ESD_PROTECT 1 -+#define NVT_TOUCH_ESD_CHECK_PERIOD 1500 /* ms */ -+#define NVT_TOUCH_WDT_RECOVERY 1 -+ -+enum nvt_ic_state { -+ NVT_IC_SUSPEND_IN, -+ NVT_IC_SUSPEND_OUT, -+ NVT_IC_RESUME_IN, -+ NVT_IC_RESUME_OUT, -+ NVT_IC_INIT, -+}; -+ -+struct nvt_config_info { -+ u8 tp_vendor; -+ u8 tp_color; -+ u8 display_maker; -+ u8 glass_vendor; -+ const char *nvt_fw_name; -+ const char *nvt_mp_name; -+ const char *nvt_limit_name; -+}; -+ -+struct nvt_ts_data { -+ struct spi_device *client; -+ struct input_dev *input_dev; -+ struct delayed_work nvt_fwu_work; -+ struct work_struct switch_mode_work; -+ struct work_struct pen_charge_state_change_work; -+ bool pen_is_charge; -+ struct notifier_block pen_charge_state_notifier; -+ uint16_t addr; -+ int8_t phys[32]; -+#if defined(CONFIG_FB) -+#ifdef CONFIG_DRM -+ struct notifier_block drm_notif; -+#else -+ struct notifier_block fb_notif; -+#endif -+#endif -+ uint32_t config_array_size; -+ struct nvt_config_info *config_array; -+ const char *fw_name; -+ bool lkdown_readed; -+ uint8_t fw_ver; -+ uint8_t x_num; -+ uint8_t y_num; -+ int ic_state; -+ uint16_t abs_x_max; -+ uint16_t abs_y_max; -+ uint8_t max_touch_num; -+ uint8_t max_button_num; -+ uint32_t int_trigger_type; -+ int32_t irq_gpio; -+ uint32_t irq_flags; -+ int32_t reset_gpio; -+ uint32_t reset_flags; -+ struct mutex lock; -+ const struct nvt_ts_mem_map *mmap; -+ uint8_t carrier_system; -+ uint8_t hw_crc; -+ uint16_t nvt_pid; -+ uint8_t *rbuf; -+ uint8_t *xbuf; -+ struct mutex xbuf_lock; -+ bool irq_enabled; -+ uint8_t cascade; -+ bool pen_support; -+ bool wgp_stylus; -+ uint8_t x_gang_num; -+ uint8_t y_gang_num; -+ struct input_dev *pen_input_dev; -+ bool pen_input_dev_enable; -+ int8_t pen_phys[32]; -+ struct workqueue_struct *event_wq; -+ struct work_struct suspend_work; -+ struct work_struct resume_work; -+ int result_type; -+ int panel_index; -+ uint32_t spi_max_freq; -+ int db_wakeup; -+ uint8_t debug_flag; -+ bool fw_debug; -+ bool dev_pm_suspend; -+ struct completion dev_pm_suspend_completion; -+ bool palm_sensor_switch; -+ int gesture_command_delayed; -+ struct pinctrl *ts_pinctrl; -+ struct pinctrl_state *pinctrl_state_active; -+ struct pinctrl_state *pinctrl_state_suspend; -+}; -+ -+typedef enum { -+ RESET_STATE_INIT = 0xA0,// IC reset -+ RESET_STATE_REK, // ReK baseline -+ RESET_STATE_REK_FINISH, // baseline is ready -+ RESET_STATE_NORMAL_RUN, // normal run -+ RESET_STATE_MAX = 0xAF -+} RST_COMPLETE_STATE; -+ -+typedef enum { -+ EVENT_MAP_HOST_CMD = 0x50, -+ EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE = 0x51, -+ EVENT_MAP_RESET_COMPLETE = 0x60, -+ EVENT_MAP_FWINFO = 0x78, -+ EVENT_MAP_PROJECTID = 0x9A, -+} SPI_EVENT_MAP; -+ -+//---SPI READ/WRITE--- -+#define SPI_WRITE_MASK(a) (a | 0x80) -+#define SPI_READ_MASK(a) (a & 0x7F) -+ -+#define DUMMY_BYTES (1) -+#define NVT_TRANSFER_LEN (63*1024) -+#define NVT_READ_LEN (2*1024) -+ -+typedef enum { -+ NVTWRITE = 0, -+ NVTREAD = 1 -+} NVT_SPI_RW; -+ -+//---extern structures--- -+extern struct nvt_ts_data *ts; -+ -+//---extern functions--- -+int32_t CTP_SPI_READ(struct spi_device *client, uint8_t *buf, uint16_t len); -+int32_t CTP_SPI_WRITE(struct spi_device *client, uint8_t *buf, uint16_t len); -+void nvt_bootloader_reset(void); -+void nvt_eng_reset(void); -+void nvt_sw_reset(void); -+void nvt_sw_reset_idle(void); -+void nvt_boot_ready(void); -+void nvt_bld_crc_enable(void); -+void nvt_fw_crc_enable(void); -+void nvt_tx_auto_copy_mode(void); -+void nvt_set_dbgfw_status(bool enable); -+void nvt_match_fw(void); -+int32_t nvt_update_firmware(const char *firmware_name); -+int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state); -+int32_t nvt_get_fw_info(void); -+int32_t nvt_clear_fw_status(void); -+int32_t nvt_check_fw_status(void); -+int32_t nvt_check_spi_dma_tx_info(void); -+int32_t nvt_set_page(uint32_t addr); -+int32_t nvt_write_addr(uint32_t addr, uint8_t data); -+bool nvt_get_dbgfw_status(void); -+int32_t nvt_set_pocket_palm_switch(uint8_t pocket_palm_switch); -+#if NVT_TOUCH_ESD_PROTECT -+extern void nvt_esd_check_enable(uint8_t enable); -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+#endif /* _LINUX_NVT_TOUCH_H */ -diff --git a/drivers/input/touchscreen/nt36523/nt36xxx_fw_update.c b/drivers/input/touchscreen/nt36523/nt36xxx_fw_update.c -new file mode 100644 -index 000000000000..4f383dac2c3c ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/nt36xxx_fw_update.c -@@ -0,0 +1,857 @@ -+/* -+ * Copyright (C) 2010 - 2018 Novatek, Inc. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * $Revision: 68983 $ -+ * $Date: 2020-09-17 09:43:23 +0800 (週四, 17 九月 2020) $ -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ * more details. -+ * -+ */ -+ -+#include -+#include -+ -+#include "nt36xxx.h" -+ -+#if BOOT_UPDATE_FIRMWARE -+ -+#define SIZE_4KB 4096 -+#define FLASH_SECTOR_SIZE SIZE_4KB -+#define FW_BIN_VER_OFFSET (fw_need_write_size - SIZE_4KB) -+#define FW_BIN_VER_BAR_OFFSET (FW_BIN_VER_OFFSET + 1) -+#define NVT_FLASH_END_FLAG_LEN 3 -+#define NVT_FLASH_END_FLAG_ADDR (fw_need_write_size - NVT_FLASH_END_FLAG_LEN) -+ -+static ktime_t start, end; -+const struct firmware *fw_entry = NULL; -+static size_t fw_need_write_size = 0; -+static uint8_t *fwbuf = NULL; -+ -+struct nvt_ts_bin_map { -+ char name[12]; -+ uint32_t BIN_addr; -+ uint32_t SRAM_addr; -+ uint32_t size; -+ uint32_t crc; -+}; -+ -+static struct nvt_ts_bin_map *bin_map; -+ -+/******************************************************* -+Description: -+ Novatek touchscreen init variable and allocate buffer -+for download firmware function. -+ -+return: -+ n.a. -+*******************************************************/ -+static int32_t nvt_download_init(void) -+{ -+ /* allocate buffer for transfer firmware */ -+ //NVT_LOG("NVT_TRANSFER_LEN = 0x%06X\n", NVT_TRANSFER_LEN); -+ -+ if (fwbuf == NULL) { -+ fwbuf = (uint8_t *)kzalloc((NVT_TRANSFER_LEN + 1 + DUMMY_BYTES), GFP_KERNEL); -+ if(fwbuf == NULL) { -+ NVT_ERR("kzalloc for fwbuf failed!\n"); -+ return -ENOMEM; -+ } -+ } -+ -+ return 0; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen checksum function. Calculate bin -+file checksum for comparison. -+ -+return: -+ n.a. -+*******************************************************/ -+static uint32_t CheckSum(const u8 *data, size_t len) -+{ -+ uint32_t i = 0; -+ uint32_t checksum = 0; -+ -+ for (i = 0 ; i < len+1 ; i++) -+ checksum += data[i]; -+ -+ checksum += len; -+ checksum = ~checksum +1; -+ -+ return checksum; -+} -+ -+static uint32_t byte_to_word(const uint8_t *data) -+{ -+ return data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen parsing bin header function. -+ -+return: -+ n.a. -+*******************************************************/ -+static uint32_t partition = 0; -+static uint8_t ilm_dlm_num = 2; -+static uint8_t cascade_2nd_header_info = 0; -+static int32_t nvt_bin_header_parser(const u8 *fwdata, size_t fwsize) -+{ -+ uint32_t list = 0; -+ uint32_t pos = 0x00; -+ uint32_t end = 0x00; -+ uint8_t info_sec_num = 0; -+ uint8_t ovly_sec_num = 0; -+ uint8_t ovly_info = 0; -+ uint8_t find_bin_header = 0; -+ -+ /* Find the header size */ -+ end = fwdata[0] + (fwdata[1] << 8) + (fwdata[2] << 16) + (fwdata[3] << 24); -+ -+ /* check cascade next header */ -+ cascade_2nd_header_info = (fwdata[0x20] & 0x02) >> 1; -+ NVT_LOG("cascade_2nd_header_info = %d\n", cascade_2nd_header_info); -+ -+ if (cascade_2nd_header_info) { -+ pos = 0x30; // info section start at 0x30 offset -+ while (pos < (end / 2)) { -+ info_sec_num ++; -+ pos += 0x10; /* each header info is 16 bytes */ -+ } -+ -+ info_sec_num = info_sec_num + 1; //next header section -+ } else { -+ pos = 0x30; // info section start at 0x30 offset -+ while (pos < end) { -+ info_sec_num ++; -+ pos += 0x10; /* each header info is 16 bytes */ -+ } -+ } -+ -+ /* -+ * Find the DLM OVLY section -+ * [0:3] Overlay Section Number -+ * [4] Overlay Info -+ */ -+ ovly_info = (fwdata[0x28] & 0x10) >> 4; -+ ovly_sec_num = (ovly_info) ? (fwdata[0x28] & 0x0F) : 0; -+ -+ /* -+ * calculate all partition number -+ * ilm_dlm_num (ILM & DLM) + ovly_sec_num + info_sec_num -+ */ -+ partition = ilm_dlm_num + ovly_sec_num + info_sec_num; -+ NVT_LOG("ovly_info = %d, ilm_dlm_num = %d, ovly_sec_num = %d, info_sec_num = %d, partition = %d\n", -+ ovly_info, ilm_dlm_num, ovly_sec_num, info_sec_num, partition); -+ -+ /* allocated memory for header info */ -+ bin_map = (struct nvt_ts_bin_map *)kzalloc((partition+1) * sizeof(struct nvt_ts_bin_map), GFP_KERNEL); -+ if(bin_map == NULL) { -+ NVT_ERR("kzalloc for bin_map failed!\n"); -+ return -ENOMEM; -+ } -+ -+ for (list = 0; list < partition; list++) { -+ /* -+ * [1] parsing ILM & DLM header info -+ * BIN_addr : SRAM_addr : size (12-bytes) -+ * crc located at 0x18 & 0x1C -+ */ -+ if (list < ilm_dlm_num) { -+ bin_map[list].BIN_addr = byte_to_word(&fwdata[0 + list*12]); -+ bin_map[list].SRAM_addr = byte_to_word(&fwdata[4 + list*12]); -+ bin_map[list].size = byte_to_word(&fwdata[8 + list*12]); -+ if (ts->hw_crc) -+ bin_map[list].crc = byte_to_word(&fwdata[0x18 + list*4]); -+ else { //ts->hw_crc -+ if ((bin_map[list].BIN_addr + bin_map[list].size) < fwsize) -+ bin_map[list].crc = CheckSum(&fwdata[bin_map[list].BIN_addr], bin_map[list].size); -+ else { -+ NVT_ERR("access range (0x%08X to 0x%08X) is larger than bin size!\n", -+ bin_map[list].BIN_addr, bin_map[list].BIN_addr + bin_map[list].size); -+ return -EINVAL; -+ } -+ } //ts->hw_crc -+ if (list == 0) -+ sprintf(bin_map[list].name, "ILM"); -+ else if (list == 1) -+ sprintf(bin_map[list].name, "DLM"); -+ } -+ -+ /* -+ * [2] parsing others header info -+ * SRAM_addr : size : BIN_addr : crc (16-bytes) -+ */ -+ if ((list >= ilm_dlm_num) && (list < (ilm_dlm_num + info_sec_num))) { -+ if (find_bin_header == 0) { -+ /* others partition located at 0x30 offset */ -+ pos = 0x30 + (0x10 * (list - ilm_dlm_num)); -+ } else if (find_bin_header && cascade_2nd_header_info) { -+ /* cascade 2nd header info */ -+ pos = end - 0x10; -+ } -+ -+ bin_map[list].SRAM_addr = byte_to_word(&fwdata[pos]); -+ bin_map[list].size = byte_to_word(&fwdata[pos+4]); -+ bin_map[list].BIN_addr = byte_to_word(&fwdata[pos+8]); -+ if (ts->hw_crc) -+ bin_map[list].crc = byte_to_word(&fwdata[pos+12]); -+ else { //ts->hw_crc -+ if ((bin_map[list].BIN_addr + bin_map[list].size) < fwsize) -+ bin_map[list].crc = CheckSum(&fwdata[bin_map[list].BIN_addr], bin_map[list].size); -+ else { -+ NVT_ERR("access range (0x%08X to 0x%08X) is larger than bin size!\n", -+ bin_map[list].BIN_addr, bin_map[list].BIN_addr + bin_map[list].size); -+ return -EINVAL; -+ } -+ } //ts->hw_crc -+ /* detect header end to protect parser function */ -+ if ((bin_map[list].BIN_addr < end) && (bin_map[list].size != 0)) { -+ sprintf(bin_map[list].name, "Header"); -+ find_bin_header = 1; -+ } else { -+ sprintf(bin_map[list].name, "Info-%d", (list - ilm_dlm_num)); -+ } -+ } -+ -+ /* -+ * [3] parsing overlay section header info -+ * SRAM_addr : size : BIN_addr : crc (16-bytes) -+ */ -+ if (list >= (ilm_dlm_num + info_sec_num)) { -+ /* overlay info located at DLM (list = 1) start addr */ -+ pos = bin_map[1].BIN_addr + (0x10 * (list- ilm_dlm_num - info_sec_num)); -+ -+ bin_map[list].SRAM_addr = byte_to_word(&fwdata[pos]); -+ bin_map[list].size = byte_to_word(&fwdata[pos+4]); -+ bin_map[list].BIN_addr = byte_to_word(&fwdata[pos+8]); -+ if (ts->hw_crc) -+ bin_map[list].crc = byte_to_word(&fwdata[pos+12]); -+ else { //ts->hw_crc -+ if ((bin_map[list].BIN_addr + bin_map[list].size) < fwsize) -+ bin_map[list].crc = CheckSum(&fwdata[bin_map[list].BIN_addr], bin_map[list].size); -+ else { -+ NVT_ERR("access range (0x%08X to 0x%08X) is larger than bin size!\n", -+ bin_map[list].BIN_addr, bin_map[list].BIN_addr + bin_map[list].size); -+ return -EINVAL; -+ } -+ } //ts->hw_crc -+ sprintf(bin_map[list].name, "Overlay-%d", (list- ilm_dlm_num - info_sec_num)); -+ } -+ -+ /* BIN size error detect */ -+ if ((bin_map[list].BIN_addr + bin_map[list].size) > fwsize) { -+ NVT_ERR("access range (0x%08X to 0x%08X) is larger than bin size!\n", -+ bin_map[list].BIN_addr, bin_map[list].BIN_addr + bin_map[list].size); -+ return -EINVAL; -+ } -+ -+// NVT_LOG("[%d][%s] SRAM (0x%08X), SIZE (0x%08X), BIN (0x%08X), CRC (0x%08X)\n", -+// list, bin_map[list].name, -+// bin_map[list].SRAM_addr, bin_map[list].size, bin_map[list].BIN_addr, bin_map[list].crc); -+ } -+ -+ return 0; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen release update firmware function. -+ -+return: -+ n.a. -+*******************************************************/ -+static void update_firmware_release(void) -+{ -+ if (fw_entry) { -+ release_firmware(fw_entry); -+ } -+ -+ fw_entry = NULL; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen request update firmware function. -+ -+return: -+ Executive outcomes. 0---succeed. -1,-22---failed. -+*******************************************************/ -+static int32_t update_firmware_request(const char *filename) -+{ -+ uint8_t retry = 0; -+ int32_t ret = 0; -+ -+ if (NULL == filename) { -+ return -ENOENT; -+ } -+ -+ while (1) { -+ NVT_LOG("filename is %s\n", filename); -+ -+ ret = request_firmware(&fw_entry, filename, &ts->client->dev); -+ if (ret) { -+ NVT_ERR("firmware load failed, ret=%d\n", ret); -+ goto request_fail; -+ } -+ -+ fw_need_write_size = fw_entry->size; -+ -+ // check if FW version add FW version bar equals 0xFF -+ if (*(fw_entry->data + FW_BIN_VER_OFFSET) + *(fw_entry->data + FW_BIN_VER_BAR_OFFSET) != 0xFF) { -+ NVT_ERR("bin file FW_VER + FW_VER_BAR should be 0xFF!\n"); -+ NVT_ERR("FW_VER=0x%02X, FW_VER_BAR=0x%02X\n", *(fw_entry->data+FW_BIN_VER_OFFSET), *(fw_entry->data+FW_BIN_VER_BAR_OFFSET)); -+ ret = -ENOEXEC; -+ goto invalid; -+ } -+ -+ /* BIN Header Parser */ -+ ret = nvt_bin_header_parser(fw_entry->data, fw_entry->size); -+ if (ret) { -+ NVT_ERR("bin header parser failed\n"); -+ goto invalid; -+ } else { -+ break; -+ } -+ -+invalid: -+ update_firmware_release(); -+ if (!IS_ERR_OR_NULL(bin_map)) { -+ kfree(bin_map); -+ bin_map = NULL; -+ } -+ -+request_fail: -+ retry++; -+ if(unlikely(retry > 2)) { -+ NVT_ERR("error, retry=%d\n", retry); -+ break; -+ } -+ } -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen write data to sram function. -+ -+- fwdata : The buffer is written -+- SRAM_addr: The sram destination address -+- size : Number of data bytes in @fwdata being written -+- BIN_addr : The transferred data offset of @fwdata -+ -+return: -+ Executive outcomes. 0---succeed. else---fail. -+*******************************************************/ -+static int32_t nvt_write_sram(const u8 *fwdata, -+ uint32_t SRAM_addr, uint32_t size, uint32_t BIN_addr) -+{ -+ int32_t ret = 0; -+ uint32_t i = 0; -+ uint16_t len = 0; -+ int32_t count = 0; -+ -+ if (size % NVT_TRANSFER_LEN) -+ count = (size / NVT_TRANSFER_LEN) + 1; -+ else -+ count = (size / NVT_TRANSFER_LEN); -+ -+ for (i = 0 ; i < count ; i++) { -+ len = (size < NVT_TRANSFER_LEN) ? size : NVT_TRANSFER_LEN; -+ -+ //---set xdata index to start address of SRAM--- -+ ret = nvt_set_page(SRAM_addr); -+ if (ret) { -+ NVT_ERR("set page failed, ret = %d\n", ret); -+ return ret; -+ } -+ -+ //---write data into SRAM--- -+ fwbuf[0] = SRAM_addr & 0x7F; //offset -+ memcpy(fwbuf+1, &fwdata[BIN_addr], len); //payload -+ ret = CTP_SPI_WRITE(ts->client, fwbuf, len+1); -+ if (ret) { -+ NVT_ERR("write to sram failed, ret = %d\n", ret); -+ return ret; -+ } -+ -+ SRAM_addr += NVT_TRANSFER_LEN; -+ BIN_addr += NVT_TRANSFER_LEN; -+ size -= NVT_TRANSFER_LEN; -+ } -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen nvt_write_firmware function to write -+firmware into each partition. -+ -+return: -+ n.a. -+*******************************************************/ -+static int32_t nvt_write_firmware(const u8 *fwdata, size_t fwsize) -+{ -+ uint32_t list = 0; -+ char *name; -+ uint32_t BIN_addr, SRAM_addr, size; -+ int32_t ret = 0; -+ -+ memset(fwbuf, 0, (NVT_TRANSFER_LEN+1)); -+ -+ for (list = 0; list < partition; list++) { -+ /* initialize variable */ -+ SRAM_addr = bin_map[list].SRAM_addr; -+ size = bin_map[list].size; -+ BIN_addr = bin_map[list].BIN_addr; -+ name = bin_map[list].name; -+ -+// NVT_LOG("[%d][%s] SRAM (0x%08X), SIZE (0x%08X), BIN (0x%08X)\n", -+// list, name, SRAM_addr, size, BIN_addr); -+ -+ /* Check data size */ -+ if ((BIN_addr + size) > fwsize) { -+ NVT_ERR("access range (0x%08X to 0x%08X) is larger than bin size!\n", -+ BIN_addr, BIN_addr + size); -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ /* ignore reserved partition (Reserved Partition size is zero) */ -+ if (!size) -+ continue; -+ else -+ size = size +1; -+ -+ /* write data to SRAM */ -+ ret = nvt_write_sram(fwdata, SRAM_addr, size, BIN_addr); -+ if (ret) { -+ NVT_ERR("sram program failed, ret = %d\n", ret); -+ goto out; -+ } -+ } -+ -+out: -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen check checksum function. -+This function will compare file checksum and fw checksum. -+ -+return: -+ n.a. -+*******************************************************/ -+static int32_t nvt_check_fw_checksum(void) -+{ -+ uint32_t fw_checksum = 0; -+ uint32_t len = partition*4; -+ uint32_t list = 0; -+ int32_t ret = 0; -+ -+ memset(fwbuf, 0, (len+1)); -+ -+ //---set xdata index to checksum--- -+ nvt_set_page(ts->mmap->R_ILM_CHECKSUM_ADDR); -+ -+ /* read checksum */ -+ fwbuf[0] = (ts->mmap->R_ILM_CHECKSUM_ADDR) & 0x7F; -+ ret = CTP_SPI_READ(ts->client, fwbuf, len+1); -+ if (ret) { -+ NVT_ERR("Read fw checksum failed\n"); -+ return ret; -+ } -+ -+ /* -+ * Compare each checksum from fw -+ * ILM + DLM + Overlay + Info -+ * ilm_dlm_num (ILM & DLM) + ovly_sec_num + info_sec_num -+ */ -+ for (list = 0; list < partition; list++) { -+ fw_checksum = byte_to_word(&fwbuf[1+list*4]); -+ -+ /* ignore reserved partition (Reserved Partition size is zero) */ -+ if(!bin_map[list].size) -+ continue; -+ -+ if (bin_map[list].crc != fw_checksum) { -+ NVT_ERR("[%d] BIN_checksum=0x%08X, FW_checksum=0x%08X\n", -+ list, bin_map[list].crc, fw_checksum); -+ ret = -EIO; -+ } -+ } -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen set bootload crc reg bank function. -+This function will set hw crc reg before enable crc function. -+ -+return: -+ n.a. -+*******************************************************/ -+static void nvt_set_bld_crc_bank(uint32_t DES_ADDR, uint32_t SRAM_ADDR, -+ uint32_t LENGTH_ADDR, uint32_t size, -+ uint32_t G_CHECKSUM_ADDR, uint32_t crc) -+{ -+ /* write destination address */ -+ nvt_set_page(DES_ADDR); -+ fwbuf[0] = DES_ADDR & 0x7F; -+ fwbuf[1] = (SRAM_ADDR) & 0xFF; -+ fwbuf[2] = (SRAM_ADDR >> 8) & 0xFF; -+ fwbuf[3] = (SRAM_ADDR >> 16) & 0xFF; -+ CTP_SPI_WRITE(ts->client, fwbuf, 4); -+ -+ /* write length */ -+ //nvt_set_page(LENGTH_ADDR); -+ fwbuf[0] = LENGTH_ADDR & 0x7F; -+ fwbuf[1] = (size) & 0xFF; -+ fwbuf[2] = (size >> 8) & 0xFF; -+ fwbuf[3] = (size >> 16) & 0x01; -+ if (ts->hw_crc == 1) { -+ CTP_SPI_WRITE(ts->client, fwbuf, 3); -+ } else if (ts->hw_crc > 1) { -+ CTP_SPI_WRITE(ts->client, fwbuf, 4); -+ } -+ -+ /* write golden dlm checksum */ -+ //nvt_set_page(G_CHECKSUM_ADDR); -+ fwbuf[0] = G_CHECKSUM_ADDR & 0x7F; -+ fwbuf[1] = (crc) & 0xFF; -+ fwbuf[2] = (crc >> 8) & 0xFF; -+ fwbuf[3] = (crc >> 16) & 0xFF; -+ fwbuf[4] = (crc >> 24) & 0xFF; -+ CTP_SPI_WRITE(ts->client, fwbuf, 5); -+ -+ return; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen set BLD hw crc function. -+This function will set ILM and DLM crc information to register. -+ -+return: -+ n.a. -+*******************************************************/ -+static void nvt_set_bld_hw_crc(void) -+{ -+ /* [0] ILM */ -+ /* write register bank */ -+ nvt_set_bld_crc_bank(ts->mmap->ILM_DES_ADDR, bin_map[0].SRAM_addr, -+ ts->mmap->ILM_LENGTH_ADDR, bin_map[0].size, -+ ts->mmap->G_ILM_CHECKSUM_ADDR, bin_map[0].crc); -+ -+ /* [1] DLM */ -+ /* write register bank */ -+ nvt_set_bld_crc_bank(ts->mmap->DLM_DES_ADDR, bin_map[1].SRAM_addr, -+ ts->mmap->DLM_LENGTH_ADDR, bin_map[1].size, -+ ts->mmap->G_DLM_CHECKSUM_ADDR, bin_map[1].crc); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen read BLD hw crc info function. -+This function will check crc results from register. -+ -+return: -+ n.a. -+*******************************************************/ -+static void nvt_read_bld_hw_crc(void) -+{ -+ uint8_t buf[8] = {0}; -+ uint32_t g_crc = 0, r_crc = 0; -+ -+ /* CRC Flag */ -+ nvt_set_page(ts->mmap->BLD_ILM_DLM_CRC_ADDR); -+ buf[0] = ts->mmap->BLD_ILM_DLM_CRC_ADDR & 0x7F; -+ buf[1] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 2); -+ NVT_ERR("crc_done = %d, ilm_crc_flag = %d, dlm_crc_flag = %d\n", -+ (buf[1] >> 2) & 0x01, (buf[1] >> 0) & 0x01, (buf[1] >> 1) & 0x01); -+ -+ /* ILM CRC */ -+ nvt_set_page(ts->mmap->G_ILM_CHECKSUM_ADDR); -+ buf[0] = ts->mmap->G_ILM_CHECKSUM_ADDR & 0x7F; -+ buf[1] = 0x00; -+ buf[2] = 0x00; -+ buf[3] = 0x00; -+ buf[4] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 5); -+ g_crc = buf[1] | (buf[2] << 8) | (buf[3] << 16) | (buf[4] << 24); -+ -+ nvt_set_page(ts->mmap->R_ILM_CHECKSUM_ADDR); -+ buf[0] = ts->mmap->R_ILM_CHECKSUM_ADDR & 0x7F; -+ buf[1] = 0x00; -+ buf[2] = 0x00; -+ buf[3] = 0x00; -+ buf[4] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 5); -+ r_crc = buf[1] | (buf[2] << 8) | (buf[3] << 16) | (buf[4] << 24); -+ -+ NVT_ERR("ilm: bin crc = 0x%08X, golden = 0x%08X, result = 0x%08X\n", -+ bin_map[0].crc, g_crc, r_crc); -+ -+ /* DLM CRC */ -+ nvt_set_page(ts->mmap->G_DLM_CHECKSUM_ADDR); -+ buf[0] = ts->mmap->G_DLM_CHECKSUM_ADDR & 0x7F; -+ buf[1] = 0x00; -+ buf[2] = 0x00; -+ buf[3] = 0x00; -+ buf[4] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 5); -+ g_crc = buf[1] | (buf[2] << 8) | (buf[3] << 16) | (buf[4] << 24); -+ -+ nvt_set_page(ts->mmap->R_DLM_CHECKSUM_ADDR); -+ buf[0] = ts->mmap->R_DLM_CHECKSUM_ADDR & 0x7F; -+ buf[1] = 0x00; -+ buf[2] = 0x00; -+ buf[3] = 0x00; -+ buf[4] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 5); -+ r_crc = buf[1] | (buf[2] << 8) | (buf[3] << 16) | (buf[4] << 24); -+ -+ NVT_ERR("dlm: bin crc = 0x%08X, golden = 0x%08X, result = 0x%08X\n", -+ bin_map[1].crc, g_crc, r_crc); -+ -+ return; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen Download_Firmware with HW CRC -+function. It's complete download firmware flow. -+ -+return: -+ Executive outcomes. 0---succeed. else---fail. -+*******************************************************/ -+static int32_t nvt_download_firmware_hw_crc(void) -+{ -+ uint8_t retry = 0; -+ int32_t ret = 0; -+ -+ start = ktime_get(); -+ -+ while (1) { -+ /* bootloader reset to reset MCU */ -+ nvt_bootloader_reset(); -+ -+ /* set ilm & dlm reg bank */ -+ nvt_set_bld_hw_crc(); -+ -+ /* Start to write firmware process */ -+ if (cascade_2nd_header_info) { -+ /* for cascade */ -+ nvt_tx_auto_copy_mode(); -+ -+ ret = nvt_write_firmware(fw_entry->data, fw_entry->size); -+ if (ret) { -+ NVT_ERR("Write_Firmware failed. (%d)\n", ret); -+ goto fail; -+ } -+ -+ ret = nvt_check_spi_dma_tx_info(); -+ if (ret) { -+ NVT_ERR("spi dma tx info failed. (%d)\n", ret); -+ goto fail; -+ } -+ } else { -+ ret = nvt_write_firmware(fw_entry->data, fw_entry->size); -+ if (ret) { -+ NVT_ERR("Write_Firmware failed. (%d)\n", ret); -+ goto fail; -+ } -+ } -+ -+ /* enable hw bld crc function */ -+ nvt_bld_crc_enable(); -+ -+ /* clear fw reset status & enable fw crc check */ -+ nvt_fw_crc_enable(); -+ -+ /* Set Boot Ready Bit */ -+ nvt_boot_ready(); -+ -+ ret = nvt_check_fw_reset_state(RESET_STATE_INIT); -+ if (ret) { -+ NVT_ERR("nvt_check_fw_reset_state failed. (%d)\n", ret); -+ goto fail; -+ } else { -+ break; -+ } -+ -+fail: -+ retry++; -+ if(unlikely(retry > 2)) { -+ NVT_ERR("error, retry=%d\n", retry); -+ nvt_read_bld_hw_crc(); -+ break; -+ } -+ } -+ -+ end = ktime_get(); -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen Download_Firmware function. It's -+complete download firmware flow. -+ -+return: -+ n.a. -+*******************************************************/ -+static int32_t nvt_download_firmware(void) -+{ -+ uint8_t retry = 0; -+ int32_t ret = 0; -+ -+ start = ktime_get(); -+ -+ while (1) { -+ /* -+ * Send eng reset cmd before download FW -+ * Keep TP_RESX low when send eng reset cmd -+ */ -+#if NVT_TOUCH_SUPPORT_HW_RST -+ gpio_set_value(ts->reset_gpio, 0); -+ mdelay(1); //wait 1ms -+#endif -+ nvt_eng_reset(); -+#if NVT_TOUCH_SUPPORT_HW_RST -+ gpio_set_value(ts->reset_gpio, 1); -+ mdelay(10); //wait tRT2BRST after TP_RST -+#endif -+ nvt_bootloader_reset(); -+ -+ /* clear fw reset status */ -+ nvt_write_addr(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_RESET_COMPLETE, 0x00); -+ -+ /* Start to write firmware process */ -+ ret = nvt_write_firmware(fw_entry->data, fw_entry->size); -+ if (ret) { -+ NVT_ERR("Write_Firmware failed. (%d)\n", ret); -+ goto fail; -+ } -+ -+ /* Set Boot Ready Bit */ -+ nvt_boot_ready(); -+ -+ ret = nvt_check_fw_reset_state(RESET_STATE_INIT); -+ if (ret) { -+ NVT_ERR("nvt_check_fw_reset_state failed. (%d)\n", ret); -+ goto fail; -+ } -+ -+ /* check fw checksum result */ -+ ret = nvt_check_fw_checksum(); -+ if (ret) { -+ NVT_ERR("firmware checksum not match, retry=%d\n", retry); -+ goto fail; -+ } else { -+ break; -+ } -+ -+fail: -+ retry++; -+ if(unlikely(retry > 2)) { -+ NVT_ERR("error, retry=%d\n", retry); -+ break; -+ } -+ } -+ -+ end = ktime_get(); -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen update firmware main function. -+ -+return: -+ n.a. -+*******************************************************/ -+int32_t nvt_update_firmware(const char *firmware_name) -+{ -+ int32_t ret = 0; -+ -+ // request bin file in "/etc/firmware" -+ ret = update_firmware_request(firmware_name); -+ if (ret) { -+ NVT_ERR("update_firmware_request failed. (%d)\n", ret); -+ goto request_firmware_fail; -+ } -+ -+ /* initial buffer and variable */ -+ ret = nvt_download_init(); -+ if (ret) { -+ NVT_ERR("Download Init failed. (%d)\n", ret); -+ goto download_fail; -+ } -+ -+ /* download firmware process */ -+ if (ts->hw_crc) -+ ret = nvt_download_firmware_hw_crc(); -+ else -+ ret = nvt_download_firmware(); -+ if (ret) { -+ NVT_ERR("Download Firmware failed. (%d)\n", ret); -+ goto download_fail; -+ } -+ -+ NVT_LOG("Update firmware success! <%ld us>\n", -+ (long) ktime_us_delta(end, start)); -+ -+ /* Get FW Info */ -+ ret = nvt_get_fw_info(); -+ if (ret) { -+ NVT_ERR("nvt_get_fw_info failed. (%d)\n", ret); -+ } -+ -+download_fail: -+ if (!IS_ERR_OR_NULL(bin_map)) { -+ kfree(bin_map); -+ bin_map = NULL; -+ } -+ -+ update_firmware_release(); -+request_firmware_fail: -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen update firmware when booting -+ function. -+ -+return: -+ n.a. -+*******************************************************/ -+void Boot_Update_Firmware(struct work_struct *work) -+{ -+ mutex_lock(&ts->lock); -+ nvt_update_firmware(ts->fw_name); -+ nvt_get_fw_info(); -+ mutex_unlock(&ts->lock); -+} -+#endif /* BOOT_UPDATE_FIRMWARE */ -diff --git a/drivers/input/touchscreen/nt36523/nt36xxx_mem_map.h b/drivers/input/touchscreen/nt36523/nt36xxx_mem_map.h -new file mode 100644 -index 000000000000..3f4195d636a0 ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/nt36xxx_mem_map.h -@@ -0,0 +1,390 @@ -+/* -+ * Copyright (C) 2010 - 2018 Novatek, Inc. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * $Revision: 57674 $ -+ * $Date: 2020-03-02 11:16:20 +0800 (週一, 02 三月 2020) $ -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ * more details. -+ * -+ */ -+ -+#define CHIP_VER_TRIM_ADDR 0x3F004 -+#define CHIP_VER_TRIM_OLD_ADDR 0x1F64E -+ -+struct nvt_ts_mem_map { -+ uint32_t EVENT_BUF_ADDR; -+ uint32_t RAW_PIPE0_ADDR; -+ uint32_t RAW_PIPE1_ADDR; -+ uint32_t BASELINE_ADDR; -+ uint32_t BASELINE_BTN_ADDR; -+ uint32_t DIFF_PIPE0_ADDR; -+ uint32_t DIFF_PIPE1_ADDR; -+ uint32_t RAW_BTN_PIPE0_ADDR; -+ uint32_t RAW_BTN_PIPE1_ADDR; -+ uint32_t DIFF_BTN_PIPE0_ADDR; -+ uint32_t DIFF_BTN_PIPE1_ADDR; -+ uint32_t PEN_2D_BL_TIP_X_ADDR; -+ uint32_t PEN_2D_BL_TIP_Y_ADDR; -+ uint32_t PEN_2D_BL_RING_X_ADDR; -+ uint32_t PEN_2D_BL_RING_Y_ADDR; -+ uint32_t PEN_2D_DIFF_TIP_X_ADDR; -+ uint32_t PEN_2D_DIFF_TIP_Y_ADDR; -+ uint32_t PEN_2D_DIFF_RING_X_ADDR; -+ uint32_t PEN_2D_DIFF_RING_Y_ADDR; -+ uint32_t PEN_2D_RAW_TIP_X_ADDR; -+ uint32_t PEN_2D_RAW_TIP_Y_ADDR; -+ uint32_t PEN_2D_RAW_RING_X_ADDR; -+ uint32_t PEN_2D_RAW_RING_Y_ADDR; -+ uint32_t PEN_1D_DIFF_TIP_X_ADDR; -+ uint32_t PEN_1D_DIFF_TIP_Y_ADDR; -+ uint32_t PEN_1D_DIFF_RING_X_ADDR; -+ uint32_t PEN_1D_DIFF_RING_Y_ADDR; -+ uint32_t READ_FLASH_CHECKSUM_ADDR; -+ uint32_t RW_FLASH_DATA_ADDR; -+ /* Phase 2 Host Download */ -+ uint32_t BOOT_RDY_ADDR; -+ uint32_t POR_CD_ADDR; -+ uint32_t TX_AUTO_COPY_EN; -+ uint32_t SPI_DMA_TX_INFO; -+ /* BLD CRC */ -+ uint32_t BLD_LENGTH_ADDR; -+ uint32_t ILM_LENGTH_ADDR; -+ uint32_t DLM_LENGTH_ADDR; -+ uint32_t BLD_DES_ADDR; -+ uint32_t ILM_DES_ADDR; -+ uint32_t DLM_DES_ADDR; -+ uint32_t G_ILM_CHECKSUM_ADDR; -+ uint32_t G_DLM_CHECKSUM_ADDR; -+ uint32_t R_ILM_CHECKSUM_ADDR; -+ uint32_t R_DLM_CHECKSUM_ADDR; -+ uint32_t BLD_CRC_EN_ADDR; -+ uint32_t DMA_CRC_EN_ADDR; -+ uint32_t BLD_ILM_DLM_CRC_ADDR; -+ uint32_t DMA_CRC_FLAG_ADDR; -+ uint32_t FW_HISTORY_ADDR; -+}; -+ -+struct nvt_ts_hw_info { -+ uint8_t carrier_system; -+ uint8_t hw_crc; -+}; -+ -+static const struct nvt_ts_mem_map NT36523_memory_map = { -+ .EVENT_BUF_ADDR = 0x2FE00, -+ .RAW_PIPE0_ADDR = 0x30FA0, -+ .RAW_PIPE1_ADDR = 0x30FA0, -+ .BASELINE_ADDR = 0x36510, -+ .BASELINE_BTN_ADDR = 0, -+ .DIFF_PIPE0_ADDR = 0x373E8, -+ .DIFF_PIPE1_ADDR = 0x38068, -+ .RAW_BTN_PIPE0_ADDR = 0, -+ .RAW_BTN_PIPE1_ADDR = 0, -+ .DIFF_BTN_PIPE0_ADDR = 0, -+ .DIFF_BTN_PIPE1_ADDR = 0, -+ .PEN_2D_BL_TIP_X_ADDR = 0x2988A, -+ .PEN_2D_BL_TIP_Y_ADDR = 0x29A1A, -+ .PEN_2D_BL_RING_X_ADDR = 0x29BAA, -+ .PEN_2D_BL_RING_Y_ADDR = 0x29D3A, -+ .PEN_2D_DIFF_TIP_X_ADDR = 0x29ECA, -+ .PEN_2D_DIFF_TIP_Y_ADDR = 0x2A05A, -+ .PEN_2D_DIFF_RING_X_ADDR = 0x2A1EA, -+ .PEN_2D_DIFF_RING_Y_ADDR = 0x2A37A, -+ .PEN_2D_RAW_TIP_X_ADDR = 0x2A50A, -+ .PEN_2D_RAW_TIP_Y_ADDR = 0x2A69A, -+ .PEN_2D_RAW_RING_X_ADDR = 0x2A82A, -+ .PEN_2D_RAW_RING_Y_ADDR = 0x2A9BA, -+ .PEN_1D_DIFF_TIP_X_ADDR = 0x2AB4A, -+ .PEN_1D_DIFF_TIP_Y_ADDR = 0x2ABAE, -+ .PEN_1D_DIFF_RING_X_ADDR = 0x2AC12, -+ .PEN_1D_DIFF_RING_Y_ADDR = 0x2AC76, -+ .READ_FLASH_CHECKSUM_ADDR = 0x24000, -+ .RW_FLASH_DATA_ADDR = 0x24002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x3F10D, -+ .TX_AUTO_COPY_EN = 0x3F7E8, -+ .SPI_DMA_TX_INFO = 0x3F7F1, -+ /* BLD CRC */ -+ .BLD_LENGTH_ADDR = 0x3F138, //0x3F138 ~ 0x3F13A (3 bytes) -+ .ILM_LENGTH_ADDR = 0x3F118, //0x3F118 ~ 0x3F11A (3 bytes) -+ .DLM_LENGTH_ADDR = 0x3F130, //0x3F130 ~ 0x3F132 (3 bytes) -+ .BLD_DES_ADDR = 0x3F114, //0x3F114 ~ 0x3F116 (3 bytes) -+ .ILM_DES_ADDR = 0x3F128, //0x3F128 ~ 0x3F12A (3 bytes) -+ .DLM_DES_ADDR = 0x3F12C, //0x3F12C ~ 0x3F12E (3 bytes) -+ .G_ILM_CHECKSUM_ADDR = 0x3F100, //0x3F100 ~ 0x3F103 (4 bytes) -+ .G_DLM_CHECKSUM_ADDR = 0x3F104, //0x3F104 ~ 0x3F107 (4 bytes) -+ .R_ILM_CHECKSUM_ADDR = 0x3F120, //0x3F120 ~ 0x3F123 (4 bytes) -+ .R_DLM_CHECKSUM_ADDR = 0x3F124, //0x3F124 ~ 0x3F127 (4 bytes) -+ .BLD_CRC_EN_ADDR = 0x3F30E, -+ .DMA_CRC_EN_ADDR = 0x3F136, -+ .BLD_ILM_DLM_CRC_ADDR = 0x3F133, -+ .DMA_CRC_FLAG_ADDR = 0x3F134, -+ .FW_HISTORY_ADDR = 0x38D54, -+}; -+ -+static const struct nvt_ts_mem_map NT36526_memory_map = { -+ .EVENT_BUF_ADDR = 0x22D00, -+ .RAW_PIPE0_ADDR = 0x24000, -+ .RAW_PIPE1_ADDR = 0x24000, -+ .BASELINE_ADDR = 0x21758, -+ .BASELINE_BTN_ADDR = 0, -+ .DIFF_PIPE0_ADDR = 0x20AB0, -+ .DIFF_PIPE1_ADDR = 0x24AB0, -+ .RAW_BTN_PIPE0_ADDR = 0, -+ .RAW_BTN_PIPE1_ADDR = 0, -+ .DIFF_BTN_PIPE0_ADDR = 0, -+ .DIFF_BTN_PIPE1_ADDR = 0, -+ .READ_FLASH_CHECKSUM_ADDR = 0x24000, -+ .RW_FLASH_DATA_ADDR = 0x24002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x3F10D, -+ /* BLD CRC */ -+ .BLD_LENGTH_ADDR = 0x3F138, //0x3F138 ~ 0x3F13A (3 bytes) -+ .ILM_LENGTH_ADDR = 0x3F118, //0x3F118 ~ 0x3F11A (3 bytes) -+ .DLM_LENGTH_ADDR = 0x3F130, //0x3F130 ~ 0x3F132 (3 bytes) -+ .BLD_DES_ADDR = 0x3F114, //0x3F114 ~ 0x3F116 (3 bytes) -+ .ILM_DES_ADDR = 0x3F128, //0x3F128 ~ 0x3F12A (3 bytes) -+ .DLM_DES_ADDR = 0x3F12C, //0x3F12C ~ 0x3F12E (3 bytes) -+ .G_ILM_CHECKSUM_ADDR = 0x3F100, //0x3F100 ~ 0x3F103 (4 bytes) -+ .G_DLM_CHECKSUM_ADDR = 0x3F104, //0x3F104 ~ 0x3F107 (4 bytes) -+ .R_ILM_CHECKSUM_ADDR = 0x3F120, //0x3F120 ~ 0x3F123 (4 bytes) -+ .R_DLM_CHECKSUM_ADDR = 0x3F124, //0x3F124 ~ 0x3F127 (4 bytes) -+ .BLD_CRC_EN_ADDR = 0x3F30E, -+ .DMA_CRC_EN_ADDR = 0x3F136, -+ .BLD_ILM_DLM_CRC_ADDR = 0x3F133, -+ .DMA_CRC_FLAG_ADDR = 0x3F134, -+}; -+ -+ -+static const struct nvt_ts_mem_map NT36675_memory_map = { -+ .EVENT_BUF_ADDR = 0x22D00, -+ .RAW_PIPE0_ADDR = 0x24000, -+ .RAW_PIPE1_ADDR = 0x24000, -+ .BASELINE_ADDR = 0x21B90, -+ .BASELINE_BTN_ADDR = 0, -+ .DIFF_PIPE0_ADDR = 0x20C60, -+ .DIFF_PIPE1_ADDR = 0x24C60, -+ .RAW_BTN_PIPE0_ADDR = 0, -+ .RAW_BTN_PIPE1_ADDR = 0, -+ .DIFF_BTN_PIPE0_ADDR = 0, -+ .DIFF_BTN_PIPE1_ADDR = 0, -+ .READ_FLASH_CHECKSUM_ADDR = 0x24000, -+ .RW_FLASH_DATA_ADDR = 0x24002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x3F10D, -+ /* BLD CRC */ -+ .BLD_LENGTH_ADDR = 0x3F138, //0x3F138 ~ 0x3F13A (3 bytes) -+ .ILM_LENGTH_ADDR = 0x3F118, //0x3F118 ~ 0x3F11A (3 bytes) -+ .DLM_LENGTH_ADDR = 0x3F130, //0x3F130 ~ 0x3F132 (3 bytes) -+ .BLD_DES_ADDR = 0x3F114, //0x3F114 ~ 0x3F116 (3 bytes) -+ .ILM_DES_ADDR = 0x3F128, //0x3F128 ~ 0x3F12A (3 bytes) -+ .DLM_DES_ADDR = 0x3F12C, //0x3F12C ~ 0x3F12E (3 bytes) -+ .G_ILM_CHECKSUM_ADDR = 0x3F100, //0x3F100 ~ 0x3F103 (4 bytes) -+ .G_DLM_CHECKSUM_ADDR = 0x3F104, //0x3F104 ~ 0x3F107 (4 bytes) -+ .R_ILM_CHECKSUM_ADDR = 0x3F120, //0x3F120 ~ 0x3F123 (4 bytes) -+ .R_DLM_CHECKSUM_ADDR = 0x3F124, //0x3F124 ~ 0x3F127 (4 bytes) -+ .BLD_CRC_EN_ADDR = 0x3F30E, -+ .DMA_CRC_EN_ADDR = 0x3F136, -+ .BLD_ILM_DLM_CRC_ADDR = 0x3F133, -+ .DMA_CRC_FLAG_ADDR = 0x3F134, -+}; -+ -+ -+static const struct nvt_ts_mem_map NT36672A_memory_map = { -+ .EVENT_BUF_ADDR = 0x21C00, -+ .RAW_PIPE0_ADDR = 0x20000, -+ .RAW_PIPE1_ADDR = 0x23000, -+ .BASELINE_ADDR = 0x20BFC, -+ .BASELINE_BTN_ADDR = 0x23BFC, -+ .DIFF_PIPE0_ADDR = 0x206DC, -+ .DIFF_PIPE1_ADDR = 0x236DC, -+ .RAW_BTN_PIPE0_ADDR = 0x20510, -+ .RAW_BTN_PIPE1_ADDR = 0x23510, -+ .DIFF_BTN_PIPE0_ADDR = 0x20BF0, -+ .DIFF_BTN_PIPE1_ADDR = 0x23BF0, -+ .READ_FLASH_CHECKSUM_ADDR = 0x24000, -+ .RW_FLASH_DATA_ADDR = 0x24002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x3F10D, -+ /* BLD CRC */ -+ .BLD_LENGTH_ADDR = 0x3F10E, //0x3F10E ~ 0x3F10F (2 bytes) -+ .ILM_LENGTH_ADDR = 0x3F118, //0x3F118 ~ 0x3F119 (2 bytes) -+ .DLM_LENGTH_ADDR = 0x3F130, //0x3F130 ~ 0x3F131 (2 bytes) -+ .BLD_DES_ADDR = 0x3F114, //0x3F114 ~ 0x3F116 (3 bytes) -+ .ILM_DES_ADDR = 0x3F128, //0x3F128 ~ 0x3F12A (3 bytes) -+ .DLM_DES_ADDR = 0x3F12C, //0x3F12C ~ 0x3F12E (3 bytes) -+ .G_ILM_CHECKSUM_ADDR = 0x3F100, //0x3F100 ~ 0x3F103 (4 bytes) -+ .G_DLM_CHECKSUM_ADDR = 0x3F104, //0x3F104 ~ 0x3F107 (4 bytes) -+ .R_ILM_CHECKSUM_ADDR = 0x3F120, //0x3F120 ~ 0x3F123 (4 bytes) -+ .R_DLM_CHECKSUM_ADDR = 0x3F124, //0x3F124 ~ 0x3F127 (4 bytes) -+ .BLD_CRC_EN_ADDR = 0x3F30E, -+ .DMA_CRC_EN_ADDR = 0x3F132, -+ .BLD_ILM_DLM_CRC_ADDR = 0x3F133, -+ .DMA_CRC_FLAG_ADDR = 0x3F134, -+}; -+ -+static const struct nvt_ts_mem_map NT36772_memory_map = { -+ .EVENT_BUF_ADDR = 0x11E00, -+ .RAW_PIPE0_ADDR = 0x10000, -+ .RAW_PIPE1_ADDR = 0x12000, -+ .BASELINE_ADDR = 0x10E70, -+ .BASELINE_BTN_ADDR = 0x12E70, -+ .DIFF_PIPE0_ADDR = 0x10830, -+ .DIFF_PIPE1_ADDR = 0x12830, -+ .RAW_BTN_PIPE0_ADDR = 0x10E60, -+ .RAW_BTN_PIPE1_ADDR = 0x12E60, -+ .DIFF_BTN_PIPE0_ADDR = 0x10E68, -+ .DIFF_BTN_PIPE1_ADDR = 0x12E68, -+ .READ_FLASH_CHECKSUM_ADDR = 0x14000, -+ .RW_FLASH_DATA_ADDR = 0x14002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x1F141, -+ .POR_CD_ADDR = 0x1F61C, -+ /* BLD CRC */ -+ .R_ILM_CHECKSUM_ADDR = 0x1BF00, -+}; -+ -+static const struct nvt_ts_mem_map NT36525_memory_map = { -+ .EVENT_BUF_ADDR = 0x11A00, -+ .RAW_PIPE0_ADDR = 0x10000, -+ .RAW_PIPE1_ADDR = 0x12000, -+ .BASELINE_ADDR = 0x10B08, -+ .BASELINE_BTN_ADDR = 0x12B08, -+ .DIFF_PIPE0_ADDR = 0x1064C, -+ .DIFF_PIPE1_ADDR = 0x1264C, -+ .RAW_BTN_PIPE0_ADDR = 0x10634, -+ .RAW_BTN_PIPE1_ADDR = 0x12634, -+ .DIFF_BTN_PIPE0_ADDR = 0x10AFC, -+ .DIFF_BTN_PIPE1_ADDR = 0x12AFC, -+ .READ_FLASH_CHECKSUM_ADDR = 0x14000, -+ .RW_FLASH_DATA_ADDR = 0x14002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x1F141, -+ .POR_CD_ADDR = 0x1F61C, -+ /* BLD CRC */ -+ .R_ILM_CHECKSUM_ADDR = 0x1BF00, -+}; -+ -+static const struct nvt_ts_mem_map NT36676F_memory_map = { -+ .EVENT_BUF_ADDR = 0x11A00, -+ .RAW_PIPE0_ADDR = 0x10000, -+ .RAW_PIPE1_ADDR = 0x12000, -+ .BASELINE_ADDR = 0x10B08, -+ .BASELINE_BTN_ADDR = 0x12B08, -+ .DIFF_PIPE0_ADDR = 0x1064C, -+ .DIFF_PIPE1_ADDR = 0x1264C, -+ .RAW_BTN_PIPE0_ADDR = 0x10634, -+ .RAW_BTN_PIPE1_ADDR = 0x12634, -+ .DIFF_BTN_PIPE0_ADDR = 0x10AFC, -+ .DIFF_BTN_PIPE1_ADDR = 0x12AFC, -+ .READ_FLASH_CHECKSUM_ADDR = 0x14000, -+ .RW_FLASH_DATA_ADDR = 0x14002, -+}; -+ -+static struct nvt_ts_hw_info NT36523_hw_info = { -+ .carrier_system = 2, -+ .hw_crc = 2, -+}; -+ -+static struct nvt_ts_hw_info NT36526_hw_info = { -+ .carrier_system = 2, -+ .hw_crc = 2, -+}; -+ -+static struct nvt_ts_hw_info NT36675_hw_info = { -+ .carrier_system = 2, -+ .hw_crc = 2, -+}; -+ -+static struct nvt_ts_hw_info NT36672A_hw_info = { -+ .carrier_system = 0, -+ .hw_crc = 1, -+}; -+ -+static struct nvt_ts_hw_info NT36772_hw_info = { -+ .carrier_system = 0, -+ .hw_crc = 0, -+}; -+ -+static struct nvt_ts_hw_info NT36525_hw_info = { -+ .carrier_system = 0, -+ .hw_crc = 0, -+}; -+ -+static struct nvt_ts_hw_info NT36676F_hw_info = { -+ .carrier_system = 0, -+ .hw_crc = 0, -+}; -+ -+#define NVT_ID_BYTE_MAX 6 -+struct nvt_ts_trim_id_table { -+ uint8_t id[NVT_ID_BYTE_MAX]; -+ uint8_t mask[NVT_ID_BYTE_MAX]; -+ const struct nvt_ts_mem_map *mmap; -+ const struct nvt_ts_hw_info *hwinfo; -+}; -+ -+static const struct nvt_ts_trim_id_table trim_id_table[] = { -+ {.id = {0x20, 0xFF, 0xFF, 0x23, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36523_memory_map, .hwinfo = &NT36523_hw_info}, -+ {.id = {0x0C, 0xFF, 0xFF, 0x23, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36523_memory_map, .hwinfo = &NT36523_hw_info}, -+ {.id = {0x0B, 0xFF, 0xFF, 0x23, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36523_memory_map, .hwinfo = &NT36523_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x23, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36523_memory_map, .hwinfo = &NT36523_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x23, 0x65, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36523_memory_map, .hwinfo = &NT36523_hw_info}, -+ {.id = {0x0C, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36675_memory_map, .hwinfo = &NT36675_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x26, 0x65, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36526_memory_map, .hwinfo = &NT36526_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x75, 0x66, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36675_memory_map, .hwinfo = &NT36675_hw_info}, -+ {.id = {0x0B, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0B, 0xFF, 0xFF, 0x82, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0B, 0xFF, 0xFF, 0x25, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x72, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x82, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x70, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0B, 0xFF, 0xFF, 0x70, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x72, 0x67, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x55, 0x00, 0xFF, 0x00, 0x00, 0x00}, .mask = {1, 1, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0x55, 0x72, 0xFF, 0x00, 0x00, 0x00}, .mask = {1, 1, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xAA, 0x00, 0xFF, 0x00, 0x00, 0x00}, .mask = {1, 1, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xAA, 0x72, 0xFF, 0x00, 0x00, 0x00}, .mask = {1, 1, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x72, 0x67, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x70, 0x66, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x70, 0x67, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x25, 0x65, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36525_memory_map, .hwinfo = &NT36525_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x76, 0x66, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36676F_memory_map, .hwinfo = &NT36676F_hw_info} -+}; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0012-arm64-dts-qcom-sm8250-xiaomi-elish-enable-wifi-and-b.patch b/patch/kernel/archive/sm8250-6.5/0012-arm64-dts-qcom-sm8250-xiaomi-elish-enable-wifi-and-b.patch deleted file mode 100644 index 72574393e321..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0012-arm64-dts-qcom-sm8250-xiaomi-elish-enable-wifi-and-b.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Mon, 6 Mar 2023 23:13:06 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: enable wifi and bluetooth - -Signed-off-by: Jianhua Lu ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 61 ++++++++++ - 1 file changed, 61 insertions(+) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index b841ea9192ae..f857fa8c1f2a 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -29,6 +29,10 @@ / { - qcom,msm-id = ; /* SM8250 v2.1 */ - qcom,board-id = <0x10008 0>; - -+ aliases { -+ hsuart0 = &uart6; -+ }; -+ - chosen { - #address-cells = <2>; - #size-cells = <2>; -@@ -113,6 +117,25 @@ vreg_s6c_0p88: smpc6-regulator { - vin-supply = <&vph_pwr>; - }; - -+ qca639x: qca639x { -+ compatible = "qcom,qca6390"; -+ #power-domain-cells = <0>; -+ -+ vddaon-supply = <&vreg_s6a_0p95>; -+ vddpmu-supply = <&vreg_s6a_0p95>; -+ vddrfa1-supply = <&vreg_s6a_0p95>; -+ vddrfa2-supply = <&vreg_s8c_1p35>; -+ vddrfa3-supply = <&vreg_s5a_1p9>; -+ vddpcie1-supply = <&vreg_s8c_1p35>; -+ vddpcie2-supply = <&vreg_s5a_1p9>; -+ vddio-supply = <&vreg_s4a_1p8>; -+ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&wlan_en_state>; -+ -+ wlan-en-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; -+ }; -+ - reserved-memory { - xbl_aop_mem: xbl-aop@80700000 { - reg = <0x0 0x80600000 0x0 0x260000>; -@@ -615,6 +638,9 @@ &pcie0_phy { - vdda-phy-supply = <&vreg_l5a_0p88>; - vdda-pll-supply = <&vreg_l9a_1p2>; - status = "okay"; -+ -+ /* Power on QCA639x chip, otherwise PCIe bus timeouts */ -+ power-domains = <&qca639x>; - }; - - &pm8150_gpios { -@@ -655,6 +681,41 @@ &slpi { - - &tlmm { - gpio-reserved-ranges = <40 4>; -+ -+ bt_en_state: bt-default-state { -+ bt-en-pins { -+ pins = "gpio21"; -+ function = "gpio"; -+ -+ drive-strength = <16>; -+ output-low; -+ bias-pull-up; -+ }; -+ }; -+ -+ wlan_en_state: wlan-default-state { -+ wlan-en-pins { -+ pins = "gpio20"; -+ function = "gpio"; -+ -+ drive-strength = <16>; -+ output-low; -+ bias-pull-up; -+ }; -+ }; -+}; -+ -+&uart6 { -+ status = "okay"; -+ -+ bluetooth { -+ compatible = "qcom,qca6390-bt"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&bt_en_state>; -+ -+ power-domains = <&qca639x>; -+ enable-gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; -+ }; - }; - - &usb_1 { --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0013-arm64-dts-qcom-sm8250-xiaomi-elish-enable-touchscree.patch b/patch/kernel/archive/sm8250-6.5/0013-arm64-dts-qcom-sm8250-xiaomi-elish-enable-touchscree.patch deleted file mode 100644 index 3a3e0ddfb59c..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0013-arm64-dts-qcom-sm8250-xiaomi-elish-enable-touchscree.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Mon, 6 Mar 2023 23:23:13 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: enable touchscreen - -Signed-off-by: Jianhua Lu ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-boe.dts | 5 ++ - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 32 ++++++++++ - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-csot.dts | 5 ++ - 3 files changed, 42 insertions(+) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-boe.dts b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-boe.dts -index de6101ddebe7..b8d9e9406440 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-boe.dts -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-boe.dts -@@ -16,3 +16,8 @@ &display_panel { - compatible = "xiaomi,elish-boe-nt36523", "novatek,nt36523"; - status = "okay"; - }; -+ -+&touchscreen { -+ firmware-name = "novatek/nt36523-boe.bin"; -+ status = "okay"; -+}; -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index f857fa8c1f2a..f61a00a86e89 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -662,6 +662,16 @@ &pon_resin { - status = "okay"; - }; - -+&qup_spi4_cs_gpio { -+ drive-strength = <6>; -+ bias-disable; -+}; -+ -+&qup_spi4_data_clk { -+ drive-strength = <6>; -+ bias-disable; -+}; -+ - &qupv3_id_0 { - status = "okay"; - }; -@@ -679,6 +689,28 @@ &slpi { - status = "okay"; - }; - -+&spi4 { -+ status = "okay"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&qup_spi4_data_clk &qup_spi4_cs_gpio>; -+ cs-gpios = <&tlmm 11 GPIO_ACTIVE_LOW>; -+ touchscreen: touchscreen@0 { -+ compatible = "novatek,NVT-ts-spi"; -+ reg = <0>; //Same as CS ID -+ status = "disabled"; -+ -+ spi-max-frequency = <19200000>; //4800000,9600000,15000000,19200000 -+ novatek,irq-gpio = <&tlmm 39 0x2001>; -+ -+ novatek,pen-support; -+ novatek,wgp-stylus; -+ -+ /* 523 */ -+ novatek,swrst-n8-addr = <0x03F0FE>; -+ novatek,spi-rd-fast-addr = <0x03F310>; -+ }; -+}; -+ - &tlmm { - gpio-reserved-ranges = <40 4>; - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-csot.dts b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-csot.dts -index 4cffe9c703df..5953f652e812 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-csot.dts -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-csot.dts -@@ -16,3 +16,8 @@ &display_panel { - compatible = "xiaomi,elish-csot-nt36523", "novatek,nt36523"; - status = "okay"; - }; -+ -+&touchscreen { -+ firmware-name = "novatek/nt36523-csot.bin"; -+ status = "okay"; -+}; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0014-arm64-dts-qcom-sm8250-xiaomi-elish-Disable-slpi.patch b/patch/kernel/archive/sm8250-6.5/0014-arm64-dts-qcom-sm8250-xiaomi-elish-Disable-slpi.patch deleted file mode 100644 index 8e6556503b02..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0014-arm64-dts-qcom-sm8250-xiaomi-elish-Disable-slpi.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Wed, 29 Mar 2023 01:57:43 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: Disable slpi - ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index f61a00a86e89..e3745af861eb 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -686,7 +686,7 @@ &qupv3_id_2 { - - &slpi { - firmware-name = "qcom/sm8250/xiaomi/elish/slpi.mbn"; -- status = "okay"; -+ status = "disabled"; - }; - - &spi4 { --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0015-sound-soc-qcom-sm8250-Add-tdm-support.patch b/patch/kernel/archive/sm8250-6.5/0015-sound-soc-qcom-sm8250-Add-tdm-support.patch deleted file mode 100644 index 01a39cee0b90..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0015-sound-soc-qcom-sm8250-Add-tdm-support.patch +++ /dev/null @@ -1,148 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Fri, 17 Feb 2023 21:31:38 +0800 -Subject: sound: soc: qcom: sm8250: Add tdm support - ---- - sound/soc/qcom/sdw.c | 65 ++++++++++ - sound/soc/qcom/sm8250.c | 17 +++ - 2 files changed, 82 insertions(+) - -diff --git a/sound/soc/qcom/sdw.c b/sound/soc/qcom/sdw.c -index 1a41419c7eb8..5e09fb1e3143 100644 ---- a/sound/soc/qcom/sdw.c -+++ b/sound/soc/qcom/sdw.c -@@ -4,9 +4,12 @@ - - #include - #include -+#include - #include "qdsp6/q6afe.h" - #include "sdw.h" - -+static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28}; -+ - int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream, - struct sdw_stream_runtime *sruntime, - bool *stream_prepared) -@@ -58,6 +61,64 @@ int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream, - } - EXPORT_SYMBOL_GPL(qcom_snd_sdw_prepare); - -+static int qcom_tdm_snd_hw_params(struct snd_pcm_substream *substream, -+ struct snd_pcm_hw_params *params) -+{ -+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); -+ struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); -+ -+ int ret = 0; -+ int channels, slot_width; -+ -+ switch (params_format(params)) { -+ case SNDRV_PCM_FORMAT_S16_LE: -+ slot_width = 32; -+ break; -+ default: -+ dev_err(rtd->dev, "%s: invalid param format 0x%x\n", -+ __func__, params_format(params)); -+ return -EINVAL; -+ } -+ -+ channels = params_channels(params); -+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { -+ ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 0x03, -+ 8, slot_width); -+ if (ret < 0) { -+ dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n", -+ __func__, ret); -+ goto end; -+ } -+ -+ ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, -+ channels, tdm_slot_offset); -+ if (ret < 0) { -+ dev_err(rtd->dev, "%s: failed to set channel map, err:%d\n", -+ __func__, ret); -+ goto end; -+ } -+ } else { -+ ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xf, 0, -+ 8, slot_width); -+ if (ret < 0) { -+ dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n", -+ __func__, ret); -+ goto end; -+ } -+ -+ ret = snd_soc_dai_set_channel_map(cpu_dai, channels, -+ tdm_slot_offset, 0, NULL); -+ if (ret < 0) { -+ dev_err(rtd->dev, "%s: failed to set channel map, err:%d\n", -+ __func__, ret); -+ goto end; -+ } -+ } -+ -+end: -+ return ret; -+} -+ - int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct sdw_stream_runtime **psruntime) -@@ -82,6 +143,10 @@ int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, - *psruntime = sruntime; - } - break; -+ case TERTIARY_TDM_RX_0: -+ case TERTIARY_TDM_TX_0: -+ qcom_tdm_snd_hw_params(substream, params); -+ break; - } - - return 0; -diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c -index 9626a9ef78c2..abeab190337a 100644 ---- a/sound/soc/qcom/sm8250.c -+++ b/sound/soc/qcom/sm8250.c -@@ -16,6 +16,7 @@ - - #define DRIVER_NAME "sm8250" - #define MI2S_BCLK_RATE 1536000 -+#define TDM_BCLK_RATE 12288000 - - struct sm8250_snd_data { - bool stream_prepared[AFE_PORT_MAX]; -@@ -53,6 +54,7 @@ static int sm8250_snd_startup(struct snd_pcm_substream *substream) - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); - struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); -+ int ret,j; - - switch (cpu_dai->id) { - case TERTIARY_MI2S_RX: -@@ -63,6 +65,21 @@ static int sm8250_snd_startup(struct snd_pcm_substream *substream) - snd_soc_dai_set_fmt(cpu_dai, fmt); - snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt); - break; -+ case TERTIARY_TDM_RX_0: -+ codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_DSP_A; -+ snd_soc_dai_set_sysclk(cpu_dai, -+ Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT, -+ TDM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); -+ -+ for_each_rtd_codec_dais(rtd, j, codec_dai) { -+ ret = snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt); -+ snd_soc_dai_set_sysclk(codec_dai, 0, TDM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); -+ if (ret < 0) { -+ dev_err(rtd->dev, "TDM fmt err:%d\n", ret); -+ return ret; -+ } -+ } -+ break; - default: - break; - } --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0018-arm64-dts-qcom-sm8250-xiaomi-elish-Add-xiaomi-keyboa.patch b/patch/kernel/archive/sm8250-6.5/0018-arm64-dts-qcom-sm8250-xiaomi-elish-Add-xiaomi-keyboa.patch deleted file mode 100644 index 85b000333bd9..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0018-arm64-dts-qcom-sm8250-xiaomi-elish-Add-xiaomi-keyboa.patch +++ /dev/null @@ -1,100 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Xin Xu -Date: Tue, 22 Aug 2023 00:04:45 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: Add xiaomi-keyboard support - ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 56 ++++++++++ - 1 file changed, 56 insertions(+) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index 38166e05127f..d276fb5f0b5b 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -178,6 +178,14 @@ ramoops@b0000000 { - no-map; - }; - }; -+ -+ extcon_usb: extcon-usb { -+ compatible = "linux,extcon-usb-gpio"; -+ id-gpio = <&tlmm 91 GPIO_ACTIVE_HIGH>; -+ vbus-gpio = <&pm8150_gpios 10 GPIO_ACTIVE_HIGH>; -+ pinctrl-0 = <&keyboard_active &usb_2_vbus_det_n>; -+ pinctrl-names = "default"; -+ }; - }; - - &adsp { -@@ -792,6 +800,14 @@ &pcie0_phy { - }; - - &pm8150_gpios { -+ usb_2_vbus_det_n: usb-2-vbus-det-state { -+ pins = "gpio10"; -+ function = "normal"; -+ power-source = <1>; -+ input-enable; -+ bias-pull-down; -+ }; -+ - vol_up_n: vol-up-n-state { - pins = "gpio6"; - function = "normal"; -@@ -967,6 +983,23 @@ dout-pins { - bias-disable; - }; - }; -+ -+ keyboard_active: keyboard-active-state { -+ active-pins { -+ pins = "gpio155"; -+ function = "gpio"; -+ drive-strength = <8>; -+ bias-pull-up; -+ }; -+ -+ vdd-pins { -+ pins = "gpio127"; -+ function = "gpio"; -+ drive-strength = <8>; -+ bias-disable; -+ output-high; -+ }; -+ }; - }; - - &uart6 { -@@ -1003,6 +1036,29 @@ &usb_1_hsphy { - status = "okay"; - }; - -+&usb_2 { -+ status = "okay"; -+}; -+ -+&usb_2_dwc3 { -+ dr_mode = "host"; -+ maximum-speed = "super-speed"; -+ extcon = <&extcon_usb>; -+}; -+ -+&usb_2_hsphy { -+ vdda-pll-supply = <&vreg_l5a_0p88>; -+ vdda18-supply = <&vreg_l12a_1p8>; -+ vdda33-supply = <&vreg_l2a_3p1>; -+ status = "okay"; -+}; -+ -+&usb_2_qmpphy { -+ vdda-phy-supply = <&vreg_l9a_1p2>; -+ vdda-pll-supply = <&vreg_l18a_0p9>; -+ status = "okay"; -+}; -+ - &ufs_mem_hc { - vcc-supply = <&vreg_l17a_3p0>; - vcc-max-microamp = <800000>; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0019-drm-panel-nt36523-Fix-for-kernel-6.5.patch b/patch/kernel/archive/sm8250-6.5/0019-drm-panel-nt36523-Fix-for-kernel-6.5.patch deleted file mode 100644 index 4bd42bd12d8c..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0019-drm-panel-nt36523-Fix-for-kernel-6.5.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:28:48 +0800 -Subject: drm/panel: nt36523: Fix for kernel 6.5 - ---- - drivers/gpu/drm/panel/panel-novatek-nt36523.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36523.c b/drivers/gpu/drm/panel/panel-novatek-nt36523.c -index c3befa7f253d..3ac5ae7f97b3 100644 ---- a/drivers/gpu/drm/panel/panel-novatek-nt36523.c -+++ b/drivers/gpu/drm/panel/panel-novatek-nt36523.c -@@ -1274,6 +1274,7 @@ static int nt36523_probe(struct mipi_dsi_device *dsi) - - pinfo->dsi[0] = dsi; - mipi_dsi_set_drvdata(dsi, pinfo); -+ pinfo->panel.prepare_prev_first = true; - drm_panel_init(&pinfo->panel, dev, &nt36523_panel_funcs, DRM_MODE_CONNECTOR_DSI); - - ret = of_drm_get_panel_orientation(dev->of_node, &pinfo->orientation); --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0020-drivers-input-misc-add-xiaomi-keyboard-vendor-driver.patch b/patch/kernel/archive/sm8250-6.5/0020-drivers-input-misc-add-xiaomi-keyboard-vendor-driver.patch deleted file mode 100644 index 9bc77a42e383..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0020-drivers-input-misc-add-xiaomi-keyboard-vendor-driver.patch +++ /dev/null @@ -1,723 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:29:58 +0800 -Subject: drivers/input/misc: add xiaomi keyboard vendor driver - ---- - drivers/input/misc/Kconfig | 1 + - drivers/input/misc/Makefile | 1 + - drivers/input/misc/xiaomi_keyboard/Kconfig | 8 + - drivers/input/misc/xiaomi_keyboard/Makefile | 1 + - drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.c | 608 ++++++++++ - drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.h | 45 + - 6 files changed, 664 insertions(+) - -diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig -index 8a320e6218e3..9cff88458f38 100644 ---- a/drivers/input/misc/Kconfig -+++ b/drivers/input/misc/Kconfig -@@ -939,4 +939,5 @@ config INPUT_STPMIC1_ONKEY - To compile this driver as a module, choose M here: the - module will be called stpmic1_onkey. - -+source "drivers/input/misc/xiaomi_keyboard/Kconfig" - endif -diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile -index 04296a4abe8e..83773d457387 100644 ---- a/drivers/input/misc/Makefile -+++ b/drivers/input/misc/Makefile -@@ -90,3 +90,4 @@ obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o - obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o - obj-$(CONFIG_INPUT_YEALINK) += yealink.o - obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR) += ideapad_slidebar.o -+obj-$(CONFIG_XIAOMI_KEYBOARD) += xiaomi_keyboard/ -diff --git a/drivers/input/misc/xiaomi_keyboard/Kconfig b/drivers/input/misc/xiaomi_keyboard/Kconfig -new file mode 100644 -index 000000000000..bfc4b1d891e5 ---- /dev/null -+++ b/drivers/input/misc/xiaomi_keyboard/Kconfig -@@ -0,0 +1,8 @@ -+config XIAOMI_KEYBOARD -+ bool "xiaomi keyboard control-driver" -+ depends on INPUT -+ default n -+ help -+ Say Y here, compile xiaomi keyboard control driver. -+ -+ If unsure, say N. -diff --git a/drivers/input/misc/xiaomi_keyboard/Makefile b/drivers/input/misc/xiaomi_keyboard/Makefile -new file mode 100644 -index 000000000000..0a00118c658e ---- /dev/null -+++ b/drivers/input/misc/xiaomi_keyboard/Makefile -@@ -0,0 +1 @@ -+obj-$(CONFIG_XIAOMI_KEYBOARD) += xiaomi_keyboard.o -\ No newline at end of file -diff --git a/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.c b/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.c -new file mode 100644 -index 000000000000..a7a736f3c1e8 ---- /dev/null -+++ b/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.c -@@ -0,0 +1,608 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include "xiaomi_keyboard.h" -+#include -+#include -+ -+static struct xiaomi_keyboard_data *mdata; -+ -+static void set_keyboard_status(bool on); -+ -+static void xiaomi_keyboard_reset(void) -+{ -+ if (!mdata || !mdata->pdata) { -+ MI_KB_ERR("reset failed!Invalid Memory\n"); -+ return; -+ } -+ MI_KB_INFO("xiaomi keyboard IC Reset\n"); -+ gpio_direction_output(mdata->pdata->rst_gpio, 0); -+ msleep(2); -+ gpio_direction_output(mdata->pdata->rst_gpio, 1); -+} -+ -+static void xiaomi_keyboard_connected_notify(struct device *dev) -+{ -+ sysfs_notify(&dev->kobj, NULL, "xiaomi_keyboard_conn_status"); -+ MI_KB_INFO("connected status notify\n"); -+} -+ -+static ssize_t xiaomi_keyboard_conn_status_show (struct device *dev, struct device_attribute *attr, char *buf) -+{ -+ int ret = 0, value = 1; -+ MI_KB_INFO("%s enter\n", __func__); -+ if (!mdata) { -+ MI_KB_ERR("Invalid driver info\n"); -+ return ret; -+ } -+ -+ mutex_lock(&mdata->rw_mutex); -+ value = mdata->keyboard_conn_status; -+ mutex_unlock(&mdata->rw_mutex); -+ -+ return scnprintf(buf, PAGE_SIZE, "%d", value); -+} -+ -+static ssize_t xiaomi_keyboard_conn_status_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) -+{ -+ char *cmd; -+ cmd = kzalloc(count + 1, GFP_KERNEL); -+ -+ if (!cmd) { -+ MI_KB_ERR("Allocate Meomory Failed\n"); -+ goto out; -+ } -+ memcpy(cmd, buf, count); -+ -+ if (!mdata) -+ goto out; -+ -+ if (!strncmp(cmd, "reset", 5)) { -+ xiaomi_keyboard_reset(); -+ } else if (!strncmp(cmd, "enable_keyboard", 15)) { -+ MI_KB_INFO("enable keyboard\n"); -+ set_keyboard_status(1); -+ } else if (!strncmp(cmd, "disable_keyboard", 16)) { -+ MI_KB_INFO("disable keyboard\n"); -+ set_keyboard_status(0); -+ } -+ else -+ MI_KB_ERR("Undefined CMD: %s\n", cmd); -+out: -+ if (cmd) -+ kfree(cmd); -+ return count; -+} -+ -+DEVICE_ATTR(xiaomi_keyboard_conn_status, (S_IRUGO | S_IWUSR | S_IWGRP), xiaomi_keyboard_conn_status_show, xiaomi_keyboard_conn_status_store); -+ -+static irqreturn_t xiaomi_keyboard_irq_func(int irq, void *data) -+{ -+ int value = 0; -+ MI_KB_INFO("keyboard event: wakeup system\n"); -+ pm_wakeup_event(&mdata->pdev->dev, 500); -+ value = gpio_get_value_cansleep(mdata->pdata->in_irq_gpio); -+ -+ mutex_lock(&mdata->rw_mutex); -+ mdata->keyboard_conn_status = !mdata->keyboard_conn_status; -+ mutex_unlock(&mdata->rw_mutex); -+ -+ xiaomi_keyboard_connected_notify(&mdata->pdev->dev); -+ MI_KB_INFO("keyboard connected status: %d", mdata->keyboard_conn_status); -+ return IRQ_HANDLED; -+} -+ -+static int xiaomi_keyboard_gpio_config(struct xiaomi_keyboard_platdata *pdata) -+{ -+ int ret = 0; -+ if (gpio_is_valid(pdata->rst_gpio)) { -+ ret = gpio_request_one(pdata->rst_gpio, GPIOF_OUT_INIT_LOW, "kb_rst"); -+ if (ret) { -+ MI_KB_ERR("Failed to request xiaomi keyboard rst gpio\n"); -+ goto err_request_rst_gpio; -+ } -+ } -+ -+ if (gpio_is_valid(pdata->in_irq_gpio)) { -+ ret = gpio_request_one(pdata->in_irq_gpio, GPIOF_IN, "kb_in_irq"); -+ if (ret) { -+ MI_KB_ERR("Failed to request xiaomi keyboard in-irq gpio\n"); -+ goto err_request_in_irq_gpio; -+ } -+ } -+ -+ return ret; -+err_request_in_irq_gpio: -+ gpio_free(pdata->rst_gpio); -+err_request_rst_gpio: -+ return ret; -+} -+ -+static void xiaomi_keyboard_gpio_deconfig(struct xiaomi_keyboard_platdata *pdata) -+{ -+ if (gpio_is_valid(pdata->rst_gpio)) -+ gpio_free(pdata->rst_gpio); -+ -+ if (gpio_is_valid(pdata->in_irq_gpio)) -+ gpio_free(pdata->in_irq_gpio); -+} -+ -+static int xiaomi_keyboard_setup_gpio(struct xiaomi_keyboard_platdata *pdata) -+{ -+ int ret = 0; -+ if (!pdata) { -+ MI_KB_ERR("xiaomi keyboard platdata is NULL\n"); -+ return -EINVAL; -+ } -+ if (gpio_is_valid(pdata->rst_gpio)) -+ gpio_direction_output(pdata->rst_gpio, 1); -+ -+ mdata->irq = gpio_to_irq(pdata->in_irq_gpio); -+ if (mdata->irq) { -+ ret = request_threaded_irq(mdata->irq, NULL, xiaomi_keyboard_irq_func, -+ IRQF_TRIGGER_RISING|IRQF_ONESHOT, "MiKB-IRQ", mdata); -+ if (ret != 0) { -+ MI_KB_ERR("request threaded irq failed\n"); -+ return ret; -+ } -+ } -+ -+ return ret; -+} -+ -+static int xiaomi_keyboard_resetup_gpio(struct xiaomi_keyboard_platdata *pdata) -+{ -+ int ret = 0; -+ -+ if (!mdata || !pdata) { -+ MI_KB_ERR("mdata or pdata not ready, return!"); -+ return -EINVAL; -+ } -+ -+ if (gpio_is_valid(pdata->rst_gpio)) -+ gpio_direction_output(pdata->rst_gpio, 0); -+ -+ free_irq(mdata->irq, mdata); -+ -+ return ret; -+} -+ -+#ifdef CONFIG_OF -+static int xiaomi_keyboard_parse_dt(struct device *dev) -+{ -+ struct device_node *np = dev->of_node; -+ struct xiaomi_keyboard_platdata *pdata; -+ int ret = 0; -+ -+ pdata = mdata->pdata; -+ -+ pdata->rst_gpio = of_get_named_gpio(np, "xiaomi-keyboard,rst-gpio", 0); -+ MI_KB_INFO("xiaomi-kb,reset-gpio=%d\n", pdata->rst_gpio); -+ -+ pdata->in_irq_gpio = of_get_named_gpio(np, "xiaomi-keyboard,in-irq-gpio", 0); -+ MI_KB_INFO("xiaomi-kb,in-irq-gpio=%d\n", pdata->in_irq_gpio); -+ -+ pdata->vdd_gpio = of_get_named_gpio(np, "xiaomi-keyboard,vdd-gpio", 0); -+ MI_KB_INFO("xiaomi-kb,vdd-gpio=%d\n", pdata->vdd_gpio); -+ -+ return ret; -+} -+#else -+static int xiaomi_keyboard_parse_dt(struct device *dev) -+{ -+ MI_KB_ERR("Xiaomi Keyboard dev is not defined\n"); -+ return -EINVAL; -+} -+#endif -+ -+static int xiaomi_keyboard_pinctrl_init(struct device *dev) -+{ -+ int ret = 0; -+ -+ mdata->pinctrl = devm_pinctrl_get(dev); -+ if (IS_ERR_OR_NULL(mdata->pinctrl)) { -+ MI_KB_ERR("Failed to get pinctrl, please check dts\n"); -+ ret = PTR_ERR(mdata->pinctrl); -+ goto err_pinctrl_get; -+ } -+ mdata->pins_active = pinctrl_lookup_state(mdata->pinctrl, "pm_kb_active"); -+ if (IS_ERR_OR_NULL(mdata->pins_active)) { -+ MI_KB_ERR("Pin state [active] not found\n"); -+ ret = PTR_ERR(mdata->pins_active); -+ goto err_pinctrl_lookup; -+ } -+ -+ mdata->pins_suspend = pinctrl_lookup_state(mdata->pinctrl, "pm_kb_suspend"); -+ if (IS_ERR_OR_NULL(mdata->pins_suspend)) { -+ MI_KB_ERR("Pin state [suspend] not found\n"); -+ ret = PTR_ERR(mdata->pins_suspend); -+ goto err_pinctrl_lookup; -+ } -+ -+ return 0; -+err_pinctrl_lookup: -+ if (mdata->pinctrl) { -+ devm_pinctrl_put(mdata->pinctrl); -+ } -+err_pinctrl_get: -+ return ret; -+} -+ -+static int xiaomi_keyboard_power_on(void) -+{ -+ int ret = 0; -+ struct xiaomi_keyboard_platdata *pdata; -+ pdata = mdata->pdata; -+ MI_KB_INFO("Power On\n"); -+ if (gpio_is_valid(pdata->vdd_gpio)) { -+ ret = gpio_request_one(pdata->vdd_gpio, GPIOF_OUT_INIT_HIGH, "kb_vdd_gpio"); -+ if (ret) { -+ MI_KB_ERR("Failed to request xiaomi-keyboard-out-irq gpio\n"); -+ goto err_request_vdd_gpio; -+ } -+ } -+ -+ gpio_direction_output(pdata->vdd_gpio, 1); -+err_request_vdd_gpio: -+ return ret; -+} -+ -+static void xiaomi_keyboard_power_off(void) -+{ -+ struct xiaomi_keyboard_platdata *pdata; -+ pdata = mdata->pdata; -+ MI_KB_INFO("Power Off\n"); -+ if (gpio_is_valid(pdata->vdd_gpio)) { -+ gpio_direction_output(pdata->vdd_gpio, 0); -+ gpio_free(pdata->vdd_gpio); -+ } -+ return; -+} -+ -+static int xiaomi_keyboard_suspend(struct device *dev) -+{ -+ int ret = 0; -+ MI_KB_INFO("enter\n"); -+ if (mdata->pinctrl && mdata->pins_suspend) { -+ ret = (mdata->keyboard_is_enable && mdata->is_usb_exist) -+ ? 0 : pinctrl_select_state(mdata->pinctrl, mdata->pins_suspend); -+ if (ret < 0) { -+ MI_KB_ERR("Set suspend pin state error:%d\n", ret); -+ } -+ } -+ MI_KB_INFO("exit\n"); -+ return ret; -+} -+ -+static int xiaomi_keyboard_resume(struct device *dev) -+{ -+ int ret = 0; -+ MI_KB_INFO("enter\n"); -+ if (!mdata->keyboard_is_enable) { -+ MI_KB_INFO("keyboard_is_enable is false, stop resume.\n"); -+ MI_KB_INFO("exit\n"); -+ return -1; -+ } -+ if (mdata->pinctrl && mdata->pins_active) { -+ ret = pinctrl_select_state(mdata->pinctrl, mdata->pins_active); -+ if (ret < 0) { -+ MI_KB_ERR("Set active pin state error:%d\n", ret); -+ } -+ } -+ MI_KB_INFO("exit\n"); -+ return ret; -+} -+ -+static int xiaomi_keyboard_pm_suspend(struct device *dev) -+{ -+ int ret = 0; -+ MI_KB_INFO("enter\n"); -+ enable_irq_wake(mdata->irq); -+ mdata->dev_pm_suspend = true; -+ return ret; -+} -+ -+static int xiaomi_keyboard_pm_resume(struct device *dev) -+{ -+ int ret = 0; -+ MI_KB_INFO("enter\n"); -+ disable_irq_wake(mdata->irq); -+ mdata->dev_pm_suspend = false; -+ return ret; -+} -+ -+static const struct dev_pm_ops xiaomi_keyboard_pm_ops = { -+ .suspend = xiaomi_keyboard_pm_suspend, -+ .resume = xiaomi_keyboard_pm_resume, -+}; -+ -+static int keyboard_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data) -+{ -+ int blank = *(enum drm_notifier_data *)data; -+ struct xiaomi_keyboard_data *mdata = -+ container_of(self, struct xiaomi_keyboard_data, drm_notif); -+ -+ if (mdata) { -+ flush_workqueue(mdata->event_wq); -+ if (event == MI_DRM_EARLY_EVENT_BLANK) { -+ if (blank == MI_DRM_BLANK_POWERDOWN) { -+ MI_KB_ERR("keyboard suspend"); -+ mdata->is_in_suspend = true; -+ queue_work(mdata->event_wq, &mdata->suspend_work); -+ } -+ } else if (event == MI_DRM_EVENT_BLANK) { -+ if (blank == MI_DRM_BLANK_UNBLANK) { -+ MI_KB_ERR("keyboard resume"); -+ mdata->is_in_suspend = false; -+ flush_workqueue(mdata->event_wq); -+ queue_work(mdata->event_wq, &mdata->resume_work); -+ } -+ } -+ } -+ -+ return 0; -+} -+ -+static void keyboard_resume_work(struct work_struct *work) -+{ -+ struct xiaomi_keyboard_data *mdata = container_of(work, struct xiaomi_keyboard_data, resume_work); -+ xiaomi_keyboard_resume(&mdata->pdev->dev); -+} -+ -+static void keyboard_suspend_work(struct work_struct *work) -+{ -+ struct xiaomi_keyboard_data *mdata = container_of(work, struct xiaomi_keyboard_data, resume_work); -+ xiaomi_keyboard_suspend(&mdata->pdev->dev); -+} -+ -+static int kb_power_supply_event(struct notifier_block *nb, -+ unsigned long event, void *ptr) -+{ -+ struct xiaomi_keyboard_data *mdata = -+ container_of(nb, struct xiaomi_keyboard_data, power_supply_notifier); -+ -+ if (mdata != NULL) -+ queue_work(mdata->event_wq, &mdata->power_supply_work); -+ -+ return 0; -+} -+ -+static void kb_power_supply_work(struct work_struct *work) -+{ -+ struct xiaomi_keyboard_data *mdata = container_of(work, struct xiaomi_keyboard_data, power_supply_work); -+ int is_usb_exist = 0; -+ -+ mutex_lock(&mdata->power_supply_lock); -+ is_usb_exist = !!power_supply_is_system_supplied(); -+ if (is_usb_exist != mdata->is_usb_exist) { -+ mdata->is_usb_exist = is_usb_exist; -+ MI_KB_INFO("power supply is: %d", mdata->is_usb_exist); -+ } -+ mutex_unlock(&mdata->power_supply_lock); -+} -+ -+static void set_keyboard_status(bool on) { -+ int ret = 0; -+ -+ if (!mdata || !(mdata->pdata)) { -+ MI_KB_ERR("mdata or pdata not ready, return!"); -+ return; -+ } -+ -+ if (on && !(mdata->keyboard_is_enable)) { -+ ret = xiaomi_keyboard_power_on(); -+ if (ret) { -+ MI_KB_ERR("Init 3.3V power failed\n"); -+ return; -+ } -+ msleep(1); -+ ret = xiaomi_keyboard_setup_gpio(mdata->pdata); -+ if (ret) { -+ MI_KB_ERR("setup gpio failed\n"); -+ return; -+ } -+ msleep(2); -+ -+ if (!mdata->is_in_suspend) { -+ ret = pinctrl_select_state(mdata->pinctrl, mdata->pins_active); -+ if (ret < 0) { -+ MI_KB_ERR("Set active pin state error:%d\n", ret); -+ } -+ } -+ mdata->keyboard_is_enable = true; -+ -+ } else if (!on && mdata->keyboard_is_enable) { -+ if (!mdata->is_in_suspend) { -+ ret = pinctrl_select_state(mdata->pinctrl, mdata->pins_suspend); -+ if (ret < 0) { -+ MI_KB_ERR("Set suspend pin state error:%d\n", ret); -+ } -+ } -+ -+ ret = xiaomi_keyboard_resetup_gpio(mdata->pdata); -+ if (ret < 0) { -+ MI_KB_ERR("resetup gpio failed\n"); -+ return; -+ } -+ xiaomi_keyboard_power_off(); -+ mdata->keyboard_is_enable = false; -+ } else { -+ MI_KB_INFO("keyboard status do not need change!"); -+ } -+} -+ -+/******************************************************* -+Description: -+ xiami pad keyboard driver probe function. -+ -+return: -+ Executive outcomes. 0---succeed. negative---failed -+*******************************************************/ -+static int xiaomi_keyboard_probe(struct platform_device *pdev) -+{ -+ struct xiaomi_keyboard_platdata *pdata; -+ int ret = 0; -+ MI_KB_INFO("enter\n"); -+ mdata = kzalloc(sizeof(struct xiaomi_keyboard_data), GFP_KERNEL); -+ if (!mdata) { -+ MI_KB_ERR("Alloc Memory for xiaomi_keyboard_data failed\n"); -+ return -ENOMEM; -+ } -+ -+ pdata = devm_kzalloc(&pdev->dev, sizeof(struct xiaomi_keyboard_platdata), GFP_KERNEL); -+ if (!pdata) { -+ MI_KB_ERR("Alloc Memory for xiaomi_keyboard_platdata failed\n"); -+ return -ENOMEM; -+ } -+ -+ mdata->pdev = pdev; -+ mdata->pdata = pdata; -+ mutex_init(&mdata->rw_mutex); -+ mutex_init(&mdata->power_supply_lock); -+ mdata->is_usb_exist = 0; -+ -+ ret = xiaomi_keyboard_parse_dt(&pdev->dev); -+ if (ret) { -+ MI_KB_ERR("parse device tree failed\n"); -+ goto out; -+ } -+ -+ ret = xiaomi_keyboard_pinctrl_init(&pdev->dev); -+ if (ret) { -+ MI_KB_ERR("Pinctrl init failed\n"); -+ goto out; -+ } -+ -+ pdata = mdata->pdata; -+ ret = xiaomi_keyboard_gpio_config(pdata); -+ if (ret) { -+ MI_KB_ERR("set gpio config failed\n"); -+ goto out; -+ } -+ -+ mdata->dev_pm_suspend = false; -+ mdata->keyboard_is_enable = false; -+ mdata->is_in_suspend = false; -+ -+ ret = sysfs_create_file(&mdata->pdev->dev.kobj, &dev_attr_xiaomi_keyboard_conn_status.attr); -+ if (ret < 0) { -+ MI_KB_ERR("Create sysfs attribute xiaomi_keyboard_conn_status Failed\n"); -+ goto err_pinctrl_select; -+ } -+ -+ mdata->event_wq = alloc_workqueue("kb-event-queue", -+ WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE, 1); -+ if (!mdata->event_wq) { -+ MI_KB_ERR("Can not create work thread for suspend/resume!!"); -+ ret = -ENOMEM; -+ goto err_alloc_work_thread_failed; -+ } -+ -+ set_keyboard_status(1); -+ -+ INIT_WORK(&mdata->resume_work, keyboard_resume_work); -+ INIT_WORK(&mdata->suspend_work, keyboard_suspend_work); -+ INIT_WORK(&mdata->power_supply_work, kb_power_supply_work); -+ -+ mdata->drm_notif.notifier_call = keyboard_drm_notifier_callback; -+ ret = mi_drm_register_client(&mdata->drm_notif); -+ if(ret) { -+ MI_KB_ERR("register drm_notifier failed. ret=%d\n", ret); -+ goto err_register_drm_notif_failed; -+ } -+ -+ mdata->power_supply_notifier.notifier_call = kb_power_supply_event; -+ ret = power_supply_reg_notifier(&mdata->power_supply_notifier); -+ if (ret) { -+ MI_KB_ERR("register power_supply_notifier failed. ret=%d\n", ret); -+ goto err_register_power_supply_notif_failed; -+ } -+ -+ MI_KB_INFO("Success\n"); -+ return ret; -+ -+err_register_power_supply_notif_failed: -+err_register_drm_notif_failed: -+ if (mdata->event_wq) { -+ destroy_workqueue(mdata->event_wq); -+ } -+err_alloc_work_thread_failed: -+ sysfs_remove_file(&mdata->pdev->dev.kobj, &dev_attr_xiaomi_keyboard_conn_status.attr); -+err_pinctrl_select: -+ if (mdata->pinctrl) { -+ devm_pinctrl_put(mdata->pinctrl); -+ } -+ xiaomi_keyboard_gpio_deconfig(pdata); -+out: -+ mutex_destroy(&mdata->rw_mutex); -+ mutex_destroy(&mdata->power_supply_lock); -+ if (mdata) { -+ kfree(mdata); -+ mdata = NULL; -+ } -+ MI_KB_ERR("Failed\n"); -+ return ret; -+} -+ -+static int xiaomi_keyboard_remove(struct platform_device *pdev) -+{ -+ MI_KB_INFO("enter\n"); -+ mi_drm_unregister_client(&mdata->drm_notif); -+ destroy_workqueue(mdata->event_wq); -+ xiaomi_keyboard_gpio_deconfig(mdata->pdata); -+ sysfs_remove_file(&mdata->pdev->dev.kobj, &dev_attr_xiaomi_keyboard_conn_status.attr); -+ xiaomi_keyboard_power_off(); -+ devm_pinctrl_put(mdata->pinctrl); -+ xiaomi_keyboard_gpio_deconfig(mdata->pdata); -+ mutex_destroy(&mdata->rw_mutex); -+ mutex_destroy(&mdata->power_supply_lock); -+ if (mdata) { -+ kfree(mdata); -+ mdata = NULL; -+ } -+ return 0; -+} -+ -+#ifdef CONFIG_OF -+static const struct of_device_id xiaomi_keyboard_dt_match[] = { -+ { .compatible = "xiaomi,keyboard" }, -+ {}, -+}; -+MODULE_DEVICE_TABLE(of, xiaomi_keyboard_dt_match); -+#endif -+ -+static const struct platform_device_id xiaomi_keyboard_driver_ids[] = { -+ { -+ .name = "xiaomi-keyboard", -+ .driver_data = 0, -+ }, -+}; -+MODULE_DEVICE_TABLE(platform, xiaomi_keyboard_driver_ids); -+ -+ -+static struct platform_driver xiaomi_keyboard_driver = { -+ .probe = xiaomi_keyboard_probe, -+ .remove = xiaomi_keyboard_remove, -+ .driver = { -+ .name = "xiaomi-keyboard", -+ .of_match_table = of_match_ptr(xiaomi_keyboard_dt_match), -+ .pm = &xiaomi_keyboard_pm_ops, -+ }, -+ .id_table = xiaomi_keyboard_driver_ids, -+}; -+ -+module_platform_driver(xiaomi_keyboard_driver); -+ -+MODULE_DESCRIPTION("Xiaomi Keyboard Control-driver"); -+MODULE_AUTHOR("Tonghui Wang"); -diff --git a/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.h b/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.h -new file mode 100644 -index 000000000000..5c4220077bf8 ---- /dev/null -+++ b/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.h -@@ -0,0 +1,45 @@ -+#ifndef __XIAOMI_KEYBOARD_H -+#define __XIAOMI_KEYBOARD_H -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define XIAOMI_KB_TAG "xiaomi-keyboard" -+#define MI_KB_INFO(fmt, args...) pr_info("[%s] %s %d: " fmt, XIAOMI_KB_TAG, __func__, __LINE__, ##args) -+#define MI_KB_ERR(fmt, args...) pr_err("[%s] %s %d: " fmt, XIAOMI_KB_TAG, __func__, __LINE__, ##args) -+ -+struct xiaomi_keyboard_platdata { -+ u32 rst_gpio; -+ u32 rst_flags; -+ u32 in_irq_gpio; -+ u32 in_irq_flags; -+ u32 vdd_gpio; -+}; -+ -+struct xiaomi_keyboard_data { -+ struct notifier_block drm_notif; -+ struct xiaomi_keyboard_platdata *pdata; -+ bool dev_pm_suspend; -+ int irq; -+ struct platform_device *pdev; -+ struct pinctrl *pinctrl; -+ struct pinctrl_state *pins_active; -+ struct pinctrl_state *pins_suspend; -+ struct workqueue_struct *event_wq; -+ struct work_struct resume_work; -+ struct work_struct suspend_work; -+ int keyboard_conn_status; -+ struct mutex rw_mutex; -+ -+ struct mutex power_supply_lock; -+ struct work_struct power_supply_work; -+ struct notifier_block power_supply_notifier; -+ int is_usb_exist; -+ bool keyboard_is_enable; -+ bool is_in_suspend; -+}; -+#endif --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0021-arm64-dts-qcom-sm8250-xiaomi-elish-use-vendor-keyboa.patch b/patch/kernel/archive/sm8250-6.5/0021-arm64-dts-qcom-sm8250-xiaomi-elish-use-vendor-keyboa.patch deleted file mode 100644 index deca5464069a..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0021-arm64-dts-qcom-sm8250-xiaomi-elish-use-vendor-keyboa.patch +++ /dev/null @@ -1,104 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:31:25 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: use vendor keyboard driver - ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 58 +++++----- - 1 file changed, 31 insertions(+), 27 deletions(-) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index d276fb5f0b5b..115cb9c86458 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -179,12 +179,14 @@ ramoops@b0000000 { - }; - }; - -- extcon_usb: extcon-usb { -- compatible = "linux,extcon-usb-gpio"; -- id-gpio = <&tlmm 91 GPIO_ACTIVE_HIGH>; -- vbus-gpio = <&pm8150_gpios 10 GPIO_ACTIVE_HIGH>; -- pinctrl-0 = <&keyboard_active &usb_2_vbus_det_n>; -- pinctrl-names = "default"; -+ xiaomi_keyboard { -+ compatible = "xiaomi,keyboard"; -+ pinctrl-names = "pm_kb_active", "pm_kb_suspend"; -+ pinctrl-0 = <&xiaomi_keyboard_active>; -+ pinctrl-1 = <&xiaomi_keyboard_suspend>; -+ xiaomi-keyboard,rst-gpio = <&tlmm 141 0x00>; -+ xiaomi-keyboard,in-irq-gpio = <&tlmm 83 0x2001>; -+ xiaomi-keyboard,vdd-gpio = <&tlmm 127 0x00>; - }; - }; - -@@ -800,14 +802,6 @@ &pcie0_phy { - }; - - &pm8150_gpios { -- usb_2_vbus_det_n: usb-2-vbus-det-state { -- pins = "gpio10"; -- function = "normal"; -- power-source = <1>; -- input-enable; -- bias-pull-down; -- }; -- - vol_up_n: vol-up-n-state { - pins = "gpio6"; - function = "normal"; -@@ -984,20 +978,31 @@ dout-pins { - }; - }; - -- keyboard_active: keyboard-active-state { -- active-pins { -- pins = "gpio155"; -- function = "gpio"; -- drive-strength = <8>; -- bias-pull-up; -+ xiaomi_keyboard_mcu { -+ xiaomi_keyboard_suspend: xiaomi_keyboard_suspend { -+ mux { -+ pins = "gpio155"; -+ function = "gpio"; -+ }; -+ -+ config { -+ pins = "gpio155"; -+ drive-strength = <8>; -+ bias-pull-down; -+ }; - }; - -- vdd-pins { -- pins = "gpio127"; -- function = "gpio"; -- drive-strength = <8>; -- bias-disable; -- output-high; -+ xiaomi_keyboard_active: xiaomi_keyboard_active { -+ mux { -+ pins = "gpio155"; -+ function = "gpio"; -+ }; -+ -+ config { -+ pins = "gpio155"; -+ drive-strength = <8>; -+ bias-pull-up; -+ }; - }; - }; - }; -@@ -1043,7 +1048,6 @@ &usb_2 { - &usb_2_dwc3 { - dr_mode = "host"; - maximum-speed = "super-speed"; -- extcon = <&extcon_usb>; - }; - - &usb_2_hsphy { --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0022-drivers-spmi-spmi-pmic-arb.c-remove-warnings.patch b/patch/kernel/archive/sm8250-6.5/0022-drivers-spmi-spmi-pmic-arb.c-remove-warnings.patch deleted file mode 100644 index 25f3798fec15..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0022-drivers-spmi-spmi-pmic-arb.c-remove-warnings.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:32:19 +0800 -Subject: drivers/spmi/spmi-pmic-arb.c: remove warnings - ---- - drivers/spmi/spmi-pmic-arb.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c -index dcb675d980d4..2688ac2a7e55 100644 ---- a/drivers/spmi/spmi-pmic-arb.c -+++ b/drivers/spmi/spmi-pmic-arb.c -@@ -289,7 +289,6 @@ static int pmic_arb_wait_for_done(struct spmi_controller *ctrl, - if (status & PMIC_ARB_STATUS_FAILURE) { - dev_err(&ctrl->dev, "%s: %#x %#x: transaction failed (%#x)\n", - __func__, sid, addr, status); -- WARN_ON(1); - return -EIO; - } - --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0024-Asoc-wm_adsp-Use-xiaomi-elish-firmware-name.patch b/patch/kernel/archive/sm8250-6.5/0024-Asoc-wm_adsp-Use-xiaomi-elish-firmware-name.patch deleted file mode 100644 index 7c332c660f6a..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0024-Asoc-wm_adsp-Use-xiaomi-elish-firmware-name.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Tue, 24 Oct 2023 01:01:46 +0800 -Subject: Asoc: wm_adsp: Use xiaomi-elish firmware name - ---- - sound/soc/codecs/wm_adsp.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c -index c1d8d7786244..dc234dce8ed8 100644 ---- a/sound/soc/codecs/wm_adsp.c -+++ b/sound/soc/codecs/wm_adsp.c -@@ -827,7 +827,7 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp, - } - } else if (asoc_component_prefix) { - if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename, -- cirrus_dir, NULL, -+ cirrus_dir, "xiaomi-elish", - NULL, "wmfw")) { - adsp_dbg(dsp, "Found '%s'\n", *wmfw_filename); - wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.5/0025-input-nt36523-short-the-firmware-download-delay-from.patch b/patch/kernel/archive/sm8250-6.5/0025-input-nt36523-short-the-firmware-download-delay-from.patch deleted file mode 100644 index 4b1d5303f3f7..000000000000 --- a/patch/kernel/archive/sm8250-6.5/0025-input-nt36523-short-the-firmware-download-delay-from.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Thu, 26 Oct 2023 13:13:34 +0800 -Subject: input: nt36523: short the firmware download delay from 14s to 4s - ---- - drivers/input/touchscreen/nt36523/nt36xxx.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/input/touchscreen/nt36523/nt36xxx.c b/drivers/input/touchscreen/nt36523/nt36xxx.c -index 45500ad5cd91..27f93e531290 100644 ---- a/drivers/input/touchscreen/nt36523/nt36xxx.c -+++ b/drivers/input/touchscreen/nt36523/nt36xxx.c -@@ -1452,7 +1452,7 @@ static int32_t nvt_ts_probe(struct spi_device *client) - } - INIT_DELAYED_WORK(&ts->nvt_fwu_work, Boot_Update_Firmware); - // please make sure boot update start after display reset(RESX) sequence -- queue_delayed_work(nvt_fwu_wq, &ts->nvt_fwu_work, msecs_to_jiffies(14000)); -+ queue_delayed_work(nvt_fwu_wq, &ts->nvt_fwu_work, msecs_to_jiffies(4000)); - #endif - - NVT_LOG("NVT_TOUCH_ESD_PROTECT is %d\n", NVT_TOUCH_ESD_PROTECT); --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0001-drm-msm-dpu1-improve-support-for-active-CTLs.patch b/patch/kernel/archive/sm8250-6.6/0001-drm-msm-dpu1-improve-support-for-active-CTLs.patch deleted file mode 100644 index 8701076f42a6..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0001-drm-msm-dpu1-improve-support-for-active-CTLs.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sun, 14 Mar 2021 04:52:34 +0300 -Subject: drm/msm/dpu1: improve support for active CTLs - -- Support setting master interface if several INTFs are to be handled by - a single CTL - -- Support setting handling several MERGE_3D instances using a single - CTL. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 15 ++++++++++ - drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 2 ++ - 2 files changed, 17 insertions(+) - -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c -index 86182c734606..4ecffbcdba20 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c -@@ -510,6 +510,7 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx, - u32 intf_active = 0; - u32 wb_active = 0; - u32 mode_sel = 0; -+ u32 merge_3d_active = 0; - - /* CTL_TOP[31:28] carries group_id to collate CTL paths - * per VM. Explicitly disable it until VM support is -@@ -530,16 +531,30 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx, - if (cfg->wb) - wb_active |= BIT(cfg->wb - WB_0); - -+ merge_3d_active = DPU_REG_READ(c, CTL_MERGE_3D_ACTIVE); -+ if (cfg->merge_3d) -+ merge_3d_active |= BIT(cfg->merge_3d - MERGE_3D_0); -+ - DPU_REG_WRITE(c, CTL_TOP, mode_sel); - DPU_REG_WRITE(c, CTL_INTF_ACTIVE, intf_active); - DPU_REG_WRITE(c, CTL_WB_ACTIVE, wb_active); - -+ if (cfg->intf_master) -+ DPU_REG_WRITE(c, CTL_INTF_MASTER, BIT(cfg->intf_master - INTF_0)); -+ - if (cfg->merge_3d) - DPU_REG_WRITE(c, CTL_MERGE_3D_ACTIVE, - BIT(cfg->merge_3d - MERGE_3D_0)); - - if (cfg->dsc) - DPU_REG_WRITE(c, CTL_DSC_ACTIVE, cfg->dsc); -+ if (cfg->merge_3d) -+ DPU_REG_WRITE(c, CTL_MERGE_3D_ACTIVE, merge_3d_active); -+ -+ if (cfg->intf_master) -+ DPU_DEBUG_DRIVER("ACTIVE: %x %x %lx\n", intf_active, merge_3d_active, BIT(cfg->intf_master - INTF_0)); -+ else -+ DPU_DEBUG_DRIVER("ACTIVE: %x %x\n", intf_active, merge_3d_active); - } - - static void dpu_hw_ctl_intf_cfg(struct dpu_hw_ctl *ctx, -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h -index 1c242298ff2e..36dd4e91a0b4 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h -@@ -36,6 +36,7 @@ struct dpu_hw_stage_cfg { - /** - * struct dpu_hw_intf_cfg :Describes how the DPU writes data to output interface - * @intf : Interface id -+ * @intf_master: Master interface id in the dual pipe topology - * @mode_3d: 3d mux configuration - * @merge_3d: 3d merge block used - * @intf_mode_sel: Interface mode, cmd / vid -@@ -44,6 +45,7 @@ struct dpu_hw_stage_cfg { - */ - struct dpu_hw_intf_cfg { - enum dpu_intf intf; -+ enum dpu_intf intf_master; - enum dpu_wb wb; - enum dpu_3d_blend_mode mode_3d; - enum dpu_merge_3d merge_3d; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0003-drm-msm-dpu1-dpu_encoder_phys_-proper-suppor-for-act.patch b/patch/kernel/archive/sm8250-6.6/0003-drm-msm-dpu1-dpu_encoder_phys_-proper-suppor-for-act.patch deleted file mode 100644 index f77460b200f2..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0003-drm-msm-dpu1-dpu_encoder_phys_-proper-suppor-for-act.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sun, 14 Mar 2021 05:03:35 +0300 -Subject: drm/msm/dpu1: dpu_encoder_phys_*: proper suppor for active CTLs - -Adapt dpu_encoder_phys_* to properly support active CTLs and their -features. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 2 ++ - drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 5 ++++- - 2 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c -index df88358e7037..6d1ac183531e 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c -@@ -57,6 +57,8 @@ static void _dpu_encoder_phys_cmd_update_intf_cfg( - return; - - intf_cfg.intf = phys_enc->hw_intf->idx; -+ if (phys_enc->split_role == ENC_ROLE_MASTER) -+ intf_cfg.intf_master = phys_enc->hw_intf->idx; - intf_cfg.intf_mode_sel = DPU_CTL_MODE_SEL_CMD; - intf_cfg.stream_sel = cmd_enc->stream_sel; - intf_cfg.mode_3d = dpu_encoder_helper_get_3d_blend_mode(phys_enc); -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c -index c2189e58de6a..5d5c7c8088f6 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c -@@ -271,6 +271,8 @@ static void dpu_encoder_phys_vid_setup_timing_engine( - DPU_DEBUG_VIDENC(phys_enc, "fmt_fourcc 0x%X\n", fmt_fourcc); - - intf_cfg.intf = phys_enc->hw_intf->idx; -+ if (phys_enc->split_role == ENC_ROLE_MASTER) -+ intf_cfg.intf_master = phys_enc->hw_intf->idx; - intf_cfg.intf_mode_sel = DPU_CTL_MODE_SEL_VID; - intf_cfg.stream_sel = 0; /* Don't care value for video mode */ - intf_cfg.mode_3d = dpu_encoder_helper_get_3d_blend_mode(phys_enc); -@@ -344,7 +346,8 @@ static void dpu_encoder_phys_vid_underrun_irq(void *arg, int irq_idx) - static bool dpu_encoder_phys_vid_needs_single_flush( - struct dpu_encoder_phys *phys_enc) - { -- return phys_enc->split_role != ENC_ROLE_SOLO; -+ return !(phys_enc->hw_ctl->caps->features & BIT(DPU_CTL_ACTIVE_CFG)) && -+ phys_enc->split_role != ENC_ROLE_SOLO; - } - - static void dpu_encoder_phys_vid_atomic_mode_set( --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0004-dt-bindings-mfd-qcom-qca639x-add-binding-for-QCA639x.patch b/patch/kernel/archive/sm8250-6.6/0004-dt-bindings-mfd-qcom-qca639x-add-binding-for-QCA639x.patch deleted file mode 100644 index 5a17b7e1029c..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0004-dt-bindings-mfd-qcom-qca639x-add-binding-for-QCA639x.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sun, 20 Dec 2020 18:47:57 +0300 -Subject: dt-bindings: mfd: qcom,qca639x: add binding for QCA639x defvice - -Qualcomm QCA639x is a family of WiFi + Bluetooth SoCs, with BT part -being controlled through the UART and WiFi being present on PCIe bus. -Both blocks share common power sources. Add binding to describe power -sequencing required to power up this device. - -Signed-off-by: Dmitry Baryshkov ---- - Documentation/devicetree/bindings/mfd/qcom,qca639x.yaml | 84 ++++++++++ - 1 file changed, 84 insertions(+) - -diff --git a/Documentation/devicetree/bindings/mfd/qcom,qca639x.yaml b/Documentation/devicetree/bindings/mfd/qcom,qca639x.yaml -new file mode 100644 -index 000000000000..d43c75da136f ---- /dev/null -+++ b/Documentation/devicetree/bindings/mfd/qcom,qca639x.yaml -@@ -0,0 +1,84 @@ -+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) -+%YAML 1.2 -+--- -+$id: "http://devicetree.org/schemas/mfd/qcom,qca639x.yaml#" -+$schema: "http://devicetree.org/meta-schemas/core.yaml#" -+ -+title: Qualcomm QCA639x WiFi + Bluetoot SoC bindings -+ -+maintainers: -+ - Andy Gross -+ - Bjorn Andersson -+ -+description: | -+ This binding describes thes Qualcomm QCA6390 or QCA6391 power supplies and -+ enablement pins. -+ -+properties: -+ compatible: -+ const: qcom,qca639x -+ -+ '#power-domain-cells': -+ const: 0 -+ -+ pinctrl-0: true -+ pinctrl-1: true -+ -+ pinctrl-names: -+ items: -+ - const: default -+ - const: active -+ -+ vddaon-supply: -+ description: -+ 0.95V always-on LDO power input -+ -+ vddpmu-supply: -+ description: -+ 0.95V LDO power input to PMU -+ -+ vddrfa1-supply: -+ description: -+ 0.95V LDO power input to RFA -+ -+ vddrfa2-supply: -+ description: -+ 1.25V LDO power input to RFA -+ -+ vddrfa3-supply: -+ description: -+ 2V LDO power input to RFA -+ -+ vddpcie1-supply: -+ description: -+ 1.25V LDO power input to PCIe part -+ -+ vddpcie2-supply: -+ description: -+ 2V LDO power input to PCIe part -+ -+ vddio-supply: -+ description: -+ 1.8V VIO input -+ -+additionalProperties: false -+ -+examples: -+ - | -+ qca639x: qca639x { -+ compatible = "qcom,qca639x"; -+ #power-domain-cells = <0>; -+ -+ vddaon-supply = <&vreg_s6a_0p95>; -+ vddpmu-supply = <&vreg_s2f_0p95>; -+ vddrfa1-supply = <&vreg_s2f_0p95>; -+ vddrfa2-supply = <&vreg_s8c_1p3>; -+ vddrfa3-supply = <&vreg_s5a_1p9>; -+ vddpcie1-supply = <&vreg_s8c_1p3>; -+ vddpcie2-supply = <&vreg_s5a_1p9>; -+ vddio-supply = <&vreg_s4a_1p8>; -+ pinctrl-names = "default", "active"; -+ pinctrl-0 = <&wlan_default_state &bt_default_state>; -+ pinctrl-1 = <&wlan_active_state &bt_active_state>; -+ }; -+... --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0005-mfd-qca639x-add-support-for-QCA639x-powerup-sequence.patch b/patch/kernel/archive/sm8250-6.6/0005-mfd-qca639x-add-support-for-QCA639x-powerup-sequence.patch deleted file mode 100644 index d92bc95bae0c..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0005-mfd-qca639x-add-support-for-QCA639x-powerup-sequence.patch +++ /dev/null @@ -1,223 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Fri, 18 Dec 2020 16:24:56 +0300 -Subject: mfd: qca639x: add support for QCA639x powerup sequence - -Qualcomm QCA639x is a family of WiFi + Bluetooth SoCs, with BT part -being controlled through the UART and WiFi being present on PCIe -bus. Both blocks share common power sources. So add mfd device driver -handling power sequencing of QCA6390/1. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/mfd/Kconfig | 12 + - drivers/mfd/Makefile | 1 + - drivers/mfd/qcom-qca639x.c | 162 ++++++++++ - 3 files changed, 175 insertions(+) - -diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig -index 90ce58fd629e..2dd393ff2cf5 100644 ---- a/drivers/mfd/Kconfig -+++ b/drivers/mfd/Kconfig -@@ -1123,6 +1123,18 @@ config MFD_PM8XXX - Say M here if you want to include support for PM8xxx chips as a - module. This will build a module called "pm8xxx-core". - -+config MFD_QCOM_QCA639X -+ tristate "Qualcomm QCA639x WiFi/Bluetooth module support" -+ depends on REGULATOR && PM_GENERIC_DOMAINS -+ help -+ If you say yes to this option, support will be included for Qualcomm -+ QCA639x family of WiFi and Bluetooth SoCs. Note, this driver supports -+ only power control for this SoC, you still have to enable individual -+ Bluetooth and WiFi drivers. -+ -+ Say M here if you want to include support for QCA639x chips as a -+ module. This will build a module called "qcom-qca639x". -+ - config MFD_QCOM_RPM - tristate "Qualcomm Resource Power Manager (RPM)" - depends on ARCH_QCOM && OF -diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile -index c66f07edcd0e..3e1b32dd0d8a 100644 ---- a/drivers/mfd/Makefile -+++ b/drivers/mfd/Makefile -@@ -204,6 +204,7 @@ obj-$(CONFIG_MFD_SI476X_CORE) += si476x-core.o - obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o - obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o omap-usb-tll.o - obj-$(CONFIG_MFD_PM8XXX) += qcom-pm8xxx.o ssbi.o -+obj-$(CONFIG_MFD_QCOM_QCA639X) += qcom-qca639x.o - obj-$(CONFIG_MFD_QCOM_RPM) += qcom_rpm.o - obj-$(CONFIG_MFD_SPMI_PMIC) += qcom-spmi-pmic.o - obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o -diff --git a/drivers/mfd/qcom-qca639x.c b/drivers/mfd/qcom-qca639x.c -new file mode 100644 -index 000000000000..b31e4b65bec5 ---- /dev/null -+++ b/drivers/mfd/qcom-qca639x.c -@@ -0,0 +1,162 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define MAX_NUM_REGULATORS 8 -+ -+static struct vreg { -+ const char *name; -+ unsigned int load_uA; -+} vregs [MAX_NUM_REGULATORS] = { -+ /* 2.0 V */ -+ { "vddpcie2", 15000 }, -+ { "vddrfa3", 400000 }, -+ -+ /* 0.95 V */ -+ { "vddaon", 100000 }, -+ { "vddpmu", 1250000 }, -+ { "vddrfa1", 200000 }, -+ -+ /* 1.35 V */ -+ { "vddrfa2", 400000 }, -+ { "vddpcie1", 35000 }, -+ -+ /* 1.8 V */ -+ { "vddio", 20000 }, -+}; -+ -+struct qca639x_data { -+ struct regulator_bulk_data regulators[MAX_NUM_REGULATORS]; -+ size_t num_vregs; -+ struct device *dev; -+ struct pinctrl_state *active_state; -+ struct generic_pm_domain pd; -+}; -+ -+#define domain_to_data(domain) container_of(domain, struct qca639x_data, pd) -+ -+static int qca639x_power_on(struct generic_pm_domain *domain) -+{ -+ struct qca639x_data *data = domain_to_data(domain); -+ int ret; -+ -+ dev_warn(&domain->dev, "DUMMY POWER ON\n"); -+ -+ ret = regulator_bulk_enable(data->num_vregs, data->regulators); -+ if (ret) { -+ dev_err(data->dev, "Failed to enable regulators"); -+ return ret; -+ } -+ -+ /* Wait for 1ms before toggling enable pins. */ -+ msleep(1); -+ -+ ret = pinctrl_select_state(data->dev->pins->p, data->active_state); -+ if (ret) { -+ dev_err(data->dev, "Failed to select active state"); -+ return ret; -+ } -+ -+ /* Wait for all power levels to stabilize */ -+ msleep(6); -+ -+ return 0; -+} -+ -+static int qca639x_power_off(struct generic_pm_domain *domain) -+{ -+ struct qca639x_data *data = domain_to_data(domain); -+ -+ dev_warn(&domain->dev, "DUMMY POWER OFF\n"); -+ -+ pinctrl_select_default_state(data->dev); -+ regulator_bulk_disable(data->num_vregs, data->regulators); -+ -+ return 0; -+} -+ -+static int qca639x_probe(struct platform_device *pdev) -+{ -+ struct qca639x_data *data; -+ struct device *dev = &pdev->dev; -+ int i, ret; -+ -+ if (!dev->pins || IS_ERR_OR_NULL(dev->pins->default_state)) -+ return -EINVAL; -+ -+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); -+ if (!data) -+ return -ENOMEM; -+ -+ data->dev = dev; -+ data->num_vregs = ARRAY_SIZE(vregs); -+ -+ data->active_state = pinctrl_lookup_state(dev->pins->p, "active"); -+ if (IS_ERR(data->active_state)) { -+ ret = PTR_ERR(data->active_state); -+ dev_err(dev, "Failed to get active_state: %d\n", ret); -+ return ret; -+ } -+ -+ for (i = 0; i < data->num_vregs; i++) -+ data->regulators[i].supply = vregs[i].name; -+ ret = devm_regulator_bulk_get(dev, data->num_vregs, data->regulators); -+ if (ret < 0) -+ return ret; -+ -+ for (i = 0; i < data->num_vregs; i++) { -+ ret = regulator_set_load(data->regulators[i].consumer, vregs[i].load_uA); -+ if (ret) -+ return ret; -+ } -+ -+ data->pd.name = dev_name(dev); -+ data->pd.power_on = qca639x_power_on; -+ data->pd.power_off = qca639x_power_off; -+ -+ ret = pm_genpd_init(&data->pd, NULL, true); -+ if (ret < 0) -+ return ret; -+ -+ ret = of_genpd_add_provider_simple(dev->of_node, &data->pd); -+ if (ret < 0) { -+ pm_genpd_remove(&data->pd); -+ return ret; -+ } -+ -+ platform_set_drvdata(pdev, data); -+ -+ return 0; -+} -+ -+static int qca639x_remove(struct platform_device *pdev) -+{ -+ struct qca639x_data *data = platform_get_drvdata(pdev); -+ -+ pm_genpd_remove(&data->pd); -+ -+ return 0; -+} -+ -+static const struct of_device_id qca639x_of_match[] = { -+ { .compatible = "qcom,qca639x" }, -+}; -+ -+static struct platform_driver qca639x_driver = { -+ .probe = qca639x_probe, -+ .remove = qca639x_remove, -+ .driver = { -+ .name = "qca639x", -+ .of_match_table = qca639x_of_match, -+ }, -+}; -+ -+module_platform_driver(qca639x_driver); -+MODULE_LICENSE("GPL v2"); --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0006-mfd-qcom-qca639x-switch-to-platform-config-data.patch b/patch/kernel/archive/sm8250-6.6/0006-mfd-qcom-qca639x-switch-to-platform-config-data.patch deleted file mode 100644 index 3d795fec064a..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0006-mfd-qcom-qca639x-switch-to-platform-config-data.patch +++ /dev/null @@ -1,188 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sat, 26 Feb 2022 21:13:18 +0300 -Subject: mfd: qcom-qca639x: switch to platform config data - -Change qcom-qca639x to use platform config data, in preparation to -supporting other devices. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/mfd/qcom-qca639x.c | 74 ++++++---- - 1 file changed, 46 insertions(+), 28 deletions(-) - -diff --git a/drivers/mfd/qcom-qca639x.c b/drivers/mfd/qcom-qca639x.c -index b31e4b65bec5..22792561dbad 100644 ---- a/drivers/mfd/qcom-qca639x.c -+++ b/drivers/mfd/qcom-qca639x.c -@@ -1,4 +1,5 @@ - #include -+#include - #include - #include - #include -@@ -6,15 +7,21 @@ - #include - #include - #include -+#include - #include - #include - --#define MAX_NUM_REGULATORS 8 -- --static struct vreg { -+struct vreg { - const char *name; - unsigned int load_uA; --} vregs [MAX_NUM_REGULATORS] = { -+}; -+ -+struct qca_cfg_data { -+ const struct vreg *vregs; -+ size_t num_vregs; -+}; -+ -+static const struct vreg qca6390_vregs[] = { - /* 2.0 V */ - { "vddpcie2", 15000 }, - { "vddrfa3", 400000 }, -@@ -32,19 +39,24 @@ static struct vreg { - { "vddio", 20000 }, - }; - --struct qca639x_data { -- struct regulator_bulk_data regulators[MAX_NUM_REGULATORS]; -+static const struct qca_cfg_data qca6390_cfg_data = { -+ .vregs = qca6390_vregs, -+ .num_vregs = ARRAY_SIZE(qca6390_vregs), -+}; -+ -+struct qca_data { - size_t num_vregs; - struct device *dev; - struct pinctrl_state *active_state; - struct generic_pm_domain pd; -+ struct regulator_bulk_data regulators[]; - }; - --#define domain_to_data(domain) container_of(domain, struct qca639x_data, pd) -+#define domain_to_data(domain) container_of(domain, struct qca_data, pd) - --static int qca639x_power_on(struct generic_pm_domain *domain) -+static int qca_power_on(struct generic_pm_domain *domain) - { -- struct qca639x_data *data = domain_to_data(domain); -+ struct qca_data *data = domain_to_data(domain); - int ret; - - dev_warn(&domain->dev, "DUMMY POWER ON\n"); -@@ -70,9 +82,9 @@ static int qca639x_power_on(struct generic_pm_domain *domain) - return 0; - } - --static int qca639x_power_off(struct generic_pm_domain *domain) -+static int qca_power_off(struct generic_pm_domain *domain) - { -- struct qca639x_data *data = domain_to_data(domain); -+ struct qca_data *data = domain_to_data(domain); - - dev_warn(&domain->dev, "DUMMY POWER OFF\n"); - -@@ -82,21 +94,26 @@ static int qca639x_power_off(struct generic_pm_domain *domain) - return 0; - } - --static int qca639x_probe(struct platform_device *pdev) -+static int qca_probe(struct platform_device *pdev) - { -- struct qca639x_data *data; -+ const struct qca_cfg_data *cfg; -+ struct qca_data *data; - struct device *dev = &pdev->dev; - int i, ret; - -+ cfg = device_get_match_data(&pdev->dev); -+ if (!cfg) -+ return -EINVAL; -+ - if (!dev->pins || IS_ERR_OR_NULL(dev->pins->default_state)) - return -EINVAL; - -- data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); -+ data = devm_kzalloc(dev, struct_size(data, regulators, cfg->num_vregs), GFP_KERNEL); - if (!data) - return -ENOMEM; - - data->dev = dev; -- data->num_vregs = ARRAY_SIZE(vregs); -+ data->num_vregs = cfg->num_vregs; - - data->active_state = pinctrl_lookup_state(dev->pins->p, "active"); - if (IS_ERR(data->active_state)) { -@@ -106,20 +123,20 @@ static int qca639x_probe(struct platform_device *pdev) - } - - for (i = 0; i < data->num_vregs; i++) -- data->regulators[i].supply = vregs[i].name; -+ data->regulators[i].supply = cfg->vregs[i].name; - ret = devm_regulator_bulk_get(dev, data->num_vregs, data->regulators); - if (ret < 0) - return ret; - - for (i = 0; i < data->num_vregs; i++) { -- ret = regulator_set_load(data->regulators[i].consumer, vregs[i].load_uA); -+ ret = regulator_set_load(data->regulators[i].consumer, cfg->vregs[i].load_uA); - if (ret) - return ret; - } - - data->pd.name = dev_name(dev); -- data->pd.power_on = qca639x_power_on; -- data->pd.power_off = qca639x_power_off; -+ data->pd.power_on = qca_power_on; -+ data->pd.power_off = qca_power_off; - - ret = pm_genpd_init(&data->pd, NULL, true); - if (ret < 0) -@@ -136,27 +153,28 @@ static int qca639x_probe(struct platform_device *pdev) - return 0; - } - --static int qca639x_remove(struct platform_device *pdev) -+static int qca_remove(struct platform_device *pdev) - { -- struct qca639x_data *data = platform_get_drvdata(pdev); -+ struct qca_data *data = platform_get_drvdata(pdev); - - pm_genpd_remove(&data->pd); - - return 0; - } - --static const struct of_device_id qca639x_of_match[] = { -- { .compatible = "qcom,qca639x" }, -+static const struct of_device_id qca_of_match[] = { -+ { .compatible = "qcom,qca6390", .data = &qca6390_cfg_data }, -+ { }, - }; - --static struct platform_driver qca639x_driver = { -- .probe = qca639x_probe, -- .remove = qca639x_remove, -+static struct platform_driver qca_driver = { -+ .probe = qca_probe, -+ .remove = qca_remove, - .driver = { - .name = "qca639x", -- .of_match_table = qca639x_of_match, -+ .of_match_table = qca_of_match, - }, - }; - --module_platform_driver(qca639x_driver); -+module_platform_driver(qca_driver); - MODULE_LICENSE("GPL v2"); --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0007-mfd-qcom-qca639x-change-qca639x-to-use-gpios-rather-.patch b/patch/kernel/archive/sm8250-6.6/0007-mfd-qcom-qca639x-change-qca639x-to-use-gpios-rather-.patch deleted file mode 100644 index 2570a84bde28..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0007-mfd-qcom-qca639x-change-qca639x-to-use-gpios-rather-.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sat, 26 Feb 2022 21:17:22 +0300 -Subject: mfd: qcom-qca639x: change qca639x to use gpios rather than pinctrl - -Use gpio interface instead of pinctrl interface to toggle enable pins. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/mfd/qcom-qca639x.c | 33 ++++++---- - 1 file changed, 19 insertions(+), 14 deletions(-) - -diff --git a/drivers/mfd/qcom-qca639x.c b/drivers/mfd/qcom-qca639x.c -index 22792561dbad..4de860e9bbd0 100644 ---- a/drivers/mfd/qcom-qca639x.c -+++ b/drivers/mfd/qcom-qca639x.c -@@ -47,8 +47,9 @@ static const struct qca_cfg_data qca6390_cfg_data = { - struct qca_data { - size_t num_vregs; - struct device *dev; -- struct pinctrl_state *active_state; - struct generic_pm_domain pd; -+ struct gpio_desc *wlan_en_gpio; -+ struct gpio_desc *bt_en_gpio; - struct regulator_bulk_data regulators[]; - }; - -@@ -70,11 +71,10 @@ static int qca_power_on(struct generic_pm_domain *domain) - /* Wait for 1ms before toggling enable pins. */ - msleep(1); - -- ret = pinctrl_select_state(data->dev->pins->p, data->active_state); -- if (ret) { -- dev_err(data->dev, "Failed to select active state"); -- return ret; -- } -+ if (data->wlan_en_gpio) -+ gpiod_set_value(data->wlan_en_gpio, 1); -+ if (data->bt_en_gpio) -+ gpiod_set_value(data->bt_en_gpio, 1); - - /* Wait for all power levels to stabilize */ - msleep(6); -@@ -88,7 +88,11 @@ static int qca_power_off(struct generic_pm_domain *domain) - - dev_warn(&domain->dev, "DUMMY POWER OFF\n"); - -- pinctrl_select_default_state(data->dev); -+ if (data->wlan_en_gpio) -+ gpiod_set_value(data->wlan_en_gpio, 0); -+ if (data->bt_en_gpio) -+ gpiod_set_value(data->bt_en_gpio, 0); -+ - regulator_bulk_disable(data->num_vregs, data->regulators); - - return 0; -@@ -115,13 +119,6 @@ static int qca_probe(struct platform_device *pdev) - data->dev = dev; - data->num_vregs = cfg->num_vregs; - -- data->active_state = pinctrl_lookup_state(dev->pins->p, "active"); -- if (IS_ERR(data->active_state)) { -- ret = PTR_ERR(data->active_state); -- dev_err(dev, "Failed to get active_state: %d\n", ret); -- return ret; -- } -- - for (i = 0; i < data->num_vregs; i++) - data->regulators[i].supply = cfg->vregs[i].name; - ret = devm_regulator_bulk_get(dev, data->num_vregs, data->regulators); -@@ -134,6 +131,14 @@ static int qca_probe(struct platform_device *pdev) - return ret; - } - -+ data->wlan_en_gpio = devm_gpiod_get_optional(&pdev->dev, "wlan-en", GPIOD_OUT_LOW); -+ if (IS_ERR(data->wlan_en_gpio)) -+ return PTR_ERR(data->wlan_en_gpio); -+ -+ data->bt_en_gpio = devm_gpiod_get_optional(&pdev->dev, "bt-en", GPIOD_OUT_LOW); -+ if (IS_ERR(data->bt_en_gpio)) -+ return PTR_ERR(data->bt_en_gpio); -+ - data->pd.name = dev_name(dev); - data->pd.power_on = qca_power_on; - data->pd.power_off = qca_power_off; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0008-Bluetooth-hci_qca-reopen-serial-port-after-toggling-.patch b/patch/kernel/archive/sm8250-6.6/0008-Bluetooth-hci_qca-reopen-serial-port-after-toggling-.patch deleted file mode 100644 index e386b2f4a7ef..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0008-Bluetooth-hci_qca-reopen-serial-port-after-toggling-.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sat, 26 Feb 2022 23:07:54 +0300 -Subject: Bluetooth: hci_qca: reopen serial port after toggling power - -Reopen the serial port after toggling the power. This saves us from -getting command timeouts on first command submitted. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/bluetooth/hci_qca.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c -index 4b57e15f9c7a..e96ebb27188a 100644 ---- a/drivers/bluetooth/hci_qca.c -+++ b/drivers/bluetooth/hci_qca.c -@@ -1797,6 +1797,8 @@ static int qca_power_on(struct hci_dev *hdev) - gpiod_set_value_cansleep(qcadev->bt_en, 1); - /* Controller needs time to bootup. */ - msleep(150); -+ serdev_device_close(hu->serdev); -+ ret = serdev_device_open(hu->serdev); - } - } - --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0010-arm64-swiotlb-Reduce-the-default-size-if-no-ZONE_DMA-bouncing-needed.patch b/patch/kernel/archive/sm8250-6.6/0010-arm64-swiotlb-Reduce-the-default-size-if-no-ZONE_DMA-bouncing-needed.patch deleted file mode 100644 index c31c4414fbaa..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0010-arm64-swiotlb-Reduce-the-default-size-if-no-ZONE_DMA-bouncing-needed.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 7648741002eeb851ceb394864253445b77ea3d25 Mon Sep 17 00:00:00 2001 -From: Catalin Marinas -Date: Wed, 10 Apr 2024 08:25:37 -0400 -Subject: [PATCH] arm64: swiotlb: Reduce the default size if no ZONE_DMA - bouncing needed - -With CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC enabled, the arm64 kernel still -allocates the default SWIOTLB buffer (64MB) even if ZONE_DMA is disabled -or all the RAM fits into this zone. However, this potentially wastes a -non-negligible amount of memory on platforms with little RAM. - -Reduce the SWIOTLB size to 1MB per 1GB of RAM if only needed for -kmalloc() buffer bouncing. - -Signed-off-by: Catalin Marinas -Suggested-by: Ross Burton -Cc: Ross Burton -Cc: Will Deacon -Reviewed-by: Robin Murphy ---- - arch/arm64/mm/init.c | 11 ++++++++++- - 1 file changed, 10 insertions(+), 1 deletion(-) - -diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c -index 8a0f8604348b..8deec68028ac 100644 ---- a/arch/arm64/mm/init.c -+++ b/arch/arm64/mm/init.c -@@ -16,6 +16,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -493,8 +494,16 @@ void __init mem_init(void) - { - bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit); - -- if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC)) -+ if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && !swiotlb) { -+ /* -+ * If no bouncing needed for ZONE_DMA, reduce the swiotlb -+ * buffer for kmalloc() bouncing to 1MB per 1GB of RAM. -+ */ -+ unsigned long size = -+ DIV_ROUND_UP(memblock_phys_mem_size(), 1024); -+ swiotlb_adjust_size(min(swiotlb_size_or_default(), size)); - swiotlb = true; -+ } - - swiotlb_init(swiotlb, SWIOTLB_VERBOSE); - --- -2.39.2 - diff --git a/patch/kernel/archive/sm8250-6.6/0010-drm-dsi-emit-panel-turn-on-off-signal-to-touchscreen.patch b/patch/kernel/archive/sm8250-6.6/0010-drm-dsi-emit-panel-turn-on-off-signal-to-touchscreen.patch deleted file mode 100644 index ec52243de5ca..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0010-drm-dsi-emit-panel-turn-on-off-signal-to-touchscreen.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Mon, 17 Oct 2022 08:02:58 +0800 -Subject: drm: dsi: emit panel turn on/off signal to touchscreen - ---- - drivers/gpu/drm/msm/dsi/dsi_manager.c | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c -index 28b8012a21f2..f9d05c711c2f 100644 ---- a/drivers/gpu/drm/msm/dsi/dsi_manager.c -+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c -@@ -7,6 +7,7 @@ - - #include "msm_kms.h" - #include "dsi.h" -+#include "drm/drm_notifier.h" - - #define DSI_CLOCK_MASTER DSI_0 - #define DSI_CLOCK_SLAVE DSI_1 -@@ -303,6 +304,7 @@ static void dsi_mgr_bridge_pre_enable(struct drm_bridge *bridge) - struct mipi_dsi_host *host = msm_dsi->host; - bool is_bonded_dsi = IS_BONDED_DSI(); - int ret; -+ enum drm_notifier_data notifier_data; - - DBG("id=%d", id); - if (!msm_dsi_device_connected(msm_dsi)) -@@ -318,6 +320,9 @@ static void dsi_mgr_bridge_pre_enable(struct drm_bridge *bridge) - return; - } - -+ notifier_data = MI_DRM_BLANK_UNBLANK; -+ mi_drm_notifier_call_chain(MI_DRM_EVENT_BLANK, ¬ifier_data); -+ - ret = msm_dsi_host_enable(host); - if (ret) { - pr_err("%s: enable host %d failed, %d\n", __func__, id, ret); -@@ -361,12 +366,16 @@ static void dsi_mgr_bridge_post_disable(struct drm_bridge *bridge) - struct mipi_dsi_host *host = msm_dsi->host; - bool is_bonded_dsi = IS_BONDED_DSI(); - int ret; -+ enum drm_notifier_data notifier_data; - - DBG("id=%d", id); - - if (!msm_dsi_device_connected(msm_dsi)) - return; - -+ notifier_data = MI_DRM_BLANK_POWERDOWN; -+ mi_drm_notifier_call_chain(MI_DRM_EARLY_EVENT_BLANK, ¬ifier_data); -+ - /* - * Do nothing with the host if it is slave-DSI in case of bonded DSI. - * It is safe to call dsi_mgr_phy_disable() here because a single PHY --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0012-arm64-dts-qcom-sm8250-xiaomi-elish-enable-wifi-and-b.patch b/patch/kernel/archive/sm8250-6.6/0012-arm64-dts-qcom-sm8250-xiaomi-elish-enable-wifi-and-b.patch deleted file mode 100644 index 54ede9402b9e..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0012-arm64-dts-qcom-sm8250-xiaomi-elish-enable-wifi-and-b.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Mon, 6 Mar 2023 23:13:06 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: enable wifi and bluetooth - -Signed-off-by: Jianhua Lu ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 61 ++++++++++ - 1 file changed, 61 insertions(+) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index 85e5cf3dc91e..d7ec6bdd1c88 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -29,6 +29,10 @@ / { - qcom,msm-id = ; /* SM8250 v2.1 */ - qcom,board-id = <0x10008 0>; - -+ aliases { -+ hsuart0 = &uart6; -+ }; -+ - chosen { - #address-cells = <2>; - #size-cells = <2>; -@@ -113,6 +117,25 @@ vreg_s6c_0p88: smpc6-regulator { - vin-supply = <&vph_pwr>; - }; - -+ qca639x: qca639x { -+ compatible = "qcom,qca6390"; -+ #power-domain-cells = <0>; -+ -+ vddaon-supply = <&vreg_s6a_0p95>; -+ vddpmu-supply = <&vreg_s6a_0p95>; -+ vddrfa1-supply = <&vreg_s6a_0p95>; -+ vddrfa2-supply = <&vreg_s8c_1p35>; -+ vddrfa3-supply = <&vreg_s5a_1p9>; -+ vddpcie1-supply = <&vreg_s8c_1p35>; -+ vddpcie2-supply = <&vreg_s5a_1p9>; -+ vddio-supply = <&vreg_s4a_1p8>; -+ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&wlan_en_state>; -+ -+ wlan-en-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; -+ }; -+ - reserved-memory { - xbl_aop_mem: xbl-aop@80700000 { - reg = <0x0 0x80600000 0x0 0x260000>; -@@ -615,6 +638,9 @@ &pcie0_phy { - vdda-phy-supply = <&vreg_l5a_0p88>; - vdda-pll-supply = <&vreg_l9a_1p2>; - status = "okay"; -+ -+ /* Power on QCA639x chip, otherwise PCIe bus timeouts */ -+ power-domains = <&qca639x>; - }; - - &pm8150_gpios { -@@ -655,6 +681,41 @@ &slpi { - - &tlmm { - gpio-reserved-ranges = <40 4>; -+ -+ bt_en_state: bt-default-state { -+ bt-en-pins { -+ pins = "gpio21"; -+ function = "gpio"; -+ -+ drive-strength = <16>; -+ output-low; -+ bias-pull-up; -+ }; -+ }; -+ -+ wlan_en_state: wlan-default-state { -+ wlan-en-pins { -+ pins = "gpio20"; -+ function = "gpio"; -+ -+ drive-strength = <16>; -+ output-low; -+ bias-pull-up; -+ }; -+ }; -+}; -+ -+&uart6 { -+ status = "okay"; -+ -+ bluetooth { -+ compatible = "qcom,qca6390-bt"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&bt_en_state>; -+ -+ power-domains = <&qca639x>; -+ enable-gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; -+ }; - }; - - &usb_1 { --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0013-arm64-dts-qcom-sm8250-xiaomi-elish-enable-touchscree.patch b/patch/kernel/archive/sm8250-6.6/0013-arm64-dts-qcom-sm8250-xiaomi-elish-enable-touchscree.patch deleted file mode 100644 index 7a8c585ec599..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0013-arm64-dts-qcom-sm8250-xiaomi-elish-enable-touchscree.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Mon, 6 Mar 2023 23:23:13 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: enable touchscreen - -Signed-off-by: Jianhua Lu ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-boe.dts | 5 ++ - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 32 ++++++++++ - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-csot.dts | 5 ++ - 3 files changed, 42 insertions(+) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-boe.dts b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-boe.dts -index de6101ddebe7..b8d9e9406440 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-boe.dts -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-boe.dts -@@ -16,3 +16,8 @@ &display_panel { - compatible = "xiaomi,elish-boe-nt36523", "novatek,nt36523"; - status = "okay"; - }; -+ -+&touchscreen { -+ firmware-name = "novatek/nt36523-boe.bin"; -+ status = "okay"; -+}; -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index d7ec6bdd1c88..b0fe139f8d86 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -662,6 +662,16 @@ &pon_resin { - status = "okay"; - }; - -+&qup_spi4_cs_gpio { -+ drive-strength = <6>; -+ bias-disable; -+}; -+ -+&qup_spi4_data_clk { -+ drive-strength = <6>; -+ bias-disable; -+}; -+ - &qupv3_id_0 { - status = "okay"; - }; -@@ -679,6 +689,28 @@ &slpi { - status = "okay"; - }; - -+&spi4 { -+ status = "okay"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&qup_spi4_data_clk &qup_spi4_cs_gpio>; -+ cs-gpios = <&tlmm 11 GPIO_ACTIVE_LOW>; -+ touchscreen: touchscreen@0 { -+ compatible = "novatek,NVT-ts-spi"; -+ reg = <0>; //Same as CS ID -+ status = "disabled"; -+ -+ spi-max-frequency = <19200000>; //4800000,9600000,15000000,19200000 -+ novatek,irq-gpio = <&tlmm 39 0x2001>; -+ -+ novatek,pen-support; -+ novatek,wgp-stylus; -+ -+ /* 523 */ -+ novatek,swrst-n8-addr = <0x03F0FE>; -+ novatek,spi-rd-fast-addr = <0x03F310>; -+ }; -+}; -+ - &tlmm { - gpio-reserved-ranges = <40 4>; - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-csot.dts b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-csot.dts -index 4cffe9c703df..5953f652e812 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-csot.dts -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-csot.dts -@@ -16,3 +16,8 @@ &display_panel { - compatible = "xiaomi,elish-csot-nt36523", "novatek,nt36523"; - status = "okay"; - }; -+ -+&touchscreen { -+ firmware-name = "novatek/nt36523-csot.bin"; -+ status = "okay"; -+}; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0014-arm64-dts-qcom-sm8250-xiaomi-elish-Disable-slpi.patch b/patch/kernel/archive/sm8250-6.6/0014-arm64-dts-qcom-sm8250-xiaomi-elish-Disable-slpi.patch deleted file mode 100644 index e1df7f06f48f..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0014-arm64-dts-qcom-sm8250-xiaomi-elish-Disable-slpi.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Wed, 29 Mar 2023 01:57:43 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: Disable slpi - ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index b0fe139f8d86..2da3820ddbda 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -686,7 +686,7 @@ &qupv3_id_2 { - - &slpi { - firmware-name = "qcom/sm8250/xiaomi/elish/slpi.mbn"; -- status = "okay"; -+ status = "disabled"; - }; - - &spi4 { --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0015-sound-soc-qcom-sm8250-Add-tdm-support.patch b/patch/kernel/archive/sm8250-6.6/0015-sound-soc-qcom-sm8250-Add-tdm-support.patch deleted file mode 100644 index 01a39cee0b90..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0015-sound-soc-qcom-sm8250-Add-tdm-support.patch +++ /dev/null @@ -1,148 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Fri, 17 Feb 2023 21:31:38 +0800 -Subject: sound: soc: qcom: sm8250: Add tdm support - ---- - sound/soc/qcom/sdw.c | 65 ++++++++++ - sound/soc/qcom/sm8250.c | 17 +++ - 2 files changed, 82 insertions(+) - -diff --git a/sound/soc/qcom/sdw.c b/sound/soc/qcom/sdw.c -index 1a41419c7eb8..5e09fb1e3143 100644 ---- a/sound/soc/qcom/sdw.c -+++ b/sound/soc/qcom/sdw.c -@@ -4,9 +4,12 @@ - - #include - #include -+#include - #include "qdsp6/q6afe.h" - #include "sdw.h" - -+static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28}; -+ - int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream, - struct sdw_stream_runtime *sruntime, - bool *stream_prepared) -@@ -58,6 +61,64 @@ int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream, - } - EXPORT_SYMBOL_GPL(qcom_snd_sdw_prepare); - -+static int qcom_tdm_snd_hw_params(struct snd_pcm_substream *substream, -+ struct snd_pcm_hw_params *params) -+{ -+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); -+ struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); -+ -+ int ret = 0; -+ int channels, slot_width; -+ -+ switch (params_format(params)) { -+ case SNDRV_PCM_FORMAT_S16_LE: -+ slot_width = 32; -+ break; -+ default: -+ dev_err(rtd->dev, "%s: invalid param format 0x%x\n", -+ __func__, params_format(params)); -+ return -EINVAL; -+ } -+ -+ channels = params_channels(params); -+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { -+ ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 0x03, -+ 8, slot_width); -+ if (ret < 0) { -+ dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n", -+ __func__, ret); -+ goto end; -+ } -+ -+ ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, -+ channels, tdm_slot_offset); -+ if (ret < 0) { -+ dev_err(rtd->dev, "%s: failed to set channel map, err:%d\n", -+ __func__, ret); -+ goto end; -+ } -+ } else { -+ ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xf, 0, -+ 8, slot_width); -+ if (ret < 0) { -+ dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n", -+ __func__, ret); -+ goto end; -+ } -+ -+ ret = snd_soc_dai_set_channel_map(cpu_dai, channels, -+ tdm_slot_offset, 0, NULL); -+ if (ret < 0) { -+ dev_err(rtd->dev, "%s: failed to set channel map, err:%d\n", -+ __func__, ret); -+ goto end; -+ } -+ } -+ -+end: -+ return ret; -+} -+ - int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct sdw_stream_runtime **psruntime) -@@ -82,6 +143,10 @@ int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, - *psruntime = sruntime; - } - break; -+ case TERTIARY_TDM_RX_0: -+ case TERTIARY_TDM_TX_0: -+ qcom_tdm_snd_hw_params(substream, params); -+ break; - } - - return 0; -diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c -index 9626a9ef78c2..abeab190337a 100644 ---- a/sound/soc/qcom/sm8250.c -+++ b/sound/soc/qcom/sm8250.c -@@ -16,6 +16,7 @@ - - #define DRIVER_NAME "sm8250" - #define MI2S_BCLK_RATE 1536000 -+#define TDM_BCLK_RATE 12288000 - - struct sm8250_snd_data { - bool stream_prepared[AFE_PORT_MAX]; -@@ -53,6 +54,7 @@ static int sm8250_snd_startup(struct snd_pcm_substream *substream) - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); - struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); -+ int ret,j; - - switch (cpu_dai->id) { - case TERTIARY_MI2S_RX: -@@ -63,6 +65,21 @@ static int sm8250_snd_startup(struct snd_pcm_substream *substream) - snd_soc_dai_set_fmt(cpu_dai, fmt); - snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt); - break; -+ case TERTIARY_TDM_RX_0: -+ codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_DSP_A; -+ snd_soc_dai_set_sysclk(cpu_dai, -+ Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT, -+ TDM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); -+ -+ for_each_rtd_codec_dais(rtd, j, codec_dai) { -+ ret = snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt); -+ snd_soc_dai_set_sysclk(codec_dai, 0, TDM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); -+ if (ret < 0) { -+ dev_err(rtd->dev, "TDM fmt err:%d\n", ret); -+ return ret; -+ } -+ } -+ break; - default: - break; - } --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0016-arm64-dts-qcom-sm8250-xiaomi-elish-Add-sound-support.patch b/patch/kernel/archive/sm8250-6.6/0016-arm64-dts-qcom-sm8250-xiaomi-elish-Add-sound-support.patch deleted file mode 100644 index 57a382b7615d..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0016-arm64-dts-qcom-sm8250-xiaomi-elish-Add-sound-support.patch +++ /dev/null @@ -1,281 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Sat, 18 Mar 2023 22:26:22 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: Add sound support - ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 232 ++++++++++ - 1 file changed, 232 insertions(+) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index 2da3820ddbda..45775428cb92 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -6,6 +6,8 @@ - #include - #include - #include -+#include -+#include - #include "sm8250.dtsi" - #include "pm8150.dtsi" - #include "pm8150b.dtsi" -@@ -529,6 +531,152 @@ fuel-gauge@55 { - }; - }; - -+&i2c1 { -+ clock-frequency = <400000>; -+ status = "okay"; -+ -+ cs35l41_brh: speaker-amp@40 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x40>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <7 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 6 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "BRH"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_blh: speaker-amp@41 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x41>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <67 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "BLH"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_brl: speaker-amp@42 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x42>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <100 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 69 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "BRL"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_bll: speaker-amp@43 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x43>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <126 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 49 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "BLL"; -+ #sound-dai-cells = <1>; -+ }; -+}; -+ -+&i2c3 { -+ clock-frequency = <400000>; -+ status = "okay"; -+ -+ cs35l41_trh: speaker-amp@40 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x40>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <27 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "TRH"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_tlh: speaker-amp@41 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x41>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <92 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 78 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "TLH"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_tll: speaker-amp@42 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x42>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <112 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "TLL"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_trl: speaker-amp@43 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x43>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <129 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 144 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "TRL"; -+ #sound-dai-cells = <1>; -+ }; -+}; -+ - &i2c11 { - clock-frequency = <400000>; - status = "okay"; -@@ -684,11 +832,63 @@ &qupv3_id_2 { - status = "okay"; - }; - -+&q6afedai { -+ dai@56 { -+ reg = ; -+ qcom,tdm-sync-mode = <0>; -+ qcom,tdm-sync-src = <1>; -+ qcom,tdm-data-out = <0>; -+ qcom,tdm-invert-sync = <1>; -+ qcom,tdm-data-delay = <1>; -+ qcom,tdm-data-align = <0>; -+ }; -+}; -+ -+&q6asmdai { -+ dai@0 { -+ reg = <0>; -+ }; -+}; -+ - &slpi { - firmware-name = "qcom/sm8250/xiaomi/elish/slpi.mbn"; - status = "disabled"; - }; - -+&sound { -+ compatible = "qcom,sm8250-sndcard"; -+ model = "Xiaomi Mi Pad 5 Pro"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&tert_tdm_active>; -+ -+ mm1-dai-link { -+ link-name = "MultiMedia1"; -+ -+ cpu { -+ sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>; -+ }; -+ }; -+ -+ speaker-dai-link { -+ link-name = "Tertiary TDM Playback"; -+ -+ cpu { -+ sound-dai = <&q6afedai TERTIARY_TDM_RX_0>; -+ }; -+ -+ platform { -+ sound-dai = <&q6routing>; -+ }; -+ -+ codec { -+ sound-dai = <&cs35l41_tlh 0>, <&cs35l41_tll 0>, -+ <&cs35l41_trh 0>, <&cs35l41_trl 0>, -+ <&cs35l41_blh 0>, <&cs35l41_bll 0>, -+ <&cs35l41_brh 0>, <&cs35l41_brl 0>; -+ }; -+ }; -+}; -+ - &spi4 { - status = "okay"; - pinctrl-names = "default"; -@@ -735,6 +935,38 @@ wlan-en-pins { - bias-pull-up; - }; - }; -+ -+ tert_tdm_active: tert-tdm-active-state { -+ sck-pins { -+ pins = "gpio133"; -+ function = "mi2s2_sck"; -+ drive-strength = <8>; -+ bias-disable; -+ output-high; -+ }; -+ -+ din-pins { -+ pins = "gpio134"; -+ function = "mi2s2_data0"; -+ drive-strength = <8>; -+ bias-disable; -+ }; -+ -+ ws-pins { -+ pins = "gpio135"; -+ function = "mi2s2_ws"; -+ drive-strength = <8>; -+ bias-disable; -+ output-high; -+ }; -+ -+ dout-pins { -+ pins = "gpio137"; -+ function = "mi2s2_data1"; -+ drive-strength = <8>; -+ bias-disable; -+ }; -+ }; - }; - - &uart6 { --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0017-Asoc-wm_adsp-Add-prefix-support.patch b/patch/kernel/archive/sm8250-6.6/0017-Asoc-wm_adsp-Add-prefix-support.patch deleted file mode 100644 index 9cecfa65a1e7..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0017-Asoc-wm_adsp-Add-prefix-support.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Wed, 29 Mar 2023 19:38:33 +0800 -Subject: Asoc: wm_adsp: Add prefix support - ---- - sound/soc/codecs/wm_adsp.c | 14 ++++++++++ - 1 file changed, 14 insertions(+) - -diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c -index d1b9238d391e..60480d365616 100644 ---- a/sound/soc/codecs/wm_adsp.c -+++ b/sound/soc/codecs/wm_adsp.c -@@ -750,6 +750,10 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp, - *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part, - dsp->fwf_name, wm_adsp_fw[dsp->fw].file, system_name, - filetype); -+ else if (asoc_component_prefix) -+ *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part, -+ dsp->fwf_name, wm_adsp_fw[dsp->fw].file, asoc_component_prefix, -+ filetype); - else - *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, dsp->part, dsp->fwf_name, - wm_adsp_fw[dsp->fw].file, filetype); -@@ -821,6 +825,16 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp, - NULL, "bin"); - return 0; - } -+ } else if (asoc_component_prefix) { -+ if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename, -+ cirrus_dir, NULL, -+ NULL, "wmfw")) { -+ adsp_dbg(dsp, "Found '%s'\n", *wmfw_filename); -+ wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, -+ cirrus_dir, NULL, -+ asoc_component_prefix, "bin"); -+ return 0; -+ } - } - - if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename, --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0018-arm64-dts-qcom-sm8250-xiaomi-elish-Add-xiaomi-keyboa.patch b/patch/kernel/archive/sm8250-6.6/0018-arm64-dts-qcom-sm8250-xiaomi-elish-Add-xiaomi-keyboa.patch deleted file mode 100644 index b9087cc38c4f..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0018-arm64-dts-qcom-sm8250-xiaomi-elish-Add-xiaomi-keyboa.patch +++ /dev/null @@ -1,100 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Xin Xu -Date: Tue, 22 Aug 2023 00:04:45 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: Add xiaomi-keyboard support - ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 56 ++++++++++ - 1 file changed, 56 insertions(+) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index 45775428cb92..a8a684b2d7f8 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -178,6 +178,14 @@ ramoops@b0000000 { - no-map; - }; - }; -+ -+ extcon_usb: extcon-usb { -+ compatible = "linux,extcon-usb-gpio"; -+ id-gpio = <&tlmm 91 GPIO_ACTIVE_HIGH>; -+ vbus-gpio = <&pm8150_gpios 10 GPIO_ACTIVE_HIGH>; -+ pinctrl-0 = <&keyboard_active &usb_2_vbus_det_n>; -+ pinctrl-names = "default"; -+ }; - }; - - &adsp { -@@ -792,6 +800,14 @@ &pcie0_phy { - }; - - &pm8150_gpios { -+ usb_2_vbus_det_n: usb-2-vbus-det-state { -+ pins = "gpio10"; -+ function = "normal"; -+ power-source = <1>; -+ input-enable; -+ bias-pull-down; -+ }; -+ - vol_up_n: vol-up-n-state { - pins = "gpio6"; - function = "normal"; -@@ -967,6 +983,23 @@ dout-pins { - bias-disable; - }; - }; -+ -+ keyboard_active: keyboard-active-state { -+ active-pins { -+ pins = "gpio155"; -+ function = "gpio"; -+ drive-strength = <8>; -+ bias-pull-up; -+ }; -+ -+ vdd-pins { -+ pins = "gpio127"; -+ function = "gpio"; -+ drive-strength = <8>; -+ bias-disable; -+ output-high; -+ }; -+ }; - }; - - &uart6 { -@@ -1003,6 +1036,29 @@ &usb_1_hsphy { - status = "okay"; - }; - -+&usb_2 { -+ status = "okay"; -+}; -+ -+&usb_2_dwc3 { -+ dr_mode = "host"; -+ maximum-speed = "super-speed"; -+ extcon = <&extcon_usb>; -+}; -+ -+&usb_2_hsphy { -+ vdda-pll-supply = <&vreg_l5a_0p88>; -+ vdda18-supply = <&vreg_l12a_1p8>; -+ vdda33-supply = <&vreg_l2a_3p1>; -+ status = "okay"; -+}; -+ -+&usb_2_qmpphy { -+ vdda-phy-supply = <&vreg_l9a_1p2>; -+ vdda-pll-supply = <&vreg_l18a_0p9>; -+ status = "okay"; -+}; -+ - &ufs_mem_hc { - vcc-supply = <&vreg_l17a_3p0>; - vcc-max-microamp = <800000>; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0019-drm-panel-nt36523-Fix-for-kernel-6.5.patch b/patch/kernel/archive/sm8250-6.6/0019-drm-panel-nt36523-Fix-for-kernel-6.5.patch deleted file mode 100644 index 5249fcf692f5..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0019-drm-panel-nt36523-Fix-for-kernel-6.5.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:28:48 +0800 -Subject: drm/panel: nt36523: Fix for kernel 6.5 - ---- - drivers/gpu/drm/panel/panel-novatek-nt36523.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36523.c b/drivers/gpu/drm/panel/panel-novatek-nt36523.c -index 9632b9e95b71..a78970cdd5b1 100644 ---- a/drivers/gpu/drm/panel/panel-novatek-nt36523.c -+++ b/drivers/gpu/drm/panel/panel-novatek-nt36523.c -@@ -1274,6 +1274,7 @@ static int nt36523_probe(struct mipi_dsi_device *dsi) - - pinfo->dsi[0] = dsi; - mipi_dsi_set_drvdata(dsi, pinfo); -+ pinfo->panel.prepare_prev_first = true; - drm_panel_init(&pinfo->panel, dev, &nt36523_panel_funcs, DRM_MODE_CONNECTOR_DSI); - - ret = of_drm_get_panel_orientation(dev->of_node, &pinfo->orientation); --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0020-drivers-input-misc-add-xiaomi-keyboard-vendor-driver.patch b/patch/kernel/archive/sm8250-6.6/0020-drivers-input-misc-add-xiaomi-keyboard-vendor-driver.patch deleted file mode 100644 index 40e5059fda70..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0020-drivers-input-misc-add-xiaomi-keyboard-vendor-driver.patch +++ /dev/null @@ -1,723 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:29:58 +0800 -Subject: drivers/input/misc: add xiaomi keyboard vendor driver - ---- - drivers/input/misc/Kconfig | 1 + - drivers/input/misc/Makefile | 1 + - drivers/input/misc/xiaomi_keyboard/Kconfig | 8 + - drivers/input/misc/xiaomi_keyboard/Makefile | 1 + - drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.c | 608 ++++++++++ - drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.h | 45 + - 6 files changed, 664 insertions(+) - -diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig -index 6ba984d7f0b1..8ff29af395d0 100644 ---- a/drivers/input/misc/Kconfig -+++ b/drivers/input/misc/Kconfig -@@ -939,4 +939,5 @@ config INPUT_STPMIC1_ONKEY - To compile this driver as a module, choose M here: the - module will be called stpmic1_onkey. - -+source "drivers/input/misc/xiaomi_keyboard/Kconfig" - endif -diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile -index 04296a4abe8e..83773d457387 100644 ---- a/drivers/input/misc/Makefile -+++ b/drivers/input/misc/Makefile -@@ -90,3 +90,4 @@ obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o - obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o - obj-$(CONFIG_INPUT_YEALINK) += yealink.o - obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR) += ideapad_slidebar.o -+obj-$(CONFIG_XIAOMI_KEYBOARD) += xiaomi_keyboard/ -diff --git a/drivers/input/misc/xiaomi_keyboard/Kconfig b/drivers/input/misc/xiaomi_keyboard/Kconfig -new file mode 100644 -index 000000000000..bfc4b1d891e5 ---- /dev/null -+++ b/drivers/input/misc/xiaomi_keyboard/Kconfig -@@ -0,0 +1,8 @@ -+config XIAOMI_KEYBOARD -+ bool "xiaomi keyboard control-driver" -+ depends on INPUT -+ default n -+ help -+ Say Y here, compile xiaomi keyboard control driver. -+ -+ If unsure, say N. -diff --git a/drivers/input/misc/xiaomi_keyboard/Makefile b/drivers/input/misc/xiaomi_keyboard/Makefile -new file mode 100644 -index 000000000000..0a00118c658e ---- /dev/null -+++ b/drivers/input/misc/xiaomi_keyboard/Makefile -@@ -0,0 +1 @@ -+obj-$(CONFIG_XIAOMI_KEYBOARD) += xiaomi_keyboard.o -\ No newline at end of file -diff --git a/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.c b/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.c -new file mode 100644 -index 000000000000..a7a736f3c1e8 ---- /dev/null -+++ b/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.c -@@ -0,0 +1,608 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include "xiaomi_keyboard.h" -+#include -+#include -+ -+static struct xiaomi_keyboard_data *mdata; -+ -+static void set_keyboard_status(bool on); -+ -+static void xiaomi_keyboard_reset(void) -+{ -+ if (!mdata || !mdata->pdata) { -+ MI_KB_ERR("reset failed!Invalid Memory\n"); -+ return; -+ } -+ MI_KB_INFO("xiaomi keyboard IC Reset\n"); -+ gpio_direction_output(mdata->pdata->rst_gpio, 0); -+ msleep(2); -+ gpio_direction_output(mdata->pdata->rst_gpio, 1); -+} -+ -+static void xiaomi_keyboard_connected_notify(struct device *dev) -+{ -+ sysfs_notify(&dev->kobj, NULL, "xiaomi_keyboard_conn_status"); -+ MI_KB_INFO("connected status notify\n"); -+} -+ -+static ssize_t xiaomi_keyboard_conn_status_show (struct device *dev, struct device_attribute *attr, char *buf) -+{ -+ int ret = 0, value = 1; -+ MI_KB_INFO("%s enter\n", __func__); -+ if (!mdata) { -+ MI_KB_ERR("Invalid driver info\n"); -+ return ret; -+ } -+ -+ mutex_lock(&mdata->rw_mutex); -+ value = mdata->keyboard_conn_status; -+ mutex_unlock(&mdata->rw_mutex); -+ -+ return scnprintf(buf, PAGE_SIZE, "%d", value); -+} -+ -+static ssize_t xiaomi_keyboard_conn_status_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) -+{ -+ char *cmd; -+ cmd = kzalloc(count + 1, GFP_KERNEL); -+ -+ if (!cmd) { -+ MI_KB_ERR("Allocate Meomory Failed\n"); -+ goto out; -+ } -+ memcpy(cmd, buf, count); -+ -+ if (!mdata) -+ goto out; -+ -+ if (!strncmp(cmd, "reset", 5)) { -+ xiaomi_keyboard_reset(); -+ } else if (!strncmp(cmd, "enable_keyboard", 15)) { -+ MI_KB_INFO("enable keyboard\n"); -+ set_keyboard_status(1); -+ } else if (!strncmp(cmd, "disable_keyboard", 16)) { -+ MI_KB_INFO("disable keyboard\n"); -+ set_keyboard_status(0); -+ } -+ else -+ MI_KB_ERR("Undefined CMD: %s\n", cmd); -+out: -+ if (cmd) -+ kfree(cmd); -+ return count; -+} -+ -+DEVICE_ATTR(xiaomi_keyboard_conn_status, (S_IRUGO | S_IWUSR | S_IWGRP), xiaomi_keyboard_conn_status_show, xiaomi_keyboard_conn_status_store); -+ -+static irqreturn_t xiaomi_keyboard_irq_func(int irq, void *data) -+{ -+ int value = 0; -+ MI_KB_INFO("keyboard event: wakeup system\n"); -+ pm_wakeup_event(&mdata->pdev->dev, 500); -+ value = gpio_get_value_cansleep(mdata->pdata->in_irq_gpio); -+ -+ mutex_lock(&mdata->rw_mutex); -+ mdata->keyboard_conn_status = !mdata->keyboard_conn_status; -+ mutex_unlock(&mdata->rw_mutex); -+ -+ xiaomi_keyboard_connected_notify(&mdata->pdev->dev); -+ MI_KB_INFO("keyboard connected status: %d", mdata->keyboard_conn_status); -+ return IRQ_HANDLED; -+} -+ -+static int xiaomi_keyboard_gpio_config(struct xiaomi_keyboard_platdata *pdata) -+{ -+ int ret = 0; -+ if (gpio_is_valid(pdata->rst_gpio)) { -+ ret = gpio_request_one(pdata->rst_gpio, GPIOF_OUT_INIT_LOW, "kb_rst"); -+ if (ret) { -+ MI_KB_ERR("Failed to request xiaomi keyboard rst gpio\n"); -+ goto err_request_rst_gpio; -+ } -+ } -+ -+ if (gpio_is_valid(pdata->in_irq_gpio)) { -+ ret = gpio_request_one(pdata->in_irq_gpio, GPIOF_IN, "kb_in_irq"); -+ if (ret) { -+ MI_KB_ERR("Failed to request xiaomi keyboard in-irq gpio\n"); -+ goto err_request_in_irq_gpio; -+ } -+ } -+ -+ return ret; -+err_request_in_irq_gpio: -+ gpio_free(pdata->rst_gpio); -+err_request_rst_gpio: -+ return ret; -+} -+ -+static void xiaomi_keyboard_gpio_deconfig(struct xiaomi_keyboard_platdata *pdata) -+{ -+ if (gpio_is_valid(pdata->rst_gpio)) -+ gpio_free(pdata->rst_gpio); -+ -+ if (gpio_is_valid(pdata->in_irq_gpio)) -+ gpio_free(pdata->in_irq_gpio); -+} -+ -+static int xiaomi_keyboard_setup_gpio(struct xiaomi_keyboard_platdata *pdata) -+{ -+ int ret = 0; -+ if (!pdata) { -+ MI_KB_ERR("xiaomi keyboard platdata is NULL\n"); -+ return -EINVAL; -+ } -+ if (gpio_is_valid(pdata->rst_gpio)) -+ gpio_direction_output(pdata->rst_gpio, 1); -+ -+ mdata->irq = gpio_to_irq(pdata->in_irq_gpio); -+ if (mdata->irq) { -+ ret = request_threaded_irq(mdata->irq, NULL, xiaomi_keyboard_irq_func, -+ IRQF_TRIGGER_RISING|IRQF_ONESHOT, "MiKB-IRQ", mdata); -+ if (ret != 0) { -+ MI_KB_ERR("request threaded irq failed\n"); -+ return ret; -+ } -+ } -+ -+ return ret; -+} -+ -+static int xiaomi_keyboard_resetup_gpio(struct xiaomi_keyboard_platdata *pdata) -+{ -+ int ret = 0; -+ -+ if (!mdata || !pdata) { -+ MI_KB_ERR("mdata or pdata not ready, return!"); -+ return -EINVAL; -+ } -+ -+ if (gpio_is_valid(pdata->rst_gpio)) -+ gpio_direction_output(pdata->rst_gpio, 0); -+ -+ free_irq(mdata->irq, mdata); -+ -+ return ret; -+} -+ -+#ifdef CONFIG_OF -+static int xiaomi_keyboard_parse_dt(struct device *dev) -+{ -+ struct device_node *np = dev->of_node; -+ struct xiaomi_keyboard_platdata *pdata; -+ int ret = 0; -+ -+ pdata = mdata->pdata; -+ -+ pdata->rst_gpio = of_get_named_gpio(np, "xiaomi-keyboard,rst-gpio", 0); -+ MI_KB_INFO("xiaomi-kb,reset-gpio=%d\n", pdata->rst_gpio); -+ -+ pdata->in_irq_gpio = of_get_named_gpio(np, "xiaomi-keyboard,in-irq-gpio", 0); -+ MI_KB_INFO("xiaomi-kb,in-irq-gpio=%d\n", pdata->in_irq_gpio); -+ -+ pdata->vdd_gpio = of_get_named_gpio(np, "xiaomi-keyboard,vdd-gpio", 0); -+ MI_KB_INFO("xiaomi-kb,vdd-gpio=%d\n", pdata->vdd_gpio); -+ -+ return ret; -+} -+#else -+static int xiaomi_keyboard_parse_dt(struct device *dev) -+{ -+ MI_KB_ERR("Xiaomi Keyboard dev is not defined\n"); -+ return -EINVAL; -+} -+#endif -+ -+static int xiaomi_keyboard_pinctrl_init(struct device *dev) -+{ -+ int ret = 0; -+ -+ mdata->pinctrl = devm_pinctrl_get(dev); -+ if (IS_ERR_OR_NULL(mdata->pinctrl)) { -+ MI_KB_ERR("Failed to get pinctrl, please check dts\n"); -+ ret = PTR_ERR(mdata->pinctrl); -+ goto err_pinctrl_get; -+ } -+ mdata->pins_active = pinctrl_lookup_state(mdata->pinctrl, "pm_kb_active"); -+ if (IS_ERR_OR_NULL(mdata->pins_active)) { -+ MI_KB_ERR("Pin state [active] not found\n"); -+ ret = PTR_ERR(mdata->pins_active); -+ goto err_pinctrl_lookup; -+ } -+ -+ mdata->pins_suspend = pinctrl_lookup_state(mdata->pinctrl, "pm_kb_suspend"); -+ if (IS_ERR_OR_NULL(mdata->pins_suspend)) { -+ MI_KB_ERR("Pin state [suspend] not found\n"); -+ ret = PTR_ERR(mdata->pins_suspend); -+ goto err_pinctrl_lookup; -+ } -+ -+ return 0; -+err_pinctrl_lookup: -+ if (mdata->pinctrl) { -+ devm_pinctrl_put(mdata->pinctrl); -+ } -+err_pinctrl_get: -+ return ret; -+} -+ -+static int xiaomi_keyboard_power_on(void) -+{ -+ int ret = 0; -+ struct xiaomi_keyboard_platdata *pdata; -+ pdata = mdata->pdata; -+ MI_KB_INFO("Power On\n"); -+ if (gpio_is_valid(pdata->vdd_gpio)) { -+ ret = gpio_request_one(pdata->vdd_gpio, GPIOF_OUT_INIT_HIGH, "kb_vdd_gpio"); -+ if (ret) { -+ MI_KB_ERR("Failed to request xiaomi-keyboard-out-irq gpio\n"); -+ goto err_request_vdd_gpio; -+ } -+ } -+ -+ gpio_direction_output(pdata->vdd_gpio, 1); -+err_request_vdd_gpio: -+ return ret; -+} -+ -+static void xiaomi_keyboard_power_off(void) -+{ -+ struct xiaomi_keyboard_platdata *pdata; -+ pdata = mdata->pdata; -+ MI_KB_INFO("Power Off\n"); -+ if (gpio_is_valid(pdata->vdd_gpio)) { -+ gpio_direction_output(pdata->vdd_gpio, 0); -+ gpio_free(pdata->vdd_gpio); -+ } -+ return; -+} -+ -+static int xiaomi_keyboard_suspend(struct device *dev) -+{ -+ int ret = 0; -+ MI_KB_INFO("enter\n"); -+ if (mdata->pinctrl && mdata->pins_suspend) { -+ ret = (mdata->keyboard_is_enable && mdata->is_usb_exist) -+ ? 0 : pinctrl_select_state(mdata->pinctrl, mdata->pins_suspend); -+ if (ret < 0) { -+ MI_KB_ERR("Set suspend pin state error:%d\n", ret); -+ } -+ } -+ MI_KB_INFO("exit\n"); -+ return ret; -+} -+ -+static int xiaomi_keyboard_resume(struct device *dev) -+{ -+ int ret = 0; -+ MI_KB_INFO("enter\n"); -+ if (!mdata->keyboard_is_enable) { -+ MI_KB_INFO("keyboard_is_enable is false, stop resume.\n"); -+ MI_KB_INFO("exit\n"); -+ return -1; -+ } -+ if (mdata->pinctrl && mdata->pins_active) { -+ ret = pinctrl_select_state(mdata->pinctrl, mdata->pins_active); -+ if (ret < 0) { -+ MI_KB_ERR("Set active pin state error:%d\n", ret); -+ } -+ } -+ MI_KB_INFO("exit\n"); -+ return ret; -+} -+ -+static int xiaomi_keyboard_pm_suspend(struct device *dev) -+{ -+ int ret = 0; -+ MI_KB_INFO("enter\n"); -+ enable_irq_wake(mdata->irq); -+ mdata->dev_pm_suspend = true; -+ return ret; -+} -+ -+static int xiaomi_keyboard_pm_resume(struct device *dev) -+{ -+ int ret = 0; -+ MI_KB_INFO("enter\n"); -+ disable_irq_wake(mdata->irq); -+ mdata->dev_pm_suspend = false; -+ return ret; -+} -+ -+static const struct dev_pm_ops xiaomi_keyboard_pm_ops = { -+ .suspend = xiaomi_keyboard_pm_suspend, -+ .resume = xiaomi_keyboard_pm_resume, -+}; -+ -+static int keyboard_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data) -+{ -+ int blank = *(enum drm_notifier_data *)data; -+ struct xiaomi_keyboard_data *mdata = -+ container_of(self, struct xiaomi_keyboard_data, drm_notif); -+ -+ if (mdata) { -+ flush_workqueue(mdata->event_wq); -+ if (event == MI_DRM_EARLY_EVENT_BLANK) { -+ if (blank == MI_DRM_BLANK_POWERDOWN) { -+ MI_KB_ERR("keyboard suspend"); -+ mdata->is_in_suspend = true; -+ queue_work(mdata->event_wq, &mdata->suspend_work); -+ } -+ } else if (event == MI_DRM_EVENT_BLANK) { -+ if (blank == MI_DRM_BLANK_UNBLANK) { -+ MI_KB_ERR("keyboard resume"); -+ mdata->is_in_suspend = false; -+ flush_workqueue(mdata->event_wq); -+ queue_work(mdata->event_wq, &mdata->resume_work); -+ } -+ } -+ } -+ -+ return 0; -+} -+ -+static void keyboard_resume_work(struct work_struct *work) -+{ -+ struct xiaomi_keyboard_data *mdata = container_of(work, struct xiaomi_keyboard_data, resume_work); -+ xiaomi_keyboard_resume(&mdata->pdev->dev); -+} -+ -+static void keyboard_suspend_work(struct work_struct *work) -+{ -+ struct xiaomi_keyboard_data *mdata = container_of(work, struct xiaomi_keyboard_data, resume_work); -+ xiaomi_keyboard_suspend(&mdata->pdev->dev); -+} -+ -+static int kb_power_supply_event(struct notifier_block *nb, -+ unsigned long event, void *ptr) -+{ -+ struct xiaomi_keyboard_data *mdata = -+ container_of(nb, struct xiaomi_keyboard_data, power_supply_notifier); -+ -+ if (mdata != NULL) -+ queue_work(mdata->event_wq, &mdata->power_supply_work); -+ -+ return 0; -+} -+ -+static void kb_power_supply_work(struct work_struct *work) -+{ -+ struct xiaomi_keyboard_data *mdata = container_of(work, struct xiaomi_keyboard_data, power_supply_work); -+ int is_usb_exist = 0; -+ -+ mutex_lock(&mdata->power_supply_lock); -+ is_usb_exist = !!power_supply_is_system_supplied(); -+ if (is_usb_exist != mdata->is_usb_exist) { -+ mdata->is_usb_exist = is_usb_exist; -+ MI_KB_INFO("power supply is: %d", mdata->is_usb_exist); -+ } -+ mutex_unlock(&mdata->power_supply_lock); -+} -+ -+static void set_keyboard_status(bool on) { -+ int ret = 0; -+ -+ if (!mdata || !(mdata->pdata)) { -+ MI_KB_ERR("mdata or pdata not ready, return!"); -+ return; -+ } -+ -+ if (on && !(mdata->keyboard_is_enable)) { -+ ret = xiaomi_keyboard_power_on(); -+ if (ret) { -+ MI_KB_ERR("Init 3.3V power failed\n"); -+ return; -+ } -+ msleep(1); -+ ret = xiaomi_keyboard_setup_gpio(mdata->pdata); -+ if (ret) { -+ MI_KB_ERR("setup gpio failed\n"); -+ return; -+ } -+ msleep(2); -+ -+ if (!mdata->is_in_suspend) { -+ ret = pinctrl_select_state(mdata->pinctrl, mdata->pins_active); -+ if (ret < 0) { -+ MI_KB_ERR("Set active pin state error:%d\n", ret); -+ } -+ } -+ mdata->keyboard_is_enable = true; -+ -+ } else if (!on && mdata->keyboard_is_enable) { -+ if (!mdata->is_in_suspend) { -+ ret = pinctrl_select_state(mdata->pinctrl, mdata->pins_suspend); -+ if (ret < 0) { -+ MI_KB_ERR("Set suspend pin state error:%d\n", ret); -+ } -+ } -+ -+ ret = xiaomi_keyboard_resetup_gpio(mdata->pdata); -+ if (ret < 0) { -+ MI_KB_ERR("resetup gpio failed\n"); -+ return; -+ } -+ xiaomi_keyboard_power_off(); -+ mdata->keyboard_is_enable = false; -+ } else { -+ MI_KB_INFO("keyboard status do not need change!"); -+ } -+} -+ -+/******************************************************* -+Description: -+ xiami pad keyboard driver probe function. -+ -+return: -+ Executive outcomes. 0---succeed. negative---failed -+*******************************************************/ -+static int xiaomi_keyboard_probe(struct platform_device *pdev) -+{ -+ struct xiaomi_keyboard_platdata *pdata; -+ int ret = 0; -+ MI_KB_INFO("enter\n"); -+ mdata = kzalloc(sizeof(struct xiaomi_keyboard_data), GFP_KERNEL); -+ if (!mdata) { -+ MI_KB_ERR("Alloc Memory for xiaomi_keyboard_data failed\n"); -+ return -ENOMEM; -+ } -+ -+ pdata = devm_kzalloc(&pdev->dev, sizeof(struct xiaomi_keyboard_platdata), GFP_KERNEL); -+ if (!pdata) { -+ MI_KB_ERR("Alloc Memory for xiaomi_keyboard_platdata failed\n"); -+ return -ENOMEM; -+ } -+ -+ mdata->pdev = pdev; -+ mdata->pdata = pdata; -+ mutex_init(&mdata->rw_mutex); -+ mutex_init(&mdata->power_supply_lock); -+ mdata->is_usb_exist = 0; -+ -+ ret = xiaomi_keyboard_parse_dt(&pdev->dev); -+ if (ret) { -+ MI_KB_ERR("parse device tree failed\n"); -+ goto out; -+ } -+ -+ ret = xiaomi_keyboard_pinctrl_init(&pdev->dev); -+ if (ret) { -+ MI_KB_ERR("Pinctrl init failed\n"); -+ goto out; -+ } -+ -+ pdata = mdata->pdata; -+ ret = xiaomi_keyboard_gpio_config(pdata); -+ if (ret) { -+ MI_KB_ERR("set gpio config failed\n"); -+ goto out; -+ } -+ -+ mdata->dev_pm_suspend = false; -+ mdata->keyboard_is_enable = false; -+ mdata->is_in_suspend = false; -+ -+ ret = sysfs_create_file(&mdata->pdev->dev.kobj, &dev_attr_xiaomi_keyboard_conn_status.attr); -+ if (ret < 0) { -+ MI_KB_ERR("Create sysfs attribute xiaomi_keyboard_conn_status Failed\n"); -+ goto err_pinctrl_select; -+ } -+ -+ mdata->event_wq = alloc_workqueue("kb-event-queue", -+ WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE, 1); -+ if (!mdata->event_wq) { -+ MI_KB_ERR("Can not create work thread for suspend/resume!!"); -+ ret = -ENOMEM; -+ goto err_alloc_work_thread_failed; -+ } -+ -+ set_keyboard_status(1); -+ -+ INIT_WORK(&mdata->resume_work, keyboard_resume_work); -+ INIT_WORK(&mdata->suspend_work, keyboard_suspend_work); -+ INIT_WORK(&mdata->power_supply_work, kb_power_supply_work); -+ -+ mdata->drm_notif.notifier_call = keyboard_drm_notifier_callback; -+ ret = mi_drm_register_client(&mdata->drm_notif); -+ if(ret) { -+ MI_KB_ERR("register drm_notifier failed. ret=%d\n", ret); -+ goto err_register_drm_notif_failed; -+ } -+ -+ mdata->power_supply_notifier.notifier_call = kb_power_supply_event; -+ ret = power_supply_reg_notifier(&mdata->power_supply_notifier); -+ if (ret) { -+ MI_KB_ERR("register power_supply_notifier failed. ret=%d\n", ret); -+ goto err_register_power_supply_notif_failed; -+ } -+ -+ MI_KB_INFO("Success\n"); -+ return ret; -+ -+err_register_power_supply_notif_failed: -+err_register_drm_notif_failed: -+ if (mdata->event_wq) { -+ destroy_workqueue(mdata->event_wq); -+ } -+err_alloc_work_thread_failed: -+ sysfs_remove_file(&mdata->pdev->dev.kobj, &dev_attr_xiaomi_keyboard_conn_status.attr); -+err_pinctrl_select: -+ if (mdata->pinctrl) { -+ devm_pinctrl_put(mdata->pinctrl); -+ } -+ xiaomi_keyboard_gpio_deconfig(pdata); -+out: -+ mutex_destroy(&mdata->rw_mutex); -+ mutex_destroy(&mdata->power_supply_lock); -+ if (mdata) { -+ kfree(mdata); -+ mdata = NULL; -+ } -+ MI_KB_ERR("Failed\n"); -+ return ret; -+} -+ -+static int xiaomi_keyboard_remove(struct platform_device *pdev) -+{ -+ MI_KB_INFO("enter\n"); -+ mi_drm_unregister_client(&mdata->drm_notif); -+ destroy_workqueue(mdata->event_wq); -+ xiaomi_keyboard_gpio_deconfig(mdata->pdata); -+ sysfs_remove_file(&mdata->pdev->dev.kobj, &dev_attr_xiaomi_keyboard_conn_status.attr); -+ xiaomi_keyboard_power_off(); -+ devm_pinctrl_put(mdata->pinctrl); -+ xiaomi_keyboard_gpio_deconfig(mdata->pdata); -+ mutex_destroy(&mdata->rw_mutex); -+ mutex_destroy(&mdata->power_supply_lock); -+ if (mdata) { -+ kfree(mdata); -+ mdata = NULL; -+ } -+ return 0; -+} -+ -+#ifdef CONFIG_OF -+static const struct of_device_id xiaomi_keyboard_dt_match[] = { -+ { .compatible = "xiaomi,keyboard" }, -+ {}, -+}; -+MODULE_DEVICE_TABLE(of, xiaomi_keyboard_dt_match); -+#endif -+ -+static const struct platform_device_id xiaomi_keyboard_driver_ids[] = { -+ { -+ .name = "xiaomi-keyboard", -+ .driver_data = 0, -+ }, -+}; -+MODULE_DEVICE_TABLE(platform, xiaomi_keyboard_driver_ids); -+ -+ -+static struct platform_driver xiaomi_keyboard_driver = { -+ .probe = xiaomi_keyboard_probe, -+ .remove = xiaomi_keyboard_remove, -+ .driver = { -+ .name = "xiaomi-keyboard", -+ .of_match_table = of_match_ptr(xiaomi_keyboard_dt_match), -+ .pm = &xiaomi_keyboard_pm_ops, -+ }, -+ .id_table = xiaomi_keyboard_driver_ids, -+}; -+ -+module_platform_driver(xiaomi_keyboard_driver); -+ -+MODULE_DESCRIPTION("Xiaomi Keyboard Control-driver"); -+MODULE_AUTHOR("Tonghui Wang"); -diff --git a/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.h b/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.h -new file mode 100644 -index 000000000000..5c4220077bf8 ---- /dev/null -+++ b/drivers/input/misc/xiaomi_keyboard/xiaomi_keyboard.h -@@ -0,0 +1,45 @@ -+#ifndef __XIAOMI_KEYBOARD_H -+#define __XIAOMI_KEYBOARD_H -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define XIAOMI_KB_TAG "xiaomi-keyboard" -+#define MI_KB_INFO(fmt, args...) pr_info("[%s] %s %d: " fmt, XIAOMI_KB_TAG, __func__, __LINE__, ##args) -+#define MI_KB_ERR(fmt, args...) pr_err("[%s] %s %d: " fmt, XIAOMI_KB_TAG, __func__, __LINE__, ##args) -+ -+struct xiaomi_keyboard_platdata { -+ u32 rst_gpio; -+ u32 rst_flags; -+ u32 in_irq_gpio; -+ u32 in_irq_flags; -+ u32 vdd_gpio; -+}; -+ -+struct xiaomi_keyboard_data { -+ struct notifier_block drm_notif; -+ struct xiaomi_keyboard_platdata *pdata; -+ bool dev_pm_suspend; -+ int irq; -+ struct platform_device *pdev; -+ struct pinctrl *pinctrl; -+ struct pinctrl_state *pins_active; -+ struct pinctrl_state *pins_suspend; -+ struct workqueue_struct *event_wq; -+ struct work_struct resume_work; -+ struct work_struct suspend_work; -+ int keyboard_conn_status; -+ struct mutex rw_mutex; -+ -+ struct mutex power_supply_lock; -+ struct work_struct power_supply_work; -+ struct notifier_block power_supply_notifier; -+ int is_usb_exist; -+ bool keyboard_is_enable; -+ bool is_in_suspend; -+}; -+#endif --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0021-arm64-dts-qcom-sm8250-xiaomi-elish-use-vendor-keyboa.patch b/patch/kernel/archive/sm8250-6.6/0021-arm64-dts-qcom-sm8250-xiaomi-elish-use-vendor-keyboa.patch deleted file mode 100644 index 429638edd10b..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0021-arm64-dts-qcom-sm8250-xiaomi-elish-use-vendor-keyboa.patch +++ /dev/null @@ -1,104 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:31:25 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: use vendor keyboard driver - ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 58 +++++----- - 1 file changed, 31 insertions(+), 27 deletions(-) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index a8a684b2d7f8..ae6e0df3e66c 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -179,12 +179,14 @@ ramoops@b0000000 { - }; - }; - -- extcon_usb: extcon-usb { -- compatible = "linux,extcon-usb-gpio"; -- id-gpio = <&tlmm 91 GPIO_ACTIVE_HIGH>; -- vbus-gpio = <&pm8150_gpios 10 GPIO_ACTIVE_HIGH>; -- pinctrl-0 = <&keyboard_active &usb_2_vbus_det_n>; -- pinctrl-names = "default"; -+ xiaomi_keyboard { -+ compatible = "xiaomi,keyboard"; -+ pinctrl-names = "pm_kb_active", "pm_kb_suspend"; -+ pinctrl-0 = <&xiaomi_keyboard_active>; -+ pinctrl-1 = <&xiaomi_keyboard_suspend>; -+ xiaomi-keyboard,rst-gpio = <&tlmm 141 0x00>; -+ xiaomi-keyboard,in-irq-gpio = <&tlmm 83 0x2001>; -+ xiaomi-keyboard,vdd-gpio = <&tlmm 127 0x00>; - }; - }; - -@@ -800,14 +802,6 @@ &pcie0_phy { - }; - - &pm8150_gpios { -- usb_2_vbus_det_n: usb-2-vbus-det-state { -- pins = "gpio10"; -- function = "normal"; -- power-source = <1>; -- input-enable; -- bias-pull-down; -- }; -- - vol_up_n: vol-up-n-state { - pins = "gpio6"; - function = "normal"; -@@ -984,20 +978,31 @@ dout-pins { - }; - }; - -- keyboard_active: keyboard-active-state { -- active-pins { -- pins = "gpio155"; -- function = "gpio"; -- drive-strength = <8>; -- bias-pull-up; -+ xiaomi_keyboard_mcu { -+ xiaomi_keyboard_suspend: xiaomi_keyboard_suspend { -+ mux { -+ pins = "gpio155"; -+ function = "gpio"; -+ }; -+ -+ config { -+ pins = "gpio155"; -+ drive-strength = <8>; -+ bias-pull-down; -+ }; - }; - -- vdd-pins { -- pins = "gpio127"; -- function = "gpio"; -- drive-strength = <8>; -- bias-disable; -- output-high; -+ xiaomi_keyboard_active: xiaomi_keyboard_active { -+ mux { -+ pins = "gpio155"; -+ function = "gpio"; -+ }; -+ -+ config { -+ pins = "gpio155"; -+ drive-strength = <8>; -+ bias-pull-up; -+ }; - }; - }; - }; -@@ -1043,7 +1048,6 @@ &usb_2 { - &usb_2_dwc3 { - dr_mode = "host"; - maximum-speed = "super-speed"; -- extcon = <&extcon_usb>; - }; - - &usb_2_hsphy { --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0023-tty-serial-qcom-geni-fix-zero-dma-rx-len-in.patch b/patch/kernel/archive/sm8250-6.6/0023-tty-serial-qcom-geni-fix-zero-dma-rx-len-in.patch deleted file mode 100644 index a41c343bf472..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0023-tty-serial-qcom-geni-fix-zero-dma-rx-len-in.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:32:58 +0800 -Subject: tty: serial: qcom-geni: fix zero dma-rx-len-in - ---- - drivers/tty/serial/qcom_geni_serial.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c -index b8aa4c1293ba..336cd300fc63 100644 ---- a/drivers/tty/serial/qcom_geni_serial.c -+++ b/drivers/tty/serial/qcom_geni_serial.c -@@ -820,7 +820,7 @@ static void qcom_geni_serial_handle_rx_dma(struct uart_port *uport, bool drop) - rx_in = readl(uport->membase + SE_DMA_RX_LEN_IN); - if (!rx_in) { - dev_warn(uport->dev, "serial engine reports 0 RX bytes in!\n"); -- return; -+ //return; - } - - if (!drop) --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0024-Asoc-wm_adsp-Use-xiaomi-elish-firmware-name.patch b/patch/kernel/archive/sm8250-6.6/0024-Asoc-wm_adsp-Use-xiaomi-elish-firmware-name.patch deleted file mode 100644 index e1d359792864..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0024-Asoc-wm_adsp-Use-xiaomi-elish-firmware-name.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Tue, 24 Oct 2023 01:01:46 +0800 -Subject: Asoc: wm_adsp: Use xiaomi-elish firmware name - ---- - sound/soc/codecs/wm_adsp.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c -index 60480d365616..b1d59ba61963 100644 ---- a/sound/soc/codecs/wm_adsp.c -+++ b/sound/soc/codecs/wm_adsp.c -@@ -827,7 +827,7 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp, - } - } else if (asoc_component_prefix) { - if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename, -- cirrus_dir, NULL, -+ cirrus_dir, "xiaomi-elish", - NULL, "wmfw")) { - adsp_dbg(dsp, "Found '%s'\n", *wmfw_filename); - wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0026-Enable-non-coherent-dst-bufs-for-Venus-V4L2-driver.patch b/patch/kernel/archive/sm8250-6.6/0026-Enable-non-coherent-dst-bufs-for-Venus-V4L2-driver.patch deleted file mode 100644 index d4d1c0a695d6..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0026-Enable-non-coherent-dst-bufs-for-Venus-V4L2-driver.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Fri, 3 Nov 2023 11:20:40 +0800 -Subject: Enable non-coherent dst bufs for Venus V4L2 driver - ---- - drivers/media/platform/qcom/venus/vdec.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c -index dbf305cec120..14b5d2ebbdf2 100644 ---- a/drivers/media/platform/qcom/venus/vdec.c -+++ b/drivers/media/platform/qcom/venus/vdec.c -@@ -1659,6 +1659,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq, - dst_vq->min_buffers_needed = 0; - dst_vq->dev = inst->core->dev; - dst_vq->lock = &inst->ctx_q_lock; -+ dst_vq->allow_cache_hints = 1; - return vb2_queue_init(dst_vq); - } - --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.6/0027-bluetooth-fix-some-blutooth-LE-devices-not-pairing.patch b/patch/kernel/archive/sm8250-6.6/0027-bluetooth-fix-some-blutooth-LE-devices-not-pairing.patch deleted file mode 100644 index 89e8e02d56b9..000000000000 --- a/patch/kernel/archive/sm8250-6.6/0027-bluetooth-fix-some-blutooth-LE-devices-not-pairing.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Sun, 5 Nov 2023 12:23:48 +0800 -Subject: bluetooth: fix some blutooth LE devices not pairing - ---- - net/bluetooth/smp.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c -index f1a9fc0012f0..62c4f3b56d22 100644 ---- a/net/bluetooth/smp.c -+++ b/net/bluetooth/smp.c -@@ -2970,8 +2970,11 @@ static int smp_sig_channel(struct l2cap_chan *chan, struct sk_buff *skb) - if (code > SMP_CMD_MAX) - goto drop; - -- if (smp && !test_and_clear_bit(code, &smp->allow_cmd)) -- goto drop; -+ if (smp && !test_and_clear_bit(code, &smp->allow_cmd)) { -+ bt_dev_warn(hcon->hdev, "test_and_clear_bit failed with command code 0x%2.2x", code); -+ if ((code != SMP_CMD_ENCRYPT_INFO) && (code != SMP_CMD_INITIATOR_IDENT)) -+ goto drop; -+ } - - /* If we don't have a context the only allowed commands are - * pairing request and security request. --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0001-drm-msm-dpu1-improve-support-for-active-CTLs.patch b/patch/kernel/archive/sm8250-6.7/0001-drm-msm-dpu1-improve-support-for-active-CTLs.patch deleted file mode 100644 index 8701076f42a6..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0001-drm-msm-dpu1-improve-support-for-active-CTLs.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sun, 14 Mar 2021 04:52:34 +0300 -Subject: drm/msm/dpu1: improve support for active CTLs - -- Support setting master interface if several INTFs are to be handled by - a single CTL - -- Support setting handling several MERGE_3D instances using a single - CTL. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 15 ++++++++++ - drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 2 ++ - 2 files changed, 17 insertions(+) - -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c -index 86182c734606..4ecffbcdba20 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c -@@ -510,6 +510,7 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx, - u32 intf_active = 0; - u32 wb_active = 0; - u32 mode_sel = 0; -+ u32 merge_3d_active = 0; - - /* CTL_TOP[31:28] carries group_id to collate CTL paths - * per VM. Explicitly disable it until VM support is -@@ -530,16 +531,30 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx, - if (cfg->wb) - wb_active |= BIT(cfg->wb - WB_0); - -+ merge_3d_active = DPU_REG_READ(c, CTL_MERGE_3D_ACTIVE); -+ if (cfg->merge_3d) -+ merge_3d_active |= BIT(cfg->merge_3d - MERGE_3D_0); -+ - DPU_REG_WRITE(c, CTL_TOP, mode_sel); - DPU_REG_WRITE(c, CTL_INTF_ACTIVE, intf_active); - DPU_REG_WRITE(c, CTL_WB_ACTIVE, wb_active); - -+ if (cfg->intf_master) -+ DPU_REG_WRITE(c, CTL_INTF_MASTER, BIT(cfg->intf_master - INTF_0)); -+ - if (cfg->merge_3d) - DPU_REG_WRITE(c, CTL_MERGE_3D_ACTIVE, - BIT(cfg->merge_3d - MERGE_3D_0)); - - if (cfg->dsc) - DPU_REG_WRITE(c, CTL_DSC_ACTIVE, cfg->dsc); -+ if (cfg->merge_3d) -+ DPU_REG_WRITE(c, CTL_MERGE_3D_ACTIVE, merge_3d_active); -+ -+ if (cfg->intf_master) -+ DPU_DEBUG_DRIVER("ACTIVE: %x %x %lx\n", intf_active, merge_3d_active, BIT(cfg->intf_master - INTF_0)); -+ else -+ DPU_DEBUG_DRIVER("ACTIVE: %x %x\n", intf_active, merge_3d_active); - } - - static void dpu_hw_ctl_intf_cfg(struct dpu_hw_ctl *ctx, -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h -index 1c242298ff2e..36dd4e91a0b4 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h -@@ -36,6 +36,7 @@ struct dpu_hw_stage_cfg { - /** - * struct dpu_hw_intf_cfg :Describes how the DPU writes data to output interface - * @intf : Interface id -+ * @intf_master: Master interface id in the dual pipe topology - * @mode_3d: 3d mux configuration - * @merge_3d: 3d merge block used - * @intf_mode_sel: Interface mode, cmd / vid -@@ -44,6 +45,7 @@ struct dpu_hw_stage_cfg { - */ - struct dpu_hw_intf_cfg { - enum dpu_intf intf; -+ enum dpu_intf intf_master; - enum dpu_wb wb; - enum dpu_3d_blend_mode mode_3d; - enum dpu_merge_3d merge_3d; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0002-drm-msm-dpu1-use-one-active-CTL-if-it-is-available.patch b/patch/kernel/archive/sm8250-6.7/0002-drm-msm-dpu1-use-one-active-CTL-if-it-is-available.patch deleted file mode 100644 index 4644c4de8dd9..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0002-drm-msm-dpu1-use-one-active-CTL-if-it-is-available.patch +++ /dev/null @@ -1,136 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sun, 14 Mar 2021 04:58:32 +0300 -Subject: drm/msm/dpu1: use one active CTL if it is available - -Unlike previous generation, with newer ("active") CTLs it is possible to -use just one CTL to handle both interfaces. And one has to use single -CTL to support master/slave DSI config. So use one active CTL if it is -available. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_0_sm8150.h | 1 + - drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_6_0_sm8250.h | 1 + - drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 8 ++++-- - drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h | 1 + - drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 14 +++++++--- - drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 1 + - 6 files changed, 20 insertions(+), 6 deletions(-) - -diff --git a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_0_sm8150.h b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_0_sm8150.h -index 9392ad2b4d3f..35b3856f9df0 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_0_sm8150.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_5_0_sm8150.h -@@ -15,6 +15,7 @@ static const struct dpu_caps sm8150_dpu_caps = { - .has_dim_layer = true, - .has_idle_pc = true, - .has_3d_merge = true, -+ .has_active_ctls = true, - .max_linewidth = 4096, - .pixel_ram_size = DEFAULT_PIXEL_RAM_SIZE, - .max_hdeci_exp = MAX_HORZ_DECIMATION, -diff --git a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_6_0_sm8250.h b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_6_0_sm8250.h -index 94278a3e3483..be95a27c45ea 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_6_0_sm8250.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_6_0_sm8250.h -@@ -15,6 +15,7 @@ static const struct dpu_caps sm8250_dpu_caps = { - .has_dim_layer = true, - .has_idle_pc = true, - .has_3d_merge = true, -+ .has_active_ctls = true, - .max_linewidth = 4096, - .pixel_ram_size = DEFAULT_PIXEL_RAM_SIZE, - }; -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c -index 1cf7ff6caff4..98f46cc989af 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c -@@ -1117,14 +1117,18 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc, - return; - } - -- if (!hw_ctl[i]) { -+ /* Use first (and only) CTL if active CTLs are supported */ -+ if (dpu_kms->catalog->caps->has_active_ctls) -+ phys->hw_ctl = to_dpu_hw_ctl(hw_ctl[0]); -+ else -+ phys->hw_ctl = to_dpu_hw_ctl(hw_ctl[i]); -+ if (!phys->hw_ctl) { - DPU_ERROR_ENC(dpu_enc, - "no ctl block assigned at idx: %d\n", i); - return; - } - - phys->hw_pp = dpu_enc->hw_pp[i]; -- phys->hw_ctl = to_dpu_hw_ctl(hw_ctl[i]); - - phys->cached_mode = crtc_state->adjusted_mode; - if (phys->ops.atomic_mode_set) -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h -index df024e10d3a3..4e9533c7e86f 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h -@@ -359,6 +359,7 @@ struct dpu_caps { - bool has_dim_layer; - bool has_idle_pc; - bool has_3d_merge; -+ bool has_active_ctls; - /* SSPP limits */ - u32 max_linewidth; - u32 pixel_ram_size; -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c -index 8759466e2f37..ba55b4381733 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c -@@ -196,6 +196,7 @@ int dpu_rm_init(struct dpu_rm *rm, - } - rm->ctl_blks[ctl->id - CTL_0] = &hw->base; - } -+ rm->has_active_ctls = cat->caps->has_active_ctls; - - for (i = 0; i < cat->dspp_count; i++) { - struct dpu_hw_dspp *hw; -@@ -418,10 +419,15 @@ static int _dpu_rm_reserve_ctls( - int i = 0, j, num_ctls; - bool needs_split_display; - -- /* each hw_intf needs its own hw_ctrl to program its control path */ -- num_ctls = top->num_intf; -+ if (rm->has_active_ctls) { -+ num_ctls = 1; -+ needs_split_display = false; -+ } else { -+ /* each hw_intf needs its own hw_ctrl to program its control path */ -+ num_ctls = top->num_intf; - -- needs_split_display = _dpu_rm_needs_split_display(top); -+ needs_split_display = _dpu_rm_needs_split_display(top); -+ } - - for (j = 0; j < ARRAY_SIZE(rm->ctl_blks); j++) { - const struct dpu_hw_ctl *ctl; -@@ -439,7 +445,7 @@ static int _dpu_rm_reserve_ctls( - - DPU_DEBUG("ctl %d caps 0x%lX\n", j + CTL_0, features); - -- if (needs_split_display != has_split_display) -+ if (!rm->has_active_ctls && needs_split_display != has_split_display) - continue; - - ctl_idx[i] = j; -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h -index 2b551566cbf4..6e4777f57e23 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h -@@ -33,6 +33,7 @@ struct dpu_rm { - struct dpu_hw_blk *merge_3d_blks[MERGE_3D_MAX - MERGE_3D_0]; - struct dpu_hw_blk *dsc_blks[DSC_MAX - DSC_0]; - struct dpu_hw_sspp *hw_sspp[SSPP_MAX - SSPP_NONE]; -+ bool has_active_ctls; - }; - - /** --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0006-mfd-qcom-qca639x-switch-to-platform-config-data.patch b/patch/kernel/archive/sm8250-6.7/0006-mfd-qcom-qca639x-switch-to-platform-config-data.patch deleted file mode 100644 index 3d795fec064a..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0006-mfd-qcom-qca639x-switch-to-platform-config-data.patch +++ /dev/null @@ -1,188 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sat, 26 Feb 2022 21:13:18 +0300 -Subject: mfd: qcom-qca639x: switch to platform config data - -Change qcom-qca639x to use platform config data, in preparation to -supporting other devices. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/mfd/qcom-qca639x.c | 74 ++++++---- - 1 file changed, 46 insertions(+), 28 deletions(-) - -diff --git a/drivers/mfd/qcom-qca639x.c b/drivers/mfd/qcom-qca639x.c -index b31e4b65bec5..22792561dbad 100644 ---- a/drivers/mfd/qcom-qca639x.c -+++ b/drivers/mfd/qcom-qca639x.c -@@ -1,4 +1,5 @@ - #include -+#include - #include - #include - #include -@@ -6,15 +7,21 @@ - #include - #include - #include -+#include - #include - #include - --#define MAX_NUM_REGULATORS 8 -- --static struct vreg { -+struct vreg { - const char *name; - unsigned int load_uA; --} vregs [MAX_NUM_REGULATORS] = { -+}; -+ -+struct qca_cfg_data { -+ const struct vreg *vregs; -+ size_t num_vregs; -+}; -+ -+static const struct vreg qca6390_vregs[] = { - /* 2.0 V */ - { "vddpcie2", 15000 }, - { "vddrfa3", 400000 }, -@@ -32,19 +39,24 @@ static struct vreg { - { "vddio", 20000 }, - }; - --struct qca639x_data { -- struct regulator_bulk_data regulators[MAX_NUM_REGULATORS]; -+static const struct qca_cfg_data qca6390_cfg_data = { -+ .vregs = qca6390_vregs, -+ .num_vregs = ARRAY_SIZE(qca6390_vregs), -+}; -+ -+struct qca_data { - size_t num_vregs; - struct device *dev; - struct pinctrl_state *active_state; - struct generic_pm_domain pd; -+ struct regulator_bulk_data regulators[]; - }; - --#define domain_to_data(domain) container_of(domain, struct qca639x_data, pd) -+#define domain_to_data(domain) container_of(domain, struct qca_data, pd) - --static int qca639x_power_on(struct generic_pm_domain *domain) -+static int qca_power_on(struct generic_pm_domain *domain) - { -- struct qca639x_data *data = domain_to_data(domain); -+ struct qca_data *data = domain_to_data(domain); - int ret; - - dev_warn(&domain->dev, "DUMMY POWER ON\n"); -@@ -70,9 +82,9 @@ static int qca639x_power_on(struct generic_pm_domain *domain) - return 0; - } - --static int qca639x_power_off(struct generic_pm_domain *domain) -+static int qca_power_off(struct generic_pm_domain *domain) - { -- struct qca639x_data *data = domain_to_data(domain); -+ struct qca_data *data = domain_to_data(domain); - - dev_warn(&domain->dev, "DUMMY POWER OFF\n"); - -@@ -82,21 +94,26 @@ static int qca639x_power_off(struct generic_pm_domain *domain) - return 0; - } - --static int qca639x_probe(struct platform_device *pdev) -+static int qca_probe(struct platform_device *pdev) - { -- struct qca639x_data *data; -+ const struct qca_cfg_data *cfg; -+ struct qca_data *data; - struct device *dev = &pdev->dev; - int i, ret; - -+ cfg = device_get_match_data(&pdev->dev); -+ if (!cfg) -+ return -EINVAL; -+ - if (!dev->pins || IS_ERR_OR_NULL(dev->pins->default_state)) - return -EINVAL; - -- data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); -+ data = devm_kzalloc(dev, struct_size(data, regulators, cfg->num_vregs), GFP_KERNEL); - if (!data) - return -ENOMEM; - - data->dev = dev; -- data->num_vregs = ARRAY_SIZE(vregs); -+ data->num_vregs = cfg->num_vregs; - - data->active_state = pinctrl_lookup_state(dev->pins->p, "active"); - if (IS_ERR(data->active_state)) { -@@ -106,20 +123,20 @@ static int qca639x_probe(struct platform_device *pdev) - } - - for (i = 0; i < data->num_vregs; i++) -- data->regulators[i].supply = vregs[i].name; -+ data->regulators[i].supply = cfg->vregs[i].name; - ret = devm_regulator_bulk_get(dev, data->num_vregs, data->regulators); - if (ret < 0) - return ret; - - for (i = 0; i < data->num_vregs; i++) { -- ret = regulator_set_load(data->regulators[i].consumer, vregs[i].load_uA); -+ ret = regulator_set_load(data->regulators[i].consumer, cfg->vregs[i].load_uA); - if (ret) - return ret; - } - - data->pd.name = dev_name(dev); -- data->pd.power_on = qca639x_power_on; -- data->pd.power_off = qca639x_power_off; -+ data->pd.power_on = qca_power_on; -+ data->pd.power_off = qca_power_off; - - ret = pm_genpd_init(&data->pd, NULL, true); - if (ret < 0) -@@ -136,27 +153,28 @@ static int qca639x_probe(struct platform_device *pdev) - return 0; - } - --static int qca639x_remove(struct platform_device *pdev) -+static int qca_remove(struct platform_device *pdev) - { -- struct qca639x_data *data = platform_get_drvdata(pdev); -+ struct qca_data *data = platform_get_drvdata(pdev); - - pm_genpd_remove(&data->pd); - - return 0; - } - --static const struct of_device_id qca639x_of_match[] = { -- { .compatible = "qcom,qca639x" }, -+static const struct of_device_id qca_of_match[] = { -+ { .compatible = "qcom,qca6390", .data = &qca6390_cfg_data }, -+ { }, - }; - --static struct platform_driver qca639x_driver = { -- .probe = qca639x_probe, -- .remove = qca639x_remove, -+static struct platform_driver qca_driver = { -+ .probe = qca_probe, -+ .remove = qca_remove, - .driver = { - .name = "qca639x", -- .of_match_table = qca639x_of_match, -+ .of_match_table = qca_of_match, - }, - }; - --module_platform_driver(qca639x_driver); -+module_platform_driver(qca_driver); - MODULE_LICENSE("GPL v2"); --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0007-mfd-qcom-qca639x-change-qca639x-to-use-gpios-rather-.patch b/patch/kernel/archive/sm8250-6.7/0007-mfd-qcom-qca639x-change-qca639x-to-use-gpios-rather-.patch deleted file mode 100644 index 2570a84bde28..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0007-mfd-qcom-qca639x-change-qca639x-to-use-gpios-rather-.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sat, 26 Feb 2022 21:17:22 +0300 -Subject: mfd: qcom-qca639x: change qca639x to use gpios rather than pinctrl - -Use gpio interface instead of pinctrl interface to toggle enable pins. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/mfd/qcom-qca639x.c | 33 ++++++---- - 1 file changed, 19 insertions(+), 14 deletions(-) - -diff --git a/drivers/mfd/qcom-qca639x.c b/drivers/mfd/qcom-qca639x.c -index 22792561dbad..4de860e9bbd0 100644 ---- a/drivers/mfd/qcom-qca639x.c -+++ b/drivers/mfd/qcom-qca639x.c -@@ -47,8 +47,9 @@ static const struct qca_cfg_data qca6390_cfg_data = { - struct qca_data { - size_t num_vregs; - struct device *dev; -- struct pinctrl_state *active_state; - struct generic_pm_domain pd; -+ struct gpio_desc *wlan_en_gpio; -+ struct gpio_desc *bt_en_gpio; - struct regulator_bulk_data regulators[]; - }; - -@@ -70,11 +71,10 @@ static int qca_power_on(struct generic_pm_domain *domain) - /* Wait for 1ms before toggling enable pins. */ - msleep(1); - -- ret = pinctrl_select_state(data->dev->pins->p, data->active_state); -- if (ret) { -- dev_err(data->dev, "Failed to select active state"); -- return ret; -- } -+ if (data->wlan_en_gpio) -+ gpiod_set_value(data->wlan_en_gpio, 1); -+ if (data->bt_en_gpio) -+ gpiod_set_value(data->bt_en_gpio, 1); - - /* Wait for all power levels to stabilize */ - msleep(6); -@@ -88,7 +88,11 @@ static int qca_power_off(struct generic_pm_domain *domain) - - dev_warn(&domain->dev, "DUMMY POWER OFF\n"); - -- pinctrl_select_default_state(data->dev); -+ if (data->wlan_en_gpio) -+ gpiod_set_value(data->wlan_en_gpio, 0); -+ if (data->bt_en_gpio) -+ gpiod_set_value(data->bt_en_gpio, 0); -+ - regulator_bulk_disable(data->num_vregs, data->regulators); - - return 0; -@@ -115,13 +119,6 @@ static int qca_probe(struct platform_device *pdev) - data->dev = dev; - data->num_vregs = cfg->num_vregs; - -- data->active_state = pinctrl_lookup_state(dev->pins->p, "active"); -- if (IS_ERR(data->active_state)) { -- ret = PTR_ERR(data->active_state); -- dev_err(dev, "Failed to get active_state: %d\n", ret); -- return ret; -- } -- - for (i = 0; i < data->num_vregs; i++) - data->regulators[i].supply = cfg->vregs[i].name; - ret = devm_regulator_bulk_get(dev, data->num_vregs, data->regulators); -@@ -134,6 +131,14 @@ static int qca_probe(struct platform_device *pdev) - return ret; - } - -+ data->wlan_en_gpio = devm_gpiod_get_optional(&pdev->dev, "wlan-en", GPIOD_OUT_LOW); -+ if (IS_ERR(data->wlan_en_gpio)) -+ return PTR_ERR(data->wlan_en_gpio); -+ -+ data->bt_en_gpio = devm_gpiod_get_optional(&pdev->dev, "bt-en", GPIOD_OUT_LOW); -+ if (IS_ERR(data->bt_en_gpio)) -+ return PTR_ERR(data->bt_en_gpio); -+ - data->pd.name = dev_name(dev); - data->pd.power_on = qca_power_on; - data->pd.power_off = qca_power_off; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0008-Bluetooth-hci_qca-reopen-serial-port-after-toggling-.patch b/patch/kernel/archive/sm8250-6.7/0008-Bluetooth-hci_qca-reopen-serial-port-after-toggling-.patch deleted file mode 100644 index 2a5a205a7f4f..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0008-Bluetooth-hci_qca-reopen-serial-port-after-toggling-.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Sat, 26 Feb 2022 23:07:54 +0300 -Subject: Bluetooth: hci_qca: reopen serial port after toggling power - -Reopen the serial port after toggling the power. This saves us from -getting command timeouts on first command submitted. - -Signed-off-by: Dmitry Baryshkov ---- - drivers/bluetooth/hci_qca.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c -index 067e248e3599..2d77e6272c72 100644 ---- a/drivers/bluetooth/hci_qca.c -+++ b/drivers/bluetooth/hci_qca.c -@@ -1797,6 +1797,8 @@ static int qca_power_on(struct hci_dev *hdev) - gpiod_set_value_cansleep(qcadev->bt_en, 1); - /* Controller needs time to bootup. */ - msleep(150); -+ serdev_device_close(hu->serdev); -+ ret = serdev_device_open(hu->serdev); - } - } - --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0009-drm-Add-drm-notifier-support.patch b/patch/kernel/archive/sm8250-6.7/0009-drm-Add-drm-notifier-support.patch deleted file mode 100644 index 579fd216fe2c..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0009-drm-Add-drm-notifier-support.patch +++ /dev/null @@ -1,135 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Thu, 4 Aug 2022 13:26:53 +0800 -Subject: drm: Add drm notifier support - ---- - drivers/gpu/drm/Makefile | 3 +- - drivers/gpu/drm/drm_notifier.c | 57 ++++++++++ - include/drm/drm_notifier.h | 37 ++++++ - 3 files changed, 96 insertions(+), 1 deletion(-) - -diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile -index 8e1bde059170..3095874a2e6d 100644 ---- a/drivers/gpu/drm/Makefile -+++ b/drivers/gpu/drm/Makefile -@@ -45,7 +45,8 @@ drm-y := \ - drm_vblank.o \ - drm_vblank_work.o \ - drm_vma_manager.o \ -- drm_writeback.o -+ drm_writeback.o \ -+ drm_notifier.o - drm-$(CONFIG_DRM_LEGACY) += \ - drm_agpsupport.o \ - drm_bufs.o \ -diff --git a/drivers/gpu/drm/drm_notifier.c b/drivers/gpu/drm/drm_notifier.c -new file mode 100644 -index 000000000000..792069640ea7 ---- /dev/null -+++ b/drivers/gpu/drm/drm_notifier.c -@@ -0,0 +1,57 @@ -+/* -+ * Copyright (c) 2019, The Linux Foundation. All rights reserved. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 and -+ * only version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ */ -+ -+#include -+ -+static BLOCKING_NOTIFIER_HEAD(mi_drm_notifier_list); -+ -+/** -+ * mi_drm_register_client - register a client notifier -+ * @nb: notifier block to callback on events -+ * -+ * This function registers a notifier callback function -+ * to msm_drm_notifier_list, which would be called when -+ * received unblank/power down event. -+ */ -+int mi_drm_register_client(struct notifier_block *nb) -+{ -+ return blocking_notifier_chain_register(&mi_drm_notifier_list, nb); -+} -+EXPORT_SYMBOL(mi_drm_register_client); -+ -+/** -+ * mi_drm_unregister_client - unregister a client notifier -+ * @nb: notifier block to callback on events -+ * -+ * This function unregisters the callback function from -+ * msm_drm_notifier_list. -+ */ -+int mi_drm_unregister_client(struct notifier_block *nb) -+{ -+ return blocking_notifier_chain_unregister(&mi_drm_notifier_list, nb); -+} -+EXPORT_SYMBOL(mi_drm_unregister_client); -+ -+/** -+ * mi_drm_notifier_call_chain - notify clients of drm_events -+ * @val: event MSM_DRM_EARLY_EVENT_BLANK or MSM_DRM_EVENT_BLANK -+ * @v: notifier data, inculde display id and display blank -+ * event(unblank or power down). -+ */ -+int mi_drm_notifier_call_chain(unsigned long val, void *v) -+{ -+ return blocking_notifier_call_chain(&mi_drm_notifier_list, val, v); -+} -+EXPORT_SYMBOL(mi_drm_notifier_call_chain); -\ No newline at end of file -diff --git a/include/drm/drm_notifier.h b/include/drm/drm_notifier.h -new file mode 100644 -index 000000000000..fd0e976559b8 ---- /dev/null -+++ b/include/drm/drm_notifier.h -@@ -0,0 +1,37 @@ -+/* -+ * Copyright (c) 2019, The Linux Foundation. All rights reserved. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 and -+ * only version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ */ -+ -+#ifndef _DRM_NOTIFIER_H_ -+#define _DRM_NOTIFIER_H_ -+ -+#include -+ -+/* A hardware display blank change occurred */ -+#define MI_DRM_EVENT_BLANK 0x01 -+/* A hardware display blank early change occurred */ -+#define MI_DRM_EARLY_EVENT_BLANK 0x02 -+ -+enum drm_notifier_data { -+ /* panel: power on */ -+ MI_DRM_BLANK_UNBLANK, -+ /* panel: power down */ -+ MI_DRM_BLANK_POWERDOWN, -+}; -+ -+int mi_drm_register_client(struct notifier_block *nb); -+int mi_drm_unregister_client(struct notifier_block *nb); -+int mi_drm_notifier_call_chain(unsigned long val, void *v); -+ -+#endif /* _DRM_NOTIFIER_H */ --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0011-Input-Add-nt36523-touchscreen-driver.patch b/patch/kernel/archive/sm8250-6.7/0011-Input-Add-nt36523-touchscreen-driver.patch deleted file mode 100644 index 543715163750..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0011-Input-Add-nt36523-touchscreen-driver.patch +++ /dev/null @@ -1,3491 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Thu, 4 Aug 2022 13:26:26 +0800 -Subject: Input: Add nt36523 touchscreen driver - ---- - drivers/input/touchscreen/Kconfig | 2 + - drivers/input/touchscreen/Makefile | 1 + - drivers/input/touchscreen/nt36523/Kconfig | 11 + - drivers/input/touchscreen/nt36523/Makefile | 8 + - drivers/input/touchscreen/nt36523/nt36xxx.c | 1908 ++++++++++ - drivers/input/touchscreen/nt36523/nt36xxx.h | 240 ++ - drivers/input/touchscreen/nt36523/nt36xxx_fw_update.c | 857 +++++ - drivers/input/touchscreen/nt36523/nt36xxx_mem_map.h | 390 ++ - 8 files changed, 3417 insertions(+) - -diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig -index e3e2324547b9..1f8b33c2b03d 100644 ---- a/drivers/input/touchscreen/Kconfig -+++ b/drivers/input/touchscreen/Kconfig -@@ -12,6 +12,8 @@ menuconfig INPUT_TOUCHSCREEN - - if INPUT_TOUCHSCREEN - -+source "drivers/input/touchscreen/nt36523/Kconfig" -+ - config TOUCHSCREEN_88PM860X - tristate "Marvell 88PM860x touchscreen" - depends on MFD_88PM860X -diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile -index 62bd24f3ac8e..7d52592f4290 100644 ---- a/drivers/input/touchscreen/Makefile -+++ b/drivers/input/touchscreen/Makefile -@@ -118,3 +118,4 @@ obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o - obj-$(CONFIG_TOUCHSCREEN_IQS7211) += iqs7211.o - obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o - obj-$(CONFIG_TOUCHSCREEN_HIMAX_HX83112B) += himax_hx83112b.o -+obj-$(CONFIG_TOUCHSCREEN_NT36523_SPI) += nt36523/ -diff --git a/drivers/input/touchscreen/nt36523/Kconfig b/drivers/input/touchscreen/nt36523/Kconfig -new file mode 100644 -index 000000000000..5f4ef5abfd6a ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/Kconfig -@@ -0,0 +1,11 @@ -+# -+# Novatek NT36523 touchscreen driver configuration -+# -+config TOUCHSCREEN_NT36523_SPI -+ tristate "Novatek NT36523 no flash SPI driver" -+ default n -+ help -+ Say Y here if you have a Novatek NT36523 no flash touchscreen connected -+ to your system by SPI bus. -+ -+ If unsure, say N. -diff --git a/drivers/input/touchscreen/nt36523/Makefile b/drivers/input/touchscreen/nt36523/Makefile -new file mode 100644 -index 000000000000..d16afc8f127f ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/Makefile -@@ -0,0 +1,8 @@ -+# -+# Makefile for the Novatek NT36523 touchscreen driver. -+# -+ -+# Each configuration option enables a list of files. -+obj-$(CONFIG_TOUCHSCREEN_NT36523_SPI) += nt36523_ts.o -+nt36523_ts-y := nt36xxx.o \ -+ nt36xxx_fw_update.o -diff --git a/drivers/input/touchscreen/nt36523/nt36xxx.c b/drivers/input/touchscreen/nt36523/nt36xxx.c -new file mode 100644 -index 000000000000..45500ad5cd91 ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/nt36xxx.c -@@ -0,0 +1,1908 @@ -+/* -+ * Copyright (C) 2010 - 2018 Novatek, Inc. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * $Revision: 73033 $ -+ * $Date: 2020-11-26 10:09:14 +0800 (週四, 26 十一月 2020) $ -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ * more details. -+ * -+ */ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#ifdef CONFIG_DRM -+#include -+#endif -+ -+#include "nt36xxx.h" -+ -+#if NVT_TOUCH_ESD_PROTECT -+#include -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+#if NVT_TOUCH_ESD_PROTECT -+static struct delayed_work nvt_esd_check_work; -+static struct workqueue_struct *nvt_esd_check_wq; -+static unsigned long irq_timer = 0; -+uint8_t esd_check = false; -+uint8_t esd_retry = 0; -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+struct nvt_ts_data *ts; -+ -+#if BOOT_UPDATE_FIRMWARE -+static struct workqueue_struct *nvt_fwu_wq; -+extern void Boot_Update_Firmware(struct work_struct *work); -+#endif -+ -+#ifdef CONFIG_DRM -+static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data); -+#endif -+ -+static int32_t nvt_ts_suspend(struct device *dev); -+static int32_t nvt_ts_resume(struct device *dev); -+ -+uint32_t ENG_RST_ADDR = 0x7FFF80; -+uint32_t SWRST_N8_ADDR = 0; //read from dtsi -+uint32_t SPI_RD_FAST_ADDR = 0; //read from dtsi -+ -+#if TOUCH_KEY_NUM > 0 -+const uint16_t touch_key_array[TOUCH_KEY_NUM] = { -+ KEY_BACK, -+ KEY_HOME, -+ KEY_MENU -+}; -+#endif -+ -+static uint8_t bTouchIsAwake = 0; -+ -+/******************************************************* -+Description: -+ Novatek touchscreen irq enable/disable function. -+ -+return: -+ n.a. -+*******************************************************/ -+static void nvt_irq_enable(bool enable) -+{ -+ if (enable) { -+ if (!ts->irq_enabled) { -+ enable_irq(ts->client->irq); -+ ts->irq_enabled = true; -+ } -+ } else { -+ if (ts->irq_enabled) { -+ disable_irq(ts->client->irq); -+ ts->irq_enabled = false; -+ } -+ } -+} -+ -+static inline int32_t spi_read_write(struct spi_device *client, uint8_t *buf, size_t len , NVT_SPI_RW rw) -+{ -+ struct spi_message m; -+ struct spi_transfer t = { -+ .len = len, -+ }; -+ -+ memset(ts->xbuf, 0, len + DUMMY_BYTES); -+ memcpy(ts->xbuf, buf, len); -+ -+ switch (rw) { -+ case NVTREAD: -+ t.tx_buf = ts->xbuf; -+ t.rx_buf = ts->rbuf; -+ t.len = (len + DUMMY_BYTES); -+ break; -+ -+ case NVTWRITE: -+ t.tx_buf = ts->xbuf; -+ break; -+ } -+ -+ spi_message_init(&m); -+ spi_message_add_tail(&t, &m); -+ return spi_sync(client, &m); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen spi read function. -+ -+return: -+ Executive outcomes. 2---succeed. -5---I/O error -+*******************************************************/ -+int32_t CTP_SPI_READ(struct spi_device *client, uint8_t *buf, uint16_t len) -+{ -+ int32_t ret = -1; -+ int32_t retries = 0; -+ -+ mutex_lock(&ts->xbuf_lock); -+ -+ buf[0] = SPI_READ_MASK(buf[0]); -+ -+ while (retries < 5) { -+ ret = spi_read_write(client, buf, len, NVTREAD); -+ if (ret == 0) break; -+ retries++; -+ } -+ -+ if (unlikely(retries == 5)) { -+ NVT_ERR("read error, ret=%d\n", ret); -+ ret = -EIO; -+ } else { -+ memcpy((buf+1), (ts->rbuf+2), (len-1)); -+ } -+ -+ mutex_unlock(&ts->xbuf_lock); -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen spi write function. -+ -+return: -+ Executive outcomes. 1---succeed. -5---I/O error -+*******************************************************/ -+int32_t CTP_SPI_WRITE(struct spi_device *client, uint8_t *buf, uint16_t len) -+{ -+ int32_t ret = -1; -+ int32_t retries = 0; -+ -+ mutex_lock(&ts->xbuf_lock); -+ -+ buf[0] = SPI_WRITE_MASK(buf[0]); -+ -+ while (retries < 5) { -+ ret = spi_read_write(client, buf, len, NVTWRITE); -+ if (ret == 0) break; -+ retries++; -+ } -+ -+ if (unlikely(retries == 5)) { -+ NVT_ERR("error, ret=%d\n", ret); -+ ret = -EIO; -+ } -+ -+ mutex_unlock(&ts->xbuf_lock); -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen set index/page/addr address. -+ -+return: -+ Executive outcomes. 0---succeed. -5---access fail. -+*******************************************************/ -+int32_t nvt_set_page(uint32_t addr) -+{ -+ uint8_t buf[4] = {0}; -+ -+ buf[0] = 0xFF; //set index/page/addr command -+ buf[1] = (addr >> 15) & 0xFF; -+ buf[2] = (addr >> 7) & 0xFF; -+ -+ return CTP_SPI_WRITE(ts->client, buf, 3); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen write data to specify address. -+ -+return: -+ Executive outcomes. 0---succeed. -5---access fail. -+*******************************************************/ -+int32_t nvt_write_addr(uint32_t addr, uint8_t data) -+{ -+ int32_t ret = 0; -+ uint8_t buf[4] = {0}; -+ -+ //---set xdata index--- -+ buf[0] = 0xFF; //set index/page/addr command -+ buf[1] = (addr >> 15) & 0xFF; -+ buf[2] = (addr >> 7) & 0xFF; -+ ret = CTP_SPI_WRITE(ts->client, buf, 3); -+ if (ret) { -+ NVT_ERR("set page 0x%06X failed, ret = %d\n", addr, ret); -+ return ret; -+ } -+ -+ //---write data to index--- -+ buf[0] = addr & (0x7F); -+ buf[1] = data; -+ ret = CTP_SPI_WRITE(ts->client, buf, 2); -+ if (ret) { -+ NVT_ERR("write data to 0x%06X failed, ret = %d\n", addr, ret); -+ return ret; -+ } -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen enable hw bld crc function. -+ -+return: -+ N/A. -+*******************************************************/ -+void nvt_bld_crc_enable(void) -+{ -+ uint8_t buf[4] = {0}; -+ -+ //---set xdata index to BLD_CRC_EN_ADDR--- -+ nvt_set_page(ts->mmap->BLD_CRC_EN_ADDR); -+ -+ //---read data from index--- -+ buf[0] = ts->mmap->BLD_CRC_EN_ADDR & (0x7F); -+ buf[1] = 0xFF; -+ CTP_SPI_READ(ts->client, buf, 2); -+ -+ //---write data to index--- -+ buf[0] = ts->mmap->BLD_CRC_EN_ADDR & (0x7F); -+ buf[1] = buf[1] | (0x01 << 7); -+ CTP_SPI_WRITE(ts->client, buf, 2); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen clear status & enable fw crc function. -+ -+return: -+ N/A. -+*******************************************************/ -+void nvt_fw_crc_enable(void) -+{ -+ uint8_t buf[4] = {0}; -+ -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR); -+ -+ //---clear fw reset status--- -+ buf[0] = EVENT_MAP_RESET_COMPLETE & (0x7F); -+ buf[1] = 0x00; -+ CTP_SPI_WRITE(ts->client, buf, 2); -+ -+ //---enable fw crc--- -+ buf[0] = EVENT_MAP_HOST_CMD & (0x7F); -+ buf[1] = 0xAE; //enable fw crc command -+ CTP_SPI_WRITE(ts->client, buf, 2); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen set boot ready function. -+ -+return: -+ N/A. -+*******************************************************/ -+void nvt_boot_ready(void) -+{ -+ //---write BOOT_RDY status cmds--- -+ nvt_write_addr(ts->mmap->BOOT_RDY_ADDR, 1); -+ -+ mdelay(5); -+ -+ if (!ts->hw_crc) { -+ //---write BOOT_RDY status cmds--- -+ nvt_write_addr(ts->mmap->BOOT_RDY_ADDR, 0); -+ -+ //---write POR_CD cmds--- -+ nvt_write_addr(ts->mmap->POR_CD_ADDR, 0xA0); -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen enable auto copy mode function. -+ -+return: -+ N/A. -+*******************************************************/ -+void nvt_tx_auto_copy_mode(void) -+{ -+ //---write TX_AUTO_COPY_EN cmds--- -+ nvt_write_addr(ts->mmap->TX_AUTO_COPY_EN, 0x69); -+ -+ NVT_ERR("tx auto copy mode enable\n"); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen check spi dma tx info function. -+ -+return: -+ N/A. -+*******************************************************/ -+int32_t nvt_check_spi_dma_tx_info(void) -+{ -+ uint8_t buf[8] = {0}; -+ int32_t i = 0; -+ const int32_t retry = 200; -+ -+ for (i = 0; i < retry; i++) { -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->SPI_DMA_TX_INFO); -+ -+ //---read fw status--- -+ buf[0] = ts->mmap->SPI_DMA_TX_INFO & 0x7F; -+ buf[1] = 0xFF; -+ CTP_SPI_READ(ts->client, buf, 2); -+ -+ if (buf[1] == 0x00) -+ break; -+ -+ usleep_range(1000, 1000); -+ } -+ -+ if (i >= retry) { -+ NVT_ERR("failed, i=%d, buf[1]=0x%02X\n", i, buf[1]); -+ return -1; -+ } else { -+ return 0; -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen eng reset cmd -+ function. -+ -+return: -+ n.a. -+*******************************************************/ -+void nvt_eng_reset(void) -+{ -+ //---eng reset cmds to ENG_RST_ADDR--- -+ nvt_write_addr(ENG_RST_ADDR, 0x5A); -+ -+ mdelay(1); //wait tMCU_Idle2TP_REX_Hi after TP_RST -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen reset MCU -+ function. -+ -+return: -+ n.a. -+*******************************************************/ -+void nvt_sw_reset(void) -+{ -+ //---software reset cmds to SWRST_N8_ADDR--- -+ nvt_write_addr(SWRST_N8_ADDR, 0x55); -+ -+ msleep(10); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen reset MCU then into idle mode -+ function. -+ -+return: -+ n.a. -+*******************************************************/ -+void nvt_sw_reset_idle(void) -+{ -+ //---MCU idle cmds to SWRST_N8_ADDR--- -+ nvt_write_addr(SWRST_N8_ADDR, 0xAA); -+ -+ msleep(15); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen reset MCU (boot) function. -+ -+return: -+ n.a. -+*******************************************************/ -+void nvt_bootloader_reset(void) -+{ -+ //---reset cmds to SWRST_N8_ADDR--- -+ nvt_write_addr(SWRST_N8_ADDR, 0x69); -+ -+ mdelay(5); //wait tBRST2FR after Bootload RST -+ -+ if (SPI_RD_FAST_ADDR) { -+ /* disable SPI_RD_FAST */ -+ nvt_write_addr(SPI_RD_FAST_ADDR, 0x00); -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen clear FW status function. -+ -+return: -+ Executive outcomes. 0---succeed. -1---fail. -+*******************************************************/ -+int32_t nvt_clear_fw_status(void) -+{ -+ uint8_t buf[8] = {0}; -+ int32_t i = 0; -+ const int32_t retry = 20; -+ -+ for (i = 0; i < retry; i++) { -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE); -+ -+ //---clear fw status--- -+ buf[0] = EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE; -+ buf[1] = 0x00; -+ CTP_SPI_WRITE(ts->client, buf, 2); -+ -+ //---read fw status--- -+ buf[0] = EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE; -+ buf[1] = 0xFF; -+ CTP_SPI_READ(ts->client, buf, 2); -+ -+ if (buf[1] == 0x00) -+ break; -+ -+ usleep_range(10000, 10000); -+ } -+ -+ if (i >= retry) { -+ NVT_ERR("failed, i=%d, buf[1]=0x%02X\n", i, buf[1]); -+ return -1; -+ } else { -+ return 0; -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen check FW status function. -+ -+return: -+ Executive outcomes. 0---succeed. -1---failed. -+*******************************************************/ -+int32_t nvt_check_fw_status(void) -+{ -+ uint8_t buf[8] = {0}; -+ int32_t i = 0; -+ const int32_t retry = 50; -+ -+ for (i = 0; i < retry; i++) { -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE); -+ -+ //---read fw status--- -+ buf[0] = EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE; -+ buf[1] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 2); -+ -+ if ((buf[1] & 0xF0) == 0xA0) -+ break; -+ -+ usleep_range(10000, 10000); -+ } -+ -+ if (i >= retry) { -+ NVT_ERR("failed, i=%d, buf[1]=0x%02X\n", i, buf[1]); -+ return -1; -+ } else { -+ return 0; -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen check FW reset state function. -+ -+return: -+ Executive outcomes. 0---succeed. -1---failed. -+*******************************************************/ -+int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state) -+{ -+ uint8_t buf[8] = {0}; -+ int32_t ret = 0; -+ int32_t retry = 0; -+ int32_t retry_max = (check_reset_state == RESET_STATE_INIT) ? 10 : 50; -+ -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_RESET_COMPLETE); -+ -+ while (1) { -+ //---read reset state--- -+ buf[0] = EVENT_MAP_RESET_COMPLETE; -+ buf[1] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 6); -+ -+ if ((buf[1] >= check_reset_state) && (buf[1] <= RESET_STATE_MAX)) { -+ ret = 0; -+ break; -+ } -+ -+ retry++; -+ if(unlikely(retry > retry_max)) { -+ NVT_ERR("error, retry=%d, buf[1]=0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X\n", -+ retry, buf[1], buf[2], buf[3], buf[4], buf[5]); -+ ret = -1; -+ break; -+ } -+ -+ usleep_range(10000, 10000); -+ } -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen get novatek project id information -+ function. -+ -+return: -+ Executive outcomes. 0---success. -1---fail. -+*******************************************************/ -+int32_t nvt_read_pid(void) -+{ -+ uint8_t buf[4] = {0}; -+ int32_t ret = 0; -+ -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_PROJECTID); -+ -+ //---read project id--- -+ buf[0] = EVENT_MAP_PROJECTID; -+ buf[1] = 0x00; -+ buf[2] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 3); -+ -+ ts->nvt_pid = (buf[2] << 8) + buf[1]; -+ -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR); -+ -+ NVT_LOG("PID=%04X\n", ts->nvt_pid); -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen get firmware related information -+ function. -+ -+return: -+ Executive outcomes. 0---success. -1---fail. -+*******************************************************/ -+int32_t nvt_get_fw_info(void) -+{ -+ uint8_t buf[64] = {0}; -+ uint32_t retry_count = 0; -+ int32_t ret = 0; -+ -+info_retry: -+ //---set xdata index to EVENT BUF ADDR--- -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_FWINFO); -+ -+ //---read fw info--- -+ buf[0] = EVENT_MAP_FWINFO; -+ CTP_SPI_READ(ts->client, buf, 39); -+ ts->fw_ver = buf[1]; -+ ts->x_num = buf[3]; -+ ts->y_num = buf[4]; -+ ts->abs_x_max = (uint16_t)((buf[5] << 8) | buf[6]); -+ ts->abs_y_max = (uint16_t)((buf[7] << 8) | buf[8]); -+ ts->max_button_num = buf[11]; -+ ts->cascade = buf[34] & 0x01; -+ if (ts->pen_support) { -+ ts->x_gang_num = buf[37]; -+ ts->y_gang_num = buf[38]; -+ } -+ -+ //---clear x_num, y_num if fw info is broken--- -+ if ((buf[1] + buf[2]) != 0xFF) { -+ NVT_ERR("FW info is broken! fw_ver=0x%02X, ~fw_ver=0x%02X\n", buf[1], buf[2]); -+ ts->fw_ver = 0; -+ ts->x_num = 18; -+ ts->y_num = 32; -+ ts->abs_x_max = TOUCH_DEFAULT_MAX_WIDTH; -+ ts->abs_y_max = TOUCH_DEFAULT_MAX_HEIGHT; -+ ts->max_button_num = TOUCH_KEY_NUM; -+ -+ if(retry_count < 3) { -+ retry_count++; -+ NVT_ERR("retry_count=%d\n", retry_count); -+ goto info_retry; -+ } else { -+ NVT_ERR("Set default fw_ver=%d, x_num=%d, y_num=%d, " -+ "abs_x_max=%d, abs_y_max=%d, max_button_num=%d!\n", -+ ts->fw_ver, ts->x_num, ts->y_num, -+ ts->abs_x_max, ts->abs_y_max, ts->max_button_num); -+ ret = -1; -+ } -+ } else { -+ ret = 0; -+ } -+ -+ NVT_LOG("fw_ver = 0x%02X, fw_type = 0x%02X, x_num=%d, y_num=%d\n", ts->fw_ver, buf[14], ts->x_num, ts->y_num); -+ -+ //---Get Novatek PID--- -+ nvt_read_pid(); -+ -+ return ret; -+} -+ -+static void release_pen_event(void) { -+ if (ts && ts->pen_input_dev) { -+ input_report_abs(ts->pen_input_dev, ABS_X, 0); -+ input_report_abs(ts->pen_input_dev, ABS_Y, 0); -+ input_report_abs(ts->pen_input_dev, ABS_PRESSURE, 0); -+ input_report_abs(ts->pen_input_dev, ABS_TILT_X, 0); -+ input_report_abs(ts->pen_input_dev, ABS_TILT_Y, 0); -+ input_report_abs(ts->pen_input_dev, ABS_DISTANCE, 0); -+ input_report_key(ts->pen_input_dev, BTN_TOUCH, 0); -+ input_report_key(ts->pen_input_dev, BTN_TOOL_PEN, 0); -+ input_report_key(ts->pen_input_dev, BTN_STYLUS, 0); -+ input_report_key(ts->pen_input_dev, BTN_STYLUS2, 0); -+ input_sync(ts->pen_input_dev); -+ } -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen parse device tree function. -+ -+return: -+ n.a. -+*******************************************************/ -+#ifdef CONFIG_OF -+static int32_t nvt_parse_dt(struct device *dev) -+{ -+ struct device_node *np = dev->of_node; -+ int32_t ret = 0; -+ -+#if NVT_TOUCH_SUPPORT_HW_RST -+ ts->reset_gpio = of_get_named_gpio_flags(np, "novatek,reset-gpio", 0, &ts->reset_flags); -+ NVT_LOG("novatek,reset-gpio=%d\n", ts->reset_gpio); -+#endif -+ ts->irq_gpio = of_get_named_gpio(np, "novatek,irq-gpio", 0); -+ NVT_LOG("novatek,irq-gpio=%d\n", ts->irq_gpio); -+ -+ ts->pen_support = of_property_read_bool(np, "novatek,pen-support"); -+ NVT_LOG("novatek,pen-support=%d\n", ts->pen_support); -+ -+ ts->wgp_stylus = of_property_read_bool(np, "novatek,wgp-stylus"); -+ NVT_LOG("novatek,wgp-stylus=%d\n", ts->wgp_stylus); -+ -+ ret = of_property_read_u32(np, "novatek,swrst-n8-addr", &SWRST_N8_ADDR); -+ if (ret) { -+ NVT_ERR("error reading novatek,swrst-n8-addr. ret=%d\n", ret); -+ return ret; -+ } else { -+ NVT_LOG("SWRST_N8_ADDR=0x%06X\n", SWRST_N8_ADDR); -+ } -+ -+ ret = of_property_read_u32(np, "novatek,spi-rd-fast-addr", &SPI_RD_FAST_ADDR); -+ if (ret) { -+ NVT_LOG("not support novatek,spi-rd-fast-addr\n"); -+ SPI_RD_FAST_ADDR = 0; -+ ret = 0; -+ } else { -+ NVT_LOG("SPI_RD_FAST_ADDR=0x%06X\n", SPI_RD_FAST_ADDR); -+ } -+ -+ ret = of_property_read_string(np, "firmware-name", &ts->fw_name); -+ if (ret) { -+ NVT_LOG("Unable to get touchscreen firmware name\n"); -+ ts->fw_name = DEFAULT_BOOT_UPDATE_FIRMWARE_NAME; -+ } -+ -+ ret = of_property_read_u32(np, "spi-max-frequency", &ts->spi_max_freq); -+ if (ret) { -+ NVT_LOG("Unable to get spi freq\n"); -+ return ret; -+ } else { -+ NVT_LOG("spi-max-frequency: %u\n", ts->spi_max_freq); -+ } -+ -+ return ret; -+} -+#else -+static int32_t nvt_parse_dt(struct device *dev) -+{ -+#if NVT_TOUCH_SUPPORT_HW_RST -+ ts->reset_gpio = NVTTOUCH_RST_PIN; -+#endif -+ ts->irq_gpio = NVTTOUCH_INT_PIN; -+ return 0; -+} -+#endif -+ -+/******************************************************* -+Description: -+ Novatek touchscreen config and request gpio -+ -+return: -+ Executive outcomes. 0---succeed. not 0---failed. -+*******************************************************/ -+static int nvt_gpio_config(struct nvt_ts_data *ts) -+{ -+ int32_t ret = 0; -+ -+#if NVT_TOUCH_SUPPORT_HW_RST -+ /* request RST-pin (Output/High) */ -+ if (gpio_is_valid(ts->reset_gpio)) { -+ ret = gpio_request_one(ts->reset_gpio, GPIOF_OUT_INIT_LOW, "NVT-tp-rst"); -+ if (ret) { -+ NVT_ERR("Failed to request NVT-tp-rst GPIO\n"); -+ goto err_request_reset_gpio; -+ } -+ } -+#endif -+ -+ /* request INT-pin (Input) */ -+ if (gpio_is_valid(ts->irq_gpio)) { -+ ret = gpio_request_one(ts->irq_gpio, GPIOF_IN, "NVT-int"); -+ if (ret) { -+ NVT_ERR("Failed to request NVT-int GPIO\n"); -+ goto err_request_irq_gpio; -+ } -+ } -+ -+ return ret; -+ -+err_request_irq_gpio: -+#if NVT_TOUCH_SUPPORT_HW_RST -+ gpio_free(ts->reset_gpio); -+err_request_reset_gpio: -+#endif -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen deconfig gpio -+ -+return: -+ n.a. -+*******************************************************/ -+static void nvt_gpio_deconfig(struct nvt_ts_data *ts) -+{ -+ if (gpio_is_valid(ts->irq_gpio)) -+ gpio_free(ts->irq_gpio); -+#if NVT_TOUCH_SUPPORT_HW_RST -+ if (gpio_is_valid(ts->reset_gpio)) -+ gpio_free(ts->reset_gpio); -+#endif -+} -+ -+static uint8_t nvt_fw_recovery(uint8_t *point_data) -+{ -+ uint8_t i = 0; -+ uint8_t detected = true; -+ -+ /* check pattern */ -+ for (i=1 ; i<7 ; i++) { -+ if (point_data[i] != 0x77) { -+ detected = false; -+ break; -+ } -+ } -+ -+ return detected; -+} -+ -+void nvt_set_dbgfw_status(bool enable) -+{ -+ ts->fw_debug = enable; -+} -+ -+bool nvt_get_dbgfw_status(void) -+{ -+ return ts->fw_debug; -+} -+ -+#if NVT_TOUCH_ESD_PROTECT -+void nvt_esd_check_enable(uint8_t enable) -+{ -+ /* update interrupt timer */ -+ irq_timer = jiffies; -+ /* clear esd_retry counter, if protect function is enabled */ -+ esd_retry = enable ? 0 : esd_retry; -+ /* enable/disable esd check flag */ -+ esd_check = enable; -+} -+ -+static void nvt_esd_check_func(struct work_struct *work) -+{ -+ unsigned int timer = jiffies_to_msecs(jiffies - irq_timer); -+ -+ //NVT_LOG("esd_check = %d (retry %d)\n", esd_check, esd_retry); //DEBUG -+ -+ if ((timer > NVT_TOUCH_ESD_CHECK_PERIOD) && esd_check) { -+ mutex_lock(&ts->lock); -+ NVT_ERR("do ESD recovery, timer = %d, retry = %d\n", timer, esd_retry); -+ /* do esd recovery, reload fw */ -+ nvt_update_firmware(ts->fw_name); -+ mutex_unlock(&ts->lock); -+ /* update interrupt timer */ -+ irq_timer = jiffies; -+ /* update esd_retry counter */ -+ esd_retry++; -+ } -+ -+ queue_delayed_work(nvt_esd_check_wq, &nvt_esd_check_work, -+ msecs_to_jiffies(NVT_TOUCH_ESD_CHECK_PERIOD)); -+} -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+#if NVT_TOUCH_WDT_RECOVERY -+static uint8_t recovery_cnt = 0; -+static uint8_t nvt_wdt_fw_recovery(uint8_t *point_data) -+{ -+ uint32_t recovery_cnt_max = 10; -+ uint8_t recovery_enable = false; -+ uint8_t i = 0; -+ -+ recovery_cnt++; -+ -+ /* check pattern */ -+ for (i=1 ; i<7 ; i++) { -+ if ((point_data[i] != 0xFD) && (point_data[i] != 0xFE)) { -+ recovery_cnt = 0; -+ break; -+ } -+ } -+ -+ if (recovery_cnt > recovery_cnt_max){ -+ recovery_enable = true; -+ recovery_cnt = 0; -+ } -+ -+ return recovery_enable; -+} -+#endif /* #if NVT_TOUCH_WDT_RECOVERY */ -+ -+#define PEN_DATA_LEN 14 -+#define FW_HISTORY_SIZE 128 -+static uint32_t nvt_dump_fw_history(void) -+{ -+ int32_t ret = 0; -+ uint8_t buf[FW_HISTORY_SIZE + 1 + DUMMY_BYTES] = {0}; -+ int32_t i = 0; -+ char *tmp_dump = NULL; -+ int32_t line_cnt = 0; -+ -+ if (ts->mmap->FW_HISTORY_ADDR == 0) { -+ NVT_ERR("FW_HISTORY_ADDR not available!\n"); -+ ret = -1; -+ goto exit_nvt_dump_fw_history; -+ } -+ nvt_set_page(ts->mmap->FW_HISTORY_ADDR); -+ buf[0] = ts->mmap->FW_HISTORY_ADDR & 0xFF; -+ CTP_SPI_READ(ts->client, buf, FW_HISTORY_SIZE + 1); -+ if (ret) { -+ NVT_ERR("CTP_SPI_READ failed.(%d)\n", ret); -+ ret = -1; -+ goto exit_nvt_dump_fw_history; -+ } -+ -+ tmp_dump = (char *)kzalloc(FW_HISTORY_SIZE * 4, GFP_KERNEL); -+ for (i = 0; i < FW_HISTORY_SIZE; i++) { -+ sprintf(tmp_dump + i * 3 + line_cnt, "%02X ", buf[1 + i]); -+ if ((i + 1) % 16 == 0) { -+ sprintf(tmp_dump + i * 3 + line_cnt + 3, "%c", '\n'); -+ line_cnt++; -+ } -+ } -+ NVT_LOG("%s", tmp_dump); -+ -+exit_nvt_dump_fw_history: -+ if (tmp_dump) { -+ kfree(tmp_dump); -+ tmp_dump = NULL; -+ } -+ nvt_set_page(ts->mmap->EVENT_BUF_ADDR); -+ -+ return ret; -+} -+ -+#define POINT_DATA_LEN 65 -+/******************************************************* -+Description: -+ Novatek touchscreen work function. -+ -+return: -+ n.a. -+*******************************************************/ -+static irqreturn_t nvt_ts_work_func(int irq, void *data) -+{ -+ int32_t ret = -1; -+ uint8_t point_data[POINT_DATA_LEN + PEN_DATA_LEN + 1 + DUMMY_BYTES] = {0}; -+ uint32_t position = 0; -+ uint32_t input_x = 0; -+ uint32_t input_y = 0; -+ uint32_t input_w = 0; -+ uint32_t input_p = 0; -+ uint8_t input_id = 0; -+#if MT_PROTOCOL_B -+ uint8_t press_id[TOUCH_MAX_FINGER_NUM] = {0}; -+#endif /* MT_PROTOCOL_B */ -+ int32_t i = 0; -+ int32_t finger_cnt = 0; -+ uint8_t pen_format_id = 0; -+ uint32_t pen_x = 0; -+ uint32_t pen_y = 0; -+ uint32_t pen_pressure = 0; -+ uint32_t pen_distance = 0; -+ int8_t pen_tilt_x = 0; -+ int8_t pen_tilt_y = 0; -+ uint32_t pen_btn1 = 0; -+ uint32_t pen_btn2 = 0; -+ uint32_t pen_battery = 0; -+ -+ mutex_lock(&ts->lock); -+ -+ if (ts->dev_pm_suspend) { -+ ret = wait_for_completion_timeout(&ts->dev_pm_suspend_completion, msecs_to_jiffies(500)); -+ if (!ret) { -+ NVT_ERR("system(spi) can't finished resuming procedure, skip it\n"); -+ goto XFER_ERROR; -+ } -+ } -+ -+ if (ts->pen_support) -+ ret = CTP_SPI_READ(ts->client, point_data, POINT_DATA_LEN + PEN_DATA_LEN + 1); -+ else -+ ret = CTP_SPI_READ(ts->client, point_data, POINT_DATA_LEN + 1); -+ if (ret < 0) { -+ NVT_ERR("CTP_SPI_READ failed.(%d)\n", ret); -+ goto XFER_ERROR; -+ } -+ -+ /*--- dump SPI buf --- -+ for (i = 0; i < 10; i++) { -+ NVT_LOG("%02X %02X %02X %02X %02X %02X \n", -+ point_data[1+i*6], point_data[2+i*6], point_data[3+i*6], point_data[4+i*6], point_data[5+i*6], point_data[6+i*6]); -+ } -+ */ -+ -+#if NVT_TOUCH_WDT_RECOVERY -+ /* ESD protect by WDT */ -+ if (nvt_wdt_fw_recovery(point_data)) { -+ NVT_ERR("Recover for fw reset, %02X\n", point_data[1]); -+ if (point_data[1] == 0xFD) { -+ NVT_ERR("Dump FW history:\n"); -+ nvt_dump_fw_history(); -+ } -+ nvt_update_firmware(ts->fw_name); -+ goto XFER_ERROR; -+ } -+#endif /* #if NVT_TOUCH_WDT_RECOVERY */ -+ -+ /* ESD protect by FW handshake */ -+ if (nvt_fw_recovery(point_data)) { -+#if NVT_TOUCH_ESD_PROTECT -+ nvt_esd_check_enable(true); -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ goto XFER_ERROR; -+ } -+ -+ finger_cnt = 0; -+ -+ for (i = 0; i < ts->max_touch_num; i++) { -+ position = 1 + 6 * i; -+ input_id = (uint8_t)(point_data[position + 0] >> 3); -+ if ((input_id == 0) || (input_id > ts->max_touch_num)) -+ continue; -+ -+ if (((point_data[position] & 0x07) == 0x01) || ((point_data[position] & 0x07) == 0x02)) { //finger down (enter & moving) -+#if NVT_TOUCH_ESD_PROTECT -+ /* update interrupt timer */ -+ irq_timer = jiffies; -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ input_x = (uint32_t)(point_data[position + 1] << 4) + (uint32_t) (point_data[position + 3] >> 4); -+ input_y = (uint32_t)(point_data[position + 2] << 4) + (uint32_t) (point_data[position + 3] & 0x0F); -+ if ((input_x < 0) || (input_y < 0)) -+ continue; -+ if ((input_x > ts->abs_x_max) || (input_y > ts->abs_y_max)) -+ continue; -+ input_w = (uint32_t)(point_data[position + 4]); -+ if (input_w == 0) -+ input_w = 1; -+ if (i < 2) { -+ input_p = (uint32_t)(point_data[position + 5]) + (uint32_t)(point_data[i + 63] << 8); -+ if (input_p > TOUCH_FORCE_NUM) -+ input_p = TOUCH_FORCE_NUM; -+ } else { -+ input_p = (uint32_t)(point_data[position + 5]); -+ } -+ if (input_p == 0) -+ input_p = 1; -+ -+#if MT_PROTOCOL_B -+ press_id[input_id - 1] = 1; -+ input_mt_slot(ts->input_dev, input_id - 1); -+ input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); -+#else /* MT_PROTOCOL_B */ -+ input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, input_id - 1); -+ input_report_key(ts->input_dev, BTN_TOUCH, 1); -+#endif /* MT_PROTOCOL_B */ -+ -+ input_report_abs(ts->input_dev, ABS_MT_POSITION_X, input_x); -+ input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, input_y); -+ input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, input_w); -+ input_report_abs(ts->input_dev, ABS_MT_PRESSURE, input_p); -+ -+#if MT_PROTOCOL_B -+#else /* MT_PROTOCOL_B */ -+ input_mt_sync(ts->input_dev); -+#endif /* MT_PROTOCOL_B */ -+ -+ finger_cnt++; -+ } -+ } -+ -+#if MT_PROTOCOL_B -+ for (i = 0; i < ts->max_touch_num; i++) { -+ if (press_id[i] != 1) { -+ input_mt_slot(ts->input_dev, i); -+ input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); -+ input_report_abs(ts->input_dev, ABS_MT_PRESSURE, 0); -+ input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false); -+ } -+ } -+ input_report_key(ts->input_dev, BTN_TOUCH, (finger_cnt > 0)); -+#else /* MT_PROTOCOL_B */ -+ if (finger_cnt == 0) { -+ input_report_key(ts->input_dev, BTN_TOUCH, 0); -+ input_mt_sync(ts->input_dev); -+ } -+#endif /* MT_PROTOCOL_B */ -+ -+#if TOUCH_KEY_NUM > 0 -+ if (point_data[61] == 0xF8) { -+#if NVT_TOUCH_ESD_PROTECT -+ /* update interrupt timer */ -+ irq_timer = jiffies; -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ for (i = 0; i < ts->max_button_num; i++) { -+ input_report_key(ts->input_dev, touch_key_array[i], ((point_data[62] >> i) & 0x01)); -+ } -+ } else { -+ for (i = 0; i < ts->max_button_num; i++) { -+ input_report_key(ts->input_dev, touch_key_array[i], 0); -+ } -+ } -+#endif -+ -+ input_sync(ts->input_dev); -+ -+ if (ts->pen_support && ts->pen_input_dev_enable && !(ts->pen_is_charge)) { -+/* -+ //--- dump pen buf --- -+ printk("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", -+ point_data[66], point_data[67], point_data[68], point_data[69], point_data[70], -+ point_data[71], point_data[72], point_data[73], point_data[74], point_data[75], -+ point_data[76], point_data[77], point_data[78], point_data[79]); -+*/ -+ // parse and handle pen report -+ pen_format_id = point_data[66]; -+ if (pen_format_id != 0xFF) { -+ if (pen_format_id == 0x01) { -+ // report pen data -+ pen_x = (uint32_t)(point_data[67] << 8) + (uint32_t)(point_data[68]); -+ pen_y = (uint32_t)(point_data[69] << 8) + (uint32_t)(point_data[70]); -+ if (pen_x >= ts->abs_x_max * 2 - 1) { -+ pen_x -= 1; -+ } -+ if (pen_y >= ts->abs_y_max * 2 - 1) { -+ pen_y -= 1; -+ } -+ pen_pressure = (uint32_t)(point_data[71] << 8) + (uint32_t)(point_data[72]); -+ pen_tilt_x = (int32_t)point_data[73]; -+ pen_tilt_y = (int32_t)point_data[74]; -+ pen_distance = (uint32_t)(point_data[75] << 8) + (uint32_t)(point_data[76]); -+ pen_btn1 = (uint32_t)(point_data[77] & 0x01); -+ pen_btn2 = (uint32_t)((point_data[77] >> 1) & 0x01); -+ pen_battery = (uint32_t)point_data[78]; -+// printk("x=%d,y=%d,p=%d,tx=%d,ty=%d,d=%d,b1=%d,b2=%d,bat=%d\n", pen_x, pen_y, pen_pressure, -+// pen_tilt_x, pen_tilt_y, pen_distance, pen_btn1, pen_btn2, pen_battery); -+ -+ input_report_abs(ts->pen_input_dev, ABS_X, pen_x); -+ input_report_abs(ts->pen_input_dev, ABS_Y, pen_y); -+ input_report_abs(ts->pen_input_dev, ABS_PRESSURE, pen_pressure); -+ input_report_key(ts->pen_input_dev, BTN_TOUCH, !!pen_pressure); -+ input_report_abs(ts->pen_input_dev, ABS_TILT_X, pen_tilt_x); -+ input_report_abs(ts->pen_input_dev, ABS_TILT_Y, pen_tilt_y); -+ input_report_abs(ts->pen_input_dev, ABS_DISTANCE, pen_distance); -+ input_report_key(ts->pen_input_dev, BTN_TOOL_PEN, !!pen_distance || !!pen_pressure); -+ input_report_key(ts->pen_input_dev, BTN_STYLUS, pen_btn1); -+ input_report_key(ts->pen_input_dev, BTN_STYLUS2, pen_btn2); -+ input_sync(ts->pen_input_dev); -+ // TBD: pen battery event report -+ // NVT_LOG("pen_battery=%d\n", pen_battery); -+ } else if (pen_format_id == 0xF0) { -+ // report Pen ID -+ } else { -+ NVT_ERR("Unknown pen format id!\n"); -+ goto XFER_ERROR; -+ } -+ } else { // pen_format_id = 0xFF, i.e. no pen present -+ release_pen_event(); -+ } -+ } /* if (ts->pen_support) */ -+ -+XFER_ERROR: -+ -+ mutex_unlock(&ts->lock); -+ return IRQ_HANDLED; -+} -+ -+ -+/******************************************************* -+Description: -+ Novatek touchscreen check chip version trim function. -+ -+return: -+ Executive outcomes. 0---NVT IC. -1---not NVT IC. -+*******************************************************/ -+static int8_t nvt_ts_check_chip_ver_trim(uint32_t chip_ver_trim_addr) -+{ -+ -+ ts->mmap = &NT36523_memory_map; -+ ts->carrier_system = NT36523_hw_info.carrier_system; -+ ts->hw_crc = NT36523_hw_info.hw_crc; -+ return 0; -+} -+ -+static void nvt_suspend_work(struct work_struct *work) -+{ -+ struct nvt_ts_data *ts_core = container_of(work, struct nvt_ts_data, suspend_work); -+ nvt_ts_suspend(&ts_core->client->dev); -+} -+ -+static void nvt_resume_work(struct work_struct *work) -+{ -+ struct nvt_ts_data *ts_core = container_of(work, struct nvt_ts_data, resume_work); -+ nvt_ts_resume(&ts_core->client->dev); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen driver probe function. -+ -+return: -+ Executive outcomes. 0---succeed. negative---failed -+*******************************************************/ -+static int32_t nvt_ts_probe(struct spi_device *client) -+{ -+ int32_t ret = 0; -+#if (TOUCH_KEY_NUM > 0) -+ int32_t retry = 0; -+#endif -+ -+ NVT_LOG("probe start\n"); -+ -+ ts = kzalloc(sizeof(struct nvt_ts_data), GFP_KERNEL); -+ if (ts == NULL) { -+ NVT_ERR("failed to allocated memory for nvt ts data\n"); -+ return -ENOMEM; -+ } -+ -+ ts->xbuf = (uint8_t *)kzalloc((NVT_TRANSFER_LEN+1+DUMMY_BYTES), GFP_KERNEL); -+ if(ts->xbuf == NULL) { -+ NVT_ERR("kzalloc for xbuf failed!\n"); -+ ret = -ENOMEM; -+ goto err_malloc_xbuf; -+ } -+ -+ ts->rbuf = (uint8_t *)kzalloc(NVT_READ_LEN, GFP_KERNEL); -+ if(ts->rbuf == NULL) { -+ NVT_ERR("kzalloc for rbuf failed!\n"); -+ ret = -ENOMEM; -+ goto err_malloc_rbuf; -+ } -+ -+ ts->client = client; -+ spi_set_drvdata(client, ts); -+ -+ //---prepare for spi parameter--- -+ if (ts->client->master->flags & SPI_MASTER_HALF_DUPLEX) { -+ NVT_ERR("Full duplex not supported by master\n"); -+ ret = -EIO; -+ goto err_ckeck_full_duplex; -+ } -+ ts->client->bits_per_word = 8; -+ ts->client->mode = SPI_MODE_0; -+ -+ ret = spi_setup(ts->client); -+ if (ret < 0) { -+ NVT_ERR("Failed to perform SPI setup\n"); -+ goto err_spi_setup; -+ } -+ -+#ifdef CONFIG_MTK_SPI -+ /* old usage of MTK spi API */ -+ memcpy(&ts->spi_ctrl, &spi_ctrdata, sizeof(struct mt_chip_conf)); -+ ts->client->controller_data = (void *)&ts->spi_ctrl; -+#endif -+ -+#ifdef CONFIG_SPI_MT65XX -+ /* new usage of MTK spi API */ -+ memcpy(&ts->spi_ctrl, &spi_ctrdata, sizeof(struct mtk_chip_config)); -+ ts->client->controller_data = (void *)&ts->spi_ctrl; -+#endif -+ -+ NVT_LOG("mode=%d, max_speed_hz=%d\n", ts->client->mode, ts->client->max_speed_hz); -+ -+ //---parse dts--- -+ ret = nvt_parse_dt(&client->dev); -+ if (ret) { -+ NVT_ERR("parse dt error\n"); -+ goto err_spi_setup; -+ } -+ -+ //---request and config GPIOs--- -+ ret = nvt_gpio_config(ts); -+ if (ret) { -+ NVT_ERR("gpio config error!\n"); -+ goto err_gpio_config_failed; -+ } -+ -+ mutex_init(&ts->lock); -+ mutex_init(&ts->xbuf_lock); -+ -+ //---eng reset before TP_RESX high -+ nvt_eng_reset(); -+ -+#if NVT_TOUCH_SUPPORT_HW_RST -+ gpio_set_value(ts->reset_gpio, 1); -+#endif -+ -+ // need 10ms delay after POR(power on reset) -+ msleep(10); -+ -+ //---check chip version trim--- -+ ret = nvt_ts_check_chip_ver_trim(CHIP_VER_TRIM_ADDR); -+ if (ret) { -+ NVT_LOG("try to check from old chip ver trim address\n"); -+ ret = nvt_ts_check_chip_ver_trim(CHIP_VER_TRIM_OLD_ADDR); -+ if (ret) { -+ NVT_ERR("chip is not identified\n"); -+ ret = -EINVAL; -+ goto err_chipvertrim_failed; -+ } -+ } -+ -+ ts->abs_x_max = TOUCH_DEFAULT_MAX_WIDTH; -+ ts->abs_y_max = TOUCH_DEFAULT_MAX_HEIGHT; -+ -+ //---allocate input device--- -+ ts->input_dev = input_allocate_device(); -+ if (ts->input_dev == NULL) { -+ NVT_ERR("allocate input device failed\n"); -+ ret = -ENOMEM; -+ goto err_input_dev_alloc_failed; -+ } -+ -+ ts->max_touch_num = TOUCH_MAX_FINGER_NUM; -+ -+#if TOUCH_KEY_NUM > 0 -+ ts->max_button_num = TOUCH_KEY_NUM; -+#endif -+ -+ ts->int_trigger_type = INT_TRIGGER_TYPE; -+ -+ //---set input device info.--- -+ ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); -+ ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); -+ ts->input_dev->propbit[0] = BIT(INPUT_PROP_DIRECT); -+ -+ ts->db_wakeup = 0; -+ ts->fw_ver = 0; -+ ts->x_num = 32; -+ ts->y_num = 50; -+ ts->x_gang_num = 4; -+ ts->y_gang_num = 6; -+ ts->abs_x_max = TOUCH_DEFAULT_MAX_WIDTH; -+ ts->abs_y_max = TOUCH_DEFAULT_MAX_HEIGHT; -+ ts->max_button_num = TOUCH_KEY_NUM; -+ NVT_LOG("Set default fw_ver=%d, x_num=%d, y_num=%d, " -+ "abs_x_max=%d, abs_y_max=%d, max_button_num=%d!\n", -+ ts->fw_ver, ts->x_num, ts->y_num, -+ ts->abs_x_max, ts->abs_y_max, ts->max_button_num); -+ -+#if MT_PROTOCOL_B -+ input_mt_init_slots(ts->input_dev, ts->max_touch_num, 0); -+#endif -+ -+ input_set_abs_params(ts->input_dev, ABS_MT_PRESSURE, 0, TOUCH_FORCE_NUM, 0, 0); //pressure = TOUCH_FORCE_NUM -+ -+#if TOUCH_MAX_FINGER_NUM > 1 -+ input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); //area = 255 -+ -+ input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, ts->abs_x_max - 1, 0, 0); -+ input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, ts->abs_y_max - 1, 0, 0); -+#if MT_PROTOCOL_B -+ // no need to set ABS_MT_TRACKING_ID, input_mt_init_slots() already set it -+#else -+ input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, ts->max_touch_num, 0, 0); -+#endif //MT_PROTOCOL_B -+#endif //TOUCH_MAX_FINGER_NUM > 1 -+ -+#if TOUCH_KEY_NUM > 0 -+ for (retry = 0; retry < ts->max_button_num; retry++) { -+ input_set_capability(ts->input_dev, EV_KEY, touch_key_array[retry]); -+ } -+#endif -+ -+ sprintf(ts->phys, "input/ts"); -+ ts->input_dev->name = NVT_TS_NAME; -+ ts->input_dev->phys = ts->phys; -+ ts->input_dev->id.bustype = BUS_SPI; -+ -+ //---register input device--- -+ ret = input_register_device(ts->input_dev); -+ if (ret) { -+ NVT_ERR("register input device (%s) failed. ret=%d\n", ts->input_dev->name, ret); -+ goto err_input_register_device_failed; -+ } -+ -+ if (ts->pen_support) { -+ //---allocate pen input device--- -+ ts->pen_input_dev = input_allocate_device(); -+ if (ts->pen_input_dev == NULL) { -+ NVT_ERR("allocate pen input device failed\n"); -+ ret = -ENOMEM; -+ goto err_pen_input_dev_alloc_failed; -+ } -+ -+ //---set pen input device info.--- -+ ts->pen_input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); -+ ts->pen_input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); -+ ts->pen_input_dev->keybit[BIT_WORD(BTN_TOOL_PEN)] |= BIT_MASK(BTN_TOOL_PEN); -+ //ts->pen_input_dev->keybit[BIT_WORD(BTN_TOOL_RUBBER)] |= BIT_MASK(BTN_TOOL_RUBBER); -+ ts->pen_input_dev->keybit[BIT_WORD(BTN_STYLUS)] |= BIT_MASK(BTN_STYLUS); -+ ts->pen_input_dev->keybit[BIT_WORD(BTN_STYLUS2)] |= BIT_MASK(BTN_STYLUS2); -+ ts->pen_input_dev->propbit[0] = BIT(INPUT_PROP_DIRECT); -+ -+ if (ts->wgp_stylus) { -+ input_set_abs_params(ts->pen_input_dev, ABS_X, 0, ts->abs_x_max * 2 - 1, 0, 0); -+ input_set_abs_params(ts->pen_input_dev, ABS_Y, 0, ts->abs_y_max * 2 - 1, 0, 0); -+ } else { -+ input_set_abs_params(ts->pen_input_dev, ABS_X, 0, ts->abs_x_max - 1, 0, 0); -+ input_set_abs_params(ts->pen_input_dev, ABS_Y, 0, ts->abs_y_max - 1, 0, 0); -+ } -+ -+ input_set_abs_params(ts->pen_input_dev, ABS_PRESSURE, 0, PEN_PRESSURE_MAX, 0, 0); -+ input_set_abs_params(ts->pen_input_dev, ABS_DISTANCE, 0, PEN_DISTANCE_MAX, 0, 0); -+ input_set_abs_params(ts->pen_input_dev, ABS_TILT_X, PEN_TILT_MIN, PEN_TILT_MAX, 0, 0); -+ input_set_abs_params(ts->pen_input_dev, ABS_TILT_Y, PEN_TILT_MIN, PEN_TILT_MAX, 0, 0); -+ -+ sprintf(ts->pen_phys, "input/pen"); -+ ts->pen_input_dev->name = NVT_PEN_NAME; -+ ts->pen_input_dev->phys = ts->pen_phys; -+ ts->pen_input_dev->id.bustype = BUS_SPI; -+ -+ //---register pen input device--- -+ ret = input_register_device(ts->pen_input_dev); -+ if (ret) { -+ NVT_ERR("register pen input device (%s) failed. ret=%d\n", ts->pen_input_dev->name, ret); -+ goto err_pen_input_register_device_failed; -+ } -+ } /* if (ts->pen_support) */ -+ -+ //---set int-pin & request irq--- -+ client->irq = gpio_to_irq(ts->irq_gpio); -+ if (client->irq) { -+ NVT_LOG("int_trigger_type=%d\n", ts->int_trigger_type); -+ ts->irq_enabled = true; -+ ret = request_threaded_irq(client->irq, NULL, nvt_ts_work_func, -+ ts->int_trigger_type | IRQF_ONESHOT, NVT_SPI_NAME, ts); -+ if (ret != 0) { -+ NVT_ERR("request irq failed. ret=%d\n", ret); -+ goto err_int_request_failed; -+ } else { -+ nvt_irq_enable(false); -+ NVT_LOG("request irq %d succeed\n", client->irq); -+ } -+ } -+ -+ ts->pen_is_charge = false; -+ -+ ts->lkdown_readed =false; -+ pm_stay_awake(&client->dev); -+ -+ ts->ic_state = NVT_IC_INIT; -+ ts->dev_pm_suspend = false; -+ ts->gesture_command_delayed = -1; -+ init_completion(&ts->dev_pm_suspend_completion); -+ ts->fw_debug = false; -+ -+#ifdef CONFIG_FACTORY_BUILD -+ ts->pen_input_dev_enable = 1; -+#else -+ ts->pen_input_dev_enable = 0; -+#endif -+ -+#if BOOT_UPDATE_FIRMWARE -+ nvt_fwu_wq = alloc_workqueue("nvt_fwu_wq", WQ_UNBOUND | WQ_MEM_RECLAIM, 1); -+ if (!nvt_fwu_wq) { -+ NVT_ERR("nvt_fwu_wq create workqueue failed\n"); -+ ret = -ENOMEM; -+ goto err_create_nvt_fwu_wq_failed; -+ } -+ INIT_DELAYED_WORK(&ts->nvt_fwu_work, Boot_Update_Firmware); -+ // please make sure boot update start after display reset(RESX) sequence -+ queue_delayed_work(nvt_fwu_wq, &ts->nvt_fwu_work, msecs_to_jiffies(14000)); -+#endif -+ -+ NVT_LOG("NVT_TOUCH_ESD_PROTECT is %d\n", NVT_TOUCH_ESD_PROTECT); -+#if NVT_TOUCH_ESD_PROTECT -+ INIT_DELAYED_WORK(&nvt_esd_check_work, nvt_esd_check_func); -+ nvt_esd_check_wq = alloc_workqueue("nvt_esd_check_wq", WQ_MEM_RECLAIM, 1); -+ if (!nvt_esd_check_wq) { -+ NVT_ERR("nvt_esd_check_wq create workqueue failed\n"); -+ ret = -ENOMEM; -+ goto err_create_nvt_esd_check_wq_failed; -+ } -+ queue_delayed_work(nvt_esd_check_wq, &nvt_esd_check_work, -+ msecs_to_jiffies(NVT_TOUCH_ESD_CHECK_PERIOD)); -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+ ts->event_wq = alloc_workqueue("nvt-event-queue", -+ WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE, 1); -+ if (!ts->event_wq) { -+ NVT_ERR("Can not create work thread for suspend/resume!!"); -+ ret = -ENOMEM; -+ goto err_alloc_work_thread_failed; -+ } -+ INIT_WORK(&ts->resume_work, nvt_resume_work); -+ INIT_WORK(&ts->suspend_work, nvt_suspend_work); -+ -+#ifdef CONFIG_DRM -+ ts->drm_notif.notifier_call = nvt_drm_notifier_callback; -+ ret = mi_drm_register_client(&ts->drm_notif); -+ if(ret) { -+ NVT_ERR("register drm_notifier failed. ret=%d\n", ret); -+ goto err_register_drm_notif_failed; -+ } -+#endif -+ -+ bTouchIsAwake = 1; -+ NVT_LOG("end\n"); -+ -+ nvt_irq_enable(true); -+ -+ return 0; -+ -+#ifdef CONFIG_DRM -+ if (mi_drm_unregister_client(&ts->drm_notif)) -+ NVT_ERR("Error occurred while unregistering drm_notifier.\n"); -+err_register_drm_notif_failed: -+#endif -+ -+err_alloc_work_thread_failed: -+ -+#if NVT_TOUCH_ESD_PROTECT -+ if (nvt_esd_check_wq) { -+ cancel_delayed_work_sync(&nvt_esd_check_work); -+ destroy_workqueue(nvt_esd_check_wq); -+ nvt_esd_check_wq = NULL; -+ } -+err_create_nvt_esd_check_wq_failed: -+#endif -+#if BOOT_UPDATE_FIRMWARE -+ if (nvt_fwu_wq) { -+ cancel_delayed_work_sync(&ts->nvt_fwu_work); -+ destroy_workqueue(nvt_fwu_wq); -+ nvt_fwu_wq = NULL; -+ } -+err_create_nvt_fwu_wq_failed: -+ -+#endif -+ free_irq(client->irq, ts); -+err_int_request_failed: -+ if (ts->pen_support) { -+ input_unregister_device(ts->pen_input_dev); -+ ts->pen_input_dev = NULL; -+ } -+err_pen_input_register_device_failed: -+ if (ts->pen_support) { -+ if (ts->pen_input_dev) { -+ input_free_device(ts->pen_input_dev); -+ ts->pen_input_dev = NULL; -+ } -+ } -+err_pen_input_dev_alloc_failed: -+ input_unregister_device(ts->input_dev); -+ ts->input_dev = NULL; -+err_input_register_device_failed: -+ if (ts->input_dev) { -+ input_free_device(ts->input_dev); -+ ts->input_dev = NULL; -+ } -+err_input_dev_alloc_failed: -+err_chipvertrim_failed: -+ mutex_destroy(&ts->xbuf_lock); -+ mutex_destroy(&ts->lock); -+ nvt_gpio_deconfig(ts); -+err_gpio_config_failed: -+err_spi_setup: -+err_ckeck_full_duplex: -+ spi_set_drvdata(client, NULL); -+ if (ts->rbuf) { -+ kfree(ts->rbuf); -+ ts->rbuf = NULL; -+ } -+err_malloc_rbuf: -+ if (ts->xbuf) { -+ kfree(ts->xbuf); -+ ts->xbuf = NULL; -+ } -+err_malloc_xbuf: -+ if (ts) { -+ kfree(ts); -+ ts = NULL; -+ } -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen driver release function. -+ -+return: -+ Executive outcomes. 0---succeed. -+*******************************************************/ -+static void nvt_ts_remove(struct spi_device *client) -+{ -+ NVT_LOG("Removing driver...\n"); -+ -+#ifdef CONFIG_DRM -+ if (mi_drm_unregister_client(&ts->drm_notif)) -+ NVT_ERR("Error occurred while unregistering drm_notifier.\n"); -+#endif -+ -+#if NVT_TOUCH_ESD_PROTECT -+ if (nvt_esd_check_wq) { -+ cancel_delayed_work_sync(&nvt_esd_check_work); -+ nvt_esd_check_enable(false); -+ destroy_workqueue(nvt_esd_check_wq); -+ nvt_esd_check_wq = NULL; -+ } -+#endif -+ -+#if BOOT_UPDATE_FIRMWARE -+ if (nvt_fwu_wq) { -+ cancel_delayed_work_sync(&ts->nvt_fwu_work); -+ destroy_workqueue(nvt_fwu_wq); -+ nvt_fwu_wq = NULL; -+ } -+#endif -+ -+ nvt_irq_enable(false); -+ free_irq(client->irq, ts); -+ -+ mutex_destroy(&ts->xbuf_lock); -+ mutex_destroy(&ts->lock); -+ -+ nvt_gpio_deconfig(ts); -+ -+ if (ts->pen_support) { -+ if (ts->pen_input_dev) { -+ input_unregister_device(ts->pen_input_dev); -+ ts->pen_input_dev = NULL; -+ } -+ } -+ -+ if (ts->input_dev) { -+ input_unregister_device(ts->input_dev); -+ ts->input_dev = NULL; -+ } -+ -+ spi_set_drvdata(client, NULL); -+ -+ if (ts) { -+ kfree(ts); -+ ts = NULL; -+ } -+} -+ -+static void nvt_ts_shutdown(struct spi_device *client) -+{ -+ NVT_LOG("Shutdown driver...\n"); -+ -+ nvt_irq_enable(false); -+ -+#ifdef CONFIG_DRM -+ if (mi_drm_unregister_client(&ts->drm_notif)) -+ NVT_ERR("Error occurred while unregistering drm_notifier.\n"); -+#endif -+ -+ destroy_workqueue(ts->event_wq); -+ -+#if NVT_TOUCH_ESD_PROTECT -+ if (nvt_esd_check_wq) { -+ cancel_delayed_work_sync(&nvt_esd_check_work); -+ nvt_esd_check_enable(false); -+ destroy_workqueue(nvt_esd_check_wq); -+ nvt_esd_check_wq = NULL; -+ } -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+#if BOOT_UPDATE_FIRMWARE -+ if (nvt_fwu_wq) { -+ cancel_delayed_work_sync(&ts->nvt_fwu_work); -+ destroy_workqueue(nvt_fwu_wq); -+ nvt_fwu_wq = NULL; -+ } -+#endif -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen driver suspend function. -+ -+return: -+ Executive outcomes. 0---succeed. -+*******************************************************/ -+static int32_t nvt_ts_suspend(struct device *dev) -+{ -+ uint8_t buf[4] = {0}; -+#if MT_PROTOCOL_B -+ uint32_t i = 0; -+#endif -+ -+ if (!bTouchIsAwake) { -+ NVT_LOG("Touch is already suspend\n"); -+ return 0; -+ } -+ -+ pm_stay_awake(dev); -+ ts->ic_state = NVT_IC_SUSPEND_IN; -+ -+ if (!ts->db_wakeup) { -+ if (!ts->irq_enabled) -+ NVT_LOG("IRQ already disabled\n"); -+ else -+ nvt_irq_enable(false); -+ } -+ -+#if NVT_TOUCH_ESD_PROTECT -+ NVT_LOG("cancel delayed work sync\n"); -+ cancel_delayed_work_sync(&nvt_esd_check_work); -+ nvt_esd_check_enable(false); -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+ mutex_lock(&ts->lock); -+ -+ NVT_LOG("suspend start\n"); -+ -+ bTouchIsAwake = 0; -+ -+ if (ts->pen_input_dev_enable) { -+ NVT_LOG("if enable pen,will close it"); -+ } -+ -+ if (ts->db_wakeup) { -+ /*---write command to enter "wakeup gesture mode"---*/ -+ /*DoubleClick wakeup CMD was sent by display to meet timing*/ -+ /* -+ buf[0] = EVENT_MAP_HOST_CMD; -+ buf[1] = 0x13; -+ CTP_SPI_WRITE(ts->client, buf, 2); -+ */ -+ enable_irq_wake(ts->client->irq); -+ -+ NVT_LOG("Enabled touch wakeup gesture\n"); -+ } else { -+ /*---write command to enter "deep sleep mode"---*/ -+ buf[0] = EVENT_MAP_HOST_CMD; -+ buf[1] = 0x11; -+ CTP_SPI_WRITE(ts->client, buf, 2); -+ } -+ -+ mutex_unlock(&ts->lock); -+ -+ /* release all touches */ -+#if MT_PROTOCOL_B -+ for (i = 0; i < ts->max_touch_num; i++) { -+ input_mt_slot(ts->input_dev, i); -+ input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); -+ input_report_abs(ts->input_dev, ABS_MT_PRESSURE, 0); -+ input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, 0); -+ } -+#endif -+ input_report_key(ts->input_dev, BTN_TOUCH, 0); -+#if !MT_PROTOCOL_B -+ input_mt_sync(ts->input_dev); -+#endif -+ input_sync(ts->input_dev); -+ -+ msleep(50); -+ /* release pen event */ -+ release_pen_event(); -+ if (likely(ts->ic_state == NVT_IC_SUSPEND_IN)) -+ ts->ic_state = NVT_IC_SUSPEND_OUT; -+ else -+ NVT_ERR("IC state may error,caused by suspend/resume flow, please CHECK!!"); -+ pm_relax(dev); -+ NVT_LOG("end\n"); -+ -+ return 0; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen driver resume function. -+ -+return: -+ Executive outcomes. 0---succeed. -+*******************************************************/ -+static int32_t nvt_ts_resume(struct device *dev) -+{ -+ int ret = 0; -+ if (bTouchIsAwake) { -+ NVT_LOG("Touch is already resume\n"); -+ return 0; -+ } -+ -+ if (ts->dev_pm_suspend) -+ pm_stay_awake(dev); -+ -+ mutex_lock(&ts->lock); -+ -+ NVT_LOG("resume start\n"); -+ ts->ic_state = NVT_IC_RESUME_IN; -+ -+ // please make sure display reset(RESX) sequence and mipi dsi cmds sent before this -+#if NVT_TOUCH_SUPPORT_HW_RST -+ gpio_set_value(ts->reset_gpio, 1); -+#endif -+ ret = nvt_update_firmware(ts->fw_name); -+ if (ret) -+ NVT_ERR("download firmware failed\n"); -+ -+ nvt_check_fw_reset_state(RESET_STATE_REK); -+ -+ if (!ts->db_wakeup && !ts->irq_enabled) { -+ nvt_irq_enable(true); -+ } -+ -+#if NVT_TOUCH_ESD_PROTECT -+ nvt_esd_check_enable(false); -+ queue_delayed_work(nvt_esd_check_wq, &nvt_esd_check_work, -+ msecs_to_jiffies(NVT_TOUCH_ESD_CHECK_PERIOD)); -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+ bTouchIsAwake = 1; -+ -+ mutex_unlock(&ts->lock); -+ -+ if (likely(ts->ic_state == NVT_IC_RESUME_IN)) { -+ ts->ic_state = NVT_IC_RESUME_OUT; -+ } else { -+ NVT_ERR("IC state may error,caused by suspend/resume flow, please CHECK!!"); -+ } -+ if (ts->gesture_command_delayed >= 0){ -+ ts->db_wakeup = ts->gesture_command_delayed; -+ ts->gesture_command_delayed = -1; -+ NVT_LOG("execute delayed command, set double click wakeup %d\n", ts->db_wakeup); -+ } -+ -+ if (ts->dev_pm_suspend) -+ pm_relax(dev); -+ NVT_LOG("end\n"); -+ -+ return 0; -+} -+ -+ -+#ifdef CONFIG_DRM -+static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data) -+{ -+ int blank = *(enum drm_notifier_data *)data; -+ struct nvt_ts_data *ts_data = -+ container_of(self, struct nvt_ts_data, drm_notif); -+ -+ if (data && ts_data) { -+ if (event == MI_DRM_EARLY_EVENT_BLANK) { -+ if (blank == MI_DRM_BLANK_POWERDOWN) { -+ NVT_LOG("event=%lu, *blank=%d\n", event, blank); -+ flush_workqueue(ts_data->event_wq); -+ queue_work(ts_data->event_wq, &ts_data->suspend_work); -+ } -+ } else if (event == MI_DRM_EVENT_BLANK) { -+ if (blank == MI_DRM_BLANK_UNBLANK) { -+ NVT_LOG("event=%lu, *blank=%d\n", event, blank); -+ flush_workqueue(ts_data->event_wq); -+ queue_work(ts_data->event_wq, &ts_data->resume_work); -+ } -+ } -+ } -+ -+ return 0; -+} -+#endif -+ -+static int nvt_pm_suspend(struct device *dev) -+{ -+ if (device_may_wakeup(dev) && ts->db_wakeup) { -+ NVT_LOG("enable touch irq wake\n"); -+ enable_irq_wake(ts->client->irq); -+ } -+ ts->dev_pm_suspend = true; -+ reinit_completion(&ts->dev_pm_suspend_completion); -+ -+ return 0; -+} -+ -+static int nvt_pm_resume(struct device *dev) -+{ -+ if (device_may_wakeup(dev) && ts->db_wakeup) { -+ NVT_LOG("disable touch irq wake\n"); -+ disable_irq_wake(ts->client->irq); -+ } -+ ts->dev_pm_suspend = false; -+ complete(&ts->dev_pm_suspend_completion); -+ -+ return 0; -+} -+ -+static const struct dev_pm_ops nvt_dev_pm_ops = { -+ .suspend = nvt_pm_suspend, -+ .resume = nvt_pm_resume, -+}; -+ -+static const struct spi_device_id nvt_ts_id[] = { -+ { NVT_SPI_NAME, 0 }, -+ { } -+}; -+ -+#ifdef CONFIG_OF -+static struct of_device_id nvt_match_table[] = { -+ { .compatible = "novatek,NVT-ts-spi",}, -+ { }, -+}; -+#endif -+ -+static struct spi_driver nvt_spi_driver = { -+ .probe = nvt_ts_probe, -+ .remove = nvt_ts_remove, -+ .shutdown = nvt_ts_shutdown, -+ .id_table = nvt_ts_id, -+ .driver = { -+ .name = NVT_SPI_NAME, -+ .owner = THIS_MODULE, -+#ifdef CONFIG_PM -+ .pm = &nvt_dev_pm_ops, -+#endif -+#ifdef CONFIG_OF -+ .of_match_table = nvt_match_table, -+#endif -+ }, -+}; -+ -+module_spi_driver(nvt_spi_driver); -+ -+MODULE_DESCRIPTION("Novatek Touchscreen Driver"); -+MODULE_LICENSE("GPL"); -diff --git a/drivers/input/touchscreen/nt36523/nt36xxx.h b/drivers/input/touchscreen/nt36523/nt36xxx.h -new file mode 100644 -index 000000000000..2ec9ccb3b522 ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/nt36xxx.h -@@ -0,0 +1,240 @@ -+/* -+ * Copyright (C) 2010 - 2018 Novatek, Inc. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * $Revision: 69262 $ -+ * $Date: 2020-09-23 15:07:14 +0800 (週三, 23 九月 2020) $ -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ * more details. -+ * -+ */ -+#ifndef _LINUX_NVT_TOUCH_H -+#define _LINUX_NVT_TOUCH_H -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "nt36xxx_mem_map.h" -+ -+#define NVT_DEBUG 1 -+ -+//---GPIO number--- -+#define NVTTOUCH_RST_PIN 980 -+#define NVTTOUCH_INT_PIN 943 -+ -+#define PINCTRL_STATE_ACTIVE "pmx_ts_active" -+#define PINCTRL_STATE_SUSPEND "pmx_ts_suspend" -+ -+//---INT trigger mode--- -+//#define IRQ_TYPE_EDGE_RISING 1 -+//#define IRQ_TYPE_EDGE_FALLING 2 -+#define INT_TRIGGER_TYPE IRQ_TYPE_EDGE_RISING -+ -+ -+//---SPI driver info.--- -+#define NVT_SPI_NAME "NVT-ts" -+ -+#if NVT_DEBUG -+#define NVT_LOG(fmt, args...) pr_err("[%s] %s %d: " fmt, NVT_SPI_NAME, __func__, __LINE__, ##args) -+#else -+#define NVT_LOG(fmt, args...) pr_info("[%s] %s %d: " fmt, NVT_SPI_NAME, __func__, __LINE__, ##args) -+#endif -+#define NVT_ERR(fmt, args...) pr_err("[%s] %s %d: " fmt, NVT_SPI_NAME, __func__, __LINE__, ##args) -+ -+//---Input device info.--- -+#define NVT_TS_NAME "NVTCapacitiveTouchScreen" -+#define NVT_PEN_NAME "NVTCapacitivePen" -+ -+//---Touch info.--- -+#define TOUCH_DEFAULT_MAX_WIDTH 1600 -+#define TOUCH_DEFAULT_MAX_HEIGHT 2560 -+#define TOUCH_MAX_FINGER_NUM 10 -+#define TOUCH_KEY_NUM 0 -+#if TOUCH_KEY_NUM > 0 -+extern const uint16_t touch_key_array[TOUCH_KEY_NUM]; -+#endif -+#define TOUCH_FORCE_NUM 1000 -+//---for Pen--- -+#define PEN_PRESSURE_MAX (4095) -+#define PEN_DISTANCE_MAX (1) -+#define PEN_TILT_MIN (-60) -+#define PEN_TILT_MAX (60) -+ -+/* Enable only when module have tp reset pin and connected to host */ -+#define NVT_TOUCH_SUPPORT_HW_RST 0 -+ -+//---Customerized func.--- -+#define NVT_TOUCH_MP 0 -+#define NVT_TOUCH_MP_SETTING_CRITERIA_FROM_CSV 0 -+#define MT_PROTOCOL_B 1 -+#define FUNCPAGE_PALM 4 -+#define PACKET_PALM_ON 3 -+#define PACKET_PALM_OFF 4 -+ -+#define BOOT_UPDATE_FIRMWARE 1 -+#define DEFAULT_BOOT_UPDATE_FIRMWARE_NAME "novatek/nt36523.bin" -+#define DEFAULT_MP_UPDATE_FIRMWARE_NAME "novatek_ts_mp.bin" -+ -+//---ESD Protect.--- -+#define NVT_TOUCH_ESD_PROTECT 1 -+#define NVT_TOUCH_ESD_CHECK_PERIOD 1500 /* ms */ -+#define NVT_TOUCH_WDT_RECOVERY 1 -+ -+enum nvt_ic_state { -+ NVT_IC_SUSPEND_IN, -+ NVT_IC_SUSPEND_OUT, -+ NVT_IC_RESUME_IN, -+ NVT_IC_RESUME_OUT, -+ NVT_IC_INIT, -+}; -+ -+struct nvt_config_info { -+ u8 tp_vendor; -+ u8 tp_color; -+ u8 display_maker; -+ u8 glass_vendor; -+ const char *nvt_fw_name; -+ const char *nvt_mp_name; -+ const char *nvt_limit_name; -+}; -+ -+struct nvt_ts_data { -+ struct spi_device *client; -+ struct input_dev *input_dev; -+ struct delayed_work nvt_fwu_work; -+ struct work_struct switch_mode_work; -+ struct work_struct pen_charge_state_change_work; -+ bool pen_is_charge; -+ struct notifier_block pen_charge_state_notifier; -+ uint16_t addr; -+ int8_t phys[32]; -+#if defined(CONFIG_FB) -+#ifdef CONFIG_DRM -+ struct notifier_block drm_notif; -+#else -+ struct notifier_block fb_notif; -+#endif -+#endif -+ uint32_t config_array_size; -+ struct nvt_config_info *config_array; -+ const char *fw_name; -+ bool lkdown_readed; -+ uint8_t fw_ver; -+ uint8_t x_num; -+ uint8_t y_num; -+ int ic_state; -+ uint16_t abs_x_max; -+ uint16_t abs_y_max; -+ uint8_t max_touch_num; -+ uint8_t max_button_num; -+ uint32_t int_trigger_type; -+ int32_t irq_gpio; -+ uint32_t irq_flags; -+ int32_t reset_gpio; -+ uint32_t reset_flags; -+ struct mutex lock; -+ const struct nvt_ts_mem_map *mmap; -+ uint8_t carrier_system; -+ uint8_t hw_crc; -+ uint16_t nvt_pid; -+ uint8_t *rbuf; -+ uint8_t *xbuf; -+ struct mutex xbuf_lock; -+ bool irq_enabled; -+ uint8_t cascade; -+ bool pen_support; -+ bool wgp_stylus; -+ uint8_t x_gang_num; -+ uint8_t y_gang_num; -+ struct input_dev *pen_input_dev; -+ bool pen_input_dev_enable; -+ int8_t pen_phys[32]; -+ struct workqueue_struct *event_wq; -+ struct work_struct suspend_work; -+ struct work_struct resume_work; -+ int result_type; -+ int panel_index; -+ uint32_t spi_max_freq; -+ int db_wakeup; -+ uint8_t debug_flag; -+ bool fw_debug; -+ bool dev_pm_suspend; -+ struct completion dev_pm_suspend_completion; -+ bool palm_sensor_switch; -+ int gesture_command_delayed; -+ struct pinctrl *ts_pinctrl; -+ struct pinctrl_state *pinctrl_state_active; -+ struct pinctrl_state *pinctrl_state_suspend; -+}; -+ -+typedef enum { -+ RESET_STATE_INIT = 0xA0,// IC reset -+ RESET_STATE_REK, // ReK baseline -+ RESET_STATE_REK_FINISH, // baseline is ready -+ RESET_STATE_NORMAL_RUN, // normal run -+ RESET_STATE_MAX = 0xAF -+} RST_COMPLETE_STATE; -+ -+typedef enum { -+ EVENT_MAP_HOST_CMD = 0x50, -+ EVENT_MAP_HANDSHAKING_or_SUB_CMD_BYTE = 0x51, -+ EVENT_MAP_RESET_COMPLETE = 0x60, -+ EVENT_MAP_FWINFO = 0x78, -+ EVENT_MAP_PROJECTID = 0x9A, -+} SPI_EVENT_MAP; -+ -+//---SPI READ/WRITE--- -+#define SPI_WRITE_MASK(a) (a | 0x80) -+#define SPI_READ_MASK(a) (a & 0x7F) -+ -+#define DUMMY_BYTES (1) -+#define NVT_TRANSFER_LEN (63*1024) -+#define NVT_READ_LEN (2*1024) -+ -+typedef enum { -+ NVTWRITE = 0, -+ NVTREAD = 1 -+} NVT_SPI_RW; -+ -+//---extern structures--- -+extern struct nvt_ts_data *ts; -+ -+//---extern functions--- -+int32_t CTP_SPI_READ(struct spi_device *client, uint8_t *buf, uint16_t len); -+int32_t CTP_SPI_WRITE(struct spi_device *client, uint8_t *buf, uint16_t len); -+void nvt_bootloader_reset(void); -+void nvt_eng_reset(void); -+void nvt_sw_reset(void); -+void nvt_sw_reset_idle(void); -+void nvt_boot_ready(void); -+void nvt_bld_crc_enable(void); -+void nvt_fw_crc_enable(void); -+void nvt_tx_auto_copy_mode(void); -+void nvt_set_dbgfw_status(bool enable); -+void nvt_match_fw(void); -+int32_t nvt_update_firmware(const char *firmware_name); -+int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state); -+int32_t nvt_get_fw_info(void); -+int32_t nvt_clear_fw_status(void); -+int32_t nvt_check_fw_status(void); -+int32_t nvt_check_spi_dma_tx_info(void); -+int32_t nvt_set_page(uint32_t addr); -+int32_t nvt_write_addr(uint32_t addr, uint8_t data); -+bool nvt_get_dbgfw_status(void); -+int32_t nvt_set_pocket_palm_switch(uint8_t pocket_palm_switch); -+#if NVT_TOUCH_ESD_PROTECT -+extern void nvt_esd_check_enable(uint8_t enable); -+#endif /* #if NVT_TOUCH_ESD_PROTECT */ -+ -+#endif /* _LINUX_NVT_TOUCH_H */ -diff --git a/drivers/input/touchscreen/nt36523/nt36xxx_fw_update.c b/drivers/input/touchscreen/nt36523/nt36xxx_fw_update.c -new file mode 100644 -index 000000000000..4f383dac2c3c ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/nt36xxx_fw_update.c -@@ -0,0 +1,857 @@ -+/* -+ * Copyright (C) 2010 - 2018 Novatek, Inc. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * $Revision: 68983 $ -+ * $Date: 2020-09-17 09:43:23 +0800 (週四, 17 九月 2020) $ -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ * more details. -+ * -+ */ -+ -+#include -+#include -+ -+#include "nt36xxx.h" -+ -+#if BOOT_UPDATE_FIRMWARE -+ -+#define SIZE_4KB 4096 -+#define FLASH_SECTOR_SIZE SIZE_4KB -+#define FW_BIN_VER_OFFSET (fw_need_write_size - SIZE_4KB) -+#define FW_BIN_VER_BAR_OFFSET (FW_BIN_VER_OFFSET + 1) -+#define NVT_FLASH_END_FLAG_LEN 3 -+#define NVT_FLASH_END_FLAG_ADDR (fw_need_write_size - NVT_FLASH_END_FLAG_LEN) -+ -+static ktime_t start, end; -+const struct firmware *fw_entry = NULL; -+static size_t fw_need_write_size = 0; -+static uint8_t *fwbuf = NULL; -+ -+struct nvt_ts_bin_map { -+ char name[12]; -+ uint32_t BIN_addr; -+ uint32_t SRAM_addr; -+ uint32_t size; -+ uint32_t crc; -+}; -+ -+static struct nvt_ts_bin_map *bin_map; -+ -+/******************************************************* -+Description: -+ Novatek touchscreen init variable and allocate buffer -+for download firmware function. -+ -+return: -+ n.a. -+*******************************************************/ -+static int32_t nvt_download_init(void) -+{ -+ /* allocate buffer for transfer firmware */ -+ //NVT_LOG("NVT_TRANSFER_LEN = 0x%06X\n", NVT_TRANSFER_LEN); -+ -+ if (fwbuf == NULL) { -+ fwbuf = (uint8_t *)kzalloc((NVT_TRANSFER_LEN + 1 + DUMMY_BYTES), GFP_KERNEL); -+ if(fwbuf == NULL) { -+ NVT_ERR("kzalloc for fwbuf failed!\n"); -+ return -ENOMEM; -+ } -+ } -+ -+ return 0; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen checksum function. Calculate bin -+file checksum for comparison. -+ -+return: -+ n.a. -+*******************************************************/ -+static uint32_t CheckSum(const u8 *data, size_t len) -+{ -+ uint32_t i = 0; -+ uint32_t checksum = 0; -+ -+ for (i = 0 ; i < len+1 ; i++) -+ checksum += data[i]; -+ -+ checksum += len; -+ checksum = ~checksum +1; -+ -+ return checksum; -+} -+ -+static uint32_t byte_to_word(const uint8_t *data) -+{ -+ return data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen parsing bin header function. -+ -+return: -+ n.a. -+*******************************************************/ -+static uint32_t partition = 0; -+static uint8_t ilm_dlm_num = 2; -+static uint8_t cascade_2nd_header_info = 0; -+static int32_t nvt_bin_header_parser(const u8 *fwdata, size_t fwsize) -+{ -+ uint32_t list = 0; -+ uint32_t pos = 0x00; -+ uint32_t end = 0x00; -+ uint8_t info_sec_num = 0; -+ uint8_t ovly_sec_num = 0; -+ uint8_t ovly_info = 0; -+ uint8_t find_bin_header = 0; -+ -+ /* Find the header size */ -+ end = fwdata[0] + (fwdata[1] << 8) + (fwdata[2] << 16) + (fwdata[3] << 24); -+ -+ /* check cascade next header */ -+ cascade_2nd_header_info = (fwdata[0x20] & 0x02) >> 1; -+ NVT_LOG("cascade_2nd_header_info = %d\n", cascade_2nd_header_info); -+ -+ if (cascade_2nd_header_info) { -+ pos = 0x30; // info section start at 0x30 offset -+ while (pos < (end / 2)) { -+ info_sec_num ++; -+ pos += 0x10; /* each header info is 16 bytes */ -+ } -+ -+ info_sec_num = info_sec_num + 1; //next header section -+ } else { -+ pos = 0x30; // info section start at 0x30 offset -+ while (pos < end) { -+ info_sec_num ++; -+ pos += 0x10; /* each header info is 16 bytes */ -+ } -+ } -+ -+ /* -+ * Find the DLM OVLY section -+ * [0:3] Overlay Section Number -+ * [4] Overlay Info -+ */ -+ ovly_info = (fwdata[0x28] & 0x10) >> 4; -+ ovly_sec_num = (ovly_info) ? (fwdata[0x28] & 0x0F) : 0; -+ -+ /* -+ * calculate all partition number -+ * ilm_dlm_num (ILM & DLM) + ovly_sec_num + info_sec_num -+ */ -+ partition = ilm_dlm_num + ovly_sec_num + info_sec_num; -+ NVT_LOG("ovly_info = %d, ilm_dlm_num = %d, ovly_sec_num = %d, info_sec_num = %d, partition = %d\n", -+ ovly_info, ilm_dlm_num, ovly_sec_num, info_sec_num, partition); -+ -+ /* allocated memory for header info */ -+ bin_map = (struct nvt_ts_bin_map *)kzalloc((partition+1) * sizeof(struct nvt_ts_bin_map), GFP_KERNEL); -+ if(bin_map == NULL) { -+ NVT_ERR("kzalloc for bin_map failed!\n"); -+ return -ENOMEM; -+ } -+ -+ for (list = 0; list < partition; list++) { -+ /* -+ * [1] parsing ILM & DLM header info -+ * BIN_addr : SRAM_addr : size (12-bytes) -+ * crc located at 0x18 & 0x1C -+ */ -+ if (list < ilm_dlm_num) { -+ bin_map[list].BIN_addr = byte_to_word(&fwdata[0 + list*12]); -+ bin_map[list].SRAM_addr = byte_to_word(&fwdata[4 + list*12]); -+ bin_map[list].size = byte_to_word(&fwdata[8 + list*12]); -+ if (ts->hw_crc) -+ bin_map[list].crc = byte_to_word(&fwdata[0x18 + list*4]); -+ else { //ts->hw_crc -+ if ((bin_map[list].BIN_addr + bin_map[list].size) < fwsize) -+ bin_map[list].crc = CheckSum(&fwdata[bin_map[list].BIN_addr], bin_map[list].size); -+ else { -+ NVT_ERR("access range (0x%08X to 0x%08X) is larger than bin size!\n", -+ bin_map[list].BIN_addr, bin_map[list].BIN_addr + bin_map[list].size); -+ return -EINVAL; -+ } -+ } //ts->hw_crc -+ if (list == 0) -+ sprintf(bin_map[list].name, "ILM"); -+ else if (list == 1) -+ sprintf(bin_map[list].name, "DLM"); -+ } -+ -+ /* -+ * [2] parsing others header info -+ * SRAM_addr : size : BIN_addr : crc (16-bytes) -+ */ -+ if ((list >= ilm_dlm_num) && (list < (ilm_dlm_num + info_sec_num))) { -+ if (find_bin_header == 0) { -+ /* others partition located at 0x30 offset */ -+ pos = 0x30 + (0x10 * (list - ilm_dlm_num)); -+ } else if (find_bin_header && cascade_2nd_header_info) { -+ /* cascade 2nd header info */ -+ pos = end - 0x10; -+ } -+ -+ bin_map[list].SRAM_addr = byte_to_word(&fwdata[pos]); -+ bin_map[list].size = byte_to_word(&fwdata[pos+4]); -+ bin_map[list].BIN_addr = byte_to_word(&fwdata[pos+8]); -+ if (ts->hw_crc) -+ bin_map[list].crc = byte_to_word(&fwdata[pos+12]); -+ else { //ts->hw_crc -+ if ((bin_map[list].BIN_addr + bin_map[list].size) < fwsize) -+ bin_map[list].crc = CheckSum(&fwdata[bin_map[list].BIN_addr], bin_map[list].size); -+ else { -+ NVT_ERR("access range (0x%08X to 0x%08X) is larger than bin size!\n", -+ bin_map[list].BIN_addr, bin_map[list].BIN_addr + bin_map[list].size); -+ return -EINVAL; -+ } -+ } //ts->hw_crc -+ /* detect header end to protect parser function */ -+ if ((bin_map[list].BIN_addr < end) && (bin_map[list].size != 0)) { -+ sprintf(bin_map[list].name, "Header"); -+ find_bin_header = 1; -+ } else { -+ sprintf(bin_map[list].name, "Info-%d", (list - ilm_dlm_num)); -+ } -+ } -+ -+ /* -+ * [3] parsing overlay section header info -+ * SRAM_addr : size : BIN_addr : crc (16-bytes) -+ */ -+ if (list >= (ilm_dlm_num + info_sec_num)) { -+ /* overlay info located at DLM (list = 1) start addr */ -+ pos = bin_map[1].BIN_addr + (0x10 * (list- ilm_dlm_num - info_sec_num)); -+ -+ bin_map[list].SRAM_addr = byte_to_word(&fwdata[pos]); -+ bin_map[list].size = byte_to_word(&fwdata[pos+4]); -+ bin_map[list].BIN_addr = byte_to_word(&fwdata[pos+8]); -+ if (ts->hw_crc) -+ bin_map[list].crc = byte_to_word(&fwdata[pos+12]); -+ else { //ts->hw_crc -+ if ((bin_map[list].BIN_addr + bin_map[list].size) < fwsize) -+ bin_map[list].crc = CheckSum(&fwdata[bin_map[list].BIN_addr], bin_map[list].size); -+ else { -+ NVT_ERR("access range (0x%08X to 0x%08X) is larger than bin size!\n", -+ bin_map[list].BIN_addr, bin_map[list].BIN_addr + bin_map[list].size); -+ return -EINVAL; -+ } -+ } //ts->hw_crc -+ sprintf(bin_map[list].name, "Overlay-%d", (list- ilm_dlm_num - info_sec_num)); -+ } -+ -+ /* BIN size error detect */ -+ if ((bin_map[list].BIN_addr + bin_map[list].size) > fwsize) { -+ NVT_ERR("access range (0x%08X to 0x%08X) is larger than bin size!\n", -+ bin_map[list].BIN_addr, bin_map[list].BIN_addr + bin_map[list].size); -+ return -EINVAL; -+ } -+ -+// NVT_LOG("[%d][%s] SRAM (0x%08X), SIZE (0x%08X), BIN (0x%08X), CRC (0x%08X)\n", -+// list, bin_map[list].name, -+// bin_map[list].SRAM_addr, bin_map[list].size, bin_map[list].BIN_addr, bin_map[list].crc); -+ } -+ -+ return 0; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen release update firmware function. -+ -+return: -+ n.a. -+*******************************************************/ -+static void update_firmware_release(void) -+{ -+ if (fw_entry) { -+ release_firmware(fw_entry); -+ } -+ -+ fw_entry = NULL; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen request update firmware function. -+ -+return: -+ Executive outcomes. 0---succeed. -1,-22---failed. -+*******************************************************/ -+static int32_t update_firmware_request(const char *filename) -+{ -+ uint8_t retry = 0; -+ int32_t ret = 0; -+ -+ if (NULL == filename) { -+ return -ENOENT; -+ } -+ -+ while (1) { -+ NVT_LOG("filename is %s\n", filename); -+ -+ ret = request_firmware(&fw_entry, filename, &ts->client->dev); -+ if (ret) { -+ NVT_ERR("firmware load failed, ret=%d\n", ret); -+ goto request_fail; -+ } -+ -+ fw_need_write_size = fw_entry->size; -+ -+ // check if FW version add FW version bar equals 0xFF -+ if (*(fw_entry->data + FW_BIN_VER_OFFSET) + *(fw_entry->data + FW_BIN_VER_BAR_OFFSET) != 0xFF) { -+ NVT_ERR("bin file FW_VER + FW_VER_BAR should be 0xFF!\n"); -+ NVT_ERR("FW_VER=0x%02X, FW_VER_BAR=0x%02X\n", *(fw_entry->data+FW_BIN_VER_OFFSET), *(fw_entry->data+FW_BIN_VER_BAR_OFFSET)); -+ ret = -ENOEXEC; -+ goto invalid; -+ } -+ -+ /* BIN Header Parser */ -+ ret = nvt_bin_header_parser(fw_entry->data, fw_entry->size); -+ if (ret) { -+ NVT_ERR("bin header parser failed\n"); -+ goto invalid; -+ } else { -+ break; -+ } -+ -+invalid: -+ update_firmware_release(); -+ if (!IS_ERR_OR_NULL(bin_map)) { -+ kfree(bin_map); -+ bin_map = NULL; -+ } -+ -+request_fail: -+ retry++; -+ if(unlikely(retry > 2)) { -+ NVT_ERR("error, retry=%d\n", retry); -+ break; -+ } -+ } -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen write data to sram function. -+ -+- fwdata : The buffer is written -+- SRAM_addr: The sram destination address -+- size : Number of data bytes in @fwdata being written -+- BIN_addr : The transferred data offset of @fwdata -+ -+return: -+ Executive outcomes. 0---succeed. else---fail. -+*******************************************************/ -+static int32_t nvt_write_sram(const u8 *fwdata, -+ uint32_t SRAM_addr, uint32_t size, uint32_t BIN_addr) -+{ -+ int32_t ret = 0; -+ uint32_t i = 0; -+ uint16_t len = 0; -+ int32_t count = 0; -+ -+ if (size % NVT_TRANSFER_LEN) -+ count = (size / NVT_TRANSFER_LEN) + 1; -+ else -+ count = (size / NVT_TRANSFER_LEN); -+ -+ for (i = 0 ; i < count ; i++) { -+ len = (size < NVT_TRANSFER_LEN) ? size : NVT_TRANSFER_LEN; -+ -+ //---set xdata index to start address of SRAM--- -+ ret = nvt_set_page(SRAM_addr); -+ if (ret) { -+ NVT_ERR("set page failed, ret = %d\n", ret); -+ return ret; -+ } -+ -+ //---write data into SRAM--- -+ fwbuf[0] = SRAM_addr & 0x7F; //offset -+ memcpy(fwbuf+1, &fwdata[BIN_addr], len); //payload -+ ret = CTP_SPI_WRITE(ts->client, fwbuf, len+1); -+ if (ret) { -+ NVT_ERR("write to sram failed, ret = %d\n", ret); -+ return ret; -+ } -+ -+ SRAM_addr += NVT_TRANSFER_LEN; -+ BIN_addr += NVT_TRANSFER_LEN; -+ size -= NVT_TRANSFER_LEN; -+ } -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen nvt_write_firmware function to write -+firmware into each partition. -+ -+return: -+ n.a. -+*******************************************************/ -+static int32_t nvt_write_firmware(const u8 *fwdata, size_t fwsize) -+{ -+ uint32_t list = 0; -+ char *name; -+ uint32_t BIN_addr, SRAM_addr, size; -+ int32_t ret = 0; -+ -+ memset(fwbuf, 0, (NVT_TRANSFER_LEN+1)); -+ -+ for (list = 0; list < partition; list++) { -+ /* initialize variable */ -+ SRAM_addr = bin_map[list].SRAM_addr; -+ size = bin_map[list].size; -+ BIN_addr = bin_map[list].BIN_addr; -+ name = bin_map[list].name; -+ -+// NVT_LOG("[%d][%s] SRAM (0x%08X), SIZE (0x%08X), BIN (0x%08X)\n", -+// list, name, SRAM_addr, size, BIN_addr); -+ -+ /* Check data size */ -+ if ((BIN_addr + size) > fwsize) { -+ NVT_ERR("access range (0x%08X to 0x%08X) is larger than bin size!\n", -+ BIN_addr, BIN_addr + size); -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ /* ignore reserved partition (Reserved Partition size is zero) */ -+ if (!size) -+ continue; -+ else -+ size = size +1; -+ -+ /* write data to SRAM */ -+ ret = nvt_write_sram(fwdata, SRAM_addr, size, BIN_addr); -+ if (ret) { -+ NVT_ERR("sram program failed, ret = %d\n", ret); -+ goto out; -+ } -+ } -+ -+out: -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen check checksum function. -+This function will compare file checksum and fw checksum. -+ -+return: -+ n.a. -+*******************************************************/ -+static int32_t nvt_check_fw_checksum(void) -+{ -+ uint32_t fw_checksum = 0; -+ uint32_t len = partition*4; -+ uint32_t list = 0; -+ int32_t ret = 0; -+ -+ memset(fwbuf, 0, (len+1)); -+ -+ //---set xdata index to checksum--- -+ nvt_set_page(ts->mmap->R_ILM_CHECKSUM_ADDR); -+ -+ /* read checksum */ -+ fwbuf[0] = (ts->mmap->R_ILM_CHECKSUM_ADDR) & 0x7F; -+ ret = CTP_SPI_READ(ts->client, fwbuf, len+1); -+ if (ret) { -+ NVT_ERR("Read fw checksum failed\n"); -+ return ret; -+ } -+ -+ /* -+ * Compare each checksum from fw -+ * ILM + DLM + Overlay + Info -+ * ilm_dlm_num (ILM & DLM) + ovly_sec_num + info_sec_num -+ */ -+ for (list = 0; list < partition; list++) { -+ fw_checksum = byte_to_word(&fwbuf[1+list*4]); -+ -+ /* ignore reserved partition (Reserved Partition size is zero) */ -+ if(!bin_map[list].size) -+ continue; -+ -+ if (bin_map[list].crc != fw_checksum) { -+ NVT_ERR("[%d] BIN_checksum=0x%08X, FW_checksum=0x%08X\n", -+ list, bin_map[list].crc, fw_checksum); -+ ret = -EIO; -+ } -+ } -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen set bootload crc reg bank function. -+This function will set hw crc reg before enable crc function. -+ -+return: -+ n.a. -+*******************************************************/ -+static void nvt_set_bld_crc_bank(uint32_t DES_ADDR, uint32_t SRAM_ADDR, -+ uint32_t LENGTH_ADDR, uint32_t size, -+ uint32_t G_CHECKSUM_ADDR, uint32_t crc) -+{ -+ /* write destination address */ -+ nvt_set_page(DES_ADDR); -+ fwbuf[0] = DES_ADDR & 0x7F; -+ fwbuf[1] = (SRAM_ADDR) & 0xFF; -+ fwbuf[2] = (SRAM_ADDR >> 8) & 0xFF; -+ fwbuf[3] = (SRAM_ADDR >> 16) & 0xFF; -+ CTP_SPI_WRITE(ts->client, fwbuf, 4); -+ -+ /* write length */ -+ //nvt_set_page(LENGTH_ADDR); -+ fwbuf[0] = LENGTH_ADDR & 0x7F; -+ fwbuf[1] = (size) & 0xFF; -+ fwbuf[2] = (size >> 8) & 0xFF; -+ fwbuf[3] = (size >> 16) & 0x01; -+ if (ts->hw_crc == 1) { -+ CTP_SPI_WRITE(ts->client, fwbuf, 3); -+ } else if (ts->hw_crc > 1) { -+ CTP_SPI_WRITE(ts->client, fwbuf, 4); -+ } -+ -+ /* write golden dlm checksum */ -+ //nvt_set_page(G_CHECKSUM_ADDR); -+ fwbuf[0] = G_CHECKSUM_ADDR & 0x7F; -+ fwbuf[1] = (crc) & 0xFF; -+ fwbuf[2] = (crc >> 8) & 0xFF; -+ fwbuf[3] = (crc >> 16) & 0xFF; -+ fwbuf[4] = (crc >> 24) & 0xFF; -+ CTP_SPI_WRITE(ts->client, fwbuf, 5); -+ -+ return; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen set BLD hw crc function. -+This function will set ILM and DLM crc information to register. -+ -+return: -+ n.a. -+*******************************************************/ -+static void nvt_set_bld_hw_crc(void) -+{ -+ /* [0] ILM */ -+ /* write register bank */ -+ nvt_set_bld_crc_bank(ts->mmap->ILM_DES_ADDR, bin_map[0].SRAM_addr, -+ ts->mmap->ILM_LENGTH_ADDR, bin_map[0].size, -+ ts->mmap->G_ILM_CHECKSUM_ADDR, bin_map[0].crc); -+ -+ /* [1] DLM */ -+ /* write register bank */ -+ nvt_set_bld_crc_bank(ts->mmap->DLM_DES_ADDR, bin_map[1].SRAM_addr, -+ ts->mmap->DLM_LENGTH_ADDR, bin_map[1].size, -+ ts->mmap->G_DLM_CHECKSUM_ADDR, bin_map[1].crc); -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen read BLD hw crc info function. -+This function will check crc results from register. -+ -+return: -+ n.a. -+*******************************************************/ -+static void nvt_read_bld_hw_crc(void) -+{ -+ uint8_t buf[8] = {0}; -+ uint32_t g_crc = 0, r_crc = 0; -+ -+ /* CRC Flag */ -+ nvt_set_page(ts->mmap->BLD_ILM_DLM_CRC_ADDR); -+ buf[0] = ts->mmap->BLD_ILM_DLM_CRC_ADDR & 0x7F; -+ buf[1] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 2); -+ NVT_ERR("crc_done = %d, ilm_crc_flag = %d, dlm_crc_flag = %d\n", -+ (buf[1] >> 2) & 0x01, (buf[1] >> 0) & 0x01, (buf[1] >> 1) & 0x01); -+ -+ /* ILM CRC */ -+ nvt_set_page(ts->mmap->G_ILM_CHECKSUM_ADDR); -+ buf[0] = ts->mmap->G_ILM_CHECKSUM_ADDR & 0x7F; -+ buf[1] = 0x00; -+ buf[2] = 0x00; -+ buf[3] = 0x00; -+ buf[4] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 5); -+ g_crc = buf[1] | (buf[2] << 8) | (buf[3] << 16) | (buf[4] << 24); -+ -+ nvt_set_page(ts->mmap->R_ILM_CHECKSUM_ADDR); -+ buf[0] = ts->mmap->R_ILM_CHECKSUM_ADDR & 0x7F; -+ buf[1] = 0x00; -+ buf[2] = 0x00; -+ buf[3] = 0x00; -+ buf[4] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 5); -+ r_crc = buf[1] | (buf[2] << 8) | (buf[3] << 16) | (buf[4] << 24); -+ -+ NVT_ERR("ilm: bin crc = 0x%08X, golden = 0x%08X, result = 0x%08X\n", -+ bin_map[0].crc, g_crc, r_crc); -+ -+ /* DLM CRC */ -+ nvt_set_page(ts->mmap->G_DLM_CHECKSUM_ADDR); -+ buf[0] = ts->mmap->G_DLM_CHECKSUM_ADDR & 0x7F; -+ buf[1] = 0x00; -+ buf[2] = 0x00; -+ buf[3] = 0x00; -+ buf[4] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 5); -+ g_crc = buf[1] | (buf[2] << 8) | (buf[3] << 16) | (buf[4] << 24); -+ -+ nvt_set_page(ts->mmap->R_DLM_CHECKSUM_ADDR); -+ buf[0] = ts->mmap->R_DLM_CHECKSUM_ADDR & 0x7F; -+ buf[1] = 0x00; -+ buf[2] = 0x00; -+ buf[3] = 0x00; -+ buf[4] = 0x00; -+ CTP_SPI_READ(ts->client, buf, 5); -+ r_crc = buf[1] | (buf[2] << 8) | (buf[3] << 16) | (buf[4] << 24); -+ -+ NVT_ERR("dlm: bin crc = 0x%08X, golden = 0x%08X, result = 0x%08X\n", -+ bin_map[1].crc, g_crc, r_crc); -+ -+ return; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen Download_Firmware with HW CRC -+function. It's complete download firmware flow. -+ -+return: -+ Executive outcomes. 0---succeed. else---fail. -+*******************************************************/ -+static int32_t nvt_download_firmware_hw_crc(void) -+{ -+ uint8_t retry = 0; -+ int32_t ret = 0; -+ -+ start = ktime_get(); -+ -+ while (1) { -+ /* bootloader reset to reset MCU */ -+ nvt_bootloader_reset(); -+ -+ /* set ilm & dlm reg bank */ -+ nvt_set_bld_hw_crc(); -+ -+ /* Start to write firmware process */ -+ if (cascade_2nd_header_info) { -+ /* for cascade */ -+ nvt_tx_auto_copy_mode(); -+ -+ ret = nvt_write_firmware(fw_entry->data, fw_entry->size); -+ if (ret) { -+ NVT_ERR("Write_Firmware failed. (%d)\n", ret); -+ goto fail; -+ } -+ -+ ret = nvt_check_spi_dma_tx_info(); -+ if (ret) { -+ NVT_ERR("spi dma tx info failed. (%d)\n", ret); -+ goto fail; -+ } -+ } else { -+ ret = nvt_write_firmware(fw_entry->data, fw_entry->size); -+ if (ret) { -+ NVT_ERR("Write_Firmware failed. (%d)\n", ret); -+ goto fail; -+ } -+ } -+ -+ /* enable hw bld crc function */ -+ nvt_bld_crc_enable(); -+ -+ /* clear fw reset status & enable fw crc check */ -+ nvt_fw_crc_enable(); -+ -+ /* Set Boot Ready Bit */ -+ nvt_boot_ready(); -+ -+ ret = nvt_check_fw_reset_state(RESET_STATE_INIT); -+ if (ret) { -+ NVT_ERR("nvt_check_fw_reset_state failed. (%d)\n", ret); -+ goto fail; -+ } else { -+ break; -+ } -+ -+fail: -+ retry++; -+ if(unlikely(retry > 2)) { -+ NVT_ERR("error, retry=%d\n", retry); -+ nvt_read_bld_hw_crc(); -+ break; -+ } -+ } -+ -+ end = ktime_get(); -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen Download_Firmware function. It's -+complete download firmware flow. -+ -+return: -+ n.a. -+*******************************************************/ -+static int32_t nvt_download_firmware(void) -+{ -+ uint8_t retry = 0; -+ int32_t ret = 0; -+ -+ start = ktime_get(); -+ -+ while (1) { -+ /* -+ * Send eng reset cmd before download FW -+ * Keep TP_RESX low when send eng reset cmd -+ */ -+#if NVT_TOUCH_SUPPORT_HW_RST -+ gpio_set_value(ts->reset_gpio, 0); -+ mdelay(1); //wait 1ms -+#endif -+ nvt_eng_reset(); -+#if NVT_TOUCH_SUPPORT_HW_RST -+ gpio_set_value(ts->reset_gpio, 1); -+ mdelay(10); //wait tRT2BRST after TP_RST -+#endif -+ nvt_bootloader_reset(); -+ -+ /* clear fw reset status */ -+ nvt_write_addr(ts->mmap->EVENT_BUF_ADDR | EVENT_MAP_RESET_COMPLETE, 0x00); -+ -+ /* Start to write firmware process */ -+ ret = nvt_write_firmware(fw_entry->data, fw_entry->size); -+ if (ret) { -+ NVT_ERR("Write_Firmware failed. (%d)\n", ret); -+ goto fail; -+ } -+ -+ /* Set Boot Ready Bit */ -+ nvt_boot_ready(); -+ -+ ret = nvt_check_fw_reset_state(RESET_STATE_INIT); -+ if (ret) { -+ NVT_ERR("nvt_check_fw_reset_state failed. (%d)\n", ret); -+ goto fail; -+ } -+ -+ /* check fw checksum result */ -+ ret = nvt_check_fw_checksum(); -+ if (ret) { -+ NVT_ERR("firmware checksum not match, retry=%d\n", retry); -+ goto fail; -+ } else { -+ break; -+ } -+ -+fail: -+ retry++; -+ if(unlikely(retry > 2)) { -+ NVT_ERR("error, retry=%d\n", retry); -+ break; -+ } -+ } -+ -+ end = ktime_get(); -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen update firmware main function. -+ -+return: -+ n.a. -+*******************************************************/ -+int32_t nvt_update_firmware(const char *firmware_name) -+{ -+ int32_t ret = 0; -+ -+ // request bin file in "/etc/firmware" -+ ret = update_firmware_request(firmware_name); -+ if (ret) { -+ NVT_ERR("update_firmware_request failed. (%d)\n", ret); -+ goto request_firmware_fail; -+ } -+ -+ /* initial buffer and variable */ -+ ret = nvt_download_init(); -+ if (ret) { -+ NVT_ERR("Download Init failed. (%d)\n", ret); -+ goto download_fail; -+ } -+ -+ /* download firmware process */ -+ if (ts->hw_crc) -+ ret = nvt_download_firmware_hw_crc(); -+ else -+ ret = nvt_download_firmware(); -+ if (ret) { -+ NVT_ERR("Download Firmware failed. (%d)\n", ret); -+ goto download_fail; -+ } -+ -+ NVT_LOG("Update firmware success! <%ld us>\n", -+ (long) ktime_us_delta(end, start)); -+ -+ /* Get FW Info */ -+ ret = nvt_get_fw_info(); -+ if (ret) { -+ NVT_ERR("nvt_get_fw_info failed. (%d)\n", ret); -+ } -+ -+download_fail: -+ if (!IS_ERR_OR_NULL(bin_map)) { -+ kfree(bin_map); -+ bin_map = NULL; -+ } -+ -+ update_firmware_release(); -+request_firmware_fail: -+ -+ return ret; -+} -+ -+/******************************************************* -+Description: -+ Novatek touchscreen update firmware when booting -+ function. -+ -+return: -+ n.a. -+*******************************************************/ -+void Boot_Update_Firmware(struct work_struct *work) -+{ -+ mutex_lock(&ts->lock); -+ nvt_update_firmware(ts->fw_name); -+ nvt_get_fw_info(); -+ mutex_unlock(&ts->lock); -+} -+#endif /* BOOT_UPDATE_FIRMWARE */ -diff --git a/drivers/input/touchscreen/nt36523/nt36xxx_mem_map.h b/drivers/input/touchscreen/nt36523/nt36xxx_mem_map.h -new file mode 100644 -index 000000000000..3f4195d636a0 ---- /dev/null -+++ b/drivers/input/touchscreen/nt36523/nt36xxx_mem_map.h -@@ -0,0 +1,390 @@ -+/* -+ * Copyright (C) 2010 - 2018 Novatek, Inc. -+ * Copyright (C) 2021 XiaoMi, Inc. -+ * -+ * $Revision: 57674 $ -+ * $Date: 2020-03-02 11:16:20 +0800 (週一, 02 三月 2020) $ -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ * more details. -+ * -+ */ -+ -+#define CHIP_VER_TRIM_ADDR 0x3F004 -+#define CHIP_VER_TRIM_OLD_ADDR 0x1F64E -+ -+struct nvt_ts_mem_map { -+ uint32_t EVENT_BUF_ADDR; -+ uint32_t RAW_PIPE0_ADDR; -+ uint32_t RAW_PIPE1_ADDR; -+ uint32_t BASELINE_ADDR; -+ uint32_t BASELINE_BTN_ADDR; -+ uint32_t DIFF_PIPE0_ADDR; -+ uint32_t DIFF_PIPE1_ADDR; -+ uint32_t RAW_BTN_PIPE0_ADDR; -+ uint32_t RAW_BTN_PIPE1_ADDR; -+ uint32_t DIFF_BTN_PIPE0_ADDR; -+ uint32_t DIFF_BTN_PIPE1_ADDR; -+ uint32_t PEN_2D_BL_TIP_X_ADDR; -+ uint32_t PEN_2D_BL_TIP_Y_ADDR; -+ uint32_t PEN_2D_BL_RING_X_ADDR; -+ uint32_t PEN_2D_BL_RING_Y_ADDR; -+ uint32_t PEN_2D_DIFF_TIP_X_ADDR; -+ uint32_t PEN_2D_DIFF_TIP_Y_ADDR; -+ uint32_t PEN_2D_DIFF_RING_X_ADDR; -+ uint32_t PEN_2D_DIFF_RING_Y_ADDR; -+ uint32_t PEN_2D_RAW_TIP_X_ADDR; -+ uint32_t PEN_2D_RAW_TIP_Y_ADDR; -+ uint32_t PEN_2D_RAW_RING_X_ADDR; -+ uint32_t PEN_2D_RAW_RING_Y_ADDR; -+ uint32_t PEN_1D_DIFF_TIP_X_ADDR; -+ uint32_t PEN_1D_DIFF_TIP_Y_ADDR; -+ uint32_t PEN_1D_DIFF_RING_X_ADDR; -+ uint32_t PEN_1D_DIFF_RING_Y_ADDR; -+ uint32_t READ_FLASH_CHECKSUM_ADDR; -+ uint32_t RW_FLASH_DATA_ADDR; -+ /* Phase 2 Host Download */ -+ uint32_t BOOT_RDY_ADDR; -+ uint32_t POR_CD_ADDR; -+ uint32_t TX_AUTO_COPY_EN; -+ uint32_t SPI_DMA_TX_INFO; -+ /* BLD CRC */ -+ uint32_t BLD_LENGTH_ADDR; -+ uint32_t ILM_LENGTH_ADDR; -+ uint32_t DLM_LENGTH_ADDR; -+ uint32_t BLD_DES_ADDR; -+ uint32_t ILM_DES_ADDR; -+ uint32_t DLM_DES_ADDR; -+ uint32_t G_ILM_CHECKSUM_ADDR; -+ uint32_t G_DLM_CHECKSUM_ADDR; -+ uint32_t R_ILM_CHECKSUM_ADDR; -+ uint32_t R_DLM_CHECKSUM_ADDR; -+ uint32_t BLD_CRC_EN_ADDR; -+ uint32_t DMA_CRC_EN_ADDR; -+ uint32_t BLD_ILM_DLM_CRC_ADDR; -+ uint32_t DMA_CRC_FLAG_ADDR; -+ uint32_t FW_HISTORY_ADDR; -+}; -+ -+struct nvt_ts_hw_info { -+ uint8_t carrier_system; -+ uint8_t hw_crc; -+}; -+ -+static const struct nvt_ts_mem_map NT36523_memory_map = { -+ .EVENT_BUF_ADDR = 0x2FE00, -+ .RAW_PIPE0_ADDR = 0x30FA0, -+ .RAW_PIPE1_ADDR = 0x30FA0, -+ .BASELINE_ADDR = 0x36510, -+ .BASELINE_BTN_ADDR = 0, -+ .DIFF_PIPE0_ADDR = 0x373E8, -+ .DIFF_PIPE1_ADDR = 0x38068, -+ .RAW_BTN_PIPE0_ADDR = 0, -+ .RAW_BTN_PIPE1_ADDR = 0, -+ .DIFF_BTN_PIPE0_ADDR = 0, -+ .DIFF_BTN_PIPE1_ADDR = 0, -+ .PEN_2D_BL_TIP_X_ADDR = 0x2988A, -+ .PEN_2D_BL_TIP_Y_ADDR = 0x29A1A, -+ .PEN_2D_BL_RING_X_ADDR = 0x29BAA, -+ .PEN_2D_BL_RING_Y_ADDR = 0x29D3A, -+ .PEN_2D_DIFF_TIP_X_ADDR = 0x29ECA, -+ .PEN_2D_DIFF_TIP_Y_ADDR = 0x2A05A, -+ .PEN_2D_DIFF_RING_X_ADDR = 0x2A1EA, -+ .PEN_2D_DIFF_RING_Y_ADDR = 0x2A37A, -+ .PEN_2D_RAW_TIP_X_ADDR = 0x2A50A, -+ .PEN_2D_RAW_TIP_Y_ADDR = 0x2A69A, -+ .PEN_2D_RAW_RING_X_ADDR = 0x2A82A, -+ .PEN_2D_RAW_RING_Y_ADDR = 0x2A9BA, -+ .PEN_1D_DIFF_TIP_X_ADDR = 0x2AB4A, -+ .PEN_1D_DIFF_TIP_Y_ADDR = 0x2ABAE, -+ .PEN_1D_DIFF_RING_X_ADDR = 0x2AC12, -+ .PEN_1D_DIFF_RING_Y_ADDR = 0x2AC76, -+ .READ_FLASH_CHECKSUM_ADDR = 0x24000, -+ .RW_FLASH_DATA_ADDR = 0x24002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x3F10D, -+ .TX_AUTO_COPY_EN = 0x3F7E8, -+ .SPI_DMA_TX_INFO = 0x3F7F1, -+ /* BLD CRC */ -+ .BLD_LENGTH_ADDR = 0x3F138, //0x3F138 ~ 0x3F13A (3 bytes) -+ .ILM_LENGTH_ADDR = 0x3F118, //0x3F118 ~ 0x3F11A (3 bytes) -+ .DLM_LENGTH_ADDR = 0x3F130, //0x3F130 ~ 0x3F132 (3 bytes) -+ .BLD_DES_ADDR = 0x3F114, //0x3F114 ~ 0x3F116 (3 bytes) -+ .ILM_DES_ADDR = 0x3F128, //0x3F128 ~ 0x3F12A (3 bytes) -+ .DLM_DES_ADDR = 0x3F12C, //0x3F12C ~ 0x3F12E (3 bytes) -+ .G_ILM_CHECKSUM_ADDR = 0x3F100, //0x3F100 ~ 0x3F103 (4 bytes) -+ .G_DLM_CHECKSUM_ADDR = 0x3F104, //0x3F104 ~ 0x3F107 (4 bytes) -+ .R_ILM_CHECKSUM_ADDR = 0x3F120, //0x3F120 ~ 0x3F123 (4 bytes) -+ .R_DLM_CHECKSUM_ADDR = 0x3F124, //0x3F124 ~ 0x3F127 (4 bytes) -+ .BLD_CRC_EN_ADDR = 0x3F30E, -+ .DMA_CRC_EN_ADDR = 0x3F136, -+ .BLD_ILM_DLM_CRC_ADDR = 0x3F133, -+ .DMA_CRC_FLAG_ADDR = 0x3F134, -+ .FW_HISTORY_ADDR = 0x38D54, -+}; -+ -+static const struct nvt_ts_mem_map NT36526_memory_map = { -+ .EVENT_BUF_ADDR = 0x22D00, -+ .RAW_PIPE0_ADDR = 0x24000, -+ .RAW_PIPE1_ADDR = 0x24000, -+ .BASELINE_ADDR = 0x21758, -+ .BASELINE_BTN_ADDR = 0, -+ .DIFF_PIPE0_ADDR = 0x20AB0, -+ .DIFF_PIPE1_ADDR = 0x24AB0, -+ .RAW_BTN_PIPE0_ADDR = 0, -+ .RAW_BTN_PIPE1_ADDR = 0, -+ .DIFF_BTN_PIPE0_ADDR = 0, -+ .DIFF_BTN_PIPE1_ADDR = 0, -+ .READ_FLASH_CHECKSUM_ADDR = 0x24000, -+ .RW_FLASH_DATA_ADDR = 0x24002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x3F10D, -+ /* BLD CRC */ -+ .BLD_LENGTH_ADDR = 0x3F138, //0x3F138 ~ 0x3F13A (3 bytes) -+ .ILM_LENGTH_ADDR = 0x3F118, //0x3F118 ~ 0x3F11A (3 bytes) -+ .DLM_LENGTH_ADDR = 0x3F130, //0x3F130 ~ 0x3F132 (3 bytes) -+ .BLD_DES_ADDR = 0x3F114, //0x3F114 ~ 0x3F116 (3 bytes) -+ .ILM_DES_ADDR = 0x3F128, //0x3F128 ~ 0x3F12A (3 bytes) -+ .DLM_DES_ADDR = 0x3F12C, //0x3F12C ~ 0x3F12E (3 bytes) -+ .G_ILM_CHECKSUM_ADDR = 0x3F100, //0x3F100 ~ 0x3F103 (4 bytes) -+ .G_DLM_CHECKSUM_ADDR = 0x3F104, //0x3F104 ~ 0x3F107 (4 bytes) -+ .R_ILM_CHECKSUM_ADDR = 0x3F120, //0x3F120 ~ 0x3F123 (4 bytes) -+ .R_DLM_CHECKSUM_ADDR = 0x3F124, //0x3F124 ~ 0x3F127 (4 bytes) -+ .BLD_CRC_EN_ADDR = 0x3F30E, -+ .DMA_CRC_EN_ADDR = 0x3F136, -+ .BLD_ILM_DLM_CRC_ADDR = 0x3F133, -+ .DMA_CRC_FLAG_ADDR = 0x3F134, -+}; -+ -+ -+static const struct nvt_ts_mem_map NT36675_memory_map = { -+ .EVENT_BUF_ADDR = 0x22D00, -+ .RAW_PIPE0_ADDR = 0x24000, -+ .RAW_PIPE1_ADDR = 0x24000, -+ .BASELINE_ADDR = 0x21B90, -+ .BASELINE_BTN_ADDR = 0, -+ .DIFF_PIPE0_ADDR = 0x20C60, -+ .DIFF_PIPE1_ADDR = 0x24C60, -+ .RAW_BTN_PIPE0_ADDR = 0, -+ .RAW_BTN_PIPE1_ADDR = 0, -+ .DIFF_BTN_PIPE0_ADDR = 0, -+ .DIFF_BTN_PIPE1_ADDR = 0, -+ .READ_FLASH_CHECKSUM_ADDR = 0x24000, -+ .RW_FLASH_DATA_ADDR = 0x24002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x3F10D, -+ /* BLD CRC */ -+ .BLD_LENGTH_ADDR = 0x3F138, //0x3F138 ~ 0x3F13A (3 bytes) -+ .ILM_LENGTH_ADDR = 0x3F118, //0x3F118 ~ 0x3F11A (3 bytes) -+ .DLM_LENGTH_ADDR = 0x3F130, //0x3F130 ~ 0x3F132 (3 bytes) -+ .BLD_DES_ADDR = 0x3F114, //0x3F114 ~ 0x3F116 (3 bytes) -+ .ILM_DES_ADDR = 0x3F128, //0x3F128 ~ 0x3F12A (3 bytes) -+ .DLM_DES_ADDR = 0x3F12C, //0x3F12C ~ 0x3F12E (3 bytes) -+ .G_ILM_CHECKSUM_ADDR = 0x3F100, //0x3F100 ~ 0x3F103 (4 bytes) -+ .G_DLM_CHECKSUM_ADDR = 0x3F104, //0x3F104 ~ 0x3F107 (4 bytes) -+ .R_ILM_CHECKSUM_ADDR = 0x3F120, //0x3F120 ~ 0x3F123 (4 bytes) -+ .R_DLM_CHECKSUM_ADDR = 0x3F124, //0x3F124 ~ 0x3F127 (4 bytes) -+ .BLD_CRC_EN_ADDR = 0x3F30E, -+ .DMA_CRC_EN_ADDR = 0x3F136, -+ .BLD_ILM_DLM_CRC_ADDR = 0x3F133, -+ .DMA_CRC_FLAG_ADDR = 0x3F134, -+}; -+ -+ -+static const struct nvt_ts_mem_map NT36672A_memory_map = { -+ .EVENT_BUF_ADDR = 0x21C00, -+ .RAW_PIPE0_ADDR = 0x20000, -+ .RAW_PIPE1_ADDR = 0x23000, -+ .BASELINE_ADDR = 0x20BFC, -+ .BASELINE_BTN_ADDR = 0x23BFC, -+ .DIFF_PIPE0_ADDR = 0x206DC, -+ .DIFF_PIPE1_ADDR = 0x236DC, -+ .RAW_BTN_PIPE0_ADDR = 0x20510, -+ .RAW_BTN_PIPE1_ADDR = 0x23510, -+ .DIFF_BTN_PIPE0_ADDR = 0x20BF0, -+ .DIFF_BTN_PIPE1_ADDR = 0x23BF0, -+ .READ_FLASH_CHECKSUM_ADDR = 0x24000, -+ .RW_FLASH_DATA_ADDR = 0x24002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x3F10D, -+ /* BLD CRC */ -+ .BLD_LENGTH_ADDR = 0x3F10E, //0x3F10E ~ 0x3F10F (2 bytes) -+ .ILM_LENGTH_ADDR = 0x3F118, //0x3F118 ~ 0x3F119 (2 bytes) -+ .DLM_LENGTH_ADDR = 0x3F130, //0x3F130 ~ 0x3F131 (2 bytes) -+ .BLD_DES_ADDR = 0x3F114, //0x3F114 ~ 0x3F116 (3 bytes) -+ .ILM_DES_ADDR = 0x3F128, //0x3F128 ~ 0x3F12A (3 bytes) -+ .DLM_DES_ADDR = 0x3F12C, //0x3F12C ~ 0x3F12E (3 bytes) -+ .G_ILM_CHECKSUM_ADDR = 0x3F100, //0x3F100 ~ 0x3F103 (4 bytes) -+ .G_DLM_CHECKSUM_ADDR = 0x3F104, //0x3F104 ~ 0x3F107 (4 bytes) -+ .R_ILM_CHECKSUM_ADDR = 0x3F120, //0x3F120 ~ 0x3F123 (4 bytes) -+ .R_DLM_CHECKSUM_ADDR = 0x3F124, //0x3F124 ~ 0x3F127 (4 bytes) -+ .BLD_CRC_EN_ADDR = 0x3F30E, -+ .DMA_CRC_EN_ADDR = 0x3F132, -+ .BLD_ILM_DLM_CRC_ADDR = 0x3F133, -+ .DMA_CRC_FLAG_ADDR = 0x3F134, -+}; -+ -+static const struct nvt_ts_mem_map NT36772_memory_map = { -+ .EVENT_BUF_ADDR = 0x11E00, -+ .RAW_PIPE0_ADDR = 0x10000, -+ .RAW_PIPE1_ADDR = 0x12000, -+ .BASELINE_ADDR = 0x10E70, -+ .BASELINE_BTN_ADDR = 0x12E70, -+ .DIFF_PIPE0_ADDR = 0x10830, -+ .DIFF_PIPE1_ADDR = 0x12830, -+ .RAW_BTN_PIPE0_ADDR = 0x10E60, -+ .RAW_BTN_PIPE1_ADDR = 0x12E60, -+ .DIFF_BTN_PIPE0_ADDR = 0x10E68, -+ .DIFF_BTN_PIPE1_ADDR = 0x12E68, -+ .READ_FLASH_CHECKSUM_ADDR = 0x14000, -+ .RW_FLASH_DATA_ADDR = 0x14002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x1F141, -+ .POR_CD_ADDR = 0x1F61C, -+ /* BLD CRC */ -+ .R_ILM_CHECKSUM_ADDR = 0x1BF00, -+}; -+ -+static const struct nvt_ts_mem_map NT36525_memory_map = { -+ .EVENT_BUF_ADDR = 0x11A00, -+ .RAW_PIPE0_ADDR = 0x10000, -+ .RAW_PIPE1_ADDR = 0x12000, -+ .BASELINE_ADDR = 0x10B08, -+ .BASELINE_BTN_ADDR = 0x12B08, -+ .DIFF_PIPE0_ADDR = 0x1064C, -+ .DIFF_PIPE1_ADDR = 0x1264C, -+ .RAW_BTN_PIPE0_ADDR = 0x10634, -+ .RAW_BTN_PIPE1_ADDR = 0x12634, -+ .DIFF_BTN_PIPE0_ADDR = 0x10AFC, -+ .DIFF_BTN_PIPE1_ADDR = 0x12AFC, -+ .READ_FLASH_CHECKSUM_ADDR = 0x14000, -+ .RW_FLASH_DATA_ADDR = 0x14002, -+ /* Phase 2 Host Download */ -+ .BOOT_RDY_ADDR = 0x1F141, -+ .POR_CD_ADDR = 0x1F61C, -+ /* BLD CRC */ -+ .R_ILM_CHECKSUM_ADDR = 0x1BF00, -+}; -+ -+static const struct nvt_ts_mem_map NT36676F_memory_map = { -+ .EVENT_BUF_ADDR = 0x11A00, -+ .RAW_PIPE0_ADDR = 0x10000, -+ .RAW_PIPE1_ADDR = 0x12000, -+ .BASELINE_ADDR = 0x10B08, -+ .BASELINE_BTN_ADDR = 0x12B08, -+ .DIFF_PIPE0_ADDR = 0x1064C, -+ .DIFF_PIPE1_ADDR = 0x1264C, -+ .RAW_BTN_PIPE0_ADDR = 0x10634, -+ .RAW_BTN_PIPE1_ADDR = 0x12634, -+ .DIFF_BTN_PIPE0_ADDR = 0x10AFC, -+ .DIFF_BTN_PIPE1_ADDR = 0x12AFC, -+ .READ_FLASH_CHECKSUM_ADDR = 0x14000, -+ .RW_FLASH_DATA_ADDR = 0x14002, -+}; -+ -+static struct nvt_ts_hw_info NT36523_hw_info = { -+ .carrier_system = 2, -+ .hw_crc = 2, -+}; -+ -+static struct nvt_ts_hw_info NT36526_hw_info = { -+ .carrier_system = 2, -+ .hw_crc = 2, -+}; -+ -+static struct nvt_ts_hw_info NT36675_hw_info = { -+ .carrier_system = 2, -+ .hw_crc = 2, -+}; -+ -+static struct nvt_ts_hw_info NT36672A_hw_info = { -+ .carrier_system = 0, -+ .hw_crc = 1, -+}; -+ -+static struct nvt_ts_hw_info NT36772_hw_info = { -+ .carrier_system = 0, -+ .hw_crc = 0, -+}; -+ -+static struct nvt_ts_hw_info NT36525_hw_info = { -+ .carrier_system = 0, -+ .hw_crc = 0, -+}; -+ -+static struct nvt_ts_hw_info NT36676F_hw_info = { -+ .carrier_system = 0, -+ .hw_crc = 0, -+}; -+ -+#define NVT_ID_BYTE_MAX 6 -+struct nvt_ts_trim_id_table { -+ uint8_t id[NVT_ID_BYTE_MAX]; -+ uint8_t mask[NVT_ID_BYTE_MAX]; -+ const struct nvt_ts_mem_map *mmap; -+ const struct nvt_ts_hw_info *hwinfo; -+}; -+ -+static const struct nvt_ts_trim_id_table trim_id_table[] = { -+ {.id = {0x20, 0xFF, 0xFF, 0x23, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36523_memory_map, .hwinfo = &NT36523_hw_info}, -+ {.id = {0x0C, 0xFF, 0xFF, 0x23, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36523_memory_map, .hwinfo = &NT36523_hw_info}, -+ {.id = {0x0B, 0xFF, 0xFF, 0x23, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36523_memory_map, .hwinfo = &NT36523_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x23, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36523_memory_map, .hwinfo = &NT36523_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x23, 0x65, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36523_memory_map, .hwinfo = &NT36523_hw_info}, -+ {.id = {0x0C, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36675_memory_map, .hwinfo = &NT36675_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x26, 0x65, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36526_memory_map, .hwinfo = &NT36526_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x75, 0x66, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36675_memory_map, .hwinfo = &NT36675_hw_info}, -+ {.id = {0x0B, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0B, 0xFF, 0xFF, 0x82, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0B, 0xFF, 0xFF, 0x25, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x72, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x82, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x70, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0B, 0xFF, 0xFF, 0x70, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x0A, 0xFF, 0xFF, 0x72, 0x67, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, -+ .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, -+ {.id = {0x55, 0x00, 0xFF, 0x00, 0x00, 0x00}, .mask = {1, 1, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0x55, 0x72, 0xFF, 0x00, 0x00, 0x00}, .mask = {1, 1, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xAA, 0x00, 0xFF, 0x00, 0x00, 0x00}, .mask = {1, 1, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xAA, 0x72, 0xFF, 0x00, 0x00, 0x00}, .mask = {1, 1, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x72, 0x67, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x70, 0x66, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x70, 0x67, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36772_memory_map, .hwinfo = &NT36772_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x25, 0x65, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36525_memory_map, .hwinfo = &NT36525_hw_info}, -+ {.id = {0xFF, 0xFF, 0xFF, 0x76, 0x66, 0x03}, .mask = {0, 0, 0, 1, 1, 1}, -+ .mmap = &NT36676F_memory_map, .hwinfo = &NT36676F_hw_info} -+}; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0016-arm64-dts-qcom-sm8250-xiaomi-elish-Add-sound-support.patch b/patch/kernel/archive/sm8250-6.7/0016-arm64-dts-qcom-sm8250-xiaomi-elish-Add-sound-support.patch deleted file mode 100644 index 57a382b7615d..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0016-arm64-dts-qcom-sm8250-xiaomi-elish-Add-sound-support.patch +++ /dev/null @@ -1,281 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Sat, 18 Mar 2023 22:26:22 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: Add sound support - ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 232 ++++++++++ - 1 file changed, 232 insertions(+) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index 2da3820ddbda..45775428cb92 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -6,6 +6,8 @@ - #include - #include - #include -+#include -+#include - #include "sm8250.dtsi" - #include "pm8150.dtsi" - #include "pm8150b.dtsi" -@@ -529,6 +531,152 @@ fuel-gauge@55 { - }; - }; - -+&i2c1 { -+ clock-frequency = <400000>; -+ status = "okay"; -+ -+ cs35l41_brh: speaker-amp@40 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x40>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <7 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 6 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "BRH"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_blh: speaker-amp@41 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x41>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <67 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "BLH"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_brl: speaker-amp@42 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x42>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <100 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 69 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "BRL"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_bll: speaker-amp@43 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x43>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <126 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 49 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "BLL"; -+ #sound-dai-cells = <1>; -+ }; -+}; -+ -+&i2c3 { -+ clock-frequency = <400000>; -+ status = "okay"; -+ -+ cs35l41_trh: speaker-amp@40 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x40>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <27 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "TRH"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_tlh: speaker-amp@41 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x41>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <92 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 78 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "TLH"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_tll: speaker-amp@42 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x42>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <112 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "TLL"; -+ #sound-dai-cells = <1>; -+ }; -+ -+ cs35l41_trl: speaker-amp@43 { -+ compatible = "cirrus,cs35l41"; -+ reg = <0x43>; -+ interrupt-parent = <&tlmm>; -+ interrupts = <129 IRQ_TYPE_LEVEL_LOW>; -+ reset-gpios = <&tlmm 144 GPIO_ACTIVE_HIGH>; -+ cirrus,boost-type = <0>; -+ cirrus,boost-peak-milliamp = <4000>; -+ cirrus,boost-ind-nanohenry = <1000>; -+ cirrus,boost-cap-microfarad = <15>; -+ cirrus,asp-sdout-hiz = <3>; -+ cirrus,gpio2-src-select = <4>; -+ cirrus,gpio2-output-enable; -+ sound-name-prefix = "TRL"; -+ #sound-dai-cells = <1>; -+ }; -+}; -+ - &i2c11 { - clock-frequency = <400000>; - status = "okay"; -@@ -684,11 +832,63 @@ &qupv3_id_2 { - status = "okay"; - }; - -+&q6afedai { -+ dai@56 { -+ reg = ; -+ qcom,tdm-sync-mode = <0>; -+ qcom,tdm-sync-src = <1>; -+ qcom,tdm-data-out = <0>; -+ qcom,tdm-invert-sync = <1>; -+ qcom,tdm-data-delay = <1>; -+ qcom,tdm-data-align = <0>; -+ }; -+}; -+ -+&q6asmdai { -+ dai@0 { -+ reg = <0>; -+ }; -+}; -+ - &slpi { - firmware-name = "qcom/sm8250/xiaomi/elish/slpi.mbn"; - status = "disabled"; - }; - -+&sound { -+ compatible = "qcom,sm8250-sndcard"; -+ model = "Xiaomi Mi Pad 5 Pro"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&tert_tdm_active>; -+ -+ mm1-dai-link { -+ link-name = "MultiMedia1"; -+ -+ cpu { -+ sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>; -+ }; -+ }; -+ -+ speaker-dai-link { -+ link-name = "Tertiary TDM Playback"; -+ -+ cpu { -+ sound-dai = <&q6afedai TERTIARY_TDM_RX_0>; -+ }; -+ -+ platform { -+ sound-dai = <&q6routing>; -+ }; -+ -+ codec { -+ sound-dai = <&cs35l41_tlh 0>, <&cs35l41_tll 0>, -+ <&cs35l41_trh 0>, <&cs35l41_trl 0>, -+ <&cs35l41_blh 0>, <&cs35l41_bll 0>, -+ <&cs35l41_brh 0>, <&cs35l41_brl 0>; -+ }; -+ }; -+}; -+ - &spi4 { - status = "okay"; - pinctrl-names = "default"; -@@ -735,6 +935,38 @@ wlan-en-pins { - bias-pull-up; - }; - }; -+ -+ tert_tdm_active: tert-tdm-active-state { -+ sck-pins { -+ pins = "gpio133"; -+ function = "mi2s2_sck"; -+ drive-strength = <8>; -+ bias-disable; -+ output-high; -+ }; -+ -+ din-pins { -+ pins = "gpio134"; -+ function = "mi2s2_data0"; -+ drive-strength = <8>; -+ bias-disable; -+ }; -+ -+ ws-pins { -+ pins = "gpio135"; -+ function = "mi2s2_ws"; -+ drive-strength = <8>; -+ bias-disable; -+ output-high; -+ }; -+ -+ dout-pins { -+ pins = "gpio137"; -+ function = "mi2s2_data1"; -+ drive-strength = <8>; -+ bias-disable; -+ }; -+ }; - }; - - &uart6 { --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0017-Asoc-wm_adsp-Add-prefix-support.patch b/patch/kernel/archive/sm8250-6.7/0017-Asoc-wm_adsp-Add-prefix-support.patch deleted file mode 100644 index 870888fe3130..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0017-Asoc-wm_adsp-Add-prefix-support.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Wed, 29 Mar 2023 19:38:33 +0800 -Subject: Asoc: wm_adsp: Add prefix support - ---- - sound/soc/codecs/wm_adsp.c | 14 ++++++++++ - 1 file changed, 14 insertions(+) - -diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c -index c01e31175015..588f28bdc72a 100644 ---- a/sound/soc/codecs/wm_adsp.c -+++ b/sound/soc/codecs/wm_adsp.c -@@ -750,6 +750,10 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp, - *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part, - dsp->fwf_name, wm_adsp_fw[dsp->fw].file, system_name, - filetype); -+ else if (asoc_component_prefix) -+ *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s-%s.%s", dir, dsp->part, -+ dsp->fwf_name, wm_adsp_fw[dsp->fw].file, asoc_component_prefix, -+ filetype); - else - *filename = kasprintf(GFP_KERNEL, "%s%s-%s-%s.%s", dir, dsp->part, dsp->fwf_name, - wm_adsp_fw[dsp->fw].file, filetype); -@@ -821,6 +825,16 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp, - NULL, "bin"); - return 0; - } -+ } else if (asoc_component_prefix) { -+ if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename, -+ cirrus_dir, NULL, -+ NULL, "wmfw")) { -+ adsp_dbg(dsp, "Found '%s'\n", *wmfw_filename); -+ wm_adsp_request_firmware_file(dsp, coeff_firmware, coeff_filename, -+ cirrus_dir, NULL, -+ asoc_component_prefix, "bin"); -+ return 0; -+ } - } - - if (!wm_adsp_request_firmware_file(dsp, wmfw_firmware, wmfw_filename, --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0018-drm-panel-nt36523-Fix-for-kernel-6.5.patch b/patch/kernel/archive/sm8250-6.7/0018-drm-panel-nt36523-Fix-for-kernel-6.5.patch deleted file mode 100644 index 6e65056e00c2..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0018-drm-panel-nt36523-Fix-for-kernel-6.5.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:28:48 +0800 -Subject: drm/panel: nt36523: Fix for kernel 6.5 - ---- - drivers/gpu/drm/panel/panel-novatek-nt36523.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36523.c b/drivers/gpu/drm/panel/panel-novatek-nt36523.c -index a189ce236328..c8c6f0b3f613 100644 ---- a/drivers/gpu/drm/panel/panel-novatek-nt36523.c -+++ b/drivers/gpu/drm/panel/panel-novatek-nt36523.c -@@ -1262,6 +1262,7 @@ static int nt36523_probe(struct mipi_dsi_device *dsi) - - pinfo->dsi[0] = dsi; - mipi_dsi_set_drvdata(dsi, pinfo); -+ pinfo->panel.prepare_prev_first = true; - drm_panel_init(&pinfo->panel, dev, &nt36523_panel_funcs, DRM_MODE_CONNECTOR_DSI); - - ret = of_drm_get_panel_orientation(dev->of_node, &pinfo->orientation); --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0019-drivers-spmi-spmi-pmic-arb.c-remove-warnings.patch b/patch/kernel/archive/sm8250-6.7/0019-drivers-spmi-spmi-pmic-arb.c-remove-warnings.patch deleted file mode 100644 index 25f3798fec15..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0019-drivers-spmi-spmi-pmic-arb.c-remove-warnings.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:32:19 +0800 -Subject: drivers/spmi/spmi-pmic-arb.c: remove warnings - ---- - drivers/spmi/spmi-pmic-arb.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c -index dcb675d980d4..2688ac2a7e55 100644 ---- a/drivers/spmi/spmi-pmic-arb.c -+++ b/drivers/spmi/spmi-pmic-arb.c -@@ -289,7 +289,6 @@ static int pmic_arb_wait_for_done(struct spmi_controller *ctrl, - if (status & PMIC_ARB_STATUS_FAILURE) { - dev_err(&ctrl->dev, "%s: %#x %#x: transaction failed (%#x)\n", - __func__, sid, addr, status); -- WARN_ON(1); - return -EIO; - } - --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0020-tty-serial-qcom-geni-fix-zero-dma-rx-len-in.patch b/patch/kernel/archive/sm8250-6.7/0020-tty-serial-qcom-geni-fix-zero-dma-rx-len-in.patch deleted file mode 100644 index 28c01a6d791f..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0020-tty-serial-qcom-geni-fix-zero-dma-rx-len-in.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Mon, 16 Oct 2023 13:32:58 +0800 -Subject: tty: serial: qcom-geni: fix zero dma-rx-len-in - ---- - drivers/tty/serial/qcom_geni_serial.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c -index 7e78f97e8f43..6ea1a4f8ba65 100644 ---- a/drivers/tty/serial/qcom_geni_serial.c -+++ b/drivers/tty/serial/qcom_geni_serial.c -@@ -820,7 +820,7 @@ static void qcom_geni_serial_handle_rx_dma(struct uart_port *uport, bool drop) - rx_in = readl(uport->membase + SE_DMA_RX_LEN_IN); - if (!rx_in) { - dev_warn(uport->dev, "serial engine reports 0 RX bytes in!\n"); -- return; -+ //return; - } - - if (!drop) --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0022-input-nt36523-short-the-firmware-download-delay-from.patch b/patch/kernel/archive/sm8250-6.7/0022-input-nt36523-short-the-firmware-download-delay-from.patch deleted file mode 100644 index 4b1d5303f3f7..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0022-input-nt36523-short-the-firmware-download-delay-from.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Thu, 26 Oct 2023 13:13:34 +0800 -Subject: input: nt36523: short the firmware download delay from 14s to 4s - ---- - drivers/input/touchscreen/nt36523/nt36xxx.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/input/touchscreen/nt36523/nt36xxx.c b/drivers/input/touchscreen/nt36523/nt36xxx.c -index 45500ad5cd91..27f93e531290 100644 ---- a/drivers/input/touchscreen/nt36523/nt36xxx.c -+++ b/drivers/input/touchscreen/nt36523/nt36xxx.c -@@ -1452,7 +1452,7 @@ static int32_t nvt_ts_probe(struct spi_device *client) - } - INIT_DELAYED_WORK(&ts->nvt_fwu_work, Boot_Update_Firmware); - // please make sure boot update start after display reset(RESX) sequence -- queue_delayed_work(nvt_fwu_wq, &ts->nvt_fwu_work, msecs_to_jiffies(14000)); -+ queue_delayed_work(nvt_fwu_wq, &ts->nvt_fwu_work, msecs_to_jiffies(4000)); - #endif - - NVT_LOG("NVT_TOUCH_ESD_PROTECT is %d\n", NVT_TOUCH_ESD_PROTECT); --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0023-Enable-non-coherent-dst-bufs-for-Venus-V4L2-driver.patch b/patch/kernel/archive/sm8250-6.7/0023-Enable-non-coherent-dst-bufs-for-Venus-V4L2-driver.patch deleted file mode 100644 index d4d1c0a695d6..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0023-Enable-non-coherent-dst-bufs-for-Venus-V4L2-driver.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: amazingfate -Date: Fri, 3 Nov 2023 11:20:40 +0800 -Subject: Enable non-coherent dst bufs for Venus V4L2 driver - ---- - drivers/media/platform/qcom/venus/vdec.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c -index dbf305cec120..14b5d2ebbdf2 100644 ---- a/drivers/media/platform/qcom/venus/vdec.c -+++ b/drivers/media/platform/qcom/venus/vdec.c -@@ -1659,6 +1659,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq, - dst_vq->min_buffers_needed = 0; - dst_vq->dev = inst->core->dev; - dst_vq->lock = &inst->ctx_q_lock; -+ dst_vq->allow_cache_hints = 1; - return vb2_queue_init(dst_vq); - } - --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0024-arm64-dts-qcom-sm8250-xiaomi-elish-Fix-typos.patch b/patch/kernel/archive/sm8250-6.7/0024-arm64-dts-qcom-sm8250-xiaomi-elish-Fix-typos.patch deleted file mode 100644 index 3a096bc5b90f..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0024-arm64-dts-qcom-sm8250-xiaomi-elish-Fix-typos.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Sun, 26 Nov 2023 10:28:48 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: Fix typos - -There are two typos in this dtsi, so fix it. - classis -> chassis. - 80700000 -> 80600000 - -Reviewed-by: Konrad Dybcio -Signed-off-by: Jianhua Lu ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index 45775428cb92..69fab5a917f2 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -25,7 +25,7 @@ - /delete-node/ &xbl_aop_mem; - - / { -- classis-type = "tablet"; -+ chassis-type = "tablet"; - - /* required for bootloader to select correct board */ - qcom,msm-id = ; /* SM8250 v2.1 */ -@@ -139,7 +139,7 @@ qca639x: qca639x { - }; - - reserved-memory { -- xbl_aop_mem: xbl-aop@80700000 { -+ xbl_aop_mem: xbl-aop@80600000 { - reg = <0x0 0x80600000 0x0 0x260000>; - no-map; - }; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0025-arm64-dts-qcom-sm8250-xiaomi-elish-Add-pm8150b-type-.patch b/patch/kernel/archive/sm8250-6.7/0025-arm64-dts-qcom-sm8250-xiaomi-elish-Add-pm8150b-type-.patch deleted file mode 100644 index a670923194f3..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0025-arm64-dts-qcom-sm8250-xiaomi-elish-Add-pm8150b-type-.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Sun, 26 Nov 2023 10:28:49 +0800 -Subject: arm64: dts: qcom: sm8250-xiaomi-elish: Add pm8150b type-c node and - enable usb otg - -Add type-c node to feature otg function and set usb-role-switch property -for usb_1_dwc3 to enable usb otg. - -Reviewed-by: Konrad Dybcio -Signed-off-by: Jianhua Lu ---- - arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi | 43 +++++++++- - 1 file changed, 42 insertions(+), 1 deletion(-) - -diff --git a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -index 69fab5a917f2..b55bcdbcbe2c 100644 ---- a/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -+++ b/arch/arm64/boot/dts/qcom/sm8250-xiaomi-elish-common.dtsi -@@ -8,6 +8,7 @@ - #include - #include - #include -+#include - #include "sm8250.dtsi" - #include "pm8150.dtsi" - #include "pm8150b.dtsi" -@@ -801,6 +802,41 @@ vol_up_n: vol-up-n-state { - }; - }; - -+&pm8150b_typec { -+ vdd-pdphy-supply = <&vreg_l2a_3p1>; -+ status = "okay"; -+ -+ connector { -+ compatible = "usb-c-connector"; -+ -+ power-role = "source"; -+ data-role = "dual"; -+ self-powered; -+ -+ source-pdos = ; -+ -+ ports { -+ #address-cells = <1>; -+ #size-cells = <0>; -+ -+ port@0 { -+ reg = <0>; -+ -+ pm8150b_role_switch_in: endpoint { -+ remote-endpoint = <&usb_1_role_switch_out>; -+ }; -+ }; -+ }; -+ }; -+}; -+ -+&pm8150b_vbus { -+ status = "okay"; -+}; -+ - &pon_pwrkey { - status = "okay"; - }; -@@ -989,11 +1025,12 @@ &usb_1 { - }; - - &usb_1_dwc3 { -- dr_mode = "peripheral"; -+ dr_mode = "otg"; - maximum-speed = "high-speed"; - /* Remove USB3 phy */ - phys = <&usb_1_hsphy>; - phy-names = "usb2-phy"; -+ usb-role-switch; - }; - - &usb_1_hsphy { -@@ -1003,6 +1040,10 @@ &usb_1_hsphy { - status = "okay"; - }; - -+&usb_1_role_switch_out { -+ remote-endpoint = <&pm8150b_role_switch_in>; -+}; -+ - &ufs_mem_hc { - vcc-supply = <&vreg_l17a_3p0>; - vcc-max-microamp = <800000>; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0029-drm-msm-dpu-try-multirect-based-on-mdp-clock-limits.patch b/patch/kernel/archive/sm8250-6.7/0029-drm-msm-dpu-try-multirect-based-on-mdp-clock-limits.patch deleted file mode 100644 index 4a2c000ad61a..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0029-drm-msm-dpu-try-multirect-based-on-mdp-clock-limits.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Abhinav Kumar -Date: Mon, 11 Sep 2023 15:16:27 -0700 -Subject: drm/msm/dpu: try multirect based on mdp clock limits - -It's certainly possible that for large resolutions a single DPU SSPP -cannot process the image without exceeding the MDP clock limits but -it can still process it in multirect mode because the source rectangles -will get divided and can fall within the MDP clock limits. - -If the SSPP cannot process the image even in multirect mode, then it -will be rejected in dpu_plane_atomic_check_pipe(). - -Hence try using multirect for resolutions which cannot be processed -by a single SSPP without exceeding the MDP clock limits. - -changes in v2: - - use crtc_state's adjusted_mode instead of mode - - fix the UBWC condition to check maxlinewidth - -Signed-off-by: Abhinav Kumar -Reviewed-by: Dmitry Baryshkov -Tested-by: Dmitry Baryshkov ---- - drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c -index 3eef5e025e12..1e0da38c6f2a 100644 ---- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c -+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c -@@ -824,6 +824,8 @@ static int dpu_plane_atomic_check(struct drm_plane *plane, - plane); - int ret = 0, min_scale; - struct dpu_plane *pdpu = to_dpu_plane(plane); -+ struct dpu_kms *kms = _dpu_plane_get_kms(&pdpu->base); -+ u64 max_mdp_clk_rate = kms->perf.max_core_clk_rate; - struct dpu_plane_state *pstate = to_dpu_plane_state(new_plane_state); - struct dpu_sw_pipe *pipe = &pstate->pipe; - struct dpu_sw_pipe *r_pipe = &pstate->r_pipe; -@@ -892,14 +894,16 @@ static int dpu_plane_atomic_check(struct drm_plane *plane, - - max_linewidth = pdpu->catalog->caps->max_linewidth; - -- if (drm_rect_width(&pipe_cfg->src_rect) > max_linewidth) { -+ if ((drm_rect_width(&pipe_cfg->src_rect) > max_linewidth) || -+ _dpu_plane_calc_clk(&crtc_state->adjusted_mode, pipe_cfg) > max_mdp_clk_rate) { - /* - * In parallel multirect case only the half of the usual width - * is supported for tiled formats. If we are here, we know that - * full width is more than max_linewidth, thus each rect is - * wider than allowed. - */ -- if (DPU_FORMAT_IS_UBWC(fmt)) { -+ if (DPU_FORMAT_IS_UBWC(fmt) && -+ drm_rect_width(&pipe_cfg->src_rect) > max_linewidth) { - DPU_DEBUG_PLANE(pdpu, "invalid src " DRM_RECT_FMT " line:%u, tiled format\n", - DRM_RECT_ARG(&pipe_cfg->src_rect), max_linewidth); - return -E2BIG; --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0030-drm-panel-nt36523-switch-to-120Hz-for-xiaomi-elish-p.patch b/patch/kernel/archive/sm8250-6.7/0030-drm-panel-nt36523-switch-to-120Hz-for-xiaomi-elish-p.patch deleted file mode 100644 index 26a475bd1599..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0030-drm-panel-nt36523-switch-to-120Hz-for-xiaomi-elish-p.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jianhua Lu -Date: Mon, 8 Jan 2024 21:44:44 +0800 -Subject: drm/panel: nt36523: switch to 120Hz for xiaomi,elish panel - -After commit e6c0de5f4450 ("drm/msm/dpu: try multirect based on mdp clock limits") merged, -120Hz is working on xiaomi,elish panel, so enable it. - -Signed-off-by: Jianhua Lu ---- - drivers/gpu/drm/panel/panel-novatek-nt36523.c | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36523.c b/drivers/gpu/drm/panel/panel-novatek-nt36523.c -index c8c6f0b3f613..d3954b1ca944 100644 ---- a/drivers/gpu/drm/panel/panel-novatek-nt36523.c -+++ b/drivers/gpu/drm/panel/panel-novatek-nt36523.c -@@ -933,8 +933,7 @@ static int j606f_boe_init_sequence(struct panel_info *pinfo) - - static const struct drm_display_mode elish_boe_modes[] = { - { -- /* There is only one 120 Hz timing, but it doesn't work perfectly, 104 Hz preferred */ -- .clock = (1600 + 60 + 8 + 60) * (2560 + 26 + 4 + 168) * 104 / 1000, -+ .clock = (1600 + 60 + 8 + 60) * (2560 + 26 + 4 + 168) * 120 / 1000, - .hdisplay = 1600, - .hsync_start = 1600 + 60, - .hsync_end = 1600 + 60 + 8, -@@ -948,8 +947,7 @@ static const struct drm_display_mode elish_boe_modes[] = { - - static const struct drm_display_mode elish_csot_modes[] = { - { -- /* There is only one 120 Hz timing, but it doesn't work perfectly, 104 Hz preferred */ -- .clock = (1600 + 200 + 40 + 52) * (2560 + 26 + 4 + 168) * 104 / 1000, -+ .clock = (1600 + 200 + 40 + 52) * (2560 + 26 + 4 + 168) * 120 / 1000, - .hdisplay = 1600, - .hsync_start = 1600 + 200, - .hsync_end = 1600 + 200 + 40, --- -Armbian - diff --git a/patch/kernel/archive/sm8250-6.7/0031-add-umi-csot-panel.patch b/patch/kernel/archive/sm8250-6.7/0031-add-umi-csot-panel.patch deleted file mode 100644 index 6bfa1601fdc8..000000000000 --- a/patch/kernel/archive/sm8250-6.7/0031-add-umi-csot-panel.patch +++ /dev/null @@ -1,467 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: FantasyGmm <16450052+FantasyGmm@users.noreply.github.com> -Date: Mon, 29 Jan 2024 19:05:12 +0800 -Subject: Patching kernel arm64 files drivers/gpu/drm/panel/Kconfig - drivers/gpu/drm/panel/Makefile drivers/gpu/drm/panel/panel-xiaomi-umi-csot.c - -Signed-off-by: FantasyGmm <16450052+FantasyGmm@users.noreply.github.com> ---- - drivers/gpu/drm/panel/Kconfig | 9 + - drivers/gpu/drm/panel/Makefile | 1 + - drivers/gpu/drm/panel/panel-xiaomi-umi-csot.c | 416 ++++++++++ - 3 files changed, 426 insertions(+) - -diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig -index 99e14dc212ec..2ab846e5cfaf 100644 ---- a/drivers/gpu/drm/panel/Kconfig -+++ b/drivers/gpu/drm/panel/Kconfig -@@ -8,6 +8,15 @@ config DRM_PANEL - menu "Display Panels" - depends on DRM && DRM_PANEL - -+config DRM_PANEL_XIAOMI_UMI_CSOT -+ tristate "Xiaomi Mi 10 (umi) 1080x2340 CSOT AMOLED panel" -+ depends on OF -+ depends on DRM_MIPI_DSI -+ depends on BACKLIGHT_CLASS_DEVICE -+ help -+ Say Y here if you want to enable support for the CSOT 1080x2340 -+ dsc cmd mode panel as found in Xiaomi Mi 10 devices. -+ - config DRM_PANEL_ABT_Y030XX067A - tristate "ABT Y030XX067A 320x480 LCD panel" - depends on OF && SPI -diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile -index d10c3de51c6d..687a239df8b1 100644 ---- a/drivers/gpu/drm/panel/Makefile -+++ b/drivers/gpu/drm/panel/Makefile -@@ -88,3 +88,4 @@ obj-$(CONFIG_DRM_PANEL_VISIONOX_VTDR6130) += panel-visionox-vtdr6130.o - obj-$(CONFIG_DRM_PANEL_VISIONOX_R66451) += panel-visionox-r66451.o - obj-$(CONFIG_DRM_PANEL_WIDECHIPS_WS2401) += panel-widechips-ws2401.o - obj-$(CONFIG_DRM_PANEL_XINPENG_XPP055C272) += panel-xinpeng-xpp055c272.o -+obj-$(CONFIG_DRM_PANEL_XIAOMI_UMI_CSOT) += panel-xiaomi-umi-csot.o -diff --git a/drivers/gpu/drm/panel/panel-xiaomi-umi-csot.c b/drivers/gpu/drm/panel/panel-xiaomi-umi-csot.c -new file mode 100644 -index 000000000000..5e1d3ec9c08d ---- /dev/null -+++ b/drivers/gpu/drm/panel/panel-xiaomi-umi-csot.c -@@ -0,0 +1,416 @@ -+// SPDX-License-Identifier: GPL-2.0-only -+// Copyright (c) 2024 FIXME -+// Generated with linux-mdss-dsi-panel-driver-generator from vendor device tree: -+// Copyright (c) 2013, The Linux Foundation. All rights reserved. (FIXME) -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include