home |  electronics |  toolbox |  science club |  tuxtalk |  photos |  e-cards |  online-shop



November 2024

Linux: disable Integrated IR Camera

Some laptops have integrated infrared cameras besides the normal video camera. The lenovo Anniversary Edition 25 laptop has such a camera and the way it is connected to the USB bus makes the IR camera show up as the first video device (/dev/video0). Many applications simply use the first video device by default even if they allow you to choose. The annoying consequence of this is that you have to always manually change it. The integrated infrared camera is of no use and the best solution is to simply disable it. This can be done by writing a zero to a special sys-fs device file called bConfigurationValue. The change to bConfigurationValue takes immediate effect and it's dynamic. You can re-enable the camera by writing 1 to the bConfigurationValue file under /sys/bus/usb/devices.

The device position on the USB bus is fixed ( e.g /sys/bus/usb/devices/1-5 ) for a given laptop type. You can hardcode this in a script.

Here is a shell script that can disable the camera on the fly:

#!/bin/bash
# Disable the Integrated IR Camera on a lenovo Anniversary Edition 25 laptop
# This script relies on the fact that the normal camera and the IR-camera are
# two different USB devices with own connections to the USB bus. There are also
# laptops which combine all cameras into one single USB device. For those this
# script will not work.
#
# written by guido socher
#
# get info about the camera (usb-0000:00:14.0-5 means you 
#  use 1-5 further down in the script:
#root@t25:/usr/local/bin# v4l2-ctl --list-devices
#Integrated IR Camera: Integrate (usb-0000:00:14.0-5):
#	/dev/video0
#
#Integrated Camera: Integrated C (usb-0000:00:14.0-8):
#	/dev/video1
#
# before running this script:
#root@t25:/usr/local/bin# ls -al /dev/video*
#crw-rw----+ 1 root video 81, 0 Oct 13 10:36 /dev/video0
#crw-rw----+ 1 root video 81, 1 Oct 13 10:36 /dev/video1
#after running this script:
#root@t25:/usr/local/bin# ls -al /dev/video*
#crw-rw----+ 1 root video 81, 1 Oct 13 10:36 /dev/video1
#
# you can test your video camera e.g with the command cheese
#
#You can get the device numbers from lshw command:
#from lshw:
#              *-usb:1
#                   description: Video
#                   product: Integrated IR Camera
#                   vendor: SunplusIT Inc
#                   physical id: 5
#         -->       bus info: usb@1:5
#                   version: 0.20
#                   capabilities: usb-2.00
#                   configuration: driver=uvcvideo maxpower=500mA speed=480Mbit/s
#
dev="/sys/bus/usb/devices/1-5"
if [ ! -r "$dev/product" ]; then
	echo "ERROR: can not read $dev/product"
	exit 1
fi
echo -n "product to disable is: "
cat $dev/product
sleep 1
id=`id -u`
if [ ! -w "$dev/bConfigurationValue" ];then
	echo "ERROR: can not write $dev/bConfigurationValue, you must run this as root"
	exit 1
fi
echo 0 > $dev/bConfigurationValue
#
# end of disable-ir-camera.sh



Back to NPA blog index

© 2004-2024 Guido Socher