Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hid/ietp.c
| Show First 20 Lines • Show All 444 Lines • ▼ Show 20 Lines | ietp_res2dpmm(uint8_t res, bool hi_precision) | ||||
| return (dpi * 10 /254); | return (dpi * 10 /254); | ||||
| } | } | ||||
| static void | static void | ||||
| ietp_iic_identify(driver_t *driver, device_t parent) | ietp_iic_identify(driver_t *driver, device_t parent) | ||||
| { | { | ||||
| device_t iichid = device_get_parent(parent); | device_t iichid = device_get_parent(parent); | ||||
| static const uint16_t reg = IETP_PATTERN; | static const uint16_t reg = IETP_PATTERN; | ||||
| uint16_t addr = iicbus_get_addr(iichid) << 1; | uint16_t addr; | ||||
| uint8_t resp[2]; | uint8_t resp[2]; | ||||
| uint8_t cmd[2] = { reg & 0xff, (reg >> 8) & 0xff }; | uint8_t cmd[2] = { reg & 0xff, (reg >> 8) & 0xff }; | ||||
| struct iic_msg msgs[2] = { | struct iic_msg msgs[2]; | ||||
| { addr, IIC_M_WR | IIC_M_NOSTOP, sizeof(cmd), cmd }, | |||||
| { addr, IIC_M_RD, sizeof(resp), resp }, | |||||
| }; | |||||
| struct iic_rdwr_data ird = { msgs, nitems(msgs) }; | struct iic_rdwr_data ird = { msgs, nitems(msgs) }; | ||||
| uint8_t pattern; | uint8_t pattern; | ||||
| if (HIDBUS_LOOKUP_ID(parent, ietp_iic_devs) == NULL) | if (HIDBUS_LOOKUP_ID(parent, ietp_iic_devs) == NULL) | ||||
| return; | return; | ||||
| if (device_get_devclass(iichid) != devclass_find("iichid")) | if (device_get_devclass(iichid) != devclass_find("iichid")) | ||||
| return; | return; | ||||
| addr = iicbus_get_addr(iichid) << 1; | |||||
| msgs[0] = (struct iic_msg){ addr, IIC_M_WR | IIC_M_NOSTOP, sizeof(cmd), cmd }; | |||||
| msgs[1] = (struct iic_msg){ addr, IIC_M_RD, sizeof(resp), resp }; | |||||
| DPRINTF("Read reg 0x%04x with size %zu\n", reg, sizeof(resp)); | DPRINTF("Read reg 0x%04x with size %zu\n", reg, sizeof(resp)); | ||||
| if (hid_ioctl(parent, I2CRDWR, (uintptr_t)&ird) != 0) | if (hid_ioctl(parent, I2CRDWR, (uintptr_t)&ird) != 0) | ||||
| return; | return; | ||||
| DPRINTF("Response: %*D\n", (int)size(resp), resp, " "); | DPRINTF("Response: %*D\n", (int)size(resp), resp, " "); | ||||
| pattern = (resp[0] == 0xFF && resp[1] == 0xFF) ? 0 : resp[1]; | pattern = (resp[0] == 0xFF && resp[1] == 0xFF) ? 0 : resp[1]; | ||||
| ▲ Show 20 Lines • Show All 239 Lines • Show Last 20 Lines | |||||