1*e2842570SBenjamin Gaignard /* SPDX-License-Identifier: GPL-2.0 */ 29e1f05b2SVincent Abriou /* 39e1f05b2SVincent Abriou * Copyright (C) STMicroelectronics SA 2014 49e1f05b2SVincent Abriou * Author: Benjamin Gaignard <benjamin.gaignard@st.com> for STMicroelectronics. 59e1f05b2SVincent Abriou */ 69e1f05b2SVincent Abriou 79e1f05b2SVincent Abriou #ifndef _STI_PLANE_H_ 89e1f05b2SVincent Abriou #define _STI_PLANE_H_ 99e1f05b2SVincent Abriou 1029d1dc62SVincent Abriou #include <drm/drm_atomic_helper.h> 1129d1dc62SVincent Abriou 129e1f05b2SVincent Abriou #define to_sti_plane(x) container_of(x, struct sti_plane, drm_plane) 139e1f05b2SVincent Abriou 149e1f05b2SVincent Abriou #define STI_PLANE_TYPE_SHIFT 8 159e1f05b2SVincent Abriou #define STI_PLANE_TYPE_MASK (~((1 << STI_PLANE_TYPE_SHIFT) - 1)) 169e1f05b2SVincent Abriou 179e1f05b2SVincent Abriou enum sti_plane_type { 189e1f05b2SVincent Abriou STI_GDP = 1 << STI_PLANE_TYPE_SHIFT, 199e1f05b2SVincent Abriou STI_VDP = 2 << STI_PLANE_TYPE_SHIFT, 209e1f05b2SVincent Abriou STI_CUR = 3 << STI_PLANE_TYPE_SHIFT, 219e1f05b2SVincent Abriou STI_BCK = 4 << STI_PLANE_TYPE_SHIFT 229e1f05b2SVincent Abriou }; 239e1f05b2SVincent Abriou 249e1f05b2SVincent Abriou enum sti_plane_id_of_type { 259e1f05b2SVincent Abriou STI_ID_0 = 0, 269e1f05b2SVincent Abriou STI_ID_1 = 1, 279e1f05b2SVincent Abriou STI_ID_2 = 2, 289e1f05b2SVincent Abriou STI_ID_3 = 3 299e1f05b2SVincent Abriou }; 309e1f05b2SVincent Abriou 319e1f05b2SVincent Abriou enum sti_plane_desc { 329e1f05b2SVincent Abriou STI_GDP_0 = STI_GDP | STI_ID_0, 339e1f05b2SVincent Abriou STI_GDP_1 = STI_GDP | STI_ID_1, 349e1f05b2SVincent Abriou STI_GDP_2 = STI_GDP | STI_ID_2, 359e1f05b2SVincent Abriou STI_GDP_3 = STI_GDP | STI_ID_3, 369e1f05b2SVincent Abriou STI_HQVDP_0 = STI_VDP | STI_ID_0, 379e1f05b2SVincent Abriou STI_CURSOR = STI_CUR, 389e1f05b2SVincent Abriou STI_BACK = STI_BCK 399e1f05b2SVincent Abriou }; 409e1f05b2SVincent Abriou 4129d1dc62SVincent Abriou enum sti_plane_status { 4229d1dc62SVincent Abriou STI_PLANE_READY, 4329d1dc62SVincent Abriou STI_PLANE_UPDATED, 4429d1dc62SVincent Abriou STI_PLANE_DISABLING, 4529d1dc62SVincent Abriou STI_PLANE_FLUSHING, 4629d1dc62SVincent Abriou STI_PLANE_DISABLED, 4729d1dc62SVincent Abriou }; 4829d1dc62SVincent Abriou 49a69e466bSVincent Abriou #define FPS_LENGTH 128 50bf8f9e4aSVincent Abriou struct sti_fps_info { 51bf8f9e4aSVincent Abriou bool output; 52bf8f9e4aSVincent Abriou unsigned int curr_frame_counter; 53bf8f9e4aSVincent Abriou unsigned int last_frame_counter; 54bf8f9e4aSVincent Abriou unsigned int curr_field_counter; 55bf8f9e4aSVincent Abriou unsigned int last_field_counter; 562c83f581STina Ruchandani ktime_t last_timestamp; 57bf8f9e4aSVincent Abriou char fps_str[FPS_LENGTH]; 58bf8f9e4aSVincent Abriou char fips_str[FPS_LENGTH]; 59bf8f9e4aSVincent Abriou }; 60bf8f9e4aSVincent Abriou 619e1f05b2SVincent Abriou /** 629e1f05b2SVincent Abriou * STI plane structure 639e1f05b2SVincent Abriou * 649e1f05b2SVincent Abriou * @plane: drm plane it is bound to (if any) 659e1f05b2SVincent Abriou * @desc: plane type & id 6629d1dc62SVincent Abriou * @status: to know the status of the plane 67bf8f9e4aSVincent Abriou * @fps_info: frame per second info 689e1f05b2SVincent Abriou */ 699e1f05b2SVincent Abriou struct sti_plane { 709e1f05b2SVincent Abriou struct drm_plane drm_plane; 719e1f05b2SVincent Abriou enum sti_plane_desc desc; 7229d1dc62SVincent Abriou enum sti_plane_status status; 73bf8f9e4aSVincent Abriou struct sti_fps_info fps_info; 749e1f05b2SVincent Abriou }; 759e1f05b2SVincent Abriou 769e1f05b2SVincent Abriou const char *sti_plane_to_str(struct sti_plane *plane); 77bf8f9e4aSVincent Abriou void sti_plane_update_fps(struct sti_plane *plane, 78bf8f9e4aSVincent Abriou bool new_frame, 79bf8f9e4aSVincent Abriou bool new_field); 8083af0a48SBenjamin Gaignard 8129d1dc62SVincent Abriou void sti_plane_init_property(struct sti_plane *plane, 8229d1dc62SVincent Abriou enum drm_plane_type type); 839e1f05b2SVincent Abriou #endif 84