Skip to content

Commit d484c20

Browse files
bparrottomba
authored andcommitted
drm/omap: Add ability to check if requested plane modes can be supported
We currently assume that an overlay has the same maximum width and maximum height as the overlay manager. This assumption is incorrect. On some variants the overlay manager maximum width is twice the maximum width that the overlay can handle. We need to add the appropriate data per variant as well as export a helper function to retrieve the data so check can be made dynamically in omap_plane_atomic_check(). Signed-off-by: Benoit Parrot <[email protected]> Signed-off-by: Neil Armstrong <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Signed-off-by: Tomi Valkeinen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c21134b commit d484c20

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

drivers/gpu/drm/omapdrm/dss/dispc.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ struct dispc_features {
9292
u8 mgr_height_start;
9393
u16 mgr_width_max;
9494
u16 mgr_height_max;
95+
u16 ovl_width_max;
96+
u16 ovl_height_max;
9597
unsigned long max_lcd_pclk;
9698
unsigned long max_tv_pclk;
9799
unsigned int max_downscale;
@@ -2599,6 +2601,12 @@ static int dispc_ovl_calc_scaling(struct dispc_device *dispc,
25992601
return 0;
26002602
}
26012603

2604+
void dispc_ovl_get_max_size(struct dispc_device *dispc, u16 *width, u16 *height)
2605+
{
2606+
*width = dispc->feat->ovl_width_max;
2607+
*height = dispc->feat->ovl_height_max;
2608+
}
2609+
26022610
static int dispc_ovl_setup_common(struct dispc_device *dispc,
26032611
enum omap_plane_id plane,
26042612
enum omap_overlay_caps caps,
@@ -4240,6 +4248,8 @@ static const struct dispc_features omap24xx_dispc_feats = {
42404248
.mgr_height_start = 26,
42414249
.mgr_width_max = 2048,
42424250
.mgr_height_max = 2048,
4251+
.ovl_width_max = 2048,
4252+
.ovl_height_max = 2048,
42434253
.max_lcd_pclk = 66500000,
42444254
.max_downscale = 2,
42454255
/*
@@ -4278,6 +4288,8 @@ static const struct dispc_features omap34xx_rev1_0_dispc_feats = {
42784288
.mgr_height_start = 26,
42794289
.mgr_width_max = 2048,
42804290
.mgr_height_max = 2048,
4291+
.ovl_width_max = 2048,
4292+
.ovl_height_max = 2048,
42814293
.max_lcd_pclk = 173000000,
42824294
.max_tv_pclk = 59000000,
42834295
.max_downscale = 4,
@@ -4313,6 +4325,8 @@ static const struct dispc_features omap34xx_rev3_0_dispc_feats = {
43134325
.mgr_height_start = 26,
43144326
.mgr_width_max = 2048,
43154327
.mgr_height_max = 2048,
4328+
.ovl_width_max = 2048,
4329+
.ovl_height_max = 2048,
43164330
.max_lcd_pclk = 173000000,
43174331
.max_tv_pclk = 59000000,
43184332
.max_downscale = 4,
@@ -4348,6 +4362,8 @@ static const struct dispc_features omap36xx_dispc_feats = {
43484362
.mgr_height_start = 26,
43494363
.mgr_width_max = 2048,
43504364
.mgr_height_max = 2048,
4365+
.ovl_width_max = 2048,
4366+
.ovl_height_max = 2048,
43514367
.max_lcd_pclk = 173000000,
43524368
.max_tv_pclk = 59000000,
43534369
.max_downscale = 4,
@@ -4383,6 +4399,8 @@ static const struct dispc_features am43xx_dispc_feats = {
43834399
.mgr_height_start = 26,
43844400
.mgr_width_max = 2048,
43854401
.mgr_height_max = 2048,
4402+
.ovl_width_max = 2048,
4403+
.ovl_height_max = 2048,
43864404
.max_lcd_pclk = 173000000,
43874405
.max_tv_pclk = 59000000,
43884406
.max_downscale = 4,
@@ -4418,6 +4436,8 @@ static const struct dispc_features omap44xx_dispc_feats = {
44184436
.mgr_height_start = 26,
44194437
.mgr_width_max = 2048,
44204438
.mgr_height_max = 2048,
4439+
.ovl_width_max = 2048,
4440+
.ovl_height_max = 2048,
44214441
.max_lcd_pclk = 170000000,
44224442
.max_tv_pclk = 185625000,
44234443
.max_downscale = 4,
@@ -4457,6 +4477,8 @@ static const struct dispc_features omap54xx_dispc_feats = {
44574477
.mgr_height_start = 27,
44584478
.mgr_width_max = 4096,
44594479
.mgr_height_max = 4096,
4480+
.ovl_width_max = 2048,
4481+
.ovl_height_max = 4096,
44604482
.max_lcd_pclk = 170000000,
44614483
.max_tv_pclk = 192000000,
44624484
.max_downscale = 4,

drivers/gpu/drm/omapdrm/dss/dss.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ int dispc_get_num_mgrs(struct dispc_device *dispc);
397397
const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
398398
enum omap_plane_id plane);
399399

400+
void dispc_ovl_get_max_size(struct dispc_device *dispc, u16 *width, u16 *height);
401+
400402
u32 dispc_read_irqstatus(struct dispc_device *dispc);
401403
void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
402404
void dispc_write_irqenable(struct dispc_device *dispc, u32 mask);

drivers/gpu/drm/omapdrm/omap_plane.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,19 @@ static int omap_plane_atomic_check(struct drm_plane *plane,
111111
{
112112
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
113113
plane);
114+
struct omap_drm_private *priv = plane->dev->dev_private;
114115
struct drm_crtc_state *crtc_state;
116+
u32 max_width, max_height;
117+
u16 width, height;
115118
int ret;
116119

117120
if (!new_plane_state->fb)
118121
return 0;
119122

123+
dispc_ovl_get_max_size(priv->dispc, &width, &height);
124+
max_width = width << 16;
125+
max_height = height << 16;
126+
120127
/* crtc should only be NULL when disabling (i.e., !new_plane_state->fb) */
121128
if (WARN_ON(!new_plane_state->crtc))
122129
return 0;
@@ -151,6 +158,13 @@ static int omap_plane_atomic_check(struct drm_plane *plane,
151158
if (new_plane_state->crtc_y + new_plane_state->crtc_h > crtc_state->adjusted_mode.vdisplay)
152159
return -EINVAL;
153160

161+
/* Make sure dimensions are within bounds. */
162+
if (new_plane_state->src_h > max_height || new_plane_state->crtc_h > height)
163+
return -EINVAL;
164+
165+
if (new_plane_state->src_w > max_width || new_plane_state->crtc_w > width)
166+
return -EINVAL;
167+
154168
if (new_plane_state->rotation != DRM_MODE_ROTATE_0 &&
155169
!omap_framebuffer_supports_rotation(new_plane_state->fb))
156170
return -EINVAL;

0 commit comments

Comments
 (0)