2013-10-10 22:18:45 +08:00
|
|
|
/*
|
|
|
|
* i.MX IPUv3 DP Overlay Planes
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Philipp Zabel, Pengutronix
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <drm/drmP.h>
|
2016-07-08 17:40:59 +08:00
|
|
|
#include <drm/drm_atomic.h>
|
2016-07-08 17:40:56 +08:00
|
|
|
#include <drm/drm_atomic_helper.h>
|
2013-10-10 22:18:45 +08:00
|
|
|
#include <drm/drm_fb_cma_helper.h>
|
|
|
|
#include <drm/drm_gem_cma_helper.h>
|
2016-07-08 17:40:55 +08:00
|
|
|
#include <drm/drm_plane_helper.h>
|
2013-10-10 22:18:45 +08:00
|
|
|
|
2013-09-30 22:13:39 +08:00
|
|
|
#include "video/imx-ipu-v3.h"
|
2013-10-10 22:18:45 +08:00
|
|
|
#include "ipuv3-plane.h"
|
|
|
|
|
2016-07-06 21:47:11 +08:00
|
|
|
static inline struct ipu_plane *to_ipu_plane(struct drm_plane *p)
|
|
|
|
{
|
|
|
|
return container_of(p, struct ipu_plane, base);
|
|
|
|
}
|
2013-10-10 22:18:45 +08:00
|
|
|
|
|
|
|
static const uint32_t ipu_plane_formats[] = {
|
2014-12-12 20:40:38 +08:00
|
|
|
DRM_FORMAT_ARGB1555,
|
2013-10-10 22:18:45 +08:00
|
|
|
DRM_FORMAT_XRGB1555,
|
2014-12-12 20:40:38 +08:00
|
|
|
DRM_FORMAT_ABGR1555,
|
2013-10-10 22:18:45 +08:00
|
|
|
DRM_FORMAT_XBGR1555,
|
2014-12-12 20:40:38 +08:00
|
|
|
DRM_FORMAT_RGBA5551,
|
|
|
|
DRM_FORMAT_BGRA5551,
|
2015-08-04 23:22:06 +08:00
|
|
|
DRM_FORMAT_ARGB4444,
|
2013-10-10 22:18:45 +08:00
|
|
|
DRM_FORMAT_ARGB8888,
|
|
|
|
DRM_FORMAT_XRGB8888,
|
|
|
|
DRM_FORMAT_ABGR8888,
|
|
|
|
DRM_FORMAT_XBGR8888,
|
2015-04-16 21:56:40 +08:00
|
|
|
DRM_FORMAT_RGBA8888,
|
|
|
|
DRM_FORMAT_RGBX8888,
|
|
|
|
DRM_FORMAT_BGRA8888,
|
|
|
|
DRM_FORMAT_BGRA8888,
|
2016-02-12 21:35:55 +08:00
|
|
|
DRM_FORMAT_UYVY,
|
|
|
|
DRM_FORMAT_VYUY,
|
2013-10-10 22:18:45 +08:00
|
|
|
DRM_FORMAT_YUYV,
|
|
|
|
DRM_FORMAT_YVYU,
|
|
|
|
DRM_FORMAT_YUV420,
|
|
|
|
DRM_FORMAT_YVU420,
|
2015-11-24 23:29:22 +08:00
|
|
|
DRM_FORMAT_RGB565,
|
2013-10-10 22:18:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int ipu_plane_irq(struct ipu_plane *ipu_plane)
|
|
|
|
{
|
|
|
|
return ipu_idmac_channel_irq(ipu_plane->ipu, ipu_plane->ipu_ch,
|
|
|
|
IPU_IRQ_EOF);
|
|
|
|
}
|
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
static inline unsigned long
|
|
|
|
drm_plane_state_to_eba(struct drm_plane_state *state)
|
2013-10-10 22:18:45 +08:00
|
|
|
{
|
2016-07-08 17:40:55 +08:00
|
|
|
struct drm_framebuffer *fb = state->fb;
|
|
|
|
struct drm_gem_cma_object *cma_obj;
|
2013-10-10 22:18:45 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
|
|
|
|
BUG_ON(!cma_obj);
|
2013-10-10 22:18:45 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
return cma_obj->paddr + fb->offsets[0] +
|
|
|
|
fb->pitches[0] * (state->src_y >> 16) +
|
|
|
|
(fb->bits_per_pixel >> 3) * (state->src_x >> 16);
|
|
|
|
}
|
2016-07-08 17:40:53 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
static inline unsigned long
|
|
|
|
drm_plane_state_to_ubo(struct drm_plane_state *state)
|
|
|
|
{
|
|
|
|
struct drm_framebuffer *fb = state->fb;
|
|
|
|
struct drm_gem_cma_object *cma_obj;
|
|
|
|
unsigned long eba = drm_plane_state_to_eba(state);
|
2013-10-10 22:18:45 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
cma_obj = drm_fb_cma_get_gem_obj(fb, 1);
|
|
|
|
BUG_ON(!cma_obj);
|
2014-10-08 23:19:15 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
return cma_obj->paddr + fb->offsets[1] +
|
|
|
|
fb->pitches[1] * (state->src_y >> 16) / 2 +
|
|
|
|
(state->src_x >> 16) / 2 - eba;
|
|
|
|
}
|
2014-10-08 23:19:15 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
static inline unsigned long
|
|
|
|
drm_plane_state_to_vbo(struct drm_plane_state *state)
|
|
|
|
{
|
|
|
|
struct drm_framebuffer *fb = state->fb;
|
|
|
|
struct drm_gem_cma_object *cma_obj;
|
|
|
|
unsigned long eba = drm_plane_state_to_eba(state);
|
|
|
|
|
|
|
|
cma_obj = drm_fb_cma_get_gem_obj(fb, 2);
|
|
|
|
BUG_ON(!cma_obj);
|
|
|
|
|
|
|
|
return cma_obj->paddr + fb->offsets[2] +
|
|
|
|
fb->pitches[2] * (state->src_y >> 16) / 2 +
|
|
|
|
(state->src_x >> 16) / 2 - eba;
|
|
|
|
}
|
|
|
|
|
2016-10-10 14:50:07 +08:00
|
|
|
static void ipu_plane_atomic_set_base(struct ipu_plane *ipu_plane)
|
2016-07-08 17:40:55 +08:00
|
|
|
{
|
|
|
|
struct drm_plane *plane = &ipu_plane->base;
|
|
|
|
struct drm_plane_state *state = plane->state;
|
2016-10-10 14:50:06 +08:00
|
|
|
struct drm_crtc_state *crtc_state = state->crtc->state;
|
2016-07-08 17:40:55 +08:00
|
|
|
struct drm_framebuffer *fb = state->fb;
|
|
|
|
unsigned long eba, ubo, vbo;
|
|
|
|
int active;
|
|
|
|
|
|
|
|
eba = drm_plane_state_to_eba(state);
|
|
|
|
|
|
|
|
switch (fb->pixel_format) {
|
|
|
|
case DRM_FORMAT_YUV420:
|
|
|
|
case DRM_FORMAT_YVU420:
|
2016-10-10 14:50:07 +08:00
|
|
|
if (!drm_atomic_crtc_needs_modeset(crtc_state))
|
2014-10-08 23:19:12 +08:00
|
|
|
break;
|
2013-10-10 22:18:45 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
/*
|
|
|
|
* Multiplanar formats have to meet the following restrictions:
|
|
|
|
* - The (up to) three plane addresses are EBA, EBA+UBO, EBA+VBO
|
|
|
|
* - EBA, UBO and VBO are a multiple of 8
|
|
|
|
* - UBO and VBO are unsigned and not larger than 0xfffff8
|
|
|
|
* - Only EBA may be changed while scanout is active
|
|
|
|
* - The strides of U and V planes must be identical.
|
|
|
|
*/
|
|
|
|
ubo = drm_plane_state_to_ubo(state);
|
|
|
|
vbo = drm_plane_state_to_vbo(state);
|
2016-03-14 16:10:11 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
if (fb->pixel_format == DRM_FORMAT_YUV420)
|
|
|
|
ipu_cpmem_set_yuv_planar_full(ipu_plane->ipu_ch,
|
|
|
|
fb->pitches[1], ubo, vbo);
|
|
|
|
else
|
|
|
|
ipu_cpmem_set_yuv_planar_full(ipu_plane->ipu_ch,
|
|
|
|
fb->pitches[1], vbo, ubo);
|
2013-10-10 22:18:45 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
dev_dbg(ipu_plane->base.dev->dev,
|
|
|
|
"phy = %lu %lu %lu, x = %d, y = %d", eba, ubo, vbo,
|
|
|
|
state->src_x >> 16, state->src_y >> 16);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dev_dbg(ipu_plane->base.dev->dev, "phys = %lu, x = %d, y = %d",
|
|
|
|
eba, state->src_x >> 16, state->src_y >> 16);
|
2016-02-23 17:22:52 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
break;
|
|
|
|
}
|
2014-10-08 23:19:15 +08:00
|
|
|
|
2016-10-10 14:50:06 +08:00
|
|
|
if (!drm_atomic_crtc_needs_modeset(crtc_state)) {
|
2016-07-08 17:40:55 +08:00
|
|
|
active = ipu_idmac_get_current_buffer(ipu_plane->ipu_ch);
|
|
|
|
ipu_cpmem_set_buffer(ipu_plane->ipu_ch, !active, eba);
|
|
|
|
ipu_idmac_select_buffer(ipu_plane->ipu_ch, !active);
|
|
|
|
} else {
|
|
|
|
ipu_cpmem_set_buffer(ipu_plane->ipu_ch, 0, eba);
|
|
|
|
ipu_cpmem_set_buffer(ipu_plane->ipu_ch, 1, eba);
|
|
|
|
}
|
2013-10-10 22:18:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ipu_plane_put_resources(struct ipu_plane *ipu_plane)
|
|
|
|
{
|
|
|
|
if (!IS_ERR_OR_NULL(ipu_plane->dp))
|
|
|
|
ipu_dp_put(ipu_plane->dp);
|
|
|
|
if (!IS_ERR_OR_NULL(ipu_plane->dmfc))
|
|
|
|
ipu_dmfc_put(ipu_plane->dmfc);
|
|
|
|
if (!IS_ERR_OR_NULL(ipu_plane->ipu_ch))
|
|
|
|
ipu_idmac_put(ipu_plane->ipu_ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ipu_plane_get_resources(struct ipu_plane *ipu_plane)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ipu_plane->ipu_ch = ipu_idmac_get(ipu_plane->ipu, ipu_plane->dma);
|
|
|
|
if (IS_ERR(ipu_plane->ipu_ch)) {
|
|
|
|
ret = PTR_ERR(ipu_plane->ipu_ch);
|
|
|
|
DRM_ERROR("failed to get idmac channel: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ipu_plane->dmfc = ipu_dmfc_get(ipu_plane->ipu, ipu_plane->dma);
|
|
|
|
if (IS_ERR(ipu_plane->dmfc)) {
|
|
|
|
ret = PTR_ERR(ipu_plane->dmfc);
|
|
|
|
DRM_ERROR("failed to get dmfc: ret %d\n", ret);
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ipu_plane->dp_flow >= 0) {
|
|
|
|
ipu_plane->dp = ipu_dp_get(ipu_plane->ipu, ipu_plane->dp_flow);
|
|
|
|
if (IS_ERR(ipu_plane->dp)) {
|
|
|
|
ret = PTR_ERR(ipu_plane->dp);
|
|
|
|
DRM_ERROR("failed to get dp flow: %d\n", ret);
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
err_out:
|
|
|
|
ipu_plane_put_resources(ipu_plane);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
static void ipu_plane_enable(struct ipu_plane *ipu_plane)
|
2013-10-10 22:18:45 +08:00
|
|
|
{
|
2014-04-15 05:53:20 +08:00
|
|
|
if (ipu_plane->dp)
|
|
|
|
ipu_dp_enable(ipu_plane->ipu);
|
2013-10-10 22:18:45 +08:00
|
|
|
ipu_dmfc_enable_channel(ipu_plane->dmfc);
|
|
|
|
ipu_idmac_enable_channel(ipu_plane->ipu_ch);
|
|
|
|
if (ipu_plane->dp)
|
|
|
|
ipu_dp_enable_channel(ipu_plane->dp);
|
|
|
|
}
|
|
|
|
|
2016-08-11 17:18:50 +08:00
|
|
|
static int ipu_disable_plane(struct drm_plane *plane)
|
2013-10-10 22:18:45 +08:00
|
|
|
{
|
2016-08-11 17:18:50 +08:00
|
|
|
struct ipu_plane *ipu_plane = to_ipu_plane(plane);
|
|
|
|
|
|
|
|
DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
|
|
|
|
|
2013-10-10 22:18:45 +08:00
|
|
|
ipu_idmac_wait_busy(ipu_plane->ipu_ch, 50);
|
|
|
|
|
|
|
|
if (ipu_plane->dp)
|
|
|
|
ipu_dp_disable_channel(ipu_plane->dp);
|
|
|
|
ipu_idmac_disable_channel(ipu_plane->ipu_ch);
|
|
|
|
ipu_dmfc_disable_channel(ipu_plane->dmfc);
|
2014-04-15 05:53:20 +08:00
|
|
|
if (ipu_plane->dp)
|
|
|
|
ipu_dp_disable(ipu_plane->ipu);
|
2013-10-10 22:18:45 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
static void ipu_plane_destroy(struct drm_plane *plane)
|
2013-10-10 22:18:45 +08:00
|
|
|
{
|
|
|
|
struct ipu_plane *ipu_plane = to_ipu_plane(plane);
|
|
|
|
|
|
|
|
DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
|
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
drm_plane_cleanup(plane);
|
|
|
|
kfree(ipu_plane);
|
|
|
|
}
|
2013-10-10 22:18:45 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
static const struct drm_plane_funcs ipu_plane_funcs = {
|
2016-07-08 17:40:59 +08:00
|
|
|
.update_plane = drm_atomic_helper_update_plane,
|
|
|
|
.disable_plane = drm_atomic_helper_disable_plane,
|
2016-07-08 17:40:55 +08:00
|
|
|
.destroy = ipu_plane_destroy,
|
2016-07-08 17:40:56 +08:00
|
|
|
.reset = drm_atomic_helper_plane_reset,
|
|
|
|
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
|
|
|
|
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
|
2016-07-08 17:40:55 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int ipu_plane_atomic_check(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *state)
|
|
|
|
{
|
|
|
|
struct drm_plane_state *old_state = plane->state;
|
|
|
|
struct drm_crtc_state *crtc_state;
|
|
|
|
struct device *dev = plane->dev->dev;
|
|
|
|
struct drm_framebuffer *fb = state->fb;
|
|
|
|
struct drm_framebuffer *old_fb = old_state->fb;
|
|
|
|
unsigned long eba, ubo, vbo, old_ubo, old_vbo;
|
|
|
|
|
|
|
|
/* Ok to disable */
|
|
|
|
if (!fb)
|
2016-07-08 17:40:59 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!state->crtc)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
crtc_state =
|
|
|
|
drm_atomic_get_existing_crtc_state(state->state, state->crtc);
|
|
|
|
if (WARN_ON(!crtc_state))
|
|
|
|
return -EINVAL;
|
2016-07-08 17:40:55 +08:00
|
|
|
|
|
|
|
/* CRTC should be enabled */
|
2016-07-08 17:40:59 +08:00
|
|
|
if (!crtc_state->enable)
|
2016-07-08 17:40:55 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* no scaling */
|
|
|
|
if (state->src_w >> 16 != state->crtc_w ||
|
|
|
|
state->src_h >> 16 != state->crtc_h)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (plane->type) {
|
|
|
|
case DRM_PLANE_TYPE_PRIMARY:
|
|
|
|
/* full plane doesn't support partial off screen */
|
|
|
|
if (state->crtc_x || state->crtc_y ||
|
|
|
|
state->crtc_w != crtc_state->adjusted_mode.hdisplay ||
|
|
|
|
state->crtc_h != crtc_state->adjusted_mode.vdisplay)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* full plane minimum width is 13 pixels */
|
|
|
|
if (state->crtc_w < 13)
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case DRM_PLANE_TYPE_OVERLAY:
|
|
|
|
if (state->crtc_x < 0 || state->crtc_y < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (state->crtc_x + state->crtc_w >
|
|
|
|
crtc_state->adjusted_mode.hdisplay)
|
|
|
|
return -EINVAL;
|
|
|
|
if (state->crtc_y + state->crtc_h >
|
|
|
|
crtc_state->adjusted_mode.vdisplay)
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dev_warn(dev, "Unsupported plane type\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state->crtc_h < 2)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/*
|
2016-08-26 15:30:44 +08:00
|
|
|
* We support resizing active plane or changing its format by
|
|
|
|
* forcing CRTC mode change in plane's ->atomic_check callback
|
|
|
|
* and disabling all affected active planes in CRTC's ->atomic_disable
|
|
|
|
* callback. The planes will be reenabled in plane's ->atomic_update
|
|
|
|
* callback.
|
2016-07-08 17:40:55 +08:00
|
|
|
*/
|
|
|
|
if (old_fb && (state->src_w != old_state->src_w ||
|
|
|
|
state->src_h != old_state->src_h ||
|
|
|
|
fb->pixel_format != old_fb->pixel_format))
|
2016-08-26 15:30:44 +08:00
|
|
|
crtc_state->mode_changed = true;
|
2016-07-08 17:40:55 +08:00
|
|
|
|
|
|
|
eba = drm_plane_state_to_eba(state);
|
|
|
|
|
|
|
|
if (eba & 0x7)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (fb->pitches[0] < 1 || fb->pitches[0] > 16384)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (old_fb && fb->pitches[0] != old_fb->pitches[0])
|
2016-08-26 15:30:44 +08:00
|
|
|
crtc_state->mode_changed = true;
|
2016-07-08 17:40:55 +08:00
|
|
|
|
|
|
|
switch (fb->pixel_format) {
|
|
|
|
case DRM_FORMAT_YUV420:
|
|
|
|
case DRM_FORMAT_YVU420:
|
|
|
|
/*
|
|
|
|
* Multiplanar formats have to meet the following restrictions:
|
|
|
|
* - The (up to) three plane addresses are EBA, EBA+UBO, EBA+VBO
|
|
|
|
* - EBA, UBO and VBO are a multiple of 8
|
|
|
|
* - UBO and VBO are unsigned and not larger than 0xfffff8
|
|
|
|
* - Only EBA may be changed while scanout is active
|
|
|
|
* - The strides of U and V planes must be identical.
|
|
|
|
*/
|
|
|
|
ubo = drm_plane_state_to_ubo(state);
|
|
|
|
vbo = drm_plane_state_to_vbo(state);
|
|
|
|
|
|
|
|
if ((ubo & 0x7) || (vbo & 0x7))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if ((ubo > 0xfffff8) || (vbo > 0xfffff8))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (old_fb) {
|
|
|
|
old_ubo = drm_plane_state_to_ubo(old_state);
|
|
|
|
old_vbo = drm_plane_state_to_vbo(old_state);
|
|
|
|
if (ubo != old_ubo || vbo != old_vbo)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fb->pitches[1] != fb->pitches[2])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (fb->pitches[1] < 1 || fb->pitches[1] > 16384)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (old_fb && old_fb->pitches[1] != fb->pitches[1])
|
2016-08-26 15:30:44 +08:00
|
|
|
crtc_state->mode_changed = true;
|
2016-07-08 17:40:55 +08:00
|
|
|
}
|
2013-10-10 22:18:45 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
static void ipu_plane_atomic_disable(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *old_state)
|
|
|
|
{
|
|
|
|
ipu_disable_plane(plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ipu_plane_atomic_update(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *old_state)
|
2013-10-10 22:18:45 +08:00
|
|
|
{
|
|
|
|
struct ipu_plane *ipu_plane = to_ipu_plane(plane);
|
2016-07-08 17:40:55 +08:00
|
|
|
struct drm_plane_state *state = plane->state;
|
|
|
|
enum ipu_color_space ics;
|
2013-10-10 22:18:45 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
if (old_state->fb) {
|
2016-08-26 15:30:43 +08:00
|
|
|
struct drm_crtc_state *crtc_state = state->crtc->state;
|
|
|
|
|
|
|
|
if (!drm_atomic_crtc_needs_modeset(crtc_state)) {
|
2016-10-10 14:50:07 +08:00
|
|
|
ipu_plane_atomic_set_base(ipu_plane);
|
2016-08-26 15:30:43 +08:00
|
|
|
return;
|
|
|
|
}
|
2016-07-08 17:40:55 +08:00
|
|
|
}
|
2013-10-10 22:18:45 +08:00
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
switch (ipu_plane->dp_flow) {
|
|
|
|
case IPU_DP_FLOW_SYNC_BG:
|
|
|
|
ipu_dp_setup_channel(ipu_plane->dp,
|
|
|
|
IPUV3_COLORSPACE_RGB,
|
|
|
|
IPUV3_COLORSPACE_RGB);
|
|
|
|
ipu_dp_set_global_alpha(ipu_plane->dp, true, 0, true);
|
|
|
|
break;
|
|
|
|
case IPU_DP_FLOW_SYNC_FG:
|
|
|
|
ics = ipu_drm_fourcc_to_colorspace(state->fb->pixel_format);
|
|
|
|
ipu_dp_setup_channel(ipu_plane->dp, ics,
|
|
|
|
IPUV3_COLORSPACE_UNKNOWN);
|
|
|
|
ipu_dp_set_window_pos(ipu_plane->dp, state->crtc_x,
|
|
|
|
state->crtc_y);
|
|
|
|
/* Enable local alpha on partial plane */
|
|
|
|
switch (state->fb->pixel_format) {
|
|
|
|
case DRM_FORMAT_ARGB1555:
|
|
|
|
case DRM_FORMAT_ABGR1555:
|
|
|
|
case DRM_FORMAT_RGBA5551:
|
|
|
|
case DRM_FORMAT_BGRA5551:
|
|
|
|
case DRM_FORMAT_ARGB4444:
|
|
|
|
case DRM_FORMAT_ARGB8888:
|
|
|
|
case DRM_FORMAT_ABGR8888:
|
|
|
|
case DRM_FORMAT_RGBA8888:
|
|
|
|
case DRM_FORMAT_BGRA8888:
|
|
|
|
ipu_dp_set_global_alpha(ipu_plane->dp, false, 0, false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ipu_dmfc_config_wait4eot(ipu_plane->dmfc, state->crtc_w);
|
|
|
|
|
|
|
|
ipu_cpmem_zero(ipu_plane->ipu_ch);
|
|
|
|
ipu_cpmem_set_resolution(ipu_plane->ipu_ch, state->src_w >> 16,
|
|
|
|
state->src_h >> 16);
|
|
|
|
ipu_cpmem_set_fmt(ipu_plane->ipu_ch, state->fb->pixel_format);
|
|
|
|
ipu_cpmem_set_high_priority(ipu_plane->ipu_ch);
|
|
|
|
ipu_idmac_set_double_buffer(ipu_plane->ipu_ch, 1);
|
|
|
|
ipu_cpmem_set_stride(ipu_plane->ipu_ch, state->fb->pitches[0]);
|
2016-10-10 14:50:07 +08:00
|
|
|
ipu_plane_atomic_set_base(ipu_plane);
|
2016-07-08 17:40:55 +08:00
|
|
|
ipu_plane_enable(ipu_plane);
|
2013-10-10 22:18:45 +08:00
|
|
|
}
|
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
static const struct drm_plane_helper_funcs ipu_plane_helper_funcs = {
|
|
|
|
.atomic_check = ipu_plane_atomic_check,
|
|
|
|
.atomic_disable = ipu_plane_atomic_disable,
|
|
|
|
.atomic_update = ipu_plane_atomic_update,
|
2013-10-10 22:18:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
|
|
|
|
int dma, int dp, unsigned int possible_crtcs,
|
2015-11-06 18:08:02 +08:00
|
|
|
enum drm_plane_type type)
|
2013-10-10 22:18:45 +08:00
|
|
|
{
|
|
|
|
struct ipu_plane *ipu_plane;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
DRM_DEBUG_KMS("channel %d, dp flow %d, possible_crtcs=0x%x\n",
|
|
|
|
dma, dp, possible_crtcs);
|
|
|
|
|
|
|
|
ipu_plane = kzalloc(sizeof(*ipu_plane), GFP_KERNEL);
|
|
|
|
if (!ipu_plane) {
|
|
|
|
DRM_ERROR("failed to allocate plane\n");
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
ipu_plane->ipu = ipu;
|
|
|
|
ipu_plane->dma = dma;
|
|
|
|
ipu_plane->dp_flow = dp;
|
|
|
|
|
2015-11-06 18:08:02 +08:00
|
|
|
ret = drm_universal_plane_init(dev, &ipu_plane->base, possible_crtcs,
|
|
|
|
&ipu_plane_funcs, ipu_plane_formats,
|
drm: Pass 'name' to drm_universal_plane_init()
Done with coccinelle for the most part. It choked on
msm/mdp/mdp5/mdp5_plane.c like so:
"BAD:!!!!! enum drm_plane_type type;"
No idea how to deal with that, so I just fixed that up
by hand.
Also 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_plane_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.
@@
typedef uint32_t;
identifier dev, plane, possible_crtcs, funcs, formats, format_count, type;
@@
int drm_universal_plane_init(struct drm_device *dev,
struct drm_plane *plane,
unsigned long possible_crtcs,
const struct drm_plane_funcs *funcs,
const uint32_t *formats,
unsigned int format_count,
enum drm_plane_type type
+ ,const char *name, int DOTDOTDOT
)
{ ... }
@@
identifier dev, plane, possible_crtcs, funcs, formats, format_count, type;
@@
int drm_universal_plane_init(struct drm_device *dev,
struct drm_plane *plane,
unsigned long possible_crtcs,
const struct drm_plane_funcs *funcs,
const uint32_t *formats,
unsigned int format_count,
enum drm_plane_type type
+ ,const char *name, int DOTDOTDOT
);
@@
expression E1, E2, E3, E4, E5, E6, E7;
@@
drm_universal_plane_init(E1, E2, E3, E4, E5, E6, E7
+ ,NULL
)
v2: Split crtc and plane changes apart
Pass NUL for no-name instead of ""
Leave drm_plane_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/1449670795-2853-1-git-send-email-ville.syrjala@linux.intel.com
2015-12-09 22:19:55 +08:00
|
|
|
ARRAY_SIZE(ipu_plane_formats), type,
|
|
|
|
NULL);
|
2013-10-10 22:18:45 +08:00
|
|
|
if (ret) {
|
|
|
|
DRM_ERROR("failed to initialize plane\n");
|
|
|
|
kfree(ipu_plane);
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
|
|
|
|
2016-07-08 17:40:55 +08:00
|
|
|
drm_plane_helper_add(&ipu_plane->base, &ipu_plane_helper_funcs);
|
|
|
|
|
2013-10-10 22:18:45 +08:00
|
|
|
return ipu_plane;
|
|
|
|
}
|