• Home
  • Raw
  • Download

Lines Matching full:dev

15 #include "dev.h"
21 printf(" -c, --card Index of dri card (ie: /dev/dri/cardN)\n"); in show_usage()
72 static uint32_t get_prop_id(struct sp_dev *dev, in get_prop_id() argument
79 p = drmModeGetProperty(dev->fd, props->props[i]); in get_prop_id()
108 struct sp_dev *dev; in create_sp_dev() local
114 snprintf(card_path, sizeof(card_path), "/dev/dri/card%d", card); in create_sp_dev()
122 dev = calloc(1, sizeof(*dev)); in create_sp_dev()
123 if (!dev) { in create_sp_dev()
124 printf("failed to allocate dev\n"); in create_sp_dev()
128 dev->fd = fd; in create_sp_dev()
130 ret = drmSetClientCap(dev->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); in create_sp_dev()
136 ret = drmSetClientCap(dev->fd, DRM_CLIENT_CAP_ATOMIC, 1); in create_sp_dev()
142 r = drmModeGetResources(dev->fd); in create_sp_dev()
148 dev->num_connectors = r->count_connectors; in create_sp_dev()
149 dev->connectors = calloc(dev->num_connectors, in create_sp_dev()
151 if (!dev->connectors) { in create_sp_dev()
155 for (i = 0; i < dev->num_connectors; i++) { in create_sp_dev()
157 dev->connectors[i].conn = drmModeGetConnector(dev->fd, in create_sp_dev()
159 if (!dev->connectors[i].conn) { in create_sp_dev()
164 props = drmModeObjectGetProperties(dev->fd, r->connectors[i], in create_sp_dev()
171 dev->connectors[i].crtc_id_pid = get_prop_id(dev, props, in create_sp_dev()
174 if (!dev->connectors[i].crtc_id_pid) in create_sp_dev()
178 dev->num_encoders = r->count_encoders; in create_sp_dev()
179 dev->encoders = calloc(dev->num_encoders, sizeof(*dev->encoders)); in create_sp_dev()
180 if (!dev->encoders) { in create_sp_dev()
184 for (i = 0; i < dev->num_encoders; i++) { in create_sp_dev()
185 dev->encoders[i] = drmModeGetEncoder(dev->fd, r->encoders[i]); in create_sp_dev()
186 if (!dev->encoders[i]) { in create_sp_dev()
192 dev->num_crtcs = r->count_crtcs; in create_sp_dev()
193 dev->crtcs = calloc(dev->num_crtcs, sizeof(struct sp_crtc)); in create_sp_dev()
194 if (!dev->crtcs) { in create_sp_dev()
198 for (i = 0; i < dev->num_crtcs; i++) { in create_sp_dev()
201 dev->crtcs[i].crtc = drmModeGetCrtc(dev->fd, r->crtcs[i]); in create_sp_dev()
202 if (!dev->crtcs[i].crtc) { in create_sp_dev()
206 dev->crtcs[i].pipe = i; in create_sp_dev()
207 dev->crtcs[i].num_planes = 0; in create_sp_dev()
209 props = drmModeObjectGetProperties(dev->fd, r->crtcs[i], in create_sp_dev()
216 dev->crtcs[i].mode_pid = get_prop_id(dev, props, "MODE_ID"); in create_sp_dev()
217 dev->crtcs[i].active_pid = get_prop_id(dev, props, "ACTIVE"); in create_sp_dev()
219 if (!dev->crtcs[i].mode_pid || !dev->crtcs[i].active_pid) in create_sp_dev()
223 pr = drmModeGetPlaneResources(dev->fd); in create_sp_dev()
228 dev->num_planes = pr->count_planes; in create_sp_dev()
229 dev->planes = calloc(dev->num_planes, sizeof(struct sp_plane)); in create_sp_dev()
230 for(i = 0; i < dev->num_planes; i++) { in create_sp_dev()
232 struct sp_plane *plane = &dev->planes[i]; in create_sp_dev()
234 plane->dev = dev; in create_sp_dev()
235 plane->plane = drmModeGetPlane(dev->fd, pr->planes[i]); in create_sp_dev()
249 for (j = 0; j < dev->num_crtcs; j++) { in create_sp_dev()
251 dev->crtcs[j].num_planes++; in create_sp_dev()
254 props = drmModeObjectGetProperties(dev->fd, pr->planes[i], in create_sp_dev()
260 plane->crtc_pid = get_prop_id(dev, props, "CRTC_ID"); in create_sp_dev()
265 plane->fb_pid = get_prop_id(dev, props, "FB_ID"); in create_sp_dev()
270 plane->crtc_x_pid = get_prop_id(dev, props, "CRTC_X"); in create_sp_dev()
275 plane->crtc_y_pid = get_prop_id(dev, props, "CRTC_Y"); in create_sp_dev()
280 plane->crtc_w_pid = get_prop_id(dev, props, "CRTC_W"); in create_sp_dev()
285 plane->crtc_h_pid = get_prop_id(dev, props, "CRTC_H"); in create_sp_dev()
290 plane->src_x_pid = get_prop_id(dev, props, "SRC_X"); in create_sp_dev()
295 plane->src_y_pid = get_prop_id(dev, props, "SRC_Y"); in create_sp_dev()
300 plane->src_w_pid = get_prop_id(dev, props, "SRC_W"); in create_sp_dev()
305 plane->src_h_pid = get_prop_id(dev, props, "SRC_H"); in create_sp_dev()
318 return dev; in create_sp_dev()
324 destroy_sp_dev(dev); in create_sp_dev()
328 void destroy_sp_dev(struct sp_dev *dev) in destroy_sp_dev() argument
332 if (dev->planes) { in destroy_sp_dev()
333 for (i = 0; i< dev->num_planes; i++) { in destroy_sp_dev()
334 if (dev->planes[i].in_use) in destroy_sp_dev()
335 put_sp_plane(&dev->planes[i]); in destroy_sp_dev()
336 if (dev->planes[i].plane) in destroy_sp_dev()
337 drmModeFreePlane(dev->planes[i].plane); in destroy_sp_dev()
338 if (dev->planes[i].bo) in destroy_sp_dev()
339 free_sp_bo(dev->planes[i].bo); in destroy_sp_dev()
341 free(dev->planes); in destroy_sp_dev()
343 if (dev->crtcs) { in destroy_sp_dev()
344 for (i = 0; i< dev->num_crtcs; i++) { in destroy_sp_dev()
345 if (dev->crtcs[i].crtc) in destroy_sp_dev()
346 drmModeFreeCrtc(dev->crtcs[i].crtc); in destroy_sp_dev()
348 free(dev->crtcs); in destroy_sp_dev()
350 if (dev->encoders) { in destroy_sp_dev()
351 for (i = 0; i< dev->num_encoders; i++) { in destroy_sp_dev()
352 if (dev->encoders[i]) in destroy_sp_dev()
353 drmModeFreeEncoder(dev->encoders[i]); in destroy_sp_dev()
355 free(dev->encoders); in destroy_sp_dev()
357 if (dev->connectors) { in destroy_sp_dev()
358 for (i = 0; i< dev->num_connectors; i++) { in destroy_sp_dev()
359 if (dev->connectors[i].conn) in destroy_sp_dev()
360 drmModeFreeConnector(dev->connectors[i].conn); in destroy_sp_dev()
362 free(dev->connectors); in destroy_sp_dev()
365 close(dev->fd); in destroy_sp_dev()
366 free(dev); in destroy_sp_dev()