ov2680.c (d5d08ad330c9ccebc5e066fda815423a290f48b0) ov2680.c (49c282d5a8c5f4d1d9088622bec792294c716010)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Omnivision OV2680 CMOS Image Sensor driver
4 *
5 * Copyright (C) 2018 Linaro Ltd
6 *
7 * Based on OV5640 Sensor Driver
8 * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved.

--- 548 unchanged lines hidden (view full) ---

557}
558
559static int ov2680_get_fmt(struct v4l2_subdev *sd,
560 struct v4l2_subdev_state *sd_state,
561 struct v4l2_subdev_format *format)
562{
563 struct ov2680_dev *sensor = to_ov2680_dev(sd);
564 struct v4l2_mbus_framefmt *fmt = NULL;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Omnivision OV2680 CMOS Image Sensor driver
4 *
5 * Copyright (C) 2018 Linaro Ltd
6 *
7 * Based on OV5640 Sensor Driver
8 * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved.

--- 548 unchanged lines hidden (view full) ---

557}
558
559static int ov2680_get_fmt(struct v4l2_subdev *sd,
560 struct v4l2_subdev_state *sd_state,
561 struct v4l2_subdev_format *format)
562{
563 struct ov2680_dev *sensor = to_ov2680_dev(sd);
564 struct v4l2_mbus_framefmt *fmt = NULL;
565 int ret = 0;
566
567 if (format->pad != 0)
568 return -EINVAL;
569
570 mutex_lock(&sensor->lock);
571
572 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
565
566 if (format->pad != 0)
567 return -EINVAL;
568
569 mutex_lock(&sensor->lock);
570
571 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
573#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
574 fmt = v4l2_subdev_get_try_format(&sensor->sd, sd_state,
575 format->pad);
572 fmt = v4l2_subdev_get_try_format(&sensor->sd, sd_state,
573 format->pad);
576#else
577 ret = -EINVAL;
578#endif
579 } else {
580 fmt = &sensor->fmt;
581 }
582
574 } else {
575 fmt = &sensor->fmt;
576 }
577
583 if (fmt)
584 format->format = *fmt;
578 format->format = *fmt;
585
586 mutex_unlock(&sensor->lock);
587
579
580 mutex_unlock(&sensor->lock);
581
588 return ret;
582 return 0;
589}
590
591static int ov2680_set_fmt(struct v4l2_subdev *sd,
592 struct v4l2_subdev_state *sd_state,
593 struct v4l2_subdev_format *format)
594{
595 struct ov2680_dev *sensor = to_ov2680_dev(sd);
596 struct v4l2_mbus_framefmt *fmt = &format->format;
583}
584
585static int ov2680_set_fmt(struct v4l2_subdev *sd,
586 struct v4l2_subdev_state *sd_state,
587 struct v4l2_subdev_format *format)
588{
589 struct ov2680_dev *sensor = to_ov2680_dev(sd);
590 struct v4l2_mbus_framefmt *fmt = &format->format;
597#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
598 struct v4l2_mbus_framefmt *try_fmt;
591 struct v4l2_mbus_framefmt *try_fmt;
599#endif
600 const struct ov2680_mode_info *mode;
601 int ret = 0;
602
603 if (format->pad != 0)
604 return -EINVAL;
605
606 mutex_lock(&sensor->lock);
607

--- 6 unchanged lines hidden (view full) ---

614 ARRAY_SIZE(ov2680_mode_data), width,
615 height, fmt->width, fmt->height);
616 if (!mode) {
617 ret = -EINVAL;
618 goto unlock;
619 }
620
621 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
592 const struct ov2680_mode_info *mode;
593 int ret = 0;
594
595 if (format->pad != 0)
596 return -EINVAL;
597
598 mutex_lock(&sensor->lock);
599

--- 6 unchanged lines hidden (view full) ---

606 ARRAY_SIZE(ov2680_mode_data), width,
607 height, fmt->width, fmt->height);
608 if (!mode) {
609 ret = -EINVAL;
610 goto unlock;
611 }
612
613 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
622#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
623 try_fmt = v4l2_subdev_get_try_format(sd, sd_state, 0);
624 format->format = *try_fmt;
614 try_fmt = v4l2_subdev_get_try_format(sd, sd_state, 0);
615 format->format = *try_fmt;
625#endif
626 goto unlock;
627 }
628
629 fmt->width = mode->width;
630 fmt->height = mode->height;
631 fmt->code = sensor->fmt.code;
632 fmt->colorspace = sensor->fmt.colorspace;
633

--- 141 unchanged lines hidden (view full) ---

775 const struct v4l2_ctrl_ops *ops = &ov2680_ctrl_ops;
776 struct ov2680_ctrls *ctrls = &sensor->ctrls;
777 struct v4l2_ctrl_handler *hdl = &ctrls->handler;
778 int ret = 0;
779
780 v4l2_i2c_subdev_init(&sensor->sd, sensor->i2c_client,
781 &ov2680_subdev_ops);
782
616 goto unlock;
617 }
618
619 fmt->width = mode->width;
620 fmt->height = mode->height;
621 fmt->code = sensor->fmt.code;
622 fmt->colorspace = sensor->fmt.colorspace;
623

--- 141 unchanged lines hidden (view full) ---

765 const struct v4l2_ctrl_ops *ops = &ov2680_ctrl_ops;
766 struct ov2680_ctrls *ctrls = &sensor->ctrls;
767 struct v4l2_ctrl_handler *hdl = &ctrls->handler;
768 int ret = 0;
769
770 v4l2_i2c_subdev_init(&sensor->sd, sensor->i2c_client,
771 &ov2680_subdev_ops);
772
783#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
784 sensor->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
773 sensor->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
785#endif
786 sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
787 sensor->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
788
789 ret = media_entity_pads_init(&sensor->sd.entity, 1, &sensor->pad);
790 if (ret < 0)
791 return ret;
792
793 v4l2_ctrl_handler_init(hdl, 5);

--- 217 unchanged lines hidden ---
774 sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
775 sensor->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
776
777 ret = media_entity_pads_init(&sensor->sd.entity, 1, &sensor->pad);
778 if (ret < 0)
779 return ret;
780
781 v4l2_ctrl_handler_init(hdl, 5);

--- 217 unchanged lines hidden ---