From 1aa456e00aab968caedab854b364e354232dbd2b Mon Sep 17 00:00:00 2001 From: Jan Hilberath Date: Thu, 10 Mar 2016 22:59:21 +0900 Subject: [PATCH 1/4] Firmware extraction update for Mac OS X 10.11.3 This patch set updates the firmware download and extraction scripts to work with the OS X El Capitan 10.11.3 Update: https://support.apple.com/downloads/DL1858 https://support.apple.com/downloads/DL1858/en_US/osxupd10.11.3.dmg Fixes: https://github.com/patjak/bcwc_pcie/issues/62 Signed-off-by: Jan Hilberath --- firmware/Makefile | 6 +++--- firmware/extract-firmware.sh | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/firmware/Makefile b/firmware/Makefile index 6ab7287..32e2b88 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -1,12 +1,12 @@ SHELL = /bin/bash -DMG:=osxupd10.11.2.dmg +DMG:=osxupd10.11.3.dmg OSX_DRV:=AppleCameraInterface OSX_DRV_DIR:=System/Library/Extensions/AppleCameraInterface.kext/Contents/MacOS -RANGE:=420107885-421933300 +RANGE:=187085540-191012220 -URL:=https://support.apple.com/downloads/DL1849/en_US/$(DMG) +URL:=https://support.apple.com/downloads/DL1858/en_US/$(DMG) FILE:=$(OSX_DRV_DIR)/$(OSX_DRV) ifneq ("$(wildcard /usr/lib/firmware)", "") diff --git a/firmware/extract-firmware.sh b/firmware/extract-firmware.sh index bc40963..f9264e6 100755 --- a/firmware/extract-firmware.sh +++ b/firmware/extract-firmware.sh @@ -12,6 +12,7 @@ hash_drv_wnd_138='7044344593bfc08ab9b41ab691213bca568c8d924d0e05136b537f66b3c46f hash_drv_osx_140='387097b5133e980196ac51504a60ae1ad8bab736eb0070a55774925ca0194892' hash_drv_osx_143_1='4667e6828f6bfc690a39cf9d561369a525f44394f48d0a98d750931b2f3f278b' hash_drv_osx_143_2='d4650346c940dafdc50e5fcbeeeffe074ec359726773e79c0cfa601cec6b1f08' +hash_drv_osx_143_3='dfac86799c6cf0aceb59bb4e732be8f030e7943eb1146830c7136f62621c9853' hash_fw_wnd_105='dabb8cf8e874451ebc85c51ef524bd83ddfa237c9ba2e191f8532b896594e50e' hash_fw_wnd_138='ed75dc37b1a0e19949e9e046a629cb55deb6eec0f13ba8fd8dd49b5ccd5a800e' @@ -25,6 +26,7 @@ declare -A known_hashes=( ["$hash_drv_osx_140"]='OS X, El Capitan' ["$hash_drv_osx_143_1"]='OS X, El Capitan' ["$hash_drv_osx_143_2"]='OS X, El Capitan 10.11.2' + ["$hash_drv_osx_143_3"]='OS X, El Capitan 10.11.3' ) # Offset in bytes of the firmware inside the driver @@ -34,6 +36,7 @@ declare -A firmw_offsets=( ["$hash_drv_osx_140"]=81920 ["$hash_drv_osx_143_1"]=81920 ["$hash_drv_osx_143_2"]=81920 + ["$hash_drv_osx_143_3"]=81920 ) # Size in bytes of the firmware inside the driver @@ -43,6 +46,7 @@ declare -A firmw_sizes=( ["$hash_drv_osx_140"]=603715 ["$hash_drv_osx_143_1"]=603715 ["$hash_drv_osx_143_2"]=603715 + ["$hash_drv_osx_143_3"]=603715 ) # Compression method used to store the firmware inside the driver @@ -52,6 +56,7 @@ declare -A compression=( ["$hash_drv_osx_140"]='gzip' ["$hash_drv_osx_143_1"]='gzip' ["$hash_drv_osx_143_2"]='gzip' + ["$hash_drv_osx_143_3"]='gzip' ) declare -A firmw_hashes=( @@ -231,7 +236,7 @@ decompress_dmg() 7z e -y "${_main_dir}/$1" "5.hfs" > /dev/null msg2 "Extracting update package..." - tail -c +189001729 "5.hfs" | head -c 1469917156 > OSXUpd.xar + tail -c +189001729 "5.hfs" | head -c 661960661 > OSXUpd.xar rm -f "5.hfs" msg2 "Uncompressing XAR archive..." @@ -240,10 +245,10 @@ decompress_dmg() msg2 "Decoding Payload..." pbzx "OSXUpd"*.pkg"/Payload" > /dev/null - rm "OSXUpdCombo10.11.2.pkg/Payload" + rm "OSXUpd10.11.3.pkg/Payload" msg2 "Decompressing archives..." - cd "OSXUpdCombo10.11.2.pkg" + cd "OSXUpd10.11.3.pkg" find . -name "Payload.part*.xz" -exec xz --decompress --verbose {} \; cat "Payload.part"* | cpio -id &> /dev/null cp "./System/Library/Extensions/AppleCameraInterface.kext/Contents/MacOS/AppleCameraInterface" \ From 76945312a9d2e786bebc9bb5711f5962365c5c20 Mon Sep 17 00:00:00 2001 From: Joe Barnett Date: Thu, 21 Apr 2016 15:57:16 -0700 Subject: [PATCH 2/4] Add dkms.conf and tweak Makefile to work with dkms Specifically, allow building for an installed kernel that is not the running kernel --- Makefile | 3 +++ dkms.conf | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 dkms.conf diff --git a/Makefile b/Makefile index 0e4b2a8..0ddf666 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ facetimehd-objs := fthd_ddr.o fthd_hw.o fthd_drv.o fthd_ringbuf.o fthd_isp.o fthd_v4l2.o fthd_buffer.o fthd_debugfs.o obj-m := facetimehd.o +KVERSION := $(KERNELRELEASE) +ifeq ($(origin KERNELRELEASE), undefined) KVERSION := $(shell uname -r) +endif KDIR := /lib/modules/$(KVERSION)/build PWD := $(shell pwd) diff --git a/dkms.conf b/dkms.conf new file mode 100644 index 0000000..4270d1d --- /dev/null +++ b/dkms.conf @@ -0,0 +1,7 @@ +PACKAGE_NAME=facetimehd +PACKAGE_VERSION=0.1 +CLEAN="make clean" +BUILT_MODULE_NAME[0]="facetimehd" +BUILT_MODULE_LOCATION[0]="." +DEST_MODULE_LOCATION[0]="/extra" +AUTOINSTALL="yes" From 93aeb34c43761a0872f7ac5de085665f74e03165 Mon Sep 17 00:00:00 2001 From: Alex Damian Date: Fri, 22 Apr 2016 20:48:02 +0100 Subject: [PATCH 3/4] Fix compilation for newer kernels New kernels above 4.4 have a different interface for vb2_ops.queue_setup, so we respect that. Tested on 4.6.0, the camera works ok. --- fthd_v4l2.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fthd_v4l2.c b/fthd_v4l2.c index 1d62a9e..ea3fe16 100644 --- a/fthd_v4l2.c +++ b/fthd_v4l2.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,9 @@ #define FTHD_NUM_FORMATS 2 /* NV16 is disabled for now */ static int fthd_buffer_queue_setup(struct vb2_queue *vq, +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,4,0) const struct v4l2_format *fmt, +#endif unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) { @@ -55,10 +58,6 @@ static int fthd_buffer_queue_setup(struct vb2_queue *vq, return -EINVAL; /* FIXME: We assume single plane format here but not below */ - if (fmt && fmt->fmt.pix.sizeimage < - (cur_fmt->bytesperline * cur_fmt->height)) - return -EINVAL; - for (i = 0; i < *nplanes; i++) { sizes[i] = cur_fmt->sizeimage; alloc_ctxs[i] = dev_priv->alloc_ctx; From e7ee61b01baff4e8ccca8fa91a9247f2cfe53b71 Mon Sep 17 00:00:00 2001 From: nick Date: Tue, 26 Apr 2016 10:08:40 +0100 Subject: [PATCH 4/4] compile in 4.4.0 kernel --- fthd_v4l2.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/fthd_v4l2.c b/fthd_v4l2.c index ea3fe16..e3793e2 100644 --- a/fthd_v4l2.c +++ b/fthd_v4l2.c @@ -41,17 +41,27 @@ #define FTHD_MIN_HEIGHT 240 #define FTHD_NUM_FORMATS 2 /* NV16 is disabled for now */ -static int fthd_buffer_queue_setup(struct vb2_queue *vq, -#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,4,0) - const struct v4l2_format *fmt, +static int fthd_buffer_queue_setup( + struct vb2_queue *vq, +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,4,0) + const struct v4l2_format *fmt, #endif - unsigned int *nbuffers, unsigned int *nplanes, - unsigned int sizes[], void *alloc_ctxs[]) -{ +#if !(LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)) + const void *parg, +#endif + unsigned int *nbuffers, + unsigned int *nplanes, + unsigned int sizes[], + void *alloc_ctxs[] +) { + struct fthd_private *dev_priv = vb2_get_drv_priv(vq); struct v4l2_pix_format *cur_fmt = &dev_priv->fmt.fmt; int i, total_size = 0; + if (*nplanes) + return sizes[0] < (cur_fmt->bytesperline * cur_fmt->height) ? -EINVAL : 0; + *nplanes = dev_priv->fmt.planes; if (!*nplanes)