コード例 #1
0
ファイル: meta-output-xrandr.c プロジェクト: endlessm/mutter
static gboolean
output_get_supports_underscanning_xrandr (MetaOutput  *output,
                                          char       **underscan_value)
{
  Display *xdisplay = xdisplay_from_output (output);
  Atom atom, actual_type;
  int actual_format, i;
  unsigned long nitems, bytes_after;
  g_autofree unsigned char *buffer = NULL;
  XRRPropertyInfo *property_info;
  Atom *values;
  gboolean supports_underscanning = FALSE;

  atom = XInternAtom (xdisplay, "underscan", False);
  XRRGetOutputProperty (xdisplay,
                        (XID)output->winsys_id,
                        atom,
                        0, G_MAXLONG, False, False, XA_ATOM,
                        &actual_type, &actual_format,
                        &nitems, &bytes_after, &buffer);

  if (actual_type != XA_ATOM || actual_format != 32 || nitems < 1)
    return FALSE;

  property_info = XRRQueryOutputProperty (xdisplay,
                                          (XID) output->winsys_id,
                                          atom);
  values = (Atom *) property_info->values;

  for (i = 0; i < property_info->num_values; i++)
    {
      /* The output supports underscanning if "on" or "crop" are valid values
       * for the underscan property.
       */
      char *name = XGetAtomName (xdisplay, values[i]);
      if (strcmp (name, "on") == 0 || strcmp (name, "crop") == 0)
        {
          supports_underscanning = TRUE;
          if (underscan_value)
            *underscan_value = g_strdup (name);
        }

      XFree (name);

      if (supports_underscanning)
        break;
    }

  XFree (property_info);

  return supports_underscanning;
}
コード例 #2
0
ファイル: psb_xrandr.c プロジェクト: 01org/psb_video
static void psb_xrandr_hdmi_property(VADriverContextP ctx)
{
    INIT_DRIVER_DATA;
    Atom *props;
    Atom actual_type;
    XRRPropertyInfo *propinfo;
    int i, nprop, actual_format;
    unsigned long nitems, bytes_after;
    char* prop_name;
    unsigned char* prop;

    /* Check HDMI properties */
    props = XRRListOutputProperties(psb_xrandr_info->dpy, psb_xrandr_info->extend_output->output_id, &nprop);
    if (!props) {
        drv_debug_msg(VIDEO_DEBUG_ERROR, "Xrandr: XRRListOutputProperties failed\n", psb_xrandr_info->extend_output->output_id);
        return;
    }

    drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: extend output %08x has %d properties\n", psb_xrandr_info->extend_output->output_id, nprop);

    for (i = 0; i < nprop; i++) {
        XRRGetOutputProperty(psb_xrandr_info->dpy, psb_xrandr_info->extend_output->output_id, props[i],
                             0, 100, False, False, AnyPropertyType, &actual_type, &actual_format,
                             &nitems, &bytes_after, &prop);

        propinfo = XRRQueryOutputProperty(psb_xrandr_info->dpy, psb_xrandr_info->extend_output->output_id, props[i]);
        if (!propinfo) {
            drv_debug_msg(VIDEO_DEBUG_ERROR, "Xrandr: get output %08x prop %08x failed\n", psb_xrandr_info->extend_output->output_id, props[i]);
            return;
        }

        prop_name = XGetAtomName(psb_xrandr_info->dpy, props[i]);

        /* Currently all properties are XA_INTEGER, 32 */
        if (!strcmp(prop_name, "ExtVideoMode")) {
            psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode = (int)((INT32*)prop)[0];
            drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: ExtVideoMode (%08x)\n", psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode);
        } else if (!strcmp(prop_name, "ExtVideoMode_Xres")) {
            psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_XRes = (int)((INT32*)prop)[0];
            drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: ExtVideoMode_XRes (%08x)\n", psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_XRes);
        } else if (!strcmp(prop_name, "ExtVideoMode_Yres")) {
            psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_YRes = (int)((INT32*)prop)[0];
            drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: ExtVideoMode_YRes (%08x)\n", psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_YRes);
        } else if (!strcmp(prop_name, "ExtVideoMode_X_Offset")) {
            psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_X_Offset = (int)((INT32*)prop)[0];
            drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: ExtVideoMode_X_Offset (%08x)\n", psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_X_Offset);
        } else if (!strcmp(prop_name, "ExtVideoMode_Y_Offset")) {
            psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_Y_Offset = (int)((INT32*)prop)[0];
            drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: ExtVideoMode_Y_Offset (%08x)\n", psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_Y_Offset);
        } else if (!strcmp(prop_name, "ExtVideoMode_Center")) {
            psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_Center = (int)((INT32*)prop)[0];
            drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: ExtVideoMode_Center (%08x)\n", psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_Center);
        } else if (!strcmp(prop_name, "ExtVideoMode_SubTitle")) {
            psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_SubTitle = (int)((INT32*)prop)[0];
            drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: ExtVideoMode_SubTitle (%08x)\n", psb_xrandr_info->hdmi_extvideo_prop->ExtVideoMode_SubTitle);
        } else if (!strcmp(prop_name, "ExtDesktopMode")) {
            if ((psb_xrandr_info->hdmi_extvideo_prop->ExtDesktopMode != EXTENDEDVIDEO) &&
                ((int)((INT32*)prop)[0] == EXTENDEDVIDEO)) {
                driver_data->xrandr_dirty |= PSB_NEW_EXTVIDEO;
            }
            psb_xrandr_info->hdmi_extvideo_prop->ExtDesktopMode = (int)((INT32*)prop)[0];
            drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: ExtDesktopMode (%08x)\n", psb_xrandr_info->hdmi_extvideo_prop->ExtDesktopMode);
        } else if (!strcmp(prop_name, "OverscanMode")) {
            psb_xrandr_info->hdmi_extvideo_prop->OverscanMode = (int)((INT32*)prop)[0];
            drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: OverscanMode (%08x)\n", psb_xrandr_info->hdmi_extvideo_prop->OverscanMode);
        } else if (!strcmp(prop_name, "PANELFITTING")) {
            psb_xrandr_info->hdmi_extvideo_prop->PANELFITTING = (int)((INT32*)prop)[0];
            drv_debug_msg(VIDEO_DEBUG_GENERAL, "Xrandr: PANELFITTING (%08x)\n", psb_xrandr_info->hdmi_extvideo_prop->PANELFITTING);
        }
    }
}