Hi everyone, hoping someone can help me out here. I’m running an Arducam Pivariety 21MP IMX230 Colour Camera Module on a Raspberry Pi 4B with the latest Raspberry Pi OS (Bullseye, Debian 11, the Jan 28 2022 release or newer). The kernel driver installed without any problems, the camera works, and autofocus is working fine.
What I actually need is manual focus, so I can set the focus where I want it. But I can’t seem to set it manually with the delivered scripts or controls.
I cloned the driver/focuser code like this:
git clone https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver.git
cd Arducam-Pivariety-V4L2-Driver/focus
python3 FocuserExample.py
And the script just falls over with a traceback. It really looks like it’s not up to date anymore.
I also tried setting focus directly with v4l2-ctl:
v4l2-ctl -c focus_absolute=300
and got:
unknown control 'focus_absolute'
Then I listed the controls with v4l2-ctl -l and ‘focus_absolute’ just isn’t there at all. So I’m kind of stuck. Am I missing something, or are the v4l2 driver / downloaded scripts out of date? Thanks.
Hi, thanks for the detailed write-up. Let’s dig into this.
A couple of things would help us narrow it down:
Can you paste the actual traceback text from FocuserExample.py (or a screenshot)?
Please run these and share the output:
v4l2-ctl --list-devices
v4l2-ctl -l
We want to see which v4l2 subdevices exist on your system and which controls are exposed on each of them. The ‘focus_absolute’ control is usually exposed on a subdevice rather than the main video node, so that listing is important.
Also, just to confirm — you didn’t change anything in the driver install after autofocus started working, correct?
Sure, here’s the traceback from running it without any arguments:
Traceback (most recent call last):
File "FocuserExample.py", line 42, in <module>
f.focus_absolute = 300
File "FocuserExample.py", line 27, in focus_absolute
fcntl.ioctl(self.fd, self.V4L2_CID_FOCUS_ABSOLUTE, ct.pack(value))
OSError: [Errno 25] Inappropriate ioctl for device
And here’s the output of the two commands you asked for:
$ v4l2-ctl --list-devices
bcm2835-codec-decode (platform:bcm2835-codec):
/dev/video10
/dev/video11
/dev/video12
unicam (platform:fe801000.csi):
/dev/video0
/dev/v4l-subdev0
/dev/v4l-subdev1
$ v4l2-ctl -l
User Controls
... (only the standard unicam controls listed)
No ‘focus_absolute’ anywhere in the list. Nothing was changed after autofocus started working — I’ve only been trying to get manual focus going since then.
Thanks, that’s useful. The list-devices output confirms what I suspected — you have /dev/v4l-subdev1 present, which is where the focus control on the Pivariety should live.
The v4l2-ctl commands you tried default to the main video node, which is why you get unknown control 'focus_absolute'. The control is on the subdevice, not the video node.
Give this a try — the focuser example supports pointing at a specific subdevice with the -d flag:
python3 FocuserExample.py -d /dev/v4l-subdev1
That should make the script talk to the right subdevice where the focus control is actually exposed. Let me know how it goes.
So the proposed fix doesn’t work for me and produces the same traceback. It’s starting to feel like the script or the driver controls really are out of date.
Thanks for the screenshot and the traceback — [Errno 25] on the ioctl is an important detail. Before we conclude anything about the script being out of date, can you tell me a couple of things:
What does v4l2-ctl -l -d /dev/v4l-subdev1 show? (note the -d here, to list the controls on the subdevice specifically)
Have you been through any additional troubleshooting already, or tried the setup on a different OS version?
Just trying to map out exactly what you’ve already ruled out so we don’t go in circles.
It still doesn’t show ‘focus_absolute’ — that control just isn’t in the list.
As for what I’ve already tried: I’ve gone through basically all the troubleshooting threads on the Arducam forum, I tried a different version of Raspbian OS, and I followed both of these docs end to end:
The kernel driver installs fine and autofocus works. It’s only manual focus that I can’t get working — the ‘focus_absolute’ control is never exposed, and the example script errors out either way.
Thanks, that’s a good summary of what you’ve tried. So to lay out where we are:
Driver installs fine on the Pi 4B / Bullseye setup, camera works, autofocus works.
FocuserExample.py throws a traceback both with and without -d /dev/v4l-subdev1.
v4l2-ctl -c focus_absolute=300 fails with unknown control 'focus_absolute'.
v4l2-ctl -l (and the subdevice-specific list) never shows focus_absolute.
That points at the focus control not being exposed by the driver on your system, rather than just a script invocation issue — the -d /dev/v4l-subdev1 step was the right direction, but it’s not resolving it here.
A couple of last things to nail down: what kernel version are you on (uname -r), and which driver commit did you build from (git log -1 --oneline in the cloned repo)? That’ll tell us whether your driver build matches the controls the script expects. There’s no confirmed fix at this point — right now the working path is autofocus, and manual focus via focus_absolute isn’t available on your setup until we can get that control exposed.