diff options
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc/basics')
| -rw-r--r-- | drivers/gpu/drm/amd/display/dc/basics/Makefile | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/display/dc/basics/conversion.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c | 28 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/display/dc/basics/grph_object_id.c | 75 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/display/dc/basics/log_helpers.c | 10 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/display/dc/basics/logger.c | 22 | 
6 files changed, 47 insertions, 92 deletions
| diff --git a/drivers/gpu/drm/amd/display/dc/basics/Makefile b/drivers/gpu/drm/amd/display/dc/basics/Makefile index 6af8c8a9ad80..bca33bd9a0d2 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/Makefile +++ b/drivers/gpu/drm/amd/display/dc/basics/Makefile @@ -24,7 +24,7 @@  # It provides the general basic services required by other DAL  # subcomponents. -BASICS = conversion.o fixpt31_32.o fixpt32_32.o grph_object_id.o \ +BASICS = conversion.o fixpt31_32.o fixpt32_32.o \  	logger.o log_helpers.o vector.o  AMD_DAL_BASICS = $(addprefix $(AMDDALPATH)/dc/basics/,$(BASICS)) diff --git a/drivers/gpu/drm/amd/display/dc/basics/conversion.c b/drivers/gpu/drm/amd/display/dc/basics/conversion.c index 23c9a0ec0181..310964915a83 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/conversion.c +++ b/drivers/gpu/drm/amd/display/dc/basics/conversion.c @@ -46,7 +46,7 @@ uint16_t fixed_point_to_int_frac(  			arg));  	if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor)) -		numerator = (uint16_t)dal_fixed31_32_floor( +		numerator = (uint16_t)dal_fixed31_32_round(  			dal_fixed31_32_mul_int(  				arg,  				divisor)); diff --git a/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c b/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c index 26936892c6f5..011a97f82fb6 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c +++ b/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c @@ -554,6 +554,22 @@ static inline uint32_t ux_dy(  	return result | fractional_part;  } +static inline uint32_t clamp_ux_dy( +	int64_t value, +	uint32_t integer_bits, +	uint32_t fractional_bits, +	uint32_t min_clamp) +{ +	uint32_t truncated_val = ux_dy(value, integer_bits, fractional_bits); + +	if (value >= (1LL << (integer_bits + FIXED31_32_BITS_PER_FRACTIONAL_PART))) +		return (1 << (integer_bits + fractional_bits)) - 1; +	else if (truncated_val > min_clamp) +		return truncated_val; +	else +		return min_clamp; +} +  uint32_t dal_fixed31_32_u2d19(  	struct fixed31_32 arg)  { @@ -565,3 +581,15 @@ uint32_t dal_fixed31_32_u0d19(  {  	return ux_dy(arg.value, 0, 19);  } + +uint32_t dal_fixed31_32_clamp_u0d14( +	struct fixed31_32 arg) +{ +	return clamp_ux_dy(arg.value, 0, 14, 1); +} + +uint32_t dal_fixed31_32_clamp_u0d10( +	struct fixed31_32 arg) +{ +	return clamp_ux_dy(arg.value, 0, 10, 1); +} diff --git a/drivers/gpu/drm/amd/display/dc/basics/grph_object_id.c b/drivers/gpu/drm/amd/display/dc/basics/grph_object_id.c deleted file mode 100644 index 147822545252..000000000000 --- a/drivers/gpu/drm/amd/display/dc/basics/grph_object_id.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2012-15 Advanced Micro Devices, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: AMD - * - */ - -#include "dm_services.h" -#include "include/grph_object_id.h" - -static bool dal_graphics_object_id_is_valid(struct graphics_object_id id) -{ -	bool rc = true; - -	switch (id.type) { -	case OBJECT_TYPE_UNKNOWN: -		rc = false; -		break; -	case OBJECT_TYPE_GPU: -	case OBJECT_TYPE_ENGINE: -		/* do NOT check for id.id == 0 */ -		if (id.enum_id == ENUM_ID_UNKNOWN) -			rc = false; -		break; -	default: -		if (id.id == 0 || id.enum_id == ENUM_ID_UNKNOWN) -			rc = false; -		break; -	} - -	return rc; -} - -bool dal_graphics_object_id_is_equal( -	struct graphics_object_id id1, -	struct graphics_object_id id2) -{ -	if (false == dal_graphics_object_id_is_valid(id1)) { -		dm_output_to_console( -		"%s: Warning: comparing invalid object 'id1'!\n", __func__); -		return false; -	} - -	if (false == dal_graphics_object_id_is_valid(id2)) { -		dm_output_to_console( -		"%s: Warning: comparing invalid object 'id2'!\n", __func__); -		return false; -	} - -	if (id1.id == id2.id && id1.enum_id == id2.enum_id -		&& id1.type == id2.type) -		return true; - -	return false; -} - - diff --git a/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c b/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c index 6e43168fbdd6..854678a0c54b 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c +++ b/drivers/gpu/drm/amd/display/dc/basics/log_helpers.c @@ -83,15 +83,11 @@ void dc_conn_log(struct dc_context *ctx,  			link->link_index);  	va_start(args, msg); -	entry.buf_offset += dm_log_to_buffer( -		&entry.buf[entry.buf_offset], -		LOG_MAX_LINE_SIZE - entry.buf_offset, -		msg, args); +	dm_logger_append_va(&entry, msg, args); -	if (entry.buf[strlen(entry.buf) - 1] == '\n') { -		entry.buf[strlen(entry.buf) - 1] = '\0'; +	if (entry.buf_offset > 0 && +	    entry.buf[entry.buf_offset - 1] == '\n')  		entry.buf_offset--; -	}  	if (hex_data)  		for (i = 0; i < hex_data_count; i++) diff --git a/drivers/gpu/drm/amd/display/dc/basics/logger.c b/drivers/gpu/drm/amd/display/dc/basics/logger.c index e04e8ecd4874..180a9d69d351 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/logger.c +++ b/drivers/gpu/drm/amd/display/dc/basics/logger.c @@ -70,9 +70,8 @@ static bool construct(struct dc_context *ctx, struct dal_logger *logger,  {  	/* malloc buffer and init offsets */  	logger->log_buffer_size = DAL_LOGGER_BUFFER_MAX_SIZE; -	logger->log_buffer = (char *)kzalloc(logger->log_buffer_size * sizeof(char), -					     GFP_KERNEL); - +	logger->log_buffer = kcalloc(logger->log_buffer_size, sizeof(char), +				     GFP_KERNEL);  	if (!logger->log_buffer)  		return false; @@ -313,6 +312,18 @@ void dm_logger_append(  	const char *msg,  	...)  { +	va_list args; + +	va_start(args, msg); +	dm_logger_append_va(entry, msg, args); +	va_end(args); +} + +void dm_logger_append_va( +	struct log_entry *entry, +	const char *msg, +	va_list args) +{  	struct dal_logger *logger;  	if (!entry) { @@ -326,11 +337,8 @@ void dm_logger_append(  		dal_logger_should_log(logger, entry->type)) {  		uint32_t size; -		va_list args;  		char buffer[LOG_MAX_LINE_SIZE]; -		va_start(args, msg); -  		size = dm_log_to_buffer(  			buffer, LOG_MAX_LINE_SIZE, msg, args); @@ -339,8 +347,6 @@ void dm_logger_append(  		} else {  			append_entry(entry, "LOG_ERROR, line too long\n", 27);  		} - -		va_end(args);  	}  } |