Skip to content

Cannot get display based on i2c bus number #625

Description

@mikecflood

Last known version this worked on is 2.2.5. Fails when compiled with 2.2.6, 2.2.7 or 2.2.8-dev. I get the following run time error message:

DDC_DISPLAY ddca_get_display_ref() returned -3020 (DDCRC_INVALID_DISPLAY): invalid display

build command:

autoreconf --force --install
./configure --enable-install-lib-only --enable-static
make

code I am running:

std::string name_ = "DDC_DISPLAY";
int bus_ = 2;
DDCA_Display_Handle dh_ = nullptr;

void open_display()
{
    DDCA_Status rc = DDCRC_OK;
    DDCA_Display_Identifier did = nullptr;
    DDCA_Display_Ref dref = nullptr;

    rc = ddca_init2("", DDCA_SYSLOG_ERROR, DDCA_INIT_OPTIONS_CLIENT_OPENED_SYSLOG, nullptr);
    if (rc != DDCRC_OK)
    {
        log_ddcutil_error("ddca_init2", rc);
        return;
    }

    ddca_reset_stats();

    rc = ddca_create_busno_display_identifier(bus_, &did);
    if (rc != DDCRC_OK)
    {
        log_ddcutil_error("ddca_create_busno_display_identifier", rc);
        return;
    }

    rc = ddca_get_display_ref(did, &dref);
    ddca_free_display_identifier(did);
    if (rc != DDCRC_OK)
    {
        log_ddcutil_error("ddca_get_display_ref", rc);
        return;
    }

    rc = ddca_open_display2(dref, false, &dh_);
    if (rc != 0)
    {
        log_ddcutil_error("ddca_open_display2", rc);
        return;
    }
}

void DDC::log_ddcutil_error
(
    const std::string& a_func,
    const DDCA_Status a_error_code,
    const DDCA_Vcp_Feature_Code feature_code
)
{
    qWarning().noquote().nospace()
        << name_
        << " " << a_func << "()"
        << " returned " << a_error_code
        << " (" << ddca_rc_name(a_error_code) << "): "
        << ddca_rc_desc(a_error_code)
        << " dh=" << ddca_dh_repr(dh_)
        << ", feature_code=" << feature_code
        << " - " << ddca_get_feature_name(feature_code);
}

I also tried using ddca_get_display_info_list2, but it too fails to find the display.

output: DDC_DISPLAY failed to find display bus: 2

This is the code using ddca_get_display_info_list2:

std::string name_ = "DDC_DISPLAY";
int bus_ = 2;
DDCA_Display_Handle dh_ = nullptr;

void open_display()
{
    DDCA_Status rc = DDCRC_OK;
    DDCA_Display_Identifier did = nullptr;
    DDCA_Display_Ref dref = nullptr;

    rc = ddca_init2("", DDCA_SYSLOG_ERROR, DDCA_INIT_OPTIONS_CLIENT_OPENED_SYSLOG, nullptr);
    if (rc != DDCRC_OK)
    {
        log_ddcutil_error("ddca_init2", rc);
        return;
    }

    ddca_reset_stats();

    ddca_get_display_info_list2(false, &disp_list);
    if (disp_list && disp_list->ct > 0)
    {
        for (int i=0; i < disp_list->ct; i++)
        {
            if (disp_list->info[i].path.path.i2c_busno == bus_)
            {
                dref = disp_list->info[i].dref;
                display_found = true;
                break;
            }
        }
    }

    if (disp_list)
    {
        ddca_free_display_info_list(disp_list);
    }

    if (!display_found)
    {
        std::cout << name_ << "failed to find display bus: " << bus_);
        return;
    }

    rc = ddca_open_display2(dref, false, &dh_);
    if (rc != 0)
    {
        log_ddcutil_error("ddca_open_display2", rc);
        return;
    }
}

void DDC::log_ddcutil_error
(
    const std::string& a_func,
    const DDCA_Status a_error_code,
    const DDCA_Vcp_Feature_Code feature_code
)
{
    std::cout
        << name_
        << " " << a_func << "()"
        << " returned " << a_error_code
        << " (" << ddca_rc_name(a_error_code) << "): "
        << ddca_rc_desc(a_error_code)
        << " dh=" << ddca_dh_repr(dh_)
        << ", feature_code=" << feature_code
        << " - " << ddca_get_feature_name(feature_code);
}

Build env:

libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'config'.
libtoolize: copying file 'config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:116: installing 'config/ar-lib'
configure.ac:36: installing 'config/compile'
configure.ac:131: installing 'config/config.guess'
configure.ac:131: installing 'config/config.sub'
configure.ac:108: installing 'config/install-sh'
configure.ac:108: installing 'config/missing'
src/app_ddcutil/Makefile.am: installing 'config/depcomp'
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C23 features... none needed
checking whether gcc understands -c and -o together... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
configure: debug messages disabled
checking for a BSD-compatible install... /usr/bin/install -c
checking whether sleep supports fractional seconds... yes
checking filesystem timestamp resolution... 0.01
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/sbin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking whether make supports nested variables... yes
checking xargs -n works... yes
checking whether UID '0' is supported by ustar format... yes
checking whether GID '0' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking for pkg-config... /usr/sbin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for gcc... (cached) gcc
checking whether the compiler supports GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to enable C23 features... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/sbin/sed
checking for grep that handles long lines and -e... /usr/sbin/grep
checking for egrep... /usr/sbin/grep -E
checking for fgrep... /usr/sbin/grep -F
checking for ld used by gcc... /usr/aarch64-unknown-linux-gnu/bin/ld
checking if the linker (/usr/aarch64-unknown-linux-gnu/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/sbin/nm -B
checking the name lister (/usr/sbin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert aarch64-unknown-linux-gnu file names to aarch64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert aarch64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/aarch64-unknown-linux-gnu/bin/ld option to reload object files... -r
checking for file... file
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ranlib... ranlib
checking for archiver @FILE support... @
checking for strip... strip
checking command to parse /usr/sbin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/sbin/dd
checking how to truncate binary pipes... /usr/sbin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/aarch64-unknown-linux-gnu/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: Checking configure command options... 
configure: lib...              enabled 
configure: install_lib_only... enabled 
configure: build-timestamp...  enabled 
configure: envcmds...          enabled (provisional)   
configure: usb...              enabled (provisional)   
configure: systemd...           enabled (provisional)   
configure: dbus...              enabled (provisional)   
configure: drm...              enabled (provisional)   
configure: watch-displays...   enabled (provisional)   
configure: x11...              enabled (provisional)   
configure: static_functions_visible... disabled 
configure: asan...             disabled 
configure: doxygen...          disabled 
configure: Resolving options... 
configure: --enable-install-lib-only forces --disable-envcmds 
configure: targetbsd...        disabled 
configure: envcmds...          disabled 
configure: udev...             enabled 
configure: usb...              enabled  
configure: x11...              enabled  
configure: testcases...        disabled 
configure: callgraph...        disabled 
configure: failsim...          disabled 
configure: force-suse...       disabled 
checking for _Bool... yes
checking for stdbool.h that conforms to C99 or later... yes
checking for inline... inline
checking whether byte ordering is bigendian... no
checking for size_t... yes
checking for ssize_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint8_t... yes
checking whether malloc (0) returns nonnull... yes
checking whether realloc (0, 0) returns nonnull... yes
checking for gcc options to detect undeclared functions... none needed
checking for gcc options to ignore future-version functions... none needed
checking whether strerror_r is declared... yes
checking whether strerror_r returns char *... yes
checking for clock_gettime... yes
checking for memset... yes
checking for nl_langinfo... yes
checking for stpcpy... yes
checking for strchr... yes
checking for strdup... yes
checking for strerror... yes
checking for strrchr... yes
checking for strtol... yes
checking for library containing dlopen... none required
checking for fcntl.h... yes
checking for langinfo.h... yes
checking for libintl.h... yes
checking for limits.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for sys/ioctl.h... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking for wchar.h... (cached) yes
checking for dlfcn.h... (cached) yes
checking for execinfo.h... yes
checking for glib-2.0 >= 2.40... yes
checking for jansson >= 2.0... yes
checking for libacl... yes
checking for library containing __atomic_store_8... none required
checking for libudev... yes
checking for libusb-1.0 >= 1.0.15... yes
checking for libsystemd... yes
configure: systemd...             enabled  
checking for dbus-1... yes
configure: dbus...             enabled  
checking for libdrm >= 2.4.67... yes
configure: drm...             enabled  
configure: watch displays..   enabled  
checking for x11... yes
checking for xrandr... yes
checking for xext... yes
configure: x11...             enabled  
configure: doxygen disabled, not checking for Doxygen
configure: USE_DOXYGEN not set
checking for install-docs... no
configure: WARNING: doc-base not installed - continuing without doc-base support
checking for zlib... yes
checking target OS using /etc/os-release ... target is not SUSE  
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/util/Makefile
config.status: creating src/usb_util/Makefile
config.status: creating src/base/Makefile
config.status: creating src/vcp/Makefile
config.status: creating src/dynvcp/Makefile
config.status: creating src/sysfs/Makefile
config.status: creating src/i2c/Makefile
config.status: creating src/usb/Makefile
config.status: creating src/ddc/Makefile
config.status: creating src/dw/Makefile
config.status: creating src/test/Makefile
config.status: creating src/cmdline/Makefile
config.status: creating src/app_sysenv/Makefile
config.status: creating src/app_ddcutil/Makefile
config.status: creating src/libmain/Makefile
config.status: creating src/sample_clients/Makefile
config.status: creating man/Makefile
config.status: creating data/Makefile
config.status: creating docs/Makefile
config.status: creating docs/doxygen/Makefile
config.status: creating src/public/ddcutil_macros.h
config.status: creating data/ddcutil.pc
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

	ddcutil 2.2.7
	version suffix:   
	=============

	libtool version  	10:1:5

	prefix:                 /usr/local
	exec_prefix:            ${prefix}
	libexecdir:             ${exec_prefix}/libexec
	bindir:                 ${exec_prefix}/bin
	libdir:                 ${exec_prefix}/lib
	datarootdir:            ${prefix}/share
	datadir:                ${datarootdir}
	docdir:                 ${datarootdir}/doc/${PACKAGE_TARNAME}
	mandir:               	${datarootdir}/man
	includedir:             ${prefix}/include
	pkgconfigdir:           
	required_packages:       glib-2.0 >= 2.40 jansson >= 2.0 libacl

	enable_lib:             yes
	enable_install_lib_only yes
	enable_build_timestamp  yes
	enable_envcmds          no
	enable_udev             yes
	enable_usb:             yes
	enable_drm:             yes
	enable_dbus:            yes
	enable_systemd:         yes
	enable_watch_displays:  yes
	enable_x11:             yes
	enable_asan:            no
	enable_static_functions_visible:  no

	Developer-only options:
	enable_targetbsd:       no
	enable_doxygen:         no
	enable_failsim:         no
	include_testcases:      no

	compiler:               gcc
	CFLAGS:                 -g -O2
	CPPFLAGS:               
	LDFLAGS:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions