drivers/gpu/drm/amd/display/dc/sspl/dc_spl_isharp_filters.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/display/dc/sspl/dc_spl_isharp_filters.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/amd/display/dc/sspl/dc_spl_isharp_filters.c
Extension
.c
Size
17294 bytes
Lines
555
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

if (ratio.value >= ratio_level.value) {
			sharpness_level_down_adj = lookup_ptr->level_down_adj;
			break;
		}
		lookup_ptr++;
		j++;
	}
	return sharpness_level_down_adj;
}

static unsigned int spl_calculate_sharpness_level(struct spl_fixed31_32 ratio,
		unsigned int discrete_sharpness_level, enum system_setup setup,
		struct spl_sharpness_range sharpness_range,
		enum scale_to_sharpness_policy scale_to_sharpness_policy)
{
	unsigned int sharpness_level = 0;
	unsigned int sharpness_level_down_adj = 0;

	int min_sharpness, max_sharpness, mid_sharpness;

	/*
	 * Adjust sharpness level if policy requires we adjust it based on
	 *  scale ratio.  Based on scale ratio, we may adjust the sharpness
	 *  level down by a certain number of steps.  We will not select
	 *  a sharpness value of 0 so the lowest sharpness level will be
	 *  0 or 1 depending on what the min_sharpness is
	 *
	 * If the policy is no required, this code maybe removed at a later
	 *  date
	 */
	switch (setup) {

	case HDR_L:
		min_sharpness = sharpness_range.hdr_rgb_min;
		max_sharpness = sharpness_range.hdr_rgb_max;
		mid_sharpness = sharpness_range.hdr_rgb_mid;
		if (scale_to_sharpness_policy == SCALE_TO_SHARPNESS_ADJ_ALL)
			sharpness_level_down_adj = spl_calculate_sharpness_level_adj(ratio);
		break;
	case HDR_NL:
		/* currently no use case, use Non-linear SDR values for now */
	case SDR_NL:
		min_sharpness = sharpness_range.sdr_yuv_min;
		max_sharpness = sharpness_range.sdr_yuv_max;
		mid_sharpness = sharpness_range.sdr_yuv_mid;
		if (scale_to_sharpness_policy >= SCALE_TO_SHARPNESS_ADJ_YUV)
			sharpness_level_down_adj = spl_calculate_sharpness_level_adj(ratio);
		break;
	case SDR_L:
	default:
		min_sharpness = sharpness_range.sdr_rgb_min;
		max_sharpness = sharpness_range.sdr_rgb_max;
		mid_sharpness = sharpness_range.sdr_rgb_mid;
		if (scale_to_sharpness_policy == SCALE_TO_SHARPNESS_ADJ_ALL)
			sharpness_level_down_adj = spl_calculate_sharpness_level_adj(ratio);
		break;
	}

	if ((min_sharpness == 0) && (sharpness_level_down_adj >= discrete_sharpness_level))
		discrete_sharpness_level = 1;
	else if (sharpness_level_down_adj >= discrete_sharpness_level)
		discrete_sharpness_level = 0;
	else
		discrete_sharpness_level -= sharpness_level_down_adj;

	int lower_half_step_size = (mid_sharpness - min_sharpness) / 5;
	int upper_half_step_size = (max_sharpness - mid_sharpness) / 5;

	// lower half linear approximation
	if (discrete_sharpness_level < 5)
		sharpness_level = min_sharpness + (lower_half_step_size * discrete_sharpness_level);
	// upper half linear approximation
	else
		sharpness_level = mid_sharpness + (upper_half_step_size * (discrete_sharpness_level - 5));

	return sharpness_level;
}

void SPL_NAMESPACE(spl_build_isharp_1dlut_from_reference_curve(
	struct spl_fixed31_32 ratio, enum system_setup setup,
	struct adaptive_sharpness sharpness, enum scale_to_sharpness_policy scale_to_sharpness_policy))
{
	uint8_t *byte_ptr_1dlut_src, *byte_ptr_1dlut_dst;
	struct spl_fixed31_32 sharp_base, sharp_calc, sharp_level;
	int j;
	int size_1dlut;
	int sharp_calc_int;
	uint32_t filter_pregen_store[ISHARP_LUT_TABLE_SIZE];

	/* Custom sharpnessX1000 value */

Annotation

Implementation Notes