[magma] Only log unimplemented once

Don't spam the log with unimplemented log messages. Instead log the
message when the function is first called and then don't log again.

Change-Id: I849063854690b8f97fc749db73681192f7721806
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/github.com/intel/media-driver/+/746643
Reviewed-by: Craig Stout <cstout@google.com>
diff --git a/media_driver/linux/common/os/magma/mos_bufmgr_stub.c b/media_driver/linux/common/os/magma/mos_bufmgr_stub.c
index a525fab..65aa610 100644
--- a/media_driver/linux/common/os/magma/mos_bufmgr_stub.c
+++ b/media_driver/linux/common/os/magma/mos_bufmgr_stub.c
@@ -27,52 +27,56 @@
 #include <assert.h>
 #include <stdio.h>
 
-#define LOG_VERBOSE(msg, ...) do { \
-    if (true) \
-        fprintf(stderr, "mos_bufmgr_stub:%d " msg "\n", __LINE__, ##__VA_ARGS__); \
-        fflush(stderr); \
-} while (0)
+#define NOT_IMPLEMENTED()                                                               \
+  do {                                                                                  \
+    static bool logged_already = false;                                                 \
+    if (!logged_already) {                                                              \
+      fprintf(stderr, "mos_bufmgr_stub:%d %s unimplemented\n", __LINE__, __FUNCTION__); \
+      fflush(stderr);                                                                   \
+      logged_already = true;                                                            \
+    }                                                                                   \
+  } while (0)
 
 void mos_bufmgr_gem_enable_reuse(struct mos_bufmgr *bufmgr)
 {
-    LOG_VERBOSE("mos_bufmgr_gem_enable_reuse unimplemented");
+    NOT_IMPLEMENTED();
 }
 
 struct mos_linux_bo * mos_bo_gem_create_from_name(struct mos_bufmgr *bufmgr,
                   const char *name,
                   unsigned int handle)
 {
-    LOG_VERBOSE("mos_bo_gem_create_from_name unimplemented");
+    NOT_IMPLEMENTED();
     return NULL;
 }
 
 
 int mos_gem_bo_map_gtt(struct mos_linux_bo *bo)
 {
-    LOG_VERBOSE("mos_gem_bo_map_gtt unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int mos_gem_bo_map_unsynchronized(struct mos_linux_bo *bo)
 {
-    LOG_VERBOSE("mos_gem_bo_map_unsynchronized unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 void mos_gem_bo_start_gtt_access(struct mos_linux_bo *bo, int write_enable)
 {
-    LOG_VERBOSE("mos_gem_bo_start_gtt_access unimplemented");
+    NOT_IMPLEMENTED();
 }
 
 int mos_gem_bo_unmap_gtt(struct mos_linux_bo *bo)
 {
-    LOG_VERBOSE("mos_gem_bo_unmap_gtt unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int mos_query_device_blob(int fd, MEDIA_SYSTEM_INFO* gfx_info)
 {
-    LOG_VERBOSE("mos_query_device_blob unimplemented");
+    NOT_IMPLEMENTED();
     return -1;
 }
 
@@ -81,7 +85,7 @@
                 uint64_t param,
                 uint64_t *value)
 {
-    LOG_VERBOSE("mos_get_context_param unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -90,7 +94,7 @@
                 uint64_t param,
                 uint64_t value)
 {
-    LOG_VERBOSE("mos_set_context_param unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -100,31 +104,31 @@
               uint32_t *active,
               uint32_t *pending)
 {
-    LOG_VERBOSE("mos_get_reset_stats unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int mos_get_context_param_sseu(struct mos_linux_context *ctx,
                 struct drm_i915_gem_context_param_sseu *sseu) {
-    LOG_VERBOSE("mos_get_context_param_sseu unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 unsigned int mos_hweight8(uint8_t w)
 {
-    LOG_VERBOSE("mos_hweight8 unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 uint8_t mos_switch_off_n_bits(uint8_t in_mask, int n)
 {
-    LOG_VERBOSE("mos_switch_off_n_bits unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int mos_set_context_param_sseu(struct mos_linux_context *ctx,
                 struct drm_i915_gem_context_param_sseu sseu) {
-    LOG_VERBOSE("mos_set_context_param_sseu unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -133,7 +137,7 @@
                         struct i915_engine_class_instance *bond_ci,
                         unsigned int bond_count)
 {
-    LOG_VERBOSE("mos_set_context_param_bond unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -141,13 +145,13 @@
                      struct i915_engine_class_instance *ci,
                      unsigned int count)
 {
-    LOG_VERBOSE("mos_set_context_param_parallel unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 bool mos_gem_bo_is_exec_object_async(struct mos_linux_bo *bo)
 {
-    LOG_VERBOSE("mos_gem_bo_is_exec_object_async unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -155,7 +159,7 @@
                                struct drm_clip_rect *cliprects, int num_cliprects, int DR4,
                                unsigned int flags, int *fence)
 {
-    LOG_VERBOSE("mos_gem_bo_context_exec3 unimplemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -164,13 +168,13 @@
 int bufmgr_bo_get_subdata(struct mos_linux_bo *bo, unsigned long offset,
                  unsigned long size, void *data)
 {
-    LOG_VERBOSE("bufmgr_bo_get_subdata not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_bo_pad_to_size(struct mos_linux_bo *bo, uint64_t pad_to_size)
 {
-    LOG_VERBOSE("bufmgr_bo_pad_to_size not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -178,7 +182,7 @@
                 struct mos_linux_bo *target_bo, uint32_t target_offset,
                 uint32_t read_domains, uint32_t write_domain)
 {
-    LOG_VERBOSE("bufmgr_bo_emit_reloc not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -187,7 +191,7 @@
                 uint32_t read_domains, uint32_t write_domain,
                 uint64_t presumed_offset)
 {
-    LOG_VERBOSE("bufmgr_bo_emit_reloc2 not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -196,39 +200,39 @@
                   uint32_t target_offset,
                   uint32_t read_domains, uint32_t write_domain)
 {
-    LOG_VERBOSE("bufmgr_bo_emit_reloc_fence not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_bo_pin(struct mos_linux_bo *bo, uint32_t alignment)
 {
-    LOG_VERBOSE("bufmgr_bo_pin not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_bo_unpin(struct mos_linux_bo *bo)
 {
-    LOG_VERBOSE("bufmgr_bo_unpin not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_bo_get_tiling(struct mos_linux_bo *bo, uint32_t * tiling_mode,
                 uint32_t * swizzle_mode)
 {
-    LOG_VERBOSE("bufmgr_bo_get_tiling not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_bo_set_tiling(struct mos_linux_bo *bo, uint32_t * tiling_mode,
                 uint32_t stride)
 {
-    LOG_VERBOSE("bufmgr_bo_set_tiling not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_bo_flink(struct mos_linux_bo *bo, uint32_t * name)
 {
-    LOG_VERBOSE("bufmgr_bo_flink not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -236,7 +240,7 @@
                drm_clip_rect_t *cliprects, int num_cliprects,
                int DR4)
 {
-    LOG_VERBOSE("bufmgr_bo_exec2 not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
@@ -244,42 +248,42 @@
             drm_clip_rect_t *cliprects, int num_cliprects, int DR4,
             unsigned int flags)
 {
-    LOG_VERBOSE("bufmgr_bo_mrb_exec2 not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_bo_madvise(struct mos_linux_bo *bo, int madv)
 {
-    LOG_VERBOSE("bufmgr_bo_madvise not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_check_aperture_space(struct mos_linux_bo **bo_array, int count)
 {
-    LOG_VERBOSE("bufmgr_check_aperture_space not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_bo_disable_reuse(struct mos_linux_bo *bo)
 {
-    LOG_VERBOSE("bufmgr_bo_disable_reuse not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_bo_is_reusable(struct mos_linux_bo *bo)
 {
-    LOG_VERBOSE("bufmgr_bo_is_reusable not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_get_pipe_from_crtc_id(struct mos_bufmgr *bufmgr, int crtc_id)
 {
-    LOG_VERBOSE("bufmgr_get_pipe_from_crtc_id not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }
 
 int bufmgr_bo_references(struct mos_linux_bo *bo, struct mos_linux_bo *target_bo)
 {
-    LOG_VERBOSE("bufmgr_bo_references not implemented");
+    NOT_IMPLEMENTED();
     return 0;
 }