From 4ca8e31e00fd69028c87eacd4cead3f9bde9bb67 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 5 Sep 2018 16:25:51 +0200 Subject: [PATCH] intel_fb: enable Intel VBT lookup via ACPI Fixes #2965 --- repos/dde_linux/intel_fb.list | 1 + .../lib/import/import-intel_fb_include.mk | 1 + repos/dde_linux/ports/dde_linux.hash | 2 +- .../src/drivers/framebuffer/intel/dummies.c | 33 ++++++++ .../framebuffer/intel/include/lx_emul.h | 52 +++++++++++- .../src/drivers/framebuffer/intel/lx_emul.cc | 81 +++++++++++++++++-- repos/dde_linux/src/include/lx_emul/pci.h | 1 + 7 files changed, 162 insertions(+), 9 deletions(-) diff --git a/repos/dde_linux/intel_fb.list b/repos/dde_linux/intel_fb.list index a3872ee24e..ce829d10a2 100644 --- a/repos/dde_linux/intel_fb.list +++ b/repos/dde_linux/intel_fb.list @@ -128,6 +128,7 @@ linux-x.x.x/drivers/gpu/drm/i915/intel_lvds.c linux-x.x.x/drivers/gpu/drm/i915/intel_mocs.c linux-x.x.x/drivers/gpu/drm/i915/intel_mocs.h linux-x.x.x/drivers/gpu/drm/i915/intel_modes.c +linux-x.x.x/drivers/gpu/drm/i915/intel_opregion.c linux-x.x.x/drivers/gpu/drm/i915/intel_opregion.h linux-x.x.x/drivers/gpu/drm/i915/intel_overlay.c linux-x.x.x/drivers/gpu/drm/i915/intel_panel.c diff --git a/repos/dde_linux/lib/import/import-intel_fb_include.mk b/repos/dde_linux/lib/import/import-intel_fb_include.mk index e414b01320..049c92dad2 100644 --- a/repos/dde_linux/lib/import/import-intel_fb_include.mk +++ b/repos/dde_linux/lib/import/import-intel_fb_include.mk @@ -25,3 +25,4 @@ INC_DIR += $(SRC_DIR)/include \ CC_OPT += -U__linux__ -D__KERNEL__ CC_OPT += -DCONFIG_DRM_I915_KMS -DCONFIG_I2C -DCONFIG_I2C_BOARDINFO +CC_OPT += -DCONFIG_ACPI diff --git a/repos/dde_linux/ports/dde_linux.hash b/repos/dde_linux/ports/dde_linux.hash index 6e8fc7a763..91085d0b13 100644 --- a/repos/dde_linux/ports/dde_linux.hash +++ b/repos/dde_linux/ports/dde_linux.hash @@ -1 +1 @@ -b88acdf93d8db71180a25937fba45ec6b39a2841 +5ee7d9befaff281fec480e2257f302c76fe85126 diff --git a/repos/dde_linux/src/drivers/framebuffer/intel/dummies.c b/repos/dde_linux/src/drivers/framebuffer/intel/dummies.c index 90a8c7c6f3..87e3c81a4e 100644 --- a/repos/dde_linux/src/drivers/framebuffer/intel/dummies.c +++ b/repos/dde_linux/src/drivers/framebuffer/intel/dummies.c @@ -1771,3 +1771,36 @@ int stop_machine(cpu_stop_fn_t a, void *b, const struct cpumask *c) TRACE_AND_STOP; return -1; } + +int unregister_acpi_notifier(struct notifier_block *nb) +{ + TRACE_AND_STOP; + return -1; +} + +const struct acpi_device_id * i2c_acpi_match_device(const struct acpi_device_id *matches, + struct i2c_client *client) +{ + TRACE_AND_STOP; + return 0; +} + +static int i2c_acpi_notify(struct notifier_block *nb, unsigned long value, void *arg) +{ + TRACE_AND_STOP; + return -1; +} + +struct notifier_block i2c_acpi_notifier = { + .notifier_call = i2c_acpi_notify, +}; + +void intel_unregister_dsm_handler(void) +{ + TRACE_AND_STOP; +} + +enum acpi_backlight_type acpi_video_get_backlight_type(void) +{ + TRACE_AND_STOP; +} diff --git a/repos/dde_linux/src/drivers/framebuffer/intel/include/lx_emul.h b/repos/dde_linux/src/drivers/framebuffer/intel/include/lx_emul.h index 1e985cdbec..226e688e35 100644 --- a/repos/dde_linux/src/drivers/framebuffer/intel/include/lx_emul.h +++ b/repos/dde_linux/src/drivers/framebuffer/intel/include/lx_emul.h @@ -1231,10 +1231,30 @@ struct acpi_device; struct acpi_dev_node { struct acpi_device *companion; }; +/********************* + ** acpi/acpi_bus.h ** + *********************/ + +typedef char acpi_bus_id[8]; +typedef char acpi_device_class[20]; + +struct acpi_bus_event { + struct list_head node; + acpi_device_class device_class; + acpi_bus_id bus_id; + u32 type; + u32 data; +}; + + /**************** ** linux/io.h ** ****************/ +enum { + MEMREMAP_WB = 1 << 0, +}; + #define writel(value, addr) (*(volatile uint32_t *)(addr) = (value)) #define readl(addr) (*(volatile uint32_t *)(addr)) @@ -1563,8 +1583,6 @@ void vga_put(struct pci_dev *pdev, unsigned int rsrc); ** linux/notifier.h ** **********************/ -#define NOTIFY_DONE 0x0000 - /* needed by intel_lvds.c */ struct notifier_block; @@ -1573,7 +1591,12 @@ typedef int (*notifier_fn_t)(struct notifier_block *nb, unsigned long action, vo struct notifier_block { notifier_fn_t notifier_call; }; -enum { NOTIFY_OK = 0x0001 }; +enum { + NOTIFY_DONE = 0x0000, + NOTIFY_OK = 0x0001, + NOTIFY_STOP_MASK = 0x8000, + NOTIFY_BAD = (NOTIFY_STOP_MASK|0x0002), +}; struct atomic_notifier_head { unsigned dummy; }; @@ -1605,9 +1628,32 @@ static inline bool vgacon_text_force(void) { return false; } ** acpi/video.h ** ******************/ +#define ACPI_VIDEO_CLASS "video" + int acpi_video_register(void); void acpi_video_unregister(void); +enum acpi_backlight_type { + acpi_backlight_native = 3, +}; +enum acpi_backlight_type acpi_video_get_backlight_type(void); + + +/****************** + ** acpi/video.h ** + ******************/ + +int register_acpi_notifier(struct notifier_block *); +int unregister_acpi_notifier(struct notifier_block *); + + +/********************** + ** linux/memremap.h ** + **********************/ + +void *memremap(resource_size_t offset, size_t size, unsigned long flags); +void memunmap(void *addr); + /***************** ** asm/ioctl.h ** diff --git a/repos/dde_linux/src/drivers/framebuffer/intel/lx_emul.cc b/repos/dde_linux/src/drivers/framebuffer/intel/lx_emul.cc index dbf8621ee1..bb4b787ba8 100644 --- a/repos/dde_linux/src/drivers/framebuffer/intel/lx_emul.cc +++ b/repos/dde_linux/src/drivers/framebuffer/intel/lx_emul.cc @@ -1121,17 +1121,33 @@ void cpu_relax(void) ** drivers/pci/rom.c ** ***********************/ +static Genode::Constructible video_rom; + void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size) { + /* solely available in BIOS legacy mode ... */ enum { VIDEO_ROM_BASE = 0xC0000, VIDEO_ROM_SIZE = 0x20000 }; - static Genode::Attached_io_mem_dataspace vrom(Lx_kit::env().env(), - VIDEO_ROM_BASE, VIDEO_ROM_SIZE); - *size = VIDEO_ROM_SIZE; - return vrom.local_addr(); + BUG_ON(video_rom.constructed()); + + try { + video_rom.construct(Lx_kit::env().env(), VIDEO_ROM_BASE, VIDEO_ROM_SIZE); + *size = VIDEO_ROM_SIZE; + return video_rom->local_addr(); + } catch (...) { + Genode::warning("could not map ", + Genode::Hex_range(VIDEO_ROM_BASE, + VIDEO_ROM_SIZE), + " video rom region"); + } + + return nullptr; } -void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom) {} +void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom) { + BUG_ON(!video_rom.constructed()); + video_rom.destruct(); +} /****************** @@ -1924,4 +1940,59 @@ u64 local_clock(void) return jiffies_to_nsecs(jiffies); } + +/****************************************************************** + ** ACPI related function called by Intel driver (-DCONFIG_ACPI) ** + ******************************************************************/ + + +static Genode::Constructible opregion; + +void *memremap(resource_size_t offset, size_t size, unsigned long flags) +{ + Genode::addr_t paddr = offset & ~0xfffUL; + Genode::addr_t psize = size + (offset & 0xfff); + + BUG_ON(opregion.constructed()); + + try { + opregion.construct(Lx_kit::env().env(), paddr, psize); + return opregion->local_addr() + (offset & 0xfff); + } catch (...) { + Genode::warning("could not map ", + Genode::Hex_range(offset, size), + " ACPI opregion"); + } + return nullptr; +} + +void memunmap(void *addr) +{ + BUG_ON(!opregion.constructed()); + opregion.destruct(); +} + + +void intel_register_dsm_handler(void) +{ + Genode::warning(__func__, " called"); +} + +void i2c_acpi_register_devices(struct i2c_adapter *adap) +{ + Genode::warning(__func__, " called"); +} + +int register_acpi_notifier(struct notifier_block *nb) +{ + Genode::warning(__func__, " called"); + return 0; +} + +int acpi_reconfig_notifier_register(struct notifier_block *nb) +{ + Genode::warning(__func__, " called"); + return 0; +} + } /* extern "C" */ diff --git a/repos/dde_linux/src/include/lx_emul/pci.h b/repos/dde_linux/src/include/lx_emul/pci.h index cd5a83fcd4..ccf4938e7b 100644 --- a/repos/dde_linux/src/include/lx_emul/pci.h +++ b/repos/dde_linux/src/include/lx_emul/pci.h @@ -36,6 +36,7 @@ enum { PCI_ANY_ID = ~0U }; typedef enum { PCI_D0 = 0, PCI_D1 = 1, + PCI_D2 = 2, PCI_D3hot = 3, PCI_D3cold = 4, } pci_power_t;