digitaltrails / ddcutil-service

A Dbus ddcutil server for control of DDC Monitors/VDUs
GNU General Public License v2.0
11 stars 1 forks source link

Error(s) opening ddc devices, while ddcutil works #23

Closed major-mayer closed 3 months ago

major-mayer commented 3 months ago

When I install the service (from AUR) and switch on the dbus client in vdu_controls, there are no displays detected and the following error message appears when I refresh:

D-Bus  status=-3022: DDCRC_OTHER: Error(s) opening ddc devices

When i use ddcutil from CLI, the displays are identified correctly:

ddcutil detect                                                                                 ✔ 
Device /dev/i2c-1 is not readable and writable.  Error = EACCES(13): Permission denied
Device /dev/i2c-2 is not readable and writable.  Error = EACCES(13): Permission denied
Device /dev/i2c-3 is not readable and writable.  Error = EACCES(13): Permission denied
Device /dev/i2c-4 is not readable and writable.  Error = EACCES(13): Permission denied
Devices possibly used for DDC/CI communication cannot be opened: /dev/i2c-1 /dev/i2c-2 /dev/i2c-3 /dev/i2c-4
See https://www.ddcutil.com/i2c_permissions
Display 1
   I2C bus:  /dev/i2c-10
   DRM connector:           card2-HDMI-A-4
   EDID synopsis:
      Mfg id:               ACR - Acer Technologies
      Model:                Acer S222HQL
      Product code:         516  (0x0204)
      Serial number:        LR0080194201
      Binary serial number: 352827935 (0x1507ba1f)
      Manufacture year:     2011,  Week: 50
   VCP version:         2.1

Display 2
   I2C bus:  /dev/i2c-12
   DRM connector:           card2-DP-3
   EDID synopsis:
      Mfg id:               PHL - Philips Consumer Electronics Company
      Model:                PHL 326M6V
      Product code:         49555  (0xc193)
      Serial number:        
      Binary serial number: 354 (0x00000162)
      Manufacture year:     2019,  Week: 14
   VCP version:         3.0

Is this a duplicate of https://github.com/digitaltrails/ddcutil-service/issues/22 or a new issue?

digitaltrails commented 3 months ago

Given the AUR has a much more recent libddcutil, a separate issue is the correct thing to do - thanks for opening it.

A good first step would be to see if this a ddcutil-service issue (rather than vdu_controls). We can use busctl (or any dbus capable tool) to test the service:

busctl --user call com.ddcutil.DdcutilService /com/ddcutil/DdcutilObject com.ddcutil.DdcutilInterface Detect u 0

If this also errors, then you've got some combo of hardware/drivers that causes an error, probably within libddcutil. Unfortunately ddcutil and libddcutil don't completely share the same code and the timing of their bus operations also differ. So you're either stuck with ddcutil, or if you can spare the time, you can help track down the issue. Assuming you'd like to help...

It might be better to run the service in a terminal window because more debug/info messages can be gathered by using the --log-info option. The service runs as a user-session service (meaning it runs under the user's login, not root). It's also stateless and automatically registers with the dbus-daemon/broker. So any user can kill and restart the service, in a terminal window do:

killall  ddcutil-service 
ddcutil-service --log-info 2>&1 | tee ddcutil-service.log

Then running the busctl query in another terminal window should result in output in ddcutil-service's window.

Depending on what is discovered, I may be able to fix it in ddcutil-service, or I might need to pass it on as a libddcutil issue.

digitaltrails commented 3 months ago

As well as the above detect test, also try:

busctl --user call com.ddcutil.DdcutilService /com/ddcutil/DdcutilObject com.ddcutil.DdcutilInterface Detect u 1

Passing 1 is what vdu_controls does, that only returns valid displays. Invalid displays are ones that are turned off. Because some power goes down the connection cable sometimes they may appear zombie like on the bus - somewhat depends on cables/divers/gpu.

major-mayer commented 3 months ago

Thanks for your fast and very extensive response. It seems like it is indeed a service error, because I get the same results when using the busctl tool:

 busctl --user call com.ddcutil.DdcutilService /com/ddcutil/DdcutilObject com.ddcutil.DdcutilInterface Detect u 0    
ia(iiisssqsu)is 0 0 -3022 "DDCRC_OTHER: Error(s) opening ddc devices"
 busctl --user call com.ddcutil.DdcutilService /com/ddcutil/DdcutilObject com.ddcutil.DdcutilInterface Detect u 1    
ia(iiisssqsu)is 0 0 -3022 "DDCRC_OTHER: Error(s) opening ddc devices"

I'm happy to assist you debugging this, so here is the content of the log file:

ddcutil-service-Message: 21:59:47.368: Running ddcutil-service (ddcutil-service)
ddcutil-service-Message: 21:59:47.369: ddcutil-service 1.0.6, libddcutil 2.1.4
ddcutil-service-Message: 21:59:47.369: ServiceInfoLogging enabled
ddcutil-service-INFO: 21:59:47.369: LIBDDCUTIL_HAS_CHANGES_CALLBACK 1
ddcutil-service-INFO: 21:59:47.369: LIBDDCUTIL_HAS_OPTION_ARGUMENTS 1
ddcutil-service-INFO: 21:59:47.369: LIBDDCUTIL_HAS_INDIVIDUAL_SLEEP_MULTIPLIER 1
ddcutil-service-INFO: 21:59:47.369: LIBDDCUTIL_HAS_DYNAMIC_SLEEP_BOOLEAN 1
ddcutil-service-Message: 21:59:47.369: Calling ddca_init 9 2 ''
ddcutil-service: Initializing libddcutil.  ddcutil version: 2.1.4, shared library: /usr/lib/libddcutil.so.5.1.2
ddcutil-service: Options passed from client: 
ddcutil-service: Applying combined options: 
ddcutil-service: Library initialization complete.
ddcutil-service-Message: 21:59:48.083: Verifying libddcutil and i2c-dev dependencies (i2c-dev kernel module and device permissions)...
ddcutil-service: Display redetection starting.
ddcutil-service: Display redetection finished.
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.501: Device /dev/i2c-0 is not R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.501: Device /dev/i2c-1 is not R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.501: Device /dev/i2c-10 is R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-11 is R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-12 is R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-13 is R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-2 is not R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-3 is not R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-4 is not R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-5 is R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-6 is R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-7 is R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-8 is R/W accessible
(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-9 is R/W accessible
ddcutil-service-Message: 21:59:48.502: Found 9 i2c-dev devices that are R/W accessible - good!
ddcutil-service-Message: 21:59:48.503: ddca_is_dynamic_sleep_enabled()=enabled
ddcutil-service-Message: 21:59:48.503: ConnectedDisplaysChanged signals disabled(add --emit_connectivity_signals to enable them).
ddcutil-service-Message: 21:59:48.503: Enabling custom g_main_loop event source
ddcutil-service-Message: 21:59:48.505: Registered /com/ddcutil/DdcutilObject
ddcutil-service-Message: 21:59:48.506: Name acquired com.ddcutil.DdcutilService
ddcutil-service-Message: 21:59:48.506: Emitting ServiceInitialized signal
ddcutil-service-INFO: 21:59:50.890: Detect flags=0
ddcutil-service: Display redetection starting.
ddcutil-service: Display redetection finished.

(ddcutil-service:43790): ddcutil-service-WARNING **: 21:59:51.408: Detect failed to obtain VDU list - list-status=-3022 message=DDCRC_OTHER: Error(s) opening ddc devices
ddcutil-service-INFO: 21:59:56.733: Detect flags=1
ddcutil-service: Display redetection starting.
ddcutil-service: Display redetection finished.

(ddcutil-service:43790): ddcutil-service-WARNING **: 21:59:57.244: Detect failed to obtain VDU list - list-status=-3022 message=DDCRC_OTHER: Error(s) opening ddc devices
digitaltrails commented 3 months ago

Thanks for helping.

So far it appears something is going wrong inside libddcutil, but it could be to do with the way I'm using it.

If you setup a ~/.config/ddcutil/ddcutilrc we can try to get some clues. Then I can poke around inside libddcutil source. If I can't figure this out, I can forward this to @rockowitz (libddcutil developer).

You could start by creating ~/.config/ddcutil/ddcutilrc and adding these lines:

[libddcutil]
  options: --trcfunc ddc_redetect_displays --trcfunc ddc_detect_all_displays

Then restart the service, then redo the test passing 1, and see if anything gets logged.

major-mayer commented 3 months ago

All right, I created this rc file, restarted the service and repeated the second command. Here is what i get in the logs:

ddcutil-service-Message: 22:43:31.203: Running ddcutil-service (ddcutil-service)
ddcutil-service-Message: 22:43:31.203: ddcutil-service 1.0.6, libddcutil 2.1.4
ddcutil-service-Message: 22:43:31.203: ServiceInfoLogging enabled
ddcutil-service-INFO: 22:43:31.203: LIBDDCUTIL_HAS_CHANGES_CALLBACK 1
ddcutil-service-INFO: 22:43:31.203: LIBDDCUTIL_HAS_OPTION_ARGUMENTS 1
ddcutil-service-INFO: 22:43:31.203: LIBDDCUTIL_HAS_INDIVIDUAL_SLEEP_MULTIPLIER 1
ddcutil-service-INFO: 22:43:31.203: LIBDDCUTIL_HAS_DYNAMIC_SLEEP_BOOLEAN 1
ddcutil-service-Message: 22:43:31.203: Calling ddca_init 9 2 ''
ddcutil-service: Initializing libddcutil.  ddcutil version: 2.1.4, shared library: /usr/lib/libddcutil.so.5.1.2
ddcutil-service: Options passed from client: 
ddcutil-service: Using options from /home/laurenz/.config/ddcutil/ddcutilrc: --trcfunc ddc_redetect_displays --trcfunc ddc_detect_all_displays
ddcutil-service: Applying combined options: --trcfunc ddc_redetect_displays --trcfunc ddc_detect_all_displays
(ddc_detect_all_displays       ) Starting  display_caching_enabled=false, detect_usb_displays=false
(ddc_detect_all_displays       )           display_list->len=2, ddc_detect_async_threshold=3
(ddc_detect_all_displays       ) Done      Returning 0x558ccadd1390, Detected 2 valid displays
ddcutil-service: Library initialization complete.
ddcutil-service-Message: 22:43:31.627: Verifying libddcutil and i2c-dev dependencies (i2c-dev kernel module and device permissions)...
(ddc_redetect_displays         ) Starting  all_displays=0x558ccadd1390
ddcutil-service: Display redetection starting.
(ddc_detect_all_displays       ) Starting  display_caching_enabled=false, detect_usb_displays=false
(ddc_detect_all_displays       )           display_list->len=2, ddc_detect_async_threshold=3
(ddc_detect_all_displays       ) Done      Returning 0x558ccadae7f0, Detected 2 valid displays
ddcutil-service: Display redetection finished.
(ddc_redetect_displays         ) Done      all_displays=0x558ccadae7f0, all_displays->len = 2
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.986: Device /dev/i2c-0 is not R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.986: Device /dev/i2c-1 is not R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.986: Device /dev/i2c-10 is R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.986: Device /dev/i2c-11 is R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.986: Device /dev/i2c-12 is R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.986: Device /dev/i2c-13 is R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.987: Device /dev/i2c-2 is not R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.987: Device /dev/i2c-3 is not R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.987: Device /dev/i2c-4 is not R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.987: Device /dev/i2c-5 is R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.987: Device /dev/i2c-6 is R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.987: Device /dev/i2c-7 is R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.987: Device /dev/i2c-8 is R/W accessible
(ddcutil-service:55841): ddcutil-service-DEBUG: 22:43:31.987: Device /dev/i2c-9 is R/W accessible
ddcutil-service-Message: 22:43:31.987: Found 9 i2c-dev devices that are R/W accessible - good!
ddcutil-service-Message: 22:43:31.987: ddca_is_dynamic_sleep_enabled()=enabled
ddcutil-service-Message: 22:43:31.987: ConnectedDisplaysChanged signals disabled(add --emit_connectivity_signals to enable them).
ddcutil-service-Message: 22:43:31.987: Enabling custom g_main_loop event source
ddcutil-service-Message: 22:43:31.988: Registered /com/ddcutil/DdcutilObject
ddcutil-service-Message: 22:43:31.988: Name acquired com.ddcutil.DdcutilService
ddcutil-service-Message: 22:43:31.988: Emitting ServiceInitialized signal
ddcutil-service-INFO: 22:43:34.406: Detect flags=1
(ddc_redetect_displays         ) Starting  all_displays=0x558ccadae7f0
ddcutil-service: Display redetection starting.
(ddc_detect_all_displays       ) Starting  display_caching_enabled=false, detect_usb_displays=false
(ddc_detect_all_displays       )           display_list->len=2, ddc_detect_async_threshold=3
(ddc_detect_all_displays       ) Done      Returning 0x558ccadcd430, Detected 2 valid displays
ddcutil-service: Display redetection finished.
(ddc_redetect_displays         ) Done      all_displays=0x558ccadcd430, all_displays->len = 2

(ddcutil-service:55841): ddcutil-service-WARNING **: 22:43:34.768: Detect failed to obtain VDU list - list-status=-3022 message=DDCRC_OTHER: Error(s) opening ddc devices
digitaltrails commented 3 months ago

Interesting, so the detect worked. Looking at the code, the next step where the list of displays is retrieved may be erroring. Please can you append a new trace:

[libddcutil]
  options: --trcfunc ddc_redetect_displays --trcfunc ddc_detect_all_displays  --trcfunc ddca_get_display_info_list2
major-mayer commented 3 months ago

There you go:

ddcutil-service-Message: 00:06:16.364: Running ddcutil-service (ddcutil-service)
ddcutil-service-Message: 00:06:16.364: ddcutil-service 1.0.6, libddcutil 2.1.4
ddcutil-service-Message: 00:06:16.364: ServiceInfoLogging enabled
ddcutil-service-INFO: 00:06:16.364: LIBDDCUTIL_HAS_CHANGES_CALLBACK 1
ddcutil-service-INFO: 00:06:16.364: LIBDDCUTIL_HAS_OPTION_ARGUMENTS 1
ddcutil-service-INFO: 00:06:16.364: LIBDDCUTIL_HAS_INDIVIDUAL_SLEEP_MULTIPLIER 1
ddcutil-service-INFO: 00:06:16.364: LIBDDCUTIL_HAS_DYNAMIC_SLEEP_BOOLEAN 1
ddcutil-service-Message: 00:06:16.364: Calling ddca_init 9 2 ''
ddcutil-service: Initializing libddcutil.  ddcutil version: 2.1.4, shared library: /usr/lib/libddcutil.so.5.1.2
ddcutil-service: Options passed from client: 
ddcutil-service: Using options from /home/laurenz/.config/ddcutil/ddcutilrc: --trcfunc ddc_redetect_displays --trcfunc ddc_detect_all_displays  --trcfunc ddca_get_display_info_list2
ddcutil-service: Applying combined options: --trcfunc ddc_redetect_displays --trcfunc ddc_detect_all_displays --trcfunc ddca_get_display_info_list2
(ddc_detect_all_displays       ) Starting  display_caching_enabled=false, detect_usb_displays=false
(ddc_detect_all_displays       )           display_list->len=2, ddc_detect_async_threshold=3
(ddc_detect_all_displays       ) Done      Returning 0x55ad2d3f04a0, Detected 2 valid displays
ddcutil-service: Library initialization complete.
ddcutil-service-Message: 00:06:16.937: Verifying libddcutil and i2c-dev dependencies (i2c-dev kernel module and device permissions)...
(ddc_redetect_displays         ) Starting  all_displays=0x55ad2d3f04a0
ddcutil-service: Display redetection starting.
(ddc_detect_all_displays       ) Starting  display_caching_enabled=false, detect_usb_displays=false
(ddc_detect_all_displays       )           display_list->len=2, ddc_detect_async_threshold=3
(ddc_detect_all_displays       ) Done      Returning 0x55ad2d3cd950, Detected 2 valid displays
ddcutil-service: Display redetection finished.
(ddc_redetect_displays         ) Done      all_displays=0x55ad2d3cd950, all_displays->len = 2
(ddca_get_display_info_list2   ) Starting  
(ddca_get_display_info_list2   ) Final result list 0x55ad2d3e5cb0
      Found 2 displays
         Display number:  1
            I2C bus:              /dev/i2c-10
            Mfg Id:               ACR
            Model:                Acer S222HQL
            Product code:         516
            Serial number:        LR0080194201
            Binary serial number: 352827935 (0x1507ba1f)
            EDID:
                       +0          +4          +8          +c            0   4   8   c   
               +0000   00 ff ff ff ff ff ff 00 04 72 04 02 1f ba 07 15   .........r......
               +0010   32 15 01 03 80 30 1b 78 2e c5 85 a4 59 49 9a 24   2....0.x....YI.$
               +0020   12 50 54 bf ef 80 81 c0 81 40 71 4f 81 80 81 00   .PT......@qO....
               +0030   d1 c0 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c   .......:..q8-@X,
               +0040   45 00 dd 0c 11 00 00 1e 00 00 00 fd 00 32 4b 1e   E............2K.
               +0050   50 10 00 0a 20 20 20 20 20 20 00 00 00 ff 00 4c   P...      .....L
               +0060   52 30 30 38 30 31 39 34 32 30 31 0a 00 00 00 fc   R0080194201.....
               +0070   00 41 63 65 72 20 53 32 32 32 48 51 4c 0a 01 31   .Acer S222HQL..1
            VCP Version:          2.1
            dref:                Display_Ref[bus /dev/i2c-10]
            VCP Version (dref xdf): 2.1
         Display number:  2
            I2C bus:              /dev/i2c-12
            Mfg Id:               PHL
            Model:                PHL 326M6V
            Product code:         49555
            Serial number:        
            Binary serial number: 354 (0x00000162)
            EDID:
                       +0          +4          +8          +c            0   4   8   c   
               +0000   00 ff ff ff ff ff ff 00 41 0c 93 c1 62 01 00 00   ........A...b...
               +0010   0e 1d 01 04 b5 46 27 78 3b 59 05 af 4f 42 af 27   .....F'x;Y..OB.'
               +0020   0e 50 54 bf ef 00 d1 c0 b3 00 95 00 81 80 81 40   .PT............@
               +0030   81 c0 01 01 01 01 4d d0 00 a0 f0 70 3e 80 30 20   ......M....p>.0 
               +0040   35 00 ba 8e 21 00 00 1a 56 5e 00 a0 a0 a0 29 50   5...!...V^....)P
               +0050   30 20 35 00 ba 8e 21 00 00 1a 00 00 00 fc 00 50   0 5...!........P
               +0060   48 4c 20 33 32 36 4d 36 56 0a 20 20 00 00 00 fd   HL 326M6V.  ....
               +0070   00 28 3c a0 a0 3c 01 0a 20 20 20 20 20 20 01 ea   .(<..<..      ..
            VCP Version:          3.0
            dref:                Display_Ref[bus /dev/i2c-12]
            VCP Version (dref xdf): 3.0
(ddca_get_display_info_list2   ) Done      Returning: DDCRC_OTHER(-3022). Returned list has 2 displays
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-0 is not R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-1 is not R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-10 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-11 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-12 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-13 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-2 is not R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-3 is not R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-4 is not R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-5 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-6 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-7 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-8 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-9 is R/W accessible
ddcutil-service-Message: 00:06:17.598: Found 9 i2c-dev devices that are R/W accessible - good!
ddcutil-service-Message: 00:06:17.598: ddca_is_dynamic_sleep_enabled()=enabled
ddcutil-service-Message: 00:06:17.599: ConnectedDisplaysChanged signals disabled(add --emit_connectivity_signals to enable them).
ddcutil-service-Message: 00:06:17.600: Enabling custom g_main_loop event source
ddcutil-service-Message: 00:06:17.602: Registered /com/ddcutil/DdcutilObject
ddcutil-service-Message: 00:06:17.604: Name acquired com.ddcutil.DdcutilService
ddcutil-service-Message: 00:06:17.604: Emitting ServiceInitialized signal
ddcutil-service-INFO: 00:06:26.650: Detect flags=1
(ddc_redetect_displays         ) Starting  all_displays=0x55ad2d3cd950
ddcutil-service: Display redetection starting.
(ddc_detect_all_displays       ) Starting  display_caching_enabled=false, detect_usb_displays=false
(ddc_detect_all_displays       )           display_list->len=2, ddc_detect_async_threshold=3
(ddc_detect_all_displays       ) Done      Returning 0x55ad2d3ea0f0, Detected 2 valid displays
ddcutil-service: Display redetection finished.
(ddc_redetect_displays         ) Done      all_displays=0x55ad2d3ea0f0, all_displays->len = 2
(ddca_get_display_info_list2   ) Starting  
(ddca_get_display_info_list2   ) Final result list 0x55ad2d3db3d0
      Found 2 displays
         Display number:  1
            I2C bus:              /dev/i2c-10
            Mfg Id:               ACR
            Model:                Acer S222HQL
            Product code:         516
            Serial number:        LR0080194201
            Binary serial number: 352827935 (0x1507ba1f)
            EDID:
                       +0          +4          +8          +c            0   4   8   c   
               +0000   00 ff ff ff ff ff ff 00 04 72 04 02 1f ba 07 15   .........r......
               +0010   32 15 01 03 80 30 1b 78 2e c5 85 a4 59 49 9a 24   2....0.x....YI.$
               +0020   12 50 54 bf ef 80 81 c0 81 40 71 4f 81 80 81 00   .PT......@qO....
               +0030   d1 c0 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c   .......:..q8-@X,
               +0040   45 00 dd 0c 11 00 00 1e 00 00 00 fd 00 32 4b 1e   E............2K.
               +0050   50 10 00 0a 20 20 20 20 20 20 00 00 00 ff 00 4c   P...      .....L
               +0060   52 30 30 38 30 31 39 34 32 30 31 0a 00 00 00 fc   R0080194201.....
               +0070   00 41 63 65 72 20 53 32 32 32 48 51 4c 0a 01 31   .Acer S222HQL..1
            VCP Version:          2.1
            dref:                Display_Ref[bus /dev/i2c-10]
            VCP Version (dref xdf): 2.1
         Display number:  2
            I2C bus:              /dev/i2c-12
            Mfg Id:               PHL
            Model:                PHL 326M6V
            Product code:         49555
            Serial number:        
            Binary serial number: 354 (0x00000162)
            EDID:
                       +0          +4          +8          +c            0   4   8   c   
               +0000   00 ff ff ff ff ff ff 00 41 0c 93 c1 62 01 00 00   ........A...b...
               +0010   0e 1d 01 04 b5 46 27 78 3b 59 05 af 4f 42 af 27   .....F'x;Y..OB.'
               +0020   0e 50 54 bf ef 00 d1 c0 b3 00 95 00 81 80 81 40   .PT............@
               +0030   81 c0 01 01 01 01 4d d0 00 a0 f0 70 3e 80 30 20   ......M....p>.0 
               +0040   35 00 ba 8e 21 00 00 1a 56 5e 00 a0 a0 a0 29 50   5...!...V^....)P
               +0050   30 20 35 00 ba 8e 21 00 00 1a 00 00 00 fc 00 50   0 5...!........P
               +0060   48 4c 20 33 32 36 4d 36 56 0a 20 20 00 00 00 fd   HL 326M6V.  ....
               +0070   00 28 3c a0 a0 3c 01 0a 20 20 20 20 20 20 01 ea   .(<..<..      ..
            VCP Version:          3.0
            dref:                Display_Ref[bus /dev/i2c-12]
            VCP Version (dref xdf): 3.0
(ddca_get_display_info_list2   ) Done      Returning: DDCRC_OTHER(-3022). Returned list has 2 displays

(ddcutil-service:94999): ddcutil-service-WARNING **: 00:06:27.108: Detect failed to obtain VDU list - list-status=-3022 message=DDCRC_OTHER: Error(s) opening ddc devices
digitaltrails commented 3 months ago

Thanks. It almost looks like I should ignore DDCRC_OTHER. Maybe in this case it's not an error. I'll take a closer look at the code. If you're comfortable with building ddcutil-service, maybe I'll have you try an experiment with some modified code. Probably in a hour or two (got other things to do just now).

digitaltrails commented 3 months ago

I've pushed a cleanup of "Detect" that also includes changing DDCRC_OTHER to DDCRC_OK when retrieving the display list. The "Detect" code was due for a cleanup, it's the oldest, being one of the first to be implemented.

The code can be built and run as a normal user. Untar/unzip somewhere, make, and then run the executable ./ddcutil-service from the build directory (no need to install it). I don't think arch based distros need any special configuration.

If DDCRC_OTHER really is an error, you might get a core dump, but that might be interesting anyway.

major-mayer commented 3 months ago

Good job, the output is looking good now :partying_face:

busctl --user call com.ddcutil.DdcutilService /com/ddcutil/DdcutilObject com.ddcutil.DdcutilInterface Detect u 1    
ia(iiisssqsu)is 2 2 1 0 0 "ACR" "Acer S222HQL" "LR0080194201" 516 "AP///////wAEcgQCH7oHFTIVAQOAMBt4LsWFpFlJmiQSUFS/74CBwIFAcU+BgIEA0cABAQEBAjqAGHE4LUBYLEUA3QwRAAAeAAAA/QAySx5QEAAKICAgICAgAAAA/wBMUjAwODAxOTQyMDEKAAAA/ABBY2VyIFMyMjJIUUwKATE=" 352827935 2 0 0 "PHL" "PHL 326M6V" "" 49555 "AP///////wBBDJPBYgEAAA4dAQS1Rid4O1kFr09CrycOUFS/7wDRwLMAlQCBgIFAgcABAQEBTdAAoPBwPoAwIDUAuo4hAAAaVl4AoKCgKVAwIDUAuo4hAAAaAAAA/ABQSEwgMzI2TTZWCiAgAAAA/QAoPKCgPAEKICAgICAgAeo=" 354 0 "OK"
ddcutil-service-Message: 00:06:16.364: Running ddcutil-service (ddcutil-service)
ddcutil-service-Message: 00:06:16.364: ddcutil-service 1.0.6, libddcutil 2.1.4
ddcutil-service-Message: 00:06:16.364: ServiceInfoLogging enabled
ddcutil-service-INFO: 00:06:16.364: LIBDDCUTIL_HAS_CHANGES_CALLBACK 1
ddcutil-service-INFO: 00:06:16.364: LIBDDCUTIL_HAS_OPTION_ARGUMENTS 1
ddcutil-service-INFO: 00:06:16.364: LIBDDCUTIL_HAS_INDIVIDUAL_SLEEP_MULTIPLIER 1
ddcutil-service-INFO: 00:06:16.364: LIBDDCUTIL_HAS_DYNAMIC_SLEEP_BOOLEAN 1
ddcutil-service-Message: 00:06:16.364: Calling ddca_init 9 2 ''
ddcutil-service: Initializing libddcutil.  ddcutil version: 2.1.4, shared library: /usr/lib/libddcutil.so.5.1.2
ddcutil-service: Options passed from client: 
ddcutil-service: Using options from /home/laurenz/.config/ddcutil/ddcutilrc: --trcfunc ddc_redetect_displays --trcfunc ddc_detect_all_displays  --trcfunc ddca_get_display_info_list2
ddcutil-service: Applying combined options: --trcfunc ddc_redetect_displays --trcfunc ddc_detect_all_displays --trcfunc ddca_get_display_info_list2
(ddc_detect_all_displays       ) Starting  display_caching_enabled=false, detect_usb_displays=false
(ddc_detect_all_displays       )           display_list->len=2, ddc_detect_async_threshold=3
(ddc_detect_all_displays       ) Done      Returning 0x55ad2d3f04a0, Detected 2 valid displays
ddcutil-service: Library initialization complete.
ddcutil-service-Message: 00:06:16.937: Verifying libddcutil and i2c-dev dependencies (i2c-dev kernel module and device permissions)...
(ddc_redetect_displays         ) Starting  all_displays=0x55ad2d3f04a0
ddcutil-service: Display redetection starting.
(ddc_detect_all_displays       ) Starting  display_caching_enabled=false, detect_usb_displays=false
(ddc_detect_all_displays       )           display_list->len=2, ddc_detect_async_threshold=3
(ddc_detect_all_displays       ) Done      Returning 0x55ad2d3cd950, Detected 2 valid displays
ddcutil-service: Display redetection finished.
(ddc_redetect_displays         ) Done      all_displays=0x55ad2d3cd950, all_displays->len = 2
(ddca_get_display_info_list2   ) Starting  
(ddca_get_display_info_list2   ) Final result list 0x55ad2d3e5cb0
      Found 2 displays
         Display number:  1
            I2C bus:              /dev/i2c-10
            Mfg Id:               ACR
            Model:                Acer S222HQL
            Product code:         516
            Serial number:        LR0080194201
            Binary serial number: 352827935 (0x1507ba1f)
            EDID:
                       +0          +4          +8          +c            0   4   8   c   
               +0000   00 ff ff ff ff ff ff 00 04 72 04 02 1f ba 07 15   .........r......
               +0010   32 15 01 03 80 30 1b 78 2e c5 85 a4 59 49 9a 24   2....0.x....YI.$
               +0020   12 50 54 bf ef 80 81 c0 81 40 71 4f 81 80 81 00   .PT......@qO....
               +0030   d1 c0 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c   .......:..q8-@X,
               +0040   45 00 dd 0c 11 00 00 1e 00 00 00 fd 00 32 4b 1e   E............2K.
               +0050   50 10 00 0a 20 20 20 20 20 20 00 00 00 ff 00 4c   P...      .....L
               +0060   52 30 30 38 30 31 39 34 32 30 31 0a 00 00 00 fc   R0080194201.....
               +0070   00 41 63 65 72 20 53 32 32 32 48 51 4c 0a 01 31   .Acer S222HQL..1
            VCP Version:          2.1
            dref:                Display_Ref[bus /dev/i2c-10]
            VCP Version (dref xdf): 2.1
         Display number:  2
            I2C bus:              /dev/i2c-12
            Mfg Id:               PHL
            Model:                PHL 326M6V
            Product code:         49555
            Serial number:        
            Binary serial number: 354 (0x00000162)
            EDID:
                       +0          +4          +8          +c            0   4   8   c   
               +0000   00 ff ff ff ff ff ff 00 41 0c 93 c1 62 01 00 00   ........A...b...
               +0010   0e 1d 01 04 b5 46 27 78 3b 59 05 af 4f 42 af 27   .....F'x;Y..OB.'
               +0020   0e 50 54 bf ef 00 d1 c0 b3 00 95 00 81 80 81 40   .PT............@
               +0030   81 c0 01 01 01 01 4d d0 00 a0 f0 70 3e 80 30 20   ......M....p>.0 
               +0040   35 00 ba 8e 21 00 00 1a 56 5e 00 a0 a0 a0 29 50   5...!...V^....)P
               +0050   30 20 35 00 ba 8e 21 00 00 1a 00 00 00 fc 00 50   0 5...!........P
               +0060   48 4c 20 33 32 36 4d 36 56 0a 20 20 00 00 00 fd   HL 326M6V.  ....
               +0070   00 28 3c a0 a0 3c 01 0a 20 20 20 20 20 20 01 ea   .(<..<..      ..
            VCP Version:          3.0
            dref:                Display_Ref[bus /dev/i2c-12]
            VCP Version (dref xdf): 3.0
(ddca_get_display_info_list2   ) Done      Returning: DDCRC_OTHER(-3022). Returned list has 2 displays
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-0 is not R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-1 is not R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-10 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-11 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-12 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-13 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-2 is not R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-3 is not R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-4 is not R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-5 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-6 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-7 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-8 is R/W accessible
(ddcutil-service:94999): ddcutil-service-DEBUG: 00:06:17.598: Device /dev/i2c-9 is R/W accessible
ddcutil-service-Message: 00:06:17.598: Found 9 i2c-dev devices that are R/W accessible - good!
ddcutil-service-Message: 00:06:17.598: ddca_is_dynamic_sleep_enabled()=enabled
ddcutil-service-Message: 00:06:17.599: ConnectedDisplaysChanged signals disabled(add --emit_connectivity_signals to enable them).
ddcutil-service-Message: 00:06:17.600: Enabling custom g_main_loop event source
ddcutil-service-Message: 00:06:17.602: Registered /com/ddcutil/DdcutilObject
ddcutil-service-Message: 00:06:17.604: Name acquired com.ddcutil.DdcutilService
ddcutil-service-Message: 00:06:17.604: Emitting ServiceInitialized signal
ddcutil-service-INFO: 00:06:26.650: Detect flags=1
(ddc_redetect_displays         ) Starting  all_displays=0x55ad2d3cd950
ddcutil-service: Display redetection starting.
(ddc_detect_all_displays       ) Starting  display_caching_enabled=false, detect_usb_displays=false
(ddc_detect_all_displays       )           display_list->len=2, ddc_detect_async_threshold=3
(ddc_detect_all_displays       ) Done      Returning 0x55ad2d3ea0f0, Detected 2 valid displays
ddcutil-service: Display redetection finished.
(ddc_redetect_displays         ) Done      all_displays=0x55ad2d3ea0f0, all_displays->len = 2
(ddca_get_display_info_list2   ) Starting  
(ddca_get_display_info_list2   ) Final result list 0x55ad2d3db3d0
      Found 2 displays
         Display number:  1
            I2C bus:              /dev/i2c-10
            Mfg Id:               ACR
            Model:                Acer S222HQL
            Product code:         516
            Serial number:        LR0080194201
            Binary serial number: 352827935 (0x1507ba1f)
            EDID:
                       +0          +4          +8          +c            0   4   8   c   
               +0000   00 ff ff ff ff ff ff 00 04 72 04 02 1f ba 07 15   .........r......
               +0010   32 15 01 03 80 30 1b 78 2e c5 85 a4 59 49 9a 24   2....0.x....YI.$
               +0020   12 50 54 bf ef 80 81 c0 81 40 71 4f 81 80 81 00   .PT......@qO....
               +0030   d1 c0 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c   .......:..q8-@X,
               +0040   45 00 dd 0c 11 00 00 1e 00 00 00 fd 00 32 4b 1e   E............2K.
               +0050   50 10 00 0a 20 20 20 20 20 20 00 00 00 ff 00 4c   P...      .....L
               +0060   52 30 30 38 30 31 39 34 32 30 31 0a 00 00 00 fc   R0080194201.....
               +0070   00 41 63 65 72 20 53 32 32 32 48 51 4c 0a 01 31   .Acer S222HQL..1
            VCP Version:          2.1
            dref:                Display_Ref[bus /dev/i2c-10]
            VCP Version (dref xdf): 2.1
         Display number:  2
            I2C bus:              /dev/i2c-12
            Mfg Id:               PHL
            Model:                PHL 326M6V
            Product code:         49555
            Serial number:        
            Binary serial number: 354 (0x00000162)
            EDID:
                       +0          +4          +8          +c            0   4   8   c   
               +0000   00 ff ff ff ff ff ff 00 41 0c 93 c1 62 01 00 00   ........A...b...
               +0010   0e 1d 01 04 b5 46 27 78 3b 59 05 af 4f 42 af 27   .....F'x;Y..OB.'
               +0020   0e 50 54 bf ef 00 d1 c0 b3 00 95 00 81 80 81 40   .PT............@
               +0030   81 c0 01 01 01 01 4d d0 00 a0 f0 70 3e 80 30 20   ......M....p>.0 
               +0040   35 00 ba 8e 21 00 00 1a 56 5e 00 a0 a0 a0 29 50   5...!...V^....)P
               +0050   30 20 35 00 ba 8e 21 00 00 1a 00 00 00 fc 00 50   0 5...!........P
               +0060   48 4c 20 33 32 36 4d 36 56 0a 20 20 00 00 00 fd   HL 326M6V.  ....
               +0070   00 28 3c a0 a0 3c 01 0a 20 20 20 20 20 20 01 ea   .(<..<..      ..
            VCP Version:          3.0
            dref:                Display_Ref[bus /dev/i2c-12]
            VCP Version (dref xdf): 3.0
(ddca_get_display_info_list2   ) Done      Returning: DDCRC_OTHER(-3022). Returned list has 2 displays

(ddcutil-service:94999): ddcutil-service-WARNING **: 00:06:27.108: Detect failed to obtain VDU list - list-status=-3022 message=DDCRC_OTHER: Error(s) opening ddc devices
major-mayer commented 3 months ago

I guess vdu_control needs to be adjusted as well? Because there, i still get this error when activating the dbus client

D-Bus  status=-3022: DDCRC_OTHER: Error(s) opening ddc devices
digitaltrails commented 3 months ago

I think you might be connecting to the older executable. The quoted output is reporting that it is version 1.0.6:

ddcutil-service-Message: 00:06:16.364: ddcutil-service 1.0.6, libddcutil 2.1.4

For testing, what I do is start a new shell window and use it to:

cd ddcuitl-service-build-directory
killall ddcutil-service
./ddcutil-service --log-info

Which should report that it is version 1.0.7:

ddcutil-service-Message: 06:52:38.698: Running /home/michael/Projects/ddcutil-service/ddcutil-service (ddcutil-service)
ddcutil-service-Message: 06:52:38.698: ddcutil-service 1.0.7, libddcutil 2.1.5-dev
ddcutil-service-Message: 06:52:38.698: ServiceInfoLogging enabled

Sometimes, if something contacts the service before I can start a new one, then I will see:

(ddcutil-service:5407): ddcutil-service-CRITICAL **: 06:52:39.894: Exiting: lost registration - is another instance already registered?
ddcutil-service: libddcutil terminating.

In which case I just do the killall ddcutil-service and start the executable again.

Once the service is running, restart vdu_controls and use its menu to bring up About, the bottom line of the about should report the service version:

ddcutil-interface 1.0.7 (D-Bus ddcutil-service - libddcutil);...

Hopefully that might sort things out. If it works, you can either replace the arch executable with this new one, or follow the steps in the readme to setup an alternative one for your user only, then that should make the dbus-daemon/debus-broker pick up v1.0.7.

digitaltrails commented 3 months ago

I just pushed a more comprehensive fix to cover off other places in the service that might be prone to the same return code. That might also be a cause of issues with vdu_controls.

digitaltrails commented 3 months ago

Note to self: If this pans out:

  1. I need to contact the author(s) of KDE6 PowerDevil, which also uses libddcutil, and check that they are aware of this return code (if not, it may be causing some issues in KDE6).

  2. Raise an issue for libddcutil. The behaviour is not documented and probably a bug related to testing permissions on bus devices (perhaps because only some are accessible).

digitaltrails commented 3 months ago

More notes: After looking around the source for libddcutil, I think it may return DDCRC_OTHER if any i2c devices are not R/W, which might be the case if there are non-display i2c devices present. That might explain why this is only happening in this case (and perhaps other lurkers may have the same problem, but just gave up).

(ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.501: Device /dev/i2c-0 is not R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.501: Device /dev/i2c-1 is not R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.501: Device /dev/i2c-10 is R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-11 is R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-12 is R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-13 is R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-2 is not R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-3 is not R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-4 is not R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-5 is R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-6 is R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-7 is R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-8 is R/W accessible (ddcutil-service:43790): ddcutil-service-DEBUG: 21:59:48.502: Device /dev/i2c-9 is R/W accessible

Specifically: ddcutil source code src/libmain/api_displays.c ddca_get_display_info_list2() calls ddcrc = set_ddca_error_detail_from_open_errors(). If there are errors, the sub-function defaults the error code to DDCRC_OTHER. It should probably ignore i2c open failures if some VDUs were successfully opened. If this is the case, the latest service changes should be OK.

major-mayer commented 3 months ago

I think you might be connecting to the older executable. The quoted output is reporting that it is version 1.0.6: Yeah, you were right about that.

I rebuilt the service with your newest commits and copied the executable to /usr/bin/ddcutil-service and now it's working great with vdu_control :) Really impressive how fast this changes the brightness when you modify the lux slider.

Great job and thank you so much for putting so much work into this project. This should be included by default in Gnome/ KDE.

digitaltrails commented 3 months ago

I rebuilt the service with your newest commits and copied the executable to /usr/bin/ddcutil-service and now it's working great with vdu_control :) Really impressive how fast this changes the brightness when you modify the lux slider.

Thanks for testing this. I suspect this issue might be trip up quite a few potential users. I will create an official release as soon as possible. New releases usually appear in the AUR quite soon after. I'll see if @sanford has any comments, but otherwise I go ahead sometime today (NZ time).

Great job and thank you so much for putting so much work into this project. This should be included by default in Gnome/ KDE.

Thanks. It's quite surprising how complex vdu_controls and ddcutil-service have become. I had no idea buying a new monitor (4K with a modern bright backlight) would drive me down this path.

Given vdu_controls is Qt and not "pure" Gnome or KDE, I don't think there's much chance of it becoming included in either. The KDE PowerDevil developers are aware of my efforts and may borrow/copy/learn from them. I guess either could use ddcutil-service (the KDE developers briefly discussed the possibility). There's more chance both may be independently included in distributions, I had little trouble (much help in fact) getting it into Tumbleweed.

major-mayer commented 3 months ago

Yeah it would be a great first step if the Service and maybe also the Qt App gets included in the official repos of some major distros. I agree that it might not be suitable for a direct adoption to gnome /KDE, although I would love to see something like this being more integrated into the DEs (mid to long term).

And funny that you mention it, I also had the need to adjust might brightness after buying a new 4k screen. With my old screen I always had the brightness at around 100%, but now they can get crazy bright.