diff --git a/src/surface.c b/src/surface.c index b8ec932..a141762 100644 --- a/src/surface.c +++ b/src/surface.c @@ -67,17 +67,23 @@ VAStatus RequestCreateSurfaces2(VADriverContextP context, unsigned int format, VASurfaceID id; int rc; - if (format != VA_RT_FORMAT_YUV420) - return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; + request_log("CreateSurfaces2: format=0x%x %dx%d count=%d\n", + format, width, height, surfaces_count); + if (format != VA_RT_FORMAT_YUV420) { + request_log("CreateSurfaces2: rejecting RT_FORMAT 0x%x\n", format); + return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; + } if (!driver_data->video_format) { /* Could happen if RequestInit's eager probe came back NULL — * try one more time here in case the device only became * format-enumerable after streaming setup. */ driver_data->video_format = video_format_probe(driver_data->video_fd); - if (driver_data->video_format == NULL) + if (driver_data->video_format == NULL) { + request_log("CreateSurfaces2: video_format probe still NULL\n"); return VA_STATUS_ERROR_OPERATION_FAILED; + } } video_format = driver_data->video_format; @@ -87,21 +93,32 @@ VAStatus RequestCreateSurfaces2(VADriverContextP context, unsigned int format, * pinned to the picture dimensions the caller passed in. */ rc = v4l2_set_format(driver_data->video_fd, capture_type, video_format->v4l2_format, width, height); - if (rc < 0) + if (rc < 0) { + request_log("CreateSurfaces2: S_FMT(CAPTURE) failed for fmt=0x%x %dx%d\n", + video_format->v4l2_format, width, height); return VA_STATUS_ERROR_OPERATION_FAILED; + } rc = v4l2_get_format(driver_data->video_fd, capture_type, &format_width, &format_height, destination_bytesperlines, destination_sizes, NULL); - if (rc < 0) + if (rc < 0) { + request_log("CreateSurfaces2: G_FMT(CAPTURE) failed\n"); return VA_STATUS_ERROR_OPERATION_FAILED; + } + request_log("CreateSurfaces2: G_FMT got %dx%d bpl[0]=%d size[0]=%d\n", + format_width, format_height, + destination_bytesperlines[0], destination_sizes[0]); destination_planes_count = video_format->planes_count; rc = v4l2_create_buffers(driver_data->video_fd, capture_type, surfaces_count, &index_base); - if (rc < 0) + if (rc < 0) { + request_log("CreateSurfaces2: CREATE_BUFS(CAPTURE) failed\n"); return VA_STATUS_ERROR_ALLOCATION_FAILED; + } + request_log("CreateSurfaces2: CREATE_BUFS ok index_base=%u\n", index_base); for (i = 0; i < surfaces_count; i++) { index = index_base + i; @@ -116,8 +133,10 @@ VAStatus RequestCreateSurfaces2(VADriverContextP context, unsigned int format, surface_object->destination_map_lengths, surface_object->destination_map_offsets, video_format->v4l2_buffers_count); - if (rc < 0) + if (rc < 0) { + request_log("CreateSurfaces2: QUERYBUF idx=%u failed\n", index); return VA_STATUS_ERROR_ALLOCATION_FAILED; + } for (j = 0; j < video_format->v4l2_buffers_count; j++) { surface_object->destination_map[j] = @@ -127,8 +146,13 @@ VAStatus RequestCreateSurfaces2(VADriverContextP context, unsigned int format, driver_data->video_fd, surface_object->destination_map_offsets[j]); - if (surface_object->destination_map[j] == MAP_FAILED) + if (surface_object->destination_map[j] == MAP_FAILED) { + request_log("CreateSurfaces2: mmap idx=%u plane=%u len=%u offset=%u failed\n", + index, j, + surface_object->destination_map_lengths[j], + surface_object->destination_map_offsets[j]); return VA_STATUS_ERROR_ALLOCATION_FAILED; + } } /* @@ -166,6 +190,9 @@ VAStatus RequestCreateSurfaces2(VADriverContextP context, unsigned int format, destination_bytesperlines[j]; } } else { + request_log("CreateSurfaces2: buffers_count=%u planes_count=%u mismatch\n", + video_format->v4l2_buffers_count, + destination_planes_count); return VA_STATUS_ERROR_ALLOCATION_FAILED; } @@ -458,16 +485,26 @@ VAStatus RequestExportSurfaceHandle(VADriverContextP context, VAStatus status; int rc; - video_format = driver_data->video_format; - if (video_format == NULL) - return VA_STATUS_ERROR_OPERATION_FAILED; + request_log("ExportSurfaceHandle: surface_id=%u mem_type=0x%x flags=0x%x\n", + surface_id, mem_type, flags); - if (mem_type != VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2) + video_format = driver_data->video_format; + if (video_format == NULL) { + request_log("ExportSurfaceHandle: video_format NULL\n"); + return VA_STATUS_ERROR_OPERATION_FAILED; + } + + if (mem_type != VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2) { + request_log("ExportSurfaceHandle: rejecting mem_type 0x%x (only DRM_PRIME_2)\n", + mem_type); return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE; + } surface_object = SURFACE(driver_data, surface_id); - if (surface_object == NULL) + if (surface_object == NULL) { + request_log("ExportSurfaceHandle: invalid surface_id\n"); return VA_STATUS_ERROR_INVALID_SURFACE; + } export_fds_count = surface_object->destination_buffers_count; export_fds = malloc(export_fds_count * sizeof(*export_fds)); @@ -478,6 +515,8 @@ VAStatus RequestExportSurfaceHandle(VADriverContextP context, surface_object->destination_index, O_RDONLY, export_fds, export_fds_count); if (rc < 0) { + request_log("ExportSurfaceHandle: EXPBUF idx=%u count=%u failed\n", + surface_object->destination_index, export_fds_count); status = VA_STATUS_ERROR_OPERATION_FAILED; goto error; }