当前位置: 首页>>代码示例>>C++>>正文


C++ Port::IsConnected方法代码示例

本文整理汇总了C++中Port::IsConnected方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::IsConnected方法的具体用法?C++ Port::IsConnected怎么用?C++ Port::IsConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Port的用法示例。


在下文中一共展示了Port::IsConnected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

static void
dump_ports()
{
	if (gInfo->port_count == 0) {
		TRACE("%s: No ports connected\n", __func__);
		return;
	}

	TRACE("%s: Connected ports: (port_count: %" B_PRIu32 ")\n", __func__,
		gInfo->port_count);

	for (uint32 i = 0; i < gInfo->port_count; i++) {
		Port* port = gInfo->ports[i];
		if (!port) {
			TRACE("port %" B_PRIu32 ":: INVALID ALLOC!\n", i);
			continue;
		}
		TRACE("port %" B_PRIu32 ": %s %s\n", i, port->PortName(),
			port->IsConnected() ? "connected" : "disconnected");
	}
}
开发者ID:koletzky,项目名称:haiku,代码行数:21,代码来源:accelerant.cpp

示例2: new

static status_t
probe_ports()
{
	// Try to determine what ports to use. We use the following heuristic:
	// * Check for DisplayPort, these can be more or less detected reliably.
	// * Check for HDMI, it'll fail on devices not having HDMI for us to fall
	//   back to DVI.
	// * Assume DVI B if no HDMI and no DisplayPort is present, confirmed by
	//   reading EDID in the IsConnected() call.
	// * Check for analog if possible (there's a detection bit on PCH),
	//   otherwise the assumed presence is confirmed by reading EDID in
	//   IsConnected().

	TRACE("adpa: %08" B_PRIx32 "\n", read32(INTEL_ANALOG_PORT));
	TRACE("dova: %08" B_PRIx32 ", dovb: %08" B_PRIx32
		", dovc: %08" B_PRIx32 "\n", read32(INTEL_DIGITAL_PORT_A),
		read32(INTEL_DIGITAL_PORT_B), read32(INTEL_DIGITAL_PORT_C));
	TRACE("lvds: %08" B_PRIx32 "\n", read32(INTEL_DIGITAL_LVDS_PORT));

	bool foundLVDS = false;

	gInfo->port_count = 0;
	for (int i = INTEL_PORT_A; i <= INTEL_PORT_D; i++) {
		Port* displayPort = new(std::nothrow) DisplayPort((port_index)i);
		if (displayPort == NULL)
			return B_NO_MEMORY;

		if (displayPort->IsConnected())
			gInfo->ports[gInfo->port_count++] = displayPort;
		else
			delete displayPort;
	}

	// Digital Display Interface
	if (gInfo->shared_info->device_type.HasDDI()) {
		for (int i = INTEL_PORT_A; i <= INTEL_PORT_E; i++) {
			Port* ddiPort
				= new(std::nothrow) DigitalDisplayInterface((port_index)i);

			if (ddiPort == NULL)
				return B_NO_MEMORY;

			if (ddiPort->IsConnected())
				gInfo->ports[gInfo->port_count++] = ddiPort;
			else
				delete ddiPort;
		}
	}

	// Ensure DP_A isn't already taken (or DDI)
	if (!has_connected_port((port_index)INTEL_PORT_A, INTEL_PORT_TYPE_ANY)) {
		// also always try eDP, it'll also just fail if not applicable
		Port* eDPPort = new(std::nothrow) EmbeddedDisplayPort();
		if (eDPPort == NULL)
			return B_NO_MEMORY;
		if (eDPPort->IsConnected())
			gInfo->ports[gInfo->port_count++] = eDPPort;
		else
			delete eDPPort;
	}

	for (int i = INTEL_PORT_B; i <= INTEL_PORT_D; i++) {
		if (has_connected_port((port_index)i, INTEL_PORT_TYPE_ANY)) {
			// Ensure port not already claimed by something like DDI
			continue;
		}

		Port* hdmiPort = new(std::nothrow) HDMIPort((port_index)i);
		if (hdmiPort == NULL)
			return B_NO_MEMORY;

		if (hdmiPort->IsConnected())
			gInfo->ports[gInfo->port_count++] = hdmiPort;
		else
			delete hdmiPort;
	}

	if (!has_connected_port(INTEL_PORT_ANY, INTEL_PORT_TYPE_ANY)) {
		// there's neither DisplayPort nor HDMI so far, assume DVI B
		Port* dviPort = new(std::nothrow) DigitalPort(INTEL_PORT_B);
		if (dviPort == NULL)
			return B_NO_MEMORY;

		if (dviPort->IsConnected()) {
			gInfo->ports[gInfo->port_count++] = dviPort;
			gInfo->head_mode |= HEAD_MODE_B_DIGITAL;
		} else
			delete dviPort;
	}

	// always try the LVDS port, it'll simply fail if not applicable
	Port* lvdsPort = new(std::nothrow) LVDSPort();
	if (lvdsPort == NULL)
		return B_NO_MEMORY;
	if (lvdsPort->IsConnected()) {
		foundLVDS = true;
		gInfo->ports[gInfo->port_count++] = lvdsPort;
		gInfo->head_mode |= HEAD_MODE_LVDS_PANEL;
		gInfo->head_mode |= HEAD_MODE_B_DIGITAL;
	} else
//.........这里部分代码省略.........
开发者ID:koletzky,项目名称:haiku,代码行数:101,代码来源:accelerant.cpp


注:本文中的Port::IsConnected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。