Skip to content

Commit 2db6cad

Browse files
Rahi374pinchartl
authored andcommitted
media: rkisp1: Support devices lacking dual crop
Some versions of the ISP supported by the rkisp1 driver, such as the ISP in the i.MX8MP, lack the dual crop registers and don't support cropping at the resizer input. They instead rely on cropping in the Image Stabilization module, at the output of the ISP, to modify the resizer input size and implement digital zoom. Add a dual crop feature flag to distinguish the versions of the ISP that support dual crop from those that don't, and make sure that the sink crop is set to the sink format when dual crop is not supported. Signed-off-by: Paul Elder <[email protected]> Tested-by: Alexander Stein <[email protected]> Tested-by: Adam Ford <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Laurent Pinchart <[email protected]>
1 parent 8275408 commit 2db6cad

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

drivers/media/platform/rockchip/rkisp1/rkisp1-common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ enum rkisp1_isp_pad {
112112
* @RKISP1_FEATURE_MIPI_CSI2: The ISP has an internal MIPI CSI-2 receiver
113113
* @RKISP1_FEATURE_MAIN_STRIDE: The ISP supports configurable stride on the main path
114114
* @RKISP1_FEATURE_SELF_PATH: The ISP has a self path
115+
* @RKISP1_FEATURE_DUAL_CROP: The ISP has the dual crop block at the resizer input
115116
*
116117
* The ISP features are stored in a bitmask in &rkisp1_info.features and allow
117118
* the driver to implement support for features present in some ISP versions
@@ -121,6 +122,7 @@ enum rkisp1_feature {
121122
RKISP1_FEATURE_MIPI_CSI2 = BIT(0),
122123
RKISP1_FEATURE_MAIN_STRIDE = BIT(1),
123124
RKISP1_FEATURE_SELF_PATH = BIT(2),
125+
RKISP1_FEATURE_DUAL_CROP = BIT(3),
124126
};
125127

126128
#define rkisp1_has_feature(rkisp1, feature) \

drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ static const struct rkisp1_info px30_isp_info = {
485485
.isr_size = ARRAY_SIZE(px30_isp_isrs),
486486
.isp_ver = RKISP1_V12,
487487
.features = RKISP1_FEATURE_MIPI_CSI2
488-
| RKISP1_FEATURE_SELF_PATH,
488+
| RKISP1_FEATURE_SELF_PATH
489+
| RKISP1_FEATURE_DUAL_CROP,
489490
};
490491

491492
static const char * const rk3399_isp_clks[] = {
@@ -505,7 +506,8 @@ static const struct rkisp1_info rk3399_isp_info = {
505506
.isr_size = ARRAY_SIZE(rk3399_isp_isrs),
506507
.isp_ver = RKISP1_V10,
507508
.features = RKISP1_FEATURE_MIPI_CSI2
508-
| RKISP1_FEATURE_SELF_PATH,
509+
| RKISP1_FEATURE_SELF_PATH
510+
| RKISP1_FEATURE_DUAL_CROP,
509511
};
510512

511513
static const struct of_device_id rkisp1_of_match[] = {

drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,12 @@ static void rkisp1_rsz_set_sink_crop(struct rkisp1_resizer *rsz,
444444
sink_fmt = v4l2_subdev_state_get_format(sd_state, RKISP1_RSZ_PAD_SINK);
445445
sink_crop = v4l2_subdev_state_get_crop(sd_state, RKISP1_RSZ_PAD_SINK);
446446

447-
/* Not crop for MP bayer raw data */
447+
/* Not crop for MP bayer raw data, or for devices lacking dual crop. */
448448
mbus_info = rkisp1_mbus_info_get_by_code(sink_fmt->code);
449449

450-
if (rsz->id == RKISP1_MAINPATH &&
451-
mbus_info->pixel_enc == V4L2_PIXEL_ENC_BAYER) {
450+
if ((rsz->id == RKISP1_MAINPATH &&
451+
mbus_info->pixel_enc == V4L2_PIXEL_ENC_BAYER) ||
452+
!rkisp1_has_feature(rsz->rkisp1, DUAL_CROP)) {
452453
sink_crop->left = 0;
453454
sink_crop->top = 0;
454455
sink_crop->width = sink_fmt->width;
@@ -635,7 +636,8 @@ static int rkisp1_rsz_s_stream(struct v4l2_subdev *sd, int enable)
635636
struct v4l2_subdev_state *sd_state;
636637

637638
if (!enable) {
638-
rkisp1_dcrop_disable(rsz, RKISP1_SHADOW_REGS_ASYNC);
639+
if (rkisp1_has_feature(rkisp1, DUAL_CROP))
640+
rkisp1_dcrop_disable(rsz, RKISP1_SHADOW_REGS_ASYNC);
639641
rkisp1_rsz_disable(rsz, RKISP1_SHADOW_REGS_ASYNC);
640642
return 0;
641643
}
@@ -646,7 +648,8 @@ static int rkisp1_rsz_s_stream(struct v4l2_subdev *sd, int enable)
646648
sd_state = v4l2_subdev_lock_and_get_active_state(sd);
647649

648650
rkisp1_rsz_config(rsz, sd_state, when);
649-
rkisp1_dcrop_config(rsz, sd_state);
651+
if (rkisp1_has_feature(rkisp1, DUAL_CROP))
652+
rkisp1_dcrop_config(rsz, sd_state);
650653

651654
v4l2_subdev_unlock_state(sd_state);
652655

0 commit comments

Comments
 (0)