2014-04-02 02:22:35 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011-2013 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DRM_PLANE_HELPER_H
|
|
|
|
#define DRM_PLANE_HELPER_H
|
|
|
|
|
2014-05-29 19:06:52 +04:00
|
|
|
#include <drm/drm_rect.h>
|
2014-10-29 12:03:57 +03:00
|
|
|
#include <drm/drm_crtc.h>
|
2014-05-29 19:06:52 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Drivers that don't allow primary plane scaling may pass this macro in place
|
|
|
|
* of the min/max scale parameters of the update checker function.
|
|
|
|
*
|
|
|
|
* Due to src being in 16.16 fixed point and dest being in integer pixels,
|
|
|
|
* 1<<16 represents no scaling.
|
|
|
|
*/
|
|
|
|
#define DRM_PLANE_HELPER_NO_SCALING (1<<16)
|
|
|
|
|
2014-04-02 02:22:35 +04:00
|
|
|
/**
|
|
|
|
* DOC: plane helpers
|
|
|
|
*
|
|
|
|
* Helper functions to assist with creation and handling of CRTC primary
|
|
|
|
* planes.
|
|
|
|
*/
|
|
|
|
|
2015-08-12 17:54:29 +03:00
|
|
|
int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
|
|
|
|
const struct drm_crtc_funcs *funcs);
|
2014-10-29 12:03:57 +03:00
|
|
|
|
2014-11-05 02:14:14 +03:00
|
|
|
/**
|
|
|
|
* drm_plane_helper_funcs - helper operations for CRTCs
|
2014-11-25 14:09:45 +03:00
|
|
|
* @prepare_fb: prepare a framebuffer for use by the plane
|
|
|
|
* @cleanup_fb: cleanup a framebuffer when it's no longer used by the plane
|
|
|
|
* @atomic_check: check that a given atomic state is valid and can be applied
|
2014-11-25 15:05:12 +03:00
|
|
|
* @atomic_update: apply an atomic state to the plane (mandatory)
|
drm/plane: Add optional ->atomic_disable() callback
In order to prevent drivers from having to perform the same checks over
and over again, add an optional ->atomic_disable callback which the core
calls under the right circumstances.
v2: pass old state and detect edges to avoid calling ->atomic_disable on
already disabled planes, remove redundant comment (Daniel Vetter)
v3: rename helper to drm_atomic_plane_disabling() to clarify that it is
checking for transitions, move helper to drm_atomic_helper.h, clarify
check for !old_state and its relation to transitional helpers
Here's an extract from some discussion rationalizing the behaviour (for
a full version, see the reference below):
> > Hm, thinking about this some more this will result in a slight difference
> > in behaviour, at least when drivers just use the helper ->reset functions
> > but don't disable everything:
> > - With transitional helpers we assume we know nothing and call
> > ->atomic_disable.
> > - With atomic old_state->crtc == NULL in the same situation right after
> > boot-up, but we asssume the plane is really off and _dont_ call
> > ->atomic_disable.
> >
> > Should we instead check for (old_state && old_state->crtc) and state that
> > drivers need to make sure they don't have stuff hanging around?
>
> I don't think we can check for old_state because otherwise this will
> always return false, whereas we really want it to force-disable planes
> that could be on (lacking any more accurate information). For
> transitional helpers anyway.
>
> For the atomic helpers, old_state will never be NULL, but I'd assume
> that the driver would reconstruct the current state in ->reset().
By the way, the reason for why old_state can be NULL with transitional
helpers is the ordering of the steps in the atomic transition. Currently
the Tegra patches do this (based on your blog post and the Exynos proto-
type):
1) atomic conversion, phase 1:
- implement ->atomic_{check,update,disable}()
- use drm_plane_helper_{update,disable}()
2) atomic conversion, phase 2:
- call drm_mode_config_reset() from ->load()
- implement ->reset()
That's only a partial list of what's done in these steps, but that's the
only relevant pieces for why old_state is NULL.
What happens is that without ->reset() implemented there won't be any
initial state, hence plane->state (the old_state here) will be NULL the
first time atomic state is applied.
We could of course reorder the sequence such that drivers are required
to hook up ->reset() before they can (or at the same as they) hook up
the transitional helpers. We could add an appropriate WARN_ON to this
helper to make that more obvious.
However, that will not solve the problem because it only gets rid of the
special case. We still don't know whether old_state->crtc == NULL is the
current state or just the initial default.
So no matter which way we do this, I don't see a way to get away without
requiring specific semantics from drivers. They would be that:
- drivers recreate the correct state in ->reset() so that
old_state->crtc != NULL if the plane is really enabled
or
- drivers have to ensure that the real state in fact mirrors the
initial default as encoded in the state (plane disabled)
References: http://lists.freedesktop.org/archives/dri-devel/2015-January/075578.html
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2014-11-20 14:05:50 +03:00
|
|
|
* @atomic_disable: disable the plane
|
2014-11-05 02:14:14 +03:00
|
|
|
*
|
|
|
|
* The helper operations are called by the mid-layer CRTC helper.
|
|
|
|
*/
|
|
|
|
struct drm_plane_helper_funcs {
|
|
|
|
int (*prepare_fb)(struct drm_plane *plane,
|
2015-03-03 17:22:31 +03:00
|
|
|
const struct drm_plane_state *new_state);
|
2014-11-05 02:14:14 +03:00
|
|
|
void (*cleanup_fb)(struct drm_plane *plane,
|
2015-03-03 17:22:31 +03:00
|
|
|
const struct drm_plane_state *old_state);
|
2014-11-05 02:14:14 +03:00
|
|
|
|
|
|
|
int (*atomic_check)(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *state);
|
2014-11-25 14:09:44 +03:00
|
|
|
void (*atomic_update)(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *old_state);
|
drm/plane: Add optional ->atomic_disable() callback
In order to prevent drivers from having to perform the same checks over
and over again, add an optional ->atomic_disable callback which the core
calls under the right circumstances.
v2: pass old state and detect edges to avoid calling ->atomic_disable on
already disabled planes, remove redundant comment (Daniel Vetter)
v3: rename helper to drm_atomic_plane_disabling() to clarify that it is
checking for transitions, move helper to drm_atomic_helper.h, clarify
check for !old_state and its relation to transitional helpers
Here's an extract from some discussion rationalizing the behaviour (for
a full version, see the reference below):
> > Hm, thinking about this some more this will result in a slight difference
> > in behaviour, at least when drivers just use the helper ->reset functions
> > but don't disable everything:
> > - With transitional helpers we assume we know nothing and call
> > ->atomic_disable.
> > - With atomic old_state->crtc == NULL in the same situation right after
> > boot-up, but we asssume the plane is really off and _dont_ call
> > ->atomic_disable.
> >
> > Should we instead check for (old_state && old_state->crtc) and state that
> > drivers need to make sure they don't have stuff hanging around?
>
> I don't think we can check for old_state because otherwise this will
> always return false, whereas we really want it to force-disable planes
> that could be on (lacking any more accurate information). For
> transitional helpers anyway.
>
> For the atomic helpers, old_state will never be NULL, but I'd assume
> that the driver would reconstruct the current state in ->reset().
By the way, the reason for why old_state can be NULL with transitional
helpers is the ordering of the steps in the atomic transition. Currently
the Tegra patches do this (based on your blog post and the Exynos proto-
type):
1) atomic conversion, phase 1:
- implement ->atomic_{check,update,disable}()
- use drm_plane_helper_{update,disable}()
2) atomic conversion, phase 2:
- call drm_mode_config_reset() from ->load()
- implement ->reset()
That's only a partial list of what's done in these steps, but that's the
only relevant pieces for why old_state is NULL.
What happens is that without ->reset() implemented there won't be any
initial state, hence plane->state (the old_state here) will be NULL the
first time atomic state is applied.
We could of course reorder the sequence such that drivers are required
to hook up ->reset() before they can (or at the same as they) hook up
the transitional helpers. We could add an appropriate WARN_ON to this
helper to make that more obvious.
However, that will not solve the problem because it only gets rid of the
special case. We still don't know whether old_state->crtc == NULL is the
current state or just the initial default.
So no matter which way we do this, I don't see a way to get away without
requiring specific semantics from drivers. They would be that:
- drivers recreate the correct state in ->reset() so that
old_state->crtc != NULL if the plane is really enabled
or
- drivers have to ensure that the real state in fact mirrors the
initial default as encoded in the state (plane disabled)
References: http://lists.freedesktop.org/archives/dri-devel/2015-January/075578.html
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2014-11-20 14:05:50 +03:00
|
|
|
void (*atomic_disable)(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *old_state);
|
2014-11-05 02:14:14 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void drm_plane_helper_add(struct drm_plane *plane,
|
|
|
|
const struct drm_plane_helper_funcs *funcs)
|
|
|
|
{
|
2015-04-13 11:21:42 +03:00
|
|
|
plane->helper_private = funcs;
|
2014-11-05 02:14:14 +03:00
|
|
|
}
|
|
|
|
|
2015-08-12 17:54:29 +03:00
|
|
|
int drm_plane_helper_check_update(struct drm_plane *plane,
|
|
|
|
struct drm_crtc *crtc,
|
|
|
|
struct drm_framebuffer *fb,
|
|
|
|
struct drm_rect *src,
|
|
|
|
struct drm_rect *dest,
|
|
|
|
const struct drm_rect *clip,
|
|
|
|
int min_scale,
|
|
|
|
int max_scale,
|
|
|
|
bool can_position,
|
|
|
|
bool can_update_disabled,
|
|
|
|
bool *visible);
|
|
|
|
int drm_primary_helper_update(struct drm_plane *plane,
|
|
|
|
struct drm_crtc *crtc,
|
|
|
|
struct drm_framebuffer *fb,
|
|
|
|
int crtc_x, int crtc_y,
|
|
|
|
unsigned int crtc_w, unsigned int crtc_h,
|
|
|
|
uint32_t src_x, uint32_t src_y,
|
|
|
|
uint32_t src_w, uint32_t src_h);
|
|
|
|
int drm_primary_helper_disable(struct drm_plane *plane);
|
|
|
|
void drm_primary_helper_destroy(struct drm_plane *plane);
|
2014-04-02 02:22:35 +04:00
|
|
|
extern const struct drm_plane_funcs drm_primary_helper_funcs;
|
|
|
|
|
2014-07-29 17:33:05 +04:00
|
|
|
int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
|
|
|
|
struct drm_framebuffer *fb,
|
|
|
|
int crtc_x, int crtc_y,
|
|
|
|
unsigned int crtc_w, unsigned int crtc_h,
|
|
|
|
uint32_t src_x, uint32_t src_y,
|
|
|
|
uint32_t src_w, uint32_t src_h);
|
|
|
|
int drm_plane_helper_disable(struct drm_plane *plane);
|
|
|
|
|
2014-10-29 13:13:47 +03:00
|
|
|
/* For use by drm_crtc_helper.c */
|
|
|
|
int drm_plane_helper_commit(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *plane_state,
|
|
|
|
struct drm_framebuffer *old_fb);
|
2014-04-02 02:22:35 +04:00
|
|
|
#endif
|