Skip to contentSkip to conversation

SDR API with documentation

RFC PATCH Superseded Antti Palosaari 2 participants 16 messages Dec 20, 2013 – Dec 21, 2013

Subsystems (3)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover SDR API with documentation

Now with documentation and changes from Hans.

Antti Palosaari (11):
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: fix wait.c location
DocBook: document 1 Hz flag
DocBook: Software Defined Radio Interface v4l2-framework.txt: add SDR device type

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

 Documentation/DocBook/device-drivers.tmpl          |  2 +-
 Documentation/DocBook/media/v4l/compat.xml         | 10 +++
 Documentation/DocBook/media/v4l/dev-sdr.xml        | 99 ++++++++++++++++++++++
 Documentation/DocBook/media/v4l/io.xml             |  6 ++
 Documentation/DocBook/media/v4l/v4l2.xml           |  1 +
 .../DocBook/media/v4l/vidioc-enum-freq-bands.xml   |  8 +-
 Documentation/DocBook/media/v4l/vidioc-g-fmt.xml   |  6 ++
 .../DocBook/media/v4l/vidioc-g-frequency.xml       |  3 +-
 .../DocBook/media/v4l/vidioc-g-modulator.xml       |  6 +-
 Documentation/DocBook/media/v4l/vidioc-g-tuner.xml | 15 +++-
 .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml    |  8 +-
 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 ++++
 18 files changed, 270 insertions(+), 28 deletions(-)
 create mode 100644 Documentation/DocBook/media/v4l/dev-sdr.xml
Signature · 1 line
1.8.4.2
#1 lore raw

RFC PATCH v5 1/12 v4l: add device type for Software Defined Radio

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

---
 drivers/media/v4l2-core/v4l2-dev.c | 6 ++++++
 include/media/v4l2-dev.h           | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-dev.c +6 -0
index 1cc1749..a034b4c 100644
@@ -767,6 +767,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)
@@ -806,6 +808,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);
include/media/v4l2-dev.h +2 -1
index c768c9f..eec6e46 100644
@@ -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. */
Signature · 1 line
1.8.4.2
#2 lore raw

RFC PATCH v5 2/12 v4l: add new tuner types for SDR

In reply to Antti Palosaari

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.

---
 drivers/media/v4l2-core/v4l2-ioctl.c | 39 ++++++++++++++++++++++++++----------
 include/uapi/linux/videodev2.h       |  2 ++
 2 files changed, 30 insertions(+), 11 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +28 -11
index 68e6b5e..0397fc6 100644
@@ -1288,8 +1288,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);
 }
 
@@ -1300,10 +1303,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);
 }
 
@@ -1383,6 +1391,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)
@@ -1882,11 +1894,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)) {
include/uapi/linux/videodev2.h +2 -0
index 437f1b0..3fff116 100644
@@ -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 {
Signature · 1 line
1.8.4.2
#3 lore raw

RFC PATCH v5 3/12 v4l: 1 Hz resolution flag for tuners

In reply to Antti Palosaari

Add V4L2_TUNER_CAP_1HZ for 1 Hz resolution.

---
 include/uapi/linux/videodev2.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/videodev2.h +1 -0
index 3fff116..97a5e50 100644
@@ -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
Signature · 1 line
1.8.4.2
#4 lore raw

RFC PATCH v5 4/12 v4l: add stream format for SDR receiver

In reply to Antti Palosaari

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

---
 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(+)
drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
index 0397fc6..be06c21 100644
@@ -149,6 +149,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);
 
include/trace/events/v4l2.h +1 -0
index ef94eca..b9bb1f2 100644
@@ -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)						\
include/uapi/linux/videodev2.h +11 -0
index 97a5e50..c50e449 100644
@@ -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;
 };
Signature · 1 line
1.8.4.2
#5 lore raw

RFC PATCH v5 5/12 v4l: define own IOCTL ops for SDR FMT

In reply to Antti Palosaari

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

---
 include/media/v4l2-ioctl.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/media/v4l2-ioctl.h +8 -0
index e0b74a4..8be32f5 100644
@@ -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);
Signature · 1 line
1.8.4.2
#6 lore raw

RFC PATCH v5 6/12 v4l: enable some IOCTLs for SDR receiver

In reply to Antti Palosaari

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

Reorganise some some IOCTL selection logic.

---
 drivers/media/v4l2-core/v4l2-dev.c   | 21 ++++++++++++++++++---
 drivers/media/v4l2-core/v4l2-ioctl.c | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +18 -3
index a034b4c..84b2a84 100644
@@ -562,7 +562,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;
 
@@ -671,9 +671,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);
@@ -681,6 +692,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);
drivers/media/v4l2-core/v4l2-ioctl.c +35 -0
index be06c21..7bd910b 100644
@@ -243,6 +243,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));
@@ -316,6 +317,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;
 	}
 }
 
@@ -879,6 +888,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;
 
@@ -928,6 +938,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;
 	}
@@ -1047,6 +1061,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;
 }
@@ -1057,6 +1075,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;
 
@@ -1101,6 +1120,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;
 }
@@ -1111,6 +1134,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;
 
@@ -1165,6 +1189,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;
 }
@@ -1175,6 +1204,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;
 
@@ -1229,6 +1259,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;
 }
Signature · 1 line
1.8.4.2
#7 lore raw

RFC PATCH v5 7/12 v4l: add device capability flag for SDR receiver

In reply to Antti Palosaari

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

---
 include/uapi/linux/videodev2.h | 2 ++
 1 file changed, 2 insertions(+)
include/uapi/linux/videodev2.h +2 -0
index c50e449..f596b7b 100644
@@ -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 */
Signature · 1 line
1.8.4.2
#8 lore raw

RFC PATCH v5 8/12 v4l: do not allow modulator ioctls for non-radio devices

In reply to Antti Palosaari

From: Hans Verkuil <[email protected]>

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

---
 drivers/media/v4l2-core/v4l2-dev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +3 -2
index 84b2a84..db76b0a 100644
@@ -562,6 +562,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;
@@ -735,8 +736,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);
 	}
Signature · 1 line
1.8.4.2
#9 lore raw

RFC PATCH v5 9/12 DocBook: fix wait.c location

In reply to Antti Palosaari

Documentation did not compile as wait.c location was wrong.

---
 Documentation/DocBook/device-drivers.tmpl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/DocBook/device-drivers.tmpl +1 -1
index 6c9d9d3..f517008 100644
@@ -58,7 +58,7 @@
      </sect1>
      <sect1><title>Wait queues and Wake events</title>
 !Iinclude/linux/wait.h
-!Ekernel/wait.c
+!Ekernel/sched/wait.c
      </sect1>
      <sect1><title>High-resolution timers</title>
 !Iinclude/linux/ktime.h
Signature · 1 line
1.8.4.2
#10 lore raw

Re: [PATCH RFC v5 09/12] DocBook: fix wait.c location

Hi Antti,

This is already fixed in the mainline kernel, but not yet merged back into our repository. Anyway, you can drop this patch.

Regards,

Hans

Quoted 13 lines · Antti Palosaari

Documentation did not compile as wait.c location was wrong.

---
 Documentation/DocBook/device-drivers.tmpl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/DocBook/device-drivers.tmpl +0 -0
index 6c9d9d3..f517008 100644

Documentation/DocBook/device-drivers.tmpl line 64

Quoted 8 lines
Documentation/DocBook/device-drivers.tmpl +1 -1
@@ -58,7 +58,7 @@
      </sect1>
      <sect1><title>Wait queues and Wake events</title>
 !Iinclude/linux/wait.h
-!Ekernel/wait.c
+!Ekernel/sched/wait.c
      </sect1>
      <sect1><title>High-resolution timers</title>
 !Iinclude/linux/ktime.h

ZZ

#11 lore raw

RFC PATCH v5 10/12 DocBook: document 1 Hz flag

In reply to Antti Palosaari

Update documention to reflect 1 Hz frequency step flag.

