drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c
Extension
.c
Size
11805 bytes
Lines
418
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

#include <linux/gpio/machine.h>
#include <linux/pm_runtime.h>
#include "amdgpu.h"
#include "isp_v4_1_1.h"

MODULE_FIRMWARE("amdgpu/isp_4_1_1.bin");

#define ISP_PERFORMANCE_STATE_LOW 0
#define ISP_PERFORMANCE_STATE_HIGH 1

#define ISP_HIGH_PERFORMANC_XCLK 788
#define ISP_HIGH_PERFORMANC_ICLK 788

static const unsigned int isp_4_1_1_int_srcid[MAX_ISP411_INT_SRC] = {
	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9,
	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10,
	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11,
	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12,
	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT13,
	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT14,
	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT15,
	ISP_4_1__SRCID__ISP_RINGBUFFER_WPT16
};

static struct gpiod_lookup_table isp_gpio_table = {
	.dev_id = "amd_isp_capture",
	.table = {
		GPIO_LOOKUP("AMDI0030:00", 85, "enable_isp", GPIO_ACTIVE_HIGH),
		{ }
	},
};

static struct gpiod_lookup_table isp_sensor_gpio_table = {
	.dev_id = "i2c-ov05c10",
	.table = {
		GPIO_LOOKUP("amdisp-pinctrl", 0, "enable", GPIO_ACTIVE_HIGH),
		{ }
	},
};

static int isp_poweroff(struct generic_pm_domain *genpd)
{
	struct amdgpu_isp *isp = container_of(genpd, struct amdgpu_isp, ispgpd);
	struct amdgpu_device *adev = isp->adev;

	return amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_ISP, true, 0);
}

static int isp_poweron(struct generic_pm_domain *genpd)
{
	struct amdgpu_isp *isp = container_of(genpd, struct amdgpu_isp, ispgpd);
	struct amdgpu_device *adev = isp->adev;

	return amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_ISP, false, 0);
}

static int isp_set_performance_state(struct generic_pm_domain *genpd,
				     unsigned int state)
{
	struct amdgpu_isp *isp = container_of(genpd, struct amdgpu_isp, ispgpd);
	struct amdgpu_device *adev = isp->adev;
	u32 iclk, xclk;
	int ret;

	switch (state) {
	case ISP_PERFORMANCE_STATE_HIGH:
		xclk = ISP_HIGH_PERFORMANC_XCLK;
		iclk = ISP_HIGH_PERFORMANC_ICLK;
		break;
	case ISP_PERFORMANCE_STATE_LOW:
		/* isp runs at default lowest clock-rate on power-on, do nothing */
		return 0;
	default:
		return -EINVAL;
	}

	ret = amdgpu_dpm_set_soft_freq_range(adev, PP_ISPXCLK, xclk, 0);
	if (ret) {
		drm_err(&adev->ddev, "failed to set xclk %u to %u: %d\n",
			xclk, state, ret);
		return ret;
	}

	ret = amdgpu_dpm_set_soft_freq_range(adev, PP_ISPICLK, iclk, 0);
	if (ret) {
		drm_err(&adev->ddev, "failed to set iclk %u to %u: %d\n",
			iclk, state, ret);
		return ret;
	}

Annotation

Implementation Notes