drivers/media/cec/usb/pulse8/pulse8-cec.c
Source file repositories/reference/linux-study-clean/drivers/media/cec/usb/pulse8/pulse8-cec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/cec/usb/pulse8/pulse8-cec.c- Extension
.c- Size
- 25048 bytes
- Lines
- 932
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/completion.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/workqueue.hlinux/serio.hlinux/slab.hlinux/time.hlinux/delay.hmedia/cec.h
Detected Declarations
struct pulse8enum pulse8_msgcodesfunction pulse8_sendfunction pulse8_send_and_wait_oncefunction pulse8_send_and_waitfunction pulse8_tx_work_handlerfunction pulse8_irq_work_handlerfunction pulse8_interruptfunction pulse8_cec_adap_enablefunction pulse8_cec_adap_log_addrfunction pulse8_cec_adap_transmitfunction pulse8_cec_adap_freefunction pulse8_disconnectfunction pulse8_setupfunction pulse8_apply_persistent_configfunction pulse8_ping_eeprom_work_handlerfunction pulse8_connect
Annotated Snippet
struct pulse8 {
struct device *dev;
struct serio *serio;
struct cec_adapter *adap;
unsigned int vers;
struct delayed_work ping_eeprom_work;
struct work_struct irq_work;
struct cec_msg rx_msg[NUM_MSGS];
unsigned int rx_msg_cur_idx, rx_msg_num;
/* protect rx_msg_cur_idx and rx_msg_num */
spinlock_t msg_lock;
u8 new_rx_msg[CEC_MAX_MSG_SIZE];
u8 new_rx_msg_len;
struct work_struct tx_work;
u32 tx_done_status;
u32 tx_signal_free_time;
struct cec_msg tx_msg;
bool tx_msg_is_bcast;
struct completion cmd_done;
u8 data[DATA_SIZE];
unsigned int len;
u8 buf[DATA_SIZE];
unsigned int idx;
bool escape;
bool started;
/* locks access to the adapter */
struct mutex lock;
bool config_pending;
bool restoring_config;
bool autonomous;
};
static int pulse8_send(struct serio *serio, const u8 *command, u8 cmd_len)
{
int err = 0;
err = serio_write(serio, MSGSTART);
if (err)
return err;
for (; !err && cmd_len; command++, cmd_len--) {
if (*command >= MSGESC) {
err = serio_write(serio, MSGESC);
if (!err)
err = serio_write(serio, *command - MSGOFFSET);
} else {
err = serio_write(serio, *command);
}
}
if (!err)
err = serio_write(serio, MSGEND);
return err;
}
static int pulse8_send_and_wait_once(struct pulse8 *pulse8,
const u8 *cmd, u8 cmd_len,
u8 response, u8 size)
{
int err;
if (!pulse8->serio)
return -ENODEV;
if (debug > 1)
dev_info(pulse8->dev, "transmit %s: %*ph\n",
pulse8_msgname(cmd[0]), cmd_len, cmd);
init_completion(&pulse8->cmd_done);
err = pulse8_send(pulse8->serio, cmd, cmd_len);
if (err)
return err;
if (!wait_for_completion_timeout(&pulse8->cmd_done, HZ))
return -ETIMEDOUT;
if ((pulse8->data[0] & 0x3f) == MSGCODE_COMMAND_REJECTED &&
cmd[0] != MSGCODE_SET_CONTROLLED &&
cmd[0] != MSGCODE_SET_AUTO_ENABLED &&
cmd[0] != MSGCODE_GET_BUILDDATE)
return -ENOTTY;
if (response &&
((pulse8->data[0] & 0x3f) != response || pulse8->len < size + 1)) {
dev_info(pulse8->dev, "transmit %s failed with %s\n",
pulse8_msgname(cmd[0]),
pulse8_msgname(pulse8->data[0]));
return -EIO;
Annotation
- Immediate include surface: `linux/completion.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/workqueue.h`, `linux/serio.h`, `linux/slab.h`.
- Detected declarations: `struct pulse8`, `enum pulse8_msgcodes`, `function pulse8_send`, `function pulse8_send_and_wait_once`, `function pulse8_send_and_wait`, `function pulse8_tx_work_handler`, `function pulse8_irq_work_handler`, `function pulse8_interrupt`, `function pulse8_cec_adap_enable`, `function pulse8_cec_adap_log_addr`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.