Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support the VM3 screen cast #157

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions cros_gralloc/cros_gralloc_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,6 @@ cros_gralloc_driver::cros_gralloc_driver()
drv_kms_ = drv_render_;
}

if (ivshm_node_idx != -1) {
if (!(drv_ivshmem_ = drv_create(node_fd[ivshm_node_idx]))) {
drv_loge("Failed to create driver for the ivshm device with card id %d\n",
ivshm_node_idx);
close(node_fd[ivshm_node_idx]);
}
}

// Init drv
DRV_INIT(drv_render_, gpu_grp_type_, renderer_idx)
if (video_idx != renderer_idx)
Expand All @@ -326,25 +318,39 @@ cros_gralloc_driver::cros_gralloc_driver()
DRV_INIT(drv_kms_, gpu_grp_type_, virtio_node_idx)
if (drv_kms_ && (virtio_node_idx != renderer_idx) && (drv_kms_ != drv_render_)) {
bool virtiopic_with_blob = drv_virtpci_with_blob(drv_kms_);
// The virtio pci device with blob feature could import buffers
// from i915, otherwise need use virtio to allocate scanout
// non-video buffers.
if (virtiopic_with_blob) {
//igpu SRIOV or dGPU SRIOV case
drv_logi("Virtio gpu device with blob\n");
if ((drv_kms_ != drv_render_) && drv_kms_)
DRV_DESTROY(drv_kms_)
drv_kms_ = drv_render_;
} else if (drv_is_dgpu(drv_video_) && drv_virtgpu_is_ivshm(drv_kms_)){
//is dgpu passthrough + ivshm case
drv_logi("dGPU with Virtio ivshm\n");
drv_ivshmem_ = drv_kms_;
drv_kms_ = drv_render_;
yhe39 marked this conversation as resolved.
Show resolved Hide resolved
if (ivshm_node_idx != -1) {
close(node_fd[ivshm_node_idx]);
ivshm_node_idx = -1;
}
} else {
drv_logi("Virtio ivshmem device or no blob\n");
// is QNX or redhat case
drv_logi("Virtio ivshm or no blob\n");
}
}
if (ivshm_node_idx != -1) {
DRV_INIT(drv_ivshmem_, gpu_grp_type_, ivshm_node_idx)
if (drv_virtgpu_is_ivshm(drv_ivshmem_)) {
drv_logi("Node is virtio-ivishmem node");
if (!(drv_ivshmem_ = drv_create(node_fd[ivshm_node_idx]))) {
drv_loge("Failed to create driver for the ivshm device with card id %d\n",
ivshm_node_idx);
close(node_fd[ivshm_node_idx]);
} else {
drv_logi("Node is NOT virtio-ivishmem node");
DRV_DESTROY(drv_ivshmem_)
DRV_INIT(drv_ivshmem_, gpu_grp_type_, ivshm_node_idx)
if (drv_virtgpu_is_ivshm(drv_ivshmem_)) {
drv_logi("Node is virtio-ivishmem node");
} else {
drv_logi("Node is NOT virtio-ivishmem node");
DRV_DESTROY(drv_ivshmem_)
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions cros_gralloc/cros_gralloc_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ class cros_gralloc_driver
struct driver *drv_render_ = nullptr;
struct driver *drv_video_ = nullptr;
// the drv_kms_ is used to allocate scanout non-video buffer.
// in dGPU/iGPU SRIOV, BM or dual GPU scenario, the drv_kms_ = drv_render_
struct driver *drv_kms_ = nullptr;
// the drv_ivshmem_ is used to allocate scanout buffer with
// certain resolution(screen cast).
struct driver *drv_ivshmem_ = nullptr;
uint32_t drv_num_ = 0;
uint64_t gpu_grp_type_ = GPU_TYPE_NORMAL;
Expand Down
12 changes: 12 additions & 0 deletions drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,3 +857,15 @@ bool drv_virtgpu_is_ivshm(struct driver * drv)
}
return ret;
}

bool drv_is_dgpu(struct driver * drv)
{
bool ret = false;
assert(drv);
assert(drv->backend);

if (drv->backend->is_dgpu) {
ret = drv->backend->is_dgpu(drv);
}
return ret;
}
2 changes: 2 additions & 0 deletions drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ bool drv_virtpci_with_blob(struct driver * drv);

bool drv_virtgpu_is_ivshm(struct driver * drv);

bool drv_is_dgpu(struct driver * drv);

enum drv_log_level {
DRV_LOGV,
DRV_LOGD,
Expand Down
1 change: 1 addition & 0 deletions drv_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ struct backend {
uint32_t (*get_max_texture_2d_size)(struct driver *drv);
bool (*virtpci_with_blob)(struct driver *drv);
bool (*virtgpu_is_ivshm)(struct driver *drv);
bool (*is_dgpu)(struct driver *drv);
};

// clang-format off
Expand Down
7 changes: 7 additions & 0 deletions i915.c
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,12 @@ static int i915_bo_flush(struct bo *bo, struct mapping *mapping)
return 0;
}

static bool i915_is_dgpu(struct driver *drv)
{
struct i915_device *i915 = drv->priv;
return i915->has_local_mem;
}

const struct backend backend_i915 = {
.name = "i915",
.init = i915_init,
Expand All @@ -1443,6 +1449,7 @@ const struct backend backend_i915 = {
.bo_flush = i915_bo_flush,
.resolve_format_and_use_flags = drv_resolve_format_and_use_flags_helper,
.num_planes_from_modifier = i915_num_planes_from_modifier,
.is_dgpu = i915_is_dgpu,
};

#endif
2 changes: 1 addition & 1 deletion virtgpu_virgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ static bool virgl_virtpci_with_blob(struct driver *drv) {

static bool virgl_drv_virtgpu_is_ivshm(struct driver *drv) {
struct virgl_priv *prv = (struct virgl_priv *)drv->priv;
return !(prv->dev_feature & VIRTGPU_PARAM_QUERY_DEV_BIT);
return (!(prv->dev_feature & VIRTGPU_PARAM_QUERY_DEV_BIT) && (prv->dev_feature & VIRTGPU_PARAM_RESOURCE_BLOB_BIT));
}

const struct backend virtgpu_virgl = { .name = "virtgpu_virgl",
Expand Down