Skip to content

Commit ee33ac2

Browse files
committed
drm/vc4: crtc: Introduce a lower-level crtc init helper
The current vc4_crtc_init() helper assumes that we will be using hardware planes and calls vc4_plane_init(). While it's a reasonable assumption, we'll want to mock the plane and thus provide our own. Let's create a helper that will take the plane as an argument. Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Maíra Canal <mcanal@igalia.com> Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-14-4615a663a84a@cerno.tech Signed-off-by: Maxime Ripard <maxime@cerno.tech>
1 parent 3c5cb5e commit ee33ac2

File tree

2 files changed

+57
-19
lines changed

2 files changed

+57
-19
lines changed

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,31 +1286,38 @@ static void vc4_set_crtc_possible_masks(struct drm_device *drm,
12861286
}
12871287
}
12881288

1289-
int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
1290-
struct vc4_crtc *vc4_crtc,
1291-
const struct vc4_crtc_data *data,
1292-
const struct drm_crtc_funcs *crtc_funcs,
1293-
const struct drm_crtc_helper_funcs *crtc_helper_funcs,
1294-
bool feeds_txp)
1289+
/**
1290+
* __vc4_crtc_init - Initializes a CRTC
1291+
* @drm: DRM Device
1292+
* @pdev: CRTC Platform Device
1293+
* @vc4_crtc: CRTC Object to Initialize
1294+
* @data: Configuration data associated with this CRTC
1295+
* @primary_plane: Primary plane for CRTC
1296+
* @crtc_funcs: Callbacks for the new CRTC
1297+
* @crtc_helper_funcs: Helper Callbacks for the new CRTC
1298+
* @feeds_txp: Is this CRTC connected to the TXP?
1299+
*
1300+
* Initializes our private CRTC structure. This function is mostly
1301+
* relevant for KUnit testing, all other users should use
1302+
* vc4_crtc_init() instead.
1303+
*
1304+
* Returns:
1305+
* 0 on success, a negative error code on failure.
1306+
*/
1307+
int __vc4_crtc_init(struct drm_device *drm,
1308+
struct platform_device *pdev,
1309+
struct vc4_crtc *vc4_crtc,
1310+
const struct vc4_crtc_data *data,
1311+
struct drm_plane *primary_plane,
1312+
const struct drm_crtc_funcs *crtc_funcs,
1313+
const struct drm_crtc_helper_funcs *crtc_helper_funcs,
1314+
bool feeds_txp)
12951315
{
12961316
struct vc4_dev *vc4 = to_vc4_dev(drm);
12971317
struct drm_crtc *crtc = &vc4_crtc->base;
1298-
struct drm_plane *primary_plane;
12991318
unsigned int i;
13001319
int ret;
13011320

1302-
/* For now, we create just the primary and the legacy cursor
1303-
* planes. We should be able to stack more planes on easily,
1304-
* but to do that we would need to compute the bandwidth
1305-
* requirement of the plane configuration, and reject ones
1306-
* that will take too much.
1307-
*/
1308-
primary_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_PRIMARY, 0);
1309-
if (IS_ERR(primary_plane)) {
1310-
dev_err(drm->dev, "failed to construct primary plane\n");
1311-
return PTR_ERR(primary_plane);
1312-
}
1313-
13141321
vc4_crtc->data = data;
13151322
vc4_crtc->pdev = pdev;
13161323
vc4_crtc->feeds_txp = feeds_txp;
@@ -1342,6 +1349,31 @@ int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
13421349
return 0;
13431350
}
13441351

1352+
int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
1353+
struct vc4_crtc *vc4_crtc,
1354+
const struct vc4_crtc_data *data,
1355+
const struct drm_crtc_funcs *crtc_funcs,
1356+
const struct drm_crtc_helper_funcs *crtc_helper_funcs,
1357+
bool feeds_txp)
1358+
{
1359+
struct drm_plane *primary_plane;
1360+
1361+
/* For now, we create just the primary and the legacy cursor
1362+
* planes. We should be able to stack more planes on easily,
1363+
* but to do that we would need to compute the bandwidth
1364+
* requirement of the plane configuration, and reject ones
1365+
* that will take too much.
1366+
*/
1367+
primary_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_PRIMARY, 0);
1368+
if (IS_ERR(primary_plane)) {
1369+
dev_err(drm->dev, "failed to construct primary plane\n");
1370+
return PTR_ERR(primary_plane);
1371+
}
1372+
1373+
return __vc4_crtc_init(drm, pdev, vc4_crtc, data, primary_plane,
1374+
crtc_funcs, crtc_helper_funcs, feeds_txp);
1375+
}
1376+
13451377
static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
13461378
{
13471379
struct platform_device *pdev = to_platform_device(dev);

drivers/gpu/drm/vc4/vc4_drv.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,12 @@ int vc4_bo_debugfs_init(struct drm_minor *minor);
888888
/* vc4_crtc.c */
889889
extern struct platform_driver vc4_crtc_driver;
890890
int vc4_crtc_disable_at_boot(struct drm_crtc *crtc);
891+
int __vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
892+
struct vc4_crtc *vc4_crtc, const struct vc4_crtc_data *data,
893+
struct drm_plane *primary_plane,
894+
const struct drm_crtc_funcs *crtc_funcs,
895+
const struct drm_crtc_helper_funcs *crtc_helper_funcs,
896+
bool feeds_txp);
891897
int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
892898
struct vc4_crtc *vc4_crtc, const struct vc4_crtc_data *data,
893899
const struct drm_crtc_funcs *crtc_funcs,

0 commit comments

Comments
 (0)