soc_scale_crop.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef SOC_SCALE_CROP_H
  12. #define SOC_SCALE_CROP_H
  13. #include <linux/kernel.h>
  14. struct soc_camera_device;
  15. struct v4l2_crop;
  16. struct v4l2_mbus_framefmt;
  17. struct v4l2_pix_format;
  18. struct v4l2_rect;
  19. struct v4l2_subdev;
  20. static inline unsigned int soc_camera_shift_scale(unsigned int size,
  21. unsigned int shift, unsigned int scale)
  22. {
  23. return DIV_ROUND_CLOSEST(size << shift, scale);
  24. }
  25. #define soc_camera_calc_scale(in, shift, out) soc_camera_shift_scale(in, shift, out)
  26. int soc_camera_client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect);
  27. int soc_camera_client_s_crop(struct v4l2_subdev *sd,
  28. struct v4l2_crop *crop, struct v4l2_crop *cam_crop,
  29. struct v4l2_rect *target_rect, struct v4l2_rect *subrect);
  30. int soc_camera_client_scale(struct soc_camera_device *icd,
  31. struct v4l2_rect *rect, struct v4l2_rect *subrect,
  32. struct v4l2_mbus_framefmt *mf,
  33. unsigned int *width, unsigned int *height,
  34. bool host_can_scale, unsigned int shift);
  35. void soc_camera_calc_client_output(struct soc_camera_device *icd,
  36. struct v4l2_rect *rect, struct v4l2_rect *subrect,
  37. const struct v4l2_pix_format *pix, struct v4l2_mbus_framefmt *mf,
  38. unsigned int shift);
  39. #endif