/**
* @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
*/
/**
*/
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
#include "tdm.h"
#include "tdm_backend.h"
#include "tdm_private.h"
+#include "tdm_helper.h"
#define COUNT_MAX 10
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)
{
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.
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)
{
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;
+}
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) \