2 * soc-camera generic scaling-cropping manipulation functions
4 * Copyright (C) 2013 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #ifndef SOC_SCALE_CROP_H
13 #define SOC_SCALE_CROP_H
15 #include <linux/kernel.h>
17 struct soc_camera_device
;
20 struct v4l2_mbus_framefmt
;
21 struct v4l2_pix_format
;
25 static inline unsigned int soc_camera_shift_scale(unsigned int size
,
26 unsigned int shift
, unsigned int scale
)
28 return DIV_ROUND_CLOSEST(size
<< shift
, scale
);
31 #define soc_camera_calc_scale(in, shift, out) soc_camera_shift_scale(in, shift, out)
33 int soc_camera_client_g_rect(struct v4l2_subdev
*sd
, struct v4l2_rect
*rect
);
34 int soc_camera_client_s_crop(struct v4l2_subdev
*sd
,
35 struct v4l2_crop
*crop
, struct v4l2_crop
*cam_crop
,
36 struct v4l2_rect
*target_rect
, struct v4l2_rect
*subrect
);
37 int soc_camera_client_scale(struct soc_camera_device
*icd
,
38 struct v4l2_rect
*rect
, struct v4l2_rect
*subrect
,
39 struct v4l2_mbus_framefmt
*mf
,
40 unsigned int *width
, unsigned int *height
,
41 bool host_can_scale
, unsigned int shift
);
42 void soc_camera_calc_client_output(struct soc_camera_device
*icd
,
43 struct v4l2_rect
*rect
, struct v4l2_rect
*subrect
,
44 const struct v4l2_pix_format
*pix
, struct v4l2_mbus_framefmt
*mf
,