add max_attach_count variable 80/68980/1
authorBoram Park <boram1288.park@samsung.com>
Tue, 10 May 2016 23:41:28 +0000 (08:41 +0900)
committerBoram Park <boram1288.park@samsung.com>
Wed, 11 May 2016 00:37:25 +0000 (09:37 +0900)
Change-Id: Ib5f6801a489232a1ed45c83809fefa527a601a51

include/tdm_backend.h
src/tdm_pp.c

index e114d3c..596ca78 100644 (file)
@@ -156,6 +156,11 @@ typedef struct _tdm_caps_pp {
        int max_w;              /**< The maximum width. -1 means "not defined" */
        int max_h;              /**< The maximum height. -1 means "not defined" */
        int preferred_align;    /**< The prefered align. -1 means "not defined" */
+
+       int max_attach_count;   /**< The attach count which a PP object can handle.
+                                *   -1 means "not defined".
+                                * @since 1.2.0
+                                */
 } tdm_caps_pp;
 
 /**
@@ -174,6 +179,11 @@ typedef struct _tdm_caps_capture {
        int max_w;              /**< The maximum width. -1 means "not defined" */
        int max_h;              /**< The maximum height. -1 means "not defined" */
        int preferred_align;    /**< The prefered align. -1 means "not defined" */
+
+       int max_attach_count;   /**< The attach count which a capture object can handle.
+                                *   -1 means "not defined".
+                                * @since 1.2.0
+                                */
 } tdm_caps_capture;
 
 /**
index 0b56073..c574d8a 100644 (file)
@@ -360,6 +360,18 @@ tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst)
                return TDM_ERROR_NOT_IMPLEMENTED;
        }
 
+       if (tdm_display_check_module_abi(private_display, 1, 2) &&
+               private_display->caps_pp.max_attach_count > 0) {
+               int length = LIST_LENGTH(&private_pp->src_pending_buffer_list) +
+                            LIST_LENGTH(&private_pp->src_buffer_list);
+               if (length >= private_display->caps_pp.max_attach_count) {
+                       _pthread_mutex_unlock(&private_display->lock);
+                       TDM_DBG("failed: too many attached!! max_attach_count(%d)",
+                               private_display->caps_pp.max_attach_count);
+                       return TDM_ERROR_BAD_REQUEST;
+               }
+       }
+
        ret = _tdm_pp_check_if_exist(private_pp, src, dst);
        if (ret != TDM_ERROR_NONE) {
                _pthread_mutex_unlock(&private_display->lock);