Lines Matching +full:res +full:- +full:cpi

4  * SPDX-License-Identifier: Apache-2.0
83 const struct device *dev = data->dev; in pat912x_motion_work_handler()
84 const struct pat912x_config *cfg = dev->config; in pat912x_motion_work_handler()
90 ret = i2c_reg_read_byte_dt(&cfg->i2c, PAT912X_MOTION_STATUS, &val); in pat912x_motion_work_handler()
99 ret = i2c_burst_read_dt(&cfg->i2c, PAT912X_DELTA_X_LO, xy, sizeof(xy)); in pat912x_motion_work_handler()
106 ret = i2c_reg_read_byte_dt(&cfg->i2c, PAT912X_DELTA_XY_HI, &val); in pat912x_motion_work_handler()
113 x = sign_extend(x, PAT912X_DATA_SIZE_BITS - 1); in pat912x_motion_work_handler()
114 y = sign_extend(y, PAT912X_DATA_SIZE_BITS - 1); in pat912x_motion_work_handler()
116 if (cfg->invert_x) { in pat912x_motion_work_handler()
117 x *= -1; in pat912x_motion_work_handler()
119 if (cfg->invert_y) { in pat912x_motion_work_handler()
120 y *= -1; in pat912x_motion_work_handler()
125 if (cfg->axis_x >= 0) { in pat912x_motion_work_handler()
126 bool sync = cfg->axis_y < 0; in pat912x_motion_work_handler()
128 input_report_rel(data->dev, cfg->axis_x, x, sync, K_FOREVER); in pat912x_motion_work_handler()
131 if (cfg->axis_y >= 0) { in pat912x_motion_work_handler()
132 input_report_rel(data->dev, cfg->axis_y, y, true, K_FOREVER); in pat912x_motion_work_handler()
136 k_work_submit(&data->motion_work); in pat912x_motion_work_handler()
146 k_work_submit(&data->motion_work); in pat912x_motion_handler()
152 const struct pat912x_config *cfg = dev->config; in pat912x_set_resolution()
158 return -EINVAL; in pat912x_set_resolution()
161 ret = i2c_reg_write_byte_dt(&cfg->i2c, PAT912X_RES_X, in pat912x_set_resolution()
171 return -EINVAL; in pat912x_set_resolution()
174 ret = i2c_reg_write_byte_dt(&cfg->i2c, PAT912X_RES_Y, in pat912x_set_resolution()
186 const struct pat912x_config *cfg = dev->config; in pat912x_configure()
190 ret = i2c_burst_read_dt(&cfg->i2c, PAT912X_PRODUCT_ID1, id, sizeof(id)); in pat912x_configure()
197 return -ENOTSUP; in pat912x_configure()
202 i2c_reg_write_byte_dt(&cfg->i2c, PAT912X_CONFIGURATION, CONFIGURATION_RESET); in pat912x_configure()
207 ret = i2c_reg_write_byte_dt(&cfg->i2c, PAT912X_CONFIGURATION, CONFIGURATION_CLEAR); in pat912x_configure()
212 ret = pat912x_set_resolution(dev, cfg->res_x_cpi, cfg->res_y_cpi); in pat912x_configure()
217 if (cfg->sleep1_enable && cfg->sleep2_enable) { in pat912x_configure()
218 ret = i2c_reg_update_byte_dt(&cfg->i2c, in pat912x_configure()
225 } else if (cfg->sleep1_enable) { in pat912x_configure()
226 ret = i2c_reg_update_byte_dt(&cfg->i2c, in pat912x_configure()
240 const struct pat912x_config *cfg = dev->config; in pat912x_init()
241 struct pat912x_data *data = dev->data; in pat912x_init()
244 if (!i2c_is_ready_dt(&cfg->i2c)) { in pat912x_init()
245 LOG_ERR("%s is not ready", cfg->i2c.bus->name); in pat912x_init()
246 return -ENODEV; in pat912x_init()
249 data->dev = dev; in pat912x_init()
251 k_work_init(&data->motion_work, pat912x_motion_work_handler); in pat912x_init()
253 if (!gpio_is_ready_dt(&cfg->motion_gpio)) { in pat912x_init()
254 LOG_ERR("%s is not ready", cfg->motion_gpio.port->name); in pat912x_init()
255 return -ENODEV; in pat912x_init()
258 ret = gpio_pin_configure_dt(&cfg->motion_gpio, GPIO_INPUT); in pat912x_init()
264 ret = gpio_pin_interrupt_configure_dt(&cfg->motion_gpio, in pat912x_init()
271 gpio_init_callback(&data->motion_cb, pat912x_motion_handler, in pat912x_init()
272 BIT(cfg->motion_gpio.pin)); in pat912x_init()
280 ret = gpio_add_callback_dt(&cfg->motion_gpio, &data->motion_cb); in pat912x_init()
287 k_work_submit(&data->motion_work); in pat912x_init()
302 const struct pat912x_config *cfg = dev->config; in pat912x_pm_action()
314 return -ENOTSUP; in pat912x_pm_action()
317 ret = i2c_reg_update_byte_dt(&cfg->i2c, PAT912X_CONFIGURATION, in pat912x_pm_action()
329 "invalid res-x-cpi"); \
331 "invalid res-y-cpi"); \
339 .axis_x = DT_INST_PROP_OR(n, zephyr_axis_x, -1), \
340 .axis_y = DT_INST_PROP_OR(n, zephyr_axis_y, -1), \
341 .res_x_cpi = DT_INST_PROP_OR(n, res_x_cpi, -1), \
342 .res_y_cpi = DT_INST_PROP_OR(n, res_y_cpi, -1), \