mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
7d902c05b4
It's dead code, the core handles all this directly now. The only special case is nouveau and tda988x which used one function for both legacy modeset code and -nv50 atomic world instead of 2 vtables. But amounts to exactly the same. v2: Rebase over the panel/brideg refactorings in stm/ltdc. Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Cc: Archit Taneja <architt@codeaurora.org> Cc: Andrzej Hajda <a.hajda@samsung.com> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com> Cc: Peter Senna Tschudin <peter.senna@collabora.com> Cc: Martin Donnelly <martin.donnelly@ge.com> Cc: Martyn Welch <martyn.welch@collabora.co.uk> Cc: Daniel Vetter <daniel.vetter@intel.com> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Sean Paul <seanpaul@chromium.org> Cc: David Airlie <airlied@linux.ie> Cc: Inki Dae <inki.dae@samsung.com> Cc: Joonyoung Shim <jy0922.shim@samsung.com> Cc: Seung-Woo Kim <sw0312.kim@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Kukjin Kim <kgene@kernel.org> Cc: Krzysztof Kozlowski <krzk@kernel.org> Cc: Stefan Agner <stefan@agner.ch> Cc: Alison Wang <alison.wang@freescale.com> Cc: Russell King <linux@armlinux.org.uk> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: CK Hu <ck.hu@mediatek.com> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: Neil Armstrong <narmstrong@baylibre.com> Cc: Carlo Caione <carlo@caione.org> Cc: Kevin Hilman <khilman@baylibre.com> Cc: Marek Vasut <marex@denx.de> Cc: Ben Skeggs <bskeggs@redhat.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: Eric Anholt <eric@anholt.net> Cc: Mark Yao <mark.yao@rock-chips.com> Cc: Heiko Stuebner <heiko@sntech.de> Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org> Cc: Vincent Abriou <vincent.abriou@st.com> Cc: Yannick Fertre <yannick.fertre@st.com> Cc: Philippe Cornu <philippe.cornu@st.com> Cc: Maxime Ripard <maxime.ripard@free-electrons.com> Cc: Chen-Yu Tsai <wens@csie.org> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Jonathan Hunter <jonathanh@nvidia.com> Cc: Jyri Sarha <jsarha@ti.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Shawn Guo <shawnguo@kernel.org> Cc: John Stultz <john.stultz@linaro.org> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Cc: Jeffy Chen <jeffy.chen@rock-chips.com> Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com> Cc: Yakir Yang <kuankuan.y@gmail.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Jose Abreu <Jose.Abreu@synopsys.com> Cc: Romain Perier <romain.perier@collabora.com> Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Cc: Xinliang Liu <z.liuxinliang@hisilicon.com> Cc: Alexey Brodkin <abrodkin@synopsys.com> Cc: Alex Deucher <alexander.deucher@amd.com> Cc: Rongrong Zou <zourongrong@gmail.com> Cc: Rob Clark <robdclark@gmail.com> Cc: Hai Li <hali@codeaurora.org> Cc: "Noralf Trønnes" <noralf@tronnes.org> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-samsung-soc@vger.kernel.org Cc: intel-gfx@lists.freedesktop.org Cc: linux-mediatek@lists.infradead.org Cc: linux-amlogic@lists.infradead.org Cc: nouveau@lists.freedesktop.org Cc: linux-renesas-soc@vger.kernel.org Cc: linux-rockchip@lists.infradead.org Cc: linux-tegra@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Cc: zain wang <wzz@rock-chips.com> Cc: Baoyou Xie <baoyou.xie@linaro.org> Cc: Boris Brezillon <boris.brezillon@free-electrons.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20170725080122.20548-8-daniel.vetter@ffwll.ch Acked-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Neil Armstrong <narmstrong@baylibre.com> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Archit Taneja <architt@codeaurora.org> Tested-by: Philippe Cornu <philippe.cornu@st.com> (on stm) Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Shawn Guo <shawnguo@kernel.org> Acked-by: Shawn Guo <shawnguo@kernel.org> Acked-by: Noralf Trønnes <noralf@tronnes.org> Acked-by: Vincent Abriou <vincent.abriou@st.com>
252 lines
6.8 KiB
C
252 lines
6.8 KiB
C
/*
|
|
* drivers/gpu/drm/omapdrm/omap_connector.c
|
|
*
|
|
* Copyright (C) 2011 Texas Instruments
|
|
* Author: Rob Clark <rob@ti.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
* the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <drm/drm_atomic_helper.h>
|
|
#include <drm/drm_crtc.h>
|
|
#include <drm/drm_crtc_helper.h>
|
|
|
|
#include "omap_drv.h"
|
|
|
|
/*
|
|
* connector funcs
|
|
*/
|
|
|
|
#define to_omap_connector(x) container_of(x, struct omap_connector, base)
|
|
|
|
struct omap_connector {
|
|
struct drm_connector base;
|
|
struct omap_dss_device *dssdev;
|
|
bool hdmi_mode;
|
|
};
|
|
|
|
bool omap_connector_get_hdmi_mode(struct drm_connector *connector)
|
|
{
|
|
struct omap_connector *omap_connector = to_omap_connector(connector);
|
|
|
|
return omap_connector->hdmi_mode;
|
|
}
|
|
|
|
static enum drm_connector_status omap_connector_detect(
|
|
struct drm_connector *connector, bool force)
|
|
{
|
|
struct omap_connector *omap_connector = to_omap_connector(connector);
|
|
struct omap_dss_device *dssdev = omap_connector->dssdev;
|
|
struct omap_dss_driver *dssdrv = dssdev->driver;
|
|
enum drm_connector_status ret;
|
|
|
|
if (dssdrv->detect) {
|
|
if (dssdrv->detect(dssdev))
|
|
ret = connector_status_connected;
|
|
else
|
|
ret = connector_status_disconnected;
|
|
} else if (dssdev->type == OMAP_DISPLAY_TYPE_DPI ||
|
|
dssdev->type == OMAP_DISPLAY_TYPE_DBI ||
|
|
dssdev->type == OMAP_DISPLAY_TYPE_SDI ||
|
|
dssdev->type == OMAP_DISPLAY_TYPE_DSI) {
|
|
ret = connector_status_connected;
|
|
} else {
|
|
ret = connector_status_unknown;
|
|
}
|
|
|
|
VERB("%s: %d (force=%d)", omap_connector->dssdev->name, ret, force);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static void omap_connector_destroy(struct drm_connector *connector)
|
|
{
|
|
struct omap_connector *omap_connector = to_omap_connector(connector);
|
|
struct omap_dss_device *dssdev = omap_connector->dssdev;
|
|
|
|
DBG("%s", omap_connector->dssdev->name);
|
|
drm_connector_unregister(connector);
|
|
drm_connector_cleanup(connector);
|
|
kfree(omap_connector);
|
|
|
|
omap_dss_put_device(dssdev);
|
|
}
|
|
|
|
#define MAX_EDID 512
|
|
|
|
static int omap_connector_get_modes(struct drm_connector *connector)
|
|
{
|
|
struct omap_connector *omap_connector = to_omap_connector(connector);
|
|
struct omap_dss_device *dssdev = omap_connector->dssdev;
|
|
struct omap_dss_driver *dssdrv = dssdev->driver;
|
|
struct drm_device *dev = connector->dev;
|
|
int n = 0;
|
|
|
|
DBG("%s", omap_connector->dssdev->name);
|
|
|
|
/* if display exposes EDID, then we parse that in the normal way to
|
|
* build table of supported modes.. otherwise (ie. fixed resolution
|
|
* LCD panels) we just return a single mode corresponding to the
|
|
* currently configured timings:
|
|
*/
|
|
if (dssdrv->read_edid) {
|
|
void *edid = kzalloc(MAX_EDID, GFP_KERNEL);
|
|
|
|
if ((dssdrv->read_edid(dssdev, edid, MAX_EDID) > 0) &&
|
|
drm_edid_is_valid(edid)) {
|
|
drm_mode_connector_update_edid_property(
|
|
connector, edid);
|
|
n = drm_add_edid_modes(connector, edid);
|
|
|
|
omap_connector->hdmi_mode =
|
|
drm_detect_hdmi_monitor(edid);
|
|
} else {
|
|
drm_mode_connector_update_edid_property(
|
|
connector, NULL);
|
|
}
|
|
|
|
kfree(edid);
|
|
} else {
|
|
struct drm_display_mode *mode = drm_mode_create(dev);
|
|
struct videomode vm = {0};
|
|
|
|
dssdrv->get_timings(dssdev, &vm);
|
|
|
|
drm_display_mode_from_videomode(&vm, mode);
|
|
|
|
mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
|
|
drm_mode_set_name(mode);
|
|
drm_mode_probed_add(connector, mode);
|
|
|
|
n = 1;
|
|
}
|
|
|
|
return n;
|
|
}
|
|
|
|
static int omap_connector_mode_valid(struct drm_connector *connector,
|
|
struct drm_display_mode *mode)
|
|
{
|
|
struct omap_connector *omap_connector = to_omap_connector(connector);
|
|
struct omap_dss_device *dssdev = omap_connector->dssdev;
|
|
struct omap_dss_driver *dssdrv = dssdev->driver;
|
|
struct videomode vm = {0};
|
|
struct drm_device *dev = connector->dev;
|
|
struct drm_display_mode *new_mode;
|
|
int r, ret = MODE_BAD;
|
|
|
|
drm_display_mode_to_videomode(mode, &vm);
|
|
mode->vrefresh = drm_mode_vrefresh(mode);
|
|
|
|
/*
|
|
* if the panel driver doesn't have a check_timings, it's most likely
|
|
* a fixed resolution panel, check if the timings match with the
|
|
* panel's timings
|
|
*/
|
|
if (dssdrv->check_timings) {
|
|
r = dssdrv->check_timings(dssdev, &vm);
|
|
} else {
|
|
struct videomode t = {0};
|
|
|
|
dssdrv->get_timings(dssdev, &t);
|
|
|
|
/*
|
|
* Ignore the flags, as we don't get them from
|
|
* drm_display_mode_to_videomode.
|
|
*/
|
|
t.flags = 0;
|
|
|
|
if (memcmp(&vm, &t, sizeof(vm)))
|
|
r = -EINVAL;
|
|
else
|
|
r = 0;
|
|
}
|
|
|
|
if (!r) {
|
|
/* check if vrefresh is still valid */
|
|
new_mode = drm_mode_duplicate(dev, mode);
|
|
new_mode->clock = vm.pixelclock / 1000;
|
|
new_mode->vrefresh = 0;
|
|
if (mode->vrefresh == drm_mode_vrefresh(new_mode))
|
|
ret = MODE_OK;
|
|
drm_mode_destroy(dev, new_mode);
|
|
}
|
|
|
|
DBG("connector: mode %s: "
|
|
"%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
|
|
(ret == MODE_OK) ? "valid" : "invalid",
|
|
mode->base.id, mode->name, mode->vrefresh, mode->clock,
|
|
mode->hdisplay, mode->hsync_start,
|
|
mode->hsync_end, mode->htotal,
|
|
mode->vdisplay, mode->vsync_start,
|
|
mode->vsync_end, mode->vtotal, mode->type, mode->flags);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static const struct drm_connector_funcs omap_connector_funcs = {
|
|
.reset = drm_atomic_helper_connector_reset,
|
|
.detect = omap_connector_detect,
|
|
.fill_modes = drm_helper_probe_single_connector_modes,
|
|
.destroy = omap_connector_destroy,
|
|
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
|
|
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
|
|
};
|
|
|
|
static const struct drm_connector_helper_funcs omap_connector_helper_funcs = {
|
|
.get_modes = omap_connector_get_modes,
|
|
.mode_valid = omap_connector_mode_valid,
|
|
};
|
|
|
|
/* initialize connector */
|
|
struct drm_connector *omap_connector_init(struct drm_device *dev,
|
|
int connector_type, struct omap_dss_device *dssdev,
|
|
struct drm_encoder *encoder)
|
|
{
|
|
struct drm_connector *connector = NULL;
|
|
struct omap_connector *omap_connector;
|
|
|
|
DBG("%s", dssdev->name);
|
|
|
|
omap_dss_get_device(dssdev);
|
|
|
|
omap_connector = kzalloc(sizeof(*omap_connector), GFP_KERNEL);
|
|
if (!omap_connector)
|
|
goto fail;
|
|
|
|
omap_connector->dssdev = dssdev;
|
|
|
|
connector = &omap_connector->base;
|
|
|
|
drm_connector_init(dev, connector, &omap_connector_funcs,
|
|
connector_type);
|
|
drm_connector_helper_add(connector, &omap_connector_helper_funcs);
|
|
|
|
if (dssdev->driver->detect)
|
|
connector->polled = DRM_CONNECTOR_POLL_CONNECT |
|
|
DRM_CONNECTOR_POLL_DISCONNECT;
|
|
else
|
|
connector->polled = 0;
|
|
|
|
connector->interlace_allowed = 1;
|
|
connector->doublescan_allowed = 0;
|
|
|
|
return connector;
|
|
|
|
fail:
|
|
if (connector)
|
|
omap_connector_destroy(connector);
|
|
|
|
return NULL;
|
|
}
|