xref: /openbmc/linux/drivers/gpu/drm/tegra/plane.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
25acd3514SThierry Reding /*
35acd3514SThierry Reding  * Copyright (C) 2017 NVIDIA CORPORATION.  All rights reserved.
45acd3514SThierry Reding  */
55acd3514SThierry Reding 
65acd3514SThierry Reding #ifndef TEGRA_PLANE_H
75acd3514SThierry Reding #define TEGRA_PLANE_H 1
85acd3514SThierry Reding 
95acd3514SThierry Reding #include <drm/drm_plane.h>
105acd3514SThierry Reding 
1104d5d5dfSDmitry Osipenko struct icc_path;
125acd3514SThierry Reding struct tegra_bo;
131087fac1SThierry Reding struct tegra_dc;
145acd3514SThierry Reding 
155acd3514SThierry Reding struct tegra_plane {
165acd3514SThierry Reding 	struct drm_plane base;
171087fac1SThierry Reding 	struct tegra_dc *dc;
18c4755fb9SThierry Reding 	unsigned int offset;
195acd3514SThierry Reding 	unsigned int index;
2004d5d5dfSDmitry Osipenko 
2104d5d5dfSDmitry Osipenko 	struct icc_path *icc_mem;
2204d5d5dfSDmitry Osipenko 	struct icc_path *icc_mem_vfilter;
235acd3514SThierry Reding };
245acd3514SThierry Reding 
255acd3514SThierry Reding struct tegra_cursor {
265acd3514SThierry Reding 	struct tegra_plane base;
275acd3514SThierry Reding 
285acd3514SThierry Reding 	struct tegra_bo *bo;
295acd3514SThierry Reding 	unsigned int width;
305acd3514SThierry Reding 	unsigned int height;
315acd3514SThierry Reding };
325acd3514SThierry Reding 
to_tegra_plane(struct drm_plane * plane)335acd3514SThierry Reding static inline struct tegra_plane *to_tegra_plane(struct drm_plane *plane)
345acd3514SThierry Reding {
355acd3514SThierry Reding 	return container_of(plane, struct tegra_plane, base);
365acd3514SThierry Reding }
375acd3514SThierry Reding 
383dae08bcSDmitry Osipenko struct tegra_plane_legacy_blending_state {
393dae08bcSDmitry Osipenko 	bool alpha;
403dae08bcSDmitry Osipenko 	bool top;
413dae08bcSDmitry Osipenko };
423dae08bcSDmitry Osipenko 
435acd3514SThierry Reding struct tegra_plane_state {
445acd3514SThierry Reding 	struct drm_plane_state base;
455acd3514SThierry Reding 
46c6aeaf56SThierry Reding 	struct host1x_bo_mapping *map[3];
472e8d8749SThierry Reding 	dma_addr_t iova[3];
482e8d8749SThierry Reding 
495acd3514SThierry Reding 	struct tegra_bo_tiling tiling;
505acd3514SThierry Reding 	u32 format;
515acd3514SThierry Reding 	u32 swap;
52ebae8d07SThierry Reding 
53cd740777SDmitry Osipenko 	bool reflect_x;
54e9e476f7SDmitry Osipenko 	bool reflect_y;
55995c5a50SThierry Reding 
56ebae8d07SThierry Reding 	/* used for legacy blending support only */
573dae08bcSDmitry Osipenko 	struct tegra_plane_legacy_blending_state blending[2];
58ebae8d07SThierry Reding 	bool opaque;
5904d5d5dfSDmitry Osipenko 
6004d5d5dfSDmitry Osipenko 	/* bandwidths are in ICC units, i.e. kbytes/sec */
6104d5d5dfSDmitry Osipenko 	u32 total_peak_memory_bandwidth;
6204d5d5dfSDmitry Osipenko 	u32 peak_memory_bandwidth;
6304d5d5dfSDmitry Osipenko 	u32 avg_memory_bandwidth;
645acd3514SThierry Reding };
655acd3514SThierry Reding 
665acd3514SThierry Reding static inline struct tegra_plane_state *
to_tegra_plane_state(struct drm_plane_state * state)675acd3514SThierry Reding to_tegra_plane_state(struct drm_plane_state *state)
685acd3514SThierry Reding {
695acd3514SThierry Reding 	if (state)
705acd3514SThierry Reding 		return container_of(state, struct tegra_plane_state, base);
715acd3514SThierry Reding 
725acd3514SThierry Reding 	return NULL;
735acd3514SThierry Reding }
745acd3514SThierry Reding 
7504d5d5dfSDmitry Osipenko static inline const struct tegra_plane_state *
to_const_tegra_plane_state(const struct drm_plane_state * state)7604d5d5dfSDmitry Osipenko to_const_tegra_plane_state(const struct drm_plane_state *state)
7704d5d5dfSDmitry Osipenko {
7804d5d5dfSDmitry Osipenko 	return to_tegra_plane_state((struct drm_plane_state *)state);
7904d5d5dfSDmitry Osipenko }
8004d5d5dfSDmitry Osipenko 
815acd3514SThierry Reding extern const struct drm_plane_funcs tegra_plane_funcs;
825acd3514SThierry Reding 
832e8d8749SThierry Reding int tegra_plane_prepare_fb(struct drm_plane *plane,
842e8d8749SThierry Reding 			   struct drm_plane_state *state);
852e8d8749SThierry Reding void tegra_plane_cleanup_fb(struct drm_plane *plane,
862e8d8749SThierry Reding 			    struct drm_plane_state *state);
872e8d8749SThierry Reding 
885acd3514SThierry Reding int tegra_plane_state_add(struct tegra_plane *plane,
895acd3514SThierry Reding 			  struct drm_plane_state *state);
905acd3514SThierry Reding 
915acd3514SThierry Reding int tegra_plane_format(u32 fourcc, u32 *format, u32 *swap);
92e16efff4SThierry Reding bool tegra_plane_format_is_indexed(unsigned int format);
93*a649b133SThierry Reding bool tegra_plane_format_is_yuv(unsigned int format, unsigned int *planes, unsigned int *bpc);
943dae08bcSDmitry Osipenko int tegra_plane_setup_legacy_state(struct tegra_plane *tegra,
95ebae8d07SThierry Reding 				   struct tegra_plane_state *state);
9604d5d5dfSDmitry Osipenko int tegra_plane_interconnect_init(struct tegra_plane *plane);
975acd3514SThierry Reding 
985acd3514SThierry Reding #endif /* TEGRA_PLANE_H */
99