minigbm: move camera work-around
Move mt8183_camera_quirk_ into struct cross_domain_private. Add a helper `drv_get_os_option` in `drv_helper` to query os option. Advertise DRM_FORMAT_MTISP_SXYZW10 as supported format in virtgpu_cross_domain.c. Implement cross domain's own resolve_format_and_use_flags entry point. BUG=b:269982880 TEST=tested on a kukui machine after applying the change. Camera and screen recording works fine. Change-Id: Ia0d6e2cc701477aa6b9542de84e24f8aeb5a29e0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4304961 Commit-Queue: Dawn Han <dawnhan@google.com> Reviewed-by: Dominik Behr <dbehr@chromium.org> Tested-by: Dawn Han <dawnhan@google.com>
This commit is contained in:
parent
b56c26b51c
commit
3940cbd883
6 changed files with 63 additions and 15 deletions
|
|
@ -155,9 +155,6 @@ static void drv_destroy_and_close(struct driver *drv)
|
|||
|
||||
cros_gralloc_driver::cros_gralloc_driver() : drv_(init_try_nodes(), drv_destroy_and_close)
|
||||
{
|
||||
char buf[PROP_VALUE_MAX];
|
||||
property_get("ro.product.device", buf, "unknown");
|
||||
mt8183_camera_quirk_ = !strncmp(buf, "kukui", strlen("kukui"));
|
||||
}
|
||||
|
||||
cros_gralloc_driver::~cros_gralloc_driver()
|
||||
|
|
@ -179,14 +176,6 @@ bool cros_gralloc_driver::get_resolved_format_and_use_flags(
|
|||
uint64_t resolved_use_flags;
|
||||
struct combination *combo;
|
||||
|
||||
if (mt8183_camera_quirk_ && (descriptor->use_flags & BO_USE_CAMERA_READ) &&
|
||||
!(descriptor->use_flags & BO_USE_SCANOUT) &&
|
||||
descriptor->drm_format == DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED) {
|
||||
*out_use_flags = descriptor->use_flags;
|
||||
*out_format = DRM_FORMAT_MTISP_SXYZW10;
|
||||
return true;
|
||||
}
|
||||
|
||||
drv_resolve_format_and_use_flags(drv_.get(), descriptor->drm_format, descriptor->use_flags,
|
||||
&resolved_format, &resolved_use_flags);
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ class cros_gralloc_driver
|
|||
std::mutex mutex_;
|
||||
std::unordered_map<uint32_t, std::unique_ptr<cros_gralloc_buffer>> buffers_;
|
||||
std::unordered_map<cros_gralloc_handle_t, cros_gralloc_imported_handle_info> handles_;
|
||||
bool mt8183_camera_quirk_ = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
4
drv.c
4
drv.c
|
|
@ -113,8 +113,8 @@ struct driver *drv_create(int fd)
|
|||
if (!drv)
|
||||
return NULL;
|
||||
|
||||
char *minigbm_debug;
|
||||
minigbm_debug = getenv("MINIGBM_DEBUG");
|
||||
const char *minigbm_debug;
|
||||
minigbm_debug = drv_get_os_option("MINIGBM_DEBUG");
|
||||
drv->compression = (minigbm_debug == NULL) || (strcmp(minigbm_debug, "nocompression") != 0);
|
||||
|
||||
drv->fd = fd;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@
|
|||
#include <unistd.h>
|
||||
#include <xf86drm.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <cutils/properties.h>
|
||||
#endif
|
||||
|
||||
#include "drv_priv.h"
|
||||
#include "util.h"
|
||||
|
||||
|
|
@ -611,3 +615,13 @@ void drv_resolve_format_and_use_flags_helper(struct driver *drv, uint32_t format
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const char *drv_get_os_option(const char *name)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
static char prop[PROPERTY_VALUE_MAX];
|
||||
return property_get(name, prop, NULL) > 1 ? prop : NULL;
|
||||
#else
|
||||
return getenv(name);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,4 +51,9 @@ void drv_resolve_format_and_use_flags_helper(struct driver *drv, uint32_t format
|
|||
uint64_t use_flags, uint32_t *out_format,
|
||||
uint64_t *out_use_flags);
|
||||
|
||||
/*
|
||||
* Get an option. Should return NULL if specified option is not set.
|
||||
*/
|
||||
const char *drv_get_os_option(const char *name);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ struct cross_domain_private {
|
|||
void *ring_addr;
|
||||
struct drv_array *metadata_cache;
|
||||
pthread_mutex_t metadata_cache_lock;
|
||||
bool mt8183_camera_quirk_;
|
||||
};
|
||||
|
||||
static void cross_domain_release_private(struct driver *drv)
|
||||
|
|
@ -344,6 +345,10 @@ static int cross_domain_init(struct driver *drv)
|
|||
if (ret < 0)
|
||||
goto free_private;
|
||||
|
||||
const char *name;
|
||||
name = drv_get_os_option("RO_PRODUCT_DEVICE");
|
||||
priv->mt8183_camera_quirk_ = name && !strcmp(name, "kukui");
|
||||
|
||||
// minigbm bookkeeping
|
||||
add_combinations(drv);
|
||||
return 0;
|
||||
|
|
@ -426,6 +431,42 @@ static void *cross_domain_bo_map(struct bo *bo, struct vma *vma, uint32_t map_fl
|
|||
gem_map.offset);
|
||||
}
|
||||
|
||||
static void cross_domain_resolve_format_and_use_flags(struct driver *drv, uint32_t format,
|
||||
uint64_t use_flags, uint32_t *out_format,
|
||||
uint64_t *out_use_flags)
|
||||
{
|
||||
struct cross_domain_private *priv = drv->priv;
|
||||
*out_format = format;
|
||||
*out_use_flags = use_flags;
|
||||
|
||||
switch (format) {
|
||||
case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED:
|
||||
if (priv->mt8183_camera_quirk_ && (use_flags & BO_USE_CAMERA_READ) &&
|
||||
!(use_flags & BO_USE_SCANOUT)) {
|
||||
*out_format = DRM_FORMAT_MTISP_SXYZW10;
|
||||
break;
|
||||
}
|
||||
/* Common camera implementation defined format. */
|
||||
if (use_flags & (BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE)) {
|
||||
*out_format = DRM_FORMAT_NV12;
|
||||
} else {
|
||||
/* HACK: See b/28671744 */
|
||||
*out_format = DRM_FORMAT_XBGR8888;
|
||||
*out_use_flags &= ~BO_USE_HW_VIDEO_ENCODER;
|
||||
}
|
||||
break;
|
||||
case DRM_FORMAT_FLEX_YCbCr_420_888:
|
||||
/* Common flexible video format. */
|
||||
*out_format = DRM_FORMAT_NV12;
|
||||
break;
|
||||
case DRM_FORMAT_YVU420_ANDROID:
|
||||
*out_use_flags &= ~BO_USE_SCANOUT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const struct backend virtgpu_cross_domain = {
|
||||
.name = "virtgpu_cross_domain",
|
||||
.init = cross_domain_init,
|
||||
|
|
@ -435,5 +476,5 @@ const struct backend virtgpu_cross_domain = {
|
|||
.bo_destroy = drv_gem_bo_destroy,
|
||||
.bo_map = cross_domain_bo_map,
|
||||
.bo_unmap = drv_bo_munmap,
|
||||
.resolve_format_and_use_flags = drv_resolve_format_and_use_flags_helper,
|
||||
.resolve_format_and_use_flags = cross_domain_resolve_format_and_use_flags,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue