From 0306131e6b37a4cdb2c6cd45b9a0a7dfc02dc5df Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 2 Sep 2024 20:48:03 +0200 Subject: [PATCH] libstb-hal: hdmi_cec: ensure time compatibility for rc_sync with _TIME_BITS=64 This commit replaces commit: libstb-hal: Fix compatibility issues with struct input_event time assignment These issues arose because of updates in OE/Yocto versions (e.g. >= Honister), which introduced changes requiring these adjustments. - Added conditional compilation to check for input_event_sec. - Updated hdmi_cec::rc_sync method to use appropriate time fields for 64-bit suseconds. - Maintained backward compatibility for older systems with 32-bit suseconds. - Leveraged macros defined in input.h for clarity and maintainability. This should ensure proper handling of suseconds and maintain backward compatibility with older systems. This implementation uses input_event_sec and input_event_usec macros for clarity and maintainability. This changes shuold resolve build issues encountered due to compatibility problems with newer versions of libraries. It is quite certain that similar adjustments will need to be made in other files. However, since I have only worked on this platform so far, only this part of the code was noticeable at first. It should be noted that this problem likely does not "yet" affect older build systems, but it will become necessary at some point. This also applies to Neutrino (adjustments will follow). Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/7d247534d0aa89d53579a1c2d1ed2238e7a6585b Author: Thilo Graf Date: 2024-09-02 (Mon, 02 Sep 2024) Origin message was: ------------------ libstb-hal: hdmi_cec: ensure time compatibility for rc_sync with _TIME_BITS=64 This commit replaces commit: libstb-hal: Fix compatibility issues with struct input_event time assignment These issues arose because of updates in OE/Yocto versions (e.g. >= Honister), which introduced changes requiring these adjustments. - Added conditional compilation to check for input_event_sec. - Updated hdmi_cec::rc_sync method to use appropriate time fields for 64-bit suseconds. - Maintained backward compatibility for older systems with 32-bit suseconds. - Leveraged macros defined in input.h for clarity and maintainability. This should ensure proper handling of suseconds and maintain backward compatibility with older systems. This implementation uses input_event_sec and input_event_usec macros for clarity and maintainability. This changes shuold resolve build issues encountered due to compatibility problems with newer versions of libraries. It is quite certain that similar adjustments will need to be made in other files. However, since I have only worked on this platform so far, only this part of the code was noticeable at first. It should be noted that this problem likely does not "yet" affect older build systems, but it will become necessary at some point. This also applies to Neutrino (adjustments will follow). ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index 8806d53..015939e 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -790,7 +790,19 @@ void hdmi_cec::rc_sync(int fd) { struct input_event ev; + // Check if the input_event_sec macro is defined and use appropriate fields for setting time values. + // This ensures compatibility with both older and newer versions of the input_event structure. + // Newer versions use input_event_sec and input_event_usec macros for 64-bit time values, + // while older versions use the time field directly, which is a timeval structure. +#ifdef input_event_sec + struct timeval tv; + gettimeofday(&tv, NULL); + ev.input_event_sec = tv.tv_sec; + ev.input_event_usec = tv.tv_usec; +#else gettimeofday(&ev.time, NULL); +#endif + ev.type = EV_SYN; ev.code = SYN_REPORT; ev.value = 0;