Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) STMicroelectronics SA 2014 |
| 3 | * Author: Benjamin Gaignard <benjamin.gaignard@st.com> for STMicroelectronics. |
| 4 | * License terms: GNU General Public License (GPL), version 2 |
| 5 | */ |
| 6 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame] | 7 | #ifndef _STI_PLANE_H_ |
| 8 | #define _STI_PLANE_H_ |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 9 | |
| 10 | #include <drm/drmP.h> |
Vincent Abriou | 29d1dc6 | 2015-08-03 14:22:16 +0200 | [diff] [blame] | 11 | #include <drm/drm_atomic_helper.h> |
| 12 | #include <drm/drm_plane_helper.h> |
| 13 | |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 14 | #define to_sti_plane(x) container_of(x, struct sti_plane, drm_plane) |
| 15 | |
| 16 | #define STI_PLANE_TYPE_SHIFT 8 |
| 17 | #define STI_PLANE_TYPE_MASK (~((1 << STI_PLANE_TYPE_SHIFT) - 1)) |
| 18 | |
| 19 | enum sti_plane_type { |
| 20 | STI_GDP = 1 << STI_PLANE_TYPE_SHIFT, |
| 21 | STI_VDP = 2 << STI_PLANE_TYPE_SHIFT, |
| 22 | STI_CUR = 3 << STI_PLANE_TYPE_SHIFT, |
| 23 | STI_BCK = 4 << STI_PLANE_TYPE_SHIFT |
| 24 | }; |
| 25 | |
| 26 | enum sti_plane_id_of_type { |
| 27 | STI_ID_0 = 0, |
| 28 | STI_ID_1 = 1, |
| 29 | STI_ID_2 = 2, |
| 30 | STI_ID_3 = 3 |
| 31 | }; |
| 32 | |
| 33 | enum sti_plane_desc { |
| 34 | STI_GDP_0 = STI_GDP | STI_ID_0, |
| 35 | STI_GDP_1 = STI_GDP | STI_ID_1, |
| 36 | STI_GDP_2 = STI_GDP | STI_ID_2, |
| 37 | STI_GDP_3 = STI_GDP | STI_ID_3, |
| 38 | STI_HQVDP_0 = STI_VDP | STI_ID_0, |
| 39 | STI_CURSOR = STI_CUR, |
| 40 | STI_BACK = STI_BCK |
| 41 | }; |
| 42 | |
Vincent Abriou | 29d1dc6 | 2015-08-03 14:22:16 +0200 | [diff] [blame] | 43 | enum sti_plane_status { |
| 44 | STI_PLANE_READY, |
| 45 | STI_PLANE_UPDATED, |
| 46 | STI_PLANE_DISABLING, |
| 47 | STI_PLANE_FLUSHING, |
| 48 | STI_PLANE_DISABLED, |
| 49 | }; |
| 50 | |
Vincent Abriou | bf8f9e4 | 2016-02-08 11:34:31 +0100 | [diff] [blame] | 51 | #define FPS_LENGTH 64 |
| 52 | struct sti_fps_info { |
| 53 | bool output; |
| 54 | unsigned int curr_frame_counter; |
| 55 | unsigned int last_frame_counter; |
| 56 | unsigned int curr_field_counter; |
| 57 | unsigned int last_field_counter; |
Tina Ruchandani | 2c83f58 | 2016-04-13 02:28:02 -0700 | [diff] [blame] | 58 | ktime_t last_timestamp; |
Vincent Abriou | bf8f9e4 | 2016-02-08 11:34:31 +0100 | [diff] [blame] | 59 | char fps_str[FPS_LENGTH]; |
| 60 | char fips_str[FPS_LENGTH]; |
| 61 | }; |
| 62 | |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 63 | /** |
| 64 | * STI plane structure |
| 65 | * |
| 66 | * @plane: drm plane it is bound to (if any) |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 67 | * @desc: plane type & id |
Vincent Abriou | 29d1dc6 | 2015-08-03 14:22:16 +0200 | [diff] [blame] | 68 | * @status: to know the status of the plane |
Vincent Abriou | bf8f9e4 | 2016-02-08 11:34:31 +0100 | [diff] [blame] | 69 | * @fps_info: frame per second info |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 70 | */ |
| 71 | struct sti_plane { |
| 72 | struct drm_plane drm_plane; |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 73 | enum sti_plane_desc desc; |
Vincent Abriou | 29d1dc6 | 2015-08-03 14:22:16 +0200 | [diff] [blame] | 74 | enum sti_plane_status status; |
Vincent Abriou | bf8f9e4 | 2016-02-08 11:34:31 +0100 | [diff] [blame] | 75 | struct sti_fps_info fps_info; |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 76 | }; |
| 77 | |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 78 | const char *sti_plane_to_str(struct sti_plane *plane); |
Vincent Abriou | bf8f9e4 | 2016-02-08 11:34:31 +0100 | [diff] [blame] | 79 | void sti_plane_update_fps(struct sti_plane *plane, |
| 80 | bool new_frame, |
| 81 | bool new_field); |
Benjamin Gaignard | 83af0a4 | 2016-06-21 15:09:39 +0200 | [diff] [blame] | 82 | |
Vincent Abriou | 29d1dc6 | 2015-08-03 14:22:16 +0200 | [diff] [blame] | 83 | void sti_plane_init_property(struct sti_plane *plane, |
| 84 | enum drm_plane_type type); |
Benjamin Gaignard | bbd1e3a | 2016-03-24 17:18:20 +0100 | [diff] [blame^] | 85 | void sti_plane_reset(struct drm_plane *plane); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 86 | #endif |