Commit 22e0099a authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab

[media] V4L2: soc-camera: move generic functions into a separate file

The sh_mobile_ceu_camera driver implements a generic algorithm for setting
up an optimal client and host scaling and cropping configuration. This
patch makes those functions available for all drivers.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent eca430c8
......@@ -8,6 +8,9 @@ config SOC_CAMERA
over a bus like PCI or USB. For example some i2c camera connected
directly to the data bus of an SoC.
config SOC_CAMERA_SCALE_CROP
tristate
config SOC_CAMERA_PLATFORM
tristate "platform camera support"
depends on SOC_CAMERA
......@@ -51,6 +54,7 @@ config VIDEO_SH_MOBILE_CEU
tristate "SuperH Mobile CEU Interface driver"
depends on VIDEO_DEV && SOC_CAMERA && HAS_DMA && HAVE_CLK
select VIDEOBUF2_DMA_CONTIG
select SOC_CAMERA_SCALE_CROP
---help---
This is a v4l2 driver for the SuperH Mobile CEU Interface
......
obj-$(CONFIG_SOC_CAMERA) += soc_camera.o soc_mediabus.o
obj-$(CONFIG_SOC_CAMERA_SCALE_CROP) += soc_scale_crop.o
# a platform subdevice driver stub, allowing to support cameras by adding a
# couple of callback functions to the board code
obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o
# soc-camera host drivers have to be linked after camera drivers
......
This diff is collapsed.
/*
* soc-camera generic scaling-cropping manipulation functions
*
* Copyright (C) 2013 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef SOC_SCALE_CROP_H
#define SOC_SCALE_CROP_H
#include <linux/kernel.h>
struct soc_camera_device;
struct v4l2_crop;
struct v4l2_mbus_framefmt;
struct v4l2_pix_format;
struct v4l2_rect;
struct v4l2_subdev;
static inline unsigned int soc_camera_shift_scale(unsigned int size,
unsigned int shift, unsigned int scale)
{
return DIV_ROUND_CLOSEST(size << shift, scale);
}
#define soc_camera_calc_scale(in, shift, out) soc_camera_shift_scale(in, shift, out)
int soc_camera_client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect);
int soc_camera_client_s_crop(struct v4l2_subdev *sd,
struct v4l2_crop *crop, struct v4l2_crop *cam_crop,
struct v4l2_rect *target_rect, struct v4l2_rect *subrect);
int soc_camera_client_scale(struct soc_camera_device *icd,
struct v4l2_rect *rect, struct v4l2_rect *subrect,
struct v4l2_mbus_framefmt *mf,
unsigned int *width, unsigned int *height,
bool host_can_scale, unsigned int shift);
void soc_camera_calc_client_output(struct soc_camera_device *icd,
struct v4l2_rect *rect, struct v4l2_rect *subrect,
const struct v4l2_pix_format *pix, struct v4l2_mbus_framefmt *mf,
unsigned int shift);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment