drm/i915/opregion: abstract the check for valid swsci function
Add a reusable function for checking the SWSCI function. Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/778f8716ec44adad3cf95a7bb327a7c8e981291d.1644489329.git.jani.nikula@intel.com
This commit is contained in:
parent
24a644ebbf
commit
73144c0ce4
@ -245,14 +245,10 @@ struct opregion_asle_ext {
|
|||||||
|
|
||||||
#define MAX_DSLP 1500
|
#define MAX_DSLP 1500
|
||||||
|
|
||||||
static int swsci(struct drm_i915_private *dev_priv,
|
static int check_swsci_function(struct drm_i915_private *i915, u32 function)
|
||||||
u32 function, u32 parm, u32 *parm_out)
|
|
||||||
{
|
{
|
||||||
struct opregion_swsci *swsci = dev_priv->opregion.swsci;
|
struct opregion_swsci *swsci = i915->opregion.swsci;
|
||||||
struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
|
u32 main_function, sub_function;
|
||||||
u32 main_function, sub_function, scic;
|
|
||||||
u16 swsci_val;
|
|
||||||
u32 dslp;
|
|
||||||
|
|
||||||
if (!swsci)
|
if (!swsci)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
@ -264,15 +260,31 @@ static int swsci(struct drm_i915_private *dev_priv,
|
|||||||
|
|
||||||
/* Check if we can call the function. See swsci_setup for details. */
|
/* Check if we can call the function. See swsci_setup for details. */
|
||||||
if (main_function == SWSCI_SBCB) {
|
if (main_function == SWSCI_SBCB) {
|
||||||
if ((dev_priv->opregion.swsci_sbcb_sub_functions &
|
if ((i915->opregion.swsci_sbcb_sub_functions &
|
||||||
(1 << sub_function)) == 0)
|
(1 << sub_function)) == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
} else if (main_function == SWSCI_GBDA) {
|
} else if (main_function == SWSCI_GBDA) {
|
||||||
if ((dev_priv->opregion.swsci_gbda_sub_functions &
|
if ((i915->opregion.swsci_gbda_sub_functions &
|
||||||
(1 << sub_function)) == 0)
|
(1 << sub_function)) == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int swsci(struct drm_i915_private *dev_priv,
|
||||||
|
u32 function, u32 parm, u32 *parm_out)
|
||||||
|
{
|
||||||
|
struct opregion_swsci *swsci = dev_priv->opregion.swsci;
|
||||||
|
struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
|
||||||
|
u32 scic, dslp;
|
||||||
|
u16 swsci_val;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = check_swsci_function(dev_priv, function);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
/* Driver sleep timeout in ms. */
|
/* Driver sleep timeout in ms. */
|
||||||
dslp = swsci->dslp;
|
dslp = swsci->dslp;
|
||||||
if (!dslp) {
|
if (!dslp) {
|
||||||
|
Loading…
Reference in New Issue
Block a user