public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Antti Palosaari <crope@iki.fi>, linux-media@vger.kernel.org
Subject: Re: [PATCHv2 8/9] hackrf: add support for transmitter
Date: Fri, 17 Jul 2015 15:04:24 +0200	[thread overview]
Message-ID: <55A8FD58.7010806@xs4all.nl> (raw)
In-Reply-To: <1437030298-20944-9-git-send-email-crope@iki.fi>

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
> @@ -34,6 +34,7 @@ enum {
>  	CMD_AMP_ENABLE                     = 0x11,
>  	CMD_SET_LNA_GAIN                   = 0x13,
>  	CMD_SET_VGA_GAIN                   = 0x14,
> +	CMD_SET_TXVGA_GAIN                 = 0x15,
>  };
>  
>  /*
> @@ -44,7 +45,7 @@ enum {
>  #define MAX_BULK_BUFS            (6)
>  #define BULK_BUFFER_SIZE         (128 * 512)
>  
> -static const struct v4l2_frequency_band bands_adc[] = {
> +static const struct v4l2_frequency_band bands_adc_dac[] = {
>  	{
>  		.tuner = 0,
>  		.type = V4L2_TUNER_ADC,
> @@ -55,7 +56,7 @@ static const struct v4l2_frequency_band bands_adc[] = {
>  	},
>  };
>  
> -static const struct v4l2_frequency_band bands_rf[] = {
> +static const struct v4l2_frequency_band bands_rx_tx[] = {
>  	{
>  		.tuner = 1,
>  		.type = V4L2_TUNER_RF,
> @@ -91,28 +92,39 @@ struct hackrf_frame_buf {
>  };
>  
>  struct hackrf_dev {
> -#define POWER_ON                         1
> -#define USB_STATE_URB_BUF                2 /* XXX: set manually */
> -#define SAMPLE_RATE_SET                 10
> -#define RX_BANDWIDTH                    11
> -#define RX_RF_FREQUENCY                 12
> -#define RX_RF_GAIN                      13
> -#define RX_LNA_GAIN                     14
> -#define RX_IF_GAIN                      15
> +#define USB_STATE_URB_BUF                1 /* XXX: set manually */
> +#define QUEUE_SETUP                      3
> +#define RX_ON                            4
> +#define TX_ON                            5
> +#define RX_ADC_FREQUENCY                11
> +#define TX_DAC_FREQUENCY                12
> +#define RX_BANDWIDTH                    13
> +#define TX_BANDWIDTH                    14
> +#define RX_RF_FREQUENCY                 15
> +#define TX_RF_FREQUENCY                 16
> +#define RX_RF_GAIN                      17
> +#define TX_RF_GAIN                      18
> +#define RX_IF_GAIN                      19
> +#define RX_LNA_GAIN                     20
> +#define TX_LNA_GAIN                     21
>  	unsigned long flags;
>  
>  	struct usb_interface *intf;
>  	struct device *dev;
>  	struct usb_device *udev;
> -	struct video_device vdev;
> -	struct v4l2_device v4l2_dev;
> +	struct video_device rx_vdev;
> +	struct video_device tx_vdev;
> +	struct v4l2_device rx_v4l2_dev;
> +	struct v4l2_device tx_v4l2_dev;

Why two v4l2_device structs? It is a single USB device, so there is a single
v4l2_device struct.

It looks like the only reason might be that you want different control handlers
for each radio device. If that's the case, then that can easily be done by
assigning the v4l2_ctrl_handler pointer to the ctrl_handler field of the struct
video_device instead of the struct v4l2_device.

Other than that the code looks good.

Regards,

	Hans

>  
>  	/* videobuf2 queue and queued buffers list */
> -	struct vb2_queue vb_queue;
> +	struct vb2_queue rx_vb2_queue;
> +	struct vb2_queue tx_vb2_queue;
>  	struct list_head queued_bufs;
>  	spinlock_t queued_bufs_lock; /* Protects queued_bufs */
>  	unsigned sequence;	     /* Buffer sequence counter */
>  	unsigned int vb_full;        /* vb is full and packets dropped */
> +	unsigned int vb_empty;       /* vb is empty and packets dropped */
>  
>  	/* Note if taking both locks v4l2_lock must always be locked first! */
>  	struct mutex v4l2_lock;      /* Protects everything else */


  reply	other threads:[~2015-07-17 13:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16  7:04 [PATCHv2 0/9] SDR transmitter API Antti Palosaari
2015-07-16  7:04 ` [PATCHv2 1/9] v4l2: rename V4L2_TUNER_ADC to V4L2_TUNER_SDR Antti Palosaari
2015-07-17 14:32   ` Hans Verkuil
2015-07-16  7:04 ` [PATCHv2 2/9] v4l2: add RF gain control Antti Palosaari
2015-07-16  7:04 ` [PATCHv2 3/9] DocBook: document tuner " Antti Palosaari
2015-07-16  7:04 ` [PATCHv2 4/9] v4l2: add support for SDR transmitter Antti Palosaari
2015-07-16  7:04 ` [PATCHv2 5/9] DocBook: document " Antti Palosaari
2015-07-16  7:04 ` [PATCHv2 6/9] hackrf: add control for RF amplifier Antti Palosaari
2015-07-16  7:04 ` [PATCHv2 7/9] hackrf: switch to single function which configures everything Antti Palosaari
2015-07-16  7:04 ` [PATCHv2 8/9] hackrf: add support for transmitter Antti Palosaari
2015-07-17 13:04   ` Hans Verkuil [this message]
2015-07-17 14:15   ` Hans Verkuil
2015-07-27 16:19     ` Antti Palosaari
2015-07-27 17:19       ` Hans Verkuil
2015-07-17 14:43   ` Hans Verkuil
2015-07-27 20:21     ` Antti Palosaari
2015-07-27 20:38       ` Hans Verkuil
2015-07-28  0:50         ` Antti Palosaari
2015-07-28  7:06           ` Hans Verkuil
2015-07-28 23:04             ` Antti Palosaari
2015-07-16  7:04 ` [PATCHv2 9/9] hackrf: do not set human readable name for formats Antti Palosaari
2015-07-17 14:46 ` [PATCHv2 0/9] SDR transmitter API Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55A8FD58.7010806@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=crope@iki.fi \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox