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

acpi-video-detect: video: Make video_detect code part of the video module

This is a preparation patch for the backlight interface selection logic
cleanup, there are 2 reasons to not always build the video_detect code
into the kernel:

1) In order for the video_detect.c to also deal with / select native
backlight interfaces on win8 systems, instead of doing this in video.c
where it does not belong, video_detect.c needs to call into the backlight
class code. Which cannot be done if it is builtin and the blacklight class
is not.

2) Currently all the platform/x86 drivers which have quirks to prefer
the vendor driver over acpi-video call acpi_video_unregister_backlight()
to remove the acpi-video backlight interface, this logic really belongs
in video_detect.c, which will cause video_detect.c to depend on symbols of
video.c and video.c already depends on video_detect.c symbols, so they
really need to be a single module.

Note that this commits make 2 changes so as to maintain 100% kernel
commandline compatibility:

1) The __setup call for the acpi_backlight= handling is moved to
acpi/util.c as __setup may only be used by code which is alwasy builtin
2) video.c is renamed to acpi_video.c so that it can be combined with
video_detect.c into video.ko

This commit also makes changes to drivers/platform/x86/Kconfig to ensure
that drivers which use acpi_video_backlight_support() from video_detect.c,
will not be built-in when acpi_video is not built in. This also changes
some "select" uses to "depends on" to avoid dependency loops.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Hans de Goede and committed by
Rafael J. Wysocki
14ca7a47 a87878ba

+47 -32
+2 -3
drivers/acpi/Makefile
··· 52 52 acpi-$(CONFIG_DEBUG_FS) += debugfs.o 53 53 acpi-$(CONFIG_ACPI_NUMA) += numa.o 54 54 acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o 55 - ifdef CONFIG_ACPI_VIDEO 56 - acpi-y += video_detect.o 57 - endif 58 55 acpi-y += acpi_lpat.o 59 56 acpi-$(CONFIG_ACPI_GENERIC_GSI) += gsi.o 60 57 ··· 92 95 obj-$(CONFIG_PMIC_OPREGION) += pmic/intel_pmic.o 93 96 obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o 94 97 obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o 98 + 99 + video-objs += acpi_video.o video_detect.o
+15
drivers/acpi/utils.c
··· 712 712 return false; 713 713 } 714 714 EXPORT_SYMBOL(acpi_check_dsm); 715 + 716 + /* 717 + * acpi_backlight= handling, this is done here rather then in video_detect.c 718 + * because __setup cannot be used in modules. 719 + */ 720 + char acpi_video_backlight_string[16]; 721 + EXPORT_SYMBOL(acpi_video_backlight_string); 722 + 723 + static int __init acpi_backlight(char *str) 724 + { 725 + strlcpy(acpi_video_backlight_string, str, 726 + sizeof(acpi_video_backlight_string)); 727 + return 1; 728 + } 729 + __setup("acpi_backlight=", acpi_backlight);
+1 -1
drivers/acpi/video.c drivers/acpi/acpi_video.c
··· 43 43 #include <acpi/video.h> 44 44 #include <asm/uaccess.h> 45 45 46 - #include "internal.h" 46 + #define PREFIX "ACPI: " 47 47 48 48 #define ACPI_VIDEO_BUS_NAME "Video Bus" 49 49 #define ACPI_VIDEO_DEVICE_NAME "Video Device"
+12 -23
drivers/acpi/video_detect.c
··· 32 32 #include <linux/export.h> 33 33 #include <linux/acpi.h> 34 34 #include <linux/dmi.h> 35 + #include <linux/module.h> 35 36 #include <linux/pci.h> 36 - 37 - #include "internal.h" 38 37 39 38 ACPI_MODULE_NAME("video"); 40 39 #define _COMPONENT ACPI_VIDEO_COMPONENT 41 40 42 41 static long acpi_video_support; 43 42 static bool acpi_video_caps_checked; 43 + 44 + static void acpi_video_parse_cmdline(void) 45 + { 46 + if (!strcmp("vendor", acpi_video_backlight_string)) 47 + acpi_video_support |= ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR; 48 + if (!strcmp("video", acpi_video_backlight_string)) 49 + acpi_video_support |= ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO; 50 + } 44 51 45 52 static acpi_status 46 53 find_video(acpi_handle handle, u32 lvl, void *context, void **rv) ··· 181 174 * We must check whether the ACPI graphics device is physically plugged 182 175 * in. Therefore this must be called after binding PCI and ACPI devices 183 176 */ 184 - if (!acpi_video_caps_checked) 177 + if (!acpi_video_caps_checked) { 178 + acpi_video_parse_cmdline(); 185 179 acpi_video_get_capabilities(NULL); 180 + } 186 181 } 187 182 188 183 /* Promote the vendor interface instead of the generic video module. ··· 221 212 return acpi_video_support & ACPI_VIDEO_BACKLIGHT; 222 213 } 223 214 EXPORT_SYMBOL(acpi_video_backlight_support); 224 - 225 - /* 226 - * Use acpi_backlight=vendor/video to force that backlight switching 227 - * is processed by vendor specific acpi drivers or video.ko driver. 228 - */ 229 - static int __init acpi_backlight(char *str) 230 - { 231 - if (str == NULL || *str == '\0') 232 - return 1; 233 - else { 234 - if (!strcmp("vendor", str)) 235 - acpi_video_support |= 236 - ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR; 237 - if (!strcmp("video", str)) 238 - acpi_video_support |= 239 - ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO; 240 - } 241 - return 1; 242 - } 243 - __setup("acpi_backlight=", acpi_backlight);
+16 -5
drivers/platform/x86/Kconfig
··· 71 71 depends on ACPI 72 72 select LEDS_CLASS 73 73 select NEW_LEDS 74 - select BACKLIGHT_CLASS_DEVICE 74 + depends on BACKLIGHT_CLASS_DEVICE 75 75 depends on INPUT 76 76 depends on RFKILL || RFKILL = n 77 + depends on ACPI_VIDEO || ACPI_VIDEO = n 77 78 select INPUT_SPARSEKMAP 78 79 select INPUT_POLLDEV 79 80 ---help--- ··· 96 95 depends on X86 97 96 depends on DCDBAS 98 97 depends on BACKLIGHT_CLASS_DEVICE 98 + depends on ACPI_VIDEO || ACPI_VIDEO = n 99 99 depends on RFKILL || RFKILL = n 100 100 depends on SERIO_I8042 101 101 select POWER_SUPPLY ··· 111 109 tristate "Dell WMI extras" 112 110 depends on ACPI_WMI 113 111 depends on INPUT 112 + depends on ACPI_VIDEO || ACPI_VIDEO = n 114 113 select INPUT_SPARSEKMAP 115 114 ---help--- 116 115 Say Y here if you want to support WMI-based hotkeys on Dell laptops. ··· 147 144 depends on ACPI 148 145 depends on INPUT 149 146 depends on BACKLIGHT_CLASS_DEVICE 147 + depends on ACPI_VIDEO || ACPI_VIDEO = n 150 148 depends on LEDS_CLASS || LEDS_CLASS=n 151 149 ---help--- 152 150 This is a driver for laptops built by Fujitsu: ··· 251 247 tristate "MSI Laptop Extras" 252 248 depends on ACPI 253 249 depends on BACKLIGHT_CLASS_DEVICE 250 + depends on ACPI_VIDEO || ACPI_VIDEO = n 254 251 depends on RFKILL 255 252 depends on INPUT && SERIO_I8042 256 253 select INPUT_SPARSEKMAP ··· 285 280 tristate "Compal (and others) Laptop Extras" 286 281 depends on ACPI 287 282 depends on BACKLIGHT_CLASS_DEVICE 283 + depends on ACPI_VIDEO || ACPI_VIDEO = n 288 284 depends on RFKILL 289 285 depends on HWMON 290 286 depends on POWER_SUPPLY ··· 302 296 config SONY_LAPTOP 303 297 tristate "Sony Laptop Extras" 304 298 depends on ACPI 305 - select BACKLIGHT_CLASS_DEVICE 299 + depends on ACPI_VIDEO || ACPI_VIDEO = n 300 + depends on BACKLIGHT_CLASS_DEVICE 306 301 depends on INPUT 307 302 depends on RFKILL 308 303 ---help--- ··· 328 321 depends on RFKILL && INPUT 329 322 depends on SERIO_I8042 330 323 depends on BACKLIGHT_CLASS_DEVICE 324 + depends on ACPI_VIDEO || ACPI_VIDEO = n 331 325 select INPUT_SPARSEKMAP 332 326 help 333 327 This is a driver for Lenovo IdeaPad netbooks contains drivers for ··· 339 331 depends on ACPI 340 332 depends on INPUT 341 333 depends on RFKILL || RFKILL = n 342 - select BACKLIGHT_LCD_SUPPORT 343 - select BACKLIGHT_CLASS_DEVICE 334 + depends on ACPI_VIDEO || ACPI_VIDEO = n 335 + depends on BACKLIGHT_CLASS_DEVICE 344 336 select HWMON 345 337 select NVRAM 346 338 select NEW_LEDS ··· 508 500 depends on ACPI 509 501 depends on INPUT 510 502 depends on RFKILL || RFKILL = n 503 + depends on ACPI_VIDEO || ACPI_VIDEO = n 511 504 depends on HOTPLUG_PCI 512 - select BACKLIGHT_CLASS_DEVICE 505 + depends on BACKLIGHT_CLASS_DEVICE 513 506 select HWMON 514 507 select LEDS_CLASS 515 508 select NEW_LEDS ··· 596 587 depends on ACPI_WMI 597 588 depends on INPUT 598 589 depends on BACKLIGHT_CLASS_DEVICE 590 + depends on ACPI_VIDEO || ACPI_VIDEO = n 599 591 select INPUT_SPARSEKMAP 600 592 help 601 593 Say Y here if you want to support WMI-based hotkeys on MSI laptops. ··· 834 824 config INTEL_OAKTRAIL 835 825 tristate "Intel Oaktrail Platform Extras" 836 826 depends on ACPI 827 + depends on ACPI_VIDEO || ACPI_VIDEO = n 837 828 depends on RFKILL && BACKLIGHT_CLASS_DEVICE && ACPI 838 829 ---help--- 839 830 Intel Oaktrail platform need this driver to provide interfaces to
+1
include/linux/acpi.h
··· 243 243 #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR 0x0400 244 244 #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO 0x0800 245 245 246 + extern char acpi_video_backlight_string[]; 246 247 extern long acpi_is_video_device(acpi_handle handle); 247 248 248 249 #if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE)