public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [REVIEW PATCH 00/13] SDR API
@ 2014-01-23 21:08 Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 01/13] v4l: add device type for Software Defined Radio Antti Palosaari
                   ` (12 more replies)
  0 siblings, 13 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari

I think it is ready enough. PULL request will follow in next days...


The next step I	am going to add SDR API is tuner gain controls.

Modern silicon RF tuners used nowadays has many controllable gains
on signal path. Usually there is at least 3 amplifiers:
1) LNA gain. That is first amplifier just after antenna input pins.
2) Mixer gain. Quite middle of the signal path, where RF signal is
down-converted to IF/BB.
3) IF gain. That is last gain in order to adjust output signal
level to optimal level of demodulator.

Each gain controls could be often manual or automatic mode (AGC).
Total gain is something like sum of all gains. My plan is to implement
these 3 gains with manual/auto switch and group all those to one
master/total gain.

Antti

Antti Palosaari (12):
  v4l: add device type for Software Defined Radio
  v4l: add new tuner types for SDR
  v4l: 1 Hz resolution flag for tuners
  v4l: add stream format for SDR receiver
  v4l: define own IOCTL ops for SDR FMT
  v4l: enable some IOCTLs for SDR receiver
  v4l: add device capability flag for SDR receiver
  DocBook: document 1 Hz flag
  DocBook: Software Defined Radio Interface
  DocBook: mark SDR API as Experimental
  v4l2-framework.txt: add SDR device type
  devices.txt: add video4linux device for Software Defined Radio

Hans Verkuil (1):
  v4l: do not allow modulator ioctls for non-radio devices

 Documentation/DocBook/media/v4l/compat.xml         |  13 +++
 Documentation/DocBook/media/v4l/dev-sdr.xml        | 110 +++++++++++++++++++++
 Documentation/DocBook/media/v4l/io.xml             |   6 ++
 Documentation/DocBook/media/v4l/pixfmt.xml         |   8 ++
 Documentation/DocBook/media/v4l/v4l2.xml           |   1 +
 .../DocBook/media/v4l/vidioc-enum-freq-bands.xml   |   8 +-
 Documentation/DocBook/media/v4l/vidioc-g-fmt.xml   |   7 ++
 .../DocBook/media/v4l/vidioc-g-frequency.xml       |   5 +-
 .../DocBook/media/v4l/vidioc-g-modulator.xml       |   6 +-
 Documentation/DocBook/media/v4l/vidioc-g-tuner.xml |  15 ++-
 .../DocBook/media/v4l/vidioc-querycap.xml          |   6 ++
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml    |   8 +-
 Documentation/devices.txt                          |   7 ++
 Documentation/video4linux/v4l2-framework.txt       |   1 +
 drivers/media/v4l2-core/v4l2-dev.c                 |  30 +++++-
 drivers/media/v4l2-core/v4l2-ioctl.c               |  75 +++++++++++---
 include/media/v4l2-dev.h                           |   3 +-
 include/media/v4l2-ioctl.h                         |   8 ++
 include/trace/events/v4l2.h                        |   1 +
 include/uapi/linux/videodev2.h                     |  16 +++
 20 files changed, 306 insertions(+), 28 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/dev-sdr.xml

-- 
1.8.5.3


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 01/13] v4l: add device type for Software Defined Radio
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 02/13] v4l: add new tuner types for SDR Antti Palosaari
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Add new V4L device type VFL_TYPE_SDR for Software Defined Radio.
It is registered as /dev/swradio0 (/dev/sdr0 was already reserved).

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-dev.c | 6 ++++++
 include/media/v4l2-dev.h           | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index b5aaaac..2ccacf2 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -758,6 +758,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
  *	%VFL_TYPE_RADIO - A radio card
  *
  *	%VFL_TYPE_SUBDEV - A subdevice
+ *
+ *	%VFL_TYPE_SDR - Software Defined Radio
  */
 int __video_register_device(struct video_device *vdev, int type, int nr,
 		int warn_if_nr_in_use, struct module *owner)
@@ -797,6 +799,10 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
 	case VFL_TYPE_SUBDEV:
 		name_base = "v4l-subdev";
 		break;
+	case VFL_TYPE_SDR:
+		/* Use device name 'swradio' because 'sdr' was already taken. */
+		name_base = "swradio";
+		break;
 	default:
 		printk(KERN_ERR "%s called with unknown type: %d\n",
 		       __func__, type);
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index c768c9f..eec6e46 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -24,7 +24,8 @@
 #define VFL_TYPE_VBI		1
 #define VFL_TYPE_RADIO		2
 #define VFL_TYPE_SUBDEV		3
-#define VFL_TYPE_MAX		4
+#define VFL_TYPE_SDR		4
+#define VFL_TYPE_MAX		5
 
 /* Is this a receiver, transmitter or mem-to-mem? */
 /* Ignored for VFL_TYPE_SUBDEV. */
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 02/13] v4l: add new tuner types for SDR
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 01/13] v4l: add device type for Software Defined Radio Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 03/13] v4l: 1 Hz resolution flag for tuners Antti Palosaari
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Define tuner types V4L2_TUNER_ADC and V4L2_TUNER_RF for SDR usage.

ADC is used for setting sampling rate (sampling frequency) to SDR
device.

Another tuner type, named as V4L2_TUNER_RF, is possible RF tuner.
Is is used to down-convert RF frequency to range ADC could sample.
Having RF tuner is optional, whilst in practice it is almost always
there.

Also add checks to VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY and
VIDIOC_ENUM_FREQ_BANDS only allow these two tuner types when device
type is SDR (VFL_TYPE_SDR). For VIDIOC_G_FREQUENCY we do not check
tuner type, instead override type with V4L2_TUNER_ADC in every
case (requested by Hans in order to keep functionality in line with
existing tuners and existing API does not specify it).

Prohibit VIDIOC_S_HW_FREQ_SEEK explicitly when device type is SDR,
as device cannot do hardware seek without a hardware demodulator.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 39 ++++++++++++++++++++++++++----------
 include/uapi/linux/videodev2.h       |  2 ++
 2 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 707aef7..15ab349 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1291,8 +1291,11 @@ static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops,
 	struct video_device *vfd = video_devdata(file);
 	struct v4l2_frequency *p = arg;
 
-	p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
-			V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
+	if (vfd->vfl_type == VFL_TYPE_SDR)
+		p->type = V4L2_TUNER_ADC;
+	else
+		p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
+				V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
 	return ops->vidioc_g_frequency(file, fh, p);
 }
 
@@ -1303,10 +1306,15 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,
 	const struct v4l2_frequency *p = arg;
 	enum v4l2_tuner_type type;
 
-	type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
-			V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
-	if (p->type != type)
-		return -EINVAL;
+	if (vfd->vfl_type == VFL_TYPE_SDR) {
+		if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF)
+			return -EINVAL;
+	} else {
+		type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
+				V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
+		if (type != p->type)
+			return -EINVAL;
+	}
 	return ops->vidioc_s_frequency(file, fh, p);
 }
 
@@ -1386,6 +1394,10 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops,
 	struct v4l2_hw_freq_seek *p = arg;
 	enum v4l2_tuner_type type;
 
+	/* s_hw_freq_seek is not supported for SDR for now */
+	if (vfd->vfl_type == VFL_TYPE_SDR)
+		return -EINVAL;
+
 	type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
 		V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
 	if (p->type != type)
@@ -1885,11 +1897,16 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,
 	enum v4l2_tuner_type type;
 	int err;
 
-	type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
-			V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
-
-	if (type != p->type)
-		return -EINVAL;
+	if (vfd->vfl_type == VFL_TYPE_SDR) {
+		if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF)
+			return -EINVAL;
+		type = p->type;
+	} else {
+		type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
+				V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
+		if (type != p->type)
+			return -EINVAL;
+	}
 	if (ops->vidioc_enum_freq_bands)
 		return ops->vidioc_enum_freq_bands(file, fh, p);
 	if (is_valid_ioctl(vfd, VIDIOC_G_TUNER)) {
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 6ae7bbe..9dc79d1 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -159,6 +159,8 @@ enum v4l2_tuner_type {
 	V4L2_TUNER_RADIO	     = 1,
 	V4L2_TUNER_ANALOG_TV	     = 2,
 	V4L2_TUNER_DIGITAL_TV	     = 3,
+	V4L2_TUNER_ADC               = 4,
+	V4L2_TUNER_RF                = 5,
 };
 
 enum v4l2_memory {
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 03/13] v4l: 1 Hz resolution flag for tuners
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 01/13] v4l: add device type for Software Defined Radio Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 02/13] v4l: add new tuner types for SDR Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 04/13] v4l: add stream format for SDR receiver Antti Palosaari
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Add V4L2_TUNER_CAP_1HZ for 1 Hz resolution.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 include/uapi/linux/videodev2.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 9dc79d1..1cf2076 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1341,6 +1341,7 @@ struct v4l2_modulator {
 #define V4L2_TUNER_CAP_RDS_CONTROLS	0x0200
 #define V4L2_TUNER_CAP_FREQ_BANDS	0x0400
 #define V4L2_TUNER_CAP_HWSEEK_PROG_LIM	0x0800
+#define V4L2_TUNER_CAP_1HZ		0x1000
 
 /*  Flags for the 'rxsubchans' field */
 #define V4L2_TUNER_SUB_MONO		0x0001
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 04/13] v4l: add stream format for SDR receiver
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
                   ` (2 preceding siblings ...)
  2014-01-23 21:08 ` [REVIEW PATCH 03/13] v4l: 1 Hz resolution flag for tuners Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 05/13] v4l: define own IOCTL ops for SDR FMT Antti Palosaari
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Add new V4L2 stream format definition, V4L2_BUF_TYPE_SDR_CAPTURE,
for SDR receiver.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c |  1 +
 include/trace/events/v4l2.h          |  1 +
 include/uapi/linux/videodev2.h       | 11 +++++++++++
 3 files changed, 13 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 15ab349..9a2acaf 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -152,6 +152,7 @@ const char *v4l2_type_names[] = {
 	[V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "vid-out-overlay",
 	[V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE] = "vid-cap-mplane",
 	[V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE] = "vid-out-mplane",
+	[V4L2_BUF_TYPE_SDR_CAPTURE]        = "sdr-cap",
 };
 EXPORT_SYMBOL(v4l2_type_names);
 
diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
index ef94eca..b9bb1f2 100644
--- a/include/trace/events/v4l2.h
+++ b/include/trace/events/v4l2.h
@@ -18,6 +18,7 @@
 		{ V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" },\
 		{ V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" },\
 		{ V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,  "VIDEO_OUTPUT_MPLANE" }, \
+		{ V4L2_BUF_TYPE_SDR_CAPTURE,          "SDR_CAPTURE" },         \
 		{ V4L2_BUF_TYPE_PRIVATE,	      "PRIVATE" })
 
 #define show_field(field)						\
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 1cf2076..27bed7c 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -139,6 +139,7 @@ enum v4l2_buf_type {
 #endif
 	V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
 	V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE  = 10,
+	V4L2_BUF_TYPE_SDR_CAPTURE          = 11,
 	/* Deprecated, do not use */
 	V4L2_BUF_TYPE_PRIVATE              = 0x80,
 };
@@ -1695,6 +1696,15 @@ struct v4l2_pix_format_mplane {
 } __attribute__ ((packed));
 
 /**
+ * struct v4l2_format_sdr - SDR format definition
+ * @pixelformat:	little endian four character code (fourcc)
+ */
+struct v4l2_format_sdr {
+	__u32				pixelformat;
+	__u8				reserved[28];
+} __attribute__ ((packed));
+
+/**
  * struct v4l2_format - stream data format
  * @type:	enum v4l2_buf_type; type of the data stream
  * @pix:	definition of an image format
@@ -1712,6 +1722,7 @@ struct v4l2_format {
 		struct v4l2_window		win;     /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
 		struct v4l2_vbi_format		vbi;     /* V4L2_BUF_TYPE_VBI_CAPTURE */
 		struct v4l2_sliced_vbi_format	sliced;  /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
+		struct v4l2_format_sdr		sdr;     /* V4L2_BUF_TYPE_SDR_CAPTURE */
 		__u8	raw_data[200];                   /* user-defined */
 	} fmt;
 };
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 05/13] v4l: define own IOCTL ops for SDR FMT
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
                   ` (3 preceding siblings ...)
  2014-01-23 21:08 ` [REVIEW PATCH 04/13] v4l: add stream format for SDR receiver Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 06/13] v4l: enable some IOCTLs for SDR receiver Antti Palosaari
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Use own format ops for SDR data:
vidioc_enum_fmt_sdr_cap
vidioc_g_fmt_sdr_cap
vidioc_s_fmt_sdr_cap
vidioc_try_fmt_sdr_cap

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 include/media/v4l2-ioctl.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index e0b74a4..8be32f5 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -40,6 +40,8 @@ struct v4l2_ioctl_ops {
 					      struct v4l2_fmtdesc *f);
 	int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh,
 					      struct v4l2_fmtdesc *f);
+	int (*vidioc_enum_fmt_sdr_cap)     (struct file *file, void *fh,
+					    struct v4l2_fmtdesc *f);
 
 	/* VIDIOC_G_FMT handlers */
 	int (*vidioc_g_fmt_vid_cap)    (struct file *file, void *fh,
@@ -62,6 +64,8 @@ struct v4l2_ioctl_ops {
 					   struct v4l2_format *f);
 	int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
 					   struct v4l2_format *f);
+	int (*vidioc_g_fmt_sdr_cap)    (struct file *file, void *fh,
+					struct v4l2_format *f);
 
 	/* VIDIOC_S_FMT handlers */
 	int (*vidioc_s_fmt_vid_cap)    (struct file *file, void *fh,
@@ -84,6 +88,8 @@ struct v4l2_ioctl_ops {
 					   struct v4l2_format *f);
 	int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
 					   struct v4l2_format *f);
+	int (*vidioc_s_fmt_sdr_cap)    (struct file *file, void *fh,
+					struct v4l2_format *f);
 
 	/* VIDIOC_TRY_FMT handlers */
 	int (*vidioc_try_fmt_vid_cap)    (struct file *file, void *fh,
@@ -106,6 +112,8 @@ struct v4l2_ioctl_ops {
 					     struct v4l2_format *f);
 	int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
 					     struct v4l2_format *f);
+	int (*vidioc_try_fmt_sdr_cap)    (struct file *file, void *fh,
+					  struct v4l2_format *f);
 
 	/* Buffer handlers */
 	int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 06/13] v4l: enable some IOCTLs for SDR receiver
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
                   ` (4 preceding siblings ...)
  2014-01-23 21:08 ` [REVIEW PATCH 05/13] v4l: define own IOCTL ops for SDR FMT Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 07/13] v4l: add device capability flag " Antti Palosaari
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Enable stream format (FMT) IOCTLs for SDR use. These are used for negotiate
used data stream format.

Reorganise some some IOCTL selection logic.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
---
 drivers/media/v4l2-core/v4l2-dev.c   | 21 ++++++++++++++++++---
 drivers/media/v4l2-core/v4l2-ioctl.c | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 2ccacf2..6308a19 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -553,7 +553,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
 	const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops;
 	bool is_vid = vdev->vfl_type == VFL_TYPE_GRABBER;
 	bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI;
-	bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO;
+	bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR;
 	bool is_rx = vdev->vfl_dir != VFL_DIR_TX;
 	bool is_tx = vdev->vfl_dir != VFL_DIR_RX;
 
@@ -662,9 +662,20 @@ static void determine_valid_ioctls(struct video_device *vdev)
 			       ops->vidioc_try_fmt_sliced_vbi_out)))
 			set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
 		SET_VALID_IOCTL(ops, VIDIOC_G_SLICED_VBI_CAP, vidioc_g_sliced_vbi_cap);
+	} else if (is_sdr) {
+		/* SDR specific ioctls */
+		if (ops->vidioc_enum_fmt_sdr_cap)
+			set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
+		if (ops->vidioc_g_fmt_sdr_cap)
+			set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
+		if (ops->vidioc_s_fmt_sdr_cap)
+			set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
+		if (ops->vidioc_try_fmt_sdr_cap)
+			set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
 	}
-	if (!is_radio) {
-		/* ioctls valid for video or vbi */
+
+	if (is_vid || is_vbi || is_sdr) {
+		/* ioctls valid for video, vbi or sdr */
 		SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
 		SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
 		SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf);
@@ -672,6 +683,10 @@ static void determine_valid_ioctls(struct video_device *vdev)
 		SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf);
 		SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs);
 		SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf);
+	}
+
+	if (is_vid || is_vbi) {
+		/* ioctls valid for video or vbi */
 		if (ops->vidioc_s_std)
 			set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls);
 		SET_VALID_IOCTL(ops, VIDIOC_S_STD, vidioc_s_std);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 9a2acaf..95dd4f1 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -246,6 +246,7 @@ static void v4l_print_format(const void *arg, bool write_only)
 	const struct v4l2_vbi_format *vbi;
 	const struct v4l2_sliced_vbi_format *sliced;
 	const struct v4l2_window *win;
+	const struct v4l2_format_sdr *sdr;
 	unsigned i;
 
 	pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
@@ -319,6 +320,14 @@ static void v4l_print_format(const void *arg, bool write_only)
 				sliced->service_lines[0][i],
 				sliced->service_lines[1][i]);
 		break;
+	case V4L2_BUF_TYPE_SDR_CAPTURE:
+		sdr = &p->fmt.sdr;
+		pr_cont(", pixelformat=%c%c%c%c\n",
+			(sdr->pixelformat >>  0) & 0xff,
+			(sdr->pixelformat >>  8) & 0xff,
+			(sdr->pixelformat >> 16) & 0xff,
+			(sdr->pixelformat >> 24) & 0xff);
+		break;
 	}
 }
 
@@ -882,6 +891,7 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
 	const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
 	bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
 	bool is_vbi = vfd->vfl_type == VFL_TYPE_VBI;
+	bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
 	bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
 	bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
 
@@ -931,6 +941,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
 		if (is_vbi && is_tx && ops->vidioc_g_fmt_sliced_vbi_out)
 			return 0;
 		break;
+	case V4L2_BUF_TYPE_SDR_CAPTURE:
+		if (is_sdr && is_rx && ops->vidioc_g_fmt_sdr_cap)
+			return 0;
+		break;
 	default:
 		break;
 	}
@@ -1050,6 +1064,10 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
 		if (unlikely(!is_tx || !ops->vidioc_enum_fmt_vid_out_mplane))
 			break;
 		return ops->vidioc_enum_fmt_vid_out_mplane(file, fh, arg);
+	case V4L2_BUF_TYPE_SDR_CAPTURE:
+		if (unlikely(!is_rx || !ops->vidioc_enum_fmt_sdr_cap))
+			break;
+		return ops->vidioc_enum_fmt_sdr_cap(file, fh, arg);
 	}
 	return -EINVAL;
 }
@@ -1060,6 +1078,7 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
 	struct v4l2_format *p = arg;
 	struct video_device *vfd = video_devdata(file);
 	bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
+	bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
 	bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
 	bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
 
@@ -1104,6 +1123,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
 		if (unlikely(!is_tx || is_vid || !ops->vidioc_g_fmt_sliced_vbi_out))
 			break;
 		return ops->vidioc_g_fmt_sliced_vbi_out(file, fh, arg);
+	case V4L2_BUF_TYPE_SDR_CAPTURE:
+		if (unlikely(!is_rx || !is_sdr || !ops->vidioc_g_fmt_sdr_cap))
+			break;
+		return ops->vidioc_g_fmt_sdr_cap(file, fh, arg);
 	}
 	return -EINVAL;
 }
@@ -1114,6 +1137,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
 	struct v4l2_format *p = arg;
 	struct video_device *vfd = video_devdata(file);
 	bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
+	bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
 	bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
 	bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
 
@@ -1168,6 +1192,11 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
 			break;
 		CLEAR_AFTER_FIELD(p, fmt.sliced);
 		return ops->vidioc_s_fmt_sliced_vbi_out(file, fh, arg);
+	case V4L2_BUF_TYPE_SDR_CAPTURE:
+		if (unlikely(!is_rx || !is_sdr || !ops->vidioc_s_fmt_sdr_cap))
+			break;
+		CLEAR_AFTER_FIELD(p, fmt.sdr);
+		return ops->vidioc_s_fmt_sdr_cap(file, fh, arg);
 	}
 	return -EINVAL;
 }
@@ -1178,6 +1207,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
 	struct v4l2_format *p = arg;
 	struct video_device *vfd = video_devdata(file);
 	bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
+	bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
 	bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
 	bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
 
@@ -1232,6 +1262,11 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
 			break;
 		CLEAR_AFTER_FIELD(p, fmt.sliced);
 		return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg);
+	case V4L2_BUF_TYPE_SDR_CAPTURE:
+		if (unlikely(!is_rx || !is_sdr || !ops->vidioc_try_fmt_sdr_cap))
+			break;
+		CLEAR_AFTER_FIELD(p, fmt.sdr);
+		return ops->vidioc_try_fmt_sdr_cap(file, fh, arg);
 	}
 	return -EINVAL;
 }
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 07/13] v4l: add device capability flag for SDR receiver
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
                   ` (5 preceding siblings ...)
  2014-01-23 21:08 ` [REVIEW PATCH 06/13] v4l: enable some IOCTLs for SDR receiver Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 08/13] v4l: do not allow modulator ioctls for non-radio devices Antti Palosaari
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

VIDIOC_QUERYCAP IOCTL is used to query device capabilities. Add new
capability flag to inform given device supports SDR capture.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
---
 include/uapi/linux/videodev2.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 27bed7c..27fedfe 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -267,6 +267,8 @@ struct v4l2_capability {
 #define V4L2_CAP_RADIO			0x00040000  /* is a radio device */
 #define V4L2_CAP_MODULATOR		0x00080000  /* has a modulator */
 
+#define V4L2_CAP_SDR_CAPTURE		0x00100000  /* Is a SDR capture device */
+
 #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */
 #define V4L2_CAP_ASYNCIO                0x02000000  /* async I/O */
 #define V4L2_CAP_STREAMING              0x04000000  /* streaming I/O ioctls */
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 08/13] v4l: do not allow modulator ioctls for non-radio devices
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
                   ` (6 preceding siblings ...)
  2014-01-23 21:08 ` [REVIEW PATCH 07/13] v4l: add device capability flag " Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 09/13] DocBook: document 1 Hz flag Antti Palosaari
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Hans Verkuil, Antti Palosaari

From: Hans Verkuil <hverkuil@xs4all.nl>

Modulator ioctls could be enabled mistakenly for non-radio devices.
Currently those ioctls are only valid for radio. Fix it.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 drivers/media/v4l2-core/v4l2-dev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 6308a19..9adde0f 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -553,6 +553,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
 	const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops;
 	bool is_vid = vdev->vfl_type == VFL_TYPE_GRABBER;
 	bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI;
+	bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO;
 	bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR;
 	bool is_rx = vdev->vfl_dir != VFL_DIR_TX;
 	bool is_tx = vdev->vfl_dir != VFL_DIR_RX;
@@ -726,8 +727,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
 		SET_VALID_IOCTL(ops, VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings);
 		SET_VALID_IOCTL(ops, VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap);
 	}
-	if (is_tx) {
-		/* transmitter only ioctls */
+	if (is_tx && (is_radio || is_sdr)) {
+		/* radio transmitter only ioctls */
 		SET_VALID_IOCTL(ops, VIDIOC_G_MODULATOR, vidioc_g_modulator);
 		SET_VALID_IOCTL(ops, VIDIOC_S_MODULATOR, vidioc_s_modulator);
 	}
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 09/13] DocBook: document 1 Hz flag
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
                   ` (7 preceding siblings ...)
  2014-01-23 21:08 ` [REVIEW PATCH 08/13] v4l: do not allow modulator ioctls for non-radio devices Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 10/13] DocBook: Software Defined Radio Interface Antti Palosaari
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Update documentation to reflect 1 Hz frequency step flag.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 .../DocBook/media/v4l/vidioc-enum-freq-bands.xml          |  8 +++++---
 Documentation/DocBook/media/v4l/vidioc-g-frequency.xml    |  5 +++--
 Documentation/DocBook/media/v4l/vidioc-g-modulator.xml    |  6 ++++--
 Documentation/DocBook/media/v4l/vidioc-g-tuner.xml        | 15 ++++++++++++---
 Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml |  8 ++++++--
 5 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml b/Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml
index 6541ba0..4e8ea65 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml
@@ -100,7 +100,7 @@ See <xref linkend="v4l2-tuner-type" /></entry>
 	    <entry><structfield>capability</structfield></entry>
 	    <entry spanname="hspan">The tuner/modulator capability flags for
 this frequency band, see <xref linkend="tuner-capability" />. The <constant>V4L2_TUNER_CAP_LOW</constant>
-capability must be the same for all frequency bands of the selected tuner/modulator.
+or <constant>V4L2_TUNER_CAP_1HZ</constant> capability must be the same for all frequency bands of the selected tuner/modulator.
 So either all bands have that capability set, or none of them have that capability.</entry>
 	  </row>
 	  <row>
@@ -109,7 +109,8 @@ So either all bands have that capability set, or none of them have that capabili
 	    <entry spanname="hspan">The lowest tunable frequency in
 units of 62.5 kHz, or if the <structfield>capability</structfield>
 flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
-Hz, for this frequency band.</entry>
+Hz, for this frequency band. A 1 Hz unit is used when the <structfield>capability</structfield> flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
@@ -117,7 +118,8 @@ Hz, for this frequency band.</entry>
 	    <entry spanname="hspan">The highest tunable frequency in
 units of 62.5 kHz, or if the <structfield>capability</structfield>
 flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
-Hz, for this frequency band.</entry>
+Hz, for this frequency band. A 1 Hz unit is used when the <structfield>capability</structfield> flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml b/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml
index c7a1c46..d1034fb 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml
@@ -109,9 +109,10 @@ See <xref linkend="v4l2-tuner-type" /></entry>
 	    <entry>__u32</entry>
 	    <entry><structfield>frequency</structfield></entry>
 	    <entry>Tuning frequency in units of 62.5 kHz, or if the
-&v4l2-tuner; or &v4l2-modulator; <structfield>capabilities</structfield> flag
+&v4l2-tuner; or &v4l2-modulator; <structfield>capability</structfield> flag
 <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
-Hz.</entry>
+Hz. A 1 Hz unit is used when the <structfield>capability</structfield> flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml b/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml
index 7f4ac7e..7068b59 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml
@@ -113,7 +113,8 @@ change for example with the current video standard.</entry>
 	    <entry>The lowest tunable frequency in units of 62.5
 KHz, or if the <structfield>capability</structfield> flag
 <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
-Hz.</entry>
+Hz, or if the <structfield>capability</structfield> flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
@@ -121,7 +122,8 @@ Hz.</entry>
 	    <entry>The highest tunable frequency in units of 62.5
 KHz, or if the <structfield>capability</structfield> flag
 <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
-Hz.</entry>
+Hz, or if the <structfield>capability</structfield> flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml b/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml
index 6cc8201..b0d8659 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml
@@ -134,7 +134,9 @@ the structure refers to a radio tuner the
 	    <entry spanname="hspan">The lowest tunable frequency in
 units of 62.5 kHz, or if the <structfield>capability</structfield>
 flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
-Hz. If multiple frequency bands are supported, then
+Hz, or if the <structfield>capability</structfield> flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz.
+If multiple frequency bands are supported, then
 <structfield>rangelow</structfield> is the lowest frequency
 of all the frequency bands.</entry>
 	  </row>
@@ -144,7 +146,9 @@ of all the frequency bands.</entry>
 	    <entry spanname="hspan">The highest tunable frequency in
 units of 62.5 kHz, or if the <structfield>capability</structfield>
 flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
-Hz. If multiple frequency bands are supported, then
+Hz, or if the <structfield>capability</structfield> flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz.
+If multiple frequency bands are supported, then
 <structfield>rangehigh</structfield> is the highest frequency
 of all the frequency bands.</entry>
 	  </row>
@@ -270,7 +274,7 @@ applications must set the array to zero.</entry>
 	    <entry><constant>V4L2_TUNER_CAP_LOW</constant></entry>
 	    <entry>0x0001</entry>
 	    <entry>When set, tuning frequencies are expressed in units of
-62.5&nbsp;Hz, otherwise in units of 62.5&nbsp;kHz.</entry>
+62.5 Hz instead of 62.5 kHz.</entry>
 	  </row>
 	  <row>
 	    <entry><constant>V4L2_TUNER_CAP_NORM</constant></entry>
@@ -360,6 +364,11 @@ radio tuners.</entry>
 	<entry>The range to search when using the hardware seek functionality
 	is programmable, see &VIDIOC-S-HW-FREQ-SEEK; for details.</entry>
 	  </row>
+	  <row>
+	<entry><constant>V4L2_TUNER_CAP_1HZ</constant></entry>
+	<entry>0x1000</entry>
+	<entry>When set, tuning frequencies are expressed in units of 1 Hz instead of 62.5 kHz.</entry>
+	  </row>
 	</tbody>
       </tgroup>
     </table>
diff --git a/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml b/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml
index 5b379e7..a5fc4c4 100644
--- a/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml
@@ -121,7 +121,9 @@ field and the &v4l2-tuner; <structfield>index</structfield> field.</entry>
 	    <entry>If non-zero, the lowest tunable frequency of the band to
 search in units of 62.5 kHz, or if the &v4l2-tuner;
 <structfield>capability</structfield> field has the
-<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz.
+<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz or if the &v4l2-tuner;
+<structfield>capability</structfield> field has the
+<constant>V4L2_TUNER_CAP_1HZ</constant> flag set, in units of 1 Hz.
 If <structfield>rangelow</structfield> is zero a reasonable default value
 is used.</entry>
 	  </row>
@@ -131,7 +133,9 @@ is used.</entry>
 	    <entry>If non-zero, the highest tunable frequency of the band to
 search in units of 62.5 kHz, or if the &v4l2-tuner;
 <structfield>capability</structfield> field has the
-<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz.
+<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz or if the &v4l2-tuner;
+<structfield>capability</structfield> field has the
+<constant>V4L2_TUNER_CAP_1HZ</constant> flag set, in units of 1 Hz.
 If <structfield>rangehigh</structfield> is zero a reasonable default value
 is used.</entry>
 	  </row>
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 10/13] DocBook: Software Defined Radio Interface
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
                   ` (8 preceding siblings ...)
  2014-01-23 21:08 ` [REVIEW PATCH 09/13] DocBook: document 1 Hz flag Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-25  8:26   ` Hans Verkuil
  2014-01-23 21:08 ` [REVIEW PATCH 11/13] DocBook: mark SDR API as Experimental Antti Palosaari
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Document V4L2 SDR interface.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 Documentation/DocBook/media/v4l/compat.xml         |  10 ++
 Documentation/DocBook/media/v4l/dev-sdr.xml        | 104 +++++++++++++++++++++
 Documentation/DocBook/media/v4l/io.xml             |   6 ++
 Documentation/DocBook/media/v4l/pixfmt.xml         |   8 ++
 Documentation/DocBook/media/v4l/v4l2.xml           |   1 +
 Documentation/DocBook/media/v4l/vidioc-g-fmt.xml   |   7 ++
 .../DocBook/media/v4l/vidioc-querycap.xml          |   6 ++
 7 files changed, 142 insertions(+)
 create mode 100644 Documentation/DocBook/media/v4l/dev-sdr.xml

diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
index c4cac6d..83f64ce 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2535,6 +2535,16 @@ fields changed from _s32 to _u32.
       </orderedlist>
     </section>
 
+    <section>
+      <title>V4L2 in Linux 3.14</title>
+      <orderedlist>
+        <listitem>
+	  <para>Added Software Defined Radio (SDR) Interface.
+	  </para>
+        </listitem>
+      </orderedlist>
+    </section>
+
     <section id="other">
       <title>Relation of V4L2 to other Linux multimedia APIs</title>
 
diff --git a/Documentation/DocBook/media/v4l/dev-sdr.xml b/Documentation/DocBook/media/v4l/dev-sdr.xml
new file mode 100644
index 0000000..332b87f
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/dev-sdr.xml
@@ -0,0 +1,104 @@
+  <title>Software Defined Radio Interface (SDR)</title>
+
+  <para>
+SDR is an abbreviation of Software Defined Radio, the radio device
+which uses application software for modulation or demodulation. This interface
+is intended for controlling and data streaming of such devices.
+  </para>
+
+  <para>
+SDR devices are accessed through character device special files named
+<filename>/dev/swradio0</filename> to <filename>/dev/swradio255</filename>
+with major number 81 and dynamically allocated minor numbers 0 to 255.
+  </para>
+
+  <section>
+    <title>Querying Capabilities</title>
+
+    <para>
+Devices supporting the SDR receiver interface set the
+<constant>V4L2_CAP_SDR_CAPTURE</constant> and
+<constant>V4L2_CAP_TUNER</constant> flag in the
+<structfield>capabilities</structfield> field of &v4l2-capability;
+returned by the &VIDIOC-QUERYCAP; ioctl. That flag means the device has an
+Analog to Digital Converter (ADC), which is a mandatory element for the SDR receiver.
+At least one of the read/write, streaming or asynchronous I/O methods must
+be supported.
+    </para>
+  </section>
+
+  <section>
+    <title>Supplemental Functions</title>
+
+    <para>
+SDR devices can support <link linkend="control">controls</link>, and must
+support the <link linkend="tuner">tuner</link> ioctls. Tuner ioctls are used
+for setting the ADC sampling rate (sampling frequency) and the possible RF tuner
+frequency.
+    </para>
+
+    <para>
+The <constant>V4L2_TUNER_ADC</constant> tuner type is used for ADC tuners, and
+the <constant>V4L2_TUNER_RF</constant> tuner type is used for RF tuners. The
+tuner index of the RF tuner (if any) must always follow the ADC tuner index.
+Normally the ADC tuner is #0 and the RF tuner is #1.
+    </para>
+
+    <para>
+The &VIDIOC-S-HW-FREQ-SEEK; ioctl is not supported.
+    </para>
+  </section>
+
+  <section>
+    <title>Data Format Negotiation</title>
+
+    <para>
+The SDR capture device uses the <link linkend="format">format</link> ioctls to
+select the capture format. Both the sampling resolution and the data streaming
+format are bound to that selectable format. In addition to the basic
+<link linkend="format">format</link> ioctls, the &VIDIOC-ENUM-FMT; ioctl
+must be supported as well.
+    </para>
+
+    <para>
+To use the <link linkend="format">format</link> ioctls applications set the
+<structfield>type</structfield> field of a &v4l2-format; to
+<constant>V4L2_BUF_TYPE_SDR_CAPTURE</constant> and use the &v4l2-format-sdr;
+<structfield>sdr</structfield> member of the <structfield>fmt</structfield>
+union as needed per the desired operation.
+Currently only the <structfield>pixelformat</structfield> field of
+&v4l2-format-sdr; is used. The content of that field is the V4L2 fourcc code
+of the data format.
+    </para>
+
+    <table pgwide="1" frame="none" id="v4l2-format-sdr">
+      <title>struct <structname>v4l2_format_sdr</structname></title>
+      <tgroup cols="3">
+        &cs-str;
+        <tbody valign="top">
+          <row>
+            <entry>__u32</entry>
+            <entry><structfield>pixelformat</structfield></entry>
+            <entry>
+The data format or type of compression, set by the application. This is a
+little endian <link linkend="v4l2-fourcc">four character code</link>.
+V4L2 defines SDR formats in <xref linkend="sdr-formats" />.
+           </entry>
+          </row>
+          <row>
+            <entry>__u8</entry>
+            <entry><structfield>reserved[28]</structfield></entry>
+            <entry>This array is reserved for future extensions.
+Drivers and applications must set it to zero.</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+
+    <para>
+An SDR device may support <link linkend="rw">read/write</link>
+and/or streaming (<link linkend="mmap">memory mapping</link>
+or <link linkend="userp">user pointer</link>) I/O.
+    </para>
+
+  </section>
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index 2c4c068..1fb11e8 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -1005,6 +1005,12 @@ should set this to 0.</entry>
 	    <entry>Buffer for video output overlay (OSD), see <xref
 		linkend="osd" />.</entry>
 	  </row>
+	  <row>
+	    <entry><constant>V4L2_BUF_TYPE_SDR_CAPTURE</constant></entry>
+	    <entry>11</entry>
+	    <entry>Buffer for Software Defined Radio (SDR), see <xref
+		linkend="sdr" />.</entry>
+	  </row>
 	</tbody>
       </tgroup>
     </table>
diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml b/Documentation/DocBook/media/v4l/pixfmt.xml
index 72d72bd..f586d34 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -811,6 +811,14 @@ extended control <constant>V4L2_CID_MPEG_STREAM_TYPE</constant>, see
     </table>
   </section>
 
+  <section id="sdr-formats">
+    <title>SDR Formats</title>
+
+    <para>These formats are used for <link linkend="sdr">SDR Capture</link>
+interface only.</para>
+
+  </section>
+
   <section id="pixfmt-reserved">
     <title>Reserved Format Identifiers</title>
 
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
index 74b7f27..6dd899c 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -537,6 +537,7 @@ and discussions on the V4L mailing list.</revremark>
     <section id="ttx"> &sub-dev-teletext; </section>
     <section id="radio"> &sub-dev-radio; </section>
     <section id="rds"> &sub-dev-rds; </section>
+    <section id="sdr"> &sub-dev-sdr; </section>
     <section id="event"> &sub-dev-event; </section>
     <section id="subdev"> &sub-dev-subdev; </section>
   </chapter>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
index ee8f56e..ffed137 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
@@ -172,6 +172,13 @@ capture and output devices.</entry>
 	  </row>
 	  <row>
 	    <entry></entry>
+	    <entry>&v4l2-format-sdr;</entry>
+	    <entry><structfield>sdr</structfield></entry>
+	    <entry>Definition of an data format, see
+<xref linkend="pixfmt" />, used by SDR capture devices.</entry>
+	  </row>
+	  <row>
+	    <entry></entry>
 	    <entry>__u8</entry>
 	    <entry><structfield>raw_data</structfield>[200]</entry>
 	    <entry>Place holder for future extensions.</entry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-querycap.xml b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
index d5a3c97..370d49d 100644
--- a/Documentation/DocBook/media/v4l/vidioc-querycap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
@@ -296,6 +296,12 @@ modulator programming see
 <xref linkend="tuner" />.</entry>
 	  </row>
 	  <row>
+	    <entry><constant>V4L2_CAP_SDR_CAPTURE</constant></entry>
+	    <entry>0x00100000</entry>
+	    <entry>The device supports the
+<link linkend="sdr">SDR Capture</link> interface.</entry>
+	  </row>
+	  <row>
 	    <entry><constant>V4L2_CAP_READWRITE</constant></entry>
 	    <entry>0x01000000</entry>
 	    <entry>The device supports the <link
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 11/13] DocBook: mark SDR API as Experimental
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
                   ` (9 preceding siblings ...)
  2014-01-23 21:08 ` [REVIEW PATCH 10/13] DocBook: Software Defined Radio Interface Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-25  8:27   ` Hans Verkuil
  2014-01-23 21:08 ` [REVIEW PATCH 12/13] v4l2-framework.txt: add SDR device type Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 13/13] devices.txt: add video4linux device for Software Defined Radio Antti Palosaari
  12 siblings, 1 reply; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Let it be experimental still as all SDR drivers are in staging.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 Documentation/DocBook/media/v4l/compat.xml  | 3 +++
 Documentation/DocBook/media/v4l/dev-sdr.xml | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
index 83f64ce..2fb2b8d 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2661,6 +2661,9 @@ ioctls.</para>
         <listitem>
 	  <para>Exporting DMABUF files using &VIDIOC-EXPBUF; ioctl.</para>
         </listitem>
+        <listitem>
+	  <para>Software Defined Radio (SDR) Interface, <xref linkend="sdr" />.</para>
+        </listitem>
       </itemizedlist>
     </section>
 
diff --git a/Documentation/DocBook/media/v4l/dev-sdr.xml b/Documentation/DocBook/media/v4l/dev-sdr.xml
index 332b87f..ac9f1af 100644
--- a/Documentation/DocBook/media/v4l/dev-sdr.xml
+++ b/Documentation/DocBook/media/v4l/dev-sdr.xml
@@ -1,5 +1,11 @@
   <title>Software Defined Radio Interface (SDR)</title>
 
+  <note>
+    <title>Experimental</title>
+    <para>This is an <link linkend="experimental"> experimental </link>
+    interface and may change in the future.</para>
+  </note>
+
   <para>
 SDR is an abbreviation of Software Defined Radio, the radio device
 which uses application software for modulation or demodulation. This interface
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 12/13] v4l2-framework.txt: add SDR device type
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
                   ` (10 preceding siblings ...)
  2014-01-23 21:08 ` [REVIEW PATCH 11/13] DocBook: mark SDR API as Experimental Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-23 21:08 ` [REVIEW PATCH 13/13] devices.txt: add video4linux device for Software Defined Radio Antti Palosaari
  12 siblings, 0 replies; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Add SDR device type to v4l2-framework.txt document.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 Documentation/video4linux/v4l2-framework.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index 6c4866b..ae3a2cc 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -768,6 +768,7 @@ types exist:
 VFL_TYPE_GRABBER: videoX for video input/output devices
 VFL_TYPE_VBI: vbiX for vertical blank data (i.e. closed captions, teletext)
 VFL_TYPE_RADIO: radioX for radio tuners
+VFL_TYPE_SDR: swradioX for Software Defined Radio tuners
 
 The last argument gives you a certain amount of control over the device
 device node number used (i.e. the X in videoX). Normally you will pass -1
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [REVIEW PATCH 13/13] devices.txt: add video4linux device for Software Defined Radio
  2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
                   ` (11 preceding siblings ...)
  2014-01-23 21:08 ` [REVIEW PATCH 12/13] v4l2-framework.txt: add SDR device type Antti Palosaari
@ 2014-01-23 21:08 ` Antti Palosaari
  2014-01-25  8:27   ` Hans Verkuil
  12 siblings, 1 reply; 19+ messages in thread
From: Antti Palosaari @ 2014-01-23 21:08 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Hans Verkuil

Add new video4linux device named /dev/swradio for Software Defined
Radio use. V4L device minor numbers are allocated dynamically
nowadays, but there is still configuration option for old fixed style.
Add note to mention that configuration option too.

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 Documentation/devices.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index 80b7241..e852855 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -1490,10 +1490,17 @@ Your cooperation is appreciated.
 		 64 = /dev/radio0	Radio device
 		    ...
 		127 = /dev/radio63	Radio device
+		128 = /dev/swradio0	Software Defined Radio device
+		    ...
+		191 = /dev/swradio63	Software Defined Radio device
 		224 = /dev/vbi0		Vertical blank interrupt
 		    ...
 		255 = /dev/vbi31	Vertical blank interrupt
 
+		Minor numbers are allocated dynamically unless
+		CONFIG_VIDEO_FIXED_MINOR_RANGES (default n)
+		configuration option is set.
+
  81 block	I2O hard disk
 		  0 = /dev/i2o/hdq	17th I2O hard disk, whole disk
 		 16 = /dev/i2o/hdr	18th I2O hard disk, whole disk
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [REVIEW PATCH 10/13] DocBook: Software Defined Radio Interface
  2014-01-23 21:08 ` [REVIEW PATCH 10/13] DocBook: Software Defined Radio Interface Antti Palosaari
@ 2014-01-25  8:26   ` Hans Verkuil
  2014-01-25 13:01     ` Antti Palosaari
  0 siblings, 1 reply; 19+ messages in thread
From: Hans Verkuil @ 2014-01-25  8:26 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

A few comments below...

On 01/23/2014 10:08 PM, Antti Palosaari wrote:
> Document V4L2 SDR interface.
> 
> Cc: Hans Verkuil <hverkuil@xs4all.nl>
> Signed-off-by: Antti Palosaari <crope@iki.fi>
> ---
>  Documentation/DocBook/media/v4l/compat.xml         |  10 ++
>  Documentation/DocBook/media/v4l/dev-sdr.xml        | 104 +++++++++++++++++++++
>  Documentation/DocBook/media/v4l/io.xml             |   6 ++
>  Documentation/DocBook/media/v4l/pixfmt.xml         |   8 ++
>  Documentation/DocBook/media/v4l/v4l2.xml           |   1 +
>  Documentation/DocBook/media/v4l/vidioc-g-fmt.xml   |   7 ++
>  .../DocBook/media/v4l/vidioc-querycap.xml          |   6 ++
>  7 files changed, 142 insertions(+)
>  create mode 100644 Documentation/DocBook/media/v4l/dev-sdr.xml
> 
> diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
> index c4cac6d..83f64ce 100644
> --- a/Documentation/DocBook/media/v4l/compat.xml
> +++ b/Documentation/DocBook/media/v4l/compat.xml
> @@ -2535,6 +2535,16 @@ fields changed from _s32 to _u32.
>        </orderedlist>
>      </section>
>  
> +    <section>
> +      <title>V4L2 in Linux 3.14</title>

This should be 3.15.

> +      <orderedlist>
> +        <listitem>
> +	  <para>Added Software Defined Radio (SDR) Interface.
> +	  </para>
> +        </listitem>
> +      </orderedlist>
> +    </section>
> +
>      <section id="other">
>        <title>Relation of V4L2 to other Linux multimedia APIs</title>
>  
> diff --git a/Documentation/DocBook/media/v4l/dev-sdr.xml b/Documentation/DocBook/media/v4l/dev-sdr.xml
> new file mode 100644
> index 0000000..332b87f
> --- /dev/null
> +++ b/Documentation/DocBook/media/v4l/dev-sdr.xml
> @@ -0,0 +1,104 @@
> +  <title>Software Defined Radio Interface (SDR)</title>
> +
> +  <para>
> +SDR is an abbreviation of Software Defined Radio, the radio device
> +which uses application software for modulation or demodulation. This interface
> +is intended for controlling and data streaming of such devices.
> +  </para>
> +
> +  <para>
> +SDR devices are accessed through character device special files named
> +<filename>/dev/swradio0</filename> to <filename>/dev/swradio255</filename>
> +with major number 81 and dynamically allocated minor numbers 0 to 255.
> +  </para>
> +
> +  <section>
> +    <title>Querying Capabilities</title>
> +
> +    <para>
> +Devices supporting the SDR receiver interface set the
> +<constant>V4L2_CAP_SDR_CAPTURE</constant> and
> +<constant>V4L2_CAP_TUNER</constant> flag in the
> +<structfield>capabilities</structfield> field of &v4l2-capability;
> +returned by the &VIDIOC-QUERYCAP; ioctl. That flag means the device has an
> +Analog to Digital Converter (ADC), which is a mandatory element for the SDR receiver.
> +At least one of the read/write, streaming or asynchronous I/O methods must
> +be supported.
> +    </para>
> +  </section>
> +
> +  <section>
> +    <title>Supplemental Functions</title>
> +
> +    <para>
> +SDR devices can support <link linkend="control">controls</link>, and must
> +support the <link linkend="tuner">tuner</link> ioctls. Tuner ioctls are used
> +for setting the ADC sampling rate (sampling frequency) and the possible RF tuner
> +frequency.
> +    </para>
> +
> +    <para>
> +The <constant>V4L2_TUNER_ADC</constant> tuner type is used for ADC tuners, and
> +the <constant>V4L2_TUNER_RF</constant> tuner type is used for RF tuners. The
> +tuner index of the RF tuner (if any) must always follow the ADC tuner index.
> +Normally the ADC tuner is #0 and the RF tuner is #1.
> +    </para>
> +
> +    <para>
> +The &VIDIOC-S-HW-FREQ-SEEK; ioctl is not supported.
> +    </para>
> +  </section>
> +
> +  <section>
> +    <title>Data Format Negotiation</title>
> +
> +    <para>
> +The SDR capture device uses the <link linkend="format">format</link> ioctls to
> +select the capture format. Both the sampling resolution and the data streaming

I understand why the data streaming format is bound to the format, but why is
the sampling resolution bound by it as well?

> +format are bound to that selectable format. In addition to the basic
> +<link linkend="format">format</link> ioctls, the &VIDIOC-ENUM-FMT; ioctl
> +must be supported as well.
> +    </para>
> +
> +    <para>
> +To use the <link linkend="format">format</link> ioctls applications set the
> +<structfield>type</structfield> field of a &v4l2-format; to
> +<constant>V4L2_BUF_TYPE_SDR_CAPTURE</constant> and use the &v4l2-format-sdr;
> +<structfield>sdr</structfield> member of the <structfield>fmt</structfield>
> +union as needed per the desired operation.
> +Currently only the <structfield>pixelformat</structfield> field of
> +&v4l2-format-sdr; is used. The content of that field is the V4L2 fourcc code
> +of the data format.
> +    </para>
> +
> +    <table pgwide="1" frame="none" id="v4l2-format-sdr">
> +      <title>struct <structname>v4l2_format_sdr</structname></title>
> +      <tgroup cols="3">
> +        &cs-str;
> +        <tbody valign="top">
> +          <row>
> +            <entry>__u32</entry>
> +            <entry><structfield>pixelformat</structfield></entry>
> +            <entry>
> +The data format or type of compression, set by the application. This is a
> +little endian <link linkend="v4l2-fourcc">four character code</link>.
> +V4L2 defines SDR formats in <xref linkend="sdr-formats" />.
> +           </entry>
> +          </row>
> +          <row>
> +            <entry>__u8</entry>
> +            <entry><structfield>reserved[28]</structfield></entry>
> +            <entry>This array is reserved for future extensions.
> +Drivers and applications must set it to zero.</entry>
> +          </row>
> +        </tbody>
> +      </tgroup>
> +    </table>
> +
> +    <para>
> +An SDR device may support <link linkend="rw">read/write</link>
> +and/or streaming (<link linkend="mmap">memory mapping</link>
> +or <link linkend="userp">user pointer</link>) I/O.
> +    </para>
> +
> +  </section>
> diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
> index 2c4c068..1fb11e8 100644
> --- a/Documentation/DocBook/media/v4l/io.xml
> +++ b/Documentation/DocBook/media/v4l/io.xml
> @@ -1005,6 +1005,12 @@ should set this to 0.</entry>
>  	    <entry>Buffer for video output overlay (OSD), see <xref
>  		linkend="osd" />.</entry>
>  	  </row>
> +	  <row>
> +	    <entry><constant>V4L2_BUF_TYPE_SDR_CAPTURE</constant></entry>
> +	    <entry>11</entry>
> +	    <entry>Buffer for Software Defined Radio (SDR), see <xref
> +		linkend="sdr" />.</entry>
> +	  </row>
>  	</tbody>
>        </tgroup>
>      </table>
> diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml b/Documentation/DocBook/media/v4l/pixfmt.xml
> index 72d72bd..f586d34 100644
> --- a/Documentation/DocBook/media/v4l/pixfmt.xml
> +++ b/Documentation/DocBook/media/v4l/pixfmt.xml
> @@ -811,6 +811,14 @@ extended control <constant>V4L2_CID_MPEG_STREAM_TYPE</constant>, see
>      </table>
>    </section>
>  
> +  <section id="sdr-formats">
> +    <title>SDR Formats</title>
> +
> +    <para>These formats are used for <link linkend="sdr">SDR Capture</link>
> +interface only.</para>
> +
> +  </section>
> +
>    <section id="pixfmt-reserved">
>      <title>Reserved Format Identifiers</title>
>  
> diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
> index 74b7f27..6dd899c 100644
> --- a/Documentation/DocBook/media/v4l/v4l2.xml
> +++ b/Documentation/DocBook/media/v4l/v4l2.xml
> @@ -537,6 +537,7 @@ and discussions on the V4L mailing list.</revremark>
>      <section id="ttx"> &sub-dev-teletext; </section>
>      <section id="radio"> &sub-dev-radio; </section>
>      <section id="rds"> &sub-dev-rds; </section>
> +    <section id="sdr"> &sub-dev-sdr; </section>
>      <section id="event"> &sub-dev-event; </section>
>      <section id="subdev"> &sub-dev-subdev; </section>
>    </chapter>
> diff --git a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
> index ee8f56e..ffed137 100644
> --- a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
> +++ b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
> @@ -172,6 +172,13 @@ capture and output devices.</entry>
>  	  </row>
>  	  <row>
>  	    <entry></entry>
> +	    <entry>&v4l2-format-sdr;</entry>
> +	    <entry><structfield>sdr</structfield></entry>
> +	    <entry>Definition of an data format, see

s/an data/a data/

> +<xref linkend="pixfmt" />, used by SDR capture devices.</entry>
> +	  </row>
> +	  <row>
> +	    <entry></entry>
>  	    <entry>__u8</entry>
>  	    <entry><structfield>raw_data</structfield>[200]</entry>
>  	    <entry>Place holder for future extensions.</entry>
> diff --git a/Documentation/DocBook/media/v4l/vidioc-querycap.xml b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
> index d5a3c97..370d49d 100644
> --- a/Documentation/DocBook/media/v4l/vidioc-querycap.xml
> +++ b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
> @@ -296,6 +296,12 @@ modulator programming see
>  <xref linkend="tuner" />.</entry>
>  	  </row>
>  	  <row>
> +	    <entry><constant>V4L2_CAP_SDR_CAPTURE</constant></entry>
> +	    <entry>0x00100000</entry>
> +	    <entry>The device supports the
> +<link linkend="sdr">SDR Capture</link> interface.</entry>
> +	  </row>
> +	  <row>
>  	    <entry><constant>V4L2_CAP_READWRITE</constant></entry>
>  	    <entry>0x01000000</entry>
>  	    <entry>The device supports the <link
> 

Regards,

	Hans

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [REVIEW PATCH 11/13] DocBook: mark SDR API as Experimental
  2014-01-23 21:08 ` [REVIEW PATCH 11/13] DocBook: mark SDR API as Experimental Antti Palosaari
@ 2014-01-25  8:27   ` Hans Verkuil
  0 siblings, 0 replies; 19+ messages in thread
From: Hans Verkuil @ 2014-01-25  8:27 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

On 01/23/2014 10:08 PM, Antti Palosaari wrote:
> Let it be experimental still as all SDR drivers are in staging.
> 
> Cc: Hans Verkuil <hverkuil@xs4all.nl>
> Signed-off-by: Antti Palosaari <crope@iki.fi>
> ---
>  Documentation/DocBook/media/v4l/compat.xml  | 3 +++
>  Documentation/DocBook/media/v4l/dev-sdr.xml | 6 ++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
> index 83f64ce..2fb2b8d 100644
> --- a/Documentation/DocBook/media/v4l/compat.xml
> +++ b/Documentation/DocBook/media/v4l/compat.xml
> @@ -2661,6 +2661,9 @@ ioctls.</para>
>          <listitem>
>  	  <para>Exporting DMABUF files using &VIDIOC-EXPBUF; ioctl.</para>
>          </listitem>
> +        <listitem>
> +	  <para>Software Defined Radio (SDR) Interface, <xref linkend="sdr" />.</para>
> +        </listitem>
>        </itemizedlist>
>      </section>
>  
> diff --git a/Documentation/DocBook/media/v4l/dev-sdr.xml b/Documentation/DocBook/media/v4l/dev-sdr.xml
> index 332b87f..ac9f1af 100644
> --- a/Documentation/DocBook/media/v4l/dev-sdr.xml
> +++ b/Documentation/DocBook/media/v4l/dev-sdr.xml
> @@ -1,5 +1,11 @@
>    <title>Software Defined Radio Interface (SDR)</title>
>  
> +  <note>
> +    <title>Experimental</title>
> +    <para>This is an <link linkend="experimental"> experimental </link>
> +    interface and may change in the future.</para>
> +  </note>
> +
>    <para>
>  SDR is an abbreviation of Software Defined Radio, the radio device
>  which uses application software for modulation or demodulation. This interface
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [REVIEW PATCH 13/13] devices.txt: add video4linux device for Software Defined Radio
  2014-01-23 21:08 ` [REVIEW PATCH 13/13] devices.txt: add video4linux device for Software Defined Radio Antti Palosaari
@ 2014-01-25  8:27   ` Hans Verkuil
  0 siblings, 0 replies; 19+ messages in thread
From: Hans Verkuil @ 2014-01-25  8:27 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

On 01/23/2014 10:08 PM, Antti Palosaari wrote:
> Add new video4linux device named /dev/swradio for Software Defined
> Radio use. V4L device minor numbers are allocated dynamically
> nowadays, but there is still configuration option for old fixed style.
> Add note to mention that configuration option too.
> 
> Cc: Hans Verkuil <hverkuil@xs4all.nl>
> Signed-off-by: Antti Palosaari <crope@iki.fi>
> ---
>  Documentation/devices.txt | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/Documentation/devices.txt b/Documentation/devices.txt
> index 80b7241..e852855 100644
> --- a/Documentation/devices.txt
> +++ b/Documentation/devices.txt
> @@ -1490,10 +1490,17 @@ Your cooperation is appreciated.
>  		 64 = /dev/radio0	Radio device
>  		    ...
>  		127 = /dev/radio63	Radio device
> +		128 = /dev/swradio0	Software Defined Radio device
> +		    ...
> +		191 = /dev/swradio63	Software Defined Radio device
>  		224 = /dev/vbi0		Vertical blank interrupt
>  		    ...
>  		255 = /dev/vbi31	Vertical blank interrupt
>  
> +		Minor numbers are allocated dynamically unless
> +		CONFIG_VIDEO_FIXED_MINOR_RANGES (default n)
> +		configuration option is set.
> +
>   81 block	I2O hard disk
>  		  0 = /dev/i2o/hdq	17th I2O hard disk, whole disk
>  		 16 = /dev/i2o/hdr	18th I2O hard disk, whole disk
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [REVIEW PATCH 10/13] DocBook: Software Defined Radio Interface
  2014-01-25  8:26   ` Hans Verkuil
@ 2014-01-25 13:01     ` Antti Palosaari
  2014-01-25 13:44       ` Hans Verkuil
  0 siblings, 1 reply; 19+ messages in thread
From: Antti Palosaari @ 2014-01-25 13:01 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media

On 25.01.2014 10:26, Hans Verkuil wrote:
> A few comments below...
>
> On 01/23/2014 10:08 PM, Antti Palosaari wrote:
>> Document V4L2 SDR interface.
>>
>> Cc: Hans Verkuil <hverkuil@xs4all.nl>
>> Signed-off-by: Antti Palosaari <crope@iki.fi>

>> +    <section>
>> +      <title>V4L2 in Linux 3.14</title>
>
> This should be 3.15.

OK. The goal was that 3.14 but fixing that documentation has taken over 
month.


>> +
>> +    <para>
>> +The SDR capture device uses the <link linkend="format">format</link> ioctls to
>> +select the capture format. Both the sampling resolution and the data streaming
>
> I understand why the data streaming format is bound to the format, but why is
> the sampling resolution bound by it as well?

How can I explain that... it is not always bind to format nor it could 
be known 100% from sure from format. But resolution has some deep 
relation to format. Data is usually packed to smallest reasonable size 
in order to minimize needed transmission bandwidth. If you change 
sampling resolution then format likely changes too, as greater 
resolution needs more bits per sample and format carries samples. Lets 
take a some simple example:

