SDR API with documentation
Subsystems (3)
v7 cover SDR API with documentation
Changes done according to Hans comments.
I also added patch which marks that API as a experimental as it it indeed experimental. I think that this whole patch serie is ready for staging!
regards
Antti
Antti Palosaari (11):
v4l: add device type for Software Defined Radio
v4l: add new tuner types for SDR
v4l: 1 Hz resolution flag for tuners
v4l: add stream format for SDR receiver
v4l: define own IOCTL ops for SDR FMT
v4l: enable some IOCTLs for SDR receiver
v4l: add device capability flag for SDR receiver
DocBook: document 1 Hz flag
DocBook: Software Defined Radio Interface
DocBook: mark SDR API as Experimental v4l2-framework.txt: add SDR device type
Hans Verkuil (1):
v4l: do not allow modulator ioctls for non-radio devices
Documentation/DocBook/media/v4l/compat.xml | 13 +++ Documentation/DocBook/media/v4l/dev-sdr.xml | 110 +++++++++++++++++++++ Documentation/DocBook/media/v4l/io.xml | 6 ++ Documentation/DocBook/media/v4l/pixfmt.xml | 8 ++ Documentation/DocBook/media/v4l/v4l2.xml | 1 + .../DocBook/media/v4l/vidioc-enum-freq-bands.xml | 8 +- Documentation/DocBook/media/v4l/vidioc-g-fmt.xml | 7 ++ .../DocBook/media/v4l/vidioc-g-frequency.xml | 5 +- .../DocBook/media/v4l/vidioc-g-modulator.xml | 6 +- Documentation/DocBook/media/v4l/vidioc-g-tuner.xml | 15 ++- .../DocBook/media/v4l/vidioc-querycap.xml | 6 ++ .../DocBook/media/v4l/vidioc-s-hw-freq-seek.xml | 8 +- Documentation/video4linux/v4l2-framework.txt | 1 + drivers/media/v4l2-core/v4l2-dev.c | 30 +++++- drivers/media/v4l2-core/v4l2-ioctl.c | 75 +++++++++++--- include/media/v4l2-dev.h | 3 +- include/media/v4l2-ioctl.h | 8 ++ include/trace/events/v4l2.h | 1 + include/uapi/linux/videodev2.h | 16 +++ 19 files changed, 299 insertions(+), 28 deletions(-) create mode 100644 Documentation/DocBook/media/v4l/dev-sdr.xml
Signature · 1 line
1.8.4.2
RFC PATCH v7 1/12 v4l: add device type for Software Defined Radio
Add new V4L device type VFL_TYPE_SDR for Software Defined Radio. It is registered as /dev/swradio0 (/dev/sdr0 was already reserved).
--- drivers/media/v4l2-core/v4l2-dev.c | 6 ++++++ include/media/v4l2-dev.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-dev.c +6 -0
@@ -758,6 +758,8 @@ static void determine_valid_ioctls(struct video_device *vdev)* %VFL_TYPE_RADIO - A radio card * * %VFL_TYPE_SUBDEV - A subdevice +* +* %VFL_TYPE_SDR - Software Defined Radio */ int __video_register_device (struct video_device *vdev,int type,int nr,int warn_if_nr_in_use,struct module *owner)
@@ -797,6 +799,10 @@ int __video_register_device(struct video_device *vdev, int type, int nr,case VFL_TYPE_SUBDEV : name_base ="v4l-subdev" ;break ; +case VFL_TYPE_SDR : +/* Use device name 'swradio' because 'sdr' was already taken. */ + name_base ="swradio" ; +break ;default :printk (KERN_ERR "%s called with unknown type: %d\n" , __func__, type);
include/media/v4l2-dev.h +2 -1
@@ -24,7 +24,8 @@#define VFL_TYPE_VBI 1#define VFL_TYPE_RADIO 2#define VFL_TYPE_SUBDEV 3 -#define VFL_TYPE_MAX 4 +#define VFL_TYPE_SDR 4 +#define VFL_TYPE_MAX 5/* Is this a receiver, transmitter or mem-to-mem? */ /* Ignored for VFL_TYPE_SUBDEV. */
Signature · 1 line
1.8.4.2
RFC PATCH v7 2/12 v4l: add new tuner types for SDR
In reply to Antti PalosaariDefine tuner types V4L2_TUNER_ADC and V4L2_TUNER_RF for SDR usage.
ADC is used for setting sampling rate (sampling frequency) to SDR device.
Another tuner type, named as V4L2_TUNER_RF, is possible RF tuner. Is is used to down-convert RF frequency to range ADC could sample. Having RF tuner is optional, whilst in practice it is almost always there.
Also add checks to VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY and VIDIOC_ENUM_FREQ_BANDS only allow these two tuner types when device type is SDR (VFL_TYPE_SDR). For VIDIOC_G_FREQUENCY we do not check tuner type, instead override type with V4L2_TUNER_ADC in every case (requested by Hans in order to keep functionality in line with existing tuners and existing API does not specify it).
Prohibit VIDIOC_S_HW_FREQ_SEEK explicitly when device type is SDR, as device cannot do hardware seek without a hardware demodulator.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 39 ++++++++++++++++++++++++++---------- include/uapi/linux/videodev2.h | 2 ++ 2 files changed, 30 insertions(+), 11 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +28 -11
@@ -1291,8 +1291,11 @@ static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops,struct video_device *vfd =video_devdata (file);struct v4l2_frequency *p = arg; - p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ? -V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; +if (vfd->vfl_type ==VFL_TYPE_SDR ) + p->type =V4L2_TUNER_ADC ; +else + p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ? +V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ;return ops->vidioc_g_frequency (file, fh, p); }
@@ -1303,10 +1306,15 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,const struct v4l2_frequency *p = arg;enum v4l2_tuner_type type; - type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ? -V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; -if (p->type != type) -return -EINVAL ; +if (vfd->vfl_type ==VFL_TYPE_SDR ) { +if (p->type !=V4L2_TUNER_ADC && p->type !=V4L2_TUNER_RF ) +return -EINVAL ; + }else { + type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ? +V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; +if (type != p->type) +return -EINVAL ; + }return ops->vidioc_s_frequency (file, fh, p); }
@@ -1386,6 +1394,10 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops,struct v4l2_hw_freq_seek *p = arg;enum v4l2_tuner_type type; +/* s_hw_freq_seek is not supported for SDR for now */ +if (vfd->vfl_type ==VFL_TYPE_SDR ) +return -EINVAL ; + type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ;if (p->type != type)
@@ -1885,11 +1897,16 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,enum v4l2_tuner_type type;int err; - type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ? -V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; - -if (type != p->type) -return -EINVAL ; +if (vfd->vfl_type ==VFL_TYPE_SDR ) { +if (p->type !=V4L2_TUNER_ADC && p->type !=V4L2_TUNER_RF ) +return -EINVAL ; + type = p->type; + }else { + type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ? +V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ; +if (type != p->type) +return -EINVAL ; + }if (ops->vidioc_enum_freq_bands)return ops->vidioc_enum_freq_bands (file, fh, p);if (is_valid_ioctl (vfd,VIDIOC_G_TUNER )) {
include/uapi/linux/videodev2.h +2 -0
@@ -159,6 +159,8 @@ enum v4l2_tuner_type {V4L2_TUNER_RADIO =1 ,V4L2_TUNER_ANALOG_TV =2 ,V4L2_TUNER_DIGITAL_TV =3 , +V4L2_TUNER_ADC =4 , + V4L2_TUNER_RF = 5, }; enum v4l2_memory {
Signature · 1 line
1.8.4.2
RFC PATCH v7 3/12 v4l: 1 Hz resolution flag for tuners
In reply to Antti PalosaariAdd V4L2_TUNER_CAP_1HZ for 1 Hz resolution.
--- include/uapi/linux/videodev2.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/videodev2.h +1 -0
@@ -1341,6 +1341,7 @@ struct v4l2_modulator {#define V4L2_TUNER_CAP_RDS_CONTROLS 0x0200#define V4L2_TUNER_CAP_FREQ_BANDS 0x0400#define V4L2_TUNER_CAP_HWSEEK_PROG_LIM 0x0800 +#define V4L2_TUNER_CAP_1HZ 0x1000/* Flags for the 'rxsubchans' field */ #define V4L2_TUNER_SUB_MONO 0x0001
Signature · 1 line
1.8.4.2
RFC PATCH v7 4/12 v4l: add stream format for SDR receiver
In reply to Antti PalosaariAdd new V4L2 stream format definition, V4L2_BUF_TYPE_SDR_CAPTURE, for SDR receiver.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/trace/events/v4l2.h | 1 + include/uapi/linux/videodev2.h | 11 +++++++++++ 3 files changed, 13 insertions(+)
drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
@@ -152,6 +152,7 @@ const char *v4l2_type_names[] = { [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "vid-out-overlay", [V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE] = "vid-cap-mplane", [V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE] = "vid-out-mplane", + [V4L2_BUF_TYPE_SDR_CAPTURE ] ="sdr-cap" , };EXPORT_SYMBOL (v4l2_type_names);
include/trace/events/v4l2.h +1 -0
@@ -18,6 +18,7 @@ { V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" },\ { V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" },\ { V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, "VIDEO_OUTPUT_MPLANE" }, \ + { V4L2_BUF_TYPE_SDR_CAPTURE, "SDR_CAPTURE" }, \ { V4L2_BUF_TYPE_PRIVATE, "PRIVATE" }) #define show_field(field) \
include/uapi/linux/videodev2.h +11 -0
@@ -139,6 +139,7 @@ enum v4l2_buf_type {#endif V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE =9 ,V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE =10 , +V4L2_BUF_TYPE_SDR_CAPTURE =11 ,/* Deprecated, do not use */ V4L2_BUF_TYPE_PRIVATE = 0x80, };
@@ -1695,6 +1696,15 @@ struct v4l2_pix_format_mplane { } __attribute__ ((packed));/** +* struct v4l2_format_sdr - SDR format definition +* @pixelformat: little endian four character code (fourcc) +*/ +struct v4l2_format_sdr { +__u32 pixelformat; +__u8 reserved[28 ]; +} __attribute__ ((packed)); + +/** * struct v4l2_format - stream data format * @type: enum v4l2_buf_type; type of the data stream * @pix: definition of an image format
@@ -1712,6 +1722,7 @@ struct v4l2_format {struct v4l2_window win;/* V4L2_BUF_TYPE_VIDEO_OVERLAY */ struct v4l2_vbi_format vbi;/* V4L2_BUF_TYPE_VBI_CAPTURE */ struct v4l2_sliced_vbi_format sliced;/* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */ +struct v4l2_format_sdr sdr;/* V4L2_BUF_TYPE_SDR_CAPTURE */ __u8 raw_data[200 ];/* user-defined */ } fmt; };
Signature · 1 line
1.8.4.2
RFC PATCH v7 5/12 v4l: define own IOCTL ops for SDR FMT
In reply to Antti PalosaariUse own format ops for SDR data:vidioc_enum_fmt_sdr_capvidioc_g_fmt_sdr_capvidioc_s_fmt_sdr_capvidioc_try_fmt_sdr_cap
--- include/media/v4l2-ioctl.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/media/v4l2-ioctl.h +8 -0
@@ -40,6 +40,8 @@ struct v4l2_ioctl_ops { struct v4l2_fmtdesc *f);int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file,void *fh,struct v4l2_fmtdesc *f); +int (*vidioc_enum_fmt_sdr_cap) (struct file *file,void *fh, +struct v4l2_fmtdesc *f);/* VIDIOC_G_FMT handlers */ int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
@@ -62,6 +64,8 @@ struct v4l2_ioctl_ops { struct v4l2_format *f);int (*vidioc_g_fmt_vid_out_mplane)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_g_fmt_sdr_cap) (struct file *file,void *fh, +struct v4l2_format *f);/* VIDIOC_S_FMT handlers */ int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
@@ -84,6 +88,8 @@ struct v4l2_ioctl_ops { struct v4l2_format *f);int (*vidioc_s_fmt_vid_out_mplane)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_s_fmt_sdr_cap) (struct file *file,void *fh, +struct v4l2_format *f);/* VIDIOC_TRY_FMT handlers */ int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
@@ -106,6 +112,8 @@ struct v4l2_ioctl_ops { struct v4l2_format *f);int (*vidioc_try_fmt_vid_out_mplane)(struct file *file,void *fh,struct v4l2_format *f); +int (*vidioc_try_fmt_sdr_cap) (struct file *file,void *fh, +struct v4l2_format *f);/* Buffer handlers */ int (*vidioc_reqbufs) (struct file *file,void *fh,struct v4l2_requestbuffers *b);
Signature · 1 line
1.8.4.2
RFC PATCH v7 6/12 v4l: enable some IOCTLs for SDR receiver
In reply to Antti PalosaariEnable stream format (FMT) IOCTLs for SDR use. These are used for negotiate used data stream format.
Reorganise some some IOCTL selection logic.
--- drivers/media/v4l2-core/v4l2-dev.c | 21 ++++++++++++++++++--- drivers/media/v4l2-core/v4l2-ioctl.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +18 -3
@@ -553,7 +553,7 @@ static void determine_valid_ioctls(struct video_device *vdev)const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops;bool is_vid = vdev->vfl_type ==VFL_TYPE_GRABBER ;bool is_vbi = vdev->vfl_type ==VFL_TYPE_VBI ; -bool is_radio = vdev->vfl_type ==VFL_TYPE_RADIO ; +bool is_sdr = vdev->vfl_type ==VFL_TYPE_SDR ;bool is_rx = vdev->vfl_dir !=VFL_DIR_TX ;bool is_tx = vdev->vfl_dir !=VFL_DIR_RX ;
@@ -662,9 +662,20 @@ static void determine_valid_ioctls(struct video_device *vdev) ops->vidioc_try_fmt_sliced_vbi_out)))set_bit (_IOC_NR (VIDIOC_TRY_FMT ), valid_ioctls);SET_VALID_IOCTL (ops,VIDIOC_G_SLICED_VBI_CAP , vidioc_g_sliced_vbi_cap); + }else if (is_sdr) { +/* SDR specific ioctls */ +if (ops->vidioc_enum_fmt_sdr_cap) +set_bit (_IOC_NR (VIDIOC_ENUM_FMT ), valid_ioctls); +if (ops->vidioc_g_fmt_sdr_cap) +set_bit (_IOC_NR (VIDIOC_G_FMT ), valid_ioctls); +if (ops->vidioc_s_fmt_sdr_cap) +set_bit (_IOC_NR (VIDIOC_S_FMT ), valid_ioctls); +if (ops->vidioc_try_fmt_sdr_cap) +set_bit (_IOC_NR (VIDIOC_TRY_FMT ), valid_ioctls); } -if (!is_radio) { -/* ioctls valid for video or vbi */ + +if (is_vid || is_vbi || is_sdr) { +/* ioctls valid for video, vbi or sdr */ SET_VALID_IOCTL (ops,VIDIOC_REQBUFS , vidioc_reqbufs);SET_VALID_IOCTL (ops,VIDIOC_QUERYBUF , vidioc_querybuf);SET_VALID_IOCTL (ops,VIDIOC_QBUF , vidioc_qbuf);
@@ -672,6 +683,10 @@ static void determine_valid_ioctls(struct video_device *vdev)SET_VALID_IOCTL (ops,VIDIOC_DQBUF , vidioc_dqbuf);SET_VALID_IOCTL (ops,VIDIOC_CREATE_BUFS , vidioc_create_bufs);SET_VALID_IOCTL (ops,VIDIOC_PREPARE_BUF , vidioc_prepare_buf); + } + +if (is_vid || is_vbi) { +/* ioctls valid for video or vbi */ if (ops->vidioc_s_std)set_bit (_IOC_NR (VIDIOC_ENUMSTD ), valid_ioctls);SET_VALID_IOCTL (ops,VIDIOC_S_STD , vidioc_s_std);
drivers/media/v4l2-core/v4l2-ioctl.c +35 -0
@@ -246,6 +246,7 @@ static void v4l_print_format(const void *arg, bool write_only)const struct v4l2_vbi_format *vbi;const struct v4l2_sliced_vbi_format *sliced;const struct v4l2_window *win; +const struct v4l2_format_sdr *sdr;unsigned i;pr_cont ("type=%s" ,prt_names (p->type, v4l2_type_names));
@@ -319,6 +320,14 @@ static void v4l_print_format(const void *arg, bool write_only) sliced->service_lines[0 ][i], sliced->service_lines[1][i]);break ; +case V4L2_BUF_TYPE_SDR_CAPTURE : + sdr = &p->fmt.sdr; +pr_cont (", pixelformat=%c%c%c%c\n" , + (sdr->pixelformat >>0 ) &0xff , + (sdr->pixelformat >>8 ) &0xff , + (sdr->pixelformat >>16 ) &0xff , + (sdr->pixelformat >>24 ) &0xff ); +break ; } }
@@ -882,6 +891,7 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;bool is_vid = vfd->vfl_type ==VFL_TYPE_GRABBER ;bool is_vbi = vfd->vfl_type ==VFL_TYPE_VBI ; +bool is_sdr = vfd->vfl_type ==VFL_TYPE_SDR ;bool is_rx = vfd->vfl_dir !=VFL_DIR_TX ;bool is_tx = vfd->vfl_dir !=VFL_DIR_RX ;
@@ -931,6 +941,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)if (is_vbi && is_tx && ops->vidioc_g_fmt_sliced_vbi_out)return 0 ;break ; +case V4L2_BUF_TYPE_SDR_CAPTURE : +if (is_sdr && is_rx && ops->vidioc_g_fmt_sdr_cap) +return 0 ; +break ;default :break ; }
@@ -1050,6 +1064,10 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,if (unlikely (!is_tx || !ops->vidioc_enum_fmt_vid_out_mplane))break ;return ops->vidioc_enum_fmt_vid_out_mplane (file, fh, arg); +case V4L2_BUF_TYPE_SDR_CAPTURE : +if (unlikely (!is_rx || !ops->vidioc_enum_fmt_sdr_cap)) +break ; +return ops->vidioc_enum_fmt_sdr_cap (file, fh, arg); }return -EINVAL ; }
@@ -1060,6 +1078,7 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);bool is_vid = vfd->vfl_type ==VFL_TYPE_GRABBER ; +bool is_sdr = vfd->vfl_type ==VFL_TYPE_SDR ;bool is_rx = vfd->vfl_dir !=VFL_DIR_TX ;bool is_tx = vfd->vfl_dir !=VFL_DIR_RX ;
@@ -1104,6 +1123,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,if (unlikely (!is_tx || is_vid || !ops->vidioc_g_fmt_sliced_vbi_out))break ;return ops->vidioc_g_fmt_sliced_vbi_out (file, fh, arg); +case V4L2_BUF_TYPE_SDR_CAPTURE : +if (unlikely (!is_rx || !is_sdr || !ops->vidioc_g_fmt_sdr_cap)) +break ; +return ops->vidioc_g_fmt_sdr_cap (file, fh, arg); }return -EINVAL ; }
@@ -1114,6 +1137,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);bool is_vid = vfd->vfl_type ==VFL_TYPE_GRABBER ; +bool is_sdr = vfd->vfl_type ==VFL_TYPE_SDR ;bool is_rx = vfd->vfl_dir !=VFL_DIR_TX ;bool is_tx = vfd->vfl_dir !=VFL_DIR_RX ;
@@ -1168,6 +1192,11 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,break ;CLEAR_AFTER_FIELD (p, fmt.sliced);return ops->vidioc_s_fmt_sliced_vbi_out (file, fh, arg); +case V4L2_BUF_TYPE_SDR_CAPTURE : +if (unlikely (!is_rx || !is_sdr || !ops->vidioc_s_fmt_sdr_cap)) +break ; +CLEAR_AFTER_FIELD (p, fmt.sdr); +return ops->vidioc_s_fmt_sdr_cap (file, fh, arg); }return -EINVAL ; }
@@ -1178,6 +1207,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,struct v4l2_format *p = arg;struct video_device *vfd =video_devdata (file);bool is_vid = vfd->vfl_type ==VFL_TYPE_GRABBER ; +bool is_sdr = vfd->vfl_type ==VFL_TYPE_SDR ;bool is_rx = vfd->vfl_dir !=VFL_DIR_TX ;bool is_tx = vfd->vfl_dir !=VFL_DIR_RX ;
@@ -1232,6 +1262,11 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,break ;CLEAR_AFTER_FIELD (p, fmt.sliced);return ops->vidioc_try_fmt_sliced_vbi_out (file, fh, arg); +case V4L2_BUF_TYPE_SDR_CAPTURE : +if (unlikely (!is_rx || !is_sdr || !ops->vidioc_try_fmt_sdr_cap)) +break ; +CLEAR_AFTER_FIELD (p, fmt.sdr); +return ops->vidioc_try_fmt_sdr_cap (file, fh, arg); }return -EINVAL ; }
Signature · 1 line
1.8.4.2
RFC PATCH v7 7/12 v4l: add device capability flag for SDR receiver
In reply to Antti PalosaariVIDIOC_QUERYCAP IOCTL is used to query device capabilities. Add new capability flag to inform given device supports SDR capture.
--- include/uapi/linux/videodev2.h | 2 ++ 1 file changed, 2 insertions(+)
include/uapi/linux/videodev2.h +2 -0
@@ -267,6 +267,8 @@ struct v4l2_capability {#define V4L2_CAP_RADIO 0x00040000/* is a radio device */ #define V4L2_CAP_MODULATOR 0x00080000/* has a modulator */ +#define V4L2_CAP_SDR_CAPTURE 0x00100000/* Is a SDR capture device */ +#define V4L2_CAP_READWRITE 0x01000000/* read/write systemcalls */ #define V4L2_CAP_ASYNCIO 0x02000000/* async I/O */ #define V4L2_CAP_STREAMING 0x04000000/* streaming I/O ioctls */
Signature · 1 line
1.8.4.2
RFC PATCH v7 8/12 v4l: do not allow modulator ioctls for non-radio devices
In reply to Antti PalosaariFrom: Hans Verkuil <[email protected]>
Modulator ioctls could be enabled mistakenly for non-radio devices. Currently those ioctls are only valid for radio. Fix it.
--- drivers/media/v4l2-core/v4l2-dev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +3 -2
@@ -553,6 +553,7 @@ static void determine_valid_ioctls(struct video_device *vdev)const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops;bool is_vid = vdev->vfl_type ==VFL_TYPE_GRABBER ;bool is_vbi = vdev->vfl_type ==VFL_TYPE_VBI ; +bool is_radio = vdev->vfl_type ==VFL_TYPE_RADIO ;bool is_sdr = vdev->vfl_type ==VFL_TYPE_SDR ;bool is_rx = vdev->vfl_dir !=VFL_DIR_TX ;bool is_tx = vdev->vfl_dir !=VFL_DIR_RX ;
@@ -726,8 +727,8 @@ static void determine_valid_ioctls(struct video_device *vdev)SET_VALID_IOCTL (ops,VIDIOC_ENUM_DV_TIMINGS , vidioc_enum_dv_timings);SET_VALID_IOCTL (ops,VIDIOC_DV_TIMINGS_CAP , vidioc_dv_timings_cap); } -if (is_tx) { -/* transmitter only ioctls */ +if (is_tx && (is_radio || is_sdr)) { +/* radio transmitter only ioctls */ SET_VALID_IOCTL (ops,VIDIOC_G_MODULATOR , vidioc_g_modulator);SET_VALID_IOCTL (ops,VIDIOC_S_MODULATOR , vidioc_s_modulator); }
Signature · 1 line
1.8.4.2
RFC PATCH v7 9/12 DocBook: document 1 Hz flag
In reply to Antti PalosaariUpdate documentation to reflect 1 Hz frequency step flag.
--- .../DocBook/media/v4l/vidioc-enum-freq-bands.xml | 8 +++++--- Documentation/DocBook/media/v4l/vidioc-g-frequency.xml | 5 +++-- Documentation/DocBook/media/v4l/vidioc-g-modulator.xml | 6 ++++-- Documentation/DocBook/media/v4l/vidioc-g-tuner.xml | 15 ++++++++++++--- Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml | 8 ++++++-- 5 files changed, 30 insertions(+), 12 deletions(-)
Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml +5 -3
@@ -100,7 +100,7 @@ See <xref linkend="v4l2-tuner-type" /></entry> <entry><structfield>capability</structfield></entry> <entry spanname="hspan">The tuner/modulator capability flags for this frequency band, see <xref linkend="tuner-capability" />. The <constant>V4L2_TUNER_CAP_LOW</constant> -capability must be the same for all frequency bands of the selected tuner/modulator. +or <constant>V4L2_TUNER_CAP_1HZ</constant> capability must be the same for all frequency bands of the selected tuner/modulator. So either all bands have that capability set, or none of them have that capability.</entry> </row> <row>
@@ -109,7 +109,8 @@ So either all bands have that capability set, or none of them have that capabili <entry spanname="hspan">The lowest tunable frequency in units of 62.5 kHz, or if the <structfield>capability</structfield> flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 -Hz, for this frequency band.</entry> +Hz, for this frequency band. A 1 Hz unit is used when the <structfield>capability</structfield> flag +<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry> </row> <row> <entry>__u32</entry>
@@ -117,7 +118,8 @@ Hz, for this frequency band.</entry> <entry spanname="hspan">The highest tunable frequency in units of 62.5 kHz, or if the <structfield>capability</structfield> flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 -Hz, for this frequency band.</entry> +Hz, for this frequency band. A 1 Hz unit is used when the <structfield>capability</structfield> flag +<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry> </row> <row> <entry>__u32</entry>
Documentation/DocBook/media/v4l/vidioc-g-frequency.xml +3 -2
@@ -109,9 +109,10 @@ See <xref linkend="v4l2-tuner-type" /></entry> <entry>__u32</entry> <entry><structfield>frequency</structfield></entry> <entry>Tuning frequency in units of 62.5 kHz, or if the -&v4l2-tuner; or &v4l2-modulator; <structfield>capabilities</structfield> flag +&v4l2-tuner; or &v4l2-modulator; <structfield>capability</structfield> flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 -Hz.</entry> +Hz. A 1 Hz unit is used when the <structfield>capability</structfield> flag +<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry> </row> <row> <entry>__u32</entry>
Documentation/DocBook/media/v4l/vidioc-g-modulator.xml +4 -2
@@ -113,7 +113,8 @@ change for example with the current video standard.</entry> <entry>The lowest tunable frequency in units of 62.5 KHz, or if the <structfield>capability</structfield> flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 -Hz.</entry> +Hz, or if the <structfield>capability</structfield> flag +<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz.</entry> </row> <row> <entry>__u32</entry>
@@ -121,7 +122,8 @@ Hz.</entry> <entry>The highest tunable frequency in units of 62.5 KHz, or if the <structfield>capability</structfield> flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 -Hz.</entry> +Hz, or if the <structfield>capability</structfield> flag +<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz.</entry> </row> <row> <entry>__u32</entry>
Documentation/DocBook/media/v4l/vidioc-g-tuner.xml +12 -3
@@ -134,7 +134,9 @@ the structure refers to a radio tuner the <entry spanname="hspan">The lowest tunable frequency in units of 62.5 kHz, or if the <structfield>capability</structfield> flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 -Hz. If multiple frequency bands are supported, then +Hz, or if the <structfield>capability</structfield> flag +<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz. +If multiple frequency bands are supported, then <structfield>rangelow</structfield> is the lowest frequency of all the frequency bands.</entry> </row>
@@ -144,7 +146,9 @@ of all the frequency bands.</entry> <entry spanname="hspan">The highest tunable frequency in units of 62.5 kHz, or if the <structfield>capability</structfield> flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 -Hz. If multiple frequency bands are supported, then +Hz, or if the <structfield>capability</structfield> flag +<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz. +If multiple frequency bands are supported, then <structfield>rangehigh</structfield> is the highest frequency of all the frequency bands.</entry> </row>
@@ -270,7 +274,7 @@ applications must set the array to zero.</entry> <entry><constant>V4L2_TUNER_CAP_LOW</constant></entry> <entry>0x0001</entry> <entry>When set, tuning frequencies are expressed in units of -62.5 Hz, otherwise in units of 62.5 kHz.</entry> +62.5 Hz instead of 62.5 kHz.</entry> </row> <row> <entry><constant>V4L2_TUNER_CAP_NORM</constant></entry>
@@ -360,6 +364,11 @@ radio tuners.</entry> <entry>The range to search when using the hardware seek functionality is programmable, see &VIDIOC-S-HW-FREQ-SEEK; for details.</entry> </row> + <row> + <entry><constant>V4L2_TUNER_CAP_1HZ</constant></entry> + <entry>0x1000</entry> + <entry>When set, tuning frequencies are expressed in units of 1 Hz instead of 62.5 kHz.</entry> + </row> </tbody> </tgroup> </table>
Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml +6 -2
@@ -121,7 +121,9 @@ field and the &v4l2-tuner; <structfield>index</structfield> field.</entry> <entry>If non-zero, the lowest tunable frequency of the band to search in units of 62.5 kHz, or if the &v4l2-tuner; <structfield>capability</structfield> field has the -<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz. +<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz or if the &v4l2-tuner; +<structfield>capability</structfield> field has the +<constant>V4L2_TUNER_CAP_1HZ</constant> flag set, in units of 1 Hz. If <structfield>rangelow</structfield> is zero a reasonable default value is used.</entry> </row>
@@ -131,7 +133,9 @@ is used.</entry> <entry>If non-zero, the highest tunable frequency of the band to search in units of 62.5 kHz, or if the &v4l2-tuner; <structfield>capability</structfield> field has the -<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz. +<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz or if the &v4l2-tuner; +<structfield>capability</structfield> field has the +<constant>V4L2_TUNER_CAP_1HZ</constant> flag set, in units of 1 Hz. If <structfield>rangehigh</structfield> is zero a reasonable default value is used.</entry> </row>
Signature · 1 line
1.8.4.2
RFC PATCH v7 10/12 DocBook: Software Defined Radio Interface
In reply to Antti PalosaariDocument V4L2 SDR interface.
--- Documentation/DocBook/media/v4l/compat.xml | 10 ++ Documentation/DocBook/media/v4l/dev-sdr.xml | 104 +++++++++++++++++++++ Documentation/DocBook/media/v4l/io.xml | 6 ++ Documentation/DocBook/media/v4l/pixfmt.xml | 8 ++ Documentation/DocBook/media/v4l/v4l2.xml | 1 + Documentation/DocBook/media/v4l/vidioc-g-fmt.xml | 7 ++ .../DocBook/media/v4l/vidioc-querycap.xml | 6 ++ 7 files changed, 142 insertions(+) create mode 100644 Documentation/DocBook/media/v4l/dev-sdr.xml
Documentation/DocBook/media/v4l/compat.xml +10 -0
@@ -2535,6 +2535,16 @@ fields changed from _s32 to _u32. </orderedlist> </section> + <section> + <title>V4L2 in Linux 3.14</title> + <orderedlist> + <listitem> + <para>Added Software Defined Radio (SDR) Interface. + </para> + </listitem> + </orderedlist> + </section> + <section id="other"> <title>Relation of V4L2 to other Linux multimedia APIs</title>
Documentation/DocBook/media/v4l/dev-sdr.xml new file +104 -0
104 lines not on this page · raw message
Documentation/DocBook/media/v4l/io.xml +6 -0
@@ -1005,6 +1005,12 @@ should set this to 0.</entry> <entry>Buffer for video output overlay (OSD), see <xref linkend="osd" />.</entry> </row> + <row> + <entry><constant>V4L2_BUF_TYPE_SDR_CAPTURE</constant></entry> + <entry>11</entry> + <entry>Buffer for Software Defined Radio (SDR), see <xref + linkend="sdr" />.</entry> + </row> </tbody> </tgroup> </table>
Documentation/DocBook/media/v4l/pixfmt.xml +8 -0
@@ -811,6 +811,14 @@ extended control <constant>V4L2_CID_MPEG_STREAM_TYPE</constant>, see </table> </section> + <section id="sdr-formats"> + <title>SDR Formats</title> + + <para>These formats are used for <link linkend="sdr">SDR Capture</link> +interface only.</para> + + </section> + <section id="pixfmt-reserved"> <title>Reserved Format Identifiers</title>
Documentation/DocBook/media/v4l/v4l2.xml +1 -0
@@ -537,6 +537,7 @@ and discussions on the V4L mailing list.</revremark> <section id="ttx"> &sub-dev-teletext; </section> <section id="radio"> &sub-dev-radio; </section> <section id="rds"> &sub-dev-rds; </section> + <section id="sdr"> &sub-dev-sdr; </section> <section id="event"> &sub-dev-event; </section> <section id="subdev"> &sub-dev-subdev; </section> </chapter>
Documentation/DocBook/media/v4l/vidioc-g-fmt.xml +7 -0
@@ -172,6 +172,13 @@ capture and output devices.</entry> </row> <row> <entry></entry> + <entry>&v4l2-format-sdr;</entry> + <entry><structfield>sdr</structfield></entry> + <entry>Definition of an data format, see +<xref linkend="pixfmt" />, used by SDR capture devices.</entry> + </row> + <row> + <entry></entry> <entry>__u8</entry> <entry><structfield>raw_data</structfield>[200]</entry> <entry>Place holder for future extensions.</entry>
Documentation/DocBook/media/v4l/vidioc-querycap.xml +6 -0
@@ -296,6 +296,12 @@ modulator programming see <xref linkend="tuner" />.</entry> </row> <row> + <entry><constant>V4L2_CAP_SDR_CAPTURE</constant></entry> + <entry>0x00100000</entry> + <entry>The device supports the +<link linkend="sdr">SDR Capture</link> interface.</entry> + </row> + <row> <entry><constant>V4L2_CAP_READWRITE</constant></entry> <entry>0x01000000</entry> <entry>The device supports the <link
Signature · 1 line
1.8.4.2
RFC PATCH v7 11/12 DocBook: mark SDR API as Experimental
In reply to Antti PalosaariLet it be experimental still as all SDR drivers are in staging.
--- Documentation/DocBook/media/v4l/compat.xml | 3 +++ Documentation/DocBook/media/v4l/dev-sdr.xml | 6 ++++++ 2 files changed, 9 insertions(+)
Documentation/DocBook/media/v4l/compat.xml +3 -0
@@ -2661,6 +2661,9 @@ ioctls.</para> <listitem> <para>Exporting DMABUF files using &VIDIOC-EXPBUF; ioctl.</para> </listitem> + <listitem> + <para>Software Defined Radio (SDR) Interface, <xref linkend="sdr" />.</para> + </listitem> </itemizedlist> </section>
Documentation/DocBook/media/v4l/dev-sdr.xml +6 -0
@@ -1,5 +1,11 @@ <title>Software Defined Radio Interface (SDR)</title> + <note> + <title>Experimental</title> + <para>This is an <link linkend="experimental"> experimental </link> + interface and may change in the future.</para> + </note> + <para> SDR is an abbreviation of Software Defined Radio, the radio device which uses application software for modulation or demodulation. This interface
Signature · 1 line
1.8.4.2
RFC PATCH v7 12/12 v4l2-framework.txt: add SDR device type
In reply to Antti PalosaariAdd SDR device type to v4l2-framework.txt document.
--- Documentation/video4linux/v4l2-framework.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/video4linux/v4l2-framework.txt +1 -0
@@ -768,6 +768,7 @@ types exist: VFL_TYPE_GRABBER: videoX for video input/output devices VFL_TYPE_VBI: vbiX for vertical blank data (i.e. closed captions, teletext) VFL_TYPE_RADIO: radioX for radio tuners +VFL_TYPE_SDR: swradioX for Software Defined Radio tuners The last argument gives you a certain amount of control over the device device node number used (i.e. the X in videoX). Normally you will pass -1
Signature · 1 line
1.8.4.2