2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-08-20 10:19:49 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Freescale Semiconductor, Inc.
|
|
|
|
*
|
|
|
|
* Freescale DCU drm device driver
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
|
2019-06-30 14:18:57 +08:00
|
|
|
#include <video/videomode.h>
|
|
|
|
|
2015-08-20 10:19:49 +08:00
|
|
|
#include <drm/drm_atomic.h>
|
|
|
|
#include <drm/drm_atomic_helper.h>
|
|
|
|
#include <drm/drm_crtc.h>
|
2019-01-18 05:03:34 +08:00
|
|
|
#include <drm/drm_probe_helper.h>
|
2019-06-30 14:18:57 +08:00
|
|
|
#include <drm/drm_vblank.h>
|
2015-08-20 10:19:49 +08:00
|
|
|
|
|
|
|
#include "fsl_dcu_drm_crtc.h"
|
|
|
|
#include "fsl_dcu_drm_drv.h"
|
|
|
|
#include "fsl_dcu_drm_plane.h"
|
|
|
|
|
|
|
|
static void fsl_dcu_drm_crtc_atomic_flush(struct drm_crtc *crtc,
|
drm/atomic: Pass the full state to CRTC atomic begin and flush
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's start convert all the remaining helpers to provide a consistent
interface, starting with the CRTC's atomic_begin and atomic_flush.
The conversion was done using the coccinelle script below, built tested on
all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier old_crtc_state, old_state;
identifier crtc;
identifier f;
@@
f(struct drm_crtc_state *old_crtc_state)
{
...
struct drm_atomic_state *old_state = old_crtc_state->state;
<...
- FUNCS->atomic_begin(crtc, old_crtc_state);
+ FUNCS->atomic_begin(crtc, old_state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier old_crtc_state, old_state;
identifier crtc;
identifier f;
@@
f(struct drm_crtc_state *old_crtc_state)
{
...
struct drm_atomic_state *old_state = old_crtc_state->state;
<...
- FUNCS->atomic_flush(crtc, old_crtc_state);
+ FUNCS->atomic_flush(crtc, old_state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier f;
@@
f(struct drm_device *dev, struct drm_atomic_state *state, ...)
{
<...
- FUNCS->atomic_begin(crtc, crtc_state);
+ FUNCS->atomic_begin(crtc, state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier f;
@@
f(struct drm_device *dev, struct drm_atomic_state *state, ...)
{
<...
- FUNCS->atomic_flush(crtc, crtc_state);
+ FUNCS->atomic_flush(crtc, state);
...>
}
@@
identifier crtc, old_state;
@@
struct drm_crtc_helper_funcs {
...
- void (*atomic_begin)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_begin)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
- void (*atomic_flush)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_flush)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_begin = func,
...,
};
|
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_flush = func,
...,
};
)
@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
void func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
void func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@@
identifier old_state;
identifier crtc;
@@
void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@@
identifier old_state;
identifier crtc;
@@
void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
);
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{
...
}
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
);
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{
...
}
@@
identifier old_state;
identifier crtc;
@@
void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
);
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@
void func(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-2-maxime@cerno.tech
2020-10-28 20:32:22 +08:00
|
|
|
struct drm_atomic_state *state)
|
2015-08-20 10:19:49 +08:00
|
|
|
{
|
2016-09-06 10:05:12 +08:00
|
|
|
struct drm_device *dev = crtc->dev;
|
|
|
|
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
|
2016-06-08 20:18:56 +08:00
|
|
|
struct drm_pending_vblank_event *event = crtc->state->event;
|
|
|
|
|
2016-09-06 10:05:12 +08:00
|
|
|
regmap_write(fsl_dev->regmap,
|
|
|
|
DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG);
|
|
|
|
|
2016-06-08 20:18:56 +08:00
|
|
|
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);
|
|
|
|
}
|
2015-08-20 10:19:49 +08:00
|
|
|
}
|
|
|
|
|
2016-11-01 00:51:19 +08:00
|
|
|
static void fsl_dcu_drm_crtc_atomic_disable(struct drm_crtc *crtc,
|
drm/atomic: Pass the full state to CRTC atomic enable/disable
If the CRTC driver ever needs to access the full DRM state, it can't do so
at atomic_enable / atomic_disable time since drm_atomic_helper_swap_state
will have cleared the pointer from the struct drm_crtc_state to the struct
drm_atomic_state before calling those hooks.
In order to allow that, let's pass the full DRM state to atomic_enable and
atomic_disable. The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@
disable_outputs(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- FUNCS->atomic_disable(crtc, crtc_state);
+ FUNCS->atomic_disable(crtc, state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@
drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- FUNCS->atomic_enable(crtc, crtc_state);
+ FUNCS->atomic_enable(crtc, state);
...>
}
@@
identifier crtc, old_state;
@@
struct drm_crtc_helper_funcs {
...
- void (*atomic_enable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_enable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
- void (*atomic_disable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_disable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_enable = func,
...,
};
|
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
)
@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
void func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
void func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@
void func(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/845aa10ef171fc0ea060495efef142a0c13f7870.1602161031.git-series.maxime@cerno.tech
2020-10-08 20:44:08 +08:00
|
|
|
struct drm_atomic_state *state)
|
2015-08-20 10:19:49 +08:00
|
|
|
{
|
drm/atomic: Pass the full state to CRTC atomic enable/disable
If the CRTC driver ever needs to access the full DRM state, it can't do so
at atomic_enable / atomic_disable time since drm_atomic_helper_swap_state
will have cleared the pointer from the struct drm_crtc_state to the struct
drm_atomic_state before calling those hooks.
In order to allow that, let's pass the full DRM state to atomic_enable and
atomic_disable. The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@
disable_outputs(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- FUNCS->atomic_disable(crtc, crtc_state);
+ FUNCS->atomic_disable(crtc, state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@
drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- FUNCS->atomic_enable(crtc, crtc_state);
+ FUNCS->atomic_enable(crtc, state);
...>
}
@@
identifier crtc, old_state;
@@
struct drm_crtc_helper_funcs {
...
- void (*atomic_enable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_enable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
- void (*atomic_disable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_disable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_enable = func,
...,
};
|
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
)
@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
void func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
void func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@
void func(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/845aa10ef171fc0ea060495efef142a0c13f7870.1602161031.git-series.maxime@cerno.tech
2020-10-08 20:44:08 +08:00
|
|
|
struct drm_crtc_state *old_crtc_state = drm_atomic_get_old_crtc_state(state,
|
|
|
|
crtc);
|
2015-08-20 10:19:49 +08:00
|
|
|
struct drm_device *dev = crtc->dev;
|
|
|
|
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
|
|
|
|
|
2016-11-01 00:51:19 +08:00
|
|
|
/* always disable planes on the CRTC */
|
|
|
|
drm_atomic_helper_disable_planes_on_crtc(old_crtc_state, true);
|
|
|
|
|
2016-04-19 09:22:47 +08:00
|
|
|
drm_crtc_vblank_off(crtc);
|
|
|
|
|
2015-11-19 08:50:55 +08:00
|
|
|
regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
|
|
|
|
DCU_MODE_DCU_MODE_MASK,
|
|
|
|
DCU_MODE_DCU_MODE(DCU_MODE_OFF));
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
|
|
|
|
DCU_UPDATE_MODE_READREG);
|
2016-10-05 08:40:29 +08:00
|
|
|
clk_disable_unprepare(fsl_dev->pix_clk);
|
2015-08-20 10:19:49 +08:00
|
|
|
}
|
|
|
|
|
2017-06-30 17:36:44 +08:00
|
|
|
static void fsl_dcu_drm_crtc_atomic_enable(struct drm_crtc *crtc,
|
drm/atomic: Pass the full state to CRTC atomic enable/disable
If the CRTC driver ever needs to access the full DRM state, it can't do so
at atomic_enable / atomic_disable time since drm_atomic_helper_swap_state
will have cleared the pointer from the struct drm_crtc_state to the struct
drm_atomic_state before calling those hooks.
In order to allow that, let's pass the full DRM state to atomic_enable and
atomic_disable. The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@
disable_outputs(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- FUNCS->atomic_disable(crtc, crtc_state);
+ FUNCS->atomic_disable(crtc, state);
...>
}
@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@
drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- FUNCS->atomic_enable(crtc, crtc_state);
+ FUNCS->atomic_enable(crtc, state);
...>
}
@@
identifier crtc, old_state;
@@
struct drm_crtc_helper_funcs {
...
- void (*atomic_enable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_enable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
- void (*atomic_disable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+ void (*atomic_disable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
(
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_enable = func,
...,
};
|
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
)
@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@
void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+ struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
void func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
void func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@
void func(struct drm_crtc *crtc,
- struct drm_crtc_state *old_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/845aa10ef171fc0ea060495efef142a0c13f7870.1602161031.git-series.maxime@cerno.tech
2020-10-08 20:44:08 +08:00
|
|
|
struct drm_atomic_state *state)
|
2015-08-20 10:19:49 +08:00
|
|
|
{
|
|
|
|
struct drm_device *dev = crtc->dev;
|
|
|
|
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
|
|
|
|
|
2016-10-05 08:40:29 +08:00
|
|
|
clk_prepare_enable(fsl_dev->pix_clk);
|
2015-11-19 08:50:55 +08:00
|
|
|
regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
|
|
|
|
DCU_MODE_DCU_MODE_MASK,
|
|
|
|
DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
|
|
|
|
DCU_UPDATE_MODE_READREG);
|
2016-04-19 09:22:47 +08:00
|
|
|
|
|
|
|
drm_crtc_vblank_on(crtc);
|
2015-08-20 10:19:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = crtc->dev;
|
|
|
|
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
|
2016-02-09 04:50:13 +08:00
|
|
|
struct drm_connector *con = &fsl_dev->connector.base;
|
2015-08-20 10:19:49 +08:00
|
|
|
struct drm_display_mode *mode = &crtc->state->mode;
|
2018-09-27 04:41:50 +08:00
|
|
|
unsigned int pol = 0;
|
|
|
|
struct videomode vm;
|
2015-08-20 10:19:49 +08:00
|
|
|
|
2016-03-23 09:06:08 +08:00
|
|
|
clk_set_rate(fsl_dev->pix_clk, mode->clock * 1000);
|
2015-08-20 10:19:49 +08:00
|
|
|
|
2018-09-27 04:41:50 +08:00
|
|
|
drm_display_mode_to_videomode(mode, &vm);
|
2015-08-20 10:19:49 +08:00
|
|
|
|
2016-02-09 04:50:13 +08:00
|
|
|
/* INV_PXCK as default (most display sample data on rising edge) */
|
2018-09-22 20:02:42 +08:00
|
|
|
if (!(con->display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE))
|
2016-02-09 04:50:13 +08:00
|
|
|
pol |= DCU_SYN_POL_INV_PXCK;
|
|
|
|
|
2018-09-27 04:41:50 +08:00
|
|
|
if (vm.flags & DISPLAY_FLAGS_HSYNC_LOW)
|
2015-11-18 11:10:29 +08:00
|
|
|
pol |= DCU_SYN_POL_INV_HS_LOW;
|
|
|
|
|
2018-09-27 04:41:50 +08:00
|
|
|
if (vm.flags & DISPLAY_FLAGS_VSYNC_LOW)
|
2015-11-18 11:10:29 +08:00
|
|
|
pol |= DCU_SYN_POL_INV_VS_LOW;
|
|
|
|
|
2015-11-19 08:50:55 +08:00
|
|
|
regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
|
2018-09-27 04:41:50 +08:00
|
|
|
DCU_HSYN_PARA_BP(vm.hback_porch) |
|
|
|
|
DCU_HSYN_PARA_PW(vm.hsync_len) |
|
|
|
|
DCU_HSYN_PARA_FP(vm.hfront_porch));
|
2015-11-19 08:50:55 +08:00
|
|
|
regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
|
2018-09-27 04:41:50 +08:00
|
|
|
DCU_VSYN_PARA_BP(vm.vback_porch) |
|
|
|
|
DCU_VSYN_PARA_PW(vm.vsync_len) |
|
|
|
|
DCU_VSYN_PARA_FP(vm.vfront_porch));
|
2015-11-19 08:50:55 +08:00
|
|
|
regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
|
2018-09-27 04:41:50 +08:00
|
|
|
DCU_DISP_SIZE_DELTA_Y(vm.vactive) |
|
|
|
|
DCU_DISP_SIZE_DELTA_X(vm.hactive));
|
2015-11-18 11:10:29 +08:00
|
|
|
regmap_write(fsl_dev->regmap, DCU_SYN_POL, pol);
|
2015-11-19 08:50:55 +08:00
|
|
|
regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
|
|
|
|
DCU_BGND_G(0) | DCU_BGND_B(0));
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
|
|
|
|
DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
|
|
|
|
DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
|
|
|
|
DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
|
|
|
|
DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
|
2015-08-20 10:19:49 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct drm_crtc_helper_funcs fsl_dcu_drm_crtc_helper_funcs = {
|
2016-11-01 00:51:19 +08:00
|
|
|
.atomic_disable = fsl_dcu_drm_crtc_atomic_disable,
|
2015-08-20 10:19:49 +08:00
|
|
|
.atomic_flush = fsl_dcu_drm_crtc_atomic_flush,
|
2017-06-30 17:36:44 +08:00
|
|
|
.atomic_enable = fsl_dcu_drm_crtc_atomic_enable,
|
2015-08-20 10:19:49 +08:00
|
|
|
.mode_set_nofb = fsl_dcu_drm_crtc_mode_set_nofb,
|
|
|
|
};
|
|
|
|
|
2017-02-07 17:16:21 +08:00
|
|
|
static int fsl_dcu_drm_crtc_enable_vblank(struct drm_crtc *crtc)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = crtc->dev;
|
|
|
|
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
|
|
|
|
unsigned int value;
|
|
|
|
|
|
|
|
regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
|
|
|
|
value &= ~DCU_INT_MASK_VBLANK;
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fsl_dcu_drm_crtc_disable_vblank(struct drm_crtc *crtc)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = crtc->dev;
|
|
|
|
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
|
|
|
|
unsigned int value;
|
|
|
|
|
|
|
|
regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
|
|
|
|
value |= DCU_INT_MASK_VBLANK;
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
|
|
|
|
}
|
|
|
|
|
2015-08-20 10:19:49 +08:00
|
|
|
static const struct drm_crtc_funcs fsl_dcu_drm_crtc_funcs = {
|
|
|
|
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
|
|
|
|
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_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,
|
2017-02-07 17:16:21 +08:00
|
|
|
.enable_vblank = fsl_dcu_drm_crtc_enable_vblank,
|
|
|
|
.disable_vblank = fsl_dcu_drm_crtc_disable_vblank,
|
2015-08-20 10:19:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev)
|
|
|
|
{
|
|
|
|
struct drm_plane *primary;
|
|
|
|
struct drm_crtc *crtc = &fsl_dev->crtc;
|
|
|
|
int ret;
|
|
|
|
|
2016-02-12 08:51:49 +08:00
|
|
|
fsl_dcu_drm_init_planes(fsl_dev->drm);
|
|
|
|
|
2015-08-20 10:19:49 +08:00
|
|
|
primary = fsl_dcu_drm_primary_create_plane(fsl_dev->drm);
|
2015-11-17 07:43:34 +08:00
|
|
|
if (!primary)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2015-08-20 10:19:49 +08:00
|
|
|
ret = drm_crtc_init_with_planes(fsl_dev->drm, crtc, primary, NULL,
|
drm: Pass 'name' to drm_crtc_init_with_planes()
Done with coccinelle for the most part. However, it thinks '...' is
part of the semantic patch, so I put an 'int DOTDOTDOT' placeholder
in its place and got rid of it with sed afterwards.
I didn't convert drm_crtc_init() since passing the varargs through
would mean either cpp macros or va_list, and I figured we don't
care about these legacy functions enough to warrant the extra pain.
@@
identifier dev, crtc, primary, cursor, funcs;
@@
int drm_crtc_init_with_planes(struct drm_device *dev,
struct drm_crtc *crtc,
struct drm_plane *primary, struct drm_plane *cursor,
const struct drm_crtc_funcs *funcs
+ ,const char *name, int DOTDOTDOT
)
{ ... }
@@
identifier dev, crtc, primary, cursor, funcs;
@@
int drm_crtc_init_with_planes(struct drm_device *dev,
struct drm_crtc *crtc,
struct drm_plane *primary, struct drm_plane *cursor,
const struct drm_crtc_funcs *funcs
+ ,const char *name, int DOTDOTDOT
);
@@
expression E1, E2, E3, E4, E5;
@@
drm_crtc_init_with_planes(E1, E2, E3, E4, E5
+ ,NULL
)
v2: Split crtc and plane changes apart
Pass NULL for no-name instead of ""
Leave drm_crtc_init() alone
v3: Add ', or NULL...' to @name kernel doc (Jani)
Annotate the function with __printf() attribute (Jani)
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1449670771-2751-1-git-send-email-ville.syrjala@linux.intel.com
2015-12-09 22:19:31 +08:00
|
|
|
&fsl_dcu_drm_crtc_funcs, NULL);
|
2015-11-17 07:43:34 +08:00
|
|
|
if (ret) {
|
|
|
|
primary->funcs->destroy(primary);
|
2015-08-20 10:19:49 +08:00
|
|
|
return ret;
|
2015-11-17 07:43:34 +08:00
|
|
|
}
|
2015-08-20 10:19:49 +08:00
|
|
|
|
|
|
|
drm_crtc_helper_add(crtc, &fsl_dcu_drm_crtc_helper_funcs);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|