Lines Matching full:sw
24 int (*get_state)(struct ssam_tablet_sw *sw, u32 *state);
25 const char *(*state_name)(struct ssam_tablet_sw *sw, u32 state);
26 bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw, u32 state);
48 int (*get_state)(struct ssam_tablet_sw *sw, u32 *state);
49 const char *(*state_name)(struct ssam_tablet_sw *sw, u32 state);
50 bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw, u32 state);
63 struct ssam_tablet_sw *sw = dev_get_drvdata(dev); in state_show() local
64 const char *state = sw->ops.state_name(sw, sw->state); in state_show()
81 struct ssam_tablet_sw *sw = container_of(work, struct ssam_tablet_sw, update_work); in ssam_tablet_sw_update_workfn() local
85 status = sw->ops.get_state(sw, &state); in ssam_tablet_sw_update_workfn()
89 if (sw->state == state) in ssam_tablet_sw_update_workfn()
91 sw->state = state; in ssam_tablet_sw_update_workfn()
94 tablet = sw->ops.state_is_tablet_mode(sw, state); in ssam_tablet_sw_update_workfn()
95 input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet); in ssam_tablet_sw_update_workfn()
96 input_sync(sw->mode_switch); in ssam_tablet_sw_update_workfn()
101 struct ssam_tablet_sw *sw = dev_get_drvdata(dev); in ssam_tablet_sw_resume() local
103 schedule_work(&sw->update_work); in ssam_tablet_sw_resume()
111 struct ssam_tablet_sw *sw; in ssam_tablet_sw_probe() local
120 sw = devm_kzalloc(&sdev->dev, sizeof(*sw), GFP_KERNEL); in ssam_tablet_sw_probe()
121 if (!sw) in ssam_tablet_sw_probe()
124 sw->sdev = sdev; in ssam_tablet_sw_probe()
126 sw->ops.get_state = desc->ops.get_state; in ssam_tablet_sw_probe()
127 sw->ops.state_name = desc->ops.state_name; in ssam_tablet_sw_probe()
128 sw->ops.state_is_tablet_mode = desc->ops.state_is_tablet_mode; in ssam_tablet_sw_probe()
130 INIT_WORK(&sw->update_work, ssam_tablet_sw_update_workfn); in ssam_tablet_sw_probe()
132 ssam_device_set_drvdata(sdev, sw); in ssam_tablet_sw_probe()
135 status = sw->ops.get_state(sw, &sw->state); in ssam_tablet_sw_probe()
140 sw->mode_switch = devm_input_allocate_device(&sdev->dev); in ssam_tablet_sw_probe()
141 if (!sw->mode_switch) in ssam_tablet_sw_probe()
144 sw->mode_switch->name = desc->dev.name; in ssam_tablet_sw_probe()
145 sw->mode_switch->phys = desc->dev.phys; in ssam_tablet_sw_probe()
146 sw->mode_switch->id.bustype = BUS_HOST; in ssam_tablet_sw_probe()
147 sw->mode_switch->dev.parent = &sdev->dev; in ssam_tablet_sw_probe()
149 tablet = sw->ops.state_is_tablet_mode(sw, sw->state); in ssam_tablet_sw_probe()
150 input_set_capability(sw->mode_switch, EV_SW, SW_TABLET_MODE); in ssam_tablet_sw_probe()
151 input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet); in ssam_tablet_sw_probe()
153 status = input_register_device(sw->mode_switch); in ssam_tablet_sw_probe()
158 sw->notif.base.priority = 0; in ssam_tablet_sw_probe()
159 sw->notif.base.fn = desc->ops.notify; in ssam_tablet_sw_probe()
160 sw->notif.event.reg = desc->event.reg; in ssam_tablet_sw_probe()
161 sw->notif.event.id = desc->event.id; in ssam_tablet_sw_probe()
162 sw->notif.event.mask = desc->event.mask; in ssam_tablet_sw_probe()
163 sw->notif.event.flags = SSAM_EVENT_SEQUENCED; in ssam_tablet_sw_probe()
165 status = ssam_device_notifier_register(sdev, &sw->notif); in ssam_tablet_sw_probe()
174 schedule_work(&sw->update_work); in ssam_tablet_sw_probe()
178 ssam_device_notifier_unregister(sdev, &sw->notif); in ssam_tablet_sw_probe()
179 cancel_work_sync(&sw->update_work); in ssam_tablet_sw_probe()
185 struct ssam_tablet_sw *sw = ssam_device_get_drvdata(sdev); in ssam_tablet_sw_remove() local
189 ssam_device_notifier_unregister(sdev, &sw->notif); in ssam_tablet_sw_remove()
190 cancel_work_sync(&sw->update_work); in ssam_tablet_sw_remove()
206 static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw, u32 state) in ssam_kip_cover_state_name() argument
225 dev_warn(&sw->sdev->dev, "unknown KIP cover state: %u\n", state); in ssam_kip_cover_state_name()
230 static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 state) in ssam_kip_cover_state_is_tablet_mode() argument
243 dev_warn(&sw->sdev->dev, "unknown KIP cover state: %d\n", sw->state); in ssam_kip_cover_state_is_tablet_mode()
255 static int ssam_kip_get_cover_state(struct ssam_tablet_sw *sw, u32 *state) in ssam_kip_get_cover_state() argument
260 status = ssam_retry(__ssam_kip_get_cover_state, sw->sdev->ctrl, &raw); in ssam_kip_get_cover_state()
262 dev_err(&sw->sdev->dev, "failed to query KIP lid state: %d\n", status); in ssam_kip_get_cover_state()
272 struct ssam_tablet_sw *sw = container_of(nf, struct ssam_tablet_sw, notif); in ssam_kip_sw_notif() local
278 dev_warn(&sw->sdev->dev, "unexpected payload size: %u\n", event->length); in ssam_kip_sw_notif()
280 schedule_work(&sw->update_work); in ssam_kip_sw_notif()
327 static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw, u32 state) in ssam_pos_state_name() argument
343 dev_warn(&sw->sdev->dev, "unknown device posture: %u\n", state); in ssam_pos_state_name()
348 static bool ssam_pos_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 state) in ssam_pos_state_is_tablet_mode() argument
362 dev_warn(&sw->sdev->dev, "unknown device posture: %u\n", state); in ssam_pos_state_is_tablet_mode()
367 static int ssam_pos_get_sources_list(struct ssam_tablet_sw *sw, struct ssam_sources_list *sources) in ssam_pos_get_sources_list() argument
385 status = ssam_retry(ssam_request_sync_onstack, sw->sdev->ctrl, &rqst, &rsp, 0); in ssam_pos_get_sources_list()
391 dev_err(&sw->sdev->dev, "received source list response is too small\n"); in ssam_pos_get_sources_list()
397 dev_err(&sw->sdev->dev, "mismatch between number of sources and response size\n"); in ssam_pos_get_sources_list()
404 static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id) in ssam_pos_get_source() argument
409 status = ssam_pos_get_sources_list(sw, &sources); in ssam_pos_get_source()
414 dev_err(&sw->sdev->dev, "no posture sources found\n"); in ssam_pos_get_source()
438 static int ssam_pos_get_posture_for_source(struct ssam_tablet_sw *sw, u32 source_id, u32 *posture) in ssam_pos_get_posture_for_source() argument
444 status = ssam_retry(__ssam_pos_get_posture_for_source, sw->sdev->ctrl, in ssam_pos_get_posture_for_source()
453 static int ssam_pos_get_posture(struct ssam_tablet_sw *sw, u32 *state) in ssam_pos_get_posture() argument
458 status = ssam_pos_get_source(sw, &source_id); in ssam_pos_get_posture()
460 dev_err(&sw->sdev->dev, "failed to get posture source ID: %d\n", status); in ssam_pos_get_posture()
464 status = ssam_pos_get_posture_for_source(sw, source_id, state); in ssam_pos_get_posture()
466 dev_err(&sw->sdev->dev, "failed to get posture value for source %u: %d\n", in ssam_pos_get_posture()
476 struct ssam_tablet_sw *sw = container_of(nf, struct ssam_tablet_sw, notif); in ssam_pos_sw_notif() local
482 dev_warn(&sw->sdev->dev, "unexpected payload size: %u\n", event->length); in ssam_pos_sw_notif()
484 schedule_work(&sw->update_work); in ssam_pos_sw_notif()