bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0790-vc4-drm-plane-Make-use-of-chroma-siting-parameter.patch
1 From bb6fb3a029e8d745640aedce2ee57fc3fee73ea9 Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Thu, 27 Jan 2022 15:32:04 +0000
4 Subject: [PATCH] vc4/drm:plane: Make use of chroma siting parameter
5
6 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
7 ---
8 drivers/gpu/drm/vc4/vc4_plane.c | 13 +++++++++----
9 1 file changed, 9 insertions(+), 4 deletions(-)
10
11 --- a/drivers/gpu/drm/vc4/vc4_plane.c
12 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
13 @@ -461,17 +461,18 @@ static void vc4_write_tpz(struct vc4_pla
14 /* phase magnitude bits */
15 #define PHASE_BITS 6
16
17 -static void vc4_write_ppf(struct vc4_plane_state *vc4_state, u32 src, u32 dst, u32 xy, int channel)
18 +static void vc4_write_ppf(struct vc4_plane_state *vc4_state, u32 src, u32 dst, u32 xy, int channel, int chroma_offset)
19 {
20 u32 scale = src / dst;
21 s32 offset, offset2;
22 s32 phase;
23
24 /* Start the phase at 1/2 pixel from the 1st pixel at src_x.
25 - 1/4 pixel for YUV. */
26 + 1/4 pixel for YUV, plus the offset for chroma siting */
27 if (channel) {
28 /* the phase is relative to scale_src->x, so shift it for display list's x value */
29 offset = (xy & 0x1ffff) >> (16 - PHASE_BITS) >> 1;
30 + offset -= chroma_offset >> (17 - PHASE_BITS);
31 offset += -(1 << PHASE_BITS >> 2);
32 } else {
33 /* the phase is relative to scale_src->x, so shift it for display list's x value */
34 @@ -557,13 +558,15 @@ static void vc4_write_scaling_parameters
35 /* Ch0 H-PPF Word 0: Scaling Parameters */
36 if (vc4_state->x_scaling[channel] == VC4_SCALING_PPF) {
37 vc4_write_ppf(vc4_state,
38 - vc4_state->src_w[channel], vc4_state->crtc_w, vc4_state->src_x, channel);
39 + vc4_state->src_w[channel], vc4_state->crtc_w, vc4_state->src_x, channel,
40 + state->chroma_siting_h);
41 }
42
43 /* Ch0 V-PPF Words 0-1: Scaling Parameters, Context */
44 if (vc4_state->y_scaling[channel] == VC4_SCALING_PPF) {
45 vc4_write_ppf(vc4_state,
46 - vc4_state->src_h[channel], vc4_state->crtc_h, vc4_state->src_y, channel);
47 + vc4_state->src_h[channel], vc4_state->crtc_h, vc4_state->src_y, channel,
48 + state->chroma_siting_v);
49 vc4_dlist_write(vc4_state, 0xc0c0c0c0);
50 }
51
52 @@ -1622,6 +1625,8 @@ struct drm_plane *vc4_plane_init(struct
53 DRM_COLOR_YCBCR_BT709,
54 DRM_COLOR_YCBCR_LIMITED_RANGE);
55
56 + drm_plane_create_chroma_siting_properties(plane, 0, 0);
57 +
58 if (type == DRM_PLANE_TYPE_PRIMARY)
59 drm_plane_create_zpos_immutable_property(plane, 0);
60