Lines Matching full:w
62 static inline void walkera0701_parse_frame(struct walkera_dev *w) in walkera0701_parse_frame() argument
70 crc1 += w->buf[i] & 7; in walkera0701_parse_frame()
71 crc2 += (w->buf[i] & 8) >> 3; in walkera0701_parse_frame()
73 if ((w->buf[10] & 7) != (crc1 & 7)) in walkera0701_parse_frame()
75 if (((w->buf[10] & 8) >> 3) != (((crc1 >> 3) + crc2) & 1)) in walkera0701_parse_frame()
78 crc1 += w->buf[i] & 7; in walkera0701_parse_frame()
79 crc2 += (w->buf[i] & 8) >> 3; in walkera0701_parse_frame()
81 if ((w->buf[23] & 7) != (crc1 & 7)) in walkera0701_parse_frame()
83 if (((w->buf[23] & 8) >> 3) != (((crc1 >> 3) + crc2) & 1)) in walkera0701_parse_frame()
85 val1 = ((w->buf[0] & 7) * 256 + w->buf[1] * 16 + w->buf[2]) >> 2; in walkera0701_parse_frame()
86 val1 *= ((w->buf[0] >> 2) & 2) - 1; /* sign */ in walkera0701_parse_frame()
87 val2 = (w->buf[2] & 1) << 8 | (w->buf[3] << 4) | w->buf[4]; in walkera0701_parse_frame()
88 val2 *= (w->buf[2] & 2) - 1; /* sign */ in walkera0701_parse_frame()
89 val3 = ((w->buf[5] & 7) * 256 + w->buf[6] * 16 + w->buf[7]) >> 2; in walkera0701_parse_frame()
90 val3 *= ((w->buf[5] >> 2) & 2) - 1; /* sign */ in walkera0701_parse_frame()
91 val4 = (w->buf[7] & 1) << 8 | (w->buf[8] << 4) | w->buf[9]; in walkera0701_parse_frame()
92 val4 *= (w->buf[7] & 2) - 1; /* sign */ in walkera0701_parse_frame()
93 val5 = ((w->buf[11] & 7) * 256 + w->buf[12] * 16 + w->buf[13]) >> 2; in walkera0701_parse_frame()
94 val5 *= ((w->buf[11] >> 2) & 2) - 1; /* sign */ in walkera0701_parse_frame()
95 val6 = (w->buf[13] & 1) << 8 | (w->buf[14] << 4) | w->buf[15]; in walkera0701_parse_frame()
96 val6 *= (w->buf[13] & 2) - 1; /* sign */ in walkera0701_parse_frame()
97 val7 = ((w->buf[16] & 7) * 256 + w->buf[17] * 16 + w->buf[18]) >> 2; in walkera0701_parse_frame()
98 val7 *= ((w->buf[16] >> 2) & 2) - 1; /*sign */ in walkera0701_parse_frame()
99 val8 = (w->buf[18] & 1) << 8 | (w->buf[19] << 4) | w->buf[20]; in walkera0701_parse_frame()
100 val8 *= (w->buf[18] & 2) - 1; /*sign */ in walkera0701_parse_frame()
102 magic = (w->buf[21] << 4) | w->buf[22]; in walkera0701_parse_frame()
103 magic_bit = (w->buf[24] & 8) >> 3; in walkera0701_parse_frame()
108 input_report_abs(w->input_dev, ABS_X, val2); in walkera0701_parse_frame()
109 input_report_abs(w->input_dev, ABS_Y, val1); in walkera0701_parse_frame()
110 input_report_abs(w->input_dev, ABS_Z, val6); in walkera0701_parse_frame()
111 input_report_abs(w->input_dev, ABS_THROTTLE, val3); in walkera0701_parse_frame()
112 input_report_abs(w->input_dev, ABS_RUDDER, val4); in walkera0701_parse_frame()
113 input_report_abs(w->input_dev, ABS_MISC, val7); in walkera0701_parse_frame()
114 input_report_key(w->input_dev, BTN_GEAR_DOWN, val5 > 0); in walkera0701_parse_frame()
126 struct walkera_dev *w = handler_data; in walkera0701_irq_handler() local
128 w->irq_time = ktime_to_ns(ktime_get()); in walkera0701_irq_handler()
129 pulse_time = w->irq_time - w->irq_lasttime; in walkera0701_irq_handler()
130 w->irq_lasttime = w->irq_time; in walkera0701_irq_handler()
133 if (unlikely(0 != hrtimer_try_to_cancel(&w->timer))) { in walkera0701_irq_handler()
134 w->counter = NO_SYNC; in walkera0701_irq_handler()
138 if (w->counter < NO_SYNC) { in walkera0701_irq_handler()
139 if (w->ack) { in walkera0701_irq_handler()
141 w->buf[w->counter] = 8; in walkera0701_irq_handler()
144 w->buf[w->counter] = 0; in walkera0701_irq_handler()
146 if (w->counter == 24) { /* full frame */ in walkera0701_irq_handler()
147 walkera0701_parse_frame(w); in walkera0701_irq_handler()
148 w->counter = NO_SYNC; in walkera0701_irq_handler()
150 w->counter = 0; in walkera0701_irq_handler()
156 w->buf[w->counter++] |= (pulse_time & 7); in walkera0701_irq_handler()
158 w->counter = NO_SYNC; in walkera0701_irq_handler()
162 w->counter = 0; in walkera0701_irq_handler()
164 hrtimer_start(&w->timer, BIN_SAMPLE, HRTIMER_MODE_REL); in walkera0701_irq_handler()
170 struct walkera_dev *w; in timer_handler() local
172 w = container_of(handle, struct walkera_dev, timer); in timer_handler()
173 w->ack = read_ack(w->pardevice); in timer_handler()
180 struct walkera_dev *w = input_get_drvdata(dev); in walkera0701_open() local
182 if (parport_claim(w->pardevice)) in walkera0701_open()
185 parport_enable_irq(w->parport); in walkera0701_open()
191 struct walkera_dev *w = input_get_drvdata(dev); in walkera0701_close() local
193 parport_disable_irq(w->parport); in walkera0701_close()
194 hrtimer_cancel(&w->timer); in walkera0701_close()
196 parport_release(w->pardevice); in walkera0701_close()
202 struct walkera_dev *w = &w_dev; in walkera0701_attach() local
215 w->parport = pp; in walkera0701_attach()
220 walkera0701_parport_cb.private = w; in walkera0701_attach()
222 w->pardevice = parport_register_dev_model(pp, "walkera0701", in walkera0701_attach()
225 if (!w->pardevice) { in walkera0701_attach()
230 if (parport_negotiate(w->pardevice->port, IEEE1284_MODE_COMPAT)) { in walkera0701_attach()
235 hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in walkera0701_attach()
236 w->timer.function = timer_handler; in walkera0701_attach()
238 w->input_dev = input_allocate_device(); in walkera0701_attach()
239 if (!w->input_dev) { in walkera0701_attach()
244 input_set_drvdata(w->input_dev, w); in walkera0701_attach()
245 w->input_dev->name = "Walkera WK-0701 TX"; in walkera0701_attach()
246 w->input_dev->phys = w->parport->name; in walkera0701_attach()
247 w->input_dev->id.bustype = BUS_PARPORT; in walkera0701_attach()
250 w->input_dev->id.vendor = 0x0001; in walkera0701_attach()
251 w->input_dev->id.product = 0x0001; in walkera0701_attach()
252 w->input_dev->id.version = 0x0100; in walkera0701_attach()
253 w->input_dev->dev.parent = w->parport->dev; in walkera0701_attach()
254 w->input_dev->open = walkera0701_open; in walkera0701_attach()
255 w->input_dev->close = walkera0701_close; in walkera0701_attach()
257 w->input_dev->evbit[0] = BIT(EV_ABS) | BIT_MASK(EV_KEY); in walkera0701_attach()
258 w->input_dev->keybit[BIT_WORD(BTN_GEAR_DOWN)] = BIT_MASK(BTN_GEAR_DOWN); in walkera0701_attach()
260 input_set_abs_params(w->input_dev, ABS_X, -512, 512, 0, 0); in walkera0701_attach()
261 input_set_abs_params(w->input_dev, ABS_Y, -512, 512, 0, 0); in walkera0701_attach()
262 input_set_abs_params(w->input_dev, ABS_Z, -512, 512, 0, 0); in walkera0701_attach()
263 input_set_abs_params(w->input_dev, ABS_THROTTLE, -512, 512, 0, 0); in walkera0701_attach()
264 input_set_abs_params(w->input_dev, ABS_RUDDER, -512, 512, 0, 0); in walkera0701_attach()
265 input_set_abs_params(w->input_dev, ABS_MISC, -512, 512, 0, 0); in walkera0701_attach()
267 if (input_register_device(w->input_dev)) { in walkera0701_attach()
275 input_free_device(w->input_dev); in walkera0701_attach()
277 parport_unregister_device(w->pardevice); in walkera0701_attach()
282 struct walkera_dev *w = &w_dev; in walkera0701_detach() local
284 if (!w->pardevice || w->parport->number != port->number) in walkera0701_detach()
287 input_unregister_device(w->input_dev); in walkera0701_detach()
288 parport_unregister_device(w->pardevice); in walkera0701_detach()
289 w->parport = NULL; in walkera0701_detach()