aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2010-03-23 10:23:31 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:57:59 -0400
commite622681d124688d3caf1bf62cce96465a9078a11 (patch)
tree3be3e8901fd47d09aad27938b6f93ce09fdd5290
parent730947bc141b7e8feb091dcf3ee8e6a7b9379512 (diff)
V4L/DVB: sh_mobile_ceu_camera.c: preserve output window on VIDIOC_S_CROP
Current version of sh_mobile_ceu_camera.c interprets the V4L2 API specification of the VIDIOC_S_CROP ioctl as "change input (for capture devices) area, preserve scaling factors, therefore change output window," whereas a more intuitive interpretation of the API is "change input area, preserve output window." Switch sh_mobile_ceu_camera.c to use this interpretation. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c601
1 files changed, 309 insertions, 292 deletions
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index 9a46f0a0c1bb..4ac3b482fbb4 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -115,9 +115,20 @@ struct sh_mobile_ceu_dev {
115}; 115};
116 116
117struct sh_mobile_ceu_cam { 117struct sh_mobile_ceu_cam {
118 struct v4l2_rect ceu_rect; 118 /* CEU offsets within scaled by the CEU camera output */
119 unsigned int cam_width; 119 unsigned int ceu_left;
120 unsigned int cam_height; 120 unsigned int ceu_top;
121 /* Client output, as seen by the CEU */
122 unsigned int width;
123 unsigned int height;
124 /*
125 * User window from S_CROP / G_CROP, produced by client cropping and
126 * scaling, CEU scaling and CEU cropping, mapped back onto the client
127 * input window
128 */
129 struct v4l2_rect subrect;
130 /* Camera cropping rectangle */
131 struct v4l2_rect rect;
121 const struct soc_mbus_pixelfmt *extra_fmt; 132 const struct soc_mbus_pixelfmt *extra_fmt;
122 enum v4l2_mbus_pixelcode code; 133 enum v4l2_mbus_pixelcode code;
123}; 134};
@@ -565,38 +576,36 @@ static u16 calc_scale(unsigned int src, unsigned int *dst)
565} 576}
566 577
567/* rect is guaranteed to not exceed the scaled camera rectangle */ 578/* rect is guaranteed to not exceed the scaled camera rectangle */
568static void sh_mobile_ceu_set_rect(struct soc_camera_device *icd, 579static void sh_mobile_ceu_set_rect(struct soc_camera_device *icd)
569 unsigned int out_width,
570 unsigned int out_height)
571{ 580{
572 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 581 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
573 struct sh_mobile_ceu_cam *cam = icd->host_priv; 582 struct sh_mobile_ceu_cam *cam = icd->host_priv;
574 struct v4l2_rect *rect = &cam->ceu_rect;
575 struct sh_mobile_ceu_dev *pcdev = ici->priv; 583 struct sh_mobile_ceu_dev *pcdev = ici->priv;
576 unsigned int height, width, cdwdr_width, in_width, in_height; 584 unsigned int height, width, cdwdr_width, in_width, in_height;
577 unsigned int left_offset, top_offset; 585 unsigned int left_offset, top_offset;
578 u32 camor; 586 u32 camor;
579 587
580 dev_dbg(icd->dev.parent, "Crop %ux%u@%u:%u\n", 588 dev_geo(icd->dev.parent, "Crop %ux%u@%u:%u\n",
581 rect->width, rect->height, rect->left, rect->top); 589 icd->user_width, icd->user_height, cam->ceu_left, cam->ceu_top);
582 590
583 left_offset = rect->left; 591 left_offset = cam->ceu_left;
584 top_offset = rect->top; 592 top_offset = cam->ceu_top;
585 593
594 /* CEU cropping (CFSZR) is applied _after_ the scaling filter (CFLCR) */
586 if (pcdev->image_mode) { 595 if (pcdev->image_mode) {
587 in_width = rect->width; 596 in_width = cam->width;
588 if (!pcdev->is_16bit) { 597 if (!pcdev->is_16bit) {
589 in_width *= 2; 598 in_width *= 2;
590 left_offset *= 2; 599 left_offset *= 2;
591 } 600 }
592 width = out_width; 601 width = icd->user_width;
593 cdwdr_width = out_width; 602 cdwdr_width = icd->user_width;
594 } else { 603 } else {
595 int bytes_per_line = soc_mbus_bytes_per_line(out_width, 604 int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
596 icd->current_fmt->host_fmt); 605 icd->current_fmt->host_fmt);
597 unsigned int w_factor; 606 unsigned int w_factor;
598 607
599 width = out_width; 608 width = icd->user_width;
600 609
601 switch (icd->current_fmt->host_fmt->packing) { 610 switch (icd->current_fmt->host_fmt->packing) {
602 case SOC_MBUS_PACKING_2X8_PADHI: 611 case SOC_MBUS_PACKING_2X8_PADHI:
@@ -606,17 +615,17 @@ static void sh_mobile_ceu_set_rect(struct soc_camera_device *icd,
606 w_factor = 1; 615 w_factor = 1;
607 } 616 }
608 617
609 in_width = rect->width * w_factor; 618 in_width = cam->width * w_factor;
610 left_offset = left_offset * w_factor; 619 left_offset = left_offset * w_factor;
611 620
612 if (bytes_per_line < 0) 621 if (bytes_per_line < 0)
613 cdwdr_width = out_width; 622 cdwdr_width = icd->user_width;
614 else 623 else
615 cdwdr_width = bytes_per_line; 624 cdwdr_width = bytes_per_line;
616 } 625 }
617 626
618 height = out_height; 627 height = icd->user_height;
619 in_height = rect->height; 628 in_height = cam->height;
620 if (V4L2_FIELD_NONE != pcdev->field) { 629 if (V4L2_FIELD_NONE != pcdev->field) {
621 height /= 2; 630 height /= 2;
622 in_height /= 2; 631 in_height /= 2;
@@ -775,9 +784,10 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd,
775 } 784 }
776 ceu_write(pcdev, CAIFR, value); 785 ceu_write(pcdev, CAIFR, value);
777 786
778 sh_mobile_ceu_set_rect(icd, icd->user_width, icd->user_height); 787 sh_mobile_ceu_set_rect(icd);
779 mdelay(1); 788 mdelay(1);
780 789
790 dev_geo(icd->dev.parent, "CFLCR 0x%x\n", pcdev->cflcr);
781 ceu_write(pcdev, CFLCR, pcdev->cflcr); 791 ceu_write(pcdev, CFLCR, pcdev->cflcr);
782 792
783 /* 793 /*
@@ -866,6 +876,8 @@ static bool sh_mobile_ceu_packing_supported(const struct soc_mbus_pixelfmt *fmt)
866 fmt->packing == SOC_MBUS_PACKING_EXTEND16); 876 fmt->packing == SOC_MBUS_PACKING_EXTEND16);
867} 877}
868 878
879static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect);
880
869static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx, 881static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx,
870 struct soc_camera_format_xlate *xlate) 882 struct soc_camera_format_xlate *xlate)
871{ 883{
@@ -894,10 +906,55 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx,
894 return 0; 906 return 0;
895 907
896 if (!icd->host_priv) { 908 if (!icd->host_priv) {
909 struct v4l2_mbus_framefmt mf;
910 struct v4l2_rect rect;
911 struct device *dev = icd->dev.parent;
912 int shift = 0;
913
914 /* FIXME: subwindow is lost between close / open */
915
916 /* Cache current client geometry */
917 ret = client_g_rect(sd, &rect);
918 if (ret < 0)
919 return ret;
920
921 /* First time */
922 ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
923 if (ret < 0)
924 return ret;
925
926 while ((mf.width > 2560 || mf.height > 1920) && shift < 4) {
927 /* Try 2560x1920, 1280x960, 640x480, 320x240 */
928 mf.width = 2560 >> shift;
929 mf.height = 1920 >> shift;
930 ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
931 if (ret < 0)
932 return ret;
933 shift++;
934 }
935
936 if (shift == 4) {
937 dev_err(dev, "Failed to configure the client below %ux%x\n",
938 mf.width, mf.height);
939 return -EIO;
940 }
941
942 dev_geo(dev, "camera fmt %ux%u\n", mf.width, mf.height);
943
897 cam = kzalloc(sizeof(*cam), GFP_KERNEL); 944 cam = kzalloc(sizeof(*cam), GFP_KERNEL);
898 if (!cam) 945 if (!cam)
899 return -ENOMEM; 946 return -ENOMEM;
900 947
948 /* We are called with current camera crop, initialise subrect with it */
949 cam->rect = rect;
950 cam->subrect = rect;
951
952 cam->width = mf.width;
953 cam->height = mf.height;
954
955 cam->width = mf.width;
956 cam->height = mf.height;
957
901 icd->host_priv = cam; 958 icd->host_priv = cam;
902 } else { 959 } else {
903 cam = icd->host_priv; 960 cam = icd->host_priv;
@@ -979,16 +1036,12 @@ static unsigned int scale_down(unsigned int size, unsigned int scale)
979 return (size * 4096 + scale / 2) / scale; 1036 return (size * 4096 + scale / 2) / scale;
980} 1037}
981 1038
982static unsigned int scale_up(unsigned int size, unsigned int scale)
983{
984 return (size * scale + 2048) / 4096;
985}
986
987static unsigned int calc_generic_scale(unsigned int input, unsigned int output) 1039static unsigned int calc_generic_scale(unsigned int input, unsigned int output)
988{ 1040{
989 return (input * 4096 + output / 2) / output; 1041 return (input * 4096 + output / 2) / output;
990} 1042}
991 1043
1044/* Get and store current client crop */
992static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect) 1045static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect)
993{ 1046{
994 struct v4l2_crop crop; 1047 struct v4l2_crop crop;
@@ -1007,25 +1060,51 @@ static int client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect)
1007 cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1060 cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1008 1061
1009 ret = v4l2_subdev_call(sd, video, cropcap, &cap); 1062 ret = v4l2_subdev_call(sd, video, cropcap, &cap);
1010 if (ret < 0) 1063 if (!ret)
1011 return ret; 1064 *rect = cap.defrect;
1012
1013 *rect = cap.defrect;
1014 1065
1015 return ret; 1066 return ret;
1016} 1067}
1017 1068
1069/* Client crop has changed, update our sub-rectangle to remain within the area */
1070static void update_subrect(struct sh_mobile_ceu_cam *cam)
1071{
1072 struct v4l2_rect *rect = &cam->rect, *subrect = &cam->subrect;
1073
1074 if (rect->width < subrect->width)
1075 subrect->width = rect->width;
1076
1077 if (rect->height < subrect->height)
1078 subrect->height = rect->height;
1079
1080 if (rect->left > subrect->left)
1081 subrect->left = rect->left;
1082 else if (rect->left + rect->width >
1083 subrect->left + subrect->width)
1084 subrect->left = rect->left + rect->width -
1085 subrect->width;
1086
1087 if (rect->top > subrect->top)
1088 subrect->top = rect->top;
1089 else if (rect->top + rect->height >
1090 subrect->top + subrect->height)
1091 subrect->top = rect->top + rect->height -
1092 subrect->height;
1093}
1094
1018/* 1095/*
1019 * The common for both scaling and cropping iterative approach is: 1096 * The common for both scaling and cropping iterative approach is:
1020 * 1. try if the client can produce exactly what requested by the user 1097 * 1. try if the client can produce exactly what requested by the user
1021 * 2. if (1) failed, try to double the client image until we get one big enough 1098 * 2. if (1) failed, try to double the client image until we get one big enough
1022 * 3. if (2) failed, try to request the maximum image 1099 * 3. if (2) failed, try to request the maximum image
1023 */ 1100 */
1024static int client_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *crop, 1101static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop,
1025 struct v4l2_crop *cam_crop) 1102 struct v4l2_crop *cam_crop)
1026{ 1103{
1104 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1027 struct v4l2_rect *rect = &crop->c, *cam_rect = &cam_crop->c; 1105 struct v4l2_rect *rect = &crop->c, *cam_rect = &cam_crop->c;
1028 struct device *dev = sd->v4l2_dev->dev; 1106 struct device *dev = sd->v4l2_dev->dev;
1107 struct sh_mobile_ceu_cam *cam = icd->host_priv;
1029 struct v4l2_cropcap cap; 1108 struct v4l2_cropcap cap;
1030 int ret; 1109 int ret;
1031 unsigned int width, height; 1110 unsigned int width, height;
@@ -1043,6 +1122,7 @@ static int client_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *crop,
1043 /* Even if camera S_CROP failed, but camera rectangle matches */ 1122 /* Even if camera S_CROP failed, but camera rectangle matches */
1044 dev_dbg(dev, "Camera S_CROP successful for %dx%d@%d:%d\n", 1123 dev_dbg(dev, "Camera S_CROP successful for %dx%d@%d:%d\n",
1045 rect->width, rect->height, rect->left, rect->top); 1124 rect->width, rect->height, rect->left, rect->top);
1125 cam->rect = *cam_rect;
1046 return 0; 1126 return 0;
1047 } 1127 }
1048 1128
@@ -1057,6 +1137,7 @@ static int client_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *crop,
1057 if (ret < 0) 1137 if (ret < 0)
1058 return ret; 1138 return ret;
1059 1139
1140 /* Put user requested rectangle within sensor bounds */
1060 soc_camera_limit_side(&rect->left, &rect->width, cap.bounds.left, 2, 1141 soc_camera_limit_side(&rect->left, &rect->width, cap.bounds.left, 2,
1061 cap.bounds.width); 1142 cap.bounds.width);
1062 soc_camera_limit_side(&rect->top, &rect->height, cap.bounds.top, 4, 1143 soc_camera_limit_side(&rect->top, &rect->height, cap.bounds.top, 4,
@@ -1069,6 +1150,10 @@ static int client_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *crop,
1069 width = max(cam_rect->width, 2); 1150 width = max(cam_rect->width, 2);
1070 height = max(cam_rect->height, 2); 1151 height = max(cam_rect->height, 2);
1071 1152
1153 /*
1154 * Loop as long as sensor is not covering the requested rectangle and
1155 * is still within its bounds
1156 */
1072 while (!ret && (is_smaller(cam_rect, rect) || 1157 while (!ret && (is_smaller(cam_rect, rect) ||
1073 is_inside(cam_rect, rect)) && 1158 is_inside(cam_rect, rect)) &&
1074 (cap.bounds.width > width || cap.bounds.height > height)) { 1159 (cap.bounds.width > width || cap.bounds.height > height)) {
@@ -1086,6 +1171,7 @@ static int client_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *crop,
1086 * target left, set it to the middle point between the current 1171 * target left, set it to the middle point between the current
1087 * left and minimum left. But that would add too much 1172 * left and minimum left. But that would add too much
1088 * complexity: we would have to iterate each border separately. 1173 * complexity: we would have to iterate each border separately.
1174 * Instead we just drop to the left and top bounds.
1089 */ 1175 */
1090 if (cam_rect->left > rect->left) 1176 if (cam_rect->left > rect->left)
1091 cam_rect->left = cap.bounds.left; 1177 cam_rect->left = cap.bounds.left;
@@ -1122,77 +1208,19 @@ static int client_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *crop,
1122 cam_rect->left, cam_rect->top); 1208 cam_rect->left, cam_rect->top);
1123 } 1209 }
1124 1210
1125 return ret; 1211 if (!ret) {
1126} 1212 cam->rect = *cam_rect;
1127 1213 update_subrect(cam);
1128static int get_camera_scales(struct v4l2_subdev *sd, struct v4l2_rect *rect,
1129 unsigned int *scale_h, unsigned int *scale_v)
1130{
1131 struct v4l2_mbus_framefmt mf;
1132 int ret;
1133
1134 ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
1135 if (ret < 0)
1136 return ret;
1137
1138 *scale_h = calc_generic_scale(rect->width, mf.width);
1139 *scale_v = calc_generic_scale(rect->height, mf.height);
1140
1141 return 0;
1142}
1143
1144static int get_camera_subwin(struct soc_camera_device *icd,
1145 struct v4l2_rect *cam_subrect,
1146 unsigned int cam_hscale, unsigned int cam_vscale)
1147{
1148 struct sh_mobile_ceu_cam *cam = icd->host_priv;
1149 struct v4l2_rect *ceu_rect = &cam->ceu_rect;
1150
1151 if (!ceu_rect->width) {
1152 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1153 struct device *dev = icd->dev.parent;
1154 struct v4l2_mbus_framefmt mf;
1155 int ret;
1156 /* First time */
1157
1158 ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
1159 if (ret < 0)
1160 return ret;
1161
1162 dev_geo(dev, "camera fmt %ux%u\n", mf.width, mf.height);
1163
1164 if (mf.width > 2560) {
1165 ceu_rect->width = 2560;
1166 ceu_rect->left = (mf.width - 2560) / 2;
1167 } else {
1168 ceu_rect->width = mf.width;
1169 ceu_rect->left = 0;
1170 }
1171
1172 if (mf.height > 1920) {
1173 ceu_rect->height = 1920;
1174 ceu_rect->top = (mf.height - 1920) / 2;
1175 } else {
1176 ceu_rect->height = mf.height;
1177 ceu_rect->top = 0;
1178 }
1179
1180 dev_geo(dev, "initialised CEU rect %ux%u@%u:%u\n",
1181 ceu_rect->width, ceu_rect->height,
1182 ceu_rect->left, ceu_rect->top);
1183 } 1214 }
1184 1215
1185 cam_subrect->width = scale_up(ceu_rect->width, cam_hscale); 1216 return ret;
1186 cam_subrect->left = scale_up(ceu_rect->left, cam_hscale);
1187 cam_subrect->height = scale_up(ceu_rect->height, cam_vscale);
1188 cam_subrect->top = scale_up(ceu_rect->top, cam_vscale);
1189
1190 return 0;
1191} 1217}
1192 1218
1219/* Iterative s_mbus_fmt, also updates cached client crop on success */
1193static int client_s_fmt(struct soc_camera_device *icd, 1220static int client_s_fmt(struct soc_camera_device *icd,
1194 struct v4l2_mbus_framefmt *mf, bool ceu_can_scale) 1221 struct v4l2_mbus_framefmt *mf, bool ceu_can_scale)
1195{ 1222{
1223 struct sh_mobile_ceu_cam *cam = icd->host_priv;
1196 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); 1224 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1197 struct device *dev = icd->dev.parent; 1225 struct device *dev = icd->dev.parent;
1198 unsigned int width = mf->width, height = mf->height, tmp_w, tmp_h; 1226 unsigned int width = mf->width, height = mf->height, tmp_w, tmp_h;
@@ -1200,6 +1228,15 @@ static int client_s_fmt(struct soc_camera_device *icd,
1200 struct v4l2_cropcap cap; 1228 struct v4l2_cropcap cap;
1201 int ret; 1229 int ret;
1202 1230
1231 ret = v4l2_subdev_call(sd, video, s_mbus_fmt, mf);
1232 if (ret < 0)
1233 return ret;
1234
1235 dev_geo(dev, "camera scaled to %ux%u\n", mf->width, mf->height);
1236
1237 if ((width == mf->width && height == mf->height) || !ceu_can_scale)
1238 goto update_cache;
1239
1203 cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1240 cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1204 1241
1205 ret = v4l2_subdev_call(sd, video, cropcap, &cap); 1242 ret = v4l2_subdev_call(sd, video, cropcap, &cap);
@@ -1209,15 +1246,6 @@ static int client_s_fmt(struct soc_camera_device *icd,
1209 max_width = min(cap.bounds.width, 2560); 1246 max_width = min(cap.bounds.width, 2560);
1210 max_height = min(cap.bounds.height, 1920); 1247 max_height = min(cap.bounds.height, 1920);
1211 1248
1212 ret = v4l2_subdev_call(sd, video, s_mbus_fmt, mf);
1213 if (ret < 0)
1214 return ret;
1215
1216 dev_geo(dev, "camera scaled to %ux%u\n", mf->width, mf->height);
1217
1218 if ((width == mf->width && height == mf->height) || !ceu_can_scale)
1219 return 0;
1220
1221 /* Camera set a format, but geometry is not precise, try to improve */ 1249 /* Camera set a format, but geometry is not precise, try to improve */
1222 tmp_w = mf->width; 1250 tmp_w = mf->width;
1223 tmp_h = mf->height; 1251 tmp_h = mf->height;
@@ -1239,26 +1267,37 @@ static int client_s_fmt(struct soc_camera_device *icd,
1239 } 1267 }
1240 } 1268 }
1241 1269
1270update_cache:
1271 /* Update cache */
1272 ret = client_g_rect(sd, &cam->rect);
1273 if (ret < 0)
1274 return ret;
1275
1276 update_subrect(cam);
1277
1242 return 0; 1278 return 0;
1243} 1279}
1244 1280
1245/** 1281/**
1246 * @rect - camera cropped rectangle 1282 * @width - on output: user width, mapped back to input
1247 * @sub_rect - CEU cropped rectangle, mapped back to camera input area 1283 * @height - on output: user height, mapped back to input
1248 * @ceu_rect - on output calculated CEU crop rectangle 1284 * @mf - in- / output camera output window
1249 */ 1285 */
1250static int client_scale(struct soc_camera_device *icd, struct v4l2_rect *rect, 1286static int client_scale(struct soc_camera_device *icd,
1251 struct v4l2_rect *sub_rect, struct v4l2_rect *ceu_rect, 1287 struct v4l2_mbus_framefmt *mf,
1252 struct v4l2_mbus_framefmt *mf, bool ceu_can_scale) 1288 unsigned int *width, unsigned int *height,
1289 bool ceu_can_scale)
1253{ 1290{
1254 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1255 struct sh_mobile_ceu_cam *cam = icd->host_priv; 1291 struct sh_mobile_ceu_cam *cam = icd->host_priv;
1256 struct device *dev = icd->dev.parent; 1292 struct device *dev = icd->dev.parent;
1257 struct v4l2_mbus_framefmt mf_tmp = *mf; 1293 struct v4l2_mbus_framefmt mf_tmp = *mf;
1258 unsigned int scale_h, scale_v; 1294 unsigned int scale_h, scale_v;
1259 int ret; 1295 int ret;
1260 1296
1261 /* 5. Apply iterative camera S_FMT for camera user window. */ 1297 /*
1298 * 5. Apply iterative camera S_FMT for camera user window (also updates
1299 * client crop cache and the imaginary sub-rectangle).
1300 */
1262 ret = client_s_fmt(icd, &mf_tmp, ceu_can_scale); 1301 ret = client_s_fmt(icd, &mf_tmp, ceu_can_scale);
1263 if (ret < 0) 1302 if (ret < 0)
1264 return ret; 1303 return ret;
@@ -1270,60 +1309,22 @@ static int client_scale(struct soc_camera_device *icd, struct v4l2_rect *rect,
1270 1309
1271 /* unneeded - it is already in "mf_tmp" */ 1310 /* unneeded - it is already in "mf_tmp" */
1272 1311
1273 /* 7. Calculate new camera scales. */ 1312 /* 7. Calculate new client scales. */
1274 ret = get_camera_scales(sd, rect, &scale_h, &scale_v); 1313 scale_h = calc_generic_scale(cam->rect.width, mf_tmp.width);
1275 if (ret < 0) 1314 scale_v = calc_generic_scale(cam->rect.height, mf_tmp.height);
1276 return ret;
1277
1278 dev_geo(dev, "7: camera scales %u:%u\n", scale_h, scale_v);
1279 1315
1280 cam->cam_width = mf_tmp.width;
1281 cam->cam_height = mf_tmp.height;
1282 mf->width = mf_tmp.width; 1316 mf->width = mf_tmp.width;
1283 mf->height = mf_tmp.height; 1317 mf->height = mf_tmp.height;
1284 mf->colorspace = mf_tmp.colorspace; 1318 mf->colorspace = mf_tmp.colorspace;
1285 1319
1286 /* 1320 /*
1287 * 8. Calculate new CEU crop - apply camera scales to previously 1321 * 8. Calculate new CEU crop - apply camera scales to previously
1288 * calculated "effective" crop. 1322 * updated "effective" crop.
1289 */ 1323 */
1290 ceu_rect->left = scale_down(sub_rect->left, scale_h); 1324 *width = scale_down(cam->subrect.width, scale_h);
1291 ceu_rect->width = scale_down(sub_rect->width, scale_h); 1325 *height = scale_down(cam->subrect.height, scale_v);
1292 ceu_rect->top = scale_down(sub_rect->top, scale_v);
1293 ceu_rect->height = scale_down(sub_rect->height, scale_v);
1294 1326
1295 dev_geo(dev, "8: new CEU rect %ux%u@%u:%u\n", 1327 dev_geo(dev, "8: new client sub-window %ux%u\n", *width, *height);
1296 ceu_rect->width, ceu_rect->height,
1297 ceu_rect->left, ceu_rect->top);
1298
1299 return 0;
1300}
1301
1302/* Get combined scales */
1303static int get_scales(struct soc_camera_device *icd,
1304 unsigned int *scale_h, unsigned int *scale_v)
1305{
1306 struct sh_mobile_ceu_cam *cam = icd->host_priv;
1307 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1308 struct v4l2_crop cam_crop;
1309 unsigned int width_in, height_in;
1310 int ret;
1311
1312 cam_crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1313
1314 ret = client_g_rect(sd, &cam_crop.c);
1315 if (ret < 0)
1316 return ret;
1317
1318 ret = get_camera_scales(sd, &cam_crop.c, scale_h, scale_v);
1319 if (ret < 0)
1320 return ret;
1321
1322 width_in = scale_up(cam->ceu_rect.width, *scale_h);
1323 height_in = scale_up(cam->ceu_rect.height, *scale_v);
1324
1325 *scale_h = calc_generic_scale(width_in, icd->user_width);
1326 *scale_v = calc_generic_scale(height_in, icd->user_height);
1327 1328
1328 return 0; 1329 return 0;
1329} 1330}
@@ -1342,115 +1343,165 @@ static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd,
1342 struct sh_mobile_ceu_dev *pcdev = ici->priv; 1343 struct sh_mobile_ceu_dev *pcdev = ici->priv;
1343 struct v4l2_crop cam_crop; 1344 struct v4l2_crop cam_crop;
1344 struct sh_mobile_ceu_cam *cam = icd->host_priv; 1345 struct sh_mobile_ceu_cam *cam = icd->host_priv;
1345 struct v4l2_rect *cam_rect = &cam_crop.c, *ceu_rect = &cam->ceu_rect; 1346 struct v4l2_rect *cam_rect = &cam_crop.c;
1346 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); 1347 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1347 struct device *dev = icd->dev.parent; 1348 struct device *dev = icd->dev.parent;
1348 struct v4l2_mbus_framefmt mf; 1349 struct v4l2_mbus_framefmt mf;
1349 unsigned int scale_comb_h, scale_comb_v, scale_ceu_h, scale_ceu_v, 1350 unsigned int scale_cam_h, scale_cam_v, scale_ceu_h, scale_ceu_v,
1350 out_width, out_height; 1351 out_width, out_height, scale_h, scale_v;
1352 int interm_width, interm_height;
1351 u32 capsr, cflcr; 1353 u32 capsr, cflcr;
1352 int ret; 1354 int ret;
1353 1355
1354 /* 1. Calculate current combined scales. */ 1356 dev_geo(dev, "S_CROP(%ux%u@%u:%u)\n", rect->width, rect->height,
1355 ret = get_scales(icd, &scale_comb_h, &scale_comb_v); 1357 rect->left, rect->top);
1356 if (ret < 0)
1357 return ret;
1358 1358
1359 dev_geo(dev, "1: combined scales %u:%u\n", scale_comb_h, scale_comb_v); 1359 /* During camera cropping its output window can change too, stop CEU */
1360 capsr = capture_save_reset(pcdev);
1361 dev_dbg(dev, "CAPSR 0x%x, CFLCR 0x%x\n", capsr, pcdev->cflcr);
1360 1362
1361 /* 2. Apply iterative camera S_CROP for new input window. */ 1363 /* 1. - 2. Apply iterative camera S_CROP for new input window. */
1362 ret = client_s_crop(sd, a, &cam_crop); 1364 ret = client_s_crop(icd, a, &cam_crop);
1363 if (ret < 0) 1365 if (ret < 0)
1364 return ret; 1366 return ret;
1365 1367
1366 dev_geo(dev, "2: camera cropped to %ux%u@%u:%u\n", 1368 dev_geo(dev, "1-2: camera cropped to %ux%u@%u:%u\n",
1367 cam_rect->width, cam_rect->height, 1369 cam_rect->width, cam_rect->height,
1368 cam_rect->left, cam_rect->top); 1370 cam_rect->left, cam_rect->top);
1369 1371
1370 /* On success cam_crop contains current camera crop */ 1372 /* On success cam_crop contains current camera crop */
1371 1373
1372 /* 1374 /* 3. Retrieve camera output window */
1373 * 3. If old combined scales applied to new crop produce an impossible 1375 ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
1374 * user window, adjust scales to produce nearest possible window. 1376 if (ret < 0)
1375 */ 1377 return ret;
1376 out_width = scale_down(rect->width, scale_comb_h);
1377 out_height = scale_down(rect->height, scale_comb_v);
1378
1379 if (out_width > 2560)
1380 out_width = 2560;
1381 else if (out_width < 2)
1382 out_width = 2;
1383
1384 if (out_height > 1920)
1385 out_height = 1920;
1386 else if (out_height < 4)
1387 out_height = 4;
1388
1389 dev_geo(dev, "3: Adjusted output %ux%u\n", out_width, out_height);
1390
1391 /* 4. Use G_CROP to retrieve actual input window: already in cam_crop */
1392
1393 /*
1394 * 5. Using actual input window and calculated combined scales calculate
1395 * camera target output window.
1396 */
1397 mf.width = scale_down(cam_rect->width, scale_comb_h);
1398 mf.height = scale_down(cam_rect->height, scale_comb_v);
1399
1400 dev_geo(dev, "5: camera target %ux%u\n", mf.width, mf.height);
1401
1402 /* 6. - 9. */
1403 mf.code = cam->code;
1404 mf.field = pcdev->field;
1405
1406 capsr = capture_save_reset(pcdev);
1407 dev_dbg(dev, "CAPSR 0x%x, CFLCR 0x%x\n", capsr, pcdev->cflcr);
1408 1378
1409 /* Make relative to camera rectangle */ 1379 if (mf.width > 2560 || mf.height > 1920)
1410 rect->left -= cam_rect->left; 1380 return -EINVAL;
1411 rect->top -= cam_rect->top;
1412 1381
1413 ret = client_scale(icd, cam_rect, rect, ceu_rect, &mf, 1382 /* Cache camera output window */
1414 pcdev->image_mode && 1383 cam->width = mf.width;
1415 V4L2_FIELD_NONE == pcdev->field); 1384 cam->height = mf.height;
1416 1385
1417 dev_geo(dev, "6-9: %d\n", ret); 1386 /* 4. Calculate camera scales */
1387 scale_cam_h = calc_generic_scale(cam_rect->width, mf.width);
1388 scale_cam_v = calc_generic_scale(cam_rect->height, mf.height);
1418 1389
1419 /* 10. Use CEU cropping to crop to the new window. */ 1390 /* Calculate intermediate window */
1420 sh_mobile_ceu_set_rect(icd, out_width, out_height); 1391 interm_width = scale_down(rect->width, scale_cam_h);
1392 interm_height = scale_down(rect->height, scale_cam_v);
1421 1393
1422 dev_geo(dev, "10: CEU cropped to %ux%u@%u:%u\n", 1394 if (pcdev->image_mode) {
1423 ceu_rect->width, ceu_rect->height, 1395 out_width = min(interm_width, icd->user_width);
1424 ceu_rect->left, ceu_rect->top); 1396 out_height = min(interm_height, icd->user_height);
1397 } else {
1398 out_width = interm_width;
1399 out_height = interm_height;
1400 }
1425 1401
1426 /* 1402 /*
1427 * 11. Calculate CEU scales from camera scales from results of (10) and 1403 * 5. Calculate CEU scales from camera scales from results of (5) and
1428 * user window from (3) 1404 * the user window
1429 */ 1405 */
1430 scale_ceu_h = calc_scale(ceu_rect->width, &out_width); 1406 scale_ceu_h = calc_scale(interm_width, &out_width);
1431 scale_ceu_v = calc_scale(ceu_rect->height, &out_height); 1407 scale_ceu_v = calc_scale(interm_height, &out_height);
1432 1408
1433 dev_geo(dev, "11: CEU scales %u:%u\n", scale_ceu_h, scale_ceu_v); 1409 /* Calculate camera scales */
1410 scale_h = calc_generic_scale(cam_rect->width, out_width);
1411 scale_v = calc_generic_scale(cam_rect->height, out_height);
1434 1412
1435 /* 12. Apply CEU scales. */ 1413 dev_geo(dev, "5: CEU scales %u:%u\n", scale_ceu_h, scale_ceu_v);
1414
1415 /* Apply CEU scales. */
1436 cflcr = scale_ceu_h | (scale_ceu_v << 16); 1416 cflcr = scale_ceu_h | (scale_ceu_v << 16);
1437 if (cflcr != pcdev->cflcr) { 1417 if (cflcr != pcdev->cflcr) {
1438 pcdev->cflcr = cflcr; 1418 pcdev->cflcr = cflcr;
1439 ceu_write(pcdev, CFLCR, cflcr); 1419 ceu_write(pcdev, CFLCR, cflcr);
1440 } 1420 }
1441 1421
1422 icd->user_width = out_width;
1423 icd->user_height = out_height;
1424 cam->ceu_left = scale_down(rect->left - cam_rect->left, scale_h) & ~1;
1425 cam->ceu_top = scale_down(rect->top - cam_rect->top, scale_v) & ~1;
1426
1427 /* 6. Use CEU cropping to crop to the new window. */
1428 sh_mobile_ceu_set_rect(icd);
1429
1430 cam->subrect = *rect;
1431
1432 dev_geo(dev, "6: CEU cropped to %ux%u@%u:%u\n",
1433 icd->user_width, icd->user_height,
1434 cam->ceu_left, cam->ceu_top);
1435
1442 /* Restore capture */ 1436 /* Restore capture */
1443 if (pcdev->active) 1437 if (pcdev->active)
1444 capsr |= 1; 1438 capsr |= 1;
1445 capture_restore(pcdev, capsr); 1439 capture_restore(pcdev, capsr);
1446 1440
1447 icd->user_width = out_width;
1448 icd->user_height = out_height;
1449
1450 /* Even if only camera cropping succeeded */ 1441 /* Even if only camera cropping succeeded */
1451 return ret; 1442 return ret;
1452} 1443}
1453 1444
1445static int sh_mobile_ceu_get_crop(struct soc_camera_device *icd,
1446 struct v4l2_crop *a)
1447{
1448 struct sh_mobile_ceu_cam *cam = icd->host_priv;
1449
1450 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1451 a->c = cam->subrect;
1452
1453 return 0;
1454}
1455
1456/*
1457 * Calculate real client output window by applying new scales to the current
1458 * client crop. New scales are calculated from the requested output format and
1459 * CEU crop, mapped backed onto the client input (subrect).
1460 */
1461static void calculate_client_output(struct soc_camera_device *icd,
1462 struct v4l2_pix_format *pix, struct v4l2_mbus_framefmt *mf)
1463{
1464 struct sh_mobile_ceu_cam *cam = icd->host_priv;
1465 struct device *dev = icd->dev.parent;
1466 struct v4l2_rect *cam_subrect = &cam->subrect;
1467 unsigned int scale_v, scale_h;
1468
1469 if (cam_subrect->width == cam->rect.width &&
1470 cam_subrect->height == cam->rect.height) {
1471 /* No sub-cropping */
1472 mf->width = pix->width;
1473 mf->height = pix->height;
1474 return;
1475 }
1476
1477 /* 1.-2. Current camera scales and subwin - cached. */
1478
1479 dev_geo(dev, "2: subwin %ux%u@%u:%u\n",
1480 cam_subrect->width, cam_subrect->height,
1481 cam_subrect->left, cam_subrect->top);
1482
1483 /*
1484 * 3. Calculate new combined scales from input sub-window to requested
1485 * user window.
1486 */
1487
1488 /*
1489 * TODO: CEU cannot scale images larger than VGA to smaller than SubQCIF
1490 * (128x96) or larger than VGA
1491 */
1492 scale_h = calc_generic_scale(cam_subrect->width, pix->width);
1493 scale_v = calc_generic_scale(cam_subrect->height, pix->height);
1494
1495 dev_geo(dev, "3: scales %u:%u\n", scale_h, scale_v);
1496
1497 /*
1498 * 4. Calculate client output window by applying combined scales to real
1499 * input window.
1500 */
1501 mf->width = scale_down(cam->rect.width, scale_h);
1502 mf->height = scale_down(cam->rect.height, scale_v);
1503}
1504
1454/* Similar to set_crop multistage iterative algorithm */ 1505/* Similar to set_crop multistage iterative algorithm */
1455static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd, 1506static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
1456 struct v4l2_format *f) 1507 struct v4l2_format *f)
@@ -1460,18 +1511,17 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
1460 struct sh_mobile_ceu_cam *cam = icd->host_priv; 1511 struct sh_mobile_ceu_cam *cam = icd->host_priv;
1461 struct v4l2_pix_format *pix = &f->fmt.pix; 1512 struct v4l2_pix_format *pix = &f->fmt.pix;
1462 struct v4l2_mbus_framefmt mf; 1513 struct v4l2_mbus_framefmt mf;
1463 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1464 struct device *dev = icd->dev.parent; 1514 struct device *dev = icd->dev.parent;
1465 __u32 pixfmt = pix->pixelformat; 1515 __u32 pixfmt = pix->pixelformat;
1466 const struct soc_camera_format_xlate *xlate; 1516 const struct soc_camera_format_xlate *xlate;
1467 struct v4l2_crop cam_crop; 1517 unsigned int ceu_sub_width, ceu_sub_height;
1468 struct v4l2_rect *cam_rect = &cam_crop.c, cam_subrect, ceu_rect;
1469 unsigned int scale_cam_h, scale_cam_v;
1470 u16 scale_v, scale_h; 1518 u16 scale_v, scale_h;
1471 int ret; 1519 int ret;
1472 bool image_mode; 1520 bool image_mode;
1473 enum v4l2_field field; 1521 enum v4l2_field field;
1474 1522
1523 dev_geo(dev, "S_FMT(pix=0x%x, %ux%u)\n", pixfmt, pix->width, pix->height);
1524
1475 switch (pix->field) { 1525 switch (pix->field) {
1476 default: 1526 default:
1477 pix->field = V4L2_FIELD_NONE; 1527 pix->field = V4L2_FIELD_NONE;
@@ -1492,46 +1542,8 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
1492 return -EINVAL; 1542 return -EINVAL;
1493 } 1543 }
1494 1544
1495 /* 1. Calculate current camera scales. */ 1545 /* 1.-4. Calculate client output geometry */
1496 cam_crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1546 calculate_client_output(icd, &f->fmt.pix, &mf);
1497
1498 ret = client_g_rect(sd, cam_rect);
1499 if (ret < 0)
1500 return ret;
1501
1502 ret = get_camera_scales(sd, cam_rect, &scale_cam_h, &scale_cam_v);
1503 if (ret < 0)
1504 return ret;
1505
1506 dev_geo(dev, "1: camera scales %u:%u\n", scale_cam_h, scale_cam_v);
1507
1508 /*
1509 * 2. Calculate "effective" input crop (sensor subwindow) - CEU crop
1510 * scaled back at current camera scales onto input window.
1511 */
1512 ret = get_camera_subwin(icd, &cam_subrect, scale_cam_h, scale_cam_v);
1513 if (ret < 0)
1514 return ret;
1515
1516 dev_geo(dev, "2: subwin %ux%u@%u:%u\n",
1517 cam_subrect.width, cam_subrect.height,
1518 cam_subrect.left, cam_subrect.top);
1519
1520 /*
1521 * 3. Calculate new combined scales from "effective" input window to
1522 * requested user window.
1523 */
1524 scale_h = calc_generic_scale(cam_subrect.width, pix->width);
1525 scale_v = calc_generic_scale(cam_subrect.height, pix->height);
1526
1527 dev_geo(dev, "3: scales %u:%u\n", scale_h, scale_v);
1528
1529 /*
1530 * 4. Calculate camera output window by applying combined scales to real
1531 * input window.
1532 */
1533 mf.width = scale_down(cam_rect->width, scale_h);
1534 mf.height = scale_down(cam_rect->height, scale_v);
1535 mf.field = pix->field; 1547 mf.field = pix->field;
1536 mf.colorspace = pix->colorspace; 1548 mf.colorspace = pix->colorspace;
1537 mf.code = xlate->code; 1549 mf.code = xlate->code;
@@ -1547,17 +1559,17 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
1547 image_mode = false; 1559 image_mode = false;
1548 } 1560 }
1549 1561
1550 dev_geo(dev, "4: camera output %ux%u\n", mf.width, mf.height); 1562 dev_geo(dev, "4: request camera output %ux%u\n", mf.width, mf.height);
1551 1563
1552 /* 5. - 9. */ 1564 /* 5. - 9. */
1553 ret = client_scale(icd, cam_rect, &cam_subrect, &ceu_rect, &mf, 1565 ret = client_scale(icd, &mf, &ceu_sub_width, &ceu_sub_height,
1554 image_mode && V4L2_FIELD_NONE == field); 1566 image_mode && V4L2_FIELD_NONE == field);
1555 1567
1556 dev_geo(dev, "5-9: client scale %d\n", ret); 1568 dev_geo(dev, "5-9: client scale return %d\n", ret);
1557 1569
1558 /* Done with the camera. Now see if we can improve the result */ 1570 /* Done with the camera. Now see if we can improve the result */
1559 1571
1560 dev_dbg(dev, "Camera %d fmt %ux%u, requested %ux%u\n", 1572 dev_geo(dev, "Camera %d fmt %ux%u, requested %ux%u\n",
1561 ret, mf.width, mf.height, pix->width, pix->height); 1573 ret, mf.width, mf.height, pix->width, pix->height);
1562 if (ret < 0) 1574 if (ret < 0)
1563 return ret; 1575 return ret;
@@ -1565,40 +1577,44 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
1565 if (mf.code != xlate->code) 1577 if (mf.code != xlate->code)
1566 return -EINVAL; 1578 return -EINVAL;
1567 1579
1580 /* 9. Prepare CEU crop */
1581 cam->width = mf.width;
1582 cam->height = mf.height;
1583
1568 /* 10. Use CEU scaling to scale to the requested user window. */ 1584 /* 10. Use CEU scaling to scale to the requested user window. */
1569 1585
1570 /* We cannot scale up */ 1586 /* We cannot scale up */
1571 if (pix->width > mf.width) 1587 if (pix->width > ceu_sub_width)
1572 pix->width = mf.width; 1588 ceu_sub_width = pix->width;
1573 if (pix->width > ceu_rect.width)
1574 pix->width = ceu_rect.width;
1575 1589
1576 if (pix->height > mf.height) 1590 if (pix->height > ceu_sub_height)
1577 pix->height = mf.height; 1591 ceu_sub_height = pix->height;
1578 if (pix->height > ceu_rect.height)
1579 pix->height = ceu_rect.height;
1580 1592
1581 pix->colorspace = mf.colorspace; 1593 pix->colorspace = mf.colorspace;
1582 1594
1583 if (image_mode) { 1595 if (image_mode) {
1584 /* Scale pix->{width x height} down to width x height */ 1596 /* Scale pix->{width x height} down to width x height */
1585 scale_h = calc_scale(ceu_rect.width, &pix->width); 1597 scale_h = calc_scale(ceu_sub_width, &pix->width);
1586 scale_v = calc_scale(ceu_rect.height, &pix->height); 1598 scale_v = calc_scale(ceu_sub_height, &pix->height);
1587
1588 pcdev->cflcr = scale_h | (scale_v << 16);
1589 } else { 1599 } else {
1590 pix->width = ceu_rect.width; 1600 pix->width = ceu_sub_width;
1591 pix->height = ceu_rect.height; 1601 pix->height = ceu_sub_height;
1592 scale_h = scale_v = 0; 1602 scale_h = 0;
1593 pcdev->cflcr = 0; 1603 scale_v = 0;
1594 } 1604 }
1595 1605
1606 pcdev->cflcr = scale_h | (scale_v << 16);
1607
1608 /*
1609 * We have calculated CFLCR, the actual configuration will be performed
1610 * in sh_mobile_ceu_set_bus_param()
1611 */
1612
1596 dev_geo(dev, "10: W: %u : 0x%x = %u, H: %u : 0x%x = %u\n", 1613 dev_geo(dev, "10: W: %u : 0x%x = %u, H: %u : 0x%x = %u\n",
1597 ceu_rect.width, scale_h, pix->width, 1614 ceu_sub_width, scale_h, pix->width,
1598 ceu_rect.height, scale_v, pix->height); 1615 ceu_sub_height, scale_v, pix->height);
1599 1616
1600 cam->code = xlate->code; 1617 cam->code = xlate->code;
1601 cam->ceu_rect = ceu_rect;
1602 icd->current_fmt = xlate; 1618 icd->current_fmt = xlate;
1603 1619
1604 pcdev->field = field; 1620 pcdev->field = field;
@@ -1820,6 +1836,7 @@ static struct soc_camera_host_ops sh_mobile_ceu_host_ops = {
1820 .remove = sh_mobile_ceu_remove_device, 1836 .remove = sh_mobile_ceu_remove_device,
1821 .get_formats = sh_mobile_ceu_get_formats, 1837 .get_formats = sh_mobile_ceu_get_formats,
1822 .put_formats = sh_mobile_ceu_put_formats, 1838 .put_formats = sh_mobile_ceu_put_formats,
1839 .get_crop = sh_mobile_ceu_get_crop,
1823 .set_crop = sh_mobile_ceu_set_crop, 1840 .set_crop = sh_mobile_ceu_set_crop,
1824 .set_fmt = sh_mobile_ceu_set_fmt, 1841 .set_fmt = sh_mobile_ceu_set_fmt,
1825 .try_fmt = sh_mobile_ceu_try_fmt, 1842 .try_fmt = sh_mobile_ceu_try_fmt,