| 1 | /* |
| 2 | * Copyright 2023 Advanced Micro Devices, Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | * |
| 22 | * Authors: AMD |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | /* FILE POLICY AND INTENDED USAGE: |
| 27 | * This file owns the creation/destruction of link structure. |
| 28 | */ |
| 29 | #include "link_factory.h" |
| 30 | #include "link_detection.h" |
| 31 | #include "link_resource.h" |
| 32 | #include "link_validation.h" |
| 33 | #include "link_dpms.h" |
| 34 | #include "accessories/link_dp_cts.h" |
| 35 | #include "accessories/link_dp_trace.h" |
| 36 | #include "protocols/link_ddc.h" |
| 37 | #include "protocols/link_dp_capability.h" |
| 38 | #include "protocols/link_dp_dpia_bw.h" |
| 39 | #include "protocols/link_dp_dpia.h" |
| 40 | #include "protocols/link_dp_irq_handler.h" |
| 41 | #include "protocols/link_dp_phy.h" |
| 42 | #include "protocols/link_dp_training.h" |
| 43 | #include "protocols/link_edp_panel_control.h" |
| 44 | #include "protocols/link_hpd.h" |
| 45 | #include "gpio_service_interface.h" |
| 46 | #include "atomfirmware.h" |
| 47 | |
| 48 | #define DC_LOGGER \ |
| 49 | dc_ctx->logger |
| 50 | #define DC_LOGGER_INIT(logger) |
| 51 | |
| 52 | #define LINK_INFO(...) \ |
| 53 | DC_LOG_HW_HOTPLUG( \ |
| 54 | __VA_ARGS__) |
| 55 | |
| 56 | /* link factory owns the creation/destruction of link structures. */ |
| 57 | static void construct_link_service_factory(struct link_service *link_srv) |
| 58 | { |
| 59 | |
| 60 | link_srv->create_link = link_create; |
| 61 | link_srv->destroy_link = link_destroy; |
| 62 | } |
| 63 | |
| 64 | /* link_detection manages link detection states and receiver states by using |
| 65 | * various link protocols. It also provides helper functions to interpret |
| 66 | * certain capabilities or status based on the states it manages or retrieve |
| 67 | * them directly from connected receivers. |
| 68 | */ |
| 69 | static void construct_link_service_detection(struct link_service *link_srv) |
| 70 | { |
| 71 | link_srv->detect_link = link_detect; |
| 72 | link_srv->detect_connection_type = link_detect_connection_type; |
| 73 | link_srv->add_remote_sink = link_add_remote_sink; |
| 74 | link_srv->remove_remote_sink = link_remove_remote_sink; |
| 75 | link_srv->get_hpd_state = link_get_hpd_state; |
| 76 | link_srv->get_hpd_gpio = link_get_hpd_gpio; |
| 77 | link_srv->enable_hpd = link_enable_hpd; |
| 78 | link_srv->disable_hpd = link_disable_hpd; |
| 79 | link_srv->enable_hpd_filter = link_enable_hpd_filter; |
| 80 | link_srv->reset_cur_dp_mst_topology = link_reset_cur_dp_mst_topology; |
| 81 | link_srv->get_status = link_get_status; |
| 82 | link_srv->is_hdcp1x_supported = link_is_hdcp14; |
| 83 | link_srv->is_hdcp2x_supported = link_is_hdcp22; |
| 84 | link_srv->clear_dprx_states = link_clear_dprx_states; |
| 85 | } |
| 86 | |
| 87 | /* link resource implements accessors to link resource. */ |
| 88 | static void construct_link_service_resource(struct link_service *link_srv) |
| 89 | { |
| 90 | link_srv->get_cur_res_map = link_get_cur_res_map; |
| 91 | link_srv->restore_res_map = link_restore_res_map; |
| 92 | link_srv->get_cur_link_res = link_get_cur_link_res; |
| 93 | } |
| 94 | |
| 95 | /* link validation owns timing validation against various link limitations. (ex. |
| 96 | * link bandwidth, receiver capability or our hardware capability) It also |
| 97 | * provides helper functions exposing bandwidth formulas used in validation. |
| 98 | */ |
| 99 | static void construct_link_service_validation(struct link_service *link_srv) |
| 100 | { |
| 101 | link_srv->validate_mode_timing = link_validate_mode_timing; |
| 102 | link_srv->dp_link_bandwidth_kbps = dp_link_bandwidth_kbps; |
| 103 | link_srv->validate_dp_tunnel_bandwidth = link_validate_dp_tunnel_bandwidth; |
| 104 | link_srv->dp_required_hblank_size_bytes = dp_required_hblank_size_bytes; |
| 105 | } |
| 106 | |
| 107 | /* link dpms owns the programming sequence of stream's dpms state associated |
| 108 | * with the link and link's enable/disable sequences as result of the stream's |
| 109 | * dpms state change. |
| 110 | */ |
| 111 | static void construct_link_service_dpms(struct link_service *link_srv) |
| 112 | { |
| 113 | link_srv->set_dpms_on = link_set_dpms_on; |
| 114 | link_srv->set_dpms_off = link_set_dpms_off; |
| 115 | link_srv->resume = link_resume; |
| 116 | link_srv->blank_all_dp_displays = link_blank_all_dp_displays; |
| 117 | link_srv->blank_all_edp_displays = link_blank_all_edp_displays; |
| 118 | link_srv->blank_dp_stream = link_blank_dp_stream; |
| 119 | link_srv->increase_mst_payload = link_increase_mst_payload; |
| 120 | link_srv->reduce_mst_payload = link_reduce_mst_payload; |
| 121 | link_srv->set_dsc_on_stream = link_set_dsc_on_stream; |
| 122 | link_srv->set_dsc_enable = link_set_dsc_enable; |
| 123 | link_srv->update_dsc_config = link_update_dsc_config; |
| 124 | } |
| 125 | |
| 126 | /* link ddc implements generic display communication protocols such as i2c, aux |
| 127 | * and scdc. It should not contain any specific applications of these |
| 128 | * protocols such as display capability query, detection, or handshaking such as |
| 129 | * link training. |
| 130 | */ |
| 131 | static void construct_link_service_ddc(struct link_service *link_srv) |
| 132 | { |
| 133 | link_srv->create_ddc_service = link_create_ddc_service; |
| 134 | link_srv->destroy_ddc_service = link_destroy_ddc_service; |
| 135 | link_srv->query_ddc_data = link_query_ddc_data; |
| 136 | link_srv->aux_transfer_raw = link_aux_transfer_raw; |
| 137 | link_srv->configure_fixed_vs_pe_retimer = link_configure_fixed_vs_pe_retimer; |
| 138 | link_srv->aux_transfer_with_retries_no_mutex = |
| 139 | link_aux_transfer_with_retries_no_mutex; |
| 140 | link_srv->is_in_aux_transaction_mode = link_is_in_aux_transaction_mode; |
| 141 | link_srv->get_aux_defer_delay = link_get_aux_defer_delay; |
| 142 | } |
| 143 | |
| 144 | /* link dp capability implements dp specific link capability retrieval sequence. |
| 145 | * It is responsible for retrieving, parsing, overriding, deciding capability |
| 146 | * obtained from dp link. Link capability consists of encoders, DPRXs, cables, |
| 147 | * retimers, usb and all other possible backend capabilities. |
| 148 | */ |
| 149 | static void construct_link_service_dp_capability(struct link_service *link_srv) |
| 150 | { |
| 151 | link_srv->dp_is_sink_present = dp_is_sink_present; |
| 152 | link_srv->dp_is_fec_supported = dp_is_fec_supported; |
| 153 | link_srv->dp_is_128b_132b_signal = dp_is_128b_132b_signal; |
| 154 | link_srv->dp_get_max_link_enc_cap = dp_get_max_link_enc_cap; |
| 155 | link_srv->dp_get_verified_link_cap = dp_get_verified_link_cap; |
| 156 | link_srv->dp_get_encoding_format = link_dp_get_encoding_format; |
| 157 | link_srv->dp_should_enable_fec = dp_should_enable_fec; |
| 158 | link_srv->dp_decide_link_settings = link_decide_link_settings; |
| 159 | link_srv->dp_decide_tunnel_settings = link_decide_dp_tunnel_settings; |
| 160 | link_srv->mst_decide_link_encoding_format = |
| 161 | mst_decide_link_encoding_format; |
| 162 | link_srv->edp_decide_link_settings = edp_decide_link_settings; |
| 163 | link_srv->bw_kbps_from_raw_frl_link_rate_data = |
| 164 | link_bw_kbps_from_raw_frl_link_rate_data; |
| 165 | link_srv->dp_overwrite_extended_receiver_cap = |
| 166 | dp_overwrite_extended_receiver_cap; |
| 167 | link_srv->dp_decide_lttpr_mode = dp_decide_lttpr_mode; |
| 168 | link_srv->dp_get_lttpr_count = dp_get_lttpr_count; |
| 169 | link_srv->edp_get_alpm_support = edp_get_alpm_support; |
| 170 | } |
| 171 | |
| 172 | /* link dp phy/dpia implements basic dp phy/dpia functionality such as |
| 173 | * enable/disable output and set lane/drive settings. It is responsible for |
| 174 | * maintaining and update software state representing current phy/dpia status |
| 175 | * such as current link settings. |
| 176 | */ |
| 177 | static void construct_link_service_dp_phy_or_dpia(struct link_service *link_srv) |
| 178 | { |
| 179 | link_srv->dpia_handle_usb4_bandwidth_allocation_for_link = |
| 180 | dpia_handle_usb4_bandwidth_allocation_for_link; |
| 181 | link_srv->dp_set_drive_settings = dp_set_drive_settings; |
| 182 | link_srv->dpcd_write_rx_power_ctrl = dpcd_write_rx_power_ctrl; |
| 183 | } |
| 184 | |
| 185 | /* link dp irq handler implements DP HPD short pulse handling sequence according |
| 186 | * to DP specifications |
| 187 | */ |
| 188 | static void construct_link_service_dp_irq_handler(struct link_service *link_srv) |
| 189 | { |
| 190 | link_srv->dp_parse_link_loss_status = dp_parse_link_loss_status; |
| 191 | link_srv->dp_should_allow_hpd_rx_irq = dp_should_allow_hpd_rx_irq; |
| 192 | link_srv->dp_handle_link_loss = dp_handle_link_loss; |
| 193 | link_srv->dp_read_hpd_rx_irq_data = dp_read_hpd_rx_irq_data; |
| 194 | link_srv->dp_handle_hpd_rx_irq = dp_handle_hpd_rx_irq; |
| 195 | } |
| 196 | |
| 197 | /* link edp panel control implements retrieval and configuration of eDP panel |
| 198 | * features such as PSR and ABM and it also manages specs defined eDP panel |
| 199 | * power sequences. |
| 200 | */ |
| 201 | static void construct_link_service_edp_panel_control(struct link_service *link_srv) |
| 202 | { |
| 203 | link_srv->edp_panel_backlight_power_on = edp_panel_backlight_power_on; |
| 204 | link_srv->edp_get_backlight_level = edp_get_backlight_level; |
| 205 | link_srv->edp_get_backlight_level_nits = edp_get_backlight_level_nits; |
| 206 | link_srv->edp_set_backlight_level = edp_set_backlight_level; |
| 207 | link_srv->edp_set_backlight_level_nits = edp_set_backlight_level_nits; |
| 208 | link_srv->edp_get_target_backlight_pwm = edp_get_target_backlight_pwm; |
| 209 | link_srv->edp_get_psr_state = edp_get_psr_state; |
| 210 | link_srv->edp_set_psr_allow_active = edp_set_psr_allow_active; |
| 211 | link_srv->edp_setup_psr = edp_setup_psr; |
| 212 | link_srv->edp_set_sink_vtotal_in_psr_active = |
| 213 | edp_set_sink_vtotal_in_psr_active; |
| 214 | link_srv->edp_get_psr_residency = edp_get_psr_residency; |
| 215 | |
| 216 | link_srv->edp_get_replay_state = edp_get_replay_state; |
| 217 | link_srv->edp_set_replay_allow_active = edp_set_replay_allow_active; |
| 218 | link_srv->edp_setup_replay = edp_setup_replay; |
| 219 | link_srv->edp_send_replay_cmd = edp_send_replay_cmd; |
| 220 | link_srv->edp_set_coasting_vtotal = edp_set_coasting_vtotal; |
| 221 | link_srv->edp_replay_residency = edp_replay_residency; |
| 222 | link_srv->edp_set_replay_power_opt_and_coasting_vtotal = edp_set_replay_power_opt_and_coasting_vtotal; |
| 223 | |
| 224 | link_srv->edp_wait_for_t12 = edp_wait_for_t12; |
| 225 | link_srv->edp_is_ilr_optimization_required = |
| 226 | edp_is_ilr_optimization_required; |
| 227 | link_srv->edp_backlight_enable_aux = edp_backlight_enable_aux; |
| 228 | link_srv->edp_add_delay_for_T9 = edp_add_delay_for_T9; |
| 229 | link_srv->edp_receiver_ready_T9 = edp_receiver_ready_T9; |
| 230 | link_srv->edp_receiver_ready_T7 = edp_receiver_ready_T7; |
| 231 | link_srv->edp_power_alpm_dpcd_enable = edp_power_alpm_dpcd_enable; |
| 232 | link_srv->edp_set_panel_power = edp_set_panel_power; |
| 233 | } |
| 234 | |
| 235 | /* link dp cts implements dp compliance test automation protocols and manual |
| 236 | * testing interfaces for debugging and certification purpose. |
| 237 | */ |
| 238 | static void construct_link_service_dp_cts(struct link_service *link_srv) |
| 239 | { |
| 240 | link_srv->dp_handle_automated_test = dp_handle_automated_test; |
| 241 | link_srv->dp_set_test_pattern = dp_set_test_pattern; |
| 242 | link_srv->dp_set_preferred_link_settings = |
| 243 | dp_set_preferred_link_settings; |
| 244 | link_srv->dp_set_preferred_training_settings = |
| 245 | dp_set_preferred_training_settings; |
| 246 | } |
| 247 | |
| 248 | /* link dp trace implements tracing interfaces for tracking major dp sequences |
| 249 | * including execution status and timestamps |
| 250 | */ |
| 251 | static void construct_link_service_dp_trace(struct link_service *link_srv) |
| 252 | { |
| 253 | link_srv->dp_trace_is_initialized = dp_trace_is_initialized; |
| 254 | link_srv->dp_trace_set_is_logged_flag = dp_trace_set_is_logged_flag; |
| 255 | link_srv->dp_trace_is_logged = dp_trace_is_logged; |
| 256 | link_srv->dp_trace_get_lt_end_timestamp = dp_trace_get_lt_end_timestamp; |
| 257 | link_srv->dp_trace_get_lt_counts = dp_trace_get_lt_counts; |
| 258 | link_srv->dp_trace_get_link_loss_count = dp_trace_get_link_loss_count; |
| 259 | link_srv->dp_trace_set_edp_power_timestamp = |
| 260 | dp_trace_set_edp_power_timestamp; |
| 261 | link_srv->dp_trace_get_edp_poweron_timestamp = |
| 262 | dp_trace_get_edp_poweron_timestamp; |
| 263 | link_srv->dp_trace_get_edp_poweroff_timestamp = |
| 264 | dp_trace_get_edp_poweroff_timestamp; |
| 265 | link_srv->dp_trace_source_sequence = dp_trace_source_sequence; |
| 266 | } |
| 267 | |
| 268 | static void construct_link_service(struct link_service *link_srv) |
| 269 | { |
| 270 | /* All link service functions should fall under some sub categories. |
| 271 | * If a new function doesn't perfectly fall under an existing sub |
| 272 | * category, it must be that you are either adding a whole new aspect of |
| 273 | * responsibility to link service or something doesn't belong to link |
| 274 | * service. In that case please contact the arch owner to arrange a |
| 275 | * design review meeting. |
| 276 | */ |
| 277 | construct_link_service_factory(link_srv); |
| 278 | construct_link_service_detection(link_srv); |
| 279 | construct_link_service_resource(link_srv); |
| 280 | construct_link_service_validation(link_srv); |
| 281 | construct_link_service_dpms(link_srv); |
| 282 | construct_link_service_ddc(link_srv); |
| 283 | construct_link_service_dp_capability(link_srv); |
| 284 | construct_link_service_dp_phy_or_dpia(link_srv); |
| 285 | construct_link_service_dp_irq_handler(link_srv); |
| 286 | construct_link_service_edp_panel_control(link_srv); |
| 287 | construct_link_service_dp_cts(link_srv); |
| 288 | construct_link_service_dp_trace(link_srv); |
| 289 | } |
| 290 | |
| 291 | struct link_service *link_create_link_service(void) |
| 292 | { |
| 293 | struct link_service *link_srv = kzalloc(sizeof(*link_srv), GFP_KERNEL); |
| 294 | |
| 295 | if (link_srv == NULL) |
| 296 | goto fail; |
| 297 | |
| 298 | construct_link_service(link_srv); |
| 299 | |
| 300 | return link_srv; |
| 301 | fail: |
| 302 | return NULL; |
| 303 | } |
| 304 | |
| 305 | void link_destroy_link_service(struct link_service **link_srv) |
| 306 | { |
| 307 | kfree(objp: *link_srv); |
| 308 | *link_srv = NULL; |
| 309 | } |
| 310 | |
| 311 | static enum transmitter translate_encoder_to_transmitter( |
| 312 | struct graphics_object_id encoder) |
| 313 | { |
| 314 | switch (encoder.id) { |
| 315 | case ENCODER_ID_INTERNAL_UNIPHY: |
| 316 | switch (encoder.enum_id) { |
| 317 | case ENUM_ID_1: |
| 318 | return TRANSMITTER_UNIPHY_A; |
| 319 | case ENUM_ID_2: |
| 320 | return TRANSMITTER_UNIPHY_B; |
| 321 | default: |
| 322 | return TRANSMITTER_UNKNOWN; |
| 323 | } |
| 324 | break; |
| 325 | case ENCODER_ID_INTERNAL_UNIPHY1: |
| 326 | switch (encoder.enum_id) { |
| 327 | case ENUM_ID_1: |
| 328 | return TRANSMITTER_UNIPHY_C; |
| 329 | case ENUM_ID_2: |
| 330 | return TRANSMITTER_UNIPHY_D; |
| 331 | default: |
| 332 | return TRANSMITTER_UNKNOWN; |
| 333 | } |
| 334 | break; |
| 335 | case ENCODER_ID_INTERNAL_UNIPHY2: |
| 336 | switch (encoder.enum_id) { |
| 337 | case ENUM_ID_1: |
| 338 | return TRANSMITTER_UNIPHY_E; |
| 339 | case ENUM_ID_2: |
| 340 | return TRANSMITTER_UNIPHY_F; |
| 341 | default: |
| 342 | return TRANSMITTER_UNKNOWN; |
| 343 | } |
| 344 | break; |
| 345 | case ENCODER_ID_INTERNAL_UNIPHY3: |
| 346 | switch (encoder.enum_id) { |
| 347 | case ENUM_ID_1: |
| 348 | return TRANSMITTER_UNIPHY_G; |
| 349 | default: |
| 350 | return TRANSMITTER_UNKNOWN; |
| 351 | } |
| 352 | break; |
| 353 | case ENCODER_ID_EXTERNAL_NUTMEG: |
| 354 | switch (encoder.enum_id) { |
| 355 | case ENUM_ID_1: |
| 356 | return TRANSMITTER_NUTMEG_CRT; |
| 357 | default: |
| 358 | return TRANSMITTER_UNKNOWN; |
| 359 | } |
| 360 | break; |
| 361 | case ENCODER_ID_EXTERNAL_TRAVIS: |
| 362 | switch (encoder.enum_id) { |
| 363 | case ENUM_ID_1: |
| 364 | return TRANSMITTER_TRAVIS_CRT; |
| 365 | case ENUM_ID_2: |
| 366 | return TRANSMITTER_TRAVIS_LCD; |
| 367 | default: |
| 368 | return TRANSMITTER_UNKNOWN; |
| 369 | } |
| 370 | break; |
| 371 | default: |
| 372 | return TRANSMITTER_UNKNOWN; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | static void link_destruct(struct dc_link *link) |
| 377 | { |
| 378 | int i; |
| 379 | |
| 380 | if (link->hpd_gpio) { |
| 381 | dal_gpio_destroy_irq(ptr: &link->hpd_gpio); |
| 382 | link->hpd_gpio = NULL; |
| 383 | } |
| 384 | |
| 385 | if (link->ddc) |
| 386 | link_destroy_ddc_service(ddc: &link->ddc); |
| 387 | |
| 388 | if (link->panel_cntl) |
| 389 | link->panel_cntl->funcs->destroy(&link->panel_cntl); |
| 390 | |
| 391 | if (link->link_enc && !link->is_dig_mapping_flexible) { |
| 392 | /* Update link encoder resource tracking variables. These are used for |
| 393 | * the dynamic assignment of link encoders to streams. Virtual links |
| 394 | * are not assigned encoder resources on creation. |
| 395 | */ |
| 396 | if (link->link_id.id != CONNECTOR_ID_VIRTUAL && link->eng_id != ENGINE_ID_UNKNOWN) { |
| 397 | link->dc->res_pool->link_encoders[link->eng_id - ENGINE_ID_DIGA] = NULL; |
| 398 | link->dc->res_pool->dig_link_enc_count--; |
| 399 | } |
| 400 | link->link_enc->funcs->destroy(&link->link_enc); |
| 401 | } |
| 402 | |
| 403 | if (link->local_sink) |
| 404 | dc_sink_release(sink: link->local_sink); |
| 405 | |
| 406 | for (i = 0; i < link->sink_count; ++i) |
| 407 | dc_sink_release(sink: link->remote_sinks[i]); |
| 408 | } |
| 409 | |
| 410 | static enum channel_id get_ddc_line(struct dc_link *link) |
| 411 | { |
| 412 | struct ddc *ddc; |
| 413 | enum channel_id channel; |
| 414 | |
| 415 | channel = CHANNEL_ID_UNKNOWN; |
| 416 | |
| 417 | ddc = get_ddc_pin(ddc_service: link->ddc); |
| 418 | |
| 419 | if (ddc) { |
| 420 | switch (dal_ddc_get_line(ddc)) { |
| 421 | case GPIO_DDC_LINE_DDC1: |
| 422 | channel = CHANNEL_ID_DDC1; |
| 423 | break; |
| 424 | case GPIO_DDC_LINE_DDC2: |
| 425 | channel = CHANNEL_ID_DDC2; |
| 426 | break; |
| 427 | case GPIO_DDC_LINE_DDC3: |
| 428 | channel = CHANNEL_ID_DDC3; |
| 429 | break; |
| 430 | case GPIO_DDC_LINE_DDC4: |
| 431 | channel = CHANNEL_ID_DDC4; |
| 432 | break; |
| 433 | case GPIO_DDC_LINE_DDC5: |
| 434 | channel = CHANNEL_ID_DDC5; |
| 435 | break; |
| 436 | case GPIO_DDC_LINE_DDC6: |
| 437 | channel = CHANNEL_ID_DDC6; |
| 438 | break; |
| 439 | case GPIO_DDC_LINE_DDC_VGA: |
| 440 | channel = CHANNEL_ID_DDC_VGA; |
| 441 | break; |
| 442 | case GPIO_DDC_LINE_I2C_PAD: |
| 443 | channel = CHANNEL_ID_I2C_PAD; |
| 444 | break; |
| 445 | default: |
| 446 | BREAK_TO_DEBUGGER(); |
| 447 | break; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | return channel; |
| 452 | } |
| 453 | |
| 454 | static enum engine_id find_analog_engine(struct dc_link *link) |
| 455 | { |
| 456 | struct dc_bios *bp = link->ctx->dc_bios; |
| 457 | struct graphics_object_id encoder = {0}; |
| 458 | enum bp_result bp_result = BP_RESULT_OK; |
| 459 | int i; |
| 460 | |
| 461 | for (i = 0; i < 3; i++) { |
| 462 | bp_result = bp->funcs->get_src_obj(bp, link->link_id, i, &encoder); |
| 463 | |
| 464 | if (bp_result != BP_RESULT_OK) |
| 465 | return ENGINE_ID_UNKNOWN; |
| 466 | |
| 467 | switch (encoder.id) { |
| 468 | case ENCODER_ID_INTERNAL_DAC1: |
| 469 | case ENCODER_ID_INTERNAL_KLDSCP_DAC1: |
| 470 | return ENGINE_ID_DACA; |
| 471 | case ENCODER_ID_INTERNAL_DAC2: |
| 472 | case ENCODER_ID_INTERNAL_KLDSCP_DAC2: |
| 473 | return ENGINE_ID_DACB; |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | return ENGINE_ID_UNKNOWN; |
| 478 | } |
| 479 | |
| 480 | static bool transmitter_supported(const enum transmitter transmitter) |
| 481 | { |
| 482 | return transmitter != TRANSMITTER_UNKNOWN && |
| 483 | transmitter != TRANSMITTER_NUTMEG_CRT && |
| 484 | transmitter != TRANSMITTER_TRAVIS_CRT && |
| 485 | transmitter != TRANSMITTER_TRAVIS_LCD; |
| 486 | } |
| 487 | |
| 488 | static bool analog_engine_supported(const enum engine_id engine_id) |
| 489 | { |
| 490 | return engine_id == ENGINE_ID_DACA || |
| 491 | engine_id == ENGINE_ID_DACB; |
| 492 | } |
| 493 | |
| 494 | static bool construct_phy(struct dc_link *link, |
| 495 | const struct link_init_data *init_params) |
| 496 | { |
| 497 | uint8_t i; |
| 498 | struct ddc_service_init_data ddc_service_init_data = { 0 }; |
| 499 | struct dc_context *dc_ctx = init_params->ctx; |
| 500 | struct encoder_init_data enc_init_data = { 0 }; |
| 501 | struct panel_cntl_init_data panel_cntl_init_data = { 0 }; |
| 502 | struct dc_bios *bios = init_params->dc->ctx->dc_bios; |
| 503 | const struct dc_vbios_funcs *bp_funcs = bios->funcs; |
| 504 | struct bp_disp_connector_caps_info disp_connect_caps_info = { 0 }; |
| 505 | |
| 506 | DC_LOGGER_INIT(dc_ctx->logger); |
| 507 | |
| 508 | link->irq_source_hpd = DC_IRQ_SOURCE_INVALID; |
| 509 | link->irq_source_hpd_rx = DC_IRQ_SOURCE_INVALID; |
| 510 | link->irq_source_read_request = DC_IRQ_SOURCE_INVALID; |
| 511 | link->link_status.dpcd_caps = &link->dpcd_caps; |
| 512 | |
| 513 | link->dc = init_params->dc; |
| 514 | link->ctx = dc_ctx; |
| 515 | link->link_index = init_params->link_index; |
| 516 | |
| 517 | memset(&link->preferred_training_settings, 0, |
| 518 | sizeof(struct dc_link_training_overrides)); |
| 519 | memset(&link->preferred_link_setting, 0, |
| 520 | sizeof(struct dc_link_settings)); |
| 521 | |
| 522 | link->link_id = |
| 523 | bios->funcs->get_connector_id(bios, init_params->connector_index); |
| 524 | |
| 525 | /* Determine early if the link has any supported encoders, |
| 526 | * so that we avoid initializing DDC and HPD, etc. |
| 527 | */ |
| 528 | bp_funcs->get_src_obj(bios, link->link_id, 0, &enc_init_data.encoder); |
| 529 | enc_init_data.transmitter = translate_encoder_to_transmitter(encoder: enc_init_data.encoder); |
| 530 | enc_init_data.analog_engine = find_analog_engine(link); |
| 531 | |
| 532 | link->ep_type = DISPLAY_ENDPOINT_PHY; |
| 533 | |
| 534 | DC_LOG_DC("BIOS object table - link_id: %d" , link->link_id.id); |
| 535 | |
| 536 | if (!transmitter_supported(transmitter: enc_init_data.transmitter) && |
| 537 | !analog_engine_supported(engine_id: enc_init_data.analog_engine)) { |
| 538 | DC_LOG_WARNING("link_id %d has unsupported encoder\n" , link->link_id.id); |
| 539 | goto unsupported_fail; |
| 540 | } |
| 541 | |
| 542 | if (bios->funcs->get_disp_connector_caps_info) { |
| 543 | bios->funcs->get_disp_connector_caps_info(bios, link->link_id, &disp_connect_caps_info); |
| 544 | link->is_internal_display = disp_connect_caps_info.INTERNAL_DISPLAY; |
| 545 | DC_LOG_DC("BIOS object table - is_internal_display: %d" , link->is_internal_display); |
| 546 | } |
| 547 | |
| 548 | if (link->link_id.type != OBJECT_TYPE_CONNECTOR) { |
| 549 | dm_output_to_console("%s: Invalid Connector ObjectID from Adapter Service for connector index:%d! type %d expected %d\n" , |
| 550 | __func__, init_params->connector_index, |
| 551 | link->link_id.type, OBJECT_TYPE_CONNECTOR); |
| 552 | goto create_fail; |
| 553 | } |
| 554 | |
| 555 | if (link->dc->res_pool->funcs->link_init) |
| 556 | link->dc->res_pool->funcs->link_init(link); |
| 557 | |
| 558 | link->hpd_gpio = link_get_hpd_gpio(dcb: link->ctx->dc_bios, link_id: link->link_id, |
| 559 | gpio_service: link->ctx->gpio_service); |
| 560 | |
| 561 | if (link->hpd_gpio) { |
| 562 | dal_gpio_open(gpio: link->hpd_gpio, mode: GPIO_MODE_INTERRUPT); |
| 563 | dal_gpio_unlock_pin(gpio: link->hpd_gpio); |
| 564 | link->irq_source_hpd = dal_irq_get_source(irq: link->hpd_gpio); |
| 565 | |
| 566 | DC_LOG_DC("BIOS object table - hpd_gpio id: %d" , link->hpd_gpio->id); |
| 567 | DC_LOG_DC("BIOS object table - hpd_gpio en: %d" , link->hpd_gpio->en); |
| 568 | } |
| 569 | |
| 570 | switch (link->link_id.id) { |
| 571 | case CONNECTOR_ID_HDMI_TYPE_A: |
| 572 | link->connector_signal = SIGNAL_TYPE_HDMI_TYPE_A; |
| 573 | |
| 574 | if (link->hpd_gpio) |
| 575 | link->irq_source_read_request = |
| 576 | dal_irq_get_read_request(irq: link->hpd_gpio); |
| 577 | break; |
| 578 | case CONNECTOR_ID_SINGLE_LINK_DVID: |
| 579 | case CONNECTOR_ID_SINGLE_LINK_DVII: |
| 580 | link->connector_signal = SIGNAL_TYPE_DVI_SINGLE_LINK; |
| 581 | break; |
| 582 | case CONNECTOR_ID_DUAL_LINK_DVID: |
| 583 | case CONNECTOR_ID_DUAL_LINK_DVII: |
| 584 | link->connector_signal = SIGNAL_TYPE_DVI_DUAL_LINK; |
| 585 | break; |
| 586 | case CONNECTOR_ID_VGA: |
| 587 | link->connector_signal = SIGNAL_TYPE_RGB; |
| 588 | break; |
| 589 | case CONNECTOR_ID_DISPLAY_PORT: |
| 590 | case CONNECTOR_ID_MXM: |
| 591 | case CONNECTOR_ID_USBC: |
| 592 | link->connector_signal = SIGNAL_TYPE_DISPLAY_PORT; |
| 593 | |
| 594 | if (link->hpd_gpio) |
| 595 | link->irq_source_hpd_rx = |
| 596 | dal_irq_get_rx_source(irq: link->hpd_gpio); |
| 597 | |
| 598 | break; |
| 599 | case CONNECTOR_ID_EDP: |
| 600 | // If smartmux is supported, only create the link on the primary eDP. |
| 601 | // Dual eDP is not supported with smartmux. |
| 602 | if (!(!link->dc->config.smart_mux_version || dc_ctx->dc_edp_id_count == 0)) |
| 603 | goto create_fail; |
| 604 | |
| 605 | link->connector_signal = SIGNAL_TYPE_EDP; |
| 606 | |
| 607 | if (link->hpd_gpio) { |
| 608 | if (!link->dc->config.allow_edp_hotplug_detection |
| 609 | && !is_smartmux_suported(link)) |
| 610 | link->irq_source_hpd = DC_IRQ_SOURCE_INVALID; |
| 611 | |
| 612 | switch (link->dc->config.allow_edp_hotplug_detection) { |
| 613 | case HPD_EN_FOR_ALL_EDP: |
| 614 | link->irq_source_hpd_rx = |
| 615 | dal_irq_get_rx_source(irq: link->hpd_gpio); |
| 616 | break; |
| 617 | case HPD_EN_FOR_PRIMARY_EDP_ONLY: |
| 618 | if (link->link_index == 0) |
| 619 | link->irq_source_hpd_rx = |
| 620 | dal_irq_get_rx_source(irq: link->hpd_gpio); |
| 621 | else |
| 622 | link->irq_source_hpd = DC_IRQ_SOURCE_INVALID; |
| 623 | break; |
| 624 | case HPD_EN_FOR_SECONDARY_EDP_ONLY: |
| 625 | if (link->link_index == 1) |
| 626 | link->irq_source_hpd_rx = |
| 627 | dal_irq_get_rx_source(irq: link->hpd_gpio); |
| 628 | else |
| 629 | link->irq_source_hpd = DC_IRQ_SOURCE_INVALID; |
| 630 | break; |
| 631 | default: |
| 632 | link->irq_source_hpd = DC_IRQ_SOURCE_INVALID; |
| 633 | break; |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | break; |
| 638 | case CONNECTOR_ID_LVDS: |
| 639 | link->connector_signal = SIGNAL_TYPE_LVDS; |
| 640 | break; |
| 641 | default: |
| 642 | DC_LOG_WARNING("Unsupported Connector type:%d!\n" , |
| 643 | link->link_id.id); |
| 644 | goto create_fail; |
| 645 | } |
| 646 | |
| 647 | LINK_INFO("Connector[%d] description: signal: %s\n" , |
| 648 | init_params->connector_index, |
| 649 | signal_type_to_string(link->connector_signal)); |
| 650 | |
| 651 | ddc_service_init_data.ctx = link->ctx; |
| 652 | ddc_service_init_data.id = link->link_id; |
| 653 | ddc_service_init_data.link = link; |
| 654 | link->ddc = link_create_ddc_service(ddc_init_data: &ddc_service_init_data); |
| 655 | |
| 656 | if (!link->ddc) { |
| 657 | DC_ERROR("Failed to create ddc_service!\n" ); |
| 658 | goto ddc_create_fail; |
| 659 | } |
| 660 | |
| 661 | if (!link->ddc->ddc_pin) { |
| 662 | DC_ERROR("Failed to get I2C info for connector!\n" ); |
| 663 | goto ddc_create_fail; |
| 664 | } |
| 665 | |
| 666 | link->ddc_hw_inst = |
| 667 | dal_ddc_get_line(ddc: get_ddc_pin(ddc_service: link->ddc)); |
| 668 | |
| 669 | enc_init_data.ctx = dc_ctx; |
| 670 | enc_init_data.connector = link->link_id; |
| 671 | enc_init_data.channel = get_ddc_line(link); |
| 672 | enc_init_data.hpd_source = get_hpd_line(link); |
| 673 | |
| 674 | link->hpd_src = enc_init_data.hpd_source; |
| 675 | |
| 676 | link->link_enc = |
| 677 | link->dc->res_pool->funcs->link_enc_create(dc_ctx, &enc_init_data); |
| 678 | |
| 679 | if (!link->link_enc) { |
| 680 | DC_ERROR("Failed to create link encoder!\n" ); |
| 681 | goto link_enc_create_fail; |
| 682 | } |
| 683 | |
| 684 | DC_LOG_DC("BIOS object table - DP_IS_USB_C: %d" , link->link_enc->features.flags.bits.DP_IS_USB_C); |
| 685 | DC_LOG_DC("BIOS object table - IS_DP2_CAPABLE: %d" , link->link_enc->features.flags.bits.IS_DP2_CAPABLE); |
| 686 | |
| 687 | /* Update link encoder tracking variables. These are used for the dynamic |
| 688 | * assignment of link encoders to streams. |
| 689 | */ |
| 690 | link->eng_id = link->link_enc->preferred_engine; |
| 691 | link->dc->res_pool->link_encoders[link->eng_id - ENGINE_ID_DIGA] = link->link_enc; |
| 692 | link->dc->res_pool->dig_link_enc_count++; |
| 693 | |
| 694 | link->link_enc_hw_inst = link->link_enc->transmitter; |
| 695 | |
| 696 | if (link->dc->res_pool->funcs->panel_cntl_create && |
| 697 | (link->link_id.id == CONNECTOR_ID_EDP || |
| 698 | link->link_id.id == CONNECTOR_ID_LVDS)) { |
| 699 | panel_cntl_init_data.ctx = dc_ctx; |
| 700 | panel_cntl_init_data.inst = panel_cntl_init_data.ctx->dc_edp_id_count; |
| 701 | panel_cntl_init_data.eng_id = link->eng_id; |
| 702 | link->panel_cntl = |
| 703 | link->dc->res_pool->funcs->panel_cntl_create( |
| 704 | &panel_cntl_init_data); |
| 705 | panel_cntl_init_data.ctx->dc_edp_id_count++; |
| 706 | |
| 707 | if (link->panel_cntl == NULL) { |
| 708 | DC_ERROR("Failed to create link panel_cntl!\n" ); |
| 709 | goto panel_cntl_create_fail; |
| 710 | } |
| 711 | } |
| 712 | for (i = 0; i < 4; i++) { |
| 713 | if (bp_funcs->get_device_tag(dc_ctx->dc_bios, |
| 714 | link->link_id, i, |
| 715 | &link->device_tag) != BP_RESULT_OK) { |
| 716 | DC_ERROR("Failed to find device tag!\n" ); |
| 717 | goto device_tag_fail; |
| 718 | } |
| 719 | |
| 720 | /* Look for device tag that matches connector signal, |
| 721 | * CRT for rgb, LCD for other supported signal types |
| 722 | */ |
| 723 | if (!bp_funcs->is_device_id_supported(dc_ctx->dc_bios, |
| 724 | link->device_tag.dev_id)) |
| 725 | continue; |
| 726 | if (link->device_tag.dev_id.device_type == DEVICE_TYPE_CRT && |
| 727 | link->connector_signal != SIGNAL_TYPE_RGB) |
| 728 | continue; |
| 729 | if (link->device_tag.dev_id.device_type == DEVICE_TYPE_LCD && |
| 730 | link->connector_signal == SIGNAL_TYPE_RGB) |
| 731 | continue; |
| 732 | |
| 733 | DC_LOG_DC("BIOS object table - device_tag.acpi_device: %d" , link->device_tag.acpi_device); |
| 734 | DC_LOG_DC("BIOS object table - device_tag.dev_id.device_type: %d" , link->device_tag.dev_id.device_type); |
| 735 | DC_LOG_DC("BIOS object table - device_tag.dev_id.enum_id: %d" , link->device_tag.dev_id.enum_id); |
| 736 | break; |
| 737 | } |
| 738 | |
| 739 | if (bios->integrated_info) { |
| 740 | /* Look for channel mapping corresponding to connector and device tag */ |
| 741 | for (i = 0; i < MAX_NUMBER_OF_EXT_DISPLAY_PATH; i++) { |
| 742 | struct external_display_path *path = |
| 743 | &bios->integrated_info->ext_disp_conn_info.path[i]; |
| 744 | |
| 745 | if (path->device_connector_id.enum_id == link->link_id.enum_id && |
| 746 | path->device_connector_id.id == link->link_id.id && |
| 747 | path->device_connector_id.type == link->link_id.type) { |
| 748 | if (link->device_tag.acpi_device != 0 && |
| 749 | path->device_acpi_enum == link->device_tag.acpi_device) { |
| 750 | link->ddi_channel_mapping = path->channel_mapping; |
| 751 | link->chip_caps = path->caps; |
| 752 | DC_LOG_DC("BIOS object table - ddi_channel_mapping: 0x%04X" , |
| 753 | link->ddi_channel_mapping.raw); |
| 754 | DC_LOG_DC("BIOS object table - chip_caps: %d" , |
| 755 | link->chip_caps); |
| 756 | } else if (path->device_tag == |
| 757 | link->device_tag.dev_id.raw_device_tag) { |
| 758 | link->ddi_channel_mapping = path->channel_mapping; |
| 759 | link->chip_caps = path->caps; |
| 760 | DC_LOG_DC("BIOS object table - ddi_channel_mapping: 0x%04X" , |
| 761 | link->ddi_channel_mapping.raw); |
| 762 | DC_LOG_DC("BIOS object table - chip_caps: %d" , |
| 763 | link->chip_caps); |
| 764 | } |
| 765 | |
| 766 | if ((link->chip_caps & AMD_EXT_DISPLAY_PATH_CAPS__EXT_CHIP_MASK) == AMD_EXT_DISPLAY_PATH_CAPS__DP_FIXED_VS_EN) { |
| 767 | link->bios_forced_drive_settings.VOLTAGE_SWING = |
| 768 | (bios->integrated_info->ext_disp_conn_info.fixdpvoltageswing & 0x3); |
| 769 | link->bios_forced_drive_settings.PRE_EMPHASIS = |
| 770 | ((bios->integrated_info->ext_disp_conn_info.fixdpvoltageswing >> 2) & 0x3); |
| 771 | } |
| 772 | |
| 773 | break; |
| 774 | } |
| 775 | } |
| 776 | } |
| 777 | if (bios->funcs->get_atom_dc_golden_table) |
| 778 | bios->funcs->get_atom_dc_golden_table(bios); |
| 779 | |
| 780 | /* |
| 781 | * TODO check if GPIO programmed correctly |
| 782 | * |
| 783 | * If GPIO isn't programmed correctly HPD might not rise or drain |
| 784 | * fast enough, leading to bounces. |
| 785 | */ |
| 786 | program_hpd_filter(link); |
| 787 | |
| 788 | link->psr_settings.psr_vtotal_control_support = false; |
| 789 | link->psr_settings.psr_version = DC_PSR_VERSION_UNSUPPORTED; |
| 790 | link->replay_settings.config.replay_version = DC_REPLAY_VERSION_UNSUPPORTED; |
| 791 | |
| 792 | DC_LOG_DC("BIOS object table - %s finished successfully.\n" , __func__); |
| 793 | return true; |
| 794 | device_tag_fail: |
| 795 | link->link_enc->funcs->destroy(&link->link_enc); |
| 796 | link_enc_create_fail: |
| 797 | if (link->panel_cntl != NULL) |
| 798 | link->panel_cntl->funcs->destroy(&link->panel_cntl); |
| 799 | panel_cntl_create_fail: |
| 800 | link_destroy_ddc_service(ddc: &link->ddc); |
| 801 | ddc_create_fail: |
| 802 | create_fail: |
| 803 | |
| 804 | if (link->hpd_gpio) { |
| 805 | dal_gpio_destroy_irq(ptr: &link->hpd_gpio); |
| 806 | link->hpd_gpio = NULL; |
| 807 | } |
| 808 | |
| 809 | unsupported_fail: |
| 810 | DC_LOG_DC("BIOS object table - %s failed.\n" , __func__); |
| 811 | return false; |
| 812 | } |
| 813 | |
| 814 | static bool construct_dpia(struct dc_link *link, |
| 815 | const struct link_init_data *init_params) |
| 816 | { |
| 817 | struct ddc_service_init_data ddc_service_init_data = { 0 }; |
| 818 | struct dc_context *dc_ctx = init_params->ctx; |
| 819 | |
| 820 | DC_LOGGER_INIT(dc_ctx->logger); |
| 821 | |
| 822 | /* Initialized irq source for hpd and hpd rx */ |
| 823 | link->irq_source_hpd = DC_IRQ_SOURCE_INVALID; |
| 824 | link->irq_source_hpd_rx = DC_IRQ_SOURCE_INVALID; |
| 825 | link->link_status.dpcd_caps = &link->dpcd_caps; |
| 826 | |
| 827 | link->dc = init_params->dc; |
| 828 | link->ctx = dc_ctx; |
| 829 | link->link_index = init_params->link_index; |
| 830 | |
| 831 | memset(&link->preferred_training_settings, 0, |
| 832 | sizeof(struct dc_link_training_overrides)); |
| 833 | memset(&link->preferred_link_setting, 0, |
| 834 | sizeof(struct dc_link_settings)); |
| 835 | |
| 836 | /* Dummy Init for linkid */ |
| 837 | link->link_id.type = OBJECT_TYPE_CONNECTOR; |
| 838 | link->link_id.id = CONNECTOR_ID_DISPLAY_PORT; |
| 839 | link->link_id.enum_id = ENUM_ID_1 + init_params->connector_index; |
| 840 | link->is_internal_display = false; |
| 841 | link->connector_signal = SIGNAL_TYPE_DISPLAY_PORT; |
| 842 | LINK_INFO("Connector[%d] description:signal %d\n" , |
| 843 | init_params->connector_index, |
| 844 | link->connector_signal); |
| 845 | |
| 846 | link->ep_type = DISPLAY_ENDPOINT_USB4_DPIA; |
| 847 | link->is_dig_mapping_flexible = true; |
| 848 | |
| 849 | /* TODO: Initialize link : funcs->link_init */ |
| 850 | |
| 851 | ddc_service_init_data.ctx = link->ctx; |
| 852 | ddc_service_init_data.id = link->link_id; |
| 853 | ddc_service_init_data.link = link; |
| 854 | /* Set indicator for dpia link so that ddc wont be created */ |
| 855 | ddc_service_init_data.is_dpia_link = true; |
| 856 | |
| 857 | link->ddc = link_create_ddc_service(ddc_init_data: &ddc_service_init_data); |
| 858 | if (!link->ddc) { |
| 859 | DC_ERROR("Failed to create ddc_service!\n" ); |
| 860 | goto ddc_create_fail; |
| 861 | } |
| 862 | |
| 863 | /* Set dpia port index : 0 to number of dpia ports */ |
| 864 | link->ddc_hw_inst = init_params->connector_index; |
| 865 | |
| 866 | // Assign Dpia preferred eng_id |
| 867 | if (link->dc->res_pool->funcs->get_preferred_eng_id_dpia) |
| 868 | link->dpia_preferred_eng_id = link->dc->res_pool->funcs->get_preferred_eng_id_dpia(link->ddc_hw_inst); |
| 869 | |
| 870 | /* TODO: Create link encoder */ |
| 871 | |
| 872 | link->psr_settings.psr_version = DC_PSR_VERSION_UNSUPPORTED; |
| 873 | link->replay_settings.config.replay_version = DC_REPLAY_VERSION_UNSUPPORTED; |
| 874 | |
| 875 | return true; |
| 876 | |
| 877 | ddc_create_fail: |
| 878 | return false; |
| 879 | } |
| 880 | |
| 881 | static bool link_construct(struct dc_link *link, |
| 882 | const struct link_init_data *init_params) |
| 883 | { |
| 884 | /* Handle dpia case */ |
| 885 | if (init_params->is_dpia_link == true) |
| 886 | return construct_dpia(link, init_params); |
| 887 | else |
| 888 | return construct_phy(link, init_params); |
| 889 | } |
| 890 | |
| 891 | struct dc_link *link_create(const struct link_init_data *init_params) |
| 892 | { |
| 893 | struct dc_link *link = |
| 894 | kzalloc(sizeof(*link), GFP_KERNEL); |
| 895 | |
| 896 | if (NULL == link) |
| 897 | goto alloc_fail; |
| 898 | |
| 899 | if (false == link_construct(link, init_params)) |
| 900 | goto construct_fail; |
| 901 | |
| 902 | return link; |
| 903 | |
| 904 | construct_fail: |
| 905 | kfree(objp: link); |
| 906 | |
| 907 | alloc_fail: |
| 908 | return NULL; |
| 909 | } |
| 910 | |
| 911 | void link_destroy(struct dc_link **link) |
| 912 | { |
| 913 | link_destruct(link: *link); |
| 914 | kfree(objp: *link); |
| 915 | *link = NULL; |
| 916 | } |
| 917 | |