From: Antti Palosaari <crope@iki.fi>
To: linux-media@vger.kernel.org
Cc: Hans Verkuil <hverkuil@xs4all.nl>, Antti Palosaari <crope@iki.fi>
Subject: [PATCH 08/13] hackrf: add control for RF amplifier
Date: Wed, 2 Sep 2015 00:59:24 +0300 [thread overview]
Message-ID: <1441144769-29211-9-git-send-email-crope@iki.fi> (raw)
In-Reply-To: <1441144769-29211-1-git-send-email-crope@iki.fi>
There is Avago MGA-81563 amplifier just right after antenna connector.
It could be turned on/off and its gain is around 12dB.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
---
drivers/media/usb/hackrf/hackrf.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c
index fd1fa41..136de9a 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -31,6 +31,7 @@ enum {
CMD_BOARD_ID_READ = 0x0e,
CMD_VERSION_STRING_READ = 0x0f,
CMD_SET_FREQ = 0x10,
+ CMD_AMP_ENABLE = 0x11,
CMD_SET_LNA_GAIN = 0x13,
CMD_SET_VGA_GAIN = 0x14,
};
@@ -133,6 +134,7 @@ struct hackrf_dev {
struct v4l2_ctrl_handler hdl;
struct v4l2_ctrl *bandwidth_auto;
struct v4l2_ctrl *bandwidth;
+ struct v4l2_ctrl *rf_gain;
struct v4l2_ctrl *lna_gain;
struct v4l2_ctrl *if_gain;
@@ -164,6 +166,7 @@ static int hackrf_ctrl_msg(struct hackrf_dev *dev, u8 request, u16 value,
switch (request) {
case CMD_SET_TRANSCEIVER_MODE:
case CMD_SET_FREQ:
+ case CMD_AMP_ENABLE:
case CMD_SAMPLE_RATE_SET:
case CMD_BASEBAND_FILTER_BANDWIDTH_SET:
pipe = usb_sndctrlpipe(dev->udev, 0);
@@ -949,6 +952,22 @@ static int hackrf_set_bandwidth(struct hackrf_dev *dev)
return ret;
}
+static int hackrf_set_rf_gain(struct hackrf_dev *dev)
+{
+ int ret;
+ u8 u8tmp;
+
+ dev_dbg(dev->dev, "rf val=%d->%d\n",
+ dev->rf_gain->cur.val, dev->rf_gain->val);
+
+ u8tmp = (dev->rf_gain->val) ? 1 : 0;
+ ret = hackrf_ctrl_msg(dev, CMD_AMP_ENABLE, u8tmp, 0, NULL, 0);
+ if (ret)
+ dev_dbg(dev->dev, "failed=%d\n", ret);
+
+ return ret;
+}
+
static int hackrf_set_lna_gain(struct hackrf_dev *dev)
{
int ret;
@@ -992,6 +1011,9 @@ static int hackrf_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_RF_TUNER_BANDWIDTH:
ret = hackrf_set_bandwidth(dev);
break;
+ case V4L2_CID_RF_TUNER_RF_GAIN:
+ ret = hackrf_set_rf_gain(dev);
+ break;
case V4L2_CID_RF_TUNER_LNA_GAIN:
ret = hackrf_set_lna_gain(dev);
break;
@@ -1077,13 +1099,15 @@ static int hackrf_probe(struct usb_interface *intf,
}
/* Register controls */
- v4l2_ctrl_handler_init(&dev->hdl, 4);
+ v4l2_ctrl_handler_init(&dev->hdl, 5);
dev->bandwidth_auto = v4l2_ctrl_new_std(&dev->hdl, &hackrf_ctrl_ops,
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
dev->bandwidth = v4l2_ctrl_new_std(&dev->hdl, &hackrf_ctrl_ops,
V4L2_CID_RF_TUNER_BANDWIDTH,
1750000, 28000000, 50000, 1750000);
v4l2_ctrl_auto_cluster(2, &dev->bandwidth_auto, 0, false);
+ dev->rf_gain = v4l2_ctrl_new_std(&dev->hdl, &hackrf_ctrl_ops,
+ V4L2_CID_RF_TUNER_RF_GAIN, 0, 12, 12, 0);
dev->lna_gain = v4l2_ctrl_new_std(&dev->hdl, &hackrf_ctrl_ops,
V4L2_CID_RF_TUNER_LNA_GAIN, 0, 40, 8, 0);
dev->if_gain = v4l2_ctrl_new_std(&dev->hdl, &hackrf_ctrl_ops,
--
http://palosaari.fi/
next prev parent reply other threads:[~2015-09-01 21:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-01 21:59 [PATCHv4 00/13] SDR transmitter API Antti Palosaari
2015-09-01 21:59 ` [PATCH 01/13] v4l2: rename V4L2_TUNER_ADC to V4L2_TUNER_SDR Antti Palosaari
2015-09-01 21:59 ` [PATCH 02/13] v4l2: add RF gain control Antti Palosaari
2015-09-01 21:59 ` [PATCH 03/13] DocBook: document tuner " Antti Palosaari
2015-09-01 21:59 ` [PATCH 04/13] v4l2: add support for SDR transmitter Antti Palosaari
2015-09-17 9:47 ` Hans Verkuil
2015-09-01 21:59 ` [PATCH 05/13] DocBook: document " Antti Palosaari
2015-09-01 21:59 ` [PATCH 06/13] v4l: add type field to v4l2_modulator struct Antti Palosaari
2015-09-01 21:59 ` [PATCH 07/13] DocBook: add modulator type field Antti Palosaari
2015-09-04 10:40 ` Hans Verkuil
2015-09-01 21:59 ` Antti Palosaari [this message]
2015-09-01 21:59 ` [PATCH 09/13] hackrf: switch to single function which configures everything Antti Palosaari
2015-09-01 21:59 ` [PATCH 10/13] hackrf: add support for transmitter Antti Palosaari
2015-09-04 10:06 ` Hans Verkuil
2015-10-16 8:53 ` Hans Verkuil
2015-10-16 8:59 ` Antti Palosaari
2015-10-16 9:14 ` Hans Verkuil
2015-09-01 21:59 ` [PATCH 11/13] hackrf: do not set human readable name for formats Antti Palosaari
2015-09-01 21:59 ` [PATCH 12/13] DocBook: add SDR specific info to G_TUNER / S_TUNER Antti Palosaari
2015-09-01 21:59 ` [PATCH 13/13] DocBook: add SDR specific info to G_MODULATOR / S_MODULATOR Antti Palosaari
2015-09-04 10:26 ` Hans Verkuil
2015-09-04 19:24 ` Antti Palosaari
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=1441144769-29211-9-git-send-email-crope@iki.fi \
--to=crope@iki.fi \
--cc=hverkuil@xs4all.nl \
--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;
as well as URLs for NNTP newsgroup(s).