mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 11:19:37 +00:00
drm: Add drm_universal_plane_init()
Add a new plane initialization interface for universal plane support that allows a specific plane type (primary, cursor, or overlay) to be specified. drm_plane_init() remains as a compatibility API to reduce churn in existing drivers. The 'bool priv' parameter has been changed to 'bool is_primary' under the assumption that all existing uses of private planes were representing primary planes. Signed-off-by: Matt Roper <matthew.d.roper@intel.com> Reviewed-by: Rob Clark <robdclark@gmail.com>
This commit is contained in:
parent
c103d1cfb3
commit
dc415ff97d
2 changed files with 59 additions and 30 deletions
|
@ -1000,26 +1000,25 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
|
|||
EXPORT_SYMBOL(drm_encoder_cleanup);
|
||||
|
||||
/**
|
||||
* drm_plane_init - Initialise a new plane object
|
||||
* drm_universal_plane_init - Initialize a new universal plane object
|
||||
* @dev: DRM device
|
||||
* @plane: plane object to init
|
||||
* @possible_crtcs: bitmask of possible CRTCs
|
||||
* @funcs: callbacks for the new plane
|
||||
* @formats: array of supported formats (%DRM_FORMAT_*)
|
||||
* @format_count: number of elements in @formats
|
||||
* @priv: plane is private (hidden from userspace)?
|
||||
* @type: type of plane (overlay, primary, cursor)
|
||||
*
|
||||
* Inits a preallocate plane object created as base part of a driver plane
|
||||
* object.
|
||||
* Initializes a plane object of type @type.
|
||||
*
|
||||
* Returns:
|
||||
* Zero on success, error code on failure.
|
||||
*/
|
||||
int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
|
||||
int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
|
||||
unsigned long possible_crtcs,
|
||||
const struct drm_plane_funcs *funcs,
|
||||
const uint32_t *formats, uint32_t format_count,
|
||||
bool priv)
|
||||
enum drm_plane_type type)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -1044,26 +1043,49 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
|
|||
memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
|
||||
plane->format_count = format_count;
|
||||
plane->possible_crtcs = possible_crtcs;
|
||||
plane->type = DRM_PLANE_TYPE_OVERLAY;
|
||||
plane->type = type;
|
||||
|
||||
/* private planes are not exposed to userspace, but depending on
|
||||
* display hardware, might be convenient to allow sharing programming
|
||||
* for the scanout engine with the crtc implementation.
|
||||
*/
|
||||
if (!priv) {
|
||||
list_add_tail(&plane->head, &dev->mode_config.plane_list);
|
||||
dev->mode_config.num_total_plane++;
|
||||
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
|
||||
dev->mode_config.num_overlay_plane++;
|
||||
} else {
|
||||
INIT_LIST_HEAD(&plane->head);
|
||||
}
|
||||
|
||||
out:
|
||||
drm_modeset_unlock_all(dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_universal_plane_init);
|
||||
|
||||
/**
|
||||
* drm_plane_init - Initialize a legacy plane
|
||||
* @dev: DRM device
|
||||
* @plane: plane object to init
|
||||
* @possible_crtcs: bitmask of possible CRTCs
|
||||
* @funcs: callbacks for the new plane
|
||||
* @formats: array of supported formats (%DRM_FORMAT_*)
|
||||
* @format_count: number of elements in @formats
|
||||
* @is_primary: plane type (primary vs overlay)
|
||||
*
|
||||
* Legacy API to initialize a DRM plane.
|
||||
*
|
||||
* New drivers should call drm_universal_plane_init() instead.
|
||||
*
|
||||
* Returns:
|
||||
* Zero on success, error code on failure.
|
||||
*/
|
||||
int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
|
||||
unsigned long possible_crtcs,
|
||||
const struct drm_plane_funcs *funcs,
|
||||
const uint32_t *formats, uint32_t format_count,
|
||||
bool is_primary)
|
||||
{
|
||||
enum drm_plane_type type;
|
||||
|
||||
type = is_primary ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
|
||||
return drm_universal_plane_init(dev, plane, possible_crtcs, funcs,
|
||||
formats, format_count, type);
|
||||
}
|
||||
EXPORT_SYMBOL(drm_plane_init);
|
||||
|
||||
/**
|
||||
|
@ -1081,13 +1103,13 @@ void drm_plane_cleanup(struct drm_plane *plane)
|
|||
drm_modeset_lock_all(dev);
|
||||
kfree(plane->format_types);
|
||||
drm_mode_object_put(dev, &plane->base);
|
||||
/* if not added to a list, it must be a private plane */
|
||||
if (!list_empty(&plane->head)) {
|
||||
|
||||
BUG_ON(list_empty(&plane->head));
|
||||
|
||||
list_del(&plane->head);
|
||||
dev->mode_config.num_total_plane--;
|
||||
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
|
||||
dev->mode_config.num_overlay_plane--;
|
||||
}
|
||||
drm_modeset_unlock_all(dev);
|
||||
}
|
||||
EXPORT_SYMBOL(drm_plane_cleanup);
|
||||
|
|
|
@ -874,12 +874,19 @@ static inline bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
|
|||
return !!(encoder->possible_crtcs & drm_crtc_mask(crtc));
|
||||
}
|
||||
|
||||
extern int drm_universal_plane_init(struct drm_device *dev,
|
||||
struct drm_plane *plane,
|
||||
unsigned long possible_crtcs,
|
||||
const struct drm_plane_funcs *funcs,
|
||||
const uint32_t *formats,
|
||||
uint32_t format_count,
|
||||
enum drm_plane_type type);
|
||||
extern int drm_plane_init(struct drm_device *dev,
|
||||
struct drm_plane *plane,
|
||||
unsigned long possible_crtcs,
|
||||
const struct drm_plane_funcs *funcs,
|
||||
const uint32_t *formats, uint32_t format_count,
|
||||
bool priv);
|
||||
bool is_primary);
|
||||
extern void drm_plane_cleanup(struct drm_plane *plane);
|
||||
extern void drm_plane_force_disable(struct drm_plane *plane);
|
||||
extern int drm_crtc_check_viewport(const struct drm_crtc *crtc,
|
||||
|
|
Loading…
Reference in a new issue