Commit Graph

8122 Commits

Author SHA1 Message Date
Marcus Meissner
2956dc945b handle Nikon D3x capture function detection better
https://github.com/gphoto/gphoto2/issues/635#issuecomment-2373279482
2024-09-29 13:26:25 +02:00
Marcus Meissner
4f1b3d46f8 add a null check to avoid NULL ptr deref (AFL) 2024-09-29 11:22:28 +02:00
axxel
67e47ef4d6 ptp2: update a few OLC related comments 2024-09-29 11:09:31 +02:00
axxel
4952b37efb ptp2: make ptp_debug_data output easier to parse at a glance
* replace "00 " with " - "
 * don't repeat lines with all zeros

e.g.:
```
event 146: EOS prop d212 value changed, size 408 ((null))
    0x000: 0a  -  -  - 01  -  -  -  -  -  -  -  -  -  -  -
    0x010:  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
    [...]:
    0x190:  -  -  -  -  -  -  -  -
```
2024-09-29 11:09:31 +02:00
axxel
5b70cdf6dc remove lots of "discarding event type" lines from the debug log
200 lines of "discarding event type %d" on capture_image in the log is not
helpful. Replace with one line "discarding %d EOS events".
2024-09-29 11:09:31 +02:00
Marcus Meissner
57dbf7ed53 fixed NULL ptr deref in sigma fp config handling (afl) 2024-09-27 18:52:53 +02:00
Marcus Meissner
72364f304c added EOS 5rm2 2024-09-27 13:50:08 +02:00
axxel
042c4f3809 new EOS ImageFormat get/set implementation
The current `imageformat` with it's table lookup for every RAW+JPEG
combination became cumbersome to maintain and outdated. This leads to
e.g. lost of unsupported JPEG variants for e.g. the 5Ds, R5m2, 1DX.

The used naming also became inconsistent with the addition of the 1DXm2
labels in 1402f88d1a

This patch adds an (incompatible) new imageformat2 widget as a temporary
test to then hopefully replace the existing imageformat. I expect this new
implementation to fix all "Unknown value" occurrences of all currently
available EOS cameras.

I chose to do away with the verbose and arbitrary labels like
"Smaller Fine JPEG" and instead tried to mimic the strings that are
actually used by the cameras, like 'S2', etc. I added a 'c' for the
higher compression versions, along the lines of 'cRAW'. The 'c' could
also stand for 'coarse' to describe the blocky curve that is used by the
Canons to distinguish between lower and higher Jpeg quality.

Here is some sample output from the 5Ds:
Choice: 5 cM2
Choice: 6 S1
Choice: 7 cS1
Choice: 8 S2
Choice: 9 S3
Choice: 10 RAW + L
Choice: 11 RAW + cL
Choice: 12 RAW + M1
Choice: 13 RAW + cM1
2024-09-27 10:18:39 +02:00
axxel
1874ee28cf ptp2: fix missing JPEG info for RAW+JPEG formats of 1DX and R5m2
This brings my original ptp_unpack_EOS_ImageFormat() documentation
up-to-date with new M1/M2 and new 0/1 compression info added with 5Ds,
1DXm2 and R5m2.

It also fixes the problem that led to a double entry of e.g. `RAW` in the
imageformat config output visible in #1028 and also in the 1DX sample here:
5b7f7c168d/camlibs/ptp2/cameras/canon-eos-1dx.txt (L255-L269)
2024-09-27 10:18:39 +02:00
axxel
02b75096d9 ptp2: use hex format in debug output for GenericTable enum lookups
We use hex format for the same information in other parts of the log file.
2024-09-27 10:18:39 +02:00
axxel
5b7f7c168d ptp2: fix a regression in ptp_get_property_description
Generally looking for MTP prop names when searching for a Canon prop was
the wrong approach. This leads to "Aperture" beeing called "Secure Time".

Instead just copy the 3 MTP prop names actually required into the
Canon prop name list.
2024-09-26 10:06:10 +02:00
axxel
da7dead692 remove code duplication in ptp_check_event 2024-09-25 11:47:21 +02:00
axxel
8d4975f52c ptp2: make ptp_add_event(s) cleaner and more performant 2024-09-25 11:47:21 +02:00
axxel
d75762e0d8 ptp2: remove unused function ptp_have_event 2024-09-25 11:47:21 +02:00
axxel
f4e853a6fc ptp2: building with LIBXML2, olympus-wrap.c does need #include "ptp-pack.c" 2024-09-25 11:47:21 +02:00
axxel
5f2f383926 ptp2: remove unused PTPDeviceProperty::value member
The current value of the device property is only stored in the
desc.CurrentValue field.
2024-09-25 11:47:21 +02:00
axxel
8a2c257ce4 ptp2: remove PTPCanon_Propery::proptype member
The proptype (a.k.a. device property code) is already stored in
dpd.DevicePropertyCode member. This patch introduces the
ptp_find_eos_devicepropdesc() function for the commonly repeated for-loop
looking for the DevicePropDesc* in the cache.

This now allows to completely replace PTPCanon_Property with
PTPDevicePropDesc and then drop the canon_props array altogether and use
the generic one.
2024-09-25 11:47:21 +02:00
axxel
d0c91fd99e ptp2: rename ptp_unpack_... functions for Canon events
Make the names more consistent and expressive.
2024-09-25 11:47:21 +02:00
axxel
f91442f5cc ptp2: remove unused PTPCanon_Property members size and data
PTPDeviceProperty data of EOS cameras is not polled but rather pro-actively
sent by the camera via a PropValueChanged event. The unpack function used
to interpret the data and unpack it into the PTPDevicePropDesc struct
but also copied the raw event data block into an extra member (data, size)
of the special special PTPCanon_Property struct. This data is then never
looked at again.

This patch removes those data members and is a first step to completely
eliminate the special PTPCanon_Property struct.
2024-09-25 11:47:21 +02:00
axxel
4b3cd2452d ptp2: fix -Wsign-compare compiler warning in chdk.c 2024-09-25 11:47:21 +02:00
axxel
2c36303fdf ptp_pack.c: harmonize PTP_EC_CANON_EOS_PropValueChanged indentation
Layout this one case block just like the other ones. This is basically a
whitespace only change.
2024-09-25 11:47:21 +02:00
axxel
19a03c3c9e remove 7 unnecessary #include "ptp-pack.c" statements
Move the byte-order-swapping helpers from ptp-pack.c to ptp.h as well as 2
ptp_free_deviceinfo variants and remove all but one ptp-pack.c inclusions.

This speeds up compile time and removes lots of compiler warning
repetitions if one shows up in ptp-pack.c.
2024-09-25 11:47:21 +02:00
axxel
910f0d9f75 introduce helper macros for automatic offset increment after dtoh
The idea is to remove 'manual' offset adjustments:
```
unsigned offset = 0;
unsigned val = dtoh32o(data, offset);
// offset is now 4
```

Also contains some code beautification near the use of dtoh style macros.
2024-09-24 16:44:26 +02:00
axxel
05920762e4 improve API of ptp_unpack_string and ptp_unpack_uint[16|32]_array
Those functions get passed an offset value into the data buffer. This
offset value needed to be updated on the calling side after the call with
internal knowledge of what exactly the unpack function itself was doing.
Now the offset becomes an in/out parameter and in updated internally. This
substantially reduces the complexity of the calling code.

Furthermore, the return value is now an error indicator and the array
length gets set via a pointer.

This further fixes a few places where there was a bug in the bounds
checking or no bounds checking at all.
2024-09-24 16:44:26 +02:00
axxel
db4320a092 ptp2: trivial code cosmetic, mostly whitespace in switch() blocks 2024-09-23 17:29:35 +02:00
axxel
2b24e3716f fix olcsizes table entry for 5Ds
See discussion in #1020 for details.
2024-09-23 17:29:35 +02:00
axxel
e9a88c7974 summary: fix embarrassing bug in recent commit (broke %x output) 2024-09-23 17:29:35 +02:00
axxel
c5a5644035 summary: fix accidental ')' misplacement in recent commit 2024-09-23 14:23:40 +02:00
axxel
baa817cca9 summary: tune table layout of properties some more
e.g.:

Device Property Summary:
Model ID                  (d049 ro u32): 2147484546
Friendly Device Name      (d402 ro str): 'Canon EOS 5DS'
Perceived Device Type     (d407 ro u32): 1
Session Initiator Info    (d406 rw str): 'Unknown Initiator'
2024-09-23 14:23:40 +02:00
axxel
62f50604ab Canon cameras may also use MTP vendor extension codes (0xd4..)
E.g. the 5Ds:

Friendly Device Name      (d402): (ro str) 'Canon EOS 5DS'
Perceived Device Type     (d407): (ro u32) 1
Session Initiator Info    (d406): (rw str) 'Unknown Initiator'
2024-09-23 14:23:40 +02:00
axxel
f5e51fd63b summary: add info about Canon vendor extension properties
They only show up if the camera is in capturemode=on, see #1024.
2024-09-23 14:23:40 +02:00
axxel
95dc8815fd improve logging output for EOS_AutoPowerOff and EOS_ShutterReleaseCounter 2024-09-23 14:23:40 +02:00
axxel
6177718525 ptp_unpack_CANON_changes: fix bug in bounds checking code 2024-09-23 14:23:40 +02:00
axxel
4d6f9b664d ptp_generic_getdevicepropdesc: remove code duplication 2024-09-23 14:23:40 +02:00
axxel
08dca93f53 summary: layout property summary in a more table based look
Also represent type as human readable string instead of hex code and
drop the 0x prefix in the hex-representation of the property id. Example:

```
Device Property Summary:
[...]
SerialNumber      (d1af): (ro str) '153022001713'
Artist            (d1d0): (rw str) ''
Copyright         (d1d1): (rw str) ''
AEB               (d1d9): (rw u16) Enumeration [0,3,5,8,11,13,16,19, ...
LvAfSystem        (d1ba): (ro u32) Enumeration [10,1,5,6,11,12,13,14]...
MovieParam5       (d20d): (rw ???) Enumeration [] value: Undefined
```
2024-09-23 14:23:40 +02:00
axxel
b3aa6fc607 ptp2: shorten 3 overly long EOS property names (remove "Setting" substr) 2024-09-23 14:23:40 +02:00
Hans Ulrich Niedermann
155c4454ee Enable silent build rules by default
Enable silent build rules by default.

You can still use verbose build rules by using any of the following
methods:

  * run `configure` with the `--disable-silent-rules` argument
  * run `make` with the `V=1` argument

This hides the compiler command line which makes debugging users'
problems more difficult. To compensate for that, this prints the
build flags separately, but a lot less frequently:

For each part of the build (`libgphoto2_port.la`, iolibs,
`libgphoto2.la`, camlibs), if something of that part has been
rebuilt, prints the build flags (_CPPFLAGS, _CFLAGS, _LIBADD,
_LDFLAGS) once.

Always prints the environment variables CPPFLAGS CFLAGS LDADD
LIBADD LDFLAGS once, whether they are the defaults the configure
script sets or given on the `make` command line.

Not all make recipes have been converted to be completely silent,
but the majority (especially the Automake standard recipes) are
now silent.
2024-09-19 21:25:13 +02:00
axxel
1759368ea2 reduce textual 'noise' in the EOS event debug log entries
This makes the event entries in the log from an EOS more readable by
removing uninteresting information and layout out interesting information
in a more aligned/table based manner for quick visual parsing of the data.

Example excerpt:
```
event 104: EOS prop d1c9 value changed, size  4 (EOS_ContinousAFMode)
           value of d1c9 is 0x00000000 (u32)
event 105: EOS prop d19f value changed, size  4 (EOS_GPSDeviceActive)
           EOS prop d19f is unknown
           value of d19f is 0x00000001 (u32)
[...]
event 111: EOS prop d177 value changed, size 24 (EOS_SmartphoneShowImageConfig)
    0x000: 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x010: 00 00 00 00 00 00 00 00
event 112: EOS prop d105 options changed, type 1, count  0 (EOS_AutoExposureMode)
event 113: EOS prop d108 options changed, type 3, count  3 (EOS_FocusMode)
           option[ 0] of d108 is 0x00
           option[ 1] of d108 is 0x02
           option[ 2] of d108 is 0x01
```
2024-09-19 14:21:14 +02:00
axxel
6df6fbb1d8 ptp2: condense EOS OLCInfo related debug output
A full logging excerpt now looks like this
```
event 237: EOS event OLCInfoChanged (size 81, version 0x0b, mask 0x1fff)
    0x00: 49 00 00 00 ff 1f 00 00 01 00 01 01 a0 10 00 a0
    0x10: 01 01 50 20 2c 01 01 00 00 04 01 01 71 00 00 00
    0x20: 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00
    0x30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x40: 00 00 00 00 00 00 00 00 00
event 237: olcmask 0x0001, 2 bytes: 01 00
event 238: olcmask 0x0002, 6 bytes: 01 01 a0 10 00 a0
event 239: olcmask 0x0004, 5 bytes: 01 01 50 20 2c
event 240: olcmask 0x0008, 4 bytes: 01 01 00 00
event 241: olcmask 0x0010, 4 bytes: 04 01 01 71
event 242: olcmask 0x0020, 6 bytes: 00 00 00 00 00 00
event 243: olcmask 0x0040, 8 bytes: 01 00 00 00 00 00 00 00
event 244: olcmask 0x0080, 4 bytes: 00 00 00 00
event 245: olcmask 0x0100, 6 bytes: 00 00 00 00 00 00
event 246: olcmask 0x0200, 5 bytes: 00 00 00 00 00
event 247: olcmask 0x0400, 5 bytes: 00 00 00 00 00
event 248: olcmask 0x0800, 9 bytes: 00 00 00 00 00 00 00 00 00
event 249: mask 0x1000 entry truncated (1 bytes), olcsizes table (8 bytes) wrong?
event 249: olcmask 0x1000, 1 bytes: 00
```

This allows for easy grepping of the log file. See comments for gained
insight into olcmask 0x0010 entries. The user visible strings info strings
of the UNKNOWN events have changed as well, e.g.:
```
UNKNOWN OLCInfo event 0x0010, 4 bytes: 04 02 06 2f
```
It also introduces a convenient ptp_bytes2str() function to render some
bytes into a string for immediate printing/copying.
2024-09-17 13:06:14 +02:00
axxel
a26126ade8 new camera_keep_device_on() function (less noise in debug log)
Instead of calling ptp_canon_eos_keepdeviceon() in e.g.
camera_wait_for_event() directly for every invocation (often twice),
which can lead to dozens of those calls per second, this patch limits the
number to 1 every 10 seconds.

The camera_prepare_capture + ptp_check_eos_events + keepdeviceon block in
camera_lookup_by_property has been removed completely as this function is
only called from within camera_wait_for_event() where those checks have
been made just prior to the call to camera_lookup_by_property.

Furthermore: ptp_check_eos_events() will now only be called inside
camera_wait_for_event if the queue of already transmitted events is
drained first.
2024-09-16 09:55:14 +02:00
axxel
1a02f0f2b5 fix white-space and indentation inconsistencies (third round)
This is basically an amendment to #1015, I just realized that I overlooked
some places due to a too restrictive regex.

(I hope this subject is not getting old already...)

This is a whitespace only change (if you include newlines as whitespace).
2024-09-16 09:50:52 +02:00
axxel
2e17f8e2ec fix a few random compiler warnings
* unused variables
 * implicit enum conversion
 * sigend <-> unsigned comparison
 * left shift negative number

The only warnings left on my setup right now are `-Wstringop-truncation`
from strncpy calls. Those are not trivial to fix. Turns out the code does
regularly not take into account that strncpy may not result in a null
terminated string. Details, see `man string_copying`.
2024-09-16 09:47:32 +02:00
axxel
aa4197e18c fix compiler warnings about potentially truncated strings from snprintf 2024-09-16 09:47:32 +02:00
axxel
f41df32817 fix white-space and indentation inconsistencies (second round)
This is basically a continuation of the work from #1002 but her for the
camlibs directory. The purpose was to replace spaces as a means for
indentation with tab characters.

Note: there are some files which are still offending the general
rule but are (mostly) consistent within themselves. I let them be for
the moment. Fixing them would basically replace the whole file.

Also: there are still a ton of whitespace related inconsistencies like
"x=10" vs "x = 10" or "func(10)" vs "func (10)".

This is a whitespace only change (if you include newlines as whitespace).
2024-09-15 10:53:41 +02:00
axxel
efa7874ee4 add missing "event %d" prefix in debug output of OLC version string 2024-09-13 13:49:36 +02:00
axxel
adbfc5c9f1 make evaluation order consistent in equivalent if-statements
seems to have been overlooked here:
cc08c209a5
2024-09-13 13:49:36 +02:00
axxel
0243f08505 replace sprintf(buf) + strdup(buf) pattern with new aprintf()
less code and no worries about corrupting your stack due to buffer overflow
2024-09-13 13:49:36 +02:00
axxel
9c686713ff make ptp_pack/unpack functions take const data pointers where appropriate
This should help in tracking down memory leaks like in the last commit
more easily.
2024-09-13 13:49:36 +02:00
axxel
006e1347fc fix memory leak in _put_Fuji_FocusPoint 2024-09-13 13:49:36 +02:00
axxel
578ec6324d fix a couple sprintf/strncpy related issues with buffer size 2024-09-13 13:49:36 +02:00