(width & 0x01);
}
-static int pxa_camera_set_selection(struct soc_camera_device *icd,
- struct v4l2_selection *sel)
-{
- const struct v4l2_rect *rect = &sel->r;
- struct device *dev = icd->parent;
- struct soc_camera_host *ici = to_soc_camera_host(dev);
- struct pxa_camera_dev *pcdev = ici->priv;
- struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
- struct soc_camera_sense sense = {
- .master_clock = pcdev->mclk,
- .pixel_clock_max = pcdev->ciclk / 4,
- };
- struct v4l2_subdev_format fmt = {
- .which = V4L2_SUBDEV_FORMAT_ACTIVE,
- };
- struct v4l2_mbus_framefmt *mf = &fmt.format;
- struct pxa_cam *cam = icd->host_priv;
- u32 fourcc = icd->current_fmt->host_fmt->fourcc;
- struct v4l2_subdev_selection sdsel = {
- .which = V4L2_SUBDEV_FORMAT_ACTIVE,
- .target = sel->target,
- .flags = sel->flags,
- .r = sel->r,
- };
- int ret;
-
- /* If PCLK is used to latch data from the sensor, check sense */
- if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
- icd->sense = &sense;
-
- ret = sensor_call(pcdev, pad, set_selection, NULL, &sdsel);
-
- icd->sense = NULL;
-
- if (ret < 0) {
- dev_warn(pcdev_to_dev(pcdev), "Failed to crop to %ux%u@%u:%u\n",
- rect->width, rect->height, rect->left, rect->top);
- return ret;
- }
- sel->r = sdsel.r;
-
- ret = sensor_call(pcdev, pad, get_fmt, NULL, &fmt);
- if (ret < 0)
- return ret;
-
- if (pxa_camera_check_frame(mf->width, mf->height)) {
- /*
- * Camera cropping produced a frame beyond our capabilities.
- * FIXME: just extract a subframe, that we can process.
- */
- v4l_bound_align_image(&mf->width, 48, 2048, 1,
- &mf->height, 32, 2048, 0,
- fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0);
- ret = sensor_call(pcdev, pad, set_fmt, NULL, &fmt);
- if (ret < 0)
- return ret;
-
- if (pxa_camera_check_frame(mf->width, mf->height)) {
- dev_warn(pcdev_to_dev(pcdev),
- "Inconsistent state. Use S_FMT to repair\n");
- return -EINVAL;
- }
- }
-
- if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) {
- if (sense.pixel_clock > sense.pixel_clock_max) {
- dev_err(pcdev_to_dev(pcdev),
- "pixel clock %lu set by the camera too high!",
- sense.pixel_clock);
- return -EIO;
- }
- recalculate_fifo_timeout(pcdev, sense.pixel_clock);
- }
-
- icd->user_width = mf->width;
- icd->user_height = mf->height;
-
- pxa_camera_setup_cicr(icd, cam->flags, fourcc);
-
- return ret;
-}
-
static int pxa_camera_set_fmt(struct soc_camera_device *icd,
struct v4l2_format *f)
{
.remove = pxa_camera_remove_device,
.clock_start = pxa_camera_clock_start,
.clock_stop = pxa_camera_clock_stop,
- .set_selection = pxa_camera_set_selection,
.get_formats = pxa_camera_get_formats,
.put_formats = pxa_camera_put_formats,
.set_fmt = pxa_camera_set_fmt,