diff options
author | Roman Marchenko <r.marchenko@samsung.com> | 2015-12-10 14:01:33 +0200 |
---|---|---|
committer | Roman Marchenko <r.marchenko@samsung.com> | 2015-12-10 14:01:33 +0200 |
commit | 1e3e29c76eb0a9e20352d0ed75ad7f781c15ea41 (patch) | |
tree | a1e763cf7c32235ed620b2dda8f6c71cf36ceb45 | |
parent | b8bd052b41e8eed04e5780e2b9fa7718540cab6d (diff) | |
download | libdrm-1e3e29c76eb0a9e20352d0ed75ad7f781c15ea41.tar.gz libdrm-1e3e29c76eb0a9e20352d0ed75ad7f781c15ea41.tar.bz2 libdrm-1e3e29c76eb0a9e20352d0ed75ad7f781c15ea41.zip |
[SPRD] Add "type" property for planes
Change-Id: If553a6c1721539e4b11a19e6c36d1ff5f47edde1
Signed-off-by: Roman Marchenko <r.marchenko@samsung.com>
-rw-r--r--[-rwxr-xr-x] | sprd/sprd_drm.c | 100 |
1 files changed, 87 insertions, 13 deletions
diff --git a/sprd/sprd_drm.c b/sprd/sprd_drm.c index d1839c24..a00679ec 100755..100644 --- a/sprd/sprd_drm.c +++ b/sprd/sprd_drm.c @@ -82,6 +82,15 @@ #define ZPOS_TO_LYR_ID(zpos) ( zpos == 1 ? SPRD_LAYER_OSD : SPRD_LAYER_IMG) +#define DRM_PLANE_TYPE_OVERLAY 0 +#define DRM_PLANE_TYPE_PRIMARY 1 +#define DRM_PLANE_TYPE_CUCSOR 2 + +#define ZPOS_TO_LYR_TYPE(zpos) ((zpos) == 1 ? DRM_PLANE_TYPE_PRIMARY :\ + (zpos) == 0 ? DRM_PLANE_TYPE_OVERLAY : -1) +#define LYR_TYPE_TO_ZPOS(type) ((type) == DRM_PLANE_TYPE_PRIMARY ? 1 :\ + (type) == DRM_PLANE_TYPE_CURSOR ? 0 : -1) + #define DRM_PROP_NAME_LEN 32 #define DRM_MODE_PROP_PENDING (1<<0) @@ -185,7 +194,7 @@ struct sprd_drm_property { //DRM_MODE_PROP_BLOB drmMMListHead blob_list; - void (*prop_set)(struct sprd_drm_property *prop, uint32_t obj_id, uint64_t val); + int32_t (*prop_set)(struct sprd_drm_property *prop, uint32_t obj_id, uint64_t val); uint64_t (*prop_get)(struct sprd_drm_property *prop, uint32_t obj_id); }; @@ -835,24 +844,82 @@ static struct sprd_drm_mode_crtc * sprd_drm_crtc_create(struct sprd_drm_device * return crtc; } -static void sprd_drm_plane_set_property(struct sprd_drm_property *prop, uint32_t obj_id, uint64_t val) +static uint32_t _chack_zpos(uint32_t zpos) { + if (zpos == 0 || zpos == 1) + return 1; + return 0; +} + +static int32_t sprd_drm_plane_set_property(struct sprd_drm_property *prop, uint32_t obj_id, uint64_t val) +{ + int zpos = 0; struct sprd_drm_mode_plane * plane = sprd_drm_resource_get(obj_id); - if (plane) { - if (plane->zpos != (uint32_t)val) { - plane->need_update = 1; - plane->zpos = (uint32_t)val; - } + + if (plane == NULL) { + return -EINVAL; + } + + if (strcmp(prop->name, "zpos") == 0) { + zpos = (uint32_t)val; } + else if (strcmp(prop->name, "type") == 0) { + zpos = LYR_TYPE_TO_ZPOS(val); + } + + if(!_chack_zpos(zpos)) { + return -EINVAL; + } + + if (plane->zpos != zpos) { + plane->need_update = 1; + plane->zpos = zpos; + } + return 0; } static uint64_t sprd_drm_plane_get_property(struct sprd_drm_property *prop, uint32_t obj_id) { struct sprd_drm_mode_plane * plane = sprd_drm_resource_get(obj_id); - if (plane) { - return (uint64_t)plane->zpos; + if (strcmp(prop->name, "zpos") == 0) { + if (plane) { + return (uint64_t)plane->zpos; + } + return DEFAULT_ZPOZ; } - return DEFAULT_ZPOZ; + else if (strcmp(prop->name, "type") == 0) { + if (plane) { + return (uint64_t)ZPOS_TO_LYR_TYPE(plane->zpos); + } + return (uint64_t)ZPOS_TO_LYR_TYPE(DEFAULT_ZPOZ); + } + return 0; +} + +static struct sprd_drm_prop_enum_list drm_plane_type_enum_list[] = +{ { 0, "Overlay" }, + { 1, "Primary" }, + { 2, "Cursor" }, +}; + +static struct sprd_drm_property * sprd_drm_create_plane_type_prpoperty(struct sprd_drm_device * dev) +{ + + struct sprd_drm_property * prop; + + prop = drmMalloc(sizeof (struct sprd_drm_property)); + prop->id = sprd_drm_resource_new_id(prop); + strcpy(prop->name, "type"); + prop->flags = DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ENUM; + prop->prop_set = sprd_drm_plane_set_property; + prop->prop_get = sprd_drm_plane_get_property; + + prop->num_values = sizeof(drm_plane_type_enum_list)/sizeof(struct sprd_drm_prop_enum_list); + prop->enum_list = drm_plane_type_enum_list; + + DRMLISTADD(&prop->head, &dev->property_list); + + return prop; } @@ -905,6 +972,11 @@ static struct sprd_drm_mode_plane * sprd_drm_plane_create(struct sprd_drm_devic sprd_drm_resource_prop_add(plane->drm_plane.plane_id, zpos_prop); + static struct sprd_drm_property *type_prop = NULL; + if (!type_prop) + type_prop = sprd_drm_create_plane_type_prpoperty(dev); + sprd_drm_resource_prop_add(plane->drm_plane.plane_id, type_prop); + return plane; } @@ -932,7 +1004,7 @@ static int sprd_drm_connector_enable(struct sprd_drm_mode_connector * conn) return 0; } -static void sprd_drm_connector_set_property(struct sprd_drm_property *prop, uint32_t obj_id, uint64_t val) +static int32_t sprd_drm_connector_set_property(struct sprd_drm_property *prop, uint32_t obj_id, uint64_t val) { struct sprd_drm_mode_connector * conn = sprd_drm_resource_get(obj_id); if (conn) { @@ -943,6 +1015,7 @@ static void sprd_drm_connector_set_property(struct sprd_drm_property *prop, uint sprd_drm_connector_enable(conn); } } + return 0; } static uint64_t sprd_drm_connector_get_property(struct sprd_drm_property *prop, uint32_t obj_id) @@ -1313,12 +1386,13 @@ static int sprd_drm_mode_set_obj_property(int fd, void *arg) { struct drm_mode_obj_set_property *set_prop = (struct drm_mode_obj_set_property *)arg; struct sprd_drm_property *prop = NULL; + int res = -EINVAL; prop = sprd_drm_resource_get(set_prop->prop_id); if(prop) - prop->prop_set(prop, set_prop->obj_id, set_prop->value); + res = prop->prop_set(prop, set_prop->obj_id, set_prop->value); - return 0; + return res; } static int sprd_drm_mode_set_plane(int fd, void *arg) |