summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2023-05-29 11:37:37 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2023-06-09 15:34:49 +0100
commit62866c23c78d2c5db85bf82d61d8801aa9e93176 (patch)
tree11da436b6651e672968d78184078931d6c9727c7 /drivers/staging
parenta08183b8460e4800c186b754026b6fd937370871 (diff)
media: atomisp: Make atomisp_init_sensor() check if the sensor supports binning
Make atomisp_init_sensor() check if the sensor supports binning. This is a preparation patch for using the selection / crop support to determine the padding values to use with a specific sensor. Link: https://lore.kernel.org/r/20230529103741.11904-18-hdegoede@redhat.com Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp_internal.h1
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp_v4l2.c30
2 files changed, 28 insertions, 3 deletions
diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp_internal.h
index 9fded17a2c71..f7b4bee9574b 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_internal.h
+++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h
@@ -126,6 +126,7 @@ struct atomisp_input_subdev {
unsigned int type;
enum atomisp_camera_port port;
u32 code; /* MEDIA_BUS_FMT_* */
+ bool binning_support;
bool crop_support;
struct v4l2_subdev *camera;
/* Sensor rects for sensors which support crop */
diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 3a2e15605919..c43b916a006e 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -934,11 +934,12 @@ v4l2_device_failed:
static void atomisp_init_sensor(struct atomisp_input_subdev *input)
{
struct v4l2_subdev_mbus_code_enum mbus_code_enum = { };
+ struct v4l2_subdev_frame_size_enum fse = { };
struct v4l2_subdev_state sd_state = {
.pads = &input->pad_cfg,
};
struct v4l2_subdev_selection sel = { };
- int err;
+ int i, err;
mbus_code_enum.which = V4L2_SUBDEV_FORMAT_ACTIVE;
err = v4l2_subdev_call(input->camera, pad, enum_mbus_code, NULL, &mbus_code_enum);
@@ -962,6 +963,28 @@ static void atomisp_init_sensor(struct atomisp_input_subdev *input)
input->active_rect = sel.r;
/*
+ * Check for a framesize with half active_rect width and height,
+ * if found assume the sensor supports binning.
+ * Do this before changing the crop-rect since that may influence
+ * enum_frame_size results.
+ */
+ for (i = 0; ; i++) {
+ fse.index = i;
+ fse.code = input->code;
+ fse.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+
+ err = v4l2_subdev_call(input->camera, pad, enum_frame_size, NULL, &fse);
+ if (err)
+ break;
+
+ if (fse.min_width <= (input->active_rect.width / 2) &&
+ fse.min_height <= (input->active_rect.height / 2)) {
+ input->binning_support = true;
+ break;
+ }
+ }
+
+ /*
* The ISP also wants the non-active pixels at the border of the sensor
* for padding, set the crop rect to cover the entire sensor instead
* of only the default active area.
@@ -983,9 +1006,10 @@ static void atomisp_init_sensor(struct atomisp_input_subdev *input)
if (err)
return;
- dev_info(input->camera->dev, "Supports crop native %dx%d active %dx%d\n",
+ dev_info(input->camera->dev, "Supports crop native %dx%d active %dx%d binning %d\n",
input->native_rect.width, input->native_rect.height,
- input->active_rect.width, input->active_rect.height);
+ input->active_rect.width, input->active_rect.height,
+ input->binning_support);
input->crop_support = true;
}