media: rockchip: rkcif: add support for rk3568 vicap mipi capture

The RK3568 Video Capture (VICAP) unit features a MIPI CSI-2 capture
interface. Add support for the MIPI capture interface in general
and for the RK3568 VICAP MIPI capture in particular.

Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Signed-off-by: Michael Riesch <michael.riesch@collabora.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
Michael Riesch
2025-11-15 12:40:33 +01:00
committed by Hans Verkuil
parent c348d67169
commit 1f2353f5a1
6 changed files with 864 additions and 0 deletions
@@ -2,6 +2,7 @@
obj-$(CONFIG_VIDEO_ROCKCHIP_CIF) += rockchip-cif.o
rockchip-cif-objs += rkcif-capture-dvp.o
rockchip-cif-objs += rkcif-capture-mipi.o
rockchip-cif-objs += rkcif-dev.o
rockchip-cif-objs += rkcif-interface.o
rockchip-cif-objs += rkcif-stream.o
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,23 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Rockchip Camera Interface (CIF) Driver
*
* Copyright (C) 2018 Rockchip Electronics Co., Ltd.
* Copyright (C) 2025 Michael Riesch <michael.riesch@wolfvision.net>
* Copyright (C) 2025 Collabora, Ltd.
*/
#ifndef _RKCIF_CAPTURE_MIPI_H
#define _RKCIF_CAPTURE_MIPI_H
#include "rkcif-common.h"
extern const struct rkcif_mipi_match_data rkcif_rk3568_vicap_mipi_match_data;
int rkcif_mipi_register(struct rkcif_device *rkcif);
void rkcif_mipi_unregister(struct rkcif_device *rkcif);
irqreturn_t rkcif_mipi_isr(int irq, void *ctx);
#endif
@@ -73,6 +73,17 @@ enum rkcif_interface_type {
RKCIF_IF_MIPI,
};
enum rkcif_mipi_format_type {
RKCIF_MIPI_TYPE_INVALID,
RKCIF_MIPI_TYPE_RAW8,
RKCIF_MIPI_TYPE_RAW10,
RKCIF_MIPI_TYPE_RAW12,
RKCIF_MIPI_TYPE_RGB888,
RKCIF_MIPI_TYPE_YUV422SP,
RKCIF_MIPI_TYPE_YUV420SP,
RKCIF_MIPI_TYPE_YUV400,
};
struct rkcif_buffer {
struct vb2_v4l2_buffer vb;
struct list_head queue;
@@ -107,9 +118,15 @@ struct rkcif_output_fmt {
u32 fourcc;
u32 mbus_code;
u8 cplanes;
u8 depth;
union {
u32 dvp_fmt_val;
struct {
u8 dt;
bool compact;
enum rkcif_mipi_format_type type;
} mipi;
};
};
@@ -184,6 +201,17 @@ struct rkcif_interface {
void (*set_crop)(struct rkcif_stream *stream, u16 left, u16 top);
};
struct rkcif_mipi_match_data {
unsigned int mipi_num;
unsigned int regs[RKCIF_MIPI_REGISTER_MAX];
unsigned int regs_id[RKCIF_ID_MAX][RKCIF_MIPI_ID_REGISTER_MAX];
u32 (*mipi_ctrl0)(struct rkcif_stream *stream,
const struct rkcif_output_fmt *active_out_fmt);
struct {
unsigned int offset;
} blocks[RKCIF_MIPI_MAX - RKCIF_MIPI_BASE];
};
struct rkcif_dvp_match_data {
const struct rkcif_input_fmt *in_fmts;
unsigned int in_fmts_num;
@@ -199,6 +227,7 @@ struct rkcif_match_data {
const char *const *clks;
unsigned int clks_num;
const struct rkcif_dvp_match_data *dvp;
const struct rkcif_mipi_match_data *mipi;
};
struct rkcif_device {
@@ -24,6 +24,7 @@
#include <media/v4l2-mc.h>
#include "rkcif-capture-dvp.h"
#include "rkcif-capture-mipi.h"
#include "rkcif-common.h"
static const char *const px30_vip_clks[] = {
@@ -49,6 +50,7 @@ static const struct rkcif_match_data rk3568_vicap_match_data = {
.clks = rk3568_vicap_clks,
.clks_num = ARRAY_SIZE(rk3568_vicap_clks),
.dvp = &rkcif_rk3568_vicap_dvp_match_data,
.mipi = &rkcif_rk3568_vicap_mipi_match_data,
};
static const struct of_device_id rkcif_plat_of_match[] = {
@@ -72,14 +74,21 @@ static int rkcif_register(struct rkcif_device *rkcif)
if (ret && ret != -ENODEV)
goto err;
ret = rkcif_mipi_register(rkcif);
if (ret && ret != -ENODEV)
goto err_dvp_unregister;
return 0;
err_dvp_unregister:
rkcif_dvp_unregister(rkcif);
err:
return ret;
}
static void rkcif_unregister(struct rkcif_device *rkcif)
{
rkcif_mipi_unregister(rkcif);
rkcif_dvp_unregister(rkcif);
}
@@ -128,6 +137,9 @@ static irqreturn_t rkcif_isr(int irq, void *ctx)
if (rkcif_dvp_isr(irq, ctx) == IRQ_HANDLED)
ret = IRQ_HANDLED;
if (rkcif_mipi_isr(irq, ctx) == IRQ_HANDLED)
ret = IRQ_HANDLED;
return ret;
}
@@ -128,4 +128,26 @@ enum rkcif_dvp_register_index {
RKCIF_DVP_REGISTER_MAX
};
enum rkcif_mipi_register_index {
RKCIF_MIPI_CTRL,
RKCIF_MIPI_INTEN,
RKCIF_MIPI_INTSTAT,
RKCIF_MIPI_REGISTER_MAX
};
enum rkcif_mipi_id_register_index {
RKCIF_MIPI_CTRL0,
RKCIF_MIPI_CTRL1,
RKCIF_MIPI_FRAME0_ADDR_Y,
RKCIF_MIPI_FRAME0_ADDR_UV,
RKCIF_MIPI_FRAME0_VLW_Y,
RKCIF_MIPI_FRAME0_VLW_UV,
RKCIF_MIPI_FRAME1_ADDR_Y,
RKCIF_MIPI_FRAME1_ADDR_UV,
RKCIF_MIPI_FRAME1_VLW_Y,
RKCIF_MIPI_FRAME1_VLW_UV,
RKCIF_MIPI_CROP_START,
RKCIF_MIPI_ID_REGISTER_MAX
};
#endif