Skip to contentSkip to conversation

v4l2-ctl: add SDR device support

PATCH In review Antti Palosaari 2 participants 11 messages Feb 9, 2014 – Feb 10, 2014 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

cover v4l2-ctl: add SDR device support

That is here too:
http://git.linuxtv.org/anttip/v4l-utils.git/shortlog/refs/heads/sdr

I will pull request it soon.

regards
Antti

Antti Palosaari (4):
synch videodev2.h headers with kernel SDR API
v4l2-ctl: add tuner support for SDR tuners
v4l2-ctl: add support for SDR FMT
v4l2-ctl: implement list SDR buffers command

Mauro Carvalho Chehab (1):
libdvbv5: better handle ATSC/Annex B

 contrib/freebsd/include/linux/videodev2.h |  16 +++++
 include/linux/videodev2.h                 |  16 +++++
 lib/libdvbv5/dvb-file.c                   |  33 +++++++++-
 utils/v4l2-ctl/Makefile.am                |   2 +-
 utils/v4l2-ctl/v4l2-ctl-common.cpp        |   1 +
 utils/v4l2-ctl/v4l2-ctl-sdr.cpp           | 104 ++++++++++++++++++++++++++++++
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp     |   6 ++
 utils/v4l2-ctl/v4l2-ctl-tuner.cpp         |  53 ++++++++++++---
 utils/v4l2-ctl/v4l2-ctl.cpp               |  23 +++++++
 utils/v4l2-ctl/v4l2-ctl.h                 |  13 ++++
 10 files changed, 255 insertions(+), 12 deletions(-)
 create mode 100644 utils/v4l2-ctl/v4l2-ctl-sdr.cpp
Signature · 1 line
1.8.5.3
#1 lore raw

PATCH 1/5 libdvbv5: better handle ATSC/Annex B

From: Mauro Carvalho Chehab <[email protected]>

As DVBv3 is confusing with regards to ATSC and ClearQAM (DVB-C annex B), userpace apps also only differenciate between ATSC and ClearQAM via modulation.

However, when using DVBv5, may be using the delivery system in order to enforce one or the other.

In any case, the DVB API should clearly identify between ATSC and ClearQAM.

So, make the API to better handle it, fixing the delivery system if needed, when reading or write a file.

---
 lib/libdvbv5/dvb-file.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
lib/libdvbv5/dvb-file.c +32 -1
index 1c33a90..e0cef34 100644
@@ -88,6 +88,32 @@ int retrieve_entry_prop(struct dvb_entry *entry,
 	return -1;
 }
 
+static void adjust_delsys(struct dvb_entry *entry)
+{
+	uint32_t delsys = SYS_UNDEFINED;
+
+	retrieve_entry_prop(entry, DTV_DELIVERY_SYSTEM, &delsys);
+	switch (delsys) {
+	case SYS_ATSC:
+	case SYS_DVBC_ANNEX_B: {
+		uint32_t modulation = VSB_8;
+
+		retrieve_entry_prop(entry, DTV_MODULATION, &modulation);
+		switch (modulation) {
+		case VSB_8:
+		case VSB_16:
+			delsys = SYS_ATSC;
+			break;
+		default:
+			delsys = SYS_DVBC_ANNEX_B;
+			break;
+		}
+		store_entry_prop(entry, DTV_DELIVERY_SYSTEM, delsys);
+		break;
+	}
+	} /* switch */
+}
+
 /*
  * Generic parse function for all formats each channel is contained into
  * just one line.
@@ -242,7 +268,7 @@ struct dvb_file *parse_format_oneline(const char *fname,
 			entry->props[entry->n_props].cmd = DTV_INVERSION;
 			entry->props[entry->n_props++].u.data = INVERSION_AUTO;
 		}
-
+		adjust_delsys(entry);
 	} while (1);
 	fclose(fd);
 	free(buf);
@@ -330,6 +356,7 @@ int write_format_oneline(const char *fname,
 				 delsys);
 			goto error;
 		}
+		adjust_delsys(entry);
 		if (parse_file->has_delsys_id) {
 			fprintf(fp, "%s", formats[i].id);
 			first = 0;
@@ -596,6 +623,7 @@ struct dvb_file *read_dvb_file(const char *fname)
 				dvb_file->first_entry = calloc(sizeof(*entry), 1);
 				entry = dvb_file->first_entry;
 			} else {
+				adjust_delsys(entry);
 				entry->next = calloc(sizeof(*entry), 1);
 				entry = entry->next;
 			}
@@ -644,6 +672,8 @@ struct dvb_file *read_dvb_file(const char *fname)
 			}
 		}
 	} while (1);
+	if (entry)
+		adjust_delsys(entry);
 	fclose(fd);
 	return dvb_file;
 
@@ -668,6 +698,7 @@ int write_dvb_file(const char *fname, struct dvb_file *dvb_file)
 	}
 
 	for (entry = dvb_file->first_entry; entry != NULL; entry = entry->next) {
+		adjust_delsys(entry);
 		if (entry->channel) {
 			fprintf(fp, "[%s]\n", entry->channel);
 			if (entry->vchannel)
Signature · 1 line
1.8.5.3
#2 lore raw

PATCH 2/5 synch videodev2.h headers with kernel SDR API

In reply to Antti Palosaari
---
 contrib/freebsd/include/linux/videodev2.h | 16 ++++++++++++++++
 include/linux/videodev2.h                 | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)
contrib/freebsd/include/linux/videodev2.h +16 -0
index 5c75762..6d49f97 100644
@@ -173,6 +173,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,
 };
@@ -193,6 +194,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 {
@@ -298,6 +301,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 */
@@ -1373,6 +1378,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
@@ -1726,6 +1732,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 {
+	uint32_t				pixelformat;
+	uint8_t				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
@@ -1743,6 +1758,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 */
 		uint8_t	raw_data[200];                   /* user-defined */
 	} fmt;
 };
include/linux/videodev2.h +16 -0
index 6ae7bbe..27fedfe 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,
 };
@@ -159,6 +160,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 {
@@ -264,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 */
@@ -1339,6 +1344,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
@@ -1692,6 +1698,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
@@ -1709,6 +1724,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.5.3
#3 lore raw

Re: [PATCH 2/5] synch videodev2.h headers with kernel SDR API

Hi Antti,

I'm not sure if you know this, but to sync with a new kernel you use 'make sync-with-kernel'. Not a problem here, I'll do that anyway once the SDR API is merged.

Regards,

Hans

Quoted 132 lines · Antti Palosaari
---
 contrib/freebsd/include/linux/videodev2.h | 16 ++++++++++++++++
 include/linux/videodev2.h                 | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)
contrib/freebsd/include/linux/videodev2.h +16 -0
index 5c75762..6d49f97 100644
@@ -173,6 +173,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,
 };
@@ -193,6 +194,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 {
@@ -298,6 +301,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 */
@@ -1373,6 +1378,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
@@ -1726,6 +1732,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 {
+	uint32_t				pixelformat;
+	uint8_t				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
@@ -1743,6 +1758,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 */
 		uint8_t	raw_data[200];                   /* user-defined */
 	} fmt;
 };
include/linux/videodev2.h +16 -0
index 6ae7bbe..27fedfe 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,
 };
@@ -159,6 +160,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 {
@@ -264,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 */
@@ -1339,6 +1344,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
@@ -1692,6 +1698,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
@@ -1709,6 +1724,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;
 };
#4 lore raw

Re: [PATCH 2/5] synch videodev2.h headers with kernel SDR API

Moro Hans,

Quoted 5 lines · Hans Verkuil

Hi Antti,

I'm not sure if you know this, but to sync with a new kernel you use 'make sync-with-kernel'. Not a problem here, I'll do that anyway once the SDR API is merged.

No prob, I didn't know, just updated manually.

regards
Antti

Signature · 1 line
http://palosaari.fi/
#5 lore raw

PATCH 3/5 v4l2-ctl: add tuner support for SDR tuners

In reply to Antti Palosaari

Add initial SDR support for tuner related operations.

---
 utils/v4l2-ctl/v4l2-ctl-tuner.cpp | 53 +++++++++++++++++++++++++++++++--------
 1 file changed, 43 insertions(+), 10 deletions(-)
utils/v4l2-ctl/v4l2-ctl-tuner.cpp +43 -10
index 16e1652..0fc2371 100644
@@ -116,6 +116,8 @@ static std::string tcap2s(unsigned cap)
 
 	if (cap & V4L2_TUNER_CAP_LOW)
 		s += "62.5 Hz ";
+	else if (cap & V4L2_TUNER_CAP_1HZ)
+		s += "1 Hz ";
 	else
 		s += "62.5 kHz ";
 	if (cap & V4L2_TUNER_CAP_NORM)
@@ -264,12 +266,24 @@ void tuner_set(int fd)
 	if (capabilities & V4L2_CAP_MODULATOR) {
 		type = V4L2_TUNER_RADIO;
 		modulator.index = tuner_index;
-		if (doioctl(fd, VIDIOC_G_MODULATOR, &modulator) == 0)
-			fac = (modulator.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16;
+		if (doioctl(fd, VIDIOC_G_MODULATOR, &modulator) == 0) {
+			if (modulator.capability & V4L2_TUNER_CAP_LOW)
+				fac = 16000;
+			else if (modulator.capability & V4L2_TUNER_CAP_1HZ)
+				fac = 1000000;
+			else
+				fac = 16;
+		}
 	} else if (capabilities & V4L2_CAP_TUNER) {
 		tuner.index = tuner_index;
 		if (doioctl(fd, VIDIOC_G_TUNER, &tuner) == 0) {
-			fac = (tuner.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16;
+			if (tuner.capability & V4L2_TUNER_CAP_LOW)
+				fac = 16000;
+			else if (tuner.capability & V4L2_TUNER_CAP_1HZ)
+				fac = 1000000;
+			else
+				fac = 16;
+
 			type = tuner.type;
 		}
 	}
@@ -310,6 +324,9 @@ void tuner_set(int fd)
 			if (band.capability & V4L2_TUNER_CAP_LOW)
 				printf("\tFrequency Range: %.3f MHz - %.3f MHz\n",
 				     band.rangelow / 16000.0, band.rangehigh / 16000.0);
+			else if (band.capability & V4L2_TUNER_CAP_1HZ)
+				printf("\tFrequency Range: %.6f MHz - %.6f MHz\n",
+				     band.rangelow / 1000000.0, band.rangehigh / 1000000.0);
 			else
 				printf("\tFrequency Range: %.3f MHz - %.3f MHz\n",
 				     band.rangelow / 16.0, band.rangehigh / 16.0);
@@ -345,13 +362,24 @@ void tuner_get(int fd)
 		if (capabilities & V4L2_CAP_MODULATOR) {
 			vf.type = V4L2_TUNER_RADIO;
 			modulator.index = tuner_index;
-			if (doioctl(fd, VIDIOC_G_MODULATOR, &modulator) == 0)
-				fac = (modulator.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16;
+			if (doioctl(fd, VIDIOC_G_MODULATOR, &modulator) == 0) {
+				if (modulator.capability & V4L2_TUNER_CAP_LOW)
+					fac = 16000;
+				else if (modulator.capability & V4L2_TUNER_CAP_1HZ)
+					fac = 1000000;
+				else
+					fac = 16;
+			}
 		} else {
 			vf.type = V4L2_TUNER_ANALOG_TV;
 			tuner.index = tuner_index;
 			if (doioctl(fd, VIDIOC_G_TUNER, &tuner) == 0) {
-				fac = (tuner.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16;
+				if (tuner.capability & V4L2_TUNER_CAP_LOW)
+					fac = 16000;
+				else if (tuner.capability & V4L2_TUNER_CAP_1HZ)
+					fac = 1000000;
+				else
+					fac = 16;
 				vf.type = tuner.type;
 			}
 		}
@@ -373,13 +401,18 @@ void tuner_get(int fd)
 			if (vt.capability & V4L2_TUNER_CAP_LOW)
 				printf("\tFrequency range      : %.3f MHz - %.3f MHz\n",
 				     vt.rangelow / 16000.0, vt.rangehigh / 16000.0);
+			else if (vt.capability & V4L2_TUNER_CAP_1HZ)
+				printf("\tFrequency range      : %.6f MHz - %.6f MHz\n",
+				     vt.rangelow / 1000000.0, vt.rangehigh / 1000000.0);
 			else
 				printf("\tFrequency range      : %.3f MHz - %.3f MHz\n",
 				     vt.rangelow / 16.0, vt.rangehigh / 16.0);
-			printf("\tSignal strength/AFC  : %d%%/%d\n", (int)((vt.signal / 655.35)+0.5), vt.afc);
-			printf("\tCurrent audio mode   : %s\n", audmode2s(vt.audmode));
-			printf("\tAvailable subchannels: %s\n",
-					rxsubchans2s(vt.rxsubchans).c_str());
+
+			if (vt.type != V4L2_TUNER_ADC && vt.type != V4L2_TUNER_RF) {
+				printf("\tSignal strength/AFC  : %d%%/%d\n", (int)((vt.signal / 655.35)+0.5), vt.afc);
+				printf("\tCurrent audio mode   : %s\n", audmode2s(vt.audmode));
+				printf("\tAvailable subchannels: %s\n", rxsubchans2s(vt.rxsubchans).c_str());
+			}
 		}
 	}
 
Signature · 1 line
1.8.5.3
Acked-by on v1 3/5
#6 lore raw

Re: [PATCH 3/5] v4l2-ctl: add tuner support for SDR tuners

Quoted 4 lines · Antti Palosaari

Add initial SDR support for tuner related operations.

Thanks!

Hans

Quoted 107 lines
---
 utils/v4l2-ctl/v4l2-ctl-tuner.cpp | 53 +++++++++++++++++++++++++++++++--------
 1 file changed, 43 insertions(+), 10 deletions(-)
utils/v4l2-ctl/v4l2-ctl-tuner.cpp +43 -10
index 16e1652..0fc2371 100644
@@ -116,6 +116,8 @@ static std::string tcap2s(unsigned cap)
 
 	if (cap & V4L2_TUNER_CAP_LOW)
 		s += "62.5 Hz ";
+	else if (cap & V4L2_TUNER_CAP_1HZ)
+		s += "1 Hz ";
 	else
 		s += "62.5 kHz ";
 	if (cap & V4L2_TUNER_CAP_NORM)
@@ -264,12 +266,24 @@ void tuner_set(int fd)
 	if (capabilities & V4L2_CAP_MODULATOR) {
 		type = V4L2_TUNER_RADIO;
 		modulator.index = tuner_index;
-		if (doioctl(fd, VIDIOC_G_MODULATOR, &modulator) == 0)
-			fac = (modulator.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16;
+		if (doioctl(fd, VIDIOC_G_MODULATOR, &modulator) == 0) {
+			if (modulator.capability & V4L2_TUNER_CAP_LOW)
+				fac = 16000;
+			else if (modulator.capability & V4L2_TUNER_CAP_1HZ)
+				fac = 1000000;
+			else
+				fac = 16;
+		}
 	} else if (capabilities & V4L2_CAP_TUNER) {
 		tuner.index = tuner_index;
 		if (doioctl(fd, VIDIOC_G_TUNER, &tuner) == 0) {
-			fac = (tuner.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16;
+			if (tuner.capability & V4L2_TUNER_CAP_LOW)
+				fac = 16000;
+			else if (tuner.capability & V4L2_TUNER_CAP_1HZ)
+				fac = 1000000;
+			else
+				fac = 16;
+
 			type = tuner.type;
 		}
 	}
@@ -310,6 +324,9 @@ void tuner_set(int fd)
 			if (band.capability & V4L2_TUNER_CAP_LOW)
 				printf("\tFrequency Range: %.3f MHz - %.3f MHz\n",
 				     band.rangelow / 16000.0, band.rangehigh / 16000.0);
+			else if (band.capability & V4L2_TUNER_CAP_1HZ)
+				printf("\tFrequency Range: %.6f MHz - %.6f MHz\n",
+				     band.rangelow / 1000000.0, band.rangehigh / 1000000.0);
 			else
 				printf("\tFrequency Range: %.3f MHz - %.3f MHz\n",
 				     band.rangelow / 16.0, band.rangehigh / 16.0);
@@ -345,13 +362,24 @@ void tuner_get(int fd)
 		if (capabilities & V4L2_CAP_MODULATOR) {
 			vf.type = V4L2_TUNER_RADIO;
 			modulator.index = tuner_index;
-			if (doioctl(fd, VIDIOC_G_MODULATOR, &modulator) == 0)
-				fac = (modulator.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16;
+			if (doioctl(fd, VIDIOC_G_MODULATOR, &modulator) == 0) {
+				if (modulator.capability & V4L2_TUNER_CAP_LOW)
+					fac = 16000;
+				else if (modulator.capability & V4L2_TUNER_CAP_1HZ)
+					fac = 1000000;
+				else
+					fac = 16;
+			}
 		} else {
 			vf.type = V4L2_TUNER_ANALOG_TV;
 			tuner.index = tuner_index;
 			if (doioctl(fd, VIDIOC_G_TUNER, &tuner) == 0) {
-				fac = (tuner.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16;
+				if (tuner.capability & V4L2_TUNER_CAP_LOW)
+					fac = 16000;
+				else if (tuner.capability & V4L2_TUNER_CAP_1HZ)
+					fac = 1000000;
+				else
+					fac = 16;
 				vf.type = tuner.type;
 			}
 		}
@@ -373,13 +401,18 @@ void tuner_get(int fd)
 			if (vt.capability & V4L2_TUNER_CAP_LOW)
 				printf("\tFrequency range      : %.3f MHz - %.3f MHz\n",
 				     vt.rangelow / 16000.0, vt.rangehigh / 16000.0);
+			else if (vt.capability & V4L2_TUNER_CAP_1HZ)
+				printf("\tFrequency range      : %.6f MHz - %.6f MHz\n",
+				     vt.rangelow / 1000000.0, vt.rangehigh / 1000000.0);
 			else
 				printf("\tFrequency range      : %.3f MHz - %.3f MHz\n",
 				     vt.rangelow / 16.0, vt.rangehigh / 16.0);
-			printf("\tSignal strength/AFC  : %d%%/%d\n", (int)((vt.signal / 655.35)+0.5), vt.afc);
-			printf("\tCurrent audio mode   : %s\n", audmode2s(vt.audmode));
-			printf("\tAvailable subchannels: %s\n",
-					rxsubchans2s(vt.rxsubchans).c_str());
+
+			if (vt.type != V4L2_TUNER_ADC && vt.type != V4L2_TUNER_RF) {
+				printf("\tSignal strength/AFC  : %d%%/%d\n", (int)((vt.signal / 655.35)+0.5), vt.afc);
+				printf("\tCurrent audio mode   : %s\n", audmode2s(vt.audmode));
+				printf("\tAvailable subchannels: %s\n", rxsubchans2s(vt.rxsubchans).c_str());
+			}
 		}
 	}
 
#7 lore raw

PATCH 4/5 v4l2-ctl: add support for SDR FMT

In reply to Antti Palosaari

Add support for FMT IOCTL operations used for SDR receivers.

---
 utils/v4l2-ctl/Makefile.am         |   2 +-
 utils/v4l2-ctl/v4l2-ctl-common.cpp |   1 +
 utils/v4l2-ctl/v4l2-ctl-sdr.cpp    | 104 +++++++++++++++++++++++++++++++++++++
 utils/v4l2-ctl/v4l2-ctl.cpp        |  22 ++++++++
 utils/v4l2-ctl/v4l2-ctl.h          |  12 +++++
 5 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 utils/v4l2-ctl/v4l2-ctl-sdr.cpp
utils/v4l2-ctl/Makefile.am +1 -1
index b5744e7..becaa15 100644
@@ -8,5 +8,5 @@ ivtv_ctl_LDFLAGS = -lm
 v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp v4l2-ctl-tuner.cpp \
 	v4l2-ctl-io.cpp v4l2-ctl-stds.cpp v4l2-ctl-vidcap.cpp v4l2-ctl-vidout.cpp \
 	v4l2-ctl-overlay.cpp v4l2-ctl-vbi.cpp v4l2-ctl-selection.cpp v4l2-ctl-misc.cpp \
-	v4l2-ctl-streaming.cpp v4l2-ctl-test-patterns.cpp
+	v4l2-ctl-streaming.cpp v4l2-ctl-test-patterns.cpp v4l2-ctl-sdr.cpp
 v4l2_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la
utils/v4l2-ctl/v4l2-ctl-common.cpp +1 -0
index fe570b0..37099cd 100644
@@ -64,6 +64,7 @@ void common_usage(void)
 	       "  --help-io          input/output options\n"
 	       "  --help-misc        miscellaneous options\n"
 	       "  --help-overlay     overlay format options\n"
+	       "  --help-sdr         SDR format options\n"
 	       "  --help-selection   crop/selection options\n"
 	       "  --help-stds        standards and other video timings options\n"
 	       "  --help-streaming   streaming options\n"
utils/v4l2-ctl/v4l2-ctl-sdr.cpp new file +104 -0

104 lines not on this page · raw message

utils/v4l2-ctl/v4l2-ctl.cpp +22 -0
index c64c2fe..855613c 100644
@@ -85,6 +85,7 @@ static struct option long_options[] = {
 	{"help-vidout", no_argument, 0, OptHelpVidOut},
 	{"help-overlay", no_argument, 0, OptHelpOverlay},
 	{"help-vbi", no_argument, 0, OptHelpVbi},
+	{"help-sdr", no_argument, 0, OptHelpSdr},
 	{"help-selection", no_argument, 0, OptHelpSelection},
 	{"help-misc", no_argument, 0, OptHelpMisc},
 	{"help-streaming", no_argument, 0, OptHelpStreaming},
@@ -111,6 +112,7 @@ static struct option long_options[] = {
 	{"list-framesizes", required_argument, 0, OptListFrameSizes},
 	{"list-frameintervals", required_argument, 0, OptListFrameIntervals},
 	{"list-formats-overlay", no_argument, 0, OptListOverlayFormats},
+	{"list-formats-sdr", no_argument, 0, OptListSdrFormats},
 	{"list-formats-out", no_argument, 0, OptListOutFormats},
 	{"list-formats-out-mplane", no_argument, 0, OptListOutMplaneFormats},
 	{"get-standard", no_argument, 0, OptGetStandard},
@@ -145,6 +147,9 @@ static struct option long_options[] = {
 	{"try-fmt-sliced-vbi-out", required_argument, 0, OptTrySlicedVbiOutFormat},
 	{"get-fmt-vbi", no_argument, 0, OptGetVbiFormat},
 	{"get-fmt-vbi-out", no_argument, 0, OptGetVbiOutFormat},
+	{"get-fmt-sdr", no_argument, 0, OptGetSdrFormat},
+	{"set-fmt-sdr", required_argument, 0, OptSetSdrFormat},
+	{"try-fmt-sdr", required_argument, 0, OptTrySdrFormat},
 	{"get-sliced-vbi-cap", no_argument, 0, OptGetSlicedVbiCap},
 	{"get-sliced-vbi-out-cap", no_argument, 0, OptGetSlicedVbiOutCap},
 	{"get-fbuf", no_argument, 0, OptGetFBuf},
@@ -217,6 +222,7 @@ static void usage_all(void)
        vidout_usage();
        overlay_usage();
        vbi_usage();
+       sdr_usage();
        selection_usage();
        misc_usage();
        streaming_usage();
@@ -285,6 +291,8 @@ std::string buftype2s(int type)
 		return "Sliced VBI Output";
 	case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
 		return "Video Output Overlay";
+	case V4L2_BUF_TYPE_SDR_CAPTURE:
+		return "SDR Capture";
 	default:
 		return "Unknown (" + num2s(type) + ")";
 	}
@@ -458,6 +466,9 @@ void printfmt(const struct v4l2_format &vfmt)
 		}
 		printf("\tI/O Size       : %u\n", vfmt.fmt.sliced.io_size);
 		break;
+	case V4L2_BUF_TYPE_SDR_CAPTURE:
+		printf("\tSample Format   : %s\n", fcc2s(vfmt.fmt.sdr.pixelformat).c_str());
+		break;
 	}
 }
 
@@ -519,6 +530,8 @@ static std::string cap2s(unsigned cap)
 		s += "\t\tSliced VBI Capture\n";
 	if (cap & V4L2_CAP_SLICED_VBI_OUTPUT)
 		s += "\t\tSliced VBI Output\n";
+	if (cap & V4L2_CAP_SDR_CAPTURE)
+		s += "\t\tSDR Capture\n";
 	if (cap & V4L2_CAP_RDS_CAPTURE)
 		s += "\t\tRDS Capture\n";
 	if (cap & V4L2_CAP_RDS_OUTPUT)
@@ -736,6 +749,7 @@ __u32 find_pixel_format(int fd, unsigned index, bool output, bool mplane)
 	else
 		fmt.type = mplane ?  V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE :
 			V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
 	if (doioctl(fd, VIDIOC_ENUM_FMT, &fmt))
 		return 0;
 	return fmt.pixelformat;
@@ -807,6 +821,9 @@ int main(int argc, char **argv)
 		case OptHelpVbi:
 			vbi_usage();
 			return 0;
+		case OptHelpSdr:
+			sdr_usage();
+			return 0;
 		case OptHelpSelection:
 			selection_usage();
 			return 0;
@@ -860,6 +877,7 @@ int main(int argc, char **argv)
 			vidout_cmd(ch, optarg);
 			overlay_cmd(ch, optarg);
 			vbi_cmd(ch, optarg);
+			sdr_cmd(ch, optarg);
 			selection_cmd(ch, optarg);
 			misc_cmd(ch, optarg);
 			streaming_cmd(ch, optarg);
@@ -921,6 +939,7 @@ int main(int argc, char **argv)
 		options[OptGetVbiOutFormat] = 1;
 		options[OptGetSlicedVbiFormat] = 1;
 		options[OptGetSlicedVbiOutFormat] = 1;
+		options[OptGetSdrFormat] = 1;
 		options[OptGetFBuf] = 1;
 		options[OptGetCropCap] = 1;
 		options[OptGetOutputCropCap] = 1;
@@ -964,6 +983,7 @@ int main(int argc, char **argv)
 	vidout_set(fd);
 	overlay_set(fd);
 	vbi_set(fd);
+	sdr_set(fd);
 	selection_set(fd);
 	streaming_set(fd);
 	misc_set(fd);
@@ -978,6 +998,7 @@ int main(int argc, char **argv)
 	vidout_get(fd);
 	overlay_get(fd);
 	vbi_get(fd);
+	sdr_get(fd);
 	selection_get(fd);
 	misc_get(fd);
 
@@ -990,6 +1011,7 @@ int main(int argc, char **argv)
 	vidout_list(fd);
 	overlay_list(fd);
 	vbi_list(fd);
+	sdr_list(fd);
 	streaming_list(fd);
 
 	if (options[OptWaitForEvent]) {
utils/v4l2-ctl/v4l2-ctl.h +12 -0
index 03c45b7..108198d 100644
@@ -44,6 +44,7 @@ enum Option {
 	OptGetOutputOverlayFormat,
 	OptGetVbiFormat,
 	OptGetVbiOutFormat,
+	OptGetSdrFormat,
 	OptGetVideoOutFormat,
 	OptGetVideoOutMplaneFormat,
 	OptSetSlicedVbiOutFormat,
@@ -51,6 +52,7 @@ enum Option {
 	OptSetOverlayFormat,
 	//OptSetVbiFormat, TODO
 	//OptSetVbiOutFormat, TODO
+	OptSetSdrFormat,
 	OptSetVideoOutFormat,
 	OptSetVideoOutMplaneFormat,
 	OptTryVideoOutFormat,
@@ -63,6 +65,7 @@ enum Option {
 	OptTryOverlayFormat,
 	//OptTryVbiFormat, TODO
 	//OptTryVbiOutFormat, TODO
+	OptTrySdrFormat,
 	OptAll,
 	OptListStandards,
 	OptListFormats,
@@ -72,6 +75,7 @@ enum Option {
 	OptListFrameSizes,
 	OptListFrameIntervals,
 	OptListOverlayFormats,
+	OptListSdrFormats,
 	OptListOutFormats,
 	OptListOutMplaneFormats,
 	OptLogStatus,
@@ -153,6 +157,7 @@ enum Option {
 	OptHelpVidOut,
 	OptHelpOverlay,
 	OptHelpVbi,
+	OptHelpSdr,
 	OptHelpSelection,
 	OptHelpMisc,
 	OptHelpStreaming,
@@ -257,6 +262,13 @@ void vbi_set(int fd);
 void vbi_get(int fd);
 void vbi_list(int fd);
 
+// v4l2-ctl-sdr.cpp
+void sdr_usage(void);
+void sdr_cmd(int ch, char *optarg);
+void sdr_set(int fd);
+void sdr_get(int fd);
+void sdr_list(int fd);
+
 // v4l2-ctl-selection.cpp
 void selection_usage(void);
 void selection_cmd(int ch, char *optarg);
Signature · 1 line
1.8.5.3
Acked-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] v4l2-ctl: add support for SDR FMT

Quoted 4 lines · Antti Palosaari

Add support for FMT IOCTL operations used for SDR receivers.

Thanks!

Hans

Quoted 325 lines
---
 utils/v4l2-ctl/Makefile.am         |   2 +-
 utils/v4l2-ctl/v4l2-ctl-common.cpp |   1 +
 utils/v4l2-ctl/v4l2-ctl-sdr.cpp    | 104 +++++++++++++++++++++++++++++++++++++
 utils/v4l2-ctl/v4l2-ctl.cpp        |  22 ++++++++
 utils/v4l2-ctl/v4l2-ctl.h          |  12 +++++
 5 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 utils/v4l2-ctl/v4l2-ctl-sdr.cpp
utils/v4l2-ctl/Makefile.am +1 -1
index b5744e7..becaa15 100644
@@ -8,5 +8,5 @@ ivtv_ctl_LDFLAGS = -lm
 v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp v4l2-ctl-tuner.cpp \
 	v4l2-ctl-io.cpp v4l2-ctl-stds.cpp v4l2-ctl-vidcap.cpp v4l2-ctl-vidout.cpp \
 	v4l2-ctl-overlay.cpp v4l2-ctl-vbi.cpp v4l2-ctl-selection.cpp v4l2-ctl-misc.cpp \
-	v4l2-ctl-streaming.cpp v4l2-ctl-test-patterns.cpp
+	v4l2-ctl-streaming.cpp v4l2-ctl-test-patterns.cpp v4l2-ctl-sdr.cpp
 v4l2_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la
utils/v4l2-ctl/v4l2-ctl-common.cpp +1 -0
index fe570b0..37099cd 100644
@@ -64,6 +64,7 @@ void common_usage(void)
 	       "  --help-io          input/output options\n"
 	       "  --help-misc        miscellaneous options\n"
 	       "  --help-overlay     overlay format options\n"
+	       "  --help-sdr         SDR format options\n"
 	       "  --help-selection   crop/selection options\n"
 	       "  --help-stds        standards and other video timings options\n"
 	       "  --help-streaming   streaming options\n"
utils/v4l2-ctl/v4l2-ctl-sdr.cpp new file +104 -0
new file mode 100644
index 0000000..9c9a6c4
@@ -0,0 +1,104 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <dirent.h>
+#include <math.h>
+#include <config.h>
+
+#include <linux/videodev2.h>
+#include <libv4l2.h>
+#include <string>
+
+#include "v4l2-ctl.h"
+
+static struct v4l2_format vfmt;	/* set_format/get_format */
+
+void sdr_usage(void)
+{
+	printf("\nSDR Formats options:\n"
+	       "  --list-formats-sdr display supported SDR formats [VIDIOC_ENUM_FMT]\n"
+	       "  --get-fmt-sdr      query the SDR capture format [VIDIOC_G_FMT]\n"
+	       "  --set-fmt-sdr=<f>  set the SDR capture format [VIDIOC_S_FMT]\n"
+	       "                     parameter is either the format index as reported by\n"
+	       "                     --list-formats-sdr, or the fourcc value as a string\n"
+	       "  --try-fmt-sdr=<f>  try the SDR capture format [VIDIOC_TRY_FMT]\n"
+	       "                     parameter is either the format index as reported by\n"
+	       "                     --list-formats-sdr, or the fourcc value as a string\n"
+	       );
+}
+
+void sdr_cmd(int ch, char *optarg)
+{
+	switch (ch) {
+	case OptSetSdrFormat:
+	case OptTrySdrFormat:
+		if (strlen(optarg) == 0) {
+			sdr_usage();
+			exit(1);
+		} else if (strlen(optarg) == 4) {
+			vfmt.fmt.sdr.pixelformat = v4l2_fourcc(optarg[0],
+					optarg[1], optarg[2], optarg[3]);
+		} else {
+			vfmt.fmt.sdr.pixelformat = strtol(optarg, 0L, 0);
+		}
+		break;
+	}
+}
+
+void sdr_set(int fd)
+{
+	int ret;
+
+	if (options[OptSetSdrFormat] || options[OptTrySdrFormat]) {
+		struct v4l2_format in_vfmt;
+
+		in_vfmt.type = V4L2_BUF_TYPE_SDR_CAPTURE;
+		in_vfmt.fmt.sdr.pixelformat = vfmt.fmt.sdr.pixelformat;
+
+		if (in_vfmt.fmt.sdr.pixelformat < 256) {
+			struct v4l2_fmtdesc fmt;
+
+			fmt.index = in_vfmt.fmt.sdr.pixelformat;
+			fmt.type = V4L2_BUF_TYPE_SDR_CAPTURE;
+
+			if (doioctl(fd, VIDIOC_ENUM_FMT, &fmt))
+				fmt.pixelformat = 0;
+
+			in_vfmt.fmt.sdr.pixelformat = fmt.pixelformat;
+		}
+
+		if (options[OptSetSdrFormat])
+			ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt);
+		else
+			ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt);
+		if (ret == 0 && (verbose || options[OptTrySdrFormat]))
+			printfmt(in_vfmt);
+	}
+}
+
+void sdr_get(int fd)
+{
+	if (options[OptGetSdrFormat]) {
+		vfmt.type = V4L2_BUF_TYPE_SDR_CAPTURE;
+		if (doioctl(fd, VIDIOC_G_FMT, &vfmt) == 0)
+			printfmt(vfmt);
+	}
+}
+
+void sdr_list(int fd)
+{
+	if (options[OptListSdrFormats]) {
+		printf("ioctl: VIDIOC_ENUM_FMT\n");
+		print_video_formats(fd, V4L2_BUF_TYPE_SDR_CAPTURE);
+	}
+}
utils/v4l2-ctl/v4l2-ctl.cpp +22 -0
index c64c2fe..855613c 100644
@@ -85,6 +85,7 @@ static struct option long_options[] = {
 	{"help-vidout", no_argument, 0, OptHelpVidOut},
 	{"help-overlay", no_argument, 0, OptHelpOverlay},
 	{"help-vbi", no_argument, 0, OptHelpVbi},
+	{"help-sdr", no_argument, 0, OptHelpSdr},
 	{"help-selection", no_argument, 0, OptHelpSelection},
 	{"help-misc", no_argument, 0, OptHelpMisc},
 	{"help-streaming", no_argument, 0, OptHelpStreaming},
@@ -111,6 +112,7 @@ static struct option long_options[] = {
 	{"list-framesizes", required_argument, 0, OptListFrameSizes},
 	{"list-frameintervals", required_argument, 0, OptListFrameIntervals},
 	{"list-formats-overlay", no_argument, 0, OptListOverlayFormats},
+	{"list-formats-sdr", no_argument, 0, OptListSdrFormats},
 	{"list-formats-out", no_argument, 0, OptListOutFormats},
 	{"list-formats-out-mplane", no_argument, 0, OptListOutMplaneFormats},
 	{"get-standard", no_argument, 0, OptGetStandard},
@@ -145,6 +147,9 @@ static struct option long_options[] = {
 	{"try-fmt-sliced-vbi-out", required_argument, 0, OptTrySlicedVbiOutFormat},
 	{"get-fmt-vbi", no_argument, 0, OptGetVbiFormat},
 	{"get-fmt-vbi-out", no_argument, 0, OptGetVbiOutFormat},
+	{"get-fmt-sdr", no_argument, 0, OptGetSdrFormat},
+	{"set-fmt-sdr", required_argument, 0, OptSetSdrFormat},
+	{"try-fmt-sdr", required_argument, 0, OptTrySdrFormat},
 	{"get-sliced-vbi-cap", no_argument, 0, OptGetSlicedVbiCap},
 	{"get-sliced-vbi-out-cap", no_argument, 0, OptGetSlicedVbiOutCap},
 	{"get-fbuf", no_argument, 0, OptGetFBuf},
@@ -217,6 +222,7 @@ static void usage_all(void)
        vidout_usage();
        overlay_usage();
        vbi_usage();
+       sdr_usage();
        selection_usage();
        misc_usage();
        streaming_usage();
@@ -285,6 +291,8 @@ std::string buftype2s(int type)
 		return "Sliced VBI Output";
 	case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
 		return "Video Output Overlay";
+	case V4L2_BUF_TYPE_SDR_CAPTURE:
+		return "SDR Capture";
 	default:
 		return "Unknown (" + num2s(type) + ")";
 	}
@@ -458,6 +466,9 @@ void printfmt(const struct v4l2_format &vfmt)
 		}
 		printf("\tI/O Size       : %u\n", vfmt.fmt.sliced.io_size);
 		break;
+	case V4L2_BUF_TYPE_SDR_CAPTURE:
+		printf("\tSample Format   : %s\n", fcc2s(vfmt.fmt.sdr.pixelformat).c_str());
+		break;
 	}
 }
 
@@ -519,6 +530,8 @@ static std::string cap2s(unsigned cap)
 		s += "\t\tSliced VBI Capture\n";
 	if (cap & V4L2_CAP_SLICED_VBI_OUTPUT)
 		s += "\t\tSliced VBI Output\n";
+	if (cap & V4L2_CAP_SDR_CAPTURE)
+		s += "\t\tSDR Capture\n";
 	if (cap & V4L2_CAP_RDS_CAPTURE)
 		s += "\t\tRDS Capture\n";
 	if (cap & V4L2_CAP_RDS_OUTPUT)
@@ -736,6 +749,7 @@ __u32 find_pixel_format(int fd, unsigned index, bool output, bool mplane)
 	else
 		fmt.type = mplane ?  V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE :
 			V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
 	if (doioctl(fd, VIDIOC_ENUM_FMT, &fmt))
 		return 0;
 	return fmt.pixelformat;
@@ -807,6 +821,9 @@ int main(int argc, char **argv)
 		case OptHelpVbi:
 			vbi_usage();
 			return 0;
+		case OptHelpSdr:
+			sdr_usage();
+			return 0;
 		case OptHelpSelection:
 			selection_usage();
 			return 0;
@@ -860,6 +877,7 @@ int main(int argc, char **argv)
 			vidout_cmd(ch, optarg);
 			overlay_cmd(ch, optarg);
 			vbi_cmd(ch, optarg);
+			sdr_cmd(ch, optarg);
 			selection_cmd(ch, optarg);
 			misc_cmd(ch, optarg);
 			streaming_cmd(ch, optarg);
@@ -921,6 +939,7 @@ int main(int argc, char **argv)
 		options[OptGetVbiOutFormat] = 1;
 		options[OptGetSlicedVbiFormat] = 1;
 		options[OptGetSlicedVbiOutFormat] = 1;
+		options[OptGetSdrFormat] = 1;
 		options[OptGetFBuf] = 1;
 		options[OptGetCropCap] = 1;
 		options[OptGetOutputCropCap] = 1;
@@ -964,6 +983,7 @@ int main(int argc, char **argv)
 	vidout_set(fd);
 	overlay_set(fd);
 	vbi_set(fd);
+	sdr_set(fd);
 	selection_set(fd);
 	streaming_set(fd);
 	misc_set(fd);
@@ -978,6 +998,7 @@ int main(int argc, char **argv)
 	vidout_get(fd);
 	overlay_get(fd);
 	vbi_get(fd);
+	sdr_get(fd);
 	selection_get(fd);
 	misc_get(fd);
 
@@ -990,6 +1011,7 @@ int main(int argc, char **argv)
 	vidout_list(fd);
 	overlay_list(fd);
 	vbi_list(fd);
+	sdr_list(fd);
 	streaming_list(fd);
 
 	if (options[OptWaitForEvent]) {
utils/v4l2-ctl/v4l2-ctl.h +12 -0
index 03c45b7..108198d 100644
@@ -44,6 +44,7 @@ enum Option {
 	OptGetOutputOverlayFormat,
 	OptGetVbiFormat,
 	OptGetVbiOutFormat,
+	OptGetSdrFormat,
 	OptGetVideoOutFormat,
 	OptGetVideoOutMplaneFormat,
 	OptSetSlicedVbiOutFormat,
@@ -51,6 +52,7 @@ enum Option {
 	OptSetOverlayFormat,
 	//OptSetVbiFormat, TODO
 	//OptSetVbiOutFormat, TODO
+	OptSetSdrFormat,
 	OptSetVideoOutFormat,
 	OptSetVideoOutMplaneFormat,
 	OptTryVideoOutFormat,
@@ -63,6 +65,7 @@ enum Option {
 	OptTryOverlayFormat,
 	//OptTryVbiFormat, TODO
 	//OptTryVbiOutFormat, TODO
+	OptTrySdrFormat,
 	OptAll,
 	OptListStandards,
 	OptListFormats,
@@ -72,6 +75,7 @@ enum Option {
 	OptListFrameSizes,
 	OptListFrameIntervals,
 	OptListOverlayFormats,
+	OptListSdrFormats,
 	OptListOutFormats,
 	OptListOutMplaneFormats,
 	OptLogStatus,
@@ -153,6 +157,7 @@ enum Option {
 	OptHelpVidOut,
 	OptHelpOverlay,
 	OptHelpVbi,
+	OptHelpSdr,
 	OptHelpSelection,
 	OptHelpMisc,
 	OptHelpStreaming,
@@ -257,6 +262,13 @@ void vbi_set(int fd);
 void vbi_get(int fd);
 void vbi_list(int fd);
 
+// v4l2-ctl-sdr.cpp
+void sdr_usage(void);
+void sdr_cmd(int ch, char *optarg);
+void sdr_set(int fd);
+void sdr_get(int fd);
+void sdr_list(int fd);
+
 // v4l2-ctl-selection.cpp
 void selection_usage(void);
 void selection_cmd(int ch, char *optarg);
#9 lore raw

PATCH 5/5 v4l2-ctl: implement list SDR buffers command

In reply to Antti Palosaari
---
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 6 ++++++
 utils/v4l2-ctl/v4l2-ctl.cpp           | 1 +
 utils/v4l2-ctl/v4l2-ctl.h             | 1 +
 3 files changed, 8 insertions(+)
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +6 -0
index 13ee8ec..925d73d 100644
@@ -78,6 +78,8 @@ void streaming_usage(void)
 	       "                     list all sliced VBI buffers [VIDIOC_QUERYBUF]\n"
 	       "  --list-buffers-sliced-vbi-out\n"
 	       "                     list all sliced VBI output buffers [VIDIOC_QUERYBUF]\n"
+	       "  --list-buffers-sdr\n"
+	       "                     list all SDR RX buffers [VIDIOC_QUERYBUF]\n"
 	       );
 }
 
@@ -986,4 +988,8 @@ void streaming_list(int fd)
 	if (options[OptListBuffersSlicedVbiOut]) {
 		list_buffers(fd, V4L2_BUF_TYPE_SLICED_VBI_OUTPUT);
 	}
+
+	if (options[OptListBuffersSdr]) {
+		list_buffers(fd, V4L2_BUF_TYPE_SDR_CAPTURE);
+	}
 }
utils/v4l2-ctl/v4l2-ctl.cpp +1 -0
index 855613c..a602366 100644
@@ -198,6 +198,7 @@ static struct option long_options[] = {
 	{"list-buffers-sliced-vbi", no_argument, 0, OptListBuffersSlicedVbi},
 	{"list-buffers-vbi-out", no_argument, 0, OptListBuffersVbiOut},
 	{"list-buffers-sliced-vbi-out", no_argument, 0, OptListBuffersSlicedVbiOut},
+	{"list-buffers-sdr", no_argument, 0, OptListBuffersSdr},
 	{"stream-count", required_argument, 0, OptStreamCount},
 	{"stream-skip", required_argument, 0, OptStreamSkip},
 	{"stream-loop", no_argument, 0, OptStreamLoop},
utils/v4l2-ctl/v4l2-ctl.h +1 -0
index 108198d..1caac34 100644
@@ -139,6 +139,7 @@ enum Option {
 	OptListBuffersSlicedVbi,
 	OptListBuffersVbiOut,
 	OptListBuffersSlicedVbiOut,
+	OptListBuffersSdr,
 	OptStreamCount,
 	OptStreamSkip,
 	OptStreamLoop,
Signature · 1 line
1.8.5.3
Acked-by on v1 5/5
#10 lore raw

Re: [PATCH 5/5] v4l2-ctl: implement list SDR buffers command

Quoted 2 lines · Antti Palosaari

Thanks!

Hans

Quoted 53 lines
---
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 6 ++++++
 utils/v4l2-ctl/v4l2-ctl.cpp           | 1 +
 utils/v4l2-ctl/v4l2-ctl.h             | 1 +
 3 files changed, 8 insertions(+)
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +6 -0
index 13ee8ec..925d73d 100644
@@ -78,6 +78,8 @@ void streaming_usage(void)
 	       "                     list all sliced VBI buffers [VIDIOC_QUERYBUF]\n"
 	       "  --list-buffers-sliced-vbi-out\n"
 	       "                     list all sliced VBI output buffers [VIDIOC_QUERYBUF]\n"
+	       "  --list-buffers-sdr\n"
+	       "                     list all SDR RX buffers [VIDIOC_QUERYBUF]\n"
 	       );
 }
 
@@ -986,4 +988,8 @@ void streaming_list(int fd)
 	if (options[OptListBuffersSlicedVbiOut]) {
 		list_buffers(fd, V4L2_BUF_TYPE_SLICED_VBI_OUTPUT);
 	}
+
+	if (options[OptListBuffersSdr]) {
+		list_buffers(fd, V4L2_BUF_TYPE_SDR_CAPTURE);
+	}
 }
utils/v4l2-ctl/v4l2-ctl.cpp +1 -0
index 855613c..a602366 100644
@@ -198,6 +198,7 @@ static struct option long_options[] = {
 	{"list-buffers-sliced-vbi", no_argument, 0, OptListBuffersSlicedVbi},
 	{"list-buffers-vbi-out", no_argument, 0, OptListBuffersVbiOut},
 	{"list-buffers-sliced-vbi-out", no_argument, 0, OptListBuffersSlicedVbiOut},
+	{"list-buffers-sdr", no_argument, 0, OptListBuffersSdr},
 	{"stream-count", required_argument, 0, OptStreamCount},
 	{"stream-skip", required_argument, 0, OptStreamSkip},
 	{"stream-loop", no_argument, 0, OptStreamLoop},
utils/v4l2-ctl/v4l2-ctl.h +1 -0
index 108198d..1caac34 100644
@@ -139,6 +139,7 @@ enum Option {
 	OptListBuffersSlicedVbi,
 	OptListBuffersVbiOut,
 	OptListBuffersSlicedVbiOut,
+	OptListBuffersSdr,
 	OptStreamCount,
 	OptStreamSkip,
 	OptStreamLoop,