From: Dan Carpenter <error27@gmail.com>
To: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Cc: amd-gfx@lists.freedesktop.org, "SHANMUGAM,
SRINIVASAN" <SRINIVASAN.SHANMUGAM@amd.com>
Subject: [bug report] drm/amdgpu: Implement "color format" DRM property
Date: Fri, 10 Jul 2026 10:15:50 +0300 [thread overview]
Message-ID: <alCcJmDeIYEE94Eh@stanley.mountain> (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
reply other threads:[~2026-07-12 15:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alCcJmDeIYEE94Eh@stanley.mountain \
--to=error27@gmail.com \
--cc=SRINIVASAN.SHANMUGAM@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=nicolas.frattaroli@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox