Skip to contentSkip to conversation

drm/amdgpu: Implement "color format" DRM property

bug report Dan Carpenter 1 participant 1 message Jul 12

lore
Share & tools
lore
#0 lore raw

Hello Nicolas Frattaroli,

Commit 8a0343b03b98 ("drm/amdgpu: Implement "color format" DRM property") from Jun 9, 2026 (linux-next), leads to the following Smatch static checker warning:

	drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_connector.c:857 fill_stream_properties_from_drm_display_mode()
	warn: duplicate zero check 'connector_state->color_format' (previous on line 848)

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_connector.c

    801 static void fill_stream_properties_from_drm_display_mode(
    802         struct dc_stream_state *stream,
    803         const struct drm_display_mode *mode_in,
    804         const struct drm_connector *connector,
    805         const struct drm_connector_state *connector_state,
    806         const struct dc_stream_state *old_stream,
    807         int requested_bpc)
    808 {
    809         bool is_dp_or_hdmi = dc_is_hdmi_signal(stream->signal) || dc_is_dp_signal(stream->signal);
    810         struct dc_crtc_timing *timing_out = &stream->timing;
    811         const struct drm_display_info *info = &connector->display_info;
    812         struct amdgpu_dm_connector *aconnector = NULL;
    813         struct hdmi_vendor_infoframe hv_frame;
    814         struct hdmi_avi_infoframe avi_frame;
    815         bool want_420;
    816         bool want_422;
    817         ssize_t err;
    818 
    819         if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
    820                 aconnector = to_amdgpu_dm_connector(connector);
    821 
    822         memset(&hv_frame, 0, sizeof(hv_frame));
    823         memset(&avi_frame, 0, sizeof(avi_frame));
    824 
    825         timing_out->h_border_left = 0;
    826         timing_out->h_border_right = 0;
    827         timing_out->v_border_top = 0;
    828         timing_out->v_border_bottom = 0;
    829 
    830         want_420 = (aconnector && aconnector->force_yuv_pixel_format == PIXEL_ENCODING_YCBCR420) ||
    831                    (connector_state->color_format == DRM_CONNECTOR_COLOR_FORMAT_YCBCR420);
    832         want_422 = (aconnector && aconnector->force_yuv_pixel_format == PIXEL_ENCODING_YCBCR422) ||
    833                    (connector_state->color_format == DRM_CONNECTOR_COLOR_FORMAT_YCBCR422);
    834 
    835         if (drm_mode_is_420_only(info, mode_in) &&
    836             (want_420 || connector_state->color_format == DRM_CONNECTOR_COLOR_FORMAT_AUTO)) {
    837                 timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420;
    838         } else if (drm_mode_is_420_also(info, mode_in) && want_420) {
    839                 timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420;
    840         } else if ((info->color_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422)) &&
    841                    want_422 && is_dp_or_hdmi) {
    842                 timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR422;
    843         } else if (connector_state->color_format == DRM_CONNECTOR_COLOR_FORMAT_YCBCR444 &&
    844                    (info->color_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR444)) &&
    845                    is_dp_or_hdmi) {
    846                 timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR444;
    847         } else if (connector_state->color_format == DRM_CONNECTOR_COLOR_FORMAT_RGB444 ||
    848                    connector_state->color_format == DRM_CONNECTOR_COLOR_FORMAT_AUTO) {
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AUTO is handled here.

849 timing_out->pixel_encoding = PIXEL_ENCODING_RGB;
850 } else {
851 /*
852 * If a format was explicitly requested but the requested format
853 * can't be satisfied, set it to an invalid value so that an
854 * error bubbles up to userspace. This way, userspace knows it
855 * needs to make a better choice.
856 */
--> 857 if (connector_state->color_format != DRM_CONNECTOR_COLOR_FORMAT_AUTO)

    858                         timing_out->pixel_encoding = PIXEL_ENCODING_UNDEFINED;

So we know this is true and the else if else is dead code.

    859                 else if (drm_mode_is_420_only(info, mode_in))
    860                         timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420;
    861                 else
    862                         timing_out->pixel_encoding = PIXEL_ENCODING_RGB;
    863         }
    864 
    865         timing_out->timing_3d_format = TIMING_3D_FORMAT_NONE;
    866         timing_out->display_color_depth = amdgpu_dm_convert_color_depth_from_display_info(
    867                 connector,
    868                 (timing_out->pixel_encoding == PIXEL_ENCODING_YCBCR420),
    869                 requested_bpc);
    870         timing_out->scan_type = SCANNING_TYPE_NODATA;
    871         timing_out->hdmi_vic = 0;
    872 

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter