mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 09:24:37 +07:00
5e580523d9
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJXlRXSAAoJEHm+PkMAQRiGG/gH/0Z8O4zWOsrwO+X1mRToRDBH joFOjAmCVe83T1VpF5LYNB+9+owL/dEDt6+ZIswnhH7AfQPjs4RqwS4PcuMbCDVO +mDm0PmfcKaYcQZrB2Z2OwIzRNnfCTVcsDPhIHwuIHk0m4z/xuGZonD8KoAj0+tO 3yJF6sbE1KubDVjOb+lmZZSP3cXA0pDXrNhkYhE4Tsr8fiihGjeXSNJ8t2zPLjxo W3MPqo0rzDvQsOwoF4TWHHagVaFSJlhLBBgqu33fI7uO3jtfQD2G8wG68JCND1j3 qbMoBfTLFV/yQmSIJUt0Wv1axaCcwnjpweEB35A/GEeZ0mNB1rDdoBeI1eKEQkc= =DGFC -----END PGP SIGNATURE----- Backmerge tag 'v4.7' into drm-next Linux 4.7 As requested by Daniel Vetter as the conflicts were getting messy.
141 lines
3.6 KiB
C
141 lines
3.6 KiB
C
/*
|
|
* Copyright (C) 2015 Free Electrons
|
|
* Copyright (C) 2015 NextThing Co
|
|
*
|
|
* Maxime Ripard <maxime.ripard@free-electrons.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 of
|
|
* the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#include <drm/drmP.h>
|
|
#include <drm/drm_atomic_helper.h>
|
|
#include <drm/drm_crtc.h>
|
|
#include <drm/drm_crtc_helper.h>
|
|
#include <drm/drm_modes.h>
|
|
|
|
#include <linux/clk-provider.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/of_address.h>
|
|
#include <linux/of_irq.h>
|
|
#include <linux/regmap.h>
|
|
|
|
#include <video/videomode.h>
|
|
|
|
#include "sun4i_backend.h"
|
|
#include "sun4i_crtc.h"
|
|
#include "sun4i_drv.h"
|
|
#include "sun4i_tcon.h"
|
|
|
|
static void sun4i_crtc_atomic_begin(struct drm_crtc *crtc,
|
|
struct drm_crtc_state *old_state)
|
|
{
|
|
struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
|
|
struct drm_device *dev = crtc->dev;
|
|
unsigned long flags;
|
|
|
|
if (crtc->state->event) {
|
|
WARN_ON(drm_crtc_vblank_get(crtc) != 0);
|
|
|
|
spin_lock_irqsave(&dev->event_lock, flags);
|
|
scrtc->event = crtc->state->event;
|
|
spin_unlock_irqrestore(&dev->event_lock, flags);
|
|
crtc->state->event = NULL;
|
|
}
|
|
}
|
|
|
|
static void sun4i_crtc_atomic_flush(struct drm_crtc *crtc,
|
|
struct drm_crtc_state *old_state)
|
|
{
|
|
struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
|
|
struct sun4i_drv *drv = scrtc->drv;
|
|
struct drm_pending_vblank_event *event = crtc->state->event;
|
|
|
|
DRM_DEBUG_DRIVER("Committing plane changes\n");
|
|
|
|
sun4i_backend_commit(drv->backend);
|
|
|
|
if (event) {
|
|
crtc->state->event = NULL;
|
|
|
|
spin_lock_irq(&crtc->dev->event_lock);
|
|
if (drm_crtc_vblank_get(crtc) == 0)
|
|
drm_crtc_arm_vblank_event(crtc, event);
|
|
else
|
|
drm_crtc_send_vblank_event(crtc, event);
|
|
spin_unlock_irq(&crtc->dev->event_lock);
|
|
}
|
|
}
|
|
|
|
static void sun4i_crtc_disable(struct drm_crtc *crtc)
|
|
{
|
|
struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
|
|
struct sun4i_drv *drv = scrtc->drv;
|
|
|
|
DRM_DEBUG_DRIVER("Disabling the CRTC\n");
|
|
|
|
sun4i_tcon_disable(drv->tcon);
|
|
|
|
if (crtc->state->event && !crtc->state->active) {
|
|
spin_lock_irq(&crtc->dev->event_lock);
|
|
drm_crtc_send_vblank_event(crtc, crtc->state->event);
|
|
spin_unlock_irq(&crtc->dev->event_lock);
|
|
|
|
crtc->state->event = NULL;
|
|
}
|
|
}
|
|
|
|
static void sun4i_crtc_enable(struct drm_crtc *crtc)
|
|
{
|
|
struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
|
|
struct sun4i_drv *drv = scrtc->drv;
|
|
|
|
DRM_DEBUG_DRIVER("Enabling the CRTC\n");
|
|
|
|
sun4i_tcon_enable(drv->tcon);
|
|
}
|
|
|
|
static const struct drm_crtc_helper_funcs sun4i_crtc_helper_funcs = {
|
|
.atomic_begin = sun4i_crtc_atomic_begin,
|
|
.atomic_flush = sun4i_crtc_atomic_flush,
|
|
.disable = sun4i_crtc_disable,
|
|
.enable = sun4i_crtc_enable,
|
|
};
|
|
|
|
static const struct drm_crtc_funcs sun4i_crtc_funcs = {
|
|
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
|
|
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
|
|
.destroy = drm_crtc_cleanup,
|
|
.page_flip = drm_atomic_helper_page_flip,
|
|
.reset = drm_atomic_helper_crtc_reset,
|
|
.set_config = drm_atomic_helper_set_config,
|
|
};
|
|
|
|
struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm)
|
|
{
|
|
struct sun4i_drv *drv = drm->dev_private;
|
|
struct sun4i_crtc *scrtc;
|
|
int ret;
|
|
|
|
scrtc = devm_kzalloc(drm->dev, sizeof(*scrtc), GFP_KERNEL);
|
|
if (!scrtc)
|
|
return NULL;
|
|
scrtc->drv = drv;
|
|
|
|
ret = drm_crtc_init_with_planes(drm, &scrtc->crtc,
|
|
drv->primary,
|
|
NULL,
|
|
&sun4i_crtc_funcs,
|
|
NULL);
|
|
if (ret) {
|
|
dev_err(drm->dev, "Couldn't init DRM CRTC\n");
|
|
return NULL;
|
|
}
|
|
|
|
drm_crtc_helper_add(&scrtc->crtc, &sun4i_crtc_helper_funcs);
|
|
|
|
return scrtc;
|
|
}
|