Skip to content

Commit

Permalink
Add print level INFO
Browse files Browse the repository at this point in the history
Instead of printing all logs with ERROR level, some logs just
need INFO level.

Tracked-On: OAM-112267
Signed-off-by: chenyanxzhu <chenyanx.zhu@intel.com>
  • Loading branch information
chenyanxzhu committed Sep 25, 2023
1 parent 6b8fc98 commit ae5c01d
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 28 deletions.
4 changes: 2 additions & 2 deletions cros_gralloc/cros_gralloc_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int32_t cros_gralloc_sync_wait(int32_t fence, bool close_fence)
*/
int err = sync_wait(fence, 1000);
if (err < 0) {
drv_log("Timed out on sync wait, err = %s\n", strerror(errno));
drv_info("Timed out on sync wait, err = %s\n", strerror(errno));
err = sync_wait(fence, -1);
if (err < 0) {
drv_log("sync wait error = %s\n", strerror(errno));
Expand Down Expand Up @@ -148,7 +148,7 @@ int32_t cros_gralloc_sync_wait(int32_t acquire_fence)
*/
int err = sync_wait(acquire_fence, 1000);
if (err < 0) {
drv_log("Timed out on sync wait, err = %s", strerror(errno));
drv_info("Timed out on sync wait, err = %s", strerror(errno));
err = sync_wait(acquire_fence, -1);
if (err < 0) {
drv_log("sync wait error = %s", strerror(errno));
Expand Down
36 changes: 21 additions & 15 deletions cros_gralloc/gralloc1/cros_gralloc1_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ gralloc1_function_pointer_t CrosGralloc1::doGetFunction(int32_t intDescriptor)

void CrosGralloc1::dump(uint32_t *outSize, char *outBuffer)
{
drv_log("dump(%u (%p), %p", outSize ? *outSize : 0, outSize, outBuffer);
drv_info("dump(%u (%p), %p", outSize ? *outSize : 0, outSize, outBuffer);
}

int32_t CrosGralloc1::createDescriptor(gralloc1_buffer_descriptor_t *outDescriptor)
Expand Down Expand Up @@ -466,18 +466,21 @@ int32_t CrosGralloc1::lock(buffer_handle_t bufferHandle, gralloc1_producer_usage
map_flags = cros_gralloc1_convert_map_usage(producerUsage, consumerUsage);

if (driver->lock(bufferHandle, acquireFence, map_flags, addr)) {
drv_log("Plz switch to mapper 4.0 or call importBuffer & freeBuffer with mapper 2.0 before lock");
buffer_handle_t buffer_handle = native_handle_clone(bufferHandle);
auto error = retain(buffer_handle);
if (error != GRALLOC1_ERROR_NONE) {
delete buffer_handle;
return error;
}
bufferHandle = buffer_handle;
if (driver->lock(bufferHandle, acquireFence, map_flags, addr))
return CROS_GRALLOC_ERROR_BAD_HANDLE;
delete buffer_handle;
}
drv_info("Plz switch to mapper 4.0 or call importBuffer & freeBuffer with mapper 2.0 before lock");
buffer_handle_t buffer_handle = native_handle_clone(bufferHandle);
auto error = retain(buffer_handle);
if (error != GRALLOC1_ERROR_NONE) {
drv_log("Retain failed");
delete buffer_handle;
return error;
}
bufferHandle = buffer_handle;
if (driver->lock(bufferHandle, acquireFence, map_flags, addr)) {
drv_log("lock failed");
return CROS_GRALLOC_ERROR_BAD_HANDLE;
}
delete buffer_handle;
}

*outData = addr[0];

Expand Down Expand Up @@ -567,16 +570,19 @@ int32_t CrosGralloc1::lockYCbCr(buffer_handle_t bufferHandle,
map_flags = cros_gralloc1_convert_map_usage(producerUsage, consumerUsage);

if (driver->lock(bufferHandle, acquireFence, map_flags, addr)) {
drv_log("Plz switch to mapper 4.0 or call importBuffer & freeBuffer with mapper 2.0 before lockFlex");
drv_info("Plz switch to mapper 4.0 or call importBuffer & freeBuffer with mapper 2.0 before lockFlex");
buffer_handle_t buffer_handle = native_handle_clone(bufferHandle);
auto error = retain(buffer_handle);
if (error != GRALLOC1_ERROR_NONE) {
drv_log("Retain failed");
delete buffer_handle;
return error;
}
bufferHandle = buffer_handle;
if (driver->lock(bufferHandle, acquireFence, map_flags, addr))
if (driver->lock(bufferHandle, acquireFence, map_flags, addr)) {
drv_log("lock failed");
return CROS_GRALLOC_ERROR_BAD_HANDLE;
}
driver->release(buffer_handle);
delete buffer_handle;
}
Expand Down
2 changes: 2 additions & 0 deletions cros_gralloc/gralloc4/CrosGralloc4Allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Error CrosGralloc4Allocator::allocate(const BufferDescriptorInfo& descriptor, ui
}

if (!outStride || !outHandle) {
drv_log("Invalid params.\n");
return Error::NO_RESOURCES;
}

Expand All @@ -63,6 +64,7 @@ Error CrosGralloc4Allocator::allocate(const BufferDescriptorInfo& descriptor, ui

cros_gralloc_handle_t crosHandle = cros_gralloc_convert_handle(handle);
if (!crosHandle) {
drv_log("Invalid handle");
return Error::NO_RESOURCES;
}

Expand Down
1 change: 0 additions & 1 deletion cros_gralloc/gralloc4/CrosGralloc4Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ int convertToCrosDescriptor(const BufferDescriptorInfo& descriptor,

if (convertToDrmFormat(descriptor.format, &outCrosDescriptor->drm_format)) {
#ifdef USE_GRALLOC1
drv_log("Failed to convert descriptor by convertToDrmFormat");
if (!IsSupportedYUVFormat(static_cast<uint32_t>(descriptor.format))) {
std::string pixelFormatString = getPixelFormatString(descriptor.format);
drv_log("Failed to convert descriptor. Unsupported fomat %s\n", pixelFormatString.c_str());
Expand Down
2 changes: 1 addition & 1 deletion cros_gralloc/i915_private_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int32_t i915_private_invert_format(int format)
case DRM_FORMAT_YUV422:
return HAL_PIXEL_FORMAT_YCbCr_422_888;
default:
drv_log("Unhandled DRM format %4.4s", drmFormat2Str(format));
drv_info("Unhandled DRM format %4.4s", drmFormat2Str(format));
}

return 0;
Expand Down
5 changes: 2 additions & 3 deletions drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <xf86drm.h>

#ifdef __ANDROID__
#include <cutils/log.h>
#include <libgen.h>
#endif

Expand Down Expand Up @@ -711,15 +710,15 @@ uint32_t drv_num_buffers_per_bo(struct bo *bo)
return count;
}

void drv_log_prefix(const char *prefix, const char *file, int line, const char *format, ...)
void drv_log_prefix(const char *prefix, const char *file, int line, android_LogPriority level, const char *format, ...)
{
char buf[50];
snprintf(buf, sizeof(buf), "[%s:%s(%d)]", prefix, basename(file), line);

va_list args;
va_start(args, format);
#ifdef __ANDROID__
__android_log_vprint(ANDROID_LOG_ERROR, buf, format, args);
__android_log_vprint(level, buf, format, args);
#else
fprintf(stderr, "%s ", buf);
vfprintf(stderr, format, args);
Expand Down
15 changes: 12 additions & 3 deletions drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>

#ifdef __ANDROID__
#include <cutils/log.h>
#endif

#define DRV_MAX_PLANES 4

// clang-format off
Expand Down Expand Up @@ -192,11 +196,16 @@ uint32_t drv_bo_get_stride_or_tiling(struct bo *bo);

#define drv_log(format, ...) \
do { \
drv_log_prefix("minigbm", __FILE__, __LINE__, format, ##__VA_ARGS__); \
drv_log_prefix("minigbm", __FILE__, __LINE__, ANDROID_LOG_ERROR, format, ##__VA_ARGS__); \
} while (0)

#define drv_info(format, ...) \
do { \
drv_log_prefix("minigbm", __FILE__, __LINE__, ANDROID_LOG_INFO, format, ##__VA_ARGS__); \
} while (0)

__attribute__((format(printf, 4, 5))) void drv_log_prefix(const char *prefix, const char *file,
int line, const char *format, ...);
__attribute__((format(printf, 5, 6))) void drv_log_prefix(const char *prefix, const char *file,
int line, android_LogPriority level, const char *format, ...);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion i915.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ static int i915_bo_invalidate(struct bo *bo, struct mapping *mapping)

ret = drmIoctl(bo->drv->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain);
if (ret) {
drv_log("DRM_IOCTL_I915_GEM_SET_DOMAIN with %d\n", ret);
drv_info("DRM_IOCTL_I915_GEM_SET_DOMAIN with %d\n", ret);
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions virtio_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ static void virtio_gpu_add_combination(struct driver *drv, uint32_t drm_format,
if (features[feat_3d].enabled && priv->caps.max_version >= 1) {
if ((use_flags & BO_USE_SCANOUT) && priv->caps_is_v2 &&
!virtio_gpu_supports_combination_natively(drv, drm_format, use_flags)) {
drv_log("Scanout format: %d\n", drm_format);
drv_info("Scanout format: %d\n", drm_format);
use_flags &= ~BO_USE_SCANOUT;
}

Expand Down Expand Up @@ -430,7 +430,7 @@ static uint32_t use_flags_to_bind(uint64_t use_flags)
handle_flag(&use_flags, BO_USE_CAMERA_WRITE, &bind, VIRGL_BIND_LINEAR);

if (use_flags) {
drv_log("Unhandled bo use flag: %llx\n", (unsigned long long)use_flags);
drv_info("Unhandled bo use flag: %llx\n", (unsigned long long)use_flags);
}

return bind;
Expand Down

0 comments on commit ae5c01d

Please sign in to comment.