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