summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-02-04 09:14:31 -0500
committerChris Michael <cpmichael@osg.samsung.com>2016-02-04 09:27:40 -0500
commit3ed4b3e6fdfd8ff637f1efd402ab77fa4210b5f9 (patch)
tree987582d993da06a55161d3de3891eeaa531e4ec1 /src/lib/ecore_drm
parent26eefa970fafb45b0b8920e7ca79f721670e9e75 (diff)
ecore-drm: Add internal function to create planes for an output
This patch adds an internal function that we use during output creation in order to create the planes necessary and get the supported rotation values for an output Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
Diffstat (limited to 'src/lib/ecore_drm')
-rw-r--r--src/lib/ecore_drm/ecore_drm_output.c188
1 files changed, 96 insertions, 92 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c
index aba2164..1ac8f9a 100644
--- a/src/lib/ecore_drm/ecore_drm_output.c
+++ b/src/lib/ecore_drm/ecore_drm_output.c
@@ -424,6 +424,95 @@ _ecore_drm_output_subpixel_get(int subpixel)
424 } 424 }
425} 425}
426 426
427static void
428_ecore_drm_output_planes_get(Ecore_Drm_Output *output)
429{
430 Ecore_Drm_Device *dev;
431 Ecore_Drm_Plane *eplane;
432 drmModePlaneRes *pres;
433 unsigned int i = 0, j = 0;
434 int k = 0;
435
436 dev = output->dev;
437 pres = drmModeGetPlaneResources(dev->drm.fd);
438 if (!pres) return;
439
440 for (; i < pres->count_planes; i++)
441 {
442 drmModePlane *plane;
443 drmModeObjectPropertiesPtr props;
444 int type = -1;
445
446 plane = drmModeGetPlane(dev->drm.fd, pres->planes[i]);
447 if (!plane) continue;
448
449 if (!(plane->possible_crtcs & (1 << output->crtc_index)))
450 goto free_plane;
451
452 props =
453 drmModeObjectGetProperties(dev->drm.fd, plane->plane_id,
454 DRM_MODE_OBJECT_PLANE);
455 if (!props) goto free_plane;
456
457 eplane = calloc(1, sizeof(Ecore_Drm_Plane));
458 if (!eplane) goto free_plane;
459
460 eplane->id = plane->plane_id;
461
462 for (j = 0; type == -1 && j < props->count_props; j++)
463 {
464 drmModePropertyPtr prop;
465
466 prop = drmModeGetProperty(dev->drm.fd, props->props[j]);
467 if (!prop) continue;
468
469 if (!strcmp(prop->name, "type"))
470 {
471 eplane->type = props->prop_values[j];
472 if (eplane->type == ECORE_DRM_PLANE_TYPE_PRIMARY)
473 output->primary_plane_id = eplane->id;
474 }
475 else if (!strcmp(prop->name, "rotation"))
476 {
477 output->rotation_prop_id = props->props[j];
478 eplane->rotation = props->prop_values[j];
479
480 for (k = 0; k < prop->count_enums; k++)
481 {
482 int r = -1;
483
484 if (!strcmp(prop->enums[k].name, "rotate-0"))
485 r = ECORE_DRM_PLANE_ROTATION_NORMAL;
486 else if (!strcmp(prop->enums[k].name, "rotate-90"))
487 r = ECORE_DRM_PLANE_ROTATION_90;
488 else if (!strcmp(prop->enums[k].name, "rotate-180"))
489 r = ECORE_DRM_PLANE_ROTATION_180;
490 else if (!strcmp(prop->enums[k].name, "rotate-270"))
491 r = ECORE_DRM_PLANE_ROTATION_270;
492 else if (!strcmp(prop->enums[k].name, "reflect-x"))
493 r = ECORE_DRM_PLANE_ROTATION_REFLECT_X;
494 else if (!strcmp(prop->enums[k].name, "reflect-y"))
495 r = ECORE_DRM_PLANE_ROTATION_REFLECT_Y;
496
497 if (r != -1)
498 {
499 eplane->supported_rotations |= r;
500 eplane->rotation_map[ffs(r)] =
501 1 << prop->enums[k].value;
502 }
503 }
504 }
505
506 drmModeFreeProperty(prop);
507 }
508
509 output->planes = eina_list_append(output->planes, eplane);
510
511free_plane:
512 drmModeFreePlane(plane);
513 }
514}
515
427static Ecore_Drm_Output * 516static Ecore_Drm_Output *
428_ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes *res, drmModeConnector *conn, int x, int y, Eina_Bool cloned) 517_ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes *res, drmModeConnector *conn, int x, int y, Eina_Bool cloned)
429{ 518{
@@ -467,6 +556,7 @@ _ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes *res, drmModeConnecto
467 snprintf(name, sizeof(name), "%s-%d", type, conn->connector_type_id); 556 snprintf(name, sizeof(name), "%s-%d", type, conn->connector_type_id);
468 eina_stringshare_replace(&output->name, name); 557 eina_stringshare_replace(&output->name, name);
469 558
559 output->crtc_index = i;
470 output->crtc_id = res->crtcs[i]; 560 output->crtc_id = res->crtcs[i];
471 output->pipe = i; 561 output->pipe = i;
472 dev->crtc_allocator |= (1 << output->crtc_id); 562 dev->crtc_allocator |= (1 << output->crtc_id);
@@ -558,6 +648,8 @@ _ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes *res, drmModeConnecto
558 (conn->count_modes == 0) ? ", built-in" : ""); 648 (conn->count_modes == 0) ? ", built-in" : "");
559 } 649 }
560 650
651 _ecore_drm_output_planes_get(output);
652
561 return output; 653 return output;
562 654
563err: 655err:
@@ -578,6 +670,7 @@ static void
578_ecore_drm_output_free(Ecore_Drm_Output *output) 670_ecore_drm_output_free(Ecore_Drm_Output *output)
579{ 671{
580 Ecore_Drm_Output_Mode *mode; 672 Ecore_Drm_Output_Mode *mode;
673 Ecore_Drm_Plane *plane;
581 674
582 /* check for valid output */ 675 /* check for valid output */
583 if (!output) return; 676 if (!output) return;
@@ -605,6 +698,9 @@ _ecore_drm_output_free(Ecore_Drm_Output *output)
605 EINA_LIST_FREE(output->modes, mode) 698 EINA_LIST_FREE(output->modes, mode)
606 free(mode); 699 free(mode);
607 700
701 EINA_LIST_FREE(output->planes, plane)
702 free(plane);
703
608 /* free strings */ 704 /* free strings */
609 if (output->name) eina_stringshare_del(output->name); 705 if (output->name) eina_stringshare_del(output->name);
610 if (output->model) eina_stringshare_del(output->model); 706 if (output->model) eina_stringshare_del(output->model);
@@ -789,95 +885,6 @@ _ecore_drm_output_render_disable(Ecore_Drm_Output *output)
789 ecore_drm_output_dpms_set(output, DRM_MODE_DPMS_OFF); 885 ecore_drm_output_dpms_set(output, DRM_MODE_DPMS_OFF);
790} 886}
791 887
792static void
793_ecore_drm_output_planes_get(Ecore_Drm_Device *dev)
794{
795 drmModePlaneRes *pres;
796 unsigned int i = 0, j = 0;
797 int k = 0;
798
799 pres = drmModeGetPlaneResources(dev->drm.fd);
800 if (!pres) return;
801
802 for (; i < pres->count_planes; i++)
803 {
804 drmModePlane *plane;
805 drmModeObjectPropertiesPtr props;
806 int type = -1;
807
808 plane = drmModeGetPlane(dev->drm.fd, pres->planes[i]);
809 if (!plane) continue;
810
811 props = drmModeObjectGetProperties(dev->drm.fd, plane->plane_id,
812 DRM_MODE_OBJECT_PLANE);
813 if (!props) goto free_plane;
814
815 DBG("Plane %u Properties:", plane->plane_id);
816
817 for (j = 0; type == -1 && j < props->count_props; j++)
818 {
819 drmModePropertyPtr prop;
820
821 prop = drmModeGetProperty(dev->drm.fd, props->props[j]);
822 if (!prop) continue;
823
824 if (!strcmp(prop->name, "type"))
825 type = props->prop_values[j];
826
827 drmModeFreeProperty(prop);
828 }
829
830 DBG("\tFormats:");
831 for (j = 0; j < plane->count_formats; j++)
832 DBG("\t\t%4.4s", (char *)&plane->formats[j]);
833
834 for (j = 0; j < props->count_props; j++ )
835 {
836 drmModePropertyPtr prop;
837
838 prop = drmModeGetProperty(dev->drm.fd, props->props[j]);
839 if (!prop) continue;
840
841 DBG("\tProperty Name: %s", prop->name);
842
843 if (prop->flags & DRM_MODE_PROP_RANGE)
844 {
845 DBG("\t\tRange Property");
846 for (k = 0; k < prop->count_values; k++)
847 DBG("\t\t\t%"PRIu64, prop->values[k]);
848 }
849 if (prop->flags & DRM_MODE_PROP_ENUM)
850 {
851 DBG("\t\tEnum Property");
852 for (k = 0; k < prop->count_enums; k++)
853 DBG("\t\t\t%s=%llu", prop->enums[k].name,
854 prop->enums[k].value);
855 }
856 if (prop->flags & DRM_MODE_PROP_BITMASK)
857 {
858 DBG("\t\tBitmask Property");
859 for (k = 0; k < prop->count_enums; k++)
860 DBG("\t\t\t%s=0x%llx", prop->enums[k].name,
861 (1LL << prop->enums[k].value));
862 }
863
864 DBG("\t\tValue: %"PRIu64, props->prop_values[j]);
865
866 drmModeFreeProperty(prop);
867 }
868
869 DBG("\tCurrent Crtc: %d", plane->crtc_id);
870 DBG("\tPossible Crtcs: 0x%08x", plane->possible_crtcs);
871
872 drmModeFreeObjectProperties(props);
873
874free_plane:
875 drmModeFreePlane(plane);
876 }
877
878 drmModeFreePlaneResources(pres);
879}
880
881/* public functions */ 888/* public functions */
882 889
883/** 890/**
@@ -950,9 +957,6 @@ next:
950 drmModeFreeConnector(conn); 957 drmModeFreeConnector(conn);
951 } 958 }
952 959
953 /* TODO: Planes */
954 _ecore_drm_output_planes_get(dev);
955
956 ret = EINA_TRUE; 960 ret = EINA_TRUE;
957 if (eina_list_count(dev->outputs) < 1) 961 if (eina_list_count(dev->outputs) < 1)
958 ret = EINA_FALSE; 962 ret = EINA_FALSE;