Skip to content

Commit 8275408

Browse files
Rahi374pinchartl
authored andcommitted
media: rkisp1: Support devices lacking self path
Some versions of the ISP supported by the rkisp1 driver, such as the ISP in the i.MX8MP, lack the self path. Support those ISP versions by adding a self path feature flag, and massage the rest of the driver to support the lack of a self path. Signed-off-by: Paul Elder <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Tested-by: Alexander Stein <[email protected]> Tested-by: Adam Ford <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Signed-off-by: Laurent Pinchart <[email protected]>
1 parent bcb40cc commit 8275408

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ irqreturn_t rkisp1_capture_isr(int irq, void *ctx)
730730
{
731731
struct device *dev = ctx;
732732
struct rkisp1_device *rkisp1 = dev_get_drvdata(dev);
733+
unsigned int dev_count = rkisp1_path_count(rkisp1);
733734
unsigned int i;
734735
u32 status;
735736

@@ -739,7 +740,7 @@ irqreturn_t rkisp1_capture_isr(int irq, void *ctx)
739740

740741
rkisp1_write(rkisp1, RKISP1_CIF_MI_ICR, status);
741742

742-
for (i = 0; i < ARRAY_SIZE(rkisp1->capture_devs); ++i) {
743+
for (i = 0; i < dev_count; ++i) {
743744
struct rkisp1_capture *cap = &rkisp1->capture_devs[i];
744745

745746
if (!(status & RKISP1_CIF_MI_FRAME(cap)))
@@ -896,6 +897,7 @@ static void rkisp1_cap_stream_enable(struct rkisp1_capture *cap)
896897
{
897898
struct rkisp1_device *rkisp1 = cap->rkisp1;
898899
struct rkisp1_capture *other = &rkisp1->capture_devs[cap->id ^ 1];
900+
bool has_self_path = rkisp1_has_feature(rkisp1, SELF_PATH);
899901

900902
cap->ops->set_data_path(cap);
901903
cap->ops->config(cap);
@@ -913,7 +915,7 @@ static void rkisp1_cap_stream_enable(struct rkisp1_capture *cap)
913915
* This's also required because the second FE maybe corrupt
914916
* especially when run at 120fps.
915917
*/
916-
if (!other->is_streaming) {
918+
if (!has_self_path || !other->is_streaming) {
917919
/* force cfg update */
918920
rkisp1_write(rkisp1, RKISP1_CIF_MI_INIT,
919921
RKISP1_CIF_MI_INIT_SOFT_UPD);
@@ -1506,10 +1508,11 @@ rkisp1_capture_init(struct rkisp1_device *rkisp1, enum rkisp1_stream_id id)
15061508

15071509
int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1)
15081510
{
1511+
unsigned int dev_count = rkisp1_path_count(rkisp1);
15091512
unsigned int i;
15101513
int ret;
15111514

1512-
for (i = 0; i < ARRAY_SIZE(rkisp1->capture_devs); i++) {
1515+
for (i = 0; i < dev_count; i++) {
15131516
struct rkisp1_capture *cap = &rkisp1->capture_devs[i];
15141517

15151518
rkisp1_capture_init(rkisp1, i);

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ enum rkisp1_isp_pad {
111111
*
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
114+
* @RKISP1_FEATURE_SELF_PATH: The ISP has a self path
114115
*
115116
* The ISP features are stored in a bitmask in &rkisp1_info.features and allow
116117
* the driver to implement support for features present in some ISP versions
@@ -119,6 +120,7 @@ enum rkisp1_isp_pad {
119120
enum rkisp1_feature {
120121
RKISP1_FEATURE_MIPI_CSI2 = BIT(0),
121122
RKISP1_FEATURE_MAIN_STRIDE = BIT(1),
123+
RKISP1_FEATURE_SELF_PATH = BIT(2),
122124
};
123125

124126
#define rkisp1_has_feature(rkisp1, feature) \
@@ -529,6 +531,19 @@ int rkisp1_cap_enum_mbus_codes(struct rkisp1_capture *cap,
529531
*/
530532
const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_index(unsigned int index);
531533

534+
/*
535+
* rkisp1_path_count - Return the number of paths supported by the device
536+
*
537+
* Some devices only have a main path, while other device have both a main path
538+
* and a self path. This function returns the number of paths that this device
539+
* has, based on the feature flags. It should be used insted of checking
540+
* ARRAY_SIZE of capture_devs/resizer_devs.
541+
*/
542+
static inline unsigned int rkisp1_path_count(struct rkisp1_device *rkisp1)
543+
{
544+
return rkisp1_has_feature(rkisp1, SELF_PATH) ? 2 : 1;
545+
}
546+
532547
/*
533548
* rkisp1_sd_adjust_crop_rect - adjust a rectangle to fit into another rectangle.
534549
*

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ static const struct dev_pm_ops rkisp1_pm_ops = {
336336

337337
static int rkisp1_create_links(struct rkisp1_device *rkisp1)
338338
{
339+
unsigned int dev_count = rkisp1_path_count(rkisp1);
339340
unsigned int i;
340341
int ret;
341342

@@ -351,7 +352,7 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1)
351352
}
352353

353354
/* create ISP->RSZ->CAP links */
354-
for (i = 0; i < 2; i++) {
355+
for (i = 0; i < dev_count; i++) {
355356
struct media_entity *resizer =
356357
&rkisp1->resizer_devs[i].sd.entity;
357358
struct media_entity *capture =
@@ -483,7 +484,8 @@ static const struct rkisp1_info px30_isp_info = {
483484
.isrs = px30_isp_isrs,
484485
.isr_size = ARRAY_SIZE(px30_isp_isrs),
485486
.isp_ver = RKISP1_V12,
486-
.features = RKISP1_FEATURE_MIPI_CSI2,
487+
.features = RKISP1_FEATURE_MIPI_CSI2
488+
| RKISP1_FEATURE_SELF_PATH,
487489
};
488490

489491
static const char * const rk3399_isp_clks[] = {
@@ -502,7 +504,8 @@ static const struct rkisp1_info rk3399_isp_info = {
502504
.isrs = rk3399_isp_isrs,
503505
.isr_size = ARRAY_SIZE(rk3399_isp_isrs),
504506
.isp_ver = RKISP1_V10,
505-
.features = RKISP1_FEATURE_MIPI_CSI2,
507+
.features = RKISP1_FEATURE_MIPI_CSI2
508+
| RKISP1_FEATURE_SELF_PATH,
506509
};
507510

508511
static const struct of_device_id rkisp1_of_match[] = {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ static int rkisp1_rsz_s_stream(struct v4l2_subdev *sd, int enable)
631631
struct rkisp1_device *rkisp1 = rsz->rkisp1;
632632
struct rkisp1_capture *other = &rkisp1->capture_devs[rsz->id ^ 1];
633633
enum rkisp1_shadow_regs_when when = RKISP1_SHADOW_REGS_SYNC;
634+
bool has_self_path = rkisp1_has_feature(rkisp1, SELF_PATH);
634635
struct v4l2_subdev_state *sd_state;
635636

636637
if (!enable) {
@@ -639,7 +640,7 @@ static int rkisp1_rsz_s_stream(struct v4l2_subdev *sd, int enable)
639640
return 0;
640641
}
641642

642-
if (other->is_streaming)
643+
if (has_self_path && other->is_streaming)
643644
when = RKISP1_SHADOW_REGS_ASYNC;
644645

645646
sd_state = v4l2_subdev_lock_and_get_active_state(sd);
@@ -731,10 +732,11 @@ static int rkisp1_rsz_register(struct rkisp1_resizer *rsz)
731732

732733
int rkisp1_resizer_devs_register(struct rkisp1_device *rkisp1)
733734
{
735+
unsigned int dev_count = rkisp1_path_count(rkisp1);
734736
unsigned int i;
735737
int ret;
736738

737-
for (i = 0; i < ARRAY_SIZE(rkisp1->resizer_devs); i++) {
739+
for (i = 0; i < dev_count; i++) {
738740
struct rkisp1_resizer *rsz = &rkisp1->resizer_devs[i];
739741

740742
rsz->rkisp1 = rkisp1;

0 commit comments

Comments
 (0)