drivers/input/keyboard/imx-sm-bbm-key.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/imx-sm-bbm-key.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/imx-sm-bbm-key.c- Extension
.c- Size
- 5526 bytes
- Lines
- 226
- Domain
- Driver Families
- Bucket
- drivers/input
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/input.hlinux/jiffies.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/rtc.hlinux/scmi_protocol.hlinux/scmi_imx_protocol.hlinux/suspend.h
Detected Declarations
struct scmi_imx_bbmfunction scmi_imx_bbm_pwrkey_check_for_eventsfunction scmi_imx_bbm_pwrkey_eventfunction scmi_imx_bbm_pwrkey_actfunction scmi_imx_bbm_key_notifierfunction scmi_imx_bbm_pwrkey_initfunction scmi_imx_bbm_key_probefunction scmi_imx_bbm_key_suspendfunction scmi_imx_bbm_key_resume
Annotated Snippet
struct scmi_imx_bbm {
struct scmi_protocol_handle *ph;
const struct scmi_imx_bbm_proto_ops *ops;
struct notifier_block nb;
int keycode;
int keystate; /* 1:pressed */
bool suspended;
struct delayed_work check_work;
struct input_dev *input;
};
static void scmi_imx_bbm_pwrkey_check_for_events(struct work_struct *work)
{
struct scmi_imx_bbm *bbnsm = container_of(to_delayed_work(work),
struct scmi_imx_bbm, check_work);
struct scmi_protocol_handle *ph = bbnsm->ph;
struct input_dev *input = bbnsm->input;
u32 state = 0;
int ret;
ret = bbnsm->ops->button_get(ph, &state);
if (ret) {
pr_err("%s: %d\n", __func__, ret);
return;
}
pr_debug("%s: state: %d, keystate %d\n", __func__, state, bbnsm->keystate);
/* only report new event if status changed */
if (state ^ bbnsm->keystate) {
bbnsm->keystate = state;
input_event(input, EV_KEY, bbnsm->keycode, state);
input_sync(input);
pm_relax(bbnsm->input->dev.parent);
pr_debug("EV_KEY: %x\n", bbnsm->keycode);
}
/* repeat check if pressed long */
if (state)
schedule_delayed_work(&bbnsm->check_work, msecs_to_jiffies(REPEAT_INTERVAL));
}
static int scmi_imx_bbm_pwrkey_event(struct scmi_imx_bbm *bbnsm)
{
struct input_dev *input = bbnsm->input;
pm_wakeup_event(input->dev.parent, 0);
/*
* Directly report key event after resume to make no key press
* event is missed.
*/
if (READ_ONCE(bbnsm->suspended)) {
bbnsm->keystate = 1;
input_event(input, EV_KEY, bbnsm->keycode, 1);
input_sync(input);
WRITE_ONCE(bbnsm->suspended, false);
}
schedule_delayed_work(&bbnsm->check_work, msecs_to_jiffies(DEBOUNCE_TIME));
return 0;
}
static void scmi_imx_bbm_pwrkey_act(void *pdata)
{
struct scmi_imx_bbm *bbnsm = pdata;
cancel_delayed_work_sync(&bbnsm->check_work);
}
static int scmi_imx_bbm_key_notifier(struct notifier_block *nb, unsigned long event, void *data)
{
struct scmi_imx_bbm *bbnsm = container_of(nb, struct scmi_imx_bbm, nb);
struct scmi_imx_bbm_notif_report *r = data;
if (r->is_button) {
pr_debug("BBM Button Power key pressed\n");
scmi_imx_bbm_pwrkey_event(bbnsm);
} else {
/* Should never reach here */
pr_err("Unexpected BBM event: %s\n", __func__);
}
return 0;
}
static int scmi_imx_bbm_pwrkey_init(struct scmi_device *sdev)
{
const struct scmi_handle *handle = sdev->handle;
Annotation
- Immediate include surface: `linux/input.h`, `linux/jiffies.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/rtc.h`, `linux/scmi_protocol.h`, `linux/scmi_imx_protocol.h`.
- Detected declarations: `struct scmi_imx_bbm`, `function scmi_imx_bbm_pwrkey_check_for_events`, `function scmi_imx_bbm_pwrkey_event`, `function scmi_imx_bbm_pwrkey_act`, `function scmi_imx_bbm_key_notifier`, `function scmi_imx_bbm_pwrkey_init`, `function scmi_imx_bbm_key_probe`, `function scmi_imx_bbm_key_suspend`, `function scmi_imx_bbm_key_resume`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.