Every time a new V4L device is initialized by the linux kernel, it start with
the controls default settings hardcoded in the driver.

There is not central mechanism to make changes to controls values more
"persistent": applications have to save and restore the settings themselves.

This is particularly annoying for settings like "Power Line Frequency"
provided by some cameras, this is a setting which you would very rarely need
to change once you determined the right value to use for your country to fix
light flickering.

So here are some convenience scripts to save and restore settings in an
application-independent way.

Install the scripts with:

  $ sudo make install


Change the settings with your preferred v4l2 program like qv4l2 or v4l2-ctl,
e.g.:

  $ v4l2-ctl -d /dev/video0 --set-ctrl gain_automatic=0


Save the settings:


  $ sudo /etc/v4l2-persistent-settings/v4l2-settings-save.sh /dev/video0


The settings will be restored the next time the device is connected.

Inspired by:
https://superuser.com/questions/471597/linux-v4l-webcam-make-settings-stick


NOTE:

The scripts use v4l2-ctl from the v4l-utils[1] instead of v4l2ctrl from
v4l2ucp[2] (which can save to a file mor easily) because the former is
actively maintained and also because the latter may bring in Qt4 as
a dependency which can be undesirable on minimal systems.

[1] https://git.linuxtv.org/v4l-utils.git
[2] https://sourceforge.net/projects/v4l2ucp/