mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 14:15:58 +01:00
Revert "backend/drm: fetch EDID manufacturer from udev_hwdb"
This reverts commit e646d882cf
.
This commit has added a dependency on udev_hwdb. This API isn't
available on all platforms (e.g. FreeBSD), and further deepens
our udev dependency. A better solution is being worked on in [1].
[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3638
This commit is contained in:
parent
4152db92ef
commit
d75b4d8e86
3 changed files with 74 additions and 56 deletions
|
@ -1,7 +1,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <drm_fourcc.h>
|
#include <drm_fourcc.h>
|
||||||
#include <libudev.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -58,7 +57,6 @@ static void backend_destroy(struct wlr_backend *backend) {
|
||||||
|
|
||||||
finish_drm_resources(drm);
|
finish_drm_resources(drm);
|
||||||
|
|
||||||
udev_hwdb_unref(drm->hwdb);
|
|
||||||
free(drm->name);
|
free(drm->name);
|
||||||
wlr_session_close_file(drm->session, drm->dev);
|
wlr_session_close_file(drm->session, drm->dev);
|
||||||
wl_event_source_remove(drm->drm_event);
|
wl_event_source_remove(drm->drm_event);
|
||||||
|
@ -176,23 +174,6 @@ static void handle_parent_destroy(struct wl_listener *listener, void *data) {
|
||||||
backend_destroy(&drm->backend);
|
backend_destroy(&drm->backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct udev_hwdb *create_udev_hwdb(void) {
|
|
||||||
struct udev *udev = udev_new();
|
|
||||||
if (!udev) {
|
|
||||||
wlr_log(WLR_ERROR, "udev_new failed");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct udev_hwdb *hwdb = udev_hwdb_new(udev);
|
|
||||||
udev_unref(udev);
|
|
||||||
if (!hwdb) {
|
|
||||||
wlr_log(WLR_ERROR, "udev_hwdb_new failed");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hwdb;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
|
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
|
||||||
struct wlr_session *session, struct wlr_device *dev,
|
struct wlr_session *session, struct wlr_device *dev,
|
||||||
struct wlr_backend *parent) {
|
struct wlr_backend *parent) {
|
||||||
|
@ -247,12 +228,6 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
|
||||||
drm->session_active.notify = handle_session_active;
|
drm->session_active.notify = handle_session_active;
|
||||||
wl_signal_add(&session->events.active, &drm->session_active);
|
wl_signal_add(&session->events.active, &drm->session_active);
|
||||||
|
|
||||||
drm->hwdb = create_udev_hwdb();
|
|
||||||
if (!drm->hwdb) {
|
|
||||||
wlr_log(WLR_INFO, "Failed to load udev_hwdb, "
|
|
||||||
"falling back to PnP IDs instead of manufacturer names");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!check_drm_features(drm)) {
|
if (!check_drm_features(drm)) {
|
||||||
goto error_event;
|
goto error_event;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +279,6 @@ error_mgpu_renderer:
|
||||||
error_resources:
|
error_resources:
|
||||||
finish_drm_resources(drm);
|
finish_drm_resources(drm);
|
||||||
error_event:
|
error_event:
|
||||||
udev_hwdb_unref(drm->hwdb);
|
|
||||||
wl_list_remove(&drm->session_active.link);
|
wl_list_remove(&drm->session_active.link);
|
||||||
wl_event_source_remove(drm->drm_event);
|
wl_event_source_remove(drm->drm_event);
|
||||||
error_fd:
|
error_fd:
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <drm_fourcc.h>
|
#include <drm_fourcc.h>
|
||||||
#include <drm_mode.h>
|
#include <drm_mode.h>
|
||||||
#include <drm.h>
|
#include <drm.h>
|
||||||
#include <libudev.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -49,34 +48,80 @@ enum wlr_output_mode_aspect_ratio get_picture_aspect_ratio(const drmModeModeInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *get_manufacturer(struct udev_hwdb *hwdb, uint16_t code) {
|
// Constructed from http://edid.tv/manufacturer
|
||||||
static char pnp_id[4];
|
static const char *get_manufacturer(uint16_t id) {
|
||||||
|
#define ID(a, b, c) ((a & 0x1f) << 10) | ((b & 0x1f) << 5) | (c & 0x1f)
|
||||||
// The ASCII 3-letter manufacturer PnP ID is encoded in 5-bit codes
|
switch (id) {
|
||||||
pnp_id[0] = ((code >> 10) & 0x1F) + '@';
|
case ID('A', 'A', 'A'): return "Avolites Ltd";
|
||||||
pnp_id[1] = ((code >> 5) & 0x1F) + '@';
|
case ID('A', 'C', 'I'): return "Ancor Communications Inc";
|
||||||
pnp_id[2] = ((code >> 0) & 0x1F) + '@';
|
case ID('A', 'C', 'R'): return "Acer Technologies";
|
||||||
pnp_id[3] = '\0';
|
case ID('A', 'D', 'A'): return "Addi-Data GmbH";
|
||||||
|
case ID('A', 'P', 'P'): return "Apple Computer Inc";
|
||||||
if (hwdb == NULL) {
|
case ID('A', 'S', 'K'): return "Ask A/S";
|
||||||
return pnp_id;
|
case ID('A', 'V', 'T'): return "Avtek (Electronics) Pty Ltd";
|
||||||
|
case ID('B', 'N', 'O'): return "Bang & Olufsen";
|
||||||
|
case ID('B', 'N', 'Q'): return "BenQ Corporation";
|
||||||
|
case ID('C', 'M', 'N'): return "Chimei Innolux Corporation";
|
||||||
|
case ID('C', 'M', 'O'): return "Chi Mei Optoelectronics corp.";
|
||||||
|
case ID('C', 'R', 'O'): return "Extraordinary Technologies PTY Limited";
|
||||||
|
case ID('D', 'E', 'L'): return "Dell Inc.";
|
||||||
|
case ID('D', 'G', 'C'): return "Data General Corporation";
|
||||||
|
case ID('D', 'O', 'N'): return "DENON, Ltd.";
|
||||||
|
case ID('E', 'N', 'C'): return "Eizo Nanao Corporation";
|
||||||
|
case ID('E', 'P', 'H'): return "Epiphan Systems Inc.";
|
||||||
|
case ID('E', 'X', 'P'): return "Data Export Corporation";
|
||||||
|
case ID('F', 'N', 'I'): return "Funai Electric Co., Ltd.";
|
||||||
|
case ID('F', 'U', 'S'): return "Fujitsu Siemens Computers GmbH";
|
||||||
|
case ID('G', 'S', 'M'): return "Goldstar Company Ltd";
|
||||||
|
case ID('H', 'I', 'Q'): return "Kaohsiung Opto Electronics Americas, Inc.";
|
||||||
|
case ID('H', 'S', 'D'): return "HannStar Display Corp";
|
||||||
|
case ID('H', 'T', 'C'): return "Hitachi Ltd";
|
||||||
|
case ID('H', 'W', 'P'): return "Hewlett Packard";
|
||||||
|
case ID('I', 'N', 'T'): return "Interphase Corporation";
|
||||||
|
case ID('I', 'N', 'X'): return "Communications Supply Corporation (A division of WESCO)";
|
||||||
|
case ID('I', 'T', 'E'): return "Integrated Tech Express Inc";
|
||||||
|
case ID('I', 'V', 'M'): return "Iiyama North America";
|
||||||
|
case ID('L', 'E', 'N'): return "Lenovo Group Limited";
|
||||||
|
case ID('M', 'A', 'X'): return "Rogen Tech Distribution Inc";
|
||||||
|
case ID('M', 'E', 'G'): return "Abeam Tech Ltd";
|
||||||
|
case ID('M', 'E', 'I'): return "Panasonic Industry Company";
|
||||||
|
case ID('M', 'T', 'C'): return "Mars-Tech Corporation";
|
||||||
|
case ID('M', 'T', 'X'): return "Matrox";
|
||||||
|
case ID('N', 'E', 'C'): return "NEC Corporation";
|
||||||
|
case ID('N', 'E', 'X'): return "Nexgen Mediatech Inc.";
|
||||||
|
case ID('O', 'N', 'K'): return "ONKYO Corporation";
|
||||||
|
case ID('O', 'R', 'N'): return "ORION ELECTRIC CO., LTD.";
|
||||||
|
case ID('O', 'T', 'M'): return "Optoma Corporation";
|
||||||
|
case ID('O', 'V', 'R'): return "Oculus VR, Inc.";
|
||||||
|
case ID('P', 'H', 'L'): return "Philips Consumer Electronics Company";
|
||||||
|
case ID('P', 'I', 'O'): return "Pioneer Electronic Corporation";
|
||||||
|
case ID('P', 'N', 'R'): return "Planar Systems, Inc.";
|
||||||
|
case ID('Q', 'D', 'S'): return "Quanta Display Inc.";
|
||||||
|
case ID('R', 'A', 'T'): return "Rent-A-Tech";
|
||||||
|
case ID('R', 'E', 'N'): return "Renesas Technology Corp.";
|
||||||
|
case ID('S', 'A', 'M'): return "Samsung Electric Company";
|
||||||
|
case ID('S', 'A', 'N'): return "Sanyo Electric Co., Ltd.";
|
||||||
|
case ID('S', 'E', 'C'): return "Seiko Epson Corporation";
|
||||||
|
case ID('S', 'H', 'P'): return "Sharp Corporation";
|
||||||
|
case ID('S', 'I', 'I'): return "Silicon Image, Inc.";
|
||||||
|
case ID('S', 'N', 'Y'): return "Sony";
|
||||||
|
case ID('S', 'T', 'D'): return "STD Computer Inc";
|
||||||
|
case ID('S', 'V', 'S'): return "SVSI";
|
||||||
|
case ID('S', 'Y', 'N'): return "Synaptics Inc";
|
||||||
|
case ID('T', 'C', 'L'): return "Technical Concepts Ltd";
|
||||||
|
case ID('T', 'O', 'P'): return "Orion Communications Co., Ltd.";
|
||||||
|
case ID('T', 'S', 'B'): return "Toshiba America Info Systems Inc";
|
||||||
|
case ID('T', 'S', 'T'): return "Transtream Inc";
|
||||||
|
case ID('U', 'N', 'K'): return "Unknown";
|
||||||
|
case ID('V', 'E', 'S'): return "Vestel Elektronik Sanayi ve Ticaret A. S.";
|
||||||
|
case ID('V', 'I', 'T'): return "Visitech AS";
|
||||||
|
case ID('V', 'I', 'Z'): return "VIZIO, Inc";
|
||||||
|
case ID('V', 'L', 'V'): return "Valve";
|
||||||
|
case ID('V', 'S', 'C'): return "ViewSonic Corporation";
|
||||||
|
case ID('Y', 'M', 'H'): return "Yamaha Corporation";
|
||||||
|
default: return "Unknown";
|
||||||
}
|
}
|
||||||
|
#undef ID
|
||||||
char query[32];
|
|
||||||
snprintf(query, sizeof(query), "acpi:%s:", pnp_id);
|
|
||||||
struct udev_list_entry *acpi_entry =
|
|
||||||
udev_hwdb_get_properties_list_entry(hwdb, query, 0);
|
|
||||||
if (acpi_entry == NULL) {
|
|
||||||
return pnp_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct udev_list_entry *vendor_entry =
|
|
||||||
udev_list_entry_get_by_name(acpi_entry, "ID_VENDOR_FROM_DATABASE");
|
|
||||||
if (vendor_entry == NULL) {
|
|
||||||
return pnp_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return udev_list_entry_get_value(vendor_entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See https://en.wikipedia.org/wiki/Extended_Display_Identification_Data for layout of EDID data.
|
/* See https://en.wikipedia.org/wiki/Extended_Display_Identification_Data for layout of EDID data.
|
||||||
|
@ -97,7 +142,7 @@ void parse_edid(struct wlr_drm_connector *conn, size_t len, const uint8_t *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t id = (data[8] << 8) | data[9];
|
uint16_t id = (data[8] << 8) | data[9];
|
||||||
output->make = strdup(get_manufacturer(conn->backend->hwdb, id));
|
output->make = strdup(get_manufacturer(id));
|
||||||
|
|
||||||
uint16_t model = data[10] | (data[11] << 8);
|
uint16_t model = data[10] | (data[11] << 8);
|
||||||
char model_str[32];
|
char model_str[32];
|
||||||
|
|
|
@ -58,7 +58,6 @@ struct wlr_drm_backend {
|
||||||
const struct wlr_drm_interface *iface;
|
const struct wlr_drm_interface *iface;
|
||||||
clockid_t clock;
|
clockid_t clock;
|
||||||
bool addfb2_modifiers;
|
bool addfb2_modifiers;
|
||||||
struct udev_hwdb *hwdb;
|
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
Loading…
Reference in a new issue