Commit 1eb67781 authored by Hans de Goede's avatar Hans de Goede
Browse files

drm/radeon: Don't register backlight when another backlight should be used (v3)



Before this commit when we want userspace to use the acpi_video backlight
device we register both the GPU's native backlight device and acpi_video's
firmware acpi_video# backlight device. This relies on userspace preferring
firmware type backlight devices over native ones.

Registering 2 backlight devices for a single display really is
undesirable, don't register the GPU's native backlight device when
another backlight device should be used.

Changes in v2:
- To avoid linker errors when amdgpu is builtin and video_detect.c is in
  a module, select ACPI_VIDEO and its deps if ACPI is enabled.
  When ACPI is disabled, ACPI_VIDEO is also always disabled, ensuring
  the stubs from acpi/video.h will be used.

Changes in v3:
- Use drm_info(drm_dev, "...") to log messages
- ACPI_VIDEO can now be enabled on non X86 too,
  adjust the Kconfig changes to match this.

Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent da11ef83
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -248,6 +248,13 @@ config DRM_RADEON
	select HWMON
	select HWMON
	select BACKLIGHT_CLASS_DEVICE
	select BACKLIGHT_CLASS_DEVICE
	select INTERVAL_TREE
	select INTERVAL_TREE
	# radeon depends on ACPI_VIDEO when ACPI is enabled, for select to work
	# ACPI_VIDEO's dependencies must also be selected.
	select INPUT if ACPI
	select ACPI_VIDEO if ACPI
	# On x86 ACPI_VIDEO also needs ACPI_WMI
	select X86_PLATFORM_DEVICES if ACPI && X86
	select ACPI_WMI if ACPI && X86
	help
	help
	  Choose this option if you have an ATI Radeon graphics card.  There
	  Choose this option if you have an ATI Radeon graphics card.  There
	  are both PCI and AGP versions.  You don't need to choose this to
	  are both PCI and AGP versions.  You don't need to choose this to
+7 −0
Original line number Original line Diff line number Diff line
@@ -32,6 +32,8 @@
#include <drm/drm_file.h>
#include <drm/drm_file.h>
#include <drm/radeon_drm.h>
#include <drm/radeon_drm.h>


#include <acpi/video.h>

#include "atom.h"
#include "atom.h"
#include "radeon_atombios.h"
#include "radeon_atombios.h"
#include "radeon.h"
#include "radeon.h"
@@ -209,6 +211,11 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder,
	if (!(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU))
	if (!(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU))
		return;
		return;


	if (!acpi_video_backlight_use_native()) {
		drm_info(dev, "Skipping radeon atom DIG backlight registration\n");
		return;
	}

	pdata = kmalloc(sizeof(struct radeon_backlight_privdata), GFP_KERNEL);
	pdata = kmalloc(sizeof(struct radeon_backlight_privdata), GFP_KERNEL);
	if (!pdata) {
	if (!pdata) {
		DRM_ERROR("Memory allocation failed\n");
		DRM_ERROR("Memory allocation failed\n");
+7 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,8 @@
#include <drm/drm_util.h>
#include <drm/drm_util.h>
#include <drm/radeon_drm.h>
#include <drm/radeon_drm.h>


#include <acpi/video.h>

#include "radeon.h"
#include "radeon.h"
#include "radeon_asic.h"
#include "radeon_asic.h"
#include "radeon_legacy_encoders.h"
#include "radeon_legacy_encoders.h"
@@ -387,6 +389,11 @@ void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
		return;
		return;
#endif
#endif


	if (!acpi_video_backlight_use_native()) {
		drm_info(dev, "Skipping radeon legacy LVDS backlight registration\n");
		return;
	}

	pdata = kmalloc(sizeof(struct radeon_backlight_privdata), GFP_KERNEL);
	pdata = kmalloc(sizeof(struct radeon_backlight_privdata), GFP_KERNEL);
	if (!pdata) {
	if (!pdata) {
		DRM_ERROR("Memory allocation failed\n");
		DRM_ERROR("Memory allocation failed\n");