make dump at tdm_layer_set_buffer function 47/66547/7 accepted/tizen/common/20160421.161410 accepted/tizen/ivi/20160421.010410 accepted/tizen/mobile/20160421.010350 accepted/tizen/tv/20160421.010402 accepted/tizen/wearable/20160421.010413 submit/tizen/20160420.040930
authorJunkyeong Kim <jk0430.kim@samsung.com>
Tue, 19 Apr 2016 10:46:28 +0000 (19:46 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 20 Apr 2016 04:01:46 +0000 (21:01 -0700)
add tdm dump helper functions

Change-Id: I64f1d7018ede69256d45181774b91f5a27f7f341
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
include/tdm_helper.h
src/tdm_display.c
src/tdm_helper.c
src/tdm_private.h

index c3296694fa993bb325475d0f85e04d97c4313634..254999a57a83bf144d240b5a0bb7c7cc20d1a909 100644 (file)
@@ -45,7 +45,7 @@ extern "C" {
 
 /**
  * @file tdm_helper.h
- * @brief The header file to help a vendor to implement a backend module
+ * @brief The header file to help tdm backend/frontend user
  */
 
 /**
@@ -95,6 +95,29 @@ int tdm_helper_get_fd(const char *env);
  */
 void tdm_helper_set_fd(const char *env, int fd);
 
+/**
+ * @brief Start the dump debugging.
+ * @details
+ * Start tdm dump.
+ * Make dump file when tdm_layer_set_buffer() function is called.
+ * Set the dump count to 1.
+ * @param[in] dumppath The given dump path
+ * @param[in] count The dump count number
+ * @see #tdm_helper_dump_stop()
+ */
+void
+tdm_helper_dump_start(char *dumppath, int *count);
+
+/**
+ * @brief Stop the dump debugging.
+ * @details
+ * Stop tdm dump.
+ * Set the dump count to 0.
+ * @see #tdm_helper_dump_start()
+ */
+void
+tdm_helper_dump_stop(void);
+
 #ifdef __cplusplus
 }
 #endif
index 1039beb262d33d9e084ba35c65280814beb0d212..a7a1327260dc4586f51fd32659c3c576dfdf0640 100644 (file)
@@ -40,6 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tdm.h"
 #include "tdm_backend.h"
 #include "tdm_private.h"
+#include "tdm_helper.h"
 
 #define COUNT_MAX   10
 
@@ -1417,6 +1418,47 @@ tdm_layer_get_info(tdm_layer *layer, tdm_info_layer *info)
        return ret;
 }
 
+static void
+_tdm_layer_dump_buffer(tdm_layer *layer, tbm_surface_h buffer)
+{
+       tdm_private_layer *private_layer = (tdm_private_layer*)layer;
+       tdm_private_output *private_output = private_layer->private_output;
+       char *path = NULL;
+       int count;
+       unsigned int pipe;
+       int zpos;
+       tbm_surface_info_s info;
+       tbm_surface_error_e err;
+
+       path = tdm_helper_get_dump_path();
+       TDM_RETURN_IF_FAIL(path != NULL);
+
+       count = tdm_helper_get_dump_count();
+       TDM_RETURN_IF_FAIL(count != 0);
+
+       err = tbm_surface_map(buffer, TBM_SURF_OPTION_READ, &info);
+       TDM_RETURN_IF_FAIL(err == TBM_SURFACE_ERROR_NONE);
+
+       char fullpath[PATH_MAX] = {0, };
+
+       pipe = private_output->pipe;
+       zpos = private_layer->caps.zpos;
+
+       if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888)
+               snprintf(fullpath, sizeof(fullpath), "%s/%03d_out_%d_lyr_%d.png",
+                       path, count, pipe, zpos);
+       else
+               snprintf(fullpath, sizeof(fullpath), "%s/%03d_out_%d_lyr_%d_%dx%d_%c%c%c%c.yuv",
+                       path, count, pipe, zpos, info.planes[0].stride, info.height, FOURCC_STR(info.format));
+
+       tbm_surface_unmap(buffer);
+
+       tdm_helper_dump_buffer(buffer, fullpath);
+       TDM_DBG("%d, %s dump excute", count, fullpath);
+
+       return;
+}
+
 EXTERN tdm_error
 tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer)
 {
@@ -1441,6 +1483,9 @@ tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer)
        ret = func_layer->layer_set_buffer(private_layer->layer_backend, buffer);
        TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
 
+       /* dump buffer */
+       _tdm_layer_dump_buffer(layer, buffer);
+
        if (ret == TDM_ERROR_NONE) {
                /* FIXME: should save to pending_buffer first. And after committing
                 * successfully, need to move to waiting_buffer.
index e7d61547a81bb30d76e62ff279b06f76ef19d645..03d13cbdec53bebe1e7efc82815dda3252fad2d2 100644 (file)
@@ -16,6 +16,9 @@
 
 static const char *dump_prefix[2] = {"png", "yuv"};
 
+static int *tdm_helper_dump_count;
+static char *tdm_helper_dump_path;
+
 INTERN int
 tdm_helper_unlock_in_cb(tdm_private_display *private_display)
 {
@@ -263,3 +266,48 @@ tdm_helper_set_fd(const char *env, int fd)
        if (fd >= 0)
                TDM_INFO("%s: fd(%d)", env, fd);
 }
+
+EXTERN void
+tdm_helper_dump_start(char *dumppath, int *count)
+{
+       if (tdm_helper_dump_count != NULL) {
+               TDM_DBG("tdm_helper_dump is already started.");
+               return;
+       }
+
+       if (dumppath == NULL) {
+               TDM_DBG("tdm_helper_dump dumppath is null.");
+               return;
+       }
+
+       tdm_helper_dump_count = count;
+       tdm_helper_dump_path = dumppath;
+
+       TDM_DBG("tdm_helper_dump start.(path : %s)", tdm_helper_dump_path);
+}
+
+EXTERN void
+tdm_helper_dump_stop(void)
+{
+       tdm_helper_dump_path = NULL;
+       tdm_helper_dump_count = NULL;
+
+       TDM_DBG("tdm_helper_dump stop.");
+}
+
+INTERN int
+tdm_helper_get_dump_count(void)
+{
+       if ((tdm_helper_dump_count != NULL) && (tdm_helper_dump_path != NULL)) {
+               if (*tdm_helper_dump_count == 1000)
+                       *tdm_helper_dump_count = 1;
+               return (*tdm_helper_dump_count)++;
+       } else
+               return 0;
+}
+
+INTERN char *
+tdm_helper_get_dump_path(void)
+{
+       return tdm_helper_dump_path;
+}
index db82944f8d7f744d663818c124b2010f9cf1adf2..aa19633322498d1a0a5715922cdee39e7938c6e4 100644 (file)
@@ -446,6 +446,11 @@ tdm_helper_unlock_in_cb(tdm_private_display *private_display);
 void
 tdm_helper_lock_in_cb(tdm_private_display *private_display, int need_lock);
 
+int
+tdm_helper_get_dump_count(void);
+char *
+tdm_helper_get_dump_path(void);
+
 #define _pthread_mutex_lock(l) \
     do {if (tdm_debug_mutex) TDM_INFO("mutex lock"); pthread_mutex_lock(l);} while (0)
 #define _pthread_mutex_unlock(l) \