Author: Dharanendiran <dharanendiran@timesys.com>
Date: Mon, 28 Sep 2026 09:10:19 +0530

Add an 'i2c-dev' feature option to control whether edid-decode is
built with DDC/I2C EDID reading support (ddc.cpp and the
__HAS_I2C_DEV__ define).

Previously ddc.cpp was built whenever linux/i2c-dev.h was found,
with no way to turn it off. This is a problem when the compiler
cannot build ddc.cpp, for example GCC 4.9.4, which rejects the
designated-initializer assignments it uses.

---
 meson_options.txt             |  3 +++
 utils/edid-decode/meson.build | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/meson_options.txt b/meson_options.txt
index 3d04cfb..f3dfc3e 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -60,3 +60,6 @@ option('doxygen-html', type : 'boolean',
        description : 'Generate doxygen plain HTML documentation')
 option('doxygen-man', type : 'boolean', value : false,
        description : 'Generate doxygen manual pages')
+
+option('i2c-dev', type: 'feature', value: 'auto',
+       description: 'DDC/I2C EDID reading support in edid-decode (requires linux/i2c-dev.h)')
diff --git a/utils/edid-decode/meson.build b/utils/edid-decode/meson.build
index d1ed517..e46e58c 100644
--- a/utils/edid-decode/meson.build
+++ b/utils/edid-decode/meson.build
@@ -14,7 +14,18 @@ edid_decode_sources = [
 
 edid_decode_args = []
 
-if cc.has_header('linux/i2c-dev.h')
+i2c_dev_opt = get_option('i2c-dev')
+
+if i2c_dev_opt.disabled()
+	have_i2c_dev = false
+else
+	have_i2c_dev = cc.has_header('linux/i2c-dev.h')
+	if i2c_dev_opt.enabled() and not have_i2c_dev
+		error('linux/i2c-dev.h not found, cannot enable i2c-dev support')
+	endif
+endif
+
+if have_i2c_dev
 	edid_decode_sources += ['ddc.cpp']
 	edid_decode_args += ['-D__HAS_I2C_DEV__']
 endif
-- 
2.25.1

