Lines Matching +full:adc +full:- +full:joystick
1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Oleh Kravchenko (Sparkfun Qwiic Joystick driver)
10 * Datasheet: https://cdn-learn.adafruit.com/downloads/pdf/gamepad-qt.pdf
15 * - Add interrupt support
23 #include <linux/input/sparse-keymap.h>
27 #define SEESAW_DEVICE_NAME "seesaw-gamepad"
92 .addr = client->addr, in seesaw_register_read()
93 .flags = client->flags, in seesaw_register_read()
98 .addr = client->addr, in seesaw_register_read()
99 .flags = client->flags | I2C_M_RD, in seesaw_register_read()
106 ret = i2c_transfer(client->adapter, message_buf, in seesaw_register_read()
156 data->button_state = ~be32_to_cpu(read_buf); in seesaw_read_data()
165 * ADC reads left as max and right as 0, must be reversed since kernel in seesaw_read_data()
168 data->x = SEESAW_JOYSTICK_MAX_AXIS - be16_to_cpu(adc_data); in seesaw_read_data()
177 data->y = be16_to_cpu(adc_data); in seesaw_read_data()
186 private->button_state = 0; in seesaw_open()
198 err = seesaw_read_data(private->i2c_client, &data); in seesaw_poll()
200 dev_err_ratelimited(&input->dev, in seesaw_poll()
201 "failed to read joystick state: %d\n", err); in seesaw_poll()
209 changed = private->button_state ^ data.button_state; in seesaw_poll()
210 private->button_state = data.button_state; in seesaw_poll()
216 dev_err_ratelimited(&input->dev, in seesaw_poll()
236 seesaw = devm_kzalloc(&client->dev, sizeof(*seesaw), GFP_KERNEL); in seesaw_probe()
238 return -ENOMEM; in seesaw_probe()
245 dev_dbg(&client->dev, "Adafruit Seesaw Gamepad, Hardware ID: %02x\n", in seesaw_probe()
248 /* Set Pin Mode to input and enable pull-up resistors */ in seesaw_probe()
262 seesaw->i2c_client = client; in seesaw_probe()
263 seesaw->input_dev = devm_input_allocate_device(&client->dev); in seesaw_probe()
264 if (!seesaw->input_dev) in seesaw_probe()
265 return -ENOMEM; in seesaw_probe()
267 seesaw->input_dev->id.bustype = BUS_I2C; in seesaw_probe()
268 seesaw->input_dev->name = "Adafruit Seesaw Gamepad"; in seesaw_probe()
269 seesaw->input_dev->phys = "i2c/" SEESAW_DEVICE_NAME; in seesaw_probe()
270 seesaw->input_dev->open = seesaw_open; in seesaw_probe()
271 input_set_drvdata(seesaw->input_dev, seesaw); in seesaw_probe()
272 input_set_abs_params(seesaw->input_dev, ABS_X, in seesaw_probe()
275 input_set_abs_params(seesaw->input_dev, ABS_Y, in seesaw_probe()
279 err = sparse_keymap_setup(seesaw->input_dev, seesaw_buttons_new, NULL); in seesaw_probe()
281 dev_err(&client->dev, in seesaw_probe()
286 err = input_setup_polling(seesaw->input_dev, seesaw_poll); in seesaw_probe()
288 dev_err(&client->dev, "failed to set up polling: %d\n", err); in seesaw_probe()
292 input_set_poll_interval(seesaw->input_dev, in seesaw_probe()
294 input_set_max_poll_interval(seesaw->input_dev, SEESAW_GAMEPAD_POLL_MAX); in seesaw_probe()
295 input_set_min_poll_interval(seesaw->input_dev, SEESAW_GAMEPAD_POLL_MIN); in seesaw_probe()
297 err = input_register_device(seesaw->input_dev); in seesaw_probe()
299 dev_err(&client->dev, "failed to register joystick: %d\n", err); in seesaw_probe()
313 { .compatible = "adafruit,seesaw-gamepad"},