Commit 10a02eb64656e96579e136ae914d30093ca59e48
1 parent
facb4f4e7f
Exists in
master
and in
16 other branches
drm/msm: mdp4_format -> mdp_format
This can be shared between mdp4 and mdp5. Both use the same set of parameters to describe the format to the hw. Signed-off-by: Rob Clark <robdclark@gmail.com>
Showing 8 changed files with 129 additions and 96 deletions Side-by-side Diff
- drivers/gpu/drm/msm/Makefile
- drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
- drivers/gpu/drm/msm/mdp/mdp4/mdp4_format.c
- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
- drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
- drivers/gpu/drm/msm/mdp/mdp_format.c
- drivers/gpu/drm/msm/mdp/mdp_kms.h
drivers/gpu/drm/msm/Makefile
... | ... | @@ -12,9 +12,9 @@ |
12 | 12 | hdmi/hdmi_i2c.o \ |
13 | 13 | hdmi/hdmi_phy_8960.o \ |
14 | 14 | hdmi/hdmi_phy_8x60.o \ |
15 | + mdp/mdp_format.o \ | |
15 | 16 | mdp/mdp4/mdp4_crtc.o \ |
16 | 17 | mdp/mdp4/mdp4_dtv_encoder.o \ |
17 | - mdp/mdp4/mdp4_format.o \ | |
18 | 18 | mdp/mdp4/mdp4_irq.o \ |
19 | 19 | mdp/mdp4/mdp4_kms.o \ |
20 | 20 | mdp/mdp4/mdp4_plane.o \ |
drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
... | ... | @@ -262,8 +262,8 @@ |
262 | 262 | enum mdp4_pipe pipe_id = mdp4_plane_pipe(plane); |
263 | 263 | int idx = idxs[pipe_id]; |
264 | 264 | if (idx > 0) { |
265 | - const struct mdp4_format *format = | |
266 | - to_mdp4_format(msm_framebuffer_format(plane->fb)); | |
265 | + const struct mdp_format *format = | |
266 | + to_mdp_format(msm_framebuffer_format(plane->fb)); | |
267 | 267 | alpha[idx-1] = format->alpha_enable; |
268 | 268 | } |
269 | 269 | mixer_cfg |= mixercfg(mdp4_crtc->mixer, pipe_id, stages[idx]); |
drivers/gpu/drm/msm/mdp/mdp4/mdp4_format.c
1 | -/* | |
2 | - * Copyright (C) 2013 Red Hat | |
3 | - * Author: Rob Clark <robdclark@gmail.com> | |
4 | - * | |
5 | - * This program is free software; you can redistribute it and/or modify it | |
6 | - * under the terms of the GNU General Public License version 2 as published by | |
7 | - * the Free Software Foundation. | |
8 | - * | |
9 | - * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | - * more details. | |
13 | - * | |
14 | - * You should have received a copy of the GNU General Public License along with | |
15 | - * this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | - */ | |
17 | - | |
18 | - | |
19 | -#include "msm_drv.h" | |
20 | -#include "mdp4_kms.h" | |
21 | - | |
22 | -#define FMT(name, a, r, g, b, e0, e1, e2, e3, alpha, tight, c, cnt) { \ | |
23 | - .base = { .pixel_format = DRM_FORMAT_ ## name }, \ | |
24 | - .bpc_a = BPC ## a ## A, \ | |
25 | - .bpc_r = BPC ## r, \ | |
26 | - .bpc_g = BPC ## g, \ | |
27 | - .bpc_b = BPC ## b, \ | |
28 | - .unpack = { e0, e1, e2, e3 }, \ | |
29 | - .alpha_enable = alpha, \ | |
30 | - .unpack_tight = tight, \ | |
31 | - .cpp = c, \ | |
32 | - .unpack_count = cnt, \ | |
33 | - } | |
34 | - | |
35 | -#define BPC0A 0 | |
36 | - | |
37 | -static const struct mdp4_format formats[] = { | |
38 | - /* name a r g b e0 e1 e2 e3 alpha tight cpp cnt */ | |
39 | - FMT(ARGB8888, 8, 8, 8, 8, 1, 0, 2, 3, true, true, 4, 4), | |
40 | - FMT(XRGB8888, 8, 8, 8, 8, 1, 0, 2, 3, false, true, 4, 4), | |
41 | - FMT(RGB888, 0, 8, 8, 8, 1, 0, 2, 0, false, true, 3, 3), | |
42 | - FMT(BGR888, 0, 8, 8, 8, 2, 0, 1, 0, false, true, 3, 3), | |
43 | - FMT(RGB565, 0, 5, 6, 5, 1, 0, 2, 0, false, true, 2, 3), | |
44 | - FMT(BGR565, 0, 5, 6, 5, 2, 0, 1, 0, false, true, 2, 3), | |
45 | -}; | |
46 | - | |
47 | -uint32_t mdp4_get_formats(enum mdp4_pipe pipe_id, uint32_t *pixel_formats, | |
48 | - uint32_t max_formats) | |
49 | -{ | |
50 | - uint32_t i; | |
51 | - for (i = 0; i < ARRAY_SIZE(formats); i++) { | |
52 | - const struct mdp4_format *f = &formats[i]; | |
53 | - | |
54 | - if (i == max_formats) | |
55 | - break; | |
56 | - | |
57 | - pixel_formats[i] = f->base.pixel_format; | |
58 | - } | |
59 | - | |
60 | - return i; | |
61 | -} | |
62 | - | |
63 | -const struct msm_format *mdp4_get_format(struct msm_kms *kms, uint32_t format) | |
64 | -{ | |
65 | - int i; | |
66 | - for (i = 0; i < ARRAY_SIZE(formats); i++) { | |
67 | - const struct mdp4_format *f = &formats[i]; | |
68 | - if (f->base.pixel_format == format) | |
69 | - return &f->base; | |
70 | - } | |
71 | - return NULL; | |
72 | -} |
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
... | ... | @@ -155,7 +155,7 @@ |
155 | 155 | .irq = mdp4_irq, |
156 | 156 | .enable_vblank = mdp4_enable_vblank, |
157 | 157 | .disable_vblank = mdp4_disable_vblank, |
158 | - .get_format = mdp4_get_format, | |
158 | + .get_format = mdp_get_format, | |
159 | 159 | .round_pixclk = mdp4_round_pixclk, |
160 | 160 | .preclose = mdp4_preclose, |
161 | 161 | .destroy = mdp4_destroy, |
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
... | ... | @@ -18,12 +18,8 @@ |
18 | 18 | #ifndef __MDP4_KMS_H__ |
19 | 19 | #define __MDP4_KMS_H__ |
20 | 20 | |
21 | -#include <linux/clk.h> | |
22 | -#include <linux/platform_device.h> | |
23 | -#include <linux/regulator/consumer.h> | |
24 | - | |
25 | 21 | #include "msm_drv.h" |
26 | -#include "mdp/mdp_common.xml.h" | |
22 | +#include "mdp/mdp_kms.h" | |
27 | 23 | #include "mdp4.xml.h" |
28 | 24 | |
29 | 25 | |
... | ... | @@ -74,16 +70,6 @@ |
74 | 70 | uint32_t max_clk; |
75 | 71 | }; |
76 | 72 | |
77 | -struct mdp4_format { | |
78 | - struct msm_format base; | |
79 | - enum mdp_bpc bpc_r, bpc_g, bpc_b; | |
80 | - enum mdp_bpc_alpha bpc_a; | |
81 | - uint8_t unpack[4]; | |
82 | - bool alpha_enable, unpack_tight; | |
83 | - uint8_t cpp, unpack_count; | |
84 | -}; | |
85 | -#define to_mdp4_format(x) container_of(x, struct mdp4_format, base) | |
86 | - | |
87 | 73 | static inline void mdp4_write(struct mdp4_kms *mdp4_kms, u32 reg, u32 data) |
88 | 74 | { |
89 | 75 | msm_writel(data, mdp4_kms->mmio + reg); |
... | ... | @@ -189,9 +175,15 @@ |
189 | 175 | int mdp4_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc); |
190 | 176 | void mdp4_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc); |
191 | 177 | |
192 | -uint32_t mdp4_get_formats(enum mdp4_pipe pipe_id, uint32_t *formats, | |
193 | - uint32_t max_formats); | |
194 | -const struct msm_format *mdp4_get_format(struct msm_kms *kms, uint32_t format); | |
178 | +static inline | |
179 | +uint32_t mdp4_get_formats(enum mdp4_pipe pipe_id, uint32_t *pixel_formats, | |
180 | + uint32_t max_formats) | |
181 | +{ | |
182 | + /* TODO when we have YUV, we need to filter supported formats | |
183 | + * based on pipe_id.. | |
184 | + */ | |
185 | + return mdp_get_formats(pixel_formats, max_formats); | |
186 | +} | |
195 | 187 | |
196 | 188 | void mdp4_plane_install_properties(struct drm_plane *plane, |
197 | 189 | struct drm_mode_object *obj); |
drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
... | ... | @@ -132,7 +132,7 @@ |
132 | 132 | struct mdp4_plane *mdp4_plane = to_mdp4_plane(plane); |
133 | 133 | struct mdp4_kms *mdp4_kms = get_kms(plane); |
134 | 134 | enum mdp4_pipe pipe = mdp4_plane->pipe; |
135 | - const struct mdp4_format *format; | |
135 | + const struct mdp_format *format; | |
136 | 136 | uint32_t op_mode = 0; |
137 | 137 | uint32_t phasex_step = MDP4_VG_PHASE_STEP_DEFAULT; |
138 | 138 | uint32_t phasey_step = MDP4_VG_PHASE_STEP_DEFAULT; |
... | ... | @@ -175,7 +175,7 @@ |
175 | 175 | |
176 | 176 | mdp4_plane_set_scanout(plane, fb); |
177 | 177 | |
178 | - format = to_mdp4_format(msm_framebuffer_format(fb)); | |
178 | + format = to_mdp_format(msm_framebuffer_format(fb)); | |
179 | 179 | |
180 | 180 | mdp4_write(mdp4_kms, REG_MDP4_PIPE_SRC_FORMAT(pipe), |
181 | 181 | MDP4_PIPE_SRC_FORMAT_A_BPC(format->bpc_a) | |
drivers/gpu/drm/msm/mdp/mdp_format.c
1 | +/* | |
2 | + * Copyright (C) 2013 Red Hat | |
3 | + * Author: Rob Clark <robdclark@gmail.com> | |
4 | + * | |
5 | + * This program is free software; you can redistribute it and/or modify it | |
6 | + * under the terms of the GNU General Public License version 2 as published by | |
7 | + * the Free Software Foundation. | |
8 | + * | |
9 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | + * more details. | |
13 | + * | |
14 | + * You should have received a copy of the GNU General Public License along with | |
15 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | + */ | |
17 | + | |
18 | + | |
19 | +#include "msm_drv.h" | |
20 | +#include "mdp_kms.h" | |
21 | + | |
22 | +#define FMT(name, a, r, g, b, e0, e1, e2, e3, alpha, tight, c, cnt) { \ | |
23 | + .base = { .pixel_format = DRM_FORMAT_ ## name }, \ | |
24 | + .bpc_a = BPC ## a ## A, \ | |
25 | + .bpc_r = BPC ## r, \ | |
26 | + .bpc_g = BPC ## g, \ | |
27 | + .bpc_b = BPC ## b, \ | |
28 | + .unpack = { e0, e1, e2, e3 }, \ | |
29 | + .alpha_enable = alpha, \ | |
30 | + .unpack_tight = tight, \ | |
31 | + .cpp = c, \ | |
32 | + .unpack_count = cnt, \ | |
33 | + } | |
34 | + | |
35 | +#define BPC0A 0 | |
36 | + | |
37 | +static const struct mdp_format formats[] = { | |
38 | + /* name a r g b e0 e1 e2 e3 alpha tight cpp cnt */ | |
39 | + FMT(ARGB8888, 8, 8, 8, 8, 1, 0, 2, 3, true, true, 4, 4), | |
40 | + FMT(XRGB8888, 8, 8, 8, 8, 1, 0, 2, 3, false, true, 4, 4), | |
41 | + FMT(RGB888, 0, 8, 8, 8, 1, 0, 2, 0, false, true, 3, 3), | |
42 | + FMT(BGR888, 0, 8, 8, 8, 2, 0, 1, 0, false, true, 3, 3), | |
43 | + FMT(RGB565, 0, 5, 6, 5, 1, 0, 2, 0, false, true, 2, 3), | |
44 | + FMT(BGR565, 0, 5, 6, 5, 2, 0, 1, 0, false, true, 2, 3), | |
45 | +}; | |
46 | + | |
47 | +uint32_t mdp_get_formats(uint32_t *pixel_formats, uint32_t max_formats) | |
48 | +{ | |
49 | + uint32_t i; | |
50 | + for (i = 0; i < ARRAY_SIZE(formats); i++) { | |
51 | + const struct mdp_format *f = &formats[i]; | |
52 | + | |
53 | + if (i == max_formats) | |
54 | + break; | |
55 | + | |
56 | + pixel_formats[i] = f->base.pixel_format; | |
57 | + } | |
58 | + | |
59 | + return i; | |
60 | +} | |
61 | + | |
62 | +const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format) | |
63 | +{ | |
64 | + int i; | |
65 | + for (i = 0; i < ARRAY_SIZE(formats); i++) { | |
66 | + const struct mdp_format *f = &formats[i]; | |
67 | + if (f->base.pixel_format == format) | |
68 | + return &f->base; | |
69 | + } | |
70 | + return NULL; | |
71 | +} |
drivers/gpu/drm/msm/mdp/mdp_kms.h
1 | +/* | |
2 | + * Copyright (C) 2013 Red Hat | |
3 | + * Author: Rob Clark <robdclark@gmail.com> | |
4 | + * | |
5 | + * This program is free software; you can redistribute it and/or modify it | |
6 | + * under the terms of the GNU General Public License version 2 as published by | |
7 | + * the Free Software Foundation. | |
8 | + * | |
9 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | + * more details. | |
13 | + * | |
14 | + * You should have received a copy of the GNU General Public License along with | |
15 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | + */ | |
17 | + | |
18 | +#ifndef __MDP_KMS_H__ | |
19 | +#define __MDP_KMS_H__ | |
20 | + | |
21 | +#include <linux/clk.h> | |
22 | +#include <linux/platform_device.h> | |
23 | +#include <linux/regulator/consumer.h> | |
24 | + | |
25 | +#include "msm_drv.h" | |
26 | +#include "mdp_common.xml.h" | |
27 | + | |
28 | +struct mdp_format { | |
29 | + struct msm_format base; | |
30 | + enum mdp_bpc bpc_r, bpc_g, bpc_b; | |
31 | + enum mdp_bpc_alpha bpc_a; | |
32 | + uint8_t unpack[4]; | |
33 | + bool alpha_enable, unpack_tight; | |
34 | + uint8_t cpp, unpack_count; | |
35 | +}; | |
36 | +#define to_mdp_format(x) container_of(x, struct mdp_format, base) | |
37 | + | |
38 | + | |
39 | +uint32_t mdp_get_formats(uint32_t *formats, uint32_t max_formats); | |
40 | +const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format); | |
41 | + | |
42 | +#endif /* __MDP_KMS_H__ */ |