diff options
Diffstat (limited to 'include/media/v4l2-subdev.h')
-rw-r--r-- | include/media/v4l2-subdev.h | 121 |
1 files changed, 97 insertions, 24 deletions
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 980a86c08fce..9102d6ca566e 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h | |||
@@ -224,6 +224,9 @@ struct v4l2_subdev_core_ops { | |||
224 | * struct v4l2_subdev_tuner_ops - Callbacks used when v4l device was opened | 224 | * struct v4l2_subdev_tuner_ops - Callbacks used when v4l device was opened |
225 | * in radio mode. | 225 | * in radio mode. |
226 | * | 226 | * |
227 | * @standby: puts the tuner in standby mode. It will be woken up | ||
228 | * automatically the next time it is used. | ||
229 | * | ||
227 | * @s_radio: callback that switches the tuner to radio mode. | 230 | * @s_radio: callback that switches the tuner to radio mode. |
228 | * drivers should explicitly call it when a tuner ops should | 231 | * drivers should explicitly call it when a tuner ops should |
229 | * operate on radio mode, before being able to handle it. | 232 | * operate on radio mode, before being able to handle it. |
@@ -268,6 +271,7 @@ struct v4l2_subdev_core_ops { | |||
268 | * } | 271 | * } |
269 | */ | 272 | */ |
270 | struct v4l2_subdev_tuner_ops { | 273 | struct v4l2_subdev_tuner_ops { |
274 | int (*standby)(struct v4l2_subdev *sd); | ||
271 | int (*s_radio)(struct v4l2_subdev *sd); | 275 | int (*s_radio)(struct v4l2_subdev *sd); |
272 | int (*s_frequency)(struct v4l2_subdev *sd, const struct v4l2_frequency *freq); | 276 | int (*s_frequency)(struct v4l2_subdev *sd, const struct v4l2_frequency *freq); |
273 | int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); | 277 | int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); |
@@ -393,10 +397,6 @@ struct v4l2_mbus_frame_desc { | |||
393 | * | 397 | * |
394 | * @g_pixelaspect: callback to return the pixelaspect ratio. | 398 | * @g_pixelaspect: callback to return the pixelaspect ratio. |
395 | * | 399 | * |
396 | * @g_parm: callback for VIDIOC_G_PARM() ioctl handler code. | ||
397 | * | ||
398 | * @s_parm: callback for VIDIOC_S_PARM() ioctl handler code. | ||
399 | * | ||
400 | * @g_frame_interval: callback for VIDIOC_SUBDEV_G_FRAME_INTERVAL() | 400 | * @g_frame_interval: callback for VIDIOC_SUBDEV_G_FRAME_INTERVAL() |
401 | * ioctl handler code. | 401 | * ioctl handler code. |
402 | * | 402 | * |
@@ -434,8 +434,6 @@ struct v4l2_subdev_video_ops { | |||
434 | int (*g_input_status)(struct v4l2_subdev *sd, u32 *status); | 434 | int (*g_input_status)(struct v4l2_subdev *sd, u32 *status); |
435 | int (*s_stream)(struct v4l2_subdev *sd, int enable); | 435 | int (*s_stream)(struct v4l2_subdev *sd, int enable); |
436 | int (*g_pixelaspect)(struct v4l2_subdev *sd, struct v4l2_fract *aspect); | 436 | int (*g_pixelaspect)(struct v4l2_subdev *sd, struct v4l2_fract *aspect); |
437 | int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); | ||
438 | int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); | ||
439 | int (*g_frame_interval)(struct v4l2_subdev *sd, | 437 | int (*g_frame_interval)(struct v4l2_subdev *sd, |
440 | struct v4l2_subdev_frame_interval *interval); | 438 | struct v4l2_subdev_frame_interval *interval); |
441 | int (*s_frame_interval)(struct v4l2_subdev *sd, | 439 | int (*s_frame_interval)(struct v4l2_subdev *sd, |
@@ -867,6 +865,13 @@ struct v4l2_subdev { | |||
867 | struct v4l2_subdev_platform_data *pdata; | 865 | struct v4l2_subdev_platform_data *pdata; |
868 | }; | 866 | }; |
869 | 867 | ||
868 | |||
869 | /** | ||
870 | * media_entity_to_v4l2_subdev - Returns a &struct v4l2_subdev from | ||
871 | * the &struct media_entity embedded in it. | ||
872 | * | ||
873 | * @ent: pointer to &struct media_entity. | ||
874 | */ | ||
870 | #define media_entity_to_v4l2_subdev(ent) \ | 875 | #define media_entity_to_v4l2_subdev(ent) \ |
871 | ({ \ | 876 | ({ \ |
872 | typeof(ent) __me_sd_ent = (ent); \ | 877 | typeof(ent) __me_sd_ent = (ent); \ |
@@ -876,14 +881,20 @@ struct v4l2_subdev { | |||
876 | NULL; \ | 881 | NULL; \ |
877 | }) | 882 | }) |
878 | 883 | ||
884 | /** | ||
885 | * vdev_to_v4l2_subdev - Returns a &struct v4l2_subdev from | ||
886 | * the &struct video_device embedded on it. | ||
887 | * | ||
888 | * @vdev: pointer to &struct video_device | ||
889 | */ | ||
879 | #define vdev_to_v4l2_subdev(vdev) \ | 890 | #define vdev_to_v4l2_subdev(vdev) \ |
880 | ((struct v4l2_subdev *)video_get_drvdata(vdev)) | 891 | ((struct v4l2_subdev *)video_get_drvdata(vdev)) |
881 | 892 | ||
882 | /** | 893 | /** |
883 | * struct v4l2_subdev_fh - Used for storing subdev information per file handle | 894 | * struct v4l2_subdev_fh - Used for storing subdev information per file handle |
884 | * | 895 | * |
885 | * @vfh: pointer to struct v4l2_fh | 896 | * @vfh: pointer to &struct v4l2_fh |
886 | * @pad: pointer to v4l2_subdev_pad_config | 897 | * @pad: pointer to &struct v4l2_subdev_pad_config |
887 | */ | 898 | */ |
888 | struct v4l2_subdev_fh { | 899 | struct v4l2_subdev_fh { |
889 | struct v4l2_fh vfh; | 900 | struct v4l2_fh vfh; |
@@ -892,23 +903,70 @@ struct v4l2_subdev_fh { | |||
892 | #endif | 903 | #endif |
893 | }; | 904 | }; |
894 | 905 | ||
906 | /** | ||
907 | * to_v4l2_subdev_fh - Returns a &struct v4l2_subdev_fh from | ||
908 | * the &struct v4l2_fh embedded on it. | ||
909 | * | ||
910 | * @fh: pointer to &struct v4l2_fh | ||
911 | */ | ||
895 | #define to_v4l2_subdev_fh(fh) \ | 912 | #define to_v4l2_subdev_fh(fh) \ |
896 | container_of(fh, struct v4l2_subdev_fh, vfh) | 913 | container_of(fh, struct v4l2_subdev_fh, vfh) |
897 | 914 | ||
898 | #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) | 915 | #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) |
899 | #define __V4L2_SUBDEV_MK_GET_TRY(rtype, fun_name, field_name) \ | 916 | |
900 | static inline struct rtype * \ | 917 | /** |
901 | fun_name(struct v4l2_subdev *sd, \ | 918 | * v4l2_subdev_get_try_format - ancillary routine to call |
902 | struct v4l2_subdev_pad_config *cfg, \ | 919 | * &struct v4l2_subdev_pad_config->try_fmt |
903 | unsigned int pad) \ | 920 | * |
904 | { \ | 921 | * @sd: pointer to &struct v4l2_subdev |
905 | BUG_ON(pad >= sd->entity.num_pads); \ | 922 | * @cfg: pointer to &struct v4l2_subdev_pad_config array. |
906 | return &cfg[pad].field_name; \ | 923 | * @pad: index of the pad in the @cfg array. |
907 | } | 924 | */ |
908 | 925 | static inline struct v4l2_mbus_framefmt | |
909 | __V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, v4l2_subdev_get_try_format, try_fmt) | 926 | *v4l2_subdev_get_try_format(struct v4l2_subdev *sd, |
910 | __V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_crop, try_crop) | 927 | struct v4l2_subdev_pad_config *cfg, |
911 | __V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_compose, try_compose) | 928 | unsigned int pad) |
929 | { | ||
930 | if (WARN_ON(pad >= sd->entity.num_pads)) | ||
931 | pad = 0; | ||
932 | return &cfg[pad].try_fmt; | ||
933 | } | ||
934 | |||
935 | /** | ||
936 | * v4l2_subdev_get_try_crop - ancillary routine to call | ||
937 | * &struct v4l2_subdev_pad_config->try_crop | ||
938 | * | ||
939 | * @sd: pointer to &struct v4l2_subdev | ||
940 | * @cfg: pointer to &struct v4l2_subdev_pad_config array. | ||
941 | * @pad: index of the pad in the @cfg array. | ||
942 | */ | ||
943 | static inline struct v4l2_rect | ||
944 | *v4l2_subdev_get_try_crop(struct v4l2_subdev *sd, | ||
945 | struct v4l2_subdev_pad_config *cfg, | ||
946 | unsigned int pad) | ||
947 | { | ||
948 | if (WARN_ON(pad >= sd->entity.num_pads)) | ||
949 | pad = 0; | ||
950 | return &cfg[pad].try_crop; | ||
951 | } | ||
952 | |||
953 | /** | ||
954 | * v4l2_subdev_get_try_crop - ancillary routine to call | ||
955 | * &struct v4l2_subdev_pad_config->try_compose | ||
956 | * | ||
957 | * @sd: pointer to &struct v4l2_subdev | ||
958 | * @cfg: pointer to &struct v4l2_subdev_pad_config array. | ||
959 | * @pad: index of the pad in the @cfg array. | ||
960 | */ | ||
961 | static inline struct v4l2_rect | ||
962 | *v4l2_subdev_get_try_compose(struct v4l2_subdev *sd, | ||
963 | struct v4l2_subdev_pad_config *cfg, | ||
964 | unsigned int pad) | ||
965 | { | ||
966 | if (WARN_ON(pad >= sd->entity.num_pads)) | ||
967 | pad = 0; | ||
968 | return &cfg[pad].try_compose; | ||
969 | } | ||
912 | #endif | 970 | #endif |
913 | 971 | ||
914 | extern const struct v4l2_file_operations v4l2_subdev_fops; | 972 | extern const struct v4l2_file_operations v4l2_subdev_fops; |
@@ -1016,9 +1074,16 @@ void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg); | |||
1016 | void v4l2_subdev_init(struct v4l2_subdev *sd, | 1074 | void v4l2_subdev_init(struct v4l2_subdev *sd, |
1017 | const struct v4l2_subdev_ops *ops); | 1075 | const struct v4l2_subdev_ops *ops); |
1018 | 1076 | ||
1019 | /* | 1077 | /** |
1020 | * Call an ops of a v4l2_subdev, doing the right checks against | 1078 | * v4l2_subdev_call - call an operation of a v4l2_subdev. |
1021 | * NULL pointers. | 1079 | * |
1080 | * @sd: pointer to the &struct v4l2_subdev | ||
1081 | * @o: name of the element at &struct v4l2_subdev_ops that contains @f. | ||
1082 | * Each element there groups a set of callbacks functions. | ||
1083 | * @f: callback function that will be called if @cond matches. | ||
1084 | * The callback functions are defined in groups, according to | ||
1085 | * each element at &struct v4l2_subdev_ops. | ||
1086 | * @args...: arguments for @f. | ||
1022 | * | 1087 | * |
1023 | * Example: err = v4l2_subdev_call(sd, video, s_std, norm); | 1088 | * Example: err = v4l2_subdev_call(sd, video, s_std, norm); |
1024 | */ | 1089 | */ |
@@ -1034,6 +1099,14 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, | |||
1034 | __result; \ | 1099 | __result; \ |
1035 | }) | 1100 | }) |
1036 | 1101 | ||
1102 | /** | ||
1103 | * v4l2_subdev_has_op - Checks if a subdev defines a certain operation. | ||
1104 | * | ||
1105 | * @sd: pointer to the &struct v4l2_subdev | ||
1106 | * @o: The group of callback functions in &struct v4l2_subdev_ops | ||
1107 | * which @f is a part of. | ||
1108 | * @f: callback function to be checked for its existence. | ||
1109 | */ | ||
1037 | #define v4l2_subdev_has_op(sd, o, f) \ | 1110 | #define v4l2_subdev_has_op(sd, o, f) \ |
1038 | ((sd)->ops->o && (sd)->ops->o->f) | 1111 | ((sd)->ops->o && (sd)->ops->o->f) |
1039 | 1112 | ||