Commit bae1155c authored by Jacob Chen's avatar Jacob Chen Committed by Mauro Carvalho Chehab

media: staging: rkisp1: add output device for parameters

Add the output video driver that accept parameters from userspace.
Signed-off-by: default avatarJacob Chen <jacob2.chen@rock-chips.com>
Signed-off-by: default avatarShunqian Zheng <zhengsq@rock-chips.com>
Signed-off-by: default avatarYichong Zhong <zyc@rock-chips.com>
Signed-off-by: default avatarJacob Chen <cc@rock-chips.com>
Signed-off-by: default avatarEddie Cai <eddie.cai.linux@gmail.com>
Signed-off-by: default avatarJeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: default avatarAllon Huang <allon.huang@rock-chips.com>
Signed-off-by: default avatarTomasz Figa <tfiga@chromium.org>
Signed-off-by: default avatarHelen Koike <helen.koike@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 9a28dbd6
...@@ -4,4 +4,5 @@ rockchip-isp1-objs += rkisp1-capture.o \ ...@@ -4,4 +4,5 @@ rockchip-isp1-objs += rkisp1-capture.o \
rkisp1-dev.o \ rkisp1-dev.o \
rkisp1-isp.o \ rkisp1-isp.o \
rkisp1-resizer.o \ rkisp1-resizer.o \
rkisp1-stats.o rkisp1-stats.o \
rkisp1-params.o
...@@ -195,6 +195,27 @@ struct rkisp1_stats { ...@@ -195,6 +195,27 @@ struct rkisp1_stats {
struct mutex wq_lock; 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 rkisp1_resizer {
struct v4l2_subdev sd; struct v4l2_subdev sd;
enum rkisp1_stream_id id; enum rkisp1_stream_id id;
...@@ -222,6 +243,7 @@ struct rkisp1_debug { ...@@ -222,6 +243,7 @@ struct rkisp1_debug {
* @isp: ISP sub-device * @isp: ISP sub-device
* @rkisp1_capture: capture video device * @rkisp1_capture: capture video device
* @stats: ISP statistics output device * @stats: ISP statistics output device
* @params: ISP input parameters device
*/ */
struct rkisp1_device { struct rkisp1_device {
void __iomem *base_addr; void __iomem *base_addr;
...@@ -238,6 +260,7 @@ struct rkisp1_device { ...@@ -238,6 +260,7 @@ struct rkisp1_device {
struct rkisp1_resizer resizer_devs[2]; struct rkisp1_resizer resizer_devs[2];
struct rkisp1_capture capture_devs[2]; struct rkisp1_capture capture_devs[2];
struct rkisp1_stats stats; struct rkisp1_stats stats;
struct rkisp1_params params;
struct media_pipeline pipe; struct media_pipeline pipe;
struct vb2_alloc_ctx *alloc_ctx; struct vb2_alloc_ctx *alloc_ctx;
struct rkisp1_debug debug; struct rkisp1_debug debug;
...@@ -287,6 +310,7 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1); ...@@ -287,6 +310,7 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1);
void rkisp1_mipi_isr(struct rkisp1_device *rkisp1); void rkisp1_mipi_isr(struct rkisp1_device *rkisp1);
void rkisp1_capture_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_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); int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1);
void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1); void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1);
...@@ -299,4 +323,15 @@ int rkisp1_stats_register(struct rkisp1_stats *stats, ...@@ -299,4 +323,15 @@ int rkisp1_stats_register(struct rkisp1_stats *stats,
struct rkisp1_device *rkisp1); struct rkisp1_device *rkisp1);
void rkisp1_stats_unregister(struct rkisp1_stats *stats); 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 */ #endif /* _RKISP1_COMMON_H */
...@@ -57,13 +57,13 @@ ...@@ -57,13 +57,13 @@
* | DMA |------------------------------------+ Self Picture Path * | DMA |------------------------------------+ Self Picture Path
* +--------+ * +--------+
* *
* rkisp1-stats.c * rkisp1-stats.c rkisp1-params.c
* |===============| * |===============| |===============|
* +---------------+ * +---------------+ +---------------+
* | | * | | | |
* | ISP | * | ISP | | ISP |
* | | * | | | |
* +---------------+ * +---------------+ +---------------+
* *
* *
* Media Topology * Media Topology
...@@ -72,13 +72,13 @@ ...@@ -72,13 +72,13 @@
* | Sensor 2 | | Sensor X | * | Sensor 2 | | Sensor X |
* ------------ ... ------------ * ------------ ... ------------
* | 0 | | 0 | * | 0 | | 0 |
* +----------+ +----------+ * +----------+ +----------+ +-----------+
* \ | * \ | | params |
* \ | * \ | | (output) |
* +----------+ \ | * +----------+ \ | +-----------+
* | Sensor 1 | v v * | Sensor 1 | v v |
* ------------ +------+------+ * ------------ +------+------+ |
* | 0 |----->| 0 | 1 | * | 0 |----->| 0 | 1 |<---------+
* +----------+ |------+------| * +----------+ |------+------|
* | ISP | * | ISP |
* |------+------| * |------+------|
...@@ -164,6 +164,14 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1) ...@@ -164,6 +164,14 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1)
return ret; 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 */ /* 3A stats links */
source = &rkisp1->isp.sd.entity; source = &rkisp1->isp.sd.entity;
sink = &rkisp1->stats.vnode.vdev.entity; sink = &rkisp1->stats.vnode.vdev.entity;
...@@ -352,14 +360,21 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) ...@@ -352,14 +360,21 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1)
if (ret) if (ret)
goto err_unreg_capture_devs; 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); ret = rkisp1_subdev_notifier(rkisp1);
if (ret) { if (ret) {
dev_err(rkisp1->dev, dev_err(rkisp1->dev,
"Failed to register subdev notifier(%d)\n", ret); "Failed to register subdev notifier(%d)\n", ret);
goto err_unreg_stats; goto err_unreg_params;
} }
return 0; return 0;
err_unreg_params:
rkisp1_params_unregister(&rkisp1->params);
err_unreg_stats: err_unreg_stats:
rkisp1_stats_unregister(&rkisp1->stats); rkisp1_stats_unregister(&rkisp1->stats);
err_unreg_capture_devs: err_unreg_capture_devs:
...@@ -529,6 +544,7 @@ static int rkisp1_remove(struct platform_device *pdev) ...@@ -529,6 +544,7 @@ static int rkisp1_remove(struct platform_device *pdev)
v4l2_async_notifier_unregister(&rkisp1->notifier); v4l2_async_notifier_unregister(&rkisp1->notifier);
v4l2_async_notifier_cleanup(&rkisp1->notifier); v4l2_async_notifier_cleanup(&rkisp1->notifier);
rkisp1_params_unregister(&rkisp1->params);
rkisp1_stats_unregister(&rkisp1->stats); rkisp1_stats_unregister(&rkisp1->stats);
rkisp1_capture_devs_unregister(rkisp1); rkisp1_capture_devs_unregister(rkisp1);
rkisp1_resizer_devs_unregister(rkisp1); rkisp1_resizer_devs_unregister(rkisp1);
......
...@@ -357,6 +357,18 @@ static int rkisp1_config_isp(struct rkisp1_device *rkisp1) ...@@ -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_CIF_ISP_PIC_SIZE_ERROR | RKISP1_CIF_ISP_FRAME_IN;
rkisp1_write(rkisp1, irq_mask, RKISP1_CIF_ISP_IMSC); 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; return 0;
} }
...@@ -1142,4 +1154,11 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1) ...@@ -1142,4 +1154,11 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1)
RKISP1_CIF_ISP_HIST_MEASURE_RDY)) RKISP1_CIF_ISP_HIST_MEASURE_RDY))
rkisp1_stats_isr(&rkisp1->stats, isp_ris); 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);
} }
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment