linux/drivers/gpu/drm/amd/display/dc/inc/link.h

/*
 * Copyright 2022 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
 *
 */

#ifndef __DC_LINK_H__
#define __DC_LINK_H__

/* FILE POLICY AND INTENDED USAGE:
 *
 * This header defines link component function interfaces aka link_service.
 * link_service provides the only entry point to link functions with function
 * pointer style. This header is strictly private in dc and should never be
 * included by DM because it exposes too much dc detail including all dc
 * private types defined in core_types.h. Otherwise it will break DM - DC
 * encapsulation and turn DM into a maintenance nightmare.
 *
 * The following shows a link component relation map.
 *
 * DM to DC:
 * DM includes dc.h
 * dc_link_exports.c or other dc files implement dc.h
 *
 * DC to Link:
 * dc_link_exports.c or other dc files include link.h
 * link_factory.c implements link.h
 *
 * Link sub-component to Link sub-component:
 * link_factory.c includes --> link_xxx.h
 * link_xxx.c implements link_xxx.h

 * As you can see if you ever need to add a new dc link function and call it on
 * DM/dc side, it is very difficult because you will need layers of translation.
 * The most appropriate approach to implement new requirements on DM/dc side is
 * to extend or generalize the functionality of existing link function
 * interfaces so minimal modification is needed outside link component to
 * achieve your new requirements. This approach reduces or even eliminates the
 * effort needed outside link component to support a new link feature. This also
 * reduces code discrepancy among DMs to support the same link feature. If we
 * test full code path on one version of DM, and there is no feature specific
 * modification required on other DMs, then we can have higher confidence that
 * the feature will run on other DMs and produce the same result. The following
 * are some good examples to start with:
 *
 * - detect_link --> to add new link detection or capability retrieval routines
 *
 * - validate_mode_timing --> to add new timing validation conditions
 *
 * - set_dpms_on/set_dpms_off --> to include new link enablement sequences
 *
 * If you must add new link functions, you will need to:
 * 1. declare the function pointer here under the suitable commented category.
 * 2. Implement your function in the suitable link_xxx.c file.
 * 3. Assign the function to link_service in link_factory.c
 * 4. NEVER include link_xxx.h headers outside link component.
 * 5. NEVER include link.h on DM side.
 */
#include "core_types.h"

struct link_service *link_create_link_service(void);
void link_destroy_link_service(struct link_service **link_srv);

struct link_init_data {};

struct ddc_service_init_data {};

struct link_service {};
#endif /* __DC_LINK_HPD_H__ */