xref: /openbmc/linux/drivers/gpu/drm/i915/display/intel_acpi.c (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1df0566a6SJani Nikula // SPDX-License-Identifier: GPL-2.0
2df0566a6SJani Nikula /*
3df0566a6SJani Nikula  * Intel ACPI functions
4df0566a6SJani Nikula  *
5df0566a6SJani Nikula  * _DSM related code stolen from nouveau_acpi.c.
6df0566a6SJani Nikula  */
7df0566a6SJani Nikula 
8df0566a6SJani Nikula #include <linux/pci.h>
9df0566a6SJani Nikula #include <linux/acpi.h>
10*3c8b6a39SHans de Goede #include <acpi/video.h>
11df0566a6SJani Nikula 
12df0566a6SJani Nikula #include "i915_drv.h"
13df0566a6SJani Nikula #include "intel_acpi.h"
145fb44306SRajat Jain #include "intel_display_types.h"
15df0566a6SJani Nikula 
16df0566a6SJani Nikula #define INTEL_DSM_REVISION_ID 1 /* For Calpella anyway... */
17df0566a6SJani Nikula #define INTEL_DSM_FN_PLATFORM_MUX_INFO 1 /* No args */
18df0566a6SJani Nikula 
19df0566a6SJani Nikula static const guid_t intel_dsm_guid =
20df0566a6SJani Nikula 	GUID_INIT(0x7ed873d3, 0xc2d0, 0x4e4f,
21df0566a6SJani Nikula 		  0xa8, 0x54, 0x0f, 0x13, 0x17, 0xb0, 0x1c, 0x2c);
22df0566a6SJani Nikula 
238e55f99cSKai-Heng Feng #define INTEL_DSM_FN_GET_BIOS_DATA_FUNCS_SUPPORTED 0 /* No args */
248e55f99cSKai-Heng Feng 
258e55f99cSKai-Heng Feng static const guid_t intel_dsm_guid2 =
268e55f99cSKai-Heng Feng 	GUID_INIT(0x3e5b41c6, 0xeb1d, 0x4260,
278e55f99cSKai-Heng Feng 		  0x9d, 0x15, 0xc7, 0x1f, 0xba, 0xda, 0xe4, 0x14);
288e55f99cSKai-Heng Feng 
intel_dsm_port_name(u8 id)29df0566a6SJani Nikula static char *intel_dsm_port_name(u8 id)
30df0566a6SJani Nikula {
31df0566a6SJani Nikula 	switch (id) {
32df0566a6SJani Nikula 	case 0:
33df0566a6SJani Nikula 		return "Reserved";
34df0566a6SJani Nikula 	case 1:
35df0566a6SJani Nikula 		return "Analog VGA";
36df0566a6SJani Nikula 	case 2:
37df0566a6SJani Nikula 		return "LVDS";
38df0566a6SJani Nikula 	case 3:
39df0566a6SJani Nikula 		return "Reserved";
40df0566a6SJani Nikula 	case 4:
41df0566a6SJani Nikula 		return "HDMI/DVI_B";
42df0566a6SJani Nikula 	case 5:
43df0566a6SJani Nikula 		return "HDMI/DVI_C";
44df0566a6SJani Nikula 	case 6:
45df0566a6SJani Nikula 		return "HDMI/DVI_D";
46df0566a6SJani Nikula 	case 7:
47df0566a6SJani Nikula 		return "DisplayPort_A";
48df0566a6SJani Nikula 	case 8:
49df0566a6SJani Nikula 		return "DisplayPort_B";
50df0566a6SJani Nikula 	case 9:
51df0566a6SJani Nikula 		return "DisplayPort_C";
52df0566a6SJani Nikula 	case 0xa:
53df0566a6SJani Nikula 		return "DisplayPort_D";
54df0566a6SJani Nikula 	case 0xb:
55df0566a6SJani Nikula 	case 0xc:
56df0566a6SJani Nikula 	case 0xd:
57df0566a6SJani Nikula 		return "Reserved";
58df0566a6SJani Nikula 	case 0xe:
59df0566a6SJani Nikula 		return "WiDi";
60df0566a6SJani Nikula 	default:
61df0566a6SJani Nikula 		return "bad type";
62df0566a6SJani Nikula 	}
63df0566a6SJani Nikula }
64df0566a6SJani Nikula 
intel_dsm_mux_type(u8 type)65df0566a6SJani Nikula static char *intel_dsm_mux_type(u8 type)
66df0566a6SJani Nikula {
67df0566a6SJani Nikula 	switch (type) {
68df0566a6SJani Nikula 	case 0:
69df0566a6SJani Nikula 		return "unknown";
70df0566a6SJani Nikula 	case 1:
71df0566a6SJani Nikula 		return "No MUX, iGPU only";
72df0566a6SJani Nikula 	case 2:
73df0566a6SJani Nikula 		return "No MUX, dGPU only";
74df0566a6SJani Nikula 	case 3:
75df0566a6SJani Nikula 		return "MUXed between iGPU and dGPU";
76df0566a6SJani Nikula 	default:
77df0566a6SJani Nikula 		return "bad type";
78df0566a6SJani Nikula 	}
79df0566a6SJani Nikula }
80df0566a6SJani Nikula 
intel_dsm_platform_mux_info(acpi_handle dhandle)81df0566a6SJani Nikula static void intel_dsm_platform_mux_info(acpi_handle dhandle)
82df0566a6SJani Nikula {
83df0566a6SJani Nikula 	int i;
84df0566a6SJani Nikula 	union acpi_object *pkg, *connector_count;
85df0566a6SJani Nikula 
86df0566a6SJani Nikula 	pkg = acpi_evaluate_dsm_typed(dhandle, &intel_dsm_guid,
87df0566a6SJani Nikula 			INTEL_DSM_REVISION_ID, INTEL_DSM_FN_PLATFORM_MUX_INFO,
88df0566a6SJani Nikula 			NULL, ACPI_TYPE_PACKAGE);
89df0566a6SJani Nikula 	if (!pkg) {
90df0566a6SJani Nikula 		DRM_DEBUG_DRIVER("failed to evaluate _DSM\n");
91df0566a6SJani Nikula 		return;
92df0566a6SJani Nikula 	}
93df0566a6SJani Nikula 
94337d7a16STakashi Iwai 	if (!pkg->package.count) {
95337d7a16STakashi Iwai 		DRM_DEBUG_DRIVER("no connection in _DSM\n");
96337d7a16STakashi Iwai 		return;
97337d7a16STakashi Iwai 	}
98337d7a16STakashi Iwai 
99df0566a6SJani Nikula 	connector_count = &pkg->package.elements[0];
100df0566a6SJani Nikula 	DRM_DEBUG_DRIVER("MUX info connectors: %lld\n",
101df0566a6SJani Nikula 		  (unsigned long long)connector_count->integer.value);
102df0566a6SJani Nikula 	for (i = 1; i < pkg->package.count; i++) {
103df0566a6SJani Nikula 		union acpi_object *obj = &pkg->package.elements[i];
104337d7a16STakashi Iwai 		union acpi_object *connector_id;
105337d7a16STakashi Iwai 		union acpi_object *info;
106337d7a16STakashi Iwai 
107337d7a16STakashi Iwai 		if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count < 2) {
108337d7a16STakashi Iwai 			DRM_DEBUG_DRIVER("Invalid object for MUX #%d\n", i);
109337d7a16STakashi Iwai 			continue;
110337d7a16STakashi Iwai 		}
111337d7a16STakashi Iwai 
112337d7a16STakashi Iwai 		connector_id = &obj->package.elements[0];
113337d7a16STakashi Iwai 		info = &obj->package.elements[1];
114337d7a16STakashi Iwai 		if (info->type != ACPI_TYPE_BUFFER || info->buffer.length < 4) {
115337d7a16STakashi Iwai 			DRM_DEBUG_DRIVER("Invalid info for MUX obj #%d\n", i);
116337d7a16STakashi Iwai 			continue;
117337d7a16STakashi Iwai 		}
118337d7a16STakashi Iwai 
119df0566a6SJani Nikula 		DRM_DEBUG_DRIVER("Connector id: 0x%016llx\n",
120df0566a6SJani Nikula 			  (unsigned long long)connector_id->integer.value);
121df0566a6SJani Nikula 		DRM_DEBUG_DRIVER("  port id: %s\n",
122df0566a6SJani Nikula 		       intel_dsm_port_name(info->buffer.pointer[0]));
123df0566a6SJani Nikula 		DRM_DEBUG_DRIVER("  display mux info: %s\n",
124df0566a6SJani Nikula 		       intel_dsm_mux_type(info->buffer.pointer[1]));
125df0566a6SJani Nikula 		DRM_DEBUG_DRIVER("  aux/dc mux info: %s\n",
126df0566a6SJani Nikula 		       intel_dsm_mux_type(info->buffer.pointer[2]));
127df0566a6SJani Nikula 		DRM_DEBUG_DRIVER("  hpd mux info: %s\n",
128df0566a6SJani Nikula 		       intel_dsm_mux_type(info->buffer.pointer[3]));
129df0566a6SJani Nikula 	}
130df0566a6SJani Nikula 
131df0566a6SJani Nikula 	ACPI_FREE(pkg);
132df0566a6SJani Nikula }
133df0566a6SJani Nikula 
intel_dsm_pci_probe(struct pci_dev * pdev)134df0566a6SJani Nikula static acpi_handle intel_dsm_pci_probe(struct pci_dev *pdev)
135df0566a6SJani Nikula {
136df0566a6SJani Nikula 	acpi_handle dhandle;
137df0566a6SJani Nikula 
138df0566a6SJani Nikula 	dhandle = ACPI_HANDLE(&pdev->dev);
139df0566a6SJani Nikula 	if (!dhandle)
140df0566a6SJani Nikula 		return NULL;
141df0566a6SJani Nikula 
142df0566a6SJani Nikula 	if (!acpi_check_dsm(dhandle, &intel_dsm_guid, INTEL_DSM_REVISION_ID,
143df0566a6SJani Nikula 			    1 << INTEL_DSM_FN_PLATFORM_MUX_INFO)) {
144df0566a6SJani Nikula 		DRM_DEBUG_KMS("no _DSM method for intel device\n");
145df0566a6SJani Nikula 		return NULL;
146df0566a6SJani Nikula 	}
147df0566a6SJani Nikula 
148df0566a6SJani Nikula 	intel_dsm_platform_mux_info(dhandle);
149df0566a6SJani Nikula 
150df0566a6SJani Nikula 	return dhandle;
151df0566a6SJani Nikula }
152df0566a6SJani Nikula 
intel_dsm_detect(void)153df0566a6SJani Nikula static bool intel_dsm_detect(void)
154df0566a6SJani Nikula {
155df0566a6SJani Nikula 	acpi_handle dhandle = NULL;
156df0566a6SJani Nikula 	char acpi_method_name[255] = { 0 };
157df0566a6SJani Nikula 	struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name};
158df0566a6SJani Nikula 	struct pci_dev *pdev = NULL;
159df0566a6SJani Nikula 	int vga_count = 0;
160df0566a6SJani Nikula 
161df0566a6SJani Nikula 	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
162df0566a6SJani Nikula 		vga_count++;
163df0566a6SJani Nikula 		dhandle = intel_dsm_pci_probe(pdev) ?: dhandle;
164df0566a6SJani Nikula 	}
165df0566a6SJani Nikula 
166df0566a6SJani Nikula 	if (vga_count == 2 && dhandle) {
167df0566a6SJani Nikula 		acpi_get_name(dhandle, ACPI_FULL_PATHNAME, &buffer);
168df0566a6SJani Nikula 		DRM_DEBUG_DRIVER("vga_switcheroo: detected DSM switching method %s handle\n",
169df0566a6SJani Nikula 				 acpi_method_name);
170df0566a6SJani Nikula 		return true;
171df0566a6SJani Nikula 	}
172df0566a6SJani Nikula 
173df0566a6SJani Nikula 	return false;
174df0566a6SJani Nikula }
175df0566a6SJani Nikula 
intel_register_dsm_handler(void)176df0566a6SJani Nikula void intel_register_dsm_handler(void)
177df0566a6SJani Nikula {
178df0566a6SJani Nikula 	if (!intel_dsm_detect())
179df0566a6SJani Nikula 		return;
180df0566a6SJani Nikula }
181df0566a6SJani Nikula 
intel_unregister_dsm_handler(void)182df0566a6SJani Nikula void intel_unregister_dsm_handler(void)
183df0566a6SJani Nikula {
184df0566a6SJani Nikula }
1855fb44306SRajat Jain 
intel_dsm_get_bios_data_funcs_supported(struct drm_i915_private * i915)1868e55f99cSKai-Heng Feng void intel_dsm_get_bios_data_funcs_supported(struct drm_i915_private *i915)
1878e55f99cSKai-Heng Feng {
1888e55f99cSKai-Heng Feng 	struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
1898e55f99cSKai-Heng Feng 	acpi_handle dhandle;
190149ac2e7SZenghui Yu 	union acpi_object *obj;
1918e55f99cSKai-Heng Feng 
1928e55f99cSKai-Heng Feng 	dhandle = ACPI_HANDLE(&pdev->dev);
1938e55f99cSKai-Heng Feng 	if (!dhandle)
1948e55f99cSKai-Heng Feng 		return;
1958e55f99cSKai-Heng Feng 
196149ac2e7SZenghui Yu 	obj = acpi_evaluate_dsm(dhandle, &intel_dsm_guid2, INTEL_DSM_REVISION_ID,
1978e55f99cSKai-Heng Feng 				INTEL_DSM_FN_GET_BIOS_DATA_FUNCS_SUPPORTED, NULL);
198149ac2e7SZenghui Yu 	if (obj)
199149ac2e7SZenghui Yu 		ACPI_FREE(obj);
2008e55f99cSKai-Heng Feng }
2018e55f99cSKai-Heng Feng 
2025fb44306SRajat Jain /*
2035fb44306SRajat Jain  * ACPI Specification, Revision 5.0, Appendix B.3.2 _DOD (Enumerate All Devices
2045fb44306SRajat Jain  * Attached to the Display Adapter).
2055fb44306SRajat Jain  */
2065fb44306SRajat Jain #define ACPI_DISPLAY_INDEX_SHIFT		0
2075fb44306SRajat Jain #define ACPI_DISPLAY_INDEX_MASK			(0xf << 0)
2085fb44306SRajat Jain #define ACPI_DISPLAY_PORT_ATTACHMENT_SHIFT	4
2095fb44306SRajat Jain #define ACPI_DISPLAY_PORT_ATTACHMENT_MASK	(0xf << 4)
2105fb44306SRajat Jain #define ACPI_DISPLAY_TYPE_SHIFT			8
2115fb44306SRajat Jain #define ACPI_DISPLAY_TYPE_MASK			(0xf << 8)
2125fb44306SRajat Jain #define ACPI_DISPLAY_TYPE_OTHER			(0 << 8)
2135fb44306SRajat Jain #define ACPI_DISPLAY_TYPE_VGA			(1 << 8)
2145fb44306SRajat Jain #define ACPI_DISPLAY_TYPE_TV			(2 << 8)
2155fb44306SRajat Jain #define ACPI_DISPLAY_TYPE_EXTERNAL_DIGITAL	(3 << 8)
2165fb44306SRajat Jain #define ACPI_DISPLAY_TYPE_INTERNAL_DIGITAL	(4 << 8)
2175fb44306SRajat Jain #define ACPI_VENDOR_SPECIFIC_SHIFT		12
2185fb44306SRajat Jain #define ACPI_VENDOR_SPECIFIC_MASK		(0xf << 12)
2195fb44306SRajat Jain #define ACPI_BIOS_CAN_DETECT			(1 << 16)
2205fb44306SRajat Jain #define ACPI_DEPENDS_ON_VGA			(1 << 17)
2215fb44306SRajat Jain #define ACPI_PIPE_ID_SHIFT			18
2225fb44306SRajat Jain #define ACPI_PIPE_ID_MASK			(7 << 18)
2235fb44306SRajat Jain #define ACPI_DEVICE_ID_SCHEME			(1ULL << 31)
2245fb44306SRajat Jain 
acpi_display_type(struct intel_connector * connector)2255fb44306SRajat Jain static u32 acpi_display_type(struct intel_connector *connector)
2265fb44306SRajat Jain {
2275fb44306SRajat Jain 	u32 display_type;
2285fb44306SRajat Jain 
2295fb44306SRajat Jain 	switch (connector->base.connector_type) {
2305fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_VGA:
2315fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_DVIA:
2325fb44306SRajat Jain 		display_type = ACPI_DISPLAY_TYPE_VGA;
2335fb44306SRajat Jain 		break;
2345fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_Composite:
2355fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_SVIDEO:
2365fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_Component:
2375fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_9PinDIN:
2385fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_TV:
2395fb44306SRajat Jain 		display_type = ACPI_DISPLAY_TYPE_TV;
2405fb44306SRajat Jain 		break;
2415fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_DVII:
2425fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_DVID:
2435fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_DisplayPort:
2445fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_HDMIA:
2455fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_HDMIB:
2465fb44306SRajat Jain 		display_type = ACPI_DISPLAY_TYPE_EXTERNAL_DIGITAL;
2475fb44306SRajat Jain 		break;
2485fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_LVDS:
2495fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_eDP:
2505fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_DSI:
2515fb44306SRajat Jain 		display_type = ACPI_DISPLAY_TYPE_INTERNAL_DIGITAL;
2525fb44306SRajat Jain 		break;
2535fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_Unknown:
2545fb44306SRajat Jain 	case DRM_MODE_CONNECTOR_VIRTUAL:
2555fb44306SRajat Jain 		display_type = ACPI_DISPLAY_TYPE_OTHER;
2565fb44306SRajat Jain 		break;
2575fb44306SRajat Jain 	default:
2585fb44306SRajat Jain 		MISSING_CASE(connector->base.connector_type);
2595fb44306SRajat Jain 		display_type = ACPI_DISPLAY_TYPE_OTHER;
2605fb44306SRajat Jain 		break;
2615fb44306SRajat Jain 	}
2625fb44306SRajat Jain 
2635fb44306SRajat Jain 	return display_type;
2645fb44306SRajat Jain }
2655fb44306SRajat Jain 
intel_acpi_device_id_update(struct drm_i915_private * dev_priv)2665fb44306SRajat Jain void intel_acpi_device_id_update(struct drm_i915_private *dev_priv)
2675fb44306SRajat Jain {
2685fb44306SRajat Jain 	struct drm_device *drm_dev = &dev_priv->drm;
2695fb44306SRajat Jain 	struct intel_connector *connector;
2705fb44306SRajat Jain 	struct drm_connector_list_iter conn_iter;
2715fb44306SRajat Jain 	u8 display_index[16] = {};
2725fb44306SRajat Jain 
2735fb44306SRajat Jain 	/* Populate the ACPI IDs for all connectors for a given drm_device */
2745fb44306SRajat Jain 	drm_connector_list_iter_begin(drm_dev, &conn_iter);
2755fb44306SRajat Jain 	for_each_intel_connector_iter(connector, &conn_iter) {
2765fb44306SRajat Jain 		u32 device_id, type;
2775fb44306SRajat Jain 
2785fb44306SRajat Jain 		device_id = acpi_display_type(connector);
2795fb44306SRajat Jain 
2805fb44306SRajat Jain 		/* Use display type specific display index. */
2815fb44306SRajat Jain 		type = (device_id & ACPI_DISPLAY_TYPE_MASK)
2825fb44306SRajat Jain 			>> ACPI_DISPLAY_TYPE_SHIFT;
2835fb44306SRajat Jain 		device_id |= display_index[type]++ << ACPI_DISPLAY_INDEX_SHIFT;
2845fb44306SRajat Jain 
2855fb44306SRajat Jain 		connector->acpi_device_id = device_id;
2865fb44306SRajat Jain 	}
2875fb44306SRajat Jain 	drm_connector_list_iter_end(&conn_iter);
2885fb44306SRajat Jain }
289a481d0e8SHeikki Krogerus 
290a481d0e8SHeikki Krogerus /* NOTE: The connector order must be final before this is called. */
intel_acpi_assign_connector_fwnodes(struct drm_i915_private * i915)291a481d0e8SHeikki Krogerus void intel_acpi_assign_connector_fwnodes(struct drm_i915_private *i915)
292a481d0e8SHeikki Krogerus {
293a481d0e8SHeikki Krogerus 	struct drm_connector_list_iter conn_iter;
294a481d0e8SHeikki Krogerus 	struct drm_device *drm_dev = &i915->drm;
295a481d0e8SHeikki Krogerus 	struct fwnode_handle *fwnode = NULL;
296a481d0e8SHeikki Krogerus 	struct drm_connector *connector;
297a481d0e8SHeikki Krogerus 	struct acpi_device *adev;
298a481d0e8SHeikki Krogerus 
299a481d0e8SHeikki Krogerus 	drm_connector_list_iter_begin(drm_dev, &conn_iter);
300a481d0e8SHeikki Krogerus 	drm_for_each_connector_iter(connector, &conn_iter) {
301a481d0e8SHeikki Krogerus 		/* Always getting the next, even when the last was not used. */
302a481d0e8SHeikki Krogerus 		fwnode = device_get_next_child_node(drm_dev->dev, fwnode);
303a481d0e8SHeikki Krogerus 		if (!fwnode)
304a481d0e8SHeikki Krogerus 			break;
305a481d0e8SHeikki Krogerus 
306a481d0e8SHeikki Krogerus 		switch (connector->connector_type) {
307a481d0e8SHeikki Krogerus 		case DRM_MODE_CONNECTOR_LVDS:
308a481d0e8SHeikki Krogerus 		case DRM_MODE_CONNECTOR_eDP:
309a481d0e8SHeikki Krogerus 		case DRM_MODE_CONNECTOR_DSI:
310a481d0e8SHeikki Krogerus 			/*
311a481d0e8SHeikki Krogerus 			 * Integrated displays have a specific address 0x1f on
312a481d0e8SHeikki Krogerus 			 * most Intel platforms, but not on all of them.
313a481d0e8SHeikki Krogerus 			 */
314a481d0e8SHeikki Krogerus 			adev = acpi_find_child_device(ACPI_COMPANION(drm_dev->dev),
315a481d0e8SHeikki Krogerus 						      0x1f, 0);
316a481d0e8SHeikki Krogerus 			if (adev) {
317a481d0e8SHeikki Krogerus 				connector->fwnode =
318a481d0e8SHeikki Krogerus 					fwnode_handle_get(acpi_fwnode_handle(adev));
319a481d0e8SHeikki Krogerus 				break;
320a481d0e8SHeikki Krogerus 			}
321a481d0e8SHeikki Krogerus 			fallthrough;
322a481d0e8SHeikki Krogerus 		default:
323a481d0e8SHeikki Krogerus 			connector->fwnode = fwnode_handle_get(fwnode);
324a481d0e8SHeikki Krogerus 			break;
325a481d0e8SHeikki Krogerus 		}
326a481d0e8SHeikki Krogerus 	}
327a481d0e8SHeikki Krogerus 	drm_connector_list_iter_end(&conn_iter);
328a481d0e8SHeikki Krogerus 	/*
329a481d0e8SHeikki Krogerus 	 * device_get_next_child_node() takes a reference on the fwnode, if
330a481d0e8SHeikki Krogerus 	 * we stopped iterating because we are out of connectors we need to
331a481d0e8SHeikki Krogerus 	 * put this, otherwise fwnode is NULL and the put is a no-op.
332a481d0e8SHeikki Krogerus 	 */
333a481d0e8SHeikki Krogerus 	fwnode_handle_put(fwnode);
334a481d0e8SHeikki Krogerus }
335*3c8b6a39SHans de Goede 
intel_acpi_video_register(struct drm_i915_private * i915)336*3c8b6a39SHans de Goede void intel_acpi_video_register(struct drm_i915_private *i915)
337*3c8b6a39SHans de Goede {
338*3c8b6a39SHans de Goede 	struct drm_connector_list_iter conn_iter;
339*3c8b6a39SHans de Goede 	struct drm_connector *connector;
340*3c8b6a39SHans de Goede 
341*3c8b6a39SHans de Goede 	acpi_video_register();
342*3c8b6a39SHans de Goede 
343*3c8b6a39SHans de Goede 	/*
344*3c8b6a39SHans de Goede 	 * If i915 is driving an internal panel without registering its native
345*3c8b6a39SHans de Goede 	 * backlight handler try to register the acpi_video backlight.
346*3c8b6a39SHans de Goede 	 * For panels not driven by i915 another GPU driver may still register
347*3c8b6a39SHans de Goede 	 * a native backlight later and acpi_video_register_backlight() should
348*3c8b6a39SHans de Goede 	 * only be called after any native backlights have been registered.
349*3c8b6a39SHans de Goede 	 */
350*3c8b6a39SHans de Goede 	drm_connector_list_iter_begin(&i915->drm, &conn_iter);
351*3c8b6a39SHans de Goede 	drm_for_each_connector_iter(connector, &conn_iter) {
352*3c8b6a39SHans de Goede 		struct intel_panel *panel = &to_intel_connector(connector)->panel;
353*3c8b6a39SHans de Goede 
354*3c8b6a39SHans de Goede 		if (panel->backlight.funcs && !panel->backlight.device) {
355*3c8b6a39SHans de Goede 			acpi_video_register_backlight();
356*3c8b6a39SHans de Goede 			break;
357*3c8b6a39SHans de Goede 		}
358*3c8b6a39SHans de Goede 	}
359*3c8b6a39SHans de Goede 	drm_connector_list_iter_end(&conn_iter);
360*3c8b6a39SHans de Goede }
361