Commit cc485469 authored by Guido Gunther's avatar Guido Gunther

monitor: Determine monitor type

This allows us to detect built in displays
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 2ab7b6f4
......@@ -151,8 +151,24 @@ xdg_output_v1_handle_name (void *data,
struct zxdg_output_v1 *zxdg_output_v1,
const char *name)
{
g_debug("Output name is %s", name);
PhoshMonitor *self = PHOSH_MONITOR (data);
/* wlroots uses the connector's name as xdg_output name */
g_debug("Connector name is %s", name);
self->name = g_strdup (name);
/* wlroots uses the connector's name as output name so
try to derive the connector type from it */
if (g_str_has_prefix (name, "LVDS-"))
self->conn_type = PHOSH_MONITOR_CONNECTOR_TYPE_LVDS;
else if (g_str_has_prefix (name, "HDMI-A-"))
self->conn_type = PHOSH_MONITOR_CONNECTOR_TYPE_HDMIA;
else if (g_str_has_prefix (name, "eDP-"))
self->conn_type = PHOSH_MONITOR_CONNECTOR_TYPE_eDP;
else if (g_str_has_prefix (name, "DSI-"))
self->conn_type = PHOSH_MONITOR_CONNECTOR_TYPE_DSI;
else
self->conn_type = PHOSH_MONITOR_CONNECTOR_TYPE_Unknown;
}
......@@ -299,3 +315,37 @@ phosh_monitor_is_configured (PhoshMonitor *self)
g_return_val_if_fail (PHOSH_IS_MONITOR (self), FALSE);
return self->wl_output_done && self->xdg_output_done;
}
/** phosh_monitor_is_builtin
*
* Is the monitor built in panel (e.g. laptop panel or phone LCD)
*/
gboolean
phosh_monitor_is_builtin (PhoshMonitor *self)
{
g_return_val_if_fail (PHOSH_IS_MONITOR (self), FALSE);
switch (self->conn_type) {
case PHOSH_MONITOR_CONNECTOR_TYPE_eDP:
case PHOSH_MONITOR_CONNECTOR_TYPE_LVDS:
case PHOSH_MONITOR_CONNECTOR_TYPE_DSI:
return TRUE;
case PHOSH_MONITOR_CONNECTOR_TYPE_Unknown:
case PHOSH_MONITOR_CONNECTOR_TYPE_VGA:
case PHOSH_MONITOR_CONNECTOR_TYPE_DVII:
case PHOSH_MONITOR_CONNECTOR_TYPE_DVID:
case PHOSH_MONITOR_CONNECTOR_TYPE_DVIA:
case PHOSH_MONITOR_CONNECTOR_TYPE_Composite:
case PHOSH_MONITOR_CONNECTOR_TYPE_SVIDEO:
case PHOSH_MONITOR_CONNECTOR_TYPE_Component:
case PHOSH_MONITOR_CONNECTOR_TYPE_9PinDIN:
case PHOSH_MONITOR_CONNECTOR_TYPE_DisplayPort:
case PHOSH_MONITOR_CONNECTOR_TYPE_HDMIA:
case PHOSH_MONITOR_CONNECTOR_TYPE_HDMIB:
case PHOSH_MONITOR_CONNECTOR_TYPE_TV:
case PHOSH_MONITOR_CONNECTOR_TYPE_VIRTUAL:
default:
return FALSE;
}
}
......@@ -7,8 +7,31 @@
#include "phosh-wayland.h"
#include <glib-object.h>
#include <gdk/gdk.h>
#include <glib-object.h>
#include <glib/gi18n.h>
/* This matches the values in drm_mode.h */
typedef enum
{
PHOSH_MONITOR_CONNECTOR_TYPE_Unknown = 0,
PHOSH_MONITOR_CONNECTOR_TYPE_VGA = 1,
PHOSH_MONITOR_CONNECTOR_TYPE_DVII = 2,
PHOSH_MONITOR_CONNECTOR_TYPE_DVID = 3,
PHOSH_MONITOR_CONNECTOR_TYPE_DVIA = 4,
PHOSH_MONITOR_CONNECTOR_TYPE_Composite = 5,
PHOSH_MONITOR_CONNECTOR_TYPE_SVIDEO = 6,
PHOSH_MONITOR_CONNECTOR_TYPE_LVDS = 7,
PHOSH_MONITOR_CONNECTOR_TYPE_Component = 8,
PHOSH_MONITOR_CONNECTOR_TYPE_9PinDIN = 9,
PHOSH_MONITOR_CONNECTOR_TYPE_DisplayPort = 10,
PHOSH_MONITOR_CONNECTOR_TYPE_HDMIA = 11,
PHOSH_MONITOR_CONNECTOR_TYPE_HDMIB = 12,
PHOSH_MONITOR_CONNECTOR_TYPE_TV = 13,
PHOSH_MONITOR_CONNECTOR_TYPE_eDP = 14,
PHOSH_MONITOR_CONNECTOR_TYPE_VIRTUAL = 15,
PHOSH_MONITOR_CONNECTOR_TYPE_DSI = 16,
} PhoshMonitorConnectorType;
typedef struct _PhoshMonitorMode
......@@ -33,14 +56,15 @@ struct _PhoshMonitor {
gint width_mm;
gint height_mm;
char *vendor;
char *product;
gchar *vendor;
gchar *product;
GArray *modes;
guint current_mode;
guint preferred_mode;
char *name;
gchar *name;
PhoshMonitorConnectorType conn_type;
gboolean wl_output_done;
gboolean xdg_output_done;
......@@ -51,3 +75,4 @@ G_DECLARE_FINAL_TYPE (PhoshMonitor, phosh_monitor, PHOSH, MONITOR, GObject)
PhoshMonitor * phosh_monitor_new_from_wl_output (gpointer wl_output);
PhoshMonitorMode * phosh_monitor_get_current_mode (PhoshMonitor *monitor);
gboolean phosh_monitor_is_configured (PhoshMonitor *monitor);
gboolean phosh_monitor_is_builtin (PhoshMonitor *monitor);
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