const int pixel_size = 4; // RGBA
png_bytep *row_pointers =
png_malloc(pPngStruct, height * sizeof(png_byte *));
+ if (!row_pointers) {
+ png_destroy_write_struct(&pPngStruct, &pPngInfo);
+ fclose(fp);
+ return;
+ }
unsigned int *blocks = (unsigned int *)data;
int y = 0;
for (; y < height; ++y) {
png_bytep row =
png_malloc(pPngStruct, sizeof(png_byte) * width * pixel_size);
+ if (!row) {
+ for (x = 0; x < y; x++)
+ png_free(pPngStruct, row_pointers[x]);
+ png_free(pPngStruct, row_pointers);
+ png_destroy_write_struct(&pPngStruct, &pPngInfo);
+ fclose(fp);
+ return;
+ }
+
row_pointers[y] = (png_bytep)row;
for (x = 0; x < width; ++x) {
unsigned int curBlock = blocks[y * width + x];
TDM_GOTO_IF_FAIL(t != NULL, failed_make);
snprintf(fullpath, TDM_PATH_LEN, "%s/dump_%04d%02d%02d.%02d%02d%02d", path,
- t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
+ t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
if ((mkdir(fullpath, 0755)) < 0) {
TDM_ERR("mkdir '%s' fail\n", fullpath);
tbm_surface_info_s info;
int len, ret;
const char *ext;
+ int bo_cnt;
TDM_RETURN_IF_FAIL(buffer != NULL);
TDM_RETURN_IF_FAIL(file != NULL);
return;
}
+ bo_cnt = tbm_surface_internal_get_num_bos(buffer);
+ TDM_DBG("buffer: bo_cnt(%d) %dx%d %c%c%c%c, plane: (%p+%d, %d,%d) (%p+%d, %d,%d) (%p+%d, %d,%d)",
+ bo_cnt, info.width, info.height, FOURCC_STR(info.format),
+ info.planes[0].ptr, info.planes[0].offset, info.planes[0].stride, info.planes[0].size,
+ info.planes[1].ptr, info.planes[1].offset, info.planes[1].stride, info.planes[1].size,
+ info.planes[2].ptr, info.planes[2].offset, info.planes[2].stride, info.planes[2].size);
+
switch (info.format) {
case TBM_FORMAT_ARGB8888:
case TBM_FORMAT_XRGB8888:
break;
case TBM_FORMAT_NV12:
case TBM_FORMAT_NV21:
+ if (bo_cnt == 1 &&
+ (info.planes[0].ptr + info.planes[0].stride * info.height) != info.planes[1].ptr)
+ TDM_WRN("%p != %p", info.planes[0].ptr + info.planes[0].stride * info.height, info.planes[1].ptr);
+
_tdm_helper_dump_raw(file,
info.planes[0].ptr,
info.planes[0].stride * info.height,
if (rotate_step > 0) {
int c, s, tx = 0, ty = 0;
switch (rotate_step) {
- case 1:
- c = 0, s = -1, tx = -dstpos->w;
- break;
- case 2:
- c = -1, s = 0, tx = -dstpos->w, ty = -dstpos->h;
- break;
- case 3:
- c = 0, s = 1, ty = -dstpos->h;
- break;
- default:
- break;
+ case 1:
+ c = 0, s = -1, tx = -dstpos->w;
+ break;
+ case 2:
+ c = -1, s = 0, tx = -dstpos->w, ty = -dstpos->h;
+ break;
+ case 3:
+ c = 0, s = 1, ty = -dstpos->h;
+ break;
}
pixman_f_transform_translate(&ft, NULL, tx, ty);
pixman_f_transform_rotate(&ft, NULL, c, s);
{
const char *value;
int fd, newfd, flags, ret;
+ char *end;
+ errno = 0;
value = (const char*)getenv(env);
if (!value)
return -1;
- ret = sscanf(value, "%d", &fd);
- if (ret < 0) {
- TDM_ERR("sscanf failed: %m");
+ const long sl = strtol(value, &end, 10);
+ if (end == value) {
+ TDM_ERR("%s: not a decimal number\n", value);
return -1;
+ } else if (*end != '\0') {
+ TDM_ERR("%s: extra characters at end of input: %s\n", value, end);
+ return -1;
+ } else if ((sl == LONG_MIN || sl == LONG_MAX) && errno == ERANGE) {
+ TDM_ERR("%s out of range of type long\n", value);
+ return -1;
+ } else if (sl > INT_MAX) {
+ TDM_ERR("%ld greater than INT_MAX\n", sl);
+ return -1;
+ } else if (sl < INT_MIN) {
+ TDM_ERR("%ld less than INT_MIN\n", sl);
+ return -1;
+ } else {
+ fd = (int)sl;
+ if (fd < 0) {
+ TDM_ERR("%d out of fd range\n", fd);
+ return -1;
+ }
}
flags = fcntl(fd, F_GETFD);
TDM_INFO("%s: fd(%d) newfd(%d)", env, fd, newfd);
- fcntl(newfd, F_SETFD, flags | FD_CLOEXEC);
+ ret = fcntl(newfd, F_SETFD, flags | FD_CLOEXEC);
+ if (ret == -1) {
+ TDM_ERR("fcntl failed: %m");
+ close(newfd);
+ return -1;
+ }
return newfd;
}
TDM_RETURN_VAL_IF_FAIL(srcbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
TDM_RETURN_VAL_IF_FAIL(dstbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
- if (tbm_surface_map(srcbuf, TBM_SURF_OPTION_READ, &src_info)
- != TBM_SURFACE_ERROR_NONE) {
+ if (tbm_surface_map(srcbuf, TBM_SURF_OPTION_READ, &src_info) != TBM_SURFACE_ERROR_NONE) {
TDM_ERR("cannot mmap srcbuf\n");
return TDM_ERROR_OPERATION_FAILED;
}
- if (tbm_surface_map(dstbuf, TBM_SURF_OPTION_WRITE, &dst_info)
- != TBM_SURFACE_ERROR_NONE) {
+ if (tbm_surface_map(dstbuf, TBM_SURF_OPTION_WRITE, &dst_info) != TBM_SURFACE_ERROR_NONE) {
TDM_ERR("cannot mmap dstbuf\n");
tbm_surface_unmap(srcbuf);
return TDM_ERROR_OPERATION_FAILED;
TDM_SNPRINTF(reply, len, "idx maker model name type status dpms subpixel align_w min max phy(mm)\n");
TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n");
LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
- TDM_SNPRINTF(reply, len, "%d %s %s %s %s %s %s %d %d %dx%d %dx%d %dx%d\n",
+ TDM_SNPRINTF(reply, len, "%d %s %s %s %s %s %s %u %d %dx%d %dx%d %ux%u\n",
private_output->index, private_output->caps.maker,
private_output->caps.model, private_output->caps.name,
tdm_conn_str(private_output->caps.type),
TDM_FRONT_VALUE(private_output->caps.max_h),
private_output->caps.mmWidth, private_output->caps.mmHeight);
- TDM_SNPRINTF(reply, len, "\t%d modes:\n", private_output->caps.mode_count);
+ TDM_SNPRINTF(reply, len, "\t%u modes:\n", private_output->caps.mode_count);
if (private_output->caps.mode_count > 0) {
const tdm_output_mode *current_mode = NULL;
TDM_SNPRINTF(reply, len, "\t\t name refresh (Hz) clk hdisp hss hse htot vdisp vss vse vtot vscan\n");
for (i = 0; i < private_output->caps.mode_count; i++) {
char *current = (current_mode == private_output->caps.modes + i) ? "*" : " ";
- TDM_SNPRINTF(reply, len, "\t\t%s%s %d %d %d %d %d %d %d %d %d %d %d ",
+ TDM_SNPRINTF(reply, len, "\t\t%s%s %u %u %u %u %u %u %u %u %u %u %u ",
current,
private_output->caps.modes[i].name,
private_output->caps.modes[i].vrefresh,
private_output->caps.props[i].id,
&value);
TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
- TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
+ TDM_SNPRINTF(reply, len, "\t\t%s\t%u\t%u\n",
private_output->caps.props[i].name,
private_output->caps.props[i].id,
value.u32);
ret = func_layer->layer_get_info(private_layer->layer_backend, &info);
TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
- format = tbm_surface_get_format(private_layer->showing_buffer);
- tbm_surface_get_info(private_layer->showing_buffer, &buf_info);
+ if (!private_layer->showing_buffer)
+ continue;
+
+ format = tbm_surface_get_format(private_layer->showing_buffer->buffer);
+ tbm_surface_get_info(private_layer->showing_buffer->buffer, &buf_info);
if (IS_RGB(format))
size.h = buf_info.planes[0].stride >> 2;
else
size.h = buf_info.planes[0].stride;
- size.v = tbm_surface_get_height(private_layer->showing_buffer);
+ size.v = tbm_surface_get_height(private_layer->showing_buffer->buffer);
if (info.src_config.format)
- format = (info.src_config.format)?:format;
+ format = (info.src_config.format) ? : format;
- TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %dx%d %dx%d+%d+%d %dx%d+%d+%d %s\n",
+ TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %ux%u %ux%u+%u+%u %ux%u+%u+%u %s\n",
private_layer->index,
private_output->index,
private_layer->caps.zpos,
- private_layer->showing_buffer, FOURCC_STR(format), size.h, size.v,
+ private_layer->showing_buffer->buffer, FOURCC_STR(format), size.h, size.v,
info.src_config.pos.w, info.src_config.pos.h, info.src_config.pos.x, info.src_config.pos.y,
info.dst_pos.w, info.dst_pos.h, info.dst_pos.x, info.dst_pos.y,
tdm_transform_str(info.transform));
TDM_SNPRINTF(reply, len, "\n");
}
- TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_layer->caps.prop_count);
+ TDM_SNPRINTF(reply, len, "\t%u properties:\n", private_layer->caps.prop_count);
if (private_layer->caps.prop_count > 0) {
TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n");
for (i = 0; i < private_layer->caps.prop_count; i++) {
private_layer->caps.props[i].id,
&value);
TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock);
- TDM_SNPRINTF(reply, len, "\t\t%s\t%d\t%d\n",
+ TDM_SNPRINTF(reply, len, "\t\t%s\t%u\t%u\n",
private_layer->caps.props[i].name,
private_layer->caps.props[i].id,
value.u32);
TDM_SNPRINTF(reply, len, "src(format size crop) | dst(format size crop) | transform\n");
TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n");
LIST_FOR_EACH_ENTRY(private_pp, &private_display->pp_list, link) {
- TDM_SNPRINTF(reply, len, "%c%c%c%c %dx%d %dx%d+%d+%d | %c%c%c%c %dx%d %dx%d+%d+%d | %s\n",
+ TDM_SNPRINTF(reply, len, "%c%c%c%c %ux%u %ux%u+%u+%u | %c%c%c%c %ux%u %ux%u+%u+%u | %s\n",
FOURCC_STR(private_pp->info.src_config.format),
private_pp->info.src_config.size.h,
private_pp->info.src_config.size.v,
TDM_SNPRINTF(reply, len, "dst(format size crop) | transform\n");
TDM_SNPRINTF(reply, len, "-----------------------------------\n");
LIST_FOR_EACH_ENTRY(private_capture, &private_display->capture_list, link) {
- TDM_SNPRINTF(reply, len, "%c%c%c%c %dx%d %dx%d+%d+%d | %s\n",
+ TDM_SNPRINTF(reply, len, "%c%c%c%c %ux%u %ux%u+%u+%u | %s\n",
FOURCC_STR(private_capture->info.dst_config.format),
private_capture->info.dst_config.size.h,
private_capture->info.dst_config.size.v,
unlock:
_pthread_mutex_unlock(&private_display->lock);
}
+
+EXTERN int
+tdm_helper_commit_per_vblank_enabled(tdm_display *dpy)
+{
+ tdm_private_display *private_display;
+
+ TDM_RETURN_VAL_IF_FAIL(dpy != NULL, 0);
+
+ private_display = dpy;
+
+ return private_display->commit_per_vblank;
+}
+