Lines Matching full:pad
72 static int psxpad_command(struct psxpad *pad, const u8 sendcmdlen) in psxpad_command() argument
75 .tx_buf = pad->sendbuf, in psxpad_command()
76 .rx_buf = pad->response, in psxpad_command()
81 err = spi_sync_transfer(pad->spi, &xfers, 1); in psxpad_command()
83 dev_err(&pad->spi->dev, in psxpad_command()
93 static void psxpad_control_motor(struct psxpad *pad, in psxpad_control_motor() argument
98 pad->motor1enable = motor1enable; in psxpad_control_motor()
99 pad->motor2enable = motor2enable; in psxpad_control_motor()
101 memcpy(pad->sendbuf, PSX_CMD_ENTER_CFG, sizeof(PSX_CMD_ENTER_CFG)); in psxpad_control_motor()
102 err = psxpad_command(pad, sizeof(PSX_CMD_ENTER_CFG)); in psxpad_control_motor()
104 dev_err(&pad->spi->dev, in psxpad_control_motor()
110 memcpy(pad->sendbuf, PSX_CMD_ENABLE_MOTOR, in psxpad_control_motor()
112 pad->sendbuf[3] = pad->motor1enable ? 0x00 : 0xFF; in psxpad_control_motor()
113 pad->sendbuf[4] = pad->motor2enable ? 0x80 : 0xFF; in psxpad_control_motor()
114 err = psxpad_command(pad, sizeof(PSX_CMD_ENABLE_MOTOR)); in psxpad_control_motor()
116 dev_err(&pad->spi->dev, in psxpad_control_motor()
122 memcpy(pad->sendbuf, PSX_CMD_EXIT_CFG, sizeof(PSX_CMD_EXIT_CFG)); in psxpad_control_motor()
123 err = psxpad_command(pad, sizeof(PSX_CMD_EXIT_CFG)); in psxpad_control_motor()
125 dev_err(&pad->spi->dev, in psxpad_control_motor()
132 static void psxpad_set_motor_level(struct psxpad *pad, in psxpad_set_motor_level() argument
135 pad->motor1level = motor1level ? 0xFF : 0x00; in psxpad_set_motor_level()
136 pad->motor2level = REVERSE_BIT(motor2level); in psxpad_set_motor_level()
142 struct psxpad *pad = input_get_drvdata(idev); in psxpad_spi_play_effect() local
146 psxpad_set_motor_level(pad, in psxpad_spi_play_effect()
155 static int psxpad_spi_init_ff(struct psxpad *pad) in psxpad_spi_init_ff() argument
159 input_set_capability(pad->idev, EV_FF, FF_RUMBLE); in psxpad_spi_init_ff()
161 err = input_ff_create_memless(pad->idev, NULL, psxpad_spi_play_effect); in psxpad_spi_init_ff()
163 dev_err(&pad->spi->dev, in psxpad_spi_init_ff()
173 static void psxpad_control_motor(struct psxpad *pad, in psxpad_control_motor() argument
178 static void psxpad_set_motor_level(struct psxpad *pad, in psxpad_set_motor_level() argument
183 static inline int psxpad_spi_init_ff(struct psxpad *pad) in psxpad_spi_init_ff() argument
191 struct psxpad *pad = input_get_drvdata(input); in psxpad_spi_poll_open() local
193 pm_runtime_get_sync(&pad->spi->dev); in psxpad_spi_poll_open()
200 struct psxpad *pad = input_get_drvdata(input); in psxpad_spi_poll_close() local
202 pm_runtime_put_sync(&pad->spi->dev); in psxpad_spi_poll_close()
207 struct psxpad *pad = input_get_drvdata(input); in psxpad_spi_poll() local
211 psxpad_control_motor(pad, true, true); in psxpad_spi_poll()
213 memcpy(pad->sendbuf, PSX_CMD_POLL, sizeof(PSX_CMD_POLL)); in psxpad_spi_poll()
214 pad->sendbuf[3] = pad->motor1enable ? pad->motor1level : 0x00; in psxpad_spi_poll()
215 pad->sendbuf[4] = pad->motor2enable ? pad->motor2level : 0x00; in psxpad_spi_poll()
216 err = psxpad_command(pad, sizeof(PSX_CMD_POLL)); in psxpad_spi_poll()
218 dev_err(&pad->spi->dev, in psxpad_spi_poll()
223 switch (pad->response[1]) { in psxpad_spi_poll()
226 b_rsp3 = ~pad->response[3]; in psxpad_spi_poll()
227 b_rsp4 = ~pad->response[4]; in psxpad_spi_poll()
229 input_report_abs(input, ABS_X, REVERSE_BIT(pad->response[7])); in psxpad_spi_poll()
230 input_report_abs(input, ABS_Y, REVERSE_BIT(pad->response[8])); in psxpad_spi_poll()
231 input_report_abs(input, ABS_RX, REVERSE_BIT(pad->response[5])); in psxpad_spi_poll()
232 input_report_abs(input, ABS_RY, REVERSE_BIT(pad->response[6])); in psxpad_spi_poll()
253 b_rsp3 = ~pad->response[3]; in psxpad_spi_poll()
254 b_rsp4 = ~pad->response[4]; in psxpad_spi_poll()
284 struct psxpad *pad; in psxpad_spi_probe() local
288 pad = devm_kzalloc(&spi->dev, sizeof(struct psxpad), GFP_KERNEL); in psxpad_spi_probe()
289 if (!pad) in psxpad_spi_probe()
299 pad->idev = idev; in psxpad_spi_probe()
300 pad->spi = spi; in psxpad_spi_probe()
303 input_set_drvdata(idev, pad); in psxpad_spi_probe()
306 snprintf(pad->phys, sizeof(pad->phys), "%s/input", dev_name(&spi->dev)); in psxpad_spi_probe()
334 err = psxpad_spi_init_ff(pad); in psxpad_spi_probe()
346 /* pad settings */ in psxpad_spi_probe()
347 psxpad_set_motor_level(pad, 0, 0); in psxpad_spi_probe()
377 struct psxpad *pad = spi_get_drvdata(spi); in psxpad_spi_suspend() local
379 psxpad_set_motor_level(pad, 0, 0); in psxpad_spi_suspend()