Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: i2c: imx290: Add crop selection targets support

Implement read-only access to crop selection rectangles to expose the
analogue crop rectangle. The public (leaked) IMX290 documentation is not
very clear on how cropping is implemented and configured exactly, so
the margins may not be entirely accurate.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

authored by

Laurent Pinchart and committed by
Sakari Ailus
b4ab57b0 b25537ef

+94
+94
drivers/media/i2c/imx290.c
··· 105 105 106 106 #define IMX290_VMAX_DEFAULT 1125 107 107 108 + 109 + /* 110 + * The IMX290 pixel array is organized as follows: 111 + * 112 + * +------------------------------------+ 113 + * | Optical Black | } Vertical effective optical black (10) 114 + * +---+------------------------------------+---+ 115 + * | | | | } Effective top margin (8) 116 + * | | +----------------------------+ | | \ 117 + * | | | | | | | 118 + * | | | | | | | 119 + * | | | | | | | 120 + * | | | Recording Pixel Area | | | | Recommended height (1080) 121 + * | | | | | | | 122 + * | | | | | | | 123 + * | | | | | | | 124 + * | | +----------------------------+ | | / 125 + * | | | | } Effective bottom margin (9) 126 + * +---+------------------------------------+---+ 127 + * <-> <-> <--------------------------> <-> <-> 128 + * \---- Ignored right margin (4) 129 + * \-------- Effective right margin (9) 130 + * \------------------------- Recommended width (1920) 131 + * \----------------------------------------- Effective left margin (8) 132 + * \--------------------------------------------- Ignored left margin (4) 133 + * 134 + * The optical black lines are output over CSI-2 with a separate data type. 135 + * 136 + * The pixel array is meant to have 1920x1080 usable pixels after image 137 + * processing in an ISP. It has 8 (9) extra active pixels usable for color 138 + * processing in the ISP on the top and left (bottom and right) sides of the 139 + * image. In addition, 4 additional pixels are present on the left and right 140 + * sides of the image, documented as "ignored area". 141 + * 142 + * As far as is understood, all pixels of the pixel array (ignored area, color 143 + * processing margins and recording area) can be output by the sensor. 144 + */ 145 + 146 + #define IMX290_PIXEL_ARRAY_WIDTH 1945 147 + #define IMX290_PIXEL_ARRAY_HEIGHT 1097 148 + #define IMX920_PIXEL_ARRAY_MARGIN_LEFT 12 149 + #define IMX920_PIXEL_ARRAY_MARGIN_RIGHT 13 150 + #define IMX920_PIXEL_ARRAY_MARGIN_TOP 8 151 + #define IMX920_PIXEL_ARRAY_MARGIN_BOTTOM 9 152 + #define IMX290_PIXEL_ARRAY_RECORDING_WIDTH 1920 153 + #define IMX290_PIXEL_ARRAY_RECORDING_HEIGHT 1080 154 + 108 155 static const char * const imx290_supply_name[] = { 109 156 "vdda", 110 157 "vddd", ··· 714 667 return 0; 715 668 } 716 669 670 + static int imx290_get_selection(struct v4l2_subdev *sd, 671 + struct v4l2_subdev_state *sd_state, 672 + struct v4l2_subdev_selection *sel) 673 + { 674 + struct imx290 *imx290 = to_imx290(sd); 675 + struct v4l2_mbus_framefmt *format; 676 + 677 + switch (sel->target) { 678 + case V4L2_SEL_TGT_CROP: { 679 + format = imx290_get_pad_format(imx290, sd_state, sel->which); 680 + 681 + mutex_lock(&imx290->lock); 682 + 683 + sel->r.top = IMX920_PIXEL_ARRAY_MARGIN_TOP 684 + + (IMX290_PIXEL_ARRAY_RECORDING_HEIGHT - format->height) / 2; 685 + sel->r.left = IMX920_PIXEL_ARRAY_MARGIN_LEFT 686 + + (IMX290_PIXEL_ARRAY_RECORDING_WIDTH - format->width) / 2; 687 + sel->r.width = format->width; 688 + sel->r.height = format->height; 689 + 690 + mutex_unlock(&imx290->lock); 691 + return 0; 692 + } 693 + 694 + case V4L2_SEL_TGT_NATIVE_SIZE: 695 + case V4L2_SEL_TGT_CROP_BOUNDS: 696 + sel->r.top = 0; 697 + sel->r.left = 0; 698 + sel->r.width = IMX290_PIXEL_ARRAY_WIDTH; 699 + sel->r.height = IMX290_PIXEL_ARRAY_HEIGHT; 700 + 701 + return 0; 702 + 703 + case V4L2_SEL_TGT_CROP_DEFAULT: 704 + sel->r.top = IMX920_PIXEL_ARRAY_MARGIN_TOP; 705 + sel->r.left = IMX920_PIXEL_ARRAY_MARGIN_LEFT; 706 + sel->r.width = IMX290_PIXEL_ARRAY_RECORDING_WIDTH; 707 + sel->r.height = IMX290_PIXEL_ARRAY_RECORDING_HEIGHT; 708 + 709 + return 0; 710 + 711 + default: 712 + return -EINVAL; 713 + } 714 + } 715 + 717 716 static int imx290_entity_init_cfg(struct v4l2_subdev *subdev, 718 717 struct v4l2_subdev_state *sd_state) 719 718 { ··· 976 883 .enum_frame_size = imx290_enum_frame_size, 977 884 .get_fmt = imx290_get_fmt, 978 885 .set_fmt = imx290_set_fmt, 886 + .get_selection = imx290_get_selection, 979 887 }; 980 888 981 889 static const struct v4l2_subdev_ops imx290_subdev_ops = {