summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux/drivers/media/dvb/frontends/cx24113.c6
-rw-r--r--linux/drivers/media/video/hdpvr/hdpvr-video.c2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-audio.c5
-rw-r--r--linux/drivers/media/video/v4l2-ioctl.c15
-rw-r--r--v4l2-apps/util/v4l2-ctl.cpp98
5 files changed, 101 insertions, 25 deletions
diff --git a/linux/drivers/media/dvb/frontends/cx24113.c b/linux/drivers/media/dvb/frontends/cx24113.c
index e4fd533a4..075b2b57c 100644
--- a/linux/drivers/media/dvb/frontends/cx24113.c
+++ b/linux/drivers/media/dvb/frontends/cx24113.c
@@ -303,6 +303,7 @@ static void cx24113_calc_pll_nf(struct cx24113_state *state, u16 *n, s32 *f)
{
s32 N;
s64 F;
+ u64 dividend;
u8 R, r;
u8 vcodiv;
u8 factor;
@@ -346,7 +347,10 @@ static void cx24113_calc_pll_nf(struct cx24113_state *state, u16 *n, s32 *f)
F = freq_hz;
F *= (u64) (R * vcodiv * 262144);
dprintk("1 N: %d, F: %lld, R: %d\n", N, (long long)F, R);
- do_div(F, state->config->xtal_khz*1000 * factor * 2);
+ /* do_div needs an u64 as first argument */
+ dividend = F;
+ do_div(dividend, state->config->xtal_khz * 1000 * factor * 2);
+ F = dividend;
dprintk("2 N: %d, F: %lld, R: %d\n", N, (long long)F, R);
F -= (N + 32) * 262144;
diff --git a/linux/drivers/media/video/hdpvr/hdpvr-video.c b/linux/drivers/media/video/hdpvr/hdpvr-video.c
index 5937de23c..2eb9dc2eb 100644
--- a/linux/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/linux/drivers/media/video/hdpvr/hdpvr-video.c
@@ -1222,6 +1222,8 @@ static const struct video_device hdpvr_video_template = {
V4L2_STD_PAL_G | V4L2_STD_PAL_H | V4L2_STD_PAL_I |
V4L2_STD_PAL_D | V4L2_STD_PAL_M | V4L2_STD_PAL_N |
V4L2_STD_PAL_60,
+ .current_norm = V4L2_STD_NTSC | V4L2_STD_PAL_M |
+ V4L2_STD_PAL_60,
};
int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-audio.c b/linux/drivers/media/video/pvrusb2/pvrusb2-audio.c
index 42875ec21..d8c9e6632 100644
--- a/linux/drivers/media/video/pvrusb2/pvrusb2-audio.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-audio.c
@@ -66,9 +66,10 @@ void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
u32 input;
pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo");
+ sp = (sid < ARRAY_SIZE(routing_schemes)) ?
+ routing_schemes[sid] : NULL;
- if ((sid < ARRAY_SIZE(routing_schemes)) &&
- ((sp = routing_schemes[sid]) != NULL) &&
+ if ((sp != NULL) &&
(hdw->input_val >= 0) &&
(hdw->input_val < sp->cnt)) {
input = sp->def[hdw->input_val];
diff --git a/linux/drivers/media/video/v4l2-ioctl.c b/linux/drivers/media/video/v4l2-ioctl.c
index 80c94dc5a..d746d9555 100644
--- a/linux/drivers/media/video/v4l2-ioctl.c
+++ b/linux/drivers/media/video/v4l2-ioctl.c
@@ -1088,8 +1088,10 @@ static long __video_do_ioctl(struct file *file,
/* Calls the specific handler */
if (ops->vidioc_g_std)
ret = ops->vidioc_g_std(file, fh, id);
- else
+ else if (vfd->current_norm)
*id = vfd->current_norm;
+ else
+ ret = -EINVAL;
if (!ret)
dbgarg(cmd, "std=0x%08Lx\n", (long long unsigned)*id);
@@ -1560,12 +1562,19 @@ static long __video_do_ioctl(struct file *file,
break;
ret = ops->vidioc_g_parm(file, fh, p);
} else {
+ v4l2_std_id std = vfd->current_norm;
+
if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
- v4l2_video_std_frame_period(vfd->current_norm,
- &p->parm.capture.timeperframe);
ret = 0;
+ if (ops->vidioc_g_std)
+ ret = ops->vidioc_g_std(file, fh, &std);
+ else if (std == 0)
+ ret = -EINVAL;
+ if (ret == 0)
+ v4l2_video_std_frame_period(std,
+ &p->parm.capture.timeperframe);
}
dbgarg(cmd, "type=%d\n", p->type);
diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp
index 898c88cb7..60ebc5474 100644
--- a/v4l2-apps/util/v4l2-ctl.cpp
+++ b/v4l2-apps/util/v4l2-ctl.cpp
@@ -136,6 +136,8 @@ enum Option {
OptGetModulator,
OptSetModulator,
OptListDevices,
+ OptGetOutputParm,
+ OptSetOutputParm,
OptLast = 256
};
@@ -226,6 +228,8 @@ static struct option long_options[] = {
{"set-standard", required_argument, 0, OptSetStandard},
{"get-parm", no_argument, 0, OptGetParm},
{"set-parm", required_argument, 0, OptSetParm},
+ {"get-output-parm", no_argument, 0, OptGetOutputParm},
+ {"set-output-parm", required_argument, 0, OptSetOutputParm},
{"info", no_argument, 0, OptGetDriverInfo},
{"list-ctrls", no_argument, 0, OptListCtrls},
{"list-ctrls-menus", no_argument, 0, OptListCtrlsMenus},
@@ -310,8 +314,9 @@ static void usage(void)
" ntsc-X (X = M/J/K) or just 'ntsc' (V4L2_STD_NTSC)\n"
" secam-X (X = B/G/H/D/K/L/Lc) or just 'secam' (V4L2_STD_SECAM)\n"
" --list-standards display supported video standards [VIDIOC_ENUMSTD]\n"
- " -P, --get-parm display video parameters [VIDIOC_G_PARMS]\n"
- " -p, --set-parm set video rate in fps [VIDIOC_S_PARMS]\n"
+ " -P, --get-parm display video parameters [VIDIOC_G_PARM]\n"
+ " -p, --set-parm=<fps>\n"
+ " set video framerate in <fps> [VIDIOC_S_PARM]\n"
" -T, --get-tuner query the tuner settings [VIDIOC_G_TUNER]\n"
" -t, --set-tuner=<mode>\n"
" set the audio mode of the tuner [VIDIOC_S_TUNER]\n"
@@ -424,6 +429,9 @@ static void usage(void)
" bilingual: Modulate as bilingual\n"
" mono-sap: Modulate as mono with Second Audio Program\n"
" stereo-sap: Modulate as stereo with Second Audio Program\n"
+ " --get-output-parm display output video parameters [VIDIOC_G_PARM]\n"
+ " --set-output-parm=<fps>\n"
+ " set output video framerate in <fps> [VIDIOC_S_PARM]\n"
"\n");
printf("Expert options:\n"
" --streamoff turn the stream off [VIDIOC_STREAMOFF]\n"
@@ -830,7 +838,7 @@ static void printcropcap(const struct v4l2_cropcap &cropcap)
printf("\tPixel Aspect: %u/%u\n", cropcap.pixelaspect.numerator, cropcap.pixelaspect.denominator);
}
-static void printfmt(struct v4l2_format vfmt)
+static void printfmt(const struct v4l2_format &vfmt)
{
const flag_def vbi_def[] = {
{ V4L2_VBI_UNSYNC, "unsynchronized" },
@@ -1431,7 +1439,8 @@ int main(int argc, char **argv)
int txsubchans; /* set_modulator */
v4l2_std_id std; /* get_std/set_std */
double freq = 0; /* get/set frequency */
- double fps = 0; /* set framerate speed, in fps */
+ double fps = 0; /* set framerate speed, in fps */
+ double output_fps = 0; /* set framerate speed, in fps */
struct v4l2_frequency vf; /* get_freq/set_freq */
struct v4l2_standard vs; /* list_std */
int overlay; /* overlay */
@@ -1701,6 +1710,9 @@ int main(int argc, char **argv)
case OptSetParm:
fps = strtod(optarg, NULL);
break;
+ case OptSetOutputParm:
+ output_fps = strtod(optarg, NULL);
+ break;
case OptGetCtrl:
subs = optarg;
while (*subs != '\0') {
@@ -1927,6 +1939,7 @@ int main(int argc, char **argv)
options[OptGetAudioOutput] = 1;
options[OptGetStandard] = 1;
options[OptGetParm] = 1;
+ options[OptGetOutputParm] = 1;
options[OptGetFreq] = 1;
options[OptGetTuner] = 1;
options[OptGetModulator] = 1;
@@ -1990,18 +2003,38 @@ int main(int argc, char **argv)
if (options[OptSetParm]) {
- memset (&parm, 0, sizeof(parm));
+ memset(&parm, 0, sizeof(parm));
parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
parm.parm.capture.timeperframe.numerator = 1000;
- parm.parm.capture.timeperframe.denominator = (__u32)(fps * parm.parm.capture.timeperframe.numerator);
+ parm.parm.capture.timeperframe.denominator =
+ fps * parm.parm.capture.timeperframe.numerator;
if (doioctl(fd, VIDIOC_S_PARM, &parm, "VIDIOC_S_PARM") == 0) {
struct v4l2_fract *tf = &parm.parm.capture.timeperframe;
+
if (!tf->denominator || !tf->numerator)
- printf ("Invalid frame rate\n");
+ printf("Invalid frame rate\n");
else
- printf("Frame rate set to: %.3f fps\n",
- 1.0*tf->denominator/tf->numerator);
+ printf("Frame rate set to %.3f fps\n",
+ 1.0 * tf->denominator / tf->numerator);
+ }
+ }
+
+ if (options[OptSetOutputParm]) {
+ memset(&parm, 0, sizeof(parm));
+ parm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ parm.parm.output.timeperframe.numerator = 1000;
+ parm.parm.output.timeperframe.denominator =
+ fps * parm.parm.output.timeperframe.numerator;
+
+ if (doioctl(fd, VIDIOC_S_PARM, &parm, "VIDIOC_S_PARM") == 0) {
+ struct v4l2_fract *tf = &parm.parm.output.timeperframe;
+
+ if (!tf->denominator || !tf->numerator)
+ printf("Invalid frame rate\n");
+ else
+ printf("Frame rate set to %.3f fps\n",
+ 1.0 * tf->denominator / tf->numerator);
}
}
@@ -2481,19 +2514,46 @@ set_vid_fmt_error:
}
if (options[OptGetParm]) {
- memset (&parm, 0, sizeof(parm));
+ memset(&parm, 0, sizeof(parm));
parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (doioctl(fd, VIDIOC_G_PARM, &parm, "VIDIOC_G_PARM") == 0) {
- struct v4l2_fract *tf = &parm.parm.capture.timeperframe;
- if (parm.parm.capture.capability & V4L2_MODE_HIGHQUALITY)
- printf("Has High quality imaging mode\n");
- if (parm.parm.capture.capability && V4L2_CAP_TIMEPERFRAME)
- printf("Has V4L2_CAP_TIMEPERFRAME\n");
- if (!tf->denominator || !tf->numerator)
- printf ("Invalid frame rate\n");
+ const struct v4l2_fract &tf = parm.parm.capture.timeperframe;
+
+ printf("Streaming Parameters %s:\n", buftype2s(parm.type).c_str());
+ if (parm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME)
+ printf("\tCapabilities : timeperframe\n");
+ if (parm.parm.capture.capturemode & V4L2_MODE_HIGHQUALITY)
+ printf("\tCapture mode : high quality\n");
+ if (!tf.denominator || !tf.numerator)
+ printf("\tFrames per second: invalid (%d/%d)\n",
+ tf.denominator, tf.numerator);
+ else
+ printf("\tFrames per second: %.3f (%d/%d)\n",
+ (1.0 * tf.denominator) / tf.numerator,
+ tf.denominator, tf.numerator);
+ printf("\tRead buffers : %d\n", parm.parm.output.writebuffers);
+ }
+ }
+
+ if (options[OptGetOutputParm]) {
+ memset(&parm, 0, sizeof(parm));
+ parm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ if (doioctl(fd, VIDIOC_G_PARM, &parm, "VIDIOC_G_PARM") == 0) {
+ const struct v4l2_fract &tf = parm.parm.output.timeperframe;
+
+ printf("Streaming Parameters %s:\n", buftype2s(parm.type).c_str());
+ if (parm.parm.output.capability & V4L2_CAP_TIMEPERFRAME)
+ printf("\tCapabilities : timeperframe\n");
+ if (parm.parm.output.outputmode & V4L2_MODE_HIGHQUALITY)
+ printf("\tOutput mode : high quality\n");
+ if (!tf.denominator || !tf.numerator)
+ printf("\tFrames per second: invalid (%d/%d)\n",
+ tf.denominator, tf.numerator);
else
- printf("Frame rate is %.3f fps\n",
- (1.0 * tf->denominator) / tf->numerator);
+ printf("\tFrames per second: %.3f (%d/%d)\n",
+ (1.0 * tf.denominator) / tf.numerator,
+ tf.denominator, tf.numerator);
+ printf("\tWrite buffers : %d\n", parm.parm.output.writebuffers);
}
}