Lines Matching refs:sunkbd

56 struct sunkbd {  struct
78 struct sunkbd *sunkbd = serio_get_drvdata(serio); in sunkbd_interrupt() argument
80 if (sunkbd->reset <= -1) { in sunkbd_interrupt()
85 sunkbd->reset = data; in sunkbd_interrupt()
86 wake_up_interruptible(&sunkbd->wait); in sunkbd_interrupt()
90 if (sunkbd->layout == -1) { in sunkbd_interrupt()
91 sunkbd->layout = data; in sunkbd_interrupt()
92 wake_up_interruptible(&sunkbd->wait); in sunkbd_interrupt()
99 if (sunkbd->enabled) in sunkbd_interrupt()
100 schedule_work(&sunkbd->tq); in sunkbd_interrupt()
101 sunkbd->reset = -1; in sunkbd_interrupt()
105 sunkbd->layout = -1; in sunkbd_interrupt()
112 if (!sunkbd->enabled) in sunkbd_interrupt()
115 if (sunkbd->keycode[data & SUNKBD_KEY]) { in sunkbd_interrupt()
116 input_report_key(sunkbd->dev, in sunkbd_interrupt()
117 sunkbd->keycode[data & SUNKBD_KEY], in sunkbd_interrupt()
119 input_sync(sunkbd->dev); in sunkbd_interrupt()
138 struct sunkbd *sunkbd = input_get_drvdata(dev); in sunkbd_event() local
144 serio_write(sunkbd->serio, SUNKBD_CMD_SETLED); in sunkbd_event()
145 serio_write(sunkbd->serio, in sunkbd_event()
157 serio_write(sunkbd->serio, SUNKBD_CMD_NOCLICK - value); in sunkbd_event()
161 serio_write(sunkbd->serio, SUNKBD_CMD_BELLOFF - value); in sunkbd_event()
176 static int sunkbd_initialize(struct sunkbd *sunkbd) in sunkbd_initialize() argument
178 sunkbd->reset = -2; in sunkbd_initialize()
179 serio_write(sunkbd->serio, SUNKBD_CMD_RESET); in sunkbd_initialize()
180 wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ); in sunkbd_initialize()
181 if (sunkbd->reset < 0) in sunkbd_initialize()
184 sunkbd->type = sunkbd->reset; in sunkbd_initialize()
186 if (sunkbd->type == 4) { /* Type 4 keyboard */ in sunkbd_initialize()
187 sunkbd->layout = -2; in sunkbd_initialize()
188 serio_write(sunkbd->serio, SUNKBD_CMD_LAYOUT); in sunkbd_initialize()
189 wait_event_interruptible_timeout(sunkbd->wait, in sunkbd_initialize()
190 sunkbd->layout >= 0, HZ / 4); in sunkbd_initialize()
191 if (sunkbd->layout < 0) in sunkbd_initialize()
193 if (sunkbd->layout & SUNKBD_LAYOUT_5_MASK) in sunkbd_initialize()
194 sunkbd->type = 5; in sunkbd_initialize()
205 static void sunkbd_set_leds_beeps(struct sunkbd *sunkbd) in sunkbd_set_leds_beeps() argument
207 serio_write(sunkbd->serio, SUNKBD_CMD_SETLED); in sunkbd_set_leds_beeps()
208 serio_write(sunkbd->serio, in sunkbd_set_leds_beeps()
209 (!!test_bit(LED_CAPSL, sunkbd->dev->led) << 3) | in sunkbd_set_leds_beeps()
210 (!!test_bit(LED_SCROLLL, sunkbd->dev->led) << 2) | in sunkbd_set_leds_beeps()
211 (!!test_bit(LED_COMPOSE, sunkbd->dev->led) << 1) | in sunkbd_set_leds_beeps()
212 !!test_bit(LED_NUML, sunkbd->dev->led)); in sunkbd_set_leds_beeps()
213 serio_write(sunkbd->serio, in sunkbd_set_leds_beeps()
214 SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev->snd)); in sunkbd_set_leds_beeps()
215 serio_write(sunkbd->serio, in sunkbd_set_leds_beeps()
216 SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev->snd)); in sunkbd_set_leds_beeps()
227 struct sunkbd *sunkbd = container_of(work, struct sunkbd, tq); in sunkbd_reinit() local
234 wait_event_interruptible_timeout(sunkbd->wait, in sunkbd_reinit()
235 sunkbd->reset >= 0 || !sunkbd->enabled, in sunkbd_reinit()
238 if (sunkbd->reset >= 0 && sunkbd->enabled) in sunkbd_reinit()
239 sunkbd_set_leds_beeps(sunkbd); in sunkbd_reinit()
242 static void sunkbd_enable(struct sunkbd *sunkbd, bool enable) in sunkbd_enable() argument
244 serio_pause_rx(sunkbd->serio); in sunkbd_enable()
245 sunkbd->enabled = enable; in sunkbd_enable()
246 serio_continue_rx(sunkbd->serio); in sunkbd_enable()
249 wake_up_interruptible(&sunkbd->wait); in sunkbd_enable()
250 cancel_work_sync(&sunkbd->tq); in sunkbd_enable()
261 struct sunkbd *sunkbd; in sunkbd_connect() local
266 sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); in sunkbd_connect()
268 if (!sunkbd || !input_dev) in sunkbd_connect()
271 sunkbd->serio = serio; in sunkbd_connect()
272 sunkbd->dev = input_dev; in sunkbd_connect()
273 init_waitqueue_head(&sunkbd->wait); in sunkbd_connect()
274 INIT_WORK(&sunkbd->tq, sunkbd_reinit); in sunkbd_connect()
275 snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys); in sunkbd_connect()
277 serio_set_drvdata(serio, sunkbd); in sunkbd_connect()
283 if (sunkbd_initialize(sunkbd) < 0) { in sunkbd_connect()
288 snprintf(sunkbd->name, sizeof(sunkbd->name), in sunkbd_connect()
289 "Sun Type %d keyboard", sunkbd->type); in sunkbd_connect()
290 memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); in sunkbd_connect()
292 input_dev->name = sunkbd->name; in sunkbd_connect()
293 input_dev->phys = sunkbd->phys; in sunkbd_connect()
296 input_dev->id.product = sunkbd->type; in sunkbd_connect()
300 input_set_drvdata(input_dev, sunkbd); in sunkbd_connect()
310 input_dev->keycode = sunkbd->keycode; in sunkbd_connect()
314 __set_bit(sunkbd->keycode[i], input_dev->keybit); in sunkbd_connect()
317 sunkbd_enable(sunkbd, true); in sunkbd_connect()
319 err = input_register_device(sunkbd->dev); in sunkbd_connect()
325 fail4: sunkbd_enable(sunkbd, false); in sunkbd_connect()
329 kfree(sunkbd); in sunkbd_connect()
339 struct sunkbd *sunkbd = serio_get_drvdata(serio); in sunkbd_disconnect() local
341 sunkbd_enable(sunkbd, false); in sunkbd_disconnect()
342 input_unregister_device(sunkbd->dev); in sunkbd_disconnect()
345 kfree(sunkbd); in sunkbd_disconnect()