summaryrefslogtreecommitdiff
path: root/drivers/media/pci/saa7134/saa6752hs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/pci/saa7134/saa6752hs.c')
-rw-r--r--drivers/media/pci/saa7134/saa6752hs.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/drivers/media/pci/saa7134/saa6752hs.c b/drivers/media/pci/saa7134/saa6752hs.c
index 8adb7b02ab5a..8ac4b1f2322d 100644
--- a/drivers/media/pci/saa7134/saa6752hs.c
+++ b/drivers/media/pci/saa7134/saa6752hs.c
@@ -568,10 +568,36 @@ static int saa6752hs_g_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefm
return 0;
}
+static int saa6752hs_try_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f)
+{
+ int dist_352, dist_480, dist_720;
+
+ f->code = V4L2_MBUS_FMT_FIXED;
+
+ dist_352 = abs(f->width - 352);
+ dist_480 = abs(f->width - 480);
+ dist_720 = abs(f->width - 720);
+ if (dist_720 < dist_480) {
+ f->width = 720;
+ f->height = 576;
+ } else if (dist_480 < dist_352) {
+ f->width = 480;
+ f->height = 576;
+ } else {
+ f->width = 352;
+ if (abs(f->height - 576) < abs(f->height - 288))
+ f->height = 576;
+ else
+ f->height = 288;
+ }
+ f->field = V4L2_FIELD_INTERLACED;
+ f->colorspace = V4L2_COLORSPACE_SMPTE170M;
+ return 0;
+}
+
static int saa6752hs_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f)
{
struct saa6752hs_state *h = to_state(sd);
- int dist_352, dist_480, dist_720;
if (f->code != V4L2_MBUS_FMT_FIXED)
return -EINVAL;
@@ -588,30 +614,15 @@ static int saa6752hs_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefm
D1 | 720x576 | 720x480
*/
- dist_352 = abs(f->width - 352);
- dist_480 = abs(f->width - 480);
- dist_720 = abs(f->width - 720);
- if (dist_720 < dist_480) {
- f->width = 720;
- f->height = 576;
+ saa6752hs_try_mbus_fmt(sd, f);
+ if (f->width == 720)
h->video_format = SAA6752HS_VF_D1;
- } else if (dist_480 < dist_352) {
- f->width = 480;
- f->height = 576;
+ else if (f->width == 480)
h->video_format = SAA6752HS_VF_2_3_D1;
- } else {
- f->width = 352;
- if (abs(f->height - 576) <
- abs(f->height - 288)) {
- f->height = 576;
- h->video_format = SAA6752HS_VF_1_2_D1;
- } else {
- f->height = 288;
- h->video_format = SAA6752HS_VF_SIF;
- }
- }
- f->field = V4L2_FIELD_INTERLACED;
- f->colorspace = V4L2_COLORSPACE_SMPTE170M;
+ else if (f->height == 576)
+ h->video_format = SAA6752HS_VF_1_2_D1;
+ else
+ h->video_format = SAA6752HS_VF_SIF;
return 0;
}
@@ -644,6 +655,7 @@ static const struct v4l2_subdev_core_ops saa6752hs_core_ops = {
static const struct v4l2_subdev_video_ops saa6752hs_video_ops = {
.s_mbus_fmt = saa6752hs_s_mbus_fmt,
+ .try_mbus_fmt = saa6752hs_try_mbus_fmt,
.g_mbus_fmt = saa6752hs_g_mbus_fmt,
};