drivers/gpu/drm/ast/ast_ddc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/ast/ast_ddc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/ast/ast_ddc.c- Extension
.c- Size
- 5127 bytes
- Lines
- 188
- 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/i2c-algo-bit.hlinux/i2c.hdrm/drm_managed.hdrm/drm_print.hast_ddc.hast_drv.h
Detected Declarations
struct ast_ddcfunction ast_ddc_algo_bit_data_setsdafunction ast_ddc_algo_bit_data_setsclfunction ast_ddc_algo_bit_data_pre_xferfunction ast_ddc_algo_bit_data_post_xferfunction ast_ddc_algo_bit_data_getsdafunction ast_ddc_algo_bit_data_getsclfunction ast_ddc_release
Annotated Snippet
struct ast_ddc {
struct ast_device *ast;
struct i2c_algo_bit_data bit;
struct i2c_adapter adapter;
};
static void ast_ddc_algo_bit_data_setsda(void *data, int state)
{
struct ast_ddc *ddc = data;
struct ast_device *ast = ddc->ast;
int i;
u8 ujcrb7, jtemp;
for (i = 0; i < 0x10000; i++) {
ujcrb7 = ((state & 0x01) ? 0 : 1) << 2;
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0xf1, ujcrb7);
jtemp = ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x04);
if (ujcrb7 == jtemp)
break;
}
}
static void ast_ddc_algo_bit_data_setscl(void *data, int state)
{
struct ast_ddc *ddc = data;
struct ast_device *ast = ddc->ast;
int i;
u8 ujcrb7, jtemp;
for (i = 0; i < 0x10000; i++) {
ujcrb7 = ((state & 0x01) ? 0 : 1);
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0xf4, ujcrb7);
jtemp = ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x01);
if (ujcrb7 == jtemp)
break;
}
}
static int ast_ddc_algo_bit_data_pre_xfer(struct i2c_adapter *adapter)
{
struct ast_ddc *ddc = i2c_get_adapdata(adapter);
struct ast_device *ast = ddc->ast;
/*
* Protect access to I/O registers from concurrent modesetting
* by acquiring the I/O-register lock.
*/
mutex_lock(&ast->modeset_lock);
return 0;
}
static void ast_ddc_algo_bit_data_post_xfer(struct i2c_adapter *adapter)
{
struct ast_ddc *ddc = i2c_get_adapdata(adapter);
struct ast_device *ast = ddc->ast;
mutex_unlock(&ast->modeset_lock);
}
static int ast_ddc_algo_bit_data_getsda(void *data)
{
struct ast_ddc *ddc = data;
struct ast_device *ast = ddc->ast;
uint32_t val, val2, count, pass;
count = 0;
pass = 0;
val = (ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x20) >> 5) & 0x01;
do {
val2 = (ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x20) >> 5) & 0x01;
if (val == val2) {
pass++;
} else {
pass = 0;
val = (ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x20) >> 5) & 0x01;
}
} while ((pass < 5) && (count++ < 0x10000));
return val & 1 ? 1 : 0;
}
static int ast_ddc_algo_bit_data_getscl(void *data)
{
struct ast_ddc *ddc = data;
struct ast_device *ast = ddc->ast;
uint32_t val, val2, count, pass;
count = 0;
Annotation
- Immediate include surface: `linux/i2c-algo-bit.h`, `linux/i2c.h`, `drm/drm_managed.h`, `drm/drm_print.h`, `ast_ddc.h`, `ast_drv.h`.
- Detected declarations: `struct ast_ddc`, `function ast_ddc_algo_bit_data_setsda`, `function ast_ddc_algo_bit_data_setscl`, `function ast_ddc_algo_bit_data_pre_xfer`, `function ast_ddc_algo_bit_data_post_xfer`, `function ast_ddc_algo_bit_data_getsda`, `function ast_ddc_algo_bit_data_getscl`, `function ast_ddc_release`.
- 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.