Re: [PATCHv2 8/9] hackrf: add support for transmitter

Hans Verkuil
2015-07-17T14:16:53Z

On 07/16/2015 09:04 AM, Antti Palosaari wrote:
> HackRF SDR device has both receiver and transmitter. There is limitation
> that receiver and transmitter cannot be used at the same time
> (half-duplex operation). That patch implements transmitter support to
> existing receiver only driver.
>
> Cc: Hans Verkuil <hverkuil@xs4all.nl>
> Signed-off-by: Antti Palosaari <crope@iki.fi>
> ---
> drivers/media/usb/hackrf/hackrf.c | 787 +++++++++++++++++++++++++++-----------
> 1 file changed, 572 insertions(+), 215 deletions(-)
>
> diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c
> index 5bd291b..97de9cb6 100644
> --- a/drivers/media/usb/hackrf/hackrf.c
> +++ b/drivers/media/usb/hackrf/hackrf.c
> @@ -731,15 +889,19 @@ static int hackrf_querycap(struct file *file, void *fh,
> struct v4l2_capability *cap)
> {
> struct hackrf_dev *dev = video_drvdata(file);
> + struct video_device *vdev = video_devdata(file);
>
> dev_dbg(dev->dev, "\n");
>
> + if (vdev->vfl_dir == VFL_DIR_RX)
> + cap->device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_TUNER;
> + else
> + cap->device_caps = V4L2_CAP_SDR_OUTPUT | V4L2_CAP_MODULATOR;
> + cap->device_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
> + cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;

The capabilities are those of the whole device, so you should OR this with
V4L2_CAP_SDR_CAPTURE | V4L2_CAP_SDR_OUTPUT |
V4L2_CAP_TUNER | V4L2_CAP_MODULATOR

> strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
> - strlcpy(cap->card, dev->vdev.name, sizeof(cap->card));
> + strlcpy(cap->card, dev->rx_vdev.name, sizeof(cap->card));
> usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info));
> - cap->device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_STREAMING |
> - V4L2_CAP_READWRITE | V4L2_CAP_TUNER;
> - cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
>
> return 0;
> }

Regards,

Hans