From: "Lad, Prabhakar" <prabhakar.cse...@gmail.com>

this patch adds suppport to return -ENODATA for *dv_timings calls
if the current output does not support it.

Signed-off-by: Lad, Prabhakar <prabhakar.cse...@gmail.com>
---
 drivers/media/platform/davinci/vpif_display.c |   40 +++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index 81d955a..f51b5be 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -898,10 +898,21 @@ static int
 vpif_enum_dv_timings(struct file *file, void *priv,
                     struct v4l2_enum_dv_timings *timings)
 {
+       struct vpif_display_config *config = vpif_dev->platform_data;
        struct video_device *vdev = video_devdata(file);
        struct channel_obj *ch = video_get_drvdata(vdev);
+       struct vpif_display_chan_config *chan_cfg;
+       struct v4l2_output output;
        int ret;
 
+       if (config->chan_config[ch->channel_id].outputs == NULL)
+               return -ENODATA;
+
+       chan_cfg = &config->chan_config[ch->channel_id];
+       output = chan_cfg->outputs[ch->output_idx].output;
+       if (output.capabilities != V4L2_OUT_CAP_DV_TIMINGS)
+               return -ENODATA;
+
        ret = v4l2_subdev_call(ch->sd, video, enum_dv_timings, timings);
        if (ret == -ENOIOCTLCMD || ret == -ENODEV)
                return -EINVAL;
@@ -917,14 +928,29 @@ vpif_enum_dv_timings(struct file *file, void *priv,
 static int vpif_s_dv_timings(struct file *file, void *priv,
                struct v4l2_dv_timings *timings)
 {
+       struct vpif_display_config *config = vpif_dev->platform_data;
        struct video_device *vdev = video_devdata(file);
        struct channel_obj *ch = video_get_drvdata(vdev);
        struct vpif_params *vpifparams = &ch->vpifparams;
+       struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
        struct vpif_channel_config_params *std_info = &vpifparams->std_info;
        struct video_obj *vid_ch = &ch->video;
        struct v4l2_bt_timings *bt = &vid_ch->dv_timings.bt;
+       struct vpif_display_chan_config *chan_cfg;
+       struct v4l2_output output;
        int ret;
 
+       if (config->chan_config[ch->channel_id].outputs == NULL)
+               return -ENODATA;
+
+       chan_cfg = &config->chan_config[ch->channel_id];
+       output = chan_cfg->outputs[ch->output_idx].output;
+       if (output.capabilities != V4L2_OUT_CAP_DV_TIMINGS)
+               return -ENODATA;
+
+       if (vb2_is_busy(&common->buffer_queue))
+               return -EBUSY;
+
        if (timings->type != V4L2_DV_BT_656_1120) {
                vpif_dbg(2, debug, "Timing type not defined\n");
                return -EINVAL;
@@ -1006,13 +1032,27 @@ static int vpif_s_dv_timings(struct file *file, void 
*priv,
 static int vpif_g_dv_timings(struct file *file, void *priv,
                struct v4l2_dv_timings *timings)
 {
+       struct vpif_display_config *config = vpif_dev->platform_data;
        struct video_device *vdev = video_devdata(file);
        struct channel_obj *ch = video_get_drvdata(vdev);
+       struct vpif_display_chan_config *chan_cfg;
        struct video_obj *vid_ch = &ch->video;
+       struct v4l2_output output;
+
+       if (config->chan_config[ch->channel_id].outputs == NULL)
+               goto error;
+
+       chan_cfg = &config->chan_config[ch->channel_id];
+       output = chan_cfg->outputs[ch->output_idx].output;
+
+       if (output.capabilities != V4L2_OUT_CAP_DV_TIMINGS)
+               goto error;
 
        *timings = vid_ch->dv_timings;
 
        return 0;
+error:
+       return -ENODATA;
 }
 
 /*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to