This function does more than generate a diff now, it also
generates reference files. Use a more generic name.
Signed-off-by: Simon Ser <contact@emersion.fr>
errno handling is error-prone, because it relies on a global
variable. It's easy to forget to set it in error codepaths,
intermediate calls can mutate it, and so on.
Instead, return a negative error number from functions which need
to distinguish between multiple error cases, as is done by many
other C projects.
Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/emersion/libdisplay-info/-/work_items/53
This issue was caught by CI on the Clang build.
Shifting uint8_t/uint16_t without explicit casting to uint32_t may
cause overflow depending on the implicit promotion rule. Explicitly cast
to uint32_t before shifting to avoid this.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In parse_video_block() and parse_ycbcr420_block() we log failures when
size is 0, but continue with the function. Instead, let's return a
non-fatal error so that parse_data_block() is able to skip the block.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Instead of failing when we fail to parse a Data Block in
parse_data_block(), let's simply skip such block. We want to parse as
much as possible, so skipping a whole CTA extension because of a bad
Data Block is not desirable.
The test EDID added (for Lenovo T24s-28) would fail parsing without this
patch.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This removes a local variable and make use of
_di_cta_data_block_destroy() when skipping as well. This makes the next
commit easier to read.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This function can accept a data block with no tag. When we fail to fully
parse a data block this may happen. This adds a comment to document
this.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Many functions that parse_data_block() calls can fail with non-fatal
errors.
parse_data_block() needs to differentiate between:
- fatal errors (e.g. memory allocation failure), in which we fail
parsing the whole CTA extension
- non-fatal errors (e.g. data block is malformed), in which we simply
skip adding the block
- success, in which we add the block
So let's change the functions that parse_data_block() calls to set errno
to EINVAL or ENOTSUP when they fail with non-fatal errors. In the next
commit we adjust parse_data_block() to handle this properly.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
We just skip parsing the remaining data when failing to parse
latency and HDMI VICs, don't fail the entire HDMI Vendor Specific
Data Block.
Signed-off-by: Qinglong Zhong <qingloz@amazon.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
VIC values range from 1 to 219, so _di_cta_vic_video_formats has len 220
(index 0 unused).
If we pass VIC 220 to di_cta_vic_video_format_from_vic(), it tries to
access _di_cta_vic_video_formats[220] (which is out-of-bounds).
This fixes the check to avoid out-of-bounds access.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This caught a number of issues, so let's make sure we catch those things
before they make it into main.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
We only ever free'd the struct di_edid_display_descriptor, but depending
on the type of descriptor and how for we got with parsing it, there
might be more resources hanging off of it that need to be released.
We actually already have a function which takes care of that:
destroy_display_descriptor. We only have to ensure that parsing
functions return a descriptor in a consistent state and the tag is set
correctly.
Fixes: 93b0fd1 ("edid: add support for standard timings descriptor")
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
Forgot that we try to handle allocation failure. Fix it up.
Fixes: e4e0986 ("displayid: Add support for type IV timings")
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
The switch below should be exhaustive and thus always initialize the
variable but apparently gcc is not smart enough to understand that, so
let's just initialize the variables.
Fixes: 4a8684d ("edid: add support for CVT timing code descriptors")
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
Another field indicates if the coordinates are set, but we should not
leave them uninitialized either way.
Fixes: 75b2167 ("cta: add support for Speaker Location data blocks")
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
In the next commit, CTA parsing functions will be re-used for
DisplayID v2. However, DisplayID v2 doesn't embed a full EDID-style
CTA extension. Instead, it embeds a list of CTA blocks.
Stop passing around a struct di_edid_cta and instead pass a
struct di_cta with minimal state.
Signed-off-by: Simon Ser <contact@emersion.fr>
Same number of VICs as before. A few fixes in timing data because
we missed some footnote markers with the previous script.
Signed-off-by: Simon Ser <contact@emersion.fr>
The new standard combines two tables into one, and pdftotext is no
longer able to parse it. Use pdfplumber instead, which should also
be more future-proof.
Signed-off-by: Simon Ser <contact@emersion.fr>
We currently have no support for HDMI VIC codes but CTA VIC and DMT
should get printed correctly.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
It's easy to miss which VIC definition is being used. In fact, we lacked
documentation about this at some places and this commit fixes that as
well.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
Compositors might want to use the EDID/DisplayID information to figure
out the capabilities of a mode they want to drive. The mode definition
is a timing definition and not a VIC, but some of the information in the
EDID/DisplayID about a mode is tied to the VIC. (Same for DMT)
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
The DMT code is really what is encoded in the data, and as we do not
know if the caller actually needs the code or the timing data that can
be looked up from it, we should return the code and let the caller do
the lookup if wanted.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
The VICs are not tied to the CTA, EDID or DisplayID, but are really just
a mapping between a code and a timing definition.
Given that they are being used in different specs and blocks, it makes
sense to have the VIC definitions and lookups separate and reference
them where needed.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
d0c43cb795 ("edid: do not fail when extension block has invalid
checksum") has introduced _di_logger_add_failure(), which does the
same as logger_add_failure().
Signed-off-by: Simon Ser <contact@emersion.fr>
The GitLab API now returns an HTTP 403 error when checking for this.
As a result, CI is always failing for external contributors.
Since it's enabled by default, let's just drop the check.
Signed-off-by: Simon Ser <contact@emersion.fr>
No behavior change. This is just preparation for the next commit.
Both HDMI Forum Vendor-Specific Data Block (HF-VSDB) and HDMI Forum Sink
Capability Data Block (HF-SCDB) are composed of a HDMI Sink Capability
Data Structure (SCDS). For now we only support HF-VSDB, but in the next
commit we add support for HF-SCDB.
This moves the fields representing a SCDS from struct
di_cta_vendor_hdmi_forum_block to a new struct di_cta_vendor_hdmi_scds.
It also renames a few structs encapsulated by the new SCDS.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This is important because it contains a HDMI Forum Sink Capability Data
Block (HF-SCDB), and the support for that is introduced in the following
commits.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
First byte being zeroed is valid, according to the spec. Only if the
first two first bytes are zeroed we should skip parsing the DTD.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
We have multiple Data Blocks followed by Detailed Time Definitions
(DTD). Currently if we encounter a block whose reported size overlaps
DTD, we stop parsing the blocks. Instead, let's assume that this is the
last Data Block and adjust its size to parse it, taking into account the
byte in which DTD starts.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This EDID is feature-rich and contains a VSDB that is not present on
other EDID's that we have on the test suite: VSDB UHD Alliance, (OUI
1A-BB-FB).
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Helper to add functions shared between di-edid-decode files. First one
added is compute_aspect_ratio(), which was part of edid.c, and next
should be used by cta.c as well.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Unfortunately having an invalid checksum is a common issue in several
EDID extensions. Instead of failing to parsing when a bad checksum is
found, simply report the error.
This also fixes an error in which the checksum failure was being printed
in the base block.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
It contains an extension block with invalid checksum. This is important
for the next commit, in which we start accepting that.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Currently when we find an invalid SVD (bad EDID) in a video block, we
simply avoid adding it to the SVD list. Also, the map between SVD's and
the YCbCr 4:2:0 caps is based on the indices of the SVD's. Combine that
and we have a problem: we mess with the mapping.
This adds a new field "index" to struct di_cta_svd, and we use that to
properly use the mapping from SVD to YCbCr 4:2:0 cap.
Note that this is not a permanent fix that would handle all misformed
EDID's. For instance, this fails if the last VIC in the block is not
valid, or if a video block is skipped. That would require more complex
solutions, but the decision was to not introduce complexity because of
malformed EDID's.
Reported-by: Qinglong Zhong <qingloz@amazon.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
It contains HDR10+ VSDB with valid peak luminance index, so it's useful
to test next commit.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Some EDIDs might have a valid base block and an invalid extension
block. Skip the extension block in that case instead of failing the
whole EDID.
Signed-off-by: Simon Ser <contact@emersion.fr>
If the gtf options contain a bad enum di_gtf_ip_param, some variables do
not get initialized to any value but will later be read.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
Wayland compositors may be interested in this.
DI-EXT is ignored, because libdisplay-info does not parse it yet.
EDID Color Point Descriptors are ignored, because they have not been
found in shipped products.
https://github.com/linuxhw/EDID.git database contains 373 samples for
which edid-decode complains:
Basic Display Parameters & Features: sRGB is signaled, but the gamma != 2.2.
Therefore I assume that the sRGB flag is more correct when set.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Add a high-level function to get the supported additional signal
colorimetries. This is only an interesting sub-set of the CTA-861-H
defined colorimetries, for driving WCG and HDR displays.
Wayland compositors will be interested in this.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
The low-level struct di_cta_hdr_static_metadata_block is essentially
duplicated in struct di_hdr_static_metadata to make the high-level API
independent of low-level API headers. It's also simpler in form, while
new fields can still be added in the end while maintaining ABI backward
compatibility.
If new sources for HDR static metadata appear, they can be parsed into
this same structure in the future when compatible.
Wayland compositors will be interested in this.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Notifies us if the result ever changes.
The 3 decimal precision is taken from E-EDID 1.4 spec which says that
the numbers have that precision.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Add a high-level function to retrieve color primaries. Wayland
compositors will be interested in this.
A high-level function may later be extended to support stand-alone
DisplayID and other sources.
The high-level data is derived from low-level API calls in
di_info_parse_edid(). As we stash the results in struct di_info to avoid
requiring the callers to explicitly free the high-level structures, this
allows keeping struct di_info deeply const in high-level API
implementation. We also avoid some dynamic allocations.
https://github.com/linuxhw/EDID.git database contains 20399 samples for
which edid-decode complains:
Basic Display Parameters & Features: sRGB is signaled, but the chromaticities do not match.
Therefore I assume that the sRGB flag is more correct when set.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This is also used by type III timings, and there is no other
competing aspect ratio enum in the DisplayID standard.
Signed-off-by: Simon Ser <contact@emersion.fr>
Type II timings are exactly the same as Type I except more tightly
packed and no information on the aspect ratio. As such, they fit neatly
into the Type I and Type VII structure.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
Instead of hardcoding the type of timing to DTD let the caller decide.
Also lets the caller set the level of indentation.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
They only have a different resolution for the pixel clock which we can
represent by just using a type in the struct which fits the higher
resolution.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
The speaker allocation format is reused in multiple CTA data blocks.
This commit pulls it into its own struct so it can be embedded into
other data block structs.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
By default, UBSan prints the error to stderr and does nothing else.
Halt the program so that CI fails and we notice the mistake.
Signed-off-by: Simon Ser <contact@emersion.fr>
Dumps the content of every I2C address which might contain an EDID or
DisplayID blob for every connector which has an I2C bus.
This can be useful to discover DisplayID blobs which are not nested
inside an EDID blob.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
Fixes build error
../displayid.c:377:10: error: ‘ssize_t’ undeclared (first use in this function); did you mean ‘size_t’?
seen with:
arc-linux-gcc.br_real (Buildroot 2021.11-4428-g6b6741b) 10.2.0
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Since eed3e1e0f8 ("test: remove edid-decode as a test
dependency"), edid-decode is no longer required to run the test
suite. It's only required to re-generate the test data.
Expand a bit on how to setup edid-decode to re-generate the test
data.
Signed-off-by: Simon Ser <contact@emersion.fr>
Merge the stage into "Build and test". The next stages don't depend
on this stage, so we can parallelize, no need to block the next
stages because of the testing-check step.
Signed-off-by: Simon Ser <contact@emersion.fr>
by storing the reference edid-decode output in the repository. It is now
only a dependency for the gen-test-data target. The CI checks that the
reference output in the repository matches the one generated from a
specific checkout of edid-decode.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
With 'set -e' any failing command will terminate the script but we want
to print a message before exiting. Checking the exit code of a previous
failing command does not work. Print the message in the same command
instead.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
We will add more checks in the next commit which require an image which
can run meson and ninja.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
Fixes the following error:
meson.build:52:0: ERROR: Invalid Shared library version "0.2.0-dev". Must be of the form X.Y.Z where all three are numbers. Y and Z are optional.
Signed-off-by: Simon Ser <contact@emersion.fr>
We use semantic versioning but will still have ABI breaks in the 0.x.x
series so we will just bump the SONAME every new minor release.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
Exclude build/ from code coverage, otherwise build/pnp-id-table.c
is included in the stats. Also add subprojects/ which is added by
default by Meson unless there is a custom config file.
Signed-off-by: Simon Ser <contact@emersion.fr>
This prevents the Alpine image from being upgraded to a new major
version when re-generated. ci-templates defaults FDO_BASE_IMAGE to
alpine:latest.
Signed-off-by: Simon Ser <contact@emersion.fr>
Since a001cab480 ("build: split off di-edid-decode into separate
file"), di-edid-decode is located in a subdirectory.
Signed-off-by: Simon Ser <contact@emersion.fr>
This makes it easier to re-generate the test diffs. The build system
will properly set DI_EDID_DECODE/DI_EDID_PRINT (and will rebuild
these tools if they are out-of-date).
Signed-off-by: Simon Ser <contact@emersion.fr>
The three character PNP ID is a key to manufacturer name database. It
may be desirable to report the manufacturer's real name than just PNP ID
which can be misleading, e.g. MSI refers to Microstep and not MSI GmbH.
This builds the PNP ID database into libdisplay-info to avoid having to
find and parse files at runtime.
tool/gen-search-table.py started as a copy of Wayland 1.21.0's
src/embed.py and took influence from
https://github.com/golightlyb/PNP-ID/blob/10945c4ed8fcb86cccdb0913a18777ab0dc84c57/conv.py
However, our script parses the text file shipped in hwdata package in
Debian (and presumably other distributions) rather than the original
CSV.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This is needed for the following patch to find pnp.ids.
This is not available in the Alpine release we are using right now.
That --disable-blacklist works around the error:
install: unrecognized option: T
BusyBox v1.35.0 (2022-08-01 15:14:44 UTC) multi-call binary.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This seems to be what the existing python file uses, and trying to write
python when your editor is constantly resetting its settings according
to the previous "incorrect" editorconfig was infuriating.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Having to define just DI_EDID_DECODE was tolerable when REF_EDID_DECODE
does not need setting, but now that there are two built tools, it is
getting inconvenient.
Change the defaults to match the build directory structure and add a new
overridable for the build directory.
Now I only need to set BUILDDIR for this to work. My build dirs are
completely elsewhere, but if someone uses the usual 'meson build'
incantation, the default value for BUILDDIR should be fine.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This new test exercises all existing high-level API to make sure the
output does not change unexpectedly.
Unlike with edid-decode tests, these new print tests do not have an
externally defined groundtruth. They are only to detect changes and
exercise code paths.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
The functionality of these new high-level functions as implemented here
follows what Weston 11.0's ad hoc EDID parser extracted. There are
differences to Weston though:
- get_model() falls back to the numeric model field
- unusual characters are escaped as hex rather than replaced with dash
The documentation of the new functions allows to change the behavior of
get_model and get_make to e.g. convert PNP ID to a company name. The
notes about UTF-8 allow us to make use of UTF-8 fields if such appear
useful in the future.
Weston's ad hoc parser shall be replaced with this. After another API
addition, the high-level API semantics will match what Weston expects.
The memory_stream stuff is for convenience and will see more complex
use in the future.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This is a hand-crafted EDID taken from edid-decode (test/cta-vesa.test).
It contains uncommon blocks: VESA Display Transfer Characteristics Data
Block and VESA Video Display Device Data Block in the CTA-861 extension.
While it's not as good as a real-world EDID, it can still improve our
test coverage and ensure we behave like edid-decode.
Signed-off-by: Simon Ser <contact@emersion.fr>
This was used as an example of what a high-level API function would
look like, but is too opinionated to be useful across many
compositors.
Signed-off-by: Simon Ser <contact@emersion.fr>
I believe this is what we intended, and it is what I want.
It could lead to duplicating low-level API in high-level API at first,
but once we start seeing DisplayID in the wild, the high-level functions
need to start looking into both EDID and DisplayID APIs to deliver the
desired information.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
I was scratching my head for a good while, why does the test suite fail
straight out of upstream on one EDID file. Turns out I was using a
different version of edid-decode than CI, which caused the recorded diff
patch to fail to apply. I was missing
41507c0b5f "ci: update edid-decode"
Make an explicit note about this dependency.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
../../git/weston/subprojects/display-info/edid.c: In function ‘decode_chromaticity_coord’:
../../git/weston/subprojects/display-info/edid.c:250:8: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
250 | raw = (uint16_t) (hi << 2) | lo;
| ^
Apparently the cast applies to (hi << 2), then bitwise-or implicitly
promotes to signed int, and that gets assigned to uint16_t raw. At least
gcc 10.2.1 from Debian seems to think so.
Fix it by forcing the cast on the complete result.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
The section size might be smaller than the provided buffer size,
because the buffer might have padding at the end.
Signed-off-by: Simon Ser <contact@emersion.fr>
This allows callers to access the detailed DMT data.
di-edid-decode is updated to print the missing fields.
Signed-off-by: Simon Ser <contact@emersion.fr>
Make sure we didn't mess up the array size. Abort instead of
corrupting memory.
Found the array insert operations via:
git grep '++]'
Signed-off-by: Simon Ser <contact@emersion.fr>
Report the SVDs inside the video data block.
We'll need to add additional APIs to get detailed SVD mode info
in the future (with a SVD table).
Signed-off-by: Simon Ser <contact@emersion.fr>
Nested structs makes it impossible to extend the nested struct after
extending the base struct. The union acts as a single struct in this
case but the nesting is still an issue. Use pointers to those structs instead
to keep all of them extensible. Only the struct which is applicable for the
signal type is not a null pointer to make sure only valid data is accessed.
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
This makes it easier to perform an operation on all EDID files at
once, e.g. "test/edid-decode-diff.sh test/data/*.edid" to update all
diffs at once.
Signed-off-by: Simon Ser <contact@emersion.fr>
Call rm with the -f flag to ignore non-existing .diff files.
The .diff file doesn't exist if there is no difference in the
edid-decode output.
Signed-off-by: Simon Ser <contact@emersion.fr>
To parse standard timing descriptors, we'll need to re-use that
function and store the result elsewhere.
Signed-off-by: Simon Ser <contact@emersion.fr>
Upstream edid-decode uses a global variable to store the current
EDID section name and prefix failure messages.
Signed-off-by: Simon Ser <contact@emersion.fr>
This is a private function which parses DTDs. This will be useful
in the next commit to parse DTDs from the CTA extension.
Signed-off-by: Simon Ser <contact@emersion.fr>
EDID 1.2- allow the first byte descriptor to contain a display
descriptor. EDID 1.3+ require the first byte descriptor to contain
a detailed timing definition describing the display's preferred
(ie, optimal) mode.
Signed-off-by: Simon Ser <contact@emersion.fr>
EDID 1.4 forbids years < 2006, but EDID 1.3 allows them.
Error out when an EDID uses a reserved value. Correctly parse the
year on older EDID revisions.
Signed-off-by: Simon Ser <contact@emersion.fr>
These functions now only return false on fatal failures
(e.g. out of memory). They no longer return false for unsupported
block types.
Signed-off-by: Simon Ser <contact@emersion.fr>
This is a bit messy because the values depend on various misc flags
defined earlier in the spec, and the meaning changes between EDID 1.3
and 1.4. On top of that edid-decode prints something confusing in the
EDID 1.3 case.
Signed-off-by: Simon Ser <contact@emersion.fr>
The only caller skips any descriptor with errors, it doesn't surface
back the errno to the library user.
Signed-off-by: Simon Ser <contact@emersion.fr>
This will allow us to use the helpers from cta.c.
The functions are marked "static inline" to avoid warnings about
unused functions.
Signed-off-by: Simon Ser <contact@emersion.fr>
The Display Monitor Timing specification is a PDF with data tables.
A small Python script can be used to extract its contents in a
machine-readable form.
For now only extract a few fields. This can be extended later.
Signed-off-by: Simon Ser <contact@emersion.fr>
The analog/digital flags are left for a future patch.
A join_str() function is introduced in di-edid-decode: upstream
edid-decode uses a comma-separated list with a handful of other
flags.
Signed-off-by: Simon Ser <contact@emersion.fr>
This makes it clearer what the range of the value can be: we no
longer need to deal with 16-bit integers.
Signed-off-by: Simon Ser <contact@emersion.fr>
The spec allows manufacturers to store the aspect ratio in these
fields. Instead of exposing bogus values to the user, mark the
size in mm as undefined.
Signed-off-by: Simon Ser <contact@emersion.fr>
According to table 3.21 note 17, these fields should be set to zero
for some sinks, e.g. front projectors.
edid-decode hides the size from its output if both fields are zero.
Signed-off-by: Simon Ser <contact@emersion.fr>
These two compilers may have different warnings. Make sure we
don't miss any.
The Clang build also supports ASan + UBSan.
Signed-off-by: Simon Ser <contact@emersion.fr>
The motivation is two-fold:
- These were added back when we exposed values outside of the enum
entries. We no longer do that, so these can't be hit.
- The compiler now warns when we are missing an entry from the switch.
Signed-off-by: Simon Ser <contact@emersion.fr>
This should remove the risk to merge a patch with the
FDO_FORCE_REBUILD line uncommented. Mentionning the command in the
manifest makes it easier to remember.
Signed-off-by: Simon Ser <contact@emersion.fr>
A simple version script is used because it allows us to consistently
expose all symbols starting with "di_", removing the risk to forget
to mark a symbol as public.
Signed-off-by: Simon Ser <contact@emersion.fr>
The extra underscore indicates that it's not a function which is
part of our public API. This will allow the next commit to setup the
linker to export functions based on their name.
Signed-off-by: Simon Ser <contact@emersion.fr>
These appear after the basic display parameters and features in
the EDID structure, so it makes sense to put them below in the
header.
I got confused while during a rebase.
While at it, move the declaration for struct di_edid_display_descriptor
before the one for di_edid_get_display_descriptors(), because the
latter uses the former.
Signed-off-by: Simon Ser <contact@emersion.fr>
The first fread call fills our 32 KiB buffer, and then we enter a busy
loop calling fread with zero.
Found via fuzzing with AFL.
Signed-off-by: Simon Ser <contact@emersion.fr>
Upstream edid-decode hides the serial number in this case.
The spec says that it's optional, and set to zero when unused.
Signed-off-by: Simon Ser <contact@emersion.fr>
These warnings are easy to miss during development:
../edid.c: In function ‘_di_edid_parse’:
../edid.c:254:25: warning: implicit declaration of function ‘di_edid_destroy’? [-Wimplicit-function-declaration]
254 | di_edid_destroy(edid);
| ^~~~~~~~~~~~~~~
And when missed, the code still compiles. Which means one needs to clean-build
to show them again.
Signed-off-by: Simon Ser <contact@emersion.fr>
This allows us to catch issues such as unknown build options and
newer Meson features used without a bump in meson.build's project().
Signed-off-by: Simon Ser <contact@emersion.fr>
While this isn't particularly interesting to print, this reduces
the diff between di-edid-decode and edid-decode.
This is not exposed via the low-level EDID library because callers
wouldn't have a use for it.
Signed-off-by: Simon Ser <contact@emersion.fr>
The spec defines an upper bound for the extension block count,
which means we don't need to dynamically allocate the array. This
simplifies our logic a bit by removing an allocation error codepath.
The array is NULL-terminated, so EDID_MAX_BLOCK_COUNT is suitable
since it's the max number of extension blocks including the base
block, and the array doesn't include the base block.
Signed-off-by: Simon Ser <contact@emersion.fr>
It sounds like the CI container was shipping an outdated version
of edid-decode which doesn't match the commit recorded in
.gitlab-ci.yml.
Update the diffs in the test data, and bump the CI container tag
again to make sure it's up-to-date with the manifest.
Signed-off-by: Simon Ser <contact@emersion.fr>
This is what the specification uses. Makes it easier to compare the
code to the spec.
No functional change, this is purely a cosmetic change.
Signed-off-by: Simon Ser <contact@emersion.fr>
This high-level function leverages the low-level
di_edid_get_vendor_product function to build a string describing
the display device product.
Signed-off-by: Simon Ser <contact@emersion.fr>
This utility displays low-level EDID information. It uses the same
format as the official edid-decode CLI tool from linuxtv.org. It
will be helpful for testing.
Signed-off-by: Simon Ser <contact@emersion.fr>
This exposes a new di_info opaque struct from which high-level
information will be able to be queried by the user. A new
di_info_parse_edid function creates a di_info from an EDID blob.
Signed-off-by: Simon Ser <contact@emersion.fr>
Introduce an opaque struct di_edid to host EDID structures. Add
a function to create a di_edid (with basic size, header and
checksum validation). Add functions to fetch the EDID version and
revision.
This doesn't do much, but hopefully can be used as a fundation.
Signed-off-by: Simon Ser <contact@emersion.fr>
This warns when implicit conversions may alter a value. It's easy
to miss implicit conversions from signed to unsigned, from real to
integer, or to smaller types. This warning forces such conversions
to be explicit.
Signed-off-by: Simon Ser <contact@emersion.fr>
Enable a few extra warning options, including -Walloca because it's
error-prone. Enable -Wdeclaration-after-statement to enforce the code
style. Disable -Wunused-parameter and -Wmissing-field-initializers
because these are pointless and don't catch bugs.
Inspired from the Weston and wlroots options.
Signed-off-by: Simon Ser <contact@emersion.fr>