Esempio n. 1
0
static int
hdmi_read(uint8_t page, uint8_t reg, uint8_t * val)
{

	int r;

	if (val == NULL) {
		log_warn(&log, "Read called with NULL pointer\n");
		return EINVAL;
	}

	if (page != HDMI_PAGELESS) {
		r = set_page(page);
		if (r != OK) {
			log_warn(&log, "Unable to set page to 0x%x\n", page);
			return r;
		}
	}

	r = i2creg_read8(hdmi_bus_endpoint, hdmi_address, reg, val);
	if (r != OK) {
		log_warn(&log, "hdmi_read() failed (r=%d)\n", r);
		return -1;
	}

	log_trace(&log, "Read 0x%x from reg 0x%x in page 0x%x\n", *val, reg,
	    page);

	return OK;
}
Esempio n. 2
0
/*
 * Check to see if a display is connected.
 * Returns 1 for yes, 0 for no, -1 for error.
 */
static int
is_display_connected(void)
{
	int r;
	uint8_t val;

	r = i2creg_read8(cec_bus_endpoint, cec_address, CEC_STATUS_REG, &val);
	if (r != OK) {
		log_warn(&log, "Reading connection status failed (r=%d)\n", r);
		return -1;
	}

	if ((CEC_STATUS_CONNECTED_MASK & val) == 0) {
		log_debug(&log, "No Display Detected\n");
		return 0;
	} else {
		log_debug(&log, "Display Detected\n");
		return 1;
	}
}
Esempio n. 3
0
static int
check_revision(void)
{
	int r;
	uint32_t idcode;
	uint8_t idcode_7_0, idcode_15_8, idcode_23_16, idcode_31_24;

	/* need to write a special code to unlock read protect on IDCODE */
	r = i2creg_write8(bus_endpoint, addresses[ID2], UNLOCK_TEST_REG,
	    UNLOCK_TEST_CODE);
	if (r != OK) {
		log_warn(&log, "Failed to write unlock code to UNLOCK_TEST\n");
		return -1;
	}

	/*
	 * read each part of the IDCODE
	 */
	r = i2creg_read8(bus_endpoint, addresses[ID2], IDCODE_7_0_REG,
	    &idcode_7_0);
	if (r != OK) {
		log_warn(&log, "Failed to read IDCODE part 1\n");
	}

	r = i2creg_read8(bus_endpoint, addresses[ID2], IDCODE_15_8_REG,
	    &idcode_15_8);
	if (r != OK) {
		log_warn(&log, "Failed to read IDCODE part 2\n");
	}

	r = i2creg_read8(bus_endpoint, addresses[ID2], IDCODE_23_16_REG,
	    &idcode_23_16);
	if (r != OK) {
		log_warn(&log, "Failed to read IDCODE part 3\n");
	}

	r = i2creg_read8(bus_endpoint, addresses[ID2], IDCODE_31_24_REG,
	    &idcode_31_24);
	if (r != OK) {
		log_warn(&log, "Failed to read IDCODE part 4\n");
	}

	/* combine the parts to get the full IDCODE */
	idcode =
	    ((idcode_31_24 << 24) | (idcode_23_16 << 16) | (idcode_15_8 << 8) |
	    (idcode_7_0 << 0));

	log_debug(&log, "IDCODE = 0x%x\n", idcode);
	switch (idcode) {
	case IDCODE_REV_1_0:
		log_debug(&log, "TPS65950 rev 1.0\n");
		break;
	case IDCODE_REV_1_1:
		log_debug(&log, "TPS65950 rev 1.1\n");
		break;
	case IDCODE_REV_1_2:
		log_debug(&log, "TPS65950 rev 1.2\n");
		break;
	default:
		log_warn(&log, "Unexpected IDCODE: 0x%x\n", idcode);
		return -1;
	}

	return OK;
}