* [PATCH 0/5] v4l2-ctl: add SDR device support
@ 2014-02-09 6:05 Antti Palosaari
2014-02-09 6:05 ` [PATCH 1/5] libdvbv5: better handle ATSC/Annex B Antti Palosaari
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Antti Palosaari @ 2014-02-09 6:05 UTC (permalink / raw)
To: linux-media; +Cc: Mauro Carvalho Chehab, Hans Verkuil, Antti Palosaari
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
--
1.8.5.3
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH 1/5] libdvbv5: better handle ATSC/Annex B 2014-02-09 6:05 [PATCH 0/5] v4l2-ctl: add SDR device support Antti Palosaari @ 2014-02-09 6:05 ` Antti Palosaari 2014-02-09 6:05 ` [PATCH 2/5] synch videodev2.h headers with kernel SDR API Antti Palosaari ` (3 subsequent siblings) 4 siblings, 0 replies; 11+ messages in thread From: Antti Palosaari @ 2014-02-09 6:05 UTC (permalink / raw) To: linux-media; +Cc: Mauro Carvalho Chehab, Hans Verkuil From: Mauro Carvalho Chehab <m.chehab@samsung.com> 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. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> --- lib/libdvbv5/dvb-file.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c index 1c33a90..e0cef34 100644 --- a/lib/libdvbv5/dvb-file.c +++ b/lib/libdvbv5/dvb-file.c @@ -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) -- 1.8.5.3 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/5] synch videodev2.h headers with kernel SDR API 2014-02-09 6:05 [PATCH 0/5] v4l2-ctl: add SDR device support Antti Palosaari 2014-02-09 6:05 ` [PATCH 1/5] libdvbv5: better handle ATSC/Annex B Antti Palosaari @ 2014-02-09 6:05 ` Antti Palosaari 2014-02-10 9:08 ` Hans Verkuil 2014-02-09 6:05 ` [PATCH 3/5] v4l2-ctl: add tuner support for SDR tuners Antti Palosaari ` (2 subsequent siblings) 4 siblings, 1 reply; 11+ messages in thread From: Antti Palosaari @ 2014-02-09 6:05 UTC (permalink / raw) To: linux-media; +Cc: Mauro Carvalho Chehab, Hans Verkuil, Antti Palosaari Cc: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Antti Palosaari <crope@iki.fi> --- contrib/freebsd/include/linux/videodev2.h | 16 ++++++++++++++++ include/linux/videodev2.h | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/contrib/freebsd/include/linux/videodev2.h b/contrib/freebsd/include/linux/videodev2.h index 5c75762..6d49f97 100644 --- a/contrib/freebsd/include/linux/videodev2.h +++ b/contrib/freebsd/include/linux/videodev2.h @@ -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; }; diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 6ae7bbe..27fedfe 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -139,6 +139,7 @@ enum v4l2_buf_type { #endif V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10, + V4L2_BUF_TYPE_SDR_CAPTURE = 11, /* Deprecated, do not use */ V4L2_BUF_TYPE_PRIVATE = 0x80, }; @@ -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; }; -- 1.8.5.3 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] synch videodev2.h headers with kernel SDR API 2014-02-09 6:05 ` [PATCH 2/5] synch videodev2.h headers with kernel SDR API Antti Palosaari @ 2014-02-10 9:08 ` Hans Verkuil 2014-02-10 9:17 ` Antti Palosaari 0 siblings, 1 reply; 11+ messages in thread From: Hans Verkuil @ 2014-02-10 9:08 UTC (permalink / raw) To: Antti Palosaari; +Cc: linux-media, Mauro Carvalho Chehab 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 On 02/09/2014 07:05 AM, Antti Palosaari wrote: > Cc: Hans Verkuil <hverkuil@xs4all.nl> > Signed-off-by: Antti Palosaari <crope@iki.fi> > --- > contrib/freebsd/include/linux/videodev2.h | 16 ++++++++++++++++ > include/linux/videodev2.h | 16 ++++++++++++++++ > 2 files changed, 32 insertions(+) > > diff --git a/contrib/freebsd/include/linux/videodev2.h b/contrib/freebsd/include/linux/videodev2.h > index 5c75762..6d49f97 100644 > --- a/contrib/freebsd/include/linux/videodev2.h > +++ b/contrib/freebsd/include/linux/videodev2.h > @@ -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; > }; > diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h > index 6ae7bbe..27fedfe 100644 > --- a/include/linux/videodev2.h > +++ b/include/linux/videodev2.h > @@ -139,6 +139,7 @@ enum v4l2_buf_type { > #endif > V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9, > V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10, > + V4L2_BUF_TYPE_SDR_CAPTURE = 11, > /* Deprecated, do not use */ > V4L2_BUF_TYPE_PRIVATE = 0x80, > }; > @@ -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; > }; > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] synch videodev2.h headers with kernel SDR API 2014-02-10 9:08 ` Hans Verkuil @ 2014-02-10 9:17 ` Antti Palosaari 0 siblings, 0 replies; 11+ messages in thread From: Antti Palosaari @ 2014-02-10 9:17 UTC (permalink / raw) To: Hans Verkuil; +Cc: linux-media, Mauro Carvalho Chehab Moro Hans, On 10.02.2014 11:08, Hans Verkuil wrote: > 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 -- http://palosaari.fi/ ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/5] v4l2-ctl: add tuner support for SDR tuners 2014-02-09 6:05 [PATCH 0/5] v4l2-ctl: add SDR device support Antti Palosaari 2014-02-09 6:05 ` [PATCH 1/5] libdvbv5: better handle ATSC/Annex B Antti Palosaari 2014-02-09 6:05 ` [PATCH 2/5] synch videodev2.h headers with kernel SDR API Antti Palosaari @ 2014-02-09 6:05 ` Antti Palosaari 2014-02-10 9:10 ` Hans Verkuil 2014-02-09 6:05 ` [PATCH 4/5] v4l2-ctl: add support for SDR FMT Antti Palosaari 2014-02-09 6:05 ` [PATCH 5/5] v4l2-ctl: implement list SDR buffers command Antti Palosaari 4 siblings, 1 reply; 11+ messages in thread From: Antti Palosaari @ 2014-02-09 6:05 UTC (permalink / raw) To: linux-media; +Cc: Mauro Carvalho Chehab, Hans Verkuil, Antti Palosaari Add initial SDR support for tuner related operations. Cc: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Antti Palosaari <crope@iki.fi> --- utils/v4l2-ctl/v4l2-ctl-tuner.cpp | 53 +++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp index 16e1652..0fc2371 100644 --- a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp @@ -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()); + } } } -- 1.8.5.3 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 3/5] v4l2-ctl: add tuner support for SDR tuners 2014-02-09 6:05 ` [PATCH 3/5] v4l2-ctl: add tuner support for SDR tuners Antti Palosaari @ 2014-02-10 9:10 ` Hans Verkuil 0 siblings, 0 replies; 11+ messages in thread From: Hans Verkuil @ 2014-02-10 9:10 UTC (permalink / raw) To: Antti Palosaari; +Cc: linux-media, Mauro Carvalho Chehab On 02/09/2014 07:05 AM, Antti Palosaari wrote: > Add initial SDR support for tuner related operations. > > Cc: Hans Verkuil <hverkuil@xs4all.nl> > Signed-off-by: Antti Palosaari <crope@iki.fi> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Thanks! Hans > --- > utils/v4l2-ctl/v4l2-ctl-tuner.cpp | 53 +++++++++++++++++++++++++++++++-------- > 1 file changed, 43 insertions(+), 10 deletions(-) > > diff --git a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp > index 16e1652..0fc2371 100644 > --- a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp > +++ b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp > @@ -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()); > + } > } > } > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/5] v4l2-ctl: add support for SDR FMT 2014-02-09 6:05 [PATCH 0/5] v4l2-ctl: add SDR device support Antti Palosaari ` (2 preceding siblings ...) 2014-02-09 6:05 ` [PATCH 3/5] v4l2-ctl: add tuner support for SDR tuners Antti Palosaari @ 2014-02-09 6:05 ` Antti Palosaari 2014-02-10 9:11 ` Hans Verkuil 2014-02-09 6:05 ` [PATCH 5/5] v4l2-ctl: implement list SDR buffers command Antti Palosaari 4 siblings, 1 reply; 11+ messages in thread From: Antti Palosaari @ 2014-02-09 6:05 UTC (permalink / raw) To: linux-media; +Cc: Mauro Carvalho Chehab, Hans Verkuil, Antti Palosaari Add support for FMT IOCTL operations used for SDR receivers. Cc: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Antti Palosaari <crope@iki.fi> --- 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 diff --git a/utils/v4l2-ctl/Makefile.am b/utils/v4l2-ctl/Makefile.am index b5744e7..becaa15 100644 --- a/utils/v4l2-ctl/Makefile.am +++ b/utils/v4l2-ctl/Makefile.am @@ -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 diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp index fe570b0..37099cd 100644 --- a/utils/v4l2-ctl/v4l2-ctl-common.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp @@ -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" diff --git a/utils/v4l2-ctl/v4l2-ctl-sdr.cpp b/utils/v4l2-ctl/v4l2-ctl-sdr.cpp new file mode 100644 index 0000000..9c9a6c4 --- /dev/null +++ b/utils/v4l2-ctl/v4l2-ctl-sdr.cpp @@ -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); + } +} diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index c64c2fe..855613c 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -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]) { diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index 03c45b7..108198d 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -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); -- 1.8.5.3 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 4/5] v4l2-ctl: add support for SDR FMT 2014-02-09 6:05 ` [PATCH 4/5] v4l2-ctl: add support for SDR FMT Antti Palosaari @ 2014-02-10 9:11 ` Hans Verkuil 0 siblings, 0 replies; 11+ messages in thread From: Hans Verkuil @ 2014-02-10 9:11 UTC (permalink / raw) To: Antti Palosaari; +Cc: linux-media, Mauro Carvalho Chehab On 02/09/2014 07:05 AM, Antti Palosaari wrote: > Add support for FMT IOCTL operations used for SDR receivers. > > Cc: Hans Verkuil <hverkuil@xs4all.nl> > Signed-off-by: Antti Palosaari <crope@iki.fi> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Thanks! Hans > --- > 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 > > diff --git a/utils/v4l2-ctl/Makefile.am b/utils/v4l2-ctl/Makefile.am > index b5744e7..becaa15 100644 > --- a/utils/v4l2-ctl/Makefile.am > +++ b/utils/v4l2-ctl/Makefile.am > @@ -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 > diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp > index fe570b0..37099cd 100644 > --- a/utils/v4l2-ctl/v4l2-ctl-common.cpp > +++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp > @@ -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" > diff --git a/utils/v4l2-ctl/v4l2-ctl-sdr.cpp b/utils/v4l2-ctl/v4l2-ctl-sdr.cpp > new file mode 100644 > index 0000000..9c9a6c4 > --- /dev/null > +++ b/utils/v4l2-ctl/v4l2-ctl-sdr.cpp > @@ -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); > + } > +} > diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp > index c64c2fe..855613c 100644 > --- a/utils/v4l2-ctl/v4l2-ctl.cpp > +++ b/utils/v4l2-ctl/v4l2-ctl.cpp > @@ -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]) { > diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h > index 03c45b7..108198d 100644 > --- a/utils/v4l2-ctl/v4l2-ctl.h > +++ b/utils/v4l2-ctl/v4l2-ctl.h > @@ -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); > ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 5/5] v4l2-ctl: implement list SDR buffers command 2014-02-09 6:05 [PATCH 0/5] v4l2-ctl: add SDR device support Antti Palosaari ` (3 preceding siblings ...) 2014-02-09 6:05 ` [PATCH 4/5] v4l2-ctl: add support for SDR FMT Antti Palosaari @ 2014-02-09 6:05 ` Antti Palosaari 2014-02-10 9:11 ` Hans Verkuil 4 siblings, 1 reply; 11+ messages in thread From: Antti Palosaari @ 2014-02-09 6:05 UTC (permalink / raw) To: linux-media; +Cc: Mauro Carvalho Chehab, Hans Verkuil, Antti Palosaari Cc: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Antti Palosaari <crope@iki.fi> --- 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(+) diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp index 13ee8ec..925d73d 100644 --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp @@ -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); + } } diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index 855613c..a602366 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -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}, diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index 108198d..1caac34 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -139,6 +139,7 @@ enum Option { OptListBuffersSlicedVbi, OptListBuffersVbiOut, OptListBuffersSlicedVbiOut, + OptListBuffersSdr, OptStreamCount, OptStreamSkip, OptStreamLoop, -- 1.8.5.3 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] v4l2-ctl: implement list SDR buffers command 2014-02-09 6:05 ` [PATCH 5/5] v4l2-ctl: implement list SDR buffers command Antti Palosaari @ 2014-02-10 9:11 ` Hans Verkuil 0 siblings, 0 replies; 11+ messages in thread From: Hans Verkuil @ 2014-02-10 9:11 UTC (permalink / raw) To: Antti Palosaari; +Cc: linux-media, Mauro Carvalho Chehab On 02/09/2014 07:05 AM, Antti Palosaari wrote: > Cc: Hans Verkuil <hverkuil@xs4all.nl> > Signed-off-by: Antti Palosaari <crope@iki.fi> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Thanks! Hans > --- > 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(+) > > diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp > index 13ee8ec..925d73d 100644 > --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp > +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp > @@ -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); > + } > } > diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp > index 855613c..a602366 100644 > --- a/utils/v4l2-ctl/v4l2-ctl.cpp > +++ b/utils/v4l2-ctl/v4l2-ctl.cpp > @@ -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}, > diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h > index 108198d..1caac34 100644 > --- a/utils/v4l2-ctl/v4l2-ctl.h > +++ b/utils/v4l2-ctl/v4l2-ctl.h > @@ -139,6 +139,7 @@ enum Option { > OptListBuffersSlicedVbi, > OptListBuffersVbiOut, > OptListBuffersSlicedVbiOut, > + OptListBuffersSdr, > OptStreamCount, > OptStreamSkip, > OptStreamLoop, > ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-02-10 9:17 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-02-09 6:05 [PATCH 0/5] v4l2-ctl: add SDR device support Antti Palosaari 2014-02-09 6:05 ` [PATCH 1/5] libdvbv5: better handle ATSC/Annex B Antti Palosaari 2014-02-09 6:05 ` [PATCH 2/5] synch videodev2.h headers with kernel SDR API Antti Palosaari 2014-02-10 9:08 ` Hans Verkuil 2014-02-10 9:17 ` Antti Palosaari 2014-02-09 6:05 ` [PATCH 3/5] v4l2-ctl: add tuner support for SDR tuners Antti Palosaari 2014-02-10 9:10 ` Hans Verkuil 2014-02-09 6:05 ` [PATCH 4/5] v4l2-ctl: add support for SDR FMT Antti Palosaari 2014-02-10 9:11 ` Hans Verkuil 2014-02-09 6:05 ` [PATCH 5/5] v4l2-ctl: implement list SDR buffers command Antti Palosaari 2014-02-10 9:11 ` Hans Verkuil
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox