bcm27xx: add support for linux v5.15
[openwrt/staging/noltari.git] / target / linux / bcm27xx / patches-5.15 / 950-0789-drm-Add-chroma-siting-properties.patch
1 From 97a1ab8087099a4293923e9359165aa414f43035 Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Wed, 26 Jan 2022 15:58:13 +0000
4 Subject: [PATCH] drm: Add chroma siting properties
5
6 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
7 ---
8 drivers/gpu/drm/drm_atomic_state_helper.c | 14 +++++++++
9 drivers/gpu/drm/drm_atomic_uapi.c | 8 +++++
10 drivers/gpu/drm/drm_color_mgmt.c | 36 +++++++++++++++++++++++
11 include/drm/drm_color_mgmt.h | 3 ++
12 include/drm/drm_plane.h | 36 +++++++++++++++++++++++
13 5 files changed, 97 insertions(+)
14
15 --- a/drivers/gpu/drm/drm_atomic_state_helper.c
16 +++ b/drivers/gpu/drm/drm_atomic_state_helper.c
17 @@ -265,6 +265,20 @@ void __drm_atomic_helper_plane_state_res
18 plane_state->color_range = val;
19 }
20
21 + if (plane->chroma_siting_h_property) {
22 + if (!drm_object_property_get_default_value(&plane->base,
23 + plane->chroma_siting_h_property,
24 + &val))
25 + plane_state->chroma_siting_h = val;
26 + }
27 +
28 + if (plane->chroma_siting_v_property) {
29 + if (!drm_object_property_get_default_value(&plane->base,
30 + plane->chroma_siting_v_property,
31 + &val))
32 + plane_state->chroma_siting_v = val;
33 + }
34 +
35 if (plane->zpos_property) {
36 if (!drm_object_property_get_default_value(&plane->base,
37 plane->zpos_property,
38 --- a/drivers/gpu/drm/drm_atomic_uapi.c
39 +++ b/drivers/gpu/drm/drm_atomic_uapi.c
40 @@ -598,6 +598,10 @@ static int drm_atomic_plane_set_property
41 state->color_encoding = val;
42 } else if (property == plane->color_range_property) {
43 state->color_range = val;
44 + } else if (property == plane->chroma_siting_h_property) {
45 + state->chroma_siting_h = val;
46 + } else if (property == plane->chroma_siting_v_property) {
47 + state->chroma_siting_v = val;
48 } else if (property == config->prop_fb_damage_clips) {
49 ret = drm_atomic_replace_property_blob_from_id(dev,
50 &state->fb_damage_clips,
51 @@ -664,6 +668,10 @@ drm_atomic_plane_get_property(struct drm
52 *val = state->color_encoding;
53 } else if (property == plane->color_range_property) {
54 *val = state->color_range;
55 + } else if (property == plane->chroma_siting_h_property) {
56 + *val = state->chroma_siting_h;
57 + } else if (property == plane->chroma_siting_v_property) {
58 + *val = state->chroma_siting_v;
59 } else if (property == config->prop_fb_damage_clips) {
60 *val = (state->fb_damage_clips) ?
61 state->fb_damage_clips->base.id : 0;
62 --- a/drivers/gpu/drm/drm_color_mgmt.c
63 +++ b/drivers/gpu/drm/drm_color_mgmt.c
64 @@ -587,6 +587,42 @@ int drm_plane_create_color_properties(st
65 EXPORT_SYMBOL(drm_plane_create_color_properties);
66
67 /**
68 + * drm_plane_create_chroma_siting_properties - chroma siting related plane properties
69 + * @plane: plane object
70 + *
71 + * Create and attach plane specific CHROMA_SITING
72 + * properties to @plane.
73 + */
74 +int drm_plane_create_chroma_siting_properties(struct drm_plane *plane,
75 + int32_t default_chroma_siting_h,
76 + int32_t default_chroma_siting_v)
77 +{
78 + struct drm_device *dev = plane->dev;
79 + struct drm_property *prop;
80 +
81 + prop = drm_property_create_range(dev, 0, "CHROMA_SITING_H",
82 + 0, 1<<16);
83 + if (!prop)
84 + return -ENOMEM;
85 + plane->chroma_siting_h_property = prop;
86 + drm_object_attach_property(&plane->base, prop, default_chroma_siting_h);
87 +
88 + prop = drm_property_create_range(dev, 0, "CHROMA_SITING_V",
89 + 0, 1<<16);
90 + if (!prop)
91 + return -ENOMEM;
92 + plane->chroma_siting_v_property = prop;
93 + drm_object_attach_property(&plane->base, prop, default_chroma_siting_v);
94 +
95 + if (plane->state) {
96 + plane->state->chroma_siting_h = default_chroma_siting_h;
97 + plane->state->chroma_siting_v = default_chroma_siting_v;
98 + }
99 + return 0;
100 +}
101 +EXPORT_SYMBOL(drm_plane_create_chroma_siting_properties);
102 +
103 +/**
104 * drm_color_lut_check - check validity of lookup table
105 * @lut: property blob containing LUT to check
106 * @tests: bitmask of tests to run
107 --- a/include/drm/drm_color_mgmt.h
108 +++ b/include/drm/drm_color_mgmt.h
109 @@ -93,6 +93,9 @@ int drm_plane_create_color_properties(st
110 enum drm_color_encoding default_encoding,
111 enum drm_color_range default_range);
112
113 +int drm_plane_create_chroma_siting_properties(struct drm_plane *plane,
114 + int32_t default_chroma_siting_h, int32_t default_chroma_siting_v);
115 +
116 /**
117 * enum drm_color_lut_tests - hw-specific LUT tests to perform
118 *
119 --- a/include/drm/drm_plane.h
120 +++ b/include/drm/drm_plane.h
121 @@ -180,6 +180,24 @@ struct drm_plane_state {
122 enum drm_color_range color_range;
123
124 /**
125 + * @chroma_siting_h:
126 + *
127 + * Location of chroma samples horizontally compared to luma
128 + * 0 means chroma is sited with left luma
129 + * 0x8000 is interstitial. 0x10000 is sited with right luma
130 + */
131 + int32_t chroma_siting_h;
132 +
133 + /**
134 + * @chroma_siting_v:
135 + *
136 + * Location of chroma samples vertically compared to luma
137 + * 0 means chroma is sited with top luma
138 + * 0x8000 is interstitial. 0x10000 is sited with bottom luma
139 + */
140 + int32_t chroma_siting_v;
141 +
142 + /**
143 * @fb_damage_clips:
144 *
145 * Blob representing damage (area in plane framebuffer that changed
146 @@ -750,6 +768,24 @@ struct drm_plane {
147 * scaling.
148 */
149 struct drm_property *scaling_filter_property;
150 +
151 + /**
152 + * @chroma_siting_h_property:
153 + *
154 + * Optional "CHROMA_SITING_H" property for specifying
155 + * chroma siting for YUV formats.
156 + * See drm_plane_create_chroma_siting_properties().
157 + */
158 + struct drm_property *chroma_siting_h_property;
159 +
160 + /**
161 + * @chroma_siting_v_property:
162 + *
163 + * Optional "CHROMA_SITING_V" property for specifying
164 + * chroma siting for YUV formats.
165 + * See drm_plane_create_chroma_siting_properties().
166 + */
167 + struct drm_property *chroma_siting_v_property;
168 };
169
170 #define obj_to_plane(x) container_of(x, struct drm_plane, base)