Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2012 Avionic Design GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2012 NVIDIA CORPORATION.  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <drm/drm_atomic_helper.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <drm/drm_of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <drm/drm_panel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <drm/drm_simple_kms_helper.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "drm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "dc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <media/cec-notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) int tegra_output_connector_get_modes(struct drm_connector *connector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	struct tegra_output *output = connector_to_output(connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	struct edid *edid = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	 * If the panel provides one or more modes, use them exclusively and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	 * ignore any other means of obtaining a mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	if (output->panel) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		err = drm_panel_get_modes(output->panel, connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		if (err > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	if (output->edid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		edid = kmemdup(output->edid, sizeof(*edid), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	else if (output->ddc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		edid = drm_get_edid(connector, output->ddc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	cec_notifier_set_phys_addr_from_edid(output->cec, edid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	drm_connector_update_edid_property(connector, edid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	if (edid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		err = drm_add_edid_modes(connector, edid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		kfree(edid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) enum drm_connector_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) tegra_output_connector_detect(struct drm_connector *connector, bool force)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	struct tegra_output *output = connector_to_output(connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	enum drm_connector_status status = connector_status_unknown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	if (output->hpd_gpio) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		if (gpiod_get_value(output->hpd_gpio) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			status = connector_status_disconnected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			status = connector_status_connected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		if (!output->panel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			status = connector_status_disconnected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			status = connector_status_connected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if (status != connector_status_connected)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		cec_notifier_phys_addr_invalidate(output->cec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) void tegra_output_connector_destroy(struct drm_connector *connector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct tegra_output *output = connector_to_output(connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	if (output->cec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		cec_notifier_conn_unregister(output->cec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	drm_connector_unregister(connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	drm_connector_cleanup(connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static irqreturn_t hpd_irq(int irq, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct tegra_output *output = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	if (output->connector.dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		drm_helper_hpd_irq_event(output->connector.dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) int tegra_output_probe(struct tegra_output *output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	struct device_node *ddc, *panel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	int err, size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	if (!output->of_node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		output->of_node = output->dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	err = drm_of_find_panel_or_bridge(output->of_node, -1, -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 					  &output->panel, &output->bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	if (err && err != -ENODEV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	panel = of_parse_phandle(output->of_node, "nvidia,panel", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	if (panel) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		 * Don't mix nvidia,panel phandle with the graph in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		 * device-tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		WARN_ON(output->panel || output->bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		output->panel = of_drm_find_panel(panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		of_node_put(panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		if (IS_ERR(output->panel))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			return PTR_ERR(output->panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	output->edid = of_get_property(output->of_node, "nvidia,edid", &size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	ddc = of_parse_phandle(output->of_node, "nvidia,ddc-i2c-bus", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (ddc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		output->ddc = of_get_i2c_adapter_by_node(ddc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		of_node_put(ddc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		if (!output->ddc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			err = -EPROBE_DEFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	output->hpd_gpio = devm_gpiod_get_from_of_node(output->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 						       output->of_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 						       "nvidia,hpd-gpio", 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 						       GPIOD_IN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 						       "HDMI hotplug detect");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	if (IS_ERR(output->hpd_gpio)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		if (PTR_ERR(output->hpd_gpio) != -ENOENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			return PTR_ERR(output->hpd_gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		output->hpd_gpio = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (output->hpd_gpio) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		err = gpiod_to_irq(output->hpd_gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			dev_err(output->dev, "gpiod_to_irq(): %d\n", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		output->hpd_irq = err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			IRQF_ONESHOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		err = request_threaded_irq(output->hpd_irq, NULL, hpd_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 					   flags, "hpd", output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 			dev_err(output->dev, "failed to request IRQ#%u: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				output->hpd_irq, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		output->connector.polled = DRM_CONNECTOR_POLL_HPD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		 * Disable the interrupt until the connector has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		 * initialized to avoid a race in the hotplug interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		 * handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		disable_irq(output->hpd_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) void tegra_output_remove(struct tegra_output *output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	if (output->hpd_gpio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		free_irq(output->hpd_irq, output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	if (output->ddc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		i2c_put_adapter(output->ddc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	int connector_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	 * The connector is now registered and ready to receive hotplug events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	 * so the hotplug interrupt can be enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	if (output->hpd_gpio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		enable_irq(output->hpd_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	connector_type = output->connector.connector_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	 * Create a CEC notifier for HDMI connector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	    connector_type == DRM_MODE_CONNECTOR_HDMIB) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		struct cec_connector_info conn_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		cec_fill_conn_info_from_drm(&conn_info, &output->connector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		output->cec = cec_notifier_conn_register(output->dev, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 							 &conn_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		if (!output->cec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) void tegra_output_exit(struct tegra_output *output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	 * The connector is going away, so the interrupt must be disabled to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	 * prevent the hotplug interrupt handler from potentially crashing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	if (output->hpd_gpio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		disable_irq(output->hpd_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) void tegra_output_find_possible_crtcs(struct tegra_output *output,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 				      struct drm_device *drm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	struct device *dev = output->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	struct drm_crtc *crtc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	unsigned int mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	drm_for_each_crtc(crtc, drm) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		struct tegra_dc *dc = to_tegra_dc(crtc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		if (tegra_dc_has_output(dc, dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			mask |= drm_crtc_mask(crtc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	if (mask == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		dev_warn(dev, "missing output definition for heads in DT\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		mask = 0x3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	output->encoder.possible_crtcs = mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) int tegra_output_suspend(struct tegra_output *output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	if (output->hpd_irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		disable_irq(output->hpd_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) int tegra_output_resume(struct tegra_output *output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	if (output->hpd_irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		enable_irq(output->hpd_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }