Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / media / platform / soc_camera / soc_scale_crop.h
1 /*
2  * soc-camera generic scaling-cropping manipulation functions
3  *
4  * Copyright (C) 2013 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
5  *
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.
10  */
11
12 #ifndef SOC_SCALE_CROP_H
13 #define SOC_SCALE_CROP_H
14
15 #include <linux/kernel.h>
16
17 struct soc_camera_device;
18
19 struct v4l2_crop;
20 struct v4l2_mbus_framefmt;
21 struct v4l2_pix_format;
22 struct v4l2_rect;
23 struct v4l2_subdev;
24
25 static inline unsigned int soc_camera_shift_scale(unsigned int size,
26                                 unsigned int shift, unsigned int scale)
27 {
28         return DIV_ROUND_CLOSEST(size << shift, scale);
29 }
30
31 #define soc_camera_calc_scale(in, shift, out) soc_camera_shift_scale(in, shift, out)
32
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,
45                 unsigned int shift);
46
47 #endif