mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
drivers: media: imx219: Remove enum binning_mode
The enum binning_mode is redundant, it only uses values from the earlier defined binning modes. Remove it. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
This commit is contained in:
committed by
Dom Cobley
parent
9927f42c02
commit
a01183e1bb
@@ -400,42 +400,57 @@ static u32 imx219_get_format_bpp(const struct v4l2_mbus_framefmt *format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void imx219_get_binning(struct v4l2_subdev_state *state, u8 *bin_h,
|
static unsigned int imx219_get_binning(struct v4l2_subdev_state *state,
|
||||||
u8 *bin_v)
|
u8 *bin_h, u8 *bin_v)
|
||||||
{
|
{
|
||||||
const struct v4l2_mbus_framefmt *format =
|
const struct v4l2_mbus_framefmt *format =
|
||||||
v4l2_subdev_state_get_format(state, 0);
|
v4l2_subdev_state_get_format(state, 0);
|
||||||
const struct v4l2_rect *crop = v4l2_subdev_state_get_crop(state, 0);
|
unsigned int bin_mode = IMX219_BINNING_NONE;
|
||||||
u32 hbin = crop->width / format->width;
|
const struct imx219_mode *mode =
|
||||||
u32 vbin = crop->height / format->height;
|
v4l2_find_nearest_size(supported_modes,
|
||||||
|
ARRAY_SIZE(supported_modes),
|
||||||
|
width, height,
|
||||||
|
format->width, format->height);
|
||||||
|
switch (format->code) {
|
||||||
|
case MEDIA_BUS_FMT_SRGGB8_1X8:
|
||||||
|
case MEDIA_BUS_FMT_SGRBG8_1X8:
|
||||||
|
case MEDIA_BUS_FMT_SGBRG8_1X8:
|
||||||
|
case MEDIA_BUS_FMT_SBGGR8_1X8:
|
||||||
|
bin_mode = mode->binning[BINNING_IDX_8_BIT];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MEDIA_BUS_FMT_SRGGB10_1X10:
|
||||||
|
case MEDIA_BUS_FMT_SGRBG10_1X10:
|
||||||
|
case MEDIA_BUS_FMT_SGBRG10_1X10:
|
||||||
|
case MEDIA_BUS_FMT_SBGGR10_1X10:
|
||||||
|
bin_mode = mode->binning[BINNING_IDX_10_BIT];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
*bin_h = IMX219_BINNING_NONE;
|
*bin_h = IMX219_BINNING_NONE;
|
||||||
*bin_v = IMX219_BINNING_NONE;
|
*bin_v = IMX219_BINNING_NONE;
|
||||||
|
|
||||||
/*
|
if (*bin_h == 2 && *bin_v == 2)
|
||||||
* Use analog binning only if both dimensions are binned, as it crops
|
return IMX219_BINNING_X2_ANALOG;
|
||||||
* the other dimension.
|
else if (*bin_h == 2 || *bin_v == 2)
|
||||||
*/
|
/*
|
||||||
if (hbin == 2 && vbin == 2) {
|
* Don't use analog binning if only one dimension
|
||||||
*bin_h = IMX219_BINNING_X2_ANALOG;
|
* is binned, as it crops the other dimension
|
||||||
*bin_v = IMX219_BINNING_X2_ANALOG;
|
*/
|
||||||
|
return IMX219_BINNING_X2;
|
||||||
return;
|
else
|
||||||
}
|
return IMX219_BINNING_NONE;
|
||||||
|
|
||||||
if (hbin == 2)
|
|
||||||
*bin_h = IMX219_BINNING_X2;
|
|
||||||
if (vbin == 2)
|
|
||||||
*bin_v = IMX219_BINNING_X2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 imx219_get_rate_factor(struct v4l2_subdev_state *state)
|
static inline u32 imx219_get_rate_factor(struct v4l2_subdev_state *state)
|
||||||
{
|
{
|
||||||
u8 bin_h, bin_v;
|
u8 bin_h, bin_v;
|
||||||
|
unsigned int binning = imx219_get_binning(state, &bin_h, &bin_v);
|
||||||
|
|
||||||
imx219_get_binning(state, &bin_h, &bin_v);
|
if (binning == IMX219_BINNING_X2_ANALOG)
|
||||||
|
return 2;
|
||||||
|
|
||||||
return (bin_h & bin_v) == IMX219_BINNING_X2_ANALOG ? 2 : 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
@@ -671,6 +686,7 @@ static int imx219_set_framefmt(struct imx219 *imx219,
|
|||||||
{
|
{
|
||||||
const struct v4l2_mbus_framefmt *format;
|
const struct v4l2_mbus_framefmt *format;
|
||||||
const struct v4l2_rect *crop;
|
const struct v4l2_rect *crop;
|
||||||
|
unsigned int binning;
|
||||||
u8 bin_h, bin_v;
|
u8 bin_h, bin_v;
|
||||||
u32 bpp;
|
u32 bpp;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@@ -688,9 +704,11 @@ static int imx219_set_framefmt(struct imx219 *imx219,
|
|||||||
cci_write(imx219->regmap, IMX219_REG_Y_ADD_END_A,
|
cci_write(imx219->regmap, IMX219_REG_Y_ADD_END_A,
|
||||||
crop->top - IMX219_PIXEL_ARRAY_TOP + crop->height - 1, &ret);
|
crop->top - IMX219_PIXEL_ARRAY_TOP + crop->height - 1, &ret);
|
||||||
|
|
||||||
imx219_get_binning(state, &bin_h, &bin_v);
|
binning = imx219_get_binning(state, &bin_h, &bin_v);
|
||||||
cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_H, bin_h, &ret);
|
cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_H,
|
||||||
cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_V, bin_v, &ret);
|
(bin_h == 2) ? binning : IMX219_BINNING_NONE, &ret);
|
||||||
|
cci_write(imx219->regmap, IMX219_REG_BINNING_MODE_V,
|
||||||
|
(bin_v == 2) ? binning : IMX219_BINNING_NONE, &ret);
|
||||||
|
|
||||||
cci_write(imx219->regmap, IMX219_REG_X_OUTPUT_SIZE,
|
cci_write(imx219->regmap, IMX219_REG_X_OUTPUT_SIZE,
|
||||||
format->width, &ret);
|
format->width, &ret);
|
||||||
|
|||||||
Reference in New Issue
Block a user