blob: 965c333736b0b47fd9caf5bd64c20628ca0392e3 [file] [log] [blame]
Thierry Redingc4755fb2017-11-13 11:08:13 +01001/*
2 * Copyright (C) 2017 NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef TEGRA_HUB_H
10#define TEGRA_HUB_H 1
11
12#include <drm/drmP.h>
13#include <drm/drm_plane.h>
14
15#include "plane.h"
16
17struct tegra_dc;
18
19struct tegra_windowgroup {
20 unsigned int usecount;
21 struct mutex lock;
22
23 unsigned int index;
24 struct device *parent;
25 struct reset_control *rst;
26};
27
28struct tegra_shared_plane {
29 struct tegra_plane base;
30 struct tegra_windowgroup *wgrp;
31 struct tegra_dc *dc;
32};
33
34static inline struct tegra_shared_plane *
35to_tegra_shared_plane(struct drm_plane *plane)
36{
37 return container_of(plane, struct tegra_shared_plane, base.base);
38}
39
40struct tegra_display_hub_soc {
41 unsigned int num_wgrps;
42};
43
44struct tegra_display_hub {
45 struct host1x_client client;
46 struct clk *clk_disp;
47 struct clk *clk_dsc;
48 struct clk *clk_hub;
49 struct reset_control *rst;
50
51 const struct tegra_display_hub_soc *soc;
52 struct tegra_windowgroup *wgrps;
53};
54
55static inline struct tegra_display_hub *
56to_tegra_display_hub(struct host1x_client *client)
57{
58 return container_of(client, struct tegra_display_hub, client);
59}
60
61struct tegra_dc;
62struct tegra_plane;
63
64int tegra_display_hub_prepare(struct tegra_display_hub *hub);
65void tegra_display_hub_cleanup(struct tegra_display_hub *hub);
66
67struct drm_plane *tegra_shared_plane_create(struct drm_device *drm,
68 struct tegra_dc *dc,
69 unsigned int wgrp,
70 unsigned int index);
71
72void tegra_display_hub_atomic_commit(struct drm_device *drm,
73 struct drm_atomic_state *state);
74
75#define DC_CMD_IHUB_COMMON_MISC_CTL 0x068
76#define LATENCY_EVENT (1 << 3)
77
78#define DC_DISP_IHUB_COMMON_DISPLAY_FETCH_METER 0x451
79#define CURS_SLOTS(x) (((x) & 0xff) << 8)
80#define WGRP_SLOTS(x) (((x) & 0xff) << 0)
81
82#endif /* TEGRA_HUB_H */