From: "Timur Kristóf" <timur.kristof@gmail.com>
To: amd-gfx@lists.freedesktop.org, Alexander.Deucher@amd.com,
Christian.Koenig@amd.com,
Mario Limonciello <mario.limonciello@amd.com>,
Ivan Lipski <ivan.lipski@amd.com>, Alex Hung <alex.hung@amd.com>,
Prike Liang <Prike.Liang@amd.com>, Leo Li <sunpeng.li@amd.com>,
Ray Wu <Ray.Wu@amd.com>,
siqueira@igalia.com
Cc: "Timur Kristóf" <timur.kristof@gmail.com>
Subject: [PATCH 04/14] drm/amd/display: Add color depth helper function to BIOS parser
Date: Mon, 26 Jan 2026 22:08:27 +0100 [thread overview]
Message-ID: <20260126210837.21885-5-timur.kristof@gmail.com> (raw)
In-Reply-To: <20260126210837.21885-1-timur.kristof@gmail.com>
To improve consistency and avoid duplicating the same code.
Also, properly handle all enum values where they weren't
handled correctly before.
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
---
.../drm/amd/display/dc/bios/command_table.c | 101 +++++-------------
1 file changed, 26 insertions(+), 75 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/bios/command_table.c b/drivers/gpu/drm/amd/display/dc/bios/command_table.c
index 76a3559f0ddc..b638cb5adb92 100644
--- a/drivers/gpu/drm/amd/display/dc/bios/command_table.c
+++ b/drivers/gpu/drm/amd/display/dc/bios/command_table.c
@@ -226,6 +226,28 @@ static enum bp_result encoder_control_dig2_v1(
return result;
}
+static uint8_t dc_color_depth_to_atom(enum dc_color_depth color_depth)
+{
+ switch (color_depth) {
+ case COLOR_DEPTH_UNDEFINED:
+ return PANEL_BPC_UNDEFINE;
+ case COLOR_DEPTH_666:
+ return PANEL_6BIT_PER_COLOR;
+ default:
+ case COLOR_DEPTH_888:
+ return PANEL_8BIT_PER_COLOR;
+ case COLOR_DEPTH_101010:
+ return PANEL_10BIT_PER_COLOR;
+ case COLOR_DEPTH_121212:
+ return PANEL_12BIT_PER_COLOR;
+ case COLOR_DEPTH_141414:
+ dm_error("14-bit color not supported by ATOMBIOS\n");
+ return PANEL_BPC_UNDEFINE;
+ case COLOR_DEPTH_161616:
+ return PANEL_16BIT_PER_COLOR;
+ }
+}
+
static enum bp_result encoder_control_digx_v3(
struct bios_parser *bp,
struct bp_encoder_control *cntl)
@@ -248,23 +270,7 @@ static enum bp_result encoder_control_digx_v3(
cntl->signal,
cntl->enable_dp_audio);
params.ucLaneNum = (uint8_t)(cntl->lanes_number);
-
- switch (cntl->color_depth) {
- case COLOR_DEPTH_888:
- params.ucBitPerColor = PANEL_8BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_101010:
- params.ucBitPerColor = PANEL_10BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_121212:
- params.ucBitPerColor = PANEL_12BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_161616:
- params.ucBitPerColor = PANEL_16BIT_PER_COLOR;
- break;
- default:
- break;
- }
+ params.ucBitPerColor = dc_color_depth_to_atom(cntl->color_depth);
if (EXEC_BIOS_CMD_TABLE(DIGxEncoderControl, params))
result = BP_RESULT_OK;
@@ -294,23 +300,7 @@ static enum bp_result encoder_control_digx_v4(
cntl->signal,
cntl->enable_dp_audio));
params.ucLaneNum = (uint8_t)(cntl->lanes_number);
-
- switch (cntl->color_depth) {
- case COLOR_DEPTH_888:
- params.ucBitPerColor = PANEL_8BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_101010:
- params.ucBitPerColor = PANEL_10BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_121212:
- params.ucBitPerColor = PANEL_12BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_161616:
- params.ucBitPerColor = PANEL_16BIT_PER_COLOR;
- break;
- default:
- break;
- }
+ params.ucBitPerColor = dc_color_depth_to_atom(cntl->color_depth);
if (EXEC_BIOS_CMD_TABLE(DIGxEncoderControl, params))
result = BP_RESULT_OK;
@@ -334,23 +324,7 @@ static enum bp_result encoder_control_digx_v5(
cntl->signal,
cntl->enable_dp_audio));
params.ucLaneNum = (uint8_t)(cntl->lanes_number);
-
- switch (cntl->color_depth) {
- case COLOR_DEPTH_888:
- params.ucBitPerColor = PANEL_8BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_101010:
- params.ucBitPerColor = PANEL_10BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_121212:
- params.ucBitPerColor = PANEL_12BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_161616:
- params.ucBitPerColor = PANEL_16BIT_PER_COLOR;
- break;
- default:
- break;
- }
+ params.ucBitPerColor = dc_color_depth_to_atom(cntl->color_depth);
if (cntl->signal == SIGNAL_TYPE_HDMI_TYPE_A)
switch (cntl->color_depth) {
@@ -1797,30 +1771,7 @@ static enum bp_result select_crtc_source_v3(
¶ms.ucEncodeMode))
return BP_RESULT_BADINPUT;
- switch (bp_params->color_depth) {
- case COLOR_DEPTH_UNDEFINED:
- params.ucDstBpc = PANEL_BPC_UNDEFINE;
- break;
- case COLOR_DEPTH_666:
- params.ucDstBpc = PANEL_6BIT_PER_COLOR;
- break;
- default:
- case COLOR_DEPTH_888:
- params.ucDstBpc = PANEL_8BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_101010:
- params.ucDstBpc = PANEL_10BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_121212:
- params.ucDstBpc = PANEL_12BIT_PER_COLOR;
- break;
- case COLOR_DEPTH_141414:
- dm_error("14-bit color not supported by SelectCRTC_Source v3\n");
- break;
- case COLOR_DEPTH_161616:
- params.ucDstBpc = PANEL_16BIT_PER_COLOR;
- break;
- }
+ params.ucDstBpc = dc_color_depth_to_atom(bp_params->color_depth);
if (EXEC_BIOS_CMD_TABLE(SelectCRTC_Source, params))
result = BP_RESULT_OK;
--
2.52.0
next prev parent reply other threads:[~2026-01-26 21:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 21:08 [PATCH 00/14] drm/amd/display: Add support for external DP bridge encoders in DC Timur Kristóf
2026-01-26 21:08 ` [PATCH 01/14] drm/amd/display: Use DCE 6 link encoder for DCE 6 analog connectors Timur Kristóf
2026-01-26 21:08 ` [PATCH 02/14] drm/amd/display: Only use analog link encoder with analog engine Timur Kristóf
2026-01-26 21:08 ` [PATCH 03/14] drm/amd/display: Only use analog stream " Timur Kristóf
2026-01-26 21:08 ` Timur Kristóf [this message]
2026-01-26 21:08 ` [PATCH 05/14] drm/amd/display: Refactor DAC load detection, move to HWSS Timur Kristóf
2026-01-30 20:00 ` Alex Hung
2026-01-26 21:08 ` [PATCH 06/14] drm/amd/display: Implement BIOS parser external encoder control Timur Kristóf
2026-01-26 21:08 ` [PATCH 07/14] drm/amd/display: Implement DDC probe over AUX channel Timur Kristóf
2026-01-30 19:53 ` Alex Hung
2026-01-26 21:08 ` [PATCH 08/14] drm/amd/display: Add ability for HWSS to prepare the DDC before use Timur Kristóf
2026-01-26 21:08 ` [PATCH 09/14] drm/amd/display: Use preferred DP link rate if specified Timur Kristóf
2026-01-26 21:08 ` [PATCH 10/14] drm/amd/display: Add DCE HWSS support for external DP bridge encoders Timur Kristóf
2026-01-26 21:08 ` [PATCH 11/14] drm/amd/display: Link detection " Timur Kristóf
2026-01-26 21:08 ` [PATCH 12/14] drm/amd/display: Use " Timur Kristóf
2026-01-26 21:08 ` [PATCH 13/14] drm/amd/display: Implement DAC load detection on " Timur Kristóf
2026-01-26 21:08 ` [PATCH 14/14] drm/amdgpu: Use DC by default on CIK APUs Timur Kristóf
2026-02-09 15:35 ` [PATCH 00/14] drm/amd/display: Add support for external DP bridge encoders in DC Rodrigo Siqueira
2026-02-09 18:12 ` Alex Hung
2026-02-09 22:10 ` Timur Kristóf
2026-02-09 23:14 ` Alex Hung
2026-02-16 4:33 ` Alex Hung
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=20260126210837.21885-5-timur.kristof@gmail.com \
--to=timur.kristof@gmail.com \
--cc=Alexander.Deucher@amd.com \
--cc=Christian.Koenig@amd.com \
--cc=Prike.Liang@amd.com \
--cc=Ray.Wu@amd.com \
--cc=alex.hung@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=ivan.lipski@amd.com \
--cc=mario.limonciello@amd.com \
--cc=siqueira@igalia.com \
--cc=sunpeng.li@amd.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