This patch adds "pixel_encoding" connector property, which allows user to switch to different pixel encodings. This is useful and could solve some problems that auto switch would do something wrong(Basically because of wrong EDID info).
Supported encodings are: "auto" (0) (Default and original behavior), "rgb" (1), "ycbcr444" (2), "ycbcr422" (4), and "ycbcr420" (8). Signed-off-by: Matias N. Goldberg <dark_syl...@yahoo.com.ar> Signed-off-by: Rafael Carvalho <cont...@rafaelrc.com> Signed-off-by: Shengyu Qu <wiagn...@outlook.com> --- drivers/gpu/drm/drm_modes.c | 32 ++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 7 +++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index e72f855fc495..ac2265e71b00 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2162,6 +2162,35 @@ static int drm_mode_parse_tv_mode(const char *delim, return 0; } +static int drm_mode_parse_pixel_encoding(const char *delim, + struct drm_cmdline_mode *mode) +{ + const char *value; + + if (*delim != '=') + return -EINVAL; + + value = delim + 1; + delim = strchr(value, ','); + if (!delim) + delim = value + strlen(value); + + if (!strncmp(value, "auto", delim - value)) + mode->pixel_encoding = 0; + else if (!strncmp(value, "rgb", delim - value)) + mode->pixel_encoding = DRM_COLOR_FORMAT_RGB444; + else if (!strncmp(value, "ycbcr444", delim - value)) + mode->pixel_encoding = DRM_COLOR_FORMAT_YCBCR444; + else if (!strncmp(value, "ycbcr422", delim - value)) + mode->pixel_encoding = DRM_COLOR_FORMAT_YCBCR422; + else if (!strncmp(value, "ycbcr420", delim - value)) + mode->pixel_encoding = DRM_COLOR_FORMAT_YCBCR420; + else + return -EINVAL; + + return 0; +} + static int drm_mode_parse_cmdline_options(const char *str, bool freestanding, const struct drm_connector *connector, @@ -2234,6 +2263,9 @@ static int drm_mode_parse_cmdline_options(const char *str, } else if (!strncmp(option, "tv_mode", delim - option)) { if (drm_mode_parse_tv_mode(delim, mode)) return -EINVAL; + } else if (!strncmp(option, "pixel_encoding", delim - option)) { + if (drm_mode_parse_pixel_encoding(delim, mode)) + return -EINVAL; } else { return -EINVAL; } diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index f13d597370a3..fdaa86d25d6d 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1723,6 +1723,13 @@ struct drm_cmdline_mode { * Did the mode have a preferred TV mode? */ bool tv_mode_specified; + + /** + * @pixel_encoding: + * + * Output pixel format encoding. + */ + unsigned int pixel_encoding; }; /** -- 2.43.0