drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c- Extension
.c- Size
- 8852 bytes
- Lines
- 361
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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.
- 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/interrupt.hlinux/io.hlinux/module.hlinux/platform_device.hlinux/sched.hlinux/slab.hdrm/drm_edid.hmedia/cec.hmedia/cec-notifier.hdw-hdmi-cec.h
Detected Declarations
struct dw_hdmi_cecfunction dw_hdmi_writefunction dw_hdmi_readfunction dw_hdmi_cec_log_addrfunction dw_hdmi_cec_transmitfunction dw_hdmi_cec_hardirqfunction dw_hdmi_cec_threadfunction dw_hdmi_cec_enablefunction dw_hdmi_cec_delfunction dw_hdmi_cec_probefunction dw_hdmi_cec_removefunction dw_hdmi_cec_resumefunction dw_hdmi_cec_suspend
Annotated Snippet
struct dw_hdmi_cec {
struct dw_hdmi *hdmi;
const struct dw_hdmi_cec_ops *ops;
u32 addresses;
struct cec_adapter *adap;
struct cec_msg rx_msg;
unsigned int tx_status;
bool tx_done;
bool rx_done;
struct cec_notifier *notify;
int irq;
u8 regs_polarity;
u8 regs_mask;
u8 regs_mute_stat0;
};
static void dw_hdmi_write(struct dw_hdmi_cec *cec, u8 val, int offset)
{
cec->ops->write(cec->hdmi, val, offset);
}
static u8 dw_hdmi_read(struct dw_hdmi_cec *cec, int offset)
{
return cec->ops->read(cec->hdmi, offset);
}
static int dw_hdmi_cec_log_addr(struct cec_adapter *adap, u8 logical_addr)
{
struct dw_hdmi_cec *cec = cec_get_drvdata(adap);
if (logical_addr == CEC_LOG_ADDR_INVALID)
cec->addresses = 0;
else
cec->addresses |= BIT(logical_addr) | BIT(15);
dw_hdmi_write(cec, cec->addresses & 255, HDMI_CEC_ADDR_L);
dw_hdmi_write(cec, cec->addresses >> 8, HDMI_CEC_ADDR_H);
return 0;
}
static int dw_hdmi_cec_transmit(struct cec_adapter *adap, u8 attempts,
u32 signal_free_time, struct cec_msg *msg)
{
struct dw_hdmi_cec *cec = cec_get_drvdata(adap);
unsigned int i, ctrl;
switch (signal_free_time) {
case CEC_SIGNAL_FREE_TIME_RETRY:
ctrl = CEC_CTRL_RETRY;
break;
case CEC_SIGNAL_FREE_TIME_NEW_INITIATOR:
default:
ctrl = CEC_CTRL_NORMAL;
break;
case CEC_SIGNAL_FREE_TIME_NEXT_XFER:
ctrl = CEC_CTRL_IMMED;
break;
}
for (i = 0; i < msg->len; i++)
dw_hdmi_write(cec, msg->msg[i], HDMI_CEC_TX_DATA0 + i);
dw_hdmi_write(cec, msg->len, HDMI_CEC_TX_CNT);
dw_hdmi_write(cec, ctrl | CEC_CTRL_START, HDMI_CEC_CTRL);
return 0;
}
static irqreturn_t dw_hdmi_cec_hardirq(int irq, void *data)
{
struct cec_adapter *adap = data;
struct dw_hdmi_cec *cec = cec_get_drvdata(adap);
unsigned int stat = dw_hdmi_read(cec, HDMI_IH_CEC_STAT0);
irqreturn_t ret = IRQ_HANDLED;
if (stat == 0)
return IRQ_NONE;
dw_hdmi_write(cec, stat, HDMI_IH_CEC_STAT0);
if (stat & CEC_STAT_ERROR_INIT) {
cec->tx_status = CEC_TX_STATUS_ERROR;
cec->tx_done = true;
ret = IRQ_WAKE_THREAD;
} else if (stat & CEC_STAT_DONE) {
cec->tx_status = CEC_TX_STATUS_OK;
cec->tx_done = true;
ret = IRQ_WAKE_THREAD;
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/platform_device.h`, `linux/sched.h`, `linux/slab.h`, `drm/drm_edid.h`, `media/cec.h`.
- Detected declarations: `struct dw_hdmi_cec`, `function dw_hdmi_write`, `function dw_hdmi_read`, `function dw_hdmi_cec_log_addr`, `function dw_hdmi_cec_transmit`, `function dw_hdmi_cec_hardirq`, `function dw_hdmi_cec_thread`, `function dw_hdmi_cec_enable`, `function dw_hdmi_cec_del`, `function dw_hdmi_cec_probe`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- 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.