[PATCH 06/76] drm/amd/dal: Move gpio_service out of adapter_service

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Harry Wentland <harry.wentland at amd.com>
Acked-by: Harry Wentland <harry.wentland at amd.com>
---
 .../gpu/drm/amd/dal/dc/adapter/adapter_service.c   | 16 ---------------
 .../gpu/drm/amd/dal/dc/adapter/adapter_service.h   | 24 ----------------------
 drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c      |  2 +-
 drivers/gpu/drm/amd/dal/dc/core/dc.c               | 20 +++++++++++++++++-
 drivers/gpu/drm/amd/dal/dc/core/dc_link.c          |  2 +-
 drivers/gpu/drm/amd/dal/dc/core/dc_link_ddc.c      |  2 +-
 drivers/gpu/drm/amd/dal/dc/dc_types.h              |  1 +
 drivers/gpu/drm/amd/dal/dc/dce/dce_link_encoder.c  |  2 +-
 .../amd/dal/include/adapter_service_interface.h    | 20 +++++++++++++++++-
 9 files changed, 43 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c
index 119b763b2e90..6d2f5762ef63 100644
--- a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c
+++ b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c
@@ -610,7 +610,6 @@ static void adapter_service_destruct(
 	struct dc_bios *dcb = as->ctx->dc_bios;
 
 	dal_i2caux_destroy(&as->i2caux);
-	dal_gpio_service_destroy(&as->gpio_service);
 	dal_asic_capability_destroy(&as->asic_cap);
 
 	dcb->funcs->destroy_integrated_info(dcb, &as->integrated_info);
@@ -674,18 +673,6 @@ static bool adapter_service_construct(
 
 	dcb = as->ctx->dc_bios;
 
-
-	/* Create GPIO service */
-	as->gpio_service = dal_gpio_service_create(
-			dce_version,
-			as->dce_environment,
-			as->ctx);
-
-	if (!as->gpio_service) {
-		ASSERT_CRITICAL(false);
-		goto failed_to_create_gpio_service;
-	}
-
 	/* Create I2C AUX */
 	as->i2caux = dal_i2caux_create(as, as->ctx);
 
@@ -714,9 +701,6 @@ failed_to_generate_features:
 	dal_i2caux_destroy(&as->i2caux);
 
 failed_to_create_i2caux:
-	dal_gpio_service_destroy(&as->gpio_service);
-
-failed_to_create_gpio_service:
 	dal_asic_capability_destroy(&as->asic_cap);
 
 	return false;
diff --git a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h
index 0e651206af16..823322bfc3a2 100644
--- a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h
+++ b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h
@@ -30,29 +30,5 @@
 #include "dc_bios_types.h"
 #include "include/adapter_service_interface.h"
 
-#define SIZEOF_BACKLIGHT_LUT 101
-
-/*
- * Forward declaration
- */
-struct gpio_service;
-struct asic_cap;
-
-/* Adapter service */
-struct adapter_service {
-	struct dc_context *ctx;
-	struct asic_capability *asic_cap;
-	enum dce_environment dce_environment;
-	struct gpio_service *gpio_service;
-	struct i2caux *i2caux;
-	struct integrated_info *integrated_info;
-	uint32_t platform_methods_mask;
-	uint32_t ac_level_percentage;
-	uint32_t dc_level_percentage;
-	uint32_t backlight_caps_initialized;
-	uint32_t backlight_8bit_lut[SIZEOF_BACKLIGHT_LUT];
-	uint32_t adapter_feature_set[FEATURE_MAXIMUM/32];
-	uint32_t default_values[FEATURE_MAXIMUM];
-};
 
 #endif /* __DAL_ADAPTER_SERVICE_H__ */
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c
index 0647156f313c..1080c6c5527b 100644
--- a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c
+++ b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c
@@ -2932,7 +2932,7 @@ static bool i2c_read(
 		i2c_info->i2c_hw_assist,
 		i2c_info->i2c_line };
 
-	ddc = dal_gpio_create_ddc(as->gpio_service,
+	ddc = dal_gpio_create_ddc(as->ctx->gpio_service,
 		i2c_info->gpio_info.clk_a_register_index,
 		(1 << i2c_info->gpio_info.clk_a_shift), &hw_info);
 
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc.c b/drivers/gpu/drm/amd/dal/dc/core/dc.c
index c66cb6607752..e4990983924e 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc.c
@@ -537,7 +537,7 @@ static bool construct(struct core_dc *dc,
 
 		if (!dc_ctx->dc_bios) {
 			ASSERT_CRITICAL(false);
-			goto as_fail;
+			goto bios_fail;
 		}
 
 		dc_ctx->created_bios = true;
@@ -554,6 +554,17 @@ static bool construct(struct core_dc *dc,
 		}
 	}
 
+	/* Create GPIO service */
+	dc_ctx->gpio_service = dal_gpio_service_create(
+			dc_version,
+			as->dce_environment,
+			as->ctx);
+
+	if (!dc_ctx->gpio_service) {
+		ASSERT_CRITICAL(false);
+		goto gpio_fail;
+	}
+
 	dc->res_pool = dc_create_resource_pool(
 			as,
 			dc,
@@ -574,9 +585,15 @@ static bool construct(struct core_dc *dc,
 create_links_fail:
 	dc->res_pool->funcs->destroy(&dc->res_pool);
 create_resource_fail:
+	if (dc->ctx->gpio_service)
+		dal_gpio_service_destroy(&dc_ctx->gpio_service);
+gpio_fail:
 	if (as)
 		dal_adapter_service_destroy(&as);
 as_fail:
+	if (dc->ctx->created_bios)
+		dal_bios_parser_destroy(&dc->ctx->dc_bios);
+bios_fail:
 	dal_logger_destroy(&dc_ctx->logger);
 logger_fail:
 	dm_free(dc->current_context);
@@ -588,6 +605,7 @@ ctx_fail:
 
 static void destruct(struct core_dc *dc)
 {
+	dal_gpio_service_destroy(&dc->ctx->gpio_service);
 	resource_validate_ctx_destruct(dc->current_context);
 	dm_free(dc->current_context);
 	dm_free(dc->temp_flip_context);
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_link.c b/drivers/gpu/drm/amd/dal/dc/core/dc_link.c
index c2eb27a257d6..fb902558d6a2 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc_link.c
@@ -110,7 +110,7 @@ static struct gpio *get_hpd_gpio(const struct core_link *link)
 	}
 
 	return dal_gpio_service_create_irq(
-		link->adapter_srv->gpio_service,
+		link->ctx->gpio_service,
 		pin_info.offset,
 		pin_info.mask);
 }
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_link_ddc.c b/drivers/gpu/drm/amd/dal/dc/core/dc_link_ddc.c
index ffcd2a10d6f6..fd60a4c6d2a3 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc_link_ddc.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc_link_ddc.c
@@ -280,7 +280,7 @@ static bool construct(
 	enum connector_id connector_id =
 		dal_graphics_object_id_get_connector_id(init_data->id);
 
-	struct gpio_service *gpio_service = init_data->as->gpio_service;
+	struct gpio_service *gpio_service = init_data->ctx->gpio_service;
 	struct graphics_object_i2c_info i2c_info;
 	struct gpio_ddc_hw_info hw_info;
 	struct dc_bios *dcb = init_data->ctx->dc_bios;
diff --git a/drivers/gpu/drm/amd/dal/dc/dc_types.h b/drivers/gpu/drm/amd/dal/dc/dc_types.h
index c71f81f0cd95..573db6ef5a1d 100644
--- a/drivers/gpu/drm/amd/dal/dc/dc_types.h
+++ b/drivers/gpu/drm/amd/dal/dc/dc_types.h
@@ -75,6 +75,7 @@ struct dc_context {
 
 	struct dc_bios *dc_bios;
 	bool created_bios;
+	struct gpio_service *gpio_service;
 };
 
 /*
diff --git a/drivers/gpu/drm/amd/dal/dc/dce/dce_link_encoder.c b/drivers/gpu/drm/amd/dal/dc/dce/dce_link_encoder.c
index 8a9060601005..ae9de4824378 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce/dce_link_encoder.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce/dce_link_encoder.c
@@ -582,7 +582,7 @@ static struct gpio *get_hpd_gpio(const struct link_encoder *enc)
 	}
 
 	return dal_gpio_service_create_irq(
-		enc->adapter_service->gpio_service,
+		enc->ctx->gpio_service,
 		pin_info.offset,
 		pin_info.mask);
 }
diff --git a/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h b/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h
index 52bf06b8b507..052cd9ab5cf3 100644
--- a/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h
+++ b/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h
@@ -33,9 +33,11 @@
 #include "dal_types.h"
 #include "asic_capability_types.h"
 
+#define SIZEOF_BACKLIGHT_LUT 101
+
 /* forward declaration */
 struct i2caux;
-struct adapter_service;
+struct asic_cap;
 
 /*
  * enum adapter_feature_id
@@ -293,6 +295,22 @@ enum adapter_feature_id {
 	FEATURE_MAXIMUM
 };
 
+/* Adapter service */
+struct adapter_service {
+	struct dc_context *ctx;
+	struct asic_capability *asic_cap;
+	enum dce_environment dce_environment;
+	struct i2caux *i2caux;
+	struct integrated_info *integrated_info;
+	uint32_t platform_methods_mask;
+	uint32_t ac_level_percentage;
+	uint32_t dc_level_percentage;
+	uint32_t backlight_caps_initialized;
+	uint32_t backlight_8bit_lut[SIZEOF_BACKLIGHT_LUT];
+	uint32_t adapter_feature_set[FEATURE_MAXIMUM/32];
+	uint32_t default_values[FEATURE_MAXIMUM];
+};
+
 /* Adapter Service type of DRR support*/
 enum as_drr_support {
 	AS_DRR_SUPPORT_DISABLED = 0x0,
-- 
2.10.1



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux