aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/sh_mobile_ceu_camera.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/sh_mobile_ceu_camera.c')
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c91
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 0cb19689cfe..5d5781bd144 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
952static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect); 952static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect);
953 953
954static 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
960static 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
982static const struct v4l2_ctrl_ops sh_mobile_ceu_ctrl_ops = {
983 .s_ctrl = sh_mobile_ceu_s_ctrl,
984};
985
954static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int idx, 986static 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
1918static 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
1934static 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
1955static 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
1967static struct soc_camera_host_ops sh_mobile_ceu_host_ops = { 1956static 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
1988struct bus_wait { 1973struct bus_wait {