diff options
| author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-05-09 05:44:16 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-06-01 00:21:48 -0400 |
| commit | 283d637bbd7301c9fb2236103b990b9d66099d78 (patch) | |
| tree | d233994df83847081e917d1b24898bdeaae3a544 | |
| parent | f1a4435f3efa510760adf6acb87c62653de9a0ee (diff) | |
V4L/DVB: tvp514x: simplify try/g/s_fmt handling
Since there is only one possible format just have all three calls
do the same.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: Vaibhav Hiremath <hvaibhav@ti.com>
Tested-by: Vaibhav Hiremath <hvaibhav@ti.com>
Acked-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
| -rw-r--r-- | drivers/media/video/tvp514x.c | 98 |
1 files changed, 9 insertions, 89 deletions
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c index bb5df5176377..71c73fa0d68c 100644 --- a/drivers/media/video/tvp514x.c +++ b/drivers/media/video/tvp514x.c | |||
| @@ -88,7 +88,6 @@ static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable); | |||
| 88 | * @pdata: Board specific | 88 | * @pdata: Board specific |
| 89 | * @ver: Chip version | 89 | * @ver: Chip version |
| 90 | * @streaming: TVP5146/47 decoder streaming - enabled or disabled. | 90 | * @streaming: TVP5146/47 decoder streaming - enabled or disabled. |
| 91 | * @pix: Current pixel format | ||
| 92 | * @current_std: Current standard | 91 | * @current_std: Current standard |
| 93 | * @num_stds: Number of standards | 92 | * @num_stds: Number of standards |
| 94 | * @std_list: Standards list | 93 | * @std_list: Standards list |
| @@ -103,8 +102,6 @@ struct tvp514x_decoder { | |||
| 103 | int ver; | 102 | int ver; |
| 104 | int streaming; | 103 | int streaming; |
| 105 | 104 | ||
| 106 | struct v4l2_pix_format pix; | ||
| 107 | |||
| 108 | enum tvp514x_std current_std; | 105 | enum tvp514x_std current_std; |
| 109 | int num_stds; | 106 | int num_stds; |
| 110 | const struct tvp514x_std_info *std_list; | 107 | const struct tvp514x_std_info *std_list; |
| @@ -957,16 +954,15 @@ tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt) | |||
| 957 | } | 954 | } |
| 958 | 955 | ||
| 959 | /** | 956 | /** |
| 960 | * tvp514x_try_fmt_cap() - V4L2 decoder interface handler for try_fmt | 957 | * tvp514x_fmt_cap() - V4L2 decoder interface handler for try/s/g_fmt |
| 961 | * @sd: pointer to standard V4L2 sub-device structure | 958 | * @sd: pointer to standard V4L2 sub-device structure |
| 962 | * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure | 959 | * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure |
| 963 | * | 960 | * |
| 964 | * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This | 961 | * Implement the VIDIOC_TRY/S/G_FMT ioctl for the CAPTURE buffer type. This |
| 965 | * ioctl is used to negotiate the image capture size and pixel format | 962 | * ioctl is used to negotiate the image capture size and pixel format. |
| 966 | * without actually making it take effect. | ||
| 967 | */ | 963 | */ |
| 968 | static int | 964 | static int |
| 969 | tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) | 965 | tvp514x_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) |
| 970 | { | 966 | { |
| 971 | struct tvp514x_decoder *decoder = to_decoder(sd); | 967 | struct tvp514x_decoder *decoder = to_decoder(sd); |
| 972 | struct v4l2_pix_format *pix; | 968 | struct v4l2_pix_format *pix; |
| @@ -976,8 +972,7 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) | |||
| 976 | return -EINVAL; | 972 | return -EINVAL; |
| 977 | 973 | ||
| 978 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 974 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
| 979 | /* only capture is supported */ | 975 | return -EINVAL; |
| 980 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 981 | 976 | ||
| 982 | pix = &f->fmt.pix; | 977 | pix = &f->fmt.pix; |
| 983 | 978 | ||
| @@ -993,7 +988,7 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) | |||
| 993 | pix->colorspace = V4L2_COLORSPACE_SMPTE170M; | 988 | pix->colorspace = V4L2_COLORSPACE_SMPTE170M; |
| 994 | pix->priv = 0; | 989 | pix->priv = 0; |
| 995 | 990 | ||
| 996 | v4l2_dbg(1, debug, sd, "Try FMT: bytesperline - %d" | 991 | v4l2_dbg(1, debug, sd, "FMT: bytesperline - %d" |
| 997 | "Width - %d, Height - %d\n", | 992 | "Width - %d, Height - %d\n", |
| 998 | pix->bytesperline, | 993 | pix->bytesperline, |
| 999 | pix->width, pix->height); | 994 | pix->width, pix->height); |
| @@ -1001,68 +996,6 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) | |||
| 1001 | } | 996 | } |
| 1002 | 997 | ||
| 1003 | /** | 998 | /** |
| 1004 | * tvp514x_s_fmt_cap() - V4L2 decoder interface handler for s_fmt | ||
| 1005 | * @sd: pointer to standard V4L2 sub-device structure | ||
| 1006 | * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure | ||
| 1007 | * | ||
| 1008 | * If the requested format is supported, configures the HW to use that | ||
| 1009 | * format, returns error code if format not supported or HW can't be | ||
| 1010 | * correctly configured. | ||
| 1011 | */ | ||
| 1012 | static int | ||
| 1013 | tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) | ||
| 1014 | { | ||
| 1015 | struct tvp514x_decoder *decoder = to_decoder(sd); | ||
| 1016 | struct v4l2_pix_format *pix; | ||
| 1017 | int rval; | ||
| 1018 | |||
| 1019 | if (f == NULL) | ||
| 1020 | return -EINVAL; | ||
| 1021 | |||
| 1022 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 1023 | /* only capture is supported */ | ||
| 1024 | return -EINVAL; | ||
| 1025 | |||
| 1026 | pix = &f->fmt.pix; | ||
| 1027 | rval = tvp514x_try_fmt_cap(sd, f); | ||
| 1028 | if (rval) | ||
| 1029 | return rval; | ||
| 1030 | |||
| 1031 | decoder->pix = *pix; | ||
| 1032 | |||
| 1033 | return rval; | ||
| 1034 | } | ||
| 1035 | |||
| 1036 | /** | ||
| 1037 | * tvp514x_g_fmt_cap() - V4L2 decoder interface handler for tvp514x_g_fmt_cap | ||
| 1038 | * @sd: pointer to standard V4L2 sub-device structure | ||
| 1039 | * @f: pointer to standard V4L2 v4l2_format structure | ||
| 1040 | * | ||
| 1041 | * Returns the decoder's current pixel format in the v4l2_format | ||
| 1042 | * parameter. | ||
| 1043 | */ | ||
| 1044 | static int | ||
| 1045 | tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f) | ||
| 1046 | { | ||
| 1047 | struct tvp514x_decoder *decoder = to_decoder(sd); | ||
| 1048 | |||
| 1049 | if (f == NULL) | ||
| 1050 | return -EINVAL; | ||
| 1051 | |||
| 1052 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 1053 | /* only capture is supported */ | ||
| 1054 | return -EINVAL; | ||
| 1055 | |||
| 1056 | f->fmt.pix = decoder->pix; | ||
| 1057 | |||
| 1058 | v4l2_dbg(1, debug, sd, "Current FMT: bytesperline - %d" | ||
| 1059 | "Width - %d, Height - %d\n", | ||
| 1060 | decoder->pix.bytesperline, | ||
| 1061 | decoder->pix.width, decoder->pix.height); | ||
| 1062 | return 0; | ||
| 1063 | } | ||
| 1064 | |||
| 1065 | /** | ||
| 1066 | * tvp514x_g_parm() - V4L2 decoder interface handler for g_parm | 999 | * tvp514x_g_parm() - V4L2 decoder interface handler for g_parm |
| 1067 | * @sd: pointer to standard V4L2 sub-device structure | 1000 | * @sd: pointer to standard V4L2 sub-device structure |
| 1068 | * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure | 1001 | * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure |
| @@ -1199,9 +1132,9 @@ static const struct v4l2_subdev_video_ops tvp514x_video_ops = { | |||
| 1199 | .s_routing = tvp514x_s_routing, | 1132 | .s_routing = tvp514x_s_routing, |
| 1200 | .querystd = tvp514x_querystd, | 1133 | .querystd = tvp514x_querystd, |
| 1201 | .enum_fmt = tvp514x_enum_fmt_cap, | 1134 | .enum_fmt = tvp514x_enum_fmt_cap, |
| 1202 | .g_fmt = tvp514x_g_fmt_cap, | 1135 | .g_fmt = tvp514x_fmt_cap, |
| 1203 | .try_fmt = tvp514x_try_fmt_cap, | 1136 | .try_fmt = tvp514x_fmt_cap, |
| 1204 | .s_fmt = tvp514x_s_fmt_cap, | 1137 | .s_fmt = tvp514x_fmt_cap, |
| 1205 | .g_parm = tvp514x_g_parm, | 1138 | .g_parm = tvp514x_g_parm, |
| 1206 | .s_parm = tvp514x_s_parm, | 1139 | .s_parm = tvp514x_s_parm, |
| 1207 | .s_stream = tvp514x_s_stream, | 1140 | .s_stream = tvp514x_s_stream, |
| @@ -1214,19 +1147,6 @@ static const struct v4l2_subdev_ops tvp514x_ops = { | |||
| 1214 | 1147 | ||
| 1215 | static struct tvp514x_decoder tvp514x_dev = { | 1148 | static struct tvp514x_decoder tvp514x_dev = { |
| 1216 | .streaming = 0, | 1149 | .streaming = 0, |
| 1217 | |||
| 1218 | .pix = { | ||
| 1219 | /* Default to NTSC 8-bit YUV 422 */ | ||
| 1220 | .width = NTSC_NUM_ACTIVE_PIXELS, | ||
| 1221 | .height = NTSC_NUM_ACTIVE_LINES, | ||
| 1222 | .pixelformat = V4L2_PIX_FMT_UYVY, | ||
| 1223 | .field = V4L2_FIELD_INTERLACED, | ||
| 1224 | .bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2, | ||
| 1225 | .sizeimage = | ||
| 1226 | NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES, | ||
| 1227 | .colorspace = V4L2_COLORSPACE_SMPTE170M, | ||
| 1228 | }, | ||
| 1229 | |||
| 1230 | .current_std = STD_NTSC_MJ, | 1150 | .current_std = STD_NTSC_MJ, |
| 1231 | .std_list = tvp514x_std_list, | 1151 | .std_list = tvp514x_std_list, |
| 1232 | .num_stds = ARRAY_SIZE(tvp514x_std_list), | 1152 | .num_stds = ARRAY_SIZE(tvp514x_std_list), |