---
 .../DocBook/media/v4l/vidioc-enum-freq-bands.xml          |  8 +++++---
 Documentation/DocBook/media/v4l/vidioc-g-frequency.xml    |  3 ++-
 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, 29 insertions(+), 11 deletions(-)
Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml +5 -3
index 6541ba0..e2e866c 100644
@@ -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. 1 Hz unit is used when capabilities 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. 1 Hz unit is used when capabilities flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
Documentation/DocBook/media/v4l/vidioc-g-frequency.xml +2 -1
index c7a1c46..c7bd925 100644
@@ -111,7 +111,8 @@ See <xref linkend="v4l2-tuner-type" /></entry>
 	    <entry>Tuning frequency in units of 62.5 kHz, or if the
 &v4l2-tuner; or &v4l2-modulator; <structfield>capabilities</structfield> flag
 <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
-Hz.</entry>
+Hz. 1 Hz unit is used when capabilities flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
Documentation/DocBook/media/v4l/vidioc-g-modulator.xml +4 -2
index 7f4ac7e..afee56a 100644
@@ -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 unit 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 unit of 1 Hz.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
Documentation/DocBook/media/v4l/vidioc-g-tuner.xml +12 -3
index 6cc8201..6a43719 100644
@@ -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 unit 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 unit 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&nbsp;Hz, otherwise in units of 62.5&nbsp;kHz (or 1 Hz).</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 unit of 1 Hz.</entry>
+	  </row>
 	</tbody>
       </tgroup>
     </table>
Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml +6 -2
index 5b379e7..d0bff5c 100644
@@ -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 unit 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 unit of 1 Hz.
 If <structfield>rangehigh</structfield> is zero a reasonable default value
 is used.</entry>
 	  </row>
Signature · 1 line
1.8.4.2
#12 lore raw

Re: [PATCH RFC v5 10/12] DocBook: document 1 Hz flag

Some small nits:

Quoted 26 lines · Antti Palosaari

Update documention to reflect 1 Hz frequency step flag.

---
 .../DocBook/media/v4l/vidioc-enum-freq-bands.xml          |  8 +++++---
 Documentation/DocBook/media/v4l/vidioc-g-frequency.xml    |  3 ++-
 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, 29 insertions(+), 11 deletions(-)
Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml +1 -1
index 6541ba0..e2e866c 100644
@@ -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>

Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml So either all bands have that capability set, or none of them have that capabili · line 112

Quoted 5 lines
Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml +1 -1
@@ -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. 1 Hz unit is used when capabilities flag

Replace 'capabilities' by '<structfield>capability</structfield>'.

Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml Hz, for this frequency band.</entry> · line 122

Quoted 11 lines
Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml +3 -1
+<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. 1 Hz unit is used when capabilities flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry>

Ditto.

Documentation/DocBook/media/v4l/vidioc-g-frequency.xml See <xref linkend="v4l2-tuner-type" /></entry> · line 112

Quoted 10 lines
Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml +0 -0
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
Documentation/DocBook/media/v4l/vidioc-g-frequency.xml +0 -0
index c7a1c46..c7bd925 100644
@@ -111,7 +111,8 @@ See <xref linkend="v4l2-tuner-type" /></entry>
 	    <entry>Tuning frequency in units of 62.5 kHz, or if the
 &v4l2-tuner; or &v4l2-modulator; <structfield>capabilities</structfield> flag

'capabilities' should be 'capability'. Nobody noticed that the wrong field name was used here :-)

Documentation/DocBook/media/v4l/vidioc-g-frequency.xml See <xref linkend="v4l2-tuner-type" /></entry> · line 115

Quoted 4 lines
Documentation/DocBook/media/v4l/vidioc-g-frequency.xml +2 -1
 <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
-Hz.</entry>
+Hz. 1 Hz unit is used when capabilities flag
+<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry>

Replace 'capabilities' by '<structfield>capability</structfield>'.

Quoted 8 lines
Documentation/DocBook/media/v4l/vidioc-g-frequency.xml +0 -0
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
Documentation/DocBook/media/v4l/vidioc-g-modulator.xml +0 -0
index 7f4ac7e..afee56a 100644

Documentation/DocBook/media/v4l/vidioc-g-modulator.xml change for example with the current video standard.</entry> · line 117

Quoted 6 lines
Documentation/DocBook/media/v4l/vidioc-g-modulator.xml +2 -1
@@ -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 unit of 1 Hz.</entry>

s/unit/units/

Documentation/DocBook/media/v4l/vidioc-g-modulator.xml Hz.</entry> · line 126

Quoted 10 lines
Documentation/DocBook/media/v4l/vidioc-g-modulator.xml +2 -1
 	  </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 unit of 1 Hz.</entry>

Ditto.

Quoted 8 lines
Documentation/DocBook/media/v4l/vidioc-g-modulator.xml +0 -0
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
Documentation/DocBook/media/v4l/vidioc-g-tuner.xml +0 -0
index 6cc8201..6a43719 100644

Documentation/DocBook/media/v4l/vidioc-g-tuner.xml the structure refers to a radio tuner the · line 138

Quoted 6 lines
Documentation/DocBook/media/v4l/vidioc-g-tuner.xml +2 -1
@@ -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 unit of 1 Hz.

Ditto.

Documentation/DocBook/media/v4l/vidioc-g-tuner.xml of all the frequency bands.</entry> · line 150

Quoted 11 lines
Documentation/DocBook/media/v4l/vidioc-g-tuner.xml +3 -1
+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 unit of 1 Hz.

Ditto.

Documentation/DocBook/media/v4l/vidioc-g-tuner.xml applications must set the array to zero.</entry> · line 277

Quoted 10 lines
Documentation/DocBook/media/v4l/vidioc-g-tuner.xml +2 -1
+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&nbsp;Hz, otherwise in units of 62.5&nbsp;kHz (or 1 Hz).</entry>

I would change this to:

"When set, tuning frequencies are expressed in units of 62.5 Hz instead of 62.5 kHz."

Documentation/DocBook/media/v4l/vidioc-g-tuner.xml radio tuners.</entry> · line 370

Quoted 11 lines
Documentation/DocBook/media/v4l/vidioc-g-tuner.xml +4 -0
 	  </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 unit of 1 Hz.</entry>

"When set, tuning frequencies are expressed in units of 1 Hz instead of 62.5 kHz."

Quoted 9 lines
Documentation/DocBook/media/v4l/vidioc-g-tuner.xml +1 -0
+	  </row>
 	</tbody>
       </tgroup>
     </table>
Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml +0 -0
index 5b379e7..d0bff5c 100644

Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml field and the &v4l2-tuner; <structfield>index</structfield> field.</entry> · line 126

Quoted 7 lines
Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml +3 -1
@@ -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 unit of 1 Hz.

s/unit/units/

Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml is used.</entry> · line 138

Quoted 11 lines
Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml +3 -1
 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 unit of 1 Hz.

Ditto.

Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml is used.</entry> · line 141

Quoted 4 lines
Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml +0 -0
 If <structfield>rangehigh</structfield> is zero a reasonable default value
 is used.</entry>
 	  </row>

Regards,

Hans

#13 lore raw

RFC PATCH v5 11/12 DocBook: Software Defined Radio Interface

In reply to Antti Palosaari

Document V4L2 SDR interface.

---
 Documentation/DocBook/media/v4l/compat.xml       | 10 +++
 Documentation/DocBook/media/v4l/dev-sdr.xml      | 99 ++++++++++++++++++++++++
 Documentation/DocBook/media/v4l/io.xml           |  6 ++
 Documentation/DocBook/media/v4l/v4l2.xml         |  1 +
 Documentation/DocBook/media/v4l/vidioc-g-fmt.xml |  6 ++
 5 files changed, 122 insertions(+)
 create mode 100644 Documentation/DocBook/media/v4l/dev-sdr.xml
Documentation/DocBook/media/v4l/compat.xml +10 -0
index 0c7195e..85fb864 100644
@@ -2523,6 +2523,16 @@ that used it. It was originally scheduled for removal in 2.6.35.
       </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>
 
Documentation/DocBook/media/v4l/dev-sdr.xml new file +99 -0

99 lines not on this page · raw message

Documentation/DocBook/media/v4l/io.xml +6 -0
index 2c4c068..1fb11e8 100644
@@ -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>
Documentation/DocBook/media/v4l/v4l2.xml +1 -0
index 8469fe1..a27fcae 100644
@@ -529,6 +529,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>
Documentation/DocBook/media/v4l/vidioc-g-fmt.xml +6 -0
index ee8f56e..60bf9b2 100644
@@ -172,6 +172,12 @@ capture and output devices.</entry>
 	  </row>
 	  <row>
 	    <entry></entry>
+	    <entry>&v4l2-format-sdr;</entry>
+	    <entry><structfield>sdr</structfield></entry>
+	    <entry>Definition of an SDR format.</entry>
+	  </row>
+	  <row>
+	    <entry></entry>
 	    <entry>__u8</entry>
 	    <entry><structfield>raw_data</structfield>[200]</entry>
 	    <entry>Place holder for future extensions.</entry>
Signature · 1 line
1.8.4.2
#14 lore raw

Re: [PATCH RFC v5 11/12] DocBook: Software Defined Radio Interface

More nits...

Quoted 40 lines · Antti Palosaari

Document V4L2 SDR interface.

---
 Documentation/DocBook/media/v4l/compat.xml       | 10 +++
 Documentation/DocBook/media/v4l/dev-sdr.xml      | 99 ++++++++++++++++++++++++
 Documentation/DocBook/media/v4l/io.xml           |  6 ++
 Documentation/DocBook/media/v4l/v4l2.xml         |  1 +
 Documentation/DocBook/media/v4l/vidioc-g-fmt.xml |  6 ++
 5 files changed, 122 insertions(+)
 create mode 100644 Documentation/DocBook/media/v4l/dev-sdr.xml
Documentation/DocBook/media/v4l/compat.xml +10 -0
index 0c7195e..85fb864 100644
@@ -2523,6 +2523,16 @@ that used it. It was originally scheduled for removal in 2.6.35.
       </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>
 
Documentation/DocBook/media/v4l/dev-sdr.xml new file +0 -0
new file mode 100644
index 0000000..3caf44d

Documentation/DocBook/media/v4l/dev-sdr.xml line 5

Quoted 5 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +5 -0
@@ -0,0 +1,99 @@
+  <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. That interface

s/That/This/

Quoted 8 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +8 -0
+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>

Documentation/DocBook/media/v4l/dev-sdr.xml line 23

Quoted 10 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +10 -0
+
+  <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 device has

s/device has/the device has an/

Documentation/DocBook/media/v4l/dev-sdr.xml line 24

Quoted 1 line
Documentation/DocBook/media/v4l/dev-sdr.xml new file +1 -0
+Analog to Digital Converter (ADC), which is mandatory element for SDR receiver.

s/is/is a/
s/SDR/the SDR/

Documentation/DocBook/media/v4l/dev-sdr.xml line 36

Quoted 12 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +12 -0
+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 ADC sampling rate (sampling frequency) and possible RF tuner

s/ADC/the ADC/
s/RF/the RF/

Documentation/DocBook/media/v4l/dev-sdr.xml line 45

Quoted 9 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +9 -0
+frequency.
+    </para>
+
+    <para>
+<constant>V4L2_TUNER_ADC</constant> is used as a tuner type when ADC is in
+question and <constant>V4L2_TUNER_RF</constant> is used as a tuner type when
+RF tuner is in question. Possible RF tuner index number is always next one
+from the ADC index number. Normally ADC tuner is #0 and RF tuner is #1.
+    </para>

I would rewrite this paragraph. How about:

The <constant>V4L2_TUNER_ADC</constant> tuner type is used for ADC tuners, and the <constant>V4L2_TUNER_RF</constant> 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.

Documentation/DocBook/media/v4l/dev-sdr.xml line 48

Quoted 3 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +3 -0
+
+    <para>
+<constant>VIDIOC_S_HW_FREQ_SEEK</constant> ioctl is not supported.

Replace by:

The &VIDIOC-S-HW-FREQ-SEEK; ioctl is not supported.

Documentation/DocBook/media/v4l/dev-sdr.xml line 56

Quoted 8 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +8 -0
+    </para>
+  </section>
+
+  <section>
+    <title>Data Format Negotiation</title>
+
+    <para>
+SDR capture device uses <link linkend="format">format</link> ioctls to select

s/SDR/The SDR/
s/uses/uses the/

Documentation/DocBook/media/v4l/dev-sdr.xml line 57

Quoted 1 line
Documentation/DocBook/media/v4l/dev-sdr.xml new file +1 -0
+capture format. Both sampling resolution and data streaming format are bind

s/capture/the capture/
s/sampling/the sampling/
s/data/the data/
s/bind/bound/

Documentation/DocBook/media/v4l/dev-sdr.xml line 58

Quoted 1 line
Documentation/DocBook/media/v4l/dev-sdr.xml new file +1 -0
+to that selectable format. In addition to basic

s/selectable/selected/
s/basic/the basic/

Documentation/DocBook/media/v4l/dev-sdr.xml line 60

Quoted 2 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +2 -0
+<link linkend="format">format</link> ioctls, the
+<constant>VIDIOC_ENUM_FMT</constant> ioctl must be supported too.

Use '&VIDIOC-ENUM-FMT;' instead.

Documentation/DocBook/media/v4l/dev-sdr.xml line 64

Quoted 4 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +4 -0
+    </para>
+
+    <para>
+To use <link linkend="format">format</link> ioctls applications set the

s/use/use the/

Documentation/DocBook/media/v4l/dev-sdr.xml line 68

Quoted 4 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +4 -0
+<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 desired operation.

s/per/per the/

Documentation/DocBook/media/v4l/dev-sdr.xml line 70

Quoted 2 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +2 -0
+Currently there is only <structfield>pixelformat</structfield> field of
+&v4l2-format-sdr; used. Content of that field is data format V4L2 fourcc code.

Replace with:

"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."

Documentation/DocBook/media/v4l/dev-sdr.xml line 81

Quoted 11 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +11 -0
+    </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>little endian four character code (fourcc)</entry>

That's a bit obscure. Look at Table 2.1 (struct v4l2_pix_format) how pixelformat is described there and copy-and-paste that.

You also need to document the SDR pixelformats that you define.

Documentation/DocBook/media/v4l/dev-sdr.xml line 94

Quoted 13 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +13 -0
+          </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>
+A SDR device may support <link linkend="rw">read/write</link>

s/A/An/ (because you say Es-Dee-Ar :-) )

Quoted 39 lines
Documentation/DocBook/media/v4l/dev-sdr.xml new file +5 -0
+and/or streaming (<link linkend="mmap">memory mapping</link>
+or <link linkend="userp">user pointer</link>) I/O.
+    </para>
+
+  </section>
Documentation/DocBook/media/v4l/io.xml +6 -0
index 2c4c068..1fb11e8 100644
@@ -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>
Documentation/DocBook/media/v4l/v4l2.xml +1 -0
index 8469fe1..a27fcae 100644
@@ -529,6 +529,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>
Documentation/DocBook/media/v4l/vidioc-g-fmt.xml +0 -0
index ee8f56e..60bf9b2 100644

Documentation/DocBook/media/v4l/vidioc-g-fmt.xml capture and output devices.</entry> · line 177

Quoted 6 lines
Documentation/DocBook/media/v4l/vidioc-g-fmt.xml +3 -0
@@ -172,6 +172,12 @@ capture and output devices.</entry>
 	  </row>
 	  <row>
 	    <entry></entry>
+	    <entry>&v4l2-format-sdr;</entry>
+	    <entry><structfield>sdr</structfield></entry>
+	    <entry>Definition of an SDR format.</entry>

Add a link to the sdr section, same as is done for the other structs in the union.

Documentation/DocBook/media/v4l/vidioc-g-fmt.xml capture and output devices.</entry> · line 183

Quoted 7 lines
Documentation/DocBook/media/v4l/vidioc-g-fmt.xml +3 -0
+	  </row>
+	  <row>
+	    <entry></entry>
 	    <entry>__u8</entry>
 	    <entry><structfield>raw_data</structfield>[200]</entry>
 	    <entry>Place holder for future extensions.</entry>

I'm missing the documentation for the new SDR capability flag in querycap.

Regards,

Hans

#15 lore raw

RFC PATCH v5 12/12 v4l2-framework.txt: add SDR device type

In reply to Antti Palosaari

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

---
 Documentation/video4linux/v4l2-framework.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/video4linux/v4l2-framework.txt +1 -0
index 6c4866b..ae3a2cc 100644
@@ -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
Signature · 1 line
1.8.4.2