drivers/gpu/drm/loongson/lsdc_crtc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/loongson/lsdc_crtc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/loongson/lsdc_crtc.c- Extension
.c- Size
- 27500 bytes
- Lines
- 1027
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/debugfs.hlinux/delay.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_debugfs.hdrm/drm_print.hdrm/drm_vblank.hlsdc_drv.h
Detected Declarations
function Copyrightfunction lsdc_crtc1_soft_resetfunction lsdc_crtc0_enablefunction lsdc_crtc0_disablefunction lsdc_crtc1_enablefunction lsdc_crtc1_disablefunction lsdc_crtc0_scan_posfunction lsdc_crtc1_scan_posfunction lsdc_crtc0_enable_vblankfunction lsdc_crtc0_disable_vblankfunction lsdc_crtc1_enable_vblankfunction lsdc_crtc1_disable_vblankfunction lsdc_crtc0_flipfunction lsdc_crtc1_flipfunction cloningfunction lsdc_crtc1_clonefunction lsdc_crtc0_set_modefunction lsdc_crtc1_set_modefunction lsdc_crtc0_resetfunction lsdc_crtc1_resetfunction lsdc_crtc0_get_vblank_countfunction lsdc_crtc1_get_vblank_countfunction lsdc_crtc0_set_dma_stepfunction lsdc_crtc1_set_dma_stepfunction lsdc_crtc_resetfunction lsdc_crtc_atomic_destroy_statefunction lsdc_crtc_atomic_duplicate_statefunction lsdc_crtc_get_vblank_counterfunction lsdc_crtc_enable_vblankfunction lsdc_crtc_disable_vblankfunction lsdc_crtc_show_regsfunction lsdc_crtc_show_scan_positionfunction lsdc_crtc_show_vblank_counterfunction lsdc_pixpll_show_clockfunction lsdc_crtc_man_op_showfunction lsdc_crtc_man_op_openfunction lsdc_crtc_man_op_writefunction lsdc_crtc_late_registerfunction lsdc_crtc_atomic_print_statefunction lsdc_crtc_mode_validfunction lsdc_pixpll_atomic_checkfunction lsdc_crtc_helper_atomic_checkfunction lsdc_crtc_mode_set_nofbfunction lsdc_crtc_send_vblankfunction lsdc_crtc_atomic_enablefunction lsdc_crtc_atomic_disablefunction lsdc_crtc_atomic_flushfunction lsdc_crtc_get_scanout_position
Annotated Snippet
static const struct file_operations lsdc_crtc_man_op_fops = {
.owner = THIS_MODULE,
.open = lsdc_crtc_man_op_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = lsdc_crtc_man_op_write,
};
static int lsdc_crtc_late_register(struct drm_crtc *crtc)
{
struct lsdc_display_pipe *dispipe = crtc_to_display_pipe(crtc);
struct lsdc_crtc *lcrtc = to_lsdc_crtc(crtc);
struct drm_minor *minor = crtc->dev->primary;
unsigned int index = dispipe->index;
unsigned int i;
lcrtc->preg = lsdc_crtc_regs_array[index];
lcrtc->nreg = ARRAY_SIZE(lsdc_crtc_regs_array[index]);
lcrtc->p_info_list = lsdc_crtc_debugfs_list[index];
lcrtc->n_info_list = ARRAY_SIZE(lsdc_crtc_debugfs_list[index]);
for (i = 0; i < lcrtc->n_info_list; ++i)
lcrtc->p_info_list[i].data = lcrtc;
drm_debugfs_create_files(lcrtc->p_info_list, lcrtc->n_info_list,
crtc->debugfs_entry, minor);
/* Manual operations supported */
debugfs_create_file("ops", 0644, crtc->debugfs_entry, lcrtc,
&lsdc_crtc_man_op_fops);
return 0;
}
static void lsdc_crtc_atomic_print_state(struct drm_printer *p,
const struct drm_crtc_state *state)
{
const struct lsdc_crtc_state *priv_state;
const struct lsdc_pixpll_parms *pparms;
priv_state = container_of_const(state, struct lsdc_crtc_state, base);
pparms = &priv_state->pparms;
drm_printf(p, "\tInput clock divider = %u\n", pparms->div_ref);
drm_printf(p, "\tMedium clock multiplier = %u\n", pparms->loopc);
drm_printf(p, "\tOutput clock divider = %u\n", pparms->div_out);
}
static const struct drm_crtc_funcs ls7a1000_crtc_funcs = {
.reset = lsdc_crtc_reset,
.destroy = drm_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
.page_flip = drm_atomic_helper_page_flip,
.atomic_duplicate_state = lsdc_crtc_atomic_duplicate_state,
.atomic_destroy_state = lsdc_crtc_atomic_destroy_state,
.late_register = lsdc_crtc_late_register,
.enable_vblank = lsdc_crtc_enable_vblank,
.disable_vblank = lsdc_crtc_disable_vblank,
.get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
.atomic_print_state = lsdc_crtc_atomic_print_state,
};
static const struct drm_crtc_funcs ls7a2000_crtc_funcs = {
.reset = lsdc_crtc_reset,
.destroy = drm_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
.page_flip = drm_atomic_helper_page_flip,
.atomic_duplicate_state = lsdc_crtc_atomic_duplicate_state,
.atomic_destroy_state = lsdc_crtc_atomic_destroy_state,
.late_register = lsdc_crtc_late_register,
.get_vblank_counter = lsdc_crtc_get_vblank_counter,
.enable_vblank = lsdc_crtc_enable_vblank,
.disable_vblank = lsdc_crtc_disable_vblank,
.get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
.atomic_print_state = lsdc_crtc_atomic_print_state,
};
static enum drm_mode_status
lsdc_crtc_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode)
{
struct drm_device *ddev = crtc->dev;
struct lsdc_device *ldev = to_lsdc(ddev);
const struct lsdc_desc *descp = ldev->descp;
unsigned int pitch;
if (mode->hdisplay > descp->max_width)
return MODE_BAD_HVALUE;
if (mode->vdisplay > descp->max_height)
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/delay.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_debugfs.h`, `drm/drm_print.h`, `drm/drm_vblank.h`, `lsdc_drv.h`.
- Detected declarations: `function Copyright`, `function lsdc_crtc1_soft_reset`, `function lsdc_crtc0_enable`, `function lsdc_crtc0_disable`, `function lsdc_crtc1_enable`, `function lsdc_crtc1_disable`, `function lsdc_crtc0_scan_pos`, `function lsdc_crtc1_scan_pos`, `function lsdc_crtc0_enable_vblank`, `function lsdc_crtc0_disable_vblank`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.