Lets take an examples:
A is 8-bit sample, number from range 0-255.
B is 16-bit sample, number from range 0-65536.

Then your formats are defined, lets say V4L_FMT_SDR_U8 and V4L_FMT_SDR_U16.

Streams are sequence of those samples, use 10 samples here as example:
A0A1A2A3A4A5A6A7A8A9 = 80bits, 10 bytes
B0B1B2B3B4B5B6B7B8B9 = 160bits, 20 bytes

But you still don't know surely what is sampling resolution, only how it 
is represented. It is always more or less than that nominal value, die 
to many reasons. ADC datasheets usually define ENOB (effective number of 
bits) value. It is fairly common having 12bit resolution but ENOB is 
only around 10bit.

Here is example from Mirics, which shows different formats and resolutions:

format,resolution,sample rate (~max)
252    14         8613281
336    12        11484375
384    10+2      13125000 (packed, 2 bits dropped using some formula)
504    8         17226562

All in all, the idea was to tell user that the sampling resolution is 
selected according to dataformat he uses.


>> --- a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
>> +++ b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
>> @@ -172,6 +172,13 @@ capture and output devices.</entry>
>>   	  </row>
>>   	  <row>
>>   	    <entry></entry>
>> +	    <entry>&v4l2-format-sdr;</entry>
>> +	    <entry><structfield>sdr</structfield></entry>
>> +	    <entry>Definition of an data format, see
>
> s/an data/a data/

OK


regards
Antti

-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [REVIEW PATCH 10/13] DocBook: Software Defined Radio Interface
  2014-01-25 13:01     ` Antti Palosaari
@ 2014-01-25 13:44       ` Hans Verkuil
  0 siblings, 0 replies; 19+ messages in thread
From: Hans Verkuil @ 2014-01-25 13:44 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media



On 01/25/2014 02:01 PM, Antti Palosaari wrote:
> On 25.01.2014 10:26, Hans Verkuil wrote:
>> A few comments below...
>>
>> On 01/23/2014 10:08 PM, Antti Palosaari wrote:
>>> Document V4L2 SDR interface.
>>>
>>> Cc: Hans Verkuil <hverkuil@xs4all.nl>
>>> Signed-off-by: Antti Palosaari <crope@iki.fi>
> 
>>> +    <section>
>>> +      <title>V4L2 in Linux 3.14</title>
>>
>> This should be 3.15.
> 
> OK. The goal was that 3.14 but fixing that documentation has taken over month.
> 
> 
>>> +
>>> +    <para>
>>> +The SDR capture device uses the <link linkend="format">format</link> ioctls to
>>> +select the capture format. Both the sampling resolution and the data streaming
>>
>> I understand why the data streaming format is bound to the format, but why is
>> the sampling resolution bound by it as well?
> 
> How can I explain that... it is not always bind to format nor it could be known 100% from sure from format. But resolution has some deep relation to format. Data is usually packed to smallest reasonable size in order to minimize needed transmission bandwidth. If you change sampling resolution then format likely changes too, as greater resolution needs more bits per sample and format carries samples. Lets take a some simple example:
> 
> Lets take an examples:
> A is 8-bit sample, number from range 0-255.
> B is 16-bit sample, number from range 0-65536.
> 
> Then your formats are defined, lets say V4L_FMT_SDR_U8 and V4L_FMT_SDR_U16.
> 
> Streams are sequence of those samples, use 10 samples here as example:
> A0A1A2A3A4A5A6A7A8A9 = 80bits, 10 bytes
> B0B1B2B3B4B5B6B7B8B9 = 160bits, 20 bytes
> 
> But you still don't know surely what is sampling resolution, only how it is represented. It is always more or less than that nominal value, die to many reasons. ADC datasheets usually define ENOB (effective number of bits) value. It is fairly common having 12bit resolution but ENOB is only around 10bit.
> 
> Here is example from Mirics, which shows different formats and resolutions:
> 
> format,resolution,sample rate (~max)
> 252    14         8613281
> 336    12        11484375
> 384    10+2      13125000 (packed, 2 bits dropped using some formula)
> 504    8         17226562
> 
> All in all, the idea was to tell user that the sampling resolution is selected according to dataformat he uses.

I'm sorry for having you work so hard on explaining this when the problem was with
my brain that confused 'resolution' with 'rate' :-) Well, they both start with 'r'...

Your text is fine.

> 
> 
>>> --- a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
>>> +++ b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
>>> @@ -172,6 +172,13 @@ capture and output devices.</entry>
>>>         </row>
>>>         <row>
>>>           <entry></entry>
>>> +        <entry>&v4l2-format-sdr;</entry>
>>> +        <entry><structfield>sdr</structfield></entry>
>>> +        <entry>Definition of an data format, see
>>
>> s/an data/a data/
> 
> OK
> 
> 
> regards
> Antti
> 

Regards,

	Hans

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-01-25 13:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-23 21:08 [REVIEW PATCH 00/13] SDR API Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 01/13] v4l: add device type for Software Defined Radio Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 02/13] v4l: add new tuner types for SDR Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 03/13] v4l: 1 Hz resolution flag for tuners Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 04/13] v4l: add stream format for SDR receiver Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 05/13] v4l: define own IOCTL ops for SDR FMT Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 06/13] v4l: enable some IOCTLs for SDR receiver Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 07/13] v4l: add device capability flag " Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 08/13] v4l: do not allow modulator ioctls for non-radio devices Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 09/13] DocBook: document 1 Hz flag Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 10/13] DocBook: Software Defined Radio Interface Antti Palosaari
2014-01-25  8:26   ` Hans Verkuil
2014-01-25 13:01     ` Antti Palosaari
2014-01-25 13:44       ` Hans Verkuil
2014-01-23 21:08 ` [REVIEW PATCH 11/13] DocBook: mark SDR API as Experimental Antti Palosaari
2014-01-25  8:27   ` Hans Verkuil
2014-01-23 21:08 ` [REVIEW PATCH 12/13] v4l2-framework.txt: add SDR device type Antti Palosaari
2014-01-23 21:08 ` [REVIEW PATCH 13/13] devices.txt: add video4linux device for Software Defined Radio Antti Palosaari
2014-01-25  8:27   ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox