diff options
author | Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> | 2016-06-28 22:17:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-07-13 12:34:52 -0400 |
commit | 85c30a7272bac3ce228da5313554f373c163a43c (patch) | |
tree | 42b99639a695fce674741affab6911de4dac6d90 | |
parent | fb66852d4c693d5159724aef2b0c5e956206940d (diff) |
[media] tw686x: Support VIDIOC_{S,G}_PARM ioctls
Now that the frame rate can be properly set, this commit adds support
for S_PARM and G_PARM.
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/pci/tw686x/tw686x-video.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c index 487b078a5acc..cdb16de770fe 100644 --- a/drivers/media/pci/tw686x/tw686x-video.c +++ b/drivers/media/pci/tw686x/tw686x-video.c | |||
@@ -408,9 +408,6 @@ static void tw686x_set_framerate(struct tw686x_video_channel *vc, | |||
408 | { | 408 | { |
409 | unsigned int i; | 409 | unsigned int i; |
410 | 410 | ||
411 | if (vc->fps == fps) | ||
412 | return; | ||
413 | |||
414 | i = tw686x_fps_idx(fps, TW686X_MAX_FPS(vc->video_standard)); | 411 | i = tw686x_fps_idx(fps, TW686X_MAX_FPS(vc->video_standard)); |
415 | reg_write(vc->dev, VIDEO_FIELD_CTRL[vc->ch], fps_map[i]); | 412 | reg_write(vc->dev, VIDEO_FIELD_CTRL[vc->ch], fps_map[i]); |
416 | vc->fps = tw686x_real_fps(i, TW686X_MAX_FPS(vc->video_standard)); | 413 | vc->fps = tw686x_real_fps(i, TW686X_MAX_FPS(vc->video_standard)); |
@@ -813,6 +810,12 @@ static int tw686x_s_std(struct file *file, void *priv, v4l2_std_id id) | |||
813 | ret = tw686x_g_fmt_vid_cap(file, priv, &f); | 810 | ret = tw686x_g_fmt_vid_cap(file, priv, &f); |
814 | if (!ret) | 811 | if (!ret) |
815 | tw686x_s_fmt_vid_cap(file, priv, &f); | 812 | tw686x_s_fmt_vid_cap(file, priv, &f); |
813 | |||
814 | /* | ||
815 | * Frame decimation depends on the chosen standard, | ||
816 | * so reset it to the current value. | ||
817 | */ | ||
818 | tw686x_set_framerate(vc, vc->fps); | ||
816 | return 0; | 819 | return 0; |
817 | } | 820 | } |
818 | 821 | ||
@@ -882,6 +885,40 @@ static int tw686x_g_std(struct file *file, void *priv, v4l2_std_id *id) | |||
882 | return 0; | 885 | return 0; |
883 | } | 886 | } |
884 | 887 | ||
888 | static int tw686x_g_parm(struct file *file, void *priv, | ||
889 | struct v4l2_streamparm *sp) | ||
890 | { | ||
891 | struct tw686x_video_channel *vc = video_drvdata(file); | ||
892 | struct v4l2_captureparm *cp = &sp->parm.capture; | ||
893 | |||
894 | if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
895 | return -EINVAL; | ||
896 | sp->parm.capture.readbuffers = 3; | ||
897 | |||
898 | cp->capability = V4L2_CAP_TIMEPERFRAME; | ||
899 | cp->timeperframe.numerator = 1; | ||
900 | cp->timeperframe.denominator = vc->fps; | ||
901 | return 0; | ||
902 | } | ||
903 | |||
904 | static int tw686x_s_parm(struct file *file, void *priv, | ||
905 | struct v4l2_streamparm *sp) | ||
906 | { | ||
907 | struct tw686x_video_channel *vc = video_drvdata(file); | ||
908 | struct v4l2_captureparm *cp = &sp->parm.capture; | ||
909 | unsigned int denominator = cp->timeperframe.denominator; | ||
910 | unsigned int numerator = cp->timeperframe.numerator; | ||
911 | unsigned int fps; | ||
912 | |||
913 | if (vb2_is_busy(&vc->vidq)) | ||
914 | return -EBUSY; | ||
915 | |||
916 | fps = (!numerator || !denominator) ? 0 : denominator / numerator; | ||
917 | if (vc->fps != fps) | ||
918 | tw686x_set_framerate(vc, fps); | ||
919 | return tw686x_g_parm(file, priv, sp); | ||
920 | } | ||
921 | |||
885 | static int tw686x_enum_fmt_vid_cap(struct file *file, void *priv, | 922 | static int tw686x_enum_fmt_vid_cap(struct file *file, void *priv, |
886 | struct v4l2_fmtdesc *f) | 923 | struct v4l2_fmtdesc *f) |
887 | { | 924 | { |
@@ -968,6 +1005,9 @@ static const struct v4l2_ioctl_ops tw686x_video_ioctl_ops = { | |||
968 | .vidioc_g_std = tw686x_g_std, | 1005 | .vidioc_g_std = tw686x_g_std, |
969 | .vidioc_s_std = tw686x_s_std, | 1006 | .vidioc_s_std = tw686x_s_std, |
970 | 1007 | ||
1008 | .vidioc_g_parm = tw686x_g_parm, | ||
1009 | .vidioc_s_parm = tw686x_s_parm, | ||
1010 | |||
971 | .vidioc_enum_input = tw686x_enum_input, | 1011 | .vidioc_enum_input = tw686x_enum_input, |
972 | .vidioc_g_input = tw686x_g_input, | 1012 | .vidioc_g_input = tw686x_g_input, |
973 | .vidioc_s_input = tw686x_s_input, | 1013 | .vidioc_s_input = tw686x_s_input, |