drivers/gpu/drm/ast/ast_dp.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/ast/ast_dp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/ast/ast_dp.c- Extension
.c- Size
- 15588 bytes
- Lines
- 577
- 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/firmware.hlinux/delay.hdrm/drm_atomic.hdrm/drm_atomic_state_helper.hdrm/drm_edid.hdrm/drm_modeset_helper_vtables.hdrm/drm_print.hdrm/drm_probe_helper.hast_drv.hast_vbios.h
Detected Declarations
struct ast_astdp_mode_index_table_entrystruct ast_astdp_connector_statefunction to_ast_astdp_connector_statefunction ast_astdp_get_mode_indexfunction ast_astdp_is_connectedfunction ast_astdp_read_edid_blockfunction ast_dp_launchfunction ast_dp_get_phy_sleepfunction ast_dp_set_phy_sleepfunction ast_dp_link_trainingfunction __ast_dp_wait_enablefunction ast_dp_set_enablefunction ast_wait_for_vretracefunction ast_astdp_encoder_helper_mode_validfunction ast_astdp_encoder_helper_atomic_mode_setfunction ast_astdp_encoder_helper_atomic_enablefunction ast_astdp_encoder_helper_atomic_disablefunction ast_astdp_encoder_helper_atomic_checkfunction ast_astdp_connector_helper_get_modesfunction ast_astdp_connector_helper_detect_ctxfunction ast_astdp_connector_resetfunction ast_astdp_connector_atomic_duplicate_statefunction ast_astdp_connector_atomic_destroy_statefunction ast_astdp_output_init
Annotated Snippet
struct ast_astdp_mode_index_table_entry {
unsigned int hdisplay;
unsigned int vdisplay;
unsigned int mode_index;
};
/* FIXME: Do refresh rate and flags actually matter? */
static const struct ast_astdp_mode_index_table_entry ast_astdp_mode_index_table[] = {
{ 320, 240, ASTDP_320x240_60 },
{ 400, 300, ASTDP_400x300_60 },
{ 512, 384, ASTDP_512x384_60 },
{ 640, 480, ASTDP_640x480_60 },
{ 800, 600, ASTDP_800x600_56 },
{ 1024, 768, ASTDP_1024x768_60 },
{ 1152, 864, ASTDP_1152x864_75 },
{ 1280, 800, ASTDP_1280x800_60_RB },
{ 1280, 1024, ASTDP_1280x1024_60 },
{ 1360, 768, ASTDP_1366x768_60 }, // same as 1366x786
{ 1366, 768, ASTDP_1366x768_60 },
{ 1440, 900, ASTDP_1440x900_60_RB },
{ 1600, 900, ASTDP_1600x900_60_RB },
{ 1600, 1200, ASTDP_1600x1200_60 },
{ 1680, 1050, ASTDP_1680x1050_60_RB },
{ 1920, 1080, ASTDP_1920x1080_60 },
{ 1920, 1200, ASTDP_1920x1200_60 },
{ 0 }
};
struct ast_astdp_connector_state {
struct drm_connector_state base;
int mode_index;
};
static struct ast_astdp_connector_state *
to_ast_astdp_connector_state(const struct drm_connector_state *state)
{
return container_of(state, struct ast_astdp_connector_state, base);
}
static int ast_astdp_get_mode_index(unsigned int hdisplay, unsigned int vdisplay)
{
const struct ast_astdp_mode_index_table_entry *entry = ast_astdp_mode_index_table;
while (entry->hdisplay && entry->vdisplay) {
if (entry->hdisplay == hdisplay && entry->vdisplay == vdisplay)
return entry->mode_index;
++entry;
}
return -EINVAL;
}
static bool ast_astdp_is_connected(struct ast_device *ast)
{
if (!ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDF, AST_IO_VGACRDF_HPD))
return false;
/*
* HPD might be set even if no monitor is connected, so also check that
* the link training was successful.
*/
if (!ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC, AST_IO_VGACRDC_LINK_SUCCESS))
return false;
return true;
}
static int ast_astdp_read_edid_block(void *data, u8 *buf, unsigned int block, size_t len)
{
struct ast_device *ast = data;
size_t rdlen = round_up(len, 4);
int ret = 0;
unsigned int i;
if (block > 0)
return -EIO; /* extension headers not supported */
/*
* Protect access to I/O registers from concurrent modesetting
* by acquiring the I/O-register lock.
*/
mutex_lock(&ast->modeset_lock);
/* Start reading EDID data */
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xe5, (u8)~AST_IO_VGACRE5_EDID_READ_DONE, 0x00);
for (i = 0; i < rdlen; i += 4) {
unsigned int offset;
unsigned int j;
u8 ediddata[4];
u8 vgacre4;
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/delay.h`, `drm/drm_atomic.h`, `drm/drm_atomic_state_helper.h`, `drm/drm_edid.h`, `drm/drm_modeset_helper_vtables.h`, `drm/drm_print.h`, `drm/drm_probe_helper.h`.
- Detected declarations: `struct ast_astdp_mode_index_table_entry`, `struct ast_astdp_connector_state`, `function to_ast_astdp_connector_state`, `function ast_astdp_get_mode_index`, `function ast_astdp_is_connected`, `function ast_astdp_read_edid_block`, `function ast_dp_launch`, `function ast_dp_get_phy_sleep`, `function ast_dp_set_phy_sleep`, `function ast_dp_link_training`.
- 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.