Commit Graph

64 Commits

Author SHA1 Message Date
Matias Ezequiel Vara Larsen
18eace76f8 cargo fmt
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-09-20 10:38:06 +02:00
Matias Ezequiel Vara Larsen
be904f93fa remove unnecessary casting to the same type
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-09-20 10:25:45 +02:00
Dorinda Bassey
5984715806 audio_backends/pipewire.rs: use safe queue API
use safe queue API

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-09-14 14:52:09 +02:00
dorindabassey
62575fa25c
Merge pull request #28 from dorindabassey/rebasepw
crates/sound: Rebase pipewire backend
2023-09-13 10:56:52 +02:00
Dorinda Bassey
917d24c7fa crates/sound: Rebase pipewire backend
Rebase pipewire Backend

Co-authored-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Co-authored-by: Dorinda Bassey <dbassey@redhat.com>

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-09-11 16:47:08 +02:00
Albert Esteve
bf18c3ee62 sound: always compile null backend
Make Null backend compiled unconditionally,
removing the null-backend feature. That
allows having the other backend choices in
the BackendType enum to be conditional, and
make them not available if their features is
opted out at compile time.

For example, compiled with no backend features,
there is only choice (i.e., null) for --backend:

```
$ target/debug/vhost-user-sound --help

Usage: vhost-user-sound --socket <SOCKET> --backend <BACKEND>

Options:
      --socket <SOCKET>    vhost-user Unix domain socket path
      --backend <BACKEND>  audio backend to be used [possible values: null]
  -h, --help               Print help
  -V, --version            Print version
```

Fixes: #26
Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-09-04 11:26:31 +02:00
Albert Esteve
cd955a7132 sound: introduce rstest crate
Introduce 'rstest'[1] crate dependency to allow
run multiple parametrized tests (and fixtures).

[1] - https://docs.rs/rstest/latest/rstest/

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-08-31 11:43:57 +02:00
Albert Esteve
4867edc009 sound: test cli backend argument
Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-08-31 11:43:17 +02:00
Albert Esteve
6c5b2db7db sound: audio backend allow unused
When compiled with no features, the `streams`
parameter of the alloc_audio_backend() function
is not used. Mark it as allowed to avoid the
compilation warning.

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-08-31 11:41:47 +02:00
Albert Esteve
a48bff27b1 sound: cli backend selector
Change the CLI backend option to receive values
listed in a ValueEnum.

Current '--help' output:
```
A virtio-sound device using the vhost-user protocol.

Usage: vhost-user-sound --socket <SOCKET> --backend <BACKEND>

Options:
      --socket <SOCKET>  vhost-user Unix domain socket path
      --backend <BACKEND>  audio backend to be used [possible values:
      null, pipewire, alsa]
  -h, --help             Print help
  -V, --version          Print version
```

If a wrong backend is given, it give hints:
```
$ cargo run -- --socket /tmp/sound.sock --backend nul
error: invalid value 'nul' for '<BACKEND>'
  [possible values: null, pipewire, alsa]

  tip: a similar value exists: 'null'
```

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-08-31 11:40:40 +02:00
Manos Pitsidianakis
855eefb380
sound: add ALSA backend
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-08-23 23:01:34 +03:00
Manos Pitsidianakis
b7122e66af
sound: Add TX queue handler
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-08-23 23:01:32 +03:00
Manos Pitsidianakis
ecf88fb602
sound: Add CTRL queue handler
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-08-23 23:00:19 +03:00
Manos Pitsidianakis
d385dcd1b2
sound: add Stream, ControlMessage and other types
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-08-23 23:00:17 +03:00
Manos Pitsidianakis
91a5259cce
Add vhost-user-sound crate
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-08-23 22:12:35 +03:00
Dorinda Bassey
e49e8117d7 cargo fmt
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-07-11 18:23:33 +02:00
Matias Ezequiel Vara Larsen
03241612a7 Sound: Add set_param()
This commit adds the set_param() method. This method can only be called
if the stream is in the "set parameters", "prepare" or "release" state.
For the pw backend, this method only updates the internal values for the
given stream.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-07-11 12:08:30 +02:00
Dorinda Bassey
08078b752c instantiate new backend with PW thread loop functions
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-07-10 18:58:06 +02:00
Matias Ezequiel Vara Larsen
b3b83c1f41 Sound: initialize StreamInfo
This commit adds a vector named StreamInfo that contains the supported
configuration for the audio backends, e.g., rate, format. This
information is stored in the context of VhostUserSoundBackend. The
device reponses this information when getting the VIRTIO_SND_R_PCM_INFO
msg. The number of streams that are exposed in the device configuration
is got from this table.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-07-05 17:02:13 +02:00
Dorinda Bassey
110ccd736c instantiate new backend
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-07-03 16:02:37 +02:00
Matias Ezequiel Vara Larsen
e3d5071246 Sound: add audio_backend parameter
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-06-30 10:33:13 +02:00
Matias Ezequiel Vara Larsen
c4b253c433 Sound: Handle tx queue
This commit handles the pcm i/o messages to the tx transmission queue.
These msgs contains three descriptors: hdr, data and status. The data
descriptor shall be processed by the audio backend. The data may be
split in multiples descriptors.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-06-30 10:31:48 +02:00
Dorinda Bassey
582a66ff07 Sound: Handle control queue
Handle ctrl msgs from the control Queue in method for handling control queue

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-06-21 13:02:58 +02:00
Manos Pitsidianakis
d39140f82a
sound: rename typo virtio_snd_config.chmpas -> chmaps 2023-06-05 13:53:37 +03:00
Dorinda Bassey
05a959d703 sound: add PipeWire backend skeleton
to enable the pipewire backend feature, build with `--features pw-backend`

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-05-26 17:44:05 +02:00
Stefano Garzarella
a198f48cde sound: rename alloc_audio_backend 2023-05-19 18:19:47 +02:00
Stefano Garzarella
65f7c78dbd sound: support --backend option 2023-05-19 18:16:21 +02:00
Stefano Garzarella
82660840ca sound: add NullBackend skeleton 2023-05-19 18:11:14 +02:00
Stefano Garzarella
5e8fd650e9 sound: add AudioBackend trait 2023-05-19 18:11:14 +02:00
Dorinda Bassey
16e927e10e virtio_sound.rs: Added device configuration and common definitions
Added device configuration and common definitions from the
virtio sound specifications to the header file

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-04-27 08:39:15 +02:00
Stefano Garzarella
2366b76718 sound: add missing files 2023-04-03 14:33:53 +02:00
Stefano Garzarella
b81c55fbe2 sound: code refactoring 2023-03-31 17:16:21 +02:00
Stefano Garzarella
8d3ebf35e1 sound: support multiple threads 2023-03-31 15:49:46 +02:00
Stefano Garzarella
72c31053ff Revert "sound: use thread trait"
This reverts commit 3ac6c160c1.
2023-03-31 12:05:58 +02:00
Stefano Garzarella
3ac6c160c1 sound: use thread trait 2023-03-30 20:56:42 +02:00
Stefano Garzarella
a1b49a76a7 sound: use interior mutability 2023-03-30 20:23:51 +02:00
Stefano Garzarella
0a78103b41 sound: initial commit 2023-03-30 18:47:15 +02:00
dependabot[bot]
b181568ae5 build(deps): bump tempfile from 3.3.0 to 3.4.0
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/Stebalien/tempfile/releases)
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/NEWS)
- [Commits](https://github.com/Stebalien/tempfile/commits)

---
updated-dependencies:
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-13 14:09:24 +05:30
Viresh Kumar
ea699c86de tests: Initialize queues properly
The virtio-queue crate doesn't allow invalid queue state since commit
d951283a8e88 ("don't allow processing descriptors for invalid q").

Initialize the queues properly to fix testing failures.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-02-28 14:44:14 +05:30
Alex Bennée
2857681557 Updates crates to use virtio_config bindings
Rather incongruously the common VIRTIO feature flags where part of the
net binding. Now that the new binding are out we can update them to
something generic.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2023-02-28 14:19:12 +05:30
dependabot[bot]
b32559eb72 build(deps): bump clap from 4.1.4 to 4.1.6
Bumps [clap](https://github.com/clap-rs/clap) from 4.1.4 to 4.1.6.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.1.4...v4.1.6)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-20 12:09:24 +05:30
Viresh Kumar
799073f17c gpio: Migrate to the upstream version of libgpiod
The upstream version doesn't compile the .c files locally and depends on
the package to be locally compiled and installed in advance.

It also doesn't provide pre-generated bindings, and requires bindgen
support.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-02-15 08:09:13 -07:00
Viresh Kumar
b6e3fd4970 i2c: Change type of mem to GuestMemoryLoadGuard<>
This is what we need eventually, while parsing the requests, lets store
the correct type instead of creating the same everytime.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-02-13 23:41:17 +05:30
dependabot[bot]
ea09ebce2e build(deps): bump serial_test from 0.9.0 to 1.0.0
Bumps [serial_test](https://github.com/palfrey/serial_test) from 0.9.0 to 1.0.0.
- [Release notes](https://github.com/palfrey/serial_test/releases)
- [Commits](https://github.com/palfrey/serial_test/compare/v0.9.0...v1.0.0)

---
updated-dependencies:
- dependency-name: serial_test
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-13 10:39:24 +05:30
Viresh Kumar
8a6c25f3e7 gpio: Update to a newer version of libgpiod
Update to a newer version of libgpiod crates.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-01-20 15:30:53 +05:30
Stefano Garzarella
d1539d5274 vsock: require virtio-vsock 0.2.1
The 0.2.1 version of virtio-vsock crate contains a fix [1] needed to
properly work with the virtio-vsock driver provided by Linux v6.3 and
later (originally the new driver was supposed to be in v6.2, but it
was postponed).

The fix was just a quick workaround, but in the future more work will
be needed in the virtio-vsock crate to not have a Linux-only specific
implementation of VsockPacket, as described in this issue [2].

[1] https://github.com/rust-vmm/vm-virtio/pull/207
[2] https://github.com/rust-vmm/vm-virtio/issues/216

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-01-19 09:37:25 -07:00
Viresh Kumar
26a0f3ad4d Fix clippy errors
New clippy errors were reported with an updated rust-vmm-ci submodule,
fix them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-01-16 15:20:10 +05:30
Stefano Garzarella
42526a302c vsock/README: update the QEMU example
As pointed out in https://gitlab.com/qemu-project/qemu/-/issues/1337
`-numa` is not supported by all machine types, so let's update the
example using the `memory-backend` machine property.

Since we are modifying the QEMU example, let's provide only the
QEMU's vhost-user-vsock required options in the "Usage" section.
In addition we also probide a working example.

Let's also remove a spurious rust section at the bottom of the file
that does not add any useful information.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2022-12-05 21:18:25 +05:30
Viresh Kumar
f541481f30 i2c: Accept bus names instead of numbers
The I2C device names, /dev/i2c-N, can change from one boot to another of
the host machine and so aren't stable enough to be used for bus
selection.

Instead start accepting I2C master's name as parameter and parse based
on that.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2022-12-05 17:15:38 +05:30
Viresh Kumar
26e0ff25ae i2c: Move Linux userspace specific code to PhysDevice
The path "/dev/i2c-N" is valid only for Linux userspace and must be
handled within PhysDevice's implementation.

Move it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2022-12-05 17:15:38 +05:30