diff options
author | Javier Martin <javier.martin@vista-silicon.com> | 2012-01-05 08:57:39 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-07 08:54:52 -0500 |
commit | ec2c4f3f93cb9ae2b09b8e942dd75ad3bdf23c9d (patch) | |
tree | f3f720b26fb9f4507faa802ccc4b2df8fb04d5ab /drivers/media/video/tvp5150.c | |
parent | e99663417f626c9bfdc8117b35670a0292b820e6 (diff) |
[media] media: tvp5150: Add mbus_fmt callbacks
These callbacks allow a host video driver
to poll video formats supported by tvp5150.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/tvp5150.c')
-rw-r--r-- | drivers/media/video/tvp5150.c | 67 |
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 | ||
782 | static 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 | |||
804 | static 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 | |||
814 | static 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 | ||
932 | static const struct v4l2_subdev_video_ops tvp5150_video_ops = { | 996 | static 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 | ||
936 | static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = { | 1003 | static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = { |