Home | History | Annotate | Line # | Download | only in display
      1 /*	$NetBSD: intel_opregion.h,v 1.6 2024/04/16 14:34:01 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 #include <linux/acpi.h>
     33 
     34 struct drm_i915_private;
     35 struct intel_encoder;
     36 
     37 struct opregion_header;
     38 struct opregion_acpi;
     39 struct opregion_swsci;
     40 struct opregion_asle;
     41 
     42 struct intel_opregion {
     43 	struct opregion_header *header;
     44 	struct opregion_acpi *acpi;
     45 	struct opregion_swsci *swsci;
     46 	u32 swsci_gbda_sub_functions;
     47 	u32 swsci_sbcb_sub_functions;
     48 	struct opregion_asle *asle;
     49 	void *rvda;
     50 	void *vbt_firmware;
     51 	const void *vbt;
     52 	u32 vbt_size;
     53 	u32 *lid_state;
     54 	struct work_struct asle_work;
     55 #ifdef __NetBSD__
     56 	struct acpidisp_notifier *acpi_notifier;
     57 #else
     58 	struct notifier_block acpi_notifier;
     59 #endif
     60 };
     61 
     62 #define OPREGION_SIZE            (8 * 1024)
     63 
     64 #ifdef CONFIG_ACPI
     65 
     66 int intel_opregion_setup(struct drm_i915_private *dev_priv);
     67 
     68 void intel_opregion_register(struct drm_i915_private *dev_priv);
     69 void intel_opregion_unregister(struct drm_i915_private *dev_priv);
     70 
     71 void intel_opregion_resume(struct drm_i915_private *dev_priv);
     72 void intel_opregion_suspend(struct drm_i915_private *dev_priv,
     73 			    pci_power_t state);
     74 
     75 void intel_opregion_asle_intr(struct drm_i915_private *dev_priv);
     76 int intel_opregion_notify_encoder(struct intel_encoder *intel_encoder,
     77 				  bool enable);
     78 int intel_opregion_notify_adapter(struct drm_i915_private *dev_priv,
     79 				  pci_power_t state);
     80 int intel_opregion_get_panel_type(struct drm_i915_private *dev_priv);
     81 
     82 #else /* CONFIG_ACPI*/
     83 
     84 static inline int intel_opregion_setup(struct drm_i915_private *dev_priv)
     85 {
     86 	return 0;
     87 }
     88 
     89 static inline void intel_opregion_register(struct drm_i915_private *dev_priv)
     90 {
     91 }
     92 
     93 static inline void intel_opregion_unregister(struct drm_i915_private *dev_priv)
     94 {
     95 }
     96 
     97 static inline void intel_opregion_resume(struct drm_i915_private *dev_priv)
     98 {
     99 }
    100 
    101 static inline void intel_opregion_suspend(struct drm_i915_private *dev_priv,
    102 					  pci_power_t state)
    103 {
    104 }
    105 
    106 static inline void intel_opregion_asle_intr(struct drm_i915_private *dev_priv)
    107 {
    108 }
    109 
    110 static inline int
    111 intel_opregion_notify_encoder(struct intel_encoder *intel_encoder, bool enable)
    112 {
    113 	return 0;
    114 }
    115 
    116 static inline int
    117 intel_opregion_notify_adapter(struct drm_i915_private *dev, pci_power_t state)
    118 {
    119 	return 0;
    120 }
    121 
    122 static inline int intel_opregion_get_panel_type(struct drm_i915_private *dev)
    123 {
    124 	return -ENODEV;
    125 }
    126 
    127 #endif /* CONFIG_ACPI */
    128 
    129 #endif
    130