diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2011-09-05 16:07:47 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-03 16:28:35 -0400 |
commit | d34bfcd2a1e5f6be5ae81030b7a6193094632955 (patch) | |
tree | 755d31b387ce1e9be5aa838be7f1996a23fc19c2 /drivers/media/video | |
parent | ee02da64558f04fb30c2462fdeabdfafc87a9799 (diff) |
[media] sh_mobile_ceu_camera: implement the control handler
And since this is the last and only host driver that uses controls, also
remove the now obsolete control fields from soc_camera.h.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
[g.liakhovetski@gmx.de: moved code around, fixed problems]
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/sh_mobile_ceu_camera.c | 91 |
1 files changed, 38 insertions, 53 deletions
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index 0cb19689cfe8..5d5781bd1447 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c | |||
@@ -951,6 +951,38 @@ static bool sh_mobile_ceu_packing_supported(const struct soc_mbus_pixelfmt *fmt) | |||
951 | 951 | ||
952 | static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect); | 952 | static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect); |
953 | 953 | ||
954 | static struct soc_camera_device *ctrl_to_icd(struct v4l2_ctrl *ctrl) | ||
955 | { | ||
956 | return container_of(ctrl->handler, struct soc_camera_device, | ||
957 | ctrl_handler); | ||
958 | } | ||
959 | |||
960 | static int sh_mobile_ceu_s_ctrl(struct v4l2_ctrl *ctrl) | ||
961 | { | ||
962 | struct soc_camera_device *icd = ctrl_to_icd(ctrl); | ||
963 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | ||
964 | struct sh_mobile_ceu_dev *pcdev = ici->priv; | ||
965 | |||
966 | switch (ctrl->id) { | ||
967 | case V4L2_CID_SHARPNESS: | ||
968 | switch (icd->current_fmt->host_fmt->fourcc) { | ||
969 | case V4L2_PIX_FMT_NV12: | ||
970 | case V4L2_PIX_FMT_NV21: | ||
971 | case V4L2_PIX_FMT_NV16: | ||
972 | case V4L2_PIX_FMT_NV61: | ||
973 | ceu_write(pcdev, CLFCR, !ctrl->val); | ||
974 | return 0; | ||
975 | } | ||
976 | break; | ||
977 | } | ||
978 | |||
979 | return -EINVAL; | ||
980 | } | ||
981 | |||
982 | static const struct v4l2_ctrl_ops sh_mobile_ceu_ctrl_ops = { | ||
983 | .s_ctrl = sh_mobile_ceu_s_ctrl, | ||
984 | }; | ||
985 | |||
954 | static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int idx, | 986 | static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int idx, |
955 | struct soc_camera_format_xlate *xlate) | 987 | struct soc_camera_format_xlate *xlate) |
956 | { | 988 | { |
@@ -987,6 +1019,12 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int | |||
987 | struct v4l2_rect rect; | 1019 | struct v4l2_rect rect; |
988 | int shift = 0; | 1020 | int shift = 0; |
989 | 1021 | ||
1022 | /* Add our control */ | ||
1023 | v4l2_ctrl_new_std(&icd->ctrl_handler, &sh_mobile_ceu_ctrl_ops, | ||
1024 | V4L2_CID_SHARPNESS, 0, 1, 1, 0); | ||
1025 | if (icd->ctrl_handler.error) | ||
1026 | return icd->ctrl_handler.error; | ||
1027 | |||
990 | /* FIXME: subwindow is lost between close / open */ | 1028 | /* FIXME: subwindow is lost between close / open */ |
991 | 1029 | ||
992 | /* Cache current client geometry */ | 1030 | /* Cache current client geometry */ |
@@ -1915,55 +1953,6 @@ static int sh_mobile_ceu_init_videobuf(struct vb2_queue *q, | |||
1915 | return vb2_queue_init(q); | 1953 | return vb2_queue_init(q); |
1916 | } | 1954 | } |
1917 | 1955 | ||
1918 | static int sh_mobile_ceu_get_ctrl(struct soc_camera_device *icd, | ||
1919 | struct v4l2_control *ctrl) | ||
1920 | { | ||
1921 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | ||
1922 | struct sh_mobile_ceu_dev *pcdev = ici->priv; | ||
1923 | u32 val; | ||
1924 | |||
1925 | switch (ctrl->id) { | ||
1926 | case V4L2_CID_SHARPNESS: | ||
1927 | val = ceu_read(pcdev, CLFCR); | ||
1928 | ctrl->value = val ^ 1; | ||
1929 | return 0; | ||
1930 | } | ||
1931 | return -ENOIOCTLCMD; | ||
1932 | } | ||
1933 | |||
1934 | static int sh_mobile_ceu_set_ctrl(struct soc_camera_device *icd, | ||
1935 | struct v4l2_control *ctrl) | ||
1936 | { | ||
1937 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | ||
1938 | struct sh_mobile_ceu_dev *pcdev = ici->priv; | ||
1939 | |||
1940 | switch (ctrl->id) { | ||
1941 | case V4L2_CID_SHARPNESS: | ||
1942 | switch (icd->current_fmt->host_fmt->fourcc) { | ||
1943 | case V4L2_PIX_FMT_NV12: | ||
1944 | case V4L2_PIX_FMT_NV21: | ||
1945 | case V4L2_PIX_FMT_NV16: | ||
1946 | case V4L2_PIX_FMT_NV61: | ||
1947 | ceu_write(pcdev, CLFCR, !ctrl->value); | ||
1948 | return 0; | ||
1949 | } | ||
1950 | return -EINVAL; | ||
1951 | } | ||
1952 | return -ENOIOCTLCMD; | ||
1953 | } | ||
1954 | |||
1955 | static const struct v4l2_queryctrl sh_mobile_ceu_controls[] = { | ||
1956 | { | ||
1957 | .id = V4L2_CID_SHARPNESS, | ||
1958 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
1959 | .name = "Low-pass filter", | ||
1960 | .minimum = 0, | ||
1961 | .maximum = 1, | ||
1962 | .step = 1, | ||
1963 | .default_value = 0, | ||
1964 | }, | ||
1965 | }; | ||
1966 | |||
1967 | static struct soc_camera_host_ops sh_mobile_ceu_host_ops = { | 1956 | static struct soc_camera_host_ops sh_mobile_ceu_host_ops = { |
1968 | .owner = THIS_MODULE, | 1957 | .owner = THIS_MODULE, |
1969 | .add = sh_mobile_ceu_add_device, | 1958 | .add = sh_mobile_ceu_add_device, |
@@ -1975,14 +1964,10 @@ static struct soc_camera_host_ops sh_mobile_ceu_host_ops = { | |||
1975 | .set_livecrop = sh_mobile_ceu_set_livecrop, | 1964 | .set_livecrop = sh_mobile_ceu_set_livecrop, |
1976 | .set_fmt = sh_mobile_ceu_set_fmt, | 1965 | .set_fmt = sh_mobile_ceu_set_fmt, |
1977 | .try_fmt = sh_mobile_ceu_try_fmt, | 1966 | .try_fmt = sh_mobile_ceu_try_fmt, |
1978 | .set_ctrl = sh_mobile_ceu_set_ctrl, | ||
1979 | .get_ctrl = sh_mobile_ceu_get_ctrl, | ||
1980 | .poll = sh_mobile_ceu_poll, | 1967 | .poll = sh_mobile_ceu_poll, |
1981 | .querycap = sh_mobile_ceu_querycap, | 1968 | .querycap = sh_mobile_ceu_querycap, |
1982 | .set_bus_param = sh_mobile_ceu_set_bus_param, | 1969 | .set_bus_param = sh_mobile_ceu_set_bus_param, |
1983 | .init_videobuf2 = sh_mobile_ceu_init_videobuf, | 1970 | .init_videobuf2 = sh_mobile_ceu_init_videobuf, |
1984 | .controls = sh_mobile_ceu_controls, | ||
1985 | .num_controls = ARRAY_SIZE(sh_mobile_ceu_controls), | ||
1986 | }; | 1971 | }; |
1987 | 1972 | ||
1988 | struct bus_wait { | 1973 | struct bus_wait { |