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.c81
1 files changed, 74 insertions, 7 deletions
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index 6abaa16ae136..6be9910a6e24 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -703,21 +703,21 @@ static int tvp5150_set_std(struct v4l2_subdev *sd, v4l2_std_id std)
703 /* First tests should be against specific std */ 703 /* First tests should be against specific std */
704 704
705 if (std == V4L2_STD_ALL) { 705 if (std == V4L2_STD_ALL) {
706 fmt = 0; /* Autodetect mode */ 706 fmt = VIDEO_STD_AUTO_SWITCH_BIT; /* Autodetect mode */
707 } else if (std & V4L2_STD_NTSC_443) { 707 } else if (std & V4L2_STD_NTSC_443) {
708 fmt = 0xa; 708 fmt = VIDEO_STD_NTSC_4_43_BIT;
709 } else if (std & V4L2_STD_PAL_M) { 709 } else if (std & V4L2_STD_PAL_M) {
710 fmt = 0x6; 710 fmt = VIDEO_STD_PAL_M_BIT;
711 } else if (std & (V4L2_STD_PAL_N | V4L2_STD_PAL_Nc)) { 711 } else if (std & (V4L2_STD_PAL_N | V4L2_STD_PAL_Nc)) {
712 fmt = 0x8; 712 fmt = VIDEO_STD_PAL_COMBINATION_N_BIT;
713 } else { 713 } else {
714 /* Then, test against generic ones */ 714 /* Then, test against generic ones */
715 if (std & V4L2_STD_NTSC) 715 if (std & V4L2_STD_NTSC)
716 fmt = 0x2; 716 fmt = VIDEO_STD_NTSC_MJ_BIT;
717 else if (std & V4L2_STD_PAL) 717 else if (std & V4L2_STD_PAL)
718 fmt = 0x4; 718 fmt = VIDEO_STD_PAL_BDGHIN_BIT;
719 else if (std & V4L2_STD_SECAM) 719 else if (std & V4L2_STD_SECAM)
720 fmt = 0xc; 720 fmt = VIDEO_STD_SECAM_BIT;
721 } 721 }
722 722
723 v4l2_dbg(1, debug, sd, "Set video std register to %d.\n", fmt); 723 v4l2_dbg(1, debug, sd, "Set video std register to %d.\n", fmt);
@@ -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 = {