minigbm: refactor driver helpers
1. frontends access the driver via drv.h only 2. the renamed drv_helpers and drv_array_helpers are for driver only 3. remove extern "C" from drv_helpers.h given not exposed to gralloc 4. remove all redundant includes for those helpers BUG=b:199524294 TEST=CQ and gralloc builds on aosp Change-Id: I3f4d33076a6a8161804f1b7c26950ff5496507e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3195651 Tested-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Chia-I Wu <olv@google.com> Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
This commit is contained in:
parent
1905be4ad5
commit
b7a64441ef
22 changed files with 39 additions and 42 deletions
|
|
@ -11,10 +11,10 @@ MINIGBM_SRC := \
|
||||||
amdgpu.c \
|
amdgpu.c \
|
||||||
dri.c \
|
dri.c \
|
||||||
drv.c \
|
drv.c \
|
||||||
|
drv_array_helpers.c \
|
||||||
|
drv_helpers.c \
|
||||||
dumb_driver.c \
|
dumb_driver.c \
|
||||||
exynos.c \
|
exynos.c \
|
||||||
helpers_array.c \
|
|
||||||
helpers.c \
|
|
||||||
i915.c \
|
i915.c \
|
||||||
mediatek.c \
|
mediatek.c \
|
||||||
meson.c \
|
meson.c \
|
||||||
|
|
|
||||||
2
amdgpu.c
2
amdgpu.c
|
|
@ -19,8 +19,8 @@
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
|
|
||||||
#include "dri.h"
|
#include "dri.h"
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
#ifndef CROS_GRALLOC_BUFFER_H
|
#ifndef CROS_GRALLOC_BUFFER_H
|
||||||
#define CROS_GRALLOC_BUFFER_H
|
#define CROS_GRALLOC_BUFFER_H
|
||||||
|
|
||||||
#include "../drv.h"
|
|
||||||
#include "cros_gralloc_helpers.h"
|
#include "cros_gralloc_helpers.h"
|
||||||
|
|
||||||
class cros_gralloc_buffer
|
class cros_gralloc_buffer
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
#include "../drv_priv.h"
|
|
||||||
#include "../helpers.h"
|
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
|
||||||
// Constants taken from pipe_loader_drm.c in Mesa
|
// Constants taken from pipe_loader_drm.c in Mesa
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../helpers.h"
|
|
||||||
#include "../../util.h"
|
#include "../../util.h"
|
||||||
#include "../cros_gralloc_driver.h"
|
#include "../cros_gralloc_driver.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@
|
||||||
#include "cros_gralloc/cros_gralloc_helpers.h"
|
#include "cros_gralloc/cros_gralloc_helpers.h"
|
||||||
#include "cros_gralloc/gralloc4/CrosGralloc4Utils.h"
|
#include "cros_gralloc/gralloc4/CrosGralloc4Utils.h"
|
||||||
|
|
||||||
#include "helpers.h"
|
|
||||||
|
|
||||||
using aidl::android::hardware::graphics::common::BlendMode;
|
using aidl::android::hardware::graphics::common::BlendMode;
|
||||||
using aidl::android::hardware::graphics::common::Dataspace;
|
using aidl::android::hardware::graphics::common::Dataspace;
|
||||||
using aidl::android::hardware::graphics::common::PlaneLayout;
|
using aidl::android::hardware::graphics::common::PlaneLayout;
|
||||||
|
|
|
||||||
2
dri.c
2
dri.c
|
|
@ -18,8 +18,8 @@
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
#include "dri.h"
|
#include "dri.h"
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
|
|
|
||||||
11
drv.c
11
drv.c
|
|
@ -9,7 +9,6 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
@ -21,8 +20,8 @@
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#ifdef DRV_AMDGPU
|
#ifdef DRV_AMDGPU
|
||||||
|
|
@ -703,6 +702,14 @@ size_t drv_bo_get_total_size(struct bo *bo)
|
||||||
return bo->meta.total_size;
|
return bo->meta.total_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Map internal fourcc codes back to standard fourcc codes.
|
||||||
|
*/
|
||||||
|
uint32_t drv_get_standard_fourcc(uint32_t fourcc_internal)
|
||||||
|
{
|
||||||
|
return (fourcc_internal == DRM_FORMAT_YVU420_ANDROID) ? DRM_FORMAT_YVU420 : fourcc_internal;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t drv_resolve_format(struct driver *drv, uint32_t format, uint64_t use_flags)
|
uint32_t drv_resolve_format(struct driver *drv, uint32_t format, uint64_t use_flags)
|
||||||
{
|
{
|
||||||
if (drv->backend->resolve_format)
|
if (drv->backend->resolve_format)
|
||||||
|
|
|
||||||
3
drv.h
3
drv.h
|
|
@ -14,6 +14,7 @@ extern "C" {
|
||||||
#include <drm_fourcc.h>
|
#include <drm_fourcc.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define DRV_MAX_PLANES 4
|
#define DRV_MAX_PLANES 4
|
||||||
|
|
||||||
|
|
@ -178,6 +179,8 @@ uint64_t drv_bo_get_use_flags(struct bo *bo);
|
||||||
|
|
||||||
size_t drv_bo_get_total_size(struct bo *bo);
|
size_t drv_bo_get_total_size(struct bo *bo);
|
||||||
|
|
||||||
|
uint32_t drv_get_standard_fourcc(uint32_t fourcc_internal);
|
||||||
|
|
||||||
uint32_t drv_bytes_per_pixel_from_format(uint32_t format, size_t plane);
|
uint32_t drv_bytes_per_pixel_from_format(uint32_t format, size_t plane);
|
||||||
|
|
||||||
uint32_t drv_stride_from_format(uint32_t format, uint32_t width, size_t plane);
|
uint32_t drv_stride_from_format(uint32_t format, uint32_t width, size_t plane);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
#include "drv_array_helpers.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
@ -4,6 +4,11 @@
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef DRV_ARRAY_HELPERS_H
|
||||||
|
#define DRV_ARRAY_HELPERS_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
struct drv_array;
|
struct drv_array;
|
||||||
|
|
||||||
struct drv_array *drv_array_init(uint32_t item_size);
|
struct drv_array *drv_array_init(uint32_t item_size);
|
||||||
|
|
@ -20,3 +25,5 @@ uint32_t drv_array_size(struct drv_array *array);
|
||||||
|
|
||||||
/* The array and all associated data will be freed. */
|
/* The array and all associated data will be freed. */
|
||||||
void drv_array_destroy(struct drv_array *array);
|
void drv_array_destroy(struct drv_array *array);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "drv_helpers.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -15,7 +17,6 @@
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct planar_layout {
|
struct planar_layout {
|
||||||
|
|
@ -572,14 +573,6 @@ bool drv_has_modifier(const uint64_t *list, uint32_t count, uint64_t modifier)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Map internal fourcc codes back to standard fourcc codes.
|
|
||||||
*/
|
|
||||||
uint32_t drv_get_standard_fourcc(uint32_t fourcc_internal)
|
|
||||||
{
|
|
||||||
return (fourcc_internal == DRM_FORMAT_YVU420_ANDROID) ? DRM_FORMAT_YVU420 : fourcc_internal;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t drv_resolve_format_helper(uint32_t format, uint64_t use_flags)
|
uint32_t drv_resolve_format_helper(uint32_t format, uint64_t use_flags)
|
||||||
{
|
{
|
||||||
switch (format) {
|
switch (format) {
|
||||||
|
|
@ -4,22 +4,20 @@
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HELPERS_H
|
#ifndef DRV_HELPERS_H
|
||||||
#define HELPERS_H
|
#define DRV_HELPERS_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "drv.h"
|
#include "drv.h"
|
||||||
#include "helpers_array.h"
|
#include "drv_array_helpers.h"
|
||||||
|
|
||||||
#ifndef PAGE_SIZE
|
#ifndef PAGE_SIZE
|
||||||
#define PAGE_SIZE 0x1000
|
#define PAGE_SIZE 0x1000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct format_metadata;
|
||||||
|
|
||||||
uint32_t drv_height_from_format(uint32_t format, uint32_t height, size_t plane);
|
uint32_t drv_height_from_format(uint32_t format, uint32_t height, size_t plane);
|
||||||
uint32_t drv_vertical_subsampling_from_format(uint32_t format, size_t plane);
|
uint32_t drv_vertical_subsampling_from_format(uint32_t format, size_t plane);
|
||||||
uint32_t drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height, size_t plane);
|
uint32_t drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height, size_t plane);
|
||||||
|
|
@ -46,12 +44,7 @@ int drv_modify_linear_combinations(struct driver *drv);
|
||||||
uint64_t drv_pick_modifier(const uint64_t *modifiers, uint32_t count,
|
uint64_t drv_pick_modifier(const uint64_t *modifiers, uint32_t count,
|
||||||
const uint64_t *modifier_order, uint32_t order_count);
|
const uint64_t *modifier_order, uint32_t order_count);
|
||||||
bool drv_has_modifier(const uint64_t *list, uint32_t count, uint64_t modifier);
|
bool drv_has_modifier(const uint64_t *list, uint32_t count, uint64_t modifier);
|
||||||
uint32_t drv_get_standard_fourcc(uint32_t fourcc_internal);
|
|
||||||
uint32_t drv_resolve_format_helper(uint32_t format, uint64_t use_flags);
|
uint32_t drv_resolve_format_helper(uint32_t format, uint64_t use_flags);
|
||||||
uint64_t drv_resolve_use_flags_helper(struct driver *drv, uint32_t format, uint64_t use_flags);
|
uint64_t drv_resolve_use_flags_helper(struct driver *drv, uint32_t format, uint64_t use_flags);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define INIT_DUMB_DRIVER(driver) \
|
#define INIT_DUMB_DRIVER(driver) \
|
||||||
|
|
|
||||||
2
i915.c
2
i915.c
|
|
@ -15,9 +15,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "external/i915_drm.h"
|
#include "external/i915_drm.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define I915_CACHELINE_SIZE 64
|
#define I915_CACHELINE_SIZE 64
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
#include <mediatek_drm.h>
|
#include <mediatek_drm.h>
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define TILE_TYPE_LINEAR 0
|
#define TILE_TYPE_LINEAR 0
|
||||||
|
|
|
||||||
2
msm.c
2
msm.c
|
|
@ -18,8 +18,8 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
/* Alignment values are based on SDM845 Gfx IP */
|
/* Alignment values are based on SDM845 Gfx IP */
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct rockchip_private_map_data {
|
struct rockchip_private_map_data {
|
||||||
|
|
|
||||||
2
vc4.c
2
vc4.c
|
|
@ -13,8 +13,8 @@
|
||||||
#include <vc4_drm.h>
|
#include <vc4_drm.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565,
|
static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565,
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "external/virtgpu_drm.h"
|
#include "external/virtgpu_drm.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "virtgpu.h"
|
#include "virtgpu.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "external/virtgpu_cross_domain_protocol.h"
|
#include "external/virtgpu_cross_domain_protocol.h"
|
||||||
#include "external/virtgpu_drm.h"
|
#include "external/virtgpu_drm.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "virtgpu.h"
|
#include "virtgpu.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
||||||
|
#include "drv_helpers.h"
|
||||||
#include "drv_priv.h"
|
#include "drv_priv.h"
|
||||||
#include "external/virgl_hw.h"
|
#include "external/virgl_hw.h"
|
||||||
#include "external/virgl_protocol.h"
|
#include "external/virgl_protocol.h"
|
||||||
#include "external/virtgpu_drm.h"
|
#include "external/virtgpu_drm.h"
|
||||||
#include "helpers.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "virtgpu.h"
|
#include "virtgpu.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue