Lines Matching refs:data
54 int (*set_kbd_backlight)(struct yogabook_data *data, uint8_t level);
65 struct yogabook_data *data = container_of(work, struct yogabook_data, work); in yogabook_work() local
69 if (test_bit(YB_SUSPENDED, &data->flags)) in yogabook_work()
72 if (test_bit(YB_TABLET_MODE, &data->flags)) { in yogabook_work()
75 } else if (test_bit(YB_DIGITIZER_MODE, &data->flags)) { in yogabook_work()
83 if (!kbd_on && test_bit(YB_KBD_IS_ON, &data->flags)) { in yogabook_work()
88 data->set_kbd_backlight(data, 0); in yogabook_work()
89 device_release_driver(data->kbd_dev); in yogabook_work()
90 clear_bit(YB_KBD_IS_ON, &data->flags); in yogabook_work()
93 if (!digitizer_on && test_bit(YB_DIGITIZER_IS_ON, &data->flags)) { in yogabook_work()
94 led_set_brightness(data->pen_led, LED_OFF); in yogabook_work()
95 device_release_driver(data->dig_dev); in yogabook_work()
96 clear_bit(YB_DIGITIZER_IS_ON, &data->flags); in yogabook_work()
99 if (kbd_on && !test_bit(YB_KBD_IS_ON, &data->flags)) { in yogabook_work()
100 r = device_reprobe(data->kbd_dev); in yogabook_work()
102 dev_warn(data->dev, "Reprobe of keyboard touchscreen failed: %d\n", r); in yogabook_work()
104 data->set_kbd_backlight(data, data->brightness); in yogabook_work()
105 set_bit(YB_KBD_IS_ON, &data->flags); in yogabook_work()
108 if (digitizer_on && !test_bit(YB_DIGITIZER_IS_ON, &data->flags)) { in yogabook_work()
109 r = device_reprobe(data->dig_dev); in yogabook_work()
111 dev_warn(data->dev, "Reprobe of digitizer failed: %d\n", r); in yogabook_work()
113 led_set_brightness(data->pen_led, LED_FULL); in yogabook_work()
114 set_bit(YB_DIGITIZER_IS_ON, &data->flags); in yogabook_work()
118 static void yogabook_toggle_digitizer_mode(struct yogabook_data *data) in yogabook_toggle_digitizer_mode() argument
120 if (test_bit(YB_SUSPENDED, &data->flags)) in yogabook_toggle_digitizer_mode()
123 if (test_bit(YB_DIGITIZER_MODE, &data->flags)) in yogabook_toggle_digitizer_mode()
124 clear_bit(YB_DIGITIZER_MODE, &data->flags); in yogabook_toggle_digitizer_mode()
126 set_bit(YB_DIGITIZER_MODE, &data->flags); in yogabook_toggle_digitizer_mode()
132 schedule_work(&data->work); in yogabook_toggle_digitizer_mode()
137 struct yogabook_data *data = _data; in yogabook_backside_hall_irq() local
139 if (gpiod_get_value(data->backside_hall_gpio)) in yogabook_backside_hall_irq()
140 set_bit(YB_TABLET_MODE, &data->flags); in yogabook_backside_hall_irq()
142 clear_bit(YB_TABLET_MODE, &data->flags); in yogabook_backside_hall_irq()
144 schedule_work(&data->work); in yogabook_backside_hall_irq()
153 struct yogabook_data *data = kbd_led_to_yogabook(cdev); in kbd_brightness_get() local
155 return data->brightness; in kbd_brightness_get()
161 struct yogabook_data *data = kbd_led_to_yogabook(cdev); in kbd_brightness_set() local
166 data->brightness = value; in kbd_brightness_set()
168 if (!test_bit(YB_KBD_IS_ON, &data->flags)) in kbd_brightness_set()
171 return data->set_kbd_backlight(data, data->brightness); in kbd_brightness_set()
186 static int yogabook_probe(struct device *dev, struct yogabook_data *data, in yogabook_probe() argument
191 data->dev = dev; in yogabook_probe()
192 data->brightness = YB_KBD_BL_DEFAULT; in yogabook_probe()
193 set_bit(YB_KBD_IS_ON, &data->flags); in yogabook_probe()
194 set_bit(YB_DIGITIZER_IS_ON, &data->flags); in yogabook_probe()
195 INIT_WORK(&data->work, yogabook_work); in yogabook_probe()
199 data->pen_led = devm_led_get(dev, "pen-icon-led"); in yogabook_probe()
202 if (IS_ERR(data->pen_led)) in yogabook_probe()
203 return dev_err_probe(dev, PTR_ERR(data->pen_led), "Getting pen icon LED\n"); in yogabook_probe()
207 data->backside_hall_gpio = devm_gpiod_get(dev, "backside_hall_sw", GPIOD_IN); in yogabook_probe()
210 if (IS_ERR(data->backside_hall_gpio)) in yogabook_probe()
211 return dev_err_probe(dev, PTR_ERR(data->backside_hall_gpio), in yogabook_probe()
214 r = gpiod_to_irq(data->backside_hall_gpio); in yogabook_probe()
218 data->backside_hall_irq = r; in yogabook_probe()
221 data->set_kbd_backlight(data, YB_KBD_BL_DEFAULT); in yogabook_probe()
223 r = request_irq(data->backside_hall_irq, yogabook_backside_hall_irq, in yogabook_probe()
225 "backside_hall_sw", data); in yogabook_probe()
229 schedule_work(&data->work); in yogabook_probe()
231 data->kbd_bl_led.name = kbd_bl_led_name; in yogabook_probe()
232 data->kbd_bl_led.brightness_set_blocking = kbd_brightness_set; in yogabook_probe()
233 data->kbd_bl_led.brightness_get = kbd_brightness_get; in yogabook_probe()
234 data->kbd_bl_led.max_brightness = YB_KBD_BL_MAX; in yogabook_probe()
236 r = devm_led_classdev_register(dev, &data->kbd_bl_led); in yogabook_probe()
242 dev_set_drvdata(dev, data); in yogabook_probe()
246 free_irq(data->backside_hall_irq, data); in yogabook_probe()
247 cancel_work_sync(&data->work); in yogabook_probe()
251 static void yogabook_remove(struct yogabook_data *data) in yogabook_remove() argument
255 free_irq(data->backside_hall_irq, data); in yogabook_remove()
256 cancel_work_sync(&data->work); in yogabook_remove()
258 if (!test_bit(YB_KBD_IS_ON, &data->flags)) in yogabook_remove()
259 r |= device_reprobe(data->kbd_dev); in yogabook_remove()
261 if (!test_bit(YB_DIGITIZER_IS_ON, &data->flags)) in yogabook_remove()
262 r |= device_reprobe(data->dig_dev); in yogabook_remove()
265 dev_warn(data->dev, "Reprobe of devices failed\n"); in yogabook_remove()
270 struct yogabook_data *data = dev_get_drvdata(dev); in yogabook_suspend() local
272 set_bit(YB_SUSPENDED, &data->flags); in yogabook_suspend()
273 flush_work(&data->work); in yogabook_suspend()
275 if (test_bit(YB_KBD_IS_ON, &data->flags)) in yogabook_suspend()
276 data->set_kbd_backlight(data, 0); in yogabook_suspend()
283 struct yogabook_data *data = dev_get_drvdata(dev); in yogabook_resume() local
285 if (test_bit(YB_KBD_IS_ON, &data->flags)) in yogabook_resume()
286 data->set_kbd_backlight(data, data->brightness); in yogabook_resume()
288 clear_bit(YB_SUSPENDED, &data->flags); in yogabook_resume()
291 schedule_work(&data->work); in yogabook_resume()
304 static int yogabook_wmi_set_kbd_backlight(struct yogabook_data *data, in yogabook_wmi_set_kbd_backlight() argument
312 dev_dbg(data->dev, "Set KBLC level to %u\n", level); in yogabook_wmi_set_kbd_backlight()
315 acpi_device_set_power(data->kbd_adev, ACPI_STATE_D0); in yogabook_wmi_set_kbd_backlight()
323 status = acpi_evaluate_object(acpi_device_handle(data->kbd_adev), "KBLC", in yogabook_wmi_set_kbd_backlight()
326 dev_err(data->dev, "Failed to call KBLC method: 0x%x\n", status); in yogabook_wmi_set_kbd_backlight()
337 struct yogabook_data *data; in yogabook_wmi_probe() local
340 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); in yogabook_wmi_probe()
341 if (data == NULL) in yogabook_wmi_probe()
344 data->kbd_adev = acpi_dev_get_first_match_dev("GDIX1001", NULL, -1); in yogabook_wmi_probe()
345 if (!data->kbd_adev) in yogabook_wmi_probe()
348 data->dig_adev = acpi_dev_get_first_match_dev("WCOM0019", NULL, -1); in yogabook_wmi_probe()
349 if (!data->dig_adev) { in yogabook_wmi_probe()
354 data->kbd_dev = get_device(acpi_get_first_physical_node(data->kbd_adev)); in yogabook_wmi_probe()
355 if (!data->kbd_dev || !data->kbd_dev->driver) { in yogabook_wmi_probe()
360 data->dig_dev = get_device(acpi_get_first_physical_node(data->dig_adev)); in yogabook_wmi_probe()
361 if (!data->dig_dev || !data->dig_dev->driver) { in yogabook_wmi_probe()
366 data->set_kbd_backlight = yogabook_wmi_set_kbd_backlight; in yogabook_wmi_probe()
368 r = yogabook_probe(dev, data, "ybwmi::kbd_backlight"); in yogabook_wmi_probe()
375 put_device(data->dig_dev); in yogabook_wmi_probe()
376 put_device(data->kbd_dev); in yogabook_wmi_probe()
377 acpi_dev_put(data->dig_adev); in yogabook_wmi_probe()
378 acpi_dev_put(data->kbd_adev); in yogabook_wmi_probe()
384 struct yogabook_data *data = dev_get_drvdata(&wdev->dev); in yogabook_wmi_remove() local
386 yogabook_remove(data); in yogabook_wmi_remove()
388 put_device(data->dig_dev); in yogabook_wmi_remove()
389 put_device(data->kbd_dev); in yogabook_wmi_remove()
390 acpi_dev_put(data->dig_adev); in yogabook_wmi_remove()
391 acpi_dev_put(data->kbd_adev); in yogabook_wmi_remove()
430 static int yogabook_pdev_set_kbd_backlight(struct yogabook_data *data, u8 level) in yogabook_pdev_set_kbd_backlight() argument
438 pwm_apply_state(data->kbd_bl_pwm, &state); in yogabook_pdev_set_kbd_backlight()
439 gpiod_set_value(data->kbd_bl_led_enable, level ? 1 : 0); in yogabook_pdev_set_kbd_backlight()
443 static irqreturn_t yogabook_pen_touch_irq(int irq, void *data) in yogabook_pen_touch_irq() argument
445 yogabook_toggle_digitizer_mode(data); in yogabook_pen_touch_irq()
452 struct yogabook_data *data; in yogabook_pdev_probe() local
455 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); in yogabook_pdev_probe()
456 if (data == NULL) in yogabook_pdev_probe()
459 data->kbd_dev = bus_find_device_by_name(&i2c_bus_type, NULL, "i2c-goodix_ts"); in yogabook_pdev_probe()
460 if (!data->kbd_dev || !data->kbd_dev->driver) { in yogabook_pdev_probe()
465 data->dig_dev = bus_find_device_by_name(&i2c_bus_type, NULL, "i2c-wacom"); in yogabook_pdev_probe()
466 if (!data->dig_dev || !data->dig_dev->driver) { in yogabook_pdev_probe()
472 data->pen_touch_event = devm_gpiod_get(dev, "pen_touch_event", GPIOD_IN); in yogabook_pdev_probe()
473 data->kbd_bl_led_enable = devm_gpiod_get(dev, "enable_keyboard_led", GPIOD_OUT_HIGH); in yogabook_pdev_probe()
476 if (IS_ERR(data->pen_touch_event)) { in yogabook_pdev_probe()
477 r = dev_err_probe(dev, PTR_ERR(data->pen_touch_event), in yogabook_pdev_probe()
482 if (IS_ERR(data->kbd_bl_led_enable)) { in yogabook_pdev_probe()
483 r = dev_err_probe(dev, PTR_ERR(data->kbd_bl_led_enable), in yogabook_pdev_probe()
488 data->kbd_bl_pwm = devm_pwm_get(dev, "pwm_soc_lpss_2"); in yogabook_pdev_probe()
489 if (IS_ERR(data->kbd_bl_pwm)) { in yogabook_pdev_probe()
490 r = dev_err_probe(dev, PTR_ERR(data->kbd_bl_pwm), in yogabook_pdev_probe()
495 r = gpiod_to_irq(data->pen_touch_event); in yogabook_pdev_probe()
500 data->pen_touch_irq = r; in yogabook_pdev_probe()
502 r = request_irq(data->pen_touch_irq, yogabook_pen_touch_irq, IRQF_TRIGGER_FALLING, in yogabook_pdev_probe()
503 "pen_touch_event", data); in yogabook_pdev_probe()
509 data->set_kbd_backlight = yogabook_pdev_set_kbd_backlight; in yogabook_pdev_probe()
511 r = yogabook_probe(dev, data, "yogabook::kbd_backlight"); in yogabook_pdev_probe()
518 free_irq(data->pen_touch_irq, data); in yogabook_pdev_probe()
519 cancel_work_sync(&data->work); in yogabook_pdev_probe()
521 put_device(data->dig_dev); in yogabook_pdev_probe()
522 put_device(data->kbd_dev); in yogabook_pdev_probe()
528 struct yogabook_data *data = platform_get_drvdata(pdev); in yogabook_pdev_remove() local
530 yogabook_remove(data); in yogabook_pdev_remove()
531 free_irq(data->pen_touch_irq, data); in yogabook_pdev_remove()
532 cancel_work_sync(&data->work); in yogabook_pdev_remove()
533 put_device(data->dig_dev); in yogabook_pdev_remove()
534 put_device(data->kbd_dev); in yogabook_pdev_remove()