Lines Matching refs:sw

29 	int (*get_state)(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state);
30 const char *(*state_name)(struct ssam_tablet_sw *sw,
32 bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw,
55 int (*get_state)(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state);
56 const char *(*state_name)(struct ssam_tablet_sw *sw,
58 bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw,
72 struct ssam_tablet_sw *sw = dev_get_drvdata(dev); in state_show() local
73 const char *state = sw->ops.state_name(sw, &sw->state); in state_show()
90 struct ssam_tablet_sw *sw = container_of(work, struct ssam_tablet_sw, update_work); in ssam_tablet_sw_update_workfn() local
94 status = sw->ops.get_state(sw, &state); in ssam_tablet_sw_update_workfn()
98 if (sw->state.source == state.source && sw->state.state == state.state) in ssam_tablet_sw_update_workfn()
100 sw->state = state; in ssam_tablet_sw_update_workfn()
103 tablet = sw->ops.state_is_tablet_mode(sw, &state); in ssam_tablet_sw_update_workfn()
104 input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet); in ssam_tablet_sw_update_workfn()
105 input_sync(sw->mode_switch); in ssam_tablet_sw_update_workfn()
110 struct ssam_tablet_sw *sw = dev_get_drvdata(dev); in ssam_tablet_sw_resume() local
112 schedule_work(&sw->update_work); in ssam_tablet_sw_resume()
120 struct ssam_tablet_sw *sw; in ssam_tablet_sw_probe() local
129 sw = devm_kzalloc(&sdev->dev, sizeof(*sw), GFP_KERNEL); in ssam_tablet_sw_probe()
130 if (!sw) in ssam_tablet_sw_probe()
133 sw->sdev = sdev; in ssam_tablet_sw_probe()
135 sw->ops.get_state = desc->ops.get_state; in ssam_tablet_sw_probe()
136 sw->ops.state_name = desc->ops.state_name; in ssam_tablet_sw_probe()
137 sw->ops.state_is_tablet_mode = desc->ops.state_is_tablet_mode; in ssam_tablet_sw_probe()
139 INIT_WORK(&sw->update_work, ssam_tablet_sw_update_workfn); in ssam_tablet_sw_probe()
141 ssam_device_set_drvdata(sdev, sw); in ssam_tablet_sw_probe()
144 status = sw->ops.get_state(sw, &sw->state); in ssam_tablet_sw_probe()
149 sw->mode_switch = devm_input_allocate_device(&sdev->dev); in ssam_tablet_sw_probe()
150 if (!sw->mode_switch) in ssam_tablet_sw_probe()
153 sw->mode_switch->name = desc->dev.name; in ssam_tablet_sw_probe()
154 sw->mode_switch->phys = desc->dev.phys; in ssam_tablet_sw_probe()
155 sw->mode_switch->id.bustype = BUS_HOST; in ssam_tablet_sw_probe()
156 sw->mode_switch->dev.parent = &sdev->dev; in ssam_tablet_sw_probe()
158 tablet = sw->ops.state_is_tablet_mode(sw, &sw->state); in ssam_tablet_sw_probe()
159 input_set_capability(sw->mode_switch, EV_SW, SW_TABLET_MODE); in ssam_tablet_sw_probe()
160 input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet); in ssam_tablet_sw_probe()
162 status = input_register_device(sw->mode_switch); in ssam_tablet_sw_probe()
167 sw->notif.base.priority = 0; in ssam_tablet_sw_probe()
168 sw->notif.base.fn = desc->ops.notify; in ssam_tablet_sw_probe()
169 sw->notif.event.reg = desc->event.reg; in ssam_tablet_sw_probe()
170 sw->notif.event.id = desc->event.id; in ssam_tablet_sw_probe()
171 sw->notif.event.mask = desc->event.mask; in ssam_tablet_sw_probe()
172 sw->notif.event.flags = SSAM_EVENT_SEQUENCED; in ssam_tablet_sw_probe()
174 status = ssam_device_notifier_register(sdev, &sw->notif); in ssam_tablet_sw_probe()
183 schedule_work(&sw->update_work); in ssam_tablet_sw_probe()
187 ssam_device_notifier_unregister(sdev, &sw->notif); in ssam_tablet_sw_probe()
188 cancel_work_sync(&sw->update_work); in ssam_tablet_sw_probe()
194 struct ssam_tablet_sw *sw = ssam_device_get_drvdata(sdev); in ssam_tablet_sw_remove() local
198 ssam_device_notifier_unregister(sdev, &sw->notif); in ssam_tablet_sw_remove()
199 cancel_work_sync(&sw->update_work); in ssam_tablet_sw_remove()
216 static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw, in ssam_kip_cover_state_name() argument
239 dev_warn(&sw->sdev->dev, "unknown KIP cover state: %u\n", state->state); in ssam_kip_cover_state_name()
244 static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw, in ssam_kip_cover_state_is_tablet_mode() argument
259 dev_warn(&sw->sdev->dev, "unknown KIP cover state: %d\n", state->state); in ssam_kip_cover_state_is_tablet_mode()
271 static int ssam_kip_get_cover_state(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state) in ssam_kip_get_cover_state() argument
276 status = ssam_retry(__ssam_kip_get_cover_state, sw->sdev->ctrl, &raw); in ssam_kip_get_cover_state()
278 dev_err(&sw->sdev->dev, "failed to query KIP lid state: %d\n", status); in ssam_kip_get_cover_state()
289 struct ssam_tablet_sw *sw = container_of(nf, struct ssam_tablet_sw, notif); in ssam_kip_sw_notif() local
295 dev_warn(&sw->sdev->dev, "unexpected payload size: %u\n", event->length); in ssam_kip_sw_notif()
297 schedule_work(&sw->update_work); in ssam_kip_sw_notif()
358 static const char *ssam_pos_state_name_cover(struct ssam_tablet_sw *sw, u32 state) in ssam_pos_state_name_cover() argument
380 dev_warn(&sw->sdev->dev, "unknown device posture for type-cover: %u\n", state); in ssam_pos_state_name_cover()
385 static const char *ssam_pos_state_name_sls(struct ssam_tablet_sw *sw, u32 state) in ssam_pos_state_name_sls() argument
401 dev_warn(&sw->sdev->dev, "unknown device posture for SLS: %u\n", state); in ssam_pos_state_name_sls()
406 static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw, in ssam_pos_state_name() argument
411 return ssam_pos_state_name_cover(sw, state->state); in ssam_pos_state_name()
414 return ssam_pos_state_name_sls(sw, state->state); in ssam_pos_state_name()
417 dev_warn(&sw->sdev->dev, "unknown device posture source: %u\n", state->source); in ssam_pos_state_name()
422 static bool ssam_pos_state_is_tablet_mode_cover(struct ssam_tablet_sw *sw, u32 state) in ssam_pos_state_is_tablet_mode_cover() argument
436 dev_warn(&sw->sdev->dev, "unknown device posture for type-cover: %u\n", state); in ssam_pos_state_is_tablet_mode_cover()
441 static bool ssam_pos_state_is_tablet_mode_sls(struct ssam_tablet_sw *sw, u32 state) in ssam_pos_state_is_tablet_mode_sls() argument
455 dev_warn(&sw->sdev->dev, "unknown device posture for SLS: %u\n", state); in ssam_pos_state_is_tablet_mode_sls()
460 static bool ssam_pos_state_is_tablet_mode(struct ssam_tablet_sw *sw, in ssam_pos_state_is_tablet_mode() argument
465 return ssam_pos_state_is_tablet_mode_cover(sw, state->state); in ssam_pos_state_is_tablet_mode()
468 return ssam_pos_state_is_tablet_mode_sls(sw, state->state); in ssam_pos_state_is_tablet_mode()
471 dev_warn(&sw->sdev->dev, "unknown device posture source: %u\n", state->source); in ssam_pos_state_is_tablet_mode()
476 static int ssam_pos_get_sources_list(struct ssam_tablet_sw *sw, struct ssam_sources_list *sources) in ssam_pos_get_sources_list() argument
494 status = ssam_retry(ssam_request_do_sync_onstack, sw->sdev->ctrl, &rqst, &rsp, 0); in ssam_pos_get_sources_list()
500 dev_err(&sw->sdev->dev, "received source list response is too small\n"); in ssam_pos_get_sources_list()
506 dev_err(&sw->sdev->dev, "mismatch between number of sources and response size\n"); in ssam_pos_get_sources_list()
513 static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id) in ssam_pos_get_source() argument
518 status = ssam_pos_get_sources_list(sw, &sources); in ssam_pos_get_source()
523 dev_err(&sw->sdev->dev, "no posture sources found\n"); in ssam_pos_get_source()
547 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
553 status = ssam_retry(__ssam_pos_get_posture_for_source, sw->sdev->ctrl, in ssam_pos_get_posture_for_source()
562 static int ssam_pos_get_posture(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state) in ssam_pos_get_posture() argument
568 status = ssam_pos_get_source(sw, &source_id); in ssam_pos_get_posture()
570 dev_err(&sw->sdev->dev, "failed to get posture source ID: %d\n", status); in ssam_pos_get_posture()
574 status = ssam_pos_get_posture_for_source(sw, source_id, &source_state); in ssam_pos_get_posture()
576 dev_err(&sw->sdev->dev, "failed to get posture value for source %u: %d\n", in ssam_pos_get_posture()
588 struct ssam_tablet_sw *sw = container_of(nf, struct ssam_tablet_sw, notif); in ssam_pos_sw_notif() local
594 dev_warn(&sw->sdev->dev, "unexpected payload size: %u\n", event->length); in ssam_pos_sw_notif()
596 schedule_work(&sw->update_work); in ssam_pos_sw_notif()