Lines Matching full:pm

88 	struct powermate_device *pm = urb->context;  in powermate_irq()  local
89 struct device *dev = &pm->intf->dev; in powermate_irq()
110 input_report_key(pm->input, BTN_0, pm->data[0] & 0x01); in powermate_irq()
111 input_report_rel(pm->input, REL_DIAL, pm->data[1]); in powermate_irq()
112 input_sync(pm->input); in powermate_irq()
121 /* Decide if we need to issue a control message and do so. Must be called with pm->lock taken */
122 static void powermate_sync_state(struct powermate_device *pm) in powermate_sync_state() argument
124 if (pm->requires_update == 0) in powermate_sync_state()
126 if (pm->config->status == -EINPROGRESS) in powermate_sync_state()
129 if (pm->requires_update & UPDATE_PULSE_ASLEEP){ in powermate_sync_state()
130 pm->configcr->wValue = cpu_to_le16( SET_PULSE_ASLEEP ); in powermate_sync_state()
131 pm->configcr->wIndex = cpu_to_le16( pm->pulse_asleep ? 1 : 0 ); in powermate_sync_state()
132 pm->requires_update &= ~UPDATE_PULSE_ASLEEP; in powermate_sync_state()
133 }else if (pm->requires_update & UPDATE_PULSE_AWAKE){ in powermate_sync_state()
134 pm->configcr->wValue = cpu_to_le16( SET_PULSE_AWAKE ); in powermate_sync_state()
135 pm->configcr->wIndex = cpu_to_le16( pm->pulse_awake ? 1 : 0 ); in powermate_sync_state()
136 pm->requires_update &= ~UPDATE_PULSE_AWAKE; in powermate_sync_state()
137 }else if (pm->requires_update & UPDATE_PULSE_MODE){ in powermate_sync_state()
156 if (pm->pulse_speed < 255) { in powermate_sync_state()
158 arg = 255 - pm->pulse_speed; in powermate_sync_state()
159 } else if (pm->pulse_speed > 255) { in powermate_sync_state()
161 arg = pm->pulse_speed - 255; in powermate_sync_state()
166 pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE ); in powermate_sync_state()
167 pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op ); in powermate_sync_state()
168 pm->requires_update &= ~UPDATE_PULSE_MODE; in powermate_sync_state()
169 } else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS) { in powermate_sync_state()
170 pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS ); in powermate_sync_state()
171 pm->configcr->wIndex = cpu_to_le16( pm->static_brightness ); in powermate_sync_state()
172 pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS; in powermate_sync_state()
175 pm->requires_update = 0; /* fudge the bug */ in powermate_sync_state()
179 /* printk("powermate: %04x %04x\n", pm->configcr->wValue, pm->configcr->wIndex); */ in powermate_sync_state()
181 pm->configcr->bRequestType = 0x41; /* vendor request */ in powermate_sync_state()
182 pm->configcr->bRequest = 0x01; in powermate_sync_state()
183 pm->configcr->wLength = 0; in powermate_sync_state()
185 usb_fill_control_urb(pm->config, pm->udev, usb_sndctrlpipe(pm->udev, 0), in powermate_sync_state()
186 (void *) pm->configcr, NULL, 0, in powermate_sync_state()
187 powermate_config_complete, pm); in powermate_sync_state()
189 if (usb_submit_urb(pm->config, GFP_ATOMIC)) in powermate_sync_state()
196 struct powermate_device *pm = urb->context; in powermate_config_complete() local
202 spin_lock_irqsave(&pm->lock, flags); in powermate_config_complete()
203 powermate_sync_state(pm); in powermate_config_complete()
204 spin_unlock_irqrestore(&pm->lock, flags); in powermate_config_complete()
208 static void powermate_pulse_led(struct powermate_device *pm, int static_brightness, int pulse_speed, in powermate_pulse_led() argument
226 spin_lock_irqsave(&pm->lock, flags); in powermate_pulse_led()
229 if (static_brightness != pm->static_brightness) { in powermate_pulse_led()
230 pm->static_brightness = static_brightness; in powermate_pulse_led()
231 pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; in powermate_pulse_led()
233 if (pulse_asleep != pm->pulse_asleep) { in powermate_pulse_led()
234 pm->pulse_asleep = pulse_asleep; in powermate_pulse_led()
235 pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS); in powermate_pulse_led()
237 if (pulse_awake != pm->pulse_awake) { in powermate_pulse_led()
238 pm->pulse_awake = pulse_awake; in powermate_pulse_led()
239 pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS); in powermate_pulse_led()
241 if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table) { in powermate_pulse_led()
242 pm->pulse_speed = pulse_speed; in powermate_pulse_led()
243 pm->pulse_table = pulse_table; in powermate_pulse_led()
244 pm->requires_update |= UPDATE_PULSE_MODE; in powermate_pulse_led()
247 powermate_sync_state(pm); in powermate_pulse_led()
249 spin_unlock_irqrestore(&pm->lock, flags); in powermate_pulse_led()
256 struct powermate_device *pm = input_get_drvdata(dev); in powermate_input_event() local
272 powermate_pulse_led(pm, static_brightness, pulse_speed, pulse_table, pulse_asleep, pulse_awake); in powermate_input_event()
278 static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm) in powermate_alloc_buffers() argument
280 pm->data = usb_alloc_coherent(udev, POWERMATE_PAYLOAD_SIZE_MAX, in powermate_alloc_buffers()
281 GFP_KERNEL, &pm->data_dma); in powermate_alloc_buffers()
282 if (!pm->data) in powermate_alloc_buffers()
285 pm->configcr = kmalloc(sizeof(*(pm->configcr)), GFP_KERNEL); in powermate_alloc_buffers()
286 if (!pm->configcr) in powermate_alloc_buffers()
292 static void powermate_free_buffers(struct usb_device *udev, struct powermate_device *pm) in powermate_free_buffers() argument
295 pm->data, pm->data_dma); in powermate_free_buffers()
296 kfree(pm->configcr); in powermate_free_buffers()
305 struct powermate_device *pm; in powermate_probe() local
323 pm = kzalloc(sizeof(*pm), GFP_KERNEL); in powermate_probe()
325 if (!pm || !input_dev) in powermate_probe()
328 if (powermate_alloc_buffers(udev, pm)) in powermate_probe()
331 pm->irq = usb_alloc_urb(0, GFP_KERNEL); in powermate_probe()
332 if (!pm->irq) in powermate_probe()
335 pm->config = usb_alloc_urb(0, GFP_KERNEL); in powermate_probe()
336 if (!pm->config) in powermate_probe()
339 pm->udev = udev; in powermate_probe()
340 pm->intf = intf; in powermate_probe()
341 pm->input = input_dev; in powermate_probe()
343 usb_make_path(udev, pm->phys, sizeof(pm->phys)); in powermate_probe()
344 strlcat(pm->phys, "/input0", sizeof(pm->phys)); in powermate_probe()
346 spin_lock_init(&pm->lock); in powermate_probe()
361 input_dev->phys = pm->phys; in powermate_probe()
365 input_set_drvdata(input_dev, pm); in powermate_probe()
385 usb_fill_int_urb(pm->irq, udev, pipe, pm->data, in powermate_probe()
387 pm, endpoint->bInterval); in powermate_probe()
388 pm->irq->transfer_dma = pm->data_dma; in powermate_probe()
389 pm->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in powermate_probe()
392 if (usb_submit_urb(pm->irq, GFP_KERNEL)) { in powermate_probe()
397 error = input_register_device(pm->input); in powermate_probe()
403pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC… in powermate_probe()
404 powermate_pulse_led(pm, 0x80, 255, 0, 1, 0); // set default pulse parameters in powermate_probe()
406 usb_set_intfdata(intf, pm); in powermate_probe()
409 fail5: usb_kill_urb(pm->irq); in powermate_probe()
410 fail4: usb_free_urb(pm->config); in powermate_probe()
411 fail3: usb_free_urb(pm->irq); in powermate_probe()
412 fail2: powermate_free_buffers(udev, pm); in powermate_probe()
414 kfree(pm); in powermate_probe()
421 struct powermate_device *pm = usb_get_intfdata (intf); in powermate_disconnect() local
424 if (pm) { in powermate_disconnect()
425 pm->requires_update = 0; in powermate_disconnect()
426 usb_kill_urb(pm->irq); in powermate_disconnect()
427 input_unregister_device(pm->input); in powermate_disconnect()
428 usb_kill_urb(pm->config); in powermate_disconnect()
429 usb_free_urb(pm->irq); in powermate_disconnect()
430 usb_free_urb(pm->config); in powermate_disconnect()
431 powermate_free_buffers(interface_to_usbdev(intf), pm); in powermate_disconnect()
433 kfree(pm); in powermate_disconnect()