The default values for string options are set using static (i.e.
non-malloced) strings. Later, if new values are loaded from the config
file, those SANE_Strings will then point to dynamically allocated memory
which is eventually leaked.
Change the initial values for the string options to NULL, and initialize
them to the proper values within sane_init() using strdup(). This way,
whenever the value for the string is changed, we can safely free() the
previous value.
This eliminates the other main source of memory leaks in the test backend.
This patch also updates sane_init for the test backend to properly cleanup
memory if it fails.
Inside Test_Device, track whether we've already called init_options().
If we have, don't call it again when calling sane_open() again.
Add a function cleanup_options() which frees the memory used for these
options, and call it in sane_exit() if we previously called
init_options().
Change Test_Devices to be initialized with calloc instead of malloc,
so that we can assume that uninitialized fields are NULL, and can safely
call free() on them unconditionally.
This eliminates some larger memory leaks within the test backend.
In the case where we are unable to get a path for loading libs, and
instead just use LIBDIR, we set 'src = strdup(LIBDIR)'. However, we
never update orig_src to point to src before tokenizing the path with
strsep(), so the memory is never freed.
Update load to always set orig_src to src so that we don't leak memory.
Some scanners (notably the Mustek 1248UB) doesn't like receiving a
STOP scan command when it is not scanning. Flag prevents it my making
sure that START/STOP commands are only ever paired up.
We have seen this from buggy backends that present NULL for constraint
string_lists. This is probably illegal behaviour from backends but we
don't want to crash.
Calling this function upsets some scanners in this family.
This temporary sticking plaster permits the Mustek 1248UB scanner to
scan after cancelling. We need to look into this much more when a
scanner becomes available for investigation.
Enable autofocus support on my Epson 12000XL. The middle of the scan
area will be used as the focus point. An arbitrary X,Y is possible but
not implemented yet
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Allow the whole range of manual focus settings as an expert option. This
is also now independent of a TPU being installed or not. The old default
values are applied if the user changes the source type (either FLATBED
or TPU). Adding a focus group here because autofocus options will come
with later patches.
Signed-off-by: Wolfram Sang <wsa@kernel.org>
coolscan2 has focus entries already reused in coolscan3. Because I want
to add the same options to epson2, it makes sense to make them available
globally. Add i18n while here.
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Even with USB based scanners, we need to send the esci command to set
the focus. There is no byte in the extended scanning parameters for it.
So, move the code to a place where it is called for all cases.
Signed-off-by: Wolfram Sang <wsa@kernel.org>
- restructure fine calibration code
- initial support for uploading fine calibration payloads
- improve DR-C225 support
Most canon scanners require that the driver apply fine (per-cell)
calibration information. But a few require that the info be loaded
into the scanner. Here, we add initial support for that, though the
needed values are hardcoded instead of calculated.