drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c- Extension
.c- Size
- 34751 bytes
- Lines
- 1258
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/clk.hlinux/component.hlinux/crc-ccitt.hlinux/module.hlinux/of_address.hlinux/phy/phy-mipi-dphy.hlinux/phy/phy.hlinux/platform_device.hlinux/regmap.hlinux/regulator/consumer.hlinux/reset.hlinux/slab.hdrm/drm_atomic_helper.hdrm/drm_mipi_dsi.hdrm/drm_panel.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/drm_simple_kms_helper.hsun4i_crtc.hsun4i_tcon.hsun6i_mipi_dsi.hvideo/mipi_display.h
Detected Declarations
enum sun6i_dsi_start_instenum sun6i_dsi_inst_idenum sun6i_dsi_inst_modeenum sun6i_dsi_inst_escapeenum sun6i_dsi_inst_packetfunction sun6i_dsi_ecc_computefunction sun6i_dsi_crc_computefunction sun6i_dsi_crc_repeatfunction sun6i_dsi_build_sync_pktfunction sun6i_dsi_build_blk0_pktfunction sun6i_dsi_build_blk1_pktfunction sun6i_dsi_inst_abortfunction sun6i_dsi_inst_commitfunction sun6i_dsi_inst_wait_for_completionfunction sun6i_dsi_inst_setupfunction sun6i_dsi_inst_initfunction sun6i_dsi_get_video_start_delayfunction sun6i_dsi_get_line_numfunction sun6i_dsi_get_drq_edge0function sun6i_dsi_get_drq_edge1function sun6i_dsi_setup_burstfunction sun6i_dsi_setup_inst_loopfunction sun6i_dsi_setup_formatfunction sun6i_dsi_setup_timingsfunction sun6i_dsi_startfunction sun6i_dsi_encoder_enablefunction sun6i_dsi_encoder_disablefunction sun6i_dsi_get_modesfunction sun6i_dsi_connector_detectfunction sun6i_dsi_dcs_build_pkt_hdrfunction sun6i_dsi_dcs_write_shortfunction sun6i_dsi_dcs_write_longfunction sun6i_dsi_dcs_readfunction sun6i_dsi_attachfunction sun6i_dsi_detachfunction sun6i_dsi_transferfunction sun6i_dsi_bindfunction sun6i_dsi_unbindfunction sun6i_dsi_probefunction sun6i_dsi_remove
Annotated Snippet
if (!init) {
val = (BIT(j) & data) ? 1 : 0;
init = true;
} else {
val ^= (BIT(j) & data) ? 1 : 0;
}
}
ecc |= val << i;
}
return ecc;
}
static u16 sun6i_dsi_crc_compute(u8 const *buffer, size_t len)
{
return crc_ccitt(0xffff, buffer, len);
}
static u16 sun6i_dsi_crc_repeat(u8 pd, u8 *buffer, size_t len)
{
memset(buffer, pd, len);
return sun6i_dsi_crc_compute(buffer, len);
}
static u32 sun6i_dsi_build_sync_pkt(u8 dt, u8 vc, u8 d0, u8 d1)
{
u32 val = dt & 0x3f;
val |= (vc & 3) << 6;
val |= (d0 & 0xff) << 8;
val |= (d1 & 0xff) << 16;
val |= sun6i_dsi_ecc_compute(val) << 24;
return val;
}
static u32 sun6i_dsi_build_blk0_pkt(u8 vc, u16 wc)
{
return sun6i_dsi_build_sync_pkt(MIPI_DSI_BLANKING_PACKET, vc,
wc & 0xff, wc >> 8);
}
static u32 sun6i_dsi_build_blk1_pkt(u16 pd, u8 *buffer, size_t len)
{
u32 val = SUN6I_DSI_BLK_PD(pd);
return val | SUN6I_DSI_BLK_PF(sun6i_dsi_crc_repeat(pd, buffer, len));
}
static void sun6i_dsi_inst_abort(struct sun6i_dsi *dsi)
{
regmap_update_bits(dsi->regs, SUN6I_DSI_BASIC_CTL0_REG,
SUN6I_DSI_BASIC_CTL0_INST_ST, 0);
}
static void sun6i_dsi_inst_commit(struct sun6i_dsi *dsi)
{
regmap_update_bits(dsi->regs, SUN6I_DSI_BASIC_CTL0_REG,
SUN6I_DSI_BASIC_CTL0_INST_ST,
SUN6I_DSI_BASIC_CTL0_INST_ST);
}
static int sun6i_dsi_inst_wait_for_completion(struct sun6i_dsi *dsi)
{
u32 val;
return regmap_read_poll_timeout(dsi->regs, SUN6I_DSI_BASIC_CTL0_REG,
val,
!(val & SUN6I_DSI_BASIC_CTL0_INST_ST),
100, 5000);
}
static void sun6i_dsi_inst_setup(struct sun6i_dsi *dsi,
enum sun6i_dsi_inst_id id,
enum sun6i_dsi_inst_mode mode,
bool clock, u8 data,
enum sun6i_dsi_inst_packet packet,
enum sun6i_dsi_inst_escape escape)
{
regmap_write(dsi->regs, SUN6I_DSI_INST_FUNC_REG(id),
SUN6I_DSI_INST_FUNC_INST_MODE(mode) |
SUN6I_DSI_INST_FUNC_ESCAPE_ENTRY(escape) |
SUN6I_DSI_INST_FUNC_TRANS_PACKET(packet) |
(clock ? SUN6I_DSI_INST_FUNC_LANE_CEN : 0) |
SUN6I_DSI_INST_FUNC_LANE_DEN(data));
}
static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi,
Annotation
- Immediate include surface: `linux/clk.h`, `linux/component.h`, `linux/crc-ccitt.h`, `linux/module.h`, `linux/of_address.h`, `linux/phy/phy-mipi-dphy.h`, `linux/phy/phy.h`, `linux/platform_device.h`.
- Detected declarations: `enum sun6i_dsi_start_inst`, `enum sun6i_dsi_inst_id`, `enum sun6i_dsi_inst_mode`, `enum sun6i_dsi_inst_escape`, `enum sun6i_dsi_inst_packet`, `function sun6i_dsi_ecc_compute`, `function sun6i_dsi_crc_compute`, `function sun6i_dsi_crc_repeat`, `function sun6i_dsi_build_sync_pkt`, `function sun6i_dsi_build_blk0_pkt`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.