SDR sampling rate - control or IOCTL?
Hello
I am adding new property for sampling rate that is ideally the only obligatory parameter required by SDR. It is value that could be only positive and bigger the better, lets say unsigned 64 bit is quite ideal. That value sets maximum radio frequency possible to receive (ideal SDR).
Valid values are not always in some single range from X to Y, there could be some multiple value ranges.
For example possible values: 1000-2000, 23459, 900001-2800000
Reading possible values from device could be nice, but not necessary. Reading current value is more important.
Here is what I though earlier as a requirements:
sampling rate
* values: 1 - infinity (unit: Hz, samples per second) currently 500 MHz is more than enough
* operations
GET, inquire what HW supports
GET, get current value
SET, set desired value
I am not sure what is best way to implement that kind of thing. IOCTL like frequency
V4L2 Control?
put it into stream format request?
Sampling rate is actually frequency of ADC. As there devices has almost always tuner too (practical SDR) there is need for tuner frequency too. As tuner is still own entity, is it possible to use same frequency parameter for both ADC and RF tuner in same device?
regards
Antti
Signature · 1 line
http://palosaari.fi/
Em Thu, 21 Nov 2013 19:05:05 +0200
Antti Palosaari <[email protected]> escreveu:
Quoted 30 lines
Hello
I am adding new property for sampling rate that is ideally the only obligatory parameter required by SDR. It is value that could be only positive and bigger the better, lets say unsigned 64 bit is quite ideal. That value sets maximum radio frequency possible to receive (ideal SDR).Valid values are not always in some single range from X to Y, there could be some multiple value ranges.
For example possible values: 1000-2000, 23459, 900001-2800000
Reading possible values from device could be nice, but not necessary. Reading current value is more important.
Here is what I though earlier as a requirements:
sampling rate
* values: 1 - infinity (unit: Hz, samples per second) currently 500 MHz is more than enough
* operations
GET, inquire what HW supports
GET, get current value
SET, set desired valueI am not sure what is best way to implement that kind of thing. IOCTL like frequency
V4L2 Control?
put it into stream format request?
Quoted 4 lines
Sampling rate is actually frequency of ADC. As there devices has almost always tuner too (practical SDR) there is need for tuner frequency too. As tuner is still own entity, is it possible to use same frequency parameter for both ADC and RF tuner in same device?
Well, a SDR capture device will always have ADC and RF tuner.
A SDR output device will always have a DAC and a RF transmitter.
On both cases, the sampling rate and the sampling format are mandatory arguments.
In any case, the V4L2 API has already support for setting the mandatory parameters of the expected stream, at struct v4l2_format.
So, it makes sense do do:
struct v4l2_format {
__u32 type;
union {
struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
struct v4l2_pix_format_mplane pix_mp; /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */
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_sdr_format sdr; /* V4L2_BUF_TYPE_SDR_CAPTURE */
__u8 raw_data[200]; /* user-defined */
} fmt;};
And add the mandatory parameters for SDR inside its own structure, e. g. struct v4l2_sdr_format. Of course, the meta-data provided by a SDR device is different than the one for video or vbi, so you'll need to add a new streaming type for SDR anyway.
Btw, that's what I proposed here:
http://git.linuxtv.org/mchehab/experimental.git/blob/refs/heads/sdr:/include/uapi/linux/videodev2.h
With regards to the sampling rate range, my proposal there were to add a min/max value for it, to be used by VIDIOC_G_FMT, as proposed on:
http://git.linuxtv.org/mchehab/experimental.git/commitdiff/c3a73f84f038f043aeda5d5bfccc6fea66291451
So, the v4l2_sdr_format should be like:
+struct v4l2_sdr_format {
+ __u32 sampleformat; + __u32 sample_rate; /* in Hz */ + __u32 min_sample_rate; /* in Hz */ + __u32 max_sample_rate; /* in Hz */
+
+} __attribute__ ((packed));
Where sampleformat would be something similar to FOURCC, defining the size of each sample, its format, and if the sampling is in quadradure, if they're plain PCM samples, or something more complex, like DPCM, RLE, etc.
In the specific case of enumerating the sampling rate range, if the sampling rate can have multiple ranges, then maybe we'll need to do something more complex like what was done on VIDIOC_ENUM_FRAMESIZES.
Regards,
Mauro
Quoted 86 lines · Mauro Carvalho Chehab
Em Thu, 21 Nov 2013 19:05:05 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 30 lines
Hello
I am adding new property for sampling rate that is ideally the only obligatory parameter required by SDR. It is value that could be only positive and bigger the better, lets say unsigned 64 bit is quite ideal. That value sets maximum radio frequency possible to receive (ideal SDR).Valid values are not always in some single range from X to Y, there could be some multiple value ranges.
For example possible values: 1000-2000, 23459, 900001-2800000
Reading possible values from device could be nice, but not necessary. Reading current value is more important.
Here is what I though earlier as a requirements:
sampling rate
* values: 1 - infinity (unit: Hz, samples per second) currently 500 MHz is more than enough
* operations
GET, inquire what HW supports
GET, get current value
SET, set desired valueI am not sure what is best way to implement that kind of thing. IOCTL like frequency
V4L2 Control?
put it into stream format request?Quoted 4 lines
Sampling rate is actually frequency of ADC. As there devices has almost always tuner too (practical SDR) there is need for tuner frequency too. As tuner is still own entity, is it possible to use same frequency parameter for both ADC and RF tuner in same device?
Well, a SDR capture device will always have ADC and RF tuner.
A SDR output device will always have a DAC and a RF transmitter.
On both cases, the sampling rate and the sampling format are mandatory arguments.
In any case, the V4L2 API has already support for setting the mandatory parameters of the expected stream, at struct
v4l2_format.So, it makes sense do do:
struct
v4l2_format{
__u32type;
union {
structv4l2_pix_formatpix; /*V4L2_BUF_TYPE_VIDEO_CAPTURE*/
structv4l2_pix_format_mplanepix_mp; /*V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE*/
structv4l2_windowwin; /*V4L2_BUF_TYPE_VIDEO_OVERLAY*/
structv4l2_vbi_formatvbi; /*V4L2_BUF_TYPE_VBI_CAPTURE*/
structv4l2_sliced_vbi_formatsliced; /*V4L2_BUF_TYPE_SLICED_VBI_CAPTURE*/
+ structv4l2_sdr_formatsdr; /*V4L2_BUF_TYPE_SDR_CAPTURE*/__u8 raw_data[200]; /* user-defined */ } fmt;};
And add the mandatory parameters for SDR inside its own structure, e. g. struct
v4l2_sdr_format. Of course, the meta-data provided by a SDR device is different than the one for video or vbi, so you'll need to add a new streaming type for SDR anyway.Btw, that's what I proposed here:
http://git.linuxtv.org/mchehab/experimental.git/blob/refs/heads/sdr:/include/uapi/linux/videodev2.h
With regards to the sampling rate range, my proposal there were to add a min/max value for it, to be used by
VIDIOC_G_FMT, as proposed on:http://git.linuxtv.org/mchehab/experimental.git/commitdiff/c3a73f84f038f043aeda5d5bfccc6fea66291451So, the
v4l2_sdr_formatshould be like:(quoted diff) +7
-0+struct v4l2_sdr_format { + __u32 sampleformat; + __u32 sample_rate; /* in Hz */ + __u32 min_sample_rate; /* in Hz */ + __u32 max_sample_rate; /* in Hz */ + +} __attribute__ ((packed));
Quoted 8 lines
Where sampleformat would be something similar to FOURCC, defining the size of each sample, its format, and if the sampling is in quadradure, if they're plain PCM samples, or something more complex, like DPCM, RLE, etc.
In the specific case of enumerating the sampling rate range, if the sampling rate can have multiple ranges, then maybe we'll need to do something more complex like what was done on
VIDIOC_ENUM_FRAMESIZES.
Could this ioctl be adapted for this:
http://hverkuil.home.xs4all.nl/spec/media.html#vidioc-enum-freq-bands
BTW, can the sample rate change while streaming? Typically things you set through S_FMT can not be changed while streaming.
Regards,
Hans
Quoted 98 lines · Hans Verkuil
Quoted 86 lines · Mauro Carvalho Chehab
Em Thu, 21 Nov 2013 19:05:05 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 30 lines
Hello
I am adding new property for sampling rate that is ideally the only obligatory parameter required by SDR. It is value that could be only positive and bigger the better, lets say unsigned 64 bit is quite ideal. That value sets maximum radio frequency possible to receive (ideal SDR).Valid values are not always in some single range from X to Y, there could be some multiple value ranges.
For example possible values: 1000-2000, 23459, 900001-2800000
Reading possible values from device could be nice, but not necessary. Reading current value is more important.
Here is what I though earlier as a requirements:
sampling rate
* values: 1 - infinity (unit: Hz, samples per second) currently 500 MHz is more than enough
* operations
GET, inquire what HW supports
GET, get current value
SET, set desired valueI am not sure what is best way to implement that kind of thing. IOCTL like frequency
V4L2 Control?
put it into stream format request?Quoted 4 lines
Sampling rate is actually frequency of ADC. As there devices has almost always tuner too (practical SDR) there is need for tuner frequency too. As tuner is still own entity, is it possible to use same frequency parameter for both ADC and RF tuner in same device?
Well, a SDR capture device will always have ADC and RF tuner.
A SDR output device will always have a DAC and a RF transmitter.
On both cases, the sampling rate and the sampling format are mandatory arguments.
In any case, the V4L2 API has already support for setting the mandatory parameters of the expected stream, at struct
v4l2_format.So, it makes sense do do:
struct
v4l2_format{
__u32type;
union {
structv4l2_pix_formatpix; /*V4L2_BUF_TYPE_VIDEO_CAPTURE*/
structv4l2_pix_format_mplanepix_mp; /*V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE*/
structv4l2_windowwin; /*V4L2_BUF_TYPE_VIDEO_OVERLAY*/
structv4l2_vbi_formatvbi; /*V4L2_BUF_TYPE_VBI_CAPTURE*/
structv4l2_sliced_vbi_formatsliced; /*V4L2_BUF_TYPE_SLICED_VBI_CAPTURE*/
+ structv4l2_sdr_formatsdr; /*V4L2_BUF_TYPE_SDR_CAPTURE*/__u8 raw_data[200]; /* user-defined */ } fmt;};
And add the mandatory parameters for SDR inside its own structure, e. g. struct
v4l2_sdr_format. Of course, the meta-data provided by a SDR device is different than the one for video or vbi, so you'll need to add a new streaming type for SDR anyway.Btw, that's what I proposed here:
http://git.linuxtv.org/mchehab/experimental.git/blob/refs/heads/sdr:/include/uapi/linux/videodev2.h
With regards to the sampling rate range, my proposal there were to add a min/max value for it, to be used by
VIDIOC_G_FMT, as proposed on:http://git.linuxtv.org/mchehab/experimental.git/commitdiff/c3a73f84f038f043aeda5d5bfccc6fea66291451So, the
v4l2_sdr_formatshould be like:(quoted diff) +7
-0+struct v4l2_sdr_format { + __u32 sampleformat; + __u32 sample_rate; /* in Hz */ + __u32 min_sample_rate; /* in Hz */ + __u32 max_sample_rate; /* in Hz */ + +} __attribute__ ((packed));Quoted 8 lines
Where sampleformat would be something similar to FOURCC, defining the size of each sample, its format, and if the sampling is in quadradure, if they're plain PCM samples, or something more complex, like DPCM, RLE, etc.
In the specific case of enumerating the sampling rate range, if the sampling rate can have multiple ranges, then maybe we'll need to do something more complex like what was done on
VIDIOC_ENUM_FRAMESIZES.Could this ioctl be adapted for this:
Quoted 4 lines
http://hverkuil.home.xs4all.nl/spec/media.html#vidioc-enum-freq-bands
BTW, can the sample rate change while streaming? Typically things you set through
S_FMTcan not be changed while streaming.
Yes, but in practice it is uncommon. When I reverse-engineered Mirics MSi2500 USB ADC I did it hundred of times. Just started streaming and injected numbers to ADC control registers, then calculated sampling rate from the stream. That is only use case I know currently, there still could be some others. Nothing prevents do to it, the key issue is that sampling rate is needed to known by app. It is app developer choice if he wants to restart streaming when changes sampling rate.
ADC sampling frequency has no direct relation to stream format. See for example those Mirics libv4lconvert patches I send earlier that week.
regards
Antti
Signature · 1 line
http://palosaari.fi/
Em Thu, 21 Nov 2013 20:33:15 +0200
Antti Palosaari <[email protected]> escreveu:
Quoted 101 lines · Hans Verkuil
Quoted 100 lines · Mauro Carvalho Chehab
Quoted 86 lines
Em Thu, 21 Nov 2013 19:05:05 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 30 lines
Hello
I am adding new property for sampling rate that is ideally the only obligatory parameter required by SDR. It is value that could be only positive and bigger the better, lets say unsigned 64 bit is quite ideal. That value sets maximum radio frequency possible to receive (ideal SDR).Valid values are not always in some single range from X to Y, there could be some multiple value ranges.
For example possible values: 1000-2000, 23459, 900001-2800000
Reading possible values from device could be nice, but not necessary. Reading current value is more important.
Here is what I though earlier as a requirements:
sampling rate
* values: 1 - infinity (unit: Hz, samples per second) currently 500 MHz is more than enough
* operations
GET, inquire what HW supports
GET, get current value
SET, set desired valueI am not sure what is best way to implement that kind of thing. IOCTL like frequency
V4L2 Control?
put it into stream format request?Quoted 4 lines
Sampling rate is actually frequency of ADC. As there devices has almost always tuner too (practical SDR) there is need for tuner frequency too. As tuner is still own entity, is it possible to use same frequency parameter for both ADC and RF tuner in same device?
Well, a SDR capture device will always have ADC and RF tuner.
A SDR output device will always have a DAC and a RF transmitter.
On both cases, the sampling rate and the sampling format are mandatory arguments.
In any case, the V4L2 API has already support for setting the mandatory parameters of the expected stream, at struct
v4l2_format.So, it makes sense do do:
struct
v4l2_format{
__u32type;
union {
structv4l2_pix_formatpix; /*V4L2_BUF_TYPE_VIDEO_CAPTURE*/
structv4l2_pix_format_mplanepix_mp; /*V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE*/
structv4l2_windowwin; /*V4L2_BUF_TYPE_VIDEO_OVERLAY*/
structv4l2_vbi_formatvbi; /*V4L2_BUF_TYPE_VBI_CAPTURE*/
structv4l2_sliced_vbi_formatsliced; /*V4L2_BUF_TYPE_SLICED_VBI_CAPTURE*/
+ structv4l2_sdr_formatsdr; /*V4L2_BUF_TYPE_SDR_CAPTURE*/__u8 raw_data[200]; /* user-defined */ } fmt;};
And add the mandatory parameters for SDR inside its own structure, e. g. struct
v4l2_sdr_format. Of course, the meta-data provided by a SDR device is different than the one for video or vbi, so you'll need to add a new streaming type for SDR anyway.Btw, that's what I proposed here:
http://git.linuxtv.org/mchehab/experimental.git/blob/refs/heads/sdr:/include/uapi/linux/videodev2.h
With regards to the sampling rate range, my proposal there were to add a min/max value for it, to be used by
VIDIOC_G_FMT, as proposed on:http://git.linuxtv.org/mchehab/experimental.git/commitdiff/c3a73f84f038f043aeda5d5bfccc6fea66291451So, the
v4l2_sdr_formatshould be like:(quoted diff) +7
-0+struct v4l2_sdr_format { + __u32 sampleformat; + __u32 sample_rate; /* in Hz */ + __u32 min_sample_rate; /* in Hz */ + __u32 max_sample_rate; /* in Hz */ + +} __attribute__ ((packed));Quoted 8 lines
Where sampleformat would be something similar to FOURCC, defining the size of each sample, its format, and if the sampling is in quadradure, if they're plain PCM samples, or something more complex, like DPCM, RLE, etc.
In the specific case of enumerating the sampling rate range, if the sampling rate can have multiple ranges, then maybe we'll need to do something more complex like what was done on
VIDIOC_ENUM_FRAMESIZES.Could this ioctl be adapted for this:
http://hverkuil.home.xs4all.nl/spec/media.html#vidioc-enum-freq-bands
Quoted 7 lines
Quoted 2 lines
BTW, can the sample rate change while streaming? Typically things you set through
S_FMTcan not be changed while streaming.Yes, but in practice it is uncommon. When I reverse-engineered Mirics MSi2500 USB ADC I did it hundred of times. Just started streaming and injected numbers to ADC control registers, then calculated sampling rate from the stream.
That's not an use case. It is just a developer's procedure. Anyway, you could still measure the bit rate like that, if you do a stream start and stop.
Quoted 1 line
That is only use case I know currently, there still could be some others.
Seriously? Since the Shannon theorem, all theory used on DSP assumes that the samples are spaced at the very same bit rate.
Quoted 2 lines
Nothing prevents do to it, the key issue is that
sampling rate is needed to known by app.
No, it is harder than that: if the bit rate changes, then you need to pack the sampling rate changes when they occur inside the stream, as otherwise userspace will have no means to detect such changes.
This is the very same problem on video streams: we currently don't allow calling VIDIOC_S_FMT in the middle of some transmission, as there's no way to signalize when the changes are applied.
We used to allow it in the past, at least on bttv, as the old code, from V4L1 times used to always allocate memory for the max possible resolution. So, it used to support streaming resizing after start streaming.
There were even one V4L1 application doing that, basically due to a programer's mistake:
The program used to first start streaming, and then changing the image size, very quickly. I suspect that the original developer never suspected about the application misbehavior, but that became a nightmare when we removed V4L1 support. I ended by fixing the application in the process.
Quoted 5 lines
It is app developer choice if
he wants to restart streaming when changes sampling rate.ADC sampling frequency has no direct relation to stream format. See for example those Mirics libv4lconvert patches I send earlier that week.
The same applies to all write parameters passed via the pix_format structs:
they're orthogonal (e. g. one don't depend on the others).
In the specific case of v4l2_pix_format, the parameters filled by userspace are orthogonal: width, height, pixelformat, field.
Ok, not all configs are valid, and the device may have some restrictions. So, the driver can round those parameters to the closest possible value, if needed.
The bytesperline, sizeimage and colorspace are parameters filled by the driver. The first two parameters are derived from the image size and pixelformat.
The colorspace parameter is a driver-dependent fixed value (Actually, a few special drivers allow userspace to fill the colorspace too, like the mem2mem drivers - but this is an exception).
Regards,
Mauro
Quoted 121 lines · Mauro Carvalho Chehab
Em Thu, 21 Nov 2013 20:33:15 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 101 lines · Hans Verkuil
Quoted 100 lines · Mauro Carvalho Chehab
Quoted 86 lines
Em Thu, 21 Nov 2013 19:05:05 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 30 lines
Hello
I am adding new property for sampling rate that is ideally the only obligatory parameter required by SDR. It is value that could be only positive and bigger the better, lets say unsigned 64 bit is quite ideal. That value sets maximum radio frequency possible to receive (ideal SDR).Valid values are not always in some single range from X to Y, there could be some multiple value ranges.
For example possible values: 1000-2000, 23459, 900001-2800000
Reading possible values from device could be nice, but not necessary. Reading current value is more important.
Here is what I though earlier as a requirements:
sampling rate
* values: 1 - infinity (unit: Hz, samples per second) currently 500 MHz is more than enough
* operations
GET, inquire what HW supports
GET, get current value
SET, set desired valueI am not sure what is best way to implement that kind of thing. IOCTL like frequency
V4L2 Control?
put it into stream format request?Quoted 4 lines
Sampling rate is actually frequency of ADC. As there devices has almost always tuner too (practical SDR) there is need for tuner frequency too. As tuner is still own entity, is it possible to use same frequency parameter for both ADC and RF tuner in same device?
Well, a SDR capture device will always have ADC and RF tuner.
A SDR output device will always have a DAC and a RF transmitter.
On both cases, the sampling rate and the sampling format are mandatory arguments.
In any case, the V4L2 API has already support for setting the mandatory parameters of the expected stream, at struct
v4l2_format.So, it makes sense do do:
struct
v4l2_format{
__u32type;
union {
structv4l2_pix_formatpix; /*V4L2_BUF_TYPE_VIDEO_CAPTURE*/
structv4l2_pix_format_mplanepix_mp; /*V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE*/
structv4l2_windowwin; /*V4L2_BUF_TYPE_VIDEO_OVERLAY*/
structv4l2_vbi_formatvbi; /*V4L2_BUF_TYPE_VBI_CAPTURE*/
structv4l2_sliced_vbi_formatsliced; /*V4L2_BUF_TYPE_SLICED_VBI_CAPTURE*/
+ structv4l2_sdr_formatsdr; /*V4L2_BUF_TYPE_SDR_CAPTURE*/__u8 raw_data[200]; /* user-defined */ } fmt;};
And add the mandatory parameters for SDR inside its own structure, e. g. struct
v4l2_sdr_format. Of course, the meta-data provided by a SDR device is different than the one for video or vbi, so you'll need to add a new streaming type for SDR anyway.Btw, that's what I proposed here:
http://git.linuxtv.org/mchehab/experimental.git/blob/refs/heads/sdr:/include/uapi/linux/videodev2.h
With regards to the sampling rate range, my proposal there were to add a min/max value for it, to be used by
VIDIOC_G_FMT, as proposed on:http://git.linuxtv.org/mchehab/experimental.git/commitdiff/c3a73f84f038f043aeda5d5bfccc6fea66291451So, the
v4l2_sdr_formatshould be like:(quoted diff) +7
-0+struct v4l2_sdr_format { + __u32 sampleformat; + __u32 sample_rate; /* in Hz */ + __u32 min_sample_rate; /* in Hz */ + __u32 max_sample_rate; /* in Hz */ + +} __attribute__ ((packed));Quoted 8 lines
Where sampleformat would be something similar to FOURCC, defining the size of each sample, its format, and if the sampling is in quadradure, if they're plain PCM samples, or something more complex, like DPCM, RLE, etc.
In the specific case of enumerating the sampling rate range, if the sampling rate can have multiple ranges, then maybe we'll need to do something more complex like what was done on
VIDIOC_ENUM_FRAMESIZES.Could this ioctl be adapted for this:
http://hverkuil.home.xs4all.nl/spec/media.html#vidioc-enum-freq-bands
Quoted 7 lines
Quoted 2 lines
BTW, can the sample rate change while streaming? Typically things you set through
S_FMTcan not be changed while streaming.Yes, but in practice it is uncommon. When I reverse-engineered Mirics MSi2500 USB ADC I did it hundred of times. Just started streaming and injected numbers to ADC control registers, then calculated sampling rate from the stream.
That's not an use case. It is just a developer's procedure. Anyway, you could still measure the bit rate like that, if you do a stream start and stop.
Quoted 1 line
That is only use case I know currently, there still could be some others.
Seriously? Since the Shannon theorem, all theory used on DSP assumes that the samples are spaced at the very same bit rate.
Quoted 6 lines
Quoted 2 lines
Nothing prevents do to it, the key issue is that
sampling rate is needed to known by app.No, it is harder than that: if the bit rate changes, then you need to pack the sampling rate changes when they occur inside the stream, as otherwise userspace will have no means to detect such changes.
Heh, I cannot understood you. Could you explain why it works for me? Here is video I recorded just for you:
http://palosaari.fi/linux/v4l-dvb/mirics_msi3101_sdrsharp_sampling_rate.mp4
It is Mirics MSi3101 streaming FM radio with sampling rate 2.048 Msps, then I switch to 1.024 Msps and back few times - on the fly. IMHO results are just as expected. Sound start cracking when DSP application sampling rate does not match, but when you change it back to correct it recovers.
If I will add button to tell app DSP that sampling rate is changed, it will work for both cases. I haven't yet implemented that settings button, it is hard coded to SDRSharp plugin.
Could you explain why it works if it is impossible as you said?
Quoted 36 lines
This is the very same problem on video streams: we currently don't allow calling
VIDIOC_S_FMTin the middle of some transmission, as there's no way to signalize when the changes are applied.We used to allow it in the past, at least on bttv, as the old code, from V4L1 times used to always allocate memory for the max possible resolution. So, it used to support streaming resizing after start streaming.
There were even one V4L1 application doing that, basically due to a programer's mistake:
The program used to first start streaming, and then changing the image size, very quickly. I suspect that the original developer never suspected about the application misbehavior, but that became a nightmare when we removed V4L1 support. I ended by fixing the application in the process.
Quoted 5 lines
It is app developer choice if
he wants to restart streaming when changes sampling rate.ADC sampling frequency has no direct relation to stream format. See for example those Mirics libv4lconvert patches I send earlier that week.
The same applies to all write parameters passed via the
pix_formatstructs:
they're orthogonal (e. g. one don't depend on the others).In the specific case of
v4l2_pix_format, the parameters filled by userspace are orthogonal: width, height, pixelformat, field.Ok, not all configs are valid, and the device may have some restrictions. So, the driver can round those parameters to the closest possible value, if needed.
The bytesperline, sizeimage and colorspace are parameters filled by the driver. The first two parameters are derived from the image size and pixelformat.
Quoted 7 lines
The colorspace parameter is a driver-dependent fixed value (Actually, a few special drivers allow userspace to fill the colorspace too, like the mem2mem drivers - but this is an exception).
Regards,
Mauro
regards
Antti
Signature · 1 line
http://palosaari.fi/
Em Thu, 21 Nov 2013 22:22:49 +0200
Antti Palosaari <[email protected]> escreveu:
Quoted 133 lines · Mauro Carvalho Chehab
Quoted 121 lines
Em Thu, 21 Nov 2013 20:33:15 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 101 lines · Hans Verkuil
Quoted 100 lines · Mauro Carvalho Chehab
Quoted 86 lines
Em Thu, 21 Nov 2013 19:05:05 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 30 lines
Hello
I am adding new property for sampling rate that is ideally the only obligatory parameter required by SDR. It is value that could be only positive and bigger the better, lets say unsigned 64 bit is quite ideal. That value sets maximum radio frequency possible to receive (ideal SDR).Valid values are not always in some single range from X to Y, there could be some multiple value ranges.
For example possible values: 1000-2000, 23459, 900001-2800000
Reading possible values from device could be nice, but not necessary. Reading current value is more important.
Here is what I though earlier as a requirements:
sampling rate
* values: 1 - infinity (unit: Hz, samples per second) currently 500 MHz is more than enough
* operations
GET, inquire what HW supports
GET, get current value
SET, set desired valueI am not sure what is best way to implement that kind of thing. IOCTL like frequency
V4L2 Control?
put it into stream format request?Quoted 4 lines
Sampling rate is actually frequency of ADC. As there devices has almost always tuner too (practical SDR) there is need for tuner frequency too. As tuner is still own entity, is it possible to use same frequency parameter for both ADC and RF tuner in same device?
Well, a SDR capture device will always have ADC and RF tuner.
A SDR output device will always have a DAC and a RF transmitter.
On both cases, the sampling rate and the sampling format are mandatory arguments.
In any case, the V4L2 API has already support for setting the mandatory parameters of the expected stream, at struct
v4l2_format.So, it makes sense do do:
struct
v4l2_format{
__u32type;
union {
structv4l2_pix_formatpix; /*V4L2_BUF_TYPE_VIDEO_CAPTURE*/
structv4l2_pix_format_mplanepix_mp; /*V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE*/
structv4l2_windowwin; /*V4L2_BUF_TYPE_VIDEO_OVERLAY*/
structv4l2_vbi_formatvbi; /*V4L2_BUF_TYPE_VBI_CAPTURE*/
structv4l2_sliced_vbi_formatsliced; /*V4L2_BUF_TYPE_SLICED_VBI_CAPTURE*/
+ structv4l2_sdr_formatsdr; /*V4L2_BUF_TYPE_SDR_CAPTURE*/__u8 raw_data[200]; /* user-defined */ } fmt;};
And add the mandatory parameters for SDR inside its own structure, e. g. struct
v4l2_sdr_format. Of course, the meta-data provided by a SDR device is different than the one for video or vbi, so you'll need to add a new streaming type for SDR anyway.Btw, that's what I proposed here:
http://git.linuxtv.org/mchehab/experimental.git/blob/refs/heads/sdr:/include/uapi/linux/videodev2.h
With regards to the sampling rate range, my proposal there were to add a min/max value for it, to be used by
VIDIOC_G_FMT, as proposed on:http://git.linuxtv.org/mchehab/experimental.git/commitdiff/c3a73f84f038f043aeda5d5bfccc6fea66291451So, the
v4l2_sdr_formatshould be like:(quoted diff) +7
-0+struct v4l2_sdr_format { + __u32 sampleformat; + __u32 sample_rate; /* in Hz */ + __u32 min_sample_rate; /* in Hz */ + __u32 max_sample_rate; /* in Hz */ + +} __attribute__ ((packed));Quoted 8 lines
Where sampleformat would be something similar to FOURCC, defining the size of each sample, its format, and if the sampling is in quadradure, if they're plain PCM samples, or something more complex, like DPCM, RLE, etc.
In the specific case of enumerating the sampling rate range, if the sampling rate can have multiple ranges, then maybe we'll need to do something more complex like what was done on
VIDIOC_ENUM_FRAMESIZES.Could this ioctl be adapted for this:
http://hverkuil.home.xs4all.nl/spec/media.html#vidioc-enum-freq-bands
Quoted 7 lines
Quoted 2 lines
BTW, can the sample rate change while streaming? Typically things you set through
S_FMTcan not be changed while streaming.Yes, but in practice it is uncommon. When I reverse-engineered Mirics MSi2500 USB ADC I did it hundred of times. Just started streaming and injected numbers to ADC control registers, then calculated sampling rate from the stream.
That's not an use case. It is just a developer's procedure. Anyway, you could still measure the bit rate like that, if you do a stream start and stop.
Quoted 1 line
That is only use case I know currently, there still could be some others.
Seriously? Since the Shannon theorem, all theory used on DSP assumes that the samples are spaced at the very same bit rate.
Quoted 6 lines
Quoted 2 lines
Nothing prevents do to it, the key issue is that
sampling rate is needed to known by app.No, it is harder than that: if the bit rate changes, then you need to pack the sampling rate changes when they occur inside the stream, as otherwise userspace will have no means to detect such changes.
Heh, I cannot understood you. Could you explain why it works for me? Here is video I recorded just for you:
http://palosaari.fi/linux/v4l-dvb/mirics_msi3101_sdrsharp_sampling_rate.mp4
Quoted 5 lines
It is Mirics MSi3101 streaming FM radio with sampling rate 2.048 Msps, then I switch to 1.024 Msps and back few times - on the fly. IMHO results are just as expected. Sound start cracking when DSP application sampling rate does not match, but when you change it back to correct it recovers.
In other words, changing the sampling rate while streaming breaks decoding.
Quoted 5 lines
If I will add button to tell app DSP that sampling rate is changed, it will work for both cases. I haven't yet implemented that settings button, it is hard coded to SDRSharp plugin.
Could you explain why it works if it is impossible as you said?
I can't imagine any "magic" button that will be able to discover on what exact sample the sampling rate changed. The hardware may have buffers; the DMA engines and the USB stack for sure have, and also V4L. Knowing on what exact sample the sampling rate changed would require hardware support, to properly tag the sample where the change started to apply.
If the hardware supports it, I don't see an reason why blocking calling VIDIOC_S_FMT in the middle of a stream.
However, on all other hardwares, samples will be lost or will be badly decoded, with would cause audio/video artifacts or even break the decoding code if not properly written.
Anyway, if samples will be lost anyway, the right thing to do is to just stop streaming, change the sampling rate and start streaming again. This way, you'll know that all buffers received before the changes will have the old sampling rate, and all new buffers, the new one.
Regards,
Mauro
Quoted 50 lines
Quoted 38 lines
This is the very same problem on video streams: we currently don't allow calling
VIDIOC_S_FMTin the middle of some transmission, as there's no way to signalize when the changes are applied.We used to allow it in the past, at least on bttv, as the old code, from V4L1 times used to always allocate memory for the max possible resolution. So, it used to support streaming resizing after start streaming.
There were even one V4L1 application doing that, basically due to a programer's mistake:
The program used to first start streaming, and then changing the image size, very quickly. I suspect that the original developer never suspected about the application misbehavior, but that became a nightmare when we removed V4L1 support. I ended by fixing the application in the process.
Quoted 5 lines
It is app developer choice if
he wants to restart streaming when changes sampling rate.ADC sampling frequency has no direct relation to stream format. See for example those Mirics libv4lconvert patches I send earlier that week.
The same applies to all write parameters passed via the
pix_formatstructs:
they're orthogonal (e. g. one don't depend on the others).In the specific case of
v4l2_pix_format, the parameters filled by userspace are orthogonal: width, height, pixelformat, field.Ok, not all configs are valid, and the device may have some restrictions. So, the driver can round those parameters to the closest possible value, if needed.
The bytesperline, sizeimage and colorspace are parameters filled by the driver. The first two parameters are derived from the image size and pixelformat.
Quoted 7 lines
The colorspace parameter is a driver-dependent fixed value (Actually, a few special drivers allow userspace to fill the colorspace too, like the mem2mem drivers - but this is an exception).
Regards,
Mauroregards
Antti
Signature · 2 lines
Cheers, Mauro
Quoted 37 lines · Mauro Carvalho Chehab
Em Thu, 21 Nov 2013 22:22:49 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 34 lines · Mauro Carvalho Chehab
Quoted 22 lines
Em Thu, 21 Nov 2013 20:33:15 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 9 lines · Hans Verkuil
Quoted 3 lines
BTW, can the sample rate change while streaming? Typically things you set through
S_FMTcan not be changed while streaming.Yes, but in practice it is uncommon. When I reverse-engineered Mirics MSi2500 USB ADC I did it hundred of times. Just started streaming and injected numbers to ADC control registers, then calculated sampling rate from the stream.
That's not an use case. It is just a developer's procedure. Anyway, you could still measure the bit rate like that, if you do a stream start and stop.
Quoted 1 line
That is only use case I know currently, there still could be some others.
Seriously? Since the Shannon theorem, all theory used on DSP assumes that the samples are spaced at the very same bit rate.
Quoted 6 lines
Quoted 2 lines
Nothing prevents do to it, the key issue is that
sampling rate is needed to known by app.No, it is harder than that: if the bit rate changes, then you need to pack the sampling rate changes when they occur inside the stream, as otherwise userspace will have no means to detect such changes.
Heh, I cannot understood you. Could you explain why it works for me? Here is video I recorded just for you:
http://palosaari.fi/linux/v4l-dvb/mirics_msi3101_sdrsharp_sampling_rate.mp4
Quoted 7 lines
Quoted 5 lines
It is Mirics MSi3101 streaming FM radio with sampling rate 2.048 Msps, then I switch to 1.024 Msps and back few times - on the fly. IMHO results are just as expected. Sound start cracking when DSP application sampling rate does not match, but when you change it back to correct it recovers.
In other words, changing the sampling rate while streaming breaks decoding.
Of course, in a case DSP does not know what it is. I have found that changing frequency during streaming breaks my audio as well.
Quoted 4 lines
Quoted 4 lines
If I will add button to tell app DSP that sampling rate is changed, it will work for both cases. I haven't yet implemented that settings button, it is hard coded to SDRSharp plugin.
Quoted 8 lines
Quoted 1 line
Could you explain why it works if it is impossible as you said?
I can't imagine any "magic" button that will be able to discover on what exact sample the sampling rate changed. The hardware may have buffers; the DMA engines and the USB stack for sure have, and also V4L. Knowing on what exact sample the sampling rate changed would require hardware support, to properly tag the sample where the change started to apply.
"Magic button". It is just DSP application which sends request to hardware. And if hardware says OK, that magic SDR application says for own DSP hey change sampling rate to mach stream.
There is huge amount of bits streaming, no need to tag. You could just throw away second or two - does not matter. Imagine it similarly like a UDP VoIP call - when you lose data, so what, it is 20ms of audio and none cares. It is similarly here, if you lose some data due to sampling rate mismatch, so what. It is only few ms of audio (or some other). One way radio channel is something it should be robust for such issues - you cannot request retry.
Quoted 11 lines
If the hardware supports it, I don't see an reason why blocking calling
VIDIOC_S_FMTin the middle of a stream.However, on all other hardwares, samples will be lost or will be badly decoded, with would cause audio/video artifacts or even break the decoding code if not properly written.
Anyway, if samples will be lost anyway, the right thing to do is to just stop streaming, change the sampling rate and start streaming again. This way, you'll know that all buffers received before the changes will have the old sampling rate, and all new buffers, the new one.
I cannot agree. It is too slow, without real benefits, for many use cases.
Also, I am pretty sure many of the hw DSP implementations will not restart streaming when they hunt for demodulation lock. There is likely just a long shift-register or FIFO where bits are running even different sampling rates etc. are tested.
regards
Antti
Signature · 1 line
http://palosaari.fi/
Quoted 98 lines · Antti Palosaari
Quoted 45 lines · Mauro Carvalho Chehab
Em Thu, 21 Nov 2013 22:22:49 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 42 lines · Mauro Carvalho Chehab
Quoted 27 lines
Em Thu, 21 Nov 2013 20:33:15 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 11 lines · Hans Verkuil
Quoted 4 lines
BTW, can the sample rate change while streaming? Typically things you set
throughS_FMTcan not be changed while streaming.Yes, but in practice it is uncommon. When I reverse-engineered Mirics MSi2500 USB ADC I did it hundred of times. Just started streaming and injected numbers to ADC control registers, then calculated sampling rate
from the stream.That's not an use case. It is just a developer's procedure. Anyway, you could still measure the bit rate like that, if you do a stream start and
stop.Quoted 2 lines
That is only use case I know currently, there still could be some others.
Seriously? Since the Shannon theorem, all theory used on DSP assumes that
the samples are spaced at the very same bit rate.Quoted 8 lines
Quoted 2 lines
Nothing prevents do to it, the key issue is that
sampling rate is needed to known by app.No, it is harder than that: if the bit rate changes, then you need to pack
the sampling rate changes when they occur inside the stream, as otherwise
userspace will have no means to detect such changes.Heh, I cannot understood you. Could you explain why it works for me? Here is video I recorded just for you:
http://palosaari.fi/linux/v4l-dvb/mirics_msi3101_sdrsharp_sampling_rate.mp4Quoted 8 lines
Quoted 5 lines
It is Mirics MSi3101 streaming FM radio with sampling rate 2.048 Msps, then I switch to 1.024 Msps and back few times - on the fly. IMHO results are just as expected. Sound start cracking when DSP application sampling rate does not match, but when you change it back to correct it recovers.
In other words, changing the sampling rate while streaming breaks decoding.
Of course, in a case DSP does not know what it is. I have found that changing frequency during streaming breaks my audio as well.
Quoted 4 lines
Quoted 4 lines
If I will add button to tell app DSP that sampling rate is changed, it will work for both cases. I haven't yet implemented that settings button, it is hard coded to SDRSharp plugin.
Quoted 8 lines
Quoted 1 line
Could you explain why it works if it is impossible as you said?
I can't imagine any "magic" button that will be able to discover on what exact sample the sampling rate changed. The hardware may have buffers; the DMA engines and the USB stack for sure have, and also V4L. Knowing on what exact sample the sampling rate changed would require hardware support, to properly tag the sample where the change started to apply.
"Magic button". It is just DSP application which sends request to hardware. And if hardware says OK, that magic SDR application says for own DSP hey change sampling rate to mach stream.
There is huge amount of bits streaming, no need to tag. You could just throw away second or two - does not matter. Imagine it similarly like a UDP VoIP call - when you lose data, so what, it is 20ms of audio and none cares.
It is similarly here, if you lose some data due to sampling rate mismatch, so what. It is only few ms of audio (or some other). One way radio channel is something it should be robust for such issues - you cannot request retry.Quoted 7 lines
If the hardware supports it, I don't see an reason why blocking calling
VIDIOC_S_FMTin the middle of a stream.However, on all other hardwares, samples will be lost or will be badly decoded, with would cause audio/video artifacts or even break the decoding code if not properly written.
Quoted 5 lines
Anyway, if samples will be lost anyway, the right thing to do is to just stop streaming, change the sampling rate and start streaming again. This way, you'll know that all buffers received before the changes will have the old sampling rate, and all new buffers, the new one.
Quoted 6 lines
I cannot agree. It is too slow, without real benefits, for many use cases.
Also, I am pretty sure many of the hw DSP implementations will not restart streaming when they hunt for demodulation lock. There is likely just a long shift-register or FIFO where bits are running even different sampling rates etc. are tested.
I did some study of runtime sampling rate changes and I am very sure it is *required*, especially for digital receivers, like DTV dedulators, where timing is important. The main reason is synchronization - not only for when channel is acquired but for run time synchronization too in order to maintain receiver sync (lock).
Here is one document which explains some reasons and solutions for digital receiver synchronization:
http://www.cs.tut.fi/kurssit/TLT-5806/Synch.pdf
You can find a lot of more information when search "Synchronization Techniques for Digital Receivers"
What goes to Mirics MSi2500 ADC, it has even flag to signal when sampling rate is changed. Due to that you will not even lose many samples and it is possible to make demodulator design simpler. It is byte 5 in USB packet header which changes between 10/90 when sampling rate is changed as I shown in earlier video. I am pretty sure that they have had good reason to add support for run time sampling rate change as it is the only software based TV demodulator solution currently.
**********
So the requirements are what I listed originally + it must be possible to change sampling rate during streaming.
Now I am testing similar solution than VIDIOC_ENUM_FREQ_BANDS
regards
Antti
Signature · 1 line
http://palosaari.fi/
Em Thu, 21 Nov 2013 19:22:51 +0100
Hans Verkuil <[email protected]> escreveu:
Quoted 92 lines · Mauro Carvalho Chehab
Quoted 91 lines
Em Thu, 21 Nov 2013 19:05:05 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 30 lines
Hello
I am adding new property for sampling rate that is ideally the only obligatory parameter required by SDR. It is value that could be only positive and bigger the better, lets say unsigned 64 bit is quite ideal. That value sets maximum radio frequency possible to receive (ideal SDR).Valid values are not always in some single range from X to Y, there could be some multiple value ranges.
For example possible values: 1000-2000, 23459, 900001-2800000
Reading possible values from device could be nice, but not necessary. Reading current value is more important.
Here is what I though earlier as a requirements:
sampling rate
* values: 1 - infinity (unit: Hz, samples per second) currently 500 MHz is more than enough
* operations
GET, inquire what HW supports
GET, get current value
SET, set desired valueI am not sure what is best way to implement that kind of thing. IOCTL like frequency
V4L2 Control?
put it into stream format request?Quoted 4 lines
Sampling rate is actually frequency of ADC. As there devices has almost always tuner too (practical SDR) there is need for tuner frequency too. As tuner is still own entity, is it possible to use same frequency parameter for both ADC and RF tuner in same device?
Well, a SDR capture device will always have ADC and RF tuner.
A SDR output device will always have a DAC and a RF transmitter.
On both cases, the sampling rate and the sampling format are mandatory arguments.
In any case, the V4L2 API has already support for setting the mandatory parameters of the expected stream, at struct
v4l2_format.So, it makes sense do do:
struct
v4l2_format{
__u32type;
union {
structv4l2_pix_formatpix; /*V4L2_BUF_TYPE_VIDEO_CAPTURE*/
structv4l2_pix_format_mplanepix_mp; /*V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE*/
structv4l2_windowwin; /*V4L2_BUF_TYPE_VIDEO_OVERLAY*/
structv4l2_vbi_formatvbi; /*V4L2_BUF_TYPE_VBI_CAPTURE*/
structv4l2_sliced_vbi_formatsliced; /*V4L2_BUF_TYPE_SLICED_VBI_CAPTURE*/
+ structv4l2_sdr_formatsdr; /*V4L2_BUF_TYPE_SDR_CAPTURE*/__u8 raw_data[200]; /* user-defined */ } fmt;};
And add the mandatory parameters for SDR inside its own structure, e. g. struct
v4l2_sdr_format. Of course, the meta-data provided by a SDR device is different than the one for video or vbi, so you'll need to add a new streaming type for SDR anyway.Btw, that's what I proposed here:
http://git.linuxtv.org/mchehab/experimental.git/blob/refs/heads/sdr:/include/uapi/linux/videodev2.h
With regards to the sampling rate range, my proposal there were to add a min/max value for it, to be used by
VIDIOC_G_FMT, as proposed on:http://git.linuxtv.org/mchehab/experimental.git/commitdiff/c3a73f84f038f043aeda5d5bfccc6fea66291451So, the
v4l2_sdr_formatshould be like:(quoted diff) +7
-0+struct v4l2_sdr_format { + __u32 sampleformat; + __u32 sample_rate; /* in Hz */ + __u32 min_sample_rate; /* in Hz */ + __u32 max_sample_rate; /* in Hz */ + +} __attribute__ ((packed));Where sampleformat would be something similar to FOURCC, defining the size of each sample, its format, and if the sampling is in quadradure, if they're plain PCM samples, or something more complex, like DPCM, RLE, etc.
Quoted 7 lines
Quoted 3 lines
In the specific case of enumerating the sampling rate range, if the sampling rate can have multiple ranges, then maybe we'll need to do something more complex like what was done on
VIDIOC_ENUM_FRAMESIZES.Could this ioctl be adapted for this:
http://hverkuil.home.xs4all.nl/spec/media.html#vidioc-enum-freq-bands
I don't think so. Btw, it makes sense to have different frequency bands for SDR too.
Quoted 2 lines
BTW, can the sample rate change while streaming? Typically things you set through
S_FMTcan not be changed while streaming.
I don't think you can. If the sampling rate changes, you need to know exactly on what sample the bit rate changed, or otherwise you can't decode the samples.
In other words, you need to first stream off, then change the sampling rate, then do a stream on.
Cheers,
Mauro
Quoted 33 lines · Mauro Carvalho Chehab
Em Thu, 21 Nov 2013 19:05:05 +0200
Antti Palosaari <[email protected]> escreveu:Quoted 30 lines
Hello
I am adding new property for sampling rate that is ideally the only obligatory parameter required by SDR. It is value that could be only positive and bigger the better, lets say unsigned 64 bit is quite ideal. That value sets maximum radio frequency possible to receive (ideal SDR).Valid values are not always in some single range from X to Y, there could be some multiple value ranges.
For example possible values: 1000-2000, 23459, 900001-2800000
Reading possible values from device could be nice, but not necessary. Reading current value is more important.
Here is what I though earlier as a requirements:
sampling rate
* values: 1 - infinity (unit: Hz, samples per second) currently 500 MHz is more than enough
* operations
GET, inquire what HW supports
GET, get current value
SET, set desired valueI am not sure what is best way to implement that kind of thing. IOCTL like frequency
V4L2 Control?
put it into stream format request?
Quoted 6 lines
Quoted 4 lines
Sampling rate is actually frequency of ADC. As there devices has almost always tuner too (practical SDR) there is need for tuner frequency too. As tuner is still own entity, is it possible to use same frequency parameter for both ADC and RF tuner in same device?
Well, a SDR capture device will always have ADC and RF tuner.
No, no no! Look for example Ettus USRP. It is fully modular and you could select different RF boards. I think you could even feed I/O from your DTV modulator to that that, having no tuner at all.
Quoted 1 line
A SDR output device will always have a DAC and a RF transmitter.
Nope! Usually you could feed baseband too, no "tuner" at all.
Quoted 3 lines
On both cases, the sampling rate and the sampling format are mandatory arguments.
Yeah, app needs to know sampling rate and of course stream format. Application stream format is typically pair of floats, whilst hardware offers integer numbers as a ADC sampling levels.
Quoted 41 lines
In any case, the V4L2 API has already support for setting the mandatory parameters of the expected stream, at struct
v4l2_format.So, it makes sense do do:
struct
v4l2_format{
__u32type;
union {
structv4l2_pix_formatpix; /*V4L2_BUF_TYPE_VIDEO_CAPTURE*/
structv4l2_pix_format_mplanepix_mp; /*V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE*/
structv4l2_windowwin; /*V4L2_BUF_TYPE_VIDEO_OVERLAY*/
structv4l2_vbi_formatvbi; /*V4L2_BUF_TYPE_VBI_CAPTURE*/
structv4l2_sliced_vbi_formatsliced; /*V4L2_BUF_TYPE_SLICED_VBI_CAPTURE*/
+ structv4l2_sdr_formatsdr; /*V4L2_BUF_TYPE_SDR_CAPTURE*/__u8 raw_data[200]; /* user-defined */ } fmt;};
And add the mandatory parameters for SDR inside its own structure, e. g. struct
v4l2_sdr_format. Of course, the meta-data provided by a SDR device is different than the one for video or vbi, so you'll need to add a new streaming type for SDR anyway.Btw, that's what I proposed here:
http://git.linuxtv.org/mchehab/experimental.git/blob/refs/heads/sdr:/include/uapi/linux/videodev2.h
With regards to the sampling rate range, my proposal there were to add a min/max value for it, to be used by
VIDIOC_G_FMT, as proposed on:http://git.linuxtv.org/mchehab/experimental.git/commitdiff/c3a73f84f038f043aeda5d5bfccc6fea66291451So, the
v4l2_sdr_formatshould be like:(quoted diff) +7
-0+struct v4l2_sdr_format { + __u32 sampleformat; + __u32 sample_rate; /* in Hz */ + __u32 min_sample_rate; /* in Hz */ + __u32 max_sample_rate; /* in Hz */ + +} __attribute__ ((packed));
Quoted 4 lines
Where sampleformat would be something similar to FOURCC, defining the size of each sample, its format, and if the sampling is in quadradure, if they're plain PCM samples, or something more complex, like DPCM, RLE, etc.
Personally I would like to implement that a way driver returns some known integer formats. That means, driver does some small conversion, reads device specific numbers from device and outputs those to some known formats like integers.
But I already moved all that stuff to libv4lconvert.
Quoted 7 lines
In the specific case of enumerating the sampling rate range, if the sampling rate can have multiple ranges, then maybe we'll need to do something more complex like what was done on
VIDIOC_ENUM_FRAMESIZES.Regards,
Mauro
regards
Antti
Signature · 1 line
http://palosaari.fi/