Skip to content

Commit e13161a

Browse files
mattroperobclark
authored andcommitted
drm: Add drm_crtc_init_with_planes() (v2)
Add a new drm_crtc_init_with_planes() to allow drivers to provide specific primary and cursor planes at CRTC initialization. The existing drm_crtc_init() interface remains to avoid driver churn in existing drivers; it will initialize the CRTC with a plane helper-created primary plane and no cursor plane. v2: - Move drm_crtc_init() to plane helper file so that nothing in the DRM core depends on helpers. [suggested by Daniel Vetter] - Keep cursor parameter to drm_crtc_init_with_planes() a void* until we actually add cursor support. [suggested by Daniel Vetter] Signed-off-by: Matt Roper <matthew.d.roper@intel.com> Reviewed-by: Rob Clark <robdclark@gmail.com>
1 parent 9922ab5 commit e13161a

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,18 +692,23 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
692692
EXPORT_SYMBOL(drm_framebuffer_remove);
693693

694694
/**
695-
* drm_crtc_init - Initialise a new CRTC object
695+
* drm_crtc_init_with_planes - Initialise a new CRTC object with
696+
* specified primary and cursor planes.
696697
* @dev: DRM device
697698
* @crtc: CRTC object to init
699+
* @primary: Primary plane for CRTC
700+
* @cursor: Cursor plane for CRTC
698701
* @funcs: callbacks for the new CRTC
699702
*
700703
* Inits a new object created as base part of a driver crtc object.
701704
*
702705
* Returns:
703706
* Zero on success, error code on failure.
704707
*/
705-
int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
706-
const struct drm_crtc_funcs *funcs)
708+
int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
709+
struct drm_plane *primary,
710+
void *cursor,
711+
const struct drm_crtc_funcs *funcs)
707712
{
708713
int ret;
709714

@@ -724,12 +729,16 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
724729
list_add_tail(&crtc->head, &dev->mode_config.crtc_list);
725730
dev->mode_config.num_crtc++;
726731

732+
crtc->primary = primary;
733+
if (primary)
734+
primary->possible_crtcs = 1 << drm_crtc_index(crtc);
735+
727736
out:
728737
drm_modeset_unlock_all(dev);
729738

730739
return ret;
731740
}
732-
EXPORT_SYMBOL(drm_crtc_init);
741+
EXPORT_SYMBOL(drm_crtc_init_with_planes);
733742

734743
/**
735744
* drm_crtc_cleanup - Clean up the core crtc usage
@@ -2219,6 +2228,8 @@ int drm_mode_set_config_internal(struct drm_mode_set *set)
22192228

22202229
ret = crtc->funcs->set_config(set);
22212230
if (ret == 0) {
2231+
crtc->primary->crtc = crtc;
2232+
22222233
/* crtc->fb must be updated by ->set_config, enforces this. */
22232234
WARN_ON(fb != crtc->fb);
22242235
}

drivers/gpu/drm/drm_plane_helper.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,24 @@ struct drm_plane *drm_primary_helper_create_plane(struct drm_device *dev,
310310
}
311311
EXPORT_SYMBOL(drm_primary_helper_create_plane);
312312

313+
/**
314+
* drm_crtc_init - Legacy CRTC initialization function
315+
* @dev: DRM device
316+
* @crtc: CRTC object to init
317+
* @funcs: callbacks for the new CRTC
318+
*
319+
* Initialize a CRTC object with a default helper-provided primary plane and no
320+
* cursor plane.
321+
*
322+
* Returns:
323+
* Zero on success, error code on failure.
324+
*/
325+
int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
326+
const struct drm_crtc_funcs *funcs)
327+
{
328+
struct drm_plane *primary;
329+
330+
primary = drm_primary_helper_create_plane(dev, NULL, 0);
331+
return drm_crtc_init_with_planes(dev, crtc, primary, NULL, funcs);
332+
}
333+
EXPORT_SYMBOL(drm_crtc_init);

include/drm/drm_crtc.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ struct drm_crtc_funcs {
270270
* @dev: parent DRM device
271271
* @head: list management
272272
* @base: base KMS object for ID tracking etc.
273+
* @primary: primary plane for this CRTC
274+
* @cursor: cursor plane for this CRTC
273275
* @enabled: is this CRTC enabled?
274276
* @mode: current mode timings
275277
* @hwmode: mode timings as programmed to hw regs
@@ -305,6 +307,10 @@ struct drm_crtc {
305307

306308
struct drm_mode_object base;
307309

310+
/* primary and cursor planes for CRTC */
311+
struct drm_plane *primary;
312+
struct drm_plane *cursor;
313+
308314
/* framebuffer the connector is currently bound to */
309315
struct drm_framebuffer *fb;
310316

@@ -824,6 +830,11 @@ extern void drm_modeset_lock_all(struct drm_device *dev);
824830
extern void drm_modeset_unlock_all(struct drm_device *dev);
825831
extern void drm_warn_on_modeset_not_all_locked(struct drm_device *dev);
826832

833+
extern int drm_crtc_init_with_planes(struct drm_device *dev,
834+
struct drm_crtc *crtc,
835+
struct drm_plane *primary,
836+
void *cursor,
837+
const struct drm_crtc_funcs *funcs);
827838
extern int drm_crtc_init(struct drm_device *dev,
828839
struct drm_crtc *crtc,
829840
const struct drm_crtc_funcs *funcs);

0 commit comments

Comments
 (0)