Skip to content

Commit 7863ac5

Browse files
author
Laurent Pinchart
committed
drm: rcar-du: Add tri-planar memory formats support
Those formats are supported on Gen3 only. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
1 parent fee8abc commit 7863ac5

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

drivers/gpu/drm/rcar-du/rcar_du_kms.c

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,44 @@ static const struct rcar_du_format_info rcar_du_format_infos[] = {
9090
.pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
9191
.edf = PnDDCR4_EDF_NONE,
9292
}, {
93-
/* In YUV 4:2:2, only NV16 is supported (NV61 isn't) */
9493
.fourcc = DRM_FORMAT_NV16,
9594
.bpp = 16,
9695
.planes = 2,
9796
.pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
9897
.edf = PnDDCR4_EDF_NONE,
9998
},
99+
/* The following formats are not supported on Gen2 and thus have no
100+
* associated .pnmr or .edf settings.
101+
*/
102+
{
103+
.fourcc = DRM_FORMAT_NV61,
104+
.bpp = 16,
105+
.planes = 2,
106+
}, {
107+
.fourcc = DRM_FORMAT_YUV420,
108+
.bpp = 12,
109+
.planes = 3,
110+
}, {
111+
.fourcc = DRM_FORMAT_YVU420,
112+
.bpp = 12,
113+
.planes = 3,
114+
}, {
115+
.fourcc = DRM_FORMAT_YUV422,
116+
.bpp = 16,
117+
.planes = 3,
118+
}, {
119+
.fourcc = DRM_FORMAT_YVU422,
120+
.bpp = 16,
121+
.planes = 3,
122+
}, {
123+
.fourcc = DRM_FORMAT_YUV444,
124+
.bpp = 24,
125+
.planes = 3,
126+
}, {
127+
.fourcc = DRM_FORMAT_YVU444,
128+
.bpp = 24,
129+
.planes = 3,
130+
},
100131
};
101132

102133
const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc)
@@ -144,6 +175,7 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
144175
unsigned int max_pitch;
145176
unsigned int align;
146177
unsigned int bpp;
178+
unsigned int i;
147179

148180
format = rcar_du_format_info(mode_cmd->pixel_format);
149181
if (format == NULL) {
@@ -156,7 +188,7 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
156188
* The pitch and alignment constraints are expressed in pixels on the
157189
* hardware side and in bytes in the DRM API.
158190
*/
159-
bpp = format->planes == 2 ? 1 : format->bpp / 8;
191+
bpp = format->planes == 1 ? format->bpp / 8 : 1;
160192
max_pitch = 4096 * bpp;
161193

162194
if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B))
@@ -171,8 +203,8 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
171203
return ERR_PTR(-EINVAL);
172204
}
173205

174-
if (format->planes == 2) {
175-
if (mode_cmd->pitches[1] != mode_cmd->pitches[0]) {
206+
for (i = 1; i < format->planes; ++i) {
207+
if (mode_cmd->pitches[i] != mode_cmd->pitches[0]) {
176208
dev_dbg(dev->dev,
177209
"luma and chroma pitches do not match\n");
178210
return ERR_PTR(-EINVAL);

drivers/gpu/drm/rcar-du/rcar_du_vsp.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ static const u32 formats_kms[] = {
106106
DRM_FORMAT_NV21,
107107
DRM_FORMAT_NV16,
108108
DRM_FORMAT_NV61,
109+
DRM_FORMAT_YUV420,
110+
DRM_FORMAT_YVU420,
111+
DRM_FORMAT_YUV422,
112+
DRM_FORMAT_YVU422,
113+
DRM_FORMAT_YUV444,
114+
DRM_FORMAT_YVU444,
109115
};
110116

111117
static const u32 formats_v4l2[] = {
@@ -129,14 +135,19 @@ static const u32 formats_v4l2[] = {
129135
V4L2_PIX_FMT_NV21M,
130136
V4L2_PIX_FMT_NV16M,
131137
V4L2_PIX_FMT_NV61M,
138+
V4L2_PIX_FMT_YUV420M,
139+
V4L2_PIX_FMT_YVU420M,
140+
V4L2_PIX_FMT_YUV422M,
141+
V4L2_PIX_FMT_YVU422M,
142+
V4L2_PIX_FMT_YUV444M,
143+
V4L2_PIX_FMT_YVU444M,
132144
};
133145

134146
static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
135147
{
136148
struct rcar_du_vsp_plane_state *state =
137149
to_rcar_vsp_plane_state(plane->plane.state);
138150
struct drm_framebuffer *fb = plane->plane.state->fb;
139-
struct drm_gem_cma_object *gem;
140151
struct v4l2_rect src;
141152
struct v4l2_rect dst;
142153
dma_addr_t paddr[2] = { 0, };
@@ -153,12 +164,11 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
153164
dst.width = state->state.crtc_w;
154165
dst.height = state->state.crtc_h;
155166

156-
gem = drm_fb_cma_get_gem_obj(fb, 0);
157-
paddr[0] = gem->paddr + fb->offsets[0];
167+
for (i = 0; i < state->format->planes; ++i) {
168+
struct drm_gem_cma_object *gem;
158169

159-
if (state->format->planes == 2) {
160-
gem = drm_fb_cma_get_gem_obj(fb, 1);
161-
paddr[1] = gem->paddr + fb->offsets[1];
170+
gem = drm_fb_cma_get_gem_obj(fb, i);
171+
paddr[i] = gem->paddr + fb->offsets[i];
162172
}
163173

164174
for (i = 0; i < ARRAY_SIZE(formats_kms); ++i) {

0 commit comments

Comments
 (0)