From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/rockchip: vop2: Add YUV support to background color Date: Thu, 04 Jun 2026 13:48:15 +1000 Message-ID: In-Reply-To: <20260601-vop2-bg-yuv-v2-2-e5aef1d16fec@collabora.com> References: <20260601-vop2-bg-yuv-v2-0-e5aef1d16fec@collabora.com> <20260601-vop2-bg-yuv-v2-2-e5aef1d16fec@collabora.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review **Conversion math:** The `COEFF` macro and matrix coefficients match the v4l2-tpg reference implementation exactly. The arithmetic correctly operates in 16-bit precision space: - Coefficients encode `v * range * 256` as compile-time constants - Inputs are `u16` (from `DRM_ARGB64_GETR/G/B`) - Products can reach ~3.67 billion for white, exceeding `s32` -- correctly handled via `s64` intermediates - `>> 16` shift and 16-bit offsets (`16 << 8` for Y, `128 << 8` for chroma) produce correct 16-bit YCbCr values - Final `>> 6` to 10-bit for the hardware register is correct (e.g., limited-range white Y: `235 << 8 >> 6 = 940`) **Minor observations:** 1. **Remaining `crtc->state` usage in `atomic_enable`:** The patch correctly changes `vcstate` to use `crtc_state` (from `drm_atomic_get_new_crtc_state`), but several lines later, `mode` is still derived from `crtc->state->adjusted_mode`: ```c struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc); struct rockchip_crtc_state *vcstate = to_rockchip_crtc_state(crtc_state); struct drm_display_mode *mode = &crtc->state->adjusted_mode; /* still uses crtc->state */ ``` This is a **pre-existing issue** not introduced by this patch, but since `vcstate` was changed to use the proper atomic state, it would have been a good opportunity to also fix `mode` to use `&crtc_state->adjusted_mode`. At minimum this is worth noting so it doesn't regress further. 2. **`vop2_rgb16_to_yuv16` parameter naming:** The first parameter is `int v4l2_cs`, which takes a V4L2 colorspace enum value. The v2 changelog correctly notes this was fixed to use `vop2_convert_csc_mode()` internally, which is the right approach since `vcstate->color_space` stores a V4L2 colorspace, not a `vop_csc_format`. The function signature is clear about what it accepts. 3. **Floating-point in `COEFF` macro:** The macro `((s32)(0.5 + (v) * (r) * 256.0))` uses floating-point arithmetic, which is only valid in constant-expression context in the kernel. Since it's exclusively used in `static const` struct initializers, this is correct. The `#define` is file-scoped and not `#undef`'d, but it's a common enough pattern (the v4l2-tpg code does the same). 4. **State comparison in `vop2_bgcolor_setup`:** The early-return check compares both `background_color` and `color_space`: ```c if (!force && old_crtc_state->background_color == bgcolor && old_vcstate->color_space == new_vcstate->color_space) return; ``` This correctly handles the case where the background color hasn't changed but the colorspace has (which would require re-conversion). The `force` flag on enable is also correct since hardware state is unknown after power-on. The check does not compare `yuv_overlay`, so if the overlay mode changes between RGB and YUV without a colorspace change, the background color would still need reprogramming. However, an overlay mode change implies a modeset, which goes through `atomic_enable` with `force=true`, so this is safe. **Overall: clean patch, correct math, sensible split of work between enable and flush paths. Good to go.** --- Generated by Claude Code Patch Reviewer