Skip to content

Instantly share code, notes, and snippets.

@bafu
Last active November 22, 2019 03:56
Show Gist options
  • Save bafu/3904f4aa3528c0572ec2bb65659c63c1 to your computer and use it in GitHub Desktop.
Save bafu/3904f4aa3528c0572ec2bb65659c63c1 to your computer and use it in GitHub Desktop.
Enable MacBook Air 6.2 camera on Ubuntu
#!/bin/bash
# https://help.ubuntu.com/community/MacBookAir6-2/Trusty
# https://github.com/patjak/bcwc_pcie/wiki/Get-Started
ENABLER='/tmp/bcwc_pcie'
ACTION="$1"
show_help() {
echo "Please provide action parameter: install, load, unload, test, help"
}
download_bcwc_pcie() {
git clone https://github.com/patjak/bcwc_pcie.git $ENABLER
}
extract_firmware() {
cd $ENABLER/firmware
make
sudo make install
cd -
}
build_and_install_dkms() {
cd $ENABLER
make
sudo checkinstall
sudo depmod
cd -
}
load_kernel_module() {
echo -n "Remove bdc_pci module..."
sudo rmmod bdc_pci
echo "done."
echo -n "Insert facetimehd module..."
sudo modprobe facetimehd
echo "done."
}
unload_kernel_module() {
echo -n "Remove facetimehd module..."
sudo rmmod facetimehd
echo "done."
echo -n "Insert bdc_pci module..."
sudo modprobe bdc_pci
echo "done."
}
test_camera() {
echo "Camera test. A window streaming camera content should be popped up."
mplayer tv://
}
if [ "$ACTION" = "" ]; then
echo "No action."
show_help
elif [ "$ACTION" = "install" ]; then
download_bcwc_pcie
extract_firmware
build_and_install_dkms
elif [ "$ACTION" = "load" ]; then
load_kernel_module
elif [ "$ACTION" = "unload" ]; then
unload_kernel_module
elif [ "$ACTION" = "test" ]; then
test_camera
elif [ "$ACTION" = "help" ]; then
show_help
else
echo "Unknown action $ACTION"
show_help
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment