예제 #1
0
static int drm_plane_type(int drm_fd, int plane_id)
{
    drmModeObjectPropertiesPtr props;
    drmModePropertyPtr prop;
    int plane_type = -EINVAL;
    int i;

    props = drmModeObjectGetProperties(drm_fd, plane_id, DRM_MODE_OBJECT_PLANE);
    if (!props)
        return -ENODEV;

    for (i = 0; i < props->count_props && plane_type == -EINVAL; i++) {
        prop = drmModeGetProperty(drm_fd, props->props[i]);
        if (prop) {
            if (strcmp(prop->name, "type") == 0)
                plane_type = props->prop_values[i];

            drmModeFreeProperty(prop);
        }
    }

    drmModeFreeObjectProperties(props);

    return plane_type;
}
예제 #2
0
파일: drm_atomic.c 프로젝트: atomnuker/mpv
int drm_object_create_properties(struct mp_log *log, int fd,
                                 struct drm_object *object)
{
    object->props = drmModeObjectGetProperties(fd, object->id, object->type);
    if (object->props) {
        object->props_info = talloc_zero_size(NULL, object->props->count_props
                                              * sizeof(object->props_info));
        if (object->props_info) {
            for (int i = 0; i < object->props->count_props; i++)
                object->props_info[i] = drmModeGetProperty(fd, object->props->props[i]);
        } else {
            mp_err(log, "Out of memory\n");
            goto fail;
        }
    } else {
        mp_err(log, "Failed to retrieve properties for object id %d\n", object->id);
        goto fail;
    }

    return 0;

  fail:
    drm_object_free_properties(object);
    return -1;
}
예제 #3
0
파일: property.cpp 프로젝트: uli/kmsxx
Property::Property(Card& card, uint32_t id)
	: DrmObject(card, id, DRM_MODE_OBJECT_PROPERTY)
{
	m_priv = new PropertyPriv();
	m_priv->drm_prop = drmModeGetProperty(card.fd(), id);
	m_name = m_priv->drm_prop->name;
}
예제 #4
0
파일: plane.c 프로젝트: robclark/glplane
static void populate_crtc_props(int fd, struct my_crtc *c)
{
    drmModeObjectPropertiesPtr props;
    uint32_t i;

    props = drmModeObjectGetProperties(fd, c->base.crtc_id, DRM_MODE_OBJECT_CRTC);
    if (!props)
        return;

    for (i = 0; i < props->count_props; i++) {
        drmModePropertyPtr prop;

        prop = drmModeGetProperty(fd, props->props[i]);
        if (!prop)
            continue;

        printf("crtc prop %s %u\n", prop->name, prop->prop_id);

//		if (!strcmp(prop->name, "MODE"))
//			c->prop.mode = prop->prop_id;
//		else if (!strcmp(prop->name, "CONNECTOR_IDS"))
//			c->prop.connector_ids = prop->prop_id;

        drmModeFreeProperty(prop);
    }

    drmModeFreeObjectProperties(props);
}
예제 #5
0
static int kms_plane_probe(struct kms_plane *plane)
{
	struct kms_device *device = plane->device;
	drmModeObjectPropertiesPtr props;
	drmModePlane *p;
	unsigned int i;

	p = drmModeGetPlane(device->fd, plane->id);
	if (!p)
		return -ENODEV;

	/* TODO: allow dynamic assignment to CRTCs */
	if (p->crtc_id == 0) {
		for (i = 0; i < device->num_crtcs; i++) {
			if (p->possible_crtcs & (1 << i)) {
				p->crtc_id = device->crtcs[i]->id;
				break;
			}
		}
	}

	for (i = 0; i < device->num_crtcs; i++) {
		if (device->crtcs[i]->id == p->crtc_id) {
			plane->crtc = device->crtcs[i];
			break;
		}
	}

	plane->formats = calloc(p->count_formats, sizeof(uint32_t));
	if (!plane->formats)
		return -ENOMEM;

	for (i = 0; i < p->count_formats; i++)
		plane->formats[i] = p->formats[i];

	plane->num_formats = p->count_formats;

	drmModeFreePlane(p);

	props = drmModeObjectGetProperties(device->fd, plane->id,
					   DRM_MODE_OBJECT_PLANE);
	if (!props)
		return -ENODEV;

	for (i = 0; i < props->count_props; i++) {
		drmModePropertyPtr prop;

		prop = drmModeGetProperty(device->fd, props->props[i]);
		if (prop) {
			if (strcmp(prop->name, "type") == 0)
				plane->type = props->prop_values[i];

			drmModeFreeProperty(prop);
		}
	}

	drmModeFreeObjectProperties(props);

	return 0;
}
예제 #6
0
bool drm_mipi_setMode(int mode)
{
    drmModeConnector *connector = getConnector(gDrmCxt.drmFD, DRM_MODE_CONNECTOR_MIPI);
    if (connector == NULL)
        return false;

    int i = 0;
    drmModePropertyPtr props = NULL;

    // Set MIPI On/Off
    for (i = 0; i < connector->count_props; i++) {
        props = drmModeGetProperty(gDrmCxt.drmFD, connector->props[i]);
        if (!props) continue;

        if (props->name != NULL &&
                !strncmp(props->name, "DPMS", sizeof("DPMS"))) {
            LOGV("%s: %s %u", __func__,
                  (mode == DRM_MIPI_ON) ? "On" : "Off",
                  connector->connector_id);
            drmModeConnectorSetProperty(gDrmCxt.drmFD,
                                        connector->connector_id,
                                        props->prop_id,
                                        (mode == DRM_MIPI_ON)
                                        ? DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF);
            drmModeFreeProperty(props);
            break;
        }
        drmModeFreeProperty(props);
    }

    drmModeFreeConnector(connector);
    return true;
}
예제 #7
0
static void fill_obj_props(int fd, uint32_t id, int type, int num_props,
			   const char **prop_names, uint32_t *prop_ids)
{
	drmModeObjectPropertiesPtr props;
	int i, j;

	props = drmModeObjectGetProperties(fd, id, type);
	igt_assert(props);

	for (i = 0; i < props->count_props; i++) {
		drmModePropertyPtr prop =
			drmModeGetProperty(fd, props->props[i]);

		for (j = 0; j < num_props; j++) {
			if (strcmp(prop->name, prop_names[j]) != 0)
				continue;
			prop_ids[j] = props->props[i];
			break;
		}

		drmModeFreeProperty(prop);
	}

	drmModeFreeObjectProperties(props);
}
예제 #8
0
static void
find_crtc_properties (MetaMonitorManagerKms *manager_kms,
                      MetaCRTC *meta_crtc)
{
  MetaCRTCKms *crtc_kms;
  drmModeObjectPropertiesPtr props;
  size_t i;

  crtc_kms = meta_crtc->driver_private;

  props = drmModeObjectGetProperties (manager_kms->fd, meta_crtc->crtc_id, DRM_MODE_OBJECT_CRTC);
  if (!props)
    return;

  for (i = 0; i < props->count_props; i++)
    {
      drmModePropertyPtr prop = drmModeGetProperty (manager_kms->fd, props->props[i]);
      if (!prop)
        continue;

      if ((prop->flags & DRM_MODE_PROP_ENUM) && strcmp (prop->name, "underscan") == 0)
        crtc_kms->underscan_prop_id = prop->prop_id;
      else if ((prop->flags & DRM_MODE_PROP_RANGE) && strcmp (prop->name, "underscan hborder") == 0)
        crtc_kms->underscan_hborder_prop_id = prop->prop_id;
      else if ((prop->flags & DRM_MODE_PROP_RANGE) && strcmp (prop->name, "underscan vborder") == 0)
        crtc_kms->underscan_vborder_prop_id = prop->prop_id;

      drmModeFreeProperty (prop);
    }
}
예제 #9
0
static int
find_property_index (MetaMonitorManager         *manager,
                     drmModeObjectPropertiesPtr  props,
                     const gchar                *prop_name,
                     drmModePropertyPtr         *found)
{
  MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (manager);
  unsigned int i;

  for (i = 0; i < props->count_props; i++)
    {
      drmModePropertyPtr prop;

      prop = drmModeGetProperty (manager_kms->fd, props->props[i]);
      if (!prop)
        continue;

      if (strcmp (prop->name, prop_name) == 0)
        {
          *found = prop;
          return i;
        }

      drmModeFreeProperty (prop);
    }

  return -1;
}
예제 #10
0
static void
find_connector_properties (MetaMonitorManagerKms *manager_kms,
                           MetaOutputKms         *output_kms)
{
  int i;

  output_kms->hotplug_mode_update = 0;
  output_kms->suggested_x = -1;
  output_kms->suggested_y = -1;
  for (i = 0; i < output_kms->connector->count_props; i++)
    {
      drmModePropertyPtr prop = drmModeGetProperty (manager_kms->fd, output_kms->connector->props[i]);
      if (!prop)
        continue;

      if ((prop->flags & DRM_MODE_PROP_ENUM) && strcmp (prop->name, "DPMS") == 0)
        output_kms->dpms_prop_id = prop->prop_id;
      else if ((prop->flags & DRM_MODE_PROP_BLOB) && strcmp (prop->name, "EDID") == 0)
        output_kms->edid_blob_id = output_kms->connector->prop_values[i];
      else if ((prop->flags & DRM_MODE_PROP_BLOB) &&
               strcmp (prop->name, "TILE") == 0)
        output_kms->tile_blob_id = output_kms->connector->prop_values[i];
      else if ((prop->flags & DRM_MODE_PROP_RANGE) &&
               strcmp (prop->name, "suggested X") == 0)
        output_kms->suggested_x = output_kms->connector->prop_values[i];
      else if ((prop->flags & DRM_MODE_PROP_RANGE) &&
               strcmp (prop->name, "suggested Y") == 0)
        output_kms->suggested_y = output_kms->connector->prop_values[i];
      else if ((prop->flags & DRM_MODE_PROP_RANGE) &&
               strcmp (prop->name, "hotplug_mode_update") == 0)
        output_kms->hotplug_mode_update = output_kms->connector->prop_values[i];
      
      drmModeFreeProperty (prop);
    }
}
예제 #11
0
static void
drmmode_output_dpms(xf86OutputPtr output, int mode)
{
	drmmode_output_private_ptr drmmode_output = output->driver_private;
	drmModeConnectorPtr koutput = drmmode_output->mode_output;
	drmmode_ptr drmmode = drmmode_output->drmmode;
	int i;
	drmModePropertyPtr props;

	for (i = 0; i < koutput->count_props; i++) {
		props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
		if (!props)
			continue;

		if (!strcmp(props->name, "DPMS")) {
                        drmModeConnectorSetProperty(drmmode->fd,
                                drmmode_output->output_id,
                                props->prop_id,
                                mode);
			drmmode_output_dpms_backlight(output,
				drmmode_output->dpms_mode,
				mode);
			drmmode_output->dpms_mode = mode;
                        drmModeFreeProperty(props);
                        return;
		}
		drmModeFreeProperty(props);
	}
}
예제 #12
0
void mgm::RealKMSOutput::reset()
{
    DRMModeResources resources{drm_fd};

    /* Update the connector to ensure we have the latest information */
    connector = resources.connector(connector_id);

    if (!connector)
        fatal_error("No DRM connector found");

    // TODO: What if we can't locate the DPMS property?
    for (int i = 0; i < connector->count_props; i++)
    {
        auto prop = drmModeGetProperty(drm_fd, connector->props[i]);
        if (prop && (prop->flags & DRM_MODE_PROP_ENUM)) {
            if (!strcmp(prop->name, "DPMS"))
            {
                dpms_enum_id = connector->props[i];
                drmModeFreeProperty(prop);
                break;
            }
            drmModeFreeProperty(prop);
        }
    }

    /* Discard previously current crtc */
    current_crtc = nullptr;
}
예제 #13
0
static void printProperties(int fd, uint32_t* props, uint64_t* values, int count) {
	drmModePropertyRes* prop;
	int i;

	for (i = 0; i < count; i++) {
		prop = drmModeGetProperty(fd, props[i]);
		printProperty(fd, prop, values[i]);
		drmModeFreeProperty(prop);
    }
}
예제 #14
0
/* Pick a plane.. something that at a minimum can be connected to
 * the chosen crtc, but prefer primary plane.
 *
 * Seems like there is some room for a drmModeObjectGetNamedProperty()
 * type helper in libdrm..
 */
static int get_plane_id(void)
{
	drmModePlaneResPtr plane_resources;
	uint32_t i, j;
	int ret = -EINVAL;
	int found_primary = 0;

	plane_resources = drmModeGetPlaneResources(drm.fd);
	if (!plane_resources) {
		printf("drmModeGetPlaneResources failed: %s\n", strerror(errno));
		return -1;
	}

	for (i = 0; (i < plane_resources->count_planes) && !found_primary; i++) {
		uint32_t id = plane_resources->planes[i];
		drmModePlanePtr plane = drmModeGetPlane(drm.fd, id);
		if (!plane) {
			printf("drmModeGetPlane(%u) failed: %s\n", id, strerror(errno));
			continue;
		}

		if (plane->possible_crtcs & (1 << drm.crtc_index)) {
			drmModeObjectPropertiesPtr props =
				drmModeObjectGetProperties(drm.fd, id, DRM_MODE_OBJECT_PLANE);

			/* primary or not, this plane is good enough to use: */
			ret = id;

			for (j = 0; j < props->count_props; j++) {
				drmModePropertyPtr p =
					drmModeGetProperty(drm.fd, props->props[j]);

				if ((strcmp(p->name, "type") == 0) &&
						(props->prop_values[j] == DRM_PLANE_TYPE_PRIMARY)) {
					/* found our primary plane, lets use that: */
					found_primary = 1;
				}

				drmModeFreeProperty(p);
			}

			drmModeFreeObjectProperties(props);
		}

		drmModeFreePlane(plane);
	}

	drmModeFreePlaneResources(plane_resources);

	return ret;
}
예제 #15
0
bool Drm::setDpmsMode(int device, int mode)
{
    Mutex::Autolock _l(mLock);

    int output = getOutputIndex(device);
    if (output < 0 ) {
        return false;
    }

    if (mode != IDisplayDevice::DEVICE_DISPLAY_OFF &&
            mode != IDisplayDevice::DEVICE_DISPLAY_STANDBY &&
            mode != IDisplayDevice::DEVICE_DISPLAY_ON) {
        ELOGTRACE("invalid mode %d", mode);
        return false;
    }

    DrmOutput *out = &mOutputs[output];
    if (!out->connected) {
        ELOGTRACE("device is not connected");
        return false;
    }

    drmModePropertyPtr props;
    for (int i = 0; i < out->connector->count_props; i++) {
        props = drmModeGetProperty(mDrmFd, out->connector->props[i]);
        if (!props) {
            continue;
        }

        if (strcmp(props->name, "DPMS") == 0) {
            int ret = drmModeConnectorSetProperty(
                mDrmFd,
                out->connector->connector_id,
                props->prop_id,
                (mode == IDisplayDevice::DEVICE_DISPLAY_ON) ? DRM_MODE_DPMS_ON :
                        IDisplayDevice::DEVICE_DISPLAY_STANDBY == mode ?
                        DRM_MODE_DPMS_STANDBY : DRM_MODE_DPMS_OFF);
            drmModeFreeProperty(props);
            if (ret != 0) {
                ELOGTRACE("unable to set DPMS %d", mode);
                return false;
            } else {
                return true;
            }
        }
        drmModeFreeProperty(props);
    }
    return false;
}
예제 #16
0
파일: dev.c 프로젝트: BalintBanyasz/FFmpeg
static uint32_t get_prop_id(struct sp_dev *dev,
			    drmModeObjectPropertiesPtr props, const char *name){
	drmModePropertyPtr p;
	uint32_t i, prop_id = 0; /* Property ID should always be > 0 */

	for (i = 0; !prop_id && i < props->count_props; i++) {
		p = drmModeGetProperty(dev->fd, props->props[i]);
		if (!strcmp(p->name, name))
		prop_id = p->prop_id;
		drmModeFreeProperty(p);
	}
	if (!prop_id)
	printf("Could not find %s property\n", name);
	return prop_id;
}
예제 #17
0
파일: DRMUtils.cpp 프로젝트: Arcko/xbmc
static bool GetProperties(int fd, uint32_t id, uint32_t type, struct drm_object *object)
{
  drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(fd, id, type);
  if (!props)
    return false;

  object->id = id;
  object->type = type;
  object->props = props;
  object->props_info = new drmModePropertyPtr[props->count_props];

  for (uint32_t i = 0; i < props->count_props; i++)
    object->props_info[i] = drmModeGetProperty(fd, props->props[i]);

  return true;
}
예제 #18
0
파일: main.c 프로젝트: tdaede/drm10bit
int main(int argc, char * argv[])
{
  int control_minor = 64;
  int c = drmOpenControl(control_minor);
  if (!c) {
    printf("DRM open device %d failed\n", control_minor);
    abort();
  }
  int render_minor = 128;
  int r = drmOpenRender(render_minor);
  if (!r) {
    printf("DRM open render node %d failed\n", render_minor);
  }
  drmVersionPtr v = drmGetVersion(r);
  if (!v) {
    printf("Couldn't get DRM version\n");
    abort();
  }
  printf("%s %s %s\n", v->name, v->date, v->desc);
  drmModeResPtr moderes = drmModeGetResources(c);
  if (!moderes) {
    printf("Couldn't get DRM modesetting resources\n");
    abort();
  }
  printf("fbs: %d crtcs: %d connectors: %d encoders: %d\n",
   moderes->count_fbs, moderes->count_crtcs, moderes->count_connectors, moderes->count_encoders);
  for (int i = 0; i < moderes->count_connectors; i++) {
    printf("Connector %d\n", moderes->connectors[i]);
    drmModeConnectorPtr connector = drmModeGetConnector(c, moderes->connectors[i]);
    if (connector->connection == DRM_MODE_CONNECTED) {
      printf("\tConnected\n");
      printf("\tSize: %d x %d mm\n", connector->mmWidth, connector->mmHeight);
      printf("\tModes:\n");
      for (int j = 0; j < connector->count_modes; j++) {
        printf("\t\t%s\n", connector->modes[j].name);
      }
      printf("\tProperties:\n");
      for (int j = 0; j < connector->count_props; j++) {
        drmModePropertyPtr property = drmModeGetProperty(c, connector->props[j]);
        printf("\t\t%s\n", property->name);
      }
    } else {
      printf("\tDisconnected\n");
    }
  }
}
예제 #19
0
static void
drm_find_dpms(struct drm_device *dev, struct drm_screen *screen)
{
	drmModeConnectorPtr c = screen->connector;
	drmModePropertyPtr p;
	int i;

	for (i = 0; i < c->count_props; i++) {
		p = drmModeGetProperty(dev->drmFD, c->props[i]);
		if (!strcmp(p->name, "DPMS"))
			break;

		drmModeFreeProperty(p);
		p = NULL;
	}

	screen->dpms = p;
}
예제 #20
0
파일: drm_gfx.c 프로젝트: IlDucci/RetroArch
static uint64_t drm_plane_type(drmModePlane *plane)
{
   int i,j;
   /* The property values and their names are stored in different arrays, so we
    * access them simultaneously here.
    * We are interested in OVERLAY planes only, that's type 0 or DRM_PLANE_TYPE_OVERLAY
    * (see /usr/xf86drmMode.h for definition). */
   drmModeObjectPropertiesPtr props = 
      drmModeObjectGetProperties(drm.fd, plane->plane_id, DRM_MODE_OBJECT_PLANE);

   for (j = 0; j < props->count_props; j++)
   {
      /* found the type property */
      if ( !strcmp(drmModeGetProperty(drm.fd, props->props[j])->name, "type"))
         return (props->prop_values[j]);
   }
   return (0);
}
예제 #21
0
파일: plane.c 프로젝트: robclark/glplane
static void populate_plane_props(int fd, struct my_plane *p)
{
    drmModeObjectPropertiesPtr props;
    uint32_t i;

    props = drmModeObjectGetProperties(fd, p->base.plane_id, DRM_MODE_OBJECT_PLANE);
    if (!props)
        return;

    for (i = 0; i < props->count_props; i++) {
        drmModePropertyPtr prop;

        prop = drmModeGetProperty(fd, props->props[i]);
        if (!prop)
            continue;

        printf("plane prop %s %u\n", prop->name, prop->prop_id);

        if (!strcmp(prop->name, "SRC_X"))
            p->prop.src_x = prop->prop_id;
        else if (!strcmp(prop->name, "SRC_Y"))
            p->prop.src_y = prop->prop_id;
        else if (!strcmp(prop->name, "SRC_W"))
            p->prop.src_w = prop->prop_id;
        else if (!strcmp(prop->name, "SRC_H"))
            p->prop.src_h = prop->prop_id;
        else if (!strcmp(prop->name, "CRTC_X"))
            p->prop.crtc_x = prop->prop_id;
        else if (!strcmp(prop->name, "CRTC_Y"))
            p->prop.crtc_y = prop->prop_id;
        else if (!strcmp(prop->name, "CRTC_W"))
            p->prop.crtc_w = prop->prop_id;
        else if (!strcmp(prop->name, "CRTC_H"))
            p->prop.crtc_h = prop->prop_id;
        else if (!strcmp(prop->name, "FB_ID"))
            p->prop.fb = prop->prop_id;
        else if (!strcmp(prop->name, "CRTC_ID"))
            p->prop.crtc = prop->prop_id;

        drmModeFreeProperty(prop);
    }

    drmModeFreeObjectProperties(props);
}
예제 #22
0
파일: drm_gfx.c 프로젝트: IlDucci/RetroArch
static uint32_t get_plane_prop_id(uint32_t obj_id, const char *name)
{
   int i,j;
   drmModePlaneRes *plane_resources;
   drmModePlane *plane;
   drmModeObjectProperties *props;	
   drmModePropertyRes **props_info;

   char format_str[5];

   plane_resources = drmModeGetPlaneResources(drm.fd);
   for (i = 0; i < plane_resources->count_planes; i++)
   {
      plane = drmModeGetPlane(drm.fd, plane_resources->planes[i]);
      if (plane->plane_id != obj_id)
         continue;

      /* TODO: Improvement. We get all the properties of the 
       * plane and info about the properties.
       * We should have done this already... 
       * This implementation must be improved. */
      props      = drmModeObjectGetProperties(drm.fd,
            plane->plane_id, DRM_MODE_OBJECT_PLANE);
      props_info = malloc(props->count_props * sizeof *props_info);

      for (j = 0; j < props->count_props; ++j)
         props_info[j] =	drmModeGetProperty(drm.fd, props->props[j]);	

      /* We look for the prop_id we need */
      for (j = 0; j < props->count_props; j++)
      {
         if (!strcmp(props_info[j]->name, name))
            return props_info[j]->prop_id;
      }
      RARCH_ERR ("DRM: plane %d fb property ID with name %s not found\n",
            plane->plane_id, name);
   }
   return (0);
}
예제 #23
0
static int get_dpms(struct uterm_display *disp, drmModeConnector *conn)
{
	int i, ret;
	drmModePropertyRes *prop;

	for (i = 0; i < conn->count_props; ++i) {
		prop = drmModeGetProperty(disp->video->dumb.fd, conn->props[i]);
		if (!prop) {
			log_error("cannot get DRM property (%d): %m", errno);
			continue;
		}

		if (!strcmp(prop->name, "DPMS")) {
			switch (conn->prop_values[i]) {
			case DRM_MODE_DPMS_ON:
				ret = UTERM_DPMS_ON;
				break;
			case DRM_MODE_DPMS_STANDBY:
				ret = UTERM_DPMS_STANDBY;
				break;
			case DRM_MODE_DPMS_SUSPEND:
				ret = UTERM_DPMS_SUSPEND;
				break;
			case DRM_MODE_DPMS_OFF:
			default:
				ret = UTERM_DPMS_OFF;
			}

			drmModeFreeProperty(prop);
			return ret;
		}
		drmModeFreeProperty(prop);
	}

	if (i == conn->count_props)
		log_warn("display does not support DPMS");
	return UTERM_DPMS_UNKNOWN;
}
예제 #24
0
int DrmResources::GetProperty(uint32_t obj_id, uint32_t obj_type,
                              const char *prop_name, DrmProperty *property) {
    drmModeObjectPropertiesPtr props;

    props = drmModeObjectGetProperties(fd_, obj_id, obj_type);
    if (!props) {
        ALOGE("Failed to get properties for %d/%x", obj_id, obj_type);
        return -ENODEV;
    }

    bool found = false;
    for (int i = 0; !found && (size_t)i < props->count_props; ++i) {
        drmModePropertyPtr p = drmModeGetProperty(fd_, props->props[i]);
        if (!strcmp(p->name, prop_name)) {
            property->Init(p, props->prop_values[i]);
            found = true;
        }
        drmModeFreeProperty(p);
    }

    drmModeFreeObjectProperties(props);
    return found ? 0 : -ENOENT;
}
예제 #25
0
static void
find_properties (MetaMonitorManagerKms *manager_kms,
                 MetaOutputKms         *output_kms)
{
  drmModePropertyPtr prop;
  int i;

  for (i = 0; i < output_kms->connector->count_props; i++)
    {
      prop = drmModeGetProperty (manager_kms->fd, output_kms->connector->props[i]);
      if (!prop)
        continue;

      if ((prop->flags & DRM_MODE_PROP_ENUM) &&
          strcmp(prop->name, "DPMS") == 0)
        output_kms->dpms_prop_id = prop->prop_id;
      else if ((prop->flags & DRM_MODE_PROP_BLOB) &&
               strcmp (prop->name, "EDID") == 0)
        output_kms->edid_blob_id = output_kms->connector->prop_values[i];

      drmModeFreeProperty(prop);
    }
}
예제 #26
0
파일: DRMUtils.cpp 프로젝트: ssfdre38/xbmc
bool CDRMUtils::GetConnector()
{
  for(auto i = 0; i < m_drm_resources->count_connectors; i++)
  {
    m_connector->connector = drmModeGetConnector(m_fd,
                                                      m_drm_resources->connectors[i]);
    if(m_connector->connector->connection == DRM_MODE_CONNECTED)
    {
      CLog::Log(LOGDEBUG, "CDRMUtils::%s - found connector: %d", __FUNCTION__,
                                                                 m_connector->connector->connector_id);
      break;
    }
    drmModeFreeConnector(m_connector->connector);
    m_connector->connector = nullptr;
  }

  if(!m_connector->connector)
  {
    CLog::Log(LOGERROR, "CDRMUtils::%s - could not get connector: %s", __FUNCTION__, strerror(errno));
    return false;
  }

  m_connector->props = drmModeObjectGetProperties(m_fd, m_connector->connector->connector_id, DRM_MODE_OBJECT_CONNECTOR);
  if (!m_connector->props)
  {
    CLog::Log(LOGERROR, "CDRMUtils::%s - could not get connector %u properties: %s", __FUNCTION__, m_connector->connector->connector_id, strerror(errno));
    return false;
  }

  m_connector->props_info = new drmModePropertyPtr[m_connector->props->count_props];
  for (uint32_t i = 0; i < m_connector->props->count_props; i++)
  {
    m_connector->props_info[i] = drmModeGetProperty(m_fd, m_connector->props->props[i]);
  }

  return true;
}
예제 #27
0
파일: DRMUtils.cpp 프로젝트: ssfdre38/xbmc
bool CDRMUtils::GetCrtc()
{
  for(auto i = 0; i < m_drm_resources->count_crtcs; i++)
  {
    m_crtc->crtc = drmModeGetCrtc(m_fd, m_drm_resources->crtcs[i]);
    if(m_crtc->crtc->crtc_id == m_encoder->encoder->crtc_id)
    {
      CLog::Log(LOGDEBUG, "CDRMUtils::%s - found crtc: %d", __FUNCTION__,
                                                            m_crtc->crtc->crtc_id);
      m_crtc_index = i;
      break;
    }
    drmModeFreeCrtc(m_crtc->crtc);
    m_crtc->crtc = nullptr;
  }

  if(!m_crtc->crtc)
  {
    CLog::Log(LOGERROR, "CDRMUtils::%s - could not get crtc: %s", __FUNCTION__, strerror(errno));
    return false;
  }

  m_crtc->props = drmModeObjectGetProperties(m_fd, m_crtc->crtc->crtc_id, DRM_MODE_OBJECT_CRTC);
  if (!m_crtc->props)
  {
    CLog::Log(LOGERROR, "CDRMUtils::%s - could not get crtc %u properties: %s", __FUNCTION__, m_crtc->crtc->crtc_id, strerror(errno));
    return false;
  }

  m_crtc->props_info = new drmModePropertyPtr[m_crtc->props->count_props];
  for (uint32_t i = 0; i < m_crtc->props->count_props; i++)
  {
    m_crtc->props_info[i] = drmModeGetProperty(m_fd, m_crtc->props->props[i]);
  }

  return true;
}
예제 #28
0
/**
 * Get the extended display identification data for the monitor connected to a connector
 * 
 * @param   connection       The identifier for the connection to the card
 * @param   connector_index  The index of the connector
 * @param   edid             Storage location for the EDID, it should be 128 bytes,
 *                           or 256 bytes if you are counting on the depricated EDID 2.0,
 *                           If hexadecimal, twice that + zero termiation.
 * @param   size             The size allocated to `edid` excluding your zero termination
 * @param   hexadecimal      Whether to convert to hexadecimal representation, this is preferable
 * @return                   The length of the found value, 0 if none, as if hex is false
 */
long blueshift_drm_get_edid(int connection, int connector_index, char* edid, long size, int hexadecimal)
{
  card_connection* card = card_connections + connection;
  drmModeConnector* connector = *(card->connectors + connector_index);
  int fd = card->fd;
  long rc = 0;
  int prop_n = connector->count_props;
  int prop_i;
  
  for (prop_i = 0; prop_i < prop_n; prop_i++)
    {
      drmModePropertyRes* prop = drmModeGetProperty(fd, connector->props[prop_i]);
      if (!strcmp("EDID", prop->name))
	{
	  drmModePropertyBlobRes* blob = drmModeGetPropertyBlob(fd, (uint32_t)(connector->prop_values[prop_i]));
	  if (hexadecimal)
	    {
	      uint32_t n = (uint32_t)size / 2;
	      uint32_t i;
	      rc += blob->length;
	      if (n > blob->length)
		n = blob->length;
	      for (i = 0; i < n ; i++)
		{
		  *(edid + i * 2 + 0) = "0123456789abcdef"[(*((char*)(blob->data) + i) >> 4) & 15];
		  *(edid + i * 2 + 1) = "0123456789abcdef"[(*((char*)(blob->data) + i) >> 0) & 15];
		}
	    }
	  else
	    {
	      uint32_t len = blob->length < size ? blob->length : (uint32_t)size;
	      memcpy(edid, blob->data, (size_t)len * sizeof(char));
	    }
	  drmModeFreePropertyBlob(blob);
	  prop_i = prop_n; /* stop the for-loop */
	}
예제 #29
0
static void fill_obj_prop_map(int fd, uint32_t id, int type, const char *name,
			      int num_enums, const char **enum_names,
			      uint64_t *enum_ids)
{
	drmModeObjectPropertiesPtr props;
	int i, j, k;

	props = drmModeObjectGetProperties(fd, id, type);
	igt_assert(props);

	for (i = 0; i < props->count_props; i++) {
		drmModePropertyPtr prop =
			drmModeGetProperty(fd, props->props[i]);

		igt_assert(prop);

		if (strcmp(prop->name, name) != 0) {
			drmModeFreeProperty(prop);
			continue;
		}

		for (j = 0; j < prop->count_enums; j++) {
			struct drm_mode_property_enum *e = &prop->enums[j];

			for (k = 0; k < num_enums; k++) {
				if (strcmp(e->name, enum_names[k]) != 0)
					continue;

				enum_ids[k] = e->value;
				break;
			}
		}

		drmModeFreeProperty(prop);
	}
}
예제 #30
0
static DFBResult
drmkmsPlaneInitLayer( CoreLayer                  *layer,
                      void                       *driver_data,
                      void                       *layer_data,
                      DFBDisplayLayerDescription *description,
                      DFBDisplayLayerConfig      *config,
                      DFBColorAdjustment         *adjustment )
{
     DRMKMSData       *drmkms = driver_data;
     DRMKMSDataShared *shared = drmkms->shared;
     DRMKMSLayerData  *data   = layer_data;
     drmModeObjectPropertiesPtr props;

     D_DEBUG_AT( DRMKMS_Layer, "%s()\n", __FUNCTION__ );

     data->index       = shared->layerplane_index_count++;
     data->plane_index = shared->plane_index_count++;
     data->level       = data->index;

     D_DEBUG_AT( DRMKMS_Layer, "  -> getting plane with index %d\n", data->plane_index );

     data->plane = drmModeGetPlane(drmkms->fd, drmkms->plane_resources->planes[data->plane_index]);

     D_DEBUG_AT( DRMKMS_Layer, "     ->  plane_id is %d\n", data->plane->plane_id );

     description->type             = DLTF_GRAPHICS;
     description->caps             = DLCAPS_SURFACE | DLCAPS_SCREEN_POSITION | DLCAPS_ALPHACHANNEL;
     description->surface_caps     = DSCAPS_NONE;
     description->surface_accessor = CSAID_LAYER0;

     snprintf( description->name, DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, "DRMKMS Plane Layer %d", data->plane_index );


     config->flags      = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;
     config->width      = dfb_config->mode.width  ?: shared->mode[0].hdisplay;
     config->height     = dfb_config->mode.height ?: shared->mode[0].vdisplay;

     config->pixelformat = dfb_config->mode.format ?: DSPF_ARGB;
     config->buffermode  = DLBM_FRONTONLY;


     props = drmModeObjectGetProperties( drmkms->fd, data->plane->plane_id, DRM_MODE_OBJECT_PLANE );
     if (props) {
          int                i;
          drmModePropertyPtr prop;

          D_INFO( "DirectFB/DRMKMS: supported properties for layer id %d\n", data->plane->plane_id );
          for (i = 0; i < props->count_props; i++) {
               prop = drmModeGetProperty( drmkms->fd, props->props[i] );
               if (!strcmp(prop->name, "colorkey")) {
                    description->caps |= DLCAPS_SRC_COLORKEY;
                    data->colorkey_propid = prop->prop_id;
                    D_INFO( "     colorkey\n" );
               }
               else if (!strcmp(prop->name, "zpos")) {
                    description->caps |= DLCAPS_LEVELS;
                    data->zpos_propid = prop->prop_id;
                    D_INFO( "     zpos\n" );

                    drmModeObjectSetProperty( drmkms->fd, data->plane->plane_id, DRM_MODE_OBJECT_PLANE, data->zpos_propid, data->level );
               }
               else if (!strcmp(prop->name, "alpha")) {
                    description->caps |= DLCAPS_OPACITY;
                    data->alpha_propid = prop->prop_id;
                    D_INFO( "     alpha\n" );
               }

               drmModeFreeProperty( prop );
          }
          drmModeFreeObjectProperties( props );
     }

     shared->layer_data[data->index] = data;

     return DFB_OK;
}