aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tvp5150.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/tvp5150.c')
-rw-r--r--drivers/media/video/tvp5150.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index fc91a1ec54a0..6be9910a6e24 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -779,6 +779,70 @@ static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
779 return -EINVAL; 779 return -EINVAL;
780} 780}
781 781
782static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd)
783{
784 int val = tvp5150_read(sd, TVP5150_STATUS_REG_5);
785
786 switch (val & 0x0F) {
787 case 0x01:
788 return V4L2_STD_NTSC;
789 case 0x03:
790 return V4L2_STD_PAL;
791 case 0x05:
792 return V4L2_STD_PAL_M;
793 case 0x07:
794 return V4L2_STD_PAL_N | V4L2_STD_PAL_Nc;
795 case 0x09:
796 return V4L2_STD_NTSC_443;
797 case 0xb:
798 return V4L2_STD_SECAM;
799 default:
800 return V4L2_STD_UNKNOWN;
801 }
802}
803
804static int tvp5150_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index,
805 enum v4l2_mbus_pixelcode *code)
806{
807 if (index)
808 return -EINVAL;
809
810 *code = V4L2_MBUS_FMT_YUYV8_2X8;
811 return 0;
812}
813
814static int tvp5150_mbus_fmt(struct v4l2_subdev *sd,
815 struct v4l2_mbus_framefmt *f)
816{
817 struct tvp5150 *decoder = to_tvp5150(sd);
818 v4l2_std_id std;
819
820 if (f == NULL)
821 return -EINVAL;
822
823 tvp5150_reset(sd, 0);
824
825 /* Calculate height and width based on current standard */
826 if (decoder->norm == V4L2_STD_ALL)
827 std = tvp5150_read_std(sd);
828 else
829 std = decoder->norm;
830
831 f->width = 720;
832 if (std & V4L2_STD_525_60)
833 f->height = 480;
834 else
835 f->height = 576;
836
837 f->code = V4L2_MBUS_FMT_YUYV8_2X8;
838 f->field = V4L2_FIELD_SEQ_TB;
839 f->colorspace = V4L2_COLORSPACE_SMPTE170M;
840
841 v4l2_dbg(1, debug, sd, "width = %d, height = %d\n", f->width,
842 f->height);
843 return 0;
844}
845
782/**************************************************************************** 846/****************************************************************************
783 I2C Command 847 I2C Command
784 ****************************************************************************/ 848 ****************************************************************************/
@@ -931,6 +995,9 @@ static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = {
931 995
932static const struct v4l2_subdev_video_ops tvp5150_video_ops = { 996static const struct v4l2_subdev_video_ops tvp5150_video_ops = {
933 .s_routing = tvp5150_s_routing, 997 .s_routing = tvp5150_s_routing,
998 .enum_mbus_fmt = tvp5150_enum_mbus_fmt,
999 .s_mbus_fmt = tvp5150_mbus_fmt,
1000 .try_mbus_fmt = tvp5150_mbus_fmt,
934}; 1001};
935 1002
936static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = { 1003static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {