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" 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" \ diff --git a/fthd_v4l2.c b/fthd_v4l2.c index 1d62a9e..e3793e2 100644 --- a/fthd_v4l2.c +++ b/fthd_v4l2.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -40,25 +41,33 @@ #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, - const struct v4l2_format *fmt, - unsigned int *nbuffers, unsigned int *nplanes, - unsigned int sizes[], void *alloc_ctxs[]) -{ +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 +#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) 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;