drv/virtgpu: add log level for logging

Harmless initialization logging should be info instead of error.

TEST=build and check logcat
BUG=b:234143058

Change-Id: I41ff39b428feb85d01663eec74b3f826007337c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3759415
Commit-Queue: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
This commit is contained in:
Yiwei Zhang 2022-07-13 00:25:11 +00:00 committed by Chromeos LUCI
parent 52be91e21b
commit 7b3cbeabbb
4 changed files with 47 additions and 10 deletions

29
drv.c
View file

@ -744,7 +744,8 @@ uint32_t drv_num_buffers_per_bo(struct bo *bo)
return count; return count;
} }
void drv_log_prefix(const char *prefix, const char *file, int line, const char *format, ...) void drv_log_prefix(enum drv_log_level level, const char *prefix, const char *file, int line,
const char *format, ...)
{ {
char buf[50]; char buf[50];
snprintf(buf, sizeof(buf), "[%s:%s(%d)]", prefix, basename(file), line); snprintf(buf, sizeof(buf), "[%s:%s(%d)]", prefix, basename(file), line);
@ -752,10 +753,30 @@ void drv_log_prefix(const char *prefix, const char *file, int line, const char *
va_list args; va_list args;
va_start(args, format); va_start(args, format);
#ifdef __ANDROID__ #ifdef __ANDROID__
__android_log_vprint(ANDROID_LOG_ERROR, buf, format, args); int prio = ANDROID_LOG_ERROR;
switch (level) {
case DRV_LOGV:
prio = ANDROID_LOG_VERBOSE;
break;
case DRV_LOGD:
prio = ANDROID_LOG_DEBUG;
break;
case DRV_LOGI:
prio = ANDROID_LOG_INFO;
break;
case DRV_LOGE:
default:
break;
};
__android_log_vprint(prio, buf, format, args);
#else #else
fprintf(stderr, "%s ", buf); if (level == DRV_LOGE) {
vfprintf(stderr, format, args); fprintf(stderr, "%s ", buf);
vfprintf(stderr, format, args);
} else {
fprintf(stdout, "%s ", buf);
vfprintf(stdout, format, args);
}
#endif #endif
va_end(args); va_end(args);
} }

22
drv.h
View file

@ -206,12 +206,28 @@ int drv_resource_info(struct bo *bo, uint32_t strides[DRV_MAX_PLANES],
uint32_t drv_get_max_texture_2d_size(struct driver *drv); uint32_t drv_get_max_texture_2d_size(struct driver *drv);
#define drv_log(format, ...) \ enum drv_log_level {
DRV_LOGV,
DRV_LOGD,
DRV_LOGI,
DRV_LOGE,
};
#define _drv_log(level, format, ...) \
do { \ do { \
drv_log_prefix("minigbm", __FILE__, __LINE__, format, ##__VA_ARGS__); \ drv_log_prefix(level, "minigbm", __FILE__, __LINE__, format, ##__VA_ARGS__); \
} while (0) } while (0)
__attribute__((format(printf, 4, 5))) void drv_log_prefix(const char *prefix, const char *file, #define drv_loge(format, ...) _drv_log(DRV_LOGE, format, ##__VA_ARGS__)
#define drv_logv(format, ...) _drv_log(DRV_LOGV, format, ##__VA_ARGS__)
#define drv_logd(format, ...) _drv_log(DRV_LOGD, format, ##__VA_ARGS__)
#define drv_logi(format, ...) _drv_log(DRV_LOGI, format, ##__VA_ARGS__)
/* for backward compability purpose */
#define drv_log(format, ...) _drv_log(DRV_LOGE, format, ##__VA_ARGS__)
__attribute__((format(printf, 5, 6))) void drv_log_prefix(enum drv_log_level level,
const char *prefix, const char *file,
int line, const char *format, ...); int line, const char *format, ...);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -48,7 +48,7 @@ static int virtgpu_init(struct driver *drv)
get_param.value = (uint64_t)(uintptr_t)&params[i].value; get_param.value = (uint64_t)(uintptr_t)&params[i].value;
int ret = drmIoctl(drv->fd, DRM_IOCTL_VIRTGPU_GETPARAM, &get_param); int ret = drmIoctl(drv->fd, DRM_IOCTL_VIRTGPU_GETPARAM, &get_param);
if (ret) if (ret)
drv_log("virtgpu backend not enabling %s\n", params[i].name); drv_logi("virtgpu backend not enabling %s\n", params[i].name);
} }
for (uint32_t i = 0; i < ARRAY_SIZE(virtgpu_backends); i++) { for (uint32_t i = 0; i < ARRAY_SIZE(virtgpu_backends); i++) {

View file

@ -351,13 +351,13 @@ static void virgl_add_combination(struct driver *drv, uint32_t drm_format,
if (params[param_3d].value) { if (params[param_3d].value) {
if ((use_flags & BO_USE_SCANOUT) && if ((use_flags & BO_USE_SCANOUT) &&
!virgl_supports_combination_natively(drv, drm_format, BO_USE_SCANOUT)) { !virgl_supports_combination_natively(drv, drm_format, BO_USE_SCANOUT)) {
drv_log("Strip scanout on format: %d\n", drm_format); drv_logi("Strip scanout on format: %d\n", drm_format);
use_flags &= ~BO_USE_SCANOUT; use_flags &= ~BO_USE_SCANOUT;
} }
if (!virgl_supports_combination_natively(drv, drm_format, use_flags) && if (!virgl_supports_combination_natively(drv, drm_format, use_flags) &&
!virgl_supports_combination_through_emulation(drv, drm_format, use_flags)) { !virgl_supports_combination_through_emulation(drv, drm_format, use_flags)) {
drv_log("Skipping unsupported combination format:%d\n", drm_format); drv_logi("Skipping unsupported combination format:%d\n", drm_format);
return; return;
} }
} }