Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/opregion: fill in the CADL from connector list, not DIDL

This is essentially the same thing as duplicating DIDL now that the
connector list has the ACPI device IDs.

Cc: Peter Wu <peter@lekensteyn.nl>
Cc: Rainer Koenig <Rainer.Koenig@ts.fujitsu.com>
Cc: Jan-Marek Glogowski <glogow@fbihome.de>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Cc: Paolo Stivanin <paolostivanin@fastmail.fm>
Tested-by: Rainer Koenig <Rainer.Koenig@ts.fujitsu.com>
Tested-by: Paolo Stivanin <paolostivanin@fastmail.fm>
Tested-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/ea0a052fa99a4cb56b559a815866434bcfef853d.1479295490.git.jani.nikula@intel.com

+20 -29
+20 -29
drivers/gpu/drm/i915/intel_opregion.c
··· 642 642 * (version 3) 643 643 */ 644 644 645 - static u32 get_did(struct intel_opregion *opregion, int i) 646 - { 647 - u32 did; 648 - 649 - if (i < ARRAY_SIZE(opregion->acpi->didl)) { 650 - did = opregion->acpi->didl[i]; 651 - } else { 652 - i -= ARRAY_SIZE(opregion->acpi->didl); 653 - 654 - if (WARN_ON(i >= ARRAY_SIZE(opregion->acpi->did2))) 655 - return 0; 656 - 657 - did = opregion->acpi->did2[i]; 658 - } 659 - 660 - return did; 661 - } 662 - 663 645 static void set_did(struct intel_opregion *opregion, int i, u32 val) 664 646 { 665 647 if (i < ARRAY_SIZE(opregion->acpi->didl)) { ··· 744 762 static void intel_setup_cadls(struct drm_i915_private *dev_priv) 745 763 { 746 764 struct intel_opregion *opregion = &dev_priv->opregion; 765 + struct intel_connector *connector; 747 766 int i = 0; 748 - u32 disp_id; 749 767 750 - /* Initialize the CADL field by duplicating the DIDL values. 751 - * Technically, this is not always correct as display outputs may exist, 752 - * but not active. This initialization is necessary for some Clevo 753 - * laptops that check this field before processing the brightness and 754 - * display switching hotkeys. Just like DIDL, CADL is NULL-terminated if 755 - * there are less than eight devices. */ 756 - do { 757 - disp_id = get_did(opregion, i); 758 - opregion->acpi->cadl[i] = disp_id; 759 - } while (++i < 8 && disp_id != 0); 768 + /* 769 + * Initialize the CADL field from the connector device ids. This is 770 + * essentially the same as copying from the DIDL. Technically, this is 771 + * not always correct as display outputs may exist, but not active. This 772 + * initialization is necessary for some Clevo laptops that check this 773 + * field before processing the brightness and display switching hotkeys. 774 + * 775 + * Note that internal panels should be at the front of the connector 776 + * list already, ensuring they're not left out. 777 + */ 778 + for_each_intel_connector(&dev_priv->drm, connector) { 779 + if (i >= ARRAY_SIZE(opregion->acpi->cadl)) 780 + break; 781 + opregion->acpi->cadl[i++] = connector->acpi_device_id; 782 + } 783 + 784 + /* If fewer than 8 active devices, the list must be null terminated */ 785 + if (i < ARRAY_SIZE(opregion->acpi->cadl)) 786 + opregion->acpi->cadl[i] = 0; 760 787 } 761 788 762 789 void intel_opregion_register(struct drm_i915_private *dev_priv)