drivers/gpu/drm/sprd/sprd_dsi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sprd/sprd_dsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sprd/sprd_dsi.c- Extension
.c- Size
- 27519 bytes
- Lines
- 1067
- 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/component.hlinux/module.hlinux/of.hlinux/platform_device.hvideo/mipi_display.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_of.hdrm/drm_probe_helper.hsprd_drm.hsprd_dpu.hsprd_dsi.h
Detected Declarations
function Copyrightfunction dsi_reg_wrfunction dsi_reg_upfunction regmap_tst_io_writefunction regmap_tst_io_readfunction dphy_wait_pll_lockedfunction dsi_wait_tx_payload_fifo_emptyfunction dsi_wait_tx_cmd_fifo_emptyfunction dsi_wait_rd_resp_completedfunction calc_bytes_per_pixel_x100function calc_video_size_stepfunction round_video_sizefunction fmt_to_codingfunction sprd_dsi_initfunction sprd_dsi_finifunction sprd_dsi_dpi_videofunction sprd_dsi_edpi_videofunction sprd_dsi_wr_pktfunction modefunction sprd_dsi_set_work_modefunction sprd_dsi_state_resetfunction sprd_dphy_initfunction sprd_dphy_finifunction sprd_dsi_encoder_mode_setfunction sprd_dsi_encoder_enablefunction sprd_dsi_encoder_disablefunction sprd_dsi_encoder_initfunction sprd_dsi_bridge_initfunction sprd_dsi_context_initfunction sprd_dsi_bindfunction sprd_dsi_unbindfunction sprd_dsi_host_attachfunction sprd_dsi_host_detachfunction sprd_dsi_host_transferfunction sprd_dsi_probefunction sprd_dsi_remove
Annotated Snippet
if ((hs_to % div) == 0) {
writel(div, ctx->base + TIMEOUT_CNT_CLK_CONFIG);
writel(hs_to / div, ctx->base + LRX_H_TO_CONFIG);
writel(hs_to / div, ctx->base + HTX_TO_CONFIG);
break;
}
}
if (ctx->burst_mode == VIDEO_BURST_WITH_SYNC_PULSES) {
dsi_reg_wr(ctx, VIDEO_PKT_CONFIG, VIDEO_PKT_SIZE, 0, video_size);
writel(0, ctx->base + VIDEO_NULLPKT_SIZE);
dsi_reg_up(ctx, VIDEO_PKT_CONFIG, VIDEO_LINE_CHUNK_NUM, 0);
} else {
/* non burst transmission */
null_pkt_size = 0;
/* bytes to be sent - first as one chunk */
bytes_per_chunk = vm->hactive * bpp_x100 / 100 + pkt_header;
/* hline total bytes from the DPI interface */
total_bytes = (vm->hactive + vm->hfront_porch) *
ratio_x1000 / dsi->slave->lanes / 1000;
/* check if the pixels actually fit on the DSI link */
if (total_bytes < bytes_per_chunk) {
drm_err(dsi->drm, "current resolution can not be set\n");
return -EINVAL;
}
chunk_overhead = total_bytes - bytes_per_chunk;
/* overhead higher than 1 -> enable multi packets */
if (chunk_overhead > 1) {
/* multi packets */
for (video_size = video_size_step;
video_size < vm->hactive;
video_size += video_size_step) {
if (vm->hactive * 1000 / video_size % 1000)
continue;
chunks = vm->hactive / video_size;
bytes_per_chunk = bpp_x100 * video_size / 100
+ pkt_header;
if (total_bytes >= (bytes_per_chunk * chunks)) {
bytes_left = total_bytes -
bytes_per_chunk * chunks;
break;
}
}
/* prevent overflow (unsigned - unsigned) */
if (bytes_left > (pkt_header * chunks)) {
null_pkt_size = (bytes_left -
pkt_header * chunks) / chunks;
/* avoid register overflow */
if (null_pkt_size > 1023)
null_pkt_size = 1023;
}
} else {
/* single packet */
chunks = 1;
/* must be a multiple of 4 except 18 loosely */
for (video_size = vm->hactive;
(video_size % video_size_step) != 0;
video_size++)
;
}
dsi_reg_wr(ctx, VIDEO_PKT_CONFIG, VIDEO_PKT_SIZE, 0, video_size);
writel(null_pkt_size, ctx->base + VIDEO_NULLPKT_SIZE);
dsi_reg_wr(ctx, VIDEO_PKT_CONFIG, VIDEO_LINE_CHUNK_NUM, 16, chunks);
}
writel(ctx->int0_mask, ctx->base + MASK_PROTOCOL_INT);
writel(ctx->int1_mask, ctx->base + MASK_INTERNAL_INT);
writel(1, ctx->base + SOFT_RESET);
return 0;
}
static void sprd_dsi_edpi_video(struct dsi_context *ctx)
{
struct sprd_dsi *dsi = container_of(ctx, struct sprd_dsi, ctx);
const u32 fifo_depth = 1096;
const u32 word_length = 4;
u32 hactive = ctx->vm.hactive;
u32 bpp_x100;
u32 max_fifo_len;
Annotation
- Immediate include surface: `linux/component.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `video/mipi_display.h`, `drm/drm_atomic_helper.h`, `drm/drm_bridge.h`, `drm/drm_of.h`.
- Detected declarations: `function Copyright`, `function dsi_reg_wr`, `function dsi_reg_up`, `function regmap_tst_io_write`, `function regmap_tst_io_read`, `function dphy_wait_pll_locked`, `function dsi_wait_tx_payload_fifo_empty`, `function dsi_wait_tx_cmd_fifo_empty`, `function dsi_wait_rd_resp_completed`, `function calc_bytes_per_pixel_x100`.
- 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.