media: v4l2-subdev: add subdev-wide state struct
[linux-2.6-microblaze.git] / drivers / media / i2c / tvp5150.c
index e26e3f5..30c6355 100644 (file)
@@ -1027,7 +1027,7 @@ static void tvp5150_set_default(v4l2_std_id std, struct v4l2_rect *crop)
 
 static struct v4l2_rect *
 tvp5150_get_pad_crop(struct tvp5150 *decoder,
-                    struct v4l2_subdev_pad_config *cfg, unsigned int pad,
+                    struct v4l2_subdev_state *sd_state, unsigned int pad,
                     enum v4l2_subdev_format_whence which)
 {
        switch (which) {
@@ -1035,7 +1035,7 @@ tvp5150_get_pad_crop(struct tvp5150 *decoder,
                return &decoder->rect;
        case V4L2_SUBDEV_FORMAT_TRY:
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-               return v4l2_subdev_get_try_crop(&decoder->sd, cfg, pad);
+               return v4l2_subdev_get_try_crop(&decoder->sd, sd_state, pad);
 #else
                return ERR_PTR(-EINVAL);
 #endif
@@ -1045,7 +1045,7 @@ tvp5150_get_pad_crop(struct tvp5150 *decoder,
 }
 
 static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
-                           struct v4l2_subdev_pad_config *cfg,
+                           struct v4l2_subdev_state *sd_state,
                            struct v4l2_subdev_format *format)
 {
        struct v4l2_mbus_framefmt *f;
@@ -1104,7 +1104,7 @@ static void tvp5150_set_hw_selection(struct v4l2_subdev *sd,
 }
 
 static int tvp5150_set_selection(struct v4l2_subdev *sd,
-                                struct v4l2_subdev_pad_config *cfg,
+                                struct v4l2_subdev_state *sd_state,
                                 struct v4l2_subdev_selection *sel)
 {
        struct tvp5150 *decoder = to_tvp5150(sd);
@@ -1138,7 +1138,7 @@ static int tvp5150_set_selection(struct v4l2_subdev *sd,
            sel->which == V4L2_SUBDEV_FORMAT_TRY)
                return 0;
 
-       crop = tvp5150_get_pad_crop(decoder, cfg, sel->pad, sel->which);
+       crop = tvp5150_get_pad_crop(decoder, sd_state, sel->pad, sel->which);
        if (IS_ERR(crop))
                return PTR_ERR(crop);
 
@@ -1156,7 +1156,7 @@ static int tvp5150_set_selection(struct v4l2_subdev *sd,
 }
 
 static int tvp5150_get_selection(struct v4l2_subdev *sd,
-                                struct v4l2_subdev_pad_config *cfg,
+                                struct v4l2_subdev_state *sd_state,
                                 struct v4l2_subdev_selection *sel)
 {
        struct tvp5150 *decoder = container_of(sd, struct tvp5150, sd);
@@ -1180,7 +1180,7 @@ static int tvp5150_get_selection(struct v4l2_subdev *sd,
                        sel->r.height = TVP5150_V_MAX_OTHERS;
                return 0;
        case V4L2_SEL_TGT_CROP:
-               crop = tvp5150_get_pad_crop(decoder, cfg, sel->pad,
+               crop = tvp5150_get_pad_crop(decoder, sd_state, sel->pad,
                                            sel->which);
                if (IS_ERR(crop))
                        return PTR_ERR(crop);
@@ -1208,7 +1208,7 @@ static int tvp5150_get_mbus_config(struct v4l2_subdev *sd,
                        V4L2 subdev pad ops
  ****************************************************************************/
 static int tvp5150_init_cfg(struct v4l2_subdev *sd,
-                           struct v4l2_subdev_pad_config *cfg)
+                           struct v4l2_subdev_state *sd_state)
 {
        struct tvp5150 *decoder = to_tvp5150(sd);
        v4l2_std_id std;
@@ -1229,7 +1229,7 @@ static int tvp5150_init_cfg(struct v4l2_subdev *sd,
 }
 
 static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd,
-               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_state *sd_state,
                struct v4l2_subdev_mbus_code_enum *code)
 {
        if (code->pad || code->index)
@@ -1240,7 +1240,7 @@ static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd,
 }
 
 static int tvp5150_enum_frame_size(struct v4l2_subdev *sd,
-                                  struct v4l2_subdev_pad_config *cfg,
+                                  struct v4l2_subdev_state *sd_state,
                                   struct v4l2_subdev_frame_size_enum *fse)
 {
        struct tvp5150 *decoder = to_tvp5150(sd);
@@ -1448,11 +1448,9 @@ static int tvp5150_s_stream(struct v4l2_subdev *sd, int enable)
               TVP5150_MISC_CTL_CLOCK_OE;
 
        if (enable) {
-               ret = pm_runtime_get_sync(sd->dev);
-               if (ret < 0) {
-                       pm_runtime_put_noidle(sd->dev);
+               ret = pm_runtime_resume_and_get(sd->dev);
+               if (ret < 0)
                        return ret;
-               }
 
                tvp5150_enable(sd);
 
@@ -1675,15 +1673,7 @@ err:
 
 static int tvp5150_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 {
-       int ret;
-
-       ret = pm_runtime_get_sync(sd->dev);
-       if (ret < 0) {
-               pm_runtime_put_noidle(sd->dev);
-               return ret;
-       }
-
-       return 0;
+       return pm_runtime_resume_and_get(sd->dev);
 }
 
 static int tvp5150_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)