drivers/gpu/drm/i915/display/intel_display_power_well.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/display/intel_display_power_well.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/i915/display/intel_display_power_well.c
Extension
.c
Size
64158 bytes
Lines
2121
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct i915_power_well_regs {
	intel_reg_t bios;
	intel_reg_t driver;
	intel_reg_t kvmr;
	intel_reg_t debug;
};

struct i915_power_well_ops {
	const struct i915_power_well_regs *regs;
	/*
	 * Synchronize the well's hw state to match the current sw state, for
	 * example enable/disable it based on the current refcount. Called
	 * during driver init and resume time, possibly after first calling
	 * the enable/disable handlers.
	 */
	void (*sync_hw)(struct intel_display *display,
			struct i915_power_well *power_well);
	/*
	 * Enable the well and resources that depend on it (for example
	 * interrupts located on the well). Called after the 0->1 refcount
	 * transition.
	 */
	void (*enable)(struct intel_display *display,
		       struct i915_power_well *power_well);
	/*
	 * Disable the well and resources that depend on it. Called after
	 * the 1->0 refcount transition.
	 */
	void (*disable)(struct intel_display *display,
			struct i915_power_well *power_well);
	/* Returns the hw enabled state. */
	bool (*is_enabled)(struct intel_display *display,
			   struct i915_power_well *power_well);
};

static const struct i915_power_well_instance *
i915_power_well_instance(const struct i915_power_well *power_well)
{
	return &power_well->desc->instances->list[power_well->instance_idx];
}

struct i915_power_well *
lookup_power_well(struct intel_display *display,
		  enum i915_power_well_id power_well_id)
{
	struct i915_power_well *power_well;

	for_each_power_well(display, power_well)
		if (i915_power_well_instance(power_well)->id == power_well_id)
			return power_well;

	/*
	 * It's not feasible to add error checking code to the callers since
	 * this condition really shouldn't happen and it doesn't even make sense
	 * to abort things like display initialization sequences. Just return
	 * the first power well and hope the WARN gets reported so we can fix
	 * our driver.
	 */
	drm_WARN(display->drm, 1,
		 "Power well %d not defined for this platform\n",
		 power_well_id);
	return &display->power.domains.power_wells[0];
}

void intel_power_well_enable(struct intel_display *display,
			     struct i915_power_well *power_well)
{
	drm_dbg_kms(display->drm, "enabling %s\n", intel_power_well_name(power_well));
	power_well->desc->ops->enable(display, power_well);
	power_well->hw_enabled = true;
}

void intel_power_well_disable(struct intel_display *display,
			      struct i915_power_well *power_well)
{
	drm_dbg_kms(display->drm, "disabling %s\n", intel_power_well_name(power_well));
	power_well->hw_enabled = false;
	power_well->desc->ops->disable(display, power_well);
}

void intel_power_well_sync_hw(struct intel_display *display,
			      struct i915_power_well *power_well)
{
	power_well->desc->ops->sync_hw(display, power_well);
	power_well->hw_enabled = power_well->desc->ops->is_enabled(display, power_well);
}

void intel_power_well_get(struct intel_display *display,
			  struct i915_power_well *power_well)
{

Annotation

Implementation Notes