Skip to content

Commit

Permalink
[media] omap3isp: preview: Add support for greyscale input
Browse files Browse the repository at this point in the history
Configure CFA interpolation automatically based on the input format.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Laurent Pinchart authored and Mauro Carvalho Chehab committed May 8, 2012
1 parent 6173850 commit b2da46e
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions drivers/media/video/omap3isp/isppreview.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,23 +440,6 @@ preview_enable_dcor(struct isp_prev_device *prev, u8 enable)
ISPPRV_PCR_DCOREN);
}

/*
* preview_enable_cfa - Enable/Disable the CFA Interpolation.
* @enable: 1 - Enables the CFA.
*/
static void
preview_enable_cfa(struct isp_prev_device *prev, u8 enable)
{
struct isp_device *isp = to_isp_device(prev);

if (enable)
isp_reg_set(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR,
ISPPRV_PCR_CFAEN);
else
isp_reg_clr(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR,
ISPPRV_PCR_CFAEN);
}

/*
* preview_enable_gammabypass - Enables/Disables the GammaByPass
* @enable: 1 - Bypasses Gamma - 10bit input is cropped to 8MSB.
Expand Down Expand Up @@ -831,7 +814,7 @@ static const struct preview_update update_attrs[] = {
offsetof(struct omap3isp_prev_update_config, hmed),
}, /* OMAP3ISP_PREV_CFA */ {
preview_config_cfa,
preview_enable_cfa,
NULL,
offsetof(struct prev_params, cfa),
FIELD_SIZEOF(struct prev_params, cfa),
offsetof(struct omap3isp_prev_update_config, cfa),
Expand Down Expand Up @@ -1077,6 +1060,27 @@ static void preview_config_averager(struct isp_prev_device *prev, u8 average)
isp_reg_writel(isp, reg, OMAP3_ISP_IOMEM_PREV, ISPPRV_AVE);
}

/*
* preview_config_input_format - Configure the input format
* @prev: The preview engine
* @format: Format on the preview engine sink pad
*
* Enable CFA interpolation for Bayer formats and disable it for greyscale
* formats.
*/
static void preview_config_input_format(struct isp_prev_device *prev,
const struct v4l2_mbus_framefmt *format)
{
struct isp_device *isp = to_isp_device(prev);

if (format->code != V4L2_MBUS_FMT_Y10_1X10)
isp_reg_set(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR,
ISPPRV_PCR_CFAEN);
else
isp_reg_clr(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR,
ISPPRV_PCR_CFAEN);
}

/*
* preview_config_input_size - Configure the input frame size
*
Expand All @@ -1090,22 +1094,24 @@ static void preview_config_averager(struct isp_prev_device *prev, u8 average)
*/
static void preview_config_input_size(struct isp_prev_device *prev, u32 active)
{
const struct v4l2_mbus_framefmt *format = &prev->formats[PREV_PAD_SINK];
struct isp_device *isp = to_isp_device(prev);
unsigned int sph = prev->crop.left;
unsigned int eph = prev->crop.left + prev->crop.width - 1;
unsigned int slv = prev->crop.top;
unsigned int elv = prev->crop.top + prev->crop.height - 1;
u32 features;

features = (prev->params.params[0].features & active)
| (prev->params.params[1].features & ~active);

if (features & OMAP3ISP_PREV_CFA) {
if (format->code == V4L2_MBUS_FMT_Y10_1X10) {
sph -= 2;
eph += 2;
slv -= 2;
elv += 2;
}

features = (prev->params.params[0].features & active)
| (prev->params.params[1].features & ~active);

if (features & (OMAP3ISP_PREV_DEFECT_COR | OMAP3ISP_PREV_NF)) {
sph -= 2;
eph += 2;
Expand Down Expand Up @@ -1436,6 +1442,7 @@ static void preview_configure(struct isp_prev_device *prev)

preview_adjust_bandwidth(prev);

preview_config_input_format(prev, format);
preview_config_input_size(prev, active);

if (prev->input == PREVIEW_INPUT_CCDC)
Expand Down Expand Up @@ -1723,6 +1730,7 @@ __preview_get_crop(struct isp_prev_device *prev, struct v4l2_subdev_fh *fh,

/* previewer format descriptions */
static const unsigned int preview_input_fmts[] = {
V4L2_MBUS_FMT_Y10_1X10,
V4L2_MBUS_FMT_SGRBG10_1X10,
V4L2_MBUS_FMT_SRGGB10_1X10,
V4L2_MBUS_FMT_SBGGR10_1X10,
Expand Down

0 comments on commit b2da46e

Please sign in to comment.