├── .gitignore ├── README.md ├── archbuild ├── 60-linux.hook ├── 90-linux.hook ├── PKGBUILD ├── config.4.14 ├── config.4.15 ├── config.4.16 ├── linux.install └── linux.preset ├── firmware ├── i915_firmware_bxt.zip ├── i915_firmware_cfl.zip ├── i915_firmware_cnl.zip ├── i915_firmware_glk.zip ├── i915_firmware_kbl.zip ├── i915_firmware_skl.zip ├── ipts_firmware_v101.zip ├── ipts_firmware_v102.zip ├── ipts_firmware_v103.zip ├── ipts_firmware_v137.zip ├── ipts_firmware_v76.zip ├── ipts_firmware_v78.zip ├── ipts_firmware_v79.zip ├── mrvl_firmware.zip └── nvidia_firmware_gp108.zip ├── packages └── libwacom │ └── libwacom_0.29-1-surface_amd64.deb ├── patches ├── 4.14 │ ├── acpica.patch │ ├── cameras.patch │ ├── ipts.patch │ ├── keyboards_and_covers.patch │ ├── sdcard_reader.patch │ ├── surfaceacpi.patch │ ├── surfacedock.patch │ └── wifi.patch ├── 4.15 │ ├── acpica.patch │ ├── cameras.patch │ ├── ipts.patch │ ├── keyboards_and_covers.patch │ ├── sdcard_reader.patch │ ├── surfaceacpi.patch │ ├── surfacedock.patch │ └── wifi.patch ├── 4.16 │ ├── acpica.patch │ ├── cameras.patch │ ├── ipts.patch │ ├── keyboards_and_covers.patch │ ├── sdcard_reader.patch │ ├── surfaceacpi.patch │ ├── surfacedock.patch │ └── wifi.patch └── config.patch ├── root ├── etc │ ├── NetworkManager │ │ └── NetworkManager.conf │ ├── X11 │ │ └── xorg.conf.d │ │ │ └── 20-intel.conf │ ├── initramfs-tools │ │ └── modules │ ├── pulse │ │ └── daemon.conf │ ├── systemd │ │ ├── logind.conf │ │ └── sleep.conf │ └── udev │ │ └── rules.d │ │ ├── 98-keyboardscovers.rules │ │ └── 99-touchscreens.rules └── lib │ └── systemd │ └── system-sleep │ └── hibernate └── setup.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.tar.xz 2 | pkg 3 | src 4 | *.tar.sign 5 | linux.install.pkg 6 | linux-stable 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Linux Surface 2 | 3 | Linux running on the Surface Book, Surface Book 2, Surface Pro 3, Surface Pro 4, Surface Pro 2017 and Surface Laptop. Follow the instructions below to install the latest kernel and config files. 4 | 5 | ### What's Working 6 | 7 | * Keyboard (and backlight) (not yet working for Surface Laptop) 8 | * Touchpad 9 | * 2D/3D Acceleration 10 | * Touchscreen 11 | * Pen 12 | * WiFi 13 | * Bluetooth 14 | * Speakers 15 | * Power Button (not yet working for SB2/SP2017) 16 | * Volume Buttons (not yet working for SB2/SP2017) 17 | * SD Card Reader 18 | * Cameras (partial support, disabled for now) 19 | * Hibernate 20 | * Sensors (accelerometer, gyroscope, ambient light sensor) 21 | * Battery Readings (not yet working for SB2/SP2017) 22 | * Docking/Undocking Tablet and Keyboard 23 | * Surface Docks 24 | * DisplayPort 25 | * USB-C (including for HDMI Out) 26 | * Dedicated Nvidia GPU (Surface Book 2) 27 | 28 | ### What's NOT Working 29 | 30 | * Dedicated Nvidia GPU (if you have a performance base on a Surface Book 1, otherwise onboard works fine) 31 | * Cameras (not fully supported yet) 32 | * Suspend (uses Connected Standby which is not supported yet) 33 | 34 | ### Disclaimer 35 | * For the most part, things are tested on a Surface Book. While most things are reportedly fully working on other devices, your mileage may vary. Please look at the issues list for possible exceptions. 36 | 37 | ### Download Pre-built Kernel and Headers 38 | 39 | Downloads for ubuntu based distros (other distros will need to compile from source using the included patches): 40 | https://github.com/jakeday/linux-surface/releases 41 | 42 | Downloads for arch based distros: 43 | https://github.com/pharra/linux-surface/releases 44 | 45 | You will need to download both the image, headers and libc-dev files for the version you want to install. 46 | 47 | ### Instructions 48 | 49 | 0. (Prep) Install Git: 50 | ``` 51 | sudo apt install git 52 | ``` 53 | 1. Clone the linux-surface repo: 54 | ``` 55 | git clone https://github.com/jakeday/linux-surface.git ~/linux-surface 56 | ``` 57 | 2. Change directory to linux-surface repo: 58 | ``` 59 | cd ~/linux-surface 60 | ``` 61 | 3. Run setup script: 62 | ``` 63 | sudo sh setup.sh 64 | ``` 65 | 4. Install the headers, kernel and libc-dev (make sure you cd to your download location first): 66 | ``` 67 | sudo dpkg -i linux-headers-[VERSION].deb linux-image-[VERSION].deb linux-libc-dev-[VERSION].deb 68 | ``` 69 | 5. Reboot on installed kernel. 70 | 71 | ### Compiling the Kernel from Source 72 | 73 | If you don't want to use the pre-built kernel and headers, you can compile the kernel yourself following these steps: 74 | 75 | 0. (Prep) Install the required packages for compiling the kernel: 76 | ``` 77 | sudo apt install build-essential binutils-dev libncurses5-dev libssl-dev ccache bison flex 78 | ``` 79 | 1. Clone the mainline stable kernel repo: 80 | ``` 81 | git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git ~/linux-stable 82 | ``` 83 | 2. Go into the linux-stable directory: 84 | ``` 85 | cd ~/linux-stable 86 | ``` 87 | 3. Checkout the version of the kernel you wish to target (replacing with your target version): 88 | ``` 89 | git checkout v4.y.z 90 | ``` 91 | 4. Apply the kernel patches from the linux-surface repo (this one, and assuming you cloned it to ~/linux-surface): 92 | ``` 93 | for i in ~/linux-surface/patches/[VERSION]/*.patch; do patch -p1 < $i; done 94 | ``` 95 | 5. Get current config file and patch it: 96 | ``` 97 | cat /boot/config-$(uname -r) > .config 98 | patch -p1 < ~/linux-surface/patches/config.patch 99 | ``` 100 | 6. Compile the kernel and headers (for ubuntu, refer to the build guide for your distro): 101 | ``` 102 | make -j \`getconf _NPROCESSORS_ONLN\` deb-pkg LOCALVERSION=-linux-surface 103 | ``` 104 | 7. Install the headers, kernel and libc-dev: 105 | ``` 106 | sudo dpkg -i linux-headers-[VERSION].deb linux-image-[VERSION].deb linux-libc-dev-[VERSION].deb 107 | ``` 108 | 109 | 110 | ### Build in archlinux build system 111 | 112 | It will build the packages for archlinux 113 | Forked from jakeday/linux-surface, I have tested it in my surface pro4. 114 | ``` 115 | git clone https://github.com/jakeday/linux-surface.git 116 | cd linux-surface/build 117 | makepkg -si 118 | ``` 119 | 120 | ### NOTES 121 | 122 | * If you are getting stuck at boot when loading the ramdisk, you need to install the Processor Microcode Firmware for Intel CPUs (usually found under Additional Drivers in Software and Updates). 123 | 124 | ### Donations Appreciated! 125 | 126 | PayPal: https://www.paypal.me/jakeday42 127 | 128 | Bitcoin: 1AH7ByeJBjMoAwsgi9oeNvVLmZHvGoQg68 129 | -------------------------------------------------------------------------------- /archbuild/60-linux.hook: -------------------------------------------------------------------------------- 1 | [Trigger] 2 | Type = File 3 | Operation = Install 4 | Operation = Upgrade 5 | Operation = Remove 6 | Target = usr/lib/modules/%KERNVER%/* 7 | Target = usr/lib/modules/%EXTRAMODULES%/* 8 | 9 | [Action] 10 | Description = Updating %PKGBASE% module dependencies... 11 | When = PostTransaction 12 | Exec = /usr/bin/depmod %KERNVER% 13 | -------------------------------------------------------------------------------- /archbuild/90-linux.hook: -------------------------------------------------------------------------------- 1 | [Trigger] 2 | Type = File 3 | Operation = Install 4 | Operation = Upgrade 5 | Target = boot/vmlinuz-%PKGBASE% 6 | Target = usr/lib/initcpio/* 7 | 8 | [Action] 9 | Description = Updating %PKGBASE% initcpios... 10 | When = PostTransaction 11 | Exec = /usr/bin/mkinitcpio -p %PKGBASE% 12 | -------------------------------------------------------------------------------- /archbuild/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Shadoukun 2 | # Contributor: SuperBo 3 | # Maintainer: Tobias Powalowski 4 | # Maintainer: Thomas Baechler 5 | 6 | #pkgbase=linux # Build stock -ARCH kernel 7 | pkgbase=linux-surface4 # Build kernel with a different name 8 | _srcname=linux-stable 9 | pkgver=4.16.2 10 | _version=4.14 11 | pkgrel=1 12 | arch=('x86_64') 13 | url="https://www.kernel.org/" 14 | license=('GPL2') 15 | makedepends=('xmlto' 'kmod' 'inetutils' 'bc' 'libelf') 16 | options=('!strip') 17 | source=( 18 | git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git 19 | #"https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.xz" 20 | #"https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.sign" 21 | #"https://www.kernel.org/pub/linux/kernel/v4.x/patch-${pkgver}.xz" 22 | #"https://www.kernel.org/pub/linux/kernel/v4.x/patch-${pkgver}.sign" 23 | 'config.4.15' # the main kernel config file 24 | 'config.4.14' # the main kernel config file 25 | 'config.4.16' # the main kernel config file 26 | '60-linux.hook' # pacman hook for depmod 27 | '90-linux.hook' # pacman hook for initramfs regeneration 28 | 'linux.preset' # standard config files for mkinitcpio ramdisk 29 | ) 30 | validpgpkeys=( 31 | 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds 32 | '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman 33 | ) 34 | sha256sums=('SKIP' 35 | '63c757923f7d23fb920456d05babb8a1911e203e927b3dce12424844ae8222fd' 36 | '4834ac3660bf870c855a29fd156eb227cbb5d9c93ee217d4ea578184a83e65f6' 37 | 'a742860b05018374844e063c35f17841ba05c8be969edd5ea9fb6757c4323de5' 38 | 'ae2e95db94ef7176207c690224169594d49445e04249d2499e9d2fbc117a0b21' 39 | '75f99f5239e03238f88d1a834c50043ec32b1dc568f2cc291b07d04718483919' 40 | 'ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65') 41 | 42 | _kernelname=${pkgbase#linux} 43 | 44 | pkgver() { 45 | cd "${_srcname}" 46 | git describe --always | tr -d 'v' 47 | } 48 | 49 | prepare() { 50 | cd ${_srcname} 51 | echo "choose kernel version which you want to build(input 1or2or3):" 52 | select _version in "4.14" "4.15" "4.16" ;do 53 | break; 54 | done 55 | git pull 56 | git add . && git reset --hard HEAD^1 57 | git checkout "linux-${_version}.y" 58 | #git pull 59 | #pkgver=`git describe --always | tr -d 'v'` 60 | #echo ${pkgver} 61 | # add upstream patch 62 | #patch -p1 -i ../patch-${pkgver} 63 | 64 | # security patches 65 | 66 | # add latest fixes from stable queue, if needed 67 | # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git 68 | 69 | # https://bugs.archlinux.org/task/56207 70 | # patch -Np1 -i ../0001-platform-x86-hp-wmi-Fix-tablet-mode-detection-for-co.patch 71 | 72 | # surface Patches 73 | for i in ${srcdir}/../../patches/${_version}/*.patch; 74 | do patch -p1 < $i; 75 | done 76 | #patch -Np1 -i "${srcdir}/patches/4.15//ipts.patch" 77 | #patch -Np1 -i "${srcdir}/sdcard_reader.patch" 78 | #patch -Np1 -i "${srcdir}/wifi.patch" 79 | #patch -Np1 -i "${srcdir}/keyboards_and_covers.patch" 80 | #patch -Np1 -i "${srcdir}/surfacedock.patch" 81 | #patch -Np1 -i "${srcdir}/surfaceacpi.patch" 82 | #patch -Np1 -i "${srcdir}/cameras.patch" 83 | #patch -Np1 -i "${srcdir}/acpica.patch" 84 | cp -Tf ../config.${_version} .config 85 | 86 | if [ "${_kernelname}" != "" ]; then 87 | sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config 88 | sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config 89 | fi 90 | # set extraversion to pkgrel 91 | sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile 92 | 93 | # don't run depmod on 'make install'. We'll do this ourselves in packaging 94 | sed -i '2iexit 0' scripts/depmod.sh 95 | 96 | # get kernel version 97 | make prepare 98 | 99 | # load configuration 100 | # Configure the kernel. Replace the line below with one of your choice. 101 | #make menuconfig # CLI menu for configuration 102 | #make nconfig # new CLI menu for configuration 103 | #make xconfig # X-based configuration 104 | #make oldconfig # using old config from previous kernel version 105 | # ... or manually edit .config 106 | 107 | # rewrite configuration 108 | yes "" | make config >/dev/null 109 | } 110 | 111 | build() { 112 | cd ${_srcname} 113 | 114 | make ${MAKEFLAGS} LOCALVERSION= bzImage modules 115 | } 116 | 117 | _package() { 118 | pkgdesc="The ${pkgbase/linux/Linux} kernel and modules" 119 | [ "${pkgbase}" = "linux" ] && groups=('base') 120 | depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7') 121 | optdepends=('crda: to set the correct wireless channels of your country') 122 | backup=("etc/mkinitcpio.d/${pkgbase}.preset") 123 | install=linux.install 124 | 125 | cd ${_srcname} 126 | 127 | # get kernel version 128 | _kernver="$(make LOCALVERSION= kernelrelease)" 129 | _basekernel=${_kernver%%-*} 130 | _basekernel=${_basekernel%.*} 131 | 132 | mkdir -p "${pkgdir}"/{boot,lib/{modules,firmware},usr} 133 | make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}" modules_install 134 | cp arch/x86/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}" 135 | 136 | # make room for external modules 137 | local _extramodules="extramodules-${_basekernel}${_kernelname:--ARCH}" 138 | ln -s "../${_extramodules}" "${pkgdir}/lib/modules/${_kernver}/extramodules" 139 | 140 | # add real version for building modules and running depmod from hook 141 | echo "${_kernver}" | 142 | install -Dm644 /dev/stdin "${pkgdir}/lib/modules/${_extramodules}/version" 143 | 144 | # remove build and source links 145 | rm "${pkgdir}"/lib/modules/${_kernver}/{source,build} 146 | 147 | # remove the firmware 148 | rm -r "${pkgdir}/lib/firmware" 149 | 150 | # now we call depmod... 151 | depmod -b "${pkgdir}" -F System.map "${_kernver}" 152 | 153 | # add vmlinux 154 | install -Dt "${pkgdir}/lib/modules/${_kernver}/build" -m644 vmlinux 155 | 156 | # move module tree /lib -> /usr/lib 157 | mv -t "${pkgdir}/usr" "${pkgdir}/lib" 158 | 159 | # sed expression for following substitutions 160 | local _subst=" 161 | s|%PKGBASE%|${pkgbase}|g 162 | s|%KERNVER%|${_kernver}|g 163 | s|%EXTRAMODULES%|${_extramodules}|g 164 | " 165 | 166 | # hack to allow specifying an initially nonexisting install file 167 | sed "${_subst}" "${startdir}/${install}" > "${startdir}/${install}.pkg" 168 | true && install=${install}.pkg 169 | 170 | # install mkinitcpio preset file 171 | sed "${_subst}" ../linux.preset | 172 | install -Dm644 /dev/stdin "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset" 173 | 174 | # install pacman hooks 175 | sed "${_subst}" ../60-linux.hook | 176 | install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/60-${pkgbase}.hook" 177 | sed "${_subst}" ../90-linux.hook | 178 | install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/90-${pkgbase}.hook" 179 | 180 | install -D -C -m644 "${srcdir}/../../root/etc/udev/rules.d/99-touchscreens.rules" "${pkgdir}/usr/lib/udev/rules.d/99-touchscreens.rules" 181 | install -D -C -m644 "${srcdir}/../../root/etc/udev/rules.d/98-keyboardscovers.rules" "${pkgdir}/usr/lib/udev/rules.d/98-keyboardscovers.rules" 182 | 183 | } 184 | 185 | _package-headers() { 186 | pkgdesc="Header files and scripts for building modules for ${pkgbase/linux/Linux} kernel" 187 | 188 | cd ${_srcname} 189 | local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build" 190 | 191 | install -Dt "${_builddir}" -m644 Makefile .config Module.symvers 192 | install -Dt "${_builddir}/kernel" -m644 kernel/Makefile 193 | 194 | mkdir "${_builddir}/.tmp_versions" 195 | 196 | cp -t "${_builddir}" -a include scripts 197 | 198 | install -Dt "${_builddir}/arch/x86" -m644 arch/x86/Makefile 199 | install -Dt "${_builddir}/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s 200 | 201 | cp -t "${_builddir}/arch/x86" -a arch/x86/include 202 | 203 | install -Dt "${_builddir}/drivers/md" -m644 drivers/md/*.h 204 | install -Dt "${_builddir}/net/mac80211" -m644 net/mac80211/*.h 205 | 206 | # http://bugs.archlinux.org/task/9912 207 | # install -Dt "${_builddir}/drivers/media/dvb-core" -m644 drivers/media/dvb-core/*.h 208 | 209 | # http://bugs.archlinux.org/task/13146 210 | install -Dt "${_builddir}/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/lgdt330x.h 211 | install -Dt "${_builddir}/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h 212 | 213 | # http://bugs.archlinux.org/task/20402 214 | install -Dt "${_builddir}/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h 215 | install -Dt "${_builddir}/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h 216 | install -Dt "${_builddir}/drivers/media/tuners" -m644 drivers/media/tuners/*.h 217 | 218 | # add xfs and shmem for aufs building 219 | mkdir -p "${_builddir}"/{fs/xfs,mm} 220 | 221 | # copy in Kconfig files 222 | find . -name Kconfig\* -exec install -Dm644 {} "${_builddir}/{}" \; 223 | 224 | # add objtool for external module building and enabled VALIDATION_STACK option 225 | install -Dt "${_builddir}/tools/objtool" tools/objtool/objtool 226 | 227 | # remove unneeded architectures 228 | local _arch 229 | for _arch in "${_builddir}"/arch/*/; do 230 | [[ ${_arch} == */x86/ ]] && continue 231 | rm -r "${_arch}" 232 | done 233 | 234 | # remove files already in linux-docs package 235 | rm -r "${_builddir}/Documentation" 236 | 237 | # Fix permissions 238 | chmod -R u=rwX,go=rX "${_builddir}" 239 | 240 | # strip scripts directory 241 | local _binary _strip 242 | while read -rd '' _binary; do 243 | case "$(file -bi "${_binary}")" in 244 | *application/x-sharedlib*) _strip="${STRIP_SHARED}" ;; # Libraries (.so) 245 | *application/x-archive*) _strip="${STRIP_STATIC}" ;; # Libraries (.a) 246 | *application/x-executable*) _strip="${STRIP_BINARIES}" ;; # Binaries 247 | *) continue ;; 248 | esac 249 | /usr/bin/strip ${_strip} "${_binary}" 250 | done < <(find "${_builddir}/scripts" -type f -perm -u+w -print0 2>/dev/null) 251 | } 252 | 253 | _package-docs() { 254 | pkgdesc="Kernel hackers manual - HTML documentation that comes with the ${pkgbase/linux/Linux} kernel" 255 | 256 | cd ${_srcname} 257 | local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build" 258 | 259 | mkdir -p "${_builddir}" 260 | cp -t "${_builddir}" -a Documentation 261 | 262 | # Fix permissions 263 | chmod -R u=rwX,go=rX "${_builddir}" 264 | } 265 | 266 | pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-docs") 267 | for _p in ${pkgname[@]}; do 268 | eval "package_${_p}() { 269 | $(declare -f "_package${_p#${pkgbase}}") 270 | _package${_p#${pkgbase}} 271 | }" 272 | done 273 | 274 | # vim:set ts=8 sts=2 sw=2 et: 275 | -------------------------------------------------------------------------------- /archbuild/linux.install: -------------------------------------------------------------------------------- 1 | post_install () { 2 | # updating module dependencies 3 | echo ">>> Updating module dependencies. Please wait ..." 4 | depmod %KERNVER% 5 | 6 | firmware_instruct 7 | } 8 | 9 | post_upgrade() { 10 | if findmnt --fstab -uno SOURCE /boot &>/dev/null && ! mountpoint -q /boot; then 11 | echo "WARNING: /boot appears to be a separate partition but is not mounted." 12 | fi 13 | 14 | firmware_instruct 15 | } 16 | 17 | post_remove() { 18 | rm -f boot/initramfs-%PKGBASE%.img 19 | rm -f boot/initramfs-%PKGBASE%-fallback.img 20 | } 21 | 22 | 23 | firmware_instruct() { 24 | 25 | echo -e " 26 | #### Firmware Installation Instructions #### 27 | 28 | 29 | ## WIFI ## 30 | 31 | Install the latest Marvell firmware: 32 | 33 | $ git clone git://git.marvell.com/mwifiex-firmware.git 34 | $ sudo mkdir -p /lib/firmware/mrvl/ 35 | $ sudo cp mwifiex-firmware/mrvl/* /lib/firmware/mrvl/ 36 | 37 | 38 | ## IPTS / Touchscreen ## 39 | 40 | To enable the touchscreen to function properly, 41 | the proper firmware for your device must be downloaded. 42 | 43 | i915 Firmware: 44 | https://github.com/jakeday/linux-surface/raw/master/i915_firmware.zip 45 | 46 | Extract i915_firmware.zip to /lib/firmware/i915/: 47 | 48 | $ sudo mkdir -p /lib/firmware/i915 49 | $ sudo unzip i915_firmware.zip -d /lib/firmware/i915/ 50 | 51 | 52 | IPTS Firmware: 53 | 54 | v76 for the Surface Book 55 | https://github.com/jakeday/linux-surface/raw/master/ipts_firmware_v76.zip 56 | 57 | v78 for the Surface Pro 4 58 | https://github.com/jakeday/linux-surface/raw/master/ipts_firmware_v78.zip 59 | 60 | v79 for the Surface Laptop 61 | https://github.com/jakeday/linux-surface/raw/master/ipts_firmware_v79.zip 62 | 63 | v101 for Surface Book 2 15\" 64 | https://github.com/jakeday/linux-surface/raw/master/ipts_firmware_v101.zip 65 | 66 | v102 for the Surface Pro 2017 67 | https://github.com/jakeday/linux-surface/raw/master/ipts_firmware_v102.zip 68 | 69 | v137 for the Surface Book 2 13\" 70 | https://github.com/jakeday/linux-surface/raw/master/ipts_firmware_v137.zip 71 | 72 | 73 | Extract ipts_firmware_[VERSION].zip to /lib/firmware/intel/ipts/ 74 | 75 | $ sudo mkdir -p /lib/firmware/intel/ipts 76 | $ sudo unzip ipts_firmware_[VERSION].zip -d /lib/firmware/intel/ipts/ 77 | 78 | " 79 | } -------------------------------------------------------------------------------- /archbuild/linux.preset: -------------------------------------------------------------------------------- 1 | # mkinitcpio preset file for the '%PKGBASE%' package 2 | 3 | ALL_config="/etc/mkinitcpio.conf" 4 | ALL_kver="/boot/vmlinuz-%PKGBASE%" 5 | 6 | PRESETS=('default' 'fallback') 7 | 8 | #default_config="/etc/mkinitcpio.conf" 9 | default_image="/boot/initramfs-%PKGBASE%.img" 10 | #default_options="" 11 | 12 | #fallback_config="/etc/mkinitcpio.conf" 13 | fallback_image="/boot/initramfs-%PKGBASE%-fallback.img" 14 | fallback_options="-S autodetect" 15 | -------------------------------------------------------------------------------- /firmware/i915_firmware_bxt.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/i915_firmware_bxt.zip -------------------------------------------------------------------------------- /firmware/i915_firmware_cfl.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/i915_firmware_cfl.zip -------------------------------------------------------------------------------- /firmware/i915_firmware_cnl.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/i915_firmware_cnl.zip -------------------------------------------------------------------------------- /firmware/i915_firmware_glk.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/i915_firmware_glk.zip -------------------------------------------------------------------------------- /firmware/i915_firmware_kbl.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/i915_firmware_kbl.zip -------------------------------------------------------------------------------- /firmware/i915_firmware_skl.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/i915_firmware_skl.zip -------------------------------------------------------------------------------- /firmware/ipts_firmware_v101.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/ipts_firmware_v101.zip -------------------------------------------------------------------------------- /firmware/ipts_firmware_v102.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/ipts_firmware_v102.zip -------------------------------------------------------------------------------- /firmware/ipts_firmware_v103.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/ipts_firmware_v103.zip -------------------------------------------------------------------------------- /firmware/ipts_firmware_v137.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/ipts_firmware_v137.zip -------------------------------------------------------------------------------- /firmware/ipts_firmware_v76.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/ipts_firmware_v76.zip -------------------------------------------------------------------------------- /firmware/ipts_firmware_v78.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/ipts_firmware_v78.zip -------------------------------------------------------------------------------- /firmware/ipts_firmware_v79.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/ipts_firmware_v79.zip -------------------------------------------------------------------------------- /firmware/mrvl_firmware.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/mrvl_firmware.zip -------------------------------------------------------------------------------- /firmware/nvidia_firmware_gp108.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/firmware/nvidia_firmware_gp108.zip -------------------------------------------------------------------------------- /packages/libwacom/libwacom_0.29-1-surface_amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pharra/linux-surface/864401f1df70ce3f58cc34a671622262fe99c2f4/packages/libwacom/libwacom_0.29-1-surface_amd64.deb -------------------------------------------------------------------------------- /patches/4.14/acpica.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/acpi/acpica/dbdisply.c b/drivers/acpi/acpica/dbdisply.c 2 | index 5a606ea..7b5eb33 100644 3 | --- a/drivers/acpi/acpica/dbdisply.c 4 | +++ b/drivers/acpi/acpica/dbdisply.c 5 | @@ -642,9 +642,8 @@ void acpi_db_display_object_type(char *object_arg) 6 | return; 7 | } 8 | 9 | - acpi_os_printf("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", 10 | - ACPI_FORMAT_UINT64(info->address), 11 | - info->current_status, info->flags); 12 | + acpi_os_printf("ADR: %8.8X%8.8X, Flags: %X\n", 13 | + ACPI_FORMAT_UINT64(info->address), info->flags); 14 | 15 | acpi_os_printf("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", 16 | info->highest_dstates[0], info->highest_dstates[1], 17 | diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c 18 | index d3b6b31..37b0b4c 100644 19 | --- a/drivers/acpi/acpica/evevent.c 20 | +++ b/drivers/acpi/acpica/evevent.c 21 | @@ -204,6 +204,7 @@ u32 acpi_ev_fixed_event_detect(void) 22 | u32 fixed_status; 23 | u32 fixed_enable; 24 | u32 i; 25 | + acpi_status status; 26 | 27 | ACPI_FUNCTION_NAME(ev_fixed_event_detect); 28 | 29 | @@ -211,8 +212,12 @@ u32 acpi_ev_fixed_event_detect(void) 30 | * Read the fixed feature status and enable registers, as all the cases 31 | * depend on their values. Ignore errors here. 32 | */ 33 | - (void)acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status); 34 | - (void)acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable); 35 | + status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status); 36 | + status |= 37 | + acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable); 38 | + if (ACPI_FAILURE(status)) { 39 | + return (int_status); 40 | + } 41 | 42 | ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, 43 | "Fixed Event Block: Enable %08X Status %08X\n", 44 | diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c 45 | index a8191d2..2ad13d8 100644 46 | --- a/drivers/acpi/acpica/exdebug.c 47 | +++ b/drivers/acpi/acpica/exdebug.c 48 | @@ -88,14 +88,13 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc, 49 | return_VOID; 50 | } 51 | 52 | - /* Null string or newline -- don't emit the line header */ 53 | + /* Newline -- don't emit the line header */ 54 | 55 | if (source_desc && 56 | (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) && 57 | (source_desc->common.type == ACPI_TYPE_STRING)) { 58 | - if ((source_desc->string.length == 0) || 59 | - ((source_desc->string.length == 1) && 60 | - (*source_desc->string.pointer == '\n'))) { 61 | + if ((source_desc->string.length == 1) && 62 | + (*source_desc->string.pointer == '\n')) { 63 | acpi_os_printf("\n"); 64 | return_VOID; 65 | } 66 | diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c 67 | index 5026594..573a5f3 100644 68 | --- a/drivers/acpi/acpica/nsdumpdv.c 69 | +++ b/drivers/acpi/acpica/nsdumpdv.c 70 | @@ -88,10 +88,9 @@ acpi_ns_dump_one_device(acpi_handle obj_handle, 71 | } 72 | 73 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, 74 | - " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", 75 | + " HID: %s, ADR: %8.8X%8.8X\n", 76 | info->hardware_id.value, 77 | - ACPI_FORMAT_UINT64(info->address), 78 | - info->current_status)); 79 | + ACPI_FORMAT_UINT64(info->address)); 80 | ACPI_FREE(info); 81 | } 82 | 83 | diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c 84 | index 1069662..0a9c600 100644 85 | --- a/drivers/acpi/acpica/nsxfname.c 86 | +++ b/drivers/acpi/acpica/nsxfname.c 87 | @@ -241,7 +241,7 @@ static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, 88 | * namespace node and possibly by running several standard 89 | * control methods (Such as in the case of a device.) 90 | * 91 | - * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, 92 | + * For Device and Processor objects, run the Device _HID, _UID, _CID, 93 | * _CLS, _ADR, _sx_w, and _sx_d methods. 94 | * 95 | * Note: Allocates the return buffer, must be freed by the caller. 96 | @@ -250,8 +250,9 @@ static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, 97 | * discovery namespace traversal. Therefore, no complex methods can be 98 | * executed, especially those that access operation regions. Therefore, do 99 | * not add any additional methods that could cause problems in this area. 100 | - * this was the fate of the _SUB method which was found to cause such 101 | - * problems and was removed (11/2015). 102 | + * Because of this reason support for the following methods has been removed: 103 | + * 1) _SUB method was removed (11/2015) 104 | + * 2) _STA method was removed (02/2018) 105 | * 106 | ******************************************************************************/ 107 | 108 | @@ -374,20 +375,8 @@ acpi_get_object_info(acpi_handle handle, 109 | * Notes: none of these methods are required, so they may or may 110 | * not be present for this device. The Info->Valid bitfield is used 111 | * to indicate which methods were found and run successfully. 112 | - * 113 | - * For _STA, if the method does not exist, then (as per the ACPI 114 | - * specification), the returned current_status flags will indicate 115 | - * that the device is present/functional/enabled. Otherwise, the 116 | - * current_status flags reflect the value returned from _STA. 117 | */ 118 | 119 | - /* Execute the Device._STA method */ 120 | - 121 | - status = acpi_ut_execute_STA(node, &info->current_status); 122 | - if (ACPI_SUCCESS(status)) { 123 | - valid |= ACPI_VALID_STA; 124 | - } 125 | - 126 | /* Execute the Device._ADR method */ 127 | 128 | status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node, 129 | diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c 130 | index eb9dfac..11ce4e5 100644 131 | --- a/drivers/acpi/acpica/psargs.c 132 | +++ b/drivers/acpi/acpica/psargs.c 133 | @@ -890,6 +890,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, 134 | ACPI_POSSIBLE_METHOD_CALL); 135 | 136 | if (arg->common.aml_opcode == AML_INT_METHODCALL_OP) { 137 | + 138 | + /* Free method call op and corresponding namestring sub-ob */ 139 | + 140 | + acpi_ps_free_op(arg->common.value.arg); 141 | acpi_ps_free_op(arg); 142 | arg = NULL; 143 | walk_state->arg_count = 1; 144 | diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c 145 | index b6d58cc..5c00e5e 100644 146 | --- a/drivers/acpi/bus.c 147 | +++ b/drivers/acpi/bus.c 148 | @@ -135,6 +135,7 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle, 149 | } 150 | return status; 151 | } 152 | +EXPORT_SYMBOL_GPL(acpi_bus_get_status_handle); 153 | 154 | int acpi_bus_get_status(struct acpi_device *device) 155 | { 156 | @@ -146,6 +147,12 @@ int acpi_bus_get_status(struct acpi_device *device) 157 | return 0; 158 | } 159 | 160 | + /* Battery devices must have their deps met before calling _STA */ 161 | + if (acpi_device_is_battery(device) && device->dep_unmet) { 162 | + acpi_set_device_status(device, 0); 163 | + return 0; 164 | + } 165 | + 166 | status = acpi_bus_get_status_handle(device->handle, &sta); 167 | if (ACPI_FAILURE(status)) 168 | return -ENODEV; 169 | diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c 170 | index 984c7e8..8472c4a 100644 171 | --- a/drivers/pci/hotplug/acpiphp_ibm.c 172 | +++ b/drivers/pci/hotplug/acpiphp_ibm.c 173 | @@ -399,6 +399,7 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle, 174 | u32 lvl, void *context, void **rv) 175 | { 176 | acpi_handle *phandle = (acpi_handle *)context; 177 | + unsigned long long current_status = 0; 178 | acpi_status status; 179 | struct acpi_device_info *info; 180 | int retval = 0; 181 | @@ -410,7 +411,9 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle, 182 | return retval; 183 | } 184 | 185 | - if (info->current_status && (info->valid & ACPI_VALID_HID) && 186 | + acpi_bus_get_status_handle(handle, ¤t_status); 187 | + 188 | + if (current_status && (info->valid & ACPI_VALID_HID) && 189 | (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) || 190 | !strcmp(info->hardware_id.string, IBM_HARDWARE_ID2))) { 191 | pr_debug("found hardware: %s, handle: %p\n", 192 | diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h 193 | index 4f077ed..220ef86 100644 194 | --- a/include/acpi/actypes.h 195 | +++ b/include/acpi/actypes.h 196 | @@ -1191,7 +1191,6 @@ struct acpi_device_info { 197 | u8 flags; /* Miscellaneous info */ 198 | u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */ 199 | u8 lowest_dstates[5]; /* _sx_w values: 0xFF indicates not valid */ 200 | - u32 current_status; /* _STA value */ 201 | u64 address; /* _ADR value */ 202 | struct acpi_pnp_device_id hardware_id; /* _HID value */ 203 | struct acpi_pnp_device_id unique_id; /* _UID value */ 204 | @@ -1205,7 +1204,6 @@ struct acpi_device_info { 205 | 206 | /* Flags for Valid field above (acpi_get_object_info) */ 207 | 208 | -#define ACPI_VALID_STA 0x0001 209 | #define ACPI_VALID_ADR 0x0002 210 | #define ACPI_VALID_HID 0x0004 211 | #define ACPI_VALID_UID 0x0008 212 | -------------------------------------------------------------------------------- /patches/4.14/cameras.patch: -------------------------------------------------------------------------------- 1 | From d4460b8c7124d6dd878acbd3207e2c41ceec5266 Mon Sep 17 00:00:00 2001 2 | From: Jake Day 3 | Date: Thu, 1 Feb 2018 19:25:08 -0500 4 | Subject: initial support for surface cameras 5 | 6 | 7 | diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c 8 | index 6d22b22..b72b782 100644 9 | --- a/drivers/media/usb/uvc/uvc_driver.c 10 | +++ b/drivers/media/usb/uvc/uvc_driver.c 11 | @@ -2277,6 +2277,46 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout"); 12 | * though they are compliant. 13 | */ 14 | static const struct usb_device_id uvc_ids[] = { 15 | + /* Microsoft Surface Pro 3 Front */ 16 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 17 | + | USB_DEVICE_ID_MATCH_INT_INFO, 18 | + .idVendor = 0x045e, 19 | + .idProduct = 0x07be, 20 | + .bInterfaceClass = USB_CLASS_VIDEO, 21 | + .bInterfaceSubClass = 1, 22 | + .bInterfaceProtocol = 1 }, 23 | + /* Microsoft Surface Pro 3 Rear */ 24 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 25 | + | USB_DEVICE_ID_MATCH_INT_INFO, 26 | + .idVendor = 0x045e, 27 | + .idProduct = 0x07bf, 28 | + .bInterfaceClass = USB_CLASS_VIDEO, 29 | + .bInterfaceSubClass = 1, 30 | + .bInterfaceProtocol = 1 }, 31 | + /* Microsoft Surface Pro 4 Cam */ 32 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 33 | + | USB_DEVICE_ID_MATCH_INT_INFO, 34 | + .idVendor = 0x045e, 35 | + .idProduct = 0x090c, 36 | + .bInterfaceClass = USB_CLASS_VIDEO, 37 | + .bInterfaceSubClass = 1, 38 | + .bInterfaceProtocol = 1 }, 39 | + /* Microsoft Surface Book Cam 1 */ 40 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 41 | + | USB_DEVICE_ID_MATCH_INT_INFO, 42 | + .idVendor = 0x045e, 43 | + .idProduct = 0x090b, 44 | + .bInterfaceClass = USB_CLASS_VIDEO, 45 | + .bInterfaceSubClass = 1, 46 | + .bInterfaceProtocol = 1 }, 47 | + /* Microsoft Surface Book Cam 2 */ 48 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 49 | + | USB_DEVICE_ID_MATCH_INT_INFO, 50 | + .idVendor = 0x045e, 51 | + .idProduct = 0x091a, 52 | + .bInterfaceClass = USB_CLASS_VIDEO, 53 | + .bInterfaceSubClass = 1, 54 | + .bInterfaceProtocol = 1 }, 55 | /* LogiLink Wireless Webcam */ 56 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 57 | | USB_DEVICE_ID_MATCH_INT_INFO, 58 | diff --git a/drivers/staging/media/atomisp/i2c/ov5693/Kconfig b/drivers/staging/media/atomisp/i2c/ov5693/Kconfig 59 | index 9fb1bff..3954b8c 100644 60 | --- a/drivers/staging/media/atomisp/i2c/ov5693/Kconfig 61 | +++ b/drivers/staging/media/atomisp/i2c/ov5693/Kconfig 62 | @@ -1,6 +1,6 @@ 63 | config VIDEO_OV5693 64 | tristate "Omnivision ov5693 sensor support" 65 | - depends on I2C && VIDEO_V4L2 66 | + depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER 67 | ---help--- 68 | This is a Video4Linux2 sensor-level driver for the Micron 69 | ov5693 5 Mpixel camera. 70 | diff --git a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c 71 | index 1236425..37986f5 100644 72 | --- a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c 73 | +++ b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c 74 | @@ -1332,7 +1332,7 @@ static int power_ctrl(struct v4l2_subdev *sd, bool flag) 75 | 76 | static int gpio_ctrl(struct v4l2_subdev *sd, bool flag) 77 | { 78 | - int ret; 79 | + int ret = 0; 80 | struct ov5693_device *dev = to_ov5693_sensor(sd); 81 | 82 | if (!dev || !dev->platform_data) 83 | @@ -1342,7 +1342,8 @@ static int gpio_ctrl(struct v4l2_subdev *sd, bool flag) 84 | if (dev->platform_data->gpio_ctrl) 85 | return dev->platform_data->gpio_ctrl(sd, flag); 86 | 87 | - ret = dev->platform_data->gpio0_ctrl(sd, flag); 88 | + if (dev->platform_data->gpio0_ctrl) 89 | + ret = dev->platform_data->gpio0_ctrl(sd, flag); 90 | 91 | return ret; 92 | } 93 | @@ -1709,7 +1710,7 @@ static int ov5693_detect(struct i2c_client *client) 94 | OV5693_SC_CMMN_CHIP_ID_L, &low); 95 | id = ((((u16) high) << 8) | (u16) low); 96 | 97 | - if (id != OV5693_ID) { 98 | + if (id != OV5690_ID && id != OV5693_ID) { 99 | dev_err(&client->dev, "sensor ID error 0x%x\n", id); 100 | return -ENODEV; 101 | } 102 | diff --git a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h 103 | index 8c2e679..a657f94 100644 104 | --- a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h 105 | +++ b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h 106 | @@ -33,7 +33,7 @@ 107 | #include 108 | #include 109 | 110 | -#include "../../include/linux/atomisp_platform.h" 111 | +#include "../../include/linux/atomisp_gmin_platform.h" 112 | 113 | #define OV5693_NAME "ov5693" 114 | 115 | @@ -78,7 +78,8 @@ 116 | * bits 7-0: min f-number denominator 117 | */ 118 | #define OV5693_F_NUMBER_RANGE 0x180a180a 119 | -#define OV5693_ID 0x5690 120 | +#define OV5690_ID 0x5690 121 | +#define OV5693_ID 0x5693 122 | 123 | #define OV5693_FINE_INTG_TIME_MIN 0 124 | #define OV5693_FINE_INTG_TIME_MAX_MARGIN 0 125 | diff --git a/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c 126 | index edaae93..ca59c4f 100644 127 | --- a/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c 128 | +++ b/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c 129 | @@ -296,11 +296,13 @@ static const struct gmin_cfg_var ecs7_vars[] = { 130 | {"INT33BE:00_CsiFmt", "13"}, 131 | {"INT33BE:00_CsiBayer", "2"}, 132 | {"INT33BE:00_CamClk", "0"}, 133 | + {"INT33BE:00_ClkSrc", "1"}, 134 | {"INT33F0:00_CsiPort", "0"}, 135 | {"INT33F0:00_CsiLanes", "1"}, 136 | {"INT33F0:00_CsiFmt", "13"}, 137 | {"INT33F0:00_CsiBayer", "0"}, 138 | {"INT33F0:00_CamClk", "1"}, 139 | + {"INT33BE:00_I2CAddr", "-1"}, 140 | {"gmin_V2P8GPIO", "402"}, 141 | {}, 142 | }; 143 | @@ -325,6 +327,8 @@ static const struct { 144 | { "MRD7", mrd7_vars }, 145 | { "ST70408", ecs7_vars }, 146 | { "VTA0803", i8880_vars }, 147 | + { "Surface Book" , ecs7_vars } , 148 | + { "Surface Pro 4" , ecs7_vars } , 149 | }; 150 | 151 | 152 | -------------------------------------------------------------------------------- /patches/4.14/keyboards_and_covers.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h 2 | index ff539c0..d8cc7b2 100644 3 | --- a/drivers/hid/hid-ids.h 4 | +++ b/drivers/hid/hid-ids.h 5 | @@ -760,11 +760,22 @@ 6 | #define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3KV1 0x0732 7 | #define USB_DEVICE_ID_MS_DIGITAL_MEDIA_600 0x0750 8 | #define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c 9 | -#define USB_DEVICE_ID_MS_COMFORT_KEYBOARD 0x00e3 10 | -#define USB_DEVICE_ID_MS_SURFACE_PRO_2 0x0799 11 | -#define USB_DEVICE_ID_MS_TOUCH_COVER_2 0x07a7 12 | -#define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9 13 | -#define USB_DEVICE_ID_MS_POWER_COVER 0x07da 14 | +#define USB_DEVICE_ID_MS_COMFORT_KEYBOARD 0x00e3 15 | +#define USB_DEVICE_ID_MS_SURFACE_PRO_2 0x0799 16 | +#define USB_DEVICE_ID_MS_TOUCH_COVER_2 0x07a7 17 | +#define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9 18 | +#define USB_DEVICE_ID_MS_TYPE_COVER_3 0x07de 19 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3 0x07dc 20 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_1 0x07de 21 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2 0x07e2 22 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP 0x07dd 23 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_4 0x07e8 24 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_1 0x07e4 25 | +#define USB_DEVICE_ID_MS_SURFACE_BOOK 0x07cd 26 | +#define USB_DEVICE_ID_MS_SURFACE_BOOK_2 0x0922 27 | +#define USB_DEVICE_ID_MS_SURFACE_LAPTOP 0xf001 28 | +#define HID_DEVICE_ID_MS_SURFACE_LAPTOP 0xf001 29 | +#define USB_DEVICE_ID_MS_POWER_COVER 0x07da 30 | 31 | #define USB_VENDOR_ID_MOJO 0x8282 32 | #define USB_DEVICE_ID_RETRO_ADAPTER 0x3201 33 | diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c 34 | index 9e8c4d2..bd1b82e 100644 35 | --- a/drivers/hid/hid-multitouch.c 36 | +++ b/drivers/hid/hid-multitouch.c 37 | @@ -1594,6 +1594,58 @@ static const struct hid_device_id mt_devices[] = { 38 | HID_USB_DEVICE(USB_VENDOR_ID_LG, 39 | USB_DEVICE_ID_LG_MELFAS_MT) }, 40 | 41 | + /* Microsoft Touch Cover */ 42 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 43 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 44 | + USB_DEVICE_ID_MS_TOUCH_COVER_2) }, 45 | + 46 | + /* Microsoft Type Cover */ 47 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 48 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 49 | + USB_DEVICE_ID_MS_TYPE_COVER_2) }, 50 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 51 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 52 | + USB_DEVICE_ID_MS_TYPE_COVER_3) }, 53 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 54 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 55 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3) }, 56 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 57 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 58 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_1) }, 59 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 60 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 61 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2) }, 62 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 63 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 64 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP) }, 65 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 66 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 67 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_4) }, 68 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 69 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 70 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_1) }, 71 | + 72 | + /* Microsoft Surface Book */ 73 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 74 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 75 | + USB_DEVICE_ID_MS_SURFACE_BOOK) }, 76 | + 77 | + /* Microsoft Surface Book 2 */ 78 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 79 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 80 | + USB_DEVICE_ID_MS_SURFACE_BOOK_2) }, 81 | + 82 | + /* Microsoft Surface Laptop */ 83 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 84 | + HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, 85 | + USB_VENDOR_ID_MICROSOFT, 86 | + HID_DEVICE_ID_MS_SURFACE_LAPTOP) }, 87 | + 88 | + /* Microsoft Power Cover */ 89 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 90 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 91 | + USB_DEVICE_ID_MS_POWER_COVER) }, 92 | + 93 | /* MosArt panels */ 94 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, 95 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, 96 | diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c 97 | index f489a5c..ff88ddc 100644 98 | --- a/drivers/hid/usbhid/hid-quirks.c 99 | +++ b/drivers/hid/usbhid/hid-quirks.c 100 | @@ -108,8 +108,18 @@ static const struct hid_blacklist { 101 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOUSE_C06A, HID_QUIRK_ALWAYS_POLL }, 102 | { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, 103 | { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_PRO_2, HID_QUIRK_NO_INIT_REPORTS }, 104 | - { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2, HID_QUIRK_NO_INIT_REPORTS }, 105 | { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TOUCH_COVER_2, HID_QUIRK_NO_INIT_REPORTS }, 106 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2, HID_QUIRK_NO_INIT_REPORTS }, 107 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3, HID_QUIRK_NO_INIT_REPORTS }, 108 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3, HID_QUIRK_NO_INIT_REPORTS }, 109 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_1, HID_QUIRK_NO_INIT_REPORTS }, 110 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2, HID_QUIRK_NO_INIT_REPORTS }, 111 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP, HID_QUIRK_NO_INIT_REPORTS }, 112 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_4, HID_QUIRK_NO_INIT_REPORTS }, 113 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_1, HID_QUIRK_NO_INIT_REPORTS }, 114 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_BOOK, HID_QUIRK_NO_INIT_REPORTS }, 115 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_BOOK_2, HID_QUIRK_NO_INIT_REPORTS }, 116 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_LAPTOP, HID_QUIRK_NO_INIT_REPORTS }, 117 | { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER, HID_QUIRK_NO_INIT_REPORTS }, 118 | { USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, 119 | { USB_VENDOR_ID_NEXIO, USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750, HID_QUIRK_NO_INIT_REPORTS }, 120 | -------------------------------------------------------------------------------- /patches/4.14/sdcard_reader.patch: -------------------------------------------------------------------------------- 1 | From a0d8418d70e4411b1dc7837f3368e9b7102703fa Mon Sep 17 00:00:00 2001 2 | From: Jake Day 3 | Date: Thu, 1 Feb 2018 19:25:58 -0500 4 | Subject: fix for surface sd card reader 5 | 6 | 7 | diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c 8 | index 8f7d942..3365703 100644 9 | --- a/drivers/usb/core/hub.c 10 | +++ b/drivers/usb/core/hub.c 11 | @@ -4047,7 +4047,8 @@ void usb_enable_lpm(struct usb_device *udev) 12 | if (!udev || !udev->parent || 13 | udev->speed < USB_SPEED_SUPER || 14 | !udev->lpm_capable || 15 | - udev->state < USB_STATE_DEFAULT) 16 | + udev->state < USB_STATE_DEFAULT || 17 | + !udev->bos || !udev->bos->ss_cap) 18 | return; 19 | 20 | udev->lpm_disable_count--; 21 | -------------------------------------------------------------------------------- /patches/4.14/surfaceacpi.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig 2 | index 51ebc5a..244fa92 100644 3 | --- a/drivers/platform/x86/Kconfig 4 | +++ b/drivers/platform/x86/Kconfig 5 | @@ -1155,6 +1155,15 @@ config SURFACE_3_BUTTON 6 | ---help--- 7 | This driver handles the power/home/volume buttons on the Microsoft Surface 3 tablet. 8 | 9 | +config ACPI_SURFACE 10 | + tristate "Microsoft Surface Extras" 11 | + depends on ACPI 12 | + depends on ACPI_WMI 13 | + depends on INPUT 14 | + ---help--- 15 | + This driver adds support for access to certain system events 16 | + on Microsoft Surface devices. 17 | + 18 | config INTEL_PUNIT_IPC 19 | tristate "Intel P-Unit IPC Driver" 20 | ---help--- 21 | diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile 22 | index 2ba6cb7..bcb0dd9 100644 23 | --- a/drivers/platform/x86/Makefile 24 | +++ b/drivers/platform/x86/Makefile 25 | @@ -81,6 +81,7 @@ obj-$(CONFIG_INTEL_PMC_IPC) += intel_pmc_ipc.o 26 | obj-$(CONFIG_SILEAD_DMI) += silead_dmi.o 27 | obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o 28 | obj-$(CONFIG_SURFACE_3_BUTTON) += surface3_button.o 29 | +obj-$(CONFIG_ACPI_SURFACE) += surface_acpi.o 30 | obj-$(CONFIG_INTEL_PUNIT_IPC) += intel_punit_ipc.o 31 | obj-$(CONFIG_INTEL_BXTWC_PMIC_TMU) += intel_bxtwc_tmu.o 32 | obj-$(CONFIG_INTEL_TELEMETRY) += intel_telemetry_core.o \ 33 | diff --git a/drivers/platform/x86/surface_acpi.c b/drivers/platform/x86/surface_acpi.c 34 | new file mode 100644 35 | index 0000000..bee15e7 36 | --- /dev/null 37 | +++ b/drivers/platform/x86/surface_acpi.c 38 | @@ -0,0 +1,472 @@ 39 | +/* 40 | + * surface_acpi.c - Microsoft Surface ACPI Notify 41 | + * 42 | + * This program is free software; you can redistribute it and/or modify 43 | + * it under the terms of the GNU General Public License as published by 44 | + * the Free Software Foundation; either version 2 of the License, or 45 | + * (at your option) any later version. 46 | + * 47 | + * This program is distributed in the hope that it will be useful, 48 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of 49 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 50 | + * GNU General Public License for more details. 51 | + * 52 | + * The full GNU General Public License is included in this distribution in 53 | + * the file called "COPYING". 54 | + */ 55 | + 56 | +#define SURFACE_ACPI_VERSION "0.1" 57 | +#define SURFACE_GEN_VERSION 0x08 58 | +#define PROC_SURFACE "surface" 59 | + 60 | +#include 61 | +#include 62 | +#include 63 | +#include 64 | +#include 65 | +#include 66 | +#include 67 | +#include 68 | +#include 69 | +#include 70 | +#include 71 | + 72 | +MODULE_AUTHOR("Jake Day"); 73 | +MODULE_DESCRIPTION("Microsoft Surface ACPI Notify Driver"); 74 | +MODULE_LICENSE("GPL"); 75 | + 76 | +#define SUR_METHOD_DSM "_DSM" 77 | +#define SUR_METHOD_REG "_REG" 78 | +#define SUR_METHOD_STA "_STA" 79 | +#define SUR_METHOD_INI "_INI" 80 | +#define SUR_METHOD_CRS "_CRS" 81 | + 82 | +#define SUR_QUERY_DEVICE 0x00 83 | +#define SUR_SET_DVER 0x01 84 | +#define SUR_GET_BOARD_REVID 0x02 85 | +#define SUR_BAT1_STATE_CHANGE 0x03 86 | +#define SUR_BAT1_INFO_CHANGE 0x04 87 | +#define SUR_PSU_STATE_CHANGE 0x05 88 | +#define SUR_PSU_INFO_CHANGE 0x06 89 | +#define SUR_BAT2_STATE_CHANGE 0x07 90 | +#define SUR_BAT2_INFO_CHANGE 0x08 91 | +#define SUR_SENSOR_TRIP_POINT 0x09 92 | + 93 | +#define REG_AVAILABLE 0x01 94 | +#define REG_INIT 0x09 95 | + 96 | +static char SURFACE_EVENT_GUID[] = "93b666c5-70c6-469f-a215-3d487c91ab3c"; 97 | +static char SUR_SAN_RQST[] = "\\_SB._SAN.RQST"; 98 | +static char SUR_SAN_RQSX[] = "\\_SB._SAN.RQSX"; 99 | + 100 | +struct surface_acpi_dev { 101 | + acpi_handle handle; 102 | + acpi_handle rqst_handle; 103 | + acpi_handle rqsx_handle; 104 | + 105 | + struct acpi_device *san_dev; 106 | + struct acpi_device *ssh_dev; 107 | + struct acpi_device *bat1_dev; 108 | + struct acpi_device *bat2_dev; 109 | + struct acpi_device *psu_dev; 110 | + 111 | + unsigned int bat1_attached:1; 112 | + unsigned int bat2_attached:1; 113 | + unsigned int psu_registered:1; 114 | +}; 115 | + 116 | +static struct surface_acpi_dev *surface_acpi; 117 | + 118 | +static struct proc_dir_entry *surface_proc_dir; 119 | + 120 | +static acpi_status surface_acpi_check_status(struct acpi_device *dev) 121 | +{ 122 | + unsigned long long value; 123 | + acpi_status status; 124 | + 125 | + if (acpi_has_method(dev->handle, SUR_METHOD_STA)) { 126 | + status = acpi_evaluate_integer(dev->handle, 127 | + SUR_METHOD_STA, NULL, &value); 128 | + 129 | + if (ACPI_FAILURE(status)) { 130 | + pr_err("surface_acpi: ACPI event failure status %s\n", 131 | + acpi_format_exception(status)); 132 | + return AE_ERROR; 133 | + } 134 | + } 135 | + else 136 | + return AE_NOT_FOUND; 137 | + 138 | + return AE_OK; 139 | +} 140 | + 141 | +static acpi_status surface_acpi_san_reg(void) 142 | +{ 143 | + union acpi_object in_objs[2], out_objs[1]; 144 | + struct acpi_object_list params; 145 | + struct acpi_buffer results; 146 | + acpi_status status; 147 | + 148 | + params.count = ARRAY_SIZE(in_objs); 149 | + params.pointer = in_objs; 150 | + in_objs[0].type = ACPI_TYPE_INTEGER; 151 | + in_objs[0].integer.value = REG_INIT; 152 | + in_objs[1].type = ACPI_TYPE_INTEGER; 153 | + in_objs[1].integer.value = REG_AVAILABLE; 154 | + results.length = sizeof(out_objs); 155 | + results.pointer = out_objs; 156 | + 157 | + if (acpi_has_method(surface_acpi->handle, SUR_METHOD_REG)) { 158 | + status = acpi_evaluate_object(surface_acpi->handle, 159 | + SUR_METHOD_REG, ¶ms, &results); 160 | + 161 | + if (ACPI_FAILURE(status)) { 162 | + pr_err("surface_acpi: ACPI event failure status %s\n", 163 | + acpi_format_exception(status)); 164 | + return AE_ERROR; 165 | + } 166 | + } 167 | + else 168 | + return AE_NOT_FOUND; 169 | + 170 | + return AE_OK; 171 | +} 172 | + 173 | +static acpi_status surface_acpi_event_handler(u32 event) 174 | +{ 175 | + union acpi_object in_objs[4], out_objs[5]; 176 | + struct acpi_object_list params; 177 | + struct acpi_buffer results; 178 | + acpi_status status; 179 | + 180 | + params.count = ARRAY_SIZE(in_objs); 181 | + params.pointer = in_objs; 182 | + in_objs[0].type = ACPI_TYPE_BUFFER; 183 | + in_objs[0].buffer.length = sizeof(SURFACE_EVENT_GUID); 184 | + in_objs[0].buffer.pointer = SURFACE_EVENT_GUID; 185 | + in_objs[1].type = ACPI_TYPE_INTEGER; 186 | + in_objs[1].integer.value = SUR_QUERY_DEVICE; 187 | + in_objs[2].type = ACPI_TYPE_INTEGER; 188 | + in_objs[2].integer.value = event; 189 | + in_objs[3].type = ACPI_TYPE_PACKAGE; 190 | + in_objs[3].package.count = 0; 191 | + in_objs[3].package.elements = SURFACE_GEN_VERSION; 192 | + results.length = sizeof(out_objs); 193 | + results.pointer = out_objs; 194 | + 195 | + if (acpi_has_method(surface_acpi->handle, SUR_METHOD_DSM)) { 196 | + status = acpi_evaluate_object(surface_acpi->handle, 197 | + SUR_METHOD_DSM, ¶ms, &results); 198 | + 199 | + if (ACPI_FAILURE(status)) { 200 | + pr_err("surface_acpi: ACPI event failure status %s\n", 201 | + acpi_format_exception(status)); 202 | + return AE_ERROR; 203 | + } 204 | + } 205 | + else 206 | + return AE_NOT_FOUND; 207 | + 208 | + return AE_OK; 209 | +} 210 | + 211 | +static void surface_acpi_san_load(void) 212 | +{ 213 | + acpi_status ret; 214 | + 215 | + ret = surface_acpi_event_handler(SUR_SET_DVER); 216 | + if (ACPI_FAILURE(ret)) 217 | + pr_err("surface_acpi: Error setting Driver Version\n"); 218 | + 219 | + ret = surface_acpi_event_handler(SUR_SENSOR_TRIP_POINT); 220 | + if (ACPI_FAILURE(ret)) 221 | + pr_err("surface_acpi: Error setting Sensor Trip Point\n"); 222 | + 223 | + ret = surface_acpi_event_handler(SUR_BAT1_INFO_CHANGE); 224 | + if (ACPI_FAILURE(ret)) 225 | + pr_err("surface_acpi: Error attaching BAT1\n"); 226 | + else 227 | + surface_acpi->bat1_attached = 1; 228 | + 229 | + ret = surface_acpi_event_handler(SUR_BAT2_INFO_CHANGE); 230 | + if (ACPI_FAILURE(ret)) 231 | + pr_err("surface_acpi: Error attaching BAT2\n"); 232 | + else 233 | + surface_acpi->bat2_attached = 1; 234 | + 235 | + ret = surface_acpi_event_handler(SUR_PSU_INFO_CHANGE); 236 | + if (ACPI_FAILURE(ret)) 237 | + pr_err("surface_acpi: Error registering PSU\n"); 238 | + else 239 | + surface_acpi->psu_registered = 1; 240 | +} 241 | + 242 | +static acpi_status surface_acpi_ssh_initialize(void) 243 | +{ 244 | + acpi_status status; 245 | + 246 | + if (acpi_has_method(surface_acpi->ssh_dev->handle, SUR_METHOD_INI)) { 247 | + status = acpi_evaluate_object(surface_acpi->ssh_dev->handle, 248 | + SUR_METHOD_INI, NULL, NULL); 249 | + 250 | + if (ACPI_FAILURE(status)) { 251 | + pr_err("surface_acpi: ACPI event failure status %s\n", 252 | + acpi_format_exception(status)); 253 | + return AE_ERROR; 254 | + } 255 | + } 256 | + else 257 | + return AE_NOT_FOUND; 258 | + 259 | + return AE_OK; 260 | +} 261 | + 262 | +static int bat1_proc_show(struct seq_file *m, void *v) 263 | +{ 264 | + seq_printf(m, "attached: %d\n", surface_acpi->bat1_attached); 265 | + return 0; 266 | +} 267 | + 268 | +static int bat1_proc_open(struct inode *inode, struct file *file) 269 | +{ 270 | + return single_open(file, bat1_proc_show, PDE_DATA(inode)); 271 | +} 272 | + 273 | +static const struct file_operations bat1_proc_fops = { 274 | + .owner = THIS_MODULE, 275 | + .open = bat1_proc_open, 276 | + .read = seq_read, 277 | + .llseek = seq_lseek, 278 | + .release = single_release, 279 | +}; 280 | + 281 | +static int bat2_proc_show(struct seq_file *m, void *v) 282 | +{ 283 | + seq_printf(m, "attached: %d\n", surface_acpi->bat2_attached); 284 | + return 0; 285 | +} 286 | + 287 | +static int bat2_proc_open(struct inode *inode, struct file *file) 288 | +{ 289 | + return single_open(file, bat2_proc_show, PDE_DATA(inode)); 290 | +} 291 | + 292 | +static const struct file_operations bat2_proc_fops = { 293 | + .owner = THIS_MODULE, 294 | + .open = bat2_proc_open, 295 | + .read = seq_read, 296 | + .llseek = seq_lseek, 297 | + .release = single_release, 298 | +}; 299 | + 300 | +static int psu_proc_show(struct seq_file *m, void *v) 301 | +{ 302 | + seq_printf(m, "registered: %d\n", surface_acpi->psu_registered); 303 | + return 0; 304 | +} 305 | + 306 | +static int psu_proc_open(struct inode *inode, struct file *file) 307 | +{ 308 | + return single_open(file, psu_proc_show, PDE_DATA(inode)); 309 | +} 310 | + 311 | +static const struct file_operations psu_proc_fops = { 312 | + .owner = THIS_MODULE, 313 | + .open = psu_proc_open, 314 | + .read = seq_read, 315 | + .llseek = seq_lseek, 316 | + .release = single_release, 317 | +}; 318 | + 319 | +static int version_proc_show(struct seq_file *m, void *v) 320 | +{ 321 | + seq_printf(m, "driver: %s\n", SURFACE_ACPI_VERSION); 322 | + return 0; 323 | +} 324 | + 325 | +static int version_proc_open(struct inode *inode, struct file *file) 326 | +{ 327 | + return single_open(file, version_proc_show, PDE_DATA(inode)); 328 | +} 329 | + 330 | +static const struct file_operations version_proc_fops = { 331 | + .owner = THIS_MODULE, 332 | + .open = version_proc_open, 333 | + .read = seq_read, 334 | + .llseek = seq_lseek, 335 | + .release = single_release, 336 | +}; 337 | + 338 | +static void create_surface_proc_entries(void) 339 | +{ 340 | + proc_create_data("BAT1", 0, surface_proc_dir, 341 | + &bat1_proc_fops, surface_acpi->bat1_attached); 342 | + proc_create_data("BAT2", 0, surface_proc_dir, 343 | + &bat2_proc_fops, surface_acpi->bat2_attached); 344 | + proc_create_data("ADP1", 0, surface_proc_dir, 345 | + &psu_proc_fops, surface_acpi->psu_registered); 346 | + proc_create_data("version", 0, surface_proc_dir, 347 | + &version_proc_fops, SURFACE_ACPI_VERSION); 348 | +} 349 | + 350 | +static void remove_surface_proc_entries(void) 351 | +{ 352 | + remove_proc_entry("BAT1", surface_proc_dir); 353 | + remove_proc_entry("BAT2", surface_proc_dir); 354 | + remove_proc_entry("ADP1", surface_proc_dir); 355 | + remove_proc_entry("version", surface_proc_dir); 356 | +} 357 | + 358 | +static void surface_acpi_notify(struct acpi_device *dev, u32 event) 359 | +{ 360 | + pr_info("surface_acpi: Event received %x\n", event); 361 | +} 362 | + 363 | +static void surface_acpi_register_rqst_handler(void) 364 | +{ 365 | + acpi_status status; 366 | + 367 | + status = acpi_get_handle(NULL, SUR_SAN_RQST, &surface_acpi->rqst_handle); 368 | + if (ACPI_FAILURE(status)) { 369 | + pr_err("surface_acpi: ACPI event failure status %s\n", 370 | + acpi_format_exception(status)); 371 | + } 372 | +} 373 | + 374 | +static void surface_acpi_register_rqsx_handler(void) 375 | +{ 376 | + acpi_status status; 377 | + 378 | + status = acpi_get_handle(NULL, SUR_SAN_RQSX, &surface_acpi->rqsx_handle); 379 | + if (ACPI_FAILURE(status)) { 380 | + pr_err("surface_acpi: ACPI event failure status %s\n", 381 | + acpi_format_exception(status)); 382 | + } 383 | +} 384 | + 385 | +static acpi_status surface_acpi_walk_callback(acpi_handle handle, u32 level, 386 | + void *context, void **return_value) 387 | +{ 388 | + struct acpi_device_info *info; 389 | + 390 | + if (ACPI_SUCCESS(acpi_get_object_info(handle, &info))) { 391 | + pr_warn("method: name: %4.4s, args %X\n", 392 | + (char *)&info->name, info->param_count); 393 | + 394 | + kfree(info); 395 | + } 396 | + 397 | + return AE_OK; 398 | +} 399 | + 400 | +static void surface_acpi_walk_namespace(struct acpi_device *dev) 401 | +{ 402 | + acpi_status status; 403 | + 404 | + status = acpi_walk_namespace(ACPI_TYPE_METHOD, 405 | + dev->handle, 1, surface_acpi_walk_callback, 406 | + NULL, NULL, NULL); 407 | + if (ACPI_FAILURE(status)) 408 | + pr_warn("surface_acpi: Unable to walk acpi resources\n"); 409 | +} 410 | + 411 | +static int surface_acpi_add(struct acpi_device *dev) 412 | +{ 413 | + if (!surface_acpi) 414 | + { 415 | + surface_acpi = kzalloc(sizeof(*surface_acpi), GFP_KERNEL); 416 | + if (!surface_acpi) 417 | + return AE_NO_MEMORY; 418 | + } 419 | + 420 | + if (acpi_has_method(dev->handle, SUR_METHOD_DSM)) 421 | + { 422 | + pr_info("surface_acpi: Attaching device MSHW0091\n"); 423 | + 424 | + surface_acpi->san_dev = dev; 425 | + surface_acpi->handle = dev->handle; 426 | + 427 | + surface_acpi_walk_namespace(surface_acpi->san_dev); 428 | + surface_acpi_check_status(surface_acpi->san_dev); 429 | + 430 | + surface_acpi_register_rqst_handler(); 431 | + surface_acpi_register_rqsx_handler(); 432 | + 433 | + surface_acpi_san_reg(); 434 | + surface_acpi_san_load(); 435 | + 436 | + create_surface_proc_entries(); 437 | + } 438 | + else 439 | + { 440 | + pr_info("surface_acpi: Attaching device MSHW0084\n"); 441 | + 442 | + surface_acpi->ssh_dev = dev; 443 | + 444 | + surface_acpi_walk_namespace(surface_acpi->ssh_dev); 445 | + surface_acpi_check_status(surface_acpi->ssh_dev); 446 | + 447 | + surface_acpi_ssh_initialize(); 448 | + //surface_acpi_ssh_load(); 449 | + } 450 | + 451 | + return AE_OK; 452 | +} 453 | + 454 | +static int surface_acpi_remove(struct acpi_device *dev) 455 | +{ 456 | + remove_surface_proc_entries(); 457 | + 458 | + return AE_OK; 459 | +} 460 | + 461 | +static const struct acpi_device_id surface_device_ids[] = { 462 | + {"MSHW0091", 0}, 463 | + {"MSHW0084", 0}, 464 | + {"", 0}, 465 | +}; 466 | +MODULE_DEVICE_TABLE(acpi, surface_device_ids); 467 | + 468 | +static struct acpi_driver surface_acpi_driver = { 469 | + .name = "surface_acpi", 470 | + .owner = THIS_MODULE, 471 | + .ids = surface_device_ids, 472 | + .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, 473 | + .ops = { 474 | + .add = surface_acpi_add, 475 | + .remove = surface_acpi_remove, 476 | + .notify = surface_acpi_notify, 477 | + }, 478 | +}; 479 | + 480 | +static int __init surface_acpi_init(void) 481 | +{ 482 | + int ret; 483 | + 484 | + pr_info("surface_acpi: Microsoft Surface ACPI Notify version %s\n", 485 | + SURFACE_ACPI_VERSION); 486 | + 487 | + surface_proc_dir = proc_mkdir(PROC_SURFACE, acpi_root_dir); 488 | + if (!surface_proc_dir) { 489 | + pr_err("surface_acpi: Unable to create proc dir " PROC_SURFACE "\n"); 490 | + return -ENODEV; 491 | + } 492 | + 493 | + ret = acpi_bus_register_driver(&surface_acpi_driver); 494 | + if (ret) { 495 | + pr_err("surface_acpi: Failed to register ACPI driver: %d\n", ret); 496 | + remove_proc_entry(PROC_SURFACE, acpi_root_dir); 497 | + } 498 | + 499 | + return ret; 500 | +} 501 | + 502 | +static void __exit surface_acpi_exit(void) 503 | +{ 504 | + acpi_bus_unregister_driver(&surface_acpi_driver); 505 | + if (surface_proc_dir) 506 | + remove_proc_entry(PROC_SURFACE, acpi_root_dir); 507 | +} 508 | + 509 | +module_init(surface_acpi_init); 510 | +module_exit(surface_acpi_exit); 511 | -------------------------------------------------------------------------------- /patches/4.14/surfacedock.patch: -------------------------------------------------------------------------------- 1 | From 952348ceeaf9c900407762d97b2e024272f01191 Mon Sep 17 00:00:00 2001 2 | From: Jake Day 3 | Date: Thu, 1 Feb 2018 19:25:44 -0500 4 | Subject: support for surface dock 5 | 6 | 7 | diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c 8 | index 05dca3e..59c2fcc 100644 9 | --- a/drivers/net/usb/cdc_ether.c 10 | +++ b/drivers/net/usb/cdc_ether.c 11 | @@ -807,13 +807,6 @@ static const struct usb_device_id products[] = { 12 | .driver_info = 0, 13 | }, 14 | 15 | -/* Microsoft Surface 3 dock (based on Realtek RTL8153) */ 16 | -{ 17 | - USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07c6, USB_CLASS_COMM, 18 | - USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), 19 | - .driver_info = 0, 20 | -}, 21 | - 22 | /* TP-LINK UE300 USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ 23 | { 24 | USB_DEVICE_AND_INTERFACE_INFO(TPLINK_VENDOR_ID, 0x0601, USB_CLASS_COMM, 25 | diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c 26 | index d51d9ab..b94ebe9 100644 27 | --- a/drivers/net/usb/r8152.c 28 | +++ b/drivers/net/usb/r8152.c 29 | @@ -5310,7 +5310,6 @@ static const struct usb_device_id rtl8152_table[] = { 30 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)}, 31 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)}, 32 | {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab)}, 33 | - {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6)}, 34 | {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, 35 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)}, 36 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062)}, 37 | -------------------------------------------------------------------------------- /patches/4.14/wifi.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/net/wireless/marvell/mwifiex/11n_aggr.c b/drivers/net/wireless/marvell/mwifiex/11n_aggr.c 2 | index 042a1d0..fc9041f 100644 3 | --- a/drivers/net/wireless/marvell/mwifiex/11n_aggr.c 4 | +++ b/drivers/net/wireless/marvell/mwifiex/11n_aggr.c 5 | @@ -200,8 +200,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, 6 | 7 | do { 8 | /* Check if AMSDU can accommodate this MSDU */ 9 | - if ((skb_aggr->len + skb_src->len + LLC_SNAP_LEN) > 10 | - adapter->tx_buf_size) 11 | + if (skb_tailroom(skb_aggr) < (skb_src->len + LLC_SNAP_LEN)) 12 | break; 13 | 14 | skb_src = skb_dequeue(&pra_list->skb_head); 15 | diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c 16 | index 68aa0c7..1a883cb 100644 17 | --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c 18 | +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c 19 | @@ -416,6 +416,9 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy, 20 | 21 | ps_mode = enabled; 22 | 23 | + mwifiex_dbg(priv->adapter, ERROR, "overriding ps_mode to false\n"); 24 | + ps_mode = 0; 25 | + 26 | return mwifiex_drv_set_power(priv, &ps_mode); 27 | } 28 | 29 | diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c b/drivers/net/wireless/marvell/mwifiex/cmdevt.c 30 | index 0edc5d6..c0c9c70 100644 31 | --- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c 32 | +++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c 33 | @@ -998,6 +998,7 @@ mwifiex_cmd_timeout_func(unsigned long function_context) 34 | if (cmd_node->wait_q_enabled) { 35 | adapter->cmd_wait_q.status = -ETIMEDOUT; 36 | mwifiex_cancel_pending_ioctl(adapter); 37 | + adapter->cmd_sent = false; 38 | } 39 | } 40 | if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) { 41 | diff --git a/drivers/net/wireless/marvell/mwifiex/init.c b/drivers/net/wireless/marvell/mwifiex/init.c 42 | index e11919d..7f41cf8 100644 43 | --- a/drivers/net/wireless/marvell/mwifiex/init.c 44 | +++ b/drivers/net/wireless/marvell/mwifiex/init.c 45 | @@ -60,7 +60,7 @@ static void wakeup_timer_fn(unsigned long data) 46 | adapter->hw_status = MWIFIEX_HW_STATUS_RESET; 47 | mwifiex_cancel_all_pending_cmd(adapter); 48 | 49 | - if (adapter->if_ops.card_reset && !adapter->hs_activated) 50 | + if (adapter->if_ops.card_reset) 51 | adapter->if_ops.card_reset(adapter); 52 | } 53 | 54 | diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c 55 | index ee40b73..c7008bb 100644 56 | --- a/drivers/net/wireless/marvell/mwifiex/main.c 57 | +++ b/drivers/net/wireless/marvell/mwifiex/main.c 58 | @@ -164,6 +164,7 @@ void mwifiex_queue_main_work(struct mwifiex_adapter *adapter) 59 | spin_lock_irqsave(&adapter->main_proc_lock, flags); 60 | if (adapter->mwifiex_processing) { 61 | adapter->more_task_flag = true; 62 | + adapter->more_rx_task_flag = true; 63 | spin_unlock_irqrestore(&adapter->main_proc_lock, flags); 64 | } else { 65 | spin_unlock_irqrestore(&adapter->main_proc_lock, flags); 66 | @@ -172,18 +173,20 @@ void mwifiex_queue_main_work(struct mwifiex_adapter *adapter) 67 | } 68 | EXPORT_SYMBOL_GPL(mwifiex_queue_main_work); 69 | 70 | -static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter) 71 | +void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter) 72 | { 73 | unsigned long flags; 74 | 75 | spin_lock_irqsave(&adapter->rx_proc_lock, flags); 76 | if (adapter->rx_processing) { 77 | + adapter->more_rx_task_flag = true; 78 | spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 79 | } else { 80 | spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 81 | queue_work(adapter->rx_workqueue, &adapter->rx_work); 82 | } 83 | } 84 | +EXPORT_SYMBOL_GPL(mwifiex_queue_rx_work); 85 | 86 | static int mwifiex_process_rx(struct mwifiex_adapter *adapter) 87 | { 88 | @@ -193,13 +196,14 @@ static int mwifiex_process_rx(struct mwifiex_adapter *adapter) 89 | 90 | spin_lock_irqsave(&adapter->rx_proc_lock, flags); 91 | if (adapter->rx_processing || adapter->rx_locked) { 92 | + adapter->more_rx_task_flag = true; 93 | spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 94 | goto exit_rx_proc; 95 | } else { 96 | adapter->rx_processing = true; 97 | spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 98 | } 99 | - 100 | +rx_process_start: 101 | /* Check for Rx data */ 102 | while ((skb = skb_dequeue(&adapter->rx_data_q))) { 103 | atomic_dec(&adapter->rx_pending); 104 | @@ -221,6 +225,11 @@ static int mwifiex_process_rx(struct mwifiex_adapter *adapter) 105 | } 106 | } 107 | spin_lock_irqsave(&adapter->rx_proc_lock, flags); 108 | + if (adapter->more_rx_task_flag) { 109 | + adapter->more_rx_task_flag = false; 110 | + spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 111 | + goto rx_process_start; 112 | + } 113 | adapter->rx_processing = false; 114 | spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 115 | 116 | @@ -284,10 +293,10 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) 117 | mwifiex_process_hs_config(adapter); 118 | if (adapter->if_ops.process_int_status) 119 | adapter->if_ops.process_int_status(adapter); 120 | + if (adapter->rx_work_enabled && adapter->data_received) 121 | + mwifiex_queue_rx_work(adapter); 122 | } 123 | 124 | - if (adapter->rx_work_enabled && adapter->data_received) 125 | - mwifiex_queue_rx_work(adapter); 126 | 127 | /* Need to wake up the card ? */ 128 | if ((adapter->ps_state == PS_STATE_SLEEP) && 129 | diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h 130 | index a76bd79..b3bfb7d 100644 131 | --- a/drivers/net/wireless/marvell/mwifiex/main.h 132 | +++ b/drivers/net/wireless/marvell/mwifiex/main.h 133 | @@ -890,6 +890,7 @@ struct mwifiex_adapter { 134 | spinlock_t main_proc_lock; 135 | u32 mwifiex_processing; 136 | u8 more_task_flag; 137 | + u8 more_rx_task_flag; 138 | u16 tx_buf_size; 139 | u16 curr_tx_buf_size; 140 | /* sdio single port rx aggregation capability */ 141 | @@ -1662,6 +1663,7 @@ void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter, void *drv_info, 142 | int drv_info_size); 143 | void *mwifiex_alloc_dma_align_buf(int rx_len, gfp_t flags); 144 | void mwifiex_queue_main_work(struct mwifiex_adapter *adapter); 145 | +void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter); 146 | int mwifiex_get_wakeup_reason(struct mwifiex_private *priv, u16 action, 147 | int cmd_type, 148 | struct mwifiex_ds_wakeup_reason *wakeup_reason); 149 | diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c 150 | index 9511f5f..4a4737c 100644 151 | --- a/drivers/net/wireless/marvell/mwifiex/pcie.c 152 | +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c 153 | @@ -1729,6 +1729,16 @@ static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) 154 | } 155 | 156 | rx_len = get_unaligned_le16(skb->data); 157 | + 158 | + 159 | + if (rx_len == 0) { 160 | + mwifiex_dbg(adapter, ERROR, 161 | + "0 byte cmdrsp\n"); 162 | + mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, 163 | + PCI_DMA_FROMDEVICE); 164 | + return 0; 165 | + } 166 | + 167 | skb_put(skb, MWIFIEX_UPLD_SIZE - skb->len); 168 | skb_trim(skb, rx_len); 169 | 170 | diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c 171 | index fb09014..5b8329e 100644 172 | --- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c 173 | +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c 174 | @@ -2313,7 +2313,7 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init) 175 | if (ret) 176 | return -1; 177 | 178 | - if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { 179 | + if (0 && priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { 180 | /* Enable IEEE PS by default */ 181 | priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; 182 | ret = mwifiex_send_cmd(priv, 183 | @@ -2336,8 +2336,8 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init) 184 | return -1; 185 | } 186 | 187 | - mwifiex_send_cmd(priv, HostCmd_CMD_CHAN_REGION_CFG, 188 | - HostCmd_ACT_GEN_GET, 0, NULL, true); 189 | + //mwifiex_send_cmd(priv, HostCmd_CMD_CHAN_REGION_CFG, 190 | + // HostCmd_ACT_GEN_GET, 0, NULL, true); 191 | } 192 | 193 | /* get tx rate */ 194 | @@ -2369,7 +2369,7 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init) 195 | if (ret) 196 | return -1; 197 | 198 | - if (!disable_auto_ds && first_sta && 199 | + if (0 && !disable_auto_ds && first_sta && 200 | priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { 201 | /* Enable auto deep sleep */ 202 | auto_ds.auto_ds = DEEP_SLEEP_ON; 203 | diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c 204 | index 0fba5b1..4e1687f 100644 205 | --- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c 206 | +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c 207 | @@ -48,9 +48,14 @@ mwifiex_process_cmdresp_error(struct mwifiex_private *priv, 208 | struct host_cmd_ds_802_11_ps_mode_enh *pm; 209 | unsigned long flags; 210 | 211 | - mwifiex_dbg(adapter, ERROR, 212 | - "CMD_RESP: cmd %#x error, result=%#x\n", 213 | - resp->command, resp->result); 214 | + if (resp->command == 271 && resp->result == 2){ 215 | + // ignore this command as the firmware does not support it 216 | + } 217 | + else { 218 | + mwifiex_dbg(adapter, ERROR, 219 | + "CMD_RESP: cmd %#x error, result=%#x\n", 220 | + resp->command, resp->result); 221 | + } 222 | 223 | if (adapter->curr_cmd->wait_q_enabled) 224 | adapter->cmd_wait_q.status = -1; 225 | diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c 226 | index f4f2b9b..bbfa9f3 100644 227 | --- a/drivers/net/wireless/marvell/mwifiex/usb.c 228 | +++ b/drivers/net/wireless/marvell/mwifiex/usb.c 229 | @@ -144,6 +144,8 @@ static int mwifiex_usb_recv(struct mwifiex_adapter *adapter, 230 | skb_queue_tail(&adapter->rx_data_q, skb); 231 | adapter->data_received = true; 232 | atomic_inc(&adapter->rx_pending); 233 | + if (adapter->rx_work_enabled) 234 | + mwifiex_queue_rx_work(adapter); 235 | break; 236 | default: 237 | mwifiex_dbg(adapter, ERROR, 238 | diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c 239 | index 68c389c..74efec3 100644 240 | --- a/drivers/pci/pcie/portdrv_pci.c 241 | +++ b/drivers/pci/pcie/portdrv_pci.c 242 | @@ -150,6 +150,11 @@ static int pcie_portdrv_probe(struct pci_dev *dev, 243 | 244 | pci_save_state(dev); 245 | 246 | + /* 247 | + * D3cold disabled by default 248 | + */ 249 | + dev->d3cold_allowed = false; 250 | + 251 | if (pci_bridge_d3_possible(dev)) { 252 | /* 253 | * Keep the port resumed 100ms to make sure things like 254 | diff --git a/net/wireless/sme.c b/net/wireless/sme.c 255 | index 3dd05a0..ab32ef1 100644 256 | --- a/net/wireless/sme.c 257 | +++ b/net/wireless/sme.c 258 | @@ -690,6 +690,11 @@ void __cfg80211_connect_result(struct net_device *dev, 259 | return; 260 | } 261 | 262 | + if (WARN_ON(!wdev->ssid_len)) { 263 | + cfg80211_put_bss(wdev->wiphy, cr->bss); 264 | + return; 265 | + } 266 | + 267 | nl80211_send_connect_result(wiphy_to_rdev(wdev->wiphy), dev, cr, 268 | GFP_KERNEL); 269 | 270 | @@ -1062,7 +1067,7 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev, 271 | /* 272 | * If we have an ssid_len, we're trying to connect or are 273 | * already connected, so reject a new SSID unless it's the 274 | - * same (which is the case for re-association.) 275 | + * same (which is the case for Re-Association. 276 | */ 277 | if (wdev->ssid_len && 278 | (wdev->ssid_len != connect->ssid_len || 279 | diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl 280 | old mode 100755 281 | new mode 100644 282 | -------------------------------------------------------------------------------- /patches/4.15/acpica.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/acpi/acpica/dbdisply.c b/drivers/acpi/acpica/dbdisply.c 2 | index 5a606ea..7b5eb33 100644 3 | --- a/drivers/acpi/acpica/dbdisply.c 4 | +++ b/drivers/acpi/acpica/dbdisply.c 5 | @@ -642,9 +642,8 @@ void acpi_db_display_object_type(char *object_arg) 6 | return; 7 | } 8 | 9 | - acpi_os_printf("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", 10 | - ACPI_FORMAT_UINT64(info->address), 11 | - info->current_status, info->flags); 12 | + acpi_os_printf("ADR: %8.8X%8.8X, Flags: %X\n", 13 | + ACPI_FORMAT_UINT64(info->address), info->flags); 14 | 15 | acpi_os_printf("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", 16 | info->highest_dstates[0], info->highest_dstates[1], 17 | diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c 18 | index d3b6b31..37b0b4c 100644 19 | --- a/drivers/acpi/acpica/evevent.c 20 | +++ b/drivers/acpi/acpica/evevent.c 21 | @@ -204,6 +204,7 @@ u32 acpi_ev_fixed_event_detect(void) 22 | u32 fixed_status; 23 | u32 fixed_enable; 24 | u32 i; 25 | + acpi_status status; 26 | 27 | ACPI_FUNCTION_NAME(ev_fixed_event_detect); 28 | 29 | @@ -211,8 +212,12 @@ u32 acpi_ev_fixed_event_detect(void) 30 | * Read the fixed feature status and enable registers, as all the cases 31 | * depend on their values. Ignore errors here. 32 | */ 33 | - (void)acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status); 34 | - (void)acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable); 35 | + status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status); 36 | + status |= 37 | + acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable); 38 | + if (ACPI_FAILURE(status)) { 39 | + return (int_status); 40 | + } 41 | 42 | ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, 43 | "Fixed Event Block: Enable %08X Status %08X\n", 44 | diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c 45 | index a8191d2..2ad13d8 100644 46 | --- a/drivers/acpi/acpica/exdebug.c 47 | +++ b/drivers/acpi/acpica/exdebug.c 48 | @@ -88,14 +88,13 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc, 49 | return_VOID; 50 | } 51 | 52 | - /* Null string or newline -- don't emit the line header */ 53 | + /* Newline -- don't emit the line header */ 54 | 55 | if (source_desc && 56 | (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) && 57 | (source_desc->common.type == ACPI_TYPE_STRING)) { 58 | - if ((source_desc->string.length == 0) || 59 | - ((source_desc->string.length == 1) && 60 | - (*source_desc->string.pointer == '\n'))) { 61 | + if ((source_desc->string.length == 1) && 62 | + (*source_desc->string.pointer == '\n')) { 63 | acpi_os_printf("\n"); 64 | return_VOID; 65 | } 66 | diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c 67 | index 5026594..573a5f3 100644 68 | --- a/drivers/acpi/acpica/nsdumpdv.c 69 | +++ b/drivers/acpi/acpica/nsdumpdv.c 70 | @@ -88,10 +88,9 @@ acpi_ns_dump_one_device(acpi_handle obj_handle, 71 | } 72 | 73 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, 74 | - " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", 75 | + " HID: %s, ADR: %8.8X%8.8X\n", 76 | info->hardware_id.value, 77 | - ACPI_FORMAT_UINT64(info->address), 78 | - info->current_status)); 79 | + ACPI_FORMAT_UINT64(info->address)); 80 | ACPI_FREE(info); 81 | } 82 | 83 | diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c 84 | index 1069662..0a9c600 100644 85 | --- a/drivers/acpi/acpica/nsxfname.c 86 | +++ b/drivers/acpi/acpica/nsxfname.c 87 | @@ -241,7 +241,7 @@ static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, 88 | * namespace node and possibly by running several standard 89 | * control methods (Such as in the case of a device.) 90 | * 91 | - * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, 92 | + * For Device and Processor objects, run the Device _HID, _UID, _CID, 93 | * _CLS, _ADR, _sx_w, and _sx_d methods. 94 | * 95 | * Note: Allocates the return buffer, must be freed by the caller. 96 | @@ -250,8 +250,9 @@ static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, 97 | * discovery namespace traversal. Therefore, no complex methods can be 98 | * executed, especially those that access operation regions. Therefore, do 99 | * not add any additional methods that could cause problems in this area. 100 | - * this was the fate of the _SUB method which was found to cause such 101 | - * problems and was removed (11/2015). 102 | + * Because of this reason support for the following methods has been removed: 103 | + * 1) _SUB method was removed (11/2015) 104 | + * 2) _STA method was removed (02/2018) 105 | * 106 | ******************************************************************************/ 107 | 108 | @@ -374,20 +375,8 @@ acpi_get_object_info(acpi_handle handle, 109 | * Notes: none of these methods are required, so they may or may 110 | * not be present for this device. The Info->Valid bitfield is used 111 | * to indicate which methods were found and run successfully. 112 | - * 113 | - * For _STA, if the method does not exist, then (as per the ACPI 114 | - * specification), the returned current_status flags will indicate 115 | - * that the device is present/functional/enabled. Otherwise, the 116 | - * current_status flags reflect the value returned from _STA. 117 | */ 118 | 119 | - /* Execute the Device._STA method */ 120 | - 121 | - status = acpi_ut_execute_STA(node, &info->current_status); 122 | - if (ACPI_SUCCESS(status)) { 123 | - valid |= ACPI_VALID_STA; 124 | - } 125 | - 126 | /* Execute the Device._ADR method */ 127 | 128 | status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node, 129 | diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c 130 | index eb9dfac..11ce4e5 100644 131 | --- a/drivers/acpi/acpica/psargs.c 132 | +++ b/drivers/acpi/acpica/psargs.c 133 | @@ -890,6 +890,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, 134 | ACPI_POSSIBLE_METHOD_CALL); 135 | 136 | if (arg->common.aml_opcode == AML_INT_METHODCALL_OP) { 137 | + 138 | + /* Free method call op and corresponding namestring sub-ob */ 139 | + 140 | + acpi_ps_free_op(arg->common.value.arg); 141 | acpi_ps_free_op(arg); 142 | arg = NULL; 143 | walk_state->arg_count = 1; 144 | diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c 145 | index b6d58cc..5c00e5e 100644 146 | --- a/drivers/acpi/bus.c 147 | +++ b/drivers/acpi/bus.c 148 | @@ -135,6 +135,7 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle, 149 | } 150 | return status; 151 | } 152 | +EXPORT_SYMBOL_GPL(acpi_bus_get_status_handle); 153 | 154 | int acpi_bus_get_status(struct acpi_device *device) 155 | { 156 | @@ -146,6 +147,12 @@ int acpi_bus_get_status(struct acpi_device *device) 157 | return 0; 158 | } 159 | 160 | + /* Battery devices must have their deps met before calling _STA */ 161 | + if (acpi_device_is_battery(device) && device->dep_unmet) { 162 | + acpi_set_device_status(device, 0); 163 | + return 0; 164 | + } 165 | + 166 | status = acpi_bus_get_status_handle(device->handle, &sta); 167 | if (ACPI_FAILURE(status)) 168 | return -ENODEV; 169 | diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c 170 | index b0fe527..4c1b90e 100644 171 | --- a/drivers/acpi/scan.c 172 | +++ b/drivers/acpi/scan.c 173 | @@ -1565,6 +1565,8 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, 174 | device_initialize(&device->dev); 175 | dev_set_uevent_suppress(&device->dev, true); 176 | acpi_init_coherency(device); 177 | + /* Assume there are unmet deps until acpi_device_dep_initialize runs */ 178 | + device->dep_unmet = 1; 179 | } 180 | 181 | void acpi_device_add_finalize(struct acpi_device *device) 182 | @@ -1588,6 +1590,14 @@ static int acpi_add_single_object(struct acpi_device **child, 183 | } 184 | 185 | acpi_init_device_object(device, handle, type, sta); 186 | + /* 187 | + * For ACPI_BUS_TYPE_DEVICE getting the status is delayed till here so 188 | + * that we can call acpi_bus_get_status and use its quirk handling. 189 | + * Note this must be done before the get power-/wakeup_dev-flags calls. 190 | + */ 191 | + if (type == ACPI_BUS_TYPE_DEVICE) 192 | + acpi_bus_get_status(device); 193 | + 194 | acpi_bus_get_power_flags(device); 195 | acpi_bus_get_wakeup_device_flags(device); 196 | 197 | @@ -1660,9 +1670,11 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, 198 | return -ENODEV; 199 | 200 | *type = ACPI_BUS_TYPE_DEVICE; 201 | - status = acpi_bus_get_status_handle(handle, sta); 202 | - if (ACPI_FAILURE(status)) 203 | - *sta = 0; 204 | + /* 205 | + * acpi_add_single_object updates this once we've an acpi_device 206 | + * so that acpi_bus_get_status' quirk handling can be used. 207 | + */ 208 | + *sta = 0; 209 | break; 210 | case ACPI_TYPE_PROCESSOR: 211 | *type = ACPI_BUS_TYPE_PROCESSOR; 212 | @@ -1760,6 +1772,8 @@ static void acpi_device_dep_initialize(struct acpi_device *adev) 213 | acpi_status status; 214 | int i; 215 | 216 | + adev->dep_unmet = 0; 217 | + 218 | if (!acpi_has_method(adev->handle, "_DEP")) 219 | return; 220 | 221 | diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c 222 | index 984c7e8..8472c4a 100644 223 | --- a/drivers/pci/hotplug/acpiphp_ibm.c 224 | +++ b/drivers/pci/hotplug/acpiphp_ibm.c 225 | @@ -399,6 +399,7 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle, 226 | u32 lvl, void *context, void **rv) 227 | { 228 | acpi_handle *phandle = (acpi_handle *)context; 229 | + unsigned long long current_status = 0; 230 | acpi_status status; 231 | struct acpi_device_info *info; 232 | int retval = 0; 233 | @@ -410,7 +411,9 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle, 234 | return retval; 235 | } 236 | 237 | - if (info->current_status && (info->valid & ACPI_VALID_HID) && 238 | + acpi_bus_get_status_handle(handle, ¤t_status); 239 | + 240 | + if (current_status && (info->valid & ACPI_VALID_HID) && 241 | (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) || 242 | !strcmp(info->hardware_id.string, IBM_HARDWARE_ID2))) { 243 | pr_debug("found hardware: %s, handle: %p\n", 244 | diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h 245 | index 4f077ed..220ef86 100644 246 | --- a/include/acpi/actypes.h 247 | +++ b/include/acpi/actypes.h 248 | @@ -1191,7 +1191,6 @@ struct acpi_device_info { 249 | u8 flags; /* Miscellaneous info */ 250 | u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */ 251 | u8 lowest_dstates[5]; /* _sx_w values: 0xFF indicates not valid */ 252 | - u32 current_status; /* _STA value */ 253 | u64 address; /* _ADR value */ 254 | struct acpi_pnp_device_id hardware_id; /* _HID value */ 255 | struct acpi_pnp_device_id unique_id; /* _UID value */ 256 | @@ -1205,7 +1204,6 @@ struct acpi_device_info { 257 | 258 | /* Flags for Valid field above (acpi_get_object_info) */ 259 | 260 | -#define ACPI_VALID_STA 0x0001 261 | #define ACPI_VALID_ADR 0x0002 262 | #define ACPI_VALID_HID 0x0004 263 | #define ACPI_VALID_UID 0x0008 264 | -------------------------------------------------------------------------------- /patches/4.15/cameras.patch: -------------------------------------------------------------------------------- 1 | From 5549632053d4ae06867f383694553f7af27e40c9 Mon Sep 17 00:00:00 2001 2 | From: Jake Day 3 | Date: Fri, 2 Feb 2018 11:07:32 -0500 4 | Subject: initial support for surface cameras 5 | 6 | 7 | diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c 8 | index 28b91b7..0e5989c 100644 9 | --- a/drivers/media/usb/uvc/uvc_driver.c 10 | +++ b/drivers/media/usb/uvc/uvc_driver.c 11 | @@ -2277,6 +2277,46 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout"); 12 | * though they are compliant. 13 | */ 14 | static const struct usb_device_id uvc_ids[] = { 15 | + /* Microsoft Surface Pro 3 Front */ 16 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 17 | + | USB_DEVICE_ID_MATCH_INT_INFO, 18 | + .idVendor = 0x045e, 19 | + .idProduct = 0x07be, 20 | + .bInterfaceClass = USB_CLASS_VIDEO, 21 | + .bInterfaceSubClass = 1, 22 | + .bInterfaceProtocol = 1 }, 23 | + /* Microsoft Surface Pro 3 Rear */ 24 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 25 | + | USB_DEVICE_ID_MATCH_INT_INFO, 26 | + .idVendor = 0x045e, 27 | + .idProduct = 0x07bf, 28 | + .bInterfaceClass = USB_CLASS_VIDEO, 29 | + .bInterfaceSubClass = 1, 30 | + .bInterfaceProtocol = 1 }, 31 | + /* Microsoft Surface Pro 4 Cam */ 32 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 33 | + | USB_DEVICE_ID_MATCH_INT_INFO, 34 | + .idVendor = 0x045e, 35 | + .idProduct = 0x090c, 36 | + .bInterfaceClass = USB_CLASS_VIDEO, 37 | + .bInterfaceSubClass = 1, 38 | + .bInterfaceProtocol = 1 }, 39 | + /* Microsoft Surface Book Cam 1 */ 40 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 41 | + | USB_DEVICE_ID_MATCH_INT_INFO, 42 | + .idVendor = 0x045e, 43 | + .idProduct = 0x090b, 44 | + .bInterfaceClass = USB_CLASS_VIDEO, 45 | + .bInterfaceSubClass = 1, 46 | + .bInterfaceProtocol = 1 }, 47 | + /* Microsoft Surface Book Cam 2 */ 48 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 49 | + | USB_DEVICE_ID_MATCH_INT_INFO, 50 | + .idVendor = 0x045e, 51 | + .idProduct = 0x091a, 52 | + .bInterfaceClass = USB_CLASS_VIDEO, 53 | + .bInterfaceSubClass = 1, 54 | + .bInterfaceProtocol = 1 }, 55 | /* LogiLink Wireless Webcam */ 56 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 57 | | USB_DEVICE_ID_MATCH_INT_INFO, 58 | diff --git a/drivers/staging/media/atomisp/i2c/ov5693/Kconfig b/drivers/staging/media/atomisp/i2c/ov5693/Kconfig 59 | index 3f527f2..b882948 100644 60 | --- a/drivers/staging/media/atomisp/i2c/ov5693/Kconfig 61 | +++ b/drivers/staging/media/atomisp/i2c/ov5693/Kconfig 62 | @@ -1,7 +1,7 @@ 63 | config VIDEO_ATOMISP_OV5693 64 | tristate "Omnivision ov5693 sensor support" 65 | depends on ACPI 66 | - depends on I2C && VIDEO_V4L2 67 | + depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER 68 | ---help--- 69 | This is a Video4Linux2 sensor-level driver for the Micron 70 | ov5693 5 Mpixel camera. 71 | diff --git a/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c b/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c 72 | index 3e7c385..9b1fc1c 100644 73 | --- a/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c 74 | +++ b/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c 75 | @@ -1320,11 +1320,15 @@ static int power_ctrl(struct v4l2_subdev *sd, bool flag) 76 | static int gpio_ctrl(struct v4l2_subdev *sd, bool flag) 77 | { 78 | struct ov5693_device *dev = to_ov5693_sensor(sd); 79 | + int ret = 0; 80 | 81 | if (!dev || !dev->platform_data) 82 | return -ENODEV; 83 | 84 | - return dev->platform_data->gpio0_ctrl(sd, flag); 85 | + if (dev->platform_data->gpio0_ctrl) 86 | + ret = dev->platform_data->gpio0_ctrl(sd, flag); 87 | + 88 | + return ret; 89 | } 90 | 91 | static int __power_up(struct v4l2_subdev *sd) 92 | @@ -1689,7 +1693,7 @@ static int ov5693_detect(struct i2c_client *client) 93 | OV5693_SC_CMMN_CHIP_ID_L, &low); 94 | id = ((((u16) high) << 8) | (u16) low); 95 | 96 | - if (id != OV5693_ID) { 97 | + if (id != OV5690_ID && id != OV5693_ID) { 98 | dev_err(&client->dev, "sensor ID error 0x%x\n", id); 99 | return -ENODEV; 100 | } 101 | diff --git a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h 102 | index 2ea6380..2168daa 100644 103 | --- a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h 104 | +++ b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h 105 | @@ -29,7 +29,7 @@ 106 | #include 107 | #include 108 | 109 | -#include "../../include/linux/atomisp_platform.h" 110 | +#include "../../include/linux/atomisp_gmin_platform.h" 111 | 112 | #define OV5693_POWER_UP_RETRY_NUM 5 113 | 114 | @@ -72,7 +72,8 @@ 115 | * bits 7-0: min f-number denominator 116 | */ 117 | #define OV5693_F_NUMBER_RANGE 0x180a180a 118 | -#define OV5693_ID 0x5690 119 | +#define OV5690_ID 0x5690 120 | +#define OV5693_ID 0x5693 121 | 122 | #define OV5693_FINE_INTG_TIME_MIN 0 123 | #define OV5693_FINE_INTG_TIME_MAX_MARGIN 0 124 | diff --git a/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c 125 | index bf9f34b..6797ba1 100644 126 | --- a/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c 127 | +++ b/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c 128 | @@ -251,11 +251,13 @@ static const struct gmin_cfg_var ecs7_vars[] = { 129 | {"INT33BE:00_CsiFmt", "13"}, 130 | {"INT33BE:00_CsiBayer", "2"}, 131 | {"INT33BE:00_CamClk", "0"}, 132 | + {"INT33BE:00_ClkSrc", "1"}, 133 | {"INT33F0:00_CsiPort", "0"}, 134 | {"INT33F0:00_CsiLanes", "1"}, 135 | {"INT33F0:00_CsiFmt", "13"}, 136 | {"INT33F0:00_CsiBayer", "0"}, 137 | {"INT33F0:00_CamClk", "1"}, 138 | + {"INT33BE:00_I2CAddr", "-1"}, 139 | {"gmin_V2P8GPIO", "402"}, 140 | {}, 141 | }; 142 | @@ -280,6 +282,8 @@ static const struct { 143 | { "MRD7", mrd7_vars }, 144 | { "ST70408", ecs7_vars }, 145 | { "VTA0803", i8880_vars }, 146 | + { "Surface Book" , ecs7_vars } , 147 | + { "Surface Pro 4" , ecs7_vars } , 148 | }; 149 | 150 | 151 | -------------------------------------------------------------------------------- /patches/4.15/keyboards_and_covers.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h 2 | index a0baa5b..3e03ced8 100644 3 | --- a/drivers/hid/hid-ids.h 4 | +++ b/drivers/hid/hid-ids.h 5 | @@ -770,11 +770,22 @@ 6 | #define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3KV1 0x0732 7 | #define USB_DEVICE_ID_MS_DIGITAL_MEDIA_600 0x0750 8 | #define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c 9 | -#define USB_DEVICE_ID_MS_COMFORT_KEYBOARD 0x00e3 10 | -#define USB_DEVICE_ID_MS_SURFACE_PRO_2 0x0799 11 | -#define USB_DEVICE_ID_MS_TOUCH_COVER_2 0x07a7 12 | -#define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9 13 | -#define USB_DEVICE_ID_MS_POWER_COVER 0x07da 14 | +#define USB_DEVICE_ID_MS_COMFORT_KEYBOARD 0x00e3 15 | +#define USB_DEVICE_ID_MS_SURFACE_PRO_2 0x0799 16 | +#define USB_DEVICE_ID_MS_TOUCH_COVER_2 0x07a7 17 | +#define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9 18 | +#define USB_DEVICE_ID_MS_TYPE_COVER_3 0x07de 19 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3 0x07dc 20 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_1 0x07de 21 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2 0x07e2 22 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP 0x07dd 23 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_4 0x07e8 24 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_1 0x07e4 25 | +#define USB_DEVICE_ID_MS_SURFACE_BOOK 0x07cd 26 | +#define USB_DEVICE_ID_MS_SURFACE_BOOK_2 0x0922 27 | +#define USB_DEVICE_ID_MS_SURFACE_LAPTOP 0xf001 28 | +#define HID_DEVICE_ID_MS_SURFACE_LAPTOP 0xf001 29 | +#define USB_DEVICE_ID_MS_POWER_COVER 0x07da 30 | 31 | #define USB_VENDOR_ID_MOJO 0x8282 32 | #define USB_DEVICE_ID_RETRO_ADAPTER 0x3201 33 | diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c 34 | index 65ea23b..00ce3be 100644 35 | --- a/drivers/hid/hid-multitouch.c 36 | +++ b/drivers/hid/hid-multitouch.c 37 | @@ -1638,6 +1638,58 @@ static const struct hid_device_id mt_devices[] = { 38 | HID_USB_DEVICE(USB_VENDOR_ID_LG, 39 | USB_DEVICE_ID_LG_MELFAS_MT) }, 40 | 41 | + /* Microsoft Touch Cover */ 42 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 43 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 44 | + USB_DEVICE_ID_MS_TOUCH_COVER_2) }, 45 | + 46 | + /* Microsoft Type Cover */ 47 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 48 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 49 | + USB_DEVICE_ID_MS_TYPE_COVER_2) }, 50 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 51 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 52 | + USB_DEVICE_ID_MS_TYPE_COVER_3) }, 53 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 54 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 55 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3) }, 56 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 57 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 58 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_1) }, 59 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 60 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 61 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2) }, 62 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 63 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 64 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP) }, 65 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 66 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 67 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_4) }, 68 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 69 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 70 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_1) }, 71 | + 72 | + /* Microsoft Surface Book */ 73 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 74 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 75 | + USB_DEVICE_ID_MS_SURFACE_BOOK) }, 76 | + 77 | + /* Microsoft Surface Book 2 */ 78 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 79 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 80 | + USB_DEVICE_ID_MS_SURFACE_BOOK_2) }, 81 | + 82 | + /* Microsoft Surface Laptop */ 83 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 84 | + HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, 85 | + USB_VENDOR_ID_MICROSOFT, 86 | + HID_DEVICE_ID_MS_SURFACE_LAPTOP) }, 87 | + 88 | + /* Microsoft Power Cover */ 89 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 90 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 91 | + USB_DEVICE_ID_MS_POWER_COVER) }, 92 | + 93 | /* MosArt panels */ 94 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, 95 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, 96 | diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c 97 | index 331f7f3..6ff429f 100644 98 | --- a/drivers/hid/usbhid/hid-quirks.c 99 | +++ b/drivers/hid/usbhid/hid-quirks.c 100 | @@ -108,8 +108,18 @@ static const struct hid_blacklist { 101 | { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOUSE_C06A, HID_QUIRK_ALWAYS_POLL }, 102 | { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, 103 | { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_PRO_2, HID_QUIRK_NO_INIT_REPORTS }, 104 | - { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2, HID_QUIRK_NO_INIT_REPORTS }, 105 | { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TOUCH_COVER_2, HID_QUIRK_NO_INIT_REPORTS }, 106 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2, HID_QUIRK_NO_INIT_REPORTS }, 107 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3, HID_QUIRK_NO_INIT_REPORTS }, 108 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3, HID_QUIRK_NO_INIT_REPORTS }, 109 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_1, HID_QUIRK_NO_INIT_REPORTS }, 110 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2, HID_QUIRK_NO_INIT_REPORTS }, 111 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP, HID_QUIRK_NO_INIT_REPORTS }, 112 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_4, HID_QUIRK_NO_INIT_REPORTS }, 113 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_1, HID_QUIRK_NO_INIT_REPORTS }, 114 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_BOOK, HID_QUIRK_NO_INIT_REPORTS }, 115 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_BOOK_2, HID_QUIRK_NO_INIT_REPORTS }, 116 | + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_LAPTOP, HID_QUIRK_NO_INIT_REPORTS }, 117 | { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER, HID_QUIRK_NO_INIT_REPORTS }, 118 | { USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, 119 | { USB_VENDOR_ID_NEXIO, USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750, HID_QUIRK_NO_INIT_REPORTS }, 120 | -------------------------------------------------------------------------------- /patches/4.15/sdcard_reader.patch: -------------------------------------------------------------------------------- 1 | From fbd83f772a3be3a00bae323f6d71a59b26352c57 Mon Sep 17 00:00:00 2001 2 | From: Jake Day 3 | Date: Fri, 2 Feb 2018 11:22:21 -0500 4 | Subject: fix for surface sd card reader 5 | 6 | 7 | diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c 8 | index cf7bbcb..826fdb8 100644 9 | --- a/drivers/usb/core/hub.c 10 | +++ b/drivers/usb/core/hub.c 11 | @@ -4047,7 +4047,8 @@ void usb_enable_lpm(struct usb_device *udev) 12 | if (!udev || !udev->parent || 13 | udev->speed < USB_SPEED_SUPER || 14 | !udev->lpm_capable || 15 | - udev->state < USB_STATE_DEFAULT) 16 | + udev->state < USB_STATE_DEFAULT || 17 | + !udev->bos || !udev->bos->ss_cap) 18 | return; 19 | 20 | udev->lpm_disable_count--; 21 | -------------------------------------------------------------------------------- /patches/4.15/surfaceacpi.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig 2 | index 51ebc5a..244fa92 100644 3 | --- a/drivers/platform/x86/Kconfig 4 | +++ b/drivers/platform/x86/Kconfig 5 | @@ -1155,6 +1155,15 @@ config SURFACE_3_BUTTON 6 | ---help--- 7 | This driver handles the power/home/volume buttons on the Microsoft Surface 3 tablet. 8 | 9 | +config ACPI_SURFACE 10 | + tristate "Microsoft Surface Extras" 11 | + depends on ACPI 12 | + depends on ACPI_WMI 13 | + depends on INPUT 14 | + ---help--- 15 | + This driver adds support for access to certain system events 16 | + on Microsoft Surface devices. 17 | + 18 | config INTEL_PUNIT_IPC 19 | tristate "Intel P-Unit IPC Driver" 20 | ---help--- 21 | diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile 22 | index 2ba6cb7..bcb0dd9 100644 23 | --- a/drivers/platform/x86/Makefile 24 | +++ b/drivers/platform/x86/Makefile 25 | @@ -81,6 +81,7 @@ obj-$(CONFIG_INTEL_PMC_IPC) += intel_pmc_ipc.o 26 | obj-$(CONFIG_SILEAD_DMI) += silead_dmi.o 27 | obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o 28 | obj-$(CONFIG_SURFACE_3_BUTTON) += surface3_button.o 29 | +obj-$(CONFIG_ACPI_SURFACE) += surface_acpi.o 30 | obj-$(CONFIG_INTEL_PUNIT_IPC) += intel_punit_ipc.o 31 | obj-$(CONFIG_INTEL_BXTWC_PMIC_TMU) += intel_bxtwc_tmu.o 32 | obj-$(CONFIG_INTEL_TELEMETRY) += intel_telemetry_core.o \ 33 | diff --git a/drivers/platform/x86/surface_acpi.c b/drivers/platform/x86/surface_acpi.c 34 | new file mode 100644 35 | index 0000000..bee15e7 36 | --- /dev/null 37 | +++ b/drivers/platform/x86/surface_acpi.c 38 | @@ -0,0 +1,472 @@ 39 | +/* 40 | + * surface_acpi.c - Microsoft Surface ACPI Notify 41 | + * 42 | + * This program is free software; you can redistribute it and/or modify 43 | + * it under the terms of the GNU General Public License as published by 44 | + * the Free Software Foundation; either version 2 of the License, or 45 | + * (at your option) any later version. 46 | + * 47 | + * This program is distributed in the hope that it will be useful, 48 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of 49 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 50 | + * GNU General Public License for more details. 51 | + * 52 | + * The full GNU General Public License is included in this distribution in 53 | + * the file called "COPYING". 54 | + */ 55 | + 56 | +#define SURFACE_ACPI_VERSION "0.1" 57 | +#define SURFACE_GEN_VERSION 0x08 58 | +#define PROC_SURFACE "surface" 59 | + 60 | +#include 61 | +#include 62 | +#include 63 | +#include 64 | +#include 65 | +#include 66 | +#include 67 | +#include 68 | +#include 69 | +#include 70 | +#include 71 | + 72 | +MODULE_AUTHOR("Jake Day"); 73 | +MODULE_DESCRIPTION("Microsoft Surface ACPI Notify Driver"); 74 | +MODULE_LICENSE("GPL"); 75 | + 76 | +#define SUR_METHOD_DSM "_DSM" 77 | +#define SUR_METHOD_REG "_REG" 78 | +#define SUR_METHOD_STA "_STA" 79 | +#define SUR_METHOD_INI "_INI" 80 | +#define SUR_METHOD_CRS "_CRS" 81 | + 82 | +#define SUR_QUERY_DEVICE 0x00 83 | +#define SUR_SET_DVER 0x01 84 | +#define SUR_GET_BOARD_REVID 0x02 85 | +#define SUR_BAT1_STATE_CHANGE 0x03 86 | +#define SUR_BAT1_INFO_CHANGE 0x04 87 | +#define SUR_PSU_STATE_CHANGE 0x05 88 | +#define SUR_PSU_INFO_CHANGE 0x06 89 | +#define SUR_BAT2_STATE_CHANGE 0x07 90 | +#define SUR_BAT2_INFO_CHANGE 0x08 91 | +#define SUR_SENSOR_TRIP_POINT 0x09 92 | + 93 | +#define REG_AVAILABLE 0x01 94 | +#define REG_INIT 0x09 95 | + 96 | +static char SURFACE_EVENT_GUID[] = "93b666c5-70c6-469f-a215-3d487c91ab3c"; 97 | +static char SUR_SAN_RQST[] = "\\_SB._SAN.RQST"; 98 | +static char SUR_SAN_RQSX[] = "\\_SB._SAN.RQSX"; 99 | + 100 | +struct surface_acpi_dev { 101 | + acpi_handle handle; 102 | + acpi_handle rqst_handle; 103 | + acpi_handle rqsx_handle; 104 | + 105 | + struct acpi_device *san_dev; 106 | + struct acpi_device *ssh_dev; 107 | + struct acpi_device *bat1_dev; 108 | + struct acpi_device *bat2_dev; 109 | + struct acpi_device *psu_dev; 110 | + 111 | + unsigned int bat1_attached:1; 112 | + unsigned int bat2_attached:1; 113 | + unsigned int psu_registered:1; 114 | +}; 115 | + 116 | +static struct surface_acpi_dev *surface_acpi; 117 | + 118 | +static struct proc_dir_entry *surface_proc_dir; 119 | + 120 | +static acpi_status surface_acpi_check_status(struct acpi_device *dev) 121 | +{ 122 | + unsigned long long value; 123 | + acpi_status status; 124 | + 125 | + if (acpi_has_method(dev->handle, SUR_METHOD_STA)) { 126 | + status = acpi_evaluate_integer(dev->handle, 127 | + SUR_METHOD_STA, NULL, &value); 128 | + 129 | + if (ACPI_FAILURE(status)) { 130 | + pr_err("surface_acpi: ACPI event failure status %s\n", 131 | + acpi_format_exception(status)); 132 | + return AE_ERROR; 133 | + } 134 | + } 135 | + else 136 | + return AE_NOT_FOUND; 137 | + 138 | + return AE_OK; 139 | +} 140 | + 141 | +static acpi_status surface_acpi_san_reg(void) 142 | +{ 143 | + union acpi_object in_objs[2], out_objs[1]; 144 | + struct acpi_object_list params; 145 | + struct acpi_buffer results; 146 | + acpi_status status; 147 | + 148 | + params.count = ARRAY_SIZE(in_objs); 149 | + params.pointer = in_objs; 150 | + in_objs[0].type = ACPI_TYPE_INTEGER; 151 | + in_objs[0].integer.value = REG_INIT; 152 | + in_objs[1].type = ACPI_TYPE_INTEGER; 153 | + in_objs[1].integer.value = REG_AVAILABLE; 154 | + results.length = sizeof(out_objs); 155 | + results.pointer = out_objs; 156 | + 157 | + if (acpi_has_method(surface_acpi->handle, SUR_METHOD_REG)) { 158 | + status = acpi_evaluate_object(surface_acpi->handle, 159 | + SUR_METHOD_REG, ¶ms, &results); 160 | + 161 | + if (ACPI_FAILURE(status)) { 162 | + pr_err("surface_acpi: ACPI event failure status %s\n", 163 | + acpi_format_exception(status)); 164 | + return AE_ERROR; 165 | + } 166 | + } 167 | + else 168 | + return AE_NOT_FOUND; 169 | + 170 | + return AE_OK; 171 | +} 172 | + 173 | +static acpi_status surface_acpi_event_handler(u32 event) 174 | +{ 175 | + union acpi_object in_objs[4], out_objs[5]; 176 | + struct acpi_object_list params; 177 | + struct acpi_buffer results; 178 | + acpi_status status; 179 | + 180 | + params.count = ARRAY_SIZE(in_objs); 181 | + params.pointer = in_objs; 182 | + in_objs[0].type = ACPI_TYPE_BUFFER; 183 | + in_objs[0].buffer.length = sizeof(SURFACE_EVENT_GUID); 184 | + in_objs[0].buffer.pointer = SURFACE_EVENT_GUID; 185 | + in_objs[1].type = ACPI_TYPE_INTEGER; 186 | + in_objs[1].integer.value = SUR_QUERY_DEVICE; 187 | + in_objs[2].type = ACPI_TYPE_INTEGER; 188 | + in_objs[2].integer.value = event; 189 | + in_objs[3].type = ACPI_TYPE_PACKAGE; 190 | + in_objs[3].package.count = 0; 191 | + in_objs[3].package.elements = SURFACE_GEN_VERSION; 192 | + results.length = sizeof(out_objs); 193 | + results.pointer = out_objs; 194 | + 195 | + if (acpi_has_method(surface_acpi->handle, SUR_METHOD_DSM)) { 196 | + status = acpi_evaluate_object(surface_acpi->handle, 197 | + SUR_METHOD_DSM, ¶ms, &results); 198 | + 199 | + if (ACPI_FAILURE(status)) { 200 | + pr_err("surface_acpi: ACPI event failure status %s\n", 201 | + acpi_format_exception(status)); 202 | + return AE_ERROR; 203 | + } 204 | + } 205 | + else 206 | + return AE_NOT_FOUND; 207 | + 208 | + return AE_OK; 209 | +} 210 | + 211 | +static void surface_acpi_san_load(void) 212 | +{ 213 | + acpi_status ret; 214 | + 215 | + ret = surface_acpi_event_handler(SUR_SET_DVER); 216 | + if (ACPI_FAILURE(ret)) 217 | + pr_err("surface_acpi: Error setting Driver Version\n"); 218 | + 219 | + ret = surface_acpi_event_handler(SUR_SENSOR_TRIP_POINT); 220 | + if (ACPI_FAILURE(ret)) 221 | + pr_err("surface_acpi: Error setting Sensor Trip Point\n"); 222 | + 223 | + ret = surface_acpi_event_handler(SUR_BAT1_INFO_CHANGE); 224 | + if (ACPI_FAILURE(ret)) 225 | + pr_err("surface_acpi: Error attaching BAT1\n"); 226 | + else 227 | + surface_acpi->bat1_attached = 1; 228 | + 229 | + ret = surface_acpi_event_handler(SUR_BAT2_INFO_CHANGE); 230 | + if (ACPI_FAILURE(ret)) 231 | + pr_err("surface_acpi: Error attaching BAT2\n"); 232 | + else 233 | + surface_acpi->bat2_attached = 1; 234 | + 235 | + ret = surface_acpi_event_handler(SUR_PSU_INFO_CHANGE); 236 | + if (ACPI_FAILURE(ret)) 237 | + pr_err("surface_acpi: Error registering PSU\n"); 238 | + else 239 | + surface_acpi->psu_registered = 1; 240 | +} 241 | + 242 | +static acpi_status surface_acpi_ssh_initialize(void) 243 | +{ 244 | + acpi_status status; 245 | + 246 | + if (acpi_has_method(surface_acpi->ssh_dev->handle, SUR_METHOD_INI)) { 247 | + status = acpi_evaluate_object(surface_acpi->ssh_dev->handle, 248 | + SUR_METHOD_INI, NULL, NULL); 249 | + 250 | + if (ACPI_FAILURE(status)) { 251 | + pr_err("surface_acpi: ACPI event failure status %s\n", 252 | + acpi_format_exception(status)); 253 | + return AE_ERROR; 254 | + } 255 | + } 256 | + else 257 | + return AE_NOT_FOUND; 258 | + 259 | + return AE_OK; 260 | +} 261 | + 262 | +static int bat1_proc_show(struct seq_file *m, void *v) 263 | +{ 264 | + seq_printf(m, "attached: %d\n", surface_acpi->bat1_attached); 265 | + return 0; 266 | +} 267 | + 268 | +static int bat1_proc_open(struct inode *inode, struct file *file) 269 | +{ 270 | + return single_open(file, bat1_proc_show, PDE_DATA(inode)); 271 | +} 272 | + 273 | +static const struct file_operations bat1_proc_fops = { 274 | + .owner = THIS_MODULE, 275 | + .open = bat1_proc_open, 276 | + .read = seq_read, 277 | + .llseek = seq_lseek, 278 | + .release = single_release, 279 | +}; 280 | + 281 | +static int bat2_proc_show(struct seq_file *m, void *v) 282 | +{ 283 | + seq_printf(m, "attached: %d\n", surface_acpi->bat2_attached); 284 | + return 0; 285 | +} 286 | + 287 | +static int bat2_proc_open(struct inode *inode, struct file *file) 288 | +{ 289 | + return single_open(file, bat2_proc_show, PDE_DATA(inode)); 290 | +} 291 | + 292 | +static const struct file_operations bat2_proc_fops = { 293 | + .owner = THIS_MODULE, 294 | + .open = bat2_proc_open, 295 | + .read = seq_read, 296 | + .llseek = seq_lseek, 297 | + .release = single_release, 298 | +}; 299 | + 300 | +static int psu_proc_show(struct seq_file *m, void *v) 301 | +{ 302 | + seq_printf(m, "registered: %d\n", surface_acpi->psu_registered); 303 | + return 0; 304 | +} 305 | + 306 | +static int psu_proc_open(struct inode *inode, struct file *file) 307 | +{ 308 | + return single_open(file, psu_proc_show, PDE_DATA(inode)); 309 | +} 310 | + 311 | +static const struct file_operations psu_proc_fops = { 312 | + .owner = THIS_MODULE, 313 | + .open = psu_proc_open, 314 | + .read = seq_read, 315 | + .llseek = seq_lseek, 316 | + .release = single_release, 317 | +}; 318 | + 319 | +static int version_proc_show(struct seq_file *m, void *v) 320 | +{ 321 | + seq_printf(m, "driver: %s\n", SURFACE_ACPI_VERSION); 322 | + return 0; 323 | +} 324 | + 325 | +static int version_proc_open(struct inode *inode, struct file *file) 326 | +{ 327 | + return single_open(file, version_proc_show, PDE_DATA(inode)); 328 | +} 329 | + 330 | +static const struct file_operations version_proc_fops = { 331 | + .owner = THIS_MODULE, 332 | + .open = version_proc_open, 333 | + .read = seq_read, 334 | + .llseek = seq_lseek, 335 | + .release = single_release, 336 | +}; 337 | + 338 | +static void create_surface_proc_entries(void) 339 | +{ 340 | + proc_create_data("BAT1", 0, surface_proc_dir, 341 | + &bat1_proc_fops, surface_acpi->bat1_attached); 342 | + proc_create_data("BAT2", 0, surface_proc_dir, 343 | + &bat2_proc_fops, surface_acpi->bat2_attached); 344 | + proc_create_data("ADP1", 0, surface_proc_dir, 345 | + &psu_proc_fops, surface_acpi->psu_registered); 346 | + proc_create_data("version", 0, surface_proc_dir, 347 | + &version_proc_fops, SURFACE_ACPI_VERSION); 348 | +} 349 | + 350 | +static void remove_surface_proc_entries(void) 351 | +{ 352 | + remove_proc_entry("BAT1", surface_proc_dir); 353 | + remove_proc_entry("BAT2", surface_proc_dir); 354 | + remove_proc_entry("ADP1", surface_proc_dir); 355 | + remove_proc_entry("version", surface_proc_dir); 356 | +} 357 | + 358 | +static void surface_acpi_notify(struct acpi_device *dev, u32 event) 359 | +{ 360 | + pr_info("surface_acpi: Event received %x\n", event); 361 | +} 362 | + 363 | +static void surface_acpi_register_rqst_handler(void) 364 | +{ 365 | + acpi_status status; 366 | + 367 | + status = acpi_get_handle(NULL, SUR_SAN_RQST, &surface_acpi->rqst_handle); 368 | + if (ACPI_FAILURE(status)) { 369 | + pr_err("surface_acpi: ACPI event failure status %s\n", 370 | + acpi_format_exception(status)); 371 | + } 372 | +} 373 | + 374 | +static void surface_acpi_register_rqsx_handler(void) 375 | +{ 376 | + acpi_status status; 377 | + 378 | + status = acpi_get_handle(NULL, SUR_SAN_RQSX, &surface_acpi->rqsx_handle); 379 | + if (ACPI_FAILURE(status)) { 380 | + pr_err("surface_acpi: ACPI event failure status %s\n", 381 | + acpi_format_exception(status)); 382 | + } 383 | +} 384 | + 385 | +static acpi_status surface_acpi_walk_callback(acpi_handle handle, u32 level, 386 | + void *context, void **return_value) 387 | +{ 388 | + struct acpi_device_info *info; 389 | + 390 | + if (ACPI_SUCCESS(acpi_get_object_info(handle, &info))) { 391 | + pr_warn("method: name: %4.4s, args %X\n", 392 | + (char *)&info->name, info->param_count); 393 | + 394 | + kfree(info); 395 | + } 396 | + 397 | + return AE_OK; 398 | +} 399 | + 400 | +static void surface_acpi_walk_namespace(struct acpi_device *dev) 401 | +{ 402 | + acpi_status status; 403 | + 404 | + status = acpi_walk_namespace(ACPI_TYPE_METHOD, 405 | + dev->handle, 1, surface_acpi_walk_callback, 406 | + NULL, NULL, NULL); 407 | + if (ACPI_FAILURE(status)) 408 | + pr_warn("surface_acpi: Unable to walk acpi resources\n"); 409 | +} 410 | + 411 | +static int surface_acpi_add(struct acpi_device *dev) 412 | +{ 413 | + if (!surface_acpi) 414 | + { 415 | + surface_acpi = kzalloc(sizeof(*surface_acpi), GFP_KERNEL); 416 | + if (!surface_acpi) 417 | + return AE_NO_MEMORY; 418 | + } 419 | + 420 | + if (acpi_has_method(dev->handle, SUR_METHOD_DSM)) 421 | + { 422 | + pr_info("surface_acpi: Attaching device MSHW0091\n"); 423 | + 424 | + surface_acpi->san_dev = dev; 425 | + surface_acpi->handle = dev->handle; 426 | + 427 | + surface_acpi_walk_namespace(surface_acpi->san_dev); 428 | + surface_acpi_check_status(surface_acpi->san_dev); 429 | + 430 | + surface_acpi_register_rqst_handler(); 431 | + surface_acpi_register_rqsx_handler(); 432 | + 433 | + surface_acpi_san_reg(); 434 | + surface_acpi_san_load(); 435 | + 436 | + create_surface_proc_entries(); 437 | + } 438 | + else 439 | + { 440 | + pr_info("surface_acpi: Attaching device MSHW0084\n"); 441 | + 442 | + surface_acpi->ssh_dev = dev; 443 | + 444 | + surface_acpi_walk_namespace(surface_acpi->ssh_dev); 445 | + surface_acpi_check_status(surface_acpi->ssh_dev); 446 | + 447 | + surface_acpi_ssh_initialize(); 448 | + //surface_acpi_ssh_load(); 449 | + } 450 | + 451 | + return AE_OK; 452 | +} 453 | + 454 | +static int surface_acpi_remove(struct acpi_device *dev) 455 | +{ 456 | + remove_surface_proc_entries(); 457 | + 458 | + return AE_OK; 459 | +} 460 | + 461 | +static const struct acpi_device_id surface_device_ids[] = { 462 | + {"MSHW0091", 0}, 463 | + {"MSHW0084", 0}, 464 | + {"", 0}, 465 | +}; 466 | +MODULE_DEVICE_TABLE(acpi, surface_device_ids); 467 | + 468 | +static struct acpi_driver surface_acpi_driver = { 469 | + .name = "surface_acpi", 470 | + .owner = THIS_MODULE, 471 | + .ids = surface_device_ids, 472 | + .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, 473 | + .ops = { 474 | + .add = surface_acpi_add, 475 | + .remove = surface_acpi_remove, 476 | + .notify = surface_acpi_notify, 477 | + }, 478 | +}; 479 | + 480 | +static int __init surface_acpi_init(void) 481 | +{ 482 | + int ret; 483 | + 484 | + pr_info("surface_acpi: Microsoft Surface ACPI Notify version %s\n", 485 | + SURFACE_ACPI_VERSION); 486 | + 487 | + surface_proc_dir = proc_mkdir(PROC_SURFACE, acpi_root_dir); 488 | + if (!surface_proc_dir) { 489 | + pr_err("surface_acpi: Unable to create proc dir " PROC_SURFACE "\n"); 490 | + return -ENODEV; 491 | + } 492 | + 493 | + ret = acpi_bus_register_driver(&surface_acpi_driver); 494 | + if (ret) { 495 | + pr_err("surface_acpi: Failed to register ACPI driver: %d\n", ret); 496 | + remove_proc_entry(PROC_SURFACE, acpi_root_dir); 497 | + } 498 | + 499 | + return ret; 500 | +} 501 | + 502 | +static void __exit surface_acpi_exit(void) 503 | +{ 504 | + acpi_bus_unregister_driver(&surface_acpi_driver); 505 | + if (surface_proc_dir) 506 | + remove_proc_entry(PROC_SURFACE, acpi_root_dir); 507 | +} 508 | + 509 | +module_init(surface_acpi_init); 510 | +module_exit(surface_acpi_exit); 511 | -------------------------------------------------------------------------------- /patches/4.15/surfacedock.patch: -------------------------------------------------------------------------------- 1 | From 3600aaa37a16777a07aa34672f12e30a1ae4d95b Mon Sep 17 00:00:00 2001 2 | From: Jake Day 3 | Date: Fri, 2 Feb 2018 11:21:06 -0500 4 | Subject: support for surface dock 5 | 6 | 7 | diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c 8 | index 05dca3e..59c2fcc 100644 9 | --- a/drivers/net/usb/cdc_ether.c 10 | +++ b/drivers/net/usb/cdc_ether.c 11 | @@ -807,13 +807,6 @@ static const struct usb_device_id products[] = { 12 | .driver_info = 0, 13 | }, 14 | 15 | -/* Microsoft Surface 3 dock (based on Realtek RTL8153) */ 16 | -{ 17 | - USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07c6, USB_CLASS_COMM, 18 | - USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), 19 | - .driver_info = 0, 20 | -}, 21 | - 22 | /* TP-LINK UE300 USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ 23 | { 24 | USB_DEVICE_AND_INTERFACE_INFO(TPLINK_VENDOR_ID, 0x0601, USB_CLASS_COMM, 25 | diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c 26 | index 0657203..0a52ea0 100644 27 | --- a/drivers/net/usb/r8152.c 28 | +++ b/drivers/net/usb/r8152.c 29 | @@ -5323,7 +5323,6 @@ static const struct usb_device_id rtl8152_table[] = { 30 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)}, 31 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)}, 32 | {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab)}, 33 | - {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6)}, 34 | {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, 35 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)}, 36 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062)}, 37 | -------------------------------------------------------------------------------- /patches/4.15/wifi.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/net/wireless/marvell/mwifiex/11n_aggr.c b/drivers/net/wireless/marvell/mwifiex/11n_aggr.c 2 | index 042a1d0..fc9041f 100644 3 | --- a/drivers/net/wireless/marvell/mwifiex/11n_aggr.c 4 | +++ b/drivers/net/wireless/marvell/mwifiex/11n_aggr.c 5 | @@ -200,8 +200,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, 6 | 7 | do { 8 | /* Check if AMSDU can accommodate this MSDU */ 9 | - if ((skb_aggr->len + skb_src->len + LLC_SNAP_LEN) > 10 | - adapter->tx_buf_size) 11 | + if (skb_tailroom(skb_aggr) < (skb_src->len + LLC_SNAP_LEN)) 12 | break; 13 | 14 | skb_src = skb_dequeue(&pra_list->skb_head); 15 | diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c 16 | index f324011..7f31e43 100644 17 | --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c 18 | +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c 19 | @@ -416,6 +416,9 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy, 20 | 21 | ps_mode = enabled; 22 | 23 | + mwifiex_dbg(priv->adapter, ERROR, "overriding ps_mode to false\n"); 24 | + ps_mode = 0; 25 | + 26 | return mwifiex_drv_set_power(priv, &ps_mode); 27 | } 28 | 29 | diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c b/drivers/net/wireless/marvell/mwifiex/cmdevt.c 30 | index dcc529e..3998ffb 100644 31 | --- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c 32 | +++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c 33 | @@ -995,6 +995,7 @@ mwifiex_cmd_timeout_func(struct timer_list *t) 34 | if (cmd_node->wait_q_enabled) { 35 | adapter->cmd_wait_q.status = -ETIMEDOUT; 36 | mwifiex_cancel_pending_ioctl(adapter); 37 | + adapter->cmd_sent = false; 38 | } 39 | } 40 | if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) { 41 | diff --git a/drivers/net/wireless/marvell/mwifiex/init.c b/drivers/net/wireless/marvell/mwifiex/init.c 42 | index e1aa860..328829b 100644 43 | --- a/drivers/net/wireless/marvell/mwifiex/init.c 44 | +++ b/drivers/net/wireless/marvell/mwifiex/init.c 45 | @@ -60,7 +60,7 @@ static void wakeup_timer_fn(struct timer_list *t) 46 | adapter->hw_status = MWIFIEX_HW_STATUS_RESET; 47 | mwifiex_cancel_all_pending_cmd(adapter); 48 | 49 | - if (adapter->if_ops.card_reset && !adapter->hs_activated) 50 | + if (adapter->if_ops.card_reset) 51 | adapter->if_ops.card_reset(adapter); 52 | } 53 | 54 | diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c 55 | index a96bd7e..79b026f 100644 56 | --- a/drivers/net/wireless/marvell/mwifiex/main.c 57 | +++ b/drivers/net/wireless/marvell/mwifiex/main.c 58 | @@ -163,6 +163,7 @@ void mwifiex_queue_main_work(struct mwifiex_adapter *adapter) 59 | spin_lock_irqsave(&adapter->main_proc_lock, flags); 60 | if (adapter->mwifiex_processing) { 61 | adapter->more_task_flag = true; 62 | + adapter->more_rx_task_flag = true; 63 | spin_unlock_irqrestore(&adapter->main_proc_lock, flags); 64 | } else { 65 | spin_unlock_irqrestore(&adapter->main_proc_lock, flags); 66 | @@ -171,18 +172,20 @@ void mwifiex_queue_main_work(struct mwifiex_adapter *adapter) 67 | } 68 | EXPORT_SYMBOL_GPL(mwifiex_queue_main_work); 69 | 70 | -static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter) 71 | +void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter) 72 | { 73 | unsigned long flags; 74 | 75 | spin_lock_irqsave(&adapter->rx_proc_lock, flags); 76 | if (adapter->rx_processing) { 77 | + adapter->more_rx_task_flag = true; 78 | spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 79 | } else { 80 | spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 81 | queue_work(adapter->rx_workqueue, &adapter->rx_work); 82 | } 83 | } 84 | +EXPORT_SYMBOL_GPL(mwifiex_queue_rx_work); 85 | 86 | static int mwifiex_process_rx(struct mwifiex_adapter *adapter) 87 | { 88 | @@ -192,13 +195,14 @@ static int mwifiex_process_rx(struct mwifiex_adapter *adapter) 89 | 90 | spin_lock_irqsave(&adapter->rx_proc_lock, flags); 91 | if (adapter->rx_processing || adapter->rx_locked) { 92 | + adapter->more_rx_task_flag = true; 93 | spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 94 | goto exit_rx_proc; 95 | } else { 96 | adapter->rx_processing = true; 97 | spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 98 | } 99 | - 100 | +rx_process_start: 101 | /* Check for Rx data */ 102 | while ((skb = skb_dequeue(&adapter->rx_data_q))) { 103 | atomic_dec(&adapter->rx_pending); 104 | @@ -220,6 +224,11 @@ static int mwifiex_process_rx(struct mwifiex_adapter *adapter) 105 | } 106 | } 107 | spin_lock_irqsave(&adapter->rx_proc_lock, flags); 108 | + if (adapter->more_rx_task_flag) { 109 | + adapter->more_rx_task_flag = false; 110 | + spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 111 | + goto rx_process_start; 112 | + } 113 | adapter->rx_processing = false; 114 | spin_unlock_irqrestore(&adapter->rx_proc_lock, flags); 115 | 116 | @@ -283,10 +292,10 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) 117 | mwifiex_process_hs_config(adapter); 118 | if (adapter->if_ops.process_int_status) 119 | adapter->if_ops.process_int_status(adapter); 120 | + if (adapter->rx_work_enabled && adapter->data_received) 121 | + mwifiex_queue_rx_work(adapter); 122 | } 123 | 124 | - if (adapter->rx_work_enabled && adapter->data_received) 125 | - mwifiex_queue_rx_work(adapter); 126 | 127 | /* Need to wake up the card ? */ 128 | if ((adapter->ps_state == PS_STATE_SLEEP) && 129 | diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h 130 | index 154c079..4205344 100644 131 | --- a/drivers/net/wireless/marvell/mwifiex/main.h 132 | +++ b/drivers/net/wireless/marvell/mwifiex/main.h 133 | @@ -889,6 +889,7 @@ struct mwifiex_adapter { 134 | spinlock_t main_proc_lock; 135 | u32 mwifiex_processing; 136 | u8 more_task_flag; 137 | + u8 more_rx_task_flag; 138 | u16 tx_buf_size; 139 | u16 curr_tx_buf_size; 140 | /* sdio single port rx aggregation capability */ 141 | @@ -1661,6 +1662,7 @@ void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter, void *drv_info, 142 | int drv_info_size); 143 | void *mwifiex_alloc_dma_align_buf(int rx_len, gfp_t flags); 144 | void mwifiex_queue_main_work(struct mwifiex_adapter *adapter); 145 | +void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter); 146 | int mwifiex_get_wakeup_reason(struct mwifiex_private *priv, u16 action, 147 | int cmd_type, 148 | struct mwifiex_ds_wakeup_reason *wakeup_reason); 149 | diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c 150 | index 9511f5f..4a4737c 100644 151 | --- a/drivers/net/wireless/marvell/mwifiex/pcie.c 152 | +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c 153 | @@ -1729,6 +1729,16 @@ static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) 154 | } 155 | 156 | rx_len = get_unaligned_le16(skb->data); 157 | + 158 | + 159 | + if (rx_len == 0) { 160 | + mwifiex_dbg(adapter, ERROR, 161 | + "0 byte cmdrsp\n"); 162 | + mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, 163 | + PCI_DMA_FROMDEVICE); 164 | + return 0; 165 | + } 166 | + 167 | skb_put(skb, MWIFIEX_UPLD_SIZE - skb->len); 168 | skb_trim(skb, rx_len); 169 | 170 | diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c 171 | index fb09014..5b8329e 100644 172 | --- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c 173 | +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c 174 | @@ -2313,7 +2313,7 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init) 175 | if (ret) 176 | return -1; 177 | 178 | - if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { 179 | + if (0 && priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { 180 | /* Enable IEEE PS by default */ 181 | priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; 182 | ret = mwifiex_send_cmd(priv, 183 | @@ -2336,8 +2336,8 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init) 184 | return -1; 185 | } 186 | 187 | - mwifiex_send_cmd(priv, HostCmd_CMD_CHAN_REGION_CFG, 188 | - HostCmd_ACT_GEN_GET, 0, NULL, true); 189 | + //mwifiex_send_cmd(priv, HostCmd_CMD_CHAN_REGION_CFG, 190 | + // HostCmd_ACT_GEN_GET, 0, NULL, true); 191 | } 192 | 193 | /* get tx rate */ 194 | @@ -2369,7 +2369,7 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init) 195 | if (ret) 196 | return -1; 197 | 198 | - if (!disable_auto_ds && first_sta && 199 | + if (0 && !disable_auto_ds && first_sta && 200 | priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { 201 | /* Enable auto deep sleep */ 202 | auto_ds.auto_ds = DEEP_SLEEP_ON; 203 | diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c 204 | index 1bd4e13..27d2bac 100644 205 | --- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c 206 | +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c 207 | @@ -48,9 +48,14 @@ mwifiex_process_cmdresp_error(struct mwifiex_private *priv, 208 | struct host_cmd_ds_802_11_ps_mode_enh *pm; 209 | unsigned long flags; 210 | 211 | - mwifiex_dbg(adapter, ERROR, 212 | - "CMD_RESP: cmd %#x error, result=%#x\n", 213 | - resp->command, resp->result); 214 | + if (resp->command == 271 && resp->result == 2){ 215 | + // ignore this command as the firmware does not support it 216 | + } 217 | + else { 218 | + mwifiex_dbg(adapter, ERROR, 219 | + "CMD_RESP: cmd %#x error, result=%#x\n", 220 | + resp->command, resp->result); 221 | + } 222 | 223 | if (adapter->curr_cmd->wait_q_enabled) 224 | adapter->cmd_wait_q.status = -1; 225 | diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c 226 | index 4bc2448..d20fda1 100644 227 | --- a/drivers/net/wireless/marvell/mwifiex/usb.c 228 | +++ b/drivers/net/wireless/marvell/mwifiex/usb.c 229 | @@ -144,6 +144,8 @@ static int mwifiex_usb_recv(struct mwifiex_adapter *adapter, 230 | skb_queue_tail(&adapter->rx_data_q, skb); 231 | adapter->data_received = true; 232 | atomic_inc(&adapter->rx_pending); 233 | + if (adapter->rx_work_enabled) 234 | + mwifiex_queue_rx_work(adapter); 235 | break; 236 | default: 237 | mwifiex_dbg(adapter, ERROR, 238 | diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c 239 | index ffbf4e7..3ad81e3 100644 240 | --- a/drivers/pci/pcie/portdrv_pci.c 241 | +++ b/drivers/pci/pcie/portdrv_pci.c 242 | @@ -150,6 +150,11 @@ static int pcie_portdrv_probe(struct pci_dev *dev, 243 | 244 | pci_save_state(dev); 245 | 246 | + /* 247 | + * D3cold disabled by default 248 | + */ 249 | + dev->d3cold_allowed = false; 250 | + 251 | if (pci_bridge_d3_possible(dev)) { 252 | /* 253 | * Keep the port resumed 100ms to make sure things like 254 | diff --git a/net/wireless/sme.c b/net/wireless/sme.c 255 | index fdb3646..b44b23b 100644 256 | --- a/net/wireless/sme.c 257 | +++ b/net/wireless/sme.c 258 | @@ -690,6 +690,11 @@ void __cfg80211_connect_result(struct net_device *dev, 259 | return; 260 | } 261 | 262 | + if (WARN_ON(!wdev->ssid_len)) { 263 | + cfg80211_put_bss(wdev->wiphy, cr->bss); 264 | + return; 265 | + } 266 | + 267 | nl80211_send_connect_result(wiphy_to_rdev(wdev->wiphy), dev, cr, 268 | GFP_KERNEL); 269 | 270 | @@ -1105,7 +1110,7 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev, 271 | /* 272 | * If we have an ssid_len, we're trying to connect or are 273 | * already connected, so reject a new SSID unless it's the 274 | - * same (which is the case for re-association.) 275 | + * same (which is the case for Re-Association. 276 | */ 277 | if (wdev->ssid_len && 278 | (wdev->ssid_len != connect->ssid_len || 279 | diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl 280 | old mode 100755 281 | new mode 100644 282 | -------------------------------------------------------------------------------- /patches/4.16/acpica.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/acpi/acpica/dbdisply.c b/drivers/acpi/acpica/dbdisply.c 2 | index 5a606ea..7b5eb33 100644 3 | --- a/drivers/acpi/acpica/dbdisply.c 4 | +++ b/drivers/acpi/acpica/dbdisply.c 5 | @@ -642,9 +642,8 @@ void acpi_db_display_object_type(char *object_arg) 6 | return; 7 | } 8 | 9 | - acpi_os_printf("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", 10 | - ACPI_FORMAT_UINT64(info->address), 11 | - info->current_status, info->flags); 12 | + acpi_os_printf("ADR: %8.8X%8.8X, Flags: %X\n", 13 | + ACPI_FORMAT_UINT64(info->address), info->flags); 14 | 15 | acpi_os_printf("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", 16 | info->highest_dstates[0], info->highest_dstates[1], 17 | diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c 18 | index d3b6b31..37b0b4c 100644 19 | --- a/drivers/acpi/acpica/evevent.c 20 | +++ b/drivers/acpi/acpica/evevent.c 21 | @@ -204,6 +204,7 @@ u32 acpi_ev_fixed_event_detect(void) 22 | u32 fixed_status; 23 | u32 fixed_enable; 24 | u32 i; 25 | + acpi_status status; 26 | 27 | ACPI_FUNCTION_NAME(ev_fixed_event_detect); 28 | 29 | @@ -211,8 +212,12 @@ u32 acpi_ev_fixed_event_detect(void) 30 | * Read the fixed feature status and enable registers, as all the cases 31 | * depend on their values. Ignore errors here. 32 | */ 33 | - (void)acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status); 34 | - (void)acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable); 35 | + status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status); 36 | + status |= 37 | + acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable); 38 | + if (ACPI_FAILURE(status)) { 39 | + return (int_status); 40 | + } 41 | 42 | ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, 43 | "Fixed Event Block: Enable %08X Status %08X\n", 44 | diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c 45 | index a8191d2..2ad13d8 100644 46 | --- a/drivers/acpi/acpica/exdebug.c 47 | +++ b/drivers/acpi/acpica/exdebug.c 48 | @@ -88,14 +88,13 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc, 49 | return_VOID; 50 | } 51 | 52 | - /* Null string or newline -- don't emit the line header */ 53 | + /* Newline -- don't emit the line header */ 54 | 55 | if (source_desc && 56 | (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) && 57 | (source_desc->common.type == ACPI_TYPE_STRING)) { 58 | - if ((source_desc->string.length == 0) || 59 | - ((source_desc->string.length == 1) && 60 | - (*source_desc->string.pointer == '\n'))) { 61 | + if ((source_desc->string.length == 1) && 62 | + (*source_desc->string.pointer == '\n')) { 63 | acpi_os_printf("\n"); 64 | return_VOID; 65 | } 66 | diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c 67 | index 5026594..573a5f3 100644 68 | --- a/drivers/acpi/acpica/nsdumpdv.c 69 | +++ b/drivers/acpi/acpica/nsdumpdv.c 70 | @@ -88,10 +88,9 @@ acpi_ns_dump_one_device(acpi_handle obj_handle, 71 | } 72 | 73 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, 74 | - " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", 75 | + " HID: %s, ADR: %8.8X%8.8X\n", 76 | info->hardware_id.value, 77 | - ACPI_FORMAT_UINT64(info->address), 78 | - info->current_status)); 79 | + ACPI_FORMAT_UINT64(info->address)); 80 | ACPI_FREE(info); 81 | } 82 | 83 | diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c 84 | index 1069662..0a9c600 100644 85 | --- a/drivers/acpi/acpica/nsxfname.c 86 | +++ b/drivers/acpi/acpica/nsxfname.c 87 | @@ -241,7 +241,7 @@ static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, 88 | * namespace node and possibly by running several standard 89 | * control methods (Such as in the case of a device.) 90 | * 91 | - * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, 92 | + * For Device and Processor objects, run the Device _HID, _UID, _CID, 93 | * _CLS, _ADR, _sx_w, and _sx_d methods. 94 | * 95 | * Note: Allocates the return buffer, must be freed by the caller. 96 | @@ -250,8 +250,9 @@ static char *acpi_ns_copy_device_id(struct acpi_pnp_device_id *dest, 97 | * discovery namespace traversal. Therefore, no complex methods can be 98 | * executed, especially those that access operation regions. Therefore, do 99 | * not add any additional methods that could cause problems in this area. 100 | - * this was the fate of the _SUB method which was found to cause such 101 | - * problems and was removed (11/2015). 102 | + * Because of this reason support for the following methods has been removed: 103 | + * 1) _SUB method was removed (11/2015) 104 | + * 2) _STA method was removed (02/2018) 105 | * 106 | ******************************************************************************/ 107 | 108 | @@ -374,20 +375,8 @@ acpi_get_object_info(acpi_handle handle, 109 | * Notes: none of these methods are required, so they may or may 110 | * not be present for this device. The Info->Valid bitfield is used 111 | * to indicate which methods were found and run successfully. 112 | - * 113 | - * For _STA, if the method does not exist, then (as per the ACPI 114 | - * specification), the returned current_status flags will indicate 115 | - * that the device is present/functional/enabled. Otherwise, the 116 | - * current_status flags reflect the value returned from _STA. 117 | */ 118 | 119 | - /* Execute the Device._STA method */ 120 | - 121 | - status = acpi_ut_execute_STA(node, &info->current_status); 122 | - if (ACPI_SUCCESS(status)) { 123 | - valid |= ACPI_VALID_STA; 124 | - } 125 | - 126 | /* Execute the Device._ADR method */ 127 | 128 | status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node, 129 | diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c 130 | index eb9dfac..11ce4e5 100644 131 | --- a/drivers/acpi/acpica/psargs.c 132 | +++ b/drivers/acpi/acpica/psargs.c 133 | @@ -890,6 +890,10 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, 134 | ACPI_POSSIBLE_METHOD_CALL); 135 | 136 | if (arg->common.aml_opcode == AML_INT_METHODCALL_OP) { 137 | + 138 | + /* Free method call op and corresponding namestring sub-ob */ 139 | + 140 | + acpi_ps_free_op(arg->common.value.arg); 141 | acpi_ps_free_op(arg); 142 | arg = NULL; 143 | walk_state->arg_count = 1; 144 | diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h 145 | index 4f077ed..220ef86 100644 146 | --- a/include/acpi/actypes.h 147 | +++ b/include/acpi/actypes.h 148 | @@ -1191,7 +1191,6 @@ struct acpi_device_info { 149 | u8 flags; /* Miscellaneous info */ 150 | u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */ 151 | u8 lowest_dstates[5]; /* _sx_w values: 0xFF indicates not valid */ 152 | - u32 current_status; /* _STA value */ 153 | u64 address; /* _ADR value */ 154 | struct acpi_pnp_device_id hardware_id; /* _HID value */ 155 | struct acpi_pnp_device_id unique_id; /* _UID value */ 156 | @@ -1205,7 +1204,6 @@ struct acpi_device_info { 157 | 158 | /* Flags for Valid field above (acpi_get_object_info) */ 159 | 160 | -#define ACPI_VALID_STA 0x0001 161 | #define ACPI_VALID_ADR 0x0002 162 | #define ACPI_VALID_HID 0x0004 163 | #define ACPI_VALID_UID 0x0008 164 | -------------------------------------------------------------------------------- /patches/4.16/cameras.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c 2 | index fd387bf..35ae5af 100644 3 | --- a/drivers/media/usb/uvc/uvc_driver.c 4 | +++ b/drivers/media/usb/uvc/uvc_driver.c 5 | @@ -2353,6 +2353,46 @@ static const struct uvc_device_info uvc_quirk_force_y8 = { 6 | * though they are compliant. 7 | */ 8 | static const struct usb_device_id uvc_ids[] = { 9 | + /* Microsoft Surface Pro 3 Front */ 10 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 11 | + | USB_DEVICE_ID_MATCH_INT_INFO, 12 | + .idVendor = 0x045e, 13 | + .idProduct = 0x07be, 14 | + .bInterfaceClass = USB_CLASS_VIDEO, 15 | + .bInterfaceSubClass = 1, 16 | + .bInterfaceProtocol = 1 }, 17 | + /* Microsoft Surface Pro 3 Rear */ 18 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 19 | + | USB_DEVICE_ID_MATCH_INT_INFO, 20 | + .idVendor = 0x045e, 21 | + .idProduct = 0x07bf, 22 | + .bInterfaceClass = USB_CLASS_VIDEO, 23 | + .bInterfaceSubClass = 1, 24 | + .bInterfaceProtocol = 1 }, 25 | + /* Microsoft Surface Pro 4 Cam */ 26 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 27 | + | USB_DEVICE_ID_MATCH_INT_INFO, 28 | + .idVendor = 0x045e, 29 | + .idProduct = 0x090c, 30 | + .bInterfaceClass = USB_CLASS_VIDEO, 31 | + .bInterfaceSubClass = 1, 32 | + .bInterfaceProtocol = 1 }, 33 | + /* Microsoft Surface Book Cam 1 */ 34 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 35 | + | USB_DEVICE_ID_MATCH_INT_INFO, 36 | + .idVendor = 0x045e, 37 | + .idProduct = 0x090b, 38 | + .bInterfaceClass = USB_CLASS_VIDEO, 39 | + .bInterfaceSubClass = 1, 40 | + .bInterfaceProtocol = 1 }, 41 | + /* Microsoft Surface Book Cam 2 */ 42 | + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 43 | + | USB_DEVICE_ID_MATCH_INT_INFO, 44 | + .idVendor = 0x045e, 45 | + .idProduct = 0x091a, 46 | + .bInterfaceClass = USB_CLASS_VIDEO, 47 | + .bInterfaceSubClass = 1, 48 | + .bInterfaceProtocol = 1 }, 49 | /* LogiLink Wireless Webcam */ 50 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 51 | | USB_DEVICE_ID_MATCH_INT_INFO, 52 | diff --git a/drivers/staging/media/atomisp/i2c/ov5693/Kconfig b/drivers/staging/media/atomisp/i2c/ov5693/Kconfig 53 | index 3f527f2..b882948 100644 54 | --- a/drivers/staging/media/atomisp/i2c/ov5693/Kconfig 55 | +++ b/drivers/staging/media/atomisp/i2c/ov5693/Kconfig 56 | @@ -1,7 +1,7 @@ 57 | config VIDEO_ATOMISP_OV5693 58 | tristate "Omnivision ov5693 sensor support" 59 | depends on ACPI 60 | - depends on I2C && VIDEO_V4L2 61 | + depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER 62 | ---help--- 63 | This is a Video4Linux2 sensor-level driver for the Micron 64 | ov5693 5 Mpixel camera. 65 | diff --git a/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c b/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c 66 | index 40d01bf..4f33294 100644 67 | --- a/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c 68 | +++ b/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c 69 | @@ -1335,11 +1335,15 @@ static int power_ctrl(struct v4l2_subdev *sd, bool flag) 70 | static int gpio_ctrl(struct v4l2_subdev *sd, bool flag) 71 | { 72 | struct ov5693_device *dev = to_ov5693_sensor(sd); 73 | + int ret = 0; 74 | 75 | if (!dev || !dev->platform_data) 76 | return -ENODEV; 77 | 78 | - return dev->platform_data->gpio0_ctrl(sd, flag); 79 | + if (dev->platform_data->gpio0_ctrl) 80 | + ret = dev->platform_data->gpio0_ctrl(sd, flag); 81 | + 82 | + return ret; 83 | } 84 | 85 | static int __power_up(struct v4l2_subdev *sd) 86 | @@ -1707,7 +1711,7 @@ static int ov5693_detect(struct i2c_client *client) 87 | OV5693_SC_CMMN_CHIP_ID_L, &low); 88 | id = ((((u16) high) << 8) | (u16) low); 89 | 90 | - if (id != OV5693_ID) { 91 | + if (id != OV5690_ID && id != OV5693_ID) { 92 | dev_err(&client->dev, "sensor ID error 0x%x\n", id); 93 | return -ENODEV; 94 | } 95 | diff --git a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h 96 | index 68cfcb4..b4616ac 100644 97 | --- a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h 98 | +++ b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h 99 | @@ -29,7 +29,7 @@ 100 | #include 101 | #include 102 | 103 | -#include "../../include/linux/atomisp_platform.h" 104 | +#include "../../include/linux/atomisp_gmin_platform.h" 105 | 106 | #define OV5693_POWER_UP_RETRY_NUM 5 107 | 108 | @@ -72,7 +72,8 @@ 109 | * bits 7-0: min f-number denominator 110 | */ 111 | #define OV5693_F_NUMBER_RANGE 0x180a180a 112 | -#define OV5693_ID 0x5690 113 | +#define OV5690_ID 0x5690 114 | +#define OV5693_ID 0x5693 115 | 116 | #define OV5693_FINE_INTG_TIME_MIN 0 117 | #define OV5693_FINE_INTG_TIME_MAX_MARGIN 0 118 | diff --git a/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c 119 | index d8b7183..d9d8c48 100644 120 | --- a/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c 121 | +++ b/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c 122 | @@ -249,11 +249,13 @@ static struct gmin_cfg_var ecs7_vars[] = { 123 | {"INT33BE:00_CsiFmt", "13"}, 124 | {"INT33BE:00_CsiBayer", "2"}, 125 | {"INT33BE:00_CamClk", "0"}, 126 | + {"INT33BE:00_ClkSrc", "1"}, 127 | {"INT33F0:00_CsiPort", "0"}, 128 | {"INT33F0:00_CsiLanes", "1"}, 129 | {"INT33F0:00_CsiFmt", "13"}, 130 | {"INT33F0:00_CsiBayer", "0"}, 131 | {"INT33F0:00_CamClk", "1"}, 132 | + {"INT33BE:00_I2CAddr", "-1"}, 133 | {"gmin_V2P8GPIO", "402"}, 134 | {}, 135 | }; 136 | @@ -305,6 +307,20 @@ static const struct dmi_system_id gmin_vars[] = { 137 | }, 138 | .driver_data = i8880_vars, 139 | }, 140 | + { 141 | + .ident = "Surface Book", 142 | + .matches = { 143 | + DMI_MATCH(DMI_BOARD_NAME, "Surface Book"), 144 | + }, 145 | + .driver_data = ecs7_vars, 146 | + }, 147 | + { 148 | + .ident = "Surface Pro 4", 149 | + .matches = { 150 | + DMI_MATCH(DMI_BOARD_NAME, "Surface Pro 4"), 151 | + }, 152 | + .driver_data = ecs7_vars, 153 | + }, 154 | {} 155 | }; 156 | 157 | -------------------------------------------------------------------------------- /patches/4.16/keyboards_and_covers.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h 2 | index 9454ac1..ae2f26c 100644 3 | --- a/drivers/hid/hid-ids.h 4 | +++ b/drivers/hid/hid-ids.h 5 | @@ -774,11 +774,22 @@ 6 | #define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3KV1 0x0732 7 | #define USB_DEVICE_ID_MS_DIGITAL_MEDIA_600 0x0750 8 | #define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c 9 | -#define USB_DEVICE_ID_MS_COMFORT_KEYBOARD 0x00e3 10 | -#define USB_DEVICE_ID_MS_SURFACE_PRO_2 0x0799 11 | -#define USB_DEVICE_ID_MS_TOUCH_COVER_2 0x07a7 12 | -#define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9 13 | -#define USB_DEVICE_ID_MS_POWER_COVER 0x07da 14 | +#define USB_DEVICE_ID_MS_COMFORT_KEYBOARD 0x00e3 15 | +#define USB_DEVICE_ID_MS_SURFACE_PRO_2 0x0799 16 | +#define USB_DEVICE_ID_MS_TOUCH_COVER_2 0x07a7 17 | +#define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9 18 | +#define USB_DEVICE_ID_MS_TYPE_COVER_3 0x07de 19 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3 0x07dc 20 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_1 0x07de 21 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2 0x07e2 22 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP 0x07dd 23 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_4 0x07e8 24 | +#define USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_1 0x07e4 25 | +#define USB_DEVICE_ID_MS_SURFACE_BOOK 0x07cd 26 | +#define USB_DEVICE_ID_MS_SURFACE_BOOK_2 0x0922 27 | +#define USB_DEVICE_ID_MS_SURFACE_LAPTOP 0xf001 28 | +#define HID_DEVICE_ID_MS_SURFACE_LAPTOP 0xf001 29 | +#define USB_DEVICE_ID_MS_POWER_COVER 0x07da 30 | 31 | #define USB_VENDOR_ID_MOJO 0x8282 32 | #define USB_DEVICE_ID_RETRO_ADAPTER 0x3201 33 | diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c 34 | index 3b4739bd..82cee6c 100644 35 | --- a/drivers/hid/hid-multitouch.c 36 | +++ b/drivers/hid/hid-multitouch.c 37 | @@ -1743,6 +1743,58 @@ static const struct hid_device_id mt_devices[] = { 38 | HID_USB_DEVICE(USB_VENDOR_ID_LG, 39 | USB_DEVICE_ID_LG_MELFAS_MT) }, 40 | 41 | + /* Microsoft Touch Cover */ 42 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 43 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 44 | + USB_DEVICE_ID_MS_TOUCH_COVER_2) }, 45 | + 46 | + /* Microsoft Type Cover */ 47 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 48 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 49 | + USB_DEVICE_ID_MS_TYPE_COVER_2) }, 50 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 51 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 52 | + USB_DEVICE_ID_MS_TYPE_COVER_3) }, 53 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 54 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 55 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3) }, 56 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 57 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 58 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_1) }, 59 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 60 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 61 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2) }, 62 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 63 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 64 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP) }, 65 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 66 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 67 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_4) }, 68 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 69 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 70 | + USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_1) }, 71 | + 72 | + /* Microsoft Surface Book */ 73 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 74 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 75 | + USB_DEVICE_ID_MS_SURFACE_BOOK) }, 76 | + 77 | + /* Microsoft Surface Book 2 */ 78 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 79 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 80 | + USB_DEVICE_ID_MS_SURFACE_BOOK_2) }, 81 | + 82 | + /* Microsoft Surface Laptop */ 83 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 84 | + HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, 85 | + USB_VENDOR_ID_MICROSOFT, 86 | + HID_DEVICE_ID_MS_SURFACE_LAPTOP) }, 87 | + 88 | + /* Microsoft Power Cover */ 89 | + { .driver_data = MT_CLS_EXPORT_ALL_INPUTS, 90 | + MT_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, 91 | + USB_DEVICE_ID_MS_POWER_COVER) }, 92 | + 93 | /* MosArt panels */ 94 | { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, 95 | MT_USB_DEVICE(USB_VENDOR_ID_ASUS, 96 | diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c 97 | index e92b77f..3cfadf1 100644 98 | --- a/drivers/hid/hid-quirks.c 99 | +++ b/drivers/hid/hid-quirks.c 100 | @@ -110,6 +110,16 @@ static const struct hid_device_id hid_quirks[] = { 101 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_PRO_2), HID_QUIRK_NO_INIT_REPORTS }, 102 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TOUCH_COVER_2), HID_QUIRK_NO_INIT_REPORTS }, 103 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2), HID_QUIRK_NO_INIT_REPORTS }, 104 | + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3), HID_QUIRK_NO_INIT_REPORTS }, 105 | + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3), HID_QUIRK_NO_INIT_REPORTS }, 106 | + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_1), HID_QUIRK_NO_INIT_REPORTS }, 107 | + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2), HID_QUIRK_NO_INIT_REPORTS }, 108 | + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP), HID_QUIRK_NO_INIT_REPORTS }, 109 | + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_4), HID_QUIRK_NO_INIT_REPORTS }, 110 | + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_1), HID_QUIRK_NO_INIT_REPORTS }, 111 | + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_BOOK), HID_QUIRK_NO_INIT_REPORTS }, 112 | + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_BOOK_2), HID_QUIRK_NO_INIT_REPORTS }, 113 | + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_LAPTOP), HID_QUIRK_NO_INIT_REPORTS }, 114 | { HID_USB_DEVICE(USB_VENDOR_ID_MOJO, USB_DEVICE_ID_RETRO_ADAPTER), HID_QUIRK_MULTI_INPUT }, 115 | { HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL), HID_QUIRK_NO_INIT_REPORTS }, 116 | { HID_USB_DEVICE(USB_VENDOR_ID_MULTIPLE_1781, USB_DEVICE_ID_RAPHNET_4NES4SNES_OLD), HID_QUIRK_MULTI_INPUT }, 117 | -------------------------------------------------------------------------------- /patches/4.16/sdcard_reader.patch: -------------------------------------------------------------------------------- 1 | From fbd83f772a3be3a00bae323f6d71a59b26352c57 Mon Sep 17 00:00:00 2001 2 | From: Jake Day 3 | Date: Fri, 2 Feb 2018 11:22:21 -0500 4 | Subject: fix for surface sd card reader 5 | 6 | 7 | diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c 8 | index cf7bbcb..826fdb8 100644 9 | --- a/drivers/usb/core/hub.c 10 | +++ b/drivers/usb/core/hub.c 11 | @@ -4047,7 +4047,8 @@ void usb_enable_lpm(struct usb_device *udev) 12 | if (!udev || !udev->parent || 13 | udev->speed < USB_SPEED_SUPER || 14 | !udev->lpm_capable || 15 | - udev->state < USB_STATE_DEFAULT) 16 | + udev->state < USB_STATE_DEFAULT || 17 | + !udev->bos || !udev->bos->ss_cap) 18 | return; 19 | 20 | udev->lpm_disable_count--; 21 | -------------------------------------------------------------------------------- /patches/4.16/surfaceacpi.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig 2 | index 51ebc5a..244fa92 100644 3 | --- a/drivers/platform/x86/Kconfig 4 | +++ b/drivers/platform/x86/Kconfig 5 | @@ -1155,6 +1155,15 @@ config SURFACE_3_BUTTON 6 | ---help--- 7 | This driver handles the power/home/volume buttons on the Microsoft Surface 3 tablet. 8 | 9 | +config ACPI_SURFACE 10 | + tristate "Microsoft Surface Extras" 11 | + depends on ACPI 12 | + depends on ACPI_WMI 13 | + depends on INPUT 14 | + ---help--- 15 | + This driver adds support for access to certain system events 16 | + on Microsoft Surface devices. 17 | + 18 | config INTEL_PUNIT_IPC 19 | tristate "Intel P-Unit IPC Driver" 20 | ---help--- 21 | diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile 22 | index 2ba6cb7..bcb0dd9 100644 23 | --- a/drivers/platform/x86/Makefile 24 | +++ b/drivers/platform/x86/Makefile 25 | @@ -81,6 +81,7 @@ obj-$(CONFIG_INTEL_PMC_IPC) += intel_pmc_ipc.o 26 | obj-$(CONFIG_SILEAD_DMI) += silead_dmi.o 27 | obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o 28 | obj-$(CONFIG_SURFACE_3_BUTTON) += surface3_button.o 29 | +obj-$(CONFIG_ACPI_SURFACE) += surface_acpi.o 30 | obj-$(CONFIG_INTEL_PUNIT_IPC) += intel_punit_ipc.o 31 | obj-$(CONFIG_INTEL_BXTWC_PMIC_TMU) += intel_bxtwc_tmu.o 32 | obj-$(CONFIG_INTEL_TELEMETRY) += intel_telemetry_core.o \ 33 | diff --git a/drivers/platform/x86/surface_acpi.c b/drivers/platform/x86/surface_acpi.c 34 | new file mode 100644 35 | index 0000000..bee15e7 36 | --- /dev/null 37 | +++ b/drivers/platform/x86/surface_acpi.c 38 | @@ -0,0 +1,472 @@ 39 | +/* 40 | + * surface_acpi.c - Microsoft Surface ACPI Notify 41 | + * 42 | + * This program is free software; you can redistribute it and/or modify 43 | + * it under the terms of the GNU General Public License as published by 44 | + * the Free Software Foundation; either version 2 of the License, or 45 | + * (at your option) any later version. 46 | + * 47 | + * This program is distributed in the hope that it will be useful, 48 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of 49 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 50 | + * GNU General Public License for more details. 51 | + * 52 | + * The full GNU General Public License is included in this distribution in 53 | + * the file called "COPYING". 54 | + */ 55 | + 56 | +#define SURFACE_ACPI_VERSION "0.1" 57 | +#define SURFACE_GEN_VERSION 0x08 58 | +#define PROC_SURFACE "surface" 59 | + 60 | +#include 61 | +#include 62 | +#include 63 | +#include 64 | +#include 65 | +#include 66 | +#include 67 | +#include 68 | +#include 69 | +#include 70 | +#include 71 | + 72 | +MODULE_AUTHOR("Jake Day"); 73 | +MODULE_DESCRIPTION("Microsoft Surface ACPI Notify Driver"); 74 | +MODULE_LICENSE("GPL"); 75 | + 76 | +#define SUR_METHOD_DSM "_DSM" 77 | +#define SUR_METHOD_REG "_REG" 78 | +#define SUR_METHOD_STA "_STA" 79 | +#define SUR_METHOD_INI "_INI" 80 | +#define SUR_METHOD_CRS "_CRS" 81 | + 82 | +#define SUR_QUERY_DEVICE 0x00 83 | +#define SUR_SET_DVER 0x01 84 | +#define SUR_GET_BOARD_REVID 0x02 85 | +#define SUR_BAT1_STATE_CHANGE 0x03 86 | +#define SUR_BAT1_INFO_CHANGE 0x04 87 | +#define SUR_PSU_STATE_CHANGE 0x05 88 | +#define SUR_PSU_INFO_CHANGE 0x06 89 | +#define SUR_BAT2_STATE_CHANGE 0x07 90 | +#define SUR_BAT2_INFO_CHANGE 0x08 91 | +#define SUR_SENSOR_TRIP_POINT 0x09 92 | + 93 | +#define REG_AVAILABLE 0x01 94 | +#define REG_INIT 0x09 95 | + 96 | +static char SURFACE_EVENT_GUID[] = "93b666c5-70c6-469f-a215-3d487c91ab3c"; 97 | +static char SUR_SAN_RQST[] = "\\_SB._SAN.RQST"; 98 | +static char SUR_SAN_RQSX[] = "\\_SB._SAN.RQSX"; 99 | + 100 | +struct surface_acpi_dev { 101 | + acpi_handle handle; 102 | + acpi_handle rqst_handle; 103 | + acpi_handle rqsx_handle; 104 | + 105 | + struct acpi_device *san_dev; 106 | + struct acpi_device *ssh_dev; 107 | + struct acpi_device *bat1_dev; 108 | + struct acpi_device *bat2_dev; 109 | + struct acpi_device *psu_dev; 110 | + 111 | + unsigned int bat1_attached:1; 112 | + unsigned int bat2_attached:1; 113 | + unsigned int psu_registered:1; 114 | +}; 115 | + 116 | +static struct surface_acpi_dev *surface_acpi; 117 | + 118 | +static struct proc_dir_entry *surface_proc_dir; 119 | + 120 | +static acpi_status surface_acpi_check_status(struct acpi_device *dev) 121 | +{ 122 | + unsigned long long value; 123 | + acpi_status status; 124 | + 125 | + if (acpi_has_method(dev->handle, SUR_METHOD_STA)) { 126 | + status = acpi_evaluate_integer(dev->handle, 127 | + SUR_METHOD_STA, NULL, &value); 128 | + 129 | + if (ACPI_FAILURE(status)) { 130 | + pr_err("surface_acpi: ACPI event failure status %s\n", 131 | + acpi_format_exception(status)); 132 | + return AE_ERROR; 133 | + } 134 | + } 135 | + else 136 | + return AE_NOT_FOUND; 137 | + 138 | + return AE_OK; 139 | +} 140 | + 141 | +static acpi_status surface_acpi_san_reg(void) 142 | +{ 143 | + union acpi_object in_objs[2], out_objs[1]; 144 | + struct acpi_object_list params; 145 | + struct acpi_buffer results; 146 | + acpi_status status; 147 | + 148 | + params.count = ARRAY_SIZE(in_objs); 149 | + params.pointer = in_objs; 150 | + in_objs[0].type = ACPI_TYPE_INTEGER; 151 | + in_objs[0].integer.value = REG_INIT; 152 | + in_objs[1].type = ACPI_TYPE_INTEGER; 153 | + in_objs[1].integer.value = REG_AVAILABLE; 154 | + results.length = sizeof(out_objs); 155 | + results.pointer = out_objs; 156 | + 157 | + if (acpi_has_method(surface_acpi->handle, SUR_METHOD_REG)) { 158 | + status = acpi_evaluate_object(surface_acpi->handle, 159 | + SUR_METHOD_REG, ¶ms, &results); 160 | + 161 | + if (ACPI_FAILURE(status)) { 162 | + pr_err("surface_acpi: ACPI event failure status %s\n", 163 | + acpi_format_exception(status)); 164 | + return AE_ERROR; 165 | + } 166 | + } 167 | + else 168 | + return AE_NOT_FOUND; 169 | + 170 | + return AE_OK; 171 | +} 172 | + 173 | +static acpi_status surface_acpi_event_handler(u32 event) 174 | +{ 175 | + union acpi_object in_objs[4], out_objs[5]; 176 | + struct acpi_object_list params; 177 | + struct acpi_buffer results; 178 | + acpi_status status; 179 | + 180 | + params.count = ARRAY_SIZE(in_objs); 181 | + params.pointer = in_objs; 182 | + in_objs[0].type = ACPI_TYPE_BUFFER; 183 | + in_objs[0].buffer.length = sizeof(SURFACE_EVENT_GUID); 184 | + in_objs[0].buffer.pointer = SURFACE_EVENT_GUID; 185 | + in_objs[1].type = ACPI_TYPE_INTEGER; 186 | + in_objs[1].integer.value = SUR_QUERY_DEVICE; 187 | + in_objs[2].type = ACPI_TYPE_INTEGER; 188 | + in_objs[2].integer.value = event; 189 | + in_objs[3].type = ACPI_TYPE_PACKAGE; 190 | + in_objs[3].package.count = 0; 191 | + in_objs[3].package.elements = SURFACE_GEN_VERSION; 192 | + results.length = sizeof(out_objs); 193 | + results.pointer = out_objs; 194 | + 195 | + if (acpi_has_method(surface_acpi->handle, SUR_METHOD_DSM)) { 196 | + status = acpi_evaluate_object(surface_acpi->handle, 197 | + SUR_METHOD_DSM, ¶ms, &results); 198 | + 199 | + if (ACPI_FAILURE(status)) { 200 | + pr_err("surface_acpi: ACPI event failure status %s\n", 201 | + acpi_format_exception(status)); 202 | + return AE_ERROR; 203 | + } 204 | + } 205 | + else 206 | + return AE_NOT_FOUND; 207 | + 208 | + return AE_OK; 209 | +} 210 | + 211 | +static void surface_acpi_san_load(void) 212 | +{ 213 | + acpi_status ret; 214 | + 215 | + ret = surface_acpi_event_handler(SUR_SET_DVER); 216 | + if (ACPI_FAILURE(ret)) 217 | + pr_err("surface_acpi: Error setting Driver Version\n"); 218 | + 219 | + ret = surface_acpi_event_handler(SUR_SENSOR_TRIP_POINT); 220 | + if (ACPI_FAILURE(ret)) 221 | + pr_err("surface_acpi: Error setting Sensor Trip Point\n"); 222 | + 223 | + ret = surface_acpi_event_handler(SUR_BAT1_INFO_CHANGE); 224 | + if (ACPI_FAILURE(ret)) 225 | + pr_err("surface_acpi: Error attaching BAT1\n"); 226 | + else 227 | + surface_acpi->bat1_attached = 1; 228 | + 229 | + ret = surface_acpi_event_handler(SUR_BAT2_INFO_CHANGE); 230 | + if (ACPI_FAILURE(ret)) 231 | + pr_err("surface_acpi: Error attaching BAT2\n"); 232 | + else 233 | + surface_acpi->bat2_attached = 1; 234 | + 235 | + ret = surface_acpi_event_handler(SUR_PSU_INFO_CHANGE); 236 | + if (ACPI_FAILURE(ret)) 237 | + pr_err("surface_acpi: Error registering PSU\n"); 238 | + else 239 | + surface_acpi->psu_registered = 1; 240 | +} 241 | + 242 | +static acpi_status surface_acpi_ssh_initialize(void) 243 | +{ 244 | + acpi_status status; 245 | + 246 | + if (acpi_has_method(surface_acpi->ssh_dev->handle, SUR_METHOD_INI)) { 247 | + status = acpi_evaluate_object(surface_acpi->ssh_dev->handle, 248 | + SUR_METHOD_INI, NULL, NULL); 249 | + 250 | + if (ACPI_FAILURE(status)) { 251 | + pr_err("surface_acpi: ACPI event failure status %s\n", 252 | + acpi_format_exception(status)); 253 | + return AE_ERROR; 254 | + } 255 | + } 256 | + else 257 | + return AE_NOT_FOUND; 258 | + 259 | + return AE_OK; 260 | +} 261 | + 262 | +static int bat1_proc_show(struct seq_file *m, void *v) 263 | +{ 264 | + seq_printf(m, "attached: %d\n", surface_acpi->bat1_attached); 265 | + return 0; 266 | +} 267 | + 268 | +static int bat1_proc_open(struct inode *inode, struct file *file) 269 | +{ 270 | + return single_open(file, bat1_proc_show, PDE_DATA(inode)); 271 | +} 272 | + 273 | +static const struct file_operations bat1_proc_fops = { 274 | + .owner = THIS_MODULE, 275 | + .open = bat1_proc_open, 276 | + .read = seq_read, 277 | + .llseek = seq_lseek, 278 | + .release = single_release, 279 | +}; 280 | + 281 | +static int bat2_proc_show(struct seq_file *m, void *v) 282 | +{ 283 | + seq_printf(m, "attached: %d\n", surface_acpi->bat2_attached); 284 | + return 0; 285 | +} 286 | + 287 | +static int bat2_proc_open(struct inode *inode, struct file *file) 288 | +{ 289 | + return single_open(file, bat2_proc_show, PDE_DATA(inode)); 290 | +} 291 | + 292 | +static const struct file_operations bat2_proc_fops = { 293 | + .owner = THIS_MODULE, 294 | + .open = bat2_proc_open, 295 | + .read = seq_read, 296 | + .llseek = seq_lseek, 297 | + .release = single_release, 298 | +}; 299 | + 300 | +static int psu_proc_show(struct seq_file *m, void *v) 301 | +{ 302 | + seq_printf(m, "registered: %d\n", surface_acpi->psu_registered); 303 | + return 0; 304 | +} 305 | + 306 | +static int psu_proc_open(struct inode *inode, struct file *file) 307 | +{ 308 | + return single_open(file, psu_proc_show, PDE_DATA(inode)); 309 | +} 310 | + 311 | +static const struct file_operations psu_proc_fops = { 312 | + .owner = THIS_MODULE, 313 | + .open = psu_proc_open, 314 | + .read = seq_read, 315 | + .llseek = seq_lseek, 316 | + .release = single_release, 317 | +}; 318 | + 319 | +static int version_proc_show(struct seq_file *m, void *v) 320 | +{ 321 | + seq_printf(m, "driver: %s\n", SURFACE_ACPI_VERSION); 322 | + return 0; 323 | +} 324 | + 325 | +static int version_proc_open(struct inode *inode, struct file *file) 326 | +{ 327 | + return single_open(file, version_proc_show, PDE_DATA(inode)); 328 | +} 329 | + 330 | +static const struct file_operations version_proc_fops = { 331 | + .owner = THIS_MODULE, 332 | + .open = version_proc_open, 333 | + .read = seq_read, 334 | + .llseek = seq_lseek, 335 | + .release = single_release, 336 | +}; 337 | + 338 | +static void create_surface_proc_entries(void) 339 | +{ 340 | + proc_create_data("BAT1", 0, surface_proc_dir, 341 | + &bat1_proc_fops, surface_acpi->bat1_attached); 342 | + proc_create_data("BAT2", 0, surface_proc_dir, 343 | + &bat2_proc_fops, surface_acpi->bat2_attached); 344 | + proc_create_data("ADP1", 0, surface_proc_dir, 345 | + &psu_proc_fops, surface_acpi->psu_registered); 346 | + proc_create_data("version", 0, surface_proc_dir, 347 | + &version_proc_fops, SURFACE_ACPI_VERSION); 348 | +} 349 | + 350 | +static void remove_surface_proc_entries(void) 351 | +{ 352 | + remove_proc_entry("BAT1", surface_proc_dir); 353 | + remove_proc_entry("BAT2", surface_proc_dir); 354 | + remove_proc_entry("ADP1", surface_proc_dir); 355 | + remove_proc_entry("version", surface_proc_dir); 356 | +} 357 | + 358 | +static void surface_acpi_notify(struct acpi_device *dev, u32 event) 359 | +{ 360 | + pr_info("surface_acpi: Event received %x\n", event); 361 | +} 362 | + 363 | +static void surface_acpi_register_rqst_handler(void) 364 | +{ 365 | + acpi_status status; 366 | + 367 | + status = acpi_get_handle(NULL, SUR_SAN_RQST, &surface_acpi->rqst_handle); 368 | + if (ACPI_FAILURE(status)) { 369 | + pr_err("surface_acpi: ACPI event failure status %s\n", 370 | + acpi_format_exception(status)); 371 | + } 372 | +} 373 | + 374 | +static void surface_acpi_register_rqsx_handler(void) 375 | +{ 376 | + acpi_status status; 377 | + 378 | + status = acpi_get_handle(NULL, SUR_SAN_RQSX, &surface_acpi->rqsx_handle); 379 | + if (ACPI_FAILURE(status)) { 380 | + pr_err("surface_acpi: ACPI event failure status %s\n", 381 | + acpi_format_exception(status)); 382 | + } 383 | +} 384 | + 385 | +static acpi_status surface_acpi_walk_callback(acpi_handle handle, u32 level, 386 | + void *context, void **return_value) 387 | +{ 388 | + struct acpi_device_info *info; 389 | + 390 | + if (ACPI_SUCCESS(acpi_get_object_info(handle, &info))) { 391 | + pr_warn("method: name: %4.4s, args %X\n", 392 | + (char *)&info->name, info->param_count); 393 | + 394 | + kfree(info); 395 | + } 396 | + 397 | + return AE_OK; 398 | +} 399 | + 400 | +static void surface_acpi_walk_namespace(struct acpi_device *dev) 401 | +{ 402 | + acpi_status status; 403 | + 404 | + status = acpi_walk_namespace(ACPI_TYPE_METHOD, 405 | + dev->handle, 1, surface_acpi_walk_callback, 406 | + NULL, NULL, NULL); 407 | + if (ACPI_FAILURE(status)) 408 | + pr_warn("surface_acpi: Unable to walk acpi resources\n"); 409 | +} 410 | + 411 | +static int surface_acpi_add(struct acpi_device *dev) 412 | +{ 413 | + if (!surface_acpi) 414 | + { 415 | + surface_acpi = kzalloc(sizeof(*surface_acpi), GFP_KERNEL); 416 | + if (!surface_acpi) 417 | + return AE_NO_MEMORY; 418 | + } 419 | + 420 | + if (acpi_has_method(dev->handle, SUR_METHOD_DSM)) 421 | + { 422 | + pr_info("surface_acpi: Attaching device MSHW0091\n"); 423 | + 424 | + surface_acpi->san_dev = dev; 425 | + surface_acpi->handle = dev->handle; 426 | + 427 | + surface_acpi_walk_namespace(surface_acpi->san_dev); 428 | + surface_acpi_check_status(surface_acpi->san_dev); 429 | + 430 | + surface_acpi_register_rqst_handler(); 431 | + surface_acpi_register_rqsx_handler(); 432 | + 433 | + surface_acpi_san_reg(); 434 | + surface_acpi_san_load(); 435 | + 436 | + create_surface_proc_entries(); 437 | + } 438 | + else 439 | + { 440 | + pr_info("surface_acpi: Attaching device MSHW0084\n"); 441 | + 442 | + surface_acpi->ssh_dev = dev; 443 | + 444 | + surface_acpi_walk_namespace(surface_acpi->ssh_dev); 445 | + surface_acpi_check_status(surface_acpi->ssh_dev); 446 | + 447 | + surface_acpi_ssh_initialize(); 448 | + //surface_acpi_ssh_load(); 449 | + } 450 | + 451 | + return AE_OK; 452 | +} 453 | + 454 | +static int surface_acpi_remove(struct acpi_device *dev) 455 | +{ 456 | + remove_surface_proc_entries(); 457 | + 458 | + return AE_OK; 459 | +} 460 | + 461 | +static const struct acpi_device_id surface_device_ids[] = { 462 | + {"MSHW0091", 0}, 463 | + {"MSHW0084", 0}, 464 | + {"", 0}, 465 | +}; 466 | +MODULE_DEVICE_TABLE(acpi, surface_device_ids); 467 | + 468 | +static struct acpi_driver surface_acpi_driver = { 469 | + .name = "surface_acpi", 470 | + .owner = THIS_MODULE, 471 | + .ids = surface_device_ids, 472 | + .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, 473 | + .ops = { 474 | + .add = surface_acpi_add, 475 | + .remove = surface_acpi_remove, 476 | + .notify = surface_acpi_notify, 477 | + }, 478 | +}; 479 | + 480 | +static int __init surface_acpi_init(void) 481 | +{ 482 | + int ret; 483 | + 484 | + pr_info("surface_acpi: Microsoft Surface ACPI Notify version %s\n", 485 | + SURFACE_ACPI_VERSION); 486 | + 487 | + surface_proc_dir = proc_mkdir(PROC_SURFACE, acpi_root_dir); 488 | + if (!surface_proc_dir) { 489 | + pr_err("surface_acpi: Unable to create proc dir " PROC_SURFACE "\n"); 490 | + return -ENODEV; 491 | + } 492 | + 493 | + ret = acpi_bus_register_driver(&surface_acpi_driver); 494 | + if (ret) { 495 | + pr_err("surface_acpi: Failed to register ACPI driver: %d\n", ret); 496 | + remove_proc_entry(PROC_SURFACE, acpi_root_dir); 497 | + } 498 | + 499 | + return ret; 500 | +} 501 | + 502 | +static void __exit surface_acpi_exit(void) 503 | +{ 504 | + acpi_bus_unregister_driver(&surface_acpi_driver); 505 | + if (surface_proc_dir) 506 | + remove_proc_entry(PROC_SURFACE, acpi_root_dir); 507 | +} 508 | + 509 | +module_init(surface_acpi_init); 510 | +module_exit(surface_acpi_exit); 511 | -------------------------------------------------------------------------------- /patches/4.16/surfacedock.patch: -------------------------------------------------------------------------------- 1 | From 3600aaa37a16777a07aa34672f12e30a1ae4d95b Mon Sep 17 00:00:00 2001 2 | From: Jake Day 3 | Date: Fri, 2 Feb 2018 11:21:06 -0500 4 | Subject: support for surface dock 5 | 6 | 7 | diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c 8 | index 05dca3e..59c2fcc 100644 9 | --- a/drivers/net/usb/cdc_ether.c 10 | +++ b/drivers/net/usb/cdc_ether.c 11 | @@ -807,13 +807,6 @@ static const struct usb_device_id products[] = { 12 | .driver_info = 0, 13 | }, 14 | 15 | -/* Microsoft Surface 3 dock (based on Realtek RTL8153) */ 16 | -{ 17 | - USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07c6, USB_CLASS_COMM, 18 | - USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), 19 | - .driver_info = 0, 20 | -}, 21 | - 22 | /* TP-LINK UE300 USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */ 23 | { 24 | USB_DEVICE_AND_INTERFACE_INFO(TPLINK_VENDOR_ID, 0x0601, USB_CLASS_COMM, 25 | diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c 26 | index 0657203..0a52ea0 100644 27 | --- a/drivers/net/usb/r8152.c 28 | +++ b/drivers/net/usb/r8152.c 29 | @@ -5323,7 +5323,6 @@ static const struct usb_device_id rtl8152_table[] = { 30 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)}, 31 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)}, 32 | {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab)}, 33 | - {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6)}, 34 | {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, 35 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)}, 36 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062)}, 37 | -------------------------------------------------------------------------------- /patches/4.16/wifi.patch: -------------------------------------------------------------------------------- 1 | diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl 2 | old mode 100755 3 | new mode 100644 4 | -------------------------------------------------------------------------------- /patches/config.patch: -------------------------------------------------------------------------------- 1 | --- config-stock 2018-04-30 19:19:53.667563564 -0400 2 | +++ config-surface 2018-04-30 19:22:03.105721430 -0400 3 | @@ -52,7 +52,7 @@ 4 | CONFIG_INIT_ENV_ARG_LIMIT=32 5 | CONFIG_CROSS_COMPILE="" 6 | # CONFIG_COMPILE_TEST is not set 7 | -CONFIG_LOCALVERSION="" 8 | +CONFIG_LOCALVERSION="-surface" 9 | # CONFIG_LOCALVERSION_AUTO is not set 10 | CONFIG_HAVE_KERNEL_GZIP=y 11 | CONFIG_HAVE_KERNEL_BZIP2=y 12 | @@ -850,7 +850,7 @@ 13 | CONFIG_PCI_XEN=y 14 | CONFIG_PCI_DOMAINS=y 15 | # CONFIG_PCI_CNB20LE_QUIRK is not set 16 | -CONFIG_PCIEPORTBUS=y 17 | +# CONFIG_PCIEPORTBUS is not set 18 | CONFIG_PCI_BUS_ADDR_T_64BIT=y 19 | CONFIG_PCI_MSI=y 20 | CONFIG_PCI_MSI_IRQ_DOMAIN=y 21 | @@ -1794,7 +1794,7 @@ 22 | # CONFIG_CFG80211_CERTIFICATION_ONUS is not set 23 | CONFIG_CFG80211_REQUIRE_SIGNED_REGDB=y 24 | CONFIG_CFG80211_USE_KERNEL_REGDB_KEYS=y 25 | -CONFIG_CFG80211_DEFAULT_PS=y 26 | +# CONFIG_CFG80211_DEFAULT_PS is not set 27 | CONFIG_CFG80211_DEBUGFS=y 28 | CONFIG_CFG80211_CRDA_SUPPORT=y 29 | CONFIG_CFG80211_WEXT=y 30 | @@ -2223,6 +2223,7 @@ 31 | CONFIG_INTEL_MEI=m 32 | CONFIG_INTEL_MEI_ME=m 33 | CONFIG_INTEL_MEI_TXE=m 34 | +CONFIG_INTEL_IPTS=m 35 | CONFIG_VMWARE_VMCI=m 36 | 37 | # 38 | @@ -5244,7 +5245,7 @@ 39 | # CONFIG_DVB_DDBRIDGE_MSIENABLE is not set 40 | CONFIG_DVB_SMIPCIE=m 41 | CONFIG_DVB_NETUP_UNIDVB=m 42 | -# CONFIG_VIDEO_IPU3_CIO2 is not set 43 | +CONFIG_VIDEO_IPU3_CIO2=m 44 | CONFIG_V4L_PLATFORM_DRIVERS=y 45 | CONFIG_VIDEO_CAFE_CCIC=m 46 | CONFIG_VIDEO_VIA_CAMERA=m 47 | @@ -5389,8 +5390,10 @@ 48 | # Camera sensor devices 49 | # 50 | CONFIG_VIDEO_OV2640=m 51 | +CONFIG_VIDEO_OV5693=m 52 | CONFIG_VIDEO_OV7640=m 53 | CONFIG_VIDEO_OV7670=m 54 | +CONFIG_VIDEO_OV8865=m 55 | CONFIG_VIDEO_MT9M111=m 56 | CONFIG_VIDEO_MT9V011=m 57 | 58 | @@ -5696,7 +5699,7 @@ 59 | # CONFIG_NOUVEAU_DEBUG_MMU is not set 60 | CONFIG_DRM_NOUVEAU_BACKLIGHT=y 61 | CONFIG_DRM_I915=m 62 | -# CONFIG_DRM_I915_ALPHA_SUPPORT is not set 63 | +CONFIG_DRM_I915_ALPHA_SUPPORT=y 64 | CONFIG_DRM_I915_CAPTURE_ERROR=y 65 | CONFIG_DRM_I915_COMPRESS_ERROR=y 66 | CONFIG_DRM_I915_USERPTR=y 67 | @@ -7556,7 +7559,7 @@ 68 | CONFIG_SPEAKUP_SYNTH_TXPRT=m 69 | CONFIG_SPEAKUP_SYNTH_DUMMY=m 70 | CONFIG_STAGING_MEDIA=y 71 | -# CONFIG_INTEL_ATOMISP is not set 72 | +CONFIG_INTEL_ATOMISP=y 73 | # CONFIG_VIDEO_ATOMISP is not set 74 | # CONFIG_VIDEO_ATOMISP_OV5693 is not set 75 | # CONFIG_VIDEO_ATOMISP_OV2722 is not set 76 | @@ -7739,6 +7742,7 @@ 77 | CONFIG_INTEL_BXTWC_PMIC_TMU=m 78 | CONFIG_SURFACE_PRO3_BUTTON=m 79 | CONFIG_SURFACE_3_BUTTON=m 80 | +CONFIG_ACPI_SURFACE=m 81 | CONFIG_INTEL_PUNIT_IPC=m 82 | CONFIG_INTEL_TELEMETRY=m 83 | CONFIG_MLX_PLATFORM=m 84 | @@ -8821,7 +8825,7 @@ 85 | # 86 | # Compile-time checks and compiler options 87 | # 88 | -CONFIG_DEBUG_INFO=y 89 | +# CONFIG_DEBUG_INFO is not set 90 | # CONFIG_ENABLE_WARN_DEPRECATED is not set 91 | # CONFIG_ENABLE_MUST_CHECK is not set 92 | CONFIG_FRAME_WARN=1024 93 | -------------------------------------------------------------------------------- /root/etc/NetworkManager/NetworkManager.conf: -------------------------------------------------------------------------------- 1 | [main] 2 | plugins=ifupdown,keyfile,ofono 3 | #dns=dnsmasq 4 | 5 | [ifupdown] 6 | managed=false 7 | 8 | [connection] 9 | wifi.powersave = 2 10 | 11 | [device] 12 | wifi.scan-rand-mac-address=false 13 | -------------------------------------------------------------------------------- /root/etc/X11/xorg.conf.d/20-intel.conf: -------------------------------------------------------------------------------- 1 | Section "Device" 2 | Identifier "Intel Graphics" 3 | Driver "intel" 4 | Option "TripleBuffer" "true" 5 | Option "TearFree" "true" 6 | Option "DRI" "true" 7 | EndSection 8 | -------------------------------------------------------------------------------- /root/etc/initramfs-tools/modules: -------------------------------------------------------------------------------- 1 | # List of modules that you want to include in your initramfs. 2 | # They will be loaded at boot time in the order below. 3 | # 4 | # Syntax: module_name [args ...] 5 | # 6 | # You must run update-initramfs(8) to effect this change. 7 | # 8 | # Examples: 9 | # 10 | # raid1 11 | # sd_mod 12 | hid 13 | hid_sensor_hub 14 | i2c_hid 15 | hid_generic 16 | usbhid 17 | hid_multitouch 18 | intel_ipts 19 | -------------------------------------------------------------------------------- /root/etc/pulse/daemon.conf: -------------------------------------------------------------------------------- 1 | # This file is part of PulseAudio. 2 | # 3 | # PulseAudio is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU Lesser General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # PulseAudio is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with PulseAudio; if not, see . 15 | 16 | ## Configuration file for the PulseAudio daemon. See pulse-daemon.conf(5) for 17 | ## more information. Default values are commented out. Use either ; or # for 18 | ## commenting. 19 | 20 | ; daemonize = no 21 | ; fail = yes 22 | ; allow-module-loading = yes 23 | ; allow-exit = yes 24 | ; use-pid-file = yes 25 | ; system-instance = no 26 | ; local-server-type = user 27 | ; enable-shm = yes 28 | ; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB 29 | ; lock-memory = no 30 | ; cpu-limit = no 31 | 32 | ; high-priority = yes 33 | ; nice-level = -11 34 | 35 | ; realtime-scheduling = yes 36 | ; realtime-priority = 5 37 | 38 | ; exit-idle-time = 20 39 | ; scache-idle-time = 20 40 | 41 | ; dl-search-path = (depends on architecture) 42 | 43 | ; load-default-script-file = yes 44 | ; default-script-file = /etc/pulse/default.pa 45 | 46 | ; log-target = auto 47 | ; log-level = notice 48 | ; log-meta = no 49 | ; log-time = no 50 | ; log-backtrace = 0 51 | 52 | resample-method = speex-float-3 53 | ; enable-remixing = yes 54 | ; enable-lfe-remixing = yes 55 | ; lfe-crossover-freq = 120 56 | 57 | flat-volumes = no 58 | 59 | ; rlimit-fsize = -1 60 | ; rlimit-data = -1 61 | ; rlimit-stack = -1 62 | ; rlimit-core = -1 63 | ; rlimit-as = -1 64 | ; rlimit-rss = -1 65 | ; rlimit-nproc = -1 66 | ; rlimit-nofile = 256 67 | ; rlimit-memlock = -1 68 | ; rlimit-locks = -1 69 | ; rlimit-sigpending = -1 70 | ; rlimit-msgqueue = -1 71 | ; rlimit-nice = 31 72 | ; rlimit-rtprio = 9 73 | ; rlimit-rttime = 200000 74 | 75 | default-sample-format = s24le 76 | default-sample-rate = 44100 77 | ; alternate-sample-rate = 48000 78 | ; default-sample-channels = 2 79 | ; default-channel-map = front-left,front-right 80 | 81 | ; default-fragments = 4 82 | ; default-fragment-size-msec = 25 83 | 84 | ; enable-deferred-volume = yes 85 | ; deferred-volume-safety-margin-usec = 1 86 | ; deferred-volume-extra-delay-usec = 0 87 | -------------------------------------------------------------------------------- /root/etc/systemd/logind.conf: -------------------------------------------------------------------------------- 1 | # This file is part of systemd. 2 | # 3 | # systemd is free software; you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published by 5 | # the Free Software Foundation; either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # Entries in this file show the compile time defaults. 9 | # You can change settings by editing this file. 10 | # Defaults can be restored by simply deleting this file. 11 | # 12 | # See logind.conf(5) for details. 13 | 14 | [Login] 15 | #NAutoVTs=6 16 | #ReserveVT=6 17 | #KillUserProcesses=no 18 | #KillOnlyUsers= 19 | #KillExcludeUsers=root 20 | #InhibitDelayMaxSec=5 21 | #HandlePowerKey=poweroff 22 | #HandleSuspendKey=suspend 23 | #HandleHibernateKey=hibernate 24 | #HandleLidSwitch=suspend 25 | #HandleLidSwitchDocked=ignore 26 | #PowerKeyIgnoreInhibited=no 27 | #SuspendKeyIgnoreInhibited=no 28 | #HibernateKeyIgnoreInhibited=no 29 | #LidSwitchIgnoreInhibited=yes 30 | #HoldoffTimeoutSec=30s 31 | #IdleAction=ignore 32 | #IdleActionSec=30min 33 | #RuntimeDirectorySize=10% 34 | #RemoveIPC=yes 35 | #UserTasksMax=12288 36 | HandleLidSwitch=hibernate 37 | -------------------------------------------------------------------------------- /root/etc/systemd/sleep.conf: -------------------------------------------------------------------------------- 1 | [Sleep] 2 | SuspendState=freeze 3 | -------------------------------------------------------------------------------- /root/etc/udev/rules.d/98-keyboardscovers.rules: -------------------------------------------------------------------------------- 1 | # Type Cover Re-attach (SP4) 2 | ACTION=="add", SUBSYSTEMS=="usb", ATTR{product}=="Surface Type Cover", RUN+="/sbin/modprobe -r i2c_hid && /sbin/modprobe i2c_hid" 3 | 4 | # Keyboard Dock (SB2) 5 | ACTION=="add", SUBSYSTEMS=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="0922", RUN+="/sbin/modprobe nouveau" 6 | 7 | #Keyboard Undock (SB2) 8 | ACTION=="remove", SUBSYSTEMS=="usb", ENV{ID_MODEL}=="Surface_Keyboard", RUN+="/sbin/modprobe -r nouveau" 9 | -------------------------------------------------------------------------------- /root/etc/udev/rules.d/99-touchscreens.rules: -------------------------------------------------------------------------------- 1 | # NTRG Touchscreen (SP3) 2 | SUBSYSTEMS=="input", ATTRS{name}=="NTRG0001:01 1B96:1B05 Touchscreen", ENV{ID_INPUT_TOUCHSCREEN}="1", SYMLINK+="input/touchscreen" 3 | 4 | # NTRG Pen (SP3) 5 | SUBSYSTEMS=="input", ATTRS{name}=="NTRG0001:01 1B96:1B05 Pen", SYMLINK+="input/pen" 6 | 7 | # IPTS Touchscreen (SP4) 8 | SUBSYSTEMS=="input", ATTRS{name}=="ipts 1B96:006A Touchscreen", ENV{ID_INPUT_TOUCHSCREEN}="1", SYMLINK+="input/touchscreen" 9 | 10 | # IPTS Pen (SP4) 11 | SUBSYSTEMS=="input", ATTRS{name}=="ipts 1B96:006A Pen", SYMLINK+="input/pen" 12 | 13 | # IPTS Touchscreen (SP2017) 14 | SUBSYSTEMS=="input", ATTRS{name}=="ipts 1B96:001F Touchscreen", ENV{ID_INPUT_TOUCHSCREEN}="1", SYMLINK+="input/touchscreen" 15 | 16 | # IPTS Pen (SP2017) 17 | SUBSYSTEMS=="input", ATTRS{name}=="ipts 1B96:001F Pen", SYMLINK+="input/pen" 18 | 19 | # IPTS Touchscreen (SB) 20 | SUBSYSTEMS=="input", ATTRS{name}=="ipts 1B96:005E Touchscreen", ENV{ID_INPUT_TOUCHSCREEN}="1", SYMLINK+="input/touchscreen" 21 | 22 | # IPTS Pen (SB) 23 | SUBSYSTEMS=="input", ATTRS{name}=="ipts 1B96:005E Pen", SYMLINK+="input/pen" 24 | 25 | # IPTS Touchscreen (SB2 15") 26 | SUBSYSTEMS=="input", ATTRS{name}=="ipts 045E:0020 Touchscreen", ENV{ID_INPUT_TOUCHSCREEN}="1", SYMLINK+="input/touchscreen" 27 | 28 | # IPTS Pen (SB2 15") 29 | SUBSYSTEMS=="input", ATTRS{name}=="ipts 045E:0020 Pen", SYMLINK+="input/pen" 30 | 31 | # IPTS Touchscreen (SB2 13") 32 | SUBSYSTEMS=="input", ATTRS{name}=="ipts 045E:0021 Touchscreen", ENV{ID_INPUT_TOUCHSCREEN}="1", SYMLINK+="input/touchscreen" 33 | 34 | # IPTS Pen (SB2 13") 35 | SUBSYSTEMS=="input", ATTRS{name}=="ipts 045E:0021 Pen", SYMLINK+="input/pen" 36 | -------------------------------------------------------------------------------- /root/lib/systemd/system-sleep/hibernate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | case $1/$2 in 3 | pre/*) 4 | systemctl stop NetworkManager.service 5 | #echo 1 > /sys/bus/pci/devices/0000\:02\:00.0/reset 6 | #echo 0 > "/sys/bus/pci/devices/0000:02:00.0/d3cold_allowed" # nvme 7 | #echo 0 > "/sys/bus/pci/devices/0000:03:00.0/d3cold_allowed" # wifi 8 | rmmod intel_ipts 9 | rmmod mei_me 10 | rmmod mei 11 | rmmod mwifiex_pcie 12 | rmmod mwifiex 13 | ;; 14 | post/*) 15 | modprobe intel_ipts 16 | modprobe mei_me 17 | modprobe mei 18 | modprobe mwifiex_pcie 19 | modprobe mwifiex 20 | #echo 1 > /sys/bus/pci/devices/0000\:02\:00.0/reset 21 | echo 1 > /sys/bus/pci/rescan 22 | systemctl start NetworkManager.service 23 | ;; 24 | esac 25 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LX_BASE="" 4 | LX_VERSION="" 5 | 6 | if [ -r /etc/os-release ]; then 7 | . /etc/os-release 8 | if [ $ID = arch ]; then 9 | LX_BASE=$ID 10 | elif [ $ID = ubuntu ]; then 11 | LX_BASE=$ID 12 | LX_VERSION=$VERSION_ID 13 | elif [ ! -z "$UBUNTU_CODENAME" ] ; then 14 | LX_BASE="ubuntu" 15 | LX_VERSION=$VERSION_ID 16 | else 17 | LX_BASE=$ID 18 | LX_VERSION=$VERSION 19 | fi 20 | else 21 | echo "Could not identify your distro. Please open script and run commands manually." 22 | exit 23 | fi 24 | 25 | SUR_MODEL="$(dmidecode | grep "Product Name" -m 1 | xargs | sed -e 's/Product Name: //g')" 26 | SUR_SKU="$(dmidecode | grep "SKU Number" -m 1 | xargs | sed -e 's/SKU Number: //g')" 27 | 28 | echo "\nRunning $LX_BASE version $LX_VERSION on a $SUR_MODEL.\n" 29 | 30 | read -rp "Press enter if this is correct, or CTRL-C to cancel." cont;echo 31 | 32 | echo "\nContinuing setup...\n" 33 | 34 | echo "Coping the config files under root to where they belong...\n" 35 | cp -R root/* / 36 | 37 | echo "Making /lib/systemd/system-sleep/hibernate executable...\n" 38 | chmod a+x /lib/systemd/system-sleep/hibernate 39 | 40 | read -rp "Do you want to replace suspend with hibernate? (type yes or no) " usehibernate;echo 41 | 42 | if [ "$usehibernate" = "yes" ]; then 43 | if [ "$LX_BASE" = "ubuntu" ] && [ 1 -eq "$(echo "${LX_VERSION} >= 17.10" | bc)" ]; then 44 | echo "Using Hibernate instead of Suspend...\n" 45 | ln -sf /lib/systemd/system/hibernate.target /etc/systemd/system/suspend.target && sudo ln -sf /lib/systemd/system/systemd-hibernate.service /etc/systemd/system/systemd-suspend.service 46 | else 47 | echo "Using Hibernate instead of Suspend...\n" 48 | ln -sf /usr/lib/systemd/system/hibernate.target /etc/systemd/system/suspend.target && sudo ln -sf /usr/lib/systemd/system/systemd-hibernate.service /etc/systemd/system/systemd-suspend.service 49 | fi 50 | else 51 | echo "Not touching Suspend\n" 52 | fi 53 | 54 | read -rp "Do you want use the patched libwacom packages? (type yes or no) " uselibwacom;echo 55 | 56 | if [ "$uselibwacom" = "yes" ]; then 57 | echo "Installing patched libwacom packages..." 58 | dpkg -i packages/libwacom/*.deb 59 | apt-mark hold libwacom 60 | else 61 | echo "Not touching libwacom" 62 | fi 63 | 64 | if [ "$SUR_MODEL" = "Surface Pro 3" ]; then 65 | echo "\nInstalling i915 firmware for Surface Pro 3...\n" 66 | mkdir -p /lib/firmware/i915 67 | unzip -o firmware/i915_firmware_bxt.zip -d /lib/firmware/i915/ 68 | fi 69 | 70 | if [ "$SUR_MODEL" = "Surface Pro" ]; then 71 | echo "\nInstalling IPTS firmware for Surface Pro 2017...\n" 72 | mkdir -p /lib/firmware/intel/ipts 73 | unzip -o firmware/ipts_firmware_v102.zip -d /lib/firmware/intel/ipts/ 74 | 75 | echo "\nInstalling i915 firmware for Surface Pro 2017...\n" 76 | mkdir -p /lib/firmware/i915 77 | unzip -o firmware/i915_firmware_kbl.zip -d /lib/firmware/i915/ 78 | fi 79 | 80 | if [ "$SUR_MODEL" = "Surface Pro 4" ]; then 81 | echo "\nInstalling IPTS firmware for Surface Pro 4...\n" 82 | mkdir -p /lib/firmware/intel/ipts 83 | unzip -o firmware/ipts_firmware_v78.zip -d /lib/firmware/intel/ipts/ 84 | 85 | echo "\nInstalling i915 firmware for Surface Pro 4...\n" 86 | mkdir -p /lib/firmware/i915 87 | unzip -o firmware/i915_firmware_skl.zip -d /lib/firmware/i915/ 88 | fi 89 | 90 | if [ "$SUR_MODEL" = "Surface Pro 2017" ]; then 91 | echo "\nInstalling IPTS firmware for Surface Pro 2017...\n" 92 | mkdir -p /lib/firmware/intel/ipts 93 | unzip -o firmware/ipts_firmware_v102.zip -d /lib/firmware/intel/ipts/ 94 | 95 | echo "\nInstalling i915 firmware for Surface Pro 2017...\n" 96 | mkdir -p /lib/firmware/i915 97 | unzip -o firmware/i915_firmware_kbl.zip -d /lib/firmware/i915/ 98 | fi 99 | 100 | if [ "$SUR_MODEL" = "Surface Laptop" ]; then 101 | echo "\nInstalling IPTS firmware for Surface Laptop...\n" 102 | mkdir -p /lib/firmware/intel/ipts 103 | unzip -o firmware/ipts_firmware_v79.zip -d /lib/firmware/intel/ipts/ 104 | 105 | echo "\nInstalling i915 firmware for Surface Laptop...\n" 106 | mkdir -p /lib/firmware/i915 107 | unzip -o firmware/i915_firmware_skl.zip -d /lib/firmware/i915/ 108 | fi 109 | 110 | if [ "$SUR_MODEL" = "Surface Book" ]; then 111 | echo "\nInstalling IPTS firmware for Surface Book...\n" 112 | mkdir -p /lib/firmware/intel/ipts 113 | unzip -o firmware/ipts_firmware_v76.zip -d /lib/firmware/intel/ipts/ 114 | 115 | echo "\nInstalling i915 firmware for Surface Book...\n" 116 | mkdir -p /lib/firmware/i915 117 | unzip -o firmware/i915_firmware_skl.zip -d /lib/firmware/i915/ 118 | fi 119 | 120 | if [ "$SUR_MODEL" = "Surface Book 2" ]; then 121 | echo "\nInstalling IPTS firmware for Surface Book 2...\n" 122 | mkdir -p /lib/firmware/intel/ipts 123 | if [ "$SUR_SKU" = "Surface_Book_1793" ]; then 124 | unzip -o firmware/ipts_firmware_v101.zip -d /lib/firmware/intel/ipts/ 125 | else 126 | unzip -o firmware/ipts_firmware_v137.zip -d /lib/firmware/intel/ipts/ 127 | fi 128 | 129 | echo "\nInstalling i915 firmware for Surface Book 2...\n" 130 | mkdir -p /lib/firmware/i915 131 | unzip -o firmware/i915_firmware_kbl.zip -d /lib/firmware/i915/ 132 | 133 | echo "\nInstalling nvidia firmware for Surface Book 2...\n" 134 | mkdir -p /lib/firmware/nvidia/gp108 135 | unzip -o firmware/nvidia_firmware_gp108.zip -d /lib/firmware/nvidia/gp108/ 136 | fi 137 | 138 | echo "Installing marvell firmware...\n" 139 | mkdir -p /lib/firmware/mrvl/ 140 | unzip -o firmware/mrvl_firmware.zip -d /lib/firmware/mrvl/ 141 | 142 | echo "\nAll done! Please reboot." 143 | --------------------------------------------------------------------------------