本文整理汇总了C++中DEVICE_ACPI_HANDLE函数的典型用法代码示例。如果您正苦于以下问题:C++ DEVICE_ACPI_HANDLE函数的具体用法?C++ DEVICE_ACPI_HANDLE怎么用?C++ DEVICE_ACPI_HANDLE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DEVICE_ACPI_HANDLE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pciehp_get_hp_hw_control_from_firmware
int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
{
acpi_status status;
acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev));
struct pci_dev *pdev = dev;
u8 *path_name;
/*
* Per PCI firmware specification, we should run the ACPI _OSC
* method to get control of hotplug hardware before using it.
* If an _OSC is missing, we look for an OSHP to do the same thing.
* To handle different BIOS behavior, we look for _OSC and OSHP
* within the scope of the hotplug controller and its parents, upto
* the host bridge under which this controller exists.
*/
while (!handle) {
/*
* This hotplug controller was not listed in the ACPI name
* space at all. Try to get acpi handle of parent pci bus.
*/
if (!pdev || !pdev->bus->parent)
break;
dbg("Could not find %s in acpi namespace, trying parent\n",
pci_name(pdev));
if (!pdev->bus->parent->self)
/* Parent must be a host bridge */
handle = acpi_get_pci_rootbridge_handle(
pci_domain_nr(pdev->bus->parent),
pdev->bus->parent->number);
else
handle = DEVICE_ACPI_HANDLE(
&(pdev->bus->parent->self->dev));
pdev = pdev->bus->parent->self;
}
while (handle) {
path_name = acpi_path_name(handle);
dbg("Trying to get hotplug control for %s \n", path_name);
status = pci_osc_control_set(handle,
OSC_PCI_EXPRESS_NATIVE_HP_CONTROL);
if (status == AE_NOT_FOUND)
status = acpi_run_oshp(handle);
if (ACPI_SUCCESS(status)) {
dbg("Gained control for hotplug HW for pci %s (%s)\n",
pci_name(dev), path_name);
return 0;
}
if (is_root_bridge(handle))
break;
chandle = handle;
status = acpi_get_parent(chandle, &handle);
if (ACPI_FAILURE(status))
break;
}
err("Cannot get control of hotplug hardware for pci %s\n",
pci_name(dev));
return -1;
}
示例2: intel_dsm_pci_probe
static bool intel_dsm_pci_probe(struct pci_dev *pdev)
{
acpi_handle dhandle, intel_handle;
acpi_status status;
int ret;
dhandle = DEVICE_ACPI_HANDLE(&pdev->dev);
if (!dhandle)
return false;
status = acpi_get_handle(dhandle, "_DSM", &intel_handle);
if (ACPI_FAILURE(status)) {
DRM_DEBUG_KMS("no _DSM method for intel device\n");
return false;
}
ret = intel_dsm(dhandle, INTEL_DSM_FN_SUPPORTED_FUNCTIONS, 0);
if (ret < 0) {
DRM_ERROR("failed to get supported _DSM functions\n");
return false;
}
intel_dsm_priv.dhandle = dhandle;
intel_dsm_platform_mux_info();
return true;
}
示例3: DEVICE_ACPI_HANDLE
/**
* acpi_dev_pm_get_node - Get ACPI device node for the given physical device.
* @dev: Device to get the ACPI node for.
*/
struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
{
acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
struct acpi_device *adev;
return handle && !acpi_bus_get_device(handle, &adev) ? adev : NULL;
}
示例4: radeon_atpx_get_client_id
/**
* radeon_atpx_get_client_id - get the client id
*
* @pdev: pci device
*
* look up whether we are the integrated or discrete GPU (all asics).
* Returns the client id.
*/
static int radeon_atpx_get_client_id(struct pci_dev *pdev)
{
if (radeon_atpx_priv.dhandle == DEVICE_ACPI_HANDLE(&pdev->dev))
return VGA_SWITCHEROO_IGD;
else
return VGA_SWITCHEROO_DIS;
}
示例5: nouveau_dsm_get_client_id
static int nouveau_dsm_get_client_id(struct pci_dev *pdev)
{
if (nouveau_dsm_priv.dhandle == DEVICE_ACPI_HANDLE(&pdev->dev))
return VGA_SWITCHEROO_IGD;
else
return VGA_SWITCHEROO_DIS;
}
示例6: nouveau_acpi_edid
int
nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector)
{
struct nouveau_connector *nv_connector = nouveau_connector(connector);
struct acpi_device *acpidev;
acpi_handle handle;
int type, ret;
void *edid;
switch (connector->connector_type) {
case DRM_MODE_CONNECTOR_LVDS:
case DRM_MODE_CONNECTOR_eDP:
type = ACPI_VIDEO_DISPLAY_LCD;
break;
default:
return -EINVAL;
}
handle = DEVICE_ACPI_HANDLE(&dev->pdev->dev);
if (!handle)
return -ENODEV;
ret = acpi_bus_get_device(handle, &acpidev);
if (ret)
return -ENODEV;
ret = acpi_video_get_edid(acpidev, type, -1, &edid);
if (ret < 0)
return ret;
nv_connector->edid = edid;
return 0;
}
示例7: meh_show
static int meh_show(struct seq_file *seqfp, void *p) {
struct pci_dev *pdev = NULL;
while ((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) {
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
acpi_handle handle;
#ifdef ACPI_HANDLE
/* since Linux 3.8 */
handle = ACPI_HANDLE(&pdev->dev);
#else
/* removed since Linux 3.13 */
handle = DEVICE_ACPI_HANDLE(&pdev->dev);
#endif
seq_printf(seqfp, "%s ", dev_name(&pdev->dev));
seq_printf(seqfp, "%06x ", pdev->class);
if (handle) {
acpi_get_name(handle, ACPI_FULL_PATHNAME, &buf);
seq_printf(seqfp, "%s\n", (char *)buf.pointer);
} else {
seq_printf(seqfp, "\n");
}
}
return 0;
}
示例8: usb_acpi_find_device
static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
{
struct usb_device *udev;
struct device *parent;
acpi_handle *parent_handle;
if (!is_usb_device(dev))
return -ENODEV;
udev = to_usb_device(dev);
parent = dev->parent;
parent_handle = DEVICE_ACPI_HANDLE(parent);
if (!parent_handle)
return -ENODEV;
*handle = acpi_get_child(parent_handle, udev->portnum);
if (!*handle)
return -ENODEV;
/*
* PLD will tell us whether a port is removable to the user or
* not. If we don't get an answer from PLD (it's not present
* or it's malformed) then try to infer it from UPC. If a
* device isn't connectable then it's probably not removable.
*/
if (usb_acpi_check_pld(udev, *handle) != 0)
usb_acpi_check_upc(udev, *handle);
return 0;
}
示例9: find_slot_number_acpi
static uint8_t find_slot_number_acpi(const struct pci_dev *pcidev)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)
unsigned long sun = 0;
#else
unsigned long long sun = 0;
#endif
#ifdef DEVICE_ACPI_HANDLE
const struct device *dev = &pcidev->dev;
// Walk the tree to get a slot number, just in case we are behind a bridge. (ie ioDUO)
while (dev && !sun)
{
acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
if (handle)
{
// Use the ACPI method _SUN to get the slot number. See ACPI spec.
acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
}
dev = dev->parent;
}
#endif
return (uint8_t)sun;
}
示例10: nouveau_dsm_pci_probe
static int nouveau_dsm_pci_probe(struct pci_dev *pdev)
{
acpi_handle dhandle, nvidia_handle;
acpi_status status;
int ret, retval = 0;
uint32_t result;
dhandle = DEVICE_ACPI_HANDLE(&pdev->dev);
if (!dhandle)
return false;
status = acpi_get_handle(dhandle, "_DSM", &nvidia_handle);
if (ACPI_FAILURE(status)) {
return false;
}
ret = nouveau_dsm(dhandle, NOUVEAU_DSM_SUPPORTED,
NOUVEAU_DSM_SUPPORTED_FUNCTIONS, &result);
if (ret == 0)
retval |= NOUVEAU_DSM_HAS_MUX;
ret = nouveau_optimus_dsm(dhandle, 0, 0, &result);
if (ret == 0)
retval |= NOUVEAU_DSM_HAS_OPT;
if (retval)
nouveau_dsm_priv.dhandle = dhandle;
return retval;
}
示例11: bbswitch_init
static int __init bbswitch_init(void) {
struct proc_dir_entry *acpi_entry;
struct pci_dev *pdev = NULL;
int class = PCI_CLASS_DISPLAY_VGA << 8;
while ((pdev = pci_get_class(class, pdev)) != NULL) {
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
acpi_handle handle;
handle = DEVICE_ACPI_HANDLE(&pdev->dev);
if (!handle)
continue;
if (pdev->vendor != PCI_VENDOR_ID_INTEL) {
dis_dev = pdev;
dis_handle = handle;
acpi_get_name(handle, ACPI_FULL_PATHNAME, &buf);
printk(KERN_INFO "bbswitch: Found discrete VGA device %s: %s\n",
dev_name(&pdev->dev), (char *)buf.pointer);
}
kfree(buf.pointer);
}
if (dis_dev == NULL) {
printk(KERN_ERR "bbswitch: No discrete VGA device found\n");
return -ENODEV;
}
if (has_dsm_func(acpi_optimus_dsm_muid, 0x100, 0x1A)) {
dsm_type = DSM_TYPE_OPTIMUS;
printk(KERN_INFO "bbswitch: detected an Optimus _DSM function\n");
} else if (has_dsm_func(acpi_nvidia_dsm_muid, 0x102, 0x3)) {
dsm_type = DSM_TYPE_NVIDIA;
printk(KERN_INFO "bbswitch: detected a nVidia _DSM function\n");
} else {
printk(KERN_ERR "bbswitch: No suitable _DSM call found.\n");
return -ENODEV;
}
acpi_entry = create_proc_entry("bbswitch", 0660, acpi_root_dir);
if (acpi_entry == NULL) {
printk(KERN_ERR "bbswitch: Couldn't create proc entry\n");
return -ENOMEM;
}
printk(KERN_INFO "bbswitch: Succesfully loaded. Discrete card %s is %s\n",
dev_name(&dis_dev->dev), is_card_disabled() ? "off" : "on");
acpi_entry->write_proc = bbswitch_write;
acpi_entry->read_proc = bbswitch_read;
nb.notifier_call = &bbswitch_pm_handler;
register_pm_notifier(&nb);
return 0;
}
示例12: acpi_pci_set_power_state
static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
{
acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
acpi_handle tmp;
static const u8 state_conv[] = {
[PCI_D0] = ACPI_STATE_D0,
[PCI_D1] = ACPI_STATE_D1,
[PCI_D2] = ACPI_STATE_D2,
[PCI_D3hot] = ACPI_STATE_D3,
[PCI_D3cold] = ACPI_STATE_D3
};
示例13: get_hp_hw_control_from_firmware
void get_hp_hw_control_from_firmware(struct pci_dev *dev)
{
/*
* OSHP is an optional ACPI firmware control method. If present,
* we need to run it to inform BIOS that we will control SHPC
* hardware from now on.
*/
acpi_handle handle = DEVICE_ACPI_HANDLE(&(dev->dev));
if (!handle)
return;
acpi_run_oshp(handle);
}
示例14: ide_get_dev_handle
/**
* ide_get_dev_handle - finds acpi_handle and PCI device.function
* @dev: device to locate
* @handle: returned acpi_handle for @dev
* @pcidevfn: return PCI device.func for @dev
*
* Returns the ACPI object handle to the corresponding PCI device.
*
* Returns 0 on success, <0 on error.
*/
static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
acpi_integer *pcidevfn)
{
struct pci_dev *pdev = to_pci_dev(dev);
unsigned int bus, devnum, func;
acpi_integer addr;
acpi_handle dev_handle;
struct acpi_buffer buffer = {.length = ACPI_ALLOCATE_BUFFER,
.pointer = NULL};
acpi_status status;
struct acpi_device_info *dinfo = NULL;
int ret = -ENODEV;
bus = pdev->bus->number;
devnum = PCI_SLOT(pdev->devfn);
func = PCI_FUNC(pdev->devfn);
/* ACPI _ADR encoding for PCI bus: */
addr = (acpi_integer)(devnum << 16 | func);
DEBPRINT("ENTER: pci %02x:%02x.%01x\n", bus, devnum, func);
dev_handle = DEVICE_ACPI_HANDLE(dev);
if (!dev_handle) {
DEBPRINT("no acpi handle for device\n");
goto err;
}
status = acpi_get_object_info(dev_handle, &buffer);
if (ACPI_FAILURE(status)) {
DEBPRINT("get_object_info for device failed\n");
goto err;
}
dinfo = buffer.pointer;
if (dinfo && (dinfo->valid & ACPI_VALID_ADR) &&
dinfo->address == addr) {
*pcidevfn = addr;
*handle = dev_handle;
} else {
DEBPRINT("get_object_info for device has wrong "
" address: %llu, should be %u\n",
dinfo ? (unsigned long long)dinfo->address : -1ULL,
(unsigned int)addr);
goto err;
}
DEBPRINT("for dev=0x%x.%x, addr=0x%llx, *handle=0x%p\n",
devnum, func, (unsigned long long)addr, *handle);
ret = 0;
err:
kfree(dinfo);
return ret;
}
示例15: acpi_pm_device_sleep_state
/**
* acpi_pm_device_sleep_state - Get preferred power state of ACPI device.
* @dev: Device whose preferred target power state to return.
* @d_min_p: Location to store the upper limit of the allowed states range.
* @d_max_in: Deepest low-power state to take into consideration.
* Return value: Preferred power state of the device on success, -ENODEV
* (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure
*
* The caller must ensure that @dev is valid before using this function.
*/
int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
{
acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
struct acpi_device *adev;
if (!handle || acpi_bus_get_device(handle, &adev)) {
dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
return -ENODEV;
}
return acpi_device_power_state(dev, adev, acpi_target_system_state(),
d_max_in, d_min_p);
}