Lines Matching +full:scaling +full:- +full:x +full:- +full:resolution
4 * SPDX-License-Identifier: Apache-2.0
27 * Standard registers have 5-bit addresses, BIT[4:0], that range from
87 /* X max to 0 */
136 #define PINNACLE_SPI_FC 0xFC /* Auto-increment byte */
217 const struct pinnacle_config *config = dev->config; in pinnacle_bus_is_ready()
219 return config->bus.is_ready(&config->bus); in pinnacle_bus_is_ready()
224 const struct pinnacle_config *config = dev->config; in pinnacle_write()
226 return config->bus.write(&config->bus, address, value); in pinnacle_write()
231 const struct pinnacle_config *config = dev->config; in pinnacle_seq_write()
233 return config->bus.seq_write(&config->bus, address, value, count); in pinnacle_seq_write()
237 const struct pinnacle_config *config = dev->config; in pinnacle_read()
239 return config->bus.read(&config->bus, address, value); in pinnacle_read()
245 const struct pinnacle_config *config = dev->config; in pinnacle_seq_read()
247 return config->bus.seq_read(&config->bus, address, data, count); in pinnacle_seq_read()
252 const struct pinnacle_config *config = dev->config; in pinnacle_clear_cmd_complete()
254 return config->bus.write(&config->bus, PINNACLE_REG_STATUS1, 0x00); in pinnacle_clear_cmd_complete()
267 return -EIO; in pinnacle_era_wait_for_completion()
326 const struct pinnacle_config *config = dev->config; in pinnacle_set_sensitivity()
339 switch (config->sensitivity) { in pinnacle_set_sensitivity()
371 if (!i2c_is_ready_dt(&bus->i2c)) { in pinnacle_is_ready_i2c()
372 LOG_ERR("I2C bus %s is not ready", bus->i2c.bus->name); in pinnacle_is_ready_i2c()
383 return i2c_write_dt(&bus->i2c, buf, 2); in pinnacle_write_i2c()
396 return i2c_write_dt(&bus->i2c, buf, count * 2); in pinnacle_seq_write_i2c()
403 return i2c_write_read_dt(&bus->i2c, ®, 1, value, 1); in pinnacle_read_i2c()
411 return i2c_burst_read_dt(&bus->i2c, reg, buf, count); in pinnacle_seq_read_i2c()
418 if (!spi_is_ready_dt(&bus->spi)) { in pinnacle_is_ready_spi()
419 LOG_ERR("SPI bus %s is not ready", bus->spi.bus->name); in pinnacle_is_ready_spi()
441 return spi_write_dt(&bus->spi, &tx_set); in pinnacle_write_spi()
462 return spi_write_dt(&bus->spi, &tx_set); in pinnacle_seq_write_spi()
499 rc = spi_transceive_dt(&bus->spi, &tx_set, &rx_set); in pinnacle_read_spi()
501 LOG_ERR("Failed to read from SPI %s", bus->spi.bus->name); in pinnacle_read_spi()
553 rc = spi_transceive_dt(&bus->spi, &tx_set, &rx_set); in pinnacle_seq_read_spi()
555 LOG_ERR("Failed to read from SPI %s", bus->spi.bus->name); in pinnacle_seq_read_spi()
566 const struct pinnacle_config *config = dev->config; in pinnacle_decode_sample()
568 if (config->relative_mode) { in pinnacle_decode_sample()
569 if (config->primary_tap_enabled) { in pinnacle_decode_sample()
570 sample->btn_primary = (rx[0] & BIT(0)) == BIT(0); in pinnacle_decode_sample()
572 sample->rel_x = ((rx[0] & BIT(4)) == BIT(4)) ? -(256 - rx[1]) : rx[1]; in pinnacle_decode_sample()
573 sample->rel_y = ((rx[0] & BIT(5)) == BIT(5)) ? -(256 - rx[2]) : rx[2]; in pinnacle_decode_sample()
575 sample->abs_x = ((rx[2] & 0x0F) << 8) | rx[0]; in pinnacle_decode_sample()
576 sample->abs_y = ((rx[2] & 0xF0) << 4) | rx[1]; in pinnacle_decode_sample()
577 sample->abs_z = rx[3] & 0x3F; in pinnacle_decode_sample()
583 return (sample->abs_x == 0 && sample->abs_y == 0 && sample->abs_z == 0); in pinnacle_is_idle_sample()
588 const struct pinnacle_config *config = dev->config; in pinnacle_clip_sample()
590 if (sample->abs_x < config->active_range_x_min) { in pinnacle_clip_sample()
591 sample->abs_x = config->active_range_x_min; in pinnacle_clip_sample()
593 if (sample->abs_x > config->active_range_x_max) { in pinnacle_clip_sample()
594 sample->abs_x = config->active_range_x_max; in pinnacle_clip_sample()
596 if (sample->abs_y < config->active_range_y_min) { in pinnacle_clip_sample()
597 sample->abs_y = config->active_range_y_min; in pinnacle_clip_sample()
599 if (sample->abs_y > config->active_range_y_max) { in pinnacle_clip_sample()
600 sample->abs_y = config->active_range_y_max; in pinnacle_clip_sample()
606 const struct pinnacle_config *config = dev->config; in pinnacle_scale_sample()
608 uint16_t range_x = config->active_range_x_max - config->active_range_x_min; in pinnacle_scale_sample()
609 uint16_t range_y = config->active_range_y_max - config->active_range_y_min; in pinnacle_scale_sample()
611 sample->abs_x = (uint16_t)((uint32_t)(sample->abs_x - config->active_range_x_min) * in pinnacle_scale_sample()
612 config->resolution_x / range_x); in pinnacle_scale_sample()
613 sample->abs_y = (uint16_t)((uint32_t)(sample->abs_y - config->active_range_y_min) * in pinnacle_scale_sample()
614 config->resolution_y / range_y); in pinnacle_scale_sample()
619 const struct pinnacle_config *config = dev->config; in pinnacle_sample_fetch()
624 if (config->relative_mode) { in pinnacle_sample_fetch()
648 const struct pinnacle_config *config = dev->config; in pinnacle_handle_interrupt()
649 struct pinnacle_data *drv_data = dev->data; in pinnacle_handle_interrupt()
650 union pinnacle_sample *sample = &drv_data->sample; in pinnacle_handle_interrupt()
660 if (config->relative_mode) { in pinnacle_handle_interrupt()
661 input_report_rel(dev, INPUT_REL_X, sample->rel_x, false, K_FOREVER); in pinnacle_handle_interrupt()
662 input_report_rel(dev, INPUT_REL_Y, sample->rel_y, !config->primary_tap_enabled, in pinnacle_handle_interrupt()
664 if (config->primary_tap_enabled) { in pinnacle_handle_interrupt()
665 input_report_key(dev, INPUT_BTN_TOUCH, sample->btn_primary, true, in pinnacle_handle_interrupt()
669 if (config->clipping_enabled && !pinnacle_is_idle_sample(sample)) { in pinnacle_handle_interrupt()
671 if (config->scaling_enabled) { in pinnacle_handle_interrupt()
676 input_report_abs(dev, INPUT_ABS_X, sample->abs_x, false, K_FOREVER); in pinnacle_handle_interrupt()
677 input_report_abs(dev, INPUT_ABS_Y, sample->abs_y, false, K_FOREVER); in pinnacle_handle_interrupt()
678 input_report_abs(dev, INPUT_ABS_Z, sample->abs_z, true, K_FOREVER); in pinnacle_handle_interrupt()
689 k_work_submit(&drv_data->work); in pinnacle_data_ready_gpio_callback()
696 pinnacle_handle_interrupt(drv_data->dev); in pinnacle_work_cb()
701 struct pinnacle_data *drv_data = dev->data; in pinnacle_init_interrupt()
702 const struct pinnacle_config *config = dev->config; in pinnacle_init_interrupt()
703 const struct gpio_dt_spec *gpio = &config->dr_gpio; in pinnacle_init_interrupt()
707 drv_data->dev = dev; in pinnacle_init_interrupt()
708 drv_data->work.handler = pinnacle_work_cb; in pinnacle_init_interrupt()
713 LOG_ERR("GPIO device %s/%d is not ready", gpio->port->name, gpio->pin); in pinnacle_init_interrupt()
714 return -ENODEV; in pinnacle_init_interrupt()
719 LOG_ERR("Failed to configure %s/%d as input", gpio->port->name, gpio->pin); in pinnacle_init_interrupt()
725 LOG_ERR("Failed to configured interrupt for %s/%d", gpio->port->name, gpio->pin); in pinnacle_init_interrupt()
729 gpio_init_callback(&drv_data->dr_cb_data, pinnacle_data_ready_gpio_callback, in pinnacle_init_interrupt()
730 BIT(gpio->pin)); in pinnacle_init_interrupt()
732 rc = gpio_add_callback(gpio->port, &drv_data->dr_cb_data); in pinnacle_init_interrupt()
734 LOG_ERR("Failed to configured interrupt for %s/%d", gpio->port->name, gpio->pin); in pinnacle_init_interrupt()
743 const struct pinnacle_config *config = dev->config; in pinnacle_init()
750 return -ENODEV; in pinnacle_init()
760 LOG_ERR("Incorrect Firmware ASIC ID %x", value); in pinnacle_init()
761 return -ENODEV; in pinnacle_init()
772 return -EIO; in pinnacle_init()
779 return -EIO; in pinnacle_init()
786 return -EIO; in pinnacle_init()
796 if (config->relative_mode) { in pinnacle_init()
800 if (config->swap_xy) { in pinnacle_init()
803 if (!config->primary_tap_enabled) { in pinnacle_init()
820 if (!config->relative_mode) { in pinnacle_init()
822 if (config->invert_x) { in pinnacle_init()
825 if (config->invert_y) { in pinnacle_init()
835 /* Configure count of Z-Idle packets */ in pinnacle_init()
836 rc = pinnacle_write(dev, PINNACLE_REG_Z_IDLE, config->idle_packets_count); in pinnacle_init()
838 LOG_ERR("Failed to set count of Z-idle packets"); in pinnacle_init()
899 "active-range-x-min must be less than active-range-x-max"); \
902 "active_range-y-min must be less than active_range-y-max"); \
904 "scaling-x-resolution must be positive"); \
906 "scaling-y-resolution must be positive"); \
908 "idle-packets-count must be in range [0:255]");