• Hans de Goede's avatar
    drm/amd/display/amdgpu_dm: Pass proper parent for backlight device registration v3 · 62f03dad
    Hans de Goede authored
    The parent for the backlight device should be the drm-connector object,
    not the PCI device.
    
    Userspace relies on this to be able to detect which backlight class device
    to use on hybrid gfx devices where there may be multiple native (raw)
    backlight devices registered.
    
    Specifically gnome-settings-daemon expects the parent device to have
    an "enabled" sysfs attribute (as drm_connector devices do) and tests
    that this returns "enabled" when read.
    
    This aligns the parent of the backlight device with i915, nouveau, radeon.
    Note that drivers/gpu/drm/amd/amdgpu/atombios_encoders.c also already
    uses the drm_connector as parent, only amdgpu_dm.c used the PCI device
    as parent before this change.
    
    Changes in v3:
    Make amdgpu_dm_register_backlight_device() check bl_idx != 1 before
    registering the backlight since amdgpu_dm_connector_late_register()
    now calls it for _all_ connectors.
    
    Changes in v2:
    Together with changing the parent, also move the registration to
    drm_connector_funcs.late_register() this is necessary because the parent
    device (which now is the drm_connector) must be registered before
    the backlight class device is, otherwise the backlight class device ends
    up without any parent set at all.
    
    This brings the backlight class device registration timing inline with
    nouveau and i915 which also use drm_connector_funcs.late_register()
    for this.
    
    Note this slightly changes backlight_device_register() error handling,
    instead of not increasing dm->num_of_edps and re-using the current
    bl_idx for a potential other backlight device, dm->backlight_dev[bl_idx]
    is now simply left NULL on failure. This is ok because all code
    looking at dm->backlight_dev[i] also checks it is not NULL.
    
    Link: https://gitlab.gnome.org/GNOME/gnome-settings-daemon/-/issues/730Reviewed-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    62f03dad
amdgpu_dm.c 312 KB