Skip to content

Commit d9c24a3

Browse files
committed
drm: Add chroma siting properties
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
1 parent 2c37da3 commit d9c24a3

5 files changed

Lines changed: 97 additions & 0 deletions

File tree

‎drivers/gpu/drm/drm_atomic_state_helper.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,20 @@ void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state,
265265
plane_state->color_range = val;
266266
}
267267

268+
if (plane->chroma_siting_h_property) {
269+
if (!drm_object_property_get_default_value(&plane->base,
270+
plane->chroma_siting_h_property,
271+
&val))
272+
plane_state->chroma_siting_h = val;
273+
}
274+
275+
if (plane->chroma_siting_v_property) {
276+
if (!drm_object_property_get_default_value(&plane->base,
277+
plane->chroma_siting_v_property,
278+
&val))
279+
plane_state->chroma_siting_v = val;
280+
}
281+
268282
if (plane->zpos_property) {
269283
if (!drm_object_property_get_default_value(&plane->base,
270284
plane->zpos_property,

‎drivers/gpu/drm/drm_atomic_uapi.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,10 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
598598
state->color_encoding = val;
599599
} else if (property == plane->color_range_property) {
600600
state->color_range = val;
601+
} else if (property == plane->chroma_siting_h_property) {
602+
state->chroma_siting_h = val;
603+
} else if (property == plane->chroma_siting_v_property) {
604+
state->chroma_siting_v = val;
601605
} else if (property == config->prop_fb_damage_clips) {
602606
ret = drm_atomic_replace_property_blob_from_id(dev,
603607
&state->fb_damage_clips,
@@ -664,6 +668,10 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
664668
*val = state->color_encoding;
665669
} else if (property == plane->color_range_property) {
666670
*val = state->color_range;
671+
} else if (property == plane->chroma_siting_h_property) {
672+
*val = state->chroma_siting_h;
673+
} else if (property == plane->chroma_siting_v_property) {
674+
*val = state->chroma_siting_v;
667675
} else if (property == config->prop_fb_damage_clips) {
668676
*val = (state->fb_damage_clips) ?
669677
state->fb_damage_clips->base.id : 0;

‎drivers/gpu/drm/drm_color_mgmt.c‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,42 @@ int drm_plane_create_color_properties(struct drm_plane *plane,
586586
}
587587
EXPORT_SYMBOL(drm_plane_create_color_properties);
588588

589+
/**
590+
* drm_plane_create_chroma_siting_properties - chroma siting related plane properties
591+
* @plane: plane object
592+
*
593+
* Create and attach plane specific CHROMA_SITING
594+
* properties to @plane.
595+
*/
596+
int drm_plane_create_chroma_siting_properties(struct drm_plane *plane,
597+
int32_t default_chroma_siting_h,
598+
int32_t default_chroma_siting_v)
599+
{
600+
struct drm_device *dev = plane->dev;
601+
struct drm_property *prop;
602+
603+
prop = drm_property_create_range(dev, 0, "CHROMA_SITING_H",
604+
0, 1<<16);
605+
if (!prop)
606+
return -ENOMEM;
607+
plane->chroma_siting_h_property = prop;
608+
drm_object_attach_property(&plane->base, prop, default_chroma_siting_h);
609+
610+
prop = drm_property_create_range(dev, 0, "CHROMA_SITING_V",
611+
0, 1<<16);
612+
if (!prop)
613+
return -ENOMEM;
614+
plane->chroma_siting_v_property = prop;
615+
drm_object_attach_property(&plane->base, prop, default_chroma_siting_v);
616+
617+
if (plane->state) {
618+
plane->state->chroma_siting_h = default_chroma_siting_h;
619+
plane->state->chroma_siting_v = default_chroma_siting_v;
620+
}
621+
return 0;
622+
}
623+
EXPORT_SYMBOL(drm_plane_create_chroma_siting_properties);
624+
589625
/**
590626
* drm_color_lut_check - check validity of lookup table
591627
* @lut: property blob containing LUT to check

‎include/drm/drm_color_mgmt.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ int drm_plane_create_color_properties(struct drm_plane *plane,
9393
enum drm_color_encoding default_encoding,
9494
enum drm_color_range default_range);
9595

96+
int drm_plane_create_chroma_siting_properties(struct drm_plane *plane,
97+
int32_t default_chroma_siting_h, int32_t default_chroma_siting_v);
98+
9699
/**
97100
* enum drm_color_lut_tests - hw-specific LUT tests to perform
98101
*

‎include/drm/drm_plane.h‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,24 @@ struct drm_plane_state {
179179
*/
180180
enum drm_color_range color_range;
181181

182+
/**
183+
* @chroma_siting_h:
184+
*
185+
* Location of chroma samples horizontally compared to luma
186+
* 0 means chroma is sited with left luma
187+
* 0x8000 is interstitial. 0x10000 is sited with right luma
188+
*/
189+
int32_t chroma_siting_h;
190+
191+
/**
192+
* @chroma_siting_v:
193+
*
194+
* Location of chroma samples vertically compared to luma
195+
* 0 means chroma is sited with top luma
196+
* 0x8000 is interstitial. 0x10000 is sited with bottom luma
197+
*/
198+
int32_t chroma_siting_v;
199+
182200
/**
183201
* @fb_damage_clips:
184202
*
@@ -750,6 +768,24 @@ struct drm_plane {
750768
* scaling.
751769
*/
752770
struct drm_property *scaling_filter_property;
771+
772+
/**
773+
* @chroma_siting_h_property:
774+
*
775+
* Optional "CHROMA_SITING_H" property for specifying
776+
* chroma siting for YUV formats.
777+
* See drm_plane_create_chroma_siting_properties().
778+
*/
779+
struct drm_property *chroma_siting_h_property;
780+
781+
/**
782+
* @chroma_siting_v_property:
783+
*
784+
* Optional "CHROMA_SITING_V" property for specifying
785+
* chroma siting for YUV formats.
786+
* See drm_plane_create_chroma_siting_properties().
787+
*/
788+
struct drm_property *chroma_siting_v_property;
753789
};
754790

755791
#define obj_to_plane(x) container_of(x, struct drm_plane, base)

0 commit comments

Comments
 (0)