di-edid-decode: Move some timing printing to a shared file
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
This commit is contained in:
1 parent
9ff243bd91
commit
2d98815b45
5 files changed
+181
-149
No files matched your search
+2
-93
@@ -10,67 +10,10 @@
|
||||
#include "bits.h"
|
||||
#include "di-edid-decode.h"
|
||||
|
||||
static const char *
|
||||
video_format_picture_aspect_ratio_name(enum di_cta_vic_video_format_picture_aspect_ratio ar)
|
||||
{
|
||||
switch (ar) {
|
||||
case DI_CTA_VIC_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_4_3:
|
||||
return " 4:3 ";
|
||||
case DI_CTA_VIC_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_16_9:
|
||||
return " 16:9 ";
|
||||
case DI_CTA_VIC_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_64_27:
|
||||
return " 64:27 ";
|
||||
case DI_CTA_VIC_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_256_135:
|
||||
return "256:135";
|
||||
}
|
||||
abort(); /* unreachable */
|
||||
}
|
||||
|
||||
static void
|
||||
print_cta_vic(struct di_cta_vic vic)
|
||||
{
|
||||
const struct di_cta_vic_video_format *fmt;
|
||||
int32_t h_blank, v_blank, v_active;
|
||||
double refresh, h_freq_hz, pixel_clock_mhz, h_total, v_total;
|
||||
char buf[10];
|
||||
|
||||
printf(" VIC %3" PRIu8, vic.code);
|
||||
|
||||
fmt = di_cta_vic_video_format_from_vic(vic);
|
||||
if (fmt == NULL)
|
||||
return;
|
||||
|
||||
v_active = fmt->v_active;
|
||||
if (fmt->interlaced)
|
||||
v_active /= 2;
|
||||
|
||||
h_blank = fmt->h_front + fmt->h_sync + fmt->h_back;
|
||||
v_blank = fmt->v_front + fmt->v_sync + fmt->v_back;
|
||||
h_total = fmt->h_active + h_blank;
|
||||
|
||||
v_total = v_active + v_blank;
|
||||
if (fmt->interlaced)
|
||||
v_total += 0.5;
|
||||
|
||||
refresh = (double) fmt->pixel_clock_hz / (h_total * v_total);
|
||||
h_freq_hz = (double) fmt->pixel_clock_hz / h_total;
|
||||
pixel_clock_mhz = (double) fmt->pixel_clock_hz / (1000 * 1000);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%d%s",
|
||||
fmt->v_active,
|
||||
fmt->interlaced ? "i" : "");
|
||||
|
||||
printf(":");
|
||||
printf(" %5dx%-5s", fmt->h_active, buf);
|
||||
printf(" %10.6f Hz", refresh);
|
||||
printf(" %s", video_format_picture_aspect_ratio_name(fmt->picture_aspect_ratio));
|
||||
printf(" %8.3f kHz %13.6f MHz", h_freq_hz / 1000, pixel_clock_mhz);
|
||||
}
|
||||
|
||||
static void
|
||||
printf_cta_svd(const struct di_cta_svd *svd)
|
||||
{
|
||||
print_cta_vic(svd->vic);
|
||||
print_cta_vic_timing(svd->vic);
|
||||
if (svd->native)
|
||||
printf(" (native)");
|
||||
printf("\n");
|
||||
@@ -85,40 +28,6 @@ printf_cta_svds(const struct di_cta_svd *const *svds)
|
||||
printf_cta_svd(svds[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
print_hdmi_vic(const struct di_hdmi_vic vic)
|
||||
{
|
||||
const struct di_hdmi_vic_video_format *fmt;
|
||||
int32_t h_blank, v_blank;
|
||||
double refresh, h_freq_hz, pixel_clock_mhz, h_total, v_total;
|
||||
int horiz_ratio, vert_ratio;
|
||||
|
||||
printf(" HDMI VIC %" PRIu8, vic.code);
|
||||
|
||||
fmt = di_hdmi_vic_video_format_from_vic(vic);
|
||||
if (fmt == NULL)
|
||||
return;
|
||||
|
||||
compute_aspect_ratio(fmt->h_active, fmt->v_active, &horiz_ratio, &vert_ratio);
|
||||
|
||||
h_blank = fmt->h_front + fmt->h_sync + fmt->h_back;
|
||||
v_blank = fmt->v_front + fmt->v_sync + fmt->v_back;
|
||||
h_total = fmt->h_active + h_blank;
|
||||
|
||||
v_total = fmt->v_active + v_blank;
|
||||
|
||||
refresh = (double) fmt->pixel_clock_hz / (h_total * v_total);
|
||||
h_freq_hz = (double) fmt->pixel_clock_hz / h_total;
|
||||
pixel_clock_mhz = (double) fmt->pixel_clock_hz / (1000 * 1000);
|
||||
|
||||
printf(":");
|
||||
printf(" %5dx%-5d", fmt->h_active, fmt->v_active);
|
||||
printf(" %10.6f Hz", refresh);
|
||||
/* Not part of the spec, but edid-decode prints the aspect ratio. */
|
||||
printf(" %3u:%-3u", horiz_ratio, vert_ratio);
|
||||
printf(" %8.3f kHz %13.6f MHz", h_freq_hz / 1000, pixel_clock_mhz);
|
||||
}
|
||||
|
||||
static const char *
|
||||
vesa_display_device_interface_type_name(enum di_cta_vesa_display_device_interface_type type)
|
||||
{
|
||||
@@ -929,7 +838,7 @@ print_cta_hdmi(const struct di_cta_vendor_hdmi_block *hdmi)
|
||||
printf(" HDMI VICs:\n");
|
||||
for (i = 0; i < hdmi->vics_len; i++) {
|
||||
printf(" ");
|
||||
print_hdmi_vic(hdmi->vics[i]);
|
||||
print_hdmi_vic_timing(hdmi->vics[i]);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-55
@@ -382,57 +382,6 @@ print_color_point(const struct di_edid_color_point *c)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_dmt_timing(const struct di_dmt_timing *t)
|
||||
{
|
||||
int hbl, vbl, horiz_total, vert_total, horiz_ratio, vert_ratio;
|
||||
double refresh, horiz_freq_hz, pixel_clock_mhz;
|
||||
|
||||
compute_aspect_ratio(t->horiz_video, t->vert_video,
|
||||
&horiz_ratio, &vert_ratio);
|
||||
|
||||
hbl = t->horiz_blank - 2 * t->horiz_border;
|
||||
vbl = t->vert_blank - 2 * t->vert_border;
|
||||
horiz_total = t->horiz_video + hbl;
|
||||
vert_total = t->vert_video + vbl;
|
||||
refresh = (double) t->pixel_clock_hz / (horiz_total * vert_total);
|
||||
horiz_freq_hz = (double) t->pixel_clock_hz / horiz_total;
|
||||
pixel_clock_mhz = (double) t->pixel_clock_hz / (1000 * 1000);
|
||||
|
||||
printf(" DMT 0x%02x:", t->dmt_id);
|
||||
printf(" %5dx%-5d", t->horiz_video, t->vert_video);
|
||||
printf(" %10.6f Hz", refresh);
|
||||
printf(" %3u:%-3u", horiz_ratio, vert_ratio);
|
||||
printf(" %8.3f kHz %13.6f MHz", horiz_freq_hz / 1000, pixel_clock_mhz);
|
||||
if (t->reduced_blanking)
|
||||
printf(" (RB)");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
print_cvt_timing(struct di_cvt_timing *t, struct di_cvt_options *options,
|
||||
int hratio, int vratio, bool preferred, bool rb)
|
||||
{
|
||||
double hbl, htotal;
|
||||
|
||||
hbl = t->h_front_porch + t->h_sync + t->h_back_porch;
|
||||
htotal = t->total_active_pixels + hbl;
|
||||
|
||||
printf(" CVT: %5dx%-5d", (int)options->h_pixels, (int)options->v_lines);
|
||||
printf(" %10.6f Hz", t->act_frame_rate);
|
||||
printf(" %3u:%-3u", hratio, vratio);
|
||||
printf(" %8.3f kHz %13.6f MHz", t->act_pixel_freq * 1000 / htotal,
|
||||
(double) t->act_pixel_freq);
|
||||
|
||||
if (preferred || rb) {
|
||||
printf(" (%s%s%s)", rb ? "RB" : "",
|
||||
(preferred && rb) ? ", " : "",
|
||||
preferred ? "preferred vertical rate" : "");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
print_cvt_timing_code(const struct di_edid_cvt_timing_code *t)
|
||||
{
|
||||
@@ -525,7 +474,6 @@ print_display_desc(const struct di_edid *edid,
|
||||
const struct di_edid_standard_timing *const *standard_timings;
|
||||
const struct di_edid_color_point *const *color_points;
|
||||
const struct di_edid_established_timings_iii *established_timings_iii;
|
||||
const struct di_dmt_timing *dmt_timing;
|
||||
const struct di_edid_color_management_data *color_management_data;
|
||||
const struct di_edid_cvt_timing_code *const *cvt_timings;
|
||||
size_t i;
|
||||
@@ -648,9 +596,7 @@ print_display_desc(const struct di_edid *edid,
|
||||
|
||||
printf("\n");
|
||||
for (i = 0; i < established_timings_iii->dmt_codes_len; i++) {
|
||||
dmt_timing = di_dmt_timing_from_code(established_timings_iii->dmt_codes[i]);
|
||||
if (dmt_timing)
|
||||
print_dmt_timing(dmt_timing);
|
||||
print_dmt_timing_code(established_timings_iii->dmt_codes[i]);
|
||||
}
|
||||
break;
|
||||
case DI_EDID_DISPLAY_DESCRIPTOR_DCM_DATA:
|
||||
|
||||
@@ -7,6 +7,7 @@ di_edid_decode = executable(
|
||||
'edid.c',
|
||||
'main.c',
|
||||
'util.c',
|
||||
'timing.c',
|
||||
],
|
||||
dependencies: [di_dep, math],
|
||||
install: true,
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libdisplay-info/dmt.h>
|
||||
#include <libdisplay-info/cta-vic.h>
|
||||
#include <libdisplay-info/hdmi-vic.h>
|
||||
|
||||
#include "di-edid-decode.h"
|
||||
|
||||
static const char *
|
||||
video_format_picture_aspect_ratio_name(enum di_cta_vic_video_format_picture_aspect_ratio ar)
|
||||
{
|
||||
switch (ar) {
|
||||
case DI_CTA_VIC_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_4_3:
|
||||
return " 4:3 ";
|
||||
case DI_CTA_VIC_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_16_9:
|
||||
return " 16:9 ";
|
||||
case DI_CTA_VIC_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_64_27:
|
||||
return " 64:27 ";
|
||||
case DI_CTA_VIC_VIDEO_FORMAT_PICTURE_ASPECT_RATIO_256_135:
|
||||
return "256:135";
|
||||
}
|
||||
abort(); /* unreachable */
|
||||
}
|
||||
|
||||
void
|
||||
print_cta_vic_timing(struct di_cta_vic vic)
|
||||
{
|
||||
const struct di_cta_vic_video_format *fmt;
|
||||
int32_t h_blank, v_blank, v_active;
|
||||
double refresh, h_freq_hz, pixel_clock_mhz, h_total, v_total;
|
||||
char buf[10];
|
||||
|
||||
printf(" VIC %3" PRIu8, vic.code);
|
||||
|
||||
fmt = di_cta_vic_video_format_from_vic(vic);
|
||||
if (fmt == NULL)
|
||||
return;
|
||||
|
||||
v_active = fmt->v_active;
|
||||
if (fmt->interlaced)
|
||||
v_active /= 2;
|
||||
|
||||
h_blank = fmt->h_front + fmt->h_sync + fmt->h_back;
|
||||
v_blank = fmt->v_front + fmt->v_sync + fmt->v_back;
|
||||
h_total = fmt->h_active + h_blank;
|
||||
|
||||
v_total = v_active + v_blank;
|
||||
if (fmt->interlaced)
|
||||
v_total += 0.5;
|
||||
|
||||
refresh = (double) fmt->pixel_clock_hz / (h_total * v_total);
|
||||
h_freq_hz = (double) fmt->pixel_clock_hz / h_total;
|
||||
pixel_clock_mhz = (double) fmt->pixel_clock_hz / (1000 * 1000);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%d%s",
|
||||
fmt->v_active,
|
||||
fmt->interlaced ? "i" : "");
|
||||
|
||||
printf(":");
|
||||
printf(" %5dx%-5s", fmt->h_active, buf);
|
||||
printf(" %10.6f Hz", refresh);
|
||||
printf(" %s", video_format_picture_aspect_ratio_name(fmt->picture_aspect_ratio));
|
||||
printf(" %8.3f kHz %13.6f MHz", h_freq_hz / 1000, pixel_clock_mhz);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_hdmi_vic_timing(const struct di_hdmi_vic vic)
|
||||
{
|
||||
const struct di_hdmi_vic_video_format *fmt;
|
||||
int32_t h_blank, v_blank;
|
||||
double refresh, h_freq_hz, pixel_clock_mhz, h_total, v_total;
|
||||
int horiz_ratio, vert_ratio;
|
||||
|
||||
printf(" HDMI VIC %" PRIu8, vic.code);
|
||||
|
||||
fmt = di_hdmi_vic_video_format_from_vic(vic);
|
||||
if (fmt == NULL)
|
||||
return;
|
||||
|
||||
compute_aspect_ratio(fmt->h_active, fmt->v_active, &horiz_ratio, &vert_ratio);
|
||||
|
||||
h_blank = fmt->h_front + fmt->h_sync + fmt->h_back;
|
||||
v_blank = fmt->v_front + fmt->v_sync + fmt->v_back;
|
||||
h_total = fmt->h_active + h_blank;
|
||||
|
||||
v_total = fmt->v_active + v_blank;
|
||||
|
||||
refresh = (double) fmt->pixel_clock_hz / (h_total * v_total);
|
||||
h_freq_hz = (double) fmt->pixel_clock_hz / h_total;
|
||||
pixel_clock_mhz = (double) fmt->pixel_clock_hz / (1000 * 1000);
|
||||
|
||||
printf(":");
|
||||
printf(" %5dx%-5d", fmt->h_active, fmt->v_active);
|
||||
printf(" %10.6f Hz", refresh);
|
||||
/* Not part of the spec, but edid-decode prints the aspect ratio. */
|
||||
printf(" %3u:%-3u", horiz_ratio, vert_ratio);
|
||||
printf(" %8.3f kHz %13.6f MHz", h_freq_hz / 1000, pixel_clock_mhz);
|
||||
}
|
||||
|
||||
void
|
||||
print_dmt_timing_code(uint8_t dmt_code)
|
||||
{
|
||||
const struct di_dmt_timing *t;
|
||||
int hbl, vbl, horiz_total, vert_total, horiz_ratio, vert_ratio;
|
||||
double refresh, horiz_freq_hz, pixel_clock_mhz;
|
||||
|
||||
printf(" ");
|
||||
|
||||
t = di_dmt_timing_from_code(dmt_code);
|
||||
if (!t) {
|
||||
printf("DMT 0x%02x: Unknown\n", t->dmt_id);
|
||||
}
|
||||
|
||||
compute_aspect_ratio(t->horiz_video, t->vert_video,
|
||||
&horiz_ratio, &vert_ratio);
|
||||
|
||||
hbl = t->horiz_blank - 2 * t->horiz_border;
|
||||
vbl = t->vert_blank - 2 * t->vert_border;
|
||||
horiz_total = t->horiz_video + hbl;
|
||||
vert_total = t->vert_video + vbl;
|
||||
refresh = (double) t->pixel_clock_hz / (horiz_total * vert_total);
|
||||
horiz_freq_hz = (double) t->pixel_clock_hz / horiz_total;
|
||||
pixel_clock_mhz = (double) t->pixel_clock_hz / (1000 * 1000);
|
||||
|
||||
printf("DMT 0x%02x:", t->dmt_id);
|
||||
printf(" %5dx%-5d", t->horiz_video, t->vert_video);
|
||||
printf(" %10.6f Hz", refresh);
|
||||
printf(" %3u:%-3u", horiz_ratio, vert_ratio);
|
||||
printf(" %8.3f kHz %13.6f MHz", horiz_freq_hz / 1000, pixel_clock_mhz);
|
||||
if (t->reduced_blanking)
|
||||
printf(" (RB)");
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void
|
||||
print_cvt_timing(struct di_cvt_timing *t, struct di_cvt_options *options,
|
||||
int hratio, int vratio, bool preferred, bool rb)
|
||||
{
|
||||
double hbl, htotal;
|
||||
|
||||
hbl = t->h_front_porch + t->h_sync + t->h_back_porch;
|
||||
htotal = t->total_active_pixels + hbl;
|
||||
|
||||
printf(" CVT: %5dx%-5d", (int)options->h_pixels, (int)options->v_lines);
|
||||
printf(" %10.6f Hz", t->act_frame_rate);
|
||||
printf(" %3u:%-3u", hratio, vratio);
|
||||
printf(" %8.3f kHz %13.6f MHz", t->act_pixel_freq * 1000 / htotal,
|
||||
(double) t->act_pixel_freq);
|
||||
|
||||
if (preferred || rb) {
|
||||
printf(" (%s%s%s)", rb ? "RB" : "",
|
||||
(preferred && rb) ? ", " : "",
|
||||
preferred ? "preferred vertical rate" : "");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <libdisplay-info/edid.h>
|
||||
#include <libdisplay-info/cta.h>
|
||||
#include <libdisplay-info/cvt.h>
|
||||
#include <libdisplay-info/displayid.h>
|
||||
|
||||
struct uncommon_features {
|
||||
@@ -37,7 +38,20 @@ print_displayid2(const struct di_displayid2 *displayid2);
|
||||
|
||||
void
|
||||
print_displayid_type_i_ii_vii_timing(const struct di_displayid_type_i_ii_vii_timing *t,
|
||||
int indent, const char *prefix);
|
||||
int indent, const char *prefix);
|
||||
|
||||
void
|
||||
print_cta_vic_timing(struct di_cta_vic vic);
|
||||
|
||||
void
|
||||
print_hdmi_vic_timing(const struct di_hdmi_vic vic);
|
||||
|
||||
void
|
||||
print_dmt_timing_code(uint8_t dmt_code);
|
||||
|
||||
void
|
||||
print_cvt_timing(struct di_cvt_timing *t, struct di_cvt_options *options,
|
||||
int hratio, int vratio, bool preferred, bool rb);
|
||||
|
||||
void
|
||||
compute_aspect_ratio(int width, int height, int *horiz_ratio, int *vert_ratio);
|
||||
|
||||
Reference in new issue
Block a user