Commit e8d726b7 authored by Reza Amini's avatar Reza Amini Committed by Alex Deucher

drm/amd/display: refactor member referencing to improve readability

Signed-off-by: default avatarReza Amini <reza.amini@amd.com>
Reviewed-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 934d2923
...@@ -1519,17 +1519,16 @@ static void set_avi_info_frame( ...@@ -1519,17 +1519,16 @@ static void set_avi_info_frame(
uint8_t cn0_cn1 = 0; uint8_t cn0_cn1 = 0;
uint8_t *check_sum = NULL; uint8_t *check_sum = NULL;
uint8_t byte_index = 0; uint8_t byte_index = 0;
union hdmi_info_packet *hdmi_info = &info_frame.avi_info_packet.info_packet_hdmi;
color_space = pipe_ctx->stream->public.output_color_space; color_space = pipe_ctx->stream->public.output_color_space;
/* Initialize header */ /* Initialize header */
info_frame.avi_info_packet.info_packet_hdmi.bits.header. hdmi_info->bits.header.info_frame_type = HDMI_INFOFRAME_TYPE_AVI;
info_frame_type = HDMI_INFOFRAME_TYPE_AVI;
/* InfoFrameVersion_3 is defined by CEA861F (Section 6.4), but shall /* InfoFrameVersion_3 is defined by CEA861F (Section 6.4), but shall
* not be used in HDMI 2.0 (Section 10.1) */ * not be used in HDMI 2.0 (Section 10.1) */
info_frame.avi_info_packet.info_packet_hdmi.bits.header.version = 2; hdmi_info->bits.header.version = 2;
info_frame.avi_info_packet.info_packet_hdmi.bits.header.length = hdmi_info->bits.header.length = HDMI_AVI_INFOFRAME_SIZE;
HDMI_AVI_INFOFRAME_SIZE;
/* /*
* IDO-defined (Y2,Y1,Y0 = 1,1,1) shall not be used by devices built * IDO-defined (Y2,Y1,Y0 = 1,1,1) shall not be used by devices built
...@@ -1555,52 +1554,41 @@ static void set_avi_info_frame( ...@@ -1555,52 +1554,41 @@ static void set_avi_info_frame(
/* Y0_Y1_Y2 : The pixel encoding */ /* Y0_Y1_Y2 : The pixel encoding */
/* H14b AVI InfoFrame has extension on Y-field from 2 bits to 3 bits */ /* H14b AVI InfoFrame has extension on Y-field from 2 bits to 3 bits */
info_frame.avi_info_packet.info_packet_hdmi.bits.Y0_Y1_Y2 = hdmi_info->bits.Y0_Y1_Y2 = pixel_encoding;
pixel_encoding;
/* A0 = 1 Active Format Information valid */ /* A0 = 1 Active Format Information valid */
info_frame.avi_info_packet.info_packet_hdmi.bits.A0 = hdmi_info->bits.A0 = ACTIVE_FORMAT_VALID;
ACTIVE_FORMAT_VALID;
/* B0, B1 = 3; Bar info data is valid */ /* B0, B1 = 3; Bar info data is valid */
info_frame.avi_info_packet.info_packet_hdmi.bits.B0_B1 = hdmi_info->bits.B0_B1 = BAR_INFO_BOTH_VALID;
BAR_INFO_BOTH_VALID;
info_frame.avi_info_packet.info_packet_hdmi.bits.SC0_SC1 = hdmi_info->bits.SC0_SC1 = PICTURE_SCALING_UNIFORM;
PICTURE_SCALING_UNIFORM;
/* S0, S1 : Underscan / Overscan */ /* S0, S1 : Underscan / Overscan */
/* TODO: un-hardcode scan type */ /* TODO: un-hardcode scan type */
scan_type = SCANNING_TYPE_UNDERSCAN; scan_type = SCANNING_TYPE_UNDERSCAN;
info_frame.avi_info_packet.info_packet_hdmi.bits.S0_S1 = scan_type; hdmi_info->bits.S0_S1 = scan_type;
/* C0, C1 : Colorimetry */ /* C0, C1 : Colorimetry */
if (color_space == COLOR_SPACE_YCBCR709 || if (color_space == COLOR_SPACE_YCBCR709 ||
color_space == COLOR_SPACE_YCBCR709_LIMITED) color_space == COLOR_SPACE_YCBCR709_LIMITED)
info_frame.avi_info_packet.info_packet_hdmi.bits.C0_C1 = hdmi_info->bits.C0_C1 = COLORIMETRY_ITU709;
COLORIMETRY_ITU709;
else if (color_space == COLOR_SPACE_YCBCR601 || else if (color_space == COLOR_SPACE_YCBCR601 ||
color_space == COLOR_SPACE_YCBCR601_LIMITED) color_space == COLOR_SPACE_YCBCR601_LIMITED)
info_frame.avi_info_packet.info_packet_hdmi.bits.C0_C1 = hdmi_info->bits.C0_C1 = COLORIMETRY_ITU601;
COLORIMETRY_ITU601;
else { else {
if (stream->public.timing.pixel_encoding != PIXEL_ENCODING_RGB) if (stream->public.timing.pixel_encoding != PIXEL_ENCODING_RGB)
BREAK_TO_DEBUGGER(); BREAK_TO_DEBUGGER();
info_frame.avi_info_packet.info_packet_hdmi.bits.C0_C1 = hdmi_info->bits.C0_C1 = COLORIMETRY_NO_DATA;
COLORIMETRY_NO_DATA;
} }
if (color_space == COLOR_SPACE_2020_RGB_FULLRANGE || if (color_space == COLOR_SPACE_2020_RGB_FULLRANGE ||
color_space == COLOR_SPACE_2020_RGB_LIMITEDRANGE || color_space == COLOR_SPACE_2020_RGB_LIMITEDRANGE ||
color_space == COLOR_SPACE_2020_YCBCR) { color_space == COLOR_SPACE_2020_YCBCR) {
info_frame.avi_info_packet.info_packet_hdmi.bits.EC0_EC2 = hdmi_info->bits.EC0_EC2 = COLORIMETRYEX_BT2020RGBYCBCR;
COLORIMETRYEX_BT2020RGBYCBCR; hdmi_info->bits.C0_C1 = COLORIMETRY_EXTENDED;
info_frame.avi_info_packet.info_packet_hdmi.bits.C0_C1 =
COLORIMETRY_EXTENDED;
} else if (color_space == COLOR_SPACE_ADOBERGB) { } else if (color_space == COLOR_SPACE_ADOBERGB) {
info_frame.avi_info_packet.info_packet_hdmi.bits.EC0_EC2 = hdmi_info->bits.EC0_EC2 = COLORIMETRYEX_ADOBERGB;
COLORIMETRYEX_ADOBERGB; hdmi_info->bits.C0_C1 = COLORIMETRY_EXTENDED;
info_frame.avi_info_packet.info_packet_hdmi.bits.C0_C1 =
COLORIMETRY_EXTENDED;
} }
/* TODO: un-hardcode aspect ratio */ /* TODO: un-hardcode aspect ratio */
...@@ -1609,93 +1597,76 @@ static void set_avi_info_frame( ...@@ -1609,93 +1597,76 @@ static void set_avi_info_frame(
switch (aspect) { switch (aspect) {
case ASPECT_RATIO_4_3: case ASPECT_RATIO_4_3:
case ASPECT_RATIO_16_9: case ASPECT_RATIO_16_9:
info_frame.avi_info_packet.info_packet_hdmi.bits.M0_M1 = aspect; hdmi_info->bits.M0_M1 = aspect;
break; break;
case ASPECT_RATIO_NO_DATA: case ASPECT_RATIO_NO_DATA:
case ASPECT_RATIO_64_27: case ASPECT_RATIO_64_27:
case ASPECT_RATIO_256_135: case ASPECT_RATIO_256_135:
default: default:
info_frame.avi_info_packet.info_packet_hdmi.bits.M0_M1 = 0; hdmi_info->bits.M0_M1 = 0;
} }
/* Active Format Aspect ratio - same as Picture Aspect Ratio. */ /* Active Format Aspect ratio - same as Picture Aspect Ratio. */
info_frame.avi_info_packet.info_packet_hdmi.bits.R0_R3 = hdmi_info->bits.R0_R3 = ACTIVE_FORMAT_ASPECT_RATIO_SAME_AS_PICTURE;
ACTIVE_FORMAT_ASPECT_RATIO_SAME_AS_PICTURE;
/* TODO: un-hardcode cn0_cn1 and itc */ /* TODO: un-hardcode cn0_cn1 and itc */
cn0_cn1 = 0; cn0_cn1 = 0;
itc = false; itc = false;
if (itc) { if (itc) {
info_frame.avi_info_packet.info_packet_hdmi.bits.ITC = 1; hdmi_info->bits.ITC = 1;
info_frame.avi_info_packet.info_packet_hdmi.bits.CN0_CN1 = hdmi_info->bits.CN0_CN1 = cn0_cn1;
cn0_cn1;
} }
/* TODO : We should handle YCC quantization */ /* TODO : We should handle YCC quantization */
/* but we do not have matrix calculation */ /* but we do not have matrix calculation */
if (color_space == COLOR_SPACE_SRGB) { if (color_space == COLOR_SPACE_SRGB) {
info_frame.avi_info_packet.info_packet_hdmi.bits.Q0_Q1 = hdmi_info->bits.Q0_Q1 = RGB_QUANTIZATION_FULL_RANGE;
RGB_QUANTIZATION_FULL_RANGE; hdmi_info->bits.YQ0_YQ1 = YYC_QUANTIZATION_FULL_RANGE;
info_frame.avi_info_packet.info_packet_hdmi.bits.YQ0_YQ1 =
YYC_QUANTIZATION_FULL_RANGE;
} else if (color_space == COLOR_SPACE_SRGB_LIMITED) { } else if (color_space == COLOR_SPACE_SRGB_LIMITED) {
info_frame.avi_info_packet.info_packet_hdmi.bits.Q0_Q1 = hdmi_info->bits.Q0_Q1 = RGB_QUANTIZATION_LIMITED_RANGE;
RGB_QUANTIZATION_LIMITED_RANGE; hdmi_info->bits.YQ0_YQ1 = YYC_QUANTIZATION_LIMITED_RANGE;
info_frame.avi_info_packet.info_packet_hdmi.bits.YQ0_YQ1 =
YYC_QUANTIZATION_LIMITED_RANGE;
} else { } else {
info_frame.avi_info_packet.info_packet_hdmi.bits.Q0_Q1 = hdmi_info->bits.Q0_Q1 = RGB_QUANTIZATION_DEFAULT_RANGE;
RGB_QUANTIZATION_DEFAULT_RANGE; hdmi_info->bits.YQ0_YQ1 = YYC_QUANTIZATION_LIMITED_RANGE;
info_frame.avi_info_packet.info_packet_hdmi.bits.YQ0_YQ1 =
YYC_QUANTIZATION_LIMITED_RANGE;
} }
info_frame.avi_info_packet.info_packet_hdmi.bits.VIC0_VIC7 = hdmi_info->bits.VIC0_VIC7 =
stream->public.timing.vic; stream->public.timing.vic;
/* pixel repetition /* pixel repetition
* PR0 - PR3 start from 0 whereas pHwPathMode->mode.timing.flags.pixel * PR0 - PR3 start from 0 whereas pHwPathMode->mode.timing.flags.pixel
* repetition start from 1 */ * repetition start from 1 */
info_frame.avi_info_packet.info_packet_hdmi.bits.PR0_PR3 = 0; hdmi_info->bits.PR0_PR3 = 0;
/* Bar Info /* Bar Info
* barTop: Line Number of End of Top Bar. * barTop: Line Number of End of Top Bar.
* barBottom: Line Number of Start of Bottom Bar. * barBottom: Line Number of Start of Bottom Bar.
* barLeft: Pixel Number of End of Left Bar. * barLeft: Pixel Number of End of Left Bar.
* barRight: Pixel Number of Start of Right Bar. */ * barRight: Pixel Number of Start of Right Bar. */
info_frame.avi_info_packet.info_packet_hdmi.bits.bar_top = hdmi_info->bits.bar_top = stream->public.timing.v_border_top;
stream->public.timing.v_border_top; hdmi_info->bits.bar_bottom = (stream->public.timing.v_border_top
info_frame.avi_info_packet.info_packet_hdmi.bits.bar_bottom =
(stream->public.timing.v_border_top
- stream->public.timing.v_border_bottom + 1); - stream->public.timing.v_border_bottom + 1);
info_frame.avi_info_packet.info_packet_hdmi.bits.bar_left = hdmi_info->bits.bar_left = stream->public.timing.h_border_left;
stream->public.timing.h_border_left; hdmi_info->bits.bar_right = (stream->public.timing.h_total
info_frame.avi_info_packet.info_packet_hdmi.bits.bar_right =
(stream->public.timing.h_total
- stream->public.timing.h_border_right + 1); - stream->public.timing.h_border_right + 1);
/* check_sum - Calculate AFMT_AVI_INFO0 ~ AFMT_AVI_INFO3 */ /* check_sum - Calculate AFMT_AVI_INFO0 ~ AFMT_AVI_INFO3 */
check_sum = check_sum = &info_frame.avi_info_packet.info_packet_hdmi.packet_raw_data.sb[0];
&info_frame.
avi_info_packet.info_packet_hdmi.packet_raw_data.sb[0];
*check_sum = HDMI_INFOFRAME_TYPE_AVI + HDMI_AVI_INFOFRAME_SIZE + 2; *check_sum = HDMI_INFOFRAME_TYPE_AVI + HDMI_AVI_INFOFRAME_SIZE + 2;
for (byte_index = 1; byte_index <= HDMI_AVI_INFOFRAME_SIZE; byte_index++) for (byte_index = 1; byte_index <= HDMI_AVI_INFOFRAME_SIZE; byte_index++)
*check_sum += info_frame.avi_info_packet.info_packet_hdmi. *check_sum += hdmi_info->packet_raw_data.sb[byte_index];
packet_raw_data.sb[byte_index];
/* one byte complement */ /* one byte complement */
*check_sum = (uint8_t) (0x100 - *check_sum); *check_sum = (uint8_t) (0x100 - *check_sum);
/* Store in hw_path_mode */ /* Store in hw_path_mode */
info_packet->hb0 = info_packet->hb0 = hdmi_info->packet_raw_data.hb0;
info_frame.avi_info_packet.info_packet_hdmi.packet_raw_data.hb0; info_packet->hb1 = hdmi_info->packet_raw_data.hb1;
info_packet->hb1 = info_packet->hb2 = hdmi_info->packet_raw_data.hb2;
info_frame.avi_info_packet.info_packet_hdmi.packet_raw_data.hb1;
info_packet->hb2 =
info_frame.avi_info_packet.info_packet_hdmi.packet_raw_data.hb2;
for (byte_index = 0; byte_index < sizeof(info_frame.avi_info_packet. for (byte_index = 0; byte_index < sizeof(info_frame.avi_info_packet.
info_packet_hdmi.packet_raw_data.sb); byte_index++) info_packet_hdmi.packet_raw_data.sb); byte_index++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment