drivers/gpu/drm/sun4i/sun4i_tcon.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sun4i/sun4i_tcon.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sun4i/sun4i_tcon.c- Extension
.c- Size
- 45520 bytes
- Lines
- 1582
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/component.hlinux/ioport.hlinux/media-bus-format.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/regmap.hlinux/reset.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_connector.hdrm/drm_crtc.hdrm/drm_encoder.hdrm/drm_modes.hdrm/drm_of.hdrm/drm_panel.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/drm_vblank.huapi/drm/drm_mode.hsun4i_crtc.hsun4i_drv.hsun4i_lvds.hsun4i_rgb.hsun4i_tcon.hsun6i_mipi_dsi.hsun4i_tcon_dclk.hsun8i_tcon_top.hsunxi_engine.h
Detected Declarations
function Copyrightfunction sun4i_tcon_get_pixel_depthfunction sun4i_tcon_channel_set_statusfunction sun4i_tcon_setup_lvds_phyfunction sun6i_tcon_setup_lvds_phyfunction sun4i_tcon_lvds_set_statusfunction sun4i_tcon_set_statusfunction sun4i_tcon_enable_vblankfunction SoCsfunction sun4i_tcon_set_muxfunction sun4i_tcon_get_clk_delayfunction sun4i_tcon0_mode_set_ditheringfunction sun4i_tcon0_mode_set_cpufunction sun4i_tcon0_mode_set_lvdsfunction sun4i_tcon0_mode_set_rgbfunction sun4i_tcon1_mode_setfunction sun4i_tcon_mode_setfunction sun4i_tcon_finish_page_flipfunction sun4i_tcon_handlerfunction sun4i_tcon_init_clocksfunction sun4i_tcon_init_irqfunction sun4i_tcon_init_regmapfunction designfunction sun4i_tcon_of_get_id_from_portfunction sun4i_tcon_connected_to_tcon_topfunction sun4i_tcon_get_indexfunction designfunction sun4i_tcon_bindfunction sun4i_tcon_unbindfunction sun4i_tcon_probefunction sun4i_tcon_removefunction sun4i_a10_tcon_set_muxfunction sun5i_a13_tcon_set_muxfunction sun6i_tcon_set_muxfunction sun8i_r40_tcon_tv_set_muxexport sun4i_tcon_enable_vblankexport sun4i_tcon_mode_setexport sun4i_tcon_of_table
Annotated Snippet
if (connector->encoder == encoder) {
drm_connector_list_iter_end(&iter);
return connector;
}
drm_connector_list_iter_end(&iter);
return NULL;
}
static int sun4i_tcon_get_pixel_depth(const struct drm_encoder *encoder)
{
struct drm_connector *connector;
struct drm_display_info *info;
connector = sun4i_tcon_get_connector(encoder);
if (!connector)
return -EINVAL;
info = &connector->display_info;
if (info->num_bus_formats != 1)
return -EINVAL;
switch (info->bus_formats[0]) {
case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
return 18;
case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
return 24;
}
return -EINVAL;
}
static void sun4i_tcon_channel_set_status(struct sun4i_tcon *tcon, int channel,
bool enabled)
{
struct clk *clk;
switch (channel) {
case 0:
WARN_ON(!tcon->quirks->has_channel_0);
regmap_update_bits(tcon->regs, SUN4I_TCON0_CTL_REG,
SUN4I_TCON0_CTL_TCON_ENABLE,
enabled ? SUN4I_TCON0_CTL_TCON_ENABLE : 0);
clk = tcon->dclk;
break;
case 1:
WARN_ON(!tcon->quirks->has_channel_1);
regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG,
SUN4I_TCON1_CTL_TCON_ENABLE,
enabled ? SUN4I_TCON1_CTL_TCON_ENABLE : 0);
clk = tcon->sclk1;
break;
default:
DRM_WARN("Unknown channel... doing nothing\n");
return;
}
if (enabled) {
clk_prepare_enable(clk);
clk_rate_exclusive_get(clk);
} else {
clk_rate_exclusive_put(clk);
clk_disable_unprepare(clk);
}
}
static void sun4i_tcon_setup_lvds_phy(struct sun4i_tcon *tcon,
const struct drm_encoder *encoder)
{
regmap_write(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
SUN4I_TCON0_LVDS_ANA0_CK_EN |
SUN4I_TCON0_LVDS_ANA0_REG_V |
SUN4I_TCON0_LVDS_ANA0_REG_C |
SUN4I_TCON0_LVDS_ANA0_EN_MB |
SUN4I_TCON0_LVDS_ANA0_PD |
SUN4I_TCON0_LVDS_ANA0_DCHS);
udelay(2); /* delay at least 1200 ns */
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA1_REG,
SUN4I_TCON0_LVDS_ANA1_INIT,
SUN4I_TCON0_LVDS_ANA1_INIT);
udelay(1); /* delay at least 120 ns */
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA1_REG,
SUN4I_TCON0_LVDS_ANA1_UPDATE,
SUN4I_TCON0_LVDS_ANA1_UPDATE);
regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
SUN4I_TCON0_LVDS_ANA0_EN_MB,
SUN4I_TCON0_LVDS_ANA0_EN_MB);
Annotation
- Immediate include surface: `linux/component.h`, `linux/ioport.h`, `linux/media-bus-format.h`, `linux/module.h`, `linux/of.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `function Copyright`, `function sun4i_tcon_get_pixel_depth`, `function sun4i_tcon_channel_set_status`, `function sun4i_tcon_setup_lvds_phy`, `function sun6i_tcon_setup_lvds_phy`, `function sun4i_tcon_lvds_set_status`, `function sun4i_tcon_set_status`, `function sun4i_tcon_enable_vblank`, `function SoCs`, `function sun4i_tcon_set_mux`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.