18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2018 Texas Instruments Incorporated - https://www.ti.com/
48c2ecf20Sopenharmony_ci * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __TIDSS_DISPC_H__
88c2ecf20Sopenharmony_ci#define __TIDSS_DISPC_H__
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include "tidss_drv.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cistruct dispc_device;
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistruct drm_crtc_state;
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_cienum tidss_gamma_type { TIDSS_GAMMA_8BIT, TIDSS_GAMMA_10BIT };
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistruct tidss_vp_feat {
198c2ecf20Sopenharmony_ci	struct tidss_vp_color_feat {
208c2ecf20Sopenharmony_ci		u32 gamma_size;
218c2ecf20Sopenharmony_ci		enum tidss_gamma_type gamma_type;
228c2ecf20Sopenharmony_ci		bool has_ctm;
238c2ecf20Sopenharmony_ci	} color;
248c2ecf20Sopenharmony_ci};
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistruct tidss_plane_feat {
278c2ecf20Sopenharmony_ci	struct tidss_plane_color_feat {
288c2ecf20Sopenharmony_ci		u32 encodings;
298c2ecf20Sopenharmony_ci		u32 ranges;
308c2ecf20Sopenharmony_ci		enum drm_color_encoding default_encoding;
318c2ecf20Sopenharmony_ci		enum drm_color_range default_range;
328c2ecf20Sopenharmony_ci	} color;
338c2ecf20Sopenharmony_ci	struct tidss_plane_blend_feat {
348c2ecf20Sopenharmony_ci		bool global_alpha;
358c2ecf20Sopenharmony_ci	} blend;
368c2ecf20Sopenharmony_ci};
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistruct dispc_features_scaling {
398c2ecf20Sopenharmony_ci	u32 in_width_max_5tap_rgb;
408c2ecf20Sopenharmony_ci	u32 in_width_max_3tap_rgb;
418c2ecf20Sopenharmony_ci	u32 in_width_max_5tap_yuv;
428c2ecf20Sopenharmony_ci	u32 in_width_max_3tap_yuv;
438c2ecf20Sopenharmony_ci	u32 upscale_limit;
448c2ecf20Sopenharmony_ci	u32 downscale_limit_5tap;
458c2ecf20Sopenharmony_ci	u32 downscale_limit_3tap;
468c2ecf20Sopenharmony_ci	u32 xinc_max;
478c2ecf20Sopenharmony_ci};
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cistruct dispc_errata {
508c2ecf20Sopenharmony_ci	bool i2000; /* DSS Does Not Support YUV Pixel Data Formats */
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cienum dispc_vp_bus_type {
548c2ecf20Sopenharmony_ci	DISPC_VP_DPI,		/* DPI output */
558c2ecf20Sopenharmony_ci	DISPC_VP_OLDI,		/* OLDI (LVDS) output */
568c2ecf20Sopenharmony_ci	DISPC_VP_INTERNAL,	/* SoC internal routing */
578c2ecf20Sopenharmony_ci	DISPC_VP_MAX_BUS_TYPE,
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cienum dispc_dss_subrevision {
618c2ecf20Sopenharmony_ci	DISPC_K2G,
628c2ecf20Sopenharmony_ci	DISPC_AM65X,
638c2ecf20Sopenharmony_ci	DISPC_J721E,
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistruct dispc_features {
678c2ecf20Sopenharmony_ci	int min_pclk_khz;
688c2ecf20Sopenharmony_ci	int max_pclk_khz[DISPC_VP_MAX_BUS_TYPE];
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci	struct dispc_features_scaling scaling;
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	enum dispc_dss_subrevision subrev;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	const char *common;
758c2ecf20Sopenharmony_ci	const u16 *common_regs;
768c2ecf20Sopenharmony_ci	u32 num_vps;
778c2ecf20Sopenharmony_ci	const char *vp_name[TIDSS_MAX_PORTS]; /* Should match dt reg names */
788c2ecf20Sopenharmony_ci	const char *ovr_name[TIDSS_MAX_PORTS]; /* Should match dt reg names */
798c2ecf20Sopenharmony_ci	const char *vpclk_name[TIDSS_MAX_PORTS]; /* Should match dt clk names */
808c2ecf20Sopenharmony_ci	const enum dispc_vp_bus_type vp_bus_type[TIDSS_MAX_PORTS];
818c2ecf20Sopenharmony_ci	struct tidss_vp_feat vp_feat;
828c2ecf20Sopenharmony_ci	u32 num_planes;
838c2ecf20Sopenharmony_ci	const char *vid_name[TIDSS_MAX_PLANES]; /* Should match dt reg names */
848c2ecf20Sopenharmony_ci	bool vid_lite[TIDSS_MAX_PLANES];
858c2ecf20Sopenharmony_ci	u32 vid_order[TIDSS_MAX_PLANES];
868c2ecf20Sopenharmony_ci};
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ciextern const struct dispc_features dispc_k2g_feats;
898c2ecf20Sopenharmony_ciextern const struct dispc_features dispc_am65x_feats;
908c2ecf20Sopenharmony_ciextern const struct dispc_features dispc_j721e_feats;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_civoid dispc_set_irqenable(struct dispc_device *dispc, dispc_irq_t mask);
938c2ecf20Sopenharmony_cidispc_irq_t dispc_read_and_clear_irqstatus(struct dispc_device *dispc);
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_civoid dispc_ovr_set_plane(struct dispc_device *dispc, u32 hw_plane,
968c2ecf20Sopenharmony_ci			 u32 hw_videoport, u32 x, u32 y, u32 layer);
978c2ecf20Sopenharmony_civoid dispc_ovr_enable_layer(struct dispc_device *dispc,
988c2ecf20Sopenharmony_ci			    u32 hw_videoport, u32 layer, bool enable);
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_civoid dispc_vp_prepare(struct dispc_device *dispc, u32 hw_videoport,
1018c2ecf20Sopenharmony_ci		      const struct drm_crtc_state *state);
1028c2ecf20Sopenharmony_civoid dispc_vp_enable(struct dispc_device *dispc, u32 hw_videoport,
1038c2ecf20Sopenharmony_ci		     const struct drm_crtc_state *state);
1048c2ecf20Sopenharmony_civoid dispc_vp_disable(struct dispc_device *dispc, u32 hw_videoport);
1058c2ecf20Sopenharmony_civoid dispc_vp_unprepare(struct dispc_device *dispc, u32 hw_videoport);
1068c2ecf20Sopenharmony_cibool dispc_vp_go_busy(struct dispc_device *dispc, u32 hw_videoport);
1078c2ecf20Sopenharmony_civoid dispc_vp_go(struct dispc_device *dispc, u32 hw_videoport);
1088c2ecf20Sopenharmony_ciint dispc_vp_bus_check(struct dispc_device *dispc, u32 hw_videoport,
1098c2ecf20Sopenharmony_ci		       const struct drm_crtc_state *state);
1108c2ecf20Sopenharmony_cienum drm_mode_status dispc_vp_mode_valid(struct dispc_device *dispc,
1118c2ecf20Sopenharmony_ci					 u32 hw_videoport,
1128c2ecf20Sopenharmony_ci					 const struct drm_display_mode *mode);
1138c2ecf20Sopenharmony_ciint dispc_vp_enable_clk(struct dispc_device *dispc, u32 hw_videoport);
1148c2ecf20Sopenharmony_civoid dispc_vp_disable_clk(struct dispc_device *dispc, u32 hw_videoport);
1158c2ecf20Sopenharmony_ciint dispc_vp_set_clk_rate(struct dispc_device *dispc, u32 hw_videoport,
1168c2ecf20Sopenharmony_ci			  unsigned long rate);
1178c2ecf20Sopenharmony_civoid dispc_vp_setup(struct dispc_device *dispc, u32 hw_videoport,
1188c2ecf20Sopenharmony_ci		    const struct drm_crtc_state *state, bool newmodeset);
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ciint dispc_runtime_suspend(struct dispc_device *dispc);
1218c2ecf20Sopenharmony_ciint dispc_runtime_resume(struct dispc_device *dispc);
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ciint dispc_plane_check(struct dispc_device *dispc, u32 hw_plane,
1248c2ecf20Sopenharmony_ci		      const struct drm_plane_state *state,
1258c2ecf20Sopenharmony_ci		      u32 hw_videoport);
1268c2ecf20Sopenharmony_ciint dispc_plane_setup(struct dispc_device *dispc, u32 hw_plane,
1278c2ecf20Sopenharmony_ci		      const struct drm_plane_state *state,
1288c2ecf20Sopenharmony_ci		      u32 hw_videoport);
1298c2ecf20Sopenharmony_ciint dispc_plane_enable(struct dispc_device *dispc, u32 hw_plane, bool enable);
1308c2ecf20Sopenharmony_ciconst u32 *dispc_plane_formats(struct dispc_device *dispc, unsigned int *len);
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ciint dispc_init(struct tidss_device *tidss);
1338c2ecf20Sopenharmony_civoid dispc_remove(struct tidss_device *tidss);
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#endif
136