當前位置: 首頁>>代碼示例>>C++>>正文


C++ DEVICE_ACPI_HANDLE函數代碼示例

本文整理匯總了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;
}
開發者ID:BackupTheBerlios,項目名稱:tew632-brp-svn,代碼行數:58,代碼來源:pciehprm_acpi.c

示例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;
}
開發者ID:Berrrry,項目名稱:SPH-L710_NA_Kernel,代碼行數:27,代碼來源:intel_acpi.c

示例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;
}
開發者ID:spacex,項目名稱:kernel-centos7,代碼行數:11,代碼來源:device_pm.c

示例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;
}
開發者ID:0x000000FF,項目名稱:Linux4Edison,代碼行數:15,代碼來源:radeon_atpx_handler.c

示例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;
}
開發者ID:1703011,項目名稱:asuswrt-merlin,代碼行數:7,代碼來源:nouveau_acpi.c

示例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;
}
開發者ID:1703011,項目名稱:asuswrt-merlin,代碼行數:33,代碼來源:nouveau_acpi.c

示例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;
}
開發者ID:wmealing,項目名稱:acpi-stuff,代碼行數:25,代碼來源:acpi_dump_info.c

示例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;
}
開發者ID:ARMWorks,項目名稱:FA_2451_Linux_Kernel,代碼行數:32,代碼來源:usb-acpi.c

示例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;
}
開發者ID:promisejohn,項目名稱:fio-driver,代碼行數:26,代碼來源:pci.c

示例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;
}
開發者ID:1111saeid,項目名稱:jb_kernel_3.0.16_htc_golfu,代碼行數:30,代碼來源:nouveau_acpi.c

示例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;
}
開發者ID:TheFrozenFire,項目名稱:bumblebeed,代碼行數:56,代碼來源:bbswitch.c

示例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
	};
開發者ID:AdrianHuang,項目名稱:linux-3.8.13,代碼行數:11,代碼來源:pci-acpi.c

示例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);
}
開發者ID:ena30,項目名稱:snake-os,代碼行數:12,代碼來源:shpchprm_acpi.c

示例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;
}
開發者ID:Tigrouzen,項目名稱:k1099,代碼行數:62,代碼來源:ide-acpi.c

示例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);
}
開發者ID:AiWinters,項目名稱:linux,代碼行數:23,代碼來源:device_pm.c


注:本文中的DEVICE_ACPI_HANDLE函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。