Skip to content

Commit

Permalink
Display: report platform api used for detection
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Oct 14, 2024
1 parent 0f1ad57 commit 71a8978
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 21 deletions.
4 changes: 3 additions & 1 deletion src/detection/displayserver/displayserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ FFDisplayResult* ffdsAppendDisplay(
bool primary,
uint64_t id,
uint32_t physicalWidth,
uint32_t physicalHeight)
uint32_t physicalHeight,
const char* platformApi)
{
if(width == 0 || height == 0)
return NULL;
Expand All @@ -31,6 +32,7 @@ FFDisplayResult* ffdsAppendDisplay(
display->physicalWidth = physicalWidth;
display->physicalHeight = physicalHeight;
display->primary = primary;
display->platformApi = platformApi;

display->bitDepth = 0;
display->hdrStatus = FF_DISPLAY_HDR_STATUS_UNKNOWN;
Expand Down
4 changes: 3 additions & 1 deletion src/detection/displayserver/displayserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ typedef struct FFDisplayResult
uint32_t physicalWidth;
uint32_t physicalHeight;
bool primary;
const char* platformApi;
uint8_t bitDepth;
FFDisplayHdrStatus hdrStatus;
uint16_t manufactureYear;
Expand Down Expand Up @@ -102,4 +103,5 @@ FFDisplayResult* ffdsAppendDisplay(
bool primary,
uint64_t id,
uint32_t physicalWidth,
uint32_t physicalHeight);
uint32_t physicalHeight,
const char* platformApi);
6 changes: 4 additions & 2 deletions src/detection/displayserver/displayserver_android.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ static void detectWithDumpsys(FFDisplayServerResult* ds)
false,
0,
0,
0
0,
"dumpsys"
);
}

Expand Down Expand Up @@ -100,7 +101,8 @@ static bool detectWithGetprop(FFDisplayServerResult* ds)
false,
0,
0,
0
0,
"getprop"
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/detection/displayserver/displayserver_apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ static void detectDisplays(FFDisplayServerResult* ds)
CGDisplayIsMain(screen),
(uint64_t)screen,
physicalWidth,
physicalHeight
physicalHeight,
"CoreGraphics"
);
if (display)
{
Expand Down
3 changes: 2 additions & 1 deletion src/detection/displayserver/displayserver_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ static void detectDisplays(FFDisplayServerResult* ds)
!!(monitorInfo->info.dwFlags & MONITORINFOF_PRIMARY),
(uint64_t)(uintptr_t) monitorInfo->handle,
physicalWidth,
physicalHeight
physicalHeight,
"GDI"
);

if (display)
Expand Down
2 changes: 1 addition & 1 deletion src/detection/displayserver/linux/displayserver_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
if (ffSettingsGetFreeBSDKenv("screen.height", &buf))
{
uint32_t height = (uint32_t) ffStrbufToUInt(&buf, 0);
ffdsAppendDisplay(ds, width, height, 0, 0, 0, 0, NULL, FF_DISPLAY_TYPE_UNKNOWN, false, 0, 0, 0);
ffdsAppendDisplay(ds, width, height, 0, 0, 0, 0, NULL, FF_DISPLAY_TYPE_UNKNOWN, false, 0, 0, 0, "kenv");
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/detection/displayserver/linux/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ static const char* drmParseSysfs(FFDisplayServerResult* result)
false,
0,
physicalWidth,
physicalHeight
physicalHeight,
"sysfs-drm"
);
if (item && edidLength)
{
Expand Down Expand Up @@ -390,7 +391,8 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
false,
conn->connector_id,
conn->mmWidth,
conn->mmHeight
conn->mmHeight,
"libdrm"
);

if (item)
Expand Down
3 changes: 2 additions & 1 deletion src/detection/displayserver/linux/wayland/global-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ void ffWaylandHandleGlobalOutput(WaylandData* wldata, struct wl_registry* regist
false,
display.id,
(uint32_t) display.physicalWidth,
(uint32_t) display.physicalHeight
(uint32_t) display.physicalHeight,
"wayland-global"
);
if (item)
{
Expand Down
3 changes: 2 additions & 1 deletion src/detection/displayserver/linux/wayland/kde-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ void ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* registry,
false,
display.id,
(uint32_t) display.physicalWidth,
(uint32_t) display.physicalHeight
(uint32_t) display.physicalHeight,
"wayland-kde"
);
if (item)
{
Expand Down
3 changes: 2 additions & 1 deletion src/detection/displayserver/linux/wayland/zwlr-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ static void waylandHandleZwlrHead(void *data, FF_MAYBE_UNUSED struct zwlr_output
false,
display.id,
(uint32_t) display.physicalWidth,
(uint32_t) display.physicalHeight
(uint32_t) display.physicalHeight,
"wayland-zwlr"
);
if (item)
{
Expand Down
12 changes: 8 additions & 4 deletions src/detection/displayserver/linux/xcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ const char* ffdsConnectXcb(FFDisplayServerResult* result)
false,
0,
(uint32_t) screen->width_in_millimeters,
(uint32_t) screen->height_in_millimeters
(uint32_t) screen->height_in_millimeters,
"xcb"
);
ffxcb_screen_next(&iterator);
}
Expand Down Expand Up @@ -239,7 +240,8 @@ static bool xcbRandrHandleCrtc(XcbRandrData* data, xcb_randr_crtc_t crtc, FFstrb
primary,
0,
(uint32_t) output->mm_width,
(uint32_t) output->mm_height
(uint32_t) output->mm_height,
"xcb-randr-crtc"
);
if (item && edidLength)
{
Expand Down Expand Up @@ -327,7 +329,8 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t*
!!monitor->primary,
0,
(uint32_t) monitor->width_in_millimeters,
(uint32_t) monitor->height_in_millimeters
(uint32_t) monitor->height_in_millimeters,
"xcb-randr-monitor"
);
}

Expand Down Expand Up @@ -381,7 +384,8 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
false,
0,
(uint32_t) screen->width_in_millimeters,
(uint32_t) screen->height_in_millimeters
(uint32_t) screen->height_in_millimeters,
"xcb-randr-screen"
);
}

Expand Down
12 changes: 8 additions & 4 deletions src/detection/displayserver/linux/xlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ const char* ffdsConnectXlib(FFDisplayServerResult* result)
false,
0,
(uint32_t) WidthMMOfScreen(screen),
(uint32_t) HeightMMOfScreen(screen)
(uint32_t) HeightMMOfScreen(screen),
"xlib"
);
}

Expand Down Expand Up @@ -193,7 +194,8 @@ static bool xrandrHandleCrtc(XrandrData* data, XRROutputInfo* output, FFstrbuf*
primary,
0,
(uint32_t) output->mm_width,
(uint32_t) output->mm_height
(uint32_t) output->mm_height,
"xlib-randr-crtc"
);

if (edidLength)
Expand Down Expand Up @@ -268,7 +270,8 @@ static bool xrandrHandleMonitor(XrandrData* data, XRRMonitorInfo* monitorInfo)
!!monitorInfo->primary,
0,
(uint32_t) monitorInfo->mwidth,
(uint32_t) monitorInfo->mheight
(uint32_t) monitorInfo->mheight,
"xlib-randr-monitor"
);
}

Expand Down Expand Up @@ -318,7 +321,8 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
false,
0,
(uint32_t) WidthMMOfScreen(screen),
(uint32_t) HeightMMOfScreen(screen)
(uint32_t) HeightMMOfScreen(screen),
"xlib_randr_screen"
);
}

Expand Down
6 changes: 5 additions & 1 deletion src/modules/display/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <math.h>

#define FF_DISPLAY_NUM_FORMAT_ARGS 18
#define FF_DISPLAY_NUM_FORMAT_ARGS 19

static int sortByNameAsc(FFDisplayResult* a, FFDisplayResult* b)
{
Expand Down Expand Up @@ -181,6 +181,7 @@ void ffPrintDisplay(FFDisplayOptions* options)
FF_FORMAT_ARG(result->manufactureYear, "manufacture-year"),
FF_FORMAT_ARG(result->manufactureWeek, "manufacture-week"),
FF_FORMAT_ARG(buf, "serial"),
FF_FORMAT_ARG(result->platformApi, "platform-api"),
}));
}
}
Expand Down Expand Up @@ -395,6 +396,8 @@ void ffGenerateDisplayJsonResult(FF_MAYBE_UNUSED FFDisplayOptions* options, yyjs
yyjson_mut_obj_add_uint(doc, obj, "serial", item->serial);
else
yyjson_mut_obj_add_null(doc, obj, "serial");

yyjson_mut_obj_add_str(doc, obj, "platformApi", item->platformApi);
}
}

Expand All @@ -419,6 +422,7 @@ void ffPrintDisplayHelpFormat(void)
"Year of manufacturing - manufacture-year",
"Nth week of manufacturing in the year - manufacture-week",
"Serial number - serial",
"The platform API used when detecting the display - platform-api",
}));
}

Expand Down

0 comments on commit 71a8978

Please sign in to comment.