Skip to content

Commit

Permalink
media: staging: rkisp1: add output device for parameters
Browse files Browse the repository at this point in the history
Add the output video driver that accept parameters from userspace.

Signed-off-by: Jacob Chen <[email protected]>
Signed-off-by: Shunqian Zheng <[email protected]>
Signed-off-by: Yichong Zhong <[email protected]>
Signed-off-by: Jacob Chen <[email protected]>
Signed-off-by: Eddie Cai <[email protected]>
Signed-off-by: Jeffy Chen <[email protected]>
Signed-off-by: Allon Huang <[email protected]>
Signed-off-by: Tomasz Figa <[email protected]>
Signed-off-by: Helen Koike <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
wzyy2 authored and mchehab committed Jan 9, 2020
1 parent 9a28dbd commit bae1155
Show file tree
Hide file tree
Showing 5 changed files with 1,717 additions and 16 deletions.
3 changes: 2 additions & 1 deletion drivers/staging/media/rkisp1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ rockchip-isp1-objs += rkisp1-capture.o \
rkisp1-dev.o \
rkisp1-isp.o \
rkisp1-resizer.o \
rkisp1-stats.o
rkisp1-stats.o \
rkisp1-params.o
35 changes: 35 additions & 0 deletions drivers/staging/media/rkisp1/rkisp1-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,27 @@ struct rkisp1_stats {
struct mutex wq_lock;
};

/*
* struct rkisp1_params - ISP input parameters device
*
* @cur_params: Current ISP parameters
* @is_first_params: the first params should take effect immediately
*/
struct rkisp1_params {
struct rkisp1_vdev_node vnode;
struct rkisp1_device *rkisp1;

spinlock_t config_lock;
struct list_head params;
struct rkisp1_params_cfg cur_params;
struct v4l2_format vdev_fmt;
bool is_streaming;
bool is_first_params;

enum v4l2_quantization quantization;
enum rkisp1_fmt_raw_pat_type raw_type;
};

struct rkisp1_resizer {
struct v4l2_subdev sd;
enum rkisp1_stream_id id;
Expand Down Expand Up @@ -222,6 +243,7 @@ struct rkisp1_debug {
* @isp: ISP sub-device
* @rkisp1_capture: capture video device
* @stats: ISP statistics output device
* @params: ISP input parameters device
*/
struct rkisp1_device {
void __iomem *base_addr;
Expand All @@ -238,6 +260,7 @@ struct rkisp1_device {
struct rkisp1_resizer resizer_devs[2];
struct rkisp1_capture capture_devs[2];
struct rkisp1_stats stats;
struct rkisp1_params params;
struct media_pipeline pipe;
struct vb2_alloc_ctx *alloc_ctx;
struct rkisp1_debug debug;
Expand Down Expand Up @@ -287,6 +310,7 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1);
void rkisp1_mipi_isr(struct rkisp1_device *rkisp1);
void rkisp1_capture_isr(struct rkisp1_device *rkisp1);
void rkisp1_stats_isr(struct rkisp1_stats *stats, u32 isp_ris);
void rkisp1_params_isr(struct rkisp1_device *rkisp1, u32 isp_mis);

int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1);
void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1);
Expand All @@ -299,4 +323,15 @@ int rkisp1_stats_register(struct rkisp1_stats *stats,
struct rkisp1_device *rkisp1);
void rkisp1_stats_unregister(struct rkisp1_stats *stats);

void rkisp1_params_configure(struct rkisp1_params *params,
enum rkisp1_fmt_raw_pat_type bayer_pat,
enum v4l2_quantization quantization);
void rkisp1_params_disable(struct rkisp1_params *params);
int rkisp1_params_register(struct rkisp1_params *params,
struct v4l2_device *v4l2_dev,
struct rkisp1_device *rkisp1);
void rkisp1_params_unregister(struct rkisp1_params *params);

void rkisp1_params_isr_handler(struct rkisp1_device *rkisp1, u32 isp_mis);

#endif /* _RKISP1_COMMON_H */
46 changes: 31 additions & 15 deletions drivers/staging/media/rkisp1/rkisp1-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
* | DMA |------------------------------------+ Self Picture Path
* +--------+
*
* rkisp1-stats.c
* |===============|
* +---------------+
* | |
* | ISP |
* | |
* +---------------+
* rkisp1-stats.c rkisp1-params.c
* |===============| |===============|
* +---------------+ +---------------+
* | | | |
* | ISP | | ISP |
* | | | |
* +---------------+ +---------------+
*
*
* Media Topology
Expand All @@ -72,13 +72,13 @@
* | Sensor 2 | | Sensor X |
* ------------ ... ------------
* | 0 | | 0 |
* +----------+ +----------+
* \ |
* \ |
* +----------+ \ |
* | Sensor 1 | v v
* ------------ +------+------+
* | 0 |----->| 0 | 1 |
* +----------+ +----------+ +-----------+
* \ | | params |
* \ | | (output) |
* +----------+ \ | +-----------+
* | Sensor 1 | v v |
* ------------ +------+------+ |
* | 0 |----->| 0 | 1 |<---------+
* +----------+ |------+------|
* | ISP |
* |------+------|
Expand Down Expand Up @@ -164,6 +164,14 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1)
return ret;
}

/* params links */
source = &rkisp1->params.vnode.vdev.entity;
sink = &rkisp1->isp.sd.entity;
ret = media_create_pad_link(source, 0, sink,
RKISP1_ISP_PAD_SINK_PARAMS, flags);
if (ret)
return ret;

/* 3A stats links */
source = &rkisp1->isp.sd.entity;
sink = &rkisp1->stats.vnode.vdev.entity;
Expand Down Expand Up @@ -352,14 +360,21 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1)
if (ret)
goto err_unreg_capture_devs;

ret = rkisp1_params_register(&rkisp1->params,
&rkisp1->v4l2_dev, rkisp1);
if (ret)
goto err_unreg_stats;

ret = rkisp1_subdev_notifier(rkisp1);
if (ret) {
dev_err(rkisp1->dev,
"Failed to register subdev notifier(%d)\n", ret);
goto err_unreg_stats;
goto err_unreg_params;
}

return 0;
err_unreg_params:
rkisp1_params_unregister(&rkisp1->params);
err_unreg_stats:
rkisp1_stats_unregister(&rkisp1->stats);
err_unreg_capture_devs:
Expand Down Expand Up @@ -529,6 +544,7 @@ static int rkisp1_remove(struct platform_device *pdev)
v4l2_async_notifier_unregister(&rkisp1->notifier);
v4l2_async_notifier_cleanup(&rkisp1->notifier);

rkisp1_params_unregister(&rkisp1->params);
rkisp1_stats_unregister(&rkisp1->stats);
rkisp1_capture_devs_unregister(rkisp1);
rkisp1_resizer_devs_unregister(rkisp1);
Expand Down
19 changes: 19 additions & 0 deletions drivers/staging/media/rkisp1/rkisp1-isp.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,18 @@ static int rkisp1_config_isp(struct rkisp1_device *rkisp1)
RKISP1_CIF_ISP_PIC_SIZE_ERROR | RKISP1_CIF_ISP_FRAME_IN;
rkisp1_write(rkisp1, irq_mask, RKISP1_CIF_ISP_IMSC);

if (src_fmt->fmt_type == RKISP1_FMT_BAYER) {
rkisp1_params_disable(&rkisp1->params);
} else {
struct v4l2_mbus_framefmt *src_frm;

src_frm = rkisp1_isp_get_pad_fmt(&rkisp1->isp, NULL,
RKISP1_ISP_PAD_SINK_VIDEO,
V4L2_SUBDEV_FORMAT_ACTIVE);
rkisp1_params_configure(&rkisp1->params, sink_fmt->bayer_pat,
src_frm->quantization);
}

return 0;
}

Expand Down Expand Up @@ -1142,4 +1154,11 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1)
RKISP1_CIF_ISP_HIST_MEASURE_RDY))
rkisp1_stats_isr(&rkisp1->stats, isp_ris);
}

/*
* Then update changed configs. Some of them involve
* lot of register writes. Do those only one per frame.
* Do the updates in the order of the processing flow.
*/
rkisp1_params_isr(rkisp1, status);
}
Loading

0 comments on commit bae1155

Please sign in to comment.