drm/omap: Add virtual-planes support
Subsystems (3)
v7 cover drm/omap: Add virtual-planes support
This patchset is the follow-up the v4 patchset from Benoit Parrot at [1].
This patch series adds virtual-plane support to omapdrm driver to allow the use of display wider than 2048 pixels.
In order to do so we introduce the concept of hw_overlay which can then be dynamically allocated to a plane. When the requested output width exceed what be supported by one overlay a second is then allocated if possible to handle display wider then 2048.
This series replaces an earlier series which was DT based and using statically allocated resources.
This implementation is inspired from the work done in msm/disp/mdp5 driver.
Changes since v6 at [3]:
- Patch 1: Added comment for drm_atomic_helper_check_plane_state, added Reviewed-by
- Patch 2: added Reviewed-by
- Patch 3: added Reviewed-by
- Patch 4: added Reviewed-by
- Patch 5: added Reviewed-by
- Patch 6: No changes
- Patch 7: No changes
- Patch 8: Reformatted omap_plane_atomic_print_state() output for overlays
- Patch 9: Added a comment of the utility of the local omap_atomic_update_normalize_zpos() + atomic_print_state() reformat
Changes since v5 at [2]:
- Patch 1: renamed width/height_fp to max_width/height
- Patch 2: no changes
- Patch 3: removed possible_crtcs stuff,
added cleanup on failure to allocate,
removed name in omap_plane struct & plane_id_to_name in omap_plane.c,
switched all omap_plane->name to plane->name or omap_plane->id
- Patch 4: aligned omap_plane_atomic_duplicate_state the the crtc style
- Patch 5: removed glob_obj_lock & reformated global state declaration in omap_drv.h
- Patch 6: moved drm_atomic_helper_check_plane_state() from atomic_check() in separate commit, removed zpos change, updated debug messages to be useful,
renamed omap_overlay_disable() to omap_overlay_update_state(),
added useful comments for omap_overlay_assign() & omap_overlay_update_state(), simplified omap_overlay_assign() & omap_overlay_update_state() for actual use-cases, refactored omap_plane_atomic_check() changes to be cleaner & simpler
- Patch 7: no changes (except possible_crtcs print removal)
- Patch 8: Reformated omap_plane_atomic_check() & omap_overlay_assign() changes to match previous patches layout
Changes since v4 at [1]:
- rebased on v5.15-rc2
- adapted to drm_atomic_get_new/old_plane_state()
- tested on Beagle-x15
- checked for non-regression on Beagle-x15
- removed unused "state" variable in omap_global_state
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]
Benoit Parrot (8):
drm/omap: Add ability to check if requested plane modes can be
supported
drm/omap: Add ovl checking funcs to dispc_ops drm/omap: introduce omap_hw_overlay
drm/omap: omap_plane: subclass drm_plane_state drm/omap: Add global state as a private atomic object drm/omap: dynamically assign hw overlays to planes drm/omap: add plane_atomic_print_state support drm/omap: Add a 'right overlay' to plane state
Neil Armstrong (1):
drm/omap: add sanity plane state check
drivers/gpu/drm/omapdrm/Makefile | 1 + drivers/gpu/drm/omapdrm/dss/dispc.c | 31 ++- drivers/gpu/drm/omapdrm/dss/dss.h | 5 + drivers/gpu/drm/omapdrm/omap_drv.c | 196 +++++++++++++- drivers/gpu/drm/omapdrm/omap_drv.h | 24 ++ drivers/gpu/drm/omapdrm/omap_fb.c | 33 ++- drivers/gpu/drm/omapdrm/omap_fb.h | 4 +- drivers/gpu/drm/omapdrm/omap_overlay.c | 212 +++++++++++++++ drivers/gpu/drm/omapdrm/omap_overlay.h | 35 +++ drivers/gpu/drm/omapdrm/omap_plane.c | 349 +++++++++++++++++++++---- drivers/gpu/drm/omapdrm/omap_plane.h | 1 + 11 files changed, 832 insertions(+), 59 deletions(-) create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.c create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.h
base-commit: 49c39ec4670a8f045729e3717af2e1a74caf89a5
Signature · 1 line
2.25.1
PATCH v7 1/9 drm/omap: add sanity plane state check
Call drm_atomic_helper_check_plane_state() from the plane atomic_check() callback in order to add plane state sanity checking.
It will permit filtering out totally bad scaling factors, even if the real check are done later in the atomic commit.
Calling drm_atomic_helper_check_plane_state() also sets plane_state->visible which will be useful when dynamically assigning hw overlays to planes.
--- drivers/gpu/drm/omapdrm/omap_plane.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/gpu/drm/omapdrm/omap_plane.c +15 -0
@@ -104,12 +104,15 @@ static void omap_plane_atomic_disable(struct drm_plane *plane,dispc_ovl_enable (priv->dispc, omap_plane->id, false); } +#define FRAC_16_16 (mult, div) (((mult) << 16) / (div)) +static int omap_plane_atomic_check (struct drm_plane *plane,struct drm_atomic_state *state) {struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (state, plane);struct drm_crtc_state *crtc_state; +int ret;if (!new_plane_state->fb)return 0 ;
@@ -127,6 +130,18 @@ static int omap_plane_atomic_check(struct drm_plane *plane,if (!crtc_state->enable)return 0 ; +/* +* Note: these are just sanity checks to filter out totally bad scaling +* factors. The real limits must be calculated case by case, and +* unfortunately we currently do those checks only at the commit +* phase in dispc. +*/ + ret =drm_atomic_helper_check_plane_state (new_plane_state, crtc_state, +FRAC_16_16 (1 ,8 ),FRAC_16_16 (8 ,1 ), + true, true); +if (ret) +return ret; +if (new_plane_state->crtc_x <0 || new_plane_state->crtc_y <0 )return -EINVAL ;
Signature · 1 line
2.25.1
PATCH v7 2/9 drm/omap: Add ability to check if requested plane modes can be supported
In reply to Neil ArmstrongFrom: Benoit Parrot <[email protected]>
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().
--- drivers/gpu/drm/omapdrm/dss/dispc.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/omapdrm/dss/dss.h | 2 ++ drivers/gpu/drm/omapdrm/omap_plane.c | 14 ++++++++++++++ 3 files changed, 38 insertions(+)
drivers/gpu/drm/omapdrm/dss/dispc.c +22 -0
@@ -92,6 +92,8 @@ struct dispc_features {u8 mgr_height_start;u16 mgr_width_max;u16 mgr_height_max; +u16 ovl_width_max; +u16 ovl_height_max;unsigned long max_lcd_pclk;unsigned long max_tv_pclk;unsigned int max_downscale;
@@ -2599,6 +2601,12 @@ static int dispc_ovl_calc_scaling(struct dispc_device *dispc,return 0 ; } +void dispc_ovl_get_max_size (struct dispc_device *dispc,u16 *width,u16 *height) +{ + *width = dispc->feat->ovl_width_max; + *height = dispc->feat->ovl_height_max; +} + static int dispc_ovl_setup_common(struct dispc_device *dispc, enum omap_plane_id plane, enum omap_overlay_caps caps,
@@ -4240,6 +4248,8 @@ static const struct dispc_features omap24xx_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 66500000, .max_downscale = 2,/*
@@ -4278,6 +4288,8 @@ static const struct dispc_features omap34xx_rev1_0_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 173000000, .max_tv_pclk = 59000000, .max_downscale = 4,
@@ -4313,6 +4325,8 @@ static const struct dispc_features omap34xx_rev3_0_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 173000000, .max_tv_pclk = 59000000, .max_downscale = 4,
@@ -4348,6 +4362,8 @@ static const struct dispc_features omap36xx_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 173000000, .max_tv_pclk = 59000000, .max_downscale = 4,
@@ -4383,6 +4399,8 @@ static const struct dispc_features am43xx_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 173000000, .max_tv_pclk = 59000000, .max_downscale = 4,
@@ -4418,6 +4436,8 @@ static const struct dispc_features omap44xx_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 170000000, .max_tv_pclk = 185625000, .max_downscale = 4,
@@ -4457,6 +4477,8 @@ static const struct dispc_features omap54xx_dispc_feats = { .mgr_height_start = 27, .mgr_width_max = 4096, .mgr_height_max = 4096, + .ovl_width_max = 2048, + .ovl_height_max = 4096, .max_lcd_pclk = 170000000, .max_tv_pclk = 192000000, .max_downscale = 4,
drivers/gpu/drm/omapdrm/dss/dss.h +2 -0
@@ -397,6 +397,8 @@ int dispc_get_num_mgrs(struct dispc_device *dispc);const u32 *dispc_ovl_get_color_modes (struct dispc_device *dispc,enum omap_plane_id plane); +void dispc_ovl_get_max_size (struct dispc_device *dispc,u16 *width,u16 *height); +u32 dispc_read_irqstatus (struct dispc_device *dispc);void dispc_clear_irqstatus (struct dispc_device *dispc,u32 mask);void dispc_write_irqenable (struct dispc_device *dispc,u32 mask);
drivers/gpu/drm/omapdrm/omap_plane.c +14 -0
@@ -111,12 +111,19 @@ static int omap_plane_atomic_check(struct drm_plane *plane, {struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (state, plane); +struct omap_drm_private *priv = plane->dev->dev_private;struct drm_crtc_state *crtc_state; +u32 max_width, max_height; +u16 width, height;int ret;if (!new_plane_state->fb)return 0 ; +dispc_ovl_get_max_size (priv->dispc, &width, &height); + max_width = width <<16 ; + max_height = height <<16 ; +/* crtc should only be NULL when disabling (i.e., !new_plane_state->fb) */ if (WARN_ON (!new_plane_state->crtc))return 0 ;
@@ -151,6 +158,13 @@ static int omap_plane_atomic_check(struct drm_plane *plane,if (new_plane_state->crtc_y + new_plane_state->crtc_h > crtc_state->adjusted_mode.vdisplay)return -EINVAL ; +/* Make sure dimensions are within bounds. */ +if (new_plane_state->src_h > max_height || new_plane_state->crtc_h > height) +return -EINVAL ; + +if (new_plane_state->src_w > max_width || new_plane_state->crtc_w > width) +return -EINVAL ; +if (new_plane_state->rotation !=DRM_MODE_ROTATE_0 && !omap_framebuffer_supports_rotation (new_plane_state->fb))return -EINVAL ;
Signature · 1 line
2.25.1
PATCH v7 3/9 drm/omap: Add ovl checking funcs to dispc_ops
In reply to Neil ArmstrongFrom: Benoit Parrot <[email protected]>
In order to be able to dynamically assign overlays to planes we need to be able to asses the overlay capabilities.
Add a helper function to be able to retrieve the supported capabilities of an overlay.
And export the function to check if a fourcc is supported on a given overlay.
--- drivers/gpu/drm/omapdrm/dss/dispc.c | 9 +++++++-- drivers/gpu/drm/omapdrm/dss/dss.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/omapdrm/dss/dispc.c +7 -2
@@ -1281,8 +1281,8 @@ static u32 dispc_ovl_get_burst_size(struct dispc_device *dispc,return dispc->feat->burst_size_unit *8 ; } -static bool dispc_ovl_color_mode_supported (struct dispc_device *dispc, -enum omap_plane_id plane,u32 fourcc) +bool dispc_ovl_color_mode_supported (struct dispc_device *dispc, +enum omap_plane_id plane,u32 fourcc) {const u32 *modes;unsigned int i;
@@ -2489,6 +2489,11 @@ static int dispc_ovl_calc_scaling_44xx(struct dispc_device *dispc,return 0 ; } +enum omap_overlay_caps dispc_ovl_get_caps (struct dispc_device *dispc,enum omap_plane_id plane) +{ +return dispc->feat->overlay_caps[plane]; +} +#define DIV_FRAC (dividend, divisor) \ ((dividend) * 100 / (divisor) - ((dividend) / (divisor) * 100))
drivers/gpu/drm/omapdrm/dss/dss.h +3 -0
@@ -398,6 +398,9 @@ const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc, enum omap_plane_id plane);void dispc_ovl_get_max_size (struct dispc_device *dispc,u16 *width,u16 *height); +bool dispc_ovl_color_mode_supported (struct dispc_device *dispc, +enum omap_plane_id plane,u32 fourcc); +enum omap_overlay_caps dispc_ovl_get_caps (struct dispc_device *dispc,enum omap_plane_id plane);u32 dispc_read_irqstatus (struct dispc_device *dispc);void dispc_clear_irqstatus (struct dispc_device *dispc,u32 mask);
Signature · 1 line
2.25.1
PATCH v7 4/9 drm/omap: introduce omap_hw_overlay
In reply to Neil ArmstrongFrom: Benoit Parrot <[email protected]>
Split out the hardware overlay specifics from omap_plane. To start, the hw overlays are statically assigned to planes.
The goal is to eventually assign hw overlays dynamically to planes during plane->atomic_check() based on requested caps (scaling, YUV, etc). And then perform hw overlay re-assignment if required.
--- drivers/gpu/drm/omapdrm/Makefile | 1 + drivers/gpu/drm/omapdrm/omap_drv.c | 9 ++- drivers/gpu/drm/omapdrm/omap_drv.h | 4 ++ drivers/gpu/drm/omapdrm/omap_overlay.c | 84 ++++++++++++++++++++++++++ drivers/gpu/drm/omapdrm/omap_overlay.h | 30 +++++++++ drivers/gpu/drm/omapdrm/omap_plane.c | 54 +++++++---------- 6 files changed, 148 insertions(+), 34 deletions(-) create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.c create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.h
drivers/gpu/drm/omapdrm/Makefile +1 -0
@@ -9,6 +9,7 @@ omapdrm-y := omap_drv.o \ omap_debugfs.o \ omap_crtc.o \ omap_plane.o \ + omap_overlay.o \ omap_encoder.o \ omap_fb.o \ omap_gem.o \
drivers/gpu/drm/omapdrm/omap_drv.c +8 -1
@@ -583,10 +583,14 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)omap_gem_init (ddev); + ret =omap_hwoverlays_init (priv); +if (ret) + goto err_gem_deinit; + ret =omap_modeset_init (ddev);if (ret) {dev_err (priv->dev,"omap_modeset_init failed: ret=%d\n" , ret); - goto err_gem_deinit; + goto err_free_overlays; }/* Initialize vblank handling, start with all CRTCs disabled. */
@@ -618,6 +622,8 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)omap_fbdev_fini (ddev); err_cleanup_modeset:omap_modeset_fini (ddev); +err_free_overlays: +omap_hwoverlays_destroy (priv); err_gem_deinit:omap_gem_deinit (ddev);destroy_workqueue (priv->wq);
@@ -642,6 +648,7 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)drm_atomic_helper_shutdown (ddev);omap_modeset_fini (ddev); +omap_hwoverlays_destroy (priv);omap_gem_deinit (ddev);destroy_workqueue (priv->wq);
drivers/gpu/drm/omapdrm/omap_drv.h +4 -0
@@ -24,6 +24,7 @@#include "omap_gem.h" #include "omap_irq.h" #include "omap_plane.h" +#include "omap_overlay.h" #define DBG (fmt, ...) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)#define VERB (fmt, ...) if (0) DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__)/* verbose debug */
@@ -57,6 +58,9 @@ struct omap_drm_private {unsigned int num_planes;struct drm_plane *planes[8 ]; +unsigned int num_ovls; +struct omap_hw_overlay *overlays[8 ]; +struct drm_fb_helper *fbdev;struct workqueue_struct *wq;
drivers/gpu/drm/omapdrm/omap_overlay.c new file +84 -0
84 lines not on this page · raw message
drivers/gpu/drm/omapdrm/omap_overlay.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ +* Author: Benoit Parrot <[email protected]> +*/ + +#ifndef __OMAPDRM_OVERLAY_H__ +#define __OMAPDRM_OVERLAY_H__ + +#include <linux/types.h> + +enum drm_plane_type ; + +struct drm_device ; +struct drm_mode_object ; +struct drm_plane ; + +/* Used to associate a HW overlay/plane to a plane */ +struct omap_hw_overlay { +unsigned int idx; + +const char *name; +enum omap_plane_id id; + +enum omap_overlay_caps caps; +}; + +int omap_hwoverlays_init (struct omap_drm_private *priv); +void omap_hwoverlays_destroy (struct omap_drm_private *priv); +#endif /* __OMAPDRM_OVERLAY_H__ */
drivers/gpu/drm/omapdrm/omap_plane.c +21 -33
128 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v7 5/9 drm/omap: omap_plane: subclass drm_plane_state
In reply to Neil ArmstrongFrom: Benoit Parrot <[email protected]>
In preparation to add omap plane state specific extensions we need to subclass drm_plane_state and add the relevant helpers.
The addition of specific extension will be done separately.
--- drivers/gpu/drm/omapdrm/omap_plane.c | 36 +++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-)
drivers/gpu/drm/omapdrm/omap_plane.c +33 -3
@@ -16,6 +16,13 @@* plane funcs */ +#define to_omap_plane_state (x) container_of(x, struct omap_plane_state, base) + +struct omap_plane_state { +/* Must be first. */ +struct drm_plane_state base; +}; +#define to_omap_plane (x) container_of(x, struct omap_plane, base)struct omap_plane {
@@ -221,11 +228,17 @@ void omap_plane_install_properties(struct drm_plane *plane,static void omap_plane_reset (struct drm_plane *plane) {struct omap_plane *omap_plane =to_omap_plane (plane); +struct omap_plane_state *omap_state; -drm_atomic_helper_plane_reset (plane); -if (!plane->state) +if (plane->state) +drm_atomic_helper_plane_destroy_state (plane, plane->state); + + omap_state =kzalloc (sizeof (*omap_state),GFP_KERNEL ); +if (!omap_state)return ; +__drm_atomic_helper_plane_reset (plane, &omap_state->base); +/* * Set the zpos default depending on whether we are a primary or overlay * plane.
@@ -236,6 +249,23 @@ static void omap_plane_reset(struct drm_plane *plane) plane->state->color_range =DRM_COLOR_YCBCR_FULL_RANGE ; } +static struct drm_plane_state * +omap_plane_atomic_duplicate_state (struct drm_plane *plane) +{ +struct omap_plane_state *state; + +if (WARN_ON (!plane->state)) +return NULL ; + + state =kmalloc (sizeof (*state),GFP_KERNEL ); +if (!state) +return NULL ; + +__drm_atomic_helper_plane_duplicate_state (plane, &state->base); + +return &state->base; +} + static int omap_plane_atomic_set_property(struct drm_plane *plane, struct drm_plane_state *state, struct drm_property *property,
@@ -271,7 +301,7 @@ static const struct drm_plane_funcs omap_plane_funcs = { .disable_plane = drm_atomic_helper_disable_plane, .reset = omap_plane_reset, .destroy = omap_plane_destroy, - .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, + .atomic_duplicate_state = omap_plane_atomic_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, .atomic_set_property = omap_plane_atomic_set_property, .atomic_get_property = omap_plane_atomic_get_property,
Signature · 1 line
2.25.1
PATCH v7 6/9 drm/omap: Add global state as a private atomic object
In reply to Neil ArmstrongFrom: Benoit Parrot <[email protected]>
Global shared resources (like hw overlays) for omapdrm are implemented as a part of atomic state using the drm_private_obj infrastructure available in the atomic core.
omap_global_state is introduced as a drm atomic private object. The two funcs omap_get_global_state() and omap_get_existing_global_state() are the two variants that will be used to access omap_global_state.
drm_mode_config_init() needs to be called earlier because it creates/initializes the private_obj link list maintained by the atomic framework. The private_obj link list has to exist prior to calling drm_atomic_private_obj_init(). Similarly the cleanup handler are reordered appropriately.
--- drivers/gpu/drm/omapdrm/omap_drv.c | 91 +++++++++++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_drv.h | 17 ++++++ 2 files changed, 105 insertions(+), 3 deletions(-)
drivers/gpu/drm/omapdrm/omap_drv.c +88 -3
@@ -128,6 +128,82 @@ static const struct drm_mode_config_funcs omap_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit, }; +/* Global/shared object state funcs */ + +/* +* This is a helper that returns the private state currently in operation. +* Note that this would return the "old_state" if called in the atomic check +* path, and the "new_state" after the atomic swap has been done. +*/ +struct omap_global_state * +omap_get_existing_global_state (struct omap_drm_private *priv) +{ +return to_omap_global_state (priv->glob_obj.state); +} + +/* +* This acquires the modeset lock set aside for global state, creates +* a new duplicated private object state. +*/ +struct omap_global_state *__must_check +omap_get_global_state (struct drm_atomic_state *s) +{ +struct omap_drm_private *priv = s->dev->dev_private; +struct drm_private_state *priv_state; + + priv_state =drm_atomic_get_private_obj_state (s, &priv->glob_obj); +if (IS_ERR (priv_state)) +return ERR_CAST (priv_state); + +return to_omap_global_state (priv_state); +} + +static struct drm_private_state * +omap_global_duplicate_state (struct drm_private_obj *obj) +{ +struct omap_global_state *state; + + state =kmemdup (obj->state,sizeof (*state),GFP_KERNEL ); +if (!state) +return NULL ; + +__drm_atomic_helper_private_obj_duplicate_state (obj, &state->base); + +return &state->base; +} + +static void omap_global_destroy_state (struct drm_private_obj *obj, +struct drm_private_state *state) +{ +struct omap_global_state *omap_state =to_omap_global_state (state); + +kfree (omap_state); +} + +static const struct drm_private_state_funcs omap_global_state_funcs = { + .atomic_duplicate_state = omap_global_duplicate_state, + .atomic_destroy_state = omap_global_destroy_state, +}; + +static int omap_global_obj_init (struct drm_device *dev) +{ +struct omap_drm_private *priv = dev->dev_private; +struct omap_global_state *state; + + state =kzalloc (sizeof (*state),GFP_KERNEL ); +if (!state) +return -ENOMEM ; + +drm_atomic_private_obj_init (dev, &priv->glob_obj, &state->base, + &omap_global_state_funcs); +return 0 ; +} + +static void omap_global_obj_fini (struct omap_drm_private *priv) +{ +drm_atomic_private_obj_fini (&priv->glob_obj); +} +static void omap_disconnect_pipelines (struct drm_device *ddev) {struct omap_drm_private *priv = ddev->dev_private;
@@ -231,8 +307,6 @@ static int omap_modeset_init(struct drm_device *dev)if (!omapdss_stack_is_ready ())return -EPROBE_DEFER ; -drm_mode_config_init (dev); - ret =omap_modeset_init_properties (dev);if (ret <0 )return ret;
@@ -583,10 +657,16 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)omap_gem_init (ddev); - ret =omap_hwoverlays_init (priv); +drm_mode_config_init (ddev); + + ret =omap_global_obj_init (ddev);if (ret) goto err_gem_deinit; + ret =omap_hwoverlays_init (priv); +if (ret) + goto err_free_priv_obj; + ret =omap_modeset_init (ddev);if (ret) {dev_err (priv->dev,"omap_modeset_init failed: ret=%d\n" , ret);
@@ -624,7 +704,10 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)omap_modeset_fini (ddev); err_free_overlays:omap_hwoverlays_destroy (priv); +err_free_priv_obj: +omap_global_obj_fini (priv); err_gem_deinit: +drm_mode_config_cleanup (ddev);omap_gem_deinit (ddev);destroy_workqueue (priv->wq);omap_disconnect_pipelines (ddev);
@@ -649,6 +732,8 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)omap_modeset_fini (ddev);omap_hwoverlays_destroy (priv); +omap_global_obj_fini (priv); +drm_mode_config_cleanup (ddev);omap_gem_deinit (ddev);destroy_workqueue (priv->wq);
drivers/gpu/drm/omapdrm/omap_drv.h +17 -0
@@ -14,6 +14,7 @@#include "dss/omapdss.h" #include "dss/dss.h" +#include <drm/drm_atomic.h> #include <drm/drm_gem.h> #include <drm/omap_drm.h>
@@ -41,6 +42,16 @@ struct omap_drm_pipeline {unsigned int alias_id; }; +/* +* Global private object state for tracking resources that are shared across +* multiple kms objects (planes/crtcs/etc). +*/ +#define to_omap_global_state (x) container_of(x, struct omap_global_state, base) + +struct omap_global_state { +struct drm_private_state base; +}; +struct omap_drm_private {struct drm_device *ddev;struct device *dev;
@@ -61,6 +72,8 @@ struct omap_drm_private {unsigned int num_ovls;struct omap_hw_overlay *overlays[8 ]; +struct drm_private_obj glob_obj; +struct drm_fb_helper *fbdev;struct workqueue_struct *wq;
@@ -89,4 +102,8 @@ struct omap_drm_private {void omap_debugfs_init (struct drm_minor *minor); +struct omap_global_state *__must_check omap_get_global_state (struct drm_atomic_state *s); + +struct omap_global_state *omap_get_existing_global_state (struct omap_drm_private *priv); +#endif /* __OMAPDRM_DRV_H__ */
Signature · 1 line
2.25.1
PATCH v7 7/9 drm/omap: dynamically assign hw overlays to planes
In reply to Neil ArmstrongFrom: Benoit Parrot <[email protected]>
(re)assign the hw overlays to planes based on required caps, and to handle situations where we could not modify an in-use plane.
This means all planes advertise the superset of formats and properties. Userspace must (as always) use atomic TEST_ONLY step for atomic updates, as not all planes may be available for use on every frame.
The mapping of hwoverlays to plane is stored in omap_global_state, so that state updates are atomically committed in the same way that plane/etc state updates are managed. This is needed because the omap_plane_state keeps a pointer to the hwoverlay, and we don't want global state to become out of sync with the plane state if an atomic update fails, we hit deadlock/ backoff scenario, etc. The use of global_state_lock keeps multiple parallel updates which both re-assign hwoverlays properly serialized.
--- drivers/gpu/drm/omapdrm/omap_drv.h | 3 + drivers/gpu/drm/omapdrm/omap_overlay.c | 109 +++++++++++++++++++++ drivers/gpu/drm/omapdrm/omap_overlay.h | 4 + drivers/gpu/drm/omapdrm/omap_plane.c | 127 ++++++++++++++++++++----- 4 files changed, 220 insertions(+), 23 deletions(-)
drivers/gpu/drm/omapdrm/omap_drv.h +3 -0
@@ -50,6 +50,9 @@ struct omap_drm_pipeline {struct omap_global_state {struct drm_private_state base; + +/* global atomic state of assignment between overlays and planes */ +struct drm_plane *hwoverlay_to_plane[8 ]; };struct omap_drm_private {
drivers/gpu/drm/omapdrm/omap_overlay.c +109 -0
115 lines not on this page · raw message
drivers/gpu/drm/omapdrm/omap_overlay.h +4 -0
@@ -27,4 +27,8 @@ struct omap_hw_overlay {int omap_hwoverlays_init (struct omap_drm_private *priv);void omap_hwoverlays_destroy (struct omap_drm_private *priv); +int omap_overlay_assign (struct drm_atomic_state *s,struct drm_plane *plane, +u32 caps,u32 fourcc,struct omap_hw_overlay **overlay); +void omap_overlay_release (struct drm_atomic_state *s,struct omap_hw_overlay *overlay); +void omap_overlay_update_state (struct omap_drm_private *priv,struct omap_hw_overlay *overlay);#endif /* __OMAPDRM_OVERLAY_H__ */
drivers/gpu/drm/omapdrm/omap_plane.c +104 -23
235 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v7 8/9 drm/omap: add plane_atomic_print_state support
In reply to Neil ArmstrongFrom: Benoit Parrot <[email protected]>
Now that we added specific item to our subclassed drm_plane_state we can add omap_plane_atomic_print_state() helper to dump out our own driver specific plane state.
--- drivers/gpu/drm/omapdrm/omap_plane.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/drm/omapdrm/omap_plane.c +14 -0
@@ -348,6 +348,19 @@ omap_plane_atomic_duplicate_state(struct drm_plane *plane)return &state->base; } +static void omap_plane_atomic_print_state (struct drm_printer *p, +const struct drm_plane_state *state) +{ +struct omap_plane_state *omap_state =to_omap_plane_state (state); + +if (omap_state->overlay) +drm_printf (p,"\toverlay=%s (caps=0x%x)\n" , + omap_state->overlay->name, + omap_state->overlay->caps); +else +drm_printf (p,"\toverlay=None\n" ); +} + static int omap_plane_atomic_set_property(struct drm_plane *plane, struct drm_plane_state *state, struct drm_property *property,
@@ -387,6 +400,7 @@ static const struct drm_plane_funcs omap_plane_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, .atomic_set_property = omap_plane_atomic_set_property, .atomic_get_property = omap_plane_atomic_get_property, + .atomic_print_state = omap_plane_atomic_print_state, };static bool omap_plane_supports_yuv (struct drm_plane *plane)
Signature · 1 line
2.25.1
PATCH v7 9/9 drm/omap: Add a 'right overlay' to plane state
In reply to Neil ArmstrongFrom: Benoit Parrot <[email protected]>
If the drm_plane has a source width that's greater than the max width supported by a single hw overlay, then we assign a 'r_overlay' to it in omap_plane_atomic_check().
Both overlays should have the capabilities required to handle the source framebuffer. The only parameters that vary between the left and right hwoverlays are the src_w, crtc_w, src_x and crtc_x as we just even chop the fb into left and right halves.
We also take care of not creating odd width size when dealing with YUV formats.
Since both halves need to be 'appear' side by side the zpos is recalculated when dealing with dual overlay cases so that the other planes zpos is consistent.
Depending on user space usage it is possible that on occasion the number of requested planes exceeds the numbers of overlays required to display them. In that case a failure would be returned for the plane that cannot be handled at that time. It is up to user space to make sure the H/W resource are not over-subscribed.
--- drivers/gpu/drm/omapdrm/omap_drv.c | 98 ++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_fb.c | 33 ++++++- drivers/gpu/drm/omapdrm/omap_fb.h | 4 +- drivers/gpu/drm/omapdrm/omap_overlay.c | 23 ++++- drivers/gpu/drm/omapdrm/omap_overlay.h | 3 +- drivers/gpu/drm/omapdrm/omap_plane.c | 117 +++++++++++++++++++++++-- drivers/gpu/drm/omapdrm/omap_plane.h | 1 + 7 files changed, 267 insertions(+), 12 deletions(-)
drivers/gpu/drm/omapdrm/omap_drv.c +97 -1
@@ -117,6 +117,102 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)dispc_runtime_put (priv->dispc); } +static int drm_atomic_state_normalized_zpos_cmp (const void *a,const void *b) +{ +const struct drm_plane_state *sa = *(struct drm_plane_state **)a; +const struct drm_plane_state *sb = *(struct drm_plane_state **)b; + +if (sa->normalized_zpos != sb->normalized_zpos) +return sa->normalized_zpos - sb->normalized_zpos; +else +return sa->plane->base.id - sb->plane->base.id; +} + +/* +* This replaces the drm_atomic_normalize_zpos to handle the dual overlay case. +* +* Since both halves need to be 'appear' side by side the zpos is +* recalculated when dealing with dual overlay cases so that the other +* planes zpos is consistent. +*/ +static int omap_atomic_update_normalize_zpos (struct drm_device *dev, +struct drm_atomic_state *state) +{ +struct drm_crtc *crtc; +struct drm_crtc_state *old_state, *new_state; +struct drm_plane *plane; +int c, i, n, inc; +int total_planes = dev->mode_config.num_total_plane; +struct drm_plane_state **states; +int ret =0 ; + + states =kmalloc_array (total_planes,sizeof (*states),GFP_KERNEL ); +if (!states) +return -ENOMEM ; + +for_each_oldnew_crtc_in_state (state, crtc, old_state, new_state, c) { +if (old_state->plane_mask == new_state->plane_mask && + !new_state->zpos_changed) +continue ; + +/* Reset plane increment and index value for every crtc */ + n =0 ; + +/* +* Normalization process might create new states for planes +* which normalized_zpos has to be recalculated. +*/ +drm_for_each_plane_mask (plane, dev, new_state->plane_mask) { +struct drm_plane_state *plane_state = +drm_atomic_get_plane_state (new_state->state, + plane); +if (IS_ERR (plane_state)) { + ret =PTR_ERR (plane_state); + goto done; + } + states[n++] = plane_state; + } + +sort (states, n,sizeof (*states), + drm_atomic_state_normalized_zpos_cmp,NULL ); + +for (i =0 , inc =0 ; i < n; i++) { + plane = states[i]->plane; + + states[i]->normalized_zpos = i + inc; +DRM_DEBUG_ATOMIC ("[PLANE:%d:%s] updated normalized zpos value %d\n" , + plane->base.id, plane->name, + states[i]->normalized_zpos); + +if (is_omap_plane_dual_overlay (states[i])) + inc++; + } + new_state->zpos_changed = true; + } + +done: +kfree (states); +return ret; +} + +static int omap_atomic_check (struct drm_device *dev, +struct drm_atomic_state *state) +{ +int ret; + + ret =drm_atomic_helper_check (dev, state); +if (ret) +return ret; + +if (dev->mode_config.normalize_zpos) { + ret =omap_atomic_update_normalize_zpos (dev, state); +if (ret) +return ret; + } + +return 0 ; +} +static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs = { .atomic_commit_tail = omap_atomic_commit_tail, };
@@ -124,7 +220,7 @@ static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs =static const struct drm_mode_config_funcs omap_mode_config_funcs = { .fb_create = omap_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed, - .atomic_check = drm_atomic_helper_check, + .atomic_check = omap_atomic_check, .atomic_commit = drm_atomic_helper_commit, };
drivers/gpu/drm/omapdrm/omap_fb.c +32 -1
@@ -131,7 +131,9 @@ static u32 drm_rotation_to_tiler(unsigned int drm_rot)/* update ovl info for scanout, handles cases of multi-planar fb's, etc. */ void omap_framebuffer_update_scanout (struct drm_framebuffer *fb, -struct drm_plane_state *state,struct omap_overlay_info *info) +struct drm_plane_state *state, +struct omap_overlay_info *info, +struct omap_overlay_info *r_info) {struct omap_framebuffer *omap_fb =to_omap_framebuffer (fb);const struct drm_format_info *format = omap_fb->format;
@@ -218,6 +220,35 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, }else { info->p_uv_addr =0 ; } + +if (r_info) { + info->width /=2 ; + info->out_width /=2 ; + + *r_info = *info; + +if (fb->format->is_yuv) { +if (info->width &1 ) { + info->width++; + r_info->width--; + } + +if (info->out_width &1 ) { + info->out_width++; + r_info->out_width--; + } + } + + r_info->pos_x = info->pos_x + info->out_width; + + r_info->paddr =get_linear_addr (fb, format,0 , + x + info->width, y); +if (fb->format->format ==DRM_FORMAT_NV12 ) { + r_info->p_uv_addr = +get_linear_addr (fb, format,1 , + x + info->width, y); + } + } }/* pin, prepare for scanout: */
drivers/gpu/drm/omapdrm/omap_fb.h +3 -1
@@ -26,7 +26,9 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,int omap_framebuffer_pin (struct drm_framebuffer *fb);void omap_framebuffer_unpin (struct drm_framebuffer *fb);void omap_framebuffer_update_scanout (struct drm_framebuffer *fb, -struct drm_plane_state *state,struct omap_overlay_info *info); +struct drm_plane_state *state, +struct omap_overlay_info *info, +struct omap_overlay_info *r_info);bool omap_framebuffer_supports_rotation (struct drm_framebuffer *fb);void omap_framebuffer_describe (struct drm_framebuffer *fb,struct seq_file *m);
drivers/gpu/drm/omapdrm/omap_overlay.c +21 -2
@@ -67,12 +67,13 @@ omap_plane_find_free_overlay(struct drm_device *dev, struct drm_plane *hwoverlay* next global overlay_map to be enabled when atomic transaction is valid. */ int omap_overlay_assign (struct drm_atomic_state *s,struct drm_plane *plane, -u32 caps,u32 fourcc,struct omap_hw_overlay **overlay) +u32 caps,u32 fourcc,struct omap_hw_overlay **overlay, +struct omap_hw_overlay **r_overlay) {/* Get the global state of the current atomic transaction */ struct omap_global_state *state =omap_get_global_state (s);struct drm_plane **overlay_map = state->hwoverlay_to_plane; -struct omap_hw_overlay *ovl; +struct omap_hw_overlay *ovl, *r_ovl; ovl =omap_plane_find_free_overlay (s->dev, overlay_map, caps, fourcc);if (!ovl)
@@ -81,8 +82,26 @@ int omap_overlay_assign(struct drm_atomic_state *s, struct drm_plane *plane, overlay_map[ovl->idx] = plane; *overlay = ovl; +if (r_overlay) { + r_ovl =omap_plane_find_free_overlay (s->dev, overlay_map, + caps, fourcc); +if (!r_ovl) { + overlay_map[r_ovl->idx] =NULL ; + *overlay =NULL ; +return -ENOMEM ; + } + + overlay_map[r_ovl->idx] = plane; + *r_overlay = r_ovl; + } +DBG ("%s: assign to plane %s caps %x" , ovl->name, plane->name, caps); +if (r_overlay) { +DBG ("%s: assign to right of plane %s caps %x" , + r_ovl->name, plane->name, caps); + } +return 0 ; }
drivers/gpu/drm/omapdrm/omap_overlay.h +2 -1
@@ -28,7 +28,8 @@ struct omap_hw_overlay {int omap_hwoverlays_init (struct omap_drm_private *priv);void omap_hwoverlays_destroy (struct omap_drm_private *priv);int omap_overlay_assign (struct drm_atomic_state *s,struct drm_plane *plane, -u32 caps,u32 fourcc,struct omap_hw_overlay **overlay); +u32 caps,u32 fourcc,struct omap_hw_overlay **overlay, +struct omap_hw_overlay **r_overlay);void omap_overlay_release (struct drm_atomic_state *s,struct omap_hw_overlay *overlay);void omap_overlay_update_state (struct omap_drm_private *priv,struct omap_hw_overlay *overlay);#endif /* __OMAPDRM_OVERLAY_H__ */
drivers/gpu/drm/omapdrm/omap_plane.c +111 -6
222 lines not on this page · raw message
drivers/gpu/drm/omapdrm/omap_plane.h +1 -0
@@ -22,5 +22,6 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, u32 possible_crtcs);void omap_plane_install_properties (struct drm_plane *plane,struct drm_mode_object *obj); +bool is_omap_plane_dual_overlay (struct drm_plane_state *state);#endif /* __OMAPDRM_PLANE_H__ */
Signature · 1 line
2.25.1
Hi Tomi,
Quoted 86 lines · Neil Armstrong
This patchset is the follow-up the v4 patchset from Benoit Parrot at [1].
This patch series adds virtual-plane support to omapdrm driver to allow the use of display wider than 2048 pixels.
In order to do so we introduce the concept of
hw_overlaywhich can then be dynamically allocated to a plane. When the requested output width exceed what be supported by one overlay a second is then allocated if possible to handle display wider then 2048.This series replaces an earlier series which was DT based and using statically allocated resources.
This implementation is inspired from the work done in msm/disp/mdp5 driver.
Changes since v6 at [3]:
- Patch 1: Added comment fordrm_atomic_helper_check_plane_state, added Reviewed-by
- Patch 2: added Reviewed-by
- Patch 3: added Reviewed-by
- Patch 4: added Reviewed-by
- Patch 5: added Reviewed-by
- Patch 6: No changes
- Patch 7: No changes
- Patch 8: Reformattedomap_plane_atomic_print_state()output for overlays
- Patch 9: Added a comment of the utility of the localomap_atomic_update_normalize_zpos()+atomic_print_state()reformatChanges since v5 at [2]:
- Patch 1: renamed width/height_fp to max_width/height
- Patch 2: no changes
- Patch 3: removedpossible_crtcsstuff,
added cleanup on failure to allocate,
removed name inomap_planestruct &plane_id_to_nameinomap_plane.c,
switched allomap_plane->nametoplane->nameoromap_plane->id
- Patch 4: alignedomap_plane_atomic_duplicate_statethe the crtc style
- Patch 5: removedglob_obj_lock& reformated global state declaration inomap_drv.h
- Patch 6: moveddrm_atomic_helper_check_plane_state()fromatomic_check()in separate commit, removed zpos change, updated debug messages to be useful,
renamedomap_overlay_disable()toomap_overlay_update_state(),
added useful comments foromap_overlay_assign()&omap_overlay_update_state(), simplifiedomap_overlay_assign()&omap_overlay_update_state()for actual use-cases, refactoredomap_plane_atomic_check()changes to be cleaner & simpler
- Patch 7: no changes (exceptpossible_crtcsprint removal)
- Patch 8: Reformatedomap_plane_atomic_check()&omap_overlay_assign()changes to match previous patches layoutChanges since v4 at [1]:
- rebased on v5.15-rc2
- adapted to drm_atomic_get_new/old_plane_state()
- tested on Beagle-x15
- checked for non-regression on Beagle-x15
- removed unused "state" variable inomap_global_state[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]Benoit Parrot (8):
drm/omap: Add ability to check if requested plane modes can be
supported
drm/omap: Add ovl checking funcs todispc_opsdrm/omap: introduceomap_hw_overlay
drm/omap:omap_plane: subclassdrm_plane_statedrm/omap: Add global state as a private atomic object drm/omap: dynamically assign hw overlays to planes drm/omap: addplane_atomic_print_statesupport drm/omap: Add a 'right overlay' to plane stateNeil Armstrong (1):
drm/omap: add sanity plane state checkdrivers/gpu/drm/omapdrm/Makefile | 1 + drivers/gpu/drm/omapdrm/dss/dispc.c | 31 ++- drivers/gpu/drm/omapdrm/dss/dss.h | 5 + drivers/gpu/drm/omapdrm/omap_drv.c | 196 +++++++++++++- drivers/gpu/drm/omapdrm/omap_drv.h | 24 ++ drivers/gpu/drm/omapdrm/omap_fb.c | 33 ++- drivers/gpu/drm/omapdrm/omap_fb.h | 4 +- drivers/gpu/drm/omapdrm/omap_overlay.c | 212 +++++++++++++++ drivers/gpu/drm/omapdrm/omap_overlay.h | 35 +++ drivers/gpu/drm/omapdrm/omap_plane.c | 349 +++++++++++++++++++++---- drivers/gpu/drm/omapdrm/omap_plane.h | 1 + 11 files changed, 832 insertions(+), 59 deletions(-) create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.c create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.h
Quoted 2 lines
base-commit:
49c39ec4670a8f045729e3717af2e1a74caf89a5
Gentle ping,
Neil
Tomi Valkeinen
maintainerQuoted 10 lines · Neil Armstrong
This patchset is the follow-up the v4 patchset from Benoit Parrot at [1].
This patch series adds virtual-plane support to omapdrm driver to allow the use of display wider than 2048 pixels.
In order to do so we introduce the concept of
hw_overlaywhich can then be dynamically allocated to a plane. When the requested output width exceed what be supported by one overlay a second is then allocated if possible to handle display wider then 2048.
Quoted 5 lines
This series replaces an earlier series which was DT based and using statically allocated resources.
This implementation is inspired from the work done in msm/disp/mdp5 driver.
I think this looks good. I'll apply this to my work tree to see if I see any issues during my daily work, and if not, I'll push to drm-misc-next.
Have you tested this with other platforms than x15? I'm mostly thinking about omap3/4, as the DSS is somewhat different on those platforms.
Tomi
Hi,
Quoted 14 lines · Tomi Valkeinen
Quoted 13 lines · Neil Armstrong
This patchset is the follow-up the v4 patchset from Benoit Parrot at [1].
This patch series adds virtual-plane support to omapdrm driver to allow the use of display wider than 2048 pixels.
In order to do so we introduce the concept of
hw_overlaywhich can then be dynamically allocated to a plane. When the requested output width exceed what be supported by one overlay a second is then allocated if possible to handle display wider then 2048.This series replaces an earlier series which was DT based and using statically allocated resources.
Quoted 6 lines
Quoted 2 lines
This implementation is inspired from the work done in msm/disp/mdp5 driver.
I think this looks good. I'll apply this to my work tree to see if I see any issues during my daily work, and if not, I'll push to drm-misc-next.
Have you tested this with other platforms than x15? I'm mostly thinking about omap3/4, as the DSS is somewhat different on those platforms.
I haven't tested the last version non non-x15, but I haven't changed the logic from the original patchset which was in the TI BSP tree for multiple years.
Neil
Quoted 2 lines
Tomi