950-0042-drm-Add-chroma-siting-properties.patch 5.6 KB

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