blob: 17b7303557efc8bd49073b06382875f675508c66 [file] [log] [blame]
Narendra Muppalla1b0b3352015-09-29 10:16:51 -07001/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include "sde_kms.h"
14
15struct sde_plane {
16 struct drm_plane base;
17 const char *name;
18 uint32_t nformats;
19 uint32_t formats[32];
20};
21#define to_sde_plane(x) container_of(x, struct sde_plane, base)
22
23static int sde_plane_update(struct drm_plane *plane,
24 struct drm_crtc *crtc, struct drm_framebuffer *fb,
25 int crtc_x, int crtc_y,
26 unsigned int crtc_w, unsigned int crtc_h,
27 uint32_t src_x, uint32_t src_y,
28 uint32_t src_w, uint32_t src_h)
29{
30 return 0;
31}
32
33static int sde_plane_disable(struct drm_plane *plane)
34{
35 return 0;
36}
37
38static void sde_plane_destroy(struct drm_plane *plane)
39{
40 struct sde_plane *sde_plane = to_sde_plane(plane);
41 struct msm_drm_private *priv = plane->dev->dev_private;
42
43 if (priv->kms)
44 sde_plane_disable(plane);
45
46 drm_plane_cleanup(plane);
47
48 kfree(sde_plane);
49}
50
51/* helper to install properties which are common to planes and crtcs */
52void sde_plane_install_properties(struct drm_plane *plane,
53 struct drm_mode_object *obj)
54{
55}
56
57int sde_plane_set_property(struct drm_plane *plane,
58 struct drm_property *property, uint64_t val)
59{
60 return -EINVAL;
61}
62
63static const struct drm_plane_funcs sde_plane_funcs = {
64 .update_plane = sde_plane_update,
65 .disable_plane = sde_plane_disable,
66 .destroy = sde_plane_destroy,
67 .set_property = sde_plane_set_property,
68};
69
70void sde_plane_set_scanout(struct drm_plane *plane,
71 struct drm_framebuffer *fb)
72{
73}
74
75int sde_plane_mode_set(struct drm_plane *plane,
76 struct drm_crtc *crtc, struct drm_framebuffer *fb,
77 int crtc_x, int crtc_y,
78 unsigned int crtc_w, unsigned int crtc_h,
79 uint32_t src_x, uint32_t src_y,
80 uint32_t src_w, uint32_t src_h)
81{
82 return 0;
83}
84
85/* initialize plane */
86struct drm_plane *sde_plane_init(struct drm_device *dev, bool private_plane)
87{
88 struct drm_plane *plane = NULL;
89 struct sde_plane *sde_plane;
90 int ret;
91 enum drm_plane_type type;
92
93 sde_plane = kzalloc(sizeof(*sde_plane), GFP_KERNEL);
94 if (!sde_plane) {
95 ret = -ENOMEM;
96 goto fail;
97 }
98
99 plane = &sde_plane->base;
100
101 type = private_plane ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
102 drm_universal_plane_init(dev, plane, 0xff, &sde_plane_funcs,
103 sde_plane->formats, sde_plane->nformats,
104 type);
105
106 sde_plane_install_properties(plane, &plane->base);
107
108 return plane;
109
110fail:
111 if (plane)
112 sde_plane_destroy(plane);
113
114 return ERR_PTR(ret);
115}