2014-07-31 15:39:11 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) STMicroelectronics SA 2014
|
|
|
|
* Authors: Benjamin Gaignard <benjamin.gaignard@st.com>
|
|
|
|
* Fabien Dessenne <fabien.dessenne@st.com>
|
|
|
|
* for STMicroelectronics.
|
|
|
|
* License terms: GNU General Public License (GPL), version 2
|
|
|
|
*/
|
|
|
|
|
2015-03-19 20:35:16 +08:00
|
|
|
#include <drm/drmP.h>
|
2015-07-31 17:32:13 +08:00
|
|
|
#include <drm/drm_fb_cma_helper.h>
|
2015-08-03 20:22:16 +08:00
|
|
|
#include <drm/drm_gem_cma_helper.h>
|
2015-03-19 20:35:16 +08:00
|
|
|
|
2014-07-31 15:39:11 +08:00
|
|
|
#include "sti_compositor.h"
|
2015-07-31 17:32:34 +08:00
|
|
|
#include "sti_drv.h"
|
|
|
|
#include "sti_plane.h"
|
2014-07-31 15:39:11 +08:00
|
|
|
|
2015-07-31 17:32:13 +08:00
|
|
|
/* (Background) < GDP0 < GDP1 < HQVDP0 < GDP2 < GDP3 < (ForeGround) */
|
|
|
|
enum sti_plane_desc sti_plane_default_zorder[] = {
|
2014-07-31 15:39:11 +08:00
|
|
|
STI_GDP_0,
|
|
|
|
STI_GDP_1,
|
2015-07-31 17:32:13 +08:00
|
|
|
STI_HQVDP_0,
|
2014-07-31 15:39:11 +08:00
|
|
|
STI_GDP_2,
|
|
|
|
STI_GDP_3,
|
|
|
|
};
|
|
|
|
|
2015-07-31 17:32:13 +08:00
|
|
|
const char *sti_plane_to_str(struct sti_plane *plane)
|
2014-07-31 15:39:11 +08:00
|
|
|
{
|
2015-07-31 17:32:13 +08:00
|
|
|
switch (plane->desc) {
|
|
|
|
case STI_GDP_0:
|
|
|
|
return "GDP0";
|
|
|
|
case STI_GDP_1:
|
|
|
|
return "GDP1";
|
|
|
|
case STI_GDP_2:
|
|
|
|
return "GDP2";
|
|
|
|
case STI_GDP_3:
|
|
|
|
return "GDP3";
|
|
|
|
case STI_HQVDP_0:
|
|
|
|
return "HQVDP0";
|
|
|
|
case STI_CURSOR:
|
|
|
|
return "CURSOR";
|
|
|
|
default:
|
|
|
|
return "<UNKNOWN PLANE>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-31 17:32:34 +08:00
|
|
|
static void sti_plane_destroy(struct drm_plane *drm_plane)
|
2014-07-31 15:39:11 +08:00
|
|
|
{
|
|
|
|
DRM_DEBUG_DRIVER("\n");
|
|
|
|
|
2015-07-31 17:32:13 +08:00
|
|
|
drm_plane_helper_disable(drm_plane);
|
|
|
|
drm_plane_cleanup(drm_plane);
|
2014-07-31 15:39:11 +08:00
|
|
|
}
|
|
|
|
|
2015-07-31 17:32:34 +08:00
|
|
|
static int sti_plane_set_property(struct drm_plane *drm_plane,
|
|
|
|
struct drm_property *property,
|
|
|
|
uint64_t val)
|
2014-07-31 15:39:11 +08:00
|
|
|
{
|
2015-07-31 17:32:13 +08:00
|
|
|
struct drm_device *dev = drm_plane->dev;
|
2015-07-31 17:32:34 +08:00
|
|
|
struct sti_private *private = dev->dev_private;
|
2015-07-31 17:32:13 +08:00
|
|
|
struct sti_plane *plane = to_sti_plane(drm_plane);
|
2014-07-31 15:39:11 +08:00
|
|
|
|
|
|
|
DRM_DEBUG_DRIVER("\n");
|
|
|
|
|
|
|
|
if (property == private->plane_zorder_property) {
|
2015-07-31 17:32:13 +08:00
|
|
|
plane->zorder = val;
|
2014-07-31 15:39:11 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2015-07-31 17:32:34 +08:00
|
|
|
static void sti_plane_attach_zorder_property(struct drm_plane *drm_plane)
|
2014-07-31 15:39:11 +08:00
|
|
|
{
|
2015-07-31 17:32:13 +08:00
|
|
|
struct drm_device *dev = drm_plane->dev;
|
2015-07-31 17:32:34 +08:00
|
|
|
struct sti_private *private = dev->dev_private;
|
2015-07-31 17:32:13 +08:00
|
|
|
struct sti_plane *plane = to_sti_plane(drm_plane);
|
2014-07-31 15:39:11 +08:00
|
|
|
struct drm_property *prop;
|
|
|
|
|
|
|
|
prop = private->plane_zorder_property;
|
|
|
|
if (!prop) {
|
2015-07-31 17:31:38 +08:00
|
|
|
prop = drm_property_create_range(dev, 0, "zpos", 1,
|
|
|
|
GAM_MIXER_NB_DEPTH_LEVEL);
|
2014-07-31 15:39:11 +08:00
|
|
|
if (!prop)
|
|
|
|
return;
|
|
|
|
|
|
|
|
private->plane_zorder_property = prop;
|
|
|
|
}
|
|
|
|
|
2015-07-31 17:32:13 +08:00
|
|
|
drm_object_attach_property(&drm_plane->base, prop, plane->zorder);
|
2014-07-31 15:39:11 +08:00
|
|
|
}
|
|
|
|
|
2015-08-03 20:22:16 +08:00
|
|
|
void sti_plane_init_property(struct sti_plane *plane,
|
|
|
|
enum drm_plane_type type)
|
2014-07-31 15:39:11 +08:00
|
|
|
{
|
2015-08-03 20:22:16 +08:00
|
|
|
unsigned int i;
|
2015-03-19 20:35:16 +08:00
|
|
|
|
2015-07-31 17:32:13 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(sti_plane_default_zorder); i++)
|
|
|
|
if (sti_plane_default_zorder[i] == plane->desc)
|
2014-07-31 15:39:11 +08:00
|
|
|
break;
|
|
|
|
|
2015-07-31 17:32:13 +08:00
|
|
|
plane->zorder = i + 1;
|
2014-07-31 15:39:11 +08:00
|
|
|
|
|
|
|
if (type == DRM_PLANE_TYPE_OVERLAY)
|
2015-07-31 17:32:34 +08:00
|
|
|
sti_plane_attach_zorder_property(&plane->drm_plane);
|
2014-07-31 15:39:11 +08:00
|
|
|
|
2015-07-31 17:32:13 +08:00
|
|
|
DRM_DEBUG_DRIVER("drm plane:%d mapped to %s with zorder:%d\n",
|
|
|
|
plane->drm_plane.base.id,
|
|
|
|
sti_plane_to_str(plane), plane->zorder);
|
2014-07-31 15:39:11 +08:00
|
|
|
}
|
2015-08-03 20:22:16 +08:00
|
|
|
|
|
|
|
struct drm_plane_funcs sti_plane_helpers_funcs = {
|
|
|
|
.update_plane = drm_atomic_helper_update_plane,
|
|
|
|
.disable_plane = drm_atomic_helper_disable_plane,
|
|
|
|
.destroy = sti_plane_destroy,
|
|
|
|
.set_property = sti_plane_set_property,
|
|
|
|
.reset = drm_atomic_helper_plane_reset,
|
|
|
|
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
|
|
|
|
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
|
|
|
|
};
|