diff options
author | Sandor Yu <R01008@freescale.com> | 2014-04-21 02:51:15 -0400 |
---|---|---|
committer | Sandor Yu <R01008@freescale.com> | 2014-04-24 04:45:56 -0400 |
commit | af130d8729c548477fd5ca42e5a55d1a1fb3c55c (patch) | |
tree | 17df66c7c6dd6670c4a2eb9d9c94c06c43c22487 /drivers/media | |
parent | d45ff51590bcd04b674fbfda4656fadb71e2f8dc (diff) |
ENGR00309489-2 v4l2 capture: Change code that violate v4l2 api
-Remove parameter crop_current and replace by cam->crop_current.
-Remove parameter win_current and update pxp buffer initialize code.
-Move csi config code from s_fmt function to s_param.
-Correct crop_bound setting for vadc.
Signed-off-by: Sandor Yu <R01008@freescale.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/platform/mxc/capture/csi_v4l2_capture.c | 140 |
1 files changed, 73 insertions, 67 deletions
diff --git a/drivers/media/platform/mxc/capture/csi_v4l2_capture.c b/drivers/media/platform/mxc/capture/csi_v4l2_capture.c index f56faef7734b..6072906c8e1c 100644 --- a/drivers/media/platform/mxc/capture/csi_v4l2_capture.c +++ b/drivers/media/platform/mxc/capture/csi_v4l2_capture.c | |||
@@ -48,8 +48,6 @@ static int req_buf_number; | |||
48 | static int csi_v4l2_master_attach(struct v4l2_int_device *slave); | 48 | static int csi_v4l2_master_attach(struct v4l2_int_device *slave); |
49 | static void csi_v4l2_master_detach(struct v4l2_int_device *slave); | 49 | static void csi_v4l2_master_detach(struct v4l2_int_device *slave); |
50 | static u8 camera_power(cam_data *cam, bool cameraOn); | 50 | static u8 camera_power(cam_data *cam, bool cameraOn); |
51 | struct v4l2_crop crop_current; | ||
52 | struct v4l2_window win_current; | ||
53 | static struct v4l2_format cam_input_fmt; | 51 | static struct v4l2_format cam_input_fmt; |
54 | 52 | ||
55 | /*! Information about this driver. */ | 53 | /*! Information about this driver. */ |
@@ -138,7 +136,7 @@ static video_fmt_t video_fmts[] = { | |||
138 | .raw_height = 525, /* SENS_FRM_HEIGHT */ | 136 | .raw_height = 525, /* SENS_FRM_HEIGHT */ |
139 | .active_width = 720, /* ACT_FRM_WIDTH */ | 137 | .active_width = 720, /* ACT_FRM_WIDTH */ |
140 | .active_height = 480, /* ACT_FRM_HEIGHT */ | 138 | .active_height = 480, /* ACT_FRM_HEIGHT */ |
141 | .active_top = 13, | 139 | .active_top = 0, |
142 | .active_left = 0, | 140 | .active_left = 0, |
143 | }, | 141 | }, |
144 | { /*! (B, G, H, I, N) PAL */ | 142 | { /*! (B, G, H, I, N) PAL */ |
@@ -311,8 +309,8 @@ static int pxp_process_update(cam_data *cam) | |||
311 | pxp_conf->s0_param.pixel_fmt = v4l2_fmt_2_pxp_fmt(cam_input_fmt.fmt.pix.pixelformat); | 309 | pxp_conf->s0_param.pixel_fmt = v4l2_fmt_2_pxp_fmt(cam_input_fmt.fmt.pix.pixelformat); |
312 | pxp_conf->s0_param.color_key = -1; | 310 | pxp_conf->s0_param.color_key = -1; |
313 | pxp_conf->s0_param.color_key_enable = false; | 311 | pxp_conf->s0_param.color_key_enable = false; |
314 | pxp_conf->s0_param.width = cam->v2f.fmt.pix.width; | 312 | pxp_conf->s0_param.width = cam_input_fmt.fmt.pix.width; |
315 | pxp_conf->s0_param.height = cam->v2f.fmt.pix.height; | 313 | pxp_conf->s0_param.height = cam_input_fmt.fmt.pix.height; |
316 | 314 | ||
317 | pxp_conf->ol_param[0].combine_enable = false; | 315 | pxp_conf->ol_param[0].combine_enable = false; |
318 | 316 | ||
@@ -321,28 +319,24 @@ static int pxp_process_update(cam_data *cam) | |||
321 | proc_data->srect.width = pxp_conf->s0_param.width; | 319 | proc_data->srect.width = pxp_conf->s0_param.width; |
322 | proc_data->srect.height = pxp_conf->s0_param.height; | 320 | proc_data->srect.height = pxp_conf->s0_param.height; |
323 | 321 | ||
324 | if (crop_current.c.top != 0) | 322 | if (cam->crop_current.top != 0) |
325 | proc_data->srect.top = crop_current.c.top; | 323 | proc_data->srect.top = cam->crop_current.top; |
326 | if (crop_current.c.left != 0) | 324 | if (cam->crop_current.left != 0) |
327 | proc_data->srect.left = crop_current.c.left; | 325 | proc_data->srect.left = cam->crop_current.left; |
328 | if (crop_current.c.width != 0) | 326 | if (cam->crop_current.width != 0) |
329 | proc_data->srect.width = crop_current.c.width; | 327 | proc_data->srect.width = cam->crop_current.width; |
330 | if (crop_current.c.height != 0) | 328 | if (cam->crop_current.height != 0) |
331 | proc_data->srect.height = crop_current.c.height; | 329 | proc_data->srect.height = cam->crop_current.height; |
332 | 330 | ||
333 | proc_data->drect.left = 0; | 331 | proc_data->drect.left = 0; |
334 | proc_data->drect.top = 0; | 332 | proc_data->drect.top = 0; |
335 | proc_data->drect.width = proc_data->srect.width; | 333 | proc_data->drect.width = cam->v2f.fmt.pix.width; |
336 | proc_data->drect.height = proc_data->srect.height; | 334 | proc_data->drect.height = cam->v2f.fmt.pix.height; |
337 | 335 | ||
338 | if (win_current.w.left != 0) | 336 | /* Out buffer */ |
339 | proc_data->drect.left = win_current.w.left; | 337 | pxp_conf->out_param.pixel_fmt = v4l2_fmt_2_pxp_fmt(cam->v2f.fmt.pix.pixelformat); |
340 | if (win_current.w.top != 0) | 338 | pxp_conf->out_param.width = proc_data->drect.width; |
341 | proc_data->drect.top = win_current.w.top; | 339 | pxp_conf->out_param.height = proc_data->drect.height; |
342 | if (win_current.w.width != 0) | ||
343 | proc_data->drect.width = win_current.w.width; | ||
344 | if (win_current.w.height != 0) | ||
345 | proc_data->drect.height = win_current.w.height; | ||
346 | 340 | ||
347 | pr_debug("srect l: %d, t: %d, w: %d, h: %d; " | 341 | pr_debug("srect l: %d, t: %d, w: %d, h: %d; " |
348 | "drect l: %d, t: %d, w: %d, h: %d\n", | 342 | "drect l: %d, t: %d, w: %d, h: %d\n", |
@@ -351,11 +345,6 @@ static int pxp_process_update(cam_data *cam) | |||
351 | proc_data->drect.left, proc_data->drect.top, | 345 | proc_data->drect.left, proc_data->drect.top, |
352 | proc_data->drect.width, proc_data->drect.height); | 346 | proc_data->drect.width, proc_data->drect.height); |
353 | 347 | ||
354 | /* Out buffer */ | ||
355 | pxp_conf->out_param.pixel_fmt = v4l2_fmt_2_pxp_fmt(cam->v2f.fmt.pix.pixelformat); | ||
356 | pxp_conf->out_param.width = proc_data->drect.width; | ||
357 | pxp_conf->out_param.height = proc_data->drect.height; | ||
358 | |||
359 | if (cam->rotation % 180) | 348 | if (cam->rotation % 180) |
360 | pxp_conf->out_param.stride = pxp_conf->out_param.height; | 349 | pxp_conf->out_param.stride = pxp_conf->out_param.height; |
361 | else | 350 | else |
@@ -911,16 +900,6 @@ static int csi_v4l2_s_fmt(cam_data *cam, struct v4l2_format *f) | |||
911 | return -EINVAL; | 900 | return -EINVAL; |
912 | } | 901 | } |
913 | 902 | ||
914 | /* | ||
915 | * Force the capture window resolution to be crop bounds | ||
916 | * for Vadc input mode. | ||
917 | */ | ||
918 | if (strcmp(csi_capture_inputs[cam->current_input].name, | ||
919 | "Vadc") == 0) { | ||
920 | f->fmt.pix.width = cam->crop_current.width; | ||
921 | f->fmt.pix.height = cam->crop_current.height; | ||
922 | } | ||
923 | |||
924 | /* Handle case where size requested is larger than current | 903 | /* Handle case where size requested is larger than current |
925 | * camera setting. */ | 904 | * camera setting. */ |
926 | if ((f->fmt.pix.width > cam->crop_bounds.width) | 905 | if ((f->fmt.pix.width > cam->crop_bounds.width) |
@@ -957,32 +936,25 @@ static int csi_v4l2_s_fmt(cam_data *cam, struct v4l2_format *f) | |||
957 | "resize to %d.\n", *height); | 936 | "resize to %d.\n", *height); |
958 | } | 937 | } |
959 | 938 | ||
960 | cam_input_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 939 | switch (f->fmt.pix.pixelformat) { |
961 | vidioc_int_g_fmt_cap(cam->sensor, &cam_input_fmt); | 940 | case V4L2_PIX_FMT_RGB565: |
962 | 941 | size = f->fmt.pix.width * f->fmt.pix.height * 2; | |
963 | switch (cam_input_fmt.fmt.pix.pixelformat) { | 942 | bytesperline = f->fmt.pix.width * 2; |
943 | break; | ||
964 | case V4L2_PIX_FMT_YUV444: | 944 | case V4L2_PIX_FMT_YUV444: |
965 | size = f->fmt.pix.width * f->fmt.pix.height * 4; | 945 | size = f->fmt.pix.width * f->fmt.pix.height * 4; |
966 | csi_set_32bit_imagpara(f->fmt.pix.width, | ||
967 | f->fmt.pix.height); | ||
968 | bytesperline = f->fmt.pix.width * 4; | 946 | bytesperline = f->fmt.pix.width * 4; |
969 | break; | 947 | break; |
970 | case V4L2_PIX_FMT_UYVY: | 948 | case V4L2_PIX_FMT_UYVY: |
971 | size = f->fmt.pix.width * f->fmt.pix.height * 2; | 949 | size = f->fmt.pix.width * f->fmt.pix.height * 2; |
972 | csi_set_16bit_imagpara(f->fmt.pix.width, | ||
973 | f->fmt.pix.height); | ||
974 | bytesperline = f->fmt.pix.width * 2; | 950 | bytesperline = f->fmt.pix.width * 2; |
975 | break; | 951 | break; |
976 | case V4L2_PIX_FMT_YUYV: | 952 | case V4L2_PIX_FMT_YUYV: |
977 | size = f->fmt.pix.width * f->fmt.pix.height * 2; | 953 | size = f->fmt.pix.width * f->fmt.pix.height * 2; |
978 | csi_set_16bit_imagpara(f->fmt.pix.width, | ||
979 | f->fmt.pix.height); | ||
980 | bytesperline = f->fmt.pix.width * 2; | 954 | bytesperline = f->fmt.pix.width * 2; |
981 | break; | 955 | break; |
982 | case V4L2_PIX_FMT_YUV420: | 956 | case V4L2_PIX_FMT_YUV420: |
983 | size = f->fmt.pix.width * f->fmt.pix.height * 3 / 2; | 957 | size = f->fmt.pix.width * f->fmt.pix.height * 3 / 2; |
984 | csi_set_12bit_imagpara(f->fmt.pix.width, | ||
985 | f->fmt.pix.height); | ||
986 | bytesperline = f->fmt.pix.width; | 958 | bytesperline = f->fmt.pix.width; |
987 | break; | 959 | break; |
988 | case V4L2_PIX_FMT_YUV422P: | 960 | case V4L2_PIX_FMT_YUV422P: |
@@ -1006,6 +978,9 @@ static int csi_v4l2_s_fmt(cam_data *cam, struct v4l2_format *f) | |||
1006 | else | 978 | else |
1007 | size = f->fmt.pix.sizeimage; | 979 | size = f->fmt.pix.sizeimage; |
1008 | 980 | ||
981 | if (cam_input_fmt.fmt.pix.sizeimage > f->fmt.pix.sizeimage) | ||
982 | f->fmt.pix.sizeimage = cam_input_fmt.fmt.pix.sizeimage; | ||
983 | |||
1009 | cam->v2f.fmt.pix = f->fmt.pix; | 984 | cam->v2f.fmt.pix = f->fmt.pix; |
1010 | 985 | ||
1011 | if (cam->v2f.fmt.pix.priv != 0) { | 986 | if (cam->v2f.fmt.pix.priv != 0) { |
@@ -1020,10 +995,6 @@ static int csi_v4l2_s_fmt(cam_data *cam, struct v4l2_format *f) | |||
1020 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 995 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
1021 | pr_debug(" type=V4L2_BUF_TYPE_VIDEO_OVERLAY\n"); | 996 | pr_debug(" type=V4L2_BUF_TYPE_VIDEO_OVERLAY\n"); |
1022 | cam->win = f->fmt.win; | 997 | cam->win = f->fmt.win; |
1023 | win_current = f->fmt.win; | ||
1024 | size = win_current.w.width * win_current.w.height * 2; | ||
1025 | if (cam->v2f.fmt.pix.sizeimage < size) | ||
1026 | cam->v2f.fmt.pix.sizeimage = size; | ||
1027 | 998 | ||
1028 | break; | 999 | break; |
1029 | default: | 1000 | default: |
@@ -1048,9 +1019,10 @@ static int csi_v4l2_s_fmt(cam_data *cam, struct v4l2_format *f) | |||
1048 | static int csi_v4l2_s_param(cam_data *cam, struct v4l2_streamparm *parm) | 1019 | static int csi_v4l2_s_param(cam_data *cam, struct v4l2_streamparm *parm) |
1049 | { | 1020 | { |
1050 | struct v4l2_ifparm ifparm; | 1021 | struct v4l2_ifparm ifparm; |
1051 | struct v4l2_format cam_fmt; | 1022 | struct v4l2_format *f; |
1052 | struct v4l2_streamparm currentparm; | 1023 | struct v4l2_streamparm currentparm; |
1053 | int err = 0; | 1024 | int err = 0; |
1025 | int size = 0; | ||
1054 | 1026 | ||
1055 | pr_debug("In %s\n", __func__); | 1027 | pr_debug("In %s\n", __func__); |
1056 | 1028 | ||
@@ -1090,14 +1062,49 @@ static int csi_v4l2_s_param(cam_data *cam, struct v4l2_streamparm *parm) | |||
1090 | } | 1062 | } |
1091 | 1063 | ||
1092 | vidioc_int_g_ifparm(cam->sensor, &ifparm); | 1064 | vidioc_int_g_ifparm(cam->sensor, &ifparm); |
1093 | cam_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1065 | cam_input_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1094 | vidioc_int_g_fmt_cap(cam->sensor, &cam_fmt); | 1066 | vidioc_int_g_fmt_cap(cam->sensor, &cam_input_fmt); |
1067 | |||
1095 | pr_debug(" g_fmt_cap returns widthxheight of input as %d x %d\n", | 1068 | pr_debug(" g_fmt_cap returns widthxheight of input as %d x %d\n", |
1096 | cam_fmt.fmt.pix.width, cam_fmt.fmt.pix.height); | 1069 | cam_input_fmt.fmt.pix.width, cam_input_fmt.fmt.pix.height); |
1070 | |||
1071 | f = &cam_input_fmt; | ||
1072 | switch (f->fmt.pix.pixelformat) { | ||
1073 | case V4L2_PIX_FMT_YUV444: | ||
1074 | size = f->fmt.pix.width * f->fmt.pix.height * 4; | ||
1075 | csi_set_32bit_imagpara(f->fmt.pix.width, | ||
1076 | f->fmt.pix.height); | ||
1077 | break; | ||
1078 | case V4L2_PIX_FMT_UYVY: | ||
1079 | size = f->fmt.pix.width * f->fmt.pix.height * 2; | ||
1080 | csi_set_16bit_imagpara(f->fmt.pix.width, | ||
1081 | f->fmt.pix.height); | ||
1082 | break; | ||
1083 | case V4L2_PIX_FMT_YUYV: | ||
1084 | size = f->fmt.pix.width * f->fmt.pix.height * 2; | ||
1085 | csi_set_16bit_imagpara(f->fmt.pix.width, | ||
1086 | f->fmt.pix.height); | ||
1087 | break; | ||
1088 | case V4L2_PIX_FMT_YUV420: | ||
1089 | size = f->fmt.pix.width * f->fmt.pix.height * 3 / 2; | ||
1090 | csi_set_12bit_imagpara(f->fmt.pix.width, | ||
1091 | f->fmt.pix.height); | ||
1092 | break; | ||
1093 | case V4L2_PIX_FMT_YUV422P: | ||
1094 | case V4L2_PIX_FMT_RGB24: | ||
1095 | case V4L2_PIX_FMT_BGR24: | ||
1096 | case V4L2_PIX_FMT_BGR32: | ||
1097 | case V4L2_PIX_FMT_RGB32: | ||
1098 | case V4L2_PIX_FMT_NV12: | ||
1099 | default: | ||
1100 | pr_debug(" case not supported\n"); | ||
1101 | return -EINVAL; | ||
1102 | } | ||
1103 | f->fmt.pix.sizeimage = size; | ||
1097 | 1104 | ||
1098 | cam->crop_bounds.top = cam->crop_bounds.left = 0; | 1105 | cam->crop_bounds.top = cam->crop_bounds.left = 0; |
1099 | cam->crop_bounds.width = cam_fmt.fmt.pix.width; | 1106 | cam->crop_bounds.width = cam_input_fmt.fmt.pix.width; |
1100 | cam->crop_bounds.height = cam_fmt.fmt.pix.height; | 1107 | cam->crop_bounds.height = cam_input_fmt.fmt.pix.height; |
1101 | cam->crop_current.width = cam->crop_bounds.width; | 1108 | cam->crop_current.width = cam->crop_bounds.width; |
1102 | cam->crop_current.height = cam->crop_bounds.height; | 1109 | cam->crop_current.height = cam->crop_bounds.height; |
1103 | 1110 | ||
@@ -1177,8 +1184,8 @@ static int csi_v4l_s_std(cam_data *cam, v4l2_std_id e) | |||
1177 | csi_deinterlace_enable(true); | 1184 | csi_deinterlace_enable(true); |
1178 | 1185 | ||
1179 | /* crop will overwrite */ | 1186 | /* crop will overwrite */ |
1180 | cam->crop_bounds.width = video_fmts[video_index].raw_width; | 1187 | cam->crop_bounds.width = video_fmts[video_index].active_width; |
1181 | cam->crop_bounds.height = video_fmts[video_index].raw_height; | 1188 | cam->crop_bounds.height = video_fmts[video_index].active_height; |
1182 | cam->crop_current.width = video_fmts[video_index].active_width; | 1189 | cam->crop_current.width = video_fmts[video_index].active_width; |
1183 | cam->crop_current.height = video_fmts[video_index].active_height; | 1190 | cam->crop_current.height = video_fmts[video_index].active_height; |
1184 | cam->crop_current.top = video_fmts[video_index].active_top; | 1191 | cam->crop_current.top = video_fmts[video_index].active_top; |
@@ -1669,7 +1676,7 @@ static long csi_v4l_do_ioctl(struct file *file, | |||
1669 | crop->c.width -= crop->c.width % 8; | 1676 | crop->c.width -= crop->c.width % 8; |
1670 | crop->c.height -= crop->c.height % 8; | 1677 | crop->c.height -= crop->c.height % 8; |
1671 | 1678 | ||
1672 | crop_current.c = crop->c; | 1679 | cam->crop_current = crop->c; |
1673 | 1680 | ||
1674 | break; | 1681 | break; |
1675 | } | 1682 | } |
@@ -1682,7 +1689,7 @@ static long csi_v4l_do_ioctl(struct file *file, | |||
1682 | retval = -EINVAL; | 1689 | retval = -EINVAL; |
1683 | break; | 1690 | break; |
1684 | } | 1691 | } |
1685 | crop->c = crop_current.c; | 1692 | crop->c = cam->crop_current; |
1686 | 1693 | ||
1687 | break; | 1694 | break; |
1688 | 1695 | ||
@@ -2142,8 +2149,7 @@ static int csi_v4l2_probe(struct platform_device *pdev) | |||
2142 | err = -ENOMEM; | 2149 | err = -ENOMEM; |
2143 | goto out; | 2150 | goto out; |
2144 | } | 2151 | } |
2145 | memset(&crop_current, 0, sizeof(crop_current)); | 2152 | memset(&cam_input_fmt, 0, sizeof(cam_input_fmt)); |
2146 | memset(&win_current, 0, sizeof(win_current)); | ||
2147 | init_camera_struct(g_cam); | 2153 | init_camera_struct(g_cam); |
2148 | platform_set_drvdata(pdev, (void *)g_cam); | 2154 | platform_set_drvdata(pdev, (void *)g_cam); |
2149 | 2155 | ||