drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c- Extension
.c- Size
- 18823 bytes
- Lines
- 662
- 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/clk.hlinux/media-bus-format.hlinux/mfd/atmel-hlcdc.hlinux/pinctrl/consumer.hlinux/pm.hlinux/pm_runtime.hvideo/videomode.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_crtc.hdrm/drm_modeset_helper_vtables.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/drm_vblank.hatmel_hlcdc_dc.h
Detected Declarations
struct atmel_hlcdc_crtc_statestruct atmel_hlcdc_crtcfunction drm_crtc_state_to_atmel_hlcdc_crtc_statefunction drm_crtc_to_atmel_hlcdc_crtcfunction atmel_hlcdc_crtc_mode_set_nofbfunction atmel_hlcdc_crtc_mode_validfunction atmel_hlcdc_crtc_atomic_disablefunction atmel_hlcdc_crtc_atomic_enablefunction atmel_xlcdc_connector_output_dsifunction atmel_hlcdc_connector_output_modefunction atmel_hlcdc_crtc_select_output_modefunction for_each_new_connector_in_statefunction atmel_hlcdc_crtc_atomic_checkfunction atmel_hlcdc_crtc_atomic_beginfunction atmel_hlcdc_crtc_atomic_flushfunction atmel_hlcdc_crtc_finish_page_flipfunction atmel_hlcdc_crtc_irqfunction atmel_hlcdc_crtc_resetfunction atmel_hlcdc_crtc_duplicate_statefunction atmel_hlcdc_crtc_destroy_statefunction atmel_hlcdc_crtc_enable_vblankfunction atmel_hlcdc_crtc_disable_vblankfunction atmel_hlcdc_crtc_create
Annotated Snippet
struct atmel_hlcdc_crtc_state {
struct drm_crtc_state base;
unsigned int output_mode;
u8 dpi;
};
static inline struct atmel_hlcdc_crtc_state *
drm_crtc_state_to_atmel_hlcdc_crtc_state(struct drm_crtc_state *state)
{
return container_of(state, struct atmel_hlcdc_crtc_state, base);
}
/**
* struct atmel_hlcdc_crtc - Atmel HLCDC CRTC structure
*
* @base: base DRM CRTC structure
* @dc: pointer to the atmel_hlcdc structure provided by the MFD device
* @event: pointer to the current page flip event
* @id: CRTC id (returned by drm_crtc_index)
*/
struct atmel_hlcdc_crtc {
struct drm_crtc base;
struct atmel_hlcdc_dc *dc;
struct drm_pending_vblank_event *event;
int id;
};
static inline struct atmel_hlcdc_crtc *
drm_crtc_to_atmel_hlcdc_crtc(struct drm_crtc *crtc)
{
return container_of(crtc, struct atmel_hlcdc_crtc, base);
}
static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
{
struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
struct regmap *regmap = crtc->dc->hlcdc->regmap;
struct drm_display_mode *adj = &c->state->adjusted_mode;
struct drm_encoder *encoder = NULL, *en_iter;
struct drm_connector *connector = NULL;
struct atmel_hlcdc_crtc_state *state;
struct drm_device *ddev = c->dev;
struct drm_connector_list_iter iter;
unsigned long mode_rate;
struct videomode vm;
unsigned long prate;
unsigned int mask = ATMEL_HLCDC_CLKDIV_MASK | ATMEL_HLCDC_CLKPOL;
unsigned int cfg = 0;
int div, ret;
/* get encoder from crtc */
drm_for_each_encoder(en_iter, ddev) {
if (en_iter->crtc == c) {
encoder = en_iter;
break;
}
}
if (encoder) {
/* Get the connector from encoder */
drm_connector_list_iter_begin(ddev, &iter);
drm_for_each_connector_iter(connector, &iter)
if (connector->encoder == encoder)
break;
drm_connector_list_iter_end(&iter);
}
ret = clk_prepare_enable(crtc->dc->hlcdc->sys_clk);
if (ret)
return;
vm.vfront_porch = adj->crtc_vsync_start - adj->crtc_vdisplay;
vm.vback_porch = adj->crtc_vtotal - adj->crtc_vsync_end;
vm.vsync_len = adj->crtc_vsync_end - adj->crtc_vsync_start;
vm.hfront_porch = adj->crtc_hsync_start - adj->crtc_hdisplay;
vm.hback_porch = adj->crtc_htotal - adj->crtc_hsync_end;
vm.hsync_len = adj->crtc_hsync_end - adj->crtc_hsync_start;
regmap_write(regmap, ATMEL_HLCDC_CFG(1),
(vm.hsync_len - 1) | ((vm.vsync_len - 1) << 16));
regmap_write(regmap, ATMEL_HLCDC_CFG(2),
(vm.vfront_porch - 1) | (vm.vback_porch << 16));
regmap_write(regmap, ATMEL_HLCDC_CFG(3),
(vm.hfront_porch - 1) | ((vm.hback_porch - 1) << 16));
regmap_write(regmap, ATMEL_HLCDC_CFG(4),
(adj->crtc_hdisplay - 1) |
((adj->crtc_vdisplay - 1) << 16));
Annotation
- Immediate include surface: `linux/clk.h`, `linux/media-bus-format.h`, `linux/mfd/atmel-hlcdc.h`, `linux/pinctrl/consumer.h`, `linux/pm.h`, `linux/pm_runtime.h`, `video/videomode.h`, `drm/drm_atomic.h`.
- Detected declarations: `struct atmel_hlcdc_crtc_state`, `struct atmel_hlcdc_crtc`, `function drm_crtc_state_to_atmel_hlcdc_crtc_state`, `function drm_crtc_to_atmel_hlcdc_crtc`, `function atmel_hlcdc_crtc_mode_set_nofb`, `function atmel_hlcdc_crtc_mode_valid`, `function atmel_hlcdc_crtc_atomic_disable`, `function atmel_hlcdc_crtc_atomic_enable`, `function atmel_xlcdc_connector_output_dsi`, `function atmel_hlcdc_connector_output_mode`.
- 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.