Commit graph

18 commits

Author SHA1 Message Date
Pujun Lun
509fd7babf gpu_display: add DisplayParameters to create_surface() interface.
"width" and "height" are removed from the interface since they can
be derived from DisplayParameters.

Windows implementation was assuming only one display, so
DisplayParameters was passed in with GpuDisplay::open_winapi() and
assumed not to change. To support multi-display, it needs to be
passed in every time we create a new surface. This should make no
functional change to other platforms.

BUG=b:332910955

Change-Id: I32767a37c8a1f50716190e13aa94c9c159db3d04
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5041413
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2024-04-04 22:20:57 +00:00
Pujun Lun
224cc67e89 gpu_display: add scanout id to create_surface() interface.
GpuDisplay::create_surface() and GpuDisplay::set_scanout_id() were
called back-to-back. To support multi-display on Windows (where
host windows are associated with scanouts), it makes more sense to
pass in the scanout id when creating the surface so that we can
immediately use it for routing input events. This shouldn't affect
other platforms.

BUG=b:254702853
TEST=presubmit

Change-Id: I0c4081107706420492465e755f9440f3c4363b78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5273974
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2024-02-12 19:49:48 +00:00
A. Cody Schuffelen
97dff044f8 Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))]
Updates are made to source and documentation.

This more accurately represents the currently supported platforms of
Android/Linux and Windows, without unexpectedly including other
unix-like operating systems.

Command to reproduce:
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -i 's/cfg(unix)/cfg(any(target_os = "android", target_os = "linux"))/g' {}
$ cargo fmt

md files manually updated to fix line lengths.

Renaming `unix` modules to `linux` will be done in a later CL.

Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I42c1bf0abf80b9a0df25551613910293217c7295
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909059
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-10-11 00:43:29 +00:00
Daniel Verkamp
083dcf75f4 tree-wide: apply nightly rustfmt
BUG=None
TEST=tools/fmt --nightly

Change-Id: Ifb08dd55ccf2a74ef739d7517a64970d24a82405
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4375640
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-03-27 21:30:45 +00:00
Dennis Kempin
acc162000f Add conditional compilation for unix-only crates
Instead of configuring which crates to --exclude in
test_config.py, we can use conditional compilation to
exclude code that is not supported on windows.

This allows more fine-grained control and also allows
us to use plain cargo for building without complicated
configuration and exclusions.

BUG=b:265829867
TEST=cargo test --lib --bins --workspace
	--target=x86_64-pc-windows-gnu
	--features=all-mingw64

Change-Id: I8422c3f08053bc27d9896b220876a56bd25543d6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4165868
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-01-19 21:21:59 +00:00
Daniel Verkamp
87fd7a8d40 gpu_display: add basic error handling to examples
This helps diagnose problems if the examples don't work (for example,
simple_open requires the `x` feature to be enabled).

BUG=None
TEST=run simple and simple_open examples

Change-Id: Ic115d48d93531bf2313948597a49a003538949cd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4029530
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-16 19:33:35 +00:00
Dennis Kempin
1dab58a2cf Update all copyright headers to match new style
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.

This fulfills the request from legal and unifies our notices.

./tools/health-check has been updated to only accept this style.

BUG=b:246579983
TEST=./tools/health-check

Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-13 18:41:29 +00:00
Dennis Kempin
78f62a44e7 Update copyright header check to cover all files
generated files and a list of excluded files are skipped.
Others are fixed to include the missing header.

BUG=b:246579983
TEST=./tools/health-check --all copyright_header

Change-Id: I13e9bf79df18789f1ed4b83fc47c0c2e080d70a8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894240
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-13 18:41:29 +00:00
Dennis Kempin
4fea399df9 Reformat imports
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.

Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.

BUG=b:239937122
TEST=CQ

Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-28 00:15:50 +00:00
Robert Tarasov
bb95fc4512 gpu_display/wayland: Added keyboard and pointing devices
Added preliminary version of keyboard and pointing device routine
for wayland implementation. The pointing input is wired as a multi
touch device. Due to the fact that wayland client is callback based,
all the necessary incoming events are serialized and stashed in the
temp circular buffer and then processed afterwards from the main event
loop.

Known issues:

1. Mouse input can't be properly wired inside the guest as a mouse
   device without pointer locking, but this is not what we want. The
   approach emulates it as a multitouch device, but, of course, it
   implies limitations in functionality.  Limitations include cursor
   in the VM that doesn't move in unison with the host cursor.

2. I kept the mouse cursor surface since it's not decided yet which
   approach for handling pointing input device will be used (see #1).

   Removing the mouse surface in the guest would remove the lagging
   guest cursor.  The alternatives to the multi-touch device are:

   "- Relative mice (e.g. a typical PC mouse). These are relative
      devices, meaning they send deltas from the current cursor
      position.  Some apps like games rely on these events.

    - Touchscreens (multitouch, single touch). These are absolute
      devices, and are much easier to implement seamless guest/host
      input for.

    - Touchpads (these are absolute devices). I'm not sure these are
      really compelling for any use case." -nkgold@

3. This code is for POC purpose only, so there are still lot of minor
   issues and negligence in it.

Looking forward for your comments and proposals.

BUG=b:177939148
TEST=crosvm $ARGS \
      --display-window-keyboard \
      --display-window-mouse \
      --gpu=3d,glx=false,egl=true \
      --wayland-sock=/run/user/1000/wayland-0 \
      $OTHER_ARGS

Change-Id: If4a9b73b8da4e0cc52fa619bbd6e5588ccdb7874
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2688439
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-06-15 03:14:07 +00:00
Gurchetan Singh
41daa354c7 gpu_display: refactor event loop
There is a desire for Wayland and possibly other display backends to
reasonably handle input.  Move the event device logic inside the X11
backend up to the common layer to prevent duplication.

The common layer also keeps track of surfaces and external memory
objects to make this easier.  The GpuDisplaySurface/GpuDisplayMemory
traits are  introduced in case the common layer needs to perform
compositor specific operation.

BUG=b:173630595
TEST=compile and run with X11

Change-Id: Ied060a7cc216ac6c084030aad1fc839c022a3395
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2852523
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-06-08 22:07:17 +00:00
Andrew Walbran
9cfdbd9cc0 Fix clippy errors and some warnings.
TEST=cargo test

Change-Id: I91afe78141c717a592eec5ec77acac2a500ba163
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2623941
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2021-01-18 15:50:25 +00:00
Chirantan Ekbote
e7d1221c9d Make VolatileSlice ABI-compatible with iovec
Change VolatileSlice so that it is ABI-compatible with iovec.  This
allows us to directly pass in a VolatileSlice for a C function that
expects an iovec without having to create temporaries that convert from
one to the other.

Also change all the parameters from u64 to usize.  It's not possible to
address more memory than fits into a usize so having u64 here didn't
really provide much benefit and led to a lot of tedious casting back and
forth all over the place.

BUG=none
TEST=unit tests

Cq-Depend: chromium:2206621
Change-Id: I258f9123c603d9a4c6c5e2d4d10eb4aedf74466d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2203998
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-05-25 19:14:07 +00:00
Zach Reizner
f5285c647a gpu_display: add X11 backend
This change adds an X11 backend to the gpu_display crate. With this
addition, the virtio-gpu device can display to traditional linux
desktops that only have X11 output.

Change-Id: I86c80cac91ca5bdc97588194a44040273ae69385
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1591572
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Zach Reizner <zachr@chromium.org>
2019-07-25 22:15:48 +00:00
Stephen Barber
d6945a09b8 crosvm: add license blurb to all files
A few files were missing license blurbs at the top, so update them all
to include them.

BUG=none
TEST=none

Change-Id: Ida101be2e5c255b8cffeb15f5b93f63bfd1b130b
Reviewed-on: https://chromium-review.googlesource.com/1577900
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-04-24 15:51:38 -07:00
David Tolnay
aecf9a4dee edition: Remove extern crate lines
In Rust 2018 edition, `extern crate` is no longer required for importing
from other crates. Instead of writing:

    extern crate dep;
    use dep::Thing;

we write:

    use dep::Thing;

In this approach, macros are imported individually from the declaring
crate rather than through #[macro_use]. Before:

    #[macro_use]
    extern crate sys_util;

After:

    use sys_util::{debug, error};

The only place that `extern crate` continues to be required is in
importing the compiler's proc_macro API into a procedural macro crate.
This will hopefully be fixed in a future Rust release.

    extern crate proc_macro;

TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu
TEST=local kokoro

Change-Id: I0b43768c0d81f2a250b1959fb97ba35cbac56293
Reviewed-on: https://chromium-review.googlesource.com/1565302
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
2019-04-15 02:06:08 -07:00
Zach Reizner
a1422e6bca fix warning and bit rotted tests uncovered by kokoro
TEST=run kokoro presubmit
BUG=None

Change-Id: I301551f8f58263f1a8b7a8276867881cb17517ab
Reviewed-on: https://chromium-review.googlesource.com/1236889
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2018-09-22 01:43:11 -07:00
Zach Reizner
20d71f8928 gpu_display: provides wayland based output for virtio-gpu
This provides virtual display style output, useful for debugging
virtio-gpu. Although using virtio-gpu for display purposes clashes with
the more integreated virtio-wayland support, it is nonetheless helpful
for debugging virtio-gpu, and is technically required to fully implement
that device.

TEST=cargo build -p gpu_display
BUG=chromium:837073
CQ-DEPEND=CL:1096300

Change-Id: I59f895e951ef593d4119e7558168dd34223519ee
Reviewed-on: https://chromium-review.googlesource.com/1043446
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-07-09 15:48:21 -07:00