From: Kevin Brace <kevinbrace@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Kevin Brace <kevinbrace@xxxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/via/via_display.c | 125 ++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 drivers/gpu/drm/via/via_display.c diff --git a/drivers/gpu/drm/via/via_display.c b/drivers/gpu/drm/via/via_display.c new file mode 100644 index 000000000000..76bcfa470657 --- /dev/null +++ b/drivers/gpu/drm/via/via_display.c @@ -0,0 +1,125 @@ +/* + * Copyright © 2017-2020 Kevin Brace. + * Copyright 2012 James Simmons. All Rights Reserved. + * + * 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, sub license, + * 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) OR COPYRIGHT HOLDER(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. + * + * Author(s): + * Kevin Brace <kevinbrace@xxxxxxxxxxxxxxxxxxxx> + * James Simmons <jsimmons@xxxxxxxxxxxxx> + */ + +#include <linux/pci.h> + +#include <drm/drm_crtc.h> +#include <drm/drm_crtc_helper.h> +#include <drm/drm_probe_helper.h> + +#include "via_drv.h" + +void via_encoder_cleanup(struct drm_encoder *encoder) +{ + struct via_encoder *enc = container_of(encoder, struct via_encoder, base); + + drm_encoder_cleanup(encoder); + kfree(enc); +} + +void via_connector_destroy(struct drm_connector *connector) +{ + struct via_connector *con = container_of(connector, struct via_connector, base); + struct drm_property *property, *tmp; + + list_for_each_entry_safe(property, tmp, &con->props, head) + drm_property_destroy(connector->dev, property); + list_del(&con->props); + + drm_connector_update_edid_property(connector, NULL); + drm_connector_unregister(connector); + drm_connector_cleanup(connector); +} + +int via_modeset_init(struct drm_device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev->dev); + struct via_drm_priv *dev_priv = to_via_drm_priv(dev); + uint32_t i; + int ret = 0; + + via_mode_config_init(dev_priv); + + /* Initialize the number of display connectors. */ + dev_priv->number_fp = 0; + dev_priv->number_dvi = 0; + + via_i2c_reg_init(dev_priv); + ret = via_i2c_init(dev); + if (ret) { + DRM_ERROR("Failed to initialize I2C bus!\n"); + goto exit; + } + + for (i = 0; i < VIA_MAX_CRTC; i++) { + ret = via_crtc_init(dev_priv, i); + if (ret) { + goto exit; + } + } + + via_ext_dvi_probe(dev); + via_tmds_probe(dev); + + via_lvds_probe(dev); + + via_dac_probe(dev); + + + via_ext_dvi_init(dev); + via_tmds_init(dev); + + via_dac_init(dev); + + via_lvds_init(dev); + + switch (pdev->device) { + case PCI_DEVICE_ID_VIA_CHROME9_HD: + via_hdmi_init(dev, VIA_DI_PORT_NONE); + break; + default: + break; + } + + drm_mode_config_reset(dev); + + drm_kms_helper_poll_init(dev); +exit: + return ret; +} + +void via_modeset_fini(struct drm_device *dev) +{ + drm_kms_helper_poll_fini(dev); + + drm_helper_force_disable_all(dev); + + drm_mode_config_cleanup(dev); + + via_i2c_exit(); +} -- 2.35.1