drivers/media/platform/synopsys/hdmirx/snps_hdmirx_cec.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/synopsys/hdmirx/snps_hdmirx_cec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/synopsys/hdmirx/snps_hdmirx_cec.c- Extension
.c- Size
- 6678 bytes
- Lines
- 276
- 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.
- 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/irq.hlinux/module.hlinux/platform_device.hlinux/slab.hmedia/cec.hsnps_hdmirx.hsnps_hdmirx_cec.h
Detected Declarations
function Copyrightfunction hdmirx_cec_readfunction hdmirx_cec_update_bitsfunction hdmirx_cec_log_addrfunction hdmirx_cec_transmitfunction hdmirx_cec_hardirqfunction hdmirx_cec_threadfunction hdmirx_cec_enablefunction hdmirx_cec_delfunction snps_hdmirx_cec_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2021 Rockchip Electronics Co. Ltd.
*
* Author: Shunqing Chen <csq@rock-chips.com>
*/
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <media/cec.h>
#include "snps_hdmirx.h"
#include "snps_hdmirx_cec.h"
static void hdmirx_cec_write(struct hdmirx_cec *cec, int reg, u32 val)
{
cec->ops->write(cec->hdmirx, reg, val);
}
static u32 hdmirx_cec_read(struct hdmirx_cec *cec, int reg)
{
return cec->ops->read(cec->hdmirx, reg);
}
static void hdmirx_cec_update_bits(struct hdmirx_cec *cec, int reg, u32 mask,
u32 data)
{
u32 val = hdmirx_cec_read(cec, reg) & ~mask;
val |= (data & mask);
hdmirx_cec_write(cec, reg, val);
}
static int hdmirx_cec_log_addr(struct cec_adapter *adap, u8 logical_addr)
{
struct hdmirx_cec *cec = cec_get_drvdata(adap);
if (logical_addr == CEC_LOG_ADDR_INVALID)
cec->addresses = 0;
else
cec->addresses |= BIT(logical_addr) | BIT(15);
hdmirx_cec_write(cec, CEC_ADDR, cec->addresses);
return 0;
}
/* signal_free_time is handled by the Synopsys Designware
* HDMIRX Controller hardware.
*/
static int hdmirx_cec_transmit(struct cec_adapter *adap, u8 attempts,
u32 signal_free_time, struct cec_msg *msg)
{
struct hdmirx_cec *cec = cec_get_drvdata(adap);
u32 data[4] = {0};
int i, data_len, msg_len;
msg_len = msg->len;
hdmirx_cec_write(cec, CEC_TX_COUNT, msg_len - 1);
for (i = 0; i < msg_len; i++)
data[i / 4] |= msg->msg[i] << (i % 4) * 8;
data_len = DIV_ROUND_UP(msg_len, 4);
for (i = 0; i < data_len; i++)
hdmirx_cec_write(cec, CEC_TX_DATA3_0 + i * 4, data[i]);
hdmirx_cec_write(cec, CEC_TX_CONTROL, 0x1);
return 0;
}
static irqreturn_t hdmirx_cec_hardirq(int irq, void *data)
{
struct cec_adapter *adap = data;
struct hdmirx_cec *cec = cec_get_drvdata(adap);
u32 stat = hdmirx_cec_read(cec, CEC_INT_STATUS);
irqreturn_t ret = IRQ_HANDLED;
u32 val;
if (!stat)
return IRQ_NONE;
hdmirx_cec_write(cec, CEC_INT_CLEAR, stat);
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/io.h`, `linux/irq.h`, `linux/module.h`, `linux/platform_device.h`, `linux/slab.h`, `media/cec.h`, `snps_hdmirx.h`.
- Detected declarations: `function Copyright`, `function hdmirx_cec_read`, `function hdmirx_cec_update_bits`, `function hdmirx_cec_log_addr`, `function hdmirx_cec_transmit`, `function hdmirx_cec_hardirq`, `function hdmirx_cec_thread`, `function hdmirx_cec_enable`, `function hdmirx_cec_del`, `function snps_hdmirx_cec_unregister`.
- Atlas domain: Driver Families / drivers/media.
- 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.