Home | History | Annotate | Line # | Download | only in display
intel_opregion.h revision 1.2
      1 /*	$NetBSD: intel_opregion.h,v 1.2 2021/12/18 23:45:30 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright  2008-2017 Intel Corporation
      5  *
      6  * Permission is hereby granted, free of charge, to any person obtaining a
      7  * copy of this software and associated documentation files (the "Software"),
      8  * to deal in the Software without restriction, including without limitation
      9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  * and/or sell copies of the Software, and to permit persons to whom the
     11  * Software is furnished to do so, subject to the following conditions:
     12  *
     13  * The above copyright notice and this permission notice (including the next
     14  * paragraph) shall be included in all copies or substantial portions of the
     15  * Software.
     16  *
     17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     22  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
     23  * IN THE SOFTWARE.
     24  *
     25  */
     26 
     27 #ifndef _INTEL_OPREGION_H_
     28 #define _INTEL_OPREGION_H_
     29 
     30 #include <linux/workqueue.h>
     31 #include <linux/pci.h>
     32 
     33 struct drm_i915_private;
     34 struct intel_encoder;
     35 
     36 struct opregion_header;
     37 struct opregion_acpi;
     38 struct opregion_swsci;
     39 struct opregion_asle;
     40 
     41 #ifdef __NetBSD__		/* XXX acpi iomem */
     42 #  include <linux/acpi_io.h>
     43 #  define	__iomem		__acpi_iomem
     44 #endif
     45 
     46 struct intel_opregion {
     47 #ifdef __NetBSD__
     48 	bus_space_tag_t bst;
     49 	bus_space_handle_t bsh;
     50 #endif
     51 	struct opregion_header *header;
     52 	struct opregion_acpi *acpi;
     53 	struct opregion_swsci *swsci;
     54 	u32 swsci_gbda_sub_functions;
     55 	u32 swsci_sbcb_sub_functions;
     56 	struct opregion_asle *asle;
     57 	void *rvda;
     58 	void *vbt_firmware;
     59 	const void *vbt;
     60 	u32 vbt_size;
     61 	u32 *lid_state;
     62 	struct work_struct asle_work;
     63 	struct notifier_block acpi_notifier;
     64 };
     65 
     66 #define OPREGION_SIZE            (8 * 1024)
     67 
     68 #ifdef __NetBSD__		/* XXX acpi iomem */
     69 #  undef	__iomem
     70 #endif
     71 
     72 #ifdef CONFIG_ACPI
     73 
     74 int intel_opregion_setup(struct drm_i915_private *dev_priv);
     75 
     76 void intel_opregion_register(struct drm_i915_private *dev_priv);
     77 void intel_opregion_unregister(struct drm_i915_private *dev_priv);
     78 
     79 void intel_opregion_resume(struct drm_i915_private *dev_priv);
     80 void intel_opregion_suspend(struct drm_i915_private *dev_priv,
     81 			    pci_power_t state);
     82 
     83 void intel_opregion_asle_intr(struct drm_i915_private *dev_priv);
     84 int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
     85 				  bool enable);
     86 int intel_opregion_notify_adapter(struct drm_i915_private *dev_priv,
     87 				  pci_power_t state);
     88 int intel_opregion_get_panel_type(struct drm_i915_private *dev_priv);
     89 
     90 #else /* CONFIG_ACPI*/
     91 
     92 static inline int intel_opregion_setup(struct drm_i915_private *dev_priv)
     93 {
     94 	return 0;
     95 }
     96 
     97 static inline void intel_opregion_register(struct drm_i915_private *dev_priv)
     98 {
     99 }
    100 
    101 static inline void intel_opregion_unregister(struct drm_i915_private *dev_priv)
    102 {
    103 }
    104 
    105 static inline void intel_opregion_resume(struct drm_i915_private *dev_priv)
    106 {
    107 }
    108 
    109 static inline void intel_opregion_suspend(struct drm_i915_private *dev_priv,
    110 					  pci_power_t state)
    111 {
    112 }
    113 
    114 static inline void intel_opregion_asle_intr(struct drm_i915_private *dev_priv)
    115 {
    116 }
    117 
    118 static inline int
    119 intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, bool enable)
    120 {
    121 	return 0;
    122 }
    123 
    124 static inline int
    125 intel_opregion_notify_adapter(struct drm_i915_private *dev, pci_power_t state)
    126 {
    127 	return 0;
    128 }
    129 
    130 static inline int intel_opregion_get_panel_type(struct drm_i915_private *dev)
    131 {
    132 	return -ENODEV;
    133 }
    134 
    135 #endif /* CONFIG_ACPI */
    136 
    137 #endif
    138