Skip to content

Commit 05d1adf

Browse files
committed
drm/tegra: Count number of display controllers at runtime
In order to be able to attach planes to all possible display controllers the exact number of CRTCs must be known. Keep track of the number of the display controllers that register during initialization. Signed-off-by: Thierry Reding <[email protected]>
1 parent 476e932 commit 05d1adf

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

drivers/gpu/drm/tegra/dc.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,16 @@ static bool tegra_dc_has_window_groups(struct tegra_dc *dc)
20802080
return false;
20812081
}
20822082

2083+
static int tegra_dc_early_init(struct host1x_client *client)
2084+
{
2085+
struct drm_device *drm = dev_get_drvdata(client->host);
2086+
struct tegra_drm *tegra = drm->dev_private;
2087+
2088+
tegra->num_crtcs++;
2089+
2090+
return 0;
2091+
}
2092+
20832093
static int tegra_dc_init(struct host1x_client *client)
20842094
{
20852095
struct drm_device *drm = dev_get_drvdata(client->host);
@@ -2228,6 +2238,16 @@ static int tegra_dc_exit(struct host1x_client *client)
22282238
return 0;
22292239
}
22302240

2241+
static int tegra_dc_late_exit(struct host1x_client *client)
2242+
{
2243+
struct drm_device *drm = dev_get_drvdata(client->host);
2244+
struct tegra_drm *tegra = drm->dev_private;
2245+
2246+
tegra->num_crtcs--;
2247+
2248+
return 0;
2249+
}
2250+
22312251
static int tegra_dc_runtime_suspend(struct host1x_client *client)
22322252
{
22332253
struct tegra_dc *dc = host1x_client_to_dc(client);
@@ -2292,8 +2312,10 @@ static int tegra_dc_runtime_resume(struct host1x_client *client)
22922312
}
22932313

22942314
static const struct host1x_client_ops dc_client_ops = {
2315+
.early_init = tegra_dc_early_init,
22952316
.init = tegra_dc_init,
22962317
.exit = tegra_dc_exit,
2318+
.late_exit = tegra_dc_late_exit,
22972319
.suspend = tegra_dc_runtime_suspend,
22982320
.resume = tegra_dc_runtime_resume,
22992321
};

drivers/gpu/drm/tegra/drm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct tegra_drm {
5656

5757
unsigned int hmask, vmask;
5858
unsigned int pitch_align;
59+
unsigned int num_crtcs;
5960

6061
struct tegra_display_hub *hub;
6162
};

drivers/gpu/drm/tegra/hub.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,8 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm,
562562
enum drm_plane_type type = DRM_PLANE_TYPE_OVERLAY;
563563
struct tegra_drm *tegra = drm->dev_private;
564564
struct tegra_display_hub *hub = tegra->hub;
565-
/* planes can be assigned to arbitrary CRTCs */
566-
unsigned int possible_crtcs = 0x7;
567565
struct tegra_shared_plane *plane;
566+
unsigned int possible_crtcs;
568567
unsigned int num_formats;
569568
const u64 *modifiers;
570569
struct drm_plane *p;
@@ -583,6 +582,9 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm,
583582

584583
p = &plane->base.base;
585584

585+
/* planes can be assigned to arbitrary CRTCs */
586+
possible_crtcs = BIT(tegra->num_crtcs) - 1;
587+
586588
num_formats = ARRAY_SIZE(tegra_shared_plane_formats);
587589
formats = tegra_shared_plane_formats;
588590
modifiers = tegra_shared_plane_modifiers;

0 commit comments

Comments
 (0)