Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for reporting external monitor info using ddcutil #49

Closed
pabs3 opened this issue Jan 28, 2020 · 49 comments
Closed

add support for reporting external monitor info using ddcutil #49

pabs3 opened this issue Jan 28, 2020 · 49 comments

Comments

@pabs3
Copy link

pabs3 commented Jan 28, 2020

ddcutil speaks the DDC/MCCS protocols for speaking to external VGA/DVI/HDMI monitors. Using the ddcutil detect/capabilities/usbenv/probe/interrogate commands will provide detailed information about the connected monitors.

https://en.wikipedia.org/wiki/Display_Data_Channel
https://www.ddcutil.com/

@rockowitz is the author of ddcutil and would probably appreciate having external monitor DDC information in the https://linux-hardware.org/ database.

PS: please note that the ddcutil output currently contains serial numbers from the monitor EDID data, so those will need to be stripped out.

@rockowitz
Copy link

rockowitz commented Jan 28, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 10, 2020

@rockowitz

Is it possible to quickly get list of busy i2c bus numbers? Without iterating over all 0..31. It takes 3 seconds on my machine and this doubles execution time of the hw-probe.

@rockowitz
Copy link

rockowitz commented Feb 10, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 11, 2020

@rockowitz

I need to detect i2c bus numbers where physical monitors are connected. And then run ddcutil probe --bus N on them w/o the need to loop through 0..31.

Something like:

i2cdetect -l | grep "NVIDIA\|nvkm\|i915\|Radeon\|AMDGPU"

On my computer N=2. I need to detect this exact number quickly or somehow reduce the range 0..31.

@rockowitz
Copy link

rockowitz commented Feb 11, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 11, 2020

Fixed by f96fd2f. But still need to optimize this and test properly. I have no desktop nearby until Monday (notebooks are not supported).

@linuxhw linuxhw closed this as completed Feb 11, 2020
@rockowitz
Copy link

rockowitz commented Feb 11, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 11, 2020

@rockowitz

Could you please attach sample output of ddcutil probe --bus N for a monitor?

Thanks.

@rockowitz
Copy link

rockowitz commented Feb 11, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 11, 2020

@rockowitz

I'd like to add ddcutil to the hw-probe AppImage. But I don't see commits in 0.9.9-dev from Feb 11. Did you pushed them?

Thanks.

@rockowitz
Copy link

rockowitz commented Feb 11, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 12, 2020

@rockowitz

BTW

Tried to add ddcutil to Alpine Docker and found missed include of sys/types.h in src/util/edid.h and other Alpine build incompatibilities: https://git.alpinelinux.org/aports/tree/testing/ddcutil/execinfo.patch

Is it possible to include this patch to upstream?

@linuxhw
Copy link
Owner

linuxhw commented Feb 12, 2020

@rockowitz

I've tried to build latest 0.9.9 in Alpine 3.11, but failed to link final binary (something is bad with inline value_bytes_zero). Is ddcutil-0.9.1 good enough to use (in Alpine edge)?

@rockowitz
Copy link

rockowitz commented Feb 12, 2020 via email

@rockowitz
Copy link

rockowitz commented Feb 12, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 12, 2020

@rockowitz

What declarations are missing when compiling edid.h for Alpine Linux that require sys/types.h?

ushort type is missed.

@linuxhw linuxhw reopened this Feb 12, 2020
@rockowitz
Copy link

rockowitz commented Feb 12, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 12, 2020

@rockowitz

0.9.1 is almost 2 years old. Numerous enhancements and bug fixes. I'd rather solve the value_bytes_zero() problem. What's your compiler/linker output?

Full list of problems:

  1. Missed ushort type in edid.h
  2. Missed backtrace_symbols(buffer, nptrs) in src/util/debug_util.c
  3. Missed backtrace(buffer, MAX_ADDRS) in src/util/debug_util.c
  4. Missed sbool in src/*/*.c
  5. Undefined reference to value_bytes_zero

I've applied a temp fix for 1-4 by sed:

sed -i '1s/^/#include <sys/types.h>/' src/util/edid.h \
sed -i -e 's/backtrace_symbols(buffer, nptrs)/NULL/' src/util/debug_util.c \
sed -i -e 's/backtrace(buffer, MAX_ADDRS)/0/' src/util/debug_util.c \
sed -i -e 's/sbool/bool_repr/g' src/*/*.c

But stuck at 5 with no ideas what is going wrong. The error log of the compiler:

...
make[3]: Entering directory '/ddcutil-20200211/src'
  CC       app_ddcutil/ddcutil-main.o
  CC       app_ddcutil/ddcutil-app_dynamic_features.o
  CC       app_ddcutil/ddcutil-app_vcp_info.o
  CC       app_ddcutil/ddcutil-app_dumpload.o
  CC       app_ddcutil/ddcutil-app_setvcp.o
  CC       app_ddcutil/ddcutil-app_getvcp.o
  CCLD     libapp.la
ar: `u' modifier ignored since `D' is the default (see `U')
  CCLD     libcommon.la
ar: `u' modifier ignored since `D' is the default (see `U')
  CCLD     ddcutil
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: ./.libs/libcommon.a(ddc_vcp.o): in function `ddc_get_nontable_vcp_value':
ddc_vcp.c:(.text+0x1014): undefined reference to `value_bytes_zero'
/usr/lib/gcc/x86_64-alpine-linux-musl/9.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: ddc_vcp.c:(.text+0x1056): undefined reference to `value_bytes_zero'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:885: ddcutil] Error 1
make[3]: Leaving directory '/ddcutil-20200211/src'
make[2]: *** [Makefile:1132: all-recursive] Error 1
make[2]: Leaving directory '/ddcutil-20200211/src'
make[1]: *** [Makefile:577: all-recursive] Error 1
make[1]: Leaving directory '/ddcutil-20200211'
make: *** [Makefile:484: all] Error 2

What I'm trying to do is to add ddcutil to the Docker image of hw-probe in order to collect DDCs of all connected monitors easily like this was done for edid-decode: https://github.com/linuxhw/hw-probe/blob/master/Dockerfile

@rockowitz
Copy link

rockowitz commented Feb 12, 2020 via email

@rockowitz
Copy link

rockowitz commented Feb 13, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 13, 2020

@rockowitz

Last build error:

Making all in .
make[3]: Entering directory '/ddcutil/src'
  CC       app_ddcutil/ddcutil-main.o
  CC       app_ddcutil/ddcutil-app_dynamic_features.o
  CC       app_ddcutil/ddcutil-app_vcp_info.o
  CC       app_ddcutil/ddcutil-app_dumpload.o
  CC       app_ddcutil/ddcutil-app_setvcp.o
  CC       app_ddcutil/ddcutil-app_getvcp.o
  CCLD     libapp.la
ar: `u' modifier ignored since `D' is the default (see `U')
  CCLD     libcommon.la
ar: `u' modifier ignored since `D' is the default (see `U')
  CCLD     ddcutil
  CC       libmain/api_base.lo
In file included from libmain/api_base.c:33:
./libmain/api_base_internal.h:14:10: fatal error: sys/cdefs.h: No such file or directory
   14 | #include <sys/cdefs.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
make[3]: *** [Makefile:937: libmain/api_base.lo] Error 1
make[3]: Leaving directory '/ddcutil/src'
make[2]: *** [Makefile:1133: all-recursive] Error 1
make[2]: Leaving directory '/ddcutil/src'
make[1]: *** [Makefile:578: all-recursive] Error 1
make[1]: Leaving directory '/ddcutil'
make: *** [Makefile:485: all] Error 2

/usr/include/sys/cdefs.h is provided only by bsd-compat-headers package on Alpine with a deprecation warning for sys/cdefs.h.

@rockowitz
Copy link

rockowitz commented Feb 13, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 13, 2020

@rockowitz

I've deleted the include of sys/cdefs.h and pushed the change to github. It does not appear to be necessary. If it had been, how would you have proposed dealing with this Alpine Linux deviation.

Probably not all apps are compatible with it due to different libc implementation. But it rocks when creating portable Docker apps due to extremely light weight base system.

@linuxhw
Copy link
Owner

linuxhw commented Feb 13, 2020

@rockowitz

I've deleted the include of sys/cdefs.h and pushed the change to github. It does not appear to be necessary. If it had been, how would you have proposed dealing with this Alpine Linux deviation.

Seems that this include was necessary for __THROW in api_base_internal.h. I see a bunch of related build errors currently.

@linuxhw
Copy link
Owner

linuxhw commented Feb 13, 2020

@rockowitz

I've deleted the include of sys/cdefs.h and pushed the change to github. It does not appear to be necessary. If it had been, how would you have proposed dealing with this Alpine Linux deviation.

Could you please revert this change? I'll try to use bsd-compat-headers to get sys/cdefs.h as a temp solution.

Thanks.

@rockowitz
Copy link

rockowitz commented Feb 13, 2020 via email

@rockowitz
Copy link

rockowitz commented Feb 13, 2020 via email

@rockowitz
Copy link

rockowitz commented Feb 14, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 14, 2020

I have modified files api_base_internal.h and api_base.c to, insofar as I can tell, not depend on cdefs.h by replacing the __THROW macro with the C code it would expand to in the current context. Let me know if this works for you. If it does, cleanup will follow.

Build succeeded on 9f320. Thanks a lot!

Started build of d378f.

@linuxhw
Copy link
Owner

linuxhw commented Feb 14, 2020

@rockowitz

I have modified files api_base_internal.h and api_base.c to, insofar as I can tell, not depend on cdefs.h by replacing the __THROW macro with the C code it would expand to in the current context. Let me know if this works for you. If it does, cleanup will follow.

Build succeeded on 9f320. Thanks a lot!

Started build of d378f.

Build succeeded on d378f.

@linuxhw
Copy link
Owner

linuxhw commented Feb 14, 2020

Built 1.5-ddc tag of https://hub.docker.com/r/linuxhw/hw-probe for testing purposes:

xhost +local:
sudo docker run -it -v /dev:/dev:ro -v /lib/modules:/lib/modules:ro -v /etc/os-release:/etc/os-release:ro -v /var/log:/var/log:ro --privileged --net=host --pid=host linuxhw/hw-probe:1.5-ddc -all -upload -enable ddc

Also AppImage is ready: https://github.com/linuxhw/hw-probe/releases/download/1.5/hw-probe-1.5-162-x86_64.AppImage

chmod +x ./hw-probe-1.5-162-x86_64.AppImage
sudo ./hw-probe-1.5-162-x86_64.AppImage -all -upload -enable ddc

I'll test them when I access my desktop on Monday.

@linuxhw
Copy link
Owner

linuxhw commented Feb 17, 2020

@rockowitz

Got first probe of Dell P2414H by Docker image: https://linux-hardware.org/?probe=546f54f7e3&log=ddcutil

But it takes about 40 seconds to ddcutil probe --bus 6 on my desktop. Is it possible to speed up somehow? Where is the bottleneck?

I want to enable this probe by default to create large database of DDC probes, but execution time should be limited to 5 sec max per monitor.

Thanks.

@linuxhw
Copy link
Owner

linuxhw commented Feb 17, 2020

@rockowitz

Tried to run on another desktop, but ddcutil can't find a monitor (DELL via HDMI on Fedora 31 X11): rockowitz/ddcutil#106

@linuxhw
Copy link
Owner

linuxhw commented Feb 17, 2020

@rockowitz

Tried to run on another desktop, but ddcutil can't find a monitor (DELL via HDMI on Fedora 31 X11): rockowitz/ddcutil#106

Fixed by xhost +local:

@linuxhw
Copy link
Owner

linuxhw commented Feb 17, 2020

Second probe (DELL U2417H): https://linux-hardware.org/?probe=9e951ac165&log=ddcutil

@rockowitz
Copy link

rockowitz commented Feb 17, 2020 via email

@rockowitz
Copy link

rockowitz commented Feb 18, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 18, 2020

@rockowitz

The sleep time can be adjusted using the -- sleep-multiplier option

sudo ddcutil probe --bus 6
# Takes 37.4s

sudo ddcutil probe --bus 6 --sleep-multiplier 0.1 | grep -v "DDC Null Response"
# Takes 15.0s

Output is not changed.

Is there an option to hide ddc_write_read() succeeded after N sleep and retry ... and Extended delay as recovery ... messages?

@linuxhw
Copy link
Owner

linuxhw commented Feb 18, 2020

@rockowitz

I've made some experimental changes to reduce execution time. The changes have been pushed to branch 0.9.9-dev. One that appears to not introduce errors, but needs much more testing, eliminates certain types of sleep events. For now, it is enabled using undocumented option "--f1". Give it a try.

sudo ddcutil-prev probe --bus 6
# Takes 37.4s

sudo ddcutil-now probe --f1 --bus 6
# Takes 20.8s

sudo ddcutil-now probe --bus 6 --f1 --sleep-multiplier 0.1
# Takes 16.8s

Output is not changed. Added set_error_stats_sleep_multiplier_factor value to the output.

Thanks!

@linuxhw
Copy link
Owner

linuxhw commented Feb 18, 2020

@rockowitz

Does the best sleep-multiplier value depend on cpu or monitor itself?

I got best performance on sleep-multiplier=0.2 on Dell P2414H:

sudo ddcutil-now probe --bus 6 --f1 --sleep-multiplier 0.2
# Takes 8.5s

The --f1 option rocks.

@rockowitz
Copy link

rockowitz commented Feb 18, 2020 via email

@rockowitz
Copy link

rockowitz commented Feb 18, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 19, 2020

I've made some experimental changes to reduce execution time. The changes have been pushed to branch 0.9.9-dev. One that appears to not introduce errors, but needs much more testing, eliminates certain types of sleep events. For now, it is enabled using undocumented option "--f1". Give it a try.

Can I use --f1 in production? Will it be renamed in future?

@rockowitz
Copy link

rockowitz commented Feb 19, 2020 via email

@pabs3
Copy link
Author

pabs3 commented Feb 22, 2020 via email

@linuxhw
Copy link
Owner

linuxhw commented Feb 22, 2020

I wonder if making hw-probe run multiple processes in the background and aggregating their output would mitigate this issue by having the tool runtime be parallel instead of serial.

@rockowitz

Can a monitor handle multiple ddc requests in parallel?

@rockowitz
Copy link

rockowitz commented Feb 23, 2020 via email

@pabs3
Copy link
Author

pabs3 commented Feb 27, 2020

To be clear, I meant running ddcutil in parallel with other tools for hardware info extraction, but I agree that running ddcutil itself in parallel would be nice.

@linuxhw linuxhw closed this as completed Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants