Lines Matching refs:sunkbd
59 struct sunkbd { struct
81 struct sunkbd *sunkbd = serio_get_drvdata(serio); in sunkbd_interrupt() argument
83 if (sunkbd->reset <= -1) { in sunkbd_interrupt()
88 sunkbd->reset = data; in sunkbd_interrupt()
89 wake_up_interruptible(&sunkbd->wait); in sunkbd_interrupt()
93 if (sunkbd->layout == -1) { in sunkbd_interrupt()
94 sunkbd->layout = data; in sunkbd_interrupt()
95 wake_up_interruptible(&sunkbd->wait); in sunkbd_interrupt()
102 if (sunkbd->enabled) in sunkbd_interrupt()
103 schedule_work(&sunkbd->tq); in sunkbd_interrupt()
104 sunkbd->reset = -1; in sunkbd_interrupt()
108 sunkbd->layout = -1; in sunkbd_interrupt()
115 if (!sunkbd->enabled) in sunkbd_interrupt()
118 if (sunkbd->keycode[data & SUNKBD_KEY]) { in sunkbd_interrupt()
119 input_report_key(sunkbd->dev, in sunkbd_interrupt()
120 sunkbd->keycode[data & SUNKBD_KEY], in sunkbd_interrupt()
122 input_sync(sunkbd->dev); in sunkbd_interrupt()
141 struct sunkbd *sunkbd = input_get_drvdata(dev); in sunkbd_event() local
147 serio_write(sunkbd->serio, SUNKBD_CMD_SETLED); in sunkbd_event()
148 serio_write(sunkbd->serio, in sunkbd_event()
160 serio_write(sunkbd->serio, SUNKBD_CMD_NOCLICK - value); in sunkbd_event()
164 serio_write(sunkbd->serio, SUNKBD_CMD_BELLOFF - value); in sunkbd_event()
179 static int sunkbd_initialize(struct sunkbd *sunkbd) in sunkbd_initialize() argument
181 sunkbd->reset = -2; in sunkbd_initialize()
182 serio_write(sunkbd->serio, SUNKBD_CMD_RESET); in sunkbd_initialize()
183 wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ); in sunkbd_initialize()
184 if (sunkbd->reset < 0) in sunkbd_initialize()
187 sunkbd->type = sunkbd->reset; in sunkbd_initialize()
189 if (sunkbd->type == 4) { /* Type 4 keyboard */ in sunkbd_initialize()
190 sunkbd->layout = -2; in sunkbd_initialize()
191 serio_write(sunkbd->serio, SUNKBD_CMD_LAYOUT); in sunkbd_initialize()
192 wait_event_interruptible_timeout(sunkbd->wait, in sunkbd_initialize()
193 sunkbd->layout >= 0, HZ / 4); in sunkbd_initialize()
194 if (sunkbd->layout < 0) in sunkbd_initialize()
196 if (sunkbd->layout & SUNKBD_LAYOUT_5_MASK) in sunkbd_initialize()
197 sunkbd->type = 5; in sunkbd_initialize()
208 static void sunkbd_set_leds_beeps(struct sunkbd *sunkbd) in sunkbd_set_leds_beeps() argument
210 serio_write(sunkbd->serio, SUNKBD_CMD_SETLED); in sunkbd_set_leds_beeps()
211 serio_write(sunkbd->serio, in sunkbd_set_leds_beeps()
212 (!!test_bit(LED_CAPSL, sunkbd->dev->led) << 3) | in sunkbd_set_leds_beeps()
213 (!!test_bit(LED_SCROLLL, sunkbd->dev->led) << 2) | in sunkbd_set_leds_beeps()
214 (!!test_bit(LED_COMPOSE, sunkbd->dev->led) << 1) | in sunkbd_set_leds_beeps()
215 !!test_bit(LED_NUML, sunkbd->dev->led)); in sunkbd_set_leds_beeps()
216 serio_write(sunkbd->serio, in sunkbd_set_leds_beeps()
217 SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev->snd)); in sunkbd_set_leds_beeps()
218 serio_write(sunkbd->serio, in sunkbd_set_leds_beeps()
219 SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev->snd)); in sunkbd_set_leds_beeps()
230 struct sunkbd *sunkbd = container_of(work, struct sunkbd, tq); in sunkbd_reinit() local
237 wait_event_interruptible_timeout(sunkbd->wait, in sunkbd_reinit()
238 sunkbd->reset >= 0 || !sunkbd->enabled, in sunkbd_reinit()
241 if (sunkbd->reset >= 0 && sunkbd->enabled) in sunkbd_reinit()
242 sunkbd_set_leds_beeps(sunkbd); in sunkbd_reinit()
245 static void sunkbd_enable(struct sunkbd *sunkbd, bool enable) in sunkbd_enable() argument
247 serio_pause_rx(sunkbd->serio); in sunkbd_enable()
248 sunkbd->enabled = enable; in sunkbd_enable()
249 serio_continue_rx(sunkbd->serio); in sunkbd_enable()
252 wake_up_interruptible(&sunkbd->wait); in sunkbd_enable()
253 cancel_work_sync(&sunkbd->tq); in sunkbd_enable()
264 struct sunkbd *sunkbd; in sunkbd_connect() local
269 sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); in sunkbd_connect()
271 if (!sunkbd || !input_dev) in sunkbd_connect()
274 sunkbd->serio = serio; in sunkbd_connect()
275 sunkbd->dev = input_dev; in sunkbd_connect()
276 init_waitqueue_head(&sunkbd->wait); in sunkbd_connect()
277 INIT_WORK(&sunkbd->tq, sunkbd_reinit); in sunkbd_connect()
278 snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys); in sunkbd_connect()
280 serio_set_drvdata(serio, sunkbd); in sunkbd_connect()
286 if (sunkbd_initialize(sunkbd) < 0) { in sunkbd_connect()
291 snprintf(sunkbd->name, sizeof(sunkbd->name), in sunkbd_connect()
292 "Sun Type %d keyboard", sunkbd->type); in sunkbd_connect()
293 memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); in sunkbd_connect()
295 input_dev->name = sunkbd->name; in sunkbd_connect()
296 input_dev->phys = sunkbd->phys; in sunkbd_connect()
299 input_dev->id.product = sunkbd->type; in sunkbd_connect()
303 input_set_drvdata(input_dev, sunkbd); in sunkbd_connect()
313 input_dev->keycode = sunkbd->keycode; in sunkbd_connect()
317 __set_bit(sunkbd->keycode[i], input_dev->keybit); in sunkbd_connect()
320 sunkbd_enable(sunkbd, true); in sunkbd_connect()
322 err = input_register_device(sunkbd->dev); in sunkbd_connect()
328 fail4: sunkbd_enable(sunkbd, false); in sunkbd_connect()
332 kfree(sunkbd); in sunkbd_connect()
342 struct sunkbd *sunkbd = serio_get_drvdata(serio); in sunkbd_disconnect() local
344 sunkbd_enable(sunkbd, false); in sunkbd_disconnect()
345 input_unregister_device(sunkbd->dev); in sunkbd_disconnect()
348 kfree(sunkbd); in sunkbd_disconnect